| 1 |
/* |
| 2 |
SPDX-FileCopyrightText: 2015 Klarälvdalens Datakonsult AB a KDAB Group company [email protected] |
| 3 |
SPDX-FileContributor: Sérgio Martins <[email protected]> |
| 4 |
|
| 5 |
SPDX-FileCopyrightText: 2015 Sergio Martins <[email protected]> |
| 6 |
|
| 7 |
SPDX-License-Identifier: LGPL-2.0-or-later |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef CLAZY_UNNEEDED_CAST_H |
| 11 |
#define CLAZY_UNNEEDED_CAST_H |
| 12 |
|
| 13 |
#include "checkbase.h" |
| 14 |
|
| 15 |
namespace clang |
| 16 |
{ |
| 17 |
class CXXNamedCastExpr; |
| 18 |
class CXXRecordDecl; |
| 19 |
} // namespace clang |
| 20 |
|
| 21 |
/** |
| 22 |
* Finds redundant casts. |
| 23 |
* See README-unneeded-cast.md for more info. |
| 24 |
*/ |
| 25 |
class UnneededCast : public CheckBase |
| 26 |
{ |
| 27 |
public: |
| 28 |
using CheckBase::CheckBase; |
| 29 |
void VisitStmt(clang::Stmt *stm) override; |
| 30 |
|
| 31 |
private: |
| 32 |
bool handleNamedCast(clang::CXXNamedCastExpr *); |
| 33 |
bool handleQObjectCast(clang::Stmt *); |
| 34 |
bool maybeWarn(clang::Stmt *, clang::CXXRecordDecl *from, clang::CXXRecordDecl *to, bool isQObjectCast = false); |
| 35 |
}; |
| 36 |
|
| 37 |
#endif |