| 1 |
/* |
| 2 |
SPDX-FileCopyrightText: 2016-2017 Sergio Martins <[email protected]> |
| 3 |
|
| 4 |
SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef CLAZY_UNUSED_NON_TRIVIAL_VARIABLE_H |
| 8 |
#define CLAZY_UNUSED_NON_TRIVIAL_VARIABLE_H |
| 9 |
|
| 10 |
#include "checkbase.h" |
| 11 |
|
| 12 |
#include <string> |
| 13 |
#include <vector> |
| 14 |
|
| 15 |
namespace clang |
| 16 |
{ |
| 17 |
class VarDecl; |
| 18 |
class CXXRecordDecl; |
| 19 |
class QualType; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Warns about unused Qt value classes. |
| 24 |
* Compilers usually only warn when trivial classes are unused and don't emit warnings for non-trivial classes. |
| 25 |
* This check has a whitelist of common Qt classes such as containers, QFont, QUrl, etc and warns for those too. |
| 26 |
* |
| 27 |
* See README-unused-non-trivial-variable.md for more information |
| 28 |
*/ |
| 29 |
class UnusedNonTrivialVariable : public CheckBase |
| 30 |
{ |
| 31 |
public: |
| 32 |
explicit UnusedNonTrivialVariable(const std::string &name, Options options); |
| 33 |
void VisitStmt(clang::Stmt *stmt) override; |
| 34 |
|
| 35 |
private: |
| 36 |
void handleVarDecl(clang::VarDecl *varDecl); |
| 37 |
bool isInterestingType(clang::QualType t) const; |
| 38 |
bool isUninterestingType(const clang::CXXRecordDecl *record) const; |
| 39 |
std::vector<std::string> m_userBlacklist; |
| 40 |
std::vector<std::string> m_userWhitelist; |
| 41 |
}; |
| 42 |
|
| 43 |
#endif |