diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-07-30 23:18:24 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-07-30 23:18:24 +0000 |
commit | b197572cf1cd70a817a1f546478cb2cb9112c48e (patch) | |
tree | 478c5a2caa30004f0c3662d9f9f5c4d43be3d4ab /lib/AST/ASTContext.cpp | |
parent | 03e205031b08669f05c41eed5b896fc94c4a12bb (diff) |
Canonicalization for dependent typeof(expr) types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77639 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index e9bcc04c28..81cab925eb 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1876,9 +1876,26 @@ QualType ASTContext::getObjCInterfaceType(const ObjCInterfaceDecl *Decl, /// on canonical type's (which are always unique). QualType ASTContext::getTypeOfExprType(Expr *tofExpr) { TypeOfExprType *toe; - if (tofExpr->isTypeDependent()) - toe = new (*this, 8) TypeOfExprType(tofExpr); - else { + if (tofExpr->isTypeDependent()) { + llvm::FoldingSetNodeID ID; + DependentTypeOfExprType::Profile(ID, *this, tofExpr); + + void *InsertPos = 0; + DependentTypeOfExprType *Canon + = DependentTypeOfExprTypes.FindNodeOrInsertPos(ID, InsertPos); + if (Canon) { + // We already have a "canonical" version of an identical, dependent + // typeof(expr) type. Use that as our canonical type. + toe = new (*this, 8) TypeOfExprType(tofExpr, + QualType((TypeOfExprType*)Canon, 0)); + } + else { + // Build a new, canonical typeof(expr) type. + Canon = new (*this, 8) DependentTypeOfExprType(*this, tofExpr); + DependentTypeOfExprTypes.InsertNode(Canon, InsertPos); + toe = Canon; + } + } else { QualType Canonical = getCanonicalType(tofExpr->getType()); toe = new (*this,8) TypeOfExprType(tofExpr, Canonical); } |