aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-07-02 11:55:11 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-07-02 11:55:11 +0000
commit9763e221e16026ddf487d2564ed349d2c874a1a1 (patch)
tree6b29b1cf5e0657b9c386b16c71be688969c3fd2b /lib/Frontend
parentf52a5d23965abe1a11ca7f283fec1adc1a339516 (diff)
- Allow a typedef type to be read from PCH even if its decl is currently initializing.
- Fix creation of TemplateSpecializationType. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107471 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/PCHReader.cpp17
-rw-r--r--lib/Frontend/PCHWriter.cpp7
2 files changed, 17 insertions, 7 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index be763d51ca..330cd9a5c6 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -2116,12 +2116,15 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) {
return Context->getTypeDeclType(
cast<UnresolvedUsingTypenameDecl>(GetDecl(Record[0])));
- case pch::TYPE_TYPEDEF:
- if (Record.size() != 1) {
+ case pch::TYPE_TYPEDEF: {
+ if (Record.size() != 2) {
Error("incorrect encoding of typedef type");
return QualType();
}
- return Context->getTypeDeclType(cast<TypedefDecl>(GetDecl(Record[0])));
+ TypedefDecl *Decl = cast<TypedefDecl>(GetDecl(Record[0]));
+ QualType Canonical = GetType(Record[1]);
+ return Context->getTypedefType(Decl, Canonical);
+ }
case pch::TYPE_TYPEOF_EXPR:
return Context->getTypeOfExprType(ReadExpr());
@@ -2251,8 +2254,12 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) {
llvm::SmallVector<TemplateArgument, 8> Args;
ReadTemplateArgumentList(Args, Record, Idx);
QualType Canon = GetType(Record[Idx++]);
- return Context->getTemplateSpecializationType(Name, Args.data(),Args.size(),
- Canon);
+ if (Canon.isNull())
+ return Context->getCanonicalTemplateSpecializationType(Name, Args.data(),
+ Args.size());
+ else
+ return Context->getTemplateSpecializationType(Name, Args.data(),
+ Args.size(), Canon);
}
}
// Suppress a GCC warning
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 41815314d7..f91f76c1b4 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -173,6 +173,8 @@ void PCHTypeWriter::VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
void PCHTypeWriter::VisitTypedefType(const TypedefType *T) {
Writer.AddDeclRef(T->getDecl(), Record);
+ assert(!T->isCanonicalUnqualified() && "Invalid typedef ?");
+ Writer.AddTypeRef(T->getCanonicalTypeInternal(), Record);
Code = pch::TYPE_TYPEDEF;
}
@@ -223,8 +225,9 @@ PCHTypeWriter::VisitTemplateSpecializationType(
for (TemplateSpecializationType::iterator ArgI = T->begin(), ArgE = T->end();
ArgI != ArgE; ++ArgI)
Writer.AddTemplateArgument(*ArgI, Record);
- QualType Canon = T->getCanonicalTypeInternal();
- Writer.AddTypeRef(Canon.getTypePtr() != T ? Canon : QualType(), Record);
+ Writer.AddTypeRef(T->isCanonicalUnqualified() ? QualType()
+ : T->getCanonicalTypeInternal(),
+ Record);
Code = pch::TYPE_TEMPLATE_SPECIALIZATION;
}