[clang] [clang-tools-extra] [clang-tidy] Fix performance-unnecessary-value-param (PR #109145)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 18 11:01:00 PDT 2024
================
@@ -118,10 +118,19 @@ class FunctionParmMutationAnalyzer {
static FunctionParmMutationAnalyzer *
getFunctionParmMutationAnalyzer(const FunctionDecl &Func, ASTContext &Context,
ExprMutationAnalyzer::Memoized &Memorized) {
- auto [it, Inserted] = Memorized.FuncParmAnalyzer.try_emplace(&Func);
- if (Inserted)
- it->second = std::unique_ptr<FunctionParmMutationAnalyzer>(
- new FunctionParmMutationAnalyzer(Func, Context, Memorized));
+ auto it = Memorized.FuncParmAnalyzer.find(&Func);
+ if (it == Memorized.FuncParmAnalyzer.end())
+ // We call try_emplace here, repeating a hash lookup on the same key. Note
+ // that creating a new instance of FunctionParmMutationAnalyzer below may
+ // add additional elements to FuncParmAnalyzer and invalidate iterators.
----------------
kazutakahirata wrote:
Updated the comment accordingly. Thanks!
https://github.com/llvm/llvm-project/pull/109145
More information about the cfe-commits
mailing list