26class BuiltinFunctionChecker :
public Checker<eval::Call> {
33bool BuiltinFunctionChecker::evalCall(
const CallEvent &Call,
36 const auto *FD = dyn_cast_or_null<FunctionDecl>(
Call.getDecl());
41 const Expr *CE =
Call.getOriginExpr();
43 switch (FD->getBuiltinID()) {
47 case Builtin::BI__builtin_assume: {
48 assert (
Call.getNumArgs() > 0);
57 C.generateSink(
C.getState(),
C.getPredecessor());
61 C.addTransition(state);
65 case Builtin::BI__builtin_unpredictable:
66 case Builtin::BI__builtin_expect:
67 case Builtin::BI__builtin_expect_with_probability:
68 case Builtin::BI__builtin_assume_aligned:
69 case Builtin::BI__builtin_addressof:
70 case Builtin::BI__builtin_function_start: {
76 assert (
Call.getNumArgs() > 0);
78 C.addTransition(state->BindExpr(CE, LCtx, Arg));
82 case Builtin::BI__builtin_alloca_with_align:
83 case Builtin::BI__builtin_alloca: {
103 case Builtin::BI__builtin_dynamic_object_size:
104 case Builtin::BI__builtin_object_size:
105 case Builtin::BI__builtin_constant_p: {
113 llvm::APSInt Result = EVResult.
Val.
getInt();
119 if (FD->getBuiltinID() == Builtin::BI__builtin_constant_p) {
127 C.addTransition(state->BindExpr(CE, LCtx,
V));
137bool ento::shouldRegisterBuiltinFunctionChecker(
const CheckerManager &mgr) {
Defines enum values for all the target-independent builtin functions.
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
@ SE_NoSideEffects
Strictly evaluate the expression.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
void apply(llvm::APSInt &Value) const
Convert a given APSInt, in place, to match this type.
AllocaRegion - A region that represents an untyped blob of bytes created by a call to 'alloca'.
APSIntType getAPSIntType(QualType T) const
Returns the type of the APSInt used to store values of the given QualType.
Represents an abstract call to a function or method along a particular path.
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
const AllocaRegion * getAllocaRegion(const Expr *Ex, unsigned Cnt, const LocationContext *LC)
getAllocaRegion - Retrieve a region associated with a call to alloca().
BasicValueFactory & getBasicValueFactory()
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
ProgramStateRef setDynamicExtent(ProgramStateRef State, const MemRegion *MR, DefinedOrUnknownSVal Extent, SValBuilder &SVB)
Set the dynamic extent Extent of the region MR.
bool Call(InterpState &S, CodePtr OpPC, const Function *Func)
@ C
Languages that the frontend can parse and compile.
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.