summaryrefslogtreecommitdiffstats
path: root/clang/Driver/clang.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-17 05:59:27 +0000
committerChris Lattner <sabre@nondot.org>2007-12-17 05:59:27 +0000
commit899ff4a26df65cfeb07d56ef47efe6a6bb2af810 (patch)
treef8b934cb7072e1385eaeb83dea83d5f2e3545238 /clang/Driver/clang.cpp
parent28c91c5f3519317754f593cffa119be258ce85c1 (diff)
downloadbcm5719-llvm-899ff4a26df65cfeb07d56ef47efe6a6bb2af810.tar.gz
bcm5719-llvm-899ff4a26df65cfeb07d56ef47efe6a6bb2af810.zip
rearrange some code and make it more efficient.
llvm-svn: 45087
Diffstat (limited to 'clang/Driver/clang.cpp')
-rw-r--r--clang/Driver/clang.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index 76080f804df..095eaaa6ca0 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/Driver/clang.cpp
@@ -616,24 +616,20 @@ static void AddPath(const std::string &Path, IncludeDirGroup Group,
bool isFramework, FileManager &FM) {
assert(!Path.empty() && "can't handle empty path here");
- const DirectoryEntry *DE;
- if (Group == System) {
- if (isysroot != "/")
- DE = FM.getDirectory(isysroot + "/" + Path);
- else if (Path[0] == '/')
- DE = FM.getDirectory(Path);
- else
- DE = FM.getDirectory("/" + Path);
- } else
- DE = FM.getDirectory(Path);
+ // Compute the actual path, taking into consideration -isysroot.
+ llvm::SmallString<256> MappedPath;
- if (DE == 0) {
- if (Verbose)
- fprintf(stderr, "ignoring nonexistent directory \"%s\"\n",
- Path.c_str());
- return;
+ // Handle isysroot.
+ if (Group == System) {
+ if (isysroot.size() != 1 || isysroot[0] != '/') // Add isysroot if present.
+ MappedPath.append(isysroot.begin(), isysroot.end());
+ if (Path[0] != '/') // If in the system group, add a /.
+ MappedPath.push_back('/');
}
+ MappedPath.append(Path.begin(), Path.end());
+
+ // Compute the DirectoryLookup type.
DirectoryLookup::DirType Type;
if (Group == Quoted || Group == Angled)
Type = DirectoryLookup::NormalHeaderDir;
@@ -642,8 +638,18 @@ static void AddPath(const std::string &Path, IncludeDirGroup Group,
else
Type = DirectoryLookup::ExternCSystemHeaderDir;
- IncludeGroup[Group].push_back(DirectoryLookup(DE, Type, isUserSupplied,
- isFramework));
+
+ // If the directory exists, add it.
+ if (const DirectoryEntry *DE = FM.getDirectory(&MappedPath[0],
+ &MappedPath[0]+
+ MappedPath.size())) {
+ IncludeGroup[Group].push_back(DirectoryLookup(DE, Type, isUserSupplied,
+ isFramework));
+ return;
+ }
+
+ if (Verbose)
+ fprintf(stderr, "ignoring nonexistent directory \"%s\"\n", Path.c_str());
}
/// RemoveDuplicates - If there are duplicate directory entries in the specified
OpenPOWER on IntegriCloud