diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-12-13 03:46:13 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-12-13 03:46:13 +0000 |
commit | 869824e87940f97b87064db2df2861e82e08a8c6 (patch) | |
tree | 46fa24160a6c50347a34be7967f0de7aa5d1f2f3 /lib/Frontend/ASTUnit.cpp | |
parent | 1e69fe3a9f0a42b32a3000bda51677d51416564e (diff) |
Lift builtin-include-path logic out of ASTUnit::LoadFromCommandLine and fix CIndex to pass in the right directory (previously it was using the path to the main executable, which generally is wrong).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91238 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ASTUnit.cpp')
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 16d2ea93d8..f6cb1704f6 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -287,8 +287,7 @@ error: ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin, const char **ArgEnd, Diagnostic &Diags, - const char *Argv0, - void *MainAddr, + llvm::StringRef ResourceFilesPath, bool OnlyLocalDecls, bool UseBumpAllocator) { llvm::SmallVector<const char *, 16> Args; @@ -299,9 +298,8 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin, // also want to force it to use clang. Args.push_back("-fsyntax-only"); - llvm::sys::Path Path = llvm::sys::Path::GetMainExecutable(Argv0, MainAddr); - driver::Driver TheDriver(Path.getBasename(), Path.getDirname(), - llvm::sys::getHostTriple(), + // FIXME: We shouldn't have to pass in the path info. + driver::Driver TheDriver("clang", "/", llvm::sys::getHostTriple(), "a.out", false, Diags); llvm::OwningPtr<driver::Compilation> C( TheDriver.BuildCompilation(Args.size(), Args.data())); @@ -329,11 +327,10 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin, (const char**) CCArgs.data()+CCArgs.size(), Diags); - // Infer the builtin include path if unspecified. - if (CI.getHeaderSearchOpts().UseBuiltinIncludes && - CI.getHeaderSearchOpts().BuiltinIncludePath.empty()) - CI.getHeaderSearchOpts().BuiltinIncludePath = - CompilerInvocation::GetBuiltinIncludePath(Argv0, MainAddr); + // Set the builtin include path. + llvm::sys::Path P(ResourceFilesPath); + P.appendComponent("include"); + CI.getHeaderSearchOpts().BuiltinIncludePath = P.str(); CI.getFrontendOpts().DisableFree = UseBumpAllocator; return LoadFromCompilerInvocation(CI, Diags, OnlyLocalDecls); |