[clang-tools-extra] [clang-tidy] Use DenseMap::insert_range (NFC) (PR #133844)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 31 20:23:48 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/133844
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.
>From c55c36f5f076562ae12a46043e3cb929645dd493 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 30 Mar 2025 23:30:14 -0700
Subject: [PATCH] [clang-tidy] Use DenseMap::insert_range (NFC)
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.
---
clang-tools-extra/clang-tidy/utils/ExprSequence.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
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 {
More information about the cfe-commits
mailing list