[cfe-commits] r153442 - in /cfe/trunk: lib/Serialization/ASTWriter.cpp test/PCH/cxx-templates.cpp test/PCH/cxx-templates.h

Douglas Gregor dgregor at apple.com
Mon Mar 26 08:52:38 PDT 2012


Author: dgregor
Date: Mon Mar 26 10:52:37 2012
New Revision: 153442

URL: http://llvm.org/viewvc/llvm-project?rev=153442&view=rev
Log:
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
<rdar://problem/11112464>.

Modified:
    cfe/trunk/lib/Serialization/ASTWriter.cpp
    cfe/trunk/test/PCH/cxx-templates.cpp
    cfe/trunk/test/PCH/cxx-templates.h

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=153442&r1=153441&r2=153442&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Mar 26 10:52:37 2012
@@ -365,7 +365,7 @@
 }
 
 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;
 }

Modified: cfe/trunk/test/PCH/cxx-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-templates.cpp?rev=153442&r1=153441&r2=153442&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx-templates.cpp (original)
+++ cfe/trunk/test/PCH/cxx-templates.cpp Mon Mar 26 10:52:37 2012
@@ -62,3 +62,9 @@
     }
   };
 }
+
+template< typename D >
+Foo< D >& Foo< D >::operator=( const Foo& other )
+{
+   return *this;
+}

Modified: cfe/trunk/test/PCH/cxx-templates.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-templates.h?rev=153442&r1=153441&r2=153442&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx-templates.h (original)
+++ cfe/trunk/test/PCH/cxx-templates.h Mon Mar 26 10:52:37 2012
@@ -205,3 +205,13 @@
   template<int inlineCapacity>
     inline bool equalIgnoringNullity(const Vector<char, inlineCapacity>& a, const String& b) { return false; }
 }
+
+// <rdar://problem/11112464>
+template< typename > class Foo;
+
+template< typename T >
+class Foo : protected T
+{
+ public:
+  Foo& operator=( const Foo& other );
+};





More information about the cfe-commits mailing list