Coverage Report

Created: 2021-01-26 06:56

/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
361M
inline Expr *IgnoreExprNodesImpl(Expr *E) { return E; }
24
template <typename FnTy, typename... FnTys>
25
606M
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
606M
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
606M
}
clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&)(clang::Expr*))
Line
Count
Source
25
361M
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
361M
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
361M
}
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
244M
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
244M
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
244M
}
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
27.3k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
27.3k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
27.3k
}
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
27.3k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
27.3k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
27.3k
}
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
37.1k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
37.1k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
37.1k
}
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
37.1k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
37.1k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
37.1k
}
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
37.1k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
37.1k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
37.1k
}
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
37.1k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
37.1k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
37.1k
}
Expr.cpp:clang::Expr* clang::detail::IgnoreExprNodesImpl<clang::Expr::IgnoreUnlessSpelledInSource()::$_4&>(clang::Expr*, clang::Expr::IgnoreUnlessSpelledInSource()::$_4&)
Line
Count
Source
25
37.1k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
37.1k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
37.1k
}
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
11.0k
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
26
11.0k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
27
11.0k
}
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
286M
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
286M
  Expr *LastE = nullptr;
35
647M
  while (E != LastE) {
36
361M
    LastE = E;
37
361M
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
361M
  }
39
286M
  return E;
40
286M
}
clang::Expr* clang::IgnoreExprNodes<clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&)(clang::Expr*))
Line
Count
Source
33
107M
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
107M
  Expr *LastE = nullptr;
35
224M
  while (E != LastE) {
36
116M
    LastE = E;
37
116M
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
116M
  }
39
107M
  return E;
40
107M
}
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
178M
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
178M
  Expr *LastE = nullptr;
35
423M
  while (E != LastE) {
36
244M
    LastE = E;
37
244M
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
244M
  }
39
178M
  return E;
40
178M
}
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
23.6k
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
23.6k
  Expr *LastE = nullptr;
35
50.9k
  while (E != LastE) {
36
27.3k
    LastE = E;
37
27.3k
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
27.3k
  }
39
23.6k
  return E;
40
23.6k
}
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
34.5k
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
34.5k
  Expr *LastE = nullptr;
35
71.6k
  while (E != LastE) {
36
37.1k
    LastE = E;
37
37.1k
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
37.1k
  }
39
34.5k
  return E;
40
34.5k
}
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
9.09k
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
34
9.09k
  Expr *LastE = nullptr;
35
20.1k
  while (E != LastE) {
36
11.0k
    LastE = E;
37
11.0k
    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
38
11.0k
  }
39
9.09k
  return E;
40
9.09k
}
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
174M
inline Expr *IgnoreImplicitCastsSingleStep(Expr *E) {
48
174M
  if (auto *ICE = dyn_cast<ImplicitCastExpr>(E))
49
46.9M
    return ICE->getSubExpr();
50
51
127M
  if (auto *FE = dyn_cast<FullExpr>(E))
52
147k
    return FE->getSubExpr();
53
54
127M
  return E;
55
127M
}
56
57
155M
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
155M
  Expr *SubE = IgnoreImplicitCastsSingleStep(E);
62
155M
  if (SubE != E)
63
42.0M
    return SubE;
64
65
113M
  if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
66
262k
    return MTE->getSubExpr();
67
68
112M
  if (auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
69
1.46M
    return NTTP->getReplacement();
70
71
111M
  return E;
72
111M
}
73
74
89.6M
inline Expr *IgnoreCastsSingleStep(Expr *E) {
75
89.6M
  if (auto *CE = dyn_cast<CastExpr>(E))
76
14.6M
    return CE->getSubExpr();
77
78
74.9M
  if (auto *FE = dyn_cast<FullExpr>(E))
79
53.4k
    return FE->getSubExpr();
80
81
74.9M
  if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
82
26.4k
    return MTE->getSubExpr();
83
84
74.9M
  if (auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
85
292k
    return NTTP->getReplacement();
86
87
74.6M
  return E;
88
74.6M
}
89
90
61.7k
inline Expr *IgnoreLValueCastsSingleStep(Expr *E) {
91
  // Skip what IgnoreCastsSingleStep skips, except that only
92
  // lvalue-to-rvalue casts are skipped.
93
61.7k
  if (auto *CE = dyn_cast<CastExpr>(E))
94
3.24k
    if (CE->getCastKind() != CK_LValueToRValue)
95
287
      return E;
96
97
61.5k
  return IgnoreCastsSingleStep(E);
98
61.5k
}
99
100
40.3k
inline Expr *IgnoreBaseCastsSingleStep(Expr *E) {
101
40.3k
  if (auto *CE = dyn_cast<CastExpr>(E))
102
8.45k
    if (CE->getCastKind() == CK_DerivedToBase ||
103
8.36k
        CE->getCastKind() == CK_UncheckedDerivedToBase ||
104
8.03k
        CE->getCastKind() == CK_NoOp)
105
4.39k
      return CE->getSubExpr();
106
107
35.9k
  return E;
108
35.9k
}
109
110
7.54M
inline Expr *IgnoreImplicitSingleStep(Expr *E) {
111
7.54M
  Expr *SubE = IgnoreImplicitCastsSingleStep(E);
112
7.54M
  if (SubE != E)
113
2.02M
    return SubE;
114
115
5.51M
  if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
116
686
    return MTE->getSubExpr();
117
118
5.51M
  if (auto *BTE = dyn_cast<CXXBindTemporaryExpr>(E))
119
114
    return BTE->getSubExpr();
120
121
5.51M
  return E;
122
5.51M
}
123
124
2.52k
inline Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E) {
125
2.52k
  if (auto *ICE = dyn_cast<ImplicitCastExpr>(E))
126
1.01k
    return ICE->getSubExprAsWritten();
127
128
1.50k
  return IgnoreImplicitSingleStep(E);
129
1.50k
}
130
131
37.1k
inline Expr *IgnoreParensOnlySingleStep(Expr *E) {
132
37.1k
  if (auto *PE = dyn_cast<ParenExpr>(E))
133
5
    return PE->getSubExpr();
134
37.1k
  return E;
135
37.1k
}
136
137
342M
inline Expr *IgnoreParensSingleStep(Expr *E) {
138
342M
  if (auto *PE = dyn_cast<ParenExpr>(E))
139
11.3M
    return PE->getSubExpr();
140
141
330M
  if (auto *UO = dyn_cast<UnaryOperator>(E)) {
142
5.10M
    if (UO->getOpcode() == UO_Extension)
143
261k
      return UO->getSubExpr();
144
325M
  }
145
146
325M
  else if (auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
147
1.86k
    if (!GSE->isResultDependent())
148
1.85k
      return GSE->getResultExpr();
149
325M
  }
150
151
325M
  else if (auto *CE = dyn_cast<ChooseExpr>(E)) {
152
268
    if (!CE->isConditionDependent())
153
265
      return CE->getChosenSubExpr();
154
330M
  }
155
156
330M
  return E;
157
330M
}
158
159
} // namespace clang
160
161
#endif // LLVM_CLANG_AST_IGNOREEXPR_H