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

Nico Weber nicolasweber at gmx.de
Mon May 23 21:31:14 PDT 2011


Author: nico
Date: Mon May 23 23:31:14 2011
New Revision: 131955

URL: http://llvm.org/viewvc/llvm-project?rev=131955&view=rev
Log:
Make it possible for external tools to distinguish between paths that come from -I and paths that come from -system. Patch from Paul Holden!

Modified:
    cfe/trunk/include/clang/Lex/HeaderSearch.h
    cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
    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=131955&r1=131954&r2=131955&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Mon May 23 23:31:14 2011
@@ -105,11 +105,12 @@
   FileManager &FileMgr;
   /// #include search path information.  Requests for #include "x" search the
   /// directory of the #including file first, then each directory in SearchDirs
-  /// consequtively. Requests for <x> search the current dir first, then each
-  /// directory in SearchDirs, starting at SystemDirIdx, consequtively.  If
+  /// consecutively. Requests for <x> search the current dir first, then each
+  /// directory in SearchDirs, starting at AngledDirIdx, consecutively.  If
   /// NoCurDirSearch is true, then the check for the file in the current
   /// directory is suppressed.
   std::vector<DirectoryLookup> SearchDirs;
+  unsigned AngledDirIdx;
   unsigned SystemDirIdx;
   bool NoCurDirSearch;
 
@@ -160,8 +161,12 @@
   /// SetSearchPaths - Interface for setting the file search paths.
   ///
   void SetSearchPaths(const std::vector<DirectoryLookup> &dirs,
-                      unsigned systemDirIdx, bool noCurDirSearch) {
+                      unsigned angledDirIdx, unsigned systemDirIdx,
+                      bool noCurDirSearch) {
+    assert(angledDirIdx <= systemDirIdx && systemDirIdx <= dirs.size() &&
+        "Directory indicies are unordered");
     SearchDirs = dirs;
+    AngledDirIdx = angledDirIdx;
     SystemDirIdx = systemDirIdx;
     NoCurDirSearch = noCurDirSearch;
     //LookupFileCache.clear();
@@ -298,6 +303,20 @@
   search_dir_iterator search_dir_end() const { return SearchDirs.end(); }
   unsigned search_dir_size() const { return SearchDirs.size(); }
 
+  search_dir_iterator quoted_dir_begin() const {
+    return SearchDirs.begin();
+  }
+  search_dir_iterator quoted_dir_end() const {
+    return SearchDirs.begin() + AngledDirIdx;
+  }
+
+  search_dir_iterator angled_dir_begin() const {
+    return SearchDirs.begin() + AngledDirIdx;
+  }
+  search_dir_iterator angled_dir_end() const {
+    return SearchDirs.begin() + SystemDirIdx;
+  }
+
   search_dir_iterator system_dir_begin() const {
     return SearchDirs.begin() + SystemDirIdx;
   }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=131955&r1=131954&r2=131955&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Mon May 23 23:31:14 2011
@@ -1008,6 +1008,8 @@
     if (it->first == Angled)
       SearchList.push_back(it->second);
   }
+  RemoveDuplicates(SearchList, quoted, Verbose);
+  unsigned angled = SearchList.size();
 
   for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
        it != ie; ++it) {
@@ -1021,10 +1023,10 @@
       SearchList.push_back(it->second);
   }
 
-  RemoveDuplicates(SearchList, quoted, Verbose);
+  RemoveDuplicates(SearchList, angled, Verbose);
 
   bool DontSearchCurDir = false;  // TODO: set to true if -I- is set?
-  Headers.SetSearchPaths(SearchList, quoted, DontSearchCurDir);
+  Headers.SetSearchPaths(SearchList, quoted, angled, DontSearchCurDir);
 
   // If verbose, print the list of directories that will be searched.
   if (Verbose) {

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=131955&r1=131954&r2=131955&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Mon May 23 23:31:14 2011
@@ -37,6 +37,7 @@
 
 HeaderSearch::HeaderSearch(FileManager &FM)
     : FileMgr(FM), FrameworkMap(64) {
+  AngledDirIdx = 0;
   SystemDirIdx = 0;
   NoCurDirSearch = false;
 
@@ -317,7 +318,7 @@
   CurDir = 0;
 
   // If this is a system #include, ignore the user #include locs.
-  unsigned i = isAngled ? SystemDirIdx : 0;
+  unsigned i = isAngled ? AngledDirIdx : 0;
 
   // If this is a #include_next request, start searching after the directory the
   // file was found in.





More information about the cfe-commits mailing list