Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Sema/ParsedAttr.h
Line
Count
Source (jump to first uncovered line)
1
//======- ParsedAttr.h - Parsed attribute sets ------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file defines the ParsedAttr class, which is used to collect
10
// parsed attributes.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_SEMA_ATTRIBUTELIST_H
15
#define LLVM_CLANG_SEMA_ATTRIBUTELIST_H
16
17
#include "clang/Basic/AttrSubjectMatchRules.h"
18
#include "clang/Basic/Diagnostic.h"
19
#include "clang/Basic/SourceLocation.h"
20
#include "clang/Basic/TargetInfo.h"
21
#include "clang/Sema/Ownership.h"
22
#include "llvm/ADT/PointerUnion.h"
23
#include "llvm/ADT/SmallVector.h"
24
#include "llvm/ADT/TinyPtrVector.h"
25
#include "llvm/Support/Allocator.h"
26
#include "llvm/Support/VersionTuple.h"
27
#include <cassert>
28
#include <cstddef>
29
#include <cstring>
30
#include <utility>
31
32
namespace clang {
33
34
class ASTContext;
35
class Decl;
36
class Expr;
37
class IdentifierInfo;
38
class LangOptions;
39
40
/// Represents information about a change in availability for
41
/// an entity, which is part of the encoding of the 'availability'
42
/// attribute.
43
struct AvailabilityChange {
44
  /// The location of the keyword indicating the kind of change.
45
  SourceLocation KeywordLoc;
46
47
  /// The version number at which the change occurred.
48
  VersionTuple Version;
49
50
  /// The source range covering the version number.
51
  SourceRange VersionRange;
52
53
  /// Determine whether this availability change is valid.
54
70.9k
  bool isValid() const { return !Version.empty(); }
55
};
56
57
namespace detail {
58
enum AvailabilitySlot {
59
  IntroducedSlot, DeprecatedSlot, ObsoletedSlot, NumAvailabilitySlots
60
};
61
62
/// Describes the trailing object for Availability attribute in ParsedAttr.
63
struct AvailabilityData {
64
  AvailabilityChange Changes[NumAvailabilitySlots];
65
  SourceLocation StrictLoc;
66
  const Expr *Replacement;
67
68
  AvailabilityData(const AvailabilityChange &Introduced,
69
                   const AvailabilityChange &Deprecated,
70
                   const AvailabilityChange &Obsoleted,
71
                   SourceLocation Strict, const Expr *ReplaceExpr)
72
709k
    : StrictLoc(Strict), Replacement(ReplaceExpr) {
73
709k
    Changes[IntroducedSlot] = Introduced;
74
709k
    Changes[DeprecatedSlot] = Deprecated;
75
709k
    Changes[ObsoletedSlot] = Obsoleted;
76
709k
  }
77
};
78
79
struct TypeTagForDatatypeData {
80
  ParsedType MatchingCType;
81
  unsigned LayoutCompatible : 1;
82
  unsigned MustBeNull : 1;
83
};
84
struct PropertyData {
85
  IdentifierInfo *GetterId, *SetterId;
86
87
  PropertyData(IdentifierInfo *getterId, IdentifierInfo *setterId)
88
101
      : GetterId(getterId), SetterId(setterId) {}
89
};
90
91
} // namespace
92
93
/// Wraps an identifier and optional source location for the identifier.
94
struct IdentifierLoc {
95
  SourceLocation Loc;
96
  IdentifierInfo *Ident;
97
98
  static IdentifierLoc *create(ASTContext &Ctx, SourceLocation Loc,
99
                               IdentifierInfo *Ident);
100
};
101
102
/// A union of the various pointer types that can be passed to an
103
/// ParsedAttr as an argument.
104
using ArgsUnion = llvm::PointerUnion<Expr *, IdentifierLoc *>;
105
using ArgsVector = llvm::SmallVector<ArgsUnion, 12U>;
106
107
/// ParsedAttr - Represents a syntactic attribute.
108
///
109
/// For a GNU attribute, there are four forms of this construct:
110
///
111
/// 1: __attribute__(( const )). ParmName/Args/NumArgs will all be unused.
112
/// 2: __attribute__(( mode(byte) )). ParmName used, Args/NumArgs unused.
113
/// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
114
/// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
115
///
116
class ParsedAttr final
117
    : private llvm::TrailingObjects<
118
          ParsedAttr, ArgsUnion, detail::AvailabilityData,
119
          detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData> {
120
  friend TrailingObjects;
121
122
4.82M
  size_t numTrailingObjects(OverloadToken<ArgsUnion>) const { return NumArgs; }
123
1.01k
  size_t numTrailingObjects(OverloadToken<detail::AvailabilityData>) const {
124
1.01k
    return IsAvailability;
125
1.01k
  }
126
  size_t
127
360
      numTrailingObjects(OverloadToken<detail::TypeTagForDatatypeData>) const {
128
360
    return IsTypeTagForDatatype;
129
360
  }
130
293
  size_t numTrailingObjects(OverloadToken<ParsedType>) const {
131
293
    return HasParsedType;
132
293
  }
133
0
  size_t numTrailingObjects(OverloadToken<detail::PropertyData>) const {
134
0
    return IsProperty;
135
0
  }
136
137
public:
138
  /// The style used to specify an attribute.
139
  enum Syntax {
140
    /// __attribute__((...))
141
    AS_GNU,
142
143
    /// [[...]]
144
    AS_CXX11,
145
146
    /// [[...]]
147
    AS_C2x,
148
149
    /// __declspec(...)
150
    AS_Declspec,
151
152
    /// [uuid("...")] class Foo
153
    AS_Microsoft,
154
155
    /// __ptr16, alignas(...), etc.
156
    AS_Keyword,
157
158
    /// #pragma ...
159
    AS_Pragma,
160
161
    // Note TableGen depends on the order above.  Do not add or change the order
162
    // without adding related code to TableGen/ClangAttrEmitter.cpp.
163
    /// Context-sensitive version of a keyword attribute.
164
    AS_ContextSensitiveKeyword,
165
  };
166
167
private:
168
  IdentifierInfo *AttrName;
169
  IdentifierInfo *ScopeName;
170
  IdentifierInfo *MacroII = nullptr;
171
  SourceLocation MacroExpansionLoc;
172
  SourceRange AttrRange;
173
  SourceLocation ScopeLoc;
174
  SourceLocation EllipsisLoc;
175
176
  unsigned AttrKind : 16;
177
178
  /// The number of expression arguments this attribute has.
179
  /// The expressions themselves are stored after the object.
180
  unsigned NumArgs : 16;
181
182
  /// Corresponds to the Syntax enum.
183
  unsigned SyntaxUsed : 3;
184
185
  /// True if already diagnosed as invalid.
186
  mutable unsigned Invalid : 1;
187
188
  /// True if this attribute was used as a type attribute.
189
  mutable unsigned UsedAsTypeAttr : 1;
190
191
  /// True if this has the extra information associated with an
192
  /// availability attribute.
193
  unsigned IsAvailability : 1;
194
195
  /// True if this has extra information associated with a
196
  /// type_tag_for_datatype attribute.
197
  unsigned IsTypeTagForDatatype : 1;
198
199
  /// True if this has extra information associated with a
200
  /// Microsoft __delcspec(property) attribute.
201
  unsigned IsProperty : 1;
202
203
  /// True if this has a ParsedType
204
  unsigned HasParsedType : 1;
205
206
  /// True if the processing cache is valid.
207
  mutable unsigned HasProcessingCache : 1;
208
209
  /// A cached value.
210
  mutable unsigned ProcessingCache : 8;
211
212
  /// True if the attribute is specified using '#pragma clang attribute'.
213
  mutable unsigned IsPragmaClangAttribute : 1;
214
215
  /// The location of the 'unavailable' keyword in an
216
  /// availability attribute.
217
  SourceLocation UnavailableLoc;
218
219
  const Expr *MessageExpr;
220
221
3.74M
  ArgsUnion *getArgsBuffer() { return getTrailingObjects<ArgsUnion>(); }
222
6.28M
  ArgsUnion const *getArgsBuffer() const {
223
6.28M
    return getTrailingObjects<ArgsUnion>();
224
6.28M
  }
225
226
709k
  detail::AvailabilityData *getAvailabilityData() {
227
709k
    return getTrailingObjects<detail::AvailabilityData>();
228
709k
  }
229
4.11M
  const detail::AvailabilityData *getAvailabilityData() const {
230
4.11M
    return getTrailingObjects<detail::AvailabilityData>();
231
4.11M
  }
232
233
private:
234
  friend class AttributeFactory;
235
  friend class AttributePool;
236
237
  /// Constructor for attributes with expression arguments.
238
  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
239
             IdentifierInfo *scopeName, SourceLocation scopeLoc,
240
             ArgsUnion *args, unsigned numArgs, Syntax syntaxUsed,
241
             SourceLocation ellipsisLoc)
242
      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
243
        ScopeLoc(scopeLoc), EllipsisLoc(ellipsisLoc), NumArgs(numArgs),
244
        SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false),
245
        IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false),
246
        HasParsedType(false), HasProcessingCache(false),
247
7.36M
        IsPragmaClangAttribute(false) {
248
7.36M
    if (numArgs) 
memcpy(getArgsBuffer(), args, numArgs * sizeof(ArgsUnion))3.03M
;
249
7.36M
    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
250
7.36M
  }
251
252
  /// Constructor for availability attributes.
253
  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
254
             IdentifierInfo *scopeName, SourceLocation scopeLoc,
255
             IdentifierLoc *Parm, const AvailabilityChange &introduced,
256
             const AvailabilityChange &deprecated,
257
             const AvailabilityChange &obsoleted, SourceLocation unavailable,
258
             const Expr *messageExpr, Syntax syntaxUsed, SourceLocation strict,
259
             const Expr *replacementExpr)
260
      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
261
        ScopeLoc(scopeLoc), NumArgs(1), SyntaxUsed(syntaxUsed), Invalid(false),
262
        UsedAsTypeAttr(false), IsAvailability(true),
263
        IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
264
        HasProcessingCache(false), IsPragmaClangAttribute(false),
265
709k
        UnavailableLoc(unavailable), MessageExpr(messageExpr) {
266
709k
    ArgsUnion PVal(Parm);
267
709k
    memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion));
268
709k
    new (getAvailabilityData()) detail::AvailabilityData(
269
709k
        introduced, deprecated, obsoleted, strict, replacementExpr);
270
709k
    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
271
709k
  }
272
273
  /// Constructor for objc_bridge_related attributes.
274
  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
275
             IdentifierInfo *scopeName, SourceLocation scopeLoc,
276
             IdentifierLoc *Parm1, IdentifierLoc *Parm2, IdentifierLoc *Parm3,
277
             Syntax syntaxUsed)
278
      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
279
        ScopeLoc(scopeLoc), NumArgs(3), SyntaxUsed(syntaxUsed), Invalid(false),
280
        UsedAsTypeAttr(false), IsAvailability(false),
281
        IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
282
26
        HasProcessingCache(false), IsPragmaClangAttribute(false) {
283
26
    ArgsUnion *Args = getArgsBuffer();
284
26
    Args[0] = Parm1;
285
26
    Args[1] = Parm2;
286
26
    Args[2] = Parm3;
287
26
    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
288
26
  }
289
290
  /// Constructor for type_tag_for_datatype attribute.
291
  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
292
             IdentifierInfo *scopeName, SourceLocation scopeLoc,
293
             IdentifierLoc *ArgKind, ParsedType matchingCType,
294
             bool layoutCompatible, bool mustBeNull, Syntax syntaxUsed)
295
      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
296
        ScopeLoc(scopeLoc), NumArgs(1), SyntaxUsed(syntaxUsed), Invalid(false),
297
        UsedAsTypeAttr(false), IsAvailability(false),
298
        IsTypeTagForDatatype(true), IsProperty(false), HasParsedType(false),
299
167
        HasProcessingCache(false), IsPragmaClangAttribute(false) {
300
167
    ArgsUnion PVal(ArgKind);
301
167
    memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion));
