diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-07-31 03:54:25 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-07-31 03:54:25 +0000 |
| commit | 352169aed40c722584bfcd22920b33f16795e01e (patch) | |
| tree | cc4a5832584c895641d2c97a52b7fac207de3aeb /clang/lib | |
| parent | a93183b8c955292704fa1c054f1a5c16742d62e5 (diff) | |
| download | bcm5719-llvm-352169aed40c722584bfcd22920b33f16795e01e.tar.gz bcm5719-llvm-352169aed40c722584bfcd22920b33f16795e01e.zip | |
Canonicalize dependent extended vector types.
llvm-svn: 77663
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 34 | ||||
| -rw-r--r-- | clang/lib/AST/Type.cpp | 8 |
2 files changed, 37 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); } diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index ed91e80c3e8..bf506415ac6 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -76,6 +76,14 @@ void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID, E->Profile(ID, Context, true); } +void +DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID &ID, + ASTContext &Context, + QualType ElementType, Expr *SizeExpr) { + ID.AddPointer(ElementType.getAsOpaquePtr()); + SizeExpr->Profile(ID, Context, true); +} + void DependentSizedExtVectorType::Destroy(ASTContext& C) { // FIXME: Deallocate size expression, once we're cloning properly. // if (SizeExpr) |

