diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-04-09 16:15:19 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-04-09 16:15:19 +0000 |
commit | 99b0e14691b61d8db4f1d239a11615957071fb45 (patch) | |
tree | 0d2b666e81c5bba127bd20e6fcdfe0035612a3df /unittests | |
parent | 63911838bf7891445ff39fdc7f81d1469d54f5c1 (diff) |
Again macros without trailing semicolons: don't care about declaration context.
Summary:
Some codebases use these kinds of macros in functions, e.g. Chromium's
IPC_BEGIN_MESSAGE_MAP, IPC_BEGIN_MESSAGE_HANDLER, etc.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D645
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179099 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 3d350208f2..cb28a4ff78 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1353,6 +1353,99 @@ TEST_F(FormatTest, MacroCallsWithoutTrailingSemicolon) { " class X {};\n" " INITIALIZE_PASS_END(ScopDetection, \"polly-detect\")\n" " int *createScopDetectionPass() { return 0; }")); + // FIXME: We could probably treat IPC_BEGIN_MESSAGE_MAP/IPC_END_MESSAGE_MAP as + // braces, so that inner block is indented one level more. + EXPECT_EQ("int q() {\n" + " IPC_BEGIN_MESSAGE_MAP(WebKitTestController, message)\n" + " IPC_MESSAGE_HANDLER(xxx, qqq)\n" + " IPC_END_MESSAGE_MAP()\n" + "}", + format("int q() {\n" + " IPC_BEGIN_MESSAGE_MAP(WebKitTestController, message)\n" + " IPC_MESSAGE_HANDLER(xxx, qqq)\n" + " IPC_END_MESSAGE_MAP()\n" + "}")); + EXPECT_EQ("int q() {\n" + " f(x);\n" + " f(x) {}\n" + " f(x)->g();\n" + " f(x)->*g();\n" + " f(x).g();\n" + " f(x) = x;\n" + " f(x) += x;\n" + " f(x) -= x;\n" + " f(x) *= x;\n" + " f(x) /= x;\n" + " f(x) %= x;\n" + " f(x) &= x;\n" + " f(x) |= x;\n" + " f(x) ^= x;\n" + " f(x) >>= x;\n" + " f(x) <<= x;\n" + " f(x)[y].z();\n" + " LOG(INFO) << x;\n" + " ifstream(x) >> x;\n" + "}\n", + format("int q() {\n" + " f(x)\n;\n" + " f(x)\n {}\n" + " f(x)\n->g();\n" + " f(x)\n->*g();\n" + " f(x)\n.g();\n" + " f(x)\n = x;\n" + " f(x)\n += x;\n" + " f(x)\n -= x;\n" + " f(x)\n *= x;\n" + " f(x)\n /= x;\n" + " f(x)\n %= x;\n" + " f(x)\n &= x;\n" + " f(x)\n |= x;\n" + " f(x)\n ^= x;\n" + " f(x)\n >>= x;\n" + " f(x)\n <<= x;\n" + " f(x)\n[y].z();\n" + " LOG(INFO)\n << x;\n" + " ifstream(x)\n >> x;\n" + "}\n")); + EXPECT_EQ("int q() {\n" + " f(x)\n" + " if (1) {\n" + " }\n" + " f(x)\n" + " while (1) {\n" + " }\n" + " f(x)\n" + " g(x);\n" + " f(x)\n" + " try {\n" + " q();\n" + " }\n" + " catch (...) {\n" + " }\n" + "}\n", + format("int q() {\n" + "f(x)\n" + "if (1) {}\n" + "f(x)\n" + "while (1) {}\n" + "f(x)\n" + "g(x);\n" + "f(x)\n" + "try { q(); } catch (...) {}\n" + "}\n")); + EXPECT_EQ("class A {\n" + " A() : t(0) {}\n" + " A(X x)\n" // FIXME: function-level try blocks are broken. + " try : t(0) {\n" + " }\n" + " catch (...) {\n" + " }\n" + "};", + format("class A {\n" + " A()\n : t(0) {}\n" + " A(X x)\n" + " try : t(0) {} catch (...) {}\n" + "};")); } TEST_F(FormatTest, IndentPreprocessorDirectivesAtZero) { |