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"
72 using MaybeCount = std::optional<unsigned>;
74 mutable std::optional<const IdentifierInfo *> II;
77 std::vector<std::string> QualifiedName;
78 MaybeCount RequiredArgs;
79 MaybeCount RequiredParams;
100 MaybeCount RequiredArgs = std::nullopt,
101 MaybeCount RequiredParams = std::nullopt);
105 MaybeCount RequiredArgs = std::nullopt,
106 MaybeCount RequiredParams = std::nullopt);
116 return std::next(QualifiedName.rbegin());
144 template <
typename... Ts>
182 template <
typename... Ts>
191 bool matchesImpl(
const FunctionDecl *Callee,
size_t ArgCount,
192 size_t ParamCount)
const;
194 bool matchNameOnly(
const NamedDecl *ND)
const;
195 bool matchQualifiedNameParts(
const Decl *D)
const;
208 std::vector<std::pair<CallDescription, T>> LinearMap;
212 std::initializer_list<std::pair<CallDescription, T>> &&List)
215 template <
typename InputIt>
231 for (
const std::pair<CallDescription, T> &I : LinearMap)
232 if (I.first.matches(
Call))
253 for (
const std::pair<CallDescription, T> &I : LinearMap)
254 if (I.first.matchesAsWritten(
Call))
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.
This represents a decl that may have a 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! This function exists only when that is not ava...
CallDescriptionMap & operator=(const CallDescription &)=delete
An immutable set of CallDescriptions.
bool containsAsWritten(const CallExpr &CE) const
When available, always prefer lookup with a CallEvent! This function exists only when that is not ava...
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...
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
CallDescription(std::nullptr_t)=delete
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.
@ 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.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T