diff options
Diffstat (limited to 'include/clang/Sema/DelayedDiagnostic.h')
-rw-r--r-- | include/clang/Sema/DelayedDiagnostic.h | 87 |
1 files changed, 56 insertions, 31 deletions
diff --git a/include/clang/Sema/DelayedDiagnostic.h b/include/clang/Sema/DelayedDiagnostic.h index d65dbf0cd34e0..76aa4546d749a 100644 --- a/include/clang/Sema/DelayedDiagnostic.h +++ b/include/clang/Sema/DelayedDiagnostic.h @@ -1,4 +1,4 @@ -//===--- DelayedDiagnostic.h - Delayed declarator diagnostics ---*- C++ -*-===// +//===- DelayedDiagnostic.h - Delayed declarator diagnostics -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,9 +6,9 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file -/// \brief Defines the classes clang::DelayedDiagnostic and +/// Defines the classes clang::DelayedDiagnostic and /// clang::AccessedEntity. /// /// DelayedDiangostic is used to record diagnostics that are being @@ -16,15 +16,34 @@ /// diagnostics -- notably deprecation and access control -- are suppressed /// based on semantic properties of the parsed declaration that aren't known /// until it is fully parsed. -/// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H #define LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H +#include "clang/AST/DeclAccessPair.h" +#include "clang/AST/DeclBase.h" +#include "clang/AST/DeclCXX.h" +#include "clang/AST/Type.h" +#include "clang/Basic/LLVM.h" +#include "clang/Basic/PartialDiagnostic.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/Specifiers.h" #include "clang/Sema/Sema.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Casting.h" +#include <cassert> +#include <cstddef> +#include <utility> namespace clang { + +class ObjCInterfaceDecl; +class ObjCPropertyDecl; + namespace sema { /// A declaration being accessed, together with information about how @@ -39,16 +58,14 @@ public: /// The target is the base class. enum BaseNonce { Base }; - bool isMemberAccess() const { return IsMember; } - AccessedEntity(PartialDiagnostic::StorageAllocator &Allocator, MemberNonce _, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, QualType BaseObjectType) - : Access(FoundDecl.getAccess()), IsMember(true), - Target(FoundDecl.getDecl()), NamingClass(NamingClass), - BaseObjectType(BaseObjectType), Diag(0, Allocator) { + : Access(FoundDecl.getAccess()), IsMember(true), + Target(FoundDecl.getDecl()), NamingClass(NamingClass), + BaseObjectType(BaseObjectType), Diag(0, Allocator) { } AccessedEntity(PartialDiagnostic::StorageAllocator &Allocator, @@ -56,11 +73,10 @@ public: CXXRecordDecl *BaseClass, CXXRecordDecl *DerivedClass, AccessSpecifier Access) - : Access(Access), IsMember(false), - Target(BaseClass), - NamingClass(DerivedClass), - Diag(0, Allocator) { - } + : Access(Access), IsMember(false), Target(BaseClass), + NamingClass(DerivedClass), Diag(0, Allocator) {} + + bool isMemberAccess() const { return IsMember; } bool isQuiet() const { return Diag.getDiagID() == 0; } @@ -123,7 +139,7 @@ public: void Destroy(); static DelayedDiagnostic makeAvailability(AvailabilityResult AR, - SourceLocation Loc, + ArrayRef<SourceLocation> Locs, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, const ObjCInterfaceDecl *UnknownObjCClass, @@ -131,7 +147,6 @@ public: StringRef Msg, bool ObjCPropertyAccess); - static DelayedDiagnostic makeAccess(SourceLocation Loc, const AccessedEntity &Entity) { DelayedDiagnostic DD; @@ -179,6 +194,12 @@ public: return StringRef(AvailabilityData.Message, AvailabilityData.MessageLen); } + ArrayRef<SourceLocation> getAvailabilitySelectorLocs() const { + assert(Kind == Availability && "Not an availability diagnostic."); + return llvm::makeArrayRef(AvailabilityData.SelectorLocs, + AvailabilityData.NumSelectorLocs); + } + AvailabilityResult getAvailabilityResult() const { assert(Kind == Availability && "Not an availability diagnostic."); return AvailabilityData.AR; @@ -216,7 +237,6 @@ public: } private: - struct AD { const NamedDecl *ReferringDecl; const NamedDecl *OffendingDecl; @@ -224,6 +244,8 @@ private: const ObjCPropertyDecl *ObjCProperty; const char *Message; size_t MessageLen; + SourceLocation *SelectorLocs; + size_t NumSelectorLocs; AvailabilityResult AR; bool ObjCPropertyAccess; }; @@ -243,25 +265,22 @@ private: }; }; -/// \brief A collection of diagnostics which were delayed. +/// A collection of diagnostics which were delayed. class DelayedDiagnosticPool { const DelayedDiagnosticPool *Parent; SmallVector<DelayedDiagnostic, 4> Diagnostics; - DelayedDiagnosticPool(const DelayedDiagnosticPool &) = delete; - void operator=(const DelayedDiagnosticPool &) = delete; public: DelayedDiagnosticPool(const DelayedDiagnosticPool *parent) : Parent(parent) {} - ~DelayedDiagnosticPool() { - for (SmallVectorImpl<DelayedDiagnostic>::iterator - i = Diagnostics.begin(), e = Diagnostics.end(); i != e; ++i) - i->Destroy(); - } + + DelayedDiagnosticPool(const DelayedDiagnosticPool &) = delete; + DelayedDiagnosticPool &operator=(const DelayedDiagnosticPool &) = delete; DelayedDiagnosticPool(DelayedDiagnosticPool &&Other) - : Parent(Other.Parent), Diagnostics(std::move(Other.Diagnostics)) { + : Parent(Other.Parent), Diagnostics(std::move(Other.Diagnostics)) { Other.Diagnostics.clear(); } + DelayedDiagnosticPool &operator=(DelayedDiagnosticPool &&Other) { Parent = Other.Parent; Diagnostics = std::move(Other.Diagnostics); @@ -269,6 +288,12 @@ public: return *this; } + ~DelayedDiagnosticPool() { + for (SmallVectorImpl<DelayedDiagnostic>::iterator + i = Diagnostics.begin(), e = Diagnostics.end(); i != e; ++i) + i->Destroy(); + } + const DelayedDiagnosticPool *getParent() const { return Parent; } /// Does this pool, or any of its ancestors, contain any diagnostics? @@ -293,13 +318,14 @@ public: pool.Diagnostics.clear(); } - typedef SmallVectorImpl<DelayedDiagnostic>::const_iterator pool_iterator; + using pool_iterator = SmallVectorImpl<DelayedDiagnostic>::const_iterator; + pool_iterator pool_begin() const { return Diagnostics.begin(); } pool_iterator pool_end() const { return Diagnostics.end(); } bool pool_empty() const { return Diagnostics.empty(); } }; -} +} // namespace clang /// Add a diagnostic to the current delay pool. inline void Sema::DelayedDiagnostics::add(const sema::DelayedDiagnostic &diag) { @@ -307,7 +333,6 @@ inline void Sema::DelayedDiagnostics::add(const sema::DelayedDiagnostic &diag) { CurPool->add(diag); } +} // namespace clang -} - -#endif +#endif // LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H |