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

Chandler Carruth chandlerc at gmail.com
Sun Nov 14 23:15:26 PST 2010


Author: chandlerc
Date: Mon Nov 15 01:15:26 2010
New Revision: 119131

URL: http://llvm.org/viewvc/llvm-project?rev=119131&view=rev
Log:
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.

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=119131&r1=119130&r2=119131&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Mon Nov 15 01:15:26 2010
@@ -41,13 +41,16 @@
   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 @@
   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.





More information about the cfe-commits mailing list