diff options
| author | Daniel Jasper <djasper@google.com> | 2013-05-13 07:14:40 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-05-13 07:14:40 +0000 |
| commit | b910bbb87ae16180b8110e46b648288484b4ad2e (patch) | |
| tree | 530a3ce57f63a0de381c2148be6b7aec5eb998d4 | |
| parent | d900f98bdf497fda3acff461cb9291a596d2787a (diff) | |
| download | bcm5719-llvm-b910bbb87ae16180b8110e46b648288484b4ad2e.tar.gz bcm5719-llvm-b910bbb87ae16180b8110e46b648288484b4ad2e.zip | |
Assume macros to contain declarations.
This seems to be the vastly more common case. If we find enough
examples to the contrary, we can make it smarter.
Before: #define MACRO void f(int * a)
After: #define MACRO void f(int *a)
llvm-svn: 181687
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 1 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 12031166e23..29eaaa8b581 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -591,6 +591,7 @@ private: } } else if (Current.isOneOf(tok::kw_return, tok::kw_throw) || (Current.is(tok::l_paren) && !Line.MustBeDeclaration && + !Line.InPPDirective && (!Current.Parent || Current.Parent->isNot(tok::kw_for)))) { Contexts.back().IsExpression = true; } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index f694c5b2141..9b3fb9cc06d 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2638,10 +2638,16 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyFormat("for (int i = a * a; i < 10; ++i) {\n}"); verifyFormat("for (int i = 0; i < a * a; ++i) {\n}"); + verifyFormat("#define MACRO \\\n" + " int *i = a * b; \\\n" + " void f(a *b);", + getLLVMStyleWithColumns(19)); + verifyIndependentOfContext("A = new SomeType *[Length];"); verifyIndependentOfContext("A = new SomeType *[Length]();"); verifyGoogleFormat("A = new SomeType* [Length]();"); verifyGoogleFormat("A = new SomeType* [Length];"); + FormatStyle PointerLeft = getLLVMStyle(); PointerLeft.PointerBindsToType = true; verifyFormat("delete *x;", PointerLeft); |

