Coverage Report

Created: 2018-09-23 03:40

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/AST/CanonicalType.h
Line
Count
Source (jump to first uncovered line)
1
//===- CanonicalType.h - C Language Family Type Representation --*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
//  This file defines the CanQual class template, which provides access to
11
//  canonical types.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CLANG_AST_CANONICALTYPE_H
16
#define LLVM_CLANG_AST_CANONICALTYPE_H
17
18
#include "clang/AST/Type.h"
19
#include "clang/Basic/Diagnostic.h"
20
#include "clang/Basic/SourceLocation.h"
21
#include "llvm/ADT/ArrayRef.h"
22
#include "llvm/ADT/FoldingSet.h"
23
#include "llvm/ADT/iterator.h"
24
#include "llvm/Support/Casting.h"
25
#include "llvm/Support/PointerLikeTypeTraits.h"
26
#include <cassert>
27
#include <iterator>
28
#include <type_traits>
29
30
namespace clang {
31
32
template<typename T> class CanProxy;
33
template<typename T> struct CanProxyAdaptor;
34
class CXXRecordDecl;
35
class EnumDecl;
36
class Expr;
37
class IdentifierInfo;
38
class ObjCInterfaceDecl;
39
class RecordDecl;
40
class TagDecl;
41
class TemplateTypeParmDecl;
42
43
//----------------------------------------------------------------------------//
44
// Canonical, qualified type template
45
//----------------------------------------------------------------------------//
46
47
/// Represents a canonical, potentially-qualified type.
48
///
49
/// The CanQual template is a lightweight smart pointer that provides access
50
/// to the canonical representation of a type, where all typedefs and other
51
/// syntactic sugar has been eliminated. A CanQualType may also have various
52
/// qualifiers (const, volatile, restrict) attached to it.
53
///
54
/// The template type parameter @p T is one of the Type classes (PointerType,
55
/// BuiltinType, etc.). The type stored within @c CanQual<T> will be of that
56
/// type (or some subclass of that type). The typedef @c CanQualType is just
57
/// a shorthand for @c CanQual<Type>.
58
///
59
/// An instance of @c CanQual<T> can be implicitly converted to a
60
/// @c CanQual<U> when T is derived from U, which essentially provides an
61
/// implicit upcast. For example, @c CanQual<LValueReferenceType> can be
62
/// converted to @c CanQual<ReferenceType>. Note that any @c CanQual type can
63
/// be implicitly converted to a QualType, but the reverse operation requires
64
/// a call to ASTContext::getCanonicalType().
65
template<typename T = Type>
66
class CanQual {
67
  /// The actual, canonical type.
68
  QualType Stored;
69
70
public:
71
  /// Constructs a NULL canonical type.
72
772M
  CanQual() = default;
clang::CanQual<clang::Type>::CanQual()
Line
Count
Source
72
753M
  CanQual() = default;
clang::CanQual<clang::FunctionType>::CanQual()
Line
Count
Source
72
78.0k
  CanQual() = default;
clang::CanQual<clang::FunctionProtoType>::CanQual()
Line
Count
Source
72
14.7M
  CanQual() = default;
clang::CanQual<clang::FunctionNoProtoType>::CanQual()
Line
Count
Source
72
554k
  CanQual() = default;
clang::CanQual<clang::PointerType>::CanQual()
Line
Count
Source
72
2.02M
  CanQual() = default;
clang::CanQual<clang::ComplexType>::CanQual()
Line
Count
Source
72
23
  CanQual() = default;
clang::CanQual<clang::RecordType>::CanQual()
Line
Count
Source
72
2.16M
  CanQual() = default;
clang::CanQual<clang::ReferenceType>::CanQual()
Line
Count
Source
72
10.4k
  CanQual() = default;
clang::CanQual<clang::BlockPointerType>::CanQual()
Line
Count
Source
72
48
  CanQual() = default;
clang::CanQual<clang::MemberPointerType>::CanQual()
Line
Count
Source
72
3.10k
  CanQual() = default;
73
74
  /// Converting constructor that permits implicit upcasting of
75
  /// canonical type pointers.
76
  template <typename U>
77
  CanQual(const CanQual<U> &Other,
78
          typename std::enable_if<std::is_base_of<T, U>::value, int>::type = 0);
79
80
  /// Retrieve the underlying type pointer, which refers to a
81
  /// canonical type.
82
  ///
83
  /// The underlying pointer must not be nullptr.
84
248M
  const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
clang::CanQual<clang::FunctionNoProtoType>::getTypePtr() const
Line
Count
Source
84
55.9k
  const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
clang::CanQual<clang::FunctionProtoType>::getTypePtr() const
Line
Count
Source
84
11.3M
  const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
Unexecuted instantiation: clang::CanQual<clang::FunctionType>::getTypePtr() const
clang::CanQual<clang::Type>::getTypePtr() const
Line
Count
Source
84
236M
  const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
clang::CanQual<clang::PointerType>::getTypePtr() const
Line
Count
Source
84
1.01M
  const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
Unexecuted instantiation: clang::CanQual<clang::ComplexType>::getTypePtr() const
Unexecuted instantiation: clang::CanQual<clang::RecordType>::getTypePtr() const
clang::CanQual<clang::ReferenceType>::getTypePtr() const
Line
Count
Source
84
1.01k
  const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
clang::CanQual<clang::BlockPointerType>::getTypePtr() const
Line
Count
Source
84
24
  const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
clang::CanQual<clang::MemberPointerType>::getTypePtr() const
Line
Count
Source
84
2.66k
  const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
85
86
  /// Retrieve the underlying type pointer, which refers to a
87
  /// canonical type, or nullptr.
88
2.07M
  const T *getTypePtrOrNull() const {
89
2.07M
    return cast_or_null<T>(Stored.getTypePtrOrNull());
90
2.07M
  }
clang::CanQual<clang::FunctionType>::getTypePtrOrNull() const
Line
Count
Source
88
39.0k
  const T *getTypePtrOrNull() const {
89
39.0k
    return cast_or_null<T>(Stored.getTypePtrOrNull());
90
39.0k
  }
clang::CanQual<clang::PointerType>::getTypePtrOrNull() const
Line
Count
Source
88
206
  const T *getTypePtrOrNull() const {
89
206
    return cast_or_null<T>(Stored.getTypePtrOrNull());
90
206
  }
clang::CanQual<clang::ComplexType>::getTypePtrOrNull() const
Line
Count
Source
88
21
  const T *getTypePtrOrNull() const {
89
21
    return cast_or_null<T>(Stored.getTypePtrOrNull());
90
21
  }
clang::CanQual<clang::RecordType>::getTypePtrOrNull() const
Line
Count
Source
88
2.03M
  const T *getTypePtrOrNull() const {
89
2.03M
    return cast_or_null<T>(Stored.getTypePtrOrNull());
90
2.03M
  }
91
92
  /// Implicit conversion to a qualified type.
93
587M
  operator QualType() const { return Stored; }
94
95
  /// Implicit conversion to bool.
96
760k
  explicit operator bool() const { return !isNull(); }
clang::CanQual<clang::FunctionNoProtoType>::operator bool() const
Line
Count
Source
96
470k
  explicit operator bool() const { return !isNull(); }
clang::CanQual<clang::ReferenceType>::operator bool() const
Line
Count
Source
96
8.39k
  explicit operator bool() const { return !isNull(); }
clang::CanQual<clang::PointerType>::operator bool() const
Line
Count
Source
96
5.89k
  explicit operator bool() const { return !isNull(); }
clang::CanQual<clang::Type>::operator bool() const
Line
Count
Source
96
276k
  explicit operator bool() const { return !isNull(); }
97
98
765k
  bool isNull() const {
99
765k
    return Stored.isNull();
100
765k
  }
clang::CanQual<clang::FunctionNoProtoType>::isNull() const
Line
Count
Source
98
470k
  bool isNull() const {
99
470k
    return Stored.isNull();
100
470k
  }
clang::CanQual<clang::Type>::isNull() const
Line
Count
Source
98
280k
  bool isNull() const {
99
280k
    return Stored.isNull();
100
280k
  }
clang::CanQual<clang::ReferenceType>::isNull() const
Line
Count
Source
98
8.39k
  bool isNull() const {
99
8.39k
    return Stored.isNull();
100
8.39k
  }
clang::CanQual<clang::PointerType>::isNull() const
Line
Count
Source
98
5.89k
  bool isNull() const {
99
5.89k
    return Stored.isNull();
100
5.89k
  }
101
102
251k
  SplitQualType split() const { return Stored.split(); }
103
104
  /// Retrieve a canonical type pointer with a different static type,
105
  /// upcasting or downcasting as needed.
106
  ///
107
  /// The getAs() function is typically used to try to downcast to a
108
  /// more specific (canonical) type in the type system. For example:
109
  ///
110
  /// @code
111
  /// void f(CanQual<Type> T) {
112
  ///   if (CanQual<PointerType> Ptr = T->getAs<PointerType>()) {
113
  ///     // look at Ptr's pointee type
114
  ///   }
115
  /// }
116
  /// @endcode
117
  ///
118
  /// \returns A proxy pointer to the same type, but with the specified
119
  /// static type (@p U). If the dynamic type is not the specified static type
120
  /// or a derived class thereof, a NULL canonical type.
121
  template<typename U> CanProxy<U> getAs() const;
122
123
  template<typename U> CanProxy<U> castAs() const;
124
125
  /// Overloaded arrow operator that produces a canonical type
126
  /// proxy.
127
  CanProxy<T> operator->() const;
128
129
  /// Retrieve all qualifiers.
130
6.05M
  Qualifiers getQualifiers() const { return Stored.getLocalQualifiers(); }
clang::CanQual<clang::Type>::getQualifiers() const
Line
Count
Source
130
6.05M
  Qualifiers getQualifiers() const { return Stored.getLocalQualifiers(); }
clang::CanQual<clang::FunctionProtoType>::getQualifiers() const
Line
Count
Source
130
106
  Qualifiers getQualifiers() const { return Stored.getLocalQualifiers(); }
131
132
  /// Retrieve the const/volatile/restrict qualifiers.
133
1.43M
  unsigned getCVRQualifiers() const { return Stored.getLocalCVRQualifiers(); }
134
135
  /// Determines whether this type has any qualifiers
136
  bool hasQualifiers() const { return Stored.hasLocalQualifiers(); }
137
138
1.88M
  bool isConstQualified() const {
139
1.88M
    return Stored.isLocalConstQualified();
140
1.88M
  }
141
142
6.74k
  bool isVolatileQualified() const {
143
6.74k
    return Stored.isLocalVolatileQualified();
144
6.74k
  }
145
146
  bool isRestrictQualified() const {
147
    return Stored.isLocalRestrictQualified();
148
  }
149
150
  /// Determines if this canonical type is furthermore
151
  /// canonical as a parameter.  The parameter-canonicalization
152
  /// process decays arrays to pointers and drops top-level qualifiers.
153
  bool isCanonicalAsParam() const {
154
    return Stored.isCanonicalAsParam();
155
  }
156
157
  /// Retrieve the unqualified form of this type.
158
  CanQual<T> getUnqualifiedType() const;
159
160
  /// Retrieves a version of this type with const applied.
161
  /// Note that this does not always yield a canonical type.
162
295k
  QualType withConst() const {
163
295k
    return Stored.withConst();
164
295k
  }
165
166
  /// Determines whether this canonical type is more qualified than
167
  /// the @p Other canonical type.
168
  bool isMoreQualifiedThan(CanQual<T> Other) const {
169
    return Stored.isMoreQualifiedThan(Other.Stored);
170
  }
171
172
  /// Determines whether this canonical type is at least as qualified as
173
  /// the @p Other canonical type.
174
7.12k
  bool isAtLeastAsQualifiedAs(CanQual<T> Other) const {
175
7.12k
    return Stored.isAtLeastAsQualifiedAs(Other.Stored);
176
7.12k
  }
177
178
  /// If the canonical type is a reference type, returns the type that
179
  /// it refers to; otherwise, returns the type itself.
180
  CanQual<Type> getNonReferenceType() const;
181
182
  /// Retrieve the internal representation of this canonical type.
183
136M
  void *getAsOpaquePtr() const { return Stored.getAsOpaquePtr(); }
184
185
  /// Construct a canonical type from its internal representation.
186
  static CanQual<T> getFromOpaquePtr(void *Ptr);
187
188
  /// Builds a canonical type from a QualType.
189
  ///
190
  /// This routine is inherently unsafe, because it requires the user to
191
  /// ensure that the given type is a canonical type with the correct
192
  // (dynamic) type.
193
  static CanQual<T> CreateUnsafe(QualType Other);
194
195
  void dump() const { Stored.dump(); }
196
197
18.0M
  void Profile(llvm::FoldingSetNodeID &ID) const {
198
18.0M
    ID.AddPointer(getAsOpaquePtr());
199
18.0M
  }
200
};
201
202
template<typename T, typename U>
203
41.3M
inline bool operator==(CanQual<T> x, CanQual<U> y) {
204
41.3M
  return x.getAsOpaquePtr() == y.getAsOpaquePtr();
205
41.3M
}
206
207
template<typename T, typename U>
208
14.9M
inline bool operator!=(CanQual<T> x, CanQual<U> y) {
209
14.9M
  return x.getAsOpaquePtr() != y.getAsOpaquePtr();
210
14.9M
}
211
212
/// Represents a canonical, potentially-qualified type.
213
using CanQualType = CanQual<Type>;
214
215
2.85M
inline CanQualType Type::getCanonicalTypeUnqualified() const {
216
2.85M
  return CanQualType::CreateUnsafe(getCanonicalTypeInternal());
217
2.85M
}
218
219
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
220
57
                                           CanQualType T) {
221
57
  DB << static_cast<QualType>(T);
222
57
  return DB;
223
57
}
224
225
//----------------------------------------------------------------------------//
226
// Internal proxy classes used by canonical types
227
//----------------------------------------------------------------------------//
228
229
#define LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(Accessor)                    \
230
2.55M
CanQualType Accessor() const {                                           \
231
2.55M
return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor());      \
232
2.55M
}
clang::CanProxyAdaptor<clang::FunctionNoProtoType>::getReturnType() const
Line
Count
Source
230
27.9k
CanQualType Accessor() const {                                           \
231
27.9k
return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor());      \
232
27.9k
}
clang::CanProxyAdaptor<clang::FunctionProtoType>::getReturnType() const
Line
Count
Source
230
1.50M
CanQualType Accessor() const {                                           \
231
1.50M
return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor());      \
232
1.50M
}
Unexecuted instantiation: clang::CanProxyAdaptor<clang::FunctionType>::getReturnType() const
clang::CanProxyAdaptor<clang::PointerType>::getPointeeType() const
Line
Count
Source
230
1.01M
CanQualType Accessor() const {                                           \
231
1.01M
return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor());      \
232
1.01M
}
Unexecuted instantiation: clang::CanProxyAdaptor<clang::ComplexType>::getElementType() const
clang::CanProxyAdaptor<clang::ReferenceType>::getPointeeType() const
Line
Count
Source
230
1.01k
CanQualType Accessor() const {                                           \
231
1.01k
return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor());      \
232
1.01k
}
clang::CanProxyAdaptor<clang::BlockPointerType>::getPointeeType() const
Line
Count
Source
230
24
CanQualType Accessor() const {                                           \
231
24
return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor());      \
232
24
}
clang::CanProxyAdaptor<clang::MemberPointerType>::getPointeeType() const
Line
Count
Source
230
1.11k
CanQualType Accessor() const {                                           \
231
1.11k
return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor());      \
232
1.11k
}
233
234
#define LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Type, Accessor)             \
235
12.0M
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyAdaptor<clang::FunctionNoProtoType>::getExtInfo() const
Line
Count
Source
235
27.9k
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyAdaptor<clang::FunctionProtoType>::getNumParams() const
Line
Count
Source
235
1.65k
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyAdaptor<clang::FunctionProtoType>::getExtParameterInfos() const
Line
Count
Source
235
749
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyAdaptor<clang::FunctionProtoType>::getExtInfo() const
Line
Count
Source
235
1.97M
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyAdaptor<clang::FunctionProtoType>::hasExtParameterInfos() const
Line
Count
Source
235
1.97M
Type Accessor() const { return this->getTypePtr()->Accessor(); }
Unexecuted instantiation: clang::CanProxyAdaptor<clang::FunctionProtoType>::isVariadic() const
Unexecuted instantiation: clang::CanProxyAdaptor<clang::FunctionProtoType>::getTypeQuals() const
Unexecuted instantiation: clang::CanProxyAdaptor<clang::FunctionType>::getExtInfo() const
clang::CanProxyBase<clang::Type>::getAsCXXRecordDecl() const
Line
Count
Source
235
292k
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyBase<clang::Type>::hasPointerRepresentation() const
Line
Count
Source
235
148
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyBase<clang::Type>::isVoidType() const
Line
Count
Source
235
699
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyBase<clang::Type>::isStructureOrClassType() const
Line
Count
Source
235
144
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyBase<clang::Type>::isDependentType() const
Line
Count
Source
235
165
Type Accessor() const { return this->getTypePtr()->Accessor(); }
Unexecuted instantiation: clang::CanProxyAdaptor<clang::RecordType>::getDecl() const
Unexecuted instantiation: clang::CanProxyAdaptor<clang::RecordType>::isBeingDefined() const
Unexecuted instantiation: clang::CanProxyAdaptor<clang::RecordType>::hasConstFields() const
clang::CanProxyBase<clang::Type>::isEnumeralType() const
Line
Count
Source
235
109
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyBase<clang::Type>::getTypeClass() const
Line
Count
Source
235
4.01M
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyBase<clang::Type>::isUnsignedIntegerType() const
Line
Count
Source
235
10
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyAdaptor<clang::MemberPointerType>::getClass() const
Line
Count
Source
235
1.55k
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyBase<clang::Type>::isArrayType() const
Line
Count
Source
235
1.88M
Type Accessor() const { return this->getTypePtr()->Accessor(); }
clang::CanProxyBase<clang::Type>::isIncompleteType() const
Line
Count
Source
235
1.88M
Type Accessor() const { return this->getTypePtr()->Accessor(); }
236
237
/// Base class of all canonical proxy types, which is responsible for
238
/// storing the underlying canonical type and providing basic conversions.
239
template<typename T>
240
class CanProxyBase {
241
protected:
242
  CanQual<T> Stored;
243
244
public:
245
  /// Retrieve the pointer to the underlying Type
246
18.9M
  const T *getTypePtr() const { return Stored.getTypePtr(); }
clang::CanProxyBase<clang::FunctionNoProtoType>::getTypePtr() const
Line
Count
Source
246
55.9k
  const T *getTypePtr() const { return Stored.getTypePtr(); }
clang::CanProxyBase<clang::FunctionProtoType>::getTypePtr() const
Line
Count
Source
246
9.75M
  const T *getTypePtr() const { return Stored.getTypePtr(); }
Unexecuted instantiation: clang::CanProxyBase<clang::FunctionType>::getTypePtr() const
clang::CanProxyBase<clang::PointerType>::getTypePtr() const
Line
Count
Source
246
1.01M
  const T *getTypePtr() const { return Stored.getTypePtr(); }
clang::CanProxyBase<clang::Type>::getTypePtr() const
Line
Count
Source
246
8.08M
  const T *getTypePtr() const { return Stored.getTypePtr(); }
Unexecuted instantiation: clang::CanProxyBase<clang::ComplexType>::getTypePtr() const
Unexecuted instantiation: clang::CanProxyBase<clang::RecordType>::getTypePtr() const
clang::CanProxyBase<clang::ReferenceType>::getTypePtr() const
Line
Count
Source
246
1.01k
  const T *getTypePtr() const { return Stored.getTypePtr(); }
clang::CanProxyBase<clang::BlockPointerType>::getTypePtr() const
Line
Count
Source
246
24
  const T *getTypePtr() const { return Stored.getTypePtr(); }
clang::CanProxyBase<clang::MemberPointerType>::getTypePtr() const
Line
Count
Source
246
2.66k
  const T *getTypePtr() const { return Stored.getTypePtr(); }
247
248
  /// Implicit conversion to the underlying pointer.
249
  ///
250
  /// Also provides the ability to use canonical type proxies in a Boolean
251
  // context,e.g.,
252
  /// @code
253
  ///   if (CanQual<PointerType> Ptr = T->getAs<PointerType>()) { ... }
254
  /// @endcode
255
2.07M
  operator const T*() const { return this->Stored.getTypePtrOrNull(); }
clang::CanProxyBase<clang::FunctionType>::operator clang::FunctionType const*() const
Line
Count
Source
255
39.0k
  operator const T*() const { return this->Stored.getTypePtrOrNull(); }
clang::CanProxyBase<clang::PointerType>::operator clang::PointerType const*() const
Line
Count
Source
255
206
  operator const T*() const { return this->Stored.getTypePtrOrNull(); }
clang::CanProxyBase<clang::ComplexType>::operator clang::ComplexType const*() const
Line
Count
Source
255
21
  operator const T*() const { return this->Stored.getTypePtrOrNull(); }
clang::CanProxyBase<clang::RecordType>::operator clang::RecordType const*() const
Line
Count
Source
255
2.03M
  operator const T*() const { return this->Stored.getTypePtrOrNull(); }
256
257
  /// Try to convert the given canonical type to a specific structural
258
  /// type.
259
2.08M
  template<typename U> CanProxy<U> getAs() const {
260
2.08M
    return this->Stored.template getAs<U>();
261
2.08M
  }
clang::CanProxy<clang::FunctionType> clang::CanProxyBase<clang::Type>::getAs<clang::FunctionType>() const
Line
Count
Source
259
39.0k
  template<typename U> CanProxy<U> getAs() const {
260
39.0k
    return this->Stored.template getAs<U>();
261
39.0k
  }
clang::CanProxy<clang::ComplexType> clang::CanProxyBase<clang::Type>::getAs<clang::ComplexType>() const
Line
Count
Source
259
21
  template<typename U> CanProxy<U> getAs() const {
260
21
    return this->Stored.template getAs<U>();
261
21
  }
clang::CanProxy<clang::RecordType> clang::CanProxyBase<clang::Type>::getAs<clang::RecordType>() const
Line
Count
Source
259
2.03M
  template<typename U> CanProxy<U> getAs() const {
260
2.03M
    return this->Stored.template getAs<U>();
261
2.03M
  }
clang::CanProxy<clang::FunctionProtoType> clang::CanProxyBase<clang::Type>::getAs<clang::FunctionProtoType>() const
Line
Count
Source
259
106
  template<typename U> CanProxy<U> getAs() const {
260
106
    return this->Stored.template getAs<U>();
261
106
  }
clang::CanProxy<clang::ReferenceType> clang::CanProxyBase<clang::Type>::getAs<clang::ReferenceType>() const
Line
Count
Source
259
6.78k
  template<typename U> CanProxy<U> getAs() const {
260
6.78k
    return this->Stored.template getAs<U>();
261
6.78k
  }
clang::CanProxy<clang::PointerType> clang::CanProxyBase<clang::Type>::getAs<clang::PointerType>() const
Line
Count
Source
259
11.1k
  template<typename U> CanProxy<U> getAs() const {
260
11.1k
    return this->Stored.template getAs<U>();
261
11.1k
  }
262
263
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Type::TypeClass, getTypeClass)
264
265
  // Type predicates
266
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjectType)
267
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIncompleteType)
268
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIncompleteOrObjectType)
269
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVariablyModifiedType)
270
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIntegerType)
271
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isEnumeralType)
272
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isBooleanType)
273
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isCharType)
274
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isWideCharType)
275
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIntegralType)
276
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIntegralOrEnumerationType)
277
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isRealFloatingType)
278
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isComplexType)
279
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isAnyComplexType)
280
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isFloatingType)
281
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isRealType)
282
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isArithmeticType)
283
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVoidType)
284
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isDerivedType)
285
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isScalarType)
286
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isAggregateType)
287
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isAnyPointerType)
288
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVoidPointerType)
289
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isFunctionPointerType)
290
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isMemberFunctionPointerType)
291
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isClassType)
292
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isStructureType)
293
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isInterfaceType)
294
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isStructureOrClassType)
295
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isUnionType)
296
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isComplexIntegerType)
297
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isNullPtrType)
298
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isDependentType)
299
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isOverloadableType)
300
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isArrayType)
301
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasPointerRepresentation)
302
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasObjCPointerRepresentation)
303
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasIntegerRepresentation)
304
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasSignedIntegerRepresentation)
305
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasUnsignedIntegerRepresentation)
306
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasFloatingRepresentation)
307
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isPromotableIntegerType)
308
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isSignedIntegerType)
309
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isUnsignedIntegerType)
310
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isSignedIntegerOrEnumerationType)
311
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isUnsignedIntegerOrEnumerationType)
312
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isConstantSizeType)
313
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isSpecifierType)
314
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(CXXRecordDecl*, getAsCXXRecordDecl)
315
316
  /// Retrieve the proxy-adaptor type.
