class CallDescription

Declaration

class CallDescription { /* full declaration omitted */ };

Description

This class represents a description of a function call using the number of arguments and the name of the function.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:43

Member Variables

private Optional<const clang::IdentifierInfo*> II
private std::vector<std::string> QualifiedName
private clang::ento::CallDescription::MaybeCount RequiredArgs
private clang::ento::CallDescription::MaybeCount RequiredParams
private int Flags

Method Overview

  • public CallDescription(clang::ento::CallDescriptionFlags Flags, ArrayRef<const char *> QualifiedName, clang::ento::CallDescription::MaybeCount RequiredArgs = None, clang::ento::CallDescription::MaybeCount RequiredParams = None)
  • public CallDescription(ArrayRef<const char *> QualifiedName, clang::ento::CallDescription::MaybeCount RequiredArgs = None, clang::ento::CallDescription::MaybeCount RequiredParams = None)
  • public CallDescription(std::nullptr_t)
  • public std::reverse_iterator<__gnu_cxx::__normal_iterator<const std::basic_string<char> *, std::vector<std::basic_string<char>>>> begin_qualified_name_parts() const
  • public std::vector<std::basic_string<char>>::const_reverse_iterator end_qualified_name_parts() const
  • public llvm::StringRef getFunctionName() const
  • public bool hasQualifiedNameParts() const
  • public bool matches(const clang::ento::CallEvent & Call) const
  • public bool matchesAsWritten(const clang::CallExpr & CE) const
  • private bool matchesImpl(const clang::FunctionDecl * Callee, size_t ArgCount, size_t ParamCount) const

Methods

CallDescription(
    clang::ento::CallDescriptionFlags Flags,
    ArrayRef<const char*> QualifiedName,
    clang::ento::CallDescription::MaybeCount
        RequiredArgs = None,
    clang::ento::CallDescription::MaybeCount
        RequiredParams = None)

Description

Constructs a CallDescription object.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:66

Parameters

clang::ento::CallDescriptionFlags Flags
ArrayRef<const char*> 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().
clang::ento::CallDescription::MaybeCount RequiredArgs = None
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.
clang::ento::CallDescription::MaybeCount RequiredParams = None

CallDescription(
    ArrayRef<const char*> QualifiedName,
    clang::ento::CallDescription::MaybeCount
        RequiredArgs = None,
    clang::ento::CallDescription::MaybeCount
        RequiredParams = None)

Description

Construct a CallDescription with default flags.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:72

Parameters

ArrayRef<const char*> QualifiedName
clang::ento::CallDescription::MaybeCount RequiredArgs = None
clang::ento::CallDescription::MaybeCount RequiredParams = None

CallDescription(std::nullptr_t)

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:76

Parameters

std::nullptr_t

std::reverse_iterator<
    __gnu_cxx::__normal_iterator<
        const std::basic_string<char>*,
        std::vector<std::basic_string<char>>>>
begin_qualified_name_parts() const

Description

Get the qualified name parts in reversed order. E.g. { "std", "vector", "data" } -> "vector", "std"

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:83

std::vector<std::basic_string<char>>::
    const_reverse_iterator
    end_qualified_name_parts() const

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:86

llvm::StringRef getFunctionName() const

Description

Get the name of the function that this object matches.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:79

bool hasQualifiedNameParts() const

Description

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`.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:90

bool matches(
    const clang::ento::CallEvent& Call) const

Description

Returns true if the CallEvent is a call to a function that matches the CallDescription.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:100

Parameters

const clang::ento::CallEvent& Call

bool matchesAsWritten(
    const clang::CallExpr& CE) const

Description

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.

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:137

Parameters

const clang::CallExpr& CE

bool matchesImpl(
    const clang::FunctionDecl* Callee,
    size_t ArgCount,
    size_t ParamCount) const

Description

@ }

Declared at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h:159

Parameters

const clang::FunctionDecl* Callee
size_t ArgCount
size_t ParamCount