Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
Line
Count
Source (jump to first uncovered line)
1
//===- CallDescription.h - function/method call matching       --*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
/// \file This file defines a generic mechanism for matching for function and
10
/// method calls of C, C++, and Objective-C languages. Instances of these
11
/// classes are frequently used together with the CallEvent classes.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLDESCRIPTION_H
16
#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLDESCRIPTION_H
17
18
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
19
#include "llvm/ADT/ArrayRef.h"
20
#include "llvm/ADT/Optional.h"
21
#include "llvm/Support/Compiler.h"
22
#include <vector>
23
24
namespace clang {
25
class IdentifierInfo;
26
} // namespace clang
27
28
namespace clang {
29
namespace ento {
30
31
enum CallDescriptionFlags : unsigned {
32
  CDF_None = 0,
33
34
  /// Describes a C standard function that is sometimes implemented as a macro
35
  /// that expands to a compiler builtin with some __builtin prefix.
36
  /// The builtin may as well have a few extra arguments on top of the requested
37
  /// number of arguments.
38
  CDF_MaybeBuiltin = 1 << 0,
39
};
40
41
/// This class represents a description of a function call using the number of
42
/// arguments and the name of the function.
43
class CallDescription {
44
  friend class CallEvent;
45
  using MaybeCount = Optional<unsigned>;
46
47
  mutable Optional<const IdentifierInfo *> II;
48
  // The list of the qualified names used to identify the specified CallEvent,
49
  // e.g. "{a, b}" represent the qualified names, like "a::b".
50
  std::vector<std::string> QualifiedName;
51
  MaybeCount RequiredArgs;
52
  MaybeCount RequiredParams;
53
  int Flags;
54
55
public:
56
  /// Constructs a CallDescription object.
57
  ///
58
  /// @param QualifiedName The list of the name qualifiers of the function that
59
  /// will be matched. The user is allowed to skip any of the qualifiers.
60
  /// For example, {"std", "basic_string", "c_str"} would match both
61
  /// std::basic_string<...>::c_str() and std::__1::basic_string<...>::c_str().
62
  ///
63
  /// @param RequiredArgs The number of arguments that is expected to match a
64
  /// call. Omit this parameter to match every occurrence of call with a given
65
  /// name regardless the number of arguments.
66
  CallDescription(CallDescriptionFlags Flags,
67
                  ArrayRef<const char *> QualifiedName,
68
                  MaybeCount RequiredArgs = None,
69
                  MaybeCount RequiredParams = None);
70
71
  /// Construct a CallDescription with default flags.
72
  CallDescription(ArrayRef<const char *> QualifiedName,
73
                  MaybeCount RequiredArgs = None,
74
                  MaybeCount RequiredParams = None);
75
76
  CallDescription(std::nullptr_t) = delete;
77
78
  /// Get the name of the function that this object matches.
79
762k
  StringRef getFunctionName() const { return QualifiedName.back(); }
80
81
  /// Get the qualified name parts in reversed order.
82
  /// E.g. { "std", "vector", "data" } -> "vector", "std"
83
2.47k
  auto begin_qualified_name_parts() const {
84
2.47k
    return std::next(QualifiedName.rbegin());
85
2.47k
  }
86
2.47k
  auto end_qualified_name_parts() const { return QualifiedName.rend(); }
87
88
  /// It's false, if and only if we expect a single identifier, such as
89
  /// `getenv`. It's true for `std::swap`, or `my::detail::container::data`.
90
11.5k
  bool hasQualifiedNameParts() const { return QualifiedName.size() > 1; }
91
92
  /// @name Matching CallDescriptions against a CallEvent
93
  /// @{
94
95
  /// Returns true if the CallEvent is a call to a function that matches
96
  /// the CallDescription.
97
  ///
98
  /// \note This function is not intended to be used to match Obj-C method
99
  /// calls.
100
  bool matches(const CallEvent &Call) const;
101
102
  /// Returns true whether the CallEvent matches on any of the CallDescriptions
103
  /// supplied.
104
  ///
105
  /// \note This function is not intended to be used to match Obj-C method
106
  /// calls.
107
75.6k
  friend bool matchesAny(const CallEvent &Call, const CallDescription &CD1) {
108
75.6k
    return CD1.matches(Call);
109
75.6k
  }
110
111
  /// \copydoc clang::ento::matchesAny(const CallEvent &, const CallDescription &)
112
  template <typename... Ts>
113
  friend bool matchesAny(const CallEvent &Call, const CallDescription &CD1,
114
144k
                         const Ts &...CDs) {
115
144k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)144k
;
116
144k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
75.6k
                         const Ts &...CDs) {
115
75.6k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)75.6k
;
116
75.6k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
3.59k
                         const Ts &...CDs) {
115
3.59k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)3.59k
;
116
3.59k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
3.59k
                         const Ts &...CDs) {
115
3.59k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)3.59k
;
116
3.59k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
3.59k
                         const Ts &...CDs) {
115
3.59k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)3.59k
;
116
3.59k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
3.59k
                         const Ts &...CDs) {
115
3.59k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)3.59k
;
116
3.59k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
3.59k
                         const Ts &...CDs) {
115
3.59k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)3.59k
;
116
3.59k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
3.59k
                         const Ts &...CDs) {
115
3.59k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)3.59k
;
116
3.59k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
3.71k
                         const Ts &...CDs) {
115
3.71k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)3.69k
;
116
3.71k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
3.80k
                         const Ts &...CDs) {
115
3.80k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)3.78k
;
116
3.80k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription, clang::ento::CallDescription, clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
3.78k
                         const Ts &...CDs) {
115
3.78k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)3.77k
;
116
3.78k
  }
