// Look for temporaries that are constructed in-place and immediately
// destroyed. Look for temporaries created by a functional cast but not for
// those returned from a call.
- auto BindTemp =
- cxxBindTemporaryExpr(unless(has(ignoringParenImpCasts(callExpr()))))
- .bind("temp");
+ auto BindTemp = cxxBindTemporaryExpr(
+ unless(has(ignoringParenImpCasts(callExpr()))),
+ unless(has(ignoringParenImpCasts(objcMessageExpr()))))
+ .bind("temp");
Finder->addMatcher(
traverse(ast_type_traits::TK_AsIs,
exprWithCleanups(
auto Matches =
match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context);
const auto *TL = selectFirst<TypeLoc>("t", Matches);
+ assert(TL);
D << FixItHint::CreateInsertion(
Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager,
getLangOpts()),
--- /dev/null
+// RUN: clang-tidy %s -checks=-*,bugprone-unused-raii -- | count 0
+
+struct CxxClass {
+ ~CxxClass() {}
+};
+
+@interface ObjcClass {
+}
+- (CxxClass)set:(int)p;
+@end
+
+void test(ObjcClass *s) {
+ [s set:1]; // ok, no crash, no diagnostic emitted.
+ return;
+}