Fix use-after-destruction introduced in r224924.

getMainExecutable() returns a std::string, assigning its result
to StringRef immediately creates a dangling pointer. This was
detected by half-broken fast-MSan-bootstrap bot.

llvm-svn: 224956
This commit is contained in:
Alexey Samsonov
2014-12-29 21:28:15 +00:00
parent 488b6f7bbc
commit 6465d4f7a3

View File

@@ -983,7 +983,8 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
void *MainAddr) {
StringRef ClangExecutable = llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
std::string ClangExecutable =
llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
StringRef Dir = llvm::sys::path::parent_path(ClangExecutable);
// Compute the path to the resource directory.