summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-10-01 13:54:45 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-10-01 21:41:44 +0200
commit152b3ef0f36a067e3ee07172d3057a3a728e12f1 (patch)
treedbdf088485ef82f65e504b9e02ea8ab759546a8a /compilerplugins
parentdf6bf6dd3d7f11b308f6881326de6400d44b46da (diff)
loplugin:noexceptmove: Cater for null FunctionDecl::getBody
...which can happen for function templates with clang-cl, leading to false warnings like > [build CXX] codemaker/source/commoncpp/commoncpp.cxx > In file included from codemaker/source/commoncpp/commoncpp.cxx:25: > In file included from include\codemaker/typemanager.hxx:28: > include\rtl/ref.hxx(126,5): error: move operator= can be noexcept [loplugin:noexceptmove] > Reference<reference_type> & > ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: I541c7c3d86d05964834e3e5cf678c8f1145ea132 Reviewed-on: https://gerrit.libreoffice.org/79956 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/noexceptmove.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/compilerplugins/clang/noexceptmove.cxx b/compilerplugins/clang/noexceptmove.cxx
index 1a1f2de41971..f0fd6cd899c5 100644
--- a/compilerplugins/clang/noexceptmove.cxx
+++ b/compilerplugins/clang/noexceptmove.cxx
@@ -67,7 +67,8 @@ bool NoExceptMove::TraverseCXXConstructorDecl(CXXConstructorDecl* constructorDec
&& constructorDecl->getExceptionSpecType() == EST_None
&& !constructorDecl->isDefaulted() && !constructorDecl->isDeleted()
&& !ignoreLocation(constructorDecl)
- && constructorDecl->isThisDeclarationADefinition();
+ && constructorDecl->isThisDeclarationADefinition()
+ && constructorDecl->getBody() != nullptr;
if (isMove)
{
m_ConstructorThrows.push_back(false);
@@ -115,7 +116,7 @@ bool NoExceptMove::TraverseCXXMethodDecl(CXXMethodDecl* methodDecl)
bool isMove = methodDecl->isMoveAssignmentOperator()
&& methodDecl->getExceptionSpecType() == EST_None && !methodDecl->isDefaulted()
&& !methodDecl->isDeleted() && !ignoreLocation(methodDecl)
- && methodDecl->isThisDeclarationADefinition();
+ && methodDecl->isThisDeclarationADefinition() && methodDecl->getBody() != nullptr;
if (isMove)
{
StringRef fn = getFileNameOfSpellingLoc(