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 | 6f688e131e125ffce23a63a9d286578a454cc4e0 (patch) | |
tree | a6d66b75a917b16f23e499357edaa40dbf1933d3 /Driver/PrintPreprocessedOutput.cpp | |
parent | ba0f43571a5d15b3001420d6f166ea9824b7b441 (diff) |
clang -E should not print tokens from the predefines buffer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/PrintPreprocessedOutput.cpp')
-rw-r--r-- | Driver/PrintPreprocessedOutput.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp index aed26cfd58..a3db2b0997 100644 --- a/Driver/PrintPreprocessedOutput.cpp +++ b/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(); |