From dbcfdd6382ae829ff9f9758347144e40e179ee71 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 22 Jan 2014 00:30:17 +0000 Subject: [PATCH] Build an appropriate (albeit trivial) TypeSourceInfo for a destructor name, so AST consumers can determine where the destructor name was written. Patch by Olivier Goffart! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199779 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 15 +++++++++++---- test/SemaCXX/sourceranges.cpp | 9 +++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 2916059072..eb668ccbfe 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -209,7 +209,8 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, Context.hasSameUnqualifiedType(T, SearchType)) { // We found our type! - return ParsedType::make(T); + return CreateParsedType(T, + Context.getTrivialTypeSourceInfo(T, NameLoc)); } if (!SearchType.isNull()) @@ -245,7 +246,9 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, = dyn_cast(Record->getDecl())) { if (Spec->getSpecializedTemplate()->getCanonicalDecl() == Template->getCanonicalDecl()) - return ParsedType::make(MemberOfType); + return CreateParsedType( + MemberOfType, + Context.getTrivialTypeSourceInfo(MemberOfType, NameLoc)); } continue; @@ -264,7 +267,9 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // specialized. if (TemplateDecl *SpecTemplate = SpecName.getAsTemplateDecl()) { if (SpecTemplate->getCanonicalDecl() == Template->getCanonicalDecl()) - return ParsedType::make(MemberOfType); + return CreateParsedType( + MemberOfType, + Context.getTrivialTypeSourceInfo(MemberOfType, NameLoc)); continue; } @@ -275,7 +280,9 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, = SpecName.getAsDependentTemplateName()) { if (DepTemplate->isIdentifier() && DepTemplate->getIdentifier() == Template->getIdentifier()) - return ParsedType::make(MemberOfType); + return CreateParsedType( + MemberOfType, + Context.getTrivialTypeSourceInfo(MemberOfType, NameLoc)); continue; } diff --git a/test/SemaCXX/sourceranges.cpp b/test/SemaCXX/sourceranges.cpp index 1f25d5bce9..900db89fef 100644 --- a/test/SemaCXX/sourceranges.cpp +++ b/test/SemaCXX/sourceranges.cpp @@ -28,3 +28,12 @@ foo::A getName() { // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} 'foo::A' return foo::A(); } + +void destruct(foo::A *a1, foo::A *a2, P *p1) { + // CHECK: MemberExpr {{0x[0-9a-fA-F]+}} '' ->~A + a1->~A(); + // CHECK: MemberExpr {{0x[0-9a-fA-F]+}} '' ->~A + a2->foo::A::~A(); + // CHECK: MemberExpr {{0x[0-9a-fA-F]+}} '' ->~P + p1->~P(); +} \ No newline at end of file -- 2.40.0