Fix dereference of pointers in throw statements.

Before:
  throw * x;

After:
  throw *x;

Patch by Erik Uhlmann.

llvm-svn: 308185
This commit is contained in:
Manuel Klimek 2017-07-17 15:27:53 +00:00
parent 8d0ecbedbe
commit 06b575ca81
2 changed files with 3 additions and 1 deletions

View File

@ -1383,7 +1383,8 @@ private:
if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
tok::equal, tok::kw_delete, tok::kw_sizeof) ||
tok::equal, tok::kw_delete, tok::kw_sizeof,
tok::kw_throw) ||
PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
TT_UnaryOperator, TT_CastRParen))
return TT_UnaryOperator;

View File

@ -5350,6 +5350,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyFormat("x = *a(x) = *a(y);", Left);
verifyFormat("for (;; *a = b) {\n}", Left);
verifyFormat("return *this += 1;", Left);
verifyFormat("throw *x;", Left);
verifyIndependentOfContext("a = *(x + y);");
verifyIndependentOfContext("a = &(x + y);");