diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-03-16 15:23:52 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-03-16 21:10:27 +0100 |
commit | 10981fb2fa26474f432e85165b1babbca6d74e16 (patch) | |
tree | e90ef351a346b28da0d8f894c0879e4fa1f09c00 /compilerplugins | |
parent | a20e0ae4e346dae93bacf25deff2e7fbcbf1dbe1 (diff) |
Consistently avoid loplugin:trivialconstructor when there are defaulted params
(The template default constructor in S8 had already been suppressed via
std::distance(recordDecl->ctor_begin(), recordDecl->ctor_end()
being zero, but the similar case in S7 caused a warning.)
Change-Id: I4d18dec8bb971198eb8503262572a08c019c66bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131663
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/test/trivialconstructor.cxx | 10 | ||||
-rw-r--r-- | compilerplugins/clang/trivialconstructor.cxx | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/trivialconstructor.cxx b/compilerplugins/clang/test/trivialconstructor.cxx index ef17e9c60fee..5b48c4cf4250 100644 --- a/compilerplugins/clang/test/trivialconstructor.cxx +++ b/compilerplugins/clang/test/trivialconstructor.cxx @@ -43,4 +43,14 @@ template <typename> struct S6 template <typename T> S6(T); }; +struct S7 +{ + S7(int = 0) {} +}; + +struct S8 +{ + template <typename T> S8(T = 0) {} +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/compilerplugins/clang/trivialconstructor.cxx b/compilerplugins/clang/trivialconstructor.cxx index dd830058fac9..c991d71ae703 100644 --- a/compilerplugins/clang/trivialconstructor.cxx +++ b/compilerplugins/clang/trivialconstructor.cxx @@ -51,6 +51,8 @@ bool TrivialConstructor::VisitCXXConstructorDecl(CXXConstructorDecl const* const return true; if (!constructorDecl->isDefaultConstructor()) return true; + if (constructorDecl->getNumParams() != 0) + return true; if (!constructorDecl->inits().empty()) return true; if (constructorDecl->getExceptionSpecType() != EST_None) |