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); }
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); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits