From: Ted Kremenek Date: Fri, 25 Jun 2010 22:48:49 +0000 (+0000) Subject: Use TypeSourceInfo to help determine the SourceRange of a CXXNewExpr. This fixes... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9d5bac60bce072a754ca629d3899e8c6c0b5018;p=clang Use TypeSourceInfo to help determine the SourceRange of a CXXNewExpr. This fixes several 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 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 3220494cbc..4d93e72be2 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -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