diff options
| author | Daniel Jasper <djasper@google.com> | 2013-01-02 08:44:14 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-01-02 08:44:14 +0000 |
| commit | d1926a3758e9c031e4a9f48d9ccdd754e438a816 (patch) | |
| tree | 4ec6f8999eabbb24af0951b4996477c7b0301193 /clang/lib/Format/Format.cpp | |
| parent | 9791afb1821b9163a8db162ed2e9aeef13819a02 (diff) | |
| download | bcm5719-llvm-d1926a3758e9c031e4a9f48d9ccdd754e438a816.tar.gz bcm5719-llvm-d1926a3758e9c031e4a9f48d9ccdd754e438a816.zip | |
Don't break after pointer or reference specifier.
This fixes llvm.org/PR14717.
Buggy format:
TypeSpecDecl *
TypeSpecDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
IdentifierInfo *II, Type *T) {
Now changed to:
TypeSpecDecl *TypeSpecDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *II,
Type *T) {
llvm-svn: 171357
Diffstat (limited to 'clang/lib/Format/Format.cpp')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 93126613ec5..a6c11dcd7ad 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -660,8 +660,7 @@ public: for (int i = 1, e = Line.Tokens.size(); i != e; ++i) { TokenAnnotation &Annotation = Annotations[i]; - Annotation.CanBreakBefore = - canBreakBetween(Line.Tokens[i - 1], Line.Tokens[i]); + Annotation.CanBreakBefore = canBreakBefore(i); if (Annotation.Type == TokenAnnotation::TT_CtorInitializerColon) { Annotation.MustBreakBefore = true; @@ -896,7 +895,13 @@ private: return true; } - bool canBreakBetween(const FormatToken &Left, const FormatToken &Right) { + bool canBreakBefore(unsigned i) { + if (Annotations[i - 1].Type == TokenAnnotation::TT_PointerOrReference || + Annotations[i].Type == TokenAnnotation::TT_ConditionalExpr) { + return false; + } + const FormatToken &Left = Line.Tokens[i - 1]; + const FormatToken &Right = Line.Tokens[i]; if (Right.Tok.is(tok::r_paren) || Right.Tok.is(tok::l_brace) || Right.Tok.is(tok::comment) || Right.Tok.is(tok::greater)) return false; |

