[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);
This commit is contained in:
Kazu Hirata 2025-03-23 00:23:19 -07:00 committed by GitHub
parent c440563da7
commit 4a7643400c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 11 additions and 15 deletions

View File

@ -464,7 +464,7 @@ getUsedDecls(const HelperDeclRefGraph *RG,
for (const auto *D : Decls) {
auto Result = RG->getReachableNodes(
HelperDeclRGBuilder::getOutmostClassOrFunDecl(D));
Nodes.insert(Result.begin(), Result.end());
Nodes.insert_range(Result);
}
llvm::DenseSet<const Decl *> Results;
for (const auto *Node : Nodes)

View File

@ -43,13 +43,11 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name,
IgnoredExceptionsVec;
StringRef(RawFunctionsThatShouldNotThrow)
.split(FunctionsThatShouldNotThrowVec, ",", -1, false);
FunctionsThatShouldNotThrow.insert(FunctionsThatShouldNotThrowVec.begin(),
FunctionsThatShouldNotThrowVec.end());
FunctionsThatShouldNotThrow.insert_range(FunctionsThatShouldNotThrowVec);
llvm::StringSet<> IgnoredExceptions;
StringRef(RawIgnoredExceptions).split(IgnoredExceptionsVec, ",", -1, false);
IgnoredExceptions.insert(IgnoredExceptionsVec.begin(),
IgnoredExceptionsVec.end());
IgnoredExceptions.insert_range(IgnoredExceptionsVec);
Tracer.ignoreExceptions(std::move(IgnoredExceptions));
Tracer.ignoreBadAlloc(true);
}

View File

@ -51,7 +51,7 @@ public:
// We've decided that it isn't performant to keep using vector.
// Let's migrate the data into Set.
Set.reserve(Storage.size());
Set.insert(Storage.begin(), Storage.end());
Set.insert_range(Storage);
}
/// count - Return 1 if the element is in the set, 0 otherwise.
@ -97,7 +97,7 @@ private:
const size_t NewMaxElts = 4 * Vector.size();
Vector.reserve(NewMaxElts);
Set.reserve(NewMaxElts);
Set.insert(Vector.begin(), Vector.end());
Set.insert_range(Vector);
}
/// count - Return 1 if the element is in the set, 0 otherwise.

View File

@ -30,8 +30,7 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name,
StringRef(RawIgnoredExceptions).split(IgnoredExceptionsVec, ",", -1, false);
llvm::transform(IgnoredExceptionsVec, IgnoredExceptionsVec.begin(),
[](StringRef S) { return S.trim(); });
IgnoredExceptions.insert(IgnoredExceptionsVec.begin(),
IgnoredExceptionsVec.end());
IgnoredExceptions.insert_range(IgnoredExceptionsVec);
Tracer.ignoreExceptions(std::move(IgnoredExceptions));
Tracer.ignoreBadAlloc(true);
}

View File

@ -22,7 +22,7 @@ void ExceptionAnalyzer::ExceptionInfo::registerExceptions(
if (Exceptions.empty())
return;
Behaviour = State::Throwing;
ThrownExceptions.insert(Exceptions.begin(), Exceptions.end());
ThrownExceptions.insert_range(Exceptions);
}
ExceptionAnalyzer::ExceptionInfo &ExceptionAnalyzer::ExceptionInfo::merge(
@ -39,8 +39,7 @@ ExceptionAnalyzer::ExceptionInfo &ExceptionAnalyzer::ExceptionInfo::merge(
Behaviour = State::Unknown;
ContainsUnknown = ContainsUnknown || Other.ContainsUnknown;
ThrownExceptions.insert(Other.ThrownExceptions.begin(),
Other.ThrownExceptions.end());
ThrownExceptions.insert_range(Other.ThrownExceptions);
return *this;
}

View File

@ -202,7 +202,7 @@ class Lookup : public Command {
}
LookupRequest Request;
Request.IDs.insert(IDs.begin(), IDs.end());
Request.IDs.insert_range(IDs);
bool FoundSymbol = false;
Index->lookup(Request, [&](const Symbol &Sym) {
FoundSymbol = true;
@ -255,7 +255,7 @@ class Refs : public Command {
}
}
RefsRequest RefRequest;
RefRequest.IDs.insert(IDs.begin(), IDs.end());
RefRequest.IDs.insert_range(IDs);
llvm::Regex RegexFilter(Filter);
Index->refs(RefRequest, [&RegexFilter](const Ref &R) {
auto U = URI::parse(R.Location.FileURI);

View File

@ -151,7 +151,7 @@ std::vector<std::string> match(const SymbolIndex &I,
std::vector<std::string> lookup(const SymbolIndex &I,
llvm::ArrayRef<SymbolID> IDs) {
LookupRequest Req;
Req.IDs.insert(IDs.begin(), IDs.end());
Req.IDs.insert_range(IDs);
std::vector<std::string> Results;
I.lookup(Req, [&](const Symbol &Sym) {
Results.push_back(getQualifiedName(Sym));