]> granicus.if.org Git - clang/commitdiff
Fix source range of CXXNewExpr with parentheses around the type. PR15569.
authorEli Friedman <eli.friedman@gmail.com>
Mon, 17 Jun 2013 22:35:10 +0000 (22:35 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 17 Jun 2013 22:35:10 +0000 (22:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184139 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprCXX.cpp
unittests/AST/SourceLocationTest.cpp

index 59e780ae0a171f816cdc1340c54dfca131ce2672..55bd1990f605c42cf51f08f6520c15ce490bb53c 100644 (file)
@@ -134,7 +134,10 @@ CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
     this->Range.setEnd(DirectInitRange.getEnd()); break;
   case ListInit:
     this->Range.setEnd(getInitializer()->getSourceRange().getEnd()); break;
-  default: break;
+  default:
+    if (TypeIdParens.isValid())
+      this->Range.setEnd(TypeIdParens.getEnd());
+    break;
   }
 }
 
index 990e6dfc85a8b34c2a917ee3e32b610a638163f2..669fcd48a47fca6acad4410fb48e7ac9018c2fc7 100644 (file)
@@ -174,5 +174,11 @@ TEST(TemplateSpecializationTypeLoc, AngleBracketLocations) {
       loc(templateSpecializationType())));
 }
 
+TEST(CXXNewExpr, TypeParenRange) {
+  RangeVerifier<CXXNewExpr> Verifier;
+  Verifier.expectRange(1, 10, 1, 18);
+  EXPECT_TRUE(Verifier.match("int* a = new (int);", newExpr()));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang