File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -27,9 +27,10 @@ void UnusedRaiiCheck::registerMatchers(MatchFinder *Finder) {
27
27
// Look for temporaries that are constructed in-place and immediately
28
28
// destroyed. Look for temporaries created by a functional cast but not for
29
29
// those returned from a call.
30
- auto BindTemp =
31
- cxxBindTemporaryExpr (unless (has (ignoringParenImpCasts (callExpr ()))))
32
- .bind (" temp" );
30
+ auto BindTemp = cxxBindTemporaryExpr (
31
+ unless (has (ignoringParenImpCasts (callExpr ()))),
32
+ unless (has (ignoringParenImpCasts (objcMessageExpr ()))))
33
+ .bind (" temp" );
33
34
Finder->addMatcher (
34
35
traverse (ast_type_traits::TK_AsIs,
35
36
exprWithCleanups (
@@ -79,6 +80,7 @@ void UnusedRaiiCheck::check(const MatchFinder::MatchResult &Result) {
79
80
auto Matches =
80
81
match (expr (hasDescendant (typeLoc ().bind (" t" ))), *E, *Result.Context );
81
82
const auto *TL = selectFirst<TypeLoc>(" t" , Matches);
83
+ assert (TL);
82
84
D << FixItHint::CreateInsertion (
83
85
Lexer::getLocForEndOfToken (TL->getEndLoc (), 0 , *Result.SourceManager ,
84
86
getLangOpts ()),
Original file line number Diff line number Diff line change
1
+ // RUN: clang-tidy %s -checks=-*,bugprone-unused-raii -- | count 0
2
+
3
+ struct CxxClass {
4
+ ~CxxClass () {}
5
+ };
6
+
7
+ @interface ObjcClass {
8
+ }
9
+ - (CxxClass)set : (int )p ;
10
+ @end
11
+
12
+ void test (ObjcClass *s) {
13
+ [s set: 1 ]; // ok, no crash, no diagnostic emitted.
14
+ return ;
15
+ }
You can’t perform that action at this time.
0 commit comments