Fix a use-after-scope from 9902362701

This commit is contained in:
Duncan P. N. Exon Smith 2021-10-29 16:24:11 -07:00
parent 40a6be4346
commit 9091df5fad
1 changed files with 2 additions and 2 deletions

View File

@ -123,14 +123,14 @@ FileManager::getDirectoryRef(StringRef DirName, bool CacheFailure) {
DirName != llvm::sys::path::root_path(DirName) &&
llvm::sys::path::is_separator(DirName.back()))
DirName = DirName.substr(0, DirName.size()-1);
Optional<std::string> DirNameStr;
if (is_style_windows(llvm::sys::path::Style::native)) {
// Fixing a problem with "clang C:test.c" on Windows.
// Stat("C:") does not recognize "C:" as a valid directory
std::string DirNameStr;
if (DirName.size() > 1 && DirName.back() == ':' &&
DirName.equals_insensitive(llvm::sys::path::root_name(DirName))) {
DirNameStr = DirName.str() + '.';
DirName = DirNameStr;
DirName = *DirNameStr;
}
}