]> granicus.if.org Git - clang/commitdiff
remove the type_info identifier cache. Compared to the cost
authorChris Lattner <sabre@nondot.org>
Thu, 20 Nov 2008 05:51:55 +0000 (05:51 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 20 Nov 2008 05:51:55 +0000 (05:51 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59711 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.cpp
lib/Sema/Sema.h
lib/Sema/SemaExprCXX.cpp

index e1eb86c98facf181e40588b9b1d76535f4cf50bd..c9e4cd98338ac3fee4baddd0ae1f9069b7ef428c 100644 (file)
@@ -103,9 +103,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer)
   KnownFunctionIDs[id_vsnprintf_chk] = &IT.get("__builtin___vsnprintf_chk");
   KnownFunctionIDs[id_vprintf]       = &IT.get("vprintf");
 
-  Ident_TypeInfo = 0;
   StdNamespace = 0;
-
   TUScope = 0;
   if (getLangOptions().CPlusPlus)
     FieldCollector.reset(new CXXFieldCollector());
index 7840dec5e7c8d84689dcef81c8447eae878250d4..52610ef6b78fbfe1050b4376a576421d1b0a2d84 100644 (file)
@@ -192,9 +192,6 @@ public:
   /// This list is populated upon the creation of a Sema object.    
   IdentifierInfo* KnownFunctionIDs[id_num_known_functions];
 
-  /// Identifiers used by the C++ language
-  IdentifierInfo *Ident_TypeInfo; // "type_info" - lazily created
-
   /// Translation Unit Scope - useful to Objective-C actions that need
   /// to lookup file scope declarations in the "ordinary" C decl namespace.
   /// For example, user-defined classes, built-in "id" type, etc.
index 0186fc3f1453353b6460317dd593f3b1ea80738a..80bd8eeef37518cde8a69e1b9da7af925e1fc238 100644 (file)
@@ -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);