clang: include/clang/Sema/Designator.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_CLANG_SEMA_DESIGNATOR_H
15#define LLVM_CLANG_SEMA_DESIGNATOR_H
16
18#include "llvm/ADT/SmallVector.h"
19
21
22class Expr;
23class IdentifierInfo;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
39
40 struct FieldDesignatorInfo {
41
43
44
46
47
49
52 : FieldName(FieldName), DotLoc(DotLoc), FieldLoc(FieldLoc) {}
53 };
54
55
56 struct ArrayDesignatorInfo {
58
59
61
62
64
66 : Index(Index), LBracketLoc(LBracketLoc) {}
67 };
68
69
70 struct ArrayRangeDesignatorInfo {
73
74
76
77
79
80
82
85 : Start(Start), End(End), LBracketLoc(LBracketLoc),
86 EllipsisLoc(EllipsisLoc) {}
87 };
88
89
90 enum DesignatorKind {
91 FieldDesignator,
92 ArrayDesignator,
93 ArrayRangeDesignator
94 };
95
96 DesignatorKind Kind;
97
98 union {
102 };
103
104 Designator(DesignatorKind Kind) : Kind(Kind) {}
105
106public:
110
111
112
113
114
119 new (&D.FieldInfo) FieldDesignatorInfo(FieldName, DotLoc, FieldLoc);
120 return D;
121 }
122
126 }
127
131 }
132
136 }
137
138
139
140
141
145 new (&D.ArrayInfo) ArrayDesignatorInfo(Index, LBracketLoc);
146 return D;
147 }
148
152 }
153
156 "Invalid accessor");
159 }
160
163 "Invalid accessor");
166 }
167
168
169
170
171
176 new (&D.ArrayRangeInfo)
177 ArrayRangeDesignatorInfo(Start, End, LBracketLoc, EllipsisLoc);
178 return D;
179 }
180
184 }
185
189 }
190
194 }
195
198 "Invalid accessor");
200 ArrayInfo.RBracketLoc = RBracketLoc;
201 else
203 }
204};
205
206
207
209
211
212public:
213
215
216 bool empty() const { return Designators.empty(); }
217
220 assert(Idx < Designators.size());
221 return Designators[Idx];
222 }
223};
224
225}
226
227#endif
Defines the clang::SourceLocation class and associated facilities.
Designation - Represent a full designation, which is a sequence of designators.
const Designator & getDesignator(unsigned Idx) const
unsigned getNumDesignators() const
void AddDesignator(Designator D)
AddDesignator - Add a designator to the end of this list.
Designator - A designator in a C99 designated initializer.
SourceLocation getFieldLoc() const
SourceLocation getDotLoc() const
Expr * getArrayRangeStart() const
bool isArrayDesignator() const
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
SourceLocation getLBracketLoc() const
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
void setRBracketLoc(SourceLocation RBracketLoc) const
bool isArrayRangeDesignator() const
bool isFieldDesignator() const
SourceLocation getRBracketLoc() const
ArrayRangeDesignatorInfo ArrayRangeInfo
SourceLocation getEllipsisLoc() const
ArrayDesignatorInfo ArrayInfo
Expr * getArrayRangeEnd() const
const IdentifierInfo * getFieldDecl() const
FieldDesignatorInfo FieldInfo
Expr * getArrayIndex() const
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
This represents one expression.
One of these records is kept for each identifier that is lexed.
Encodes a location in the source.
The JSON file list parser is used to communicate input to InstallAPI.