aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/WindowsToolChain.cpp
diff options
context:
space:
mode:
authorJoao Matos <ripzonetriton@gmail.com>2012-09-01 22:33:43 +0000
committerJoao Matos <ripzonetriton@gmail.com>2012-09-01 22:33:43 +0000
commit601944aeaf1369f92b90e5c279c22f557eb87cdb (patch)
tree98a2bbbddfa7a9b3975e3ce74c59a9f43f158b9f /lib/Driver/WindowsToolChain.cpp
parent9eb214a691663a04ee61197e7d605128c85e09f7 (diff)
Refactored the Windows headers location lookup code. Expose it so standalone tools can have access to it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163076 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/WindowsToolChain.cpp')
-rw-r--r--lib/Driver/WindowsToolChain.cpp56
1 files changed, 34 insertions, 22 deletions
diff --git a/lib/Driver/WindowsToolChain.cpp b/lib/Driver/WindowsToolChain.cpp
index 6827034ef4..5fba6b48b0 100644
--- a/lib/Driver/WindowsToolChain.cpp
+++ b/lib/Driver/WindowsToolChain.cpp
@@ -14,6 +14,7 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
+#include "clang/Driver/Util.h"
#include "clang/Basic/Version.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h"
@@ -304,19 +305,8 @@ static bool getVisualStudioDir(std::string &path) {
#endif // _MSC_VER
-void Windows::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
- ArgStringList &CC1Args) const {
- if (DriverArgs.hasArg(options::OPT_nostdinc))
- return;
-
- if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
- llvm::sys::Path P(getDriver().ResourceDir);
- P.appendComponent("include");
- addSystemInclude(DriverArgs, CC1Args, P.str());
- }
-
- if (DriverArgs.hasArg(options::OPT_nostdlibinc))
- return;
+std::vector<std::string> clang::driver::GetWindowsSystemIncludeDirs() {
+ std::vector<std::string> Paths;
#ifdef _MSC_VER
// Honor %INCLUDE%. It should know essential search paths with vcvarsall.bat.
@@ -330,9 +320,9 @@ void Windows::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
if (d.size() == 0)
continue;
++n;
- addSystemInclude(DriverArgs, CC1Args, d);
+ Paths.push_back(d);
}
- if (n) return;
+ if (n) return Paths;
}
std::string VSDir;
@@ -341,25 +331,47 @@ void Windows::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
// When built with access to the proper Windows APIs, try to actually find
// the correct include paths first.
if (getVisualStudioDir(VSDir)) {
- addSystemInclude(DriverArgs, CC1Args, VSDir + "\\VC\\include");
+ Paths.push_back(VSDir + "\\VC\\include");
if (getWindowsSDKDir(WindowsSDKDir))
- addSystemInclude(DriverArgs, CC1Args, WindowsSDKDir + "\\include");
+ Paths.push_back(WindowsSDKDir + "\\include");
else
- addSystemInclude(DriverArgs, CC1Args,
- VSDir + "\\VC\\PlatformSDK\\Include");
- return;
+ Paths.push_back(VSDir + "\\VC\\PlatformSDK\\Include");
+ return Paths;
}
#endif // _MSC_VER
// As a fallback, select default install paths.
- const StringRef Paths[] = {
+ const StringRef FallbackPaths[] = {
"C:/Program Files/Microsoft Visual Studio 10.0/VC/include",
"C:/Program Files/Microsoft Visual Studio 9.0/VC/include",
"C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",
"C:/Program Files/Microsoft Visual Studio 8/VC/include",
"C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"
};
- addSystemIncludes(DriverArgs, CC1Args, Paths);
+
+ for (unsigned i = 0; i < sizeof(FallbackPaths) / sizeof(FallbackPaths[0]); ++i)
+ Paths.push_back(Paths[i]);
+
+ return Paths;
+}
+
+void Windows::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
+ ArgStringList &CC1Args) const {
+ if (DriverArgs.hasArg(options::OPT_nostdinc))
+ return;
+
+ if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+ llvm::sys::Path P(getDriver().ResourceDir);
+ P.appendComponent("include");
+ addSystemInclude(DriverArgs, CC1Args, P.str());
+ }
+
+ if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+ return;
+
+ std::vector<std::string> Paths = driver::GetWindowsSystemIncludeDirs();
+ for (size_t i = 0; i < Paths.size(); ++i)
+ addSystemInclude(DriverArgs, CC1Args, Paths[i]);
}
void Windows::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,