317
  ///
318
  /// This arrow operator is used when CanProxyAdaptor has been specialized
319
  /// for the given type T. In that case, we reference members of the
320
  /// CanProxyAdaptor specialization. Otherwise, this operator will be hidden
321
  /// by the arrow operator in the primary CanProxyAdaptor template.
322
20.4M
  const CanProxyAdaptor<T> *operator->() const {
323
20.4M
    return static_cast<const CanProxyAdaptor<T> *>(this);
324
20.4M
  }
clang::CanProxyBase<clang::Type>::operator->() const
Line
Count
Source
322
10.1M
  const CanProxyAdaptor<T> *operator->() const {
323
10.1M
    return static_cast<const CanProxyAdaptor<T> *>(this);
324
10.1M
  }
clang::CanProxyBase<clang::FunctionNoProtoType>::operator->() const
Line
Count
Source
322
55.9k
  const CanProxyAdaptor<T> *operator->() const {
323
55.9k
    return static_cast<const CanProxyAdaptor<T> *>(this);
324
55.9k
  }
clang::CanProxyBase<clang::FunctionProtoType>::operator->() const
Line
Count
Source
322
9.24M
  const CanProxyAdaptor<T> *operator->() const {
323
9.24M
    return static_cast<const CanProxyAdaptor<T> *>(this);
324
9.24M
  }
