]> granicus.if.org Git - clang/commitdiff
Use TypeSourceInfo to help determine the SourceRange of a CXXNewExpr. This fixes...
authorTed Kremenek <kremenek@apple.com>
Fri, 25 Jun 2010 22:48:49 +0000 (22:48 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 25 Jun 2010 22:48:49 +0000 (22:48 +0000)
cases where we generated an invalid SourceRange for this expression.  Thanks to John McCall
for helping me figure this out.

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

lib/Sema/SemaExprCXX.cpp

index 3220494cbc8162af21f0060c1ecf6df1cc447a36..4d93e72be20f3b67d52fd4ed5840f3da6f05ecd2 100644 (file)
@@ -671,7 +671,8 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
   QualType AllocType = TInfo->getType();
   if (D.isInvalidType())
     return ExprError();
-    
+  
+  SourceRange R = TInfo->getTypeLoc().getSourceRange();    
   return BuildCXXNew(StartLoc, UseGlobal,
                      PlacementLParen,
                      move(PlacementArgs),
@@ -679,7 +680,7 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
                      ParenTypeId,
                      AllocType,
                      D.getSourceRange().getBegin(),
-                     D.getSourceRange(),
+                     R,
                      Owned(ArraySize),
                      ConstructorLParen,
                      move(ConstructorArgs),
@@ -851,13 +852,15 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
   PlacementArgs.release();
   ConstructorArgs.release();
   ArraySizeE.release();
+  
+  // FIXME: The TypeSourceInfo should also be included in CXXNewExpr.
   return Owned(new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew,
                                         PlaceArgs, NumPlaceArgs, ParenTypeId,
                                         ArraySize, Constructor, Init,
                                         ConsArgs, NumConsArgs, OperatorDelete,
                                         ResultType, StartLoc,
                                         Init ? ConstructorRParen :
-                                               SourceLocation()));
+                                               TypeRange.getEnd()));
 }
 
 /// CheckAllocatedType - Checks that a type is suitable as the allocated type