302
167
    detail::TypeTagForDatatypeData &ExtraData = getTypeTagForDatatypeDataSlot();
303
167
    new (&ExtraData.MatchingCType) ParsedType(matchingCType);
304
167
    ExtraData.LayoutCompatible = layoutCompatible;
305
167
    ExtraData.MustBeNull = mustBeNull;
306
167
    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
307
167
  }
308
309
  /// Constructor for attributes with a single type argument.
310
  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
311
             IdentifierInfo *scopeName, SourceLocation scopeLoc,
312
             ParsedType typeArg, Syntax syntaxUsed)
313
      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
314
        ScopeLoc(scopeLoc), NumArgs(0), SyntaxUsed(syntaxUsed), Invalid(false),
315
        UsedAsTypeAttr(false), IsAvailability(false),
316
        IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(true),
317
36
        HasProcessingCache(false), IsPragmaClangAttribute(false) {
318
36
    new (&getTypeBuffer()) ParsedType(typeArg);
319
36
    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
320
36
  }
321
322
  /// Constructor for microsoft __declspec(property) attribute.
323
  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
324
             IdentifierInfo *scopeName, SourceLocation scopeLoc,
325
             IdentifierInfo *getterId, IdentifierInfo *setterId,
326
             Syntax syntaxUsed)
327
      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
328
        ScopeLoc(scopeLoc), NumArgs(0), SyntaxUsed(syntaxUsed), Invalid(false),
329
        UsedAsTypeAttr(false), IsAvailability(false),
330
        IsTypeTagForDatatype(false), IsProperty(true), HasParsedType(false),
331
101
        HasProcessingCache(false), IsPragmaClangAttribute(false) {
332
101
    new (&getPropertyDataBuffer()) detail::PropertyData(getterId, setterId);
333
101
    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
334
101
  }
335
336
  /// Type tag information is stored immediately following the arguments, if
337
  /// any, at the end of the object.  They are mutually exclusive with
338
  /// availability slots.
339
167
  detail::TypeTagForDatatypeData &getTypeTagForDatatypeDataSlot() {
340
167
    return *getTrailingObjects<detail::TypeTagForDatatypeData>();
341
167
  }
342
492
  const detail::TypeTagForDatatypeData &getTypeTagForDatatypeDataSlot() const {
343
492
    return *getTrailingObjects<detail::TypeTagForDatatypeData>();
344
492
  }
345
346
  /// The type buffer immediately follows the object and are mutually exclusive
347
  /// with arguments.
348
36
  ParsedType &getTypeBuffer() { return *getTrailingObjects<ParsedType>(); }
349
31
  const ParsedType &getTypeBuffer() const {
350
31
    return *getTrailingObjects<ParsedType>();
351
31
  }
352
353
  /// The property data immediately follows the object is is mutually exclusive
354
  /// with arguments.
355
101
  detail::PropertyData &getPropertyDataBuffer() {
356
101
    assert(IsProperty);
357
101
    return *getTrailingObjects<detail::PropertyData>();
358
101
  }
359
192
  const detail::PropertyData &getPropertyDataBuffer() const {
360
192
    assert(IsProperty);
361
192
    return *getTrailingObjects<detail::PropertyData>();
362
192
  }
363
364
  size_t allocated_size() const;
365
366
public:
367
  ParsedAttr(const ParsedAttr &) = delete;
368
  ParsedAttr(ParsedAttr &&) = delete;
369
  ParsedAttr &operator=(const ParsedAttr &) = delete;
370
  ParsedAttr &operator=(ParsedAttr &&) = delete;
371
  ~ParsedAttr() = delete;
372
373
  void operator delete(void *) = delete;
374
375
  enum Kind {
376
    #define PARSED_ATTR(NAME) AT_##NAME,
377
    #include "clang/Sema/AttrParsedAttrList.inc"
378
    #undef PARSED_ATTR
379
    IgnoredAttribute,
380
    UnknownAttribute
381
  };
382
383
9.24M
  IdentifierInfo *getName() const { return AttrName; }
384
284k
  SourceLocation getLoc() const { return AttrRange.getBegin(); }
385
8.11M
  SourceRange getRange() const { return AttrRange; }
386
387
0
  bool hasScope() const { return ScopeName; }
388
8.07M
  IdentifierInfo *getScopeName() const { return ScopeName; }
389
0
  SourceLocation getScopeLoc() const { return ScopeLoc; }
390
391
8.61k
  bool isGNUScope() const {
392
8.61k
    return ScopeName &&
393
8.61k
           
(468
ScopeName->isStr("gnu")468
||
ScopeName->isStr("__gnu__")334
);
394
8.61k
  }
395
396
8.19M
  bool hasParsedType() const { return HasParsedType; }
397
398
  /// Is this the Microsoft __declspec(property) attribute?
399
1.26M
  bool isDeclspecPropertyAttribute() const  {
400
1.26M
    return IsProperty;
401
1.26M
  }
402
403
23.7M
  bool isAlignasAttribute() const {
404
23.7M
    // FIXME: Use a better mechanism to determine this.
405
23.7M
    return getKind() == AT_Aligned && 
isKeywordAttribute()84.3k
;
406
23.7M
  }
407
408
22.9k
  bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
409
254
  bool isMicrosoftAttribute() const { return SyntaxUsed == AS_Microsoft; }
410
411
23.8M
  bool isCXX11Attribute() const {
412
23.8M
    return SyntaxUsed == AS_CXX11 || 
isAlignasAttribute()23.7M
;
413
23.8M
  }
414
415
10.1k
  bool isC2xAttribute() const {
416
10.1k
    return SyntaxUsed == AS_C2x;
417
10.1k
  }
418
419
84.3k
  bool isKeywordAttribute() const {
420
84.3k
    return SyntaxUsed == AS_Keyword || 
SyntaxUsed == AS_ContextSensitiveKeyword73.3k
;
421
84.3k
  }
422
423
210k
  bool isContextSensitiveKeywordAttribute() const {
424
210k
    return SyntaxUsed == AS_ContextSensitiveKeyword;
425
210k
  }
426
427
15.7M
  bool isInvalid() const { return Invalid; }
428
318
  void setInvalid(bool b = true) const { Invalid = b; }
429
430
5.17k
  bool hasProcessingCache() const { return HasProcessingCache; }
431
432
2.45k
  unsigned getProcessingCache() const {
433
2.45k
    assert(hasProcessingCache());
434
2.45k
    return ProcessingCache;
435
2.45k
  }
436
437
2.68k
  void setProcessingCache(unsigned value) const {
438
2.68k
    ProcessingCache = value;
439
2.68k
    HasProcessingCache = true;
440
2.68k
  }
441
442
64.5k
  bool isUsedAsTypeAttr() const { return UsedAsTypeAttr; }
443
574k
  void setUsedAsTypeAttr(bool Used = true) { UsedAsTypeAttr = Used; }
444
445
  /// True if the attribute is specified using '#pragma clang attribute'.
446
822k
  bool isPragmaClangAttribute() const { return IsPragmaClangAttribute; }
447
448
654
  void setIsPragmaClangAttribute() { IsPragmaClangAttribute = true; }
449
450
107k
  bool isPackExpansion() const { return EllipsisLoc.isValid(); }
451
1
  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
452
453
149M
  Kind getKind() const { return Kind(AttrKind); }
454
  static Kind getKind(const IdentifierInfo *Name, const IdentifierInfo *Scope,
455
                      Syntax SyntaxUsed);
456
457
  /// getNumArgs - Return the number of actual arguments to this attribute.
458
8.32M
  unsigned getNumArgs() const { return NumArgs; }
459
460
  /// getArg - Return the specified argument.
461
6.28M
  ArgsUnion getArg(unsigned Arg) const {
462
6.28M
    assert(Arg < NumArgs && "Arg access out of range!");
463
6.28M
    return getArgsBuffer()[Arg];
464
6.28M
  }
465
466
45.6k
  bool isArgExpr(unsigned Arg) const {
467
45.6k
    return Arg < NumArgs && 
getArg(Arg).is<Expr*>()6.49k
;
468
45.6k
  }
469
470
3.12M
  Expr *getArgAsExpr(unsigned Arg) const {
471
3.12M
    return getArg(Arg).get<Expr*>();
472
3.12M
  }
473
474
2.27M
  bool isArgIdent(unsigned Arg) const {
475
2.27M
    return Arg < NumArgs && 
getArg(Arg).is<IdentifierLoc*>()2.27M
;
476
2.27M
  }
477
478
885k
  IdentifierLoc *getArgAsIdent(unsigned Arg) const {
479
885k
    return getArg(Arg).get<IdentifierLoc*>();
480
885k
  }
481
482
822k
  const AvailabilityChange &getAvailabilityIntroduced() const {
483
822k
    assert(getKind() == AT_Availability && "Not an availability attribute");
484
822k
    return getAvailabilityData()->Changes[detail::IntroducedSlot];
485
822k
  }
486
487
822k
  const AvailabilityChange &getAvailabilityDeprecated() const {
488
822k
    assert(getKind() == AT_Availability && "Not an availability attribute");
489
822k
    return getAvailabilityData()->Changes[detail::DeprecatedSlot];
490
822k
  }
491
492
822k
  const AvailabilityChange &getAvailabilityObsoleted() const {
493
822k
    assert(getKind() == AT_Availability && "Not an availability attribute");
494
822k
    return getAvailabilityData()->Changes[detail::ObsoletedSlot];
495
822k
  }
496
497
822k
  SourceLocation getStrictLoc() const {
498
822k
    assert(getKind() == AT_Availability && "Not an availability attribute");
499
822k
    return getAvailabilityData()->StrictLoc;
500
822k
  }
501
502
822k
  SourceLocation getUnavailableLoc() const {
503
822k
    assert(getKind() == AT_Availability && "Not an availability attribute");
504
822k
    return UnavailableLoc;
505
822k
  }
506
507
822k
  const Expr * getMessageExpr() const {
508
822k
    assert(getKind() == AT_Availability && "Not an availability attribute");
509
822k
    return MessageExpr;
510
822k
  }
511
512
822k
  const Expr *getReplacementExpr() const {
513
822k
    assert(getKind() == AT_Availability && "Not an availability attribute");
514
822k
    return getAvailabilityData()->Replacement;
515
822k
  }
516
517
164
  const ParsedType &getMatchingCType() const {
518
164
    assert(getKind() == AT_TypeTagForDatatype &&
519
164
           "Not a type_tag_for_datatype attribute");
520
164
    return getTypeTagForDatatypeDataSlot().MatchingCType;
521
164
  }
522
523
164
  bool getLayoutCompatible() const {
524
164
    assert(getKind() == AT_TypeTagForDatatype &&
525
164
           "Not a type_tag_for_datatype attribute");
526
164
    return getTypeTagForDatatypeDataSlot().LayoutCompatible;
527
164
  }
528
529
164
  bool getMustBeNull() const {
530
164
    assert(getKind() == AT_TypeTagForDatatype &&
531
164
           "Not a type_tag_for_datatype attribute");
532
164
    return getTypeTagForDatatypeDataSlot().MustBeNull;
533
164
  }
534
535
31
  const ParsedType &getTypeArg() const {
536
31
    assert(HasParsedType && "Not a type attribute");
537
31
    return getTypeBuffer();
538
31
  }
539
540
96
  IdentifierInfo *getPropertyDataGetter() const {
541
96
    assert(isDeclspecPropertyAttribute() &&
542
96
           "Not a __delcspec(property) attribute");
543
96
    return getPropertyDataBuffer().GetterId;
544
96
  }
545
546
96
  IdentifierInfo *getPropertyDataSetter() const {
547
96
    assert(isDeclspecPropertyAttribute() &&
548
96
           "Not a __delcspec(property) attribute");
549
96
    return getPropertyDataBuffer().SetterId;
550
96
  }
551
552
  /// Set the macro identifier info object that this parsed attribute was
553
  /// declared in if it was declared in a macro. Also set the expansion location
