22 #include "llvm/ADT/StringSwitch.h"
25 using namespace clang;
30 class NoReturnFunctionChecker :
public Checker< check::PostCall,
31 check::PostObjCMessage > {
32 mutable Selector HandleFailureInFunctionSel;
33 mutable Selector HandleFailureInMethodSel;
41 void NoReturnFunctionChecker::checkPostCall(
const CallEvent &CE,
43 bool BuildSinks =
false;
46 BuildSinks = FD->hasAttr<AnalyzerNoReturnAttr>() || FD->isNoReturn();
49 if (!BuildSinks && Callee)
58 = llvm::StringSwitch<bool>(StringRef(II->getName()))
66 .Case(
"assfail",
true)
67 .Case(
"db_error",
true)
68 .Case(
"__assert",
true)
71 .Case(
"_wassert",
true)
72 .Case(
"__assert_rtn",
true)
73 .Case(
"__assert_fail",
true)
74 .Case(
"dtrace_assfail",
true)
75 .Case(
"yy_fatal_error",
true)
76 .Case(
"_XCAssertionFailureHandler",
true)
77 .Case(
"_DTAssertionFailureHandler",
true)
78 .Case(
"_TSAssertionFailureHandler",
true)
87 void NoReturnFunctionChecker::checkPostObjCMessage(
const ObjCMethodCall &Msg,
91 MD = MD->getCanonicalDecl();
92 if (MD->hasAttr<AnalyzerNoReturnAttr>()) {
124 "handleFailureInFunction",
"file",
"lineNumber",
125 "description",
nullptr);
126 if (Sel != HandleFailureInFunctionSel)
131 "handleFailureInMethod",
"object",
"file",
132 "lineNumber",
"description",
nullptr);
133 if (Sel != HandleFailureInMethodSel)
Smart pointer class that efficiently represents Objective-C method names.
bool isInstanceMessage() const
IdentifierInfo * getIdentifier() const
const ObjCInterfaceDecl * getReceiverInterface() const
Get the interface for the receiver.
const Expr * getOriginExpr() const
Returns the expression whose value will be the result of this call. May be null.
Represents any expression that calls an Objective-C method.
Represents an ObjC class declaration.
ExplodedNode * generateSink(ProgramStateRef State=nullptr, ExplodedNode *Pred=nullptr, const ProgramPointTag *Tag=nullptr)
Generate a sink node. Generating a sink stops exploration of the given path.
bool isGlobalCFunction(StringRef SpecificName=StringRef()) const
Returns true if the callee is an externally-visible function in the top-level namespace, such as malloc.
unsigned getNumArgs() const
static LLVM_END_WITH_NULL void lazyInitKeywordSelector(Selector &Sel, ASTContext &Ctx, const char *First,...)
CHECKER * registerChecker()
Used to register checkers.
Selector getSelector() const
const IdentifierInfo * getCalleeIdentifier() const
Returns the name of the callee, if its name is a simple identifier.
const ObjCMethodDecl * getDecl() const override
virtual const Decl * getDecl() const
Returns the declaration of the function or method that will be called. May be null.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
ASTContext & getASTContext()
FunctionType::ExtInfo getFunctionExtInfo(const Type &t)
Represents an abstract call to a function or method along a particular path.