diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index ea218d5403d8..de14425d3616 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -290,9 +290,9 @@ static void SetInstallDir(SmallVectorImpl &argv, if (CanonicalPrefixes) llvm::sys::fs::make_absolute(InstalledPath); - InstalledPath = llvm::sys::path::parent_path(InstalledPath); - if (llvm::sys::fs::exists(InstalledPath.c_str())) - TheDriver.setInstalledDir(InstalledPath); + StringRef InstalledPathParent(llvm::sys::path::parent_path(InstalledPath)); + if (llvm::sys::fs::exists(InstalledPathParent)) + TheDriver.setInstalledDir(InstalledPathParent); } static int ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {