summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-10-12 05:16:06 +0000
committerDaniel Jasper <djasper@google.com>2013-10-12 05:16:06 +0000
commitfba84ff00d1fe7c56378eb665e5c09d050ba443d (patch)
tree9d64c37e3b71e9a1106203e5cd8425277d8537b1 /clang
parented699259989868985a1a220d745161576242f4c9 (diff)
downloadbcm5719-llvm-fba84ff00d1fe7c56378eb665e5c09d050ba443d.tar.gz
bcm5719-llvm-fba84ff00d1fe7c56378eb665e5c09d050ba443d.zip
clang-format: No space in "<::" in C++11 mode.
llvm-svn: 192524
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/Format.cpp12
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp6
3 files changed, 17 insertions, 6 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index aac9fffb01e..7e92a705cad 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1012,10 +1012,14 @@ private:
++CountBoundToType;
}
- if (Tok->Type == TT_TemplateCloser &&
- Tok->Previous->Type == TT_TemplateCloser &&
- Tok->WhitespaceRange.getBegin() == Tok->WhitespaceRange.getEnd())
- HasCpp03IncompatibleFormat = true;
+ if (Tok->WhitespaceRange.getBegin() == Tok->WhitespaceRange.getEnd()) {
+ if (Tok->is(tok::coloncolon) &&
+ Tok->Previous->Type == TT_TemplateOpener)
+ HasCpp03IncompatibleFormat = true;
+ if (Tok->Type == TT_TemplateCloser &&
+ Tok->Previous->Type == TT_TemplateCloser)
+ HasCpp03IncompatibleFormat = true;
+ }
if (Tok->PackingKind == PPK_BinPacked)
HasBinPackedFunction = true;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index e1ffc25f633..4d95ecfe4f9 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1231,8 +1231,9 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
if (Left.is(tok::coloncolon))
return false;
if (Right.is(tok::coloncolon))
- return !Left.isOneOf(tok::identifier, tok::greater, tok::l_paren,
- tok::r_paren);
+ 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))
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index f80dc6fc34b..5fea8e781eb 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3711,8 +3711,14 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
verifyGoogleFormat("A<A<int> > a;");
verifyGoogleFormat("A<A<A<int> > > a;");
verifyGoogleFormat("A<A<A<A<int> > > > a;");
+ verifyGoogleFormat("A<::A<int>> a;");
+ verifyGoogleFormat("A<::A> a;");
+ verifyGoogleFormat("A< ::A> a;");
+ verifyGoogleFormat("A< ::A<int> > a;");
EXPECT_EQ("A<A<A<A>>> a;", format("A<A<A<A> >> a;", getGoogleStyle()));
EXPECT_EQ("A<A<A<A>>> a;", format("A<A<A<A>> > a;", getGoogleStyle()));
+ EXPECT_EQ("A<::A<int>> a;", format("A< ::A<int>> a;", getGoogleStyle()));
+ EXPECT_EQ("A<::A<int>> a;", format("A<::A<int> > a;", getGoogleStyle()));
verifyFormat("test >> a >> b;");
verifyFormat("test << a >> b;");
OpenPOWER on IntegriCloud