21 #ifndef LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H 22 #define LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H 33 #include "llvm/ADT/ArrayRef.h" 34 #include "llvm/ADT/SmallVector.h" 35 #include "llvm/ADT/StringRef.h" 36 #include "llvm/Support/Casting.h" 43 class ObjCInterfaceDecl;
44 class ObjCPropertyDecl;
66 Target(FoundDecl.getDecl()), NamingClass(NamingClass),
67 BaseObjectType(BaseObjectType), Diag(0, Allocator) {
75 : Access(Access), IsMember(
false), Target(BaseClass),
76 NamingClass(DerivedClass), Diag(0, Allocator) {}
90 assert(!IsMember);
return cast<CXXRecordDecl>(Target);
105 assert(
isQuiet() &&
"partial diagnostic already defined");
109 assert(
isQuiet() &&
"partial diagnostic already defined");
110 assert(DiagID &&
"creating null diagnostic");
120 unsigned IsMember : 1;
131 enum DDKind :
unsigned char { Availability, Access, ForbiddenType };
147 bool ObjCPropertyAccess);
164 DD.
Kind = ForbiddenType;
174 assert(Kind == Access &&
"Not an access diagnostic.");
178 assert(Kind == Access &&
"Not an access diagnostic.");
183 assert(Kind == Availability &&
"Not an availability diagnostic.");
184 return AvailabilityData.ReferringDecl;
188 return AvailabilityData.OffendingDecl;
192 assert(Kind == Availability &&
"Not an availability diagnostic.");
193 return StringRef(AvailabilityData.Message, AvailabilityData.MessageLen);
197 assert(Kind == Availability &&
"Not an availability diagnostic.");
198 return llvm::makeArrayRef(AvailabilityData.SelectorLocs,
199 AvailabilityData.NumSelectorLocs);
203 assert(Kind == Availability &&
"Not an availability diagnostic.");
204 return AvailabilityData.AR;
212 assert(Kind == ForbiddenType &&
"not a forbidden-type diagnostic");
213 return ForbiddenTypeData.Diagnostic;
217 assert(Kind == ForbiddenType &&
"not a forbidden-type diagnostic");
218 return ForbiddenTypeData.Argument;
222 assert(Kind == ForbiddenType &&
"not a forbidden-type diagnostic");
227 return AvailabilityData.UnknownObjCClass;
231 return AvailabilityData.ObjCProperty;
235 return AvailabilityData.ObjCPropertyAccess;
247 size_t NumSelectorLocs;
249 bool ObjCPropertyAccess;
259 struct AD AvailabilityData;
260 struct FTD ForbiddenTypeData;
279 : Parent(Other.Parent), Diagnostics(
std::move(Other.Diagnostics)) {
280 Other.Diagnostics.clear();
284 Parent = Other.Parent;
285 Diagnostics = std::move(Other.Diagnostics);
286 Other.Diagnostics.clear();
292 i = Diagnostics.begin(), e = Diagnostics.end(); i != e; ++i)
300 return (Diagnostics.empty() && (!Parent || Parent->
empty()));
305 Diagnostics.push_back(diag);
310 if (pool.Diagnostics.empty())
return;
312 if (Diagnostics.empty()) {
313 Diagnostics = std::move(pool.Diagnostics);
317 pool.Diagnostics.clear();
331 assert(shouldDelayDiagnostics() &&
"trying to delay without pool");
337 #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
bool Destroy(InterpState &S, CodePtr OpPC, uint32_t I)
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)