DependentSizedArrayType *Canon = 0;
llvm::FoldingSetNodeID ID;
+ QualType CanonicalEltTy = getCanonicalType(EltTy);
if (NumElts) {
// Dependently-sized array types that do not have a specified
// number of elements will have their sizes deduced from an
// initializer.
- DependentSizedArrayType::Profile(ID, *this, getCanonicalType(EltTy), ASM,
+ DependentSizedArrayType::Profile(ID, *this, CanonicalEltTy, ASM,
EltTypeQuals, NumElts);
Canon = DependentSizedArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
New = new (*this, TypeAlignment)
DependentSizedArrayType(*this, EltTy, QualType(Canon, 0),
NumElts, ASM, EltTypeQuals, Brackets);
- } else {
- QualType CanonEltTy = getCanonicalType(EltTy);
- if (CanonEltTy == EltTy) {
- New = new (*this, TypeAlignment)
- DependentSizedArrayType(*this, EltTy, QualType(),
- NumElts, ASM, EltTypeQuals, Brackets);
-
- if (NumElts) {
- DependentSizedArrayType *CanonCheck
- = DependentSizedArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
- assert(!CanonCheck && "Dependent-sized canonical array type broken");
- (void)CanonCheck;
- DependentSizedArrayTypes.InsertNode(New, InsertPos);
- }
- } else {
- QualType Canon = getDependentSizedArrayType(CanonEltTy, NumElts,
- ASM, EltTypeQuals,
- SourceRange());
- New = new (*this, TypeAlignment)
- DependentSizedArrayType(*this, EltTy, Canon,
- NumElts, ASM, EltTypeQuals, Brackets);
+ } else if (CanonicalEltTy == EltTy) {
+ // This is a canonical type. Record it.
+ New = new (*this, TypeAlignment)
+ DependentSizedArrayType(*this, EltTy, QualType(),
+ NumElts, ASM, EltTypeQuals, Brackets);
+
+ if (NumElts) {
+#ifndef NDEBUG
+ DependentSizedArrayType *CanonCheck
+ = DependentSizedArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
+ assert(!CanonCheck && "Dependent-sized canonical array type broken");
+ (void)CanonCheck;
+#endif
+ DependentSizedArrayTypes.InsertNode(New, InsertPos);
}
+ } else {
+ QualType Canon = getDependentSizedArrayType(CanonicalEltTy, NumElts,
+ ASM, EltTypeQuals,
+ SourceRange());
+ New = new (*this, TypeAlignment)
+ DependentSizedArrayType(*this, EltTy, Canon,
+ NumElts, ASM, EltTypeQuals, Brackets);
}
Types.push_back(New);
}
TypedefDecl *Decl = cast<TypedefDecl>(GetDecl(Record[0]));
QualType Canonical = GetType(Record[1]);
+ if (!Canonical.isNull())
+ Canonical = Context->getCanonicalType(Canonical);
return Context->getTypedefType(Decl, Canonical);
}
NestedNameSpecifier *NNS = ReadNestedNameSpecifier(Record, Idx);
const IdentifierInfo *Name = this->GetIdentifierInfo(Record, Idx);
QualType Canon = GetType(Record[Idx++]);
+ if (!Canon.isNull())
+ Canon = Context->getCanonicalType(Canon);
return Context->getDependentNameType(Keyword, NNS, Name, Canon);
}