summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-10-21 09:57:09 +0000
committerDaniel Jasper <djasper@google.com>2014-10-21 09:57:09 +0000
commit16b107e9f04edfe2673e0ce4072e52560274f732 (patch)
tree9f5e058ec1226423ee60fd58959dc26d8b861122 /clang/lib/Format
parent4bf9d470cb7ba743241b935eba4bcf8c26640d8f (diff)
downloadbcm5719-llvm-16b107e9f04edfe2673e0ce4072e52560274f732.tar.gz
bcm5719-llvm-16b107e9f04edfe2673e0ce4072e52560274f732.zip
clang-format: [Java] Improve generic support.
Before: Iterable< ? > a; Iterable< ? extends SomeObject > a; After: Iterable<?> a; Iterable<? extends SomeObject> a; llvm-svn: 220281
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 4f32b9f9eb9..4493471d217 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -51,6 +51,10 @@ private:
Contexts.back().InTemplateArgument =
Left->Previous && Left->Previous->Tok.isNot(tok::kw_template);
+ if (Style.Language == FormatStyle::LK_Java &&
+ CurrentToken->is(tok::question))
+ next();
+
while (CurrentToken) {
if (CurrentToken->is(tok::greater)) {
Left->MatchingParen = CurrentToken;
@@ -60,7 +64,7 @@ private:
return true;
}
if (CurrentToken->isOneOf(tok::r_paren, tok::r_square, tok::r_brace,
- tok::question, tok::colon))
+ tok::colon, tok::question))
return false;
// If a && or || is found and interpreted as a binary operator, this set
// of angles is likely part of something like "a < b && c > d". If the
@@ -1532,9 +1536,6 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
(Left.MatchingParen && Left.MatchingParen->Type == TT_CastRParen))
? Style.SpacesInCStyleCastParentheses
: Style.SpacesInParentheses;
- if (Style.SpacesInAngles &&
- ((Left.Type == TT_TemplateOpener) != (Right.Type == TT_TemplateCloser)))
- return true;
if (Right.isOneOf(tok::semi, tok::comma))
return false;
if (Right.is(tok::less) &&
@@ -1550,10 +1551,6 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
return false;
if (Left.is(tok::coloncolon))
return false;
- if (Right.is(tok::coloncolon) && Left.isNot(tok::l_brace))
- return (Left.is(tok::less) && Style.Standard == FormatStyle::LS_Cpp03) ||
- !Left.isOneOf(tok::identifier, tok::greater, tok::l_paren,
- tok::r_paren, tok::less);
if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less))
return false;
if (Right.is(tok::ellipsis))
@@ -1697,6 +1694,12 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
if (!Style.SpaceBeforeAssignmentOperators &&
Right.getPrecedence() == prec::Assignment)
return false;
+ if (Right.is(tok::coloncolon) && Left.isNot(tok::l_brace))
+ return (Left.is(tok::less) && Style.Standard == FormatStyle::LS_Cpp03) ||
+ !Left.isOneOf(tok::identifier, tok::greater, tok::l_paren,
+ tok::r_paren, tok::less);
+ if ((Left.Type == TT_TemplateOpener) != (Right.Type == TT_TemplateCloser))
+ return Style.SpacesInAngles;
if ((Right.Type == TT_BinaryOperator && !Left.is(tok::l_paren)) ||
Left.Type == TT_BinaryOperator || Left.Type == TT_ConditionalExpr)
return true;
OpenPOWER on IntegriCloud