]> granicus.if.org Git - clang/commitdiff
For TagType and TemplateSpecializationType, isDependent calculation may be invalid...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 8 Jul 2010 13:09:53 +0000 (13:09 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 8 Jul 2010 13:09:53 +0000 (13:09 +0000)
calculation is using may still be initializing.
Thus, store the isDependent flag to PCH and restore directly to Type.

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

include/clang/AST/Type.h
lib/Frontend/PCHReader.cpp
lib/Frontend/PCHWriter.cpp

index b9cac6417150cb41f18aad167053169a3e31cf53..8d03641e9dbfc873fb4265b95219e903674d152f 100644 (file)
@@ -1013,6 +1013,9 @@ public:
   CanQualType getCanonicalTypeUnqualified() const; // in CanonicalType.h
   void dump() const;
   static bool classof(const Type *) { return true; }
+
+  friend class PCHReader;
+  friend class PCHWriter;
 };
 
 template <> inline const TypedefType *Type::getAs() const {
index e2701cea40bb21e6d14386fc23eea7e2f30d4078..568d9ce77e6d5408e4fe5104c087fea1221ac84c 100644 (file)
@@ -2160,19 +2160,27 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) {
   case pch::TYPE_DECLTYPE:
     return Context->getDecltypeType(ReadExpr());
 
-  case pch::TYPE_RECORD:
-    if (Record.size() != 1) {
+  case pch::TYPE_RECORD: {
+    if (Record.size() != 2) {
       Error("incorrect encoding of record type");
       return QualType();
     }
-    return Context->getRecordType(cast<RecordDecl>(GetDecl(Record[0])));
+    bool IsDependent = Record[0];
+    QualType T = Context->getRecordType(cast<RecordDecl>(GetDecl(Record[1])));
+    T->Dependent = IsDependent;
+    return T;
+  }
 
-  case pch::TYPE_ENUM:
-    if (Record.size() != 1) {
+  case pch::TYPE_ENUM: {
+    if (Record.size() != 2) {
       Error("incorrect encoding of enum type");
       return QualType();
     }
-    return Context->getEnumType(cast<EnumDecl>(GetDecl(Record[0])));
+    bool IsDependent = Record[0];
+    QualType T = Context->getEnumType(cast<EnumDecl>(GetDecl(Record[1])));
+    T->Dependent = IsDependent;
+    return T;
+  }
 
   case pch::TYPE_ELABORATED: {
     unsigned Idx = 0;
@@ -2273,16 +2281,20 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) {
 
   case pch::TYPE_TEMPLATE_SPECIALIZATION: {
     unsigned Idx = 0;
+    bool IsDependent = Record[Idx++];
     TemplateName Name = ReadTemplateName(Record, Idx);
     llvm::SmallVector<TemplateArgument, 8> Args;
     ReadTemplateArgumentList(Args, Record, Idx);
     QualType Canon = GetType(Record[Idx++]);
+    QualType T;
     if (Canon.isNull())
-      return Context->getCanonicalTemplateSpecializationType(Name, Args.data(),
-                                                             Args.size());
+      T = Context->getCanonicalTemplateSpecializationType(Name, Args.data(),
+                                                          Args.size());
     else
-      return Context->getTemplateSpecializationType(Name, Args.data(),
-                                                    Args.size(), Canon);
+      T = Context->getTemplateSpecializationType(Name, Args.data(),
+                                                 Args.size(), Canon);
+    T->Dependent = IsDependent;
+    return T;
   }
   }
   // Suppress a GCC warning
index e0009f44abcf51e2dfe391bc2ed92e373a484388..8684a06eb0bbede0c21b49f6856eee4313a05f1d 100644 (file)
@@ -194,6 +194,7 @@ void PCHTypeWriter::VisitDecltypeType(const DecltypeType *T) {
 }
 
 void PCHTypeWriter::VisitTagType(const TagType *T) {
+  Record.push_back(T->isDependentType());
   Writer.AddDeclRef(T->getDecl(), Record);
   assert(!T->isBeingDefined() &&
          "Cannot serialize in the middle of a type definition");
@@ -220,6 +221,7 @@ PCHTypeWriter::VisitSubstTemplateTypeParmType(
 void
 PCHTypeWriter::VisitTemplateSpecializationType(
                                        const TemplateSpecializationType *T) {
+  Record.push_back(T->isDependentType());
   Writer.AddTemplateName(T->getTemplateName(), Record);
   Record.push_back(T->getNumArgs());
   for (TemplateSpecializationType::iterator ArgI = T->begin(), ArgE = T->end();