File tree 3 files changed +22
-3
lines changed
3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -33,14 +33,20 @@ handleFrom(const ast_matchers::internal::Matcher<RecordDecl> &IsAHandle,
33
33
34
34
ast_matchers::internal::Matcher<Stmt> handleFromTemporaryValue (
35
35
const ast_matchers::internal::Matcher<RecordDecl> &IsAHandle) {
36
+
37
+ const auto TemporaryExpr = anyOf (
38
+ cxxBindTemporaryExpr (),
39
+ cxxFunctionalCastExpr (
40
+ hasCastKind (CK_ConstructorConversion),
41
+ hasSourceExpression (ignoringParenImpCasts (cxxBindTemporaryExpr ()))));
36
42
// If a ternary operator returns a temporary value, then both branches hold a
37
43
// temporary value. If one of them is not a temporary then it must be copied
38
44
// into one to satisfy the type of the operator.
39
45
const auto TemporaryTernary = conditionalOperator (
40
- hasTrueExpression (ignoringParenImpCasts (cxxBindTemporaryExpr () )),
41
- hasFalseExpression (ignoringParenImpCasts (cxxBindTemporaryExpr () )));
46
+ hasTrueExpression (ignoringParenImpCasts (TemporaryExpr )),
47
+ hasFalseExpression (ignoringParenImpCasts (TemporaryExpr )));
42
48
43
- return handleFrom (IsAHandle, anyOf (cxxBindTemporaryExpr () , TemporaryTernary));
49
+ return handleFrom (IsAHandle, anyOf (TemporaryExpr , TemporaryTernary));
44
50
}
45
51
46
52
ast_matchers::internal::Matcher<RecordDecl> isASequence () {
Original file line number Diff line number Diff line change @@ -207,6 +207,11 @@ New check aliases
207
207
Changes in existing checks
208
208
^^^^^^^^^^^^^^^^^^^^^^^^^^
209
209
210
+ - Improved :doc: `bugprone-dangling-handle
211
+ <clang-tidy/checks/bugprone/dangling-handle>` check to support functional
212
+ casting during type conversions at variable initialization, now with improved
213
+ compatibility for C++17 and later versions.
214
+
210
215
- Improved :doc: `bugprone-lambda-function-name
211
216
<clang-tidy/checks/bugprone/lambda-function-name>` check by adding option
212
217
`IgnoreMacros ` to ignore warnings in macros.
Original file line number Diff line number Diff line change @@ -108,6 +108,14 @@ void Positives() {
108
108
std::string_view view4 (ReturnsAString ());
109
109
// CHECK-MESSAGES-CXX14: [[@LINE-1]]:20: warning: std::basic_string_view outlives
110
110
// CHECK-MESSAGES-CXX17: [[@LINE-2]]:26: warning: std::basic_string_view outlives
111
+
112
+ std::string_view view5 = std::string (" test" );
113
+ // CHECK-MESSAGES-CXX14: [[@LINE-1]]:20: warning: std::basic_string_view outlives its value [bugprone-dangling-handle]
114
+ // CHECK-MESSAGES-CXX17: [[@LINE-2]]:28: warning: std::basic_string_view outlives its value [bugprone-dangling-handle]
115
+
116
+ std::string_view view6 = std::string{" test" };
117
+ // CHECK-MESSAGES-CXX14: [[@LINE-1]]:20: warning: std::basic_string_view outlives its value [bugprone-dangling-handle]
118
+ // CHECK-MESSAGES-CXX17: [[@LINE-2]]:28: warning: std::basic_string_view outlives its value [bugprone-dangling-handle]
111
119
}
112
120
113
121
void OtherTypes () {
You can’t perform that action at this time.
0 commit comments