554
  /// of the macro.
555
4.45M
  void setMacroIdentifier(IdentifierInfo *MacroName, SourceLocation Loc) {
556
4.45M
    MacroII = MacroName;
557
4.45M
    MacroExpansionLoc = Loc;
558
4.45M
  }
559
560
  /// Returns true if this attribute was declared in a macro.
561
261k
  bool hasMacroIdentifier() const { return MacroII != nullptr; }
562
563
  /// Return the macro identifier if this attribute was declared in a macro.
564
  /// nullptr is returned if it was not declared in a macro.
565
8.60k
  IdentifierInfo *getMacroIdentifier() const { return MacroII; }
566
567
8.60k
  SourceLocation getMacroExpansionLoc() const {
568
8.60k
    assert(hasMacroIdentifier() && "Can only get the macro expansion location "
569
8.60k
                                   "if this attribute has a macro identifier.");
570
8.60k
    return MacroExpansionLoc;
571
8.60k
  }
572
573
  /// Get an index into the attribute spelling list
574
  /// defined in Attr.td. This index is used by an attribute
575
  /// to pretty print itself.
576
  unsigned getAttributeSpellingListIndex() const;
577
578
  bool isTargetSpecificAttr() const;
579
  bool isTypeAttr() const;
580
  bool isStmtAttr() const;
581
582
  bool hasCustomParsing() const;
583
  unsigned getMinArgs() const;
584
  unsigned getMaxArgs() const;
585
  bool hasVariadicArg() const;
586
  bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const;
587
  bool appliesToDecl(const Decl *D, attr::SubjectMatchRule MatchRule) const;
588
  void getMatchRules(const LangOptions &LangOpts,
589
                     SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>>
590
                         &MatchRules) const;
591
  bool diagnoseLangOpts(class Sema &S) const;
592
  bool existsInTarget(const TargetInfo &Target) const;
593
  bool isKnownToGCC() const;
594
  bool isSupportedByPragmaAttribute() const;
595
596
  /// If the parsed attribute has a semantic equivalent, and it would
597
  /// have a semantic Spelling enumeration (due to having semantically-distinct
598
  /// spelling variations), return the value of that semantic spelling. If the
599
  /// parsed attribute does not have a semantic equivalent, or would not have
600
  /// a Spelling enumeration, the value UINT_MAX is returned.
601
  unsigned getSemanticSpelling() const;
602
603
  /// If this is an OpenCL addr space attribute returns its representation
604
  /// in LangAS, otherwise returns default addr space.
605
28.7k
  LangAS asOpenCLLangAS() const {
606
28.7k
    switch (getKind()) {
607
28.7k
    case ParsedAttr::AT_OpenCLConstantAddressSpace:
608
1.95k
      return LangAS::opencl_constant;
609
28.7k
    case ParsedAttr::AT_OpenCLGlobalAddressSpace:
610
12.3k
      return LangAS::opencl_global;
611
28.7k
    case ParsedAttr::AT_OpenCLLocalAddressSpace:
612
10.6k
      return LangAS::opencl_local;
613
28.7k
    case ParsedAttr::AT_OpenCLPrivateAddressSpace:
614
3.40k
      return LangAS::opencl_private;
615
28.7k
    case ParsedAttr::AT_OpenCLGenericAddressSpace:
616
414
      return LangAS::opencl_generic;
617
28.7k
    default:
618
0
      return LangAS::Default;
619
28.7k
    }
620
28.7k
  }
621
};
622
623
class AttributePool;
624
/// A factory, from which one makes pools, from which one creates
625
/// individual attributes which are deallocated with the pool.
626
///
627
/// Note that it's tolerably cheap to create and destroy one of
628
/// these as long as you don't actually allocate anything in it.
629
class AttributeFactory {
630
public:
631
  enum {
632
    AvailabilityAllocSize =
633
        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
634
                                     detail::TypeTagForDatatypeData, ParsedType,
635
                                     detail::PropertyData>(1, 1, 0, 0, 0),
636
    TypeTagForDatatypeAllocSize =
637
        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
638
                                     detail::TypeTagForDatatypeData, ParsedType,
639
                                     detail::PropertyData>(1, 0, 1, 0, 0),
640
    PropertyAllocSize =
641
        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
642
                                     detail::TypeTagForDatatypeData, ParsedType,
643
                                     detail::PropertyData>(0, 0, 0, 0, 1),
644
  };
645
646
private:
647
  enum {
648
    /// The number of free lists we want to be sure to support
649
    /// inline.  This is just enough that availability attributes
650
    /// don't surpass it.  It's actually very unlikely we'll see an
651
    /// attribute that needs more than that; on x86-64 you'd need 10
652
    /// expression arguments, and on i386 you'd need 19.
653
    InlineFreeListsCapacity =
654
        1 + (AvailabilityAllocSize - sizeof(ParsedAttr)) / sizeof(void *)
655
  };
656
657
  llvm::BumpPtrAllocator Alloc;
658
659
  /// Free lists.  The index is determined by the following formula:
660
  ///   (size - sizeof(ParsedAttr)) / sizeof(void*)
661
  SmallVector<SmallVector<ParsedAttr *, 8>, InlineFreeListsCapacity> FreeLists;
662
663
  // The following are the private interface used by AttributePool.
664
  friend class AttributePool;
665
666
  /// Allocate an attribute of the given size.
667
  void *allocate(size_t size);
668
669
  void deallocate(ParsedAttr *AL);
670
671
  /// Reclaim all the attributes in the given pool chain, which is
672
  /// non-empty.  Note that the current implementation is safe
673
  /// against reclaiming things which were not actually allocated
674
  /// with the allocator, although of course it's important to make
675
  /// sure that their allocator lives at least as long as this one.
676
  void reclaimPool(AttributePool &head);
677
678
public:
679
  AttributeFactory();
680
  ~AttributeFactory();
681
};
682
683
class AttributePool {
684
  friend class AttributeFactory;
685
  friend class ParsedAttributes;
686
  AttributeFactory &Factory;
687
  llvm::TinyPtrVector<ParsedAttr *> Attrs;
688
689
8.07M
  void *allocate(size_t size) {
690
8.07M
    return Factory.allocate(size);
691
8.07M
  }
692
693
8.07M
  ParsedAttr *add(ParsedAttr *attr) {
694
8.07M
    Attrs.push_back(attr);
695
8.07M
    return attr;
696
8.07M
  }
697
698
11
  void remove(ParsedAttr *attr) {
699
11
    assert(llvm::is_contained(Attrs, attr) &&
700
11
           "Can't take attribute from a pool that doesn't own it!");
701
11
    Attrs.erase(llvm::find(Attrs, attr));
702
11
  }
703
704
  void takePool(AttributePool &pool);
705
706
public:
707
  /// Create a new pool for a factory.
708
155M
  AttributePool(AttributeFactory &factory) : Factory(factory) {}
709
710
  AttributePool(const AttributePool &) = delete;
711
712
155M
  ~AttributePool() { Factory.reclaimPool(*this); }
713
714
  /// Move the given pool's allocations to this pool.
715
  AttributePool(AttributePool &&pool) = default;
716
717
32.2M
  AttributeFactory &getFactory() const { return Factory; }
718
719
32.0M
  void clear() {
720
32.0M
    Factory.reclaimPool(*this);
721
32.0M
    Attrs.clear();
722
32.0M
  }
723
724
  /// Take the given pool's allocations and add them to this pool.
725
36.8M
  void takeAllFrom(AttributePool &pool) {
726
36.8M
    takePool(pool);
727
36.8M
    pool.Attrs.clear();
728
36.8M
  }
729
730
  ParsedAttr *create(IdentifierInfo *attrName, SourceRange attrRange,
731
                     IdentifierInfo *scopeName, SourceLocation scopeLoc,
732
                     ArgsUnion *args, unsigned numArgs,
733
                     ParsedAttr::Syntax syntax,
734
7.36M
                     SourceLocation ellipsisLoc = SourceLocation()) {
735
7.36M
    size_t temp =
736
7.36M
        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
737
7.36M
                                     detail::TypeTagForDatatypeData, ParsedType,
738
7.36M
                                     detail::PropertyData>(numArgs, 0, 0, 0, 0);
739
7.36M
    (void)temp;
740
7.36M
    void *memory = allocate(
741
7.36M
        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
742
7.36M
                                     detail::TypeTagForDatatypeData, ParsedType,
743
7.36M
                                     detail::PropertyData>(numArgs, 0, 0, 0,
744
7.36M
                                                           0));
745
7.36M
    return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
746
7.36M
                                       args, numArgs, syntax, ellipsisLoc));
747
7.36M
  }
748
749
  ParsedAttr *create(IdentifierInfo *attrName, SourceRange attrRange,
750
                     IdentifierInfo *scopeName, SourceLocation scopeLoc,
751
                     IdentifierLoc *Param, const AvailabilityChange &introduced,
752
                     const AvailabilityChange &deprecated,
753
                     const AvailabilityChange &obsoleted,
754
                     SourceLocation unavailable, const Expr *MessageExpr,
755
                     ParsedAttr::Syntax syntax, SourceLocation strict,
756
709k
                     const Expr *ReplacementExpr) {
757
709k
    void *memory = allocate(AttributeFactory::AvailabilityAllocSize);
758
709k
    return add(new (memory) ParsedAttr(
759
709k
        attrName, attrRange, scopeName, scopeLoc, Param, introduced, deprecated,
760
709k
        obsoleted, unavailable, MessageExpr, syntax, strict, ReplacementExpr));
761
709k
  }
762
763
  ParsedAttr *create(IdentifierInfo *attrName, SourceRange attrRange,
764
                     IdentifierInfo *scopeName, SourceLocation scopeLoc,
765
                     IdentifierLoc *Param1, IdentifierLoc *Param2,
766
26
                     IdentifierLoc *Param3, ParsedAttr::Syntax syntax) {
767
26
    void *memory = allocate(
768
26
        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
769
26
                                     detail::TypeTagForDatatypeData, ParsedType,
770
26
                                     detail::PropertyData>(3, 0, 0, 0, 0));
771
26
    return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
772
26
                                       Param1, Param2, Param3, syntax));
773
26
  }
774
775
  ParsedAttr *
776
  createTypeTagForDatatype(IdentifierInfo *attrName, SourceRange attrRange,
777
                           IdentifierInfo *scopeName, SourceLocation scopeLoc,
778
                           IdentifierLoc *argumentKind,
779
                           ParsedType matchingCType, bool layoutCompatible,
780
167
                           bool mustBeNull, ParsedAttr::Syntax syntax) {
781
167
    void *memory = allocate(AttributeFactory::TypeTagForDatatypeAllocSize);
782
167
    return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
783
167
                                       argumentKind, matchingCType,
784
167
                                       layoutCompatible, mustBeNull, syntax));
785
167
  }
786
787
  ParsedAttr *createTypeAttribute(IdentifierInfo *attrName,
788
                                  SourceRange attrRange,
789
                                  IdentifierInfo *scopeName,
790
                                  SourceLocation scopeLoc, ParsedType typeArg,
791
36
                                  ParsedAttr::Syntax syntaxUsed) {
792
36
    void *memory = allocate(
793
36
        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
794
36
                                     detail::TypeTagForDatatypeData, ParsedType,
795
36
                                     detail::PropertyData>(0, 0, 0, 1, 0));
796
36
    return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
797
36
                                       typeArg, syntaxUsed));
798
36
  }
799
800
  ParsedAttr *
801
  createPropertyAttribute(IdentifierInfo *attrName, SourceRange attrRange,
802
                          IdentifierInfo *scopeName, SourceLocation scopeLoc,
803
                          IdentifierInfo *getterId, IdentifierInfo *setterId,
804
101
                          ParsedAttr::Syntax syntaxUsed) {
805
101
    void *memory = allocate(AttributeFactory::PropertyAllocSize);
806
101
    return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
807
101
                                       getterId, setterId, syntaxUsed));
808
101
  }
