[cfe-commits] r119099 - /cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
Chris Lattner
clattner at apple.com
Mon Nov 15 11:03:37 PST 2010
On Nov 14, 2010, at 4:48 PM, Chandler Carruth wrote:
> Author: chandlerc
> Date: Sun Nov 14 18:48:13 2010
> New Revision: 119099
>
> URL: http://llvm.org/viewvc/llvm-project?rev=119099&view=rev
> Log:
> Switch the sysroot logic to use the Path interface, resolving a FIXME and
> making the code less gross.
Hi Chandler,
sys::Path always makes me scared. Are there any build time performance regressions due to this patch? Among other things, it seems that we really want a "sys::Path::isRootDirectory()" method instead of constructing and comparing a new sys::Path for the root directory all the time.
-Chris
>
> 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=119099&r1=119098&r2=119099&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Sun Nov 14 18:48:13 2010
> @@ -41,7 +41,7 @@
> std::vector<DirectoryLookup> IncludeGroup[4];
> HeaderSearch& Headers;
> bool Verbose;
> - std::string isysroot;
> + llvm::sys::Path isysroot;
>
> public:
>
> @@ -103,14 +103,15 @@
>
> // Compute the actual path, taking into consideration -isysroot.
> llvm::SmallString<256> MappedPathStorage;
> - llvm::StringRef MappedPath = Path.toStringRef(MappedPathStorage);
> + llvm::StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
> + llvm::sys::Path MappedPath(MappedPathStr);
>
> // Handle isysroot.
> - 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 + Path).toStringRef(MappedPathStorage);
> + 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);
> }
>
> // Compute the DirectoryLookup type.
> @@ -124,7 +125,7 @@
>
>
> // If the directory exists, add it.
> - if (const DirectoryEntry *DE = FM.getDirectory(MappedPath, FSOpts)) {
> + if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr, FSOpts)) {
> IncludeGroup[Group].push_back(DirectoryLookup(DE, Type, isUserSupplied,
> isFramework));
> return;
> @@ -133,7 +134,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, FSOpts)) {
> + if (const FileEntry *FE = FM.getFile(MappedPathStr, 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));
> @@ -143,7 +144,8 @@
> }
>
> if (Verbose)
> - llvm::errs() << "ignoring nonexistent directory \"" << MappedPath << "\"\n";
> + llvm::errs() << "ignoring nonexistent directory \""
> + << MappedPathStr << "\"\n";
> }
>
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list