diff options
Diffstat (limited to 'compilerplugins/clang/unusedmember.cxx')
-rw-r--r-- | compilerplugins/clang/unusedmember.cxx | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/compilerplugins/clang/unusedmember.cxx b/compilerplugins/clang/unusedmember.cxx index 1d3017134892..610c94e162b3 100644 --- a/compilerplugins/clang/unusedmember.cxx +++ b/compilerplugins/clang/unusedmember.cxx @@ -18,8 +18,6 @@ #include <cassert> #include <set> -#include "config_clang.h" - #include "check.hxx" #include "compat.hxx" #include "plugin.hxx" @@ -60,40 +58,21 @@ public: { } -#if CLANG_VERSION < 60000 - - bool TraverseAlignedAttr(AlignedAttr* attr) - { - bool ret = FilteringPlugin::TraverseAlignedAttr(attr); - PostTraverseAlignedAttr(attr, ret); - return ret; - } - - bool PostTraverseAlignedAttr(AlignedAttr* attr, bool run) + bool VisitDeclaratorDecl(DeclaratorDecl const* decl) { - if (!run) - { - return false; - } - if (attr->isAlignmentExpr()) - { - if (!TraverseStmt(attr->getAlignmentExpr())) - { - return false; - } - } - else if (auto const tsi = attr->getAlignmentType()) + // For declarations like + // + // enum E { ... } e; + // + // it may be that the declaration of E is not marked as referenced even though the + // declaration of e clearly references it: + if (auto const t = decl->getType()->getAs<EnumType>()) { - if (!TraverseTypeLoc(tsi->getTypeLoc())) - { - return false; - } + deferred_.erase(t->getDecl()); } return true; } -#endif - bool VisitCXXRecordDecl(CXXRecordDecl const* decl) //TODO: non-CXX RecordDecl? { if (ignoreLocation(decl)) @@ -147,6 +126,8 @@ public: { #if 0 //TODO: friend function definitions are not marked as referenced even if used? if (!d3->isThisDeclarationADefinition()) //TODO: do this check for all kinds? +#else + (void)d3; #endif { continue; @@ -174,7 +155,7 @@ public: } if (auto const d1 = dyn_cast<FieldDecl>(d)) { - if (d1->isUnnamedBitfield()) + if (compat::isUnnamedBitField(d1)) { continue; } @@ -241,6 +222,10 @@ public: return true; } auto const t1 = expr->getTypeSourceInfo()->getType(); + if (t1->isTemplateTypeParmType()) + { + return true; + } RecordDecl const* d; if (auto const t2 = t1->getAs<InjectedClassNameType>()) { @@ -264,9 +249,7 @@ public: { case UETT_SizeOf: case UETT_AlignOf: -#if CLANG_VERSION >= 80000 case UETT_PreferredAlignOf: -#endif break; default: return true; @@ -459,4 +442,6 @@ private: loplugin::Plugin::Registration<UnusedMember> unusedmember("unusedmember"); } +// Cannot be shared, uses TraverseStmt(). + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |