21#include "llvm/ADT/StringSwitch.h"
29class NoReturnFunctionChecker :
public Checker< check::PostCall,
30 check::PostObjCMessage > {
31 mutable Selector HandleFailureInFunctionSel;
32 mutable Selector HandleFailureInMethodSel;
40void NoReturnFunctionChecker::checkPostCall(
const CallEvent &CE,
42 bool BuildSinks =
false;
45 BuildSinks = FD->hasAttr<AnalyzerNoReturnAttr>() || FD->isNoReturn();
48 CExpr && !BuildSinks) {
49 if (
const Expr *
C = CExpr->getCallee())
59 = llvm::StringSwitch<bool>(StringRef(II->getName()))
67 .Case(
"assfail",
true)
68 .Case(
"db_error",
true)
69 .Case(
"__assert",
true)
70 .Case(
"__assert2",
true)
73 .Case(
"_wassert",
true)
74 .Case(
"__assert_rtn",
true)
75 .Case(
"__assert_fail",
true)
76 .Case(
"dtrace_assfail",
true)
77 .Case(
"yy_fatal_error",
true)
78 .Case(
"_XCAssertionFailureHandler",
true)
79 .Case(
"_DTAssertionFailureHandler",
true)
80 .Case(
"_TSAssertionFailureHandler",
true)
86 C.generateSink(
C.getState(),
C.getPredecessor());
89void NoReturnFunctionChecker::checkPostObjCMessage(
const ObjCMethodCall &Msg,
93 MD = MD->getCanonicalDecl();
94 if (MD->hasAttr<AnalyzerNoReturnAttr>()) {
95 C.generateSink(
C.getState(),
C.getPredecessor());
126 "handleFailureInFunction",
"file",
"lineNumber",
128 if (Sel != HandleFailureInFunctionSel)
133 "handleFailureInMethod",
"object",
"file",
134 "lineNumber",
"description");
135 if (Sel != HandleFailureInMethodSel)
141 C.generateSink(
C.getState(),
C.getPredecessor());
148bool ento::shouldRegisterNoReturnFunctionChecker(
const CheckerManager &mgr) {
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
This represents one expression.
Represents a function declaration or definition.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents an ObjC class declaration.
ObjCMethodDecl - Represents an instance or class method declaration.
Smart pointer class that efficiently represents Objective-C method names.
unsigned getNumArgs() const
Represents an abstract call to a function or method along a particular path.
virtual const Expr * getOriginExpr() const
Returns the expression whose value will be the result of this call.
const IdentifierInfo * getCalleeIdentifier() const
Returns the name of the callee, if its name is a simple identifier.
bool isGlobalCFunction(StringRef SpecificName=StringRef()) const
Returns true if the callee is an externally-visible function in the top-level namespace,...
virtual const Decl * getDecl() const
Returns the declaration of the function or method that will be called.
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
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 ObjCInterfaceDecl * getReceiverInterface() const
Get the interface for the receiver.
Selector getSelector() const
The JSON file list parser is used to communicate input to InstallAPI.
static void lazyInitKeywordSelector(Selector &Sel, ASTContext &Ctx, IdentifierInfos *... IIs)
FunctionType::ExtInfo getFunctionExtInfo(const Type &t)