compilerplugins/clang/test/trivialdestructor.cxx | 9 +++++++++ compilerplugins/clang/trivialdestructor.cxx | 4 ++++ 2 files changed, 13 insertions(+)
New commits: commit 5b02a080474c74c06abe0a28a7f0bb50c3fe20f6 Author: Stephan Bergmann <[email protected]> AuthorDate: Thu Mar 19 09:33:01 2026 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Thu Mar 19 12:03:17 2026 +0100 Silence loplugin:trivialdestructor involving preproc cond inclusion ...as seen in non-debug builds at > dbaccess/source/core/misc/dsntypes.cxx:527:35: error: no need for explicit destructor decl [loplugin:trivialdestructor] > 527 | ODsnTypeCollection::TypeIterator::~TypeIterator() > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ > 528 | { > | ~ > 529 | #if OSL_DEBUG_LEVEL > 0 > | ~~~~~~~~~~~~~~~~~~~~~~~ > 530 | --const_cast<ODsnTypeCollection*>(m_pContainer)->m_nLivingIterators; > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 531 | #endif > | ~~~~~~ > 532 | } > | ~ > dbaccess/source/inc/dsntypes.hxx:201:5: note: previous declaration is here [loplugin:trivialdestructor] > 201 | ~TypeIterator(); > | ^~~~~~~~~~~~~~~ Change-Id: I2312649700941d4abae2a008fcf123994720b743 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202141 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/compilerplugins/clang/test/trivialdestructor.cxx b/compilerplugins/clang/test/trivialdestructor.cxx index b6ba4e968193..ff24765f701e 100644 --- a/compilerplugins/clang/test/trivialdestructor.cxx +++ b/compilerplugins/clang/test/trivialdestructor.cxx @@ -54,4 +54,13 @@ struct S5 ~S5() {} }; +struct Preproc +{ + ~Preproc() + { +#if defined MACRO +#endif + } +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/compilerplugins/clang/trivialdestructor.cxx b/compilerplugins/clang/trivialdestructor.cxx index fa4d0bad9ac9..3640c0b85dfd 100644 --- a/compilerplugins/clang/trivialdestructor.cxx +++ b/compilerplugins/clang/trivialdestructor.cxx @@ -60,6 +60,10 @@ bool TrivialDestructor::VisitCXXDestructorDecl(CXXDestructorDecl const* destruct return true; if (!HasTrivialDestructorBody(destructorDecl->getParent())) return true; + if (containsPreprocessingConditionalInclusion(destructorDecl->getBody()->getSourceRange())) + { + return true; + } report(DiagnosticsEngine::Warning, "no need for explicit destructor decl", destructorDecl->getLocation())
