[cfe-commits] r172050 - /cfe/trunk/lib/Format/UnwrappedLineParser.cpp
Chandler Carruth
chandlerc at google.com
Thu Jan 10 02:51:07 PST 2013
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?
On Thu, Jan 10, 2013 at 2:05 AM, Manuel Klimek <klimek at google.com> wrote:
> 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;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130110/9d2d1294/attachment.html>
More information about the cfe-commits
mailing list