37 #include "llvm/ADT/StringExtras.h" 38 #include "llvm/Support/Path.h" 40 using namespace clang;
52 std::min(static_cast<char>(Lhs), static_cast<char>(Rhs)));
55 const char *getNullabilityString(
Nullability Nullab) {
58 return "contradicted";
66 llvm_unreachable(
"Unexpected enumeration.");
75 NullableAssignedToNonnull,
76 NullableReturnedToNonnull,
78 NullablePassedToNonnull
81 class NullabilityChecker
82 :
public Checker<check::Bind, check::PreCall, check::PreStmt<ReturnStmt>,
83 check::PostCall, check::PostStmt<ExplicitCastExpr>,
84 check::PostObjCMessage, check::DeadSymbols,
85 check::Event<ImplicitNullDerefEvent>> {
86 mutable std::unique_ptr<BugType> BT;
95 DefaultBool NoDiagnoseCallsToSystemHeaders;
97 void checkBind(SVal L, SVal V,
const Stmt *S, CheckerContext &C)
const;
99 void checkPreStmt(
const ReturnStmt *S, CheckerContext &C)
const;
100 void checkPostObjCMessage(
const ObjCMethodCall &M, CheckerContext &C)
const;
101 void checkPostCall(
const CallEvent &Call, CheckerContext &C)
const;
102 void checkPreCall(
const CallEvent &Call, CheckerContext &C)
const;
103 void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C)
const;
104 void checkEvent(ImplicitNullDerefEvent Event)
const;
107 const char *Sep)
const override;
109 struct NullabilityChecksFilter {
110 DefaultBool CheckNullPassedToNonnull;
111 DefaultBool CheckNullReturnedFromNonnull;
112 DefaultBool CheckNullableDereferenced;
113 DefaultBool CheckNullablePassedToNonnull;
114 DefaultBool CheckNullableReturnedFromNonnull;
116 CheckName CheckNameNullPassedToNonnull;
117 CheckName CheckNameNullReturnedFromNonnull;
118 CheckName CheckNameNullableDereferenced;
119 CheckName CheckNameNullablePassedToNonnull;
120 CheckName CheckNameNullableReturnedFromNonnull;
123 NullabilityChecksFilter
Filter;
128 DefaultBool NeedTracking;
133 NullabilityBugVisitor(
const MemRegion *M) : Region(M) {}
135 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
138 ID.AddPointer(Region);
141 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *N,
142 BugReporterContext &BRC,
143 BugReport &BR)
override;
147 const MemRegion *Region;
155 void reportBugIfInvariantHolds(StringRef Msg,
ErrorKind Error,
156 ExplodedNode *N,
const MemRegion *Region,
158 const Stmt *ValueExpr =
nullptr,
159 bool SuppressPath =
false)
const;
161 void reportBug(StringRef Msg,
ErrorKind Error, ExplodedNode *N,
162 const MemRegion *Region, BugReporter &BR,
163 const Stmt *ValueExpr =
nullptr)
const {
167 auto R = llvm::make_unique<BugReport>(*BT, Msg, N);
169 R->markInteresting(Region);
170 R->addVisitor(llvm::make_unique<NullabilityBugVisitor>(Region));
173 R->addRange(ValueExpr->getSourceRange());
174 if (Error == ErrorKind::NilAssignedToNonnull ||
175 Error == ErrorKind::NilPassedToNonnull ||
176 Error == ErrorKind::NilReturnedToNonnull)
177 if (
const auto *Ex = dyn_cast<Expr>(ValueExpr))
178 bugreporter::trackExpressionValue(N, Ex, *R);
180 BR.emitReport(std::move(R));
185 const SymbolicRegion *getTrackRegion(SVal Val,
186 bool CheckSuperRegion =
false)
const;
190 bool isDiagnosableCall(
const CallEvent &Call)
const {
191 if (NoDiagnoseCallsToSystemHeaders && Call.isInSystemHeader())
198 class NullabilityState {
201 : Nullab(Nullab), Source(Source) {}
203 const Stmt *getNullabilitySource()
const {
return Source; }
207 void Profile(llvm::FoldingSetNodeID &
ID)
const {
208 ID.AddInteger(static_cast<char>(Nullab));
209 ID.AddPointer(Source);
212 void print(raw_ostream &Out)
const {
213 Out << getNullabilityString(Nullab) <<
"\n";
225 bool operator==(NullabilityState Lhs, NullabilityState Rhs) {
226 return Lhs.getValue() == Rhs.getValue() &&
227 Lhs.getNullabilitySource() == Rhs.getNullabilitySource();
261 enum class NullConstraint { IsNull, IsNotNull, Unknown };
265 ConditionTruthVal Nullness = State->isNull(Val);
266 if (Nullness.isConstrainedFalse())
267 return NullConstraint::IsNotNull;
268 if (Nullness.isConstrainedTrue())
269 return NullConstraint::IsNull;
273 const SymbolicRegion *
274 NullabilityChecker::getTrackRegion(SVal Val,
bool CheckSuperRegion)
const {
278 auto RegionSVal = Val.getAs<loc::MemRegionVal>();
282 const MemRegion *Region = RegionSVal->getRegion();
284 if (CheckSuperRegion) {
285 if (
auto FieldReg = Region->getAs<FieldRegion>())
286 return dyn_cast<SymbolicRegion>(FieldReg->getSuperRegion());
287 if (
auto ElementReg = Region->getAs<ElementRegion>())
288 return dyn_cast<SymbolicRegion>(ElementReg->getSuperRegion());
291 return dyn_cast<SymbolicRegion>(Region);
294 std::shared_ptr<PathDiagnosticPiece>
295 NullabilityChecker::NullabilityBugVisitor::VisitNode(
const ExplodedNode *N,
296 BugReporterContext &BRC,
301 const NullabilityState *TrackedNullab = State->get<NullabilityMap>(Region);
302 const NullabilityState *TrackedNullabPrev =
303 StatePrev->get<NullabilityMap>(Region);
307 if (TrackedNullabPrev &&
308 TrackedNullabPrev->getValue() == TrackedNullab->getValue())
312 const Stmt *S = TrackedNullab->getNullabilitySource();
320 std::string InfoText =
321 (llvm::Twine(
"Nullability '") +
322 getNullabilityString(TrackedNullab->getValue()) +
"' is inferred")
326 PathDiagnosticLocation Pos(S, BRC.getSourceManager(),
327 N->getLocationContext());
328 return std::make_shared<PathDiagnosticEventPiece>(Pos, InfoText,
true,
339 auto RegionVal = LV.getAs<loc::MemRegionVal>();
349 auto StoredVal = State->getSVal(*RegionVal).getAs<loc::MemRegionVal>();
350 if (!StoredVal || !isa<SymbolicRegion>(StoredVal->getRegion()))
363 for (
const auto *ParamDecl : Params) {
364 if (ParamDecl->isParameterPack())
367 SVal LV = State->getLValue(ParamDecl, LocCtxt);
369 ParamDecl->getType())) {
380 if (!MD || !MD->isInstanceMethod())
387 SVal SelfVal = State->getSVal(State->getRegion(SelfDecl, LocCtxt));
398 for (
const auto *IvarDecl : ID->
ivars()) {
399 SVal LV = State->getLValue(IvarDecl, SelfVal);
409 if (State->get<InvariantViolated>())
418 if (
const auto *BD = dyn_cast<BlockDecl>(D))
419 Params = BD->parameters();
420 else if (
const auto *FD = dyn_cast<FunctionDecl>(D))
421 Params = FD->parameters();
422 else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
423 Params = MD->parameters();
430 C.addTransition(State->set<InvariantViolated>(
true), N);
436 void NullabilityChecker::reportBugIfInvariantHolds(StringRef Msg,
437 ErrorKind Error, ExplodedNode *N,
const MemRegion *Region,
438 CheckerContext &C,
const Stmt *ValueExpr,
bool SuppressPath)
const {
444 OriginalState = OriginalState->set<InvariantViolated>(
true);
445 N = C.addTransition(OriginalState, N);
448 reportBug(Msg, Error, N, Region, C.getBugReporter(), ValueExpr);
452 void NullabilityChecker::checkDeadSymbols(SymbolReaper &SR,
453 CheckerContext &C)
const {
455 NullabilityMapTy Nullabilities = State->get<NullabilityMap>();
456 for (NullabilityMapTy::iterator I = Nullabilities.begin(),
457 E = Nullabilities.end();
459 const auto *Region = I->first->getAs<SymbolicRegion>();
460 assert(Region &&
"Non-symbolic region is tracked.");
461 if (SR.isDead(Region->getSymbol())) {
462 State = State->remove<NullabilityMap>(I->first);
471 C.addTransition(State);
477 void NullabilityChecker::checkEvent(ImplicitNullDerefEvent Event)
const {
478 if (Event.SinkNode->getState()->get<InvariantViolated>())
481 const MemRegion *Region =
482 getTrackRegion(Event.Location,
true);
487 const NullabilityState *TrackedNullability =
488 State->get<NullabilityMap>(Region);
490 if (!TrackedNullability)
493 if (
Filter.CheckNullableDereferenced &&
495 BugReporter &BR = *Event.BR;
498 if (Event.IsDirectDereference)
499 reportBug(
"Nullable pointer is dereferenced",
500 ErrorKind::NullableDereferenced, Event.SinkNode, Region, BR);
502 reportBug(
"Nullable pointer is passed to a callee that requires a " 503 "non-null", ErrorKind::NullablePassedToNonnull,
504 Event.SinkNode, Region, BR);
516 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(E)) {
517 E = ICE->getSubExpr();
525 void NullabilityChecker::checkPreStmt(
const ReturnStmt *S,
526 CheckerContext &C)
const {
531 if (!RetExpr->getType()->isAnyPointerType())
535 if (State->get<InvariantViolated>())
538 auto RetSVal = C.getSVal(S).getAs<DefinedOrUnknownSVal>();
542 bool InSuppressedMethodFamily =
false;
546 C.getLocationContext()->getAnalysisDeclContext();
548 if (
auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
555 InSuppressedMethodFamily =
true;
557 RequiredRetType = MD->getReturnType();
558 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
559 RequiredRetType = FD->getReturnType();
577 Nullness == NullConstraint::IsNull);
578 if (
Filter.CheckNullReturnedFromNonnull &&
579 NullReturnedFromNonNull &&
581 !InSuppressedMethodFamily &&
582 C.getLocationContext()->inTopFrame()) {
583 static CheckerProgramPointTag Tag(
this,
"NullReturnedFromNonnull");
584 ExplodedNode *N = C.generateErrorNode(State, &Tag);
589 llvm::raw_svector_ostream
OS(SBuf);
590 OS << (RetExpr->getType()->isObjCObjectPointerType() ?
"nil" :
"Null");
591 OS <<
" returned from a " << C.getDeclDescription(D) <<
592 " that is expected to return a non-null value";
593 reportBugIfInvariantHolds(OS.str(),
594 ErrorKind::NilReturnedToNonnull, N,
nullptr, C,
601 if (NullReturnedFromNonNull) {
602 State = State->set<InvariantViolated>(
true);
603 C.addTransition(State);
607 const MemRegion *Region = getTrackRegion(*RetSVal);
611 const NullabilityState *TrackedNullability =
612 State->get<NullabilityMap>(Region);
613 if (TrackedNullability) {
614 Nullability TrackedNullabValue = TrackedNullability->getValue();
615 if (
Filter.CheckNullableReturnedFromNonnull &&
616 Nullness != NullConstraint::IsNotNull &&
619 static CheckerProgramPointTag Tag(
this,
"NullableReturnedFromNonnull");
620 ExplodedNode *N = C.addTransition(State, C.getPredecessor(), &Tag);
623 llvm::raw_svector_ostream
OS(SBuf);
624 OS <<
"Nullable pointer is returned from a " << C.getDeclDescription(D) <<
625 " that is expected to return a non-null value";
627 reportBugIfInvariantHolds(OS.str(),
628 ErrorKind::NullableReturnedToNonnull, N,
634 State = State->set<NullabilityMap>(Region,
635 NullabilityState(RequiredNullability,
637 C.addTransition(State);
643 void NullabilityChecker::checkPreCall(
const CallEvent &Call,
644 CheckerContext &C)
const {
649 if (State->get<InvariantViolated>())
655 for (
const ParmVarDecl *Param : Call.parameters()) {
656 if (Param->isParameterPack())
659 if (Idx >= Call.getNumArgs())
662 const Expr *ArgExpr = Call.getArgExpr(Idx);
663 auto ArgSVal = Call.getArgSVal(Idx++).getAs<DefinedOrUnknownSVal>();
667 if (!Param->getType()->isAnyPointerType() &&
668 !Param->getType()->isReferenceType())
678 unsigned ParamIdx = Param->getFunctionScopeIndex() + 1;
680 if (
Filter.CheckNullPassedToNonnull && Nullness == NullConstraint::IsNull &&
683 isDiagnosableCall(Call)) {
684 ExplodedNode *N = C.generateErrorNode(State);
689 llvm::raw_svector_ostream
OS(SBuf);
690 OS << (Param->getType()->isObjCObjectPointerType() ?
"nil" :
"Null");
691 OS <<
" passed to a callee that requires a non-null " << ParamIdx
692 << llvm::getOrdinalSuffix(ParamIdx) <<
" parameter";
693 reportBugIfInvariantHolds(OS.str(), ErrorKind::NilPassedToNonnull, N,
699 const MemRegion *Region = getTrackRegion(*ArgSVal);
703 const NullabilityState *TrackedNullability =
704 State->get<NullabilityMap>(Region);
706 if (TrackedNullability) {
707 if (Nullness == NullConstraint::IsNotNull ||
711 if (
Filter.CheckNullablePassedToNonnull &&
713 isDiagnosableCall(Call)) {
714 ExplodedNode *N = C.addTransition(State);
716 llvm::raw_svector_ostream
OS(SBuf);
717 OS <<
"Nullable pointer is passed to a callee that requires a non-null " 718 << ParamIdx << llvm::getOrdinalSuffix(ParamIdx) <<
" parameter";
719 reportBugIfInvariantHolds(OS.str(),
720 ErrorKind::NullablePassedToNonnull, N,
721 Region, C, ArgExpr,
true);
724 if (
Filter.CheckNullableDereferenced &&
725 Param->getType()->isReferenceType()) {
726 ExplodedNode *N = C.addTransition(State);
727 reportBugIfInvariantHolds(
"Nullable pointer is dereferenced",
728 ErrorKind::NullableDereferenced, N, Region,
737 State = State->set<NullabilityMap>(
738 Region, NullabilityState(ArgExprTypeLevelNullability, ArgExpr));
740 if (State != OrigState)
741 C.addTransition(State);
745 void NullabilityChecker::checkPostCall(
const CallEvent &Call,
746 CheckerContext &C)
const {
747 auto Decl = Call.getDecl();
760 if (State->get<InvariantViolated>())
763 const MemRegion *Region = getTrackRegion(Call.getReturnValue());
771 if (llvm::sys::path::filename(FilePath).startswith(
"CG")) {
773 C.addTransition(State);
777 const NullabilityState *TrackedNullability =
778 State->get<NullabilityMap>(Region);
780 if (!TrackedNullability &&
783 C.addTransition(State);
796 if (
auto DefOrUnknown = Receiver.getAs<DefinedOrUnknownSVal>()) {
800 if (Nullness == NullConstraint::IsNotNull)
803 auto ValueRegionSVal = Receiver.getAs<loc::MemRegionVal>();
804 if (ValueRegionSVal) {
805 const MemRegion *SelfRegion = ValueRegionSVal->getRegion();
808 const NullabilityState *TrackedSelfNullability =
809 State->get<NullabilityMap>(SelfRegion);
810 if (TrackedSelfNullability)
811 return TrackedSelfNullability->getValue();
819 void NullabilityChecker::checkPostObjCMessage(
const ObjCMethodCall &M,
820 CheckerContext &C)
const {
829 if (State->get<InvariantViolated>())
832 const MemRegion *ReturnRegion = getTrackRegion(M.getReturnValue());
836 auto Interface =
Decl->getClassInterface();
837 auto Name = Interface ? Interface->getName() :
"";
841 if (Name.startswith(
"NS")) {
853 C.addTransition(State);
858 if (Name.contains(
"Array") &&
859 (FirstSelectorSlot ==
"firstObject" ||
860 FirstSelectorSlot ==
"lastObject")) {
863 C.addTransition(State);
871 if (Name.contains(
"String")) {
873 if (Param->getName() ==
"encoding") {
874 State = State->set<NullabilityMap>(ReturnRegion,
876 C.addTransition(State);
886 const NullabilityState *NullabilityOfReturn =
887 State->get<NullabilityMap>(ReturnRegion);
889 if (NullabilityOfReturn) {
893 Nullability RetValTracked = NullabilityOfReturn->getValue();
895 getMostNullable(RetValTracked, SelfNullability);
896 if (ComputedNullab != RetValTracked &&
898 const Stmt *NullabilitySource =
899 ComputedNullab == RetValTracked
900 ? NullabilityOfReturn->getNullabilitySource()
902 State = State->set<NullabilityMap>(
903 ReturnRegion, NullabilityState(ComputedNullab, NullabilitySource));
904 C.addTransition(State);
919 Nullability ComputedNullab = getMostNullable(RetNullability, SelfNullability);
921 const Stmt *NullabilitySource = ComputedNullab == RetNullability
924 State = State->set<NullabilityMap>(
925 ReturnRegion, NullabilityState(ComputedNullab, NullabilitySource));
926 C.addTransition(State);
935 CheckerContext &C)
const {
944 if (State->get<InvariantViolated>())
954 auto RegionSVal = C.getSVal(CE).getAs<DefinedOrUnknownSVal>();
955 const MemRegion *Region = getTrackRegion(*RegionSVal);
962 if (Nullness == NullConstraint::IsNull) {
964 C.addTransition(State);
969 const NullabilityState *TrackedNullability =
970 State->get<NullabilityMap>(Region);
972 if (!TrackedNullability) {
975 State = State->set<NullabilityMap>(Region,
976 NullabilityState(DestNullability, CE));
977 C.addTransition(State);
981 if (TrackedNullability->getValue() != DestNullability &&
984 C.addTransition(State);
992 if (
auto *BinOp = dyn_cast<BinaryOperator>(S)) {
993 if (BinOp->getOpcode() == BO_Assign)
994 return BinOp->getRHS();
998 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
999 if (DS->isSingleDecl()) {
1000 auto *VD = dyn_cast<
VarDecl>(DS->getSingleDecl());
1004 if (
const Expr *Init = VD->getInit())
1029 if (!C.getASTContext().getLangOpts().ObjCAutoRefCount)
1033 if (!DS || !DS->isSingleDecl())
1036 auto *VD = dyn_cast<
VarDecl>(DS->getSingleDecl());
1041 if(!VD->getType().getQualifiers().hasObjCLifetime())
1044 const Expr *Init = VD->getInit();
1045 assert(Init &&
"ObjC local under ARC without initializer");
1048 if (!isa<ImplicitValueInitExpr>(Init))
1056 void NullabilityChecker::checkBind(SVal L, SVal V,
const Stmt *S,
1057 CheckerContext &C)
const {
1058 const TypedValueRegion *TVR =
1059 dyn_cast_or_null<TypedValueRegion>(L.getAsRegion());
1063 QualType LocType = TVR->getValueType();
1068 if (State->get<InvariantViolated>())
1071 auto ValDefOrUnknown = V.getAs<DefinedOrUnknownSVal>();
1072 if (!ValDefOrUnknown)
1078 if (
SymbolRef Sym = ValDefOrUnknown->getAsSymbol())
1088 ValueExprTypeLevelNullability =
1093 RhsNullness == NullConstraint::IsNull);
1094 if (
Filter.CheckNullPassedToNonnull &&
1095 NullAssignedToNonNull &&
1099 static CheckerProgramPointTag Tag(
this,
"NullPassedToNonnull");
1100 ExplodedNode *N = C.generateErrorNode(State, &Tag);
1105 const Stmt *ValueStmt = S;
1107 ValueStmt = ValueExpr;
1110 llvm::raw_svector_ostream
OS(SBuf);
1112 OS <<
" assigned to a pointer which is expected to have non-null value";
1113 reportBugIfInvariantHolds(OS.str(),
1114 ErrorKind::NilAssignedToNonnull, N,
nullptr, C,
1121 if (NullAssignedToNonNull) {
1122 State = State->set<InvariantViolated>(
true);
1123 C.addTransition(State);
1130 const MemRegion *ValueRegion = getTrackRegion(*ValDefOrUnknown);
1134 const NullabilityState *TrackedNullability =
1135 State->get<NullabilityMap>(ValueRegion);
1137 if (TrackedNullability) {
1138 if (RhsNullness == NullConstraint::IsNotNull ||
1141 if (
Filter.CheckNullablePassedToNonnull &&
1143 static CheckerProgramPointTag Tag(
this,
"NullablePassedToNonnull");
1144 ExplodedNode *N = C.addTransition(State, C.getPredecessor(), &Tag);
1145 reportBugIfInvariantHolds(
"Nullable pointer is assigned to a pointer " 1146 "which is expected to have non-null value",
1147 ErrorKind::NullableAssignedToNonnull, N,
1158 const Stmt *NullabilitySource = BinOp ? BinOp->getRHS() : S;
1159 State = State->set<NullabilityMap>(
1160 ValueRegion, NullabilityState(ValNullability, NullabilitySource));
1161 C.addTransition(State);
1166 const Stmt *NullabilitySource = BinOp ? BinOp->getLHS() : S;
1167 State = State->set<NullabilityMap>(
1168 ValueRegion, NullabilityState(LocNullability, NullabilitySource));
1169 C.addTransition(State);
1174 const char *NL,
const char *Sep)
const {
1176 NullabilityMapTy B = State->get<NullabilityMap>();
1178 if (State->get<InvariantViolated>())
1180 <<
"Nullability invariant was violated, warnings suppressed." << NL;
1185 if (!State->get<InvariantViolated>())
1188 for (NullabilityMapTy::iterator I = B.begin(), E = B.end(); I != E; ++I) {
1189 Out << I->first <<
" : ";
1190 I->second.print(Out);
1195 #define REGISTER_CHECKER(name, trackingRequired) \ 1196 void ento::register##name##Checker(CheckerManager &mgr) { \ 1197 NullabilityChecker *checker = mgr.registerChecker<NullabilityChecker>(); \ 1198 checker->Filter.Check##name = true; \ 1199 checker->Filter.CheckName##name = mgr.getCurrentCheckName(); \ 1200 checker->NeedTracking = checker->NeedTracking || trackingRequired; \ 1201 checker->NoDiagnoseCallsToSystemHeaders = \ 1202 checker->NoDiagnoseCallsToSystemHeaders || \ 1203 mgr.getAnalyzerOptions().getCheckerBooleanOption( \ 1204 "NoDiagnoseCallsToSystemHeaders", false, checker, true); \
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)
ObjCMethodFamily
A family of Objective-C methods.
SourceLocation getBeginLoc() const LLVM_READONLY
AnalysisDeclContext contains the context data for the function or method under analysis.
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 ...
static bool checkSelfIvarsForInvariantViolation(ProgramStateRef State, const LocationContext *LocCtxt)
__DEVICE__ int min(int __a, int __b)
This class handles loading and caching of source files into memory.