From: Douglas Gregor Date: Mon, 26 Mar 2012 15:52:37 +0000 (+0000) Subject: Canonicalize the declaration we write to a PCH file for an X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a8e0b978d63c52e39c002fbf014ce553374fedcf;p=clang Canonicalize the declaration we write to a PCH file for an InjectedClassNameType; otherwise, it won't be properly wired to the original (canonical) declaration when it is deserialized. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153442 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index b746cff76e..a4301b53e8 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -365,7 +365,7 @@ void ASTTypeWriter::VisitElaboratedType(const ElaboratedType *T) { } void ASTTypeWriter::VisitInjectedClassNameType(const InjectedClassNameType *T) { - Writer.AddDeclRef(T->getDecl(), Record); + Writer.AddDeclRef(T->getDecl()->getCanonicalDecl(), Record); Writer.AddTypeRef(T->getInjectedSpecializationType(), Record); Code = TYPE_INJECTED_CLASS_NAME; } diff --git a/test/PCH/cxx-templates.cpp b/test/PCH/cxx-templates.cpp index 982fc67e4e..7ce247721f 100644 --- a/test/PCH/cxx-templates.cpp +++ b/test/PCH/cxx-templates.cpp @@ -62,3 +62,9 @@ namespace Test1 { } }; } + +template< typename D > +Foo< D >& Foo< D >::operator=( const Foo& other ) +{ + return *this; +} diff --git a/test/PCH/cxx-templates.h b/test/PCH/cxx-templates.h index c45e02dcb2..152e8cef54 100644 --- a/test/PCH/cxx-templates.h +++ b/test/PCH/cxx-templates.h @@ -205,3 +205,13 @@ namespace NonTypeTemplateParmContext { template inline bool equalIgnoringNullity(const Vector& a, const String& b) { return false; } } + +// +template< typename > class Foo; + +template< typename T > +class Foo : protected T +{ + public: + Foo& operator=( const Foo& other ); +};