clang::CanProxyBase<clang::PointerType>::operator->() const
Line
Count
Source
322
1.01M
  const CanProxyAdaptor<T> *operator->() const {
323
1.01M
    return static_cast<const CanProxyAdaptor<T> *>(this);
324
1.01M
  }
clang::CanProxyBase<clang::ReferenceType>::operator->() const
Line
Count
Source
322
1.01k
  const CanProxyAdaptor<T> *operator->() const {
323
1.01k
    return static_cast<const CanProxyAdaptor<T> *>(this);
324
1.01k
  }
clang::CanProxyBase<clang::BlockPointerType>::operator->() const
Line
Count
Source
322
24
  const CanProxyAdaptor<T> *operator->() const {
323
24
    return static_cast<const CanProxyAdaptor<T> *>(this);
324
24
  }
clang::CanProxyBase<clang::MemberPointerType>::operator->() const
Line
Count
Source
322
2.66k
  const CanProxyAdaptor<T> *operator->() const {
323
2.66k
    return static_cast<const CanProxyAdaptor<T> *>(this);
324
2.66k
  }
325
};
326
327
/// Replaceable canonical proxy adaptor class that provides the link
328
/// between a canonical type and the accessors of the type.
329
///
330
/// The CanProxyAdaptor is a replaceable class template that is instantiated
331
/// as part of each canonical proxy type. The primary template merely provides
332
/// redirection to the underlying type (T), e.g., @c PointerType. One can
333
/// provide specializations of this class template for each underlying type
334
/// that provide accessors returning canonical types (@c CanQualType) rather
335
/// than the more typical @c QualType, to propagate the notion of "canonical"
336
/// through the system.
337
template<typename T>
338
struct CanProxyAdaptor : CanProxyBase<T> {};
339
340
/// Canonical proxy type returned when retrieving the members of a
341
/// canonical type or as the result of the @c CanQual<T>::getAs member
342
/// function.
343
///
344
/// The CanProxy type mainly exists as a proxy through which operator-> will
345
/// look to either map down to a raw T* (e.g., PointerType*) or to a proxy
346
/// type that provides canonical-type access to the fields of the type.
347
template<typename T>
348
class CanProxy : public CanProxyAdaptor<T> {
349
public:
350
  /// Build a NULL proxy.
351
2.36M
  CanProxy() = default;
Unexecuted instantiation: clang::CanProxy<clang::FunctionType>::CanProxy()
Unexecuted instantiation: clang::CanProxy<clang::FunctionProtoType>::CanProxy()
Unexecuted instantiation: clang::CanProxy<clang::Type>::CanProxy()
clang::CanProxy<clang::FunctionNoProtoType>::CanProxy()
Line
Count
Source
351
450k
  CanProxy() = default;
clang::CanProxy<clang::ComplexType>::CanProxy()
Line
Count
Source
351
19
  CanProxy() = default;
clang::CanProxy<clang::RecordType>::CanProxy()
Line
Count
Source
351
1.89M
  CanProxy() = default;
clang::CanProxy<clang::ReferenceType>::CanProxy()
Line
Count
Source
351
7.39k
  CanProxy() = default;
clang::CanProxy<clang::PointerType>::CanProxy()
Line
Count
Source
351
5.71k
  CanProxy() = default;
Unexecuted instantiation: clang::CanProxy<clang::BlockPointerType>::CanProxy()
Unexecuted instantiation: clang::CanProxy<clang::MemberPointerType>::CanProxy()
352
353
  /// Build a proxy to the given canonical type.
354
23.6M
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
clang::CanProxy<clang::Type>::CanProxy(clang::CanQual<clang::Type>)
Line
Count
Source
354
10.6M
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
clang::CanProxy<clang::FunctionType>::CanProxy(clang::CanQual<clang::FunctionType>)
Line
Count
Source
354
39.0k
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
clang::CanProxy<clang::FunctionProtoType>::CanProxy(clang::CanQual<clang::FunctionProtoType>)
Line
Count
Source
354
11.7M
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
clang::CanProxy<clang::FunctionNoProtoType>::CanProxy(clang::CanQual<clang::FunctionNoProtoType>)
Line
Count
Source
354
75.1k
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
clang::CanProxy<clang::PointerType>::CanProxy(clang::CanQual<clang::PointerType>)
Line
Count
Source
354
1.01M
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
clang::CanProxy<clang::ComplexType>::CanProxy(clang::CanQual<clang::ComplexType>)
Line
Count
Source
354
2
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
clang::CanProxy<clang::RecordType>::CanProxy(clang::CanQual<clang::RecordType>)
Line
Count
Source
354
134k
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
clang::CanProxy<clang::ReferenceType>::CanProxy(clang::CanQual<clang::ReferenceType>)
Line
Count
Source
354
2.01k
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
clang::CanProxy<clang::BlockPointerType>::CanProxy(clang::CanQual<clang::BlockPointerType>)
Line
Count
Source
354
24
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
clang::CanProxy<clang::MemberPointerType>::CanProxy(clang::CanQual<clang::MemberPointerType>)
Line
Count
Source
354
1.55k
  CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
355
356
  /// Implicit conversion to the stored canonical type.
357
2.97M
  operator CanQual<T>() const { return this->Stored; }
clang::CanProxy<clang::FunctionProtoType>::operator clang::CanQual<clang::FunctionProtoType>() const
Line
Count
Source
357
1.96M
  operator CanQual<T>() const { return this->Stored; }
clang::CanProxy<clang::Type>::operator clang::CanQual<clang::Type>() const
Line
Count
Source
357
524k
  operator CanQual<T>() const { return this->Stored; }
clang::CanProxy<clang::FunctionNoProtoType>::operator clang::CanQual<clang::FunctionNoProtoType>() const
Line
Count
Source
357
470k
  operator CanQual<T>() const { return this->Stored; }
clang::CanProxy<clang::ReferenceType>::operator clang::CanQual<clang::ReferenceType>() const
Line
Count
Source
357
8.39k
  operator CanQual<T>() const { return this->Stored; }
clang::CanProxy<clang::PointerType>::operator clang::CanQual<clang::PointerType>() const
Line
Count
Source
357
5.89k
  operator CanQual<T>() const { return this->Stored; }
358
};
359
360
} // namespace clang
361
362
namespace llvm {
363
364
/// Implement simplify_type for CanQual<T>, so that we can dyn_cast from
365
/// CanQual<T> to a specific Type class. We're prefer isa/dyn_cast/cast/etc.
366
/// to return smart pointer (proxies?).
367
template<typename T>
368
struct simplify_type< ::clang::CanQual<T>> {
369
  using SimpleType = const T *;
370
371
832k
  static SimpleType getSimplifiedValue(::clang::CanQual<T> Val) {
372
832k
    return Val.getTypePtr();
373
832k
  }
374
};
375
376
// Teach SmallPtrSet that CanQual<T> is "basically a pointer".
377
template<typename T>
378
struct PointerLikeTypeTraits<clang::CanQual<T>> {
379
263k
  static void *getAsVoidPointer(clang::CanQual<T> P) {
380
263k
    return P.getAsOpaquePtr();
381
263k
  }
382
383
  static clang::CanQual<T> getFromVoidPointer(void *P) {
384
    return clang::CanQual<T>::getFromOpaquePtr(P);
385
  }
386
387
  // qualifier information is encoded in the low bits.
388
  enum { NumLowBitsAvailable = 0 };
389
};
390
391
} // namespace llvm
392
393
namespace clang {
394
395
//----------------------------------------------------------------------------//
396
// Canonical proxy adaptors for canonical type nodes.
397
//----------------------------------------------------------------------------//
398
399
/// Iterator adaptor that turns an iterator over canonical QualTypes
400
/// into an iterator over CanQualTypes.
401
template <typename InputIterator>
402
struct CanTypeIterator
403
    : llvm::iterator_adaptor_base<
404
          CanTypeIterator<InputIterator>, InputIterator,
405
          typename std::iterator_traits<InputIterator>::iterator_category,
406
          CanQualType,
407
          typename std::iterator_traits<InputIterator>::difference_type,
408
          CanProxy<Type>, CanQualType> {
409
  CanTypeIterator() = default;
410
  explicit CanTypeIterator(InputIterator Iter)
411
3.77M
      : CanTypeIterator::iterator_adaptor_base(std::move(Iter)) {}
412
413
2.40M
  CanQualType operator*() const { return CanQualType::CreateUnsafe(*this->I); }
414
  CanProxy<Type> operator->() const;
415
};
416
417
template<>
418
struct CanProxyAdaptor<ComplexType> : public CanProxyBase<ComplexType> {
419
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
420
};
421
422
template<>
423
struct CanProxyAdaptor<PointerType> : public CanProxyBase<PointerType> {
424
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
425
};
426
427
template<>
428
struct CanProxyAdaptor<BlockPointerType>
429
  : public CanProxyBase<BlockPointerType> {
430
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
431
};
432
433
template<>
434
struct CanProxyAdaptor<ReferenceType> : public CanProxyBase<ReferenceType> {
435
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
436
};
437
438
template<>
439
struct CanProxyAdaptor<LValueReferenceType>
440
  : public CanProxyBase<LValueReferenceType> {
441
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
442
};
443
444
template<>
445
struct CanProxyAdaptor<RValueReferenceType>
446
  : public CanProxyBase<RValueReferenceType> {
447
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
448
};
449
450
template<>
451
struct CanProxyAdaptor<MemberPointerType>
452
  : public CanProxyBase<MemberPointerType> {
453
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
454
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const Type *, getClass)
455
};
456
457
// CanProxyAdaptors for arrays are intentionally unimplemented because
458
// they are not safe.
459
template<> struct CanProxyAdaptor<ArrayType>;
460
template<> struct CanProxyAdaptor<ConstantArrayType>;
461
template<> struct CanProxyAdaptor<IncompleteArrayType>;
462
template<> struct CanProxyAdaptor<VariableArrayType>;
463
template<> struct CanProxyAdaptor<DependentSizedArrayType>;
464
465
template<>
466
struct CanProxyAdaptor<DependentSizedExtVectorType>
467
  : public CanProxyBase<DependentSizedExtVectorType> {
468
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
469
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const Expr *, getSizeExpr)
470
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceLocation, getAttributeLoc)
471
};
472
473
template<>
474
struct CanProxyAdaptor<VectorType> : public CanProxyBase<VectorType> {
475
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
476
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumElements)
477
};
478
479
template<>
480
struct CanProxyAdaptor<ExtVectorType> : public CanProxyBase<ExtVectorType> {
481
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
482
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumElements)
483
};
484
485
template<>
486
struct CanProxyAdaptor<FunctionType> : public CanProxyBase<FunctionType> {
487
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getReturnType)
488
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(FunctionType::ExtInfo, getExtInfo)
489
};
490
491
template<>
492
struct CanProxyAdaptor<FunctionNoProtoType>
493
  : public CanProxyBase<FunctionNoProtoType> {
494
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getReturnType)
495
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(FunctionType::ExtInfo, getExtInfo)
496
};
497
498
template<>
499
struct CanProxyAdaptor<FunctionProtoType>
500
  : public CanProxyBase<FunctionProtoType> {
501
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getReturnType)
502
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(FunctionType::ExtInfo, getExtInfo)
503
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumParams)
504
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasExtParameterInfos)
505
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(
506
            ArrayRef<FunctionProtoType::ExtParameterInfo>, getExtParameterInfos)