bool clang::ento::matchesAny<clang::ento::CallDescription, clang::ento::CallDescription>(clang::ento::CallEvent const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&, clang::ento::CallDescription const&)
Line
Count
Source
114
35.9k
                         const Ts &...CDs) {
115
35.9k
    return CD1.matches(Call) || 
matchesAny(Call, CDs...)35.9k
;
116
35.9k
  }
117
  /// @}
118
};
119
120
/// An immutable map from CallDescriptions to arbitrary data. Provides a unified
121
/// way for checkers to react on function calls.
122
template <typename T> class CallDescriptionMap {
123
  friend class CallDescriptionSet;
124
125
  // Some call descriptions aren't easily hashable (eg., the ones with qualified
126
  // names in which some sections are omitted), so let's put them
127
  // in a simple vector and use linear lookup.
128
  // TODO: Implement an actual map for fast lookup for "hashable" call
129
  // descriptions (eg., the ones for C functions that just match the name).
130
  std::vector<std::pair<CallDescription, T>> LinearMap;
131
132
public:
133
  CallDescriptionMap(
134
      std::initializer_list<std::pair<CallDescription, T>> &&List)
135
1.60k
      : LinearMap(List) {}
CStringChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::CStringChecker::*)(clang::ento::CheckerContext&, clang::CallExpr const*) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::CStringChecker::*)(clang::ento::CheckerContext&, clang::CallExpr const*) const> >&&)
Line
Count
Source
135
260
      : LinearMap(List) {}
CastValueChecker.cpp:clang::ento::CallDescriptionMap<std::__1::pair<std::__1::function<void ((anonymous namespace)::CastValueChecker const*, clang::ento::CallEvent const&, clang::ento::DefinedOrUnknownSVal, clang::ento::CheckerContext&)>, (anonymous namespace)::CastValueChecker::CallKind> >::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, std::__1::pair<std::__1::function<void ((anonymous namespace)::CastValueChecker const*, clang::ento::CallEvent const&, clang::ento::DefinedOrUnknownSVal, clang::ento::CheckerContext&)>, (anonymous namespace)::CastValueChecker::CallKind> > >&&)
Line
Count
Source
135
43
      : LinearMap(List) {}
ContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::Expr const*) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::Expr const*) const> >&&)
Line
Count
Source
135
21
      : LinearMap(List) {}
ContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal) const> >&&)
Line
Count
Source
135
21
      : LinearMap(List) {}
ContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal, clang::ento::SVal) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal, clang::ento::SVal) const> >&&)
Line
Count
Source
135
21
      : LinearMap(List) {}
DebugContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::DebugContainerModeling::*)(clang::CallExpr const*, clang::ento::CheckerContext&) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::DebugContainerModeling::*)(clang::CallExpr const*, clang::ento::CheckerContext&) const> >&&)
Line
Count
Source
135
13
      : LinearMap(List) {}
DebugIteratorModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::DebugIteratorModeling::*)(clang::CallExpr const*, clang::ento::CheckerContext&) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::DebugIteratorModeling::*)(clang::CallExpr const*, clang::ento::CheckerContext&) const> >&&)
Line
Count
Source
135
11
      : LinearMap(List) {}
GenericTaintChecker.cpp:clang::ento::CallDescriptionMap<(anonymous namespace)::GenericTaintRule>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, (anonymous namespace)::GenericTaintRule> >&&)
Line
Count
Source
135
16
      : LinearMap(List) {}
InvalidPtrChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::InvalidPtrChecker::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::InvalidPtrChecker::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&) const> >&&)
Line
Count
Source
135
14
      : LinearMap(List) {}
IteratorModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::IteratorModeling::*)(clang::ento::CheckerContext&, clang::Expr const*, clang::ento::SVal, clang::ento::SVal, clang::ento::SVal) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::IteratorModeling::*)(clang::ento::CheckerContext&, clang::Expr const*, clang::ento::SVal, clang::ento::SVal, clang::ento::SVal) const> >&&)
Line
Count
Source
135
19
      : LinearMap(List) {}
IteratorRangeChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::IteratorRangeChecker::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::IteratorRangeChecker::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal) const> >&&)
Line
Count
Source
135
2
      : LinearMap(List) {}
MallocChecker.cpp:clang::ento::CallDescriptionMap<std::__1::function<void ((anonymous namespace)::MallocChecker const*, clang::ento::CallEvent const&, clang::ento::CheckerContext&)> >::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, std::__1::function<void ((anonymous namespace)::MallocChecker const*, clang::ento::CallEvent const&, clang::ento::CheckerContext&)> > >&&)
Line
Count
Source
135
717
      : LinearMap(List) {}
PthreadLockChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::PthreadLockChecker::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&, (anonymous namespace)::PthreadLockChecker::CheckerKind) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::PthreadLockChecker::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&, (anonymous namespace)::PthreadLockChecker::CheckerKind) const> >&&)
Line
Count
Source
135
225
      : LinearMap(List) {}
clang::ento::CallDescriptionMap<bool>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, bool> >&&)
Line
Count
Source
135
120
      : LinearMap(List) {}
SmartPtrModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::SmartPtrModeling::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, void ((anonymous namespace)::SmartPtrModeling::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&) const> >&&)
Line
Count
Source
135
77
      : LinearMap(List) {}
STLAlgorithmModeling.cpp:clang::ento::CallDescriptionMap<bool ((anonymous namespace)::STLAlgorithmModeling::*)(clang::ento::CheckerContext&, clang::CallExpr const*) const>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, bool ((anonymous namespace)::STLAlgorithmModeling::*)(clang::ento::CheckerContext&, clang::CallExpr const*) const> >&&)
Line
Count
Source
135
2
      : LinearMap(List) {}
StreamChecker.cpp:clang::ento::CallDescriptionMap<(anonymous namespace)::FnDescription>::CallDescriptionMap(std::initializer_list<std::__1::pair<clang::ento::CallDescription, (anonymous namespace)::FnDescription> >&&)
Line
Count
Source
135
22
      : LinearMap(List) {}
136
137
  template <typename InputIt>
138
24
  CallDescriptionMap(InputIt First, InputIt Last) : LinearMap(First, Last) {}
139
140
1.64k
  ~CallDescriptionMap() = default;
clang::ento::CallDescriptionMap<bool>::~CallDescriptionMap()
Line
Count
Source
140
120
  ~CallDescriptionMap() = default;
CStringChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::CStringChecker::*)(clang::ento::CheckerContext&, clang::CallExpr const*) const>::~CallDescriptionMap()
Line
Count
Source
140
260
  ~CallDescriptionMap() = default;
CastValueChecker.cpp:clang::ento::CallDescriptionMap<std::__1::pair<std::__1::function<void ((anonymous namespace)::CastValueChecker const*, clang::ento::CallEvent const&, clang::ento::DefinedOrUnknownSVal, clang::ento::CheckerContext&)>, (anonymous namespace)::CastValueChecker::CallKind> >::~CallDescriptionMap()
Line
Count
Source
140
43
  ~CallDescriptionMap() = default;
ContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal, clang::ento::SVal) const>::~CallDescriptionMap()
Line
Count
Source
140
21
  ~CallDescriptionMap() = default;
ContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal) const>::~CallDescriptionMap()
Line
Count
Source
140
21
  ~CallDescriptionMap() = default;
ContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::Expr const*) const>::~CallDescriptionMap()
Line
Count
Source
140
21
  ~CallDescriptionMap() = default;
DebugContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::DebugContainerModeling::*)(clang::CallExpr const*, clang::ento::CheckerContext&) const>::~CallDescriptionMap()
Line
Count
Source
140
13
  ~CallDescriptionMap() = default;
DebugIteratorModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::DebugIteratorModeling::*)(clang::CallExpr const*, clang::ento::CheckerContext&) const>::~CallDescriptionMap()
Line
Count
Source
140
11
  ~CallDescriptionMap() = default;
GenericTaintChecker.cpp:clang::ento::CallDescriptionMap<(anonymous namespace)::GenericTaintRule>::~CallDescriptionMap()
Line
Count
Source
140
56
  ~CallDescriptionMap() = default;
InvalidPtrChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::InvalidPtrChecker::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&) const>::~CallDescriptionMap()
Line
Count
Source
140
14
  ~CallDescriptionMap() = default;
IteratorModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::IteratorModeling::*)(clang::ento::CheckerContext&, clang::Expr const*, clang::ento::SVal, clang::ento::SVal, clang::ento::SVal) const>::~CallDescriptionMap()
Line
Count
Source
140
19
  ~CallDescriptionMap() = default;
IteratorRangeChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::IteratorRangeChecker::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal) const>::~CallDescriptionMap()
Line
Count
Source
140
2
  ~CallDescriptionMap() = default;
MallocChecker.cpp:clang::ento::CallDescriptionMap<std::__1::function<void ((anonymous namespace)::MallocChecker const*, clang::ento::CallEvent const&, clang::ento::CheckerContext&)> >::~CallDescriptionMap()
Line
Count
Source
140
717
  ~CallDescriptionMap() = default;
PthreadLockChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::PthreadLockChecker::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&, (anonymous namespace)::PthreadLockChecker::CheckerKind) const>::~CallDescriptionMap()
Line
Count
Source
140
225
  ~CallDescriptionMap() = default;
SmartPtrModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::SmartPtrModeling::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&) const>::~CallDescriptionMap()
Line
Count
Source
140
77
  ~CallDescriptionMap() = default;
STLAlgorithmModeling.cpp:clang::ento::CallDescriptionMap<bool ((anonymous namespace)::STLAlgorithmModeling::*)(clang::ento::CheckerContext&, clang::CallExpr const*) const>::~CallDescriptionMap()
Line
Count
Source
140
2
  ~CallDescriptionMap() = default;
StreamChecker.cpp:clang::ento::CallDescriptionMap<(anonymous namespace)::FnDescription>::~CallDescriptionMap()
Line
Count
Source
140
22
  ~CallDescriptionMap() = default;
141
142
  // These maps are usually stored once per checker, so let's make sure
143
  // we don't do redundant copies.
144
  CallDescriptionMap(const CallDescriptionMap &) = delete;
145
  CallDescriptionMap &operator=(const CallDescription &) = delete;
146
147
16
  CallDescriptionMap(CallDescriptionMap &&) = default;
148
0
  CallDescriptionMap &operator=(CallDescriptionMap &&) = default;
149
150
191k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
191k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
1.84M
      if (I.first.matches(Call))
155
11.8k
        return &I.second;
156
157
179k
    return nullptr;
158
191k
  }
CStringChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::CStringChecker::*)(clang::ento::CheckerContext&, clang::CallExpr const*) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
19.8k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
19.8k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
452k
      if (I.first.matches(Call))
155
2.07k
        return &I.second;
156
157
17.7k
    return nullptr;
158
19.8k
  }
CastValueChecker.cpp:clang::ento::CallDescriptionMap<std::__1::pair<std::__1::function<void ((anonymous namespace)::CastValueChecker const*, clang::ento::CallEvent const&, clang::ento::DefinedOrUnknownSVal, clang::ento::CheckerContext&)>, (anonymous namespace)::CastValueChecker::CallKind> >::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
258
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
258
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
1.88k
      if (I.first.matches(Call))
155
55
        return &I.second;
156
157
203
    return nullptr;
158
258
  }
ContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::Expr const*) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
3.28k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
3.28k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
25.5k
      if (I.first.matches(Call))
155
187
        return &I.second;
156
157
3.09k
    return nullptr;
158
3.28k
  }
ContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
3.09k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
3.09k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
11.7k
      if (I.first.matches(Call))
155
326
        return &I.second;
156
157
2.76k
    return nullptr;
158
3.09k
  }
ContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::ContainerModeling::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal, clang::ento::SVal) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
2.76k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
2.76k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
5.53k
      if (I.first.matches(Call))
155
8
        return &I.second;
156
157
2.76k
    return nullptr;
158
2.76k
  }
DebugContainerModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::DebugContainerModeling::*)(clang::CallExpr const*, clang::ento::CheckerContext&) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
10.6k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
10.6k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
20.7k
      if (I.first.matches(Call))
155
1.08k
        return &I.second;
156
157
9.52k
    return nullptr;
158
10.6k
  }
DebugIteratorModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::DebugIteratorModeling::*)(clang::CallExpr const*, clang::ento::CheckerContext&) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
10.5k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
10.5k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
28.8k
      if (I.first.matches(Call))
155
2.68k
        return &I.second;
156
157
7.90k
    return nullptr;
158
10.5k
  }
GenericTaintChecker.cpp:clang::ento::CallDescriptionMap<(anonymous namespace)::GenericTaintRule>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
2.11k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
2.11k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
69.5k
      if (I.first.matches(Call))
155
762
        return &I.second;
156
157
1.35k
    return nullptr;
158
2.11k
  }
InvalidPtrChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::InvalidPtrChecker::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
194
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
194
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
782
      if (I.first.matches(Call))
155
59
        return &I.second;
156
157
135
    return nullptr;
158
194
  }
IteratorModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::IteratorModeling::*)(clang::ento::CheckerContext&, clang::Expr const*, clang::ento::SVal, clang::ento::SVal, clang::ento::SVal) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
16.0k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
16.0k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
47.9k
      if (I.first.matches(Call))
155
248
        return &I.second;
156
157
15.8k
    return nullptr;
158
16.0k
  }
IteratorRangeChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::IteratorRangeChecker::*)(clang::ento::CheckerContext&, clang::ento::SVal, clang::ento::SVal) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
1.39k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
1.39k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
3.89k
      if (I.first.matches(Call))
155
228
        return &I.second;
156
157
1.17k
    return nullptr;
158
1.39k
  }
MallocChecker.cpp:clang::ento::CallDescriptionMap<std::__1::function<void ((anonymous namespace)::MallocChecker const*, clang::ento::CallEvent const&, clang::ento::CheckerContext&)> >::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
111k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
111k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
1.06M
      if (I.first.matches(Call))
155
2.62k
        return &I.second;
156
157
108k
    return nullptr;
158
111k
  }
PthreadLockChecker.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::PthreadLockChecker::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&, (anonymous namespace)::PthreadLockChecker::CheckerKind) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
5.67k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
5.67k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
70.8k
      if (I.first.matches(Call))
155
521
        return &I.second;
156
157
5.15k
    return nullptr;
158
5.67k
  }
clang::ento::CallDescriptionMap<bool>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
1.33k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
1.33k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
7.04k
      if (I.first.matches(Call))
155
263
        return &I.second;
156
157
1.07k
    return nullptr;
158
1.33k
  }
SmartPtrModeling.cpp:clang::ento::CallDescriptionMap<void ((anonymous namespace)::SmartPtrModeling::*)(clang::ento::CallEvent const&, clang::ento::CheckerContext&) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
155
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
155
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
485
      if (I.first.matches(Call))
155
97
        return &I.second;
156
157
58
    return nullptr;
158
155
  }
STLAlgorithmModeling.cpp:clang::ento::CallDescriptionMap<bool ((anonymous namespace)::STLAlgorithmModeling::*)(clang::ento::CheckerContext&, clang::CallExpr const*) const>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
1.23k
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
1.23k
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
27.9k
      if (I.first.matches(Call))
155
54
        return &I.second;
156
157
1.18k
    return nullptr;
158
1.23k
  }
StreamChecker.cpp:clang::ento::CallDescriptionMap<(anonymous namespace)::FnDescription>::lookup(clang::ento::CallEvent const&) const
Line
Count
Source
150
795
  LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
151
    // Slow path: linear lookup.
152
    // TODO: Implement some sort of fast path.
153
795
    for (const std::pair<CallDescription, T> &I : LinearMap)
154
6.46k
      if (I.first.matches(Call))
155
576
        return &I.second;
156
157
219
    return nullptr;
158
795
  }
159
};
160
161
/// An immutable set of CallDescriptions.
162
/// Checkers can efficiently decide if a given CallEvent matches any
163
/// CallDescription in the set.
164
class CallDescriptionSet {
165
  CallDescriptionMap<bool /*unused*/> Impl = {};
166
167
public:
168
  CallDescriptionSet(std::initializer_list<CallDescription> &&List);
169
170
  CallDescriptionSet(const CallDescriptionSet &) = delete;
171
  CallDescriptionSet &operator=(const CallDescription &) = delete;
172
173
  LLVM_NODISCARD bool contains(const CallEvent &Call) const;
174
};
175
176
} // namespace ento
177
} // namespace clang
178
179
#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLDESCRIPTION_H