summaryrefslogtreecommitdiffstats
path: root/clang/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
commit352169aed40c722584bfcd22920b33f16795e01e (patch)
treecc4a5832584c895641d2c97a52b7fac207de3aeb /clang/lib/AST/ASTContext.cpp
parenta93183b8c955292704fa1c054f1a5c16742d62e5 (diff)
downloadbcm5719-llvm-352169aed40c722584bfcd22920b33f16795e01e.tar.gz
bcm5719-llvm-352169aed40c722584bfcd22920b33f16795e01e.zip
Canonicalize dependent extended vector types.
llvm-svn: 77663
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r--clang/lib/AST/ASTContext.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 912b302f74e..1b73679beb7 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/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);
}
OpenPOWER on IntegriCloud