[PATCH] D115576: [clang-tidy][#51939] Exempt placement-new expressions from 'bugprone-throw-keyword-missing'
Markus Böck via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 15 07:59:24 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb7d55771ce3e: [clang-tidy][#51939] Exempt placement-new expressions from 'bugprone-throw… (authored by zero9178).
Changed prior to commit:
https://reviews.llvm.org/D115576?vs=393671&id=394575#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115576/new/
https://reviews.llvm.org/D115576
Files:
clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/bugprone-throw-keyword-missing.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-throw-keyword-missing.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-throw-keyword-missing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-throw-keyword-missing.cpp
@@ -175,3 +175,14 @@
void exceptionRAIITest() {
ExceptionRAII E;
}
+
+namespace std {
+typedef decltype(sizeof(void*)) size_t;
+}
+
+void* operator new(std::size_t, void*);
+
+void placeMentNewTest() {
+ alignas(RegularException) unsigned char expr[sizeof(RegularException)];
+ new (expr) RegularException{};
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===================================================================
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -148,6 +148,10 @@
- Fixed a false positive in :doc:`fuchsia-trailing-return
<clang-tidy/checks/fuchsia-trailing-return>` for C++17 deduction guides.
+
+- Fixed a false positive in :doc:`bugprone-throw-keyword-missing
+ <clang-tidy/checks/bugprone-throw-keyword-missing>` when creating an exception object
+ using placement new
Removed checks
^^^^^^^^^^^^^^
Index: clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
@@ -24,11 +24,13 @@
cxxConstructExpr(
hasType(cxxRecordDecl(
isSameOrDerivedFrom(matchesName("[Ee]xception|EXCEPTION")))),
- unless(anyOf(hasAncestor(stmt(
- anyOf(cxxThrowExpr(), callExpr(), returnStmt()))),
- hasAncestor(decl(anyOf(varDecl(), fieldDecl()))),
- allOf(hasAncestor(CtorInitializerList),
- unless(hasAncestor(cxxCatchStmt()))))))
+ unless(anyOf(
+ hasAncestor(
+ stmt(anyOf(cxxThrowExpr(), callExpr(), returnStmt()))),
+ hasAncestor(decl(anyOf(varDecl(), fieldDecl()))),
+ hasAncestor(expr(cxxNewExpr(hasAnyPlacementArg(anything())))),
+ allOf(hasAncestor(CtorInitializerList),
+ unless(hasAncestor(cxxCatchStmt()))))))
.bind("temporary-exception-not-thrown"),
this);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115576.394575.patch
Type: text/x-patch
Size: 2438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211215/39495f36/attachment.bin>
More information about the cfe-commits
mailing list