aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-07-31 03:54:25 +0000
committerDouglas Gregor <dgregor@apple.com>2009-07-31 03:54:25 +0000
commit2ec09f1dc123e1942ed756e8ee4fef86451eac9e (patch)
tree9f72b9fbba13c5812220255c234ead5577a59b72 /lib/AST/ASTContext.cpp
parent7b1fdbda2757cc4a7f25664475be44119d7f8e59 (diff)
Canonicalize dependent extended vector types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77663 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 912b302f74..1b73679beb 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1515,11 +1515,35 @@ QualType ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) {
QualType ASTContext::getDependentSizedExtVectorType(QualType vecType,
Expr *SizeExpr,
SourceLocation AttrLoc) {
- DependentSizedExtVectorType *New =
- new (*this,8) DependentSizedExtVectorType(vecType, QualType(),
- SizeExpr, AttrLoc);
-
- DependentSizedExtVectorTypes.push_back(New);
+ llvm::FoldingSetNodeID ID;
+ DependentSizedExtVectorType::Profile(ID, *this, getCanonicalType(vecType),
+ SizeExpr);
+
+ void *InsertPos = 0;
+ DependentSizedExtVectorType *Canon
+ = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
+ DependentSizedExtVectorType *New;
+ if (Canon) {
+ // We already have a canonical version of this array type; use it as
+ // the canonical type for a newly-built type.
+ New = new (*this,8) DependentSizedExtVectorType(*this, vecType,
+ QualType(Canon, 0),
+ SizeExpr, AttrLoc);
+ } else {
+ QualType CanonVecTy = getCanonicalType(vecType);
+ if (CanonVecTy == vecType) {
+ New = new (*this,8) DependentSizedExtVectorType(*this, vecType,
+ QualType(), SizeExpr,
+ AttrLoc);
+ DependentSizedExtVectorTypes.InsertNode(New, InsertPos);
+ } else {
+ QualType Canon = getDependentSizedExtVectorType(CanonVecTy, SizeExpr,
+ SourceLocation());
+ New = new (*this,8) DependentSizedExtVectorType(*this, vecType, Canon,
+ SizeExpr, AttrLoc);
+ }
+ }
+
Types.push_back(New);
return QualType(New, 0);
}