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)
69 .Case(
"__assert2",
true)
72 .Case(
"_wassert",
true)
73 .Case(
"__assert_rtn",
true)
74 .Case(
"__assert_fail",
true)
75 .Case(
"dtrace_assfail",
true)
76 .Case(
"yy_fatal_error",
true)
77 .Case(
"_XCAssertionFailureHandler",
true)
78 .Case(
"_DTAssertionFailureHandler",
true)
79 .Case(
"_TSAssertionFailureHandler",
true)
88 void NoReturnFunctionChecker::checkPostObjCMessage(
const ObjCMethodCall &Msg,
92 MD = MD->getCanonicalDecl();
93 if (MD->hasAttr<AnalyzerNoReturnAttr>()) {
125 "handleFailureInFunction",
"file",
"lineNumber",
126 "description",
nullptr);
127 if (Sel != HandleFailureInFunctionSel)
132 "handleFailureInMethod",
"object",
"file",
133 "lineNumber",
"description",
nullptr);
134 if (Sel != HandleFailureInMethodSel)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Smart pointer class that efficiently represents Objective-C method names.
bool isInstanceMessage() const
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
ObjCMethodDecl - Represents an instance or class method declaration.
ExplodedNode * getPredecessor()
Returns the previous node in the exploded graph, which includes the state of the program before the c...
const ObjCInterfaceDecl * getReceiverInterface() const
Get the interface for the receiver.
One of these records is kept for each identifier that is lexed.
const Expr * getOriginExpr() const
Returns the expression whose value will be the result of this call.
Represents any expression that calls an Objective-C method.
Represents an ObjC class declaration.
bool isGlobalCFunction(StringRef SpecificName=StringRef()) const
Returns true if the callee is an externally-visible function in the top-level namespace, such as malloc.
Expr - This represents one expression.
const ProgramStateRef & getState() const
unsigned getNumArgs() const
static LLVM_END_WITH_NULL void lazyInitKeywordSelector(Selector &Sel, ASTContext &Ctx, const char *First,...)
CHECKER * registerChecker()
Used to register checkers.
ExplodedNode * generateSink(ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
Generate a sink node.
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.
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.