diff options
author | Chris Lattner <sabre@nondot.org> | 2008-11-20 05:51:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-11-20 05:51:55 +0000 |
commit | ec7f7732f1475c706765973f5ef9348c2e453aaa (patch) | |
tree | 5ce86efbb3915d3fff481151c9f040509d4d7426 /clang/lib/Sema/SemaExprCXX.cpp | |
parent | 0e73b2c352ec6de56973fc84a5f82199d75b7df1 (diff) | |
download | bcm5719-llvm-ec7f7732f1475c706765973f5ef9348c2e453aaa.tar.gz bcm5719-llvm-ec7f7732f1475c706765973f5ef9348c2e453aaa.zip |
remove the type_info identifier cache. Compared to the cost
of doing the lookup_decl, the hash lookup is cheap. Also,
typeid doesn't happen enough in real world code to worry about
it.
I'd like to eventually get rid of KnownFunctionIDs from Sema
also, but today is not that day.
llvm-svn: 59711
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 0186fc3f145..80bd8eeef37 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -55,21 +55,16 @@ Action::ExprResult Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc) { const NamespaceDecl *StdNs = GetStdNamespace(); - if (!StdNs) { - Diag(OpLoc, diag::err_need_header_before_typeid); - return ExprResult(true); - } - if (!Ident_TypeInfo) { - Ident_TypeInfo = &PP.getIdentifierTable().get("type_info"); - } - Decl *TypeInfoDecl = LookupDecl(Ident_TypeInfo, + if (!StdNs) + return Diag(OpLoc, diag::err_need_header_before_typeid); + + IdentifierInfo *TypeInfoII = &PP.getIdentifierTable().get("type_info"); + Decl *TypeInfoDecl = LookupDecl(TypeInfoII, Decl::IDNS_Tag | Decl::IDNS_Ordinary, 0, StdNs, /*createBuiltins=*/false); RecordDecl *TypeInfoRecordDecl = dyn_cast_or_null<RecordDecl>(TypeInfoDecl); - if (!TypeInfoRecordDecl) { - Diag(OpLoc, diag::err_need_header_before_typeid); - return ExprResult(true); - } + if (!TypeInfoRecordDecl) + return Diag(OpLoc, diag::err_need_header_before_typeid); QualType TypeInfoType = Context.getTypeDeclType(TypeInfoRecordDecl); |