]> granicus.if.org Git - clang/commitdiff
Fix dereference of pointers in throw statements.
authorManuel Klimek <klimek@google.com>
Mon, 17 Jul 2017 15:27:53 +0000 (15:27 +0000)
committerManuel Klimek <klimek@google.com>
Mon, 17 Jul 2017 15:27:53 +0000 (15:27 +0000)
Before:
  throw * x;

After:
  throw *x;

Patch by Erik Uhlmann.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308185 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index c6e90a9175e1c8d2e2963a687a27599048d4b4eb..46ea06b880ed2c3df0dc2d0f5d89db52b945100e 100644 (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;
index eb7bcc1ed8f761b032f47552e15a26969a2edef1..f533ebf2234baeb90629c181ca9de85cf23bb945 100644 (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);");