507
508
1.68k
  CanQualType getParamType(unsigned i) const {
509
1.68k
    return CanQualType::CreateUnsafe(this->getTypePtr()->getParamType(i));
510
1.68k
  }
511
512
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVariadic)
513
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getTypeQuals)
514
515
  using param_type_iterator =
516
      CanTypeIterator<FunctionProtoType::param_type_iterator>;
517
518
1.88M
  param_type_iterator param_type_begin() const {
519
1.88M
    return param_type_iterator(this->getTypePtr()->param_type_begin());
520
1.88M
  }
521
522
1.88M
  param_type_iterator param_type_end() const {
523
1.88M
    return param_type_iterator(this->getTypePtr()->param_type_end());
524
1.88M
  }
525
526
  // Note: canonical function types never have exception specifications
527
};
528
529
template<>
530
struct CanProxyAdaptor<TypeOfType> : public CanProxyBase<TypeOfType> {
531
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getUnderlyingType)
532
};
533
534
template<>
535
struct CanProxyAdaptor<DecltypeType> : public CanProxyBase<DecltypeType> {
536
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Expr *, getUnderlyingExpr)
537
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getUnderlyingType)
538
};
539
540
template <>
541
struct CanProxyAdaptor<UnaryTransformType>
542
    : public CanProxyBase<UnaryTransformType> {
543
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getBaseType)
544
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getUnderlyingType)
545
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(UnaryTransformType::UTTKind, getUTTKind)
546
};
547
548
template<>
549
struct CanProxyAdaptor<TagType> : public CanProxyBase<TagType> {
550
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(TagDecl *, getDecl)
551
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isBeingDefined)
552
};
553
554
template<>
555
struct CanProxyAdaptor<RecordType> : public CanProxyBase<RecordType> {
556
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(RecordDecl *, getDecl)
557
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isBeingDefined)
558
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasConstFields)
559
};
560
561
template<>
562
struct CanProxyAdaptor<EnumType> : public CanProxyBase<EnumType> {
563
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(EnumDecl *, getDecl)
564
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isBeingDefined)
565
};
566
567
template<>
568
struct CanProxyAdaptor<TemplateTypeParmType>
569
  : public CanProxyBase<TemplateTypeParmType> {
570
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getDepth)
571
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndex)
572
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isParameterPack)
573
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(TemplateTypeParmDecl *, getDecl)
574
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(IdentifierInfo *, getIdentifier)
575
};
576
577
template<>
578
struct CanProxyAdaptor<ObjCObjectType>
579
  : public CanProxyBase<ObjCObjectType> {
580
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getBaseType)
581
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const ObjCInterfaceDecl *,
582
                                      getInterface)
