diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-10-10 20:45:16 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-10-10 20:45:16 +0000 |
| commit | 3ff2e69713b37f90e0193995cce534a906bccb21 (patch) | |
| tree | ffbdadcb8845383aa539f5f6b52e402ac8688013 | |
| parent | 45f3bb8239c173990b677bfbdc0bb3c5020a2ef8 (diff) | |
| download | bcm5719-llvm-3ff2e69713b37f90e0193995cce534a906bccb21.tar.gz bcm5719-llvm-3ff2e69713b37f90e0193995cce534a906bccb21.zip | |
clang -E should not print tokens from the predefines buffer.
llvm-svn: 42838
| -rw-r--r-- | clang/Driver/PrintPreprocessedOutput.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/clang/Driver/PrintPreprocessedOutput.cpp b/clang/Driver/PrintPreprocessedOutput.cpp index aed26cfd588..a3db2b09977 100644 --- a/clang/Driver/PrintPreprocessedOutput.cpp +++ b/clang/Driver/PrintPreprocessedOutput.cpp @@ -535,10 +535,16 @@ void clang::DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP, // Start parsing the specified input file. PP.EnterMainSourceFile(MainFileID); - - do { - PrevTok = Tok; - PP.Lex(Tok); + + // Consume all of the tokens that come from the predefines buffer. Those + // should not be emitted into the output and are guaranteed to be at the + // start. + const SourceManager &SourceMgr = PP.getSourceManager(); + do PP.Lex(Tok); + while (Tok.isNot(tok::eof) && + !strcmp(SourceMgr.getSourceName(Tok.getLocation()), "<predefines>")); + + while (1) { // If this token is at the start of a line, emit newlines if needed. if (Tok.isAtStartOfLine()) { @@ -565,7 +571,12 @@ void clang::DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP, OutputString(&S[0], S.size()); } Callbacks->SetEmittedTokensOnThisLine(); - } while (Tok.isNot(tok::eof)); + + if (Tok.is(tok::eof)) break; + + PrevTok = Tok; + PP.Lex(Tok); + } OutputChar('\n'); CleanupOutputBuffer(); |

