summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 0d3f2807a94..eacd189840f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1690,6 +1690,34 @@ TEST_F(FormatTest, MacroDefinitionsWithIncompleteCode) {
"f(STR(this_is_a_string_literal{));");
}
+TEST_F(FormatTest, MacrosWithoutTrailingSemicolon) {
+ verifyFormat("SOME_TYPE_NAME abc;"); // Gated on the newline.
+ EXPECT_EQ("class A : public QObject {\n"
+ " Q_OBJECT\n"
+ "\n"
+ " A() {}\n"
+ "};",
+ format("class A : public QObject {\n"
+ " Q_OBJECT\n"
+ "\n"
+ " A() {\n}\n"
+ "} ;"));
+ // Only if the identifier contains at least 5 characters.
+ EXPECT_EQ("HTTP f();",
+ format("HTTP\nf();"));
+ EXPECT_EQ("MACRO\nf();",
+ format("MACRO\nf();"));
+ // Only if everything is upper case.
+ EXPECT_EQ("class A : public QObject {\n"
+ " Q_Object A() {}\n"
+ "};",
+ format("class A : public QObject {\n"
+ " Q_Object\n"
+ "\n"
+ " A() {\n}\n"
+ "} ;"));
+}
+
TEST_F(FormatTest, MacroCallsWithoutTrailingSemicolon) {
EXPECT_EQ("INITIALIZE_PASS_BEGIN(ScopDetection, \"polly-detect\")\n"
"INITIALIZE_AG_DEPENDENCY(AliasAnalysis)\n"
OpenPOWER on IntegriCloud