aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-11-06 07:31:36 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-11-06 07:31:36 +0000
commit5ffa3eed8b1ca69e1638cffbee2e464276a1ce06 (patch)
tree460b6b9b135e5a81ba6eef835f95e2dbe737c5b3
parent5b898cc987a0717538caa161a1c25343c3b6cd6f (diff)
Start pruning down the set of flags passed to CC1 for header search.
This cleans up the CC1 invocations, and reduces the overhead there. We're still hammering the filesystem looking for the C++ standard libraries though. The only reservation I have about this policy is the case of virtualized files inside of CC1, but it's not clear what the best way to solve that is. The Driver consistently queries the actual filesystem to make its decisions. Changing that would be a very large undertaking. It might be worthwhile, but it's not an immediate goal. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143864 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Driver/ToolChains.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 3d4f12cb86..6d31e46204 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -56,6 +56,10 @@ using namespace clang;
/// \brief Utility function to add a system include directory to CC1 arguments.
static void addSystemInclude(const ArgList &DriverArgs, ArgStringList &CC1Args,
const Twine &Path) {
+ // Prune out non-existent directories to minimize the number of flags.
+ if (!llvm::sys::fs::exists(Path))
+ return;
+
CC1Args.push_back("-internal-isystem");
CC1Args.push_back(DriverArgs.MakeArgString(Path));
}
@@ -70,6 +74,10 @@ static void addSystemInclude(const ArgList &DriverArgs, ArgStringList &CC1Args,
/// classification.
static void addExternCSystemInclude(const ArgList &DriverArgs,
ArgStringList &CC1Args, const Twine &Path) {
+ // Prune out non-existent directories to minimize the number of flags.
+ if (!llvm::sys::fs::exists(Path))
+ return;
+
CC1Args.push_back("-internal-externc-isystem");
CC1Args.push_back(DriverArgs.MakeArgString(Path));
}
@@ -80,6 +88,10 @@ static void addSystemIncludes(const ArgList &DriverArgs,
ArrayRef<StringRef> Paths) {
for (ArrayRef<StringRef>::iterator I = Paths.begin(), E = Paths.end();
I != E; ++I) {
+ // Prune out non-existent directories to minimize the number of flags.
+ if (!llvm::sys::fs::exists(*I))
+ continue;
+
CC1Args.push_back("-internal-isystem");
CC1Args.push_back(DriverArgs.MakeArgString(*I));
}