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

Manuel Klimek klimek at google.com
Wed Jan 16 04:31:12 PST 2013


Author: klimek
Date: Wed Jan 16 06:31:12 2013
New Revision: 172608

URL: http://llvm.org/viewvc/llvm-project?rev=172608&view=rev
Log:
Use standard llvm Debug.h support for debugging output.

Leave a quick "// Uncomment this." hint to enable the debug output in
tests. FIXME: figure out whether we want to enable debug command line
handling for all tests.

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=172608&r1=172607&r2=172608&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Jan 16 06:31:12 2013
@@ -16,14 +16,15 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "UnwrappedLineParser.h"
+#define DEBUG_TYPE "format-parser"
+
 #include "clang/Basic/Diagnostic.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
+#include "UnwrappedLineParser.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
+// Uncomment to get debug output from tests:
+// #define DEBUG_WITH_TYPE(T, X) do { X; } while(0)
 
 namespace clang {
 namespace format {
@@ -109,9 +110,7 @@
 }
 
 bool UnwrappedLineParser::parse() {
-#ifdef UNWRAPPED_LINE_PARSER_DEBUG_OUTPUT
-  llvm::errs() << "----\n";
-#endif
+  DEBUG(llvm::dbgs() << "----\n");
   readToken();
   return parseFile();
 }
@@ -658,16 +657,16 @@
          FormatTok.Tok.is(tok::comment)) {
     nextToken();
   }
-#ifdef UNWRAPPED_LINE_PARSER_DEBUG_OUTPUT
-  llvm::errs() << "Line: ";
-  for (std::list<FormatToken>::iterator I = Line->Tokens.begin(),
-                                        E = Line->Tokens.end();
-       I != E; ++I) {
-    llvm::errs() << I->Tok.getName() << " ";
+  DEBUG({
+    llvm::dbgs() << "Line: ";
+    for (std::list<FormatToken>::iterator I = Line->Tokens.begin(),
+                                          E = Line->Tokens.end();
+         I != E; ++I) {
+      llvm::dbgs() << I->Tok.getName() << " ";
 
-  }
-  llvm::errs() << "\n";
-#endif
+    }
+    llvm::dbgs() << "\n";
+  });
   Callback.consumeUnwrappedLine(*Line);
   Line->Tokens.clear();
 }





More information about the cfe-commits mailing list