[cfe-commits] r45090 - in /cfe/trunk: Driver/clang.cpp include/clang/Lex/DirectoryLookup.h

Chris Lattner sabre at nondot.org
Sun Dec 16 22:44:30 PST 2007


Author: lattner
Date: Mon Dec 17 00:44:29 2007
New Revision: 45090

URL: http://llvm.org/viewvc/llvm-project?rev=45090&view=rev
Log:
teach RemoveDuplicates about header maps.

Modified:
    cfe/trunk/Driver/clang.cpp
    cfe/trunk/include/clang/Lex/DirectoryLookup.h

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=45090&r1=45089&r2=45090&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Mon Dec 17 00:44:29 2007
@@ -676,15 +676,30 @@
 /// search list, remove the later (dead) ones.
 static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList) {
   llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs;
+  llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps;
   for (unsigned i = 0; i != SearchList.size(); ++i) {
-    // If this isn't the first time we've seen this dir, remove it.
-    if (!SeenDirs.insert(SearchList[i].getDir())) {
+    if (SearchList[i].isNormalDir()) {
+      // If this isn't the first time we've seen this dir, remove it.
+      if (SeenDirs.insert(SearchList[i].getDir()))
+        continue;
+      
+      if (Verbose)
+        fprintf(stderr, "ignoring duplicate directory \"%s\"\n",
+                SearchList[i].getDir()->getName());
+    } else {
+      assert(SearchList[i].isHeaderMap() && "Not a headermap or normal dir?");
+      // If this isn't the first time we've seen this headermap, remove it.
+      if (SeenHeaderMaps.insert(SearchList[i].getHeaderMap()))
+        continue;
+      
       if (Verbose)
         fprintf(stderr, "ignoring duplicate directory \"%s\"\n",
                 SearchList[i].getDir()->getName());
-      SearchList.erase(SearchList.begin()+i);
-      --i;
     }
+    
+    // This is reached if the current entry is a duplicate.
+    SearchList.erase(SearchList.begin()+i);
+    --i;
   }
 }
 

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

==============================================================================
--- cfe/trunk/include/clang/Lex/DirectoryLookup.h (original)
+++ cfe/trunk/include/clang/Lex/DirectoryLookup.h Mon Dec 17 00:44:29 2007
@@ -53,16 +53,16 @@
   ///
   bool Framework : 1;
   
-  /// isHeaderMap - True if the HeaderMap field is valid, false if the Dir field
+  /// IsHeaderMap - True if the HeaderMap field is valid, false if the Dir field
   /// is valid.
-  bool isHeaderMap : 1;
+  bool IsHeaderMap : 1;
 public:
   /// DirectoryLookup ctor - Note that this ctor *does not take ownership* of
   /// 'dir'.
   DirectoryLookup(const DirectoryEntry *dir, DirType DT, bool isUser,
                   bool isFramework)
     : DirCharacteristic(DT), UserSupplied(isUser),
-      Framework(isFramework), isHeaderMap(false) {
+      Framework(isFramework), IsHeaderMap(false) {
     u.Dir = dir; 
   }
   
@@ -70,17 +70,23 @@
   /// 'map'.
   DirectoryLookup(const HeaderMap *map, DirType DT, bool isUser, bool isFWork)
     : DirCharacteristic(DT), UserSupplied(isUser), Framework(isFWork), 
-      isHeaderMap(true) {
+      IsHeaderMap(true) {
     u.Map = map; 
   }
   
   /// getDir - Return the directory that this entry refers to.
   ///
-  const DirectoryEntry *getDir() const { return !isHeaderMap ? u.Dir : 0; }
+  const DirectoryEntry *getDir() const { return !IsHeaderMap ? u.Dir : 0; }
   
   /// getHeaderMap - Return the directory that this entry refers to.
   ///
-  const HeaderMap *getHeaderMap() const { return isHeaderMap ? u.Map : 0; }
+  const HeaderMap *getHeaderMap() const { return IsHeaderMap ? u.Map : 0; }
+
+  /// isNormalDir - Return true if this is a normal directory, not a header map.
+  bool isNormalDir() const { return !IsHeaderMap; }
+  
+  /// isHeaderMap - Return true if this is a header map, not a normal directory.
+  bool isHeaderMap() const { return IsHeaderMap; }
   
   /// DirCharacteristic - The type of directory this is, one of the DirType enum
   /// values.





More information about the cfe-commits mailing list