summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/unusedvariablecheck.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-26 15:36:47 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-02-01 12:49:42 +0000
commit994e38e336beeacbd983faafac480afc94d3947e (patch)
treef6dd4fc3427d9051701637d2d052a9a51bb76c88 /compilerplugins/clang/unusedvariablecheck.cxx
parenteb6c18dfbeb7d2ad20ba7221d156969bd754faed (diff)
loplugin: use TypeCheck instead of getQualifiedNameAsString
since the latter is rather slow Change-Id: Ib73cdb923585580777c2265b561c1808e93b2baa Reviewed-on: https://gerrit.libreoffice.org/33585 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/unusedvariablecheck.cxx')
-rw-r--r--compilerplugins/clang/unusedvariablecheck.cxx27
1 files changed, 16 insertions, 11 deletions
diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx
index db6a45e1ae3f..50b41d5664f8 100644
--- a/compilerplugins/clang/unusedvariablecheck.cxx
+++ b/compilerplugins/clang/unusedvariablecheck.cxx
@@ -17,6 +17,7 @@
#if !HAVE_GCC_ATTRIBUTE_WARN_UNUSED_STL
#include "compat.hxx"
+#include "check.hxx"
#include "unusedvariablecheck.hxx"
#include <clang/AST/Attr.h>
@@ -56,11 +57,11 @@ bool BaseCheckNotSomethingInterestingSubclass(
#endif
)
{
- if (BaseDefinition && BaseDefinition->getQualifiedNameAsString().compare("Dialog") == 0) {
- return false;
- }
- if (BaseDefinition && BaseDefinition->getQualifiedNameAsString().compare("SfxPoolItem") == 0) {
- return false;
+ if (BaseDefinition) {
+ auto tc = loplugin::TypeCheck(BaseDefinition);
+ if (tc.Class("Dialog").GlobalNamespace() || tc.Class("SfxPoolItem").GlobalNamespace()) {
+ return false;
+ }
}
return true;
}
@@ -68,9 +69,10 @@ bool BaseCheckNotSomethingInterestingSubclass(
bool isDerivedFromSomethingInteresting(const CXXRecordDecl *decl) {
if (!decl)
return false;
- if (decl->getQualifiedNameAsString() == "Dialog")
+ auto tc = loplugin::TypeCheck(decl);
+ if (tc.Class("Dialog"))
return true;
- if (decl->getQualifiedNameAsString() == "SfxPoolItem")
+ if (tc.Class("SfxPoolItem"))
return true;
if (!decl->hasDefinition()) {
return false;
@@ -113,11 +115,14 @@ bool UnusedVariableCheck::VisitVarDecl( const VarDecl* var )
}
if( !warn_unused )
{
- string n = type->getQualifiedNameAsString();
+ auto tc = loplugin::TypeCheck(type);
// Check some common non-LO types.
- if( n == "std::string" || n == "std::basic_string"
- || n == "std::list" || n == "std::__debug::list"
- || n == "std::vector" || n == "std::__debug::vector" )
+ if( tc.Class("string").Namespace("std").GlobalNamespace()
+ || tc.Class("basic_string").Namespace("std").GlobalNamespace()
+ || tc.Class("list").Namespace("std").GlobalNamespace()
+ || tc.Class("list").Namespace("__debug").Namespace("std").GlobalNamespace()
+ || tc.Class("vector").Namespace("std").GlobalNamespace()
+ || tc.Class("vector" ).Namespace("__debug").Namespace("std").GlobalNamespace())
warn_unused = true;
if (!warn_unused && isDerivedFromSomethingInteresting(type))
warn_unused = true;