]> granicus.if.org Git - clang/commitdiff
Bring ASTReader and Writer into sync for the case where a canonical template speciali...
authorAxel Naumann <Axel.Naumann@cern.ch>
Mon, 1 Oct 2012 07:34:47 +0000 (07:34 +0000)
committerAxel Naumann <Axel.Naumann@cern.ch>
Mon, 1 Oct 2012 07:34:47 +0000 (07:34 +0000)
The easiest way out is to store whether the decl was canonical at the time of writing.
Add test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164927 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp
test/Modules/Inputs/redecl-merge-left.h
test/Modules/Inputs/redecl-merge-right.h
test/Modules/Inputs/redecl-merge-top.h
test/Modules/redecl-merge.m

index c9788a32164dc8c4866668a2c74c3005eaaf91ed..843893d90f2952e9074e30a9b91091d18650da7c 100644 (file)
@@ -1395,14 +1395,17 @@ void ASTDeclReader::VisitClassTemplateSpecializationDecl(
                                                      TemplArgs.size());
   D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
   D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
-  
-  if (D->isCanonicalDecl()) { // It's kept in the folding set.
+
+  bool writtenAsCanonicalDecl = Record[Idx++];
+  if (writtenAsCanonicalDecl) {
     ClassTemplateDecl *CanonPattern = ReadDeclAs<ClassTemplateDecl>(Record,Idx);
-    if (ClassTemplatePartialSpecializationDecl *Partial
-                       = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
-      CanonPattern->getCommonPtr()->PartialSpecializations.InsertNode(Partial);
-    } else {
-      CanonPattern->getCommonPtr()->Specializations.InsertNode(D);
+    if (D->isCanonicalDecl()) { // It's kept in the folding set.
+      if (ClassTemplatePartialSpecializationDecl *Partial
+                        = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
+       CanonPattern->getCommonPtr()->PartialSpecializations.InsertNode(Partial);
+      } else {
+        CanonPattern->getCommonPtr()->Specializations.InsertNode(D);
+      }
     }
   }
 }
index 7122bca9699ea5c35c88b08157d711346a96e72e..0f9bb3824b88c5cadb60c658676e7438b2ac0aca 100644 (file)
@@ -1106,6 +1106,7 @@ void ASTDeclWriter::VisitClassTemplateSpecializationDecl(
   Writer.AddTemplateArgumentList(&D->getTemplateArgs(), Record);
   Writer.AddSourceLocation(D->getPointOfInstantiation(), Record);
   Record.push_back(D->getSpecializationKind());
+  Record.push_back(D->isCanonicalDecl());
 
   if (D->isCanonicalDecl()) {
     // When reading, we'll add it to the folding set of the following template. 
index b3a7ba83c1af2d6f7a0525e150f69a8529ca7c64..4bdd01570f6f428cc7bb223d09050517ececd44a 100644 (file)
@@ -82,6 +82,12 @@ extern double var3;
 template<typename T> class Vector;
 
 template<typename T> class Vector;
+
+template<typename T> class List;
+template<> class List<bool> {
+public:
+  void push_back(int);
+};
 #endif
 
 // Make sure this doesn't introduce an ambiguity-creating 'id' at the
index de7aa08cfb2b4bdcd86d038217c631c732623a9e..695327674fb056dcdb05341d243317a6d1a2df13 100644 (file)
@@ -83,6 +83,12 @@ template<typename T> class Vector {
 public:
   void push_back(const T&);
 };
+
+template<typename T> class List;
+template<> class List<bool> {
+public:
+  void push_back(int);
+};
 #endif
 
 int ONE;
index 519254ca22139288efcb5146288240a3a69a76df..7053936b2ccd750ee73b3f46bd049c6961ac81e6 100644 (file)
@@ -17,4 +17,9 @@ struct S2;
 
 #ifdef __cplusplus
 template<typename T> class Vector;
+
+template<typename T> class List {
+public:
+  void push_back(T);
+};
 #endif
index d7930aca2ecc2a9e25e71521481f5da2c422c4b3..0e5cd4ac37dc46dc1787ea189e6e7480eea16150 100644 (file)
@@ -150,6 +150,9 @@ id<P3> p3;
 void testVector() {
   Vector<int> vec_int;
   vec_int.push_back(0);
+
+  List<bool> list_bool;
+  list_bool.push_back(false);
 }
 #endif