diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-11-15 07:15:26 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-11-15 07:15:26 +0000 |
commit | eb84200747cb8c69be69bf2bc6b3725063697f3a (patch) | |
tree | 4c329c576437d38831d530008b117ca89d09cf30 /clang/lib/Frontend/InitHeaderSearch.cpp | |
parent | 578c765fc85d6d303950b8c650aea39b44223dfd (diff) | |
download | bcm5719-llvm-eb84200747cb8c69be69bf2bc6b3725063697f3a.tar.gz bcm5719-llvm-eb84200747cb8c69be69bf2bc6b3725063697f3a.zip |
Clean up some names and fix the handling of default sysroots on Windows and
other platforms where the textual default of '/' isn't the system's root
directory. We should probably still make the textual default platform specific,
but this should avoid the particularly bad problem with the previous state: we
applied a sysroot of '/' to '/usr/local/google' which added
'//usr/local/include' to the windows header search path, a share on another
machine named 'usr'. Oops.
llvm-svn: 119131
Diffstat (limited to 'clang/lib/Frontend/InitHeaderSearch.cpp')
-rw-r--r-- | clang/lib/Frontend/InitHeaderSearch.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp index 492dff84eb0..733adbf8b92 100644 --- a/clang/lib/Frontend/InitHeaderSearch.cpp +++ b/clang/lib/Frontend/InitHeaderSearch.cpp @@ -41,13 +41,16 @@ class InitHeaderSearch { std::vector<DirectoryLookup> IncludeGroup[4]; HeaderSearch& Headers; bool Verbose; - llvm::sys::Path isysroot; + llvm::sys::Path IncludeSysroot; public: - InitHeaderSearch(HeaderSearch &HS, - bool verbose = false, const std::string &iSysroot = "") - : Headers(HS), Verbose(verbose), isysroot(iSysroot) {} + InitHeaderSearch(HeaderSearch &HS, bool verbose, llvm::StringRef sysroot) + : Headers(HS), Verbose(verbose), + IncludeSysroot((sysroot.empty() || sysroot == "/") ? + llvm::sys::Path::GetRootDirectory() : + llvm::sys::Path(sysroot)) { + } /// AddPath - Add the specified path to the specified group list. void AddPath(const llvm::Twine &Path, IncludeDirGroup Group, @@ -107,11 +110,11 @@ void InitHeaderSearch::AddPath(const llvm::Twine &Path, llvm::sys::Path MappedPath(MappedPathStr); // Handle isysroot. - if (Group == System && !IgnoreSysRoot && MappedPath.isAbsolute()) { - // Prepend isysroot if present. - if (isysroot.isValid() && isysroot.isAbsolute() && - isysroot != llvm::sys::Path::GetRootDirectory()) - MappedPathStr = (isysroot.str() + Path).toStringRef(MappedPathStorage); + if (Group == System && !IgnoreSysRoot && MappedPath.isAbsolute() && + IncludeSysroot.isValid() && IncludeSysroot.isAbsolute() && + IncludeSysroot != llvm::sys::Path::GetRootDirectory()) { + MappedPathStr = + (IncludeSysroot.str() + Path).toStringRef(MappedPathStorage); } // Compute the DirectoryLookup type. |