22 using namespace clang;
26 class UndefinedArraySubscriptChecker
27 :
public Checker< check::PreStmt<ArraySubscriptExpr> > {
28 mutable std::unique_ptr<BugType> BT;
37 CheckerContext &C)
const {
39 if (!C.getSVal(Index).isUndef())
44 const Decl *D = C.getLocationContext()->getDecl();
46 if (Ctor->isDefaulted())
49 ExplodedNode *N = C.generateErrorNode();
53 BT.reset(
new BuiltinBug(
this,
"Array subscript is undefined"));
56 auto R = llvm::make_unique<BugReport>(*BT, BT->getName(), N);
58 bugreporter::trackExpressionValue(N, A->
getIdx(), *R);
59 C.emitReport(std::move(R));
62 void ento::registerUndefinedArraySubscriptChecker(CheckerManager &mgr) {
63 mgr.registerChecker<UndefinedArraySubscriptChecker>();
Decl - This represents one declaration (or definition), e.g.
Represents a C++ constructor within a class.
This represents one expression.
Dataflow Directional Tag Classes.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...