[c-index-test] Use correct executable path to discover resource directory.

Driver builds resource directory path based on provided executable path.
Instead of string "clang" use actual executable path.

rdar://problem/42699514

Reviewers: nathawes, akyrtzi, bob.wilson

Reviewed By: akyrtzi

Subscribers: dexonsmith, cfe-commits

Differential Revision: https://reviews.llvm.org/D50160

llvm-svn: 338741
This commit is contained in:
Volodymyr Sapsai 2018-08-02 17:29:53 +00:00
parent bd45adb50f
commit 7b16e8ad32
1 changed files with 10 additions and 5 deletions

View File

@ -20,6 +20,7 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Serialization/ASTReader.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/PrettyStackTrace.h"
@ -202,11 +203,11 @@ static void dumpModuleFileInputs(serialization::ModuleFile &Mod,
});
}
static bool printSourceSymbols(ArrayRef<const char *> Args,
bool dumpModuleImports,
bool indexLocals) {
static bool printSourceSymbols(const char *Executable,
ArrayRef<const char *> Args,
bool dumpModuleImports, bool indexLocals) {
SmallVector<const char *, 4> ArgsWithProgName;
ArgsWithProgName.push_back("clang");
ArgsWithProgName.push_back(Executable);
ArgsWithProgName.append(Args.begin(), Args.end());
IntrusiveRefCntPtr<DiagnosticsEngine>
Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
@ -314,6 +315,8 @@ static void printSymbolNameAndUSR(const Decl *D, ASTContext &Ctx,
int indextest_core_main(int argc, const char **argv) {
sys::PrintStackTraceOnErrorSignal(argv[0]);
PrettyStackTraceProgram X(argc, argv);
void *MainAddr = (void*) (intptr_t) indextest_core_main;
std::string Executable = llvm::sys::fs::getMainExecutable(argv[0], MainAddr);
assert(argv[1] == StringRef("core"));
++argv;
@ -343,7 +346,9 @@ int indextest_core_main(int argc, const char **argv) {
errs() << "error: missing compiler args; pass '-- <compiler arguments>'\n";
return 1;
}
return printSourceSymbols(CompArgs, options::DumpModuleImports, options::IncludeLocals);
return printSourceSymbols(Executable.c_str(), CompArgs,
options::DumpModuleImports,
options::IncludeLocals);
}
return 0;