[cfe-commits] r39026 - in /cfe/cfe/trunk: Lex/HeaderSearch.cpp include/clang/Lex/HeaderSearch.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:26:57 PDT 2007


Author: sabre
Date: Wed Jul 11 11:26:56 2007
New Revision: 39026

URL: http://llvm.org/viewvc/llvm-project?rev=39026&view=rev
Log:
count # framework lookups

Modified:
    cfe/cfe/trunk/Lex/HeaderSearch.cpp
    cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h

Modified: cfe/cfe/trunk/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/HeaderSearch.cpp?rev=39026&r1=39025&r2=39026&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/HeaderSearch.cpp (original)
+++ cfe/cfe/trunk/Lex/HeaderSearch.cpp Wed Jul 11 11:26:56 2007
@@ -19,6 +19,15 @@
 using namespace llvm;
 using namespace clang;
 
+HeaderSearch::HeaderSearch(FileManager &FM) : FileMgr(FM) {
+  SystemDirIdx = 0;
+  NoCurDirSearch = false;
+  
+  NumIncluded = 0;
+  NumMultiIncludeFileOptzn = 0;
+  NumFrameworkLookups = NumSubFrameworkLookups = 0;
+}
+
 void HeaderSearch::PrintStats() {
   std::cerr << "\n*** HeaderSearch Stats:\n";
   std::cerr << FileInfo.size() << " files tracked.\n";
@@ -36,22 +45,24 @@
   std::cerr << "  " << NumIncluded << " #include/#include_next/#import.\n";
   std::cerr << "    " << NumMultiIncludeFileOptzn << " #includes skipped due to"
             << " the multi-include optimization.\n";
-
+  
+  std::cerr << NumFrameworkLookups << " framework lookups.\n";
+  std::cerr << NumSubFrameworkLookups << " subframework lookups.\n";
 }
 
 //===----------------------------------------------------------------------===//
 // Header File Location.
 //===----------------------------------------------------------------------===//
 
-static const FileEntry *DoFrameworkLookup(const DirectoryEntry *Dir,
-                                          const std::string &Filename,
-                                          FileManager &FM) {
-  // TODO: caching.
-  
+const FileEntry *HeaderSearch::DoFrameworkLookup(const DirectoryEntry *Dir,
+                                                 const std::string &Filename) {
   // Framework names must have a '/' in the filename.
   std::string::size_type SlashPos = Filename.find('/');
   if (SlashPos == std::string::npos) return 0;
   
+  // TODO: caching.
+  ++NumFrameworkLookups;
+  
   // FrameworkName = "/System/Library/Frameworks/"
   std::string FrameworkName = Dir->getName();
   if (FrameworkName.empty() || FrameworkName[FrameworkName.size()-1] != '/')
@@ -66,13 +77,13 @@
   // Check "/System/Library/Frameworks/Cocoa.framework/Headers/file.h"
   std::string HeadersFilename = FrameworkName + "Headers/" +
     std::string(Filename.begin()+SlashPos+1, Filename.end());
-  if (const FileEntry *FE = FM.getFile(HeadersFilename))
+  if (const FileEntry *FE = FileMgr.getFile(HeadersFilename))
     return FE;
   
   // Check "/System/Library/Frameworks/Cocoa.framework/PrivateHeaders/file.h"
   std::string PrivateHeadersFilename = FrameworkName + "PrivateHeaders/" +
     std::string(Filename.begin()+SlashPos+1, Filename.end());
-  return FM.getFile(PrivateHeadersFilename);
+  return FileMgr.getFile(PrivateHeadersFilename);
 }
 
 /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,
@@ -131,10 +142,9 @@
     const FileEntry *FE = 0;
     if (!SearchDirs[i].isFramework()) {
       // FIXME: Portability.  Adding file to dir should be in sys::Path.
-      std::string SearchDir = SearchDirs[i].getDir()->getName()+"/"+Filename;
-      FE = FileMgr.getFile(SearchDir);
+      FE = FileMgr.getFile(SearchDirs[i].getDir()->getName()+"/"+Filename);
     } else {
-      FE = DoFrameworkLookup(SearchDirs[i].getDir(), Filename, FileMgr);
+      FE = DoFrameworkLookup(SearchDirs[i].getDir(), Filename);
     }
     
     if (FE) {
@@ -163,6 +173,7 @@
   if (SlashPos == std::string::npos) return 0;
   
   // TODO: Cache subframework.
+  ++NumSubFrameworkLookups;
   
   // Look up the base framework name of the ContextFileEnt.
   const std::string &ContextName = ContextFileEnt->getName();

Modified: cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=39026&r1=39025&r2=39026&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h Wed Jul 11 11:26:56 2007
@@ -120,14 +120,9 @@
   // Various statistics we track for performance analysis.
   unsigned NumIncluded;
   unsigned NumMultiIncludeFileOptzn;
+  unsigned NumFrameworkLookups, NumSubFrameworkLookups;
 public:
-  HeaderSearch(FileManager &FM) : FileMgr(FM) {
-    SystemDirIdx = 0;
-    NoCurDirSearch = false;
-
-    NumIncluded = 0;
-    NumMultiIncludeFileOptzn = 0;
-  }
+  HeaderSearch(FileManager &FM);
     
   /// SetSearchPaths - Interface for setting the file search paths.
   ///
@@ -193,6 +188,9 @@
   
   void PrintStats();
 private:
+  const FileEntry *DoFrameworkLookup(const DirectoryEntry *Dir,
+                                     const std::string &Filename);
+      
   /// getFileInfo - Return the PerFileInfo structure for the specified
   /// FileEntry.
   PerFileInfo &getFileInfo(const FileEntry *FE);





More information about the cfe-commits mailing list