diff options
author | Reid Kleckner <rnk@google.com> | 2017-10-16 23:07:15 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-10-16 23:07:15 +0000 |
commit | 400a64e81b5a297f88a789573c89fe08c60bf914 (patch) | |
tree | f07f40d074efcf6a8ae4ce46be534978fae15694 /clang/lib/Frontend/PrintPreprocessedOutput.cpp | |
parent | cf3ab11caa9bf21fbe9ea7e1c300d8f60c320f4d (diff) | |
download | llvm-400a64e81b5a297f88a789573c89fe08c60bf914.zip llvm-400a64e81b5a297f88a789573c89fe08c60bf914.tar.gz llvm-400a64e81b5a297f88a789573c89fe08c60bf914.tar.bz2 |
Don't print end-of-directive tokens in -E output
This comes up when pre-processing standalone .s files containing
hash-prefixed comments. The pre-processor should skip the unknown
directive and not emit an extra newline as we were doing.
Fixes PR34950
llvm-svn: 315953
Diffstat (limited to 'clang/lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 8ae9038..2e02329 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -720,6 +720,12 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok, // -traditional-cpp the lexer keeps /all/ whitespace, including comments. SourceLocation StartLoc = Tok.getLocation(); Callbacks->MoveToLine(StartLoc.getLocWithOffset(Tok.getLength())); + } else if (Tok.is(tok::eod)) { + // Don't print end of directive tokens, since they are typically newlines + // that mess up our line tracking. These come from unknown pre-processor + // directives or hash-prefixed comments in standalone assembly files. + PP.Lex(Tok); + continue; } else if (Tok.is(tok::annot_module_include)) { // PrintPPOutputPPCallbacks::InclusionDirective handles producing // appropriate output here. Ignore this token entirely. |