clang-format: Fix regression caused by r206165.

llvm-svn: 206173
This commit is contained in:
Daniel Jasper 2014-04-14 13:15:29 +00:00
parent cb9c3cfb58
commit 866468ae4d
2 changed files with 13 additions and 1 deletions

View File

@ -111,7 +111,9 @@ private:
// static_assert, if and while usually contain expressions.
Contexts.back().IsExpression = true;
} else if (Line.InPPDirective &&
(!Left->Previous || Left->Previous->isNot(tok::identifier))) {
(!Left->Previous ||
(Left->Previous->isNot(tok::identifier) &&
Left->Previous->Type != TT_OverloadedOperator))) {
Contexts.back().IsExpression = true;
} else if (Left->Previous && Left->Previous->is(tok::r_square) &&
Left->Previous->MatchingParen &&

View File

@ -4584,6 +4584,16 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
// FIXME: Is there a way to make this work?
// verifyIndependentOfContext("MACRO(A *a);");
EXPECT_EQ("#define OP(x) \\\n"
" ostream &operator<<(ostream &s, const A &a) { \\\n"
" return s << a.DebugString(); \\\n"
" }",
format("#define OP(x) \\\n"
" ostream &operator<<(ostream &s, const A &a) { \\\n"
" return s << a.DebugString(); \\\n"
" }",
getLLVMStyleWithColumns(50)));
// FIXME: We cannot handle this case yet; we might be able to figure out that
// foo<x> d > v; doesn't make sense.
verifyFormat("foo<a < b && c> d > v;");