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 CheckerNameRef CheckNameNullPassedToNonnull;
116 CheckerNameRef CheckNameNullReturnedFromNonnull;
117 CheckerNameRef CheckNameNullableDereferenced;
118 CheckerNameRef CheckNameNullablePassedToNonnull;
119 CheckerNameRef 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);
141 BugReporterContext &BRC,
142 PathSensitiveBugReport &BR)
override;
146 const MemRegion *Region;
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 = std::make_unique<PathSensitiveBugReport>(*BT, Msg, N);
168 R->markInteresting(Region);
169 R->addVisitor(std::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);
294 const ExplodedNode *N, BugReporterContext &BRC,
295 PathSensitiveBugReport &BR) {
299 const NullabilityState *TrackedNullab = State->get<NullabilityMap>(Region);
300 const NullabilityState *TrackedNullabPrev =
301 StatePrev->get<NullabilityMap>(Region);
305 if (TrackedNullabPrev &&
306 TrackedNullabPrev->getValue() == TrackedNullab->getValue())
310 const Stmt *S = TrackedNullab->getNullabilitySource();
312 S = N->getStmtForDiagnostics();
318 std::string InfoText =
319 (llvm::Twine(
"Nullability '") +
320 getNullabilityString(TrackedNullab->getValue()) +
"' is inferred")
324 PathDiagnosticLocation Pos(S, BRC.getSourceManager(),
325 N->getLocationContext());
326 return std::make_shared<PathDiagnosticEventPiece>(Pos, InfoText,
true);
336 auto RegionVal = LV.getAs<loc::MemRegionVal>();
346 auto StoredVal = State->getSVal(*RegionVal).getAs<loc::MemRegionVal>();
347 if (!StoredVal || !isa<SymbolicRegion>(StoredVal->getRegion()))
360 for (
const auto *ParamDecl : Params) {
361 if (ParamDecl->isParameterPack())
364 SVal LV = State->getLValue(ParamDecl, LocCtxt);
366 ParamDecl->getType())) {
377 if (!MD || !MD->isInstanceMethod())
384 SVal SelfVal = State->getSVal(State->getRegion(SelfDecl, LocCtxt));
395 for (
const auto *IvarDecl : ID->
ivars()) {
396 SVal LV = State->getLValue(IvarDecl, SelfVal);
406 if (State->get<InvariantViolated>())
415 if (
const auto *BD = dyn_cast<BlockDecl>(D))
416 Params = BD->parameters();
417 else if (
const auto *FD = dyn_cast<FunctionDecl>(D))
418 Params = FD->parameters();
419 else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
420 Params = MD->parameters();
427 C.addTransition(State->set<InvariantViolated>(
true), N);
433 void NullabilityChecker::reportBugIfInvariantHolds(StringRef Msg,
435 CheckerContext &C,
const Stmt *ValueExpr,
bool SuppressPath)
const {
441 OriginalState = OriginalState->set<InvariantViolated>(
true);
442 N = C.addTransition(OriginalState, N);
445 reportBug(Msg, Error, N, Region, C.getBugReporter(), ValueExpr);
449 void NullabilityChecker::checkDeadSymbols(SymbolReaper &SR,
450 CheckerContext &C)
const {
452 NullabilityMapTy Nullabilities = State->get<NullabilityMap>();
453 for (NullabilityMapTy::iterator I = Nullabilities.begin(),
454 E = Nullabilities.end();
456 const auto *Region = I->first->getAs<SymbolicRegion>();
457 assert(Region &&
"Non-symbolic region is tracked.");
458 if (SR.isDead(Region->getSymbol())) {
459 State = State->remove<NullabilityMap>(I->first);
468 C.addTransition(State);
474 void NullabilityChecker::checkEvent(ImplicitNullDerefEvent Event)
const {
475 if (Event.SinkNode->getState()->get<InvariantViolated>())
478 const MemRegion *Region =
479 getTrackRegion(Event.Location,
true);
484 const NullabilityState *TrackedNullability =
485 State->get<NullabilityMap>(Region);
487 if (!TrackedNullability)
490 if (
Filter.CheckNullableDereferenced &&
492 BugReporter &BR = *Event.BR;
495 if (Event.IsDirectDereference)
496 reportBug(
"Nullable pointer is dereferenced",
497 ErrorKind::NullableDereferenced, Event.SinkNode, Region, BR);
499 reportBug(
"Nullable pointer is passed to a callee that requires a " 500 "non-null", ErrorKind::NullablePassedToNonnull,
501 Event.SinkNode, Region, BR);
513 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(E)) {
514 E = ICE->getSubExpr();
522 void NullabilityChecker::checkPreStmt(
const ReturnStmt *S,
523 CheckerContext &C)
const {
528 if (!RetExpr->getType()->isAnyPointerType())
532 if (State->get<InvariantViolated>())
535 auto RetSVal = C.getSVal(S).getAs<DefinedOrUnknownSVal>();
539 bool InSuppressedMethodFamily =
false;
543 C.getLocationContext()->getAnalysisDeclContext();
545 if (
auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
552 InSuppressedMethodFamily =
true;
554 RequiredRetType = MD->getReturnType();
555 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
556 RequiredRetType = FD->getReturnType();
574 Nullness == NullConstraint::IsNull);
575 if (
Filter.CheckNullReturnedFromNonnull &&
576 NullReturnedFromNonNull &&
578 !InSuppressedMethodFamily &&
579 C.getLocationContext()->inTopFrame()) {
580 static CheckerProgramPointTag Tag(
this,
"NullReturnedFromNonnull");
581 ExplodedNode *N = C.generateErrorNode(State, &Tag);
586 llvm::raw_svector_ostream
OS(SBuf);
587 OS << (RetExpr->getType()->isObjCObjectPointerType() ?
"nil" :
"Null");
588 OS <<
" returned from a " << C.getDeclDescription(D) <<
589 " that is expected to return a non-null value";
590 reportBugIfInvariantHolds(OS.str(),
591 ErrorKind::NilReturnedToNonnull, N,
nullptr, C,
598 if (NullReturnedFromNonNull) {
599 State = State->set<InvariantViolated>(
true);
600 C.addTransition(State);
604 const MemRegion *Region = getTrackRegion(*RetSVal);
608 const NullabilityState *TrackedNullability =
609 State->get<NullabilityMap>(Region);
610 if (TrackedNullability) {
611 Nullability TrackedNullabValue = TrackedNullability->getValue();
612 if (
Filter.CheckNullableReturnedFromNonnull &&
613 Nullness != NullConstraint::IsNotNull &&
616 static CheckerProgramPointTag Tag(
this,
"NullableReturnedFromNonnull");
617 ExplodedNode *N = C.addTransition(State, C.getPredecessor(), &Tag);
620 llvm::raw_svector_ostream
OS(SBuf);
621 OS <<
"Nullable pointer is returned from a " << C.getDeclDescription(D) <<
622 " that is expected to return a non-null value";
624 reportBugIfInvariantHolds(OS.str(),
625 ErrorKind::NullableReturnedToNonnull, N,
631 State = State->set<NullabilityMap>(Region,
632 NullabilityState(RequiredNullability,
634 C.addTransition(State);
640 void NullabilityChecker::checkPreCall(
const CallEvent &Call,
641 CheckerContext &C)
const {
646 if (State->get<InvariantViolated>())
652 for (
const ParmVarDecl *Param : Call.parameters()) {
653 if (Param->isParameterPack())
656 if (Idx >= Call.getNumArgs())
659 const Expr *ArgExpr = Call.getArgExpr(Idx);
660 auto ArgSVal = Call.getArgSVal(Idx++).getAs<DefinedOrUnknownSVal>();
664 if (!Param->getType()->isAnyPointerType() &&
665 !Param->getType()->isReferenceType())
675 unsigned ParamIdx = Param->getFunctionScopeIndex() + 1;
677 if (
Filter.CheckNullPassedToNonnull && Nullness == NullConstraint::IsNull &&
680 isDiagnosableCall(Call)) {
681 ExplodedNode *N = C.generateErrorNode(State);
686 llvm::raw_svector_ostream
OS(SBuf);
687 OS << (Param->getType()->isObjCObjectPointerType() ?
"nil" :
"Null");
688 OS <<
" passed to a callee that requires a non-null " << ParamIdx
689 << llvm::getOrdinalSuffix(ParamIdx) <<
" parameter";
690 reportBugIfInvariantHolds(OS.str(), ErrorKind::NilPassedToNonnull, N,
696 const MemRegion *Region = getTrackRegion(*ArgSVal);
700 const NullabilityState *TrackedNullability =
701 State->get<NullabilityMap>(Region);
703 if (TrackedNullability) {
704 if (Nullness == NullConstraint::IsNotNull ||
708 if (
Filter.CheckNullablePassedToNonnull &&
710 isDiagnosableCall(Call)) {
711 ExplodedNode *N = C.addTransition(State);
713 llvm::raw_svector_ostream
OS(SBuf);
714 OS <<
"Nullable pointer is passed to a callee that requires a non-null " 715 << ParamIdx << llvm::getOrdinalSuffix(ParamIdx) <<
" parameter";
716 reportBugIfInvariantHolds(OS.str(),
717 ErrorKind::NullablePassedToNonnull, N,
718 Region, C, ArgExpr,
true);
721 if (
Filter.CheckNullableDereferenced &&
722 Param->getType()->isReferenceType()) {
723 ExplodedNode *N = C.addTransition(State);
724 reportBugIfInvariantHolds(
"Nullable pointer is dereferenced",
725 ErrorKind::NullableDereferenced, N, Region,
732 if (State != OrigState)
733 C.addTransition(State);
737 void NullabilityChecker::checkPostCall(
const CallEvent &Call,
738 CheckerContext &C)
const {
739 auto Decl = Call.getDecl();
752 if (State->get<InvariantViolated>())
755 const MemRegion *Region = getTrackRegion(Call.getReturnValue());
763 if (llvm::sys::path::filename(FilePath).startswith(
"CG")) {
765 C.addTransition(State);
769 const NullabilityState *TrackedNullability =
770 State->get<NullabilityMap>(Region);
772 if (!TrackedNullability &&
775 C.addTransition(State);
788 if (
auto DefOrUnknown = Receiver.getAs<DefinedOrUnknownSVal>()) {
792 if (Nullness == NullConstraint::IsNotNull)
795 auto ValueRegionSVal = Receiver.getAs<loc::MemRegionVal>();
796 if (ValueRegionSVal) {
797 const MemRegion *SelfRegion = ValueRegionSVal->getRegion();
800 const NullabilityState *TrackedSelfNullability =
801 State->get<NullabilityMap>(SelfRegion);
802 if (TrackedSelfNullability)
803 return TrackedSelfNullability->getValue();
811 void NullabilityChecker::checkPostObjCMessage(
const ObjCMethodCall &M,
812 CheckerContext &C)
const {
821 if (State->get<InvariantViolated>())
824 const MemRegion *ReturnRegion = getTrackRegion(M.getReturnValue());
828 auto Interface =
Decl->getClassInterface();
829 auto Name = Interface ? Interface->getName() :
"";
833 if (Name.startswith(
"NS")) {
845 C.addTransition(State);
850 if (Name.contains(
"Array") &&
851 (FirstSelectorSlot ==
"firstObject" ||
852 FirstSelectorSlot ==
"lastObject")) {
855 C.addTransition(State);
863 if (Name.contains(
"String")) {
865 if (Param->getName() ==
"encoding") {
866 State = State->set<NullabilityMap>(ReturnRegion,
868 C.addTransition(State);
878 const NullabilityState *NullabilityOfReturn =
879 State->get<NullabilityMap>(ReturnRegion);
881 if (NullabilityOfReturn) {
885 Nullability RetValTracked = NullabilityOfReturn->getValue();
887 getMostNullable(RetValTracked, SelfNullability);
888 if (ComputedNullab != RetValTracked &&
890 const Stmt *NullabilitySource =
891 ComputedNullab == RetValTracked
892 ? NullabilityOfReturn->getNullabilitySource()
894 State = State->set<NullabilityMap>(
895 ReturnRegion, NullabilityState(ComputedNullab, NullabilitySource));
896 C.addTransition(State);
911 Nullability ComputedNullab = getMostNullable(RetNullability, SelfNullability);
913 const Stmt *NullabilitySource = ComputedNullab == RetNullability
916 State = State->set<NullabilityMap>(
917 ReturnRegion, NullabilityState(ComputedNullab, NullabilitySource));
918 C.addTransition(State);
927 CheckerContext &C)
const {
936 if (State->get<InvariantViolated>())
946 auto RegionSVal = C.getSVal(CE).getAs<DefinedOrUnknownSVal>();
947 const MemRegion *Region = getTrackRegion(*RegionSVal);
954 if (Nullness == NullConstraint::IsNull) {
956 C.addTransition(State);
961 const NullabilityState *TrackedNullability =
962 State->get<NullabilityMap>(Region);
964 if (!TrackedNullability) {
967 State = State->set<NullabilityMap>(Region,
968 NullabilityState(DestNullability, CE));
969 C.addTransition(State);
973 if (TrackedNullability->getValue() != DestNullability &&
976 C.addTransition(State);
984 if (
auto *BinOp = dyn_cast<BinaryOperator>(S)) {
985 if (BinOp->getOpcode() == BO_Assign)
986 return BinOp->getRHS();
990 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
991 if (DS->isSingleDecl()) {
992 auto *VD = dyn_cast<
VarDecl>(DS->getSingleDecl());
996 if (
const Expr *Init = VD->getInit())
1021 if (!C.getASTContext().getLangOpts().ObjCAutoRefCount)
1025 if (!DS || !DS->isSingleDecl())
1028 auto *VD = dyn_cast<
VarDecl>(DS->getSingleDecl());
1033 if(!VD->getType().getQualifiers().hasObjCLifetime())
1036 const Expr *Init = VD->getInit();
1037 assert(Init &&
"ObjC local under ARC without initializer");
1040 if (!isa<ImplicitValueInitExpr>(Init))
1048 void NullabilityChecker::checkBind(SVal L, SVal
V,
const Stmt *S,
1049 CheckerContext &C)
const {
1050 const TypedValueRegion *TVR =
1051 dyn_cast_or_null<TypedValueRegion>(L.getAsRegion());
1055 QualType LocType = TVR->getValueType();
1060 if (State->get<InvariantViolated>())
1063 auto ValDefOrUnknown = V.getAs<DefinedOrUnknownSVal>();
1064 if (!ValDefOrUnknown)
1070 if (
SymbolRef Sym = ValDefOrUnknown->getAsSymbol())
1080 ValueExprTypeLevelNullability =
1085 RhsNullness == NullConstraint::IsNull);
1086 if (
Filter.CheckNullPassedToNonnull &&
1087 NullAssignedToNonNull &&
1091 static CheckerProgramPointTag Tag(
this,
"NullPassedToNonnull");
1092 ExplodedNode *N = C.generateErrorNode(State, &Tag);
1099 ValueStmt = ValueExpr;
1102 llvm::raw_svector_ostream
OS(SBuf);
1104 OS <<
" assigned to a pointer which is expected to have non-null value";
1105 reportBugIfInvariantHolds(OS.str(),
1106 ErrorKind::NilAssignedToNonnull, N,
nullptr, C,
1113 if (NullAssignedToNonNull) {
1114 State = State->set<InvariantViolated>(
true);
1115 C.addTransition(State);
1122 const MemRegion *ValueRegion = getTrackRegion(*ValDefOrUnknown);
1126 const NullabilityState *TrackedNullability =
1127 State->get<NullabilityMap>(ValueRegion);
1129 if (TrackedNullability) {
1130 if (RhsNullness == NullConstraint::IsNotNull ||
1133 if (
Filter.CheckNullablePassedToNonnull &&
1135 static CheckerProgramPointTag Tag(
this,
"NullablePassedToNonnull");
1136 ExplodedNode *N = C.addTransition(State, C.getPredecessor(), &Tag);
1137 reportBugIfInvariantHolds(
"Nullable pointer is assigned to a pointer " 1138 "which is expected to have non-null value",
1139 ErrorKind::NullableAssignedToNonnull, N,
1150 const Stmt *NullabilitySource = BinOp ? BinOp->getRHS() : S;
1151 State = State->set<NullabilityMap>(
1152 ValueRegion, NullabilityState(ValNullability, NullabilitySource));
1153 C.addTransition(State);
1158 const Stmt *NullabilitySource = BinOp ? BinOp->getLHS() : S;
1159 State = State->set<NullabilityMap>(
1160 ValueRegion, NullabilityState(LocNullability, NullabilitySource));
1161 C.addTransition(State);
1166 const char *NL,
const char *Sep)
const {
1168 NullabilityMapTy B = State->get<NullabilityMap>();
1170 if (State->get<InvariantViolated>())
1172 <<
"Nullability invariant was violated, warnings suppressed." << NL;
1177 if (!State->get<InvariantViolated>())
1180 for (NullabilityMapTy::iterator I = B.begin(), E = B.end(); I != E; ++I) {
1181 Out << I->first <<
" : ";
1182 I->second.print(Out);
1187 void ento::registerNullabilityBase(CheckerManager &mgr) {
1188 mgr.registerChecker<NullabilityChecker>();
1191 bool ento::shouldRegisterNullabilityBase(
const LangOptions &LO) {
1195 #define REGISTER_CHECKER(name, trackingRequired) \ 1196 void ento::register##name##Checker(CheckerManager &mgr) { \ 1197 NullabilityChecker *checker = mgr.getChecker<NullabilityChecker>(); \ 1198 checker->Filter.Check##name = true; \ 1199 checker->Filter.CheckName##name = mgr.getCurrentCheckerName(); \ 1200 checker->NeedTracking = checker->NeedTracking || trackingRequired; \ 1201 checker->NoDiagnoseCallsToSystemHeaders = \ 1202 checker->NoDiagnoseCallsToSystemHeaders || \ 1203 mgr.getAnalyzerOptions().getCheckerBooleanOption( \ 1204 checker, "NoDiagnoseCallsToSystemHeaders", true); \ 1207 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)
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.
void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx, QualType Ty)
Represents a parameter to a function.
static NullConstraint getNullConstraint(DefinedOrUnknownSVal Val, ProgramStateRef State)
Represents a statement that could possibly have a value and type.
const SymExpr * SymbolRef
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...
std::shared_ptr< PathDiagnosticPiece > PathDiagnosticPieceRef
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
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.