зеркало из https://github.com/microsoft/clang-1.git
Driver: Get executable path using llvm::sys::Path::GetMainExecutable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67228 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
9a2f1acf79
Коммит
734932c7dc
|
@ -60,15 +60,18 @@ void DriverDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
|
|||
OS << '\n';
|
||||
}
|
||||
|
||||
llvm::sys::Path GetExecutablePath(const char *Argv0) {
|
||||
// This just needs to be some symbol in the binary; C++ doesn't
|
||||
// allow taking the address of ::main however.
|
||||
void *P = (void*) (intptr_t) GetExecutablePath;
|
||||
return llvm::sys::Path::GetMainExecutable(Argv0, P);
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv) {
|
||||
llvm::sys::PrintStackTraceOnErrorSignal();
|
||||
llvm::PrettyStackTraceProgram X(argc, argv);
|
||||
|
||||
// FIXME: We should use GetMainExecutable here, probably, but we may
|
||||
// want to handle symbolic links slightly differently. The problem
|
||||
// is that the path derived from this will influence search paths.
|
||||
llvm::sys::Path Path(argv[0]);
|
||||
|
||||
llvm::sys::Path Path = GetExecutablePath(argv[0]);
|
||||
llvm::OwningPtr<DiagnosticClient>
|
||||
DiagClient(new DriverDiagnosticPrinter(Path.getBasename(), llvm::errs()));
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче