thieta updated this revision to Diff 430954. thieta added a comment. Removed comment
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/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -18825,6 +18825,13 @@ EXPECT_EQ("#pragma option -C -A", format("#pragma option -C -A")); } +TEST_F(FormatTest, UnderstandPragmaRegion) { + auto Style = getLLVMStyleWithColumns(0); + verifyFormat("#pragma region TEST(FOO : BAR)", Style); + + EXPECT_EQ("#pragma region TEST(FOO : BAR)", format("#pragma region TEST(FOO : BAR)", Style)); +} + TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) { FormatStyle Style = getLLVMStyleWithColumns(20); Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1223,9 +1223,9 @@ 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(); next(); // Consume first token (so we fix leading whitespace). while (CurrentToken) { if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator)) 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/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -18825,6 +18825,13 @@ EXPECT_EQ("#pragma option -C -A", format("#pragma option -C -A")); } +TEST_F(FormatTest, UnderstandPragmaRegion) { + auto Style = getLLVMStyleWithColumns(0); + verifyFormat("#pragma region TEST(FOO : BAR)", Style); + + EXPECT_EQ("#pragma region TEST(FOO : BAR)", format("#pragma region TEST(FOO : BAR)", Style)); +} + TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) { FormatStyle Style = getLLVMStyleWithColumns(20); Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1223,9 +1223,9 @@ 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(); next(); // Consume first token (so we fix leading whitespace). while (CurrentToken) { if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator)) 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