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"
73 using MaybeCount = std::optional<unsigned>;
75 mutable std::optional<const IdentifierInfo *> II;
78 std::vector<std::string> QualifiedName;
79 MaybeCount RequiredArgs;
80 MaybeCount RequiredParams;
101 MaybeCount RequiredArgs = std::nullopt,
102 MaybeCount RequiredParams = std::nullopt);
110 return std::next(QualifiedName.rbegin());
138 template <
typename... Ts>
176 template <
typename... Ts>
185 bool matchesImpl(
const FunctionDecl *Callee,
size_t ArgCount,
186 size_t ParamCount)
const;
188 bool matchNameOnly(
const NamedDecl *ND)
const;
189 bool matchQualifiedNameParts(
const Decl *
D)
const;
202 std::vector<std::pair<CallDescription, T>> LinearMap;
206 std::initializer_list<std::pair<CallDescription, T>> &&List)
209 template <
typename InputIt>
225 for (
const std::pair<CallDescription, T> &I : LinearMap)
226 if (I.first.matches(
Call))
247 for (
const std::pair<CallDescription, T> &I : LinearMap)
248 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
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