<div dir="ltr"><div class="gmail_default" style>LLVM has a DEBUG() and llvm::dbgs() system for optionally enabled debug output... Maybe there is a way to wire it up in the clang tools?</div></div><div class="gmail_extra"><br>
<br><div class="gmail_quote">On Thu, Jan 10, 2013 at 2:05 AM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: klimek<br>
Date: Thu Jan 10 04:05:08 2013<br>
New Revision: 172050<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=172050&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=172050&view=rev</a><br>
Log:<br>
Introduce a define to switch on debug output.<br>
<br>
After re-writing the same loop multiple times, we deicided it's time to<br>
add this as an optional debugging help.<br>
<br>
Modified:<br>
    cfe/trunk/lib/Format/UnwrappedLineParser.cpp<br>
<br>
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=172050&r1=172049&r2=172050&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=172050&r1=172049&r2=172050&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)<br>
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Jan 10 04:05:08 2013<br>
@@ -19,6 +19,11 @@<br>
 #include "UnwrappedLineParser.h"<br>
 #include "llvm/Support/raw_ostream.h"<br>
<br>
+// Uncomment to get debug output from the UnwrappedLineParser.<br>
+// Use in combination with --gtest_filter=*TestName* to limit the output to a<br>
+// single test.<br>
+// #define UNWRAPPED_LINE_PARSER_DEBUG_OUTPUT<br>
+<br>
 namespace clang {<br>
 namespace format {<br>
<br>
@@ -80,6 +85,9 @@<br>
 }<br>
<br>
 bool UnwrappedLineParser::parse() {<br>
+#ifdef UNWRAPPED_LINE_PARSER_DEBUG_OUTPUT<br>
+  llvm::errs() << "----\n";<br>
+#endif<br>
   readToken();<br>
   return parseFile();<br>
 }<br>
@@ -576,6 +584,15 @@<br>
          <a href="http://FormatTok.Tok.is" target="_blank">FormatTok.Tok.is</a>(tok::comment)) {<br>
     nextToken();<br>
   }<br>
+#ifdef UNWRAPPED_LINE_PARSER_DEBUG_OUTPUT<br>
+  FormatToken* NextToken = &Line->RootToken;<br>
+  llvm::errs() << "Line: ";<br>
+  while (NextToken) {<br>
+    llvm::errs() << NextToken->Tok.getName() << " ";<br>
+    NextToken = NextToken->Children.empty() ? NULL : &NextToken->Children[0];<br>
+  }<br>
+  llvm::errs() << "\n";<br>
+#endif<br>
   Callback.consumeUnwrappedLine(*Line);<br>
   RootTokenInitialized = false;<br>
   LastInCurrentLine = NULL;<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>