[PATCH] D83293: [clang-tidy] Fix an unused-raii check crash on objective-c++.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 7 04:35:08 PDT 2020
hokein updated this revision to Diff 275994.
hokein marked an inline comment as done.
hokein added a comment.
fix names.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83293/new/
https://reviews.llvm.org/D83293
Files:
clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm
===================================================================
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm
@@ -0,0 +1,15 @@
+// RUN: clang-tidy %s -checks=-*,bugprone-unused-raii -- | count 0
+
+struct CxxClass {
+ ~CxxClass() {}
+};
+
+ at interface ObjcClass {
+}
+- (CxxClass)set:(int)p;
+ at end
+
+void test(ObjcClass *s) {
+ [s set:1]; // ok, no crash, no diagnostic emitted.
+ return;
+}
Index: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
@@ -27,9 +27,10 @@
// 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(
@@ -79,6 +80,7 @@
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()),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83293.275994.patch
Type: text/x-patch
Size: 1781 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200707/b6303415/attachment-0001.bin>
More information about the cfe-commits
mailing list