[clang] 9091df5 - Fix a use-after-scope from 99023627010bbfefb71e25a2b4d056de1cbd354e
Duncan P. N. Exon Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 29 16:25:27 PDT 2021
Author: Duncan P. N. Exon Smith
Date: 2021-10-29T16:25:13-07:00
New Revision: 9091df5fad52ab6a281d7f4d6a508696e6f9fbae
URL: https://github.com/llvm/llvm-project/commit/9091df5fad52ab6a281d7f4d6a508696e6f9fbae
DIFF: https://github.com/llvm/llvm-project/commit/9091df5fad52ab6a281d7f4d6a508696e6f9fbae.diff
LOG: Fix a use-after-scope from 99023627010bbfefb71e25a2b4d056de1cbd354e
Added:
Modified:
clang/lib/Basic/FileManager.cpp
Removed:
################################################################################
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 1cb52d5594d59..f4cf27848d7d9 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -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;
}
}
More information about the cfe-commits
mailing list