Skip to content

Commit 5ea6f7b

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-runtime-checks
2 parents 7996451 + ccb40b0 commit 5ea6f7b

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ using namespace clang::ast_matchers;
1515
namespace clang::tidy::bugprone {
1616

1717
void ThrowKeywordMissingCheck::registerMatchers(MatchFinder *Finder) {
18-
auto CtorInitializerList =
19-
cxxConstructorDecl(hasAnyConstructorInitializer(anything()));
20-
2118
Finder->addMatcher(
2219
cxxConstructExpr(
2320
hasType(cxxRecordDecl(
@@ -27,7 +24,7 @@ void ThrowKeywordMissingCheck::registerMatchers(MatchFinder *Finder) {
2724
stmt(anyOf(cxxThrowExpr(), callExpr(), returnStmt()))),
2825
hasAncestor(decl(anyOf(varDecl(), fieldDecl()))),
2926
hasAncestor(expr(cxxNewExpr(hasAnyPlacementArg(anything())))),
30-
allOf(hasAncestor(CtorInitializerList),
27+
allOf(hasAncestor(cxxConstructorDecl()),
3128
unless(hasAncestor(cxxCatchStmt()))))))
3229
.bind("temporary-exception-not-thrown"),
3330
this);

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ Changes in existing checks
177177
usages of ``sizeof()``, ``alignof()``, and ``offsetof()`` when adding or
178178
subtracting from a pointer directly or when used to scale a numeric value.
179179

180+
- Improved :doc:`bugprone-throw-keyword-missing
181+
<clang-tidy/checks/bugprone/throw-keyword-missing>` by fixing a false positive
182+
when using non-static member initializers and a constructor.
183+
180184
- Improved :doc:`bugprone-unchecked-optional-access
181185
<clang-tidy/checks/bugprone/unchecked-optional-access>` to support
182186
`bsl::optional` and `bdlb::NullableValue` from

clang-tools-extra/test/clang-tidy/checkers/bugprone/throw-keyword-missing.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ CtorInitializerListTest::CtorInitializerListTest(float) try : exc(RegularExcepti
139139
RegularException();
140140
}
141141

142+
namespace GH115055 {
143+
class CtorInitializerListTest2 {
144+
public:
145+
CtorInitializerListTest2() {}
146+
private:
147+
RegularException exc{};
148+
};
149+
} // namespace GH115055
150+
142151
RegularException funcReturningExceptionTest(int i) {
143152
return RegularException();
144153
}

llvm/include/llvm/ADT/STLExtras.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ static constexpr bool HasFreeFunctionRBegin =
416416
} // namespace detail
417417

418418
// Returns an iterator_range over the given container which iterates in reverse.
419-
template <typename ContainerTy> auto reverse(ContainerTy &&C) {
419+
// Does not mutate the container.
420+
template <typename ContainerTy> [[nodiscard]] auto reverse(ContainerTy &&C) {
420421
if constexpr (detail::HasFreeFunctionRBegin<ContainerTy>)
421422
return make_range(adl_rbegin(C), adl_rend(C));
422423
else
@@ -1182,11 +1183,13 @@ template <typename ValueT, typename... RangeTs> class concat_range {
11821183

11831184
} // end namespace detail
11841185

1185-
/// Concatenated range across two or more ranges.
1186+
/// Returns a concatenated range across two or more ranges. Does not modify the
1187+
/// ranges.
11861188
///
11871189
/// The desired value type must be explicitly specified.
11881190
template <typename ValueT, typename... RangeTs>
1189-
detail::concat_range<ValueT, RangeTs...> concat(RangeTs &&... Ranges) {
1191+
[[nodiscard]] detail::concat_range<ValueT, RangeTs...>
1192+
concat(RangeTs &&...Ranges) {
11901193
static_assert(sizeof...(RangeTs) > 1,
11911194
"Need more than one range to concatenate!");
11921195
return detail::concat_range<ValueT, RangeTs...>(

0 commit comments

Comments
 (0)