clang 18.0.0git
|
This class represents a description of a function call using the number of arguments and the name of the function. More...
#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
Public Member Functions | |
CallDescription (CallDescriptionFlags Flags, ArrayRef< StringRef > QualifiedName, MaybeCount RequiredArgs=std::nullopt, MaybeCount RequiredParams=std::nullopt) | |
Constructs a CallDescription object. | |
CallDescription (ArrayRef< StringRef > QualifiedName, MaybeCount RequiredArgs=std::nullopt, MaybeCount RequiredParams=std::nullopt) | |
Construct a CallDescription with default flags. | |
CallDescription (std::nullptr_t)=delete | |
StringRef | getFunctionName () const |
Get the name of the function that this object matches. | |
auto | begin_qualified_name_parts () const |
Get the qualified name parts in reversed order. | |
auto | end_qualified_name_parts () const |
bool | hasQualifiedNameParts () const |
It's false, if and only if we expect a single identifier, such as getenv . | |
Friends | |
class | CallEvent |
Matching CallDescriptions against a CallEvent | |
bool | matchesAny (const CallEvent &Call, const CallDescription &CD1) |
Returns true whether the CallEvent matches on any of the CallDescriptions supplied. | |
template<typename... Ts> | |
bool | matchesAny (const CallEvent &Call, const CallDescription &CD1, const Ts &...CDs) |
Returns true whether the CallEvent matches on any of the CallDescriptions supplied. | |
bool | matches (const CallEvent &Call) const |
Returns true if the CallEvent is a call to a function that matches the CallDescription. | |
Matching CallDescriptions against a CallExpr | |
bool | matchesAnyAsWritten (const CallExpr &CE, const CallDescription &CD1) |
Returns true whether the CallExpr matches on any of the CallDescriptions supplied. | |
template<typename... Ts> | |
bool | matchesAnyAsWritten (const CallExpr &CE, const CallDescription &CD1, const Ts &...CDs) |
Returns true whether the CallExpr matches on any of the CallDescriptions supplied. | |
bool | matchesAsWritten (const CallExpr &CE) const |
Returns true if the CallExpr is a call to a function that matches the CallDescription. | |
This class represents a description of a function call using the number of arguments and the name of the function.
Definition at line 43 of file CallDescription.h.
ento::CallDescription::CallDescription | ( | CallDescriptionFlags | Flags, |
ArrayRef< StringRef > | QualifiedName, | ||
MaybeCount | RequiredArgs = std::nullopt , |
||
MaybeCount | RequiredParams = std::nullopt |
||
) |
Constructs a CallDescription object.
QualifiedName | The list of the name qualifiers of the function that will be matched. The user is allowed to skip any of the qualifiers. For example, {"std", "basic_string", "c_str"} would match both std::basic_string<...>::c_str() and std::__1::basic_string<...>::c_str(). |
RequiredArgs | The number of arguments that is expected to match a call. Omit this parameter to match every occurrence of call with a given name regardless the number of arguments. |
Definition at line 38 of file CallDescription.cpp.
ento::CallDescription::CallDescription | ( | ArrayRef< StringRef > | QualifiedName, |
MaybeCount | RequiredArgs = std::nullopt , |
||
MaybeCount | RequiredParams = std::nullopt |
||
) |
Construct a CallDescription with default flags.
Definition at line 52 of file CallDescription.cpp.
|
delete |
|
inline |
Get the qualified name parts in reversed order.
E.g. { "std", "vector", "data" } -> "vector", "std"
Definition at line 82 of file CallDescription.h.
|
inline |
Definition at line 85 of file CallDescription.h.
|
inline |
Get the name of the function that this object matches.
Definition at line 78 of file CallDescription.h.
|
inline |
It's false, if and only if we expect a single identifier, such as getenv
.
It's true for std::swap
, or my::detail::container::data
.
Definition at line 89 of file CallDescription.h.
Returns true if the CallEvent is a call to a function that matches the CallDescription.
Definition at line 57 of file CallDescription.cpp.
References clang::ento::CE_ObjCMessage.
Returns true if the CallExpr is a call to a function that matches the CallDescription.
When available, always prefer matching with a CallEvent! This function exists only when that is not available, for example, when only syntactic check is done on a piece of code.
Also, StdLibraryFunctionsChecker::Signature is likely a better candicade for syntactic only matching if you are writing a new checker. This is handy if a CallDescriptionMap is already there.
The function is imprecise because CallEvent may know path sensitive information, such as the precise argument count (see comments for CallEvent::getNumArgs), the called function if it was called through a function pointer, and other information not available syntactically.
Definition at line 69 of file CallDescription.cpp.
References clang::CallExpr::getCalleeDecl(), and clang::CallExpr::getNumArgs().
|
friend |
Definition at line 44 of file CallDescription.h.
|
friend |
Returns true whether the CallEvent matches on any of the CallDescriptions supplied.
Definition at line 106 of file CallDescription.h.
|
friend |
Returns true whether the CallEvent matches on any of the CallDescriptions supplied.
Definition at line 112 of file CallDescription.h.
|
friend |
Returns true whether the CallExpr matches on any of the CallDescriptions supplied.
Definition at line 143 of file CallDescription.h.
|
friend |
Returns true whether the CallExpr matches on any of the CallDescriptions supplied.
Definition at line 150 of file CallDescription.h.