809
};
810
811
class ParsedAttributesView {
812
  using VecTy = llvm::TinyPtrVector<ParsedAttr *>;
813
  using SizeType = decltype(std::declval<VecTy>().size());
814
815
public:
816
112M
  bool empty() const { return AttrList.empty(); }
817
17.6M
  SizeType size() const { return AttrList.size(); }
818
4.45M
  ParsedAttr &operator[](SizeType pos) { return *AttrList[pos]; }
819
0
  const ParsedAttr &operator[](SizeType pos) const { return *AttrList[pos]; }
820
821
8.24M
  void addAtEnd(ParsedAttr *newAttr) {
822
8.24M
    assert(newAttr);
823
8.24M
    AttrList.push_back(newAttr);
824
8.24M
  }
825
826
29.1k
  void remove(ParsedAttr *ToBeRemoved) {
827
29.1k
    assert(is_contained(AttrList, ToBeRemoved) &&
828
29.1k
           "Cannot remove attribute that isn't in the list");
829
29.1k
    AttrList.erase(llvm::find(AttrList, ToBeRemoved));
830
29.1k
  }
831
832
55.7M
  void clearListOnly() { AttrList.clear(); }
833
834
  struct iterator : llvm::iterator_adaptor_base<iterator, VecTy::iterator,
835
                                                std::random_access_iterator_tag,
836
                                                ParsedAttr> {
837
0
    iterator() : iterator_adaptor_base(nullptr) {}
838
240M
    iterator(VecTy::iterator I) : iterator_adaptor_base(I) {}
839
8.30M
    reference operator*() { return **I; }
840
    friend class ParsedAttributesView;
841
  };
842
  struct const_iterator
843
      : llvm::iterator_adaptor_base<const_iterator, VecTy::const_iterator,
844
                                    std::random_access_iterator_tag,
845
                                    ParsedAttr> {
846
0
    const_iterator() : iterator_adaptor_base(nullptr) {}
847
82.0M
    const_iterator(VecTy::const_iterator I) : iterator_adaptor_base(I) {}
848
849
10.3M
    reference operator*() const { return **I; }
850
    friend class ParsedAttributesView;
851
  };
852
853
40.0M
  void addAll(iterator B, iterator E) {
854
40.0M
    AttrList.insert(AttrList.begin(), B.I, E.I);
855
40.0M
  }
856
857
0
  void addAll(const_iterator B, const_iterator E) {
858
0
    AttrList.insert(AttrList.begin(), B.I, E.I);
859
0
  }
860
861
0
  void addAllAtEnd(iterator B, iterator E) {
862
0
    AttrList.insert(AttrList.end(), B.I, E.I);
863
0
  }
864
865
0
  void addAllAtEnd(const_iterator B, const_iterator E) {
866
0
    AttrList.insert(AttrList.end(), B.I, E.I);
867
0
  }
868
869
120M
  iterator begin() { return iterator(AttrList.begin()); }
870
39.1M
  const_iterator begin() const { return const_iterator(AttrList.begin()); }
871
120M
  iterator end() { return iterator(AttrList.end()); }
872
42.9M
  const_iterator end() const { return const_iterator(AttrList.end()); }
873
874
0
  ParsedAttr &front() {
875
0
    assert(!empty());
876
0
    return *AttrList.front();
877
0
  }
878
0
  const ParsedAttr &front() const {
879
0
    assert(!empty());
880
0
    return *AttrList.front();
881
0
  }
882
37
  ParsedAttr &back() {
883
37
    assert(!empty());
884
37
    return *AttrList.back();
885
37
  }
886
0
  const ParsedAttr &back() const {
887
0
    assert(!empty());
888
0
    return *AttrList.back();
889
0
  }
890
891
79.2M
  bool hasAttribute(ParsedAttr::Kind K) const {
892
79.2M
    return llvm::any_of(
893
79.2M
        AttrList, [K](const ParsedAttr *AL) 
{ return AL->getKind() == K; }13.8M
);
894
79.2M
  }
895
896
private:
897
  VecTy AttrList;
898
};
899
900
/// ParsedAttributes - A collection of parsed attributes.  Currently
901
/// we don't differentiate between the various attribute syntaxes,
902
/// which is basically silly.
903
///
904
/// Right now this is a very lightweight container, but the expectation
905
/// is that this will become significantly more serious.
906
class ParsedAttributes : public ParsedAttributesView {
907
public:
908
155M
  ParsedAttributes(AttributeFactory &factory) : pool(factory) {}
909
  ParsedAttributes(const ParsedAttributes &) = delete;
910
911
63.3M
  AttributePool &getPool() const { return pool; }
912
913
23.6M
  void takeAllFrom(ParsedAttributes &attrs) {
914
23.6M
    addAll(attrs.begin(), attrs.end());
915
23.6M
    attrs.clearListOnly();
916
23.6M
    pool.takeAllFrom(attrs.pool);
917
23.6M
  }
918
919
11
  void takeOneFrom(ParsedAttributes &Attrs, ParsedAttr *PA) {
920
11
    Attrs.getPool().remove(PA);
921
11
    Attrs.remove(PA);
922
11
    getPool().add(PA);
923
11
    addAtEnd(PA);
924
11
  }
925
926
32.0M
  void clear() {
927
32.0M
    clearListOnly();
928
32.0M
    pool.clear();
929
32.0M
  }
930
931
  /// Add attribute with expression arguments.
932
  ParsedAttr *addNew(IdentifierInfo *attrName, SourceRange attrRange,
933
                     IdentifierInfo *scopeName, SourceLocation scopeLoc,
934
                     ArgsUnion *args, unsigned numArgs,
935
                     ParsedAttr::Syntax syntax,
936
7.20M
                     SourceLocation ellipsisLoc = SourceLocation()) {
937
7.20M
    ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc,
938
7.20M
                                   args, numArgs, syntax, ellipsisLoc);
939
7.20M
    addAtEnd(attr);
940
7.20M
    return attr;
941
7.20M
  }
942
943
  /// Add availability attribute.
