Updated patch attached. It is much simpler now that we have a resource dir :-)
One thing that looks a bit of a hack in the patch is to use <resource
dir>../../../<user specified directory>.
Other options I considered:
*) Using just <resource dir>/<user specified directory> . The problem
is that libstdc++ will not be installed under lib/clang/<version>. The
user would always have to use something like
--cxx-include-root=../../../foo/bar
*) Change the resource dir to point to the directory where clang was
installed. It would be easy for the current user to append
lib/clang/<version> to it.
Cheers,
--
Rafael Ávila de Espíndola
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
index 9555125..849c337 100644
--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -42,12 +42,15 @@ class InitHeaderSearch {
HeaderSearch& Headers;
bool Verbose;
std::string isysroot;
+ std::string ResourceDir;
public:
InitHeaderSearch(HeaderSearch &HS,
- bool verbose = false, const std::string &iSysroot = "")
- : Headers(HS), Verbose(verbose), isysroot(iSysroot) {}
+ const std::string &resourceDir, bool verbose = false,
+ const std::string &iSysroot = "")
+ : Headers(HS), Verbose(verbose), isysroot(iSysroot),
+ ResourceDir(resourceDir) {}
/// AddPath - Add the specified path to the specified group list.
void AddPath(const llvm::Twine &Path, IncludeDirGroup Group,
@@ -442,6 +445,10 @@ void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths(const llvm::Triple &tripl
llvm::Triple::OSType os = triple.getOS();
llvm::StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT);
if (CxxIncludeRoot != "") {
+ // ResourceDir is of the form .../lib/clang/<version>
+ if (!llvm::sys::Path::isAbsolute(CxxIncludeRoot.data(),
+ CxxIncludeRoot.size()))
+ CxxIncludeRoot = ResourceDir + "/../../../" + CxxIncludeRoot.str();
llvm::StringRef CxxIncludeArch(CXX_INCLUDE_ARCH);
if (CxxIncludeArch == "")
AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str().c_str(),
@@ -713,7 +720,7 @@ void clang::ApplyHeaderSearchOptions(HeaderSearch &HS,
const HeaderSearchOptions &HSOpts,
const LangOptions &Lang,
const llvm::Triple &Triple) {
- InitHeaderSearch Init(HS, HSOpts.Verbose, HSOpts.Sysroot);
+ InitHeaderSearch Init(HS, HSOpts.ResourceDir, HSOpts.Verbose, HSOpts.Sysroot);
// Add the user defined entries.
for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits