Skip to content

Commit 861fc85

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents 322000f + c482b8f commit 861fc85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+578
-671
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));

clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,18 @@ void MismatchedIteratorChecker::checkPreCall(const CallEvent &Call,
9191
InstCall->getCXXThisVal().getAsRegion());
9292
}
9393
} else if (isInsertCall(Func)) {
94-
verifyMatch(C, Call.getArgSVal(0),
95-
InstCall->getCXXThisVal().getAsRegion());
96-
if (Call.getNumArgs() == 3 &&
97-
isIteratorType(Call.getArgExpr(1)->getType()) &&
98-
isIteratorType(Call.getArgExpr(2)->getType())) {
99-
verifyMatch(C, Call.getArgSVal(1), Call.getArgSVal(2));
94+
if (Call.getNumArgs() == 2 &&
95+
isIteratorType(Call.getArgExpr(0)->getType()) &&
96+
isIteratorType(Call.getArgExpr(1)->getType())) {
97+
verifyMatch(C, Call.getArgSVal(0), Call.getArgSVal(1));
98+
} else {
99+
verifyMatch(C, Call.getArgSVal(0),
100+
InstCall->getCXXThisVal().getAsRegion());
101+
if (Call.getNumArgs() == 3 &&
102+
isIteratorType(Call.getArgExpr(1)->getType()) &&
103+
isIteratorType(Call.getArgExpr(2)->getType())) {
104+
verifyMatch(C, Call.getArgSVal(1), Call.getArgSVal(2));
105+
}
100106
}
101107
} else if (isEmplaceCall(Func)) {
102108
verifyMatch(C, Call.getArgSVal(0),

clang/test/Analysis/Inputs/system-header-simulator-cxx.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,7 @@ template<
12441244
class Alloc = std::allocator<Key>
12451245
> class unordered_set {
12461246
public:
1247+
unordered_set() {}
12471248
unordered_set(initializer_list<Key> __list) {}
12481249

12491250
class iterator {
@@ -1260,6 +1261,9 @@ template<
12601261
Key *val;
12611262
iterator begin() const { return iterator(val); }
12621263
iterator end() const { return iterator(val + 1); }
1264+
1265+
template< class InputIt >
1266+
void insert( InputIt first, InputIt last );
12631267
};
12641268

12651269
template <typename T>

clang/test/Analysis/mismatched-iterator.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ void good_insert4(std::vector<int> &V, int len, int n) {
1919
V.insert(V.cbegin(), {n-1, n, n+1}); // no-warning
2020
}
2121

22+
void good_insert5(std::vector<int> &V, int len, int n) {
23+
std::unordered_set<int> us;
24+
us.insert(V.cbegin(), V.cend()); // no-warning
25+
}
26+
2227
void good_insert_find(std::vector<int> &V, int n, int m) {
2328
auto i = std::find(V.cbegin(), V.cend(), n);
2429
V.insert(i, m); // no-warning
@@ -70,6 +75,11 @@ void bad_insert4(std::vector<int> &V1, std::vector<int> &V2, int len, int n) {
7075
V2.insert(V1.cbegin(), {n-1, n, n+1}); // expected-warning{{Container accessed using foreign iterator argument}}
7176
}
7277

78+
void bad_insert5(std::vector<int> &V1, std::vector<int> &V2, int len, int n) {
79+
std::unordered_set<int> us;
80+
us.insert(V1.cbegin(), V2.cend()); // expected-warning{{Iterators of different containers used where the same container is expected}}
81+
}
82+
7383
void bad_erase1(std::vector<int> &V1, std::vector<int> &V2) {
7484
V2.erase(V1.cbegin()); // expected-warning{{Container accessed using foreign iterator argument}}
7585
}

0 commit comments

Comments
 (0)