Make it possible for external tools to distinguish between paths that come from -I and paths that come from -system. Patch from Paul Holden!

llvm-svn: 131955
This commit is contained in:
Nico Weber 2011-05-24 04:31:14 +00:00
parent 0130027dec
commit 3b1d1217f8
3 changed files with 28 additions and 6 deletions

View File

@ -105,11 +105,12 @@ class HeaderSearch {
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 @@ public:
/// 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 @@ public:
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;
}

View File

@ -1008,6 +1008,8 @@ void InitHeaderSearch::Realize(const LangOptions &Lang) {
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 @@ void InitHeaderSearch::Realize(const LangOptions &Lang) {
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) {

View File

@ -37,6 +37,7 @@ ExternalHeaderFileInfoSource::~ExternalHeaderFileInfoSource() {}
HeaderSearch::HeaderSearch(FileManager &FM)
: FileMgr(FM), FrameworkMap(64) {
AngledDirIdx = 0;
SystemDirIdx = 0;
NoCurDirSearch = false;
@ -317,7 +318,7 @@ const FileEntry *HeaderSearch::LookupFile(
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.