33#include "llvm/ADT/STLExtras.h"
34#include "llvm/ADT/StringMap.h"
35#include "llvm/Support/raw_ostream.h"
43class APIMisuse :
public BugType {
45 APIMisuse(
const CheckerBase *checker,
const char *name)
56 return ID->getIdentifier()->getName();
72 bool IncludeSuperclasses =
true) {
73 static const llvm::StringMap<FoundationClass> Classes{
81 FoundationClass result = Classes.lookup(ID->getIdentifier()->getName());
82 if (result ==
FC_None && IncludeSuperclasses)
94class NilArgChecker :
public Checker<check::PreObjCMessage,
95 check::PostStmt<ObjCDictionaryLiteral>,
96 check::PostStmt<ObjCArrayLiteral>,
97 EventDispatcher<ImplicitNullDerefEvent>> {
98 const APIMisuse BT{
this,
"nil argument"};
100 mutable llvm::SmallDenseMap<Selector, unsigned, 16> StringSelectors;
101 mutable Selector ArrayWithObjectSel;
102 mutable Selector AddObjectSel;
103 mutable Selector InsertObjectAtIndexSel;
104 mutable Selector ReplaceObjectAtIndexWithObjectSel;
105 mutable Selector SetObjectAtIndexedSubscriptSel;
106 mutable Selector ArrayByAddingObjectSel;
107 mutable Selector DictionaryWithObjectForKeySel;
108 mutable Selector SetObjectForKeySel;
109 mutable Selector SetObjectForKeyedSubscriptSel;
110 mutable Selector RemoveObjectForKeySel;
112 void warnIfNilExpr(
const Expr *E,
const char *Msg, CheckerContext &
C)
const;
114 void warnIfNilArg(CheckerContext &
C,
const ObjCMethodCall &msg,
unsigned Arg,
117 void generateBugReport(ExplodedNode *N, StringRef Msg, SourceRange Range,
118 const Expr *Expr, CheckerContext &
C)
const;
121 void checkPreObjCMessage(
const ObjCMethodCall &M, CheckerContext &
C)
const;
122 void checkPostStmt(
const ObjCDictionaryLiteral *DL, CheckerContext &
C)
const;
123 void checkPostStmt(
const ObjCArrayLiteral *AL, CheckerContext &
C)
const;
127void NilArgChecker::warnIfNilExpr(
const Expr *E,
130 auto Location =
C.getSVal(E).getAs<Loc>();
138 if (ExplodedNode *N =
C.generateErrorNode()) {
147 if (ExplodedNode *N =
C.generateSink(Null,
C.getPredecessor())) {
148 dispatchEvent({*Location,
false, N, &
C.getBugReporter(),
155void NilArgChecker::warnIfNilArg(CheckerContext &
C,
156 const ObjCMethodCall &msg,
159 bool CanBeSubscript)
const {
162 if (!State->isNull(msg.
getArgSVal(Arg)).isConstrainedTrue())
170 if (ExplodedNode *N =
C.generateErrorNode()) {
171 SmallString<128> sbuf;
172 llvm::raw_svector_ostream os(sbuf);
177 os <<
"Array element cannot be nil";
180 os <<
"Value stored into '";
187 llvm_unreachable(
"Missing foundation class for the subscript expr");
192 os <<
"Value argument ";
195 os <<
"Key argument ";
199 os <<
"' cannot be nil";
203 os <<
"' cannot be nil";
212void NilArgChecker::generateBugReport(ExplodedNode *N,
216 CheckerContext &
C)
const {
217 auto R = std::make_unique<PathSensitiveBugReport>(BT, Msg, N);
220 C.emitReport(std::move(R));
223void NilArgChecker::checkPreObjCMessage(
const ObjCMethodCall &msg,
224 CheckerContext &
C)
const {
231 static const unsigned InvalidArgIndex =
UINT_MAX;
232 unsigned Arg = InvalidArgIndex;
233 bool CanBeSubscript =
false;
241 if (StringSelectors.empty()) {
242 ASTContext &Ctx =
C.getASTContext();
255 for (Selector KnownSel : Sels)
256 StringSelectors[KnownSel] = 0;
258 auto I = StringSelectors.find(S);
259 if (I == StringSelectors.end())
268 if (ArrayWithObjectSel.
isNull()) {
269 ASTContext &Ctx =
C.getASTContext();
272 InsertObjectAtIndexSel =
274 ReplaceObjectAtIndexWithObjectSel =
276 SetObjectAtIndexedSubscriptSel =
281 if (S == ArrayWithObjectSel || S == AddObjectSel ||
282 S == InsertObjectAtIndexSel || S == ArrayByAddingObjectSel) {
284 }
else if (S == SetObjectAtIndexedSubscriptSel) {
286 CanBeSubscript =
true;
287 }
else if (S == ReplaceObjectAtIndexWithObjectSel) {
296 if (DictionaryWithObjectForKeySel.
isNull()) {
297 ASTContext &Ctx =
C.getASTContext();
298 DictionaryWithObjectForKeySel =
301 SetObjectForKeyedSubscriptSel =
306 if (S == DictionaryWithObjectForKeySel || S == SetObjectForKeySel) {
308 warnIfNilArg(
C, msg, 1,
Class);
309 }
else if (S == SetObjectForKeyedSubscriptSel) {
310 CanBeSubscript =
true;
312 }
else if (S == RemoveObjectForKeySel) {
318 if ((Arg != InvalidArgIndex))
319 warnIfNilArg(
C, msg, Arg,
Class, CanBeSubscript);
322void NilArgChecker::checkPostStmt(
const ObjCArrayLiteral *AL,
323 CheckerContext &
C)
const {
325 for (
unsigned i = 0; i < NumOfElements; ++i) {
326 warnIfNilExpr(AL->
getElement(i),
"Array element cannot be nil",
C);
330void NilArgChecker::checkPostStmt(
const ObjCDictionaryLiteral *DL,
331 CheckerContext &
C)
const {
333 for (
unsigned i = 0; i < NumOfElements; ++i) {
335 warnIfNilExpr(Element.
Key,
"Dictionary key cannot be nil",
C);
336 warnIfNilExpr(Element.
Value,
"Dictionary value cannot be nil",
C);
345class CFNumberChecker :
public Checker< check::PreStmt<CallExpr> > {
346 const APIMisuse BT{
this,
"Bad use of CFNumber APIs"};
347 mutable IdentifierInfo *ICreate =
nullptr, *IGetValue =
nullptr;
349 CFNumberChecker() =
default;
351 void checkPreStmt(
const CallExpr *CE, CheckerContext &
C)
const;
375 static const unsigned char FixedSize[] = { 8, 16, 32, 64, 32, 64 };
378 return FixedSize[i-1];
402static const char* GetCFNumberTypeStr(uint64_t i) {
403 static const char* Names[] = {
404 "kCFNumberSInt8Type",
405 "kCFNumberSInt16Type",
406 "kCFNumberSInt32Type",
407 "kCFNumberSInt64Type",
408 "kCFNumberFloat32Type",
409 "kCFNumberFloat64Type",
411 "kCFNumberShortType",
414 "kCFNumberLongLongType",
415 "kCFNumberFloatType",
416 "kCFNumberDoubleType",
417 "kCFNumberCFIndexType",
418 "kCFNumberNSIntegerType",
419 "kCFNumberCGFloatType"
426void CFNumberChecker::checkPreStmt(
const CallExpr *CE,
427 CheckerContext &
C)
const {
428 const FunctionDecl *FD =
C.getCalleeDecl(CE);
432 ASTContext &Ctx =
C.getASTContext();
434 ICreate = &Ctx.
Idents.
get(
"CFNumberCreate");
435 IGetValue = &Ctx.
Idents.
get(
"CFNumberGetValue");
442 SVal TheTypeVal =
C.getSVal(CE->
getArg(1));
446 std::optional<nonloc::ConcreteInt>
V =
447 dyn_cast<nonloc::ConcreteInt>(TheTypeVal);
451 uint64_t NumberKind =
V->getValue()->getLimitedValue();
452 std::optional<uint64_t> OptCFNumberSize =
GetCFNumberSize(Ctx, NumberKind);
455 if (!OptCFNumberSize)
458 uint64_t CFNumberSize = *OptCFNumberSize;
463 SVal TheValueExpr =
C.getSVal(CE->
getArg(2));
467 std::optional<loc::MemRegionVal> LV = TheValueExpr.
getAs<loc::MemRegionVal>();
471 const TypedValueRegion*
R = dyn_cast<TypedValueRegion>(LV->stripCasts());
485 if (PrimitiveTypeSize == CFNumberSize)
490 ExplodedNode *N =
C.generateNonFatalErrorNode();
492 SmallString<128> sbuf;
493 llvm::raw_svector_ostream os(sbuf);
497 os << (PrimitiveTypeSize == 8 ?
"An " :
"A ")
498 << PrimitiveTypeSize <<
"-bit integer is used to initialize a "
499 <<
"CFNumber object that represents "
500 << (CFNumberSize == 8 ?
"an " :
"a ")
501 << CFNumberSize <<
"-bit integer; ";
503 os <<
"A CFNumber object that represents "
504 << (CFNumberSize == 8 ?
"an " :
"a ")
505 << CFNumberSize <<
"-bit integer is used to initialize "
506 << (PrimitiveTypeSize == 8 ?
"an " :
"a ")
507 << PrimitiveTypeSize <<
"-bit integer; ";
510 if (PrimitiveTypeSize < CFNumberSize)
511 os << (CFNumberSize - PrimitiveTypeSize)
512 <<
" bits of the CFNumber value will "
513 << (isCreate ?
"be garbage." :
"overwrite adjacent storage.");
515 os << (PrimitiveTypeSize - CFNumberSize)
516 <<
" bits of the integer value will be "
517 << (isCreate ?
"lost." :
"garbage.");
519 auto report = std::make_unique<PathSensitiveBugReport>(BT, os.str(), N);
521 C.emitReport(std::move(report));
530class CFRetainReleaseChecker :
public Checker<check::PreCall> {
531 const APIMisuse BT{
this,
"null passed to CF memory management function"};
532 const CallDescriptionSet ModelledCalls = {
533 {CDM::CLibrary, {
"CFRetain"}, 1},
534 {CDM::CLibrary, {
"CFRelease"}, 1},
535 {CDM::CLibrary, {
"CFMakeCollectable"}, 1},
536 {CDM::CLibrary, {
"CFAutorelease"}, 1},
540 void checkPreCall(
const CallEvent &
Call, CheckerContext &
C)
const;
544void CFRetainReleaseChecker::checkPreCall(
const CallEvent &
Call,
545 CheckerContext &
C)
const {
551 SVal ArgVal =
Call.getArgSVal(0);
552 std::optional<DefinedSVal> DefArgVal = ArgVal.
getAs<DefinedSVal>();
559 std::tie(stateNonNull, stateNull) = state->assume(*DefArgVal);
562 ExplodedNode *N =
C.generateErrorNode(stateNull);
567 raw_svector_ostream
OS(Str);
568 OS <<
"Null pointer argument in call to "
571 auto report = std::make_unique<PathSensitiveBugReport>(BT,
OS.str(), N);
572 report->addRange(
Call.getArgSourceRange(0));
574 C.emitReport(std::move(report));
579 C.addTransition(stateNonNull);
587class ClassReleaseChecker :
public Checker<check::PreObjCMessage> {
588 mutable Selector releaseS;
589 mutable Selector retainS;
590 mutable Selector autoreleaseS;
591 mutable Selector drainS;
593 this,
"message incorrectly sent to class instead of class instance"};
596 void checkPreObjCMessage(
const ObjCMethodCall &msg, CheckerContext &
C)
const;
600void ClassReleaseChecker::checkPreObjCMessage(
const ObjCMethodCall &msg,
601 CheckerContext &
C)
const {
603 ASTContext &Ctx =
C.getASTContext();
616 if (!(S == releaseS || S == retainS || S == autoreleaseS || S == drainS))
619 if (ExplodedNode *N =
C.generateNonFatalErrorNode()) {
620 SmallString<200> buf;
621 llvm::raw_svector_ostream os(buf);
625 os <<
"' message should be sent to instances "
626 "of class '" <<
Class->getName()
627 <<
"' and not the class directly";
629 auto report = std::make_unique<PathSensitiveBugReport>(BT, os.str(), N);
631 C.emitReport(std::move(report));
641class VariadicMethodTypeChecker :
public Checker<check::PreObjCMessage> {
642 mutable Selector arrayWithObjectsS;
643 mutable Selector dictionaryWithObjectsAndKeysS;
644 mutable Selector setWithObjectsS;
645 mutable Selector orderedSetWithObjectsS;
646 mutable Selector initWithObjectsS;
647 mutable Selector initWithObjectsAndKeysS;
648 const APIMisuse BT{
this,
"Arguments passed to variadic method aren't all "
649 "Objective-C pointer types"};
651 bool isVariadicMessage(
const ObjCMethodCall &msg)
const;
654 void checkPreObjCMessage(
const ObjCMethodCall &msg, CheckerContext &
C)
const;
661VariadicMethodTypeChecker::isVariadicMessage(
const ObjCMethodCall &msg)
const {
662 const ObjCMethodDecl *MD = msg.
getDecl();
682 return S == initWithObjectsS;
684 return S == initWithObjectsAndKeysS;
693 return S == arrayWithObjectsS;
695 return S == orderedSetWithObjectsS;
697 return S == setWithObjectsS;
699 return S == dictionaryWithObjectsAndKeysS;
706void VariadicMethodTypeChecker::checkPreObjCMessage(
const ObjCMethodCall &msg,
707 CheckerContext &
C)
const {
708 if (arrayWithObjectsS.
isNull()) {
709 ASTContext &Ctx =
C.getASTContext();
711 dictionaryWithObjectsAndKeysS =
720 if (!isVariadicMessage(msg))
729 unsigned variadicArgsEnd = msg.
getNumArgs() - 1;
731 if (variadicArgsEnd <= variadicArgsBegin)
735 std::optional<ExplodedNode *> errorNode;
737 for (
unsigned I = variadicArgsBegin; I != variadicArgsEnd; ++I) {
751 if (
C.getASTContext().isObjCNSObjectType(ArgTy))
760 errorNode =
C.generateNonFatalErrorNode();
765 SmallString<128> sbuf;
766 llvm::raw_svector_ostream os(sbuf);
770 os <<
"Argument to '" <<
TypeName <<
"' method '";
772 os <<
"Argument to method '";
775 os <<
"' should be an Objective-C pointer type, not '";
776 ArgTy.
print(os,
C.getLangOpts());
779 auto R = std::make_unique<PathSensitiveBugReport>(BT, os.str(), *errorNode);
781 C.emitReport(std::move(R));
796 :
public Checker<check::PostStmt<ObjCForCollectionStmt>,
797 check::PostObjCMessage,
799 check::PointerEscape > {
800 mutable IdentifierInfo *CountSelectorII =
nullptr;
802 bool isCollectionCountMethod(
const ObjCMethodCall &M,
803 CheckerContext &
C)
const;
806 ObjCLoopChecker() =
default;
807 void checkPostStmt(
const ObjCForCollectionStmt *FCS, CheckerContext &
C)
const;
808 void checkPostObjCMessage(
const ObjCMethodCall &M, CheckerContext &
C)
const;
809 void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &
C)
const;
812 const CallEvent *
Call,
849 std::optional<DefinedSVal> KnownCollection =
851 if (!KnownCollection)
855 std::tie(StNonNil, StNil) = State->assume(*KnownCollection);
856 if (StNil && !StNonNil) {
882 std::optional<Loc> ElementLoc;
883 if (
const DeclStmt *DS = dyn_cast<DeclStmt>(Element)) {
885 assert(ElemDecl->
getInit() ==
nullptr);
886 ElementLoc = State->getLValue(ElemDecl, SF);
887 }
else if (
const auto *E = dyn_cast<Expr>(Element)) {
888 ElementLoc = State->getSVal(E, SF).getAs<
Loc>();
895 SVal Val = State->getSVal(*ElementLoc);
903 SymbolRef CollectionS,
bool Assumption) {
904 if (!State || !CollectionS)
907 const SymbolRef *CountS = State->get<ContainerCountMap>(CollectionS);
909 const bool *KnownNonEmpty = State->get<ContainerNonEmptyMap>(CollectionS);
911 return State->set<ContainerNonEmptyMap>(CollectionS, Assumption);
912 return (Assumption == *KnownNonEmpty) ? State :
nullptr;
916 SVal CountGreaterThanZeroVal =
919 SvalBuilder.
makeIntVal(0, (*CountS)->getType()),
921 std::optional<DefinedSVal> CountGreaterThanZero =
923 if (!CountGreaterThanZero) {
929 return State->assume(*CountGreaterThanZero, Assumption);
951 return BE->getSrc()->getLoopTarget() == FCS;
963void ObjCLoopChecker::checkPostStmt(
const ObjCForCollectionStmt *FCS,
964 CheckerContext &
C)
const {
980 C.generateSink(
C.getState(),
C.getPredecessor());
981 else if (State !=
C.getState())
982 C.addTransition(State);
985bool ObjCLoopChecker::isCollectionCountMethod(
const ObjCMethodCall &M,
986 CheckerContext &
C)
const {
989 if (!CountSelectorII)
990 CountSelectorII = &
C.getASTContext().Idents.get(
"count");
997void ObjCLoopChecker::checkPostObjCMessage(
const ObjCMethodCall &M,
998 CheckerContext &
C)
const {
1019 if (!isCollectionCountMethod(M,
C))
1023 SymbolRef CountS =
C.getSVal(MsgExpr).getAsSymbol();
1027 C.getSymbolManager().addSymbolDependency(ContainerS, CountS);
1028 State = State->set<ContainerCountMap>(ContainerS, CountS);
1030 if (
const bool *NonEmpty = State->get<ContainerNonEmptyMap>(ContainerS)) {
1031 State = State->remove<ContainerNonEmptyMap>(ContainerS);
1035 C.addTransition(State);
1053 StaticClass = Message->getOriginExpr()->getReceiverInterface();
1074 return Message->getReceiverSVal().getAsSymbol();
1080 const CallEvent *
Call,
1090 if (Sym == ImmutableReceiver)
1095 State = State->remove<ContainerCountMap>(Sym);
1096 State = State->remove<ContainerNonEmptyMap>(Sym);
1101void ObjCLoopChecker::checkDeadSymbols(SymbolReaper &SymReaper,
1102 CheckerContext &
C)
const {
1106 ContainerCountMapTy Tracked = State->get<ContainerCountMap>();
1107 for (
SymbolRef Sym : llvm::make_first_range(Tracked)) {
1108 if (SymReaper.
isDead(Sym)) {
1109 State = State->remove<ContainerCountMap>(Sym);
1110 State = State->remove<ContainerNonEmptyMap>(Sym);
1114 C.addTransition(State);
1121class ObjCNonNilReturnValueChecker
1122 :
public Checker<check::PostObjCMessage,
1123 check::PostStmt<ObjCArrayLiteral>,
1124 check::PostStmt<ObjCDictionaryLiteral>,
1125 check::PostStmt<ObjCBoxedExpr> > {
1127 mutable Selector ObjectAtIndex;
1128 mutable Selector ObjectAtIndexedSubscript;
1129 mutable Selector NullSelector;
1132 ObjCNonNilReturnValueChecker() =
default;
1136 CheckerContext &
C)
const;
1137 void assumeExprIsNonNull(
const Expr *E, CheckerContext &
C)
const {
1138 C.addTransition(assumeExprIsNonNull(E,
C.getState(),
C));
1141 void checkPostStmt(
const ObjCArrayLiteral *E, CheckerContext &
C)
const {
1142 assumeExprIsNonNull(E,
C);
1144 void checkPostStmt(
const ObjCDictionaryLiteral *E, CheckerContext &
C)
const {
1145 assumeExprIsNonNull(E,
C);
1147 void checkPostStmt(
const ObjCBoxedExpr *E, CheckerContext &
C)
const {
1148 assumeExprIsNonNull(E,
C);
1151 void checkPostObjCMessage(
const ObjCMethodCall &M, CheckerContext &
C)
const;
1156ObjCNonNilReturnValueChecker::assumeExprIsNonNull(
const Expr *NonNullExpr,
1158 CheckerContext &
C)
const {
1159 SVal Val =
C.getSVal(NonNullExpr);
1160 if (std::optional<DefinedOrUnknownSVal> DV =
1161 Val.
getAs<DefinedOrUnknownSVal>())
1162 return State->assume(*DV,
true);
1166void ObjCNonNilReturnValueChecker::checkPostObjCMessage(
const ObjCMethodCall &M,
1172 ASTContext &Ctx =
C.getASTContext();
1174 ObjectAtIndexedSubscript =
GetUnarySelector(
"objectAtIndexedSubscript", Ctx);
1189 if (!
C.inTopFrame() && M.
getDecl() &&
1202 if (Sel == ObjectAtIndex || Sel == ObjectAtIndexedSubscript) {
1216 C.addTransition(State);
1223void ento::registerNilArgChecker(CheckerManager &mgr) {
1227bool ento::shouldRegisterNilArgChecker(
const CheckerManager &mgr) {
1231void ento::registerCFNumberChecker(CheckerManager &mgr) {
1235bool ento::shouldRegisterCFNumberChecker(
const CheckerManager &mgr) {
1239void ento::registerCFRetainReleaseChecker(CheckerManager &mgr) {
1243bool ento::shouldRegisterCFRetainReleaseChecker(
const CheckerManager &mgr) {
1247void ento::registerClassReleaseChecker(CheckerManager &mgr) {
1251bool ento::shouldRegisterClassReleaseChecker(
const CheckerManager &mgr) {
1255void ento::registerVariadicMethodTypeChecker(CheckerManager &mgr) {
1259bool ento::shouldRegisterVariadicMethodTypeChecker(
const CheckerManager &mgr) {
1263void ento::registerObjCLoopChecker(CheckerManager &mgr) {
1267bool ento::shouldRegisterObjCLoopChecker(
const CheckerManager &mgr) {
1271void ento::registerObjCNonNilReturnValueChecker(CheckerManager &mgr) {
1275bool ento::shouldRegisterObjCNonNilReturnValueChecker(
const CheckerManager &mgr) {
Defines the clang::ASTContext interface.
static bool alreadyExecutedAtLeastOneLoopIteration(const ExplodedNode *N, const ObjCForCollectionStmt *FCS)
If the fist block edge is a back edge, we are reentering the loop.
static ProgramStateRef checkCollectionNonNil(CheckerContext &C, ProgramStateRef State, const ObjCForCollectionStmt *FCS)
Assumes that the collection is non-nil.
static FoundationClass findKnownClass(const ObjCInterfaceDecl *ID, bool IncludeSuperclasses=true)
static bool isKnownNonNilCollectionType(QualType T)
static ProgramStateRef assumeCollectionNonEmpty(CheckerContext &C, ProgramStateRef State, SymbolRef CollectionS, bool Assumption)
Returns NULL state if the collection is known to contain elements (or is known not to contain element...
static SymbolRef getMethodReceiverIfKnownImmutable(const CallEvent *Call)
static StringRef GetReceiverInterfaceName(const ObjCMethodCall &msg)
static std::optional< uint64_t > GetCFNumberSize(ASTContext &Ctx, uint64_t i)
static ProgramStateRef checkElementNonNil(CheckerContext &C, ProgramStateRef State, const ObjCForCollectionStmt *FCS)
Assumes that the collection elements are non-nil.
#define REGISTER_MAP_WITH_PROGRAMSTATE(Name, Key, Value)
Declares an immutable map of type NameTy, suitable for placement into the ProgramState.
Defines the Objective-C statement AST node classes.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
DeclContext * getDeclContext()
This represents one expression.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Expr * getElement(unsigned Index)
getElement - Return the Element at the specified index.
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Represents Objective-C's collection statement.
Represents an ObjC class declaration.
ObjCInterfaceDecl * getSuperClass() const
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
ObjCInterfaceDecl * getClassInterface()
Represents a pointer to an Objective C object.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
std::optional< T > getAs() const
Convert to the specified ProgramPoint type, returning std::nullopt if this ProgramPoint is not of the...
A (possibly-)qualified type.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
bool isUnarySelector() const
bool isNull() const
Determine whether this is the empty selector.
unsigned getNumArgs() const
It represents a stack frame of the call stack.
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isBlockPointerType() const
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isObjCObjectPointerType() const
Represents a variable declaration or definition.
const Expr * getInit() const
bool contains(const CallEvent &Call) const
Represents an abstract call to a function or method along a particular path.
virtual SourceRange getArgSourceRange(unsigned Index) const
Returns the source range for errors associated with this argument.
virtual SVal getArgSVal(unsigned Index) const
Returns the value of a given argument at the time of the call.
CHECKER * registerChecker(AT &&...Args)
Register a single-part checker (derived from Checker): construct its singleton instance,...
Simple checker classes that implement one frontend (i.e.
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
static bool hasMoreIteration(ProgramStateRef State, const ObjCForCollectionStmt *O, const StackFrame *SF)
Represents any expression that calls an Objective-C method.
const ObjCMethodDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
bool isInstanceMessage() const
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
ObjCMessageKind getMessageKind() const
Returns how the message was written in the source (property access, subscript, or explicit message se...
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
const ObjCMessageExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
SourceRange getSourceRange() const override
Returns a source range for the entire call, suitable for outputting in diagnostics.
SVal getReceiverSVal() const
Returns the value of the receiver at the time of this call.
const ObjCInterfaceDecl * getReceiverInterface() const
Get the interface for the receiver.
bool isReceiverSelfOrSuper() const
Checks if the receiver refers to 'self' or 'super'.
Selector getSelector() const
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
QualType getConditionType() const
SVal evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op, SVal lhs, SVal rhs, QualType type)
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
SymbolRef getAsSymbol(bool IncludeBaseRegions=false) const
If this SVal wraps a symbol return that SymbolRef.
std::optional< T > getAs() const
Convert to the specified SVal type, returning std::nullopt if this SVal is not of the desired type.
bool isDead(SymbolRef sym)
Returns whether or not a symbol has been confirmed dead.
Represents symbolic expression that isn't a location.
bool trackExpressionValue(const ExplodedNode *N, const Expr *E, PathSensitiveBugReport &R, TrackingOptions Opts={})
Attempts to add visitors to track expression value back to its point of origin.
const char *const AppleAPIMisuse
bool isCFObjectRef(QualType T)
PointerEscapeKind
Describes the different reasons a pointer escapes during analysis.
llvm::DenseSet< SymbolRef > InvalidatedSymbols
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
const SymExpr * SymbolRef
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
bool Null(InterpState &S, uint64_t Value, const Type *Ty)
The JSON file list parser is used to communicate input to InstallAPI.
static Selector getKeywordSelector(ASTContext &Ctx, const IdentifierInfos *...IIs)
bool isa(CodeGen::Address addr)
@ NonNull
Values of this type can never be null.
Selector GetUnarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing an unary selector.
const FunctionProtoType * T
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
U cast(CodeGen::Address addr)
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Diagnostic wrappers for TextAPI types for error reporting.
Expr * Value
The value of the dictionary element.
Expr * Key
The key for the dictionary element.