[cfe-commits] r69825 - in /cfe/trunk/lib/Sema: Sema.cpp Sema.h SemaDecl.cpp

Douglas Gregor dgregor at apple.com
Wed Apr 22 13:56:09 PDT 2009


Author: dgregor
Date: Wed Apr 22 15:56:09 2009
New Revision: 69825

URL: http://llvm.org/viewvc/llvm-project?rev=69825&view=rev
Log:
Eliminate Sema::KnownFunctionIDs, so that Sema doesn't end up pulling
in a bunch of declarations from the PCH file. We're down to loading
very few declarations in Carbon-prefixed "Hello, World!":

*** PCH Statistics:
  6/20693 types read (0.028995%)
  7/59230 declarations read (0.011818%)
  50/44914 identifiers read (0.111324%)
  0/32954 statements read (0.000000%)
  5/6187 macros read (0.080815%)


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

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Apr 22 15:56:09 2009
@@ -161,15 +161,6 @@
     GlobalNewDeleteDeclared(false), 
     CompleteTranslationUnit(CompleteTranslationUnit) {
   
-  // Get IdentifierInfo objects for known functions for which we
-  // do extra checking.  
-  IdentifierTable &IT = PP.getIdentifierTable();  
-
-  KnownFunctionIDs[id_NSLog]         = &IT.get("NSLog");
-  KnownFunctionIDs[id_NSLogv]         = &IT.get("NSLogv");
-  KnownFunctionIDs[id_asprintf]      = &IT.get("asprintf");
-  KnownFunctionIDs[id_vasprintf]     = &IT.get("vasprintf");
-
   StdNamespace = 0;
   TUScope = 0;
   if (getLangOptions().CPlusPlus)

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Apr 22 15:56:09 2009
@@ -243,21 +243,6 @@
 
   IdentifierResolver IdResolver;
 
-  // Enum values used by KnownFunctionIDs (see below).
-  enum {
-    id_NSLog,
-    id_NSLogv,
-    id_asprintf,
-    id_vasprintf,
-    id_num_known_functions
-  };
-  
-  /// KnownFunctionIDs - This is a list of IdentifierInfo objects to a set
-  /// of known functions used by the semantic analysis to do various
-  /// kinds of checking (e.g. checking format string errors in printf calls).
-  /// This list is populated upon the creation of a Sema object.    
-  IdentifierInfo* KnownFunctionIDs[id_num_known_functions];
-
   /// 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/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=69825&r1=69824&r2=69825&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Apr 22 15:56:09 2009
@@ -3114,31 +3114,15 @@
   } else
     return;
 
-  unsigned KnownID;
-  for (KnownID = 0; KnownID != id_num_known_functions; ++KnownID)
-    if (KnownFunctionIDs[KnownID] == Name)
-      break;
-
-  switch (KnownID) {
-  case id_NSLog:
-  case id_NSLogv:
+  if (Name->isStr("NSLog") || Name->isStr("NSLogv")) {
     if (const FormatAttr *Format = FD->getAttr<FormatAttr>()) {
       // FIXME: We known better than our headers.
       const_cast<FormatAttr *>(Format)->setType("printf");
     } else 
       FD->addAttr(::new (Context) FormatAttr("printf", 1, 2));
-    break;
-
-  case id_asprintf:
-  case id_vasprintf:
+  } else if (Name->isStr("asprintf") || Name->isStr("vasprintf")) {
     if (!FD->getAttr<FormatAttr>())
       FD->addAttr(::new (Context) FormatAttr("printf", 2, 3));
-    break;
-
-  default:
-    // Unknown function or known function without any attributes to
-    // add. Do nothing.
-    break;
   }
 }
 





More information about the cfe-commits mailing list