21 using namespace clang;
25 class UndefinedArraySubscriptChecker
26 :
public Checker< check::PreStmt<ArraySubscriptExpr> > {
27 mutable std::unique_ptr<BugType> BT;
36 CheckerContext &C)
const {
38 if (!C.getSVal(Index).isUndef())
43 const Decl *D = C.getLocationContext()->getDecl();
45 if (Ctor->isDefaulted())
48 ExplodedNode *N = C.generateErrorNode();
52 BT.reset(
new BuiltinBug(
this,
"Array subscript is undefined"));
55 auto R = std::make_unique<PathSensitiveBugReport>(*BT, BT->getDescription(), N);
57 bugreporter::trackExpressionValue(N, A->
getIdx(), *R);
58 C.emitReport(std::move(R));
61 void ento::registerUndefinedArraySubscriptChecker(CheckerManager &mgr) {
62 mgr.registerChecker<UndefinedArraySubscriptChecker>();
65 bool ento::shouldRegisterUndefinedArraySubscriptChecker(
const LangOptions &LO) {
Decl - This represents one declaration (or definition), e.g.
Represents a C++ constructor within a class.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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...