944
  ParsedAttr *addNew(IdentifierInfo *attrName, SourceRange attrRange,
945
                     IdentifierInfo *scopeName, SourceLocation scopeLoc,
946
                     IdentifierLoc *Param, const AvailabilityChange &introduced,
947
                     const AvailabilityChange &deprecated,
948
                     const AvailabilityChange &obsoleted,
949
                     SourceLocation unavailable, const Expr *MessageExpr,
950
                     ParsedAttr::Syntax syntax, SourceLocation strict,
951
709k
                     const Expr *ReplacementExpr) {
952
709k
    ParsedAttr *attr = pool.create(
953
709k
        attrName, attrRange, scopeName, scopeLoc, Param, introduced, deprecated,
954
709k
        obsoleted, unavailable, MessageExpr, syntax, strict, ReplacementExpr);
955
709k
    addAtEnd(attr);
956
709k
    return attr;
957
709k
  }
958
959
  /// Add objc_bridge_related attribute.
960
  ParsedAttr *addNew(IdentifierInfo *attrName, SourceRange attrRange,
961
                     IdentifierInfo *scopeName, SourceLocation scopeLoc,
962
                     IdentifierLoc *Param1, IdentifierLoc *Param2,
963
26
                     IdentifierLoc *Param3, ParsedAttr::Syntax syntax) {
964
26
    ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc,
965
26
                                   Param1, Param2, Param3, syntax);
966
26
    addAtEnd(attr);
967
26
    return attr;
968
26
  }
969
970
  /// Add type_tag_for_datatype attribute.
971
  ParsedAttr *
972
  addNewTypeTagForDatatype(IdentifierInfo *attrName, SourceRange attrRange,
973
                           IdentifierInfo *scopeName, SourceLocation scopeLoc,
974
                           IdentifierLoc *argumentKind,
975
                           ParsedType matchingCType, bool layoutCompatible,
976
167
                           bool mustBeNull, ParsedAttr::Syntax syntax) {
977
167
    ParsedAttr *attr = pool.createTypeTagForDatatype(
978
167
        attrName, attrRange, scopeName, scopeLoc, argumentKind, matchingCType,
979
167
        layoutCompatible, mustBeNull, syntax);
980
167
    addAtEnd(attr);
981
167
    return attr;
982
167
  }
983
984
  /// Add an attribute with a single type argument.
985
  ParsedAttr *addNewTypeAttr(IdentifierInfo *attrName, SourceRange attrRange,
986
                             IdentifierInfo *scopeName, SourceLocation scopeLoc,
987
                             ParsedType typeArg,
988
36
                             ParsedAttr::Syntax syntaxUsed) {
989
36
    ParsedAttr *attr = pool.createTypeAttribute(attrName, attrRange, scopeName,
990
36
                                                scopeLoc, typeArg, syntaxUsed);
991
36
    addAtEnd(attr);
992
36
    return attr;
993
36
  }
994
995
  /// Add microsoft __delspec(property) attribute.
996
  ParsedAttr *
997
  addNewPropertyAttr(IdentifierInfo *attrName, SourceRange attrRange,
998
                     IdentifierInfo *scopeName, SourceLocation scopeLoc,
999
                     IdentifierInfo *getterId, IdentifierInfo *setterId,
1000
101
                     ParsedAttr::Syntax syntaxUsed) {
1001
101
    ParsedAttr *attr =
1002
101
        pool.createPropertyAttribute(attrName, attrRange, scopeName, scopeLoc,
1003
101
                                     getterId, setterId, syntaxUsed);
1004
101
    addAtEnd(attr);
1005
101
    return attr;
1006
101
  }
1007
1008
private:
1009
  mutable AttributePool pool;
1010
};
1011
1012
/// These constants match the enumerated choices of
1013
/// err_attribute_argument_n_type and err_attribute_argument_type.
1014
enum AttributeArgumentNType {
1015
  AANT_ArgumentIntOrBool,
1016
  AANT_ArgumentIntegerConstant,
1017
  AANT_ArgumentString,
1018
  AANT_ArgumentIdentifier
1019
};
1020
1021
/// These constants match the enumerated choices of
1022
/// warn_attribute_wrong_decl_type and err_attribute_wrong_decl_type.
1023
enum AttributeDeclKind {
1024
  ExpectedFunction,
1025
  ExpectedUnion,
1026
  ExpectedVariableOrFunction,
1027
  ExpectedFunctionOrMethod,
1028
  ExpectedFunctionMethodOrBlock,
1029
  ExpectedFunctionMethodOrParameter,
1030
  ExpectedVariable,
1031
  ExpectedVariableOrField,
1032
  ExpectedVariableFieldOrTag,
1033
  ExpectedTypeOrNamespace,
1034
  ExpectedFunctionVariableOrClass,
1035
  ExpectedKernelFunction,
1036
  ExpectedFunctionWithProtoType,
1037
};
1038
1039
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1040
2.49k
                                           const ParsedAttr &At) {
1041
2.49k
  DB.AddTaggedVal(reinterpret_cast<intptr_t>(At.getName()),
1042
2.49k
                  DiagnosticsEngine::ak_identifierinfo);
1043
2.49k
  return DB;
1044
2.49k
}
1045
1046
inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
1047
0
                                           const ParsedAttr &At) {
1048
0
  PD.AddTaggedVal(reinterpret_cast<intptr_t>(At.getName()),
1049
0
                  DiagnosticsEngine::ak_identifierinfo);
1050
0
  return PD;
1051
0
}
1052
1053
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1054
69
                                           const ParsedAttr *At) {
1055
69
  DB.AddTaggedVal(reinterpret_cast<intptr_t>(At->getName()),
1056
69
                  DiagnosticsEngine::ak_identifierinfo);
1057
69
  return DB;
1058
69
}
1059
1060
inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
1061
0
                                           const ParsedAttr *At) {
1062
0
  PD.AddTaggedVal(reinterpret_cast<intptr_t>(At->getName()),
1063
0
                  DiagnosticsEngine::ak_identifierinfo);
1064
0
  return PD;
1065
0
}
1066
1067
} // namespace clang
1068
1069
#endif // LLVM_CLANG_SEMA_ATTRIBUTELIST_H