summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-07-09 07:43:55 +0000
committerDaniel Jasper <djasper@google.com>2013-07-09 07:43:55 +0000
commit6331da06725dc99fe88f875647b69c80168d84dc (patch)
treedf2933c2accbc84796490e03464b2f7b1c6cba3f /clang/lib
parentdbbf09b28ec72c5834d2b35ccddfaf99ef2671de (diff)
downloadbcm5719-llvm-6331da06725dc99fe88f875647b69c80168d84dc.tar.gz
bcm5719-llvm-6331da06725dc99fe88f875647b69c80168d84dc.zip
Format overloaded operators like other functions.
This fixes llvm.org/PR16328 (at least partially). Before: SomeLoooooooooooooooooooooooooooooogType operator<<( const SomeLooooooooogType &a, const SomeLooooooooogType &b); After: SomeLoooooooooooooooooooooooooooooogType operator<<(const SomeLooooooooogType &a, const SomeLooooooooogType &b); llvm-svn: 185908
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/Format.cpp9
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp4
2 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index e4004a649b0..23f6f5b3e89 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -536,7 +536,9 @@ private:
State.Stack.back().VariablePos != 0) {
State.Column = State.Stack.back().VariablePos;
} else if (Previous.ClosesTemplateDeclaration ||
- (Current.Type == TT_StartOfName && State.ParenLevel == 0 &&
+ ((Current.Type == TT_StartOfName ||
+ Current.is(tok::kw_operator)) &&
+ State.ParenLevel == 0 &&
(!Style.IndentFunctionDeclarationAfterType ||
Line.StartsDefinition))) {
State.Column = State.Stack.back().Indent;
@@ -1111,8 +1113,9 @@ private:
(Previous.ClosesTemplateDeclaration && State.ParenLevel == 0)))
return true;
- if (Current.Type == TT_StartOfName && Line.MightBeFunctionDecl &&
- State.Stack.back().BreakBeforeParameter && State.ParenLevel == 0)
+ if ((Current.Type == TT_StartOfName || Current.is(tok::kw_operator)) &&
+ Line.MightBeFunctionDecl && State.Stack.back().BreakBeforeParameter &&
+ State.ParenLevel == 0)
return true;
return false;
}
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 3c2ae52c998..c7034734d49 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -996,7 +996,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
if (Left.is(tok::comma))
return 1;
- if (Right.Type == TT_StartOfName) {
+ if (Right.Type == TT_StartOfName || Right.is(tok::kw_operator)) {
if (Line.First->is(tok::kw_for) && Right.PartOfMultiVariableDeclStmt)
return 3;
else if (Line.MightBeFunctionDecl && Right.BindingStrength == 1)
@@ -1203,7 +1203,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
const FormatToken &Right) {
const FormatToken &Left = *Right.Previous;
- if (Right.Type == TT_StartOfName)
+ if (Right.Type == TT_StartOfName || Right.is(tok::kw_operator))
return true;
if (Right.is(tok::colon) &&
(Right.Type == TT_ObjCDictLiteral || Right.Type == TT_ObjCMethodExpr))
OpenPOWER on IntegriCloud