diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-07-08 13:09:53 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-07-08 13:09:53 +0000 |
commit | be191100e034b23a3e13053757a57b7f5068c24a (patch) | |
tree | 645d77fa17ac97204317c7f5480048ecec7f2c49 | |
parent | 663e380d7b2de2bbf20e886e05371195bea9adc4 (diff) |
For TagType and TemplateSpecializationType, isDependent calculation may be invalid because some decls that the
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
-rw-r--r-- | include/clang/AST/Type.h | 3 | ||||
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 32 | ||||
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 2 |
3 files changed, 27 insertions, 10 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index b9cac64171..8d03641e9d 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -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 { diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index e2701cea40..568d9ce77e 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -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 diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index e0009f44ab..8684a06eb0 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -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(); |