[clang] [clang-scan-deps] [P1689] Keep consistent behavior for make dependencies with clang (PR #69551)
Ben Langmuir via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 30 09:31:04 PDT 2023
================
@@ -666,13 +666,19 @@ static StringRef makeAbsoluteAndPreferred(CompilerInstance &CI, StringRef Path,
}
void ModuleDepCollector::addFileDep(StringRef Path) {
- llvm::SmallString<256> Storage;
- Path = makeAbsoluteAndPreferred(ScanInstance, Path, Storage);
+ // Within P1689 format, we don't want all the paths to be absolute path
+ // since it may violate the tranditional make style dependencies info.
+ if (!IsStdModuleP1689Format) {
+ llvm::SmallString<256> Storage;
+ Path = makeAbsoluteAndPreferred(ScanInstance, Path, Storage);
+ }
FileDeps.push_back(std::string(Path));
----------------
benlangmuir wrote:
This is a use-after-free of `Storage` since `Path` will point to that buffer if the string is modified. Same for the other case below.
https://github.com/llvm/llvm-project/pull/69551
More information about the cfe-commits
mailing list