[clang] [llvm] [NFCI][Sanitizer] Convert Matcher::Globs from StringMap to vector. (PR #140964)
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Fri May 23 13:10:16 PDT 2025
================
@@ -53,24 +53,27 @@ Error SpecialCaseList::Matcher::insert(StringRef Pattern, unsigned LineNumber,
return Error::success();
}
- auto [It, DidEmplace] = Globs.try_emplace(Pattern);
- if (DidEmplace) {
- // We must be sure to use the string in the map rather than the provided
- // reference which could be destroyed before match() is called
- Pattern = It->getKey();
- auto &Pair = It->getValue();
- if (auto Err = GlobPattern::create(Pattern, /*MaxSubPatterns=*/1024)
- .moveInto(Pair.first))
- return Err;
- Pair.second = LineNumber;
- }
+ Globs.emplace_back();
+ auto &Glob = Globs.back();
+ Glob.first = Pattern.str();
+ auto &Pair = Glob.second;
+ // We must be sure to use the string in the map rather than the provided
+ // reference which could be destroyed before match() is called
+ llvm::errs() << __func__ << " GlobPattern::create: " << Glob.first << "\n";
+ if (auto Err = GlobPattern::create(Glob.first, /*MaxSubPatterns=*/1024)
----------------
vitalybuka wrote:
Here you create with StringRef into std::string .first
std::string movable, but contains short string optimization.
When emplace_back need to resize, string will move itself into different loc.
https://github.com/llvm/llvm-project/pull/140964
More information about the cfe-commits
mailing list