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
35class ASTContext;
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
53 : public Decl,
54 private llvm::TrailingObjects<FriendDecl, TemplateParameterList *> {
55 virtual void anchor();
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
91 EllipsisLoc(EllipsisLoc), UnsupportedFriend(false),
92 NumTPLists(FriendTypeTPLists.size()) {
93 for (unsigned i = 0; i < NumTPLists; ++i)
94 getTrailingObjects<TemplateParameterList *>()[i] = FriendTypeTPLists[i];
95 }
96
97 FriendDecl(EmptyShell Empty, unsigned NumFriendTypeTPLists)
99 NumTPLists(NumFriendTypeTPLists) {}
100
101 FriendDecl *getNextFriend() {
103 return cast_or_null(NextFriend.get(nullptr));
104 return getNextFriendSlowCase();
105 }
106
107 FriendDecl *getNextFriendSlowCase();
108
109public:
114
120 unsigned FriendTypeNumTPLists);
121
122
123
124
125
128 }
129
131 return NumTPLists;
132 }
133
135 assert(N < NumTPLists);
136 return getTrailingObjects<TemplateParameterList *>()[N];
137 }
138
139
140
143 }
144
145
147 return FriendLoc;
148 }
149
150
152
153
158 : getTrailingObjects<TemplateParameterList *>()[0]
159 ->getTemplateLoc();
161 : TInfo->getTypeLoc().getEndLoc();
163 }
164
167
169 if (const auto *FD = dyn_cast(ND))
170 return FD->getSourceRange();
171 if (const auto *FTD = dyn_cast(ND))
172 return FTD->getSourceRange();
173 if (const auto *CTD = dyn_cast(ND))
174 return CTD->getSourceRange();
175 if (const auto *DD = dyn_cast(ND)) {
176 if (DD->getOuterLocStart() != DD->getInnerLocStart())
177 return DD->getSourceRange();
178 }
180 }
181
183 }
184
185
187 return UnsupportedFriend;
188 }
190 UnsupportedFriend = Unsupported;
191 }
192
194
195
198};
199
200
203
205
207
208public:
210
216
218
220 assert(Ptr && "attempt to increment past end of friend list");
221 Ptr = Ptr->getNextFriend();
222 return *this;
223 }
224
227 ++*this;
228 return tmp;
229 }
230
232 return Ptr == Other.Ptr;
233 }
234
236 return Ptr != Other.Ptr;
237 }
238
240 assert(N >= 0 && "cannot rewind a CXXRecordDecl::friend_iterator");
241 while (N--)
242 ++*this;
243 return *this;
244 }
245
248 tmp += N;
249 return tmp;
250 }
251};
252
255}
256
259}
260
263}
264
266 assert(!FD->NextFriend && "friend already has next friend?");
267 FD->NextFriend = data().FirstFriend;
268 data().FirstFriend = FD;
269}
270
271}
272
273#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 ...
An iterator over the friend declarations of a class.
std::forward_iterator_tag iterator_category
friend_iterator operator+(difference_type N) const
friend_iterator()=default
bool operator!=(const friend_iterator &Other) const
friend_iterator operator++(int)
bool operator==(const friend_iterator &Other) const
friend_iterator & operator+=(difference_type N)
reference operator*() const
friend_iterator & operator++()
Represents a C++ struct/union/class.
friend_range friends() const
friend_iterator friend_begin() const
llvm::iterator_range< friend_iterator > friend_range
void pushFriendDecl(FriendDecl *FD)
friend_iterator friend_end() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
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,...
bool isUnsupportedFriend() const
Determines if this friend kind is unsupported.
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
static bool classofKind(Kind K)
static FriendDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned FriendTypeNumTPLists)
static bool classof(const Decl *D)
unsigned getFriendTypeNumTemplateParameterLists() const
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
void setUnsupportedFriend(bool Unsupported)
SourceRange getSourceRange() const override LLVM_READONLY
Retrieves the source range for the friend declaration.
SourceLocation getEllipsisLoc() const
Retrieves the location of the '...', if present.
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
bool isPackExpansion() const
This represents a decl that may have a name.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
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',...
@ 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.