15#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLDESCRIPTION_H
16#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLDESCRIPTION_H
19#include "llvm/ADT/ArrayRef.h"
20#include "llvm/Support/Compiler.h"
35 std::optional<unsigned> BuiltinID;
36 std::optional<std::string> BuiltinName;
37 std::optional<bool> IsPredefinedLibFunction;
38 std::optional<bool> IsCLibraryDecl;
40 unsigned getBuiltinID();
42 StringRef getBuiltinName();
45 bool isPredefinedLibFunction();
48 bool isCLibraryDecl();
100 using MaybeCount = std::optional<unsigned>;
102 mutable std::optional<const IdentifierInfo *> II;
105 std::vector<std::string> QualifiedName;
106 MaybeCount RequiredArgs;
107 MaybeCount RequiredParams;
118 size_t ParamCount = 0;
119 bool IsMethod =
false;
122 explicit Callee(
const CallExpr &CE);
152 return std::next(QualifiedName.rbegin());
180 template <
typename... Ts>
218 template <
typename... Ts>
229 bool matchNameOnly(
const NamedDecl *ND)
const;
230 bool matchQualifiedNameParts(
const Decl *D)
const;
243 std::vector<std::pair<CallDescription, T>> LinearMap;
247 std::initializer_list<std::pair<CallDescription, T>> &&List)
250 template <
typename InputIt>
264 return lookupImpl(CallDescription::Callee(
Call));
280 return lookupImpl(CallDescription::Callee(
Call));
284 const T *lookupImpl(
const CallDescription::Callee &
C)
const {
292 for (
const std::pair<CallDescription, T> &I : LinearMap)
293 if (I.first.matchesImpl(
C, CLib))
std::optional< unsigned > MaybeCount
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Decl - This represents one declaration (or definition), e.g.
Represents a function declaration or definition.
One of these records is kept for each identifier that is lexed.
This represents a decl that may have a name.
The properties of a function declaration that determine whether it is a C library function with a giv...
CLibraryFunctionInfo(const FunctionDecl *FD)
bool isCLibraryFunction(StringRef Name)
Implements CheckerContext::isCLibraryFunction(FD, Name).
An immutable map from CallDescriptions to arbitrary data.
CallDescriptionMap(InputIt First, InputIt Last)
const T * lookup(const CallEvent &Call) const
CallDescriptionMap(CallDescriptionMap &&)=default
CallDescriptionMap(std::initializer_list< std::pair< CallDescription, T > > &&List)
CallDescriptionMap(const CallDescriptionMap &)=delete
CallDescriptionMap & operator=(CallDescriptionMap &&)=default
~CallDescriptionMap()=default
const T * lookupAsWritten(const CallExpr &Call) const
When available, always prefer lookup with a CallEvent!
friend class CallDescriptionSet
CallDescriptionMap & operator=(const CallDescription &)=delete
CallDescriptionSet(std::initializer_list< CallDescription > &&List)
bool containsAsWritten(const CallExpr &CE) const
When available, always prefer lookup with a CallEvent!
bool contains(const CallEvent &Call) const
CallDescriptionSet & operator=(const CallDescription &)=delete
CallDescriptionSet(const CallDescriptionSet &)=delete
A CallDescription is a pattern that can be used to match calls based on the qualified name and the ar...
CallDescription(Mode MatchAs, ArrayRef< StringRef > QualifiedName, MaybeCount RequiredArgs=std::nullopt, MaybeCount RequiredParams=std::nullopt)
Constructs a CallDescription object.
bool hasQualifiedNameParts() const
It's false, if and only if we expect a single identifier, such as getenv.
bool matches(const CallEvent &Call) const
Returns true if the CallEvent is a call to a function that matches the CallDescription.
bool matchesAsWritten(const CallExpr &CE) const
Returns true if the CallExpr is a call to a function that matches the CallDescription.
auto end_qualified_name_parts() const
StringRef getFunctionName() const
Get the name of the function that this object matches.
friend bool matchesAny(const CallEvent &Call, const CallDescription &CD1, const Ts &...CDs)
Returns true whether the CallEvent matches on any of the CallDescriptions supplied.
friend bool matchesAnyAsWritten(const CallExpr &CE, const CallDescription &CD1, const Ts &...CDs)
Returns true whether the CallExpr matches on any of the CallDescriptions supplied.
auto begin_qualified_name_parts() const
Get the qualified name parts in reversed order.
friend bool matchesAny(const CallEvent &Call, const CallDescription &CD1)
Returns true whether the CallEvent matches on any of the CallDescriptions supplied.
friend class CallDescriptionMap
@ CLibrary
Match calls to functions from the C standard library.
@ Unspecified
Match any CallEvent that is not an ObjCMethodCall.
@ CLibraryMaybeHardened
An extended version of the CLibrary mode that also matches the hardened variants like __FOO_chk() and...
@ CXXMethod
Matches a C++ method (may be static, may be virtual, may be an overloaded operator,...
@ SimpleFunc
Matches "simple" functions that are not methods.
friend bool matchesAnyAsWritten(const CallExpr &CE, const CallDescription &CD1)
Returns true whether the CallExpr matches on any of the CallDescriptions supplied.
Represents an abstract call to a function or method along a particular path.
CallDescription::Mode CDM
Enumerators of this enum class are used to construct CallDescription objects; in that context the ful...
Top level wrappers for InstallAPI frontend operations.