583
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCUnqualifiedId)
584
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCUnqualifiedClass)
585
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedId)
586
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedClass)
587
588
  using qual_iterator = ObjCObjectPointerType::qual_iterator;
589
590
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_begin)
591
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_end)
592
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, qual_empty)
593
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumProtocols)
594
};
595
596
template<>
597
struct CanProxyAdaptor<ObjCObjectPointerType>
598
  : public CanProxyBase<ObjCObjectPointerType> {
599
  LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
600
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const ObjCInterfaceType *,
601
                                      getInterfaceType)
602
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCIdType)
603
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCClassType)
604
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedIdType)
605
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedClassType)
606
607
  using qual_iterator = ObjCObjectPointerType::qual_iterator;
608
609
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_begin)
610
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_end)
611
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, qual_empty)
612
  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumProtocols)
613
};
614
615
//----------------------------------------------------------------------------//
616
// Method and function definitions
617
//----------------------------------------------------------------------------//
618
template<typename T>
619
35.6M
inline CanQual<T> CanQual<T>::getUnqualifiedType() const {
620
35.6M
  return CanQual<T>::CreateUnsafe(Stored.getLocalUnqualifiedType());
621
35.6M
}
622
623
template<typename T>
624
1.62k
inline CanQual<Type> CanQual<T>::getNonReferenceType() const {
625
1.62k
  if (CanQual<ReferenceType> RefType = getAs<ReferenceType>())
626
0
    return RefType->getPointeeType();
627
1.62k
  else
628
1.62k
    return *this;
629
1.62k
}
630
631
template<typename T>
632
577
CanQual<T> CanQual<T>::getFromOpaquePtr(void *Ptr) {
633
577
  CanQual<T> Result;
634
577
  Result.Stored = QualType::getFromOpaquePtr(Ptr);
635
577
  assert((!Result || Result.Stored.getAsOpaquePtr() == (void*)-1 ||
636
577
          Result.Stored.isCanonical()) && "Type is not canonical!");
637
577
  return Result;
638
577
}
639
640
template<typename T>
641
742M
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
742M
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
742M
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
742M
         "Dynamic type does not meet the static type's requires");
