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"
45 using MaybeCount = std::optional<unsigned>;
47 mutable std::optional<const IdentifierInfo *> II;
50 std::vector<std::string> QualifiedName;
51 MaybeCount RequiredArgs;
52 MaybeCount RequiredParams;
67 MaybeCount RequiredArgs = std::nullopt,
68 MaybeCount RequiredParams = std::nullopt);
72 MaybeCount RequiredArgs = std::nullopt,
73 MaybeCount RequiredParams = std::nullopt);
83 return std::next(QualifiedName.rbegin());
111 template <
typename... Ts>
149 template <
typename... Ts>
158 bool matchesImpl(
const FunctionDecl *Callee,
size_t ArgCount,
159 size_t ParamCount)
const;
172 std::vector<std::pair<CallDescription, T>> LinearMap;
176 std::initializer_list<std::pair<CallDescription, T>> &&List)
179 template <
typename InputIt>
195 for (
const std::pair<CallDescription, T> &I : LinearMap)
196 if (I.first.matches(Call))
217 for (
const std::pair<CallDescription, T> &I : LinearMap)
218 if (I.first.matchesAsWritten(Call))
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Represents a function declaration or definition.
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
This class represents a description of a function call using the number of arguments and the name of ...
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.
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.
@ CDF_MaybeBuiltin
Describes a C standard function that is sometimes implemented as a macro that expands to a compiler b...