36 #include "llvm/ADT/StringExtras.h" 37 #include "llvm/Support/Path.h" 39 using namespace clang;
51 std::min(static_cast<char>(Lhs), static_cast<char>(Rhs)));
54 const char *getNullabilityString(
Nullability Nullab) {
57 return "contradicted";
65 llvm_unreachable(
"Unexpected enumeration.");
74 NullableAssignedToNonnull,
75 NullableReturnedToNonnull,
77 NullablePassedToNonnull
80 class NullabilityChecker
81 :
public Checker<check::Bind, check::PreCall, check::PreStmt<ReturnStmt>,
82 check::PostCall, check::PostStmt<ExplicitCastExpr>,
83 check::PostObjCMessage, check::DeadSymbols,
84 check::Event<ImplicitNullDerefEvent>> {
85 mutable std::unique_ptr<BugType> BT;
94 DefaultBool NoDiagnoseCallsToSystemHeaders;
96 void checkBind(SVal L, SVal
V,
const Stmt *S, CheckerContext &C)
const;
98 void checkPreStmt(
const ReturnStmt *S, CheckerContext &C)
const;
99 void checkPostObjCMessage(
const ObjCMethodCall &M, CheckerContext &C)
const;
100 void checkPostCall(
const CallEvent &Call, CheckerContext &C)
const;
101 void checkPreCall(
const CallEvent &Call, CheckerContext &C)
const;
102 void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C)
const;
103 void checkEvent(ImplicitNullDerefEvent Event)
const;
106 const char *Sep)
const override;
108 struct NullabilityChecksFilter {
109 DefaultBool CheckNullPassedToNonnull;
110 DefaultBool CheckNullReturnedFromNonnull;
111 DefaultBool CheckNullableDereferenced;
112 DefaultBool CheckNullablePassedToNonnull;
113 DefaultBool CheckNullableReturnedFromNonnull;
115 CheckName CheckNameNullPassedToNonnull;
116 CheckName CheckNameNullReturnedFromNonnull;
117 CheckName CheckNameNullableDereferenced;
118 CheckName CheckNameNullablePassedToNonnull;
119 CheckName CheckNameNullableReturnedFromNonnull;
122 NullabilityChecksFilter
Filter;
127 DefaultBool NeedTracking;
132 NullabilityBugVisitor(
const MemRegion *M) : Region(M) {}
134 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
137 ID.AddPointer(Region);
140 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *N,
141 BugReporterContext &BRC,
142 BugReport &BR)
override;
146 const MemRegion *Region;
154 void reportBugIfInvariantHolds(StringRef Msg,
ErrorKind Error,
155 ExplodedNode *N,
const MemRegion *Region,
157 const Stmt *ValueExpr =
nullptr,
158 bool SuppressPath =
false)
const;
160 void reportBug(StringRef Msg,
ErrorKind Error, ExplodedNode *N,
161 const MemRegion *Region, BugReporter &BR,
162 const Stmt *ValueExpr =
nullptr)
const {
166 auto R = llvm::make_unique<BugReport>(*BT, Msg, N);
168 R->markInteresting(Region);
169 R->addVisitor(llvm::make_unique<NullabilityBugVisitor>(Region));
172 R->addRange(ValueExpr->getSourceRange());
173 if (Error == ErrorKind::NilAssignedToNonnull ||
174 Error == ErrorKind::NilPassedToNonnull ||
175 Error == ErrorKind::NilReturnedToNonnull)
176 if (
const auto *Ex = dyn_cast<Expr>(ValueExpr))
177 bugreporter::trackExpressionValue(N, Ex, *R);
179 BR.emitReport(std::move(R));
184 const SymbolicRegion *getTrackRegion(SVal Val,
185 bool CheckSuperRegion =
false)
const;
189 bool isDiagnosableCall(
const CallEvent &Call)
const {
190 if (NoDiagnoseCallsToSystemHeaders && Call.isInSystemHeader())
197 class NullabilityState {
200 : Nullab(Nullab), Source(Source) {}
202 const Stmt *getNullabilitySource()
const {
return Source; }
206 void Profile(llvm::FoldingSetNodeID &
ID)
const {
207 ID.AddInteger(static_cast<char>(Nullab));
208 ID.AddPointer(Source);
211 void print(raw_ostream &Out)
const {
212 Out << getNullabilityString(Nullab) <<
"\n";
224 bool operator==(NullabilityState Lhs, NullabilityState Rhs) {
225 return Lhs.getValue() == Rhs.getValue() &&
226 Lhs.getNullabilitySource() == Rhs.getNullabilitySource();
260 enum class NullConstraint { IsNull, IsNotNull, Unknown };
264 ConditionTruthVal Nullness = State->isNull(Val);
265 if (Nullness.isConstrainedFalse())
266 return NullConstraint::IsNotNull;
267 if (Nullness.isConstrainedTrue())
268 return NullConstraint::IsNull;
272 const SymbolicRegion *
273 NullabilityChecker::getTrackRegion(SVal Val,
bool CheckSuperRegion)
const {
277 auto RegionSVal = Val.getAs<loc::MemRegionVal>();
281 const MemRegion *Region = RegionSVal->getRegion();
283 if (CheckSuperRegion) {
284 if (
auto FieldReg = Region->getAs<FieldRegion>())
285 return dyn_cast<SymbolicRegion>(FieldReg->getSuperRegion());
286 if (
auto ElementReg = Region->getAs<ElementRegion>())
287 return dyn_cast<SymbolicRegion>(ElementReg->getSuperRegion());
290 return dyn_cast<SymbolicRegion>(Region);
293 std::shared_ptr<PathDiagnosticPiece>
294 NullabilityChecker::NullabilityBugVisitor::VisitNode(
const ExplodedNode *N,
295 BugReporterContext &BRC,
300 const NullabilityState *TrackedNullab = State->get<NullabilityMap>(Region);
301 const NullabilityState *TrackedNullabPrev =
302 StatePrev->get<NullabilityMap>(Region);
306 if (TrackedNullabPrev &&
307 TrackedNullabPrev->getValue() == TrackedNullab->getValue())
311 const Stmt *S = TrackedNullab->getNullabilitySource();
319 std::string InfoText =
320 (llvm::Twine(
"Nullability '") +
321 getNullabilityString(TrackedNullab->getValue()) +
"' is inferred")
325 PathDiagnosticLocation Pos(S, BRC.getSourceManager(),
326 N->getLocationContext());
327 return std::make_shared<PathDiagnosticEventPiece>(Pos, InfoText,
true,
338 auto RegionVal = LV.getAs<loc::MemRegionVal>();
348 auto StoredVal = State->getSVal(*RegionVal).getAs<loc::MemRegionVal>();
349 if (!StoredVal || !isa<SymbolicRegion>(StoredVal->getRegion()))
362 for (
const auto *ParamDecl : Params) {
363 if (ParamDecl->isParameterPack())
366 SVal LV = State->getLValue(ParamDecl, LocCtxt);
368 ParamDecl->getType())) {
379 if (!MD || !MD->isInstanceMethod())
386 SVal SelfVal = State->getSVal(State->getRegion(SelfDecl, LocCtxt));
397 for (
const auto *IvarDecl : ID->
ivars()) {
398 SVal LV = State->getLValue(IvarDecl, SelfVal);
408 if (State->get<InvariantViolated>())
417 if (
const auto *BD = dyn_cast<BlockDecl>(D))
418 Params = BD->parameters();
419 else if (
const auto *FD = dyn_cast<FunctionDecl>(D))
420 Params = FD->parameters();
421 else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
422 Params = MD->parameters();
429 C.addTransition(State->set<InvariantViolated>(
true), N);
435 void NullabilityChecker::reportBugIfInvariantHolds(StringRef Msg,
436 ErrorKind Error, ExplodedNode *N,
const MemRegion *Region,
437 CheckerContext &C,
const Stmt *ValueExpr,
bool SuppressPath)
const {
443 OriginalState = OriginalState->set<InvariantViolated>(
true);
444 N = C.addTransition(OriginalState, N);
447 reportBug(Msg, Error, N, Region, C.getBugReporter(), ValueExpr);
451 void NullabilityChecker::checkDeadSymbols(SymbolReaper &SR,
452 CheckerContext &C)
const {
454 NullabilityMapTy Nullabilities = State->get<NullabilityMap>();
455 for (NullabilityMapTy::iterator I = Nullabilities.begin(),
456 E = Nullabilities.end();
458 const auto *Region = I->first->getAs<SymbolicRegion>();
459 assert(Region &&
"Non-symbolic region is tracked.");
460 if (SR.isDead(Region->getSymbol())) {
461 State = State->remove<NullabilityMap>(I->first);
470 C.addTransition(State);
476 void NullabilityChecker::checkEvent(ImplicitNullDerefEvent Event)
const {
477 if (Event.SinkNode->getState()->get<InvariantViolated>())
480 const MemRegion *Region =
481 getTrackRegion(Event.Location,
true);
486 const NullabilityState *TrackedNullability =
487 State->get<NullabilityMap>(Region);
489 if (!TrackedNullability)
492 if (
Filter.CheckNullableDereferenced &&
494 BugReporter &BR = *Event.BR;
497 if (Event.IsDirectDereference)
498 reportBug(
"Nullable pointer is dereferenced",
499 ErrorKind::NullableDereferenced, Event.SinkNode, Region, BR);
501 reportBug(
"Nullable pointer is passed to a callee that requires a " 502 "non-null", ErrorKind::NullablePassedToNonnull,
503 Event.SinkNode, Region, BR);
515 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(E)) {
516 E = ICE->getSubExpr();
524 void NullabilityChecker::checkPreStmt(
const ReturnStmt *S,
525 CheckerContext &C)
const {
530 if (!RetExpr->getType()->isAnyPointerType())
534 if (State->get<InvariantViolated>())
537 auto RetSVal = C.getSVal(S).getAs<DefinedOrUnknownSVal>();
541 bool InSuppressedMethodFamily =
false;
545 C.getLocationContext()->getAnalysisDeclContext();
547 if (
auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
554 InSuppressedMethodFamily =
true;
556 RequiredRetType = MD->getReturnType();
557 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
558 RequiredRetType = FD->getReturnType();
576 Nullness == NullConstraint::IsNull);
577 if (
Filter.CheckNullReturnedFromNonnull &&
578 NullReturnedFromNonNull &&
580 !InSuppressedMethodFamily &&
581 C.getLocationContext()->inTopFrame()) {
582 static CheckerProgramPointTag Tag(
this,
"NullReturnedFromNonnull");
583 ExplodedNode *N = C.generateErrorNode(State, &Tag);
588 llvm::raw_svector_ostream
OS(SBuf);
589 OS << (RetExpr->getType()->isObjCObjectPointerType() ?
"nil" :
"Null");
590 OS <<
" returned from a " << C.getDeclDescription(D) <<
591 " that is expected to return a non-null value";
592 reportBugIfInvariantHolds(OS.str(),
593 ErrorKind::NilReturnedToNonnull, N,
nullptr, C,
600 if (NullReturnedFromNonNull) {
601 State = State->set<InvariantViolated>(
true);
602 C.addTransition(State);
606 const MemRegion *Region = getTrackRegion(*RetSVal);
610 const NullabilityState *TrackedNullability =
611 State->get<NullabilityMap>(Region);
612 if (TrackedNullability) {
613 Nullability TrackedNullabValue = TrackedNullability->getValue();
614 if (
Filter.CheckNullableReturnedFromNonnull &&
615 Nullness != NullConstraint::IsNotNull &&
618 static CheckerProgramPointTag Tag(
this,
"NullableReturnedFromNonnull");
619 ExplodedNode *N = C.addTransition(State, C.getPredecessor(), &Tag);
622 llvm::raw_svector_ostream
OS(SBuf);
623 OS <<
"Nullable pointer is returned from a " << C.getDeclDescription(D) <<
624 " that is expected to return a non-null value";
626 reportBugIfInvariantHolds(OS.str(),
627 ErrorKind::NullableReturnedToNonnull, N,
633 State = State->set<NullabilityMap>(Region,
634 NullabilityState(RequiredNullability,
636 C.addTransition(State);
642 void NullabilityChecker::checkPreCall(
const CallEvent &Call,
643 CheckerContext &C)
const {
648 if (State->get<InvariantViolated>())
654 for (
const ParmVarDecl *Param : Call.parameters()) {
655 if (Param->isParameterPack())
658 if (Idx >= Call.getNumArgs())
661 const Expr *ArgExpr = Call.getArgExpr(Idx);
662 auto ArgSVal = Call.getArgSVal(Idx++).getAs<DefinedOrUnknownSVal>();
666 if (!Param->getType()->isAnyPointerType() &&
667 !Param->getType()->isReferenceType())
677 unsigned ParamIdx = Param->getFunctionScopeIndex() + 1;
679 if (
Filter.CheckNullPassedToNonnull && Nullness == NullConstraint::IsNull &&
682 isDiagnosableCall(Call)) {
683 ExplodedNode *N = C.generateErrorNode(State);
688 llvm::raw_svector_ostream
OS(SBuf);
689 OS << (Param->getType()->isObjCObjectPointerType() ?
"nil" :
"Null");
690 OS <<
" passed to a callee that requires a non-null " << ParamIdx
691 << llvm::getOrdinalSuffix(ParamIdx) <<
" parameter";
692 reportBugIfInvariantHolds(OS.str(), ErrorKind::NilPassedToNonnull, N,
698 const MemRegion *Region = getTrackRegion(*ArgSVal);
702 const NullabilityState *TrackedNullability =
703 State->get<NullabilityMap>(Region);
705 if (TrackedNullability) {
706 if (Nullness == NullConstraint::IsNotNull ||
710 if (
Filter.CheckNullablePassedToNonnull &&
712 isDiagnosableCall(Call)) {
713 ExplodedNode *N = C.addTransition(State);
715 llvm::raw_svector_ostream
OS(SBuf);
716 OS <<
"Nullable pointer is passed to a callee that requires a non-null " 717 << ParamIdx << llvm::getOrdinalSuffix(ParamIdx) <<
" parameter";
718 reportBugIfInvariantHolds(OS.str(),
719 ErrorKind::NullablePassedToNonnull, N,
720 Region, C, ArgExpr,
true);
723 if (
Filter.CheckNullableDereferenced &&
724 Param->getType()->isReferenceType()) {
725 ExplodedNode *N = C.addTransition(State);
726 reportBugIfInvariantHolds(
"Nullable pointer is dereferenced",
727 ErrorKind::NullableDereferenced, N, Region,
736 State = State->set<NullabilityMap>(
737 Region, NullabilityState(ArgExprTypeLevelNullability, ArgExpr));
739 if (State != OrigState)
740 C.addTransition(State);
744 void NullabilityChecker::checkPostCall(
const CallEvent &Call,
745 CheckerContext &C)
const {
746 auto Decl = Call.getDecl();
759 if (State->get<InvariantViolated>())
762 const MemRegion *Region = getTrackRegion(Call.getReturnValue());
770 if (llvm::sys::path::filename(FilePath).startswith(
"CG")) {
772 C.addTransition(State);
776 const NullabilityState *TrackedNullability =
777 State->get<NullabilityMap>(Region);
779 if (!TrackedNullability &&
782 C.addTransition(State);
795 if (
auto DefOrUnknown = Receiver.getAs<DefinedOrUnknownSVal>()) {
799 if (Nullness == NullConstraint::IsNotNull)
802 auto ValueRegionSVal = Receiver.getAs<loc::MemRegionVal>();
803 if (ValueRegionSVal) {
804 const MemRegion *SelfRegion = ValueRegionSVal->getRegion();
807 const NullabilityState *TrackedSelfNullability =
808 State->get<NullabilityMap>(SelfRegion);
809 if (TrackedSelfNullability)
810 return TrackedSelfNullability->getValue();
818 void NullabilityChecker::checkPostObjCMessage(
const ObjCMethodCall &M,
819 CheckerContext &C)
const {
828 if (State->get<InvariantViolated>())
831 const MemRegion *ReturnRegion = getTrackRegion(M.getReturnValue());
835 auto Interface =
Decl->getClassInterface();
836 auto Name = Interface ? Interface->getName() :
"";
840 if (Name.startswith(
"NS")) {
852 C.addTransition(State);
857 if (Name.contains(
"Array") &&
858 (FirstSelectorSlot ==
"firstObject" ||
859 FirstSelectorSlot ==
"lastObject")) {
862 C.addTransition(State);
870 if (Name.contains(
"String")) {
872 if (Param->getName() ==
"encoding") {
873 State = State->set<NullabilityMap>(ReturnRegion,
875 C.addTransition(State);
885 const NullabilityState *NullabilityOfReturn =
886 State->get<NullabilityMap>(ReturnRegion);
888 if (NullabilityOfReturn) {
892 Nullability RetValTracked = NullabilityOfReturn->getValue();
894 getMostNullable(RetValTracked, SelfNullability);
895 if (ComputedNullab != RetValTracked &&
897 const Stmt *NullabilitySource =
898 ComputedNullab == RetValTracked
899 ? NullabilityOfReturn->getNullabilitySource()
901 State = State->set<NullabilityMap>(
902 ReturnRegion, NullabilityState(ComputedNullab, NullabilitySource));
903 C.addTransition(State);
918 Nullability ComputedNullab = getMostNullable(RetNullability, SelfNullability);
920 const Stmt *NullabilitySource = ComputedNullab == RetNullability
923 State = State->set<NullabilityMap>(
924 ReturnRegion, NullabilityState(ComputedNullab, NullabilitySource));
925 C.addTransition(State);
934 CheckerContext &C)
const {
943 if (State->get<InvariantViolated>())
953 auto RegionSVal = C.getSVal(CE).getAs<DefinedOrUnknownSVal>();
954 const MemRegion *Region = getTrackRegion(*RegionSVal);
961 if (Nullness == NullConstraint::IsNull) {
963 C.addTransition(State);
968 const NullabilityState *TrackedNullability =
969 State->get<NullabilityMap>(Region);
971 if (!TrackedNullability) {
974 State = State->set<NullabilityMap>(Region,
975 NullabilityState(DestNullability, CE));
976 C.addTransition(State);
980 if (TrackedNullability->getValue() != DestNullability &&
983 C.addTransition(State);
991 if (
auto *BinOp = dyn_cast<BinaryOperator>(S)) {
992 if (BinOp->getOpcode() == BO_Assign)
993 return BinOp->getRHS();
997 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
998 if (DS->isSingleDecl()) {
999 auto *VD = dyn_cast<
VarDecl>(DS->getSingleDecl());
1003 if (
const Expr *Init = VD->getInit())
1028 if (!C.getASTContext().getLangOpts().ObjCAutoRefCount)
1032 if (!DS || !DS->isSingleDecl())
1035 auto *VD = dyn_cast<
VarDecl>(DS->getSingleDecl());
1040 if(!VD->getType().getQualifiers().hasObjCLifetime())
1043 const Expr *Init = VD->getInit();
1044 assert(Init &&
"ObjC local under ARC without initializer");
1047 if (!isa<ImplicitValueInitExpr>(Init))
1055 void NullabilityChecker::checkBind(SVal L, SVal
V,
const Stmt *S,
1056 CheckerContext &C)
const {
1057 const TypedValueRegion *TVR =
1058 dyn_cast_or_null<TypedValueRegion>(L.getAsRegion());
1062 QualType LocType = TVR->getValueType();
1067 if (State->get<InvariantViolated>())
1070 auto ValDefOrUnknown = V.getAs<DefinedOrUnknownSVal>();
1071 if (!ValDefOrUnknown)
1077 if (
SymbolRef Sym = ValDefOrUnknown->getAsSymbol())
1087 ValueExprTypeLevelNullability =
1092 RhsNullness == NullConstraint::IsNull);
1093 if (
Filter.CheckNullPassedToNonnull &&
1094 NullAssignedToNonNull &&
1098 static CheckerProgramPointTag Tag(
this,
"NullPassedToNonnull");
1099 ExplodedNode *N = C.generateErrorNode(State, &Tag);
1106 ValueStmt = ValueExpr;
1109 llvm::raw_svector_ostream
OS(SBuf);
1111 OS <<
" assigned to a pointer which is expected to have non-null value";
1112 reportBugIfInvariantHolds(OS.str(),
1113 ErrorKind::NilAssignedToNonnull, N,
nullptr, C,
1120 if (NullAssignedToNonNull) {
1121 State = State->set<InvariantViolated>(
true);
1122 C.addTransition(State);
1129 const MemRegion *ValueRegion = getTrackRegion(*ValDefOrUnknown);
1133 const NullabilityState *TrackedNullability =
1134 State->get<NullabilityMap>(ValueRegion);
1136 if (TrackedNullability) {
1137 if (RhsNullness == NullConstraint::IsNotNull ||
1140 if (
Filter.CheckNullablePassedToNonnull &&
1142 static CheckerProgramPointTag Tag(
this,
"NullablePassedToNonnull");
1143 ExplodedNode *N = C.addTransition(State, C.getPredecessor(), &Tag);
1144 reportBugIfInvariantHolds(
"Nullable pointer is assigned to a pointer " 1145 "which is expected to have non-null value",
1146 ErrorKind::NullableAssignedToNonnull, N,
1157 const Stmt *NullabilitySource = BinOp ? BinOp->getRHS() : S;
1158 State = State->set<NullabilityMap>(
1159 ValueRegion, NullabilityState(ValNullability, NullabilitySource));
1160 C.addTransition(State);
1165 const Stmt *NullabilitySource = BinOp ? BinOp->getLHS() : S;
1166 State = State->set<NullabilityMap>(
1167 ValueRegion, NullabilityState(LocNullability, NullabilitySource));
1168 C.addTransition(State);
1173 const char *NL,
const char *Sep)
const {
1175 NullabilityMapTy B = State->get<NullabilityMap>();
1177 if (State->get<InvariantViolated>())
1179 <<
"Nullability invariant was violated, warnings suppressed." << NL;
1184 if (!State->get<InvariantViolated>())
1187 for (NullabilityMapTy::iterator I = B.begin(), E = B.end(); I != E; ++I) {
1188 Out << I->first <<
" : ";
1189 I->second.print(Out);
1194 void ento::registerNullabilityBase(CheckerManager &mgr) {
1195 mgr.registerChecker<NullabilityChecker>();
1198 bool ento::shouldRegisterNullabilityBase(
const LangOptions &LO) {
1202 #define REGISTER_CHECKER(name, trackingRequired) \ 1203 void ento::register##name##Checker(CheckerManager &mgr) { \ 1204 NullabilityChecker *checker = mgr.getChecker<NullabilityChecker>(); \ 1205 checker->Filter.Check##name = true; \ 1206 checker->Filter.CheckName##name = mgr.getCurrentCheckName(); \ 1207 checker->NeedTracking = checker->NeedTracking || trackingRequired; \ 1208 checker->NoDiagnoseCallsToSystemHeaders = \ 1209 checker->NoDiagnoseCallsToSystemHeaders || \ 1210 mgr.getAnalyzerOptions().getCheckerBooleanOption( \ 1211 checker, "NoDiagnoseCallsToSystemHeaders", true); \ 1214 bool ento::shouldRegister##name##Checker(const LangOptions &LO) { \
SVal getReceiverSVal() const
Returns the value of the receiver at the time of this call.
static bool checkParamsForPreconditionViolation(ArrayRef< ParmVarDecl *> Params, ProgramStateRef State, const LocationContext *LocCtxt)
A (possibly-)qualified type.
const char *const MemoryError
bool operator==(CanQual< T > x, CanQual< U > y)
const SymExpr * SymbolRef
Stmt - This represents one statement.
FunctionType - C99 6.7.5.3 - Function Declarators.
static bool checkValueAtLValForInvariantViolation(ProgramStateRef State, SVal LV, QualType T)
Returns true when the value stored at the given location has been constrained to null after being pas...
Decl - This represents one declaration (or definition), e.g.
SourceLocation getBeginLoc() const LLVM_READONLY
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
static Nullability getReceiverNullability(const ObjCMethodCall &M, ProgramStateRef State)
Represents a variable declaration or definition.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a parameter to a function.
static NullConstraint getNullConstraint(DefinedOrUnknownSVal Val, ProgramStateRef State)
Represents a statement that could possibly have a value and type.
ObjCMethodFamily
A family of Objective-C methods.
SourceLocation getBeginLoc() const LLVM_READONLY
AnalysisDeclContext contains the context data for the function or method under analysis.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Represents any expression that calls an Objective-C method.
const ImplicitParamDecl * getSelfDecl() const
A builtin binary operation expression such as "x + y" or "x <= y".
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
Represents an ObjC class declaration.
bool isReceiverSelfOrSuper() const
Checks if the receiver refers to 'self' or 'super'.
ArrayRef< ParmVarDecl * > parameters() const override
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible. ...
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
This represents one expression.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
static SVal getValue(SVal val, SValBuilder &svalBuilder)
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
An expression that sends a message to the given Objective-C object or class.
#define REGISTER_CHECKER(name, trackingRequired)
REGISTER_MAP_WITH_PROGRAMSTATE(NullabilityMap, const MemRegion *, NullabilityState) enum class NullConstraint
static const Stmt * getStmt(const ExplodedNode *N)
Given an exploded node, retrieve the statement that should be used for the diagnostic location...
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
#define REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, Type)
Declares a program state trait for type Type called Name, and introduce a type named NameTy...
QualType getReturnType() const
static bool isARCNilInitializedLocal(CheckerContext &C, const Stmt *S)
Returns true if.
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
static const Expr * lookThroughImplicitCasts(const Expr *E)
Find the outermost subexpression of E that is not an implicit cast.
const Decl * getDecl() const
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
static bool checkInvariantViolation(ProgramStateRef State, ExplodedNode *N, CheckerContext &C)
static const Expr * matchValueExprForBind(const Stmt *S)
For a given statement performing a bind, attempt to syntactically match the expression resulting in t...
const ObjCMethodDecl * getDecl() const override
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
virtual const ObjCMessageExpr * getOriginExpr() const
Selector getSelector() const
Dataflow Directional Tag Classes.
Nullability getNullabilityAnnotation(QualType Type)
Get nullability annotation for a given type.
ExplicitCastExpr - An explicit cast written in the source code.
ObjCMessageKind getMessageKind() const
Returns how the message was written in the source (property access, subscript, or explicit message se...
const Decl * getDecl() const
Represents a pointer to an Objective C object.
bool isInstanceMessage() const
Indicates that the tracking object is a descendant of a referenced-counted OSObject, used in the Darwin kernel.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
__DEVICE__ int min(int __a, int __b)
static bool checkSelfIvarsForInvariantViolation(ProgramStateRef State, const LocationContext *LocCtxt)
This class handles loading and caching of source files into memory.