thieta updated this revision to Diff 430882.
thieta added a comment.

Added additional tests to check other pragma statements


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125961

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/test/Format/pragma.cpp


Index: clang/test/Format/pragma.cpp
===================================================================
--- /dev/null
+++ clang/test/Format/pragma.cpp
@@ -0,0 +1,8 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style="{ColumnLimit: 0}" \
+// RUN:   | FileCheck -strict-whitespace %s
+
+// CHECK: {{^\#pragma\ warning\(disable\ \:\ 342;\ once\ \: 1232\)$}}
+#pragma warning (disable : 342; once : 1232)
+
+// CHECK: {{^\#pragma\ region\ TEST\(FOO\ \:\ BAR\)$}}
+#pragma region TEST(FOO : BAR)
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1223,7 +1223,7 @@
   void parsePragma() {
     next(); // Consume "pragma".
     if (CurrentToken &&
-        CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option)) {
+        CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option, 
Keywords.kw_region)) {
       bool IsMark = CurrentToken->is(Keywords.kw_mark);
       next(); // Consume "mark".
       next(); // Consume first token (so we fix leading whitespace).
Index: clang/lib/Format/FormatToken.h
===================================================================
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -928,6 +928,7 @@
     kw___has_include_next = &IdentTable.get("__has_include_next");
 
     kw_mark = &IdentTable.get("mark");
+    kw_region = &IdentTable.get("region");
 
     kw_extend = &IdentTable.get("extend");
     kw_option = &IdentTable.get("option");
@@ -1046,6 +1047,7 @@
 
   // Pragma keywords.
   IdentifierInfo *kw_mark;
+  IdentifierInfo *kw_region;
 
   // Proto keywords.
   IdentifierInfo *kw_extend;


Index: clang/test/Format/pragma.cpp
===================================================================
--- /dev/null
+++ clang/test/Format/pragma.cpp
@@ -0,0 +1,8 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style="{ColumnLimit: 0}" \
+// RUN:   | FileCheck -strict-whitespace %s
+
+// CHECK: {{^\#pragma\ warning\(disable\ \:\ 342;\ once\ \: 1232\)$}}
+#pragma warning (disable : 342; once : 1232)
+
+// CHECK: {{^\#pragma\ region\ TEST\(FOO\ \:\ BAR\)$}}
+#pragma region TEST(FOO : BAR)
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1223,7 +1223,7 @@
   void parsePragma() {
     next(); // Consume "pragma".
     if (CurrentToken &&
-        CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option)) {
+        CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option, Keywords.kw_region)) {
       bool IsMark = CurrentToken->is(Keywords.kw_mark);
       next(); // Consume "mark".
       next(); // Consume first token (so we fix leading whitespace).
Index: clang/lib/Format/FormatToken.h
===================================================================
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -928,6 +928,7 @@
     kw___has_include_next = &IdentTable.get("__has_include_next");
 
     kw_mark = &IdentTable.get("mark");
+    kw_region = &IdentTable.get("region");
 
     kw_extend = &IdentTable.get("extend");
     kw_option = &IdentTable.get("option");
@@ -1046,6 +1047,7 @@
 
   // Pragma keywords.
   IdentifierInfo *kw_mark;
+  IdentifierInfo *kw_region;
 
   // Proto keywords.
   IdentifierInfo *kw_extend;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to