diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-02-21 20:05:19 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-02-21 20:05:19 +0000 |
| commit | b2bc2e67520df0417fc5287de92e3cebd3060cfd (patch) | |
| tree | 8eb5c1796680a77e020f0559a51e302b8a4616e4 /clang/lib/AST/ASTContext.cpp | |
| parent | bda17491c4885ed37235c1e8afcfe75de479cd3b (diff) | |
| download | bcm5719-llvm-b2bc2e67520df0417fc5287de92e3cebd3060cfd.tar.gz bcm5719-llvm-b2bc2e67520df0417fc5287de92e3cebd3060cfd.zip | |
Tweaks to C++0x deduced auto type support:
* Flag indicating 'we're parsing this auto typed variable's initializer' moved from VarDecl to Sema
* Temporary template parameter list for auto deduction is now allocated on the stack.
* Deduced 'auto' types are now uniqued.
llvm-svn: 126139
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 945dfb87f29..df92d111929 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2683,12 +2683,22 @@ QualType ASTContext::getDecltypeType(Expr *e) const { return QualType(dt, 0); } -/// getAutoType - Unlike many "get<Type>" functions, we don't unique -/// AutoType AST's. +/// getAutoType - We only unique auto types after they've been deduced. QualType ASTContext::getAutoType(QualType DeducedType) const { - AutoType *at = new (*this, TypeAlignment) AutoType(DeducedType); - Types.push_back(at); - return QualType(at, 0); + void *InsertPos = 0; + if (!DeducedType.isNull()) { + // Look in the folding set for an existing type. + llvm::FoldingSetNodeID ID; + AutoType::Profile(ID, DeducedType); + if (AutoType *AT = AutoTypes.FindNodeOrInsertPos(ID, InsertPos)) + return QualType(AT, 0); + } + + AutoType *AT = new (*this, TypeAlignment) AutoType(DeducedType); + Types.push_back(AT); + if (InsertPos) + AutoTypes.InsertNode(AT, InsertPos); + return QualType(AT, 0); } /// getTagDeclType - Return the unique reference to the type for the |

