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

Chandler Carruth chandlerc at gmail.com
Sun Nov 14 16:05:18 PST 2010


Author: chandlerc
Date: Sun Nov 14 18:05:18 2010
New Revision: 119095

URL: http://llvm.org/viewvc/llvm-project?rev=119095&view=rev
Log:
Make sysroot only apply to baked in paths which start with a '/'.

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=119095&r1=119094&r2=119095&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Sun Nov 14 18:05:18 2010
@@ -102,19 +102,17 @@
   const FileSystemOptions &FSOpts = Headers.getFileSystemOpts();
 
   // Compute the actual path, taking into consideration -isysroot.
-  llvm::SmallString<256> MappedPathStr;
-  llvm::raw_svector_ostream MappedPath(MappedPathStr);
+  llvm::SmallString<256> MappedPathStorage;
+  llvm::StringRef MappedPath = Path.toStringRef(MappedPathStorage);
 
   // Handle isysroot.
-  if (Group == System && !IgnoreSysRoot) {
+  if (Group == System && !IgnoreSysRoot && MappedPath[0] == '/') {
     // FIXME: Portability.  This should be a sys::Path interface, this doesn't
     // handle things like C:\ right, nor win32 \\network\device\blah.
     if (isysroot.size() != 1 || isysroot[0] != '/') // Add isysroot if present.
-      MappedPath << isysroot;
+      MappedPath = (isysroot + Path).toStringRef(MappedPathStorage);
   }
 
-  Path.print(MappedPath);
-
   // Compute the DirectoryLookup type.
   SrcMgr::CharacteristicKind Type;
   if (Group == Quoted || Group == Angled)
@@ -126,7 +124,7 @@
 
 
   // If the directory exists, add it.
-  if (const DirectoryEntry *DE = FM.getDirectory(MappedPath.str(), FSOpts)) {
+  if (const DirectoryEntry *DE = FM.getDirectory(MappedPath, FSOpts)) {
     IncludeGroup[Group].push_back(DirectoryLookup(DE, Type, isUserSupplied,
                                                   isFramework));
     return;
@@ -135,7 +133,7 @@
   // Check to see if this is an apple-style headermap (which are not allowed to
   // be frameworks).
   if (!isFramework) {
-    if (const FileEntry *FE = FM.getFile(MappedPath.str(), FSOpts)) {
+    if (const FileEntry *FE = FM.getFile(MappedPath, FSOpts)) {
       if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) {
         // It is a headermap, add it to the search path.
         IncludeGroup[Group].push_back(DirectoryLookup(HM, Type,isUserSupplied));
@@ -145,8 +143,7 @@
   }
 
   if (Verbose)
-    llvm::errs() << "ignoring nonexistent directory \""
-                 << MappedPath.str() << "\"\n";
+    llvm::errs() << "ignoring nonexistent directory \"" << MappedPath << "\"\n";
 }
 
 





More information about the cfe-commits mailing list