From: Douglas Gregor Date: Wed, 24 Feb 2010 23:50:37 +0000 (+0000) Subject: Keep track of the location of the '~' in a pseudo-destructor expression. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fce46ee68f779e239826e69e45d01d4c8e5323ca;p=clang Keep track of the location of the '~' in a pseudo-destructor expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97080 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 8f052f67aa..6a06554b60 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -1047,6 +1047,9 @@ class CXXPseudoDestructorExpr : public Expr { /// expression. SourceLocation ColonColonLoc; + /// \brief The location of the '~'. + SourceLocation TildeLoc; + /// \brief The type being destroyed. TypeSourceInfo *DestroyedType; @@ -1057,6 +1060,7 @@ public: SourceRange QualifierRange, TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc, + SourceLocation TildeLoc, TypeSourceInfo *DestroyedType) : Expr(CXXPseudoDestructorExprClass, Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, @@ -1069,7 +1073,7 @@ public: Base(static_cast(Base)), IsArrow(isArrow), OperatorLoc(OperatorLoc), Qualifier(Qualifier), QualifierRange(QualifierRange), - ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), + ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), DestroyedType(DestroyedType) { } void setBase(Expr *E) { Base = E; } @@ -1113,6 +1117,9 @@ public: /// expression. SourceLocation getColonColonLoc() const { return ColonColonLoc; } + /// \brief Retrieve the location of the '~'. + SourceLocation getTildeLoc() const { return TildeLoc; } + /// \brief Retrieve the type that is being destroyed. QualType getDestroyedType() const { return DestroyedType->getType(); } diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 689ad493e8..abc775e06b 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -2187,6 +2187,7 @@ public: const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, + SourceLocation TildeLoc, TypeSourceInfo *DestroyedType, bool HasTrailingLParen); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 3fb587fc37..71aae736b1 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2940,6 +2940,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, (NestedNameSpecifier *) SS.getScopeRep(), SS.getRange(), 0, SourceLocation(), + MemberLoc, DestroyedTypeInfo)); } diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 98e8000b17..4fca322c3a 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -2433,6 +2433,7 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base, const CXXScopeSpec &SS, TypeSourceInfo *ScopeTypeInfo, SourceLocation CCLoc, + SourceLocation TildeLoc, TypeSourceInfo *DestructedTypeInfo, bool HasTrailingLParen) { assert(DestructedTypeInfo && "No destructed type in pseudo-destructor expr?"); @@ -2513,6 +2514,7 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base, SS.getRange(), ScopeTypeInfo, CCLoc, + TildeLoc, DestructedTypeInfo)); if (HasTrailingLParen) return move(Result); @@ -2789,8 +2791,8 @@ Sema::OwningExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, ExprArg Base, return BuildPseudoDestructorExpr(move(Base), OpLoc, OpKind, SS, - ScopeTypeInfo, CCLoc, DestructedTypeInfo, - HasTrailingLParen); + ScopeTypeInfo, CCLoc, TildeLoc, + DestructedTypeInfo, HasTrailingLParen); } CXXMemberCallExpr *Sema::BuildCXXMemberCallExpr(Expr *Exp, diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index bd939f0aeb..922c041393 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -888,6 +888,7 @@ public: SourceRange QualifierRange, TypeSourceInfo *ScopeType, SourceLocation CCLoc, + SourceLocation TildeLoc, TypeSourceInfo *DestroyedType); /// \brief Build a new unary operator expression. @@ -4705,6 +4706,7 @@ TreeTransform::TransformCXXPseudoDestructorExpr( E->getQualifierRange(), ScopeTypeInfo, E->getColonColonLoc(), + E->getTildeLoc(), DestroyedTypeInfo); } @@ -5755,6 +5757,7 @@ TreeTransform::RebuildCXXPseudoDestructorExpr(ExprArg Base, SourceRange QualifierRange, TypeSourceInfo *ScopeType, SourceLocation CCLoc, + SourceLocation TildeLoc, TypeSourceInfo *DestroyedType) { CXXScopeSpec SS; if (Qualifier) { @@ -5771,7 +5774,7 @@ TreeTransform::RebuildCXXPseudoDestructorExpr(ExprArg Base, // This pseudo-destructor expression is still a pseudo-destructor. return SemaRef.BuildPseudoDestructorExpr(move(Base), OperatorLoc, isArrow? tok::arrow : tok::period, - SS, ScopeType, CCLoc, + SS, ScopeType, CCLoc, TildeLoc, DestroyedType, /*FIXME?*/true); }