This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0e2586779ca6: [Preprocessor] Ensure newline after #pragma 
introduced by -fms-extensions. (authored by Meinersbur).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107183/new/

https://reviews.llvm.org/D107183

Files:
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/test/Preprocessor/whitespace-ms-extensions.c


Index: clang/test/Preprocessor/whitespace-ms-extensions.c
===================================================================
--- /dev/null
+++ clang/test/Preprocessor/whitespace-ms-extensions.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -E -P %s -o - | FileCheck %s
+// RUN: %clang_cc1 -E -P -fms-extensions %s -o - | FileCheck %s 
--check-prefix=MSEXT
+
+// -fms-extensions changes __pragma into #pragma
+// Ensure that there is a newline after the #pragma line.
+
+#define MACRO        \
+    text             \
+    __pragma(PRAGMA) \
+    after
+
+before MACRO text
+
+
+// CHECK:      before text __pragma(PRAGMA) after text
+
+// MSEXT:      before text
+// MSEXT-NEXT: #pragma PRAGMA
+// MSEXT-NEXT: after text
Index: clang/lib/Frontend/PrintPreprocessedOutput.cpp
===================================================================
--- clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -646,7 +646,9 @@
        !Tok.is(tok::annot_module_begin) && !Tok.is(tok::annot_module_end)))
     return;
 
-  if (!RequireSameLine && MoveToLine(Tok, /*RequireStartOfLine=*/false)) {
+  // EmittedDirectiveOnThisLine takes priority over RequireSameLine.
+  if ((!RequireSameLine || EmittedDirectiveOnThisLine) &&
+      MoveToLine(Tok, /*RequireStartOfLine=*/EmittedDirectiveOnThisLine)) {
     if (MinimizeWhitespace) {
       // Avoid interpreting hash as a directive under -fpreprocessed.
       if (Tok.is(tok::hash))


Index: clang/test/Preprocessor/whitespace-ms-extensions.c
===================================================================
--- /dev/null
+++ clang/test/Preprocessor/whitespace-ms-extensions.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -E -P %s -o - | FileCheck %s
+// RUN: %clang_cc1 -E -P -fms-extensions %s -o - | FileCheck %s --check-prefix=MSEXT
+
+// -fms-extensions changes __pragma into #pragma
+// Ensure that there is a newline after the #pragma line.
+
+#define MACRO        \
+    text             \
+    __pragma(PRAGMA) \
+    after
+
+before MACRO text
+
+
+// CHECK:      before text __pragma(PRAGMA) after text
+
+// MSEXT:      before text
+// MSEXT-NEXT: #pragma PRAGMA
+// MSEXT-NEXT: after text
Index: clang/lib/Frontend/PrintPreprocessedOutput.cpp
===================================================================
--- clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -646,7 +646,9 @@
        !Tok.is(tok::annot_module_begin) && !Tok.is(tok::annot_module_end)))
     return;
 
-  if (!RequireSameLine && MoveToLine(Tok, /*RequireStartOfLine=*/false)) {
+  // EmittedDirectiveOnThisLine takes priority over RequireSameLine.
+  if ((!RequireSameLine || EmittedDirectiveOnThisLine) &&
+      MoveToLine(Tok, /*RequireStartOfLine=*/EmittedDirectiveOnThisLine)) {
     if (MinimizeWhitespace) {
       // Avoid interpreting hash as a directive under -fpreprocessed.
       if (Tok.is(tok::hash))
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to