[cfe-commits] r67228 - /cfe/trunk/tools/driver/driver.cpp
Daniel Dunbar
daniel at zuster.org
Wed Mar 18 13:25:54 PDT 2009
Author: ddunbar
Date: Wed Mar 18 15:25:53 2009
New Revision: 67228
URL: http://llvm.org/viewvc/llvm-project?rev=67228&view=rev
Log:
Driver: Get executable path using llvm::sys::Path::GetMainExecutable.
Modified:
cfe/trunk/tools/driver/driver.cpp
Modified: cfe/trunk/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=67228&r1=67227&r2=67228&view=diff
==============================================================================
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Wed Mar 18 15:25:53 2009
@@ -60,15 +60,18 @@
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()));
More information about the cfe-commits
mailing list