llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Jonas Hahnfeld (hahnjo) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/104964.diff 2 Files Affected: - (modified) clang/lib/Frontend/PrintPreprocessedOutput.cpp (+4-6) - (added) clang/test/Interpreter/preprocessor.cpp (+4) ``````````diff diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 135dca0e6a1775..383d4356084916 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -916,8 +916,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok, PP.Lex(Tok); continue; } else if (Tok.is(tok::annot_repl_input_end)) { - PP.Lex(Tok); - continue; + // Fall through to exit the loop. } 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 @@ -1025,7 +1024,8 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok, Callbacks->setEmittedTokensOnThisLine(); IsStartOfLine = false; - if (Tok.is(tok::eof)) break; + if (Tok.is(tok::eof) || Tok.is(tok::annot_repl_input_end)) + break; PP.Lex(Tok); // If lexing that token causes us to need to skip future tokens, do so now. @@ -1048,9 +1048,7 @@ static void DoPrintMacros(Preprocessor &PP, raw_ostream *OS) { // the macro table at the end. PP.EnterMainSourceFile(); - Token Tok; - do PP.Lex(Tok); - while (Tok.isNot(tok::eof)); + PP.LexTokensUntilEOF(); SmallVector<id_macro_pair, 128> MacrosByID; for (Preprocessor::macro_iterator I = PP.macro_begin(), E = PP.macro_end(); diff --git a/clang/test/Interpreter/preprocessor.cpp b/clang/test/Interpreter/preprocessor.cpp new file mode 100644 index 00000000000000..8239fd45e661b0 --- /dev/null +++ b/clang/test/Interpreter/preprocessor.cpp @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -fincremental-extensions -E %s +// RUN: %clang_cc1 -fincremental-extensions -E -dD %s +// RUN: %clang_cc1 -fincremental-extensions -E -dI %s +// RUN: %clang_cc1 -fincremental-extensions -E -dM %s `````````` </details> https://github.com/llvm/llvm-project/pull/104964 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits