clang: include/clang/Sema/DelayedDiagnostic.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H
22#define LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H
23
33#include "llvm/ADT/ArrayRef.h"
34#include "llvm/ADT/SmallVector.h"
35#include "llvm/ADT/StringRef.h"
36#include "llvm/Support/Casting.h"
37#include
38#include
39#include
40
42
43class ObjCInterfaceDecl;
44class ObjCPropertyDecl;
45
46namespace sema {
47
48
49
51public:
52
53
55
56
57
59
64 Target(FoundDecl.getDecl()), NamingClass(NamingClass),
65 BaseObjectType(BaseObjectType), Diag(0, Allocator) {}
66
70 : Access(Access), IsMember(false), Target(BaseClass),
71 NamingClass(DerivedClass), Diag(0, Allocator) {}
72
74
76
78
79
82
83
85 assert(!IsMember); return cast(Target);
86 }
88
89
90
92
93
94
95
96
97
98
100 assert(isQuiet() && "partial diagnostic already defined");
101 Diag = PDiag;
102 }
104 assert(isQuiet() && "partial diagnostic already defined");
105 assert(DiagID && "creating null diagnostic");
106 Diag.Reset(DiagID);
107 return Diag;
108 }
110 return Diag;
111 }
112
113private:
115 unsigned Access : 2;
116 LLVM_PREFERRED_TYPE(bool)
117 unsigned IsMember : 1;
122};
123
124
125
127public:
129
132
134
136
143 StringRef Msg,
144 bool ObjCPropertyAccess);
145
153 return DD;
154 }
155
157 unsigned diagnostic,
159 unsigned argument) {
163 DD.Loc = loc;
167 return DD;
168 }
169
171 assert(Kind == Access && "Not an access diagnostic.");
173 }
175 assert(Kind == Access && "Not an access diagnostic.");
177 }
178
180 assert(Kind == Availability && "Not an availability diagnostic.");
182 }
183
186 }
187
189 assert(Kind == Availability && "Not an availability diagnostic.");
191 }
192
194 assert(Kind == Availability && "Not an availability diagnostic.");
197 }
198
200 assert(Kind == Availability && "Not an availability diagnostic.");
202 }
203
204
205
206
207
209 assert(Kind == ForbiddenType && "not a forbidden-type diagnostic");
211 }
212
214 assert(Kind == ForbiddenType && "not a forbidden-type diagnostic");
216 }
217
219 assert(Kind == ForbiddenType && "not a forbidden-type diagnostic");
221 }
222
225 }
226
229 }
230
233 }
234
235private:
236 struct AD {
241 const char *Message;
242 size_t MessageLen;
244 size_t NumSelectorLocs;
246 bool ObjCPropertyAccess;
247 };
248
249 struct FTD {
251 unsigned Argument;
252 void *OperandType;
253 };
254
255 union {
258
259
261 };
262};
263
264
268
269public:
271
274
277 Other.Diagnostics.clear();
278 }
279
282 Diagnostics = std::move(Other.Diagnostics);
283 Other.Diagnostics.clear();
284 return *this;
285 }
286
289 i = Diagnostics.begin(), e = Diagnostics.end(); i != e; ++i)
290 i->Destroy();
291 }
292
294
295
297 return (Diagnostics.empty() && ( || Parent->empty()));
298 }
299
300
302 Diagnostics.push_back(diag);
303 }
304
305
307 if (pool.Diagnostics.empty()) return;
308
309 if (Diagnostics.empty()) {
310 Diagnostics = std::move(pool.Diagnostics);
311 } else {
313 }
314 pool.Diagnostics.clear();
315 }
316
318
321 bool pool_empty() const { return Diagnostics.empty(); }
322};
323
324}
325
326
329 CurPool->add(diag);
330}
331
332}
333
334#endif
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::Target Target
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
C Language Family Type Representation.
Represents a C++ struct/union/class.
A POD class for pairing a NamedDecl* with an access specifier.
An allocator for DiagnosticStorage objects, which uses a small cache to objects, used to reduce mallo...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
This represents a decl that may have a name.
Represents an ObjC class declaration.
Represents one property declaration in an Objective-C interface.
unsigned getDiagID() const
void Reset(unsigned DiagID=0)
Clear out this partial diagnostic, giving it a new diagnostic ID and removing all of its arguments,...
A (possibly-)qualified type.
static QualType getFromOpaquePtr(const void *Ptr)
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
Encodes a location in the source.
A declaration being accessed, together with information about how it was accessed.
PartialDiagnostic & setDiag(unsigned DiagID)
void setDiag(const PartialDiagnostic &PDiag)
Sets a diagnostic to be performed.
CXXRecordDecl * getNamingClass() const
BaseNonce
A hierarchy (base-to-derived or derived-to-base) conversion.
AccessedEntity(PartialDiagnostic::DiagStorageAllocator &Allocator, MemberNonce _, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, QualType BaseObjectType)
CXXRecordDecl * getBaseClass() const
const PartialDiagnostic & getDiag() const
CXXRecordDecl * getDerivedClass() const
NamedDecl * getTargetDecl() const
AccessedEntity(PartialDiagnostic::DiagStorageAllocator &Allocator, BaseNonce _, CXXRecordDecl *BaseClass, CXXRecordDecl *DerivedClass, AccessSpecifier Access)
QualType getBaseObjectType() const
Retrieves the base object type, important when accessing an instance member.
bool isMemberAccess() const
AccessSpecifier getAccess() const
MemberNonce
A member declaration found through lookup.
A collection of diagnostics which were delayed.
const DelayedDiagnosticPool * getParent() const
DelayedDiagnosticPool(DelayedDiagnosticPool &&Other)
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
DelayedDiagnosticPool(const DelayedDiagnosticPool &)=delete
void add(const DelayedDiagnostic &diag)
Add a diagnostic to this pool.
DelayedDiagnosticPool & operator=(DelayedDiagnosticPool &&Other)
bool empty() const
Does this pool, or any of its ancestors, contain any diagnostics?
pool_iterator pool_end() const
SmallVectorImpl< DelayedDiagnostic >::const_iterator pool_iterator
pool_iterator pool_begin() const
DelayedDiagnosticPool(const DelayedDiagnosticPool *parent)
DelayedDiagnosticPool & operator=(const DelayedDiagnosticPool &)=delete
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
bool getObjCPropertyAccess() const
static DelayedDiagnostic makeAvailability(AvailabilityResult AR, ArrayRef< SourceLocation > Locs, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess)
QualType getForbiddenTypeOperand() const
const ObjCInterfaceDecl * getUnknownObjCClass() const
AccessedEntity & getAccessData()
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
const NamedDecl * getAvailabilityOffendingDecl() const
static DelayedDiagnostic makeAccess(SourceLocation Loc, const AccessedEntity &Entity)
unsigned getForbiddenTypeDiagnostic() const
The diagnostic ID to emit.
struct AD AvailabilityData
char AccessData[sizeof(AccessedEntity)]
Access control.
const ObjCPropertyDecl * getObjCProperty() const
StringRef getAvailabilityMessage() const
struct FTD ForbiddenTypeData
ArrayRef< SourceLocation > getAvailabilitySelectorLocs() const
AvailabilityResult getAvailabilityResult() const
const NamedDecl * getAvailabilityReferringDecl() const
unsigned getForbiddenTypeArgument() const
const AccessedEntity & getAccessData() const
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The JSON file list parser is used to communicate input to InstallAPI.
AvailabilityResult
Captures the result of checking the availability of a declaration.
@ Other
Other implicit parameter.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...