[cfe-commits] r141565 - /cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Chad Rosier mcrosier at apple.com
Mon Oct 10 11:44:24 PDT 2011


Author: mcrosier
Date: Mon Oct 10 13:44:24 2011
New Revision: 141565

URL: http://llvm.org/viewvc/llvm-project?rev=141565&view=rev
Log:
When an included non-system directory duplicates a system directory the clang 
frontend removes the non-system directory to maintain gcc compatibility.  When
this happens NumAngled needs to be updated.
PR11097

Modified:
    cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=141565&r1=141564&r2=141565&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Mon Oct 10 13:44:24 2011
@@ -968,12 +968,14 @@
 }
 
 /// RemoveDuplicates - If there are duplicate directory entries in the specified
-/// search list, remove the later (dead) ones.
-static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
-                             unsigned First, bool Verbose) {
+/// search list, remove the later (dead) ones.  Returns the number of non-system
+/// headers removed, which is used to update NumAngled.
+static unsigned RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
+                                 unsigned First, bool Verbose) {
   llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs;
   llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs;
   llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps;
+  unsigned NonSystemRemoved = 0;
   for (unsigned i = First; i != SearchList.size(); ++i) {
     unsigned DirToRemove = i;
 
@@ -1040,12 +1042,15 @@
         llvm::errs() << "  as it is a non-system directory that duplicates "
                      << "a system directory\n";
     }
+    if (DirToRemove != i)
+      ++NonSystemRemoved;
 
     // This is reached if the current entry is a duplicate.  Remove the
     // DirToRemove (usually the current dir).
     SearchList.erase(SearchList.begin()+DirToRemove);
     --i;
   }
+  return NonSystemRemoved;
 }
 
 
@@ -1092,7 +1097,8 @@
   // Remove duplicates across both the Angled and System directories.  GCC does
   // this and failing to remove duplicates across these two groups breaks
   // #include_next.
-  RemoveDuplicates(SearchList, NumQuoted, Verbose);
+  unsigned NonSystemRemoved = RemoveDuplicates(SearchList, NumQuoted, Verbose);
+  NumAngled -= NonSystemRemoved;
 
   bool DontSearchCurDir = false;  // TODO: set to true if -I- is set?
   Headers.SetSearchPaths(SearchList, NumQuoted, NumAngled, DontSearchCurDir);





More information about the cfe-commits mailing list