[clang-tools-extra] [clang-tidy] Use DenseMap::insert_range (NFC) (PR #133844)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 31 20:24:18 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
We can safely switch to insert_range here because
SyntheticStmtSourceMap starts out empty in the constructor. Also
TheCFG->synthetic_stmts() comes from DenseMap, so we know that the
keys are unique. That is, operator[] and insert are equivalent in
this particular case.
---
Full diff: https://github.com/llvm/llvm-project/pull/133844.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/utils/ExprSequence.cpp (+1-3)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/utils/ExprSequence.cpp b/clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
index 145a5fe378b3e..685277d8bfbca 100644
--- a/clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
@@ -84,9 +84,7 @@ getAllInitListForms(const InitListExpr *InitList) {
ExprSequence::ExprSequence(const CFG *TheCFG, const Stmt *Root,
ASTContext *TheContext)
: Context(TheContext), Root(Root) {
- for (const auto &SyntheticStmt : TheCFG->synthetic_stmts()) {
- SyntheticStmtSourceMap[SyntheticStmt.first] = SyntheticStmt.second;
- }
+ SyntheticStmtSourceMap.insert_range(TheCFG->synthetic_stmts());
}
bool ExprSequence::inSequence(const Stmt *Before, const Stmt *After) const {
``````````
</details>
https://github.com/llvm/llvm-project/pull/133844
More information about the cfe-commits
mailing list