]> granicus.if.org Git - clang/commitdiff
Introduce a define to switch on debug output.
authorManuel Klimek <klimek@google.com>
Thu, 10 Jan 2013 10:05:08 +0000 (10:05 +0000)
committerManuel Klimek <klimek@google.com>
Thu, 10 Jan 2013 10:05:08 +0000 (10:05 +0000)
After re-writing the same loop multiple times, we deicided it's time to
add this as an optional debugging help.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172050 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp

index 9b2a1e90e1f70b2b89b96d4ce2db9783bdbe5ce0..c09ee311d3b9b5066698334c0369bdc6c9e8af7e 100644 (file)
 #include "UnwrappedLineParser.h"
 #include "llvm/Support/raw_ostream.h"
 
+// Uncomment to get debug output from the UnwrappedLineParser.
+// Use in combination with --gtest_filter=*TestName* to limit the output to a
+// single test.
+// #define UNWRAPPED_LINE_PARSER_DEBUG_OUTPUT
+
 namespace clang {
 namespace format {
 
@@ -80,6 +85,9 @@ UnwrappedLineParser::UnwrappedLineParser(const FormatStyle &Style,
 }
 
 bool UnwrappedLineParser::parse() {
+#ifdef UNWRAPPED_LINE_PARSER_DEBUG_OUTPUT
+  llvm::errs() << "----\n";
+#endif
   readToken();
   return parseFile();
 }
@@ -576,6 +584,15 @@ void UnwrappedLineParser::addUnwrappedLine() {
          FormatTok.Tok.is(tok::comment)) {
     nextToken();
   }
+#ifdef UNWRAPPED_LINE_PARSER_DEBUG_OUTPUT
+  FormatToken* NextToken = &Line->RootToken;
+  llvm::errs() << "Line: ";
+  while (NextToken) {
+    llvm::errs() << NextToken->Tok.getName() << " ";
+    NextToken = NextToken->Children.empty() ? NULL : &NextToken->Children[0];
+  }
+  llvm::errs() << "\n";
+#endif
   Callback.consumeUnwrappedLine(*Line);
   RootTokenInitialized = false;
   LastInCurrentLine = NULL;