[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 1 09:11:48 PST 2017


On Tue, Jan 31, 2017 at 3:23 PM, Richard Smith <richardsmith at google.com> wrote:
> On 31 January 2017 at 14:49, Hans Wennborg <hans at chromium.org> wrote:
>>
>> Richard, what do you think? I don't believe this fixes a 3.9
>> regression, but the fix looks small, so it might be worth it.
>
>
> I think on the whole the benefit of this change outweighs the risk of it
> regressing something.

Merged in r293782.

Thanks,
Hans

>
>>
>> On Tue, Jan 31, 2017 at 12:07 PM, Akira Hatanaka <ahatanaka at apple.com>
>> wrote:
>> > Thanks for the review. r293678.
>> >
>> > Should this be merged to 4.0?
>> >
>> >> On Jan 31, 2017, at 12:04 PM, Akira Hatanaka via Phabricator via
>> >> cfe-commits <cfe-commits at lists.llvm.org> wrote:
>> >>
>> >> This revision was automatically updated to reflect the committed
>> >> changes.
>> >> Closed by commit rL293678: [Sema] Transform a templated name before
>> >> looking it up in (authored by ahatanak).
>> >>
>> >> Changed prior to commit:
>> >>  https://reviews.llvm.org/D24969?vs=82134&id=86474#toc
>> >>
>> >> Repository:
>> >>  rL LLVM
>> >>
>> >> https://reviews.llvm.org/D24969
>> >>
>> >> Files:
>> >>  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> >>  cfe/trunk/lib/Sema/TreeTransform.h
>> >>  cfe/trunk/test/SemaCXX/destructor.cpp
>> >>
>> >>
>> >> Index: cfe/trunk/test/SemaCXX/destructor.cpp
>> >> ===================================================================
>> >> --- cfe/trunk/test/SemaCXX/destructor.cpp
>> >> +++ cfe/trunk/test/SemaCXX/destructor.cpp
>> >> @@ -431,3 +431,23 @@
>> >>
>> >> // The constructor definition should not have errors
>> >> Invalid::~Invalid() {}
>> >> +
>> >> +namespace PR30361 {
>> >> +template <typename T>
>> >> +struct C1 {
>> >> +  ~C1() {}
>> >> +  operator C1<T>* () { return nullptr; }
>> >> +  void foo1();
>> >> +};
>> >> +
>> >> +template<typename T>
>> >> +void C1<T>::foo1() {
>> >> +  C1::operator C1<T>*();
>> >> +  C1::~C1();
>> >> +}
>> >> +
>> >> +void foo1() {
>> >> +  C1<int> x;
>> >> +  x.foo1();
>> >> +}
>> >> +}
>> >> Index: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> >> ===================================================================
>> >> --- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> >> +++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> >> @@ -4990,8 +4990,12 @@
>> >>     NamedDecl *Result = nullptr;
>> >>     // FIXME: If the name is a dependent name, this lookup won't
>> >> necessarily
>> >>     // find it. Does that ever matter?
>> >> -    if (D->getDeclName()) {
>> >> -      DeclContext::lookup_result Found =
>> >> ParentDC->lookup(D->getDeclName());
>> >> +    if (auto Name = D->getDeclName()) {
>> >> +      DeclarationNameInfo NameInfo(Name, D->getLocation());
>> >> +      Name = SubstDeclarationNameInfo(NameInfo,
>> >> TemplateArgs).getName();
>> >> +      if (!Name)
>> >> +        return nullptr;
>> >> +      DeclContext::lookup_result Found = ParentDC->lookup(Name);
>> >>       Result = findInstantiationOf(Context, D, Found.begin(),
>> >> Found.end());
>> >>     } else {
>> >>       // Since we don't have a name for the entity we're looking for,
>> >> Index: cfe/trunk/lib/Sema/TreeTransform.h
>> >> ===================================================================
>> >> --- cfe/trunk/lib/Sema/TreeTransform.h
>> >> +++ cfe/trunk/lib/Sema/TreeTransform.h
>> >> @@ -8966,12 +8966,18 @@
>> >>   // base (and therefore couldn't do the check) and a
>> >>   // nested-name-qualifier (and therefore could do the lookup).
>> >>   NamedDecl *FirstQualifierInScope = nullptr;
>> >> +  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
>> >> +  if (MemberNameInfo.getName()) {
>> >> +    MemberNameInfo =
>> >> getDerived().TransformDeclarationNameInfo(MemberNameInfo);
>> >> +    if (!MemberNameInfo.getName())
>> >> +      return ExprError();
>> >> +  }
>> >>
>> >>   return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
>> >>                                         E->isArrow(),
>> >>                                         QualifierLoc,
>> >>                                         TemplateKWLoc,
>> >> -                                        E->getMemberNameInfo(),
>> >> +                                        MemberNameInfo,
>> >>                                         Member,
>> >>                                         FoundDecl,
>> >>                                         (E->hasExplicitTemplateArgs()
>> >>
>> >>
>> >> <D24969.86474.patch>_______________________________________________
>> >> cfe-commits mailing list
>> >> cfe-commits at lists.llvm.org
>> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> >
>
>


More information about the cfe-commits mailing list