[cfe-commits] r59711 - in /cfe/trunk/lib/Sema: Sema.cpp Sema.h SemaExprCXX.cpp

Chris Lattner sabre at nondot.org
Wed Nov 19 21:51:55 PST 2008


Author: lattner
Date: Wed Nov 19 23:51:55 2008
New Revision: 59711

URL: http://llvm.org/viewvc/llvm-project?rev=59711&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=59711&r1=59710&r2=59711&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Nov 19 23:51:55 2008
@@ -103,9 +103,7 @@
   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());

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=59711&r1=59710&r2=59711&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Nov 19 23:51:55 2008
@@ -192,9 +192,6 @@
   /// 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.

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=59711&r1=59710&r2=59711&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Nov 19 23:51:55 2008
@@ -55,21 +55,16 @@
 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);
 





More information about the cfe-commits mailing list