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

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

75 bool isQuiet() const { return Diag.getDiagID() == 0; }

76

78

79

82

83

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 }

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

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

183

187

192

198

203

204

205

206

207

212

217

222

226

230

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

276 : Parent(Other.Parent), Diagnostics(std::move(Other.Diagnostics)) {

277 Other.Diagnostics.clear();

278 }

279

281 Parent = Other.Parent;

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 || 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.

static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)

Produce a diagnostic highlighting some portion of a literal.

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.

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.

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.

Definition DelayedDiagnostic.h:327

Encodes a location in the source.

clang::DiagStorageAllocator DiagStorageAllocator

A declaration being accessed, together with information about how it was accessed.

Definition DelayedDiagnostic.h:50

PartialDiagnostic & setDiag(unsigned DiagID)

Definition DelayedDiagnostic.h:103

void setDiag(const PartialDiagnostic &PDiag)

Sets a diagnostic to be performed.

Definition DelayedDiagnostic.h:99

CXXRecordDecl * getNamingClass() const

Definition DelayedDiagnostic.h:81

BaseNonce

A hierarchy (base-to-derived or derived-to-base) conversion.

Definition DelayedDiagnostic.h:58

@ Base

Definition DelayedDiagnostic.h:58

AccessedEntity(PartialDiagnostic::DiagStorageAllocator &Allocator, MemberNonce _, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, QualType BaseObjectType)

Definition DelayedDiagnostic.h:60

CXXRecordDecl * getBaseClass() const

Definition DelayedDiagnostic.h:84

const PartialDiagnostic & getDiag() const

Definition DelayedDiagnostic.h:109

CXXRecordDecl * getDerivedClass() const

Definition DelayedDiagnostic.h:87

NamedDecl * getTargetDecl() const

Definition DelayedDiagnostic.h:80

AccessedEntity(PartialDiagnostic::DiagStorageAllocator &Allocator, BaseNonce _, CXXRecordDecl *BaseClass, CXXRecordDecl *DerivedClass, AccessSpecifier Access)

Definition DelayedDiagnostic.h:67

bool isQuiet() const

Definition DelayedDiagnostic.h:75

QualType getBaseObjectType() const

Retrieves the base object type, important when accessing an instance member.

Definition DelayedDiagnostic.h:91

bool isMemberAccess() const

Definition DelayedDiagnostic.h:73

AccessSpecifier getAccess() const

Definition DelayedDiagnostic.h:77

MemberNonce

A member declaration found through lookup.

Definition DelayedDiagnostic.h:54

@ Member

Definition DelayedDiagnostic.h:54

~DelayedDiagnosticPool()

Definition DelayedDiagnostic.h:287

const DelayedDiagnosticPool * getParent() const

Definition DelayedDiagnostic.h:293

DelayedDiagnosticPool(DelayedDiagnosticPool &&Other)

Definition DelayedDiagnostic.h:275

void steal(DelayedDiagnosticPool &pool)

Steal the diagnostics from the given pool.

Definition DelayedDiagnostic.h:306

DelayedDiagnosticPool(const DelayedDiagnosticPool &)=delete

void add(const DelayedDiagnostic &diag)

Add a diagnostic to this pool.

Definition DelayedDiagnostic.h:301

DelayedDiagnosticPool & operator=(DelayedDiagnosticPool &&Other)

Definition DelayedDiagnostic.h:280

bool empty() const

Does this pool, or any of its ancestors, contain any diagnostics?

Definition DelayedDiagnostic.h:296

pool_iterator pool_end() const

Definition DelayedDiagnostic.h:320

bool pool_empty() const

Definition DelayedDiagnostic.h:321

SmallVectorImpl< DelayedDiagnostic >::const_iterator pool_iterator

Definition DelayedDiagnostic.h:317

pool_iterator pool_begin() const

Definition DelayedDiagnostic.h:319

DelayedDiagnosticPool(const DelayedDiagnosticPool *parent)

Definition DelayedDiagnostic.h:270

DelayedDiagnosticPool & operator=(const DelayedDiagnosticPool &)=delete

A diagnostic message which has been conditionally emitted pending the complete parsing of the current...

Definition DelayedDiagnostic.h:126

bool getObjCPropertyAccess() const

Definition DelayedDiagnostic.h:231

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

Definition DelayedDiagnostic.h:218

const ObjCInterfaceDecl * getUnknownObjCClass() const

Definition DelayedDiagnostic.h:223

AccessedEntity & getAccessData()

Definition DelayedDiagnostic.h:170

static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)

Definition DelayedDiagnostic.h:156

const NamedDecl * getAvailabilityOffendingDecl() const

Definition DelayedDiagnostic.h:184

static DelayedDiagnostic makeAccess(SourceLocation Loc, const AccessedEntity &Entity)

Definition DelayedDiagnostic.h:146

unsigned getForbiddenTypeDiagnostic() const

The diagnostic ID to emit.

Definition DelayedDiagnostic.h:208

struct AD AvailabilityData

Definition DelayedDiagnostic.h:256

DDKind Kind

Definition DelayedDiagnostic.h:130

char AccessData[sizeof(AccessedEntity)]

Access control.

Definition DelayedDiagnostic.h:260

const ObjCPropertyDecl * getObjCProperty() const

Definition DelayedDiagnostic.h:227

StringRef getAvailabilityMessage() const

Definition DelayedDiagnostic.h:188

struct FTD ForbiddenTypeData

Definition DelayedDiagnostic.h:257

bool Triggered

Definition DelayedDiagnostic.h:131

ArrayRef< SourceLocation > getAvailabilitySelectorLocs() const

Definition DelayedDiagnostic.h:193

AvailabilityResult getAvailabilityResult() const

Definition DelayedDiagnostic.h:199

const NamedDecl * getAvailabilityReferringDecl() const

Definition DelayedDiagnostic.h:179

unsigned getForbiddenTypeArgument() const

Definition DelayedDiagnostic.h:213

const AccessedEntity & getAccessData() const

Definition DelayedDiagnostic.h:174

SourceLocation Loc

Definition DelayedDiagnostic.h:133

DDKind

Definition DelayedDiagnostic.h:128

@ ForbiddenType

Definition DelayedDiagnostic.h:128

@ Availability

Definition DelayedDiagnostic.h:128

@ Access

Definition DelayedDiagnostic.h:128

const internal::VariadicAllOfMatcher< Type > type

Matches Types in the clang AST.

The JSON file list parser is used to communicate input to InstallAPI.

AccessSpecifier

A C++ access specifier (public, private, protected), plus the special value "none" which means differ...

AvailabilityResult

Captures the result of checking the availability of a declaration.

U cast(CodeGen::Address addr)

@ Other

Other implicit parameter.