diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-24 18:54:32 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-24 18:54:32 +0000 |
commit | 26d1b1db23babd59003f7c79219894b07fac32bb (patch) | |
tree | 604a09518c9025cdd36b0cec35e3290c4e5139ff /clang/lib/Format/TokenAnnotator.h | |
parent | c68c6df88485b7521133103c848393b8a13842af (diff) | |
download | bcm5719-llvm-26d1b1db23babd59003f7c79219894b07fac32bb.tar.gz bcm5719-llvm-26d1b1db23babd59003f7c79219894b07fac32bb.zip |
Allow breaking between a type and name in variable declarations.
This fixes llvm.org/PR14967 and is generall necessary to avoid
situations where the column limit is exceeded. The challenge is
restricting such lines splits, otherwise clang-format suddenly starts
breaking at bad places.
Before:
ReallyLongReturnType<TemplateParam1, TemplateParam2>
ReallyReallyLongFunctionName(
const std::string &SomeParameter,
const SomeType<string,
SomeOtherTemplateParameter> &ReallyReallyLongParameterName,
const SomeType<string,
SomeOtherTemplateParameter> &AnotherLongParameterName) {}
After:
ReallyLongReturnType<TemplateParam1, TemplateParam2>
ReallyReallyLongFunctionName(
const std::string &SomeParameter,
const SomeType<string, SomeOtherTemplateParameter> &
ReallyReallyLongParameterName,
const SomeType<string, SomeOtherTemplateParameter> &
AnotherLongParameterName) {}
llvm-svn: 175999
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.h')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.h b/clang/lib/Format/TokenAnnotator.h index 850b6ddedee..aa78779f9b0 100644 --- a/clang/lib/Format/TokenAnnotator.h +++ b/clang/lib/Format/TokenAnnotator.h @@ -140,7 +140,8 @@ public: AnnotatedLine(const UnwrappedLine &Line) : First(Line.Tokens.front()), Level(Line.Level), InPPDirective(Line.InPPDirective), - MustBeDeclaration(Line.MustBeDeclaration) { + MustBeDeclaration(Line.MustBeDeclaration), + MightBeFunctionDecl(false) { assert(!Line.Tokens.empty()); AnnotatedToken *Current = &First; for (std::list<FormatToken>::const_iterator I = ++Line.Tokens.begin(), @@ -155,7 +156,8 @@ public: AnnotatedLine(const AnnotatedLine &Other) : First(Other.First), Type(Other.Type), Level(Other.Level), InPPDirective(Other.InPPDirective), - MustBeDeclaration(Other.MustBeDeclaration) { + MustBeDeclaration(Other.MustBeDeclaration), + MightBeFunctionDecl(Other.MightBeFunctionDecl) { Last = &First; while (!Last->Children.empty()) { Last->Children[0].Parent = Last; @@ -170,6 +172,7 @@ public: unsigned Level; bool InPPDirective; bool MustBeDeclaration; + bool MightBeFunctionDecl; }; inline prec::Level getPrecedence(const AnnotatedToken &Tok) { |