summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorBirunthan Mohanathas <birunthan@mohanathas.com>2015-06-29 15:30:42 +0000
committerBirunthan Mohanathas <birunthan@mohanathas.com>2015-06-29 15:30:42 +0000
commita0388a8af20e9c2f16b29e5417b125bad1a42e74 (patch)
treee8a8b075d4e20a1de5f79363626284437fcb304a /clang/lib/Format/TokenAnnotator.cpp
parentbcc976a4434787fefdc0a75835f00669c7338db0 (diff)
downloadbcm5719-llvm-a0388a8af20e9c2f16b29e5417b125bad1a42e74.tar.gz
bcm5719-llvm-a0388a8af20e9c2f16b29e5417b125bad1a42e74.zip
clang-format: Add option to break after definition return type for top-level functions only
Differential Revision: http://reviews.llvm.org/D10774 llvm-svn: 240959
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 2f1aae39344..0117f222004 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1539,8 +1539,11 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) {
Current->MustBreakBefore =
Current->MustBreakBefore || mustBreakBefore(Line, *Current);
- if (Style.AlwaysBreakAfterDefinitionReturnType && InFunctionDecl &&
- Current->is(TT_FunctionDeclarationName) &&
+ if ((Style.AlwaysBreakAfterDefinitionReturnType == FormatStyle::DRTBS_All ||
+ (Style.AlwaysBreakAfterDefinitionReturnType ==
+ FormatStyle::DRTBS_TopLevel &&
+ Line.Level == 0)) &&
+ InFunctionDecl && Current->is(TT_FunctionDeclarationName) &&
!Line.Last->isOneOf(tok::semi, tok::comment)) // Only for definitions.
// FIXME: Line.Last points to other characters than tok::semi
// and tok::lbrace.
OpenPOWER on IntegriCloud