645
742M
  CanQual<T> Result;
646
742M
  Result.Stored = Other;
647
742M
  return Result;
648
742M
}
clang::CanQual<clang::Type>::CreateUnsafe(clang::QualType)
Line
Count
Source
641
738M
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
738M
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
738M
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
738M
         "Dynamic type does not meet the static type's requires");
645
738M
  CanQual<T> Result;
646
738M
  Result.Stored = Other;
647
738M
  return Result;
648
738M
}
clang::CanQual<clang::FunctionType>::CreateUnsafe(clang::QualType)
Line
Count
Source
641
39.0k
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
39.0k
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
39.0k
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
39.0k
         "Dynamic type does not meet the static type's requires");
645
39.0k
  CanQual<T> Result;
646
39.0k
  Result.Stored = Other;
647
39.0k
  return Result;
648
39.0k
}
clang::CanQual<clang::FunctionProtoType>::CreateUnsafe(clang::QualType)
Line
Count
Source
641
3.01M
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
3.01M
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
3.01M
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
3.01M
         "Dynamic type does not meet the static type's requires");
645
3.01M
  CanQual<T> Result;
646
3.01M
  Result.Stored = Other;
647
3.01M
  return Result;
648
3.01M
}
clang::CanQual<clang::FunctionNoProtoType>::CreateUnsafe(clang::QualType)
Line
Count
Source
641
27.9k
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
27.9k
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
27.9k
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
27.9k
         "Dynamic type does not meet the static type's requires");
645
27.9k
  CanQual<T> Result;
646
27.9k
  Result.Stored = Other;
647
27.9k
  return Result;
648
27.9k
}
clang::CanQual<clang::PointerType>::CreateUnsafe(clang::QualType)
Line
Count
Source
641
1.01M
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
1.01M
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
1.01M
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
1.01M
         "Dynamic type does not meet the static type's requires");
645
1.01M
  CanQual<T> Result;
646
1.01M
  Result.Stored = Other;
647
1.01M
  return Result;
648
1.01M
}
clang::CanQual<clang::ComplexType>::CreateUnsafe(clang::QualType)
Line
Count
Source
641
2
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
2
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
2
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
2
         "Dynamic type does not meet the static type's requires");
645
2
  CanQual<T> Result;
646
2
  Result.Stored = Other;
647
2
  return Result;
648
2
}
clang::CanQual<clang::RecordType>::CreateUnsafe(clang::QualType)
Line
Count
Source
641
134k
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
134k
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
134k
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
134k
         "Dynamic type does not meet the static type's requires");
645
134k
  CanQual<T> Result;
646
134k
  Result.Stored = Other;
647
134k
  return Result;
648
134k
}
clang::CanQual<clang::ReferenceType>::CreateUnsafe(clang::QualType)
Line
Count
Source
641
1.01k
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
1.01k
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
1.01k
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
1.01k
         "Dynamic type does not meet the static type's requires");
645
1.01k
  CanQual<T> Result;
646
1.01k
  Result.Stored = Other;
647
1.01k
  return Result;
648
1.01k
}
clang::CanQual<clang::BlockPointerType>::CreateUnsafe(clang::QualType)
Line
Count
Source
641
24
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
24
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
24
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
24
         "Dynamic type does not meet the static type's requires");
645
24
  CanQual<T> Result;
646
24
  Result.Stored = Other;
647
24
  return Result;
648
24
}
clang::CanQual<clang::MemberPointerType>::CreateUnsafe(clang::QualType)
Line
Count
Source
641
1.55k
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
642
1.55k
  assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
643
1.55k
  assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
644
1.55k
         "Dynamic type does not meet the static type's requires");
645
1.55k
  CanQual<T> Result;
646
1.55k
  Result.Stored = Other;
647
1.55k
  return Result;
