aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2025-07-13 14:29:51 -0700
committerGitHub <noreply@github.com>2025-07-13 14:29:51 -0700
commitc384ec431dd7f771c9dd7c462cec5301ac0f32bb (patch)
treea2a0cbab11398735e199b7aaa482e7c52ee29bd9 /clang/unittests
parent1fbfa333f64bf714efa84db6b1075fc864d53bf8 (diff)
downloadllvm-c384ec431dd7f771c9dd7c462cec5301ac0f32bb.zip
llvm-c384ec431dd7f771c9dd7c462cec5301ac0f32bb.tar.gz
llvm-c384ec431dd7f771c9dd7c462cec5301ac0f32bb.tar.bz2
[clang-format] Add MacrosSkippedByRemoveParentheses option (#148345)
This allows RemoveParentheses to skip the invocations of function-like macros. Fixes #68354. Fixes #147780.
Diffstat (limited to 'clang/unittests')
-rw-r--r--clang/unittests/Format/ConfigParseTest.cpp1
-rw-r--r--clang/unittests/Format/FormatTest.cpp4
2 files changed, 5 insertions, 0 deletions
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index aedfdd1..d17109a 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -942,6 +942,7 @@ TEST(ConfigParseTest, ParsesConfiguration) {
CHECK_PARSE_LIST(JavaImportGroups);
CHECK_PARSE_LIST(Macros);
+ CHECK_PARSE_LIST(MacrosSkippedByRemoveParentheses);
CHECK_PARSE_LIST(NamespaceMacros);
CHECK_PARSE_LIST(ObjCPropertyAttributeOrder);
CHECK_PARSE_LIST(TableGenBreakingDAGArgOperators);
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 944e7c3..0bc1c6d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -28479,6 +28479,10 @@ TEST_F(FormatTest, RemoveParentheses) {
verifyFormat("MOCK_METHOD(void, Function, (), override);",
"MOCK_METHOD(void, Function, (), (override));", Style);
+ Style.MacrosSkippedByRemoveParentheses.push_back("FOO");
+ verifyFormat("FOO((a && b));", Style);
+ verifyFormat("FOO((int), func, ((std::map<int, int>)), (override));", Style);
+
Style.RemoveParentheses = FormatStyle::RPS_ReturnStatement;
verifyFormat("#define Return0 return (0);", Style);
verifyFormat("return 0;", "return (0);", Style);