22 #ifndef LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H 23 #define LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H 34 #include "llvm/ADT/ArrayRef.h" 35 #include "llvm/ADT/SmallVector.h" 36 #include "llvm/ADT/StringRef.h" 37 #include "llvm/Support/Casting.h" 44 class ObjCInterfaceDecl;
45 class ObjCPropertyDecl;
67 Target(FoundDecl.getDecl()), NamingClass(NamingClass),
68 BaseObjectType(BaseObjectType), Diag(0, Allocator) {
76 : Access(Access), IsMember(
false), Target(BaseClass),
77 NamingClass(DerivedClass), Diag(0, Allocator) {}
91 assert(!IsMember);
return cast<CXXRecordDecl>(Target);
106 assert(
isQuiet() &&
"partial diagnostic already defined");
110 assert(
isQuiet() &&
"partial diagnostic already defined");
111 assert(DiagID &&
"creating null diagnostic");
121 unsigned IsMember : 1;
132 enum DDKind :
unsigned char { Availability, Access, ForbiddenType };
148 bool ObjCPropertyAccess);
165 DD.
Kind = ForbiddenType;
175 assert(Kind == Access &&
"Not an access diagnostic.");
179 assert(Kind == Access &&
"Not an access diagnostic.");
184 assert(Kind == Availability &&
"Not an availability diagnostic.");
185 return AvailabilityData.ReferringDecl;
189 return AvailabilityData.OffendingDecl;
193 assert(Kind == Availability &&
"Not an availability diagnostic.");
194 return StringRef(AvailabilityData.Message, AvailabilityData.MessageLen);
198 assert(Kind == Availability &&
"Not an availability diagnostic.");
199 return llvm::makeArrayRef(AvailabilityData.SelectorLocs,
200 AvailabilityData.NumSelectorLocs);
204 assert(Kind == Availability &&
"Not an availability diagnostic.");
205 return AvailabilityData.AR;
213 assert(Kind == ForbiddenType &&
"not a forbidden-type diagnostic");
214 return ForbiddenTypeData.Diagnostic;
218 assert(Kind == ForbiddenType &&
"not a forbidden-type diagnostic");
219 return ForbiddenTypeData.Argument;
223 assert(Kind == ForbiddenType &&
"not a forbidden-type diagnostic");
228 return AvailabilityData.UnknownObjCClass;
232 return AvailabilityData.ObjCProperty;
236 return AvailabilityData.ObjCPropertyAccess;
248 size_t NumSelectorLocs;
250 bool ObjCPropertyAccess;
260 struct AD AvailabilityData;
261 struct FTD ForbiddenTypeData;
280 : Parent(Other.Parent), Diagnostics(
std::move(Other.Diagnostics)) {
281 Other.Diagnostics.clear();
285 Parent = Other.Parent;
286 Diagnostics = std::move(Other.Diagnostics);
287 Other.Diagnostics.clear();
293 i = Diagnostics.begin(), e = Diagnostics.end(); i != e; ++i)
301 return (Diagnostics.empty() && (!Parent || Parent->
empty()));
306 Diagnostics.push_back(diag);
311 if (pool.Diagnostics.empty())
return;
313 if (Diagnostics.empty()) {
314 Diagnostics = std::move(pool.Diagnostics);
318 pool.Diagnostics.clear();
332 assert(shouldDelayDiagnostics() &&
"trying to delay without pool");
338 #endif // LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H DelayedDiagnosticPool(const DelayedDiagnosticPool *parent)
DelayedDiagnosticPool(DelayedDiagnosticPool &&Other)
A (possibly-)qualified type.
NamedDecl * getTargetDecl() const
C Language Family Type Representation.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
unsigned getDiagID() const
pool_iterator pool_begin() const
const ObjCPropertyDecl * getObjCProperty() const
const NamedDecl * getAvailabilityReferringDecl() const
const AccessedEntity & getAccessData() const
AccessedEntity & getAccessData()
void add(const DelayedDiagnostic &diag)
Add a diagnostic to this pool.
void Reset(unsigned DiagID=0)
Clear out this partial diagnostic, giving it a new diagnostic ID and removing all of its arguments...
CXXRecordDecl * getBaseClass() const
const NamedDecl * getAvailabilityOffendingDecl() const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
CXXRecordDecl * getNamingClass() const
CXXRecordDecl * getDerivedClass() const
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
void * getAsOpaquePtr() const
Represents an ObjC class declaration.
bool getObjCPropertyAccess() const
AvailabilityResult
Captures the result of checking the availability of a declaration.
const ObjCInterfaceDecl * getUnknownObjCClass() const
A declaration being accessed, together with information about how it was accessed.
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
An allocator for Storage objects, which uses a small cache to objects, used to reduce malloc()/free()...
ArrayRef< SourceLocation > getAvailabilitySelectorLocs() const
AccessedEntity(PartialDiagnostic::StorageAllocator &Allocator, BaseNonce _, CXXRecordDecl *BaseClass, CXXRecordDecl *DerivedClass, AccessSpecifier Access)
unsigned getForbiddenTypeDiagnostic() const
The diagnostic ID to emit.
Encodes a location in the source.
unsigned getForbiddenTypeArgument() const
MemberNonce
A member declaration found through lookup.
AccessSpecifier getAccess() const
PartialDiagnostic & setDiag(unsigned DiagID)
bool empty() const
Does this pool, or any of its ancestors, contain any diagnostics?
pool_iterator pool_end() const
AvailabilityResult getAvailabilityResult() const
Represents one property declaration in an Objective-C interface.
DelayedDiagnosticPool & operator=(DelayedDiagnosticPool &&Other)
bool isMemberAccess() const
static QualType getFromOpaquePtr(const void *Ptr)
BaseNonce
A hierarchy (base-to-derived or derived-to-base) conversion.
Defines various enumerations that describe declaration and type specifiers.
A POD class for pairing a NamedDecl* with an access specifier.
Dataflow Directional Tag Classes.
QualType getForbiddenTypeOperand() const
SmallVectorImpl< DelayedDiagnostic >::const_iterator pool_iterator
void setDiag(const PartialDiagnostic &PDiag)
Sets a diagnostic to be performed.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
struct FTD ForbiddenTypeData
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
const DelayedDiagnosticPool * getParent() const
AccessedEntity(PartialDiagnostic::StorageAllocator &Allocator, MemberNonce _, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, QualType BaseObjectType)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Defines the clang::SourceLocation class and associated facilities.
Represents a C++ struct/union/class.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
A collection of diagnostics which were delayed.
QualType getBaseObjectType() const
Retrieves the base object type, important when accessing an instance member.
This represents a decl that may have a name.
const PartialDiagnostic & getDiag() const
StringRef getAvailabilityMessage() const
static DelayedDiagnostic makeAccess(SourceLocation Loc, const AccessedEntity &Entity)