]> granicus.if.org Git - clang/commitdiff
Fixed preprocessed output of the first token for pragmas.
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 9 Feb 2016 08:51:26 +0000 (08:51 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 9 Feb 2016 08:51:26 +0000 (08:51 +0000)
Clang did not expanded macros in the very first token of the pragmas
during preprocessed output

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260211 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PrintPreprocessedOutput.cpp
test/Preprocessor/macro_expand.c

index a58c935620a2f42e62726a6613621abfd6247f00..c57a736d1b0449aa374c5f4b3d84669bd63298cd 100644 (file)
@@ -573,6 +573,15 @@ struct UnknownPragmaHandler : public PragmaHandler {
                     Token &PragmaTok) override {
     // Figure out what line we went to and insert the appropriate number of
     // newline characters.
+    if (ShouldExpandTokens) {
+      // The first token does not have expanded macros. Expand them, if
+      // required.
+      Token Toks[] = {PragmaTok};
+      PP.EnterTokenStream(Toks, llvm::array_lengthof(Toks),
+                          /*DisableMacroExpansion=*/false,
+                          /*OwnsTokens=*/false);
+      PP.Lex(PragmaTok);
+    }
     Callbacks->startNewLineIfNeeded();
     Callbacks->MoveToLine(PragmaTok.getLocation());
     Callbacks->OS.write(Prefix, strlen(Prefix));
index cf98a2cbfb8fccabf7675ca6a44472d55852c943..430068ba7295d2debf0154cae68d80c8221fe885 100644 (file)
@@ -19,3 +19,9 @@ C: for(for))
 // rdar://6880648
 #define f(x,y...) y
 f()
+
+// CHECK: #pragma omp parallel for
+#define FOO parallel
+#define Streaming _Pragma("omp FOO for")
+Streaming
+