r206933 - Driver: Avoid a duplicate path separator and clean up code
Reid Kleckner
reid at kleckner.net
Tue Apr 22 17:15:01 PDT 2014
Author: rnk
Date: Tue Apr 22 19:15:01 2014
New Revision: 206933
URL: http://llvm.org/viewvc/llvm-project?rev=206933&view=rev
Log:
Driver: Avoid a duplicate path separator and clean up code
Modified:
cfe/trunk/lib/Driver/WindowsToolChain.cpp
Modified: cfe/trunk/lib/Driver/WindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/WindowsToolChain.cpp?rev=206933&r1=206932&r2=206933&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/WindowsToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/WindowsToolChain.cpp Tue Apr 22 19:15:01 2014
@@ -297,17 +297,12 @@ void Windows::AddClangSystemIncludeArgs(
// Honor %INCLUDE%. It should know essential search paths with vcvarsall.bat.
if (const char *cl_include_dir = getenv("INCLUDE")) {
SmallVector<StringRef, 8> Dirs;
- StringRef(cl_include_dir).split(Dirs, ";");
- int n = 0;
- for (SmallVectorImpl<StringRef>::iterator I = Dirs.begin(), E = Dirs.end();
- I != E; ++I) {
- StringRef d = *I;
- if (d.size() == 0)
- continue;
- ++n;
- addSystemInclude(DriverArgs, CC1Args, d);
- }
- if (n) return;
+ StringRef(cl_include_dir)
+ .split(Dirs, ";", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+ for (StringRef Dir : Dirs)
+ addSystemInclude(DriverArgs, CC1Args, Dir);
+ if (!Dirs.empty())
+ return;
}
std::string VSDir;
@@ -316,12 +311,19 @@ void Windows::AddClangSystemIncludeArgs(
// 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");
- if (getWindowsSDKDir(WindowsSDKDir))
- addSystemInclude(DriverArgs, CC1Args, WindowsSDKDir + "\\include");
- else
- addSystemInclude(DriverArgs, CC1Args,
- VSDir + "\\VC\\PlatformSDK\\Include");
+ SmallString<128> P;
+ P = VSDir;
+ llvm::sys::path::append(P, "VC\\include");
+ addSystemInclude(DriverArgs, CC1Args, P.str());
+ if (getWindowsSDKDir(WindowsSDKDir)) {
+ P = WindowsSDKDir;
+ llvm::sys::path::append(P, "include");
+ addSystemInclude(DriverArgs, CC1Args, P.str());
+ } else {
+ P = VSDir;
+ llvm::sys::path::append(P, "VC\\PlatformSDK\\Include");
+ addSystemInclude(DriverArgs, CC1Args, P.str());
+ }
return;
}
More information about the cfe-commits
mailing list