diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-28 14:44:25 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-28 14:44:25 +0000 |
commit | 9a23be7451ea04fcbcb81ff9df79688bf280addd (patch) | |
tree | 78532551a22a31e884cf88c633c3fdcee00025bf /clang | |
parent | c3c5c0971dfeb85fc4b3862b264062230071dbcb (diff) | |
download | bcm5719-llvm-9a23be7451ea04fcbcb81ff9df79688bf280addd.tar.gz bcm5719-llvm-9a23be7451ea04fcbcb81ff9df79688bf280addd.zip |
Dont break between (( in __attribute__((.
Before:
void aaaaaaaaaaaaaaaaaa() __attribute__(
(aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaa));
After:
void aaaaaaaaaaaaaaaaaa()
__attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaa));
llvm-svn: 176260
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 5 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 5c172232198..e127f4af8e5 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1092,6 +1092,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, return false; if (Left.is(tok::equal) && Line.Type == LT_VirtualFunctionDecl) return false; + if (Left.is(tok::l_paren) && Right.is(tok::l_paren) && Left.Parent && + Left.Parent->is(tok::kw___attribute)) + return false; if (Right.Type == TT_LineComment) // We rely on MustBreakBefore being set correctly here as we should not @@ -1120,7 +1123,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, Right.is(tok::colon) || Left.is(tok::coloncolon) || Left.is(tok::semi) || Left.is(tok::l_brace) || (Left.is(tok::r_paren) && Left.Type != TT_CastRParen && - Right.is(tok::identifier)) || + (Right.is(tok::identifier) || Right.is(tok::kw___attribute))) || (Left.is(tok::l_paren) && !Right.is(tok::r_paren)) || (Left.is(tok::l_square) && !Right.is(tok::r_square)); } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 02c749337e2..392548dc6cc 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1334,6 +1334,10 @@ TEST_F(FormatTest, DoesNotBreakTrailingAnnotation) { " GUARDED_BY(aaaaaaaaaaaaa);"); verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n" " GUARDED_BY(aaaaaaaaaaaaa) {}"); + verifyFormat( + "void aaaaaaaaaaaaaaaaaa()\n" + " __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaa,\n" + " aaaaaaaaaaaaaaaaaaaaaaaaa));"); } TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) { |