clang: include/clang/AST/DeclFriend.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_CLANG_AST_DECLFRIEND_H
15#define LLVM_CLANG_AST_DECLFRIEND_H
16
25#include "llvm/ADT/ArrayRef.h"
26#include "llvm/ADT/PointerUnion.h"
27#include "llvm/Support/Casting.h"
28#include "llvm/Support/Compiler.h"
29#include "llvm/Support/TrailingObjects.h"
30#include
31#include
32
34
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52class FriendDecl final
53 : public Decl,
54 private llvm::TrailingObjects<FriendDecl, TemplateParameterList *> {
55 LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
56
57public:
58 using FriendUnion = llvm::PointerUnion<NamedDecl *, TypeSourceInfo *>;
59
60private:
63
64
66
67
69
70
72
73
75
76
77
78
79 LLVM_PREFERRED_TYPE(bool)
80 unsigned UnsupportedFriend : 1;
81
82
83
84
85 unsigned NumTPLists : 31;
86
90 : Decl(Decl::Friend, DC, L), Friend(Friend), FriendLoc(FriendL),
91 EllipsisLoc(EllipsisLoc), UnsupportedFriend(false),
92 NumTPLists(FriendTypeTPLists.size()) {
93 llvm::copy(FriendTypeTPLists, getTrailingObjects());
94 }
95
96 FriendDecl(EmptyShell Empty, unsigned NumFriendTypeTPLists)
98 NumTPLists(NumFriendTypeTPLists) {}
99
100 FriendDecl *getNextFriend() {
102 return cast_or_null(NextFriend.get(nullptr));
103 return getNextFriendSlowCase();
104 }
105
106 FriendDecl *getNextFriendSlowCase();
107
108public:
113
114 static FriendDecl *
119 unsigned FriendTypeNumTPLists);
120
121
122
123
124
128
130 return NumTPLists;
131 }
132
134 return getTrailingObjects(NumTPLists)[N];
135 }
136
137
138
140 return Friend.dyn_cast<NamedDecl *>();
141 }
142
143
145 return FriendLoc;
146 }
147
148
150
151
156 : getTrailingObjects()[0]->getTemplateLoc();
158 : TInfo->getTypeLoc().getEndLoc();
160 }
161
164
166 if (const auto *FD = dyn_cast(ND))
167 return FD->getSourceRange();
168 if (const auto *FTD = dyn_cast(ND))
169 return FTD->getSourceRange();
170 if (const auto *CTD = dyn_cast(ND))
171 return CTD->getSourceRange();
172 if (const auto *DD = dyn_cast(ND)) {
173 if (DD->getOuterLocStart() != DD->getInnerLocStart())
174 return DD->getSourceRange();
175 }
177 }
178
180 }
181
182
184 return UnsupportedFriend;
185 }
187 UnsupportedFriend = Unsupported;
188 }
189
191
192
195};
196
197
200
202
204
205public:
207
213
215
217 assert(Ptr && "attempt to increment past end of friend list");
218 Ptr = Ptr->getNextFriend();
219 return *this;
220 }
221
223 friend_iterator tmp = *this;
224 ++*this;
225 return tmp;
226 }
227
229 return Ptr == Other.Ptr;
230 }
231
233 return Ptr != Other.Ptr;
234 }
235
237 assert(N >= 0 && "cannot rewind a CXXRecordDecl::friend_iterator");
238 while (N--)
239 ++*this;
240 return *this;
241 }
242
244 friend_iterator tmp = *this;
245 tmp += N;
246 return tmp;
247 }
248};
249
253
257
261
263 assert(!FD->NextFriend && "friend already has next friend?");
264 FD->NextFriend = data().FirstFriend;
265 data().FirstFriend = FD;
266}
267
268}
269
270#endif
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Defines the clang::TypeLoc interface and its subclasses.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
An iterator over the friend declarations of a class.
Definition DeclFriend.h:198
FriendDecl * pointer
Definition DeclFriend.h:210
std::forward_iterator_tag iterator_category
Definition DeclFriend.h:212
FriendDecl * value_type
Definition DeclFriend.h:208
friend_iterator operator+(difference_type N) const
Definition DeclFriend.h:243
friend_iterator()=default
friend class CXXRecordDecl
Definition DeclFriend.h:199
bool operator!=(const friend_iterator &Other) const
Definition DeclFriend.h:232
friend_iterator operator++(int)
Definition DeclFriend.h:222
bool operator==(const friend_iterator &Other) const
Definition DeclFriend.h:228
int difference_type
Definition DeclFriend.h:211
FriendDecl * reference
Definition DeclFriend.h:209
friend_iterator & operator+=(difference_type N)
Definition DeclFriend.h:236
reference operator*() const
Definition DeclFriend.h:214
friend_iterator & operator++()
Definition DeclFriend.h:216
friend_range friends() const
Definition DeclFriend.h:258
friend_iterator friend_begin() const
Definition DeclFriend.h:250
llvm::iterator_range< friend_iterator > friend_range
void pushFriendDecl(FriendDecl *FD)
Definition DeclFriend.h:262
friend_iterator friend_end() const
Definition DeclFriend.h:254
Decl - This represents one declaration (or definition), e.g.
Kind
Lists the kind of concrete classes of Decl.
SourceLocation getLocation() const
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition DeclFriend.h:54
bool isUnsupportedFriend() const
Determines if this friend kind is unsupported.
Definition DeclFriend.h:183
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
Definition DeclFriend.h:58
static bool classofKind(Kind K)
Definition DeclFriend.h:194
static FriendDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned FriendTypeNumTPLists)
static bool classof(const Decl *D)
Definition DeclFriend.h:193
friend TrailingObjects
Definition DeclFriend.h:112
unsigned getFriendTypeNumTemplateParameterLists() const
Definition DeclFriend.h:129
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
Definition DeclFriend.h:144
void setUnsupportedFriend(bool Unsupported)
Definition DeclFriend.h:186
SourceRange getSourceRange() const override LLVM_READONLY
Retrieves the source range for the friend declaration.
Definition DeclFriend.h:152
friend class ASTDeclReader
Definition DeclFriend.h:109
friend class ASTNodeImporter
Definition DeclFriend.h:111
friend class CXXRecordDecl
Definition DeclFriend.h:61
SourceLocation getEllipsisLoc() const
Retrieves the location of the '...', if present.
Definition DeclFriend.h:149
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
Definition DeclFriend.h:133
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Definition DeclFriend.h:139
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition DeclFriend.h:125
friend class ASTDeclWriter
Definition DeclFriend.h:110
bool isPackExpansion() const
Definition DeclFriend.h:190
This represents a decl that may have a name.
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stores a list of template parameters for a TemplateDecl and its derived classes.
A container of type source information.
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
LazyOffsetPtr< Decl, GlobalDeclID, &ExternalASTSource::GetExternalDecl > LazyDeclPtr
A lazy pointer to a declaration.
@ Other
Other implicit parameter.
bool isOffset() const
Whether this pointer is currently stored as an offset.
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer points to.