Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions clang/lib/Analysis/ExprMutationAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,7 @@ FunctionParmMutationAnalyzer::findMutation(const ParmVarDecl *Parm) {
// before analyzing parameters of A. Then when analyzing the second "call A",
// FunctionParmMutationAnalyzer can use this memoized value to avoid infinite
// recursion.
Results[Parm] = nullptr;
if (const Stmt *S = BodyAnalyzer.findMutation(Parm))
return Results[Parm] = S;
return Results[Parm];
return Results[Parm] = BodyAnalyzer.findMutation(Parm);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the following a few lines above:

  const auto Memoized = Results.find(Parm);
  if (Memoized != Results.end())
    return Memoized->second;

Could we turn that into something like this and use the iterator from try_emplace?

  auto [Memoized, Inserted] = Results.try_emplace(Parm);
  if (!Inserted)
    return Memoized->second;

  Memoized->second = ...;

Maybe we should rename Memorized. The name would sound strange if the insertion is successful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I usually use "Place" or "Slot" for this.

}

} // namespace clang