<div class="gmail_extra"><div class="gmail_quote">On Sat, Sep 1, 2012 at 6:33 PM, Joao Matos <span dir="ltr"><<a href="mailto:ripzonetriton@gmail.com" target="_blank" class="cremed">ripzonetriton@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: triton<br>
Date: Sat Sep 1 17:33:43 2012<br>
New Revision: 163076<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=163076&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=163076&view=rev</a><br>
Log:<br>
Refactored the Windows headers location lookup code. Expose it so standalone tools can have access to it.<br></blockquote><div><br></div><div>Please revert this. It was not reviewed prior to commit.</div><div><br></div><div>
I'm strongly opposed to arbitrarily exposing header search logic through a Util.h header in the driver without some serious thought and planning around the API. Currently the header search logic is an implementation detail of the driver. Changing that in any way is a radical departure.</div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
cfe/trunk/include/clang/Driver/Util.h<br>
cfe/trunk/lib/Driver/WindowsToolChain.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Driver/Util.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Util.h?rev=163076&r1=163075&r2=163076&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Util.h?rev=163076&r1=163075&r2=163076&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/Util.h (original)<br>
+++ cfe/trunk/include/clang/Driver/Util.h Sat Sep 1 17:33:43 2012<br>
@@ -11,6 +11,8 @@<br>
#define CLANG_DRIVER_UTIL_H_<br>
<br>
#include "clang/Basic/LLVM.h"<br>
+#include <string><br>
+#include <vector><br>
<br>
namespace clang {<br>
namespace driver {<br>
@@ -22,6 +24,9 @@<br>
/// ActionList - Type used for lists of actions.<br>
typedef SmallVector<Action*, 3> ActionList;<br>
<br>
+ /// Gets the default Windows system include directories.<br>
+ std::vector<std::string> GetWindowsSystemIncludeDirs();<br>
+<br>
} // end namespace driver<br>
} // end namespace clang<br>
<br>
<br>
Modified: cfe/trunk/lib/Driver/WindowsToolChain.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/WindowsToolChain.cpp?rev=163076&r1=163075&r2=163076&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/WindowsToolChain.cpp?rev=163076&r1=163075&r2=163076&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/WindowsToolChain.cpp (original)<br>
+++ cfe/trunk/lib/Driver/WindowsToolChain.cpp Sat Sep 1 17:33:43 2012<br>
@@ -14,6 +14,7 @@<br>
#include "clang/Driver/Compilation.h"<br>
#include "clang/Driver/Driver.h"<br>
#include "clang/Driver/Options.h"<br>
+#include "clang/Driver/Util.h"<br>
#include "clang/Basic/Version.h"<br>
#include "llvm/Support/ErrorHandling.h"<br>
#include "llvm/Support/Path.h"<br>
@@ -304,19 +305,8 @@<br>
<br>
#endif // _MSC_VER<br>
<br>
-void Windows::AddClangSystemIncludeArgs(const ArgList &DriverArgs,<br>
- ArgStringList &CC1Args) const {<br>
- if (DriverArgs.hasArg(options::OPT_nostdinc))<br>
- return;<br>
-<br>
- if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {<br>
- llvm::sys::Path P(getDriver().ResourceDir);<br>
- P.appendComponent("include");<br>
- addSystemInclude(DriverArgs, CC1Args, P.str());<br>
- }<br>
-<br>
- if (DriverArgs.hasArg(options::OPT_nostdlibinc))<br>
- return;<br>
+std::vector<std::string> clang::driver::GetWindowsSystemIncludeDirs() {<br>
+ std::vector<std::string> Paths;<br>
<br>
#ifdef _MSC_VER<br>
// Honor %INCLUDE%. It should know essential search paths with vcvarsall.bat.<br>
@@ -330,9 +320,9 @@<br>
if (d.size() == 0)<br>
continue;<br>
++n;<br>
- addSystemInclude(DriverArgs, CC1Args, d);<br>
+ Paths.push_back(d);<br>
}<br>
- if (n) return;<br>
+ if (n) return Paths;<br>
}<br>
<br>
std::string VSDir;<br>
@@ -341,25 +331,47 @@<br>
// When built with access to the proper Windows APIs, try to actually find<br>
// the correct include paths first.<br>
if (getVisualStudioDir(VSDir)) {<br>
- addSystemInclude(DriverArgs, CC1Args, VSDir + "\\VC\\include");<br>
+ Paths.push_back(VSDir + "\\VC\\include");<br>
if (getWindowsSDKDir(WindowsSDKDir))<br>
- addSystemInclude(DriverArgs, CC1Args, WindowsSDKDir + "\\include");<br>
+ Paths.push_back(WindowsSDKDir + "\\include");<br>
else<br>
- addSystemInclude(DriverArgs, CC1Args,<br>
- VSDir + "\\VC\\PlatformSDK\\Include");<br>
- return;<br>
+ Paths.push_back(VSDir + "\\VC\\PlatformSDK\\Include");<br>
+ return Paths;<br>
}<br>
#endif // _MSC_VER<br>
<br>
// As a fallback, select default install paths.<br>
- const StringRef Paths[] = {<br>
+ const StringRef FallbackPaths[] = {<br>
"C:/Program Files/Microsoft Visual Studio 10.0/VC/include",<br>
"C:/Program Files/Microsoft Visual Studio 9.0/VC/include",<br>
"C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",<br>
"C:/Program Files/Microsoft Visual Studio 8/VC/include",<br>
"C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"<br>
};<br>
- addSystemIncludes(DriverArgs, CC1Args, Paths);<br>
+<br>
+ for (unsigned i = 0; i < sizeof(FallbackPaths) / sizeof(FallbackPaths[0]); ++i)<br>
+ Paths.push_back(Paths[i]);<br>
+<br>
+ return Paths;<br>
+}<br>
+<br>
+void Windows::AddClangSystemIncludeArgs(const ArgList &DriverArgs,<br>
+ ArgStringList &CC1Args) const {<br>
+ if (DriverArgs.hasArg(options::OPT_nostdinc))<br>
+ return;<br>
+<br>
+ if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {<br>
+ llvm::sys::Path P(getDriver().ResourceDir);<br>
+ P.appendComponent("include");<br>
+ addSystemInclude(DriverArgs, CC1Args, P.str());<br>
+ }<br>
+<br>
+ if (DriverArgs.hasArg(options::OPT_nostdlibinc))<br>
+ return;<br>
+<br>
+ std::vector<std::string> Paths = driver::GetWindowsSystemIncludeDirs();<br>
+ for (size_t i = 0; i < Paths.size(); ++i)<br>
+ addSystemInclude(DriverArgs, CC1Args, Paths[i]);<br>
}<br>
<br>
void Windows::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" class="cremed">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>