[cfe-commits] r107873 - in /cfe/trunk: include/clang/AST/Type.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Jul 8 06:09:53 PDT 2010
Author: akirtzidis
Date: Thu Jul 8 08:09:53 2010
New Revision: 107873
URL: http://llvm.org/viewvc/llvm-project?rev=107873&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=107873&r1=107872&r2=107873&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Jul 8 08:09:53 2010
@@ -1013,6 +1013,9 @@
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 {
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=107873&r1=107872&r2=107873&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Thu Jul 8 08:09:53 2010
@@ -2160,19 +2160,27 @@
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 @@
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
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=107873&r1=107872&r2=107873&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Thu Jul 8 08:09:53 2010
@@ -194,6 +194,7 @@
}
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 @@
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();
More information about the cfe-commits
mailing list