[clang] [clang][deps][modules] Allocate input file paths lazily (PR #114457)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 1 10:17:36 PDT 2024
================
@@ -779,23 +795,16 @@ static StringRef makeAbsoluteAndPreferred(CompilerInstance &CI, StringRef Path,
void ModuleDepCollector::addFileDep(StringRef Path) {
if (IsStdModuleP1689Format) {
// Within P1689 format, we don't want all the paths to be absolute path
- // since it may violate the tranditional make style dependencies info.
- FileDeps.push_back(std::string(Path));
+ // since it may violate the traditional make style dependencies info.
+ FileDeps.emplace_back(Path);
return;
}
llvm::SmallString<256> Storage;
Path = makeAbsoluteAndPreferred(ScanInstance, Path, Storage);
- FileDeps.push_back(std::string(Path));
+ FileDeps.emplace_back(Path);
}
void ModuleDepCollector::addFileDep(ModuleDeps &MD, StringRef Path) {
- if (IsStdModuleP1689Format) {
- MD.FileDeps.insert(Path);
- return;
- }
-
- llvm::SmallString<256> Storage;
- Path = makeAbsoluteAndPreferred(ScanInstance, Path, Storage);
----------------
jansvoboda11 wrote:
Looking at the `ASTWriter`/`ASTReader` code, I'm pretty sure Clang modules always have an absolute base directory. (Unless the `-fmodule-file-home-is-cwd` or `-fmodule-map-file-home-is-cwd` flags have been specified, in which case reporting relative paths is expected IMO.)
Standard C++ modules will use the `-isysroot` argument as-is as the base directory.
So I think overall the call to `makeAbsoluteAndPreferred()` is okay to remove. For context, making paths absolute was introduced by @benlangmuir in [D130934](https://reviews.llvm.org/D130934).
https://github.com/llvm/llvm-project/pull/114457
More information about the cfe-commits
mailing list