[cfe-commits] r172050 - /cfe/trunk/lib/Format/UnwrappedLineParser.cpp

Manuel Klimek klimek at google.com
Thu Jan 10 02:05:08 PST 2013


Author: klimek
Date: Thu Jan 10 04:05:08 2013
New Revision: 172050

URL: http://llvm.org/viewvc/llvm-project?rev=172050&view=rev
Log:
Introduce a define to switch on debug output.

After re-writing the same loop multiple times, we deicided it's time to
add this as an optional debugging help.

Modified:
    cfe/trunk/lib/Format/UnwrappedLineParser.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=172050&r1=172049&r2=172050&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Jan 10 04:05:08 2013
@@ -19,6 +19,11 @@
 #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 @@
 }
 
 bool UnwrappedLineParser::parse() {
+#ifdef UNWRAPPED_LINE_PARSER_DEBUG_OUTPUT
+  llvm::errs() << "----\n";
+#endif
   readToken();
   return parseFile();
 }
@@ -576,6 +584,15 @@
          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;





More information about the cfe-commits mailing list