648
1.55k
}
649
650
template<typename T>
651
template<typename U>
652
6.11M
CanProxy<U> CanQual<T>::getAs() const {
653
6.11M
  static_assert(!TypeIsArrayType<T>::value,
654
6.11M
                "ArrayType cannot be used with getAs!");
655
6.11M
656
6.11M
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
6.11M
659
6.11M
  if (isa<U>(Stored.getTypePtr()))
660
3.75M
    return CanQual<U>::CreateUnsafe(Stored);
661
2.36M
662
2.36M
  return CanProxy<U>();
663
2.36M
}
clang::CanProxy<clang::FunctionType> clang::CanQual<clang::Type>::getAs<clang::FunctionType>() const
Line
Count
Source
652
39.0k
CanProxy<U> CanQual<T>::getAs() const {
653
39.0k
  static_assert(!TypeIsArrayType<T>::value,
654
39.0k
                "ArrayType cannot be used with getAs!");
655
39.0k
656
39.0k
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
39.0k
659
39.0k
  if (isa<U>(Stored.getTypePtr()))
660
39.0k
    return CanQual<U>::CreateUnsafe(Stored);
661
0
662
0
  return CanProxy<U>();
663
0
}
clang::CanProxy<clang::FunctionProtoType> clang::CanQual<clang::Type>::getAs<clang::FunctionProtoType>() const
Line
Count
Source
652
2.02M
CanProxy<U> CanQual<T>::getAs() const {
653
2.02M
  static_assert(!TypeIsArrayType<T>::value,
654
2.02M
                "ArrayType cannot be used with getAs!");
655
2.02M
656
2.02M
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
2.02M
659
2.02M
  if (isa<U>(Stored.getTypePtr()))
660
2.02M
    return CanQual<U>::CreateUnsafe(Stored);
661
0
662
0
  return CanProxy<U>();
663
0
}
clang::CanProxy<clang::Type> clang::CanQual<clang::FunctionProtoType>::getAs<clang::Type>() const
Line
Count
Source
652
524k
CanProxy<U> CanQual<T>::getAs() const {
653
524k
  static_assert(!TypeIsArrayType<T>::value,
654
524k
                "ArrayType cannot be used with getAs!");
655
524k
656
524k
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
524k
659
524k
  if (isa<U>(Stored.getTypePtr()))
660
524k
    return CanQual<U>::CreateUnsafe(Stored);
661
0
662
0
  return CanProxy<U>();
663
0
}
clang::CanProxy<clang::FunctionNoProtoType> clang::CanQual<clang::Type>::getAs<clang::FunctionNoProtoType>() const
Line
Count
Source
652
470k
CanProxy<U> CanQual<T>::getAs() const {
653
470k
  static_assert(!TypeIsArrayType<T>::value,
654
470k
                "ArrayType cannot be used with getAs!");
655
470k
656
470k
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
470k
659
470k
  if (isa<U>(Stored.getTypePtr()))
660
19.2k
    return CanQual<U>::CreateUnsafe(Stored);
661
450k
662
450k
  return CanProxy<U>();
663
450k
}
clang::CanProxy<clang::ComplexType> clang::CanQual<clang::Type>::getAs<clang::ComplexType>() const
Line
Count
Source
652
21
CanProxy<U> CanQual<T>::getAs() const {
653
21
  static_assert(!TypeIsArrayType<T>::value,
654
21
                "ArrayType cannot be used with getAs!");
655
21
656
21
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
21
659
21
  if (isa<U>(Stored.getTypePtr()))
660
2
    return CanQual<U>::CreateUnsafe(Stored);
661
19
662
19
  return CanProxy<U>();
663
19
}
clang::CanProxy<clang::RecordType> clang::CanQual<clang::Type>::getAs<clang::RecordType>() const
Line
Count
Source
652
2.03M
CanProxy<U> CanQual<T>::getAs() const {
653
2.03M
  static_assert(!TypeIsArrayType<T>::value,
654
2.03M
                "ArrayType cannot be used with getAs!");
655
2.03M
656
2.03M
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
2.03M
659
2.03M
  if (isa<U>(Stored.getTypePtr()))
660
134k
    return CanQual<U>::CreateUnsafe(Stored);
661
1.89M
662
1.89M
  return CanProxy<U>();
663
1.89M
}
clang::CanProxy<clang::ReferenceType> clang::CanQual<clang::Type>::getAs<clang::ReferenceType>() const
Line
Count
Source
652
8.40k
CanProxy<U> CanQual<T>::getAs() const {
653
8.40k
  static_assert(!TypeIsArrayType<T>::value,
654
8.40k
                "ArrayType cannot be used with getAs!");
655
8.40k
656
8.40k
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
8.40k
659
8.40k
  if (isa<U>(Stored.getTypePtr()))
660
1.01k
    return CanQual<U>::CreateUnsafe(Stored);
661
7.39k
662
7.39k
  return CanProxy<U>();
663
7.39k
}
clang::CanProxy<clang::PointerType> clang::CanQual<clang::Type>::getAs<clang::PointerType>() const
Line
Count
Source
652
1.01M
CanProxy<U> CanQual<T>::getAs() const {
653
1.01M
  static_assert(!TypeIsArrayType<T>::value,
654
1.01M
                "ArrayType cannot be used with getAs!");
655
1.01M
656
1.01M
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
1.01M
659
1.01M
  if (isa<U>(Stored.getTypePtr()))
660
1.01M
    return CanQual<U>::CreateUnsafe(Stored);
661
5.71k
662
5.71k
  return CanProxy<U>();
663
5.71k
}
clang::CanProxy<clang::BlockPointerType> clang::CanQual<clang::Type>::getAs<clang::BlockPointerType>() const
Line
Count
Source
652
24
CanProxy<U> CanQual<T>::getAs() const {
653
24
  static_assert(!TypeIsArrayType<T>::value,
654
24
                "ArrayType cannot be used with getAs!");
655
24
656
24
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
24
659
24
  if (isa<U>(Stored.getTypePtr()))
660
24
    return CanQual<U>::CreateUnsafe(Stored);
661
0
662
0
  return CanProxy<U>();
663
0
}
clang::CanProxy<clang::MemberPointerType> clang::CanQual<clang::Type>::getAs<clang::MemberPointerType>() const
Line
Count
Source
652
1.55k
CanProxy<U> CanQual<T>::getAs() const {
653
1.55k
  static_assert(!TypeIsArrayType<T>::value,
654
1.55k
                "ArrayType cannot be used with getAs!");
655
1.55k
656
1.55k
  if (Stored.isNull())
657
0
    return CanProxy<U>();
658
1.55k
659
1.55k
  if (isa<U>(Stored.getTypePtr()))
660
1.55k
    return CanQual<U>::CreateUnsafe(Stored);
661
0
662
0
  return CanProxy<U>();
663
0
}
664
665
template<typename T>
666
template<typename U>
667
451k
CanProxy<U> CanQual<T>::castAs() const {
668
451k
  static_assert(!TypeIsArrayType<U>::value,
669
451k
                "ArrayType cannot be used with castAs!");
670
451k
671
451k
  assert(!Stored.isNull() && isa<U>(Stored.getTypePtr()));
672
451k
  return CanQual<U>::CreateUnsafe(Stored);
673
451k
}
clang::CanProxy<clang::FunctionProtoType> clang::CanQual<clang::Type>::castAs<clang::FunctionProtoType>() const
Line
Count
Source
667
450k
CanProxy<U> CanQual<T>::castAs() const {
668
450k
  static_assert(!TypeIsArrayType<U>::value,
669
450k
                "ArrayType cannot be used with castAs!");
670
450k
671
450k
  assert(!Stored.isNull() && isa<U>(Stored.getTypePtr()));
672
450k
  return CanQual<U>::CreateUnsafe(Stored);
673
450k
}
clang::CanProxy<clang::PointerType> clang::CanQual<clang::Type>::castAs<clang::PointerType>() const
Line
Count
Source
667
208
CanProxy<U> CanQual<T>::castAs() const {
668
208
  static_assert(!TypeIsArrayType<U>::value,
669
208
                "ArrayType cannot be used with castAs!");
670
208
671
208
  assert(!Stored.isNull() && isa<U>(Stored.getTypePtr()));
672
208
  return CanQual<U>::CreateUnsafe(Stored);
673
208
}
674
675
template<typename T>
676
19.4M
CanProxy<T> CanQual<T>::operator->() const {
677
19.4M
  return CanProxy<T>(*this);
678
19.4M
}
clang::CanQual<clang::Type>::operator->() const
Line
Count
Source
676
10.1M
CanProxy<T> CanQual<T>::operator->() const {
677
10.1M
  return CanProxy<T>(*this);
678
10.1M
}
clang::CanQual<clang::FunctionNoProtoType>::operator->() const
Line
Count
Source
676
55.9k
CanProxy<T> CanQual<T>::operator->() const {
677
55.9k
  return CanProxy<T>(*this);
678
55.9k
}
clang::CanQual<clang::FunctionProtoType>::operator->() const
Line
Count
Source
676
9.24M
CanProxy<T> CanQual<T>::operator->() const {
677
9.24M
  return CanProxy<T>(*this);
678
9.24M
}
clang::CanQual<clang::ReferenceType>::operator->() const
Line
Count
Source
676
1.00k
CanProxy<T> CanQual<T>::operator->() const {
677
1.00k
  return CanProxy<T>(*this);
678
1.00k
}
clang::CanQual<clang::PointerType>::operator->() const
Line
Count
Source
676
118
CanProxy<T> CanQual<T>::operator->() const {
677
118
  return CanProxy<T>(*this);
678
118
}
679
680
template <typename InputIterator>
681
CanProxy<Type> CanTypeIterator<InputIterator>::operator->() const {
682
  return CanProxy<Type>(*this);
683
}
684
685
} // namespace clang
686
687
#endif // LLVM_CLANG_AST_CANONICALTYPE_H