diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-05-27 16:00:08 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-05-27 19:51:58 +0200 |
commit | c3fbda80eb1d52239d8992eaadeabf89ee57170f (patch) | |
tree | 78222fa05db572e36382613867e765a1010d54ed /compilerplugins/clang/plugin.cxx | |
parent | a59a532371e3c4eb20e293dcdb4df812ee5506d0 (diff) |
Further fixing of loplugin:simplifypointertobool for libstdc++ std::shared_ptr
...after fe6cce01c88d045a1fcf09acf049c34c22299b02 "Fix
loplugin:simplifypointertobool for libstdc++ std::shared_ptr", this time for
uses of oox::drawingml::chart::ModelRef, which derives from std::shared_ptr.
Change-Id: I7e9620da52b3f6d26c6fe6d7909888c3a221c164
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94975
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/plugin.cxx')
-rw-r--r-- | compilerplugins/clang/plugin.cxx | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 5248927e5d84..c9e0170f2969 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -830,19 +830,21 @@ bool hasExternalLinkage(VarDecl const * decl) { bool isSmartPointerType(const Expr* e) { - // First check the object type as written, in case the get member function is - // declared at a base class of std::unique_ptr or std::shared_ptr: - auto const t = e->IgnoreImpCasts()->getType(); - auto const tc1 = loplugin::TypeCheck(t); - if (tc1.ClassOrStruct("unique_ptr").StdNamespace() - || tc1.ClassOrStruct("shared_ptr").StdNamespace()) + // First check whether the object type as written is, or is derived from, std::unique_ptr or + // std::shared_ptr, in case the get member function is declared at a base class of that std + // type: + if (loplugin::isDerivedFrom( + e->IgnoreImpCasts()->getType()->getAsCXXRecordDecl(), + [](Decl const * decl) { + auto const dc = loplugin::DeclCheck(decl); + return dc.ClassOrStruct("unique_ptr").StdNamespace() + || dc.ClassOrStruct("shared_ptr").StdNamespace(); + })) return true; // Then check the object type coerced to the type of the get member function, in // case the type-as-written is derived from one of these types (tools::SvRef is - // final, but the rest are not; but note that this will fail when the type-as- - // written is derived from std::unique_ptr or std::shared_ptr for which the get - // member function is declared at a base class): + // final, but the rest are not): auto const tc2 = loplugin::TypeCheck(e->getType()); if (tc2.ClassOrStruct("unique_ptr").StdNamespace() || tc2.ClassOrStruct("shared_ptr").StdNamespace() |