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

Daniel Dunbar daniel at zuster.org
Thu Apr 5 10:09:40 PDT 2012


Author: ddunbar
Date: Thu Apr  5 12:09:40 2012
New Revision: 154104

URL: http://llvm.org/viewvc/llvm-project?rev=154104&view=rev
Log:
[Lex] HeaderSearch: Introduce a FrameworkCacheEntry structure to hold the FrameworkMap items.
 - No functionality change.

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

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=154104&r1=154103&r2=154104&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Thu Apr  5 12:09:40 2012
@@ -120,6 +120,12 @@
 /// HeaderSearch - This class encapsulates the information needed to find the
 /// file referenced by a #include or #include_next, (sub-)framework lookup, etc.
 class HeaderSearch {
+  /// This structure is used to record entries in our framework cache.
+  struct FrameworkCacheEntry {
+    /// The directory entry which should be used for the cached framework.
+    const DirectoryEntry *Directory;
+  };
+
   FileManager &FileMgr;
   DiagnosticsEngine &Diags;
   /// #include search path information.  Requests for #include "x" search the
@@ -152,8 +158,7 @@
 
   /// FrameworkMap - This is a collection mapping a framework or subframework
   /// name like "Carbon" to the Carbon.framework directory.
-  llvm::StringMap<const DirectoryEntry *, llvm::BumpPtrAllocator>
-    FrameworkMap;
+  llvm::StringMap<FrameworkCacheEntry, llvm::BumpPtrAllocator> FrameworkMap;
 
   /// IncludeAliases - maps include file names (including the quotes or
   /// angle brackets) to other include file names.  This is used to support the
@@ -331,7 +336,7 @@
   /// LookupFrameworkCache - Look up the specified framework name in our
   /// framework cache, returning the DirectoryEntry it is in if we know,
   /// otherwise, return null.
-  const DirectoryEntry *&LookupFrameworkCache(StringRef FWName) {
+  FrameworkCacheEntry &LookupFrameworkCache(StringRef FWName) {
     return FrameworkMap.GetOrCreateValue(FWName).getValue();
   }
 

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=154104&r1=154103&r2=154104&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Apr  5 12:09:40 2012
@@ -275,12 +275,12 @@
   if (SlashPos == StringRef::npos) return 0;
 
   // Find out if this is the home for the specified framework, by checking
-  // HeaderSearch.  Possible answer are yes/no and unknown.
-  const DirectoryEntry *&FrameworkDirCache =
+  // HeaderSearch.  Possible answers are yes/no and unknown.
+  HeaderSearch::FrameworkCacheEntry &CacheEntry =
     HS.LookupFrameworkCache(Filename.substr(0, SlashPos));
 
   // If it is known and in some other directory, fail.
-  if (FrameworkDirCache && FrameworkDirCache != getFrameworkDir())
+  if (CacheEntry.Directory && CacheEntry.Directory != getFrameworkDir())
     return 0;
 
   // Otherwise, construct the path to this framework dir.
@@ -298,9 +298,8 @@
   // FrameworkName = "/System/Library/Frameworks/Cocoa.framework/"
   FrameworkName += ".framework/";
 
-  // If the cache entry is still unresolved, query to see if the cache entry is
-  // still unresolved.  If so, check its existence now.
-  if (FrameworkDirCache == 0) {
+  // If the cache entry was unresolved, populate it now.
+  if (CacheEntry.Directory == 0) {
     HS.IncrementFrameworkLookupCount();
 
     // If the framework dir doesn't exist, we fail.
@@ -310,7 +309,7 @@
 
     // Otherwise, if it does, remember that this is the right direntry for this
     // framework.
-    FrameworkDirCache = getFrameworkDir();
+    CacheEntry.Directory = getFrameworkDir();
   }
 
   if (RelativePath != NULL) {
@@ -561,26 +560,25 @@
        FrameworkPos[DotFrameworkLen] != '\\'))
     return 0;
 
-  SmallString<1024> FrameworkName(ContextName,
-                                        FrameworkPos+DotFrameworkLen+1);
+  SmallString<1024> FrameworkName(ContextName, FrameworkPos+DotFrameworkLen+1);
 
   // Append Frameworks/HIToolbox.framework/
   FrameworkName += "Frameworks/";
   FrameworkName.append(Filename.begin(), Filename.begin()+SlashPos);
   FrameworkName += ".framework/";
 
-  llvm::StringMapEntry<const DirectoryEntry *> &CacheLookup =
+  llvm::StringMapEntry<FrameworkCacheEntry> &CacheLookup =
     FrameworkMap.GetOrCreateValue(Filename.substr(0, SlashPos));
 
   // Some other location?
-  if (CacheLookup.getValue() &&
+  if (CacheLookup.getValue().Directory &&
       CacheLookup.getKeyLength() == FrameworkName.size() &&
       memcmp(CacheLookup.getKeyData(), &FrameworkName[0],
              CacheLookup.getKeyLength()) != 0)
     return 0;
 
   // Cache subframework.
-  if (CacheLookup.getValue() == 0) {
+  if (CacheLookup.getValue().Directory == 0) {
     ++NumSubFrameworkLookups;
 
     // If the framework dir doesn't exist, we fail.
@@ -589,7 +587,7 @@
 
     // Otherwise, if it does, remember that this is the right direntry for this
     // framework.
-    CacheLookup.setValue(Dir);
+    CacheLookup.getValue().Directory = Dir;
   }
 
   const FileEntry *FE = 0;





More information about the cfe-commits mailing list