21 using namespace clang;
27 const CheckerBase *Checker;
32 : BR(br), Checker(checker), AC(ac) {}
34 void VisitStmt(
Stmt *S) { VisitChildren(S); }
35 void VisitChildren(
Stmt *S);
39 void WalkAST::VisitChildren(
Stmt *S) {
65 PathDiagnosticLocation ELoc =
67 BR.EmitBasicReport(AC->getDecl(), Checker,
68 "Potential unintended use of sizeof() on pointer type",
70 "The code calls sizeof() on a pointer type. " 71 "This can produce an unexpected result.",
81 class SizeofPointerChecker :
public Checker<check::ASTCodeBody> {
83 void checkASTCodeBody(
const Decl *D, AnalysisManager& mgr,
84 BugReporter &BR)
const {
85 WalkAST walker(BR,
this, mgr.getAnalysisDeclContext(D));
91 void ento::registerSizeofPointerChecker(CheckerManager &mgr) {
92 mgr.registerChecker<SizeofPointerChecker>();
A (possibly-)qualified type.
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Stmt - This represents one statement.
Decl - This represents one declaration (or definition), e.g.
AnalysisDeclContext contains the context data for the function or method under analysis.
const char *const LogicError
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
This represents one expression.
QualType getTypeOfArgument() const
Gets the argument type, or the type of the argument expression, whichever is appropriate.
static PathDiagnosticLocation createBegin(const Decl *D, const SourceManager &SM)
Create a location for the beginning of the declaration.
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
UnaryExprOrTypeTrait getKind() const
bool isArgumentType() const
Dataflow Directional Tag Classes.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isPointerType() const
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.