Skip to content

Commit 4a76434

Browse files
[clang-tools-extra] Use *Set::insert_range (NFC) (#132589)
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently gained C++23-style insert_range. This patch replaces: Dest.insert(Src.begin(), Src.end()); with: Dest.insert_range(Src);
1 parent c440563 commit 4a76434

File tree

7 files changed

+11
-15
lines changed

7 files changed

+11
-15
lines changed

clang-tools-extra/clang-move/Move.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ getUsedDecls(const HelperDeclRefGraph *RG,
464464
for (const auto *D : Decls) {
465465
auto Result = RG->getReachableNodes(
466466
HelperDeclRGBuilder::getOutmostClassOrFunDecl(D));
467-
Nodes.insert(Result.begin(), Result.end());
467+
Nodes.insert_range(Result);
468468
}
469469
llvm::DenseSet<const Decl *> Results;
470470
for (const auto *Node : Nodes)

clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name,
4343
IgnoredExceptionsVec;
4444
StringRef(RawFunctionsThatShouldNotThrow)
4545
.split(FunctionsThatShouldNotThrowVec, ",", -1, false);
46-
FunctionsThatShouldNotThrow.insert(FunctionsThatShouldNotThrowVec.begin(),
47-
FunctionsThatShouldNotThrowVec.end());
46+
FunctionsThatShouldNotThrow.insert_range(FunctionsThatShouldNotThrowVec);
4847

4948
llvm::StringSet<> IgnoredExceptions;
5049
StringRef(RawIgnoredExceptions).split(IgnoredExceptionsVec, ",", -1, false);
51-
IgnoredExceptions.insert(IgnoredExceptionsVec.begin(),
52-
IgnoredExceptionsVec.end());
50+
IgnoredExceptions.insert_range(IgnoredExceptionsVec);
5351
Tracer.ignoreExceptions(std::move(IgnoredExceptions));
5452
Tracer.ignoreBadAlloc(true);
5553
}

clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ template <typename T, unsigned SmallSize> class ImmutableSmallSet {
5151
// We've decided that it isn't performant to keep using vector.
5252
// Let's migrate the data into Set.
5353
Set.reserve(Storage.size());
54-
Set.insert(Storage.begin(), Storage.end());
54+
Set.insert_range(Storage);
5555
}
5656

5757
/// count - Return 1 if the element is in the set, 0 otherwise.
@@ -97,7 +97,7 @@ template <typename T, unsigned SmallSize> class SmartSmallSetVector {
9797
const size_t NewMaxElts = 4 * Vector.size();
9898
Vector.reserve(NewMaxElts);
9999
Set.reserve(NewMaxElts);
100-
Set.insert(Vector.begin(), Vector.end());
100+
Set.insert_range(Vector);
101101
}
102102

103103
/// count - Return 1 if the element is in the set, 0 otherwise.

clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name,
3030
StringRef(RawIgnoredExceptions).split(IgnoredExceptionsVec, ",", -1, false);
3131
llvm::transform(IgnoredExceptionsVec, IgnoredExceptionsVec.begin(),
3232
[](StringRef S) { return S.trim(); });
33-
IgnoredExceptions.insert(IgnoredExceptionsVec.begin(),
34-
IgnoredExceptionsVec.end());
33+
IgnoredExceptions.insert_range(IgnoredExceptionsVec);
3534
Tracer.ignoreExceptions(std::move(IgnoredExceptions));
3635
Tracer.ignoreBadAlloc(true);
3736
}

clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void ExceptionAnalyzer::ExceptionInfo::registerExceptions(
2222
if (Exceptions.empty())
2323
return;
2424
Behaviour = State::Throwing;
25-
ThrownExceptions.insert(Exceptions.begin(), Exceptions.end());
25+
ThrownExceptions.insert_range(Exceptions);
2626
}
2727

2828
ExceptionAnalyzer::ExceptionInfo &ExceptionAnalyzer::ExceptionInfo::merge(
@@ -39,8 +39,7 @@ ExceptionAnalyzer::ExceptionInfo &ExceptionAnalyzer::ExceptionInfo::merge(
3939
Behaviour = State::Unknown;
4040

4141
ContainsUnknown = ContainsUnknown || Other.ContainsUnknown;
42-
ThrownExceptions.insert(Other.ThrownExceptions.begin(),
43-
Other.ThrownExceptions.end());
42+
ThrownExceptions.insert_range(Other.ThrownExceptions);
4443
return *this;
4544
}
4645

clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class Lookup : public Command {
202202
}
203203

204204
LookupRequest Request;
205-
Request.IDs.insert(IDs.begin(), IDs.end());
205+
Request.IDs.insert_range(IDs);
206206
bool FoundSymbol = false;
207207
Index->lookup(Request, [&](const Symbol &Sym) {
208208
FoundSymbol = true;
@@ -255,7 +255,7 @@ class Refs : public Command {
255255
}
256256
}
257257
RefsRequest RefRequest;
258-
RefRequest.IDs.insert(IDs.begin(), IDs.end());
258+
RefRequest.IDs.insert_range(IDs);
259259
llvm::Regex RegexFilter(Filter);
260260
Index->refs(RefRequest, [&RegexFilter](const Ref &R) {
261261
auto U = URI::parse(R.Location.FileURI);

clang-tools-extra/clangd/unittests/TestIndex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ std::vector<std::string> match(const SymbolIndex &I,
151151
std::vector<std::string> lookup(const SymbolIndex &I,
152152
llvm::ArrayRef<SymbolID> IDs) {
153153
LookupRequest Req;
154-
Req.IDs.insert(IDs.begin(), IDs.end());
154+
Req.IDs.insert_range(IDs);
155155
std::vector<std::string> Results;
156156
I.lookup(Req, [&](const Symbol &Sym) {
157157
Results.push_back(getQualifiedName(Sym));

0 commit comments

Comments
 (0)