Coverage Report

Created: 2020-09-19 12:23

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/AST/IgnoreExpr.h
Line
Count
Source
1
//===--- IgnoreExpr.h - Ignore intermediate Expressions -----------------===//
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
// This file defines common functions to ignore intermediate expression nodes
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_AST_IGNOREEXPR_H
14
#define LLVM_CLANG_AST_IGNOREEXPR_H
15
16
#include "clang/AST/Expr.h"
17
#include "clang/AST/ExprCXX.h"
18
19
namespace clang {
20
namespace detail {
21
/// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *,
22
/// Return Fn_n(...(Fn_1(E)))
23
355M
inline Expr *IgnoreExprNodesImpl(Expr *E) { return E; }
24
template <typename FnTy, typename... FnTys>
25
597M
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
597M
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
597M
}
clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&)(clang::Expr*))
Line
Count
Source
25
355M
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
355M
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
355M
}
clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*))
Line
Count
Source
25
242M
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
242M
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
242M
}
Expr.cpp:clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2&>(clang::Expr*, clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2&)
Line
Count
Source
25
20.9k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
20.9k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
20.9k
}
Expr.cpp:clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2&>(clang::Expr*, clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2&)
Line
Count
Source
25
20.9k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
20.9k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
20.9k
}
Expr.cpp:clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreUnlessSpelledInSource()::$_3&, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&>(clang::Expr*, clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreUnlessSpelledInSource()::$_3&, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&)
Line
Count
Source
25
647
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
647
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
647
}
Expr.cpp:clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreUnlessSpelledInSource()::$_3&, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&>(clang::Expr*, clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreUnlessSpelledInSource()::$_3&, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&)
Line
Count
Source
25
647
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
647
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
647
}
Expr.cpp:clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreUnlessSpelledInSource()::$_3&, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&>(clang::Expr*, clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreUnlessSpelledInSource()::$_3&, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&)
Line
Count
Source
25
647
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
647
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
647
}
Expr.cpp:clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr::IgnoreUnlessSpelledInSource()::$_3&, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&>(clang::Expr*, clang::Expr::IgnoreUnlessSpelledInSource()::$_3&, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&)
Line
Count
Source
25
647
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
647
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
647
}
Expr.cpp:clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr::IgnoreUnlessSpelledInSource()::$_4&>(clang::Expr*, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&)
Line
Count
Source
25
647
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
647
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
647
}
clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*))
Line
Count
Source
25
10.4k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
10.4k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
10.4k
}
28
} // namespace detail
29
30
/// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *,
31
/// Recursively apply each of the functions to E until reaching a fixed point.
32
/// Note that a null E is valid; in this case nothing is done.
33
280M
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
280M
  Expr *LastE = nullptr;
35
636M
  while (E != LastE) {
36
355M
    LastE = E;
37
355M
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
355M
  }
39
280M
  return E;
40
280M
}
clang::Expr* clang::IgnoreExprNodes<clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&)(clang::Expr*))
Line
Count
Source
33
104M
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
104M
  Expr *LastE = nullptr;
35
217M
  while (E != LastE) {
36
113M
    LastE = E;
37
113M
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
113M
  }
39
104M
  return E;
40
104M
}
clang::Expr* clang::IgnoreExprNodes<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*))
Line
Count
Source
33
176M
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
176M
  Expr *LastE = nullptr;
35
418M
  while (E != LastE) {
36
242M
    LastE = E;
37
242M
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
242M
  }
39
176M
  return E;
40
176M
}
Expr.cpp:clang::Expr* clang::IgnoreExprNodes<clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2&>(clang::Expr*, clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2&)
Line
Count
Source
33
19.1k
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
19.1k
  Expr *LastE = nullptr;
35
40.0k
  while (E != LastE) {
36
20.9k
    LastE = E;
37
20.9k
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
20.9k
  }
39
19.1k
  return E;
40
19.1k
}
Expr.cpp:clang::Expr* clang::IgnoreExprNodes<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreUnlessSpelledInSource()::$_3&, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&>(clang::Expr*, clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreUnlessSpelledInSource()::$_3&, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&)
Line
Count
Source
33
534
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
534
  Expr *LastE = nullptr;
35
1.18k
  while (E != LastE) {
36
647
    LastE = E;
37
647
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
647
  }
39
534
  return E;
40
534
}
clang::Expr* clang::IgnoreExprNodes<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*))
Line
Count
Source
33
8.61k
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
8.61k
  Expr *LastE = nullptr;
35
19.0k
  while (E != LastE) {
36
10.4k
    LastE = E;
37
10.4k
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
10.4k
  }
39
8.61k
  return E;
40
8.61k
}
41
42
template <typename... FnTys>
43
const Expr *IgnoreExprNodes(const Expr *E, FnTys &&...Fns) {
44
  return const_cast<Expr *>(IgnoreExprNodes(E, std::forward<FnTys>(Fns)...));
45
}
46
47
172M
inline Expr *IgnoreImplicitCastsSingleStep(Expr *E) {
48
172M
  if (auto *ICE = dyn_cast<ImplicitCastExpr>(E))
49
46.2M
    return ICE->getSubExpr();
50
126M
51
126M
  if (auto *FE = dyn_cast<FullExpr>(E))
52
145k
    return FE->getSubExpr();
53
126M
54
126M
  return E;
55
126M
}
56
57
153M
inline Expr *IgnoreImplicitCastsExtraSingleStep(Expr *E) {
58
  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
59
  // addition to what IgnoreImpCasts() skips to account for the current
60
  // behaviour of IgnoreParenImpCasts().
61
153M
  Expr *SubE = IgnoreImplicitCastsSingleStep(E);
62
153M
  if (SubE != E)
63
41.4M
    return SubE;
64
112M
65
112M
  if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
66
257k
    return MTE->getSubExpr();
67
111M
68
111M
  if (auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
69
1.43M
    return NTTP->getReplacement();
70
110M
71
110M
  return E;
72
110M
}
73
74
88.7M
inline Expr *IgnoreCastsSingleStep(Expr *E) {
75
88.7M
  if (auto *CE = dyn_cast<CastExpr>(E))
76
14.6M
    return CE->getSubExpr();
77
74.1M
78
74.1M
  if (auto *FE = dyn_cast<FullExpr>(E))
79
53.9k
    return FE->getSubExpr();
80
74.0M
81
74.0M
  if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
82
25.6k
    return MTE->getSubExpr();
83
74.0M
84
74.0M
  if (auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
85
291k
    return NTTP->getReplacement();
86
73.7M
87
73.7M
  return E;
88
73.7M
}
89
90
60.8k
inline Expr *IgnoreLValueCastsSingleStep(Expr *E) {
91
  // Skip what IgnoreCastsSingleStep skips, except that only
92
  // lvalue-to-rvalue casts are skipped.
93
60.8k
  if (auto *CE = dyn_cast<CastExpr>(E))
94
3.20k
    if (CE->getCastKind() != CK_LValueToRValue)
95
287
      return E;
96
60.5k
97
60.5k
  return IgnoreCastsSingleStep(E);
98
60.5k
}
99
100
41.9k
inline Expr *IgnoreBaseCastsSingleStep(Expr *E) {
101
41.9k
  if (auto *CE = dyn_cast<CastExpr>(E))
102
8.34k
    if (CE->getCastKind() == CK_DerivedToBase ||
103
8.26k
        CE->getCastKind() == CK_UncheckedDerivedToBase ||
104
7.93k
        CE->getCastKind() == CK_NoOp)
105
4.38k
      return CE->getSubExpr();
106
37.5k
107
37.5k
  return E;
108
37.5k
}
109
110
7.48M
inline Expr *IgnoreImplicitSingleStep(Expr *E) {
111
7.48M
  Expr *SubE = IgnoreImplicitCastsSingleStep(E);
112
7.48M
  if (SubE != E)
113
2.01M
    return SubE;
114
5.47M
115
5.47M
  if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
116
674
    return MTE->getSubExpr();
117
5.47M
118
5.47M
  if (auto *BTE = dyn_cast<CXXBindTemporaryExpr>(E))
119
115
    return BTE->getSubExpr();
120
5.47M
121
5.47M
  return E;
122
5.47M
}
123
124
861
inline Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E) {
125
861
  if (auto *ICE = dyn_cast<ImplicitCastExpr>(E))
126
183
    return ICE->getSubExprAsWritten();
127
678
128
678
  return IgnoreImplicitSingleStep(E);
129
678
}
130
131
647
inline Expr *IgnoreParensOnlySingleStep(Expr *E) {
132
647
  if (auto *PE = dyn_cast<ParenExpr>(E))
133
5
    return PE->getSubExpr();
134
642
  return E;
135
642
}
136
137
336M
inline Expr *IgnoreParensSingleStep(Expr *E) {
138
336M
  if (auto *PE = dyn_cast<ParenExpr>(E))
139
11.5M
    return PE->getSubExpr();
140
324M
141
324M
  if (auto *UO = dyn_cast<UnaryOperator>(E)) {
142
4.97M
    if (UO->getOpcode() == UO_Extension)
143
257k
      return UO->getSubExpr();
144
319M
  }
145
319M
146
319M
  else if (auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
147
1.67k
    if (!GSE->isResultDependent())
148
1.66k
      return GSE->getResultExpr();
149
319M
  }
150
319M
151
319M
  else if (auto *CE = dyn_cast<ChooseExpr>(E)) {
152
268
    if (!CE->isConditionDependent())
153
265
      return CE->getChosenSubExpr();
154
324M
  }
155
324M
156
324M
  return E;
157
324M
}
158
159
} // namespace clang
160
161
#endif // LLVM_CLANG_AST_IGNOREEXPR_H