summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/check.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-10-09 23:25:02 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-10-10 08:41:06 +0200
commitc874294ad9fb178df47c66875bfbdec466e39763 (patch)
tree971d04af65ad062001134009dd5a0c49a48e90d0 /compilerplugins/clang/check.hxx
parent4c9cf046be055affee94a533f9db67f6fb0702cb (diff)
Fix detection of std::unique_ptr/shared_ptr in loplugin:redundantpointerops
...when the get member function is implemented in a base class, as happens for std::shared_ptr in libstdc++ (where it is implemented in base __shared_ptr; see also 7d361e96c9ea822790db21806e9fc05279423833 "loplugin:redundantpointerops"). And while at it, check for precisely the classes we are interested in (for which we know the semantics of get and operator*), rather than any classes whose unqualified names happen to match. Change-Id: I0c85ba46f191a2ee038c8175d979aa0c1be765cd Reviewed-on: https://gerrit.libreoffice.org/80585 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/check.hxx')
-rw-r--r--compilerplugins/clang/check.hxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/compilerplugins/clang/check.hxx b/compilerplugins/clang/check.hxx
index e027a5ca709f..7aa56cb8523d 100644
--- a/compilerplugins/clang/check.hxx
+++ b/compilerplugins/clang/check.hxx
@@ -65,6 +65,8 @@ public:
inline ContextCheck Struct(llvm::StringRef id) const;
+ inline ContextCheck ClassOrStruct(llvm::StringRef id) const;
+
TypeCheck Typedef() const;
inline ContextCheck Typedef(llvm::StringRef id) const;
@@ -189,6 +191,15 @@ ContextCheck TypeCheck::Struct(llvm::StringRef id) const
return ContextCheck();
}
+ContextCheck TypeCheck::ClassOrStruct(llvm::StringRef id) const
+{
+ auto const c1 = Class(id);
+ if (c1) {
+ return c1;
+ }
+ return Struct(id);
+}
+
ContextCheck TypeCheck::Typedef(llvm::StringRef id) const
{
if (!type_.isNull()) {