From 419d664fb7916cd529f83421e7e98e82e4a7185f Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 28 Sep 2017 18:14:13 +0200 Subject: Adapt loplugins to clang-cl's (implicit) -fdelayed-template-parsing ...which is there for MSVC compatibility, but can cause getBody() to return null even when doesThisDeclarationHaveABody() is true. And in staticmethods.cxx we need to check doesThisDeclarationHaveABody() instead of hasBody(): For some class template member functions that are only defined outside their class definition, as is the case for OSequenceIterator::hasMoreElements in include/comphelper/sequence.hxx, hasBody() may be true for the original member function declaration inside the class (as there is some later definition that does have a body), but isLateTemplateParsed() is not (it is only true for the later definition). So just skip any such declarations that are not definitions (which is sane anyway, as otherwise such functions could pointlessly be inspected multiple times). Change-Id: I724f652a8f060a931f8b5fc3e4feb5f307a922bf Reviewed-on: https://gerrit.libreoffice.org/42914 Reviewed-by: Stephan Bergmann Tested-by: Stephan Bergmann --- compilerplugins/clang/plugin.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'compilerplugins/clang/plugin.cxx') diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 5bfdc4ed3a83..c9415ab13f03 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -206,7 +206,8 @@ bool ParentBuilder::VisitFunctionDecl( const FunctionDecl* function ) { // if( ignoreLocation( declaration )) // return true; ??? - if( function->doesThisDeclarationHaveABody()) + if( function->doesThisDeclarationHaveABody() + && !function->isLateTemplateParsed()) { const Stmt* body = function->getBody(); (*parents)[ body ] = NULL; // no parent -- cgit