Coverage Report

Created: 2018-09-25 17:16

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/tools/clang/include/clang/AST/Attrs.inc
Line
Count
Source (jump to first uncovered line)
1
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
|*                                                                            *|
3
|* Attribute classes' definitions                                             *|
4
|*                                                                            *|
5
|* Automatically generated file, do not edit!                                 *|
6
|*                                                                            *|
7
\*===----------------------------------------------------------------------===*/
8
9
#ifndef LLVM_CLANG_ATTR_CLASSES_INC
10
#define LLVM_CLANG_ATTR_CLASSES_INC
11
12
class AMDGPUFlatWorkGroupSizeAttr : public InheritableAttr {
13
unsigned min;
14
15
unsigned max;
16
17
public:
18
  static AMDGPUFlatWorkGroupSizeAttr *CreateImplicit(ASTContext &Ctx, unsigned Min, unsigned Max, SourceRange Loc = SourceRange()) {
19
    auto *A = new (Ctx) AMDGPUFlatWorkGroupSizeAttr(Loc, Ctx, Min, Max, 0);
20
    A->setImplicit(true);
21
    return A;
22
  }
23
24
  AMDGPUFlatWorkGroupSizeAttr(SourceRange R, ASTContext &Ctx
25
              , unsigned Min
26
              , unsigned Max
27
              , unsigned SI
28
             )
29
    : InheritableAttr(attr::AMDGPUFlatWorkGroupSize, R, SI, false, false)
30
              , min(Min)
31
              , max(Max)
32
86
  {
33
86
  }
34
35
  AMDGPUFlatWorkGroupSizeAttr *clone(ASTContext &C) const;
36
  void printPretty(raw_ostream &OS,
37
                   const PrintingPolicy &Policy) const;
38
  const char *getSpelling() const;
39
47
  unsigned getMin() const {
40
47
    return min;
41
47
  }
42
43
47
  unsigned getMax() const {
44
47
    return max;
45
47
  }
46
47
48
49
6.35M
  static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUFlatWorkGroupSize; }
50
};
51
52
class AMDGPUNumSGPRAttr : public InheritableAttr {
53
unsigned numSGPR;
54
55
public:
56
  static AMDGPUNumSGPRAttr *CreateImplicit(ASTContext &Ctx, unsigned NumSGPR, SourceRange Loc = SourceRange()) {
57
    auto *A = new (Ctx) AMDGPUNumSGPRAttr(Loc, Ctx, NumSGPR, 0);
58
    A->setImplicit(true);
59
    return A;
60
  }
61
62
  AMDGPUNumSGPRAttr(SourceRange R, ASTContext &Ctx
63
              , unsigned NumSGPR
64
              , unsigned SI
65
             )
66
    : InheritableAttr(attr::AMDGPUNumSGPR, R, SI, false, false)
67
              , numSGPR(NumSGPR)
68
69
  {
69
69
  }
70
71
  AMDGPUNumSGPRAttr *clone(ASTContext &C) const;
72
  void printPretty(raw_ostream &OS,
73
                   const PrintingPolicy &Policy) const;
74
  const char *getSpelling() const;
75
37
  unsigned getNumSGPR() const {
76
37
    return numSGPR;
77
37
  }
78
79
80
81
6.35M
  static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUNumSGPR; }
82
};
83
84
class AMDGPUNumVGPRAttr : public InheritableAttr {
85
unsigned numVGPR;
86
87
public:
88
  static AMDGPUNumVGPRAttr *CreateImplicit(ASTContext &Ctx, unsigned NumVGPR, SourceRange Loc = SourceRange()) {
89
    auto *A = new (Ctx) AMDGPUNumVGPRAttr(Loc, Ctx, NumVGPR, 0);
90
    A->setImplicit(true);
91
    return A;
92
  }
93
94
  AMDGPUNumVGPRAttr(SourceRange R, ASTContext &Ctx
95
              , unsigned NumVGPR
96
              , unsigned SI
97
             )
98
    : InheritableAttr(attr::AMDGPUNumVGPR, R, SI, false, false)
99
              , numVGPR(NumVGPR)
100
69
  {
101
69
  }
102
103
  AMDGPUNumVGPRAttr *clone(ASTContext &C) const;
104
  void printPretty(raw_ostream &OS,
105
                   const PrintingPolicy &Policy) const;
106
  const char *getSpelling() const;
107
37
  unsigned getNumVGPR() const {
108
37
    return numVGPR;
109
37
  }
110
111
112
113
6.35M
  static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUNumVGPR; }
114
};
115
116
class AMDGPUWavesPerEUAttr : public InheritableAttr {
117
unsigned min;
118
119
unsigned max;
120
121
public:
122
  static AMDGPUWavesPerEUAttr *CreateImplicit(ASTContext &Ctx, unsigned Min, unsigned Max, SourceRange Loc = SourceRange()) {
123
    auto *A = new (Ctx) AMDGPUWavesPerEUAttr(Loc, Ctx, Min, Max, 0);
124
    A->setImplicit(true);
125
    return A;
126
  }
127
128
  AMDGPUWavesPerEUAttr(SourceRange R, ASTContext &Ctx
129
              , unsigned Min
130
              , unsigned Max
131
              , unsigned SI
132
             )
133
    : InheritableAttr(attr::AMDGPUWavesPerEU, R, SI, false, false)
134
              , min(Min)
135
              , max(Max)
136
107
  {
137
107
  }
138
139
  AMDGPUWavesPerEUAttr(SourceRange R, ASTContext &Ctx
140
              , unsigned Min
141
              , unsigned SI
142
             )
143
    : InheritableAttr(attr::AMDGPUWavesPerEU, R, SI, false, false)
144
              , min(Min)
145
              , max()
146
  {
147
  }
148
149
  AMDGPUWavesPerEUAttr *clone(ASTContext &C) const;
150
  void printPretty(raw_ostream &OS,
151
                   const PrintingPolicy &Policy) const;
152
  const char *getSpelling() const;
153
57
  unsigned getMin() const {
154
57
    return min;
155
57
  }
156
157
57
  unsigned getMax() const {
158
57
    return max;
159
57
  }
160
161
162
163
6.35M
  static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUWavesPerEU; }
164
};
165
166
class ARMInterruptAttr : public InheritableAttr {
167
public:
168
  enum InterruptType {
169
    IRQ,
170
    FIQ,
171
    SWI,
172
    ABORT,
173
    UNDEF,
174
    Generic
175
  };
176
private:
177
  InterruptType interrupt;
178
179
public:
180
  static ARMInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) {
181
    auto *A = new (Ctx) ARMInterruptAttr(Loc, Ctx, Interrupt, 0);
182
    A->setImplicit(true);
183
    return A;
184
  }
185
186
  ARMInterruptAttr(SourceRange R, ASTContext &Ctx
187
              , InterruptType Interrupt
188
              , unsigned SI
189
             )
190
    : InheritableAttr(attr::ARMInterrupt, R, SI, false, false)
191
              , interrupt(Interrupt)
192
73
  {
193
73
  }
194
195
  ARMInterruptAttr(SourceRange R, ASTContext &Ctx
196
              , unsigned SI
197
             )
198
    : InheritableAttr(attr::ARMInterrupt, R, SI, false, false)
199
              , interrupt(InterruptType(0))
200
  {
201
  }
202
203
  ARMInterruptAttr *clone(ASTContext &C) const;
204
  void printPretty(raw_ostream &OS,
205
                   const PrintingPolicy &Policy) const;
206
  const char *getSpelling() const;
207
13
  InterruptType getInterrupt() const {
208
13
    return interrupt;
209
13
  }
210
211
78
  static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) {
212
78
    Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val)
213
78
      .Case("IRQ", ARMInterruptAttr::IRQ)
214
78
      .Case("FIQ", ARMInterruptAttr::FIQ)
215
78
      .Case("SWI", ARMInterruptAttr::SWI)
216
78
      .Case("ABORT", ARMInterruptAttr::ABORT)
217
78
      .Case("UNDEF", ARMInterruptAttr::UNDEF)
218
78
      .Case("", ARMInterruptAttr::Generic)
219
78
      .Default(Optional<InterruptType>());
220
78
    if (R) {
221
73
      Out = *R;
222
73
      return true;
223
73
    }
224
5
    return false;
225
5
  }
226
227
0
  static const char *ConvertInterruptTypeToStr(InterruptType Val) {
228
0
    switch(Val) {
229
0
    case ARMInterruptAttr::IRQ: return "IRQ";
230
0
    case ARMInterruptAttr::FIQ: return "FIQ";
231
0
    case ARMInterruptAttr::SWI: return "SWI";
232
0
    case ARMInterruptAttr::ABORT: return "ABORT";
233
0
    case ARMInterruptAttr::UNDEF: return "UNDEF";
234
0
    case ARMInterruptAttr::Generic: return "";
235
0
    }
236
0
    llvm_unreachable("No enumerator with that value");
237
0
  }
238
239
240
4.57M
  static bool classof(const Attr *A) { return A->getKind() == attr::ARMInterrupt; }
241
};
242
243
class AVRInterruptAttr : public InheritableAttr {
244
public:
245
  static AVRInterruptAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
246
    auto *A = new (Ctx) AVRInterruptAttr(Loc, Ctx, 0);
247
    A->setImplicit(true);
248
    return A;
249
  }
250
251
  AVRInterruptAttr(SourceRange R, ASTContext &Ctx
252
              , unsigned SI
253
             )
254
    : InheritableAttr(attr::AVRInterrupt, R, SI, false, false)
255
2
  {
256
2
  }
257
258
  AVRInterruptAttr *clone(ASTContext &C) const;
259
  void printPretty(raw_ostream &OS,
260
                   const PrintingPolicy &Policy) const;
261
  const char *getSpelling() const;
262
263
264
3
  static bool classof(const Attr *A) { return A->getKind() == attr::AVRInterrupt; }
265
};
266
267
class AVRSignalAttr : public InheritableAttr {
268
public:
269
  static AVRSignalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
270
    auto *A = new (Ctx) AVRSignalAttr(Loc, Ctx, 0);
271
    A->setImplicit(true);
272
    return A;
273
  }
274
275
  AVRSignalAttr(SourceRange R, ASTContext &Ctx
276
              , unsigned SI
277
             )
278
    : InheritableAttr(attr::AVRSignal, R, SI, false, false)
279
2
  {
280
2
  }
281
282
  AVRSignalAttr *clone(ASTContext &C) const;
283
  void printPretty(raw_ostream &OS,
284
                   const PrintingPolicy &Policy) const;
285
  const char *getSpelling() const;
286
287
288
3
  static bool classof(const Attr *A) { return A->getKind() == attr::AVRSignal; }
289
};
290
291
class AbiTagAttr : public Attr {
292
  unsigned tags_Size;
293
  StringRef *tags_;
294
295
public:
296
  static AbiTagAttr *CreateImplicit(ASTContext &Ctx, StringRef *Tags, unsigned TagsSize, SourceRange Loc = SourceRange()) {
297
    auto *A = new (Ctx) AbiTagAttr(Loc, Ctx, Tags, TagsSize, 0);
298
    A->setImplicit(true);
299
    return A;
300
  }
301
302
  AbiTagAttr(SourceRange R, ASTContext &Ctx
303
              , StringRef *Tags, unsigned TagsSize
304
              , unsigned SI
305
             )
306
    : Attr(attr::AbiTag, R, SI, false)
307
              , tags_Size(TagsSize), tags_(new (Ctx, 16) StringRef[tags_Size])
308
147
  {
309
355
    for (size_t I = 0, E = tags_Size; I != E;
310
208
         ++I) {
311
208
      StringRef Ref = Tags[I];
312
208
      if (!Ref.empty()) {
313
208
        char *Mem = new (Ctx, 1) char[Ref.size()];
314
208
        std::memcpy(Mem, Ref.data(), Ref.size());
315
208
        tags_[I] = StringRef(Mem, Ref.size());
316
208
      }
317
208
    }
318
147
  }
319
320
  AbiTagAttr(SourceRange R, ASTContext &Ctx
321
              , unsigned SI
322
             )
323
    : Attr(attr::AbiTag, R, SI, false)
324
              , tags_Size(0), tags_(nullptr)
325
  {
326
  }
327
328
  AbiTagAttr *clone(ASTContext &C) const;
329
  void printPretty(raw_ostream &OS,
330
                   const PrintingPolicy &Policy) const;
331
  const char *getSpelling() const;
332
  typedef StringRef* tags_iterator;
333
1.23k
  tags_iterator tags_begin() const { return tags_; }
334
1.23k
  tags_iterator tags_end() const { return tags_ + tags_Size; }
335
1
  unsigned tags_size() const { return tags_Size; }
336
1.23k
  llvm::iterator_range<tags_iterator> tags() const { return llvm::make_range(tags_begin(), tags_end()); }
337
338
339
340
341
1.86M
  static bool classof(const Attr *A) { return A->getKind() == attr::AbiTag; }
342
};
343
344
class AcquireCapabilityAttr : public InheritableAttr {
345
  unsigned args_Size;
346
  Expr * *args_;
347
348
public:
349
  enum Spelling {
350
    GNU_acquire_capability = 0,
351
    CXX11_clang_acquire_capability = 1,
352
    GNU_acquire_shared_capability = 2,
353
    CXX11_clang_acquire_shared_capability = 3,
354
    GNU_exclusive_lock_function = 4,
355
    GNU_shared_lock_function = 5
356
  };
357
358
  static AcquireCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
359
    auto *A = new (Ctx) AcquireCapabilityAttr(Loc, Ctx, Args, ArgsSize, S);
360
    A->setImplicit(true);
361
    return A;
362
  }
363
364
  AcquireCapabilityAttr(SourceRange R, ASTContext &Ctx
365
              , Expr * *Args, unsigned ArgsSize
366
              , unsigned SI
367
             )
368
    : InheritableAttr(attr::AcquireCapability, R, SI, true, true)
369
              , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
370
536
  {
371
536
    std::copy(Args, Args + args_Size, args_);
372
536
  }
373
374
  AcquireCapabilityAttr(SourceRange R, ASTContext &Ctx
375
              , unsigned SI
376
             )
377
    : InheritableAttr(attr::AcquireCapability, R, SI, true, true)
378
              , args_Size(0), args_(nullptr)
379
  {
380
  }
381
382
  AcquireCapabilityAttr *clone(ASTContext &C) const;
383
  void printPretty(raw_ostream &OS,
384
                   const PrintingPolicy &Policy) const;
385
  const char *getSpelling() const;
386
  Spelling getSemanticSpelling() const {
387
  switch (SpellingListIndex) {
388
    default: llvm_unreachable("Unknown spelling list index");
389
    case 0: return GNU_acquire_capability;
390
    case 1: return CXX11_clang_acquire_capability;
391
    case 2: return GNU_acquire_shared_capability;
392
    case 3: return CXX11_clang_acquire_shared_capability;
393
    case 4: return GNU_exclusive_lock_function;
394
    case 5: return GNU_shared_lock_function;
395
  }
396
  }
397
1.77k
  bool isShared() const { return SpellingListIndex == 2 ||
398
1.77k
    
SpellingListIndex == 31.66k
||
399
1.77k
    
SpellingListIndex == 51.66k
; }
400
  typedef Expr ** args_iterator;
401
2.35k
  args_iterator args_begin() const { return args_; }
402
2.35k
  args_iterator args_end() const { return args_ + args_Size; }
403
1.90k
  unsigned args_size() const { return args_Size; }
404
2.34k
  llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
405
406
407
408
409
289k
  static bool classof(const Attr *A) { return A->getKind() == attr::AcquireCapability; }
410
};
411
412
class AcquiredAfterAttr : public InheritableAttr {
413
  unsigned args_Size;
414
  Expr * *args_;
415
416
public:
417
  static AcquiredAfterAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
418
    auto *A = new (Ctx) AcquiredAfterAttr(Loc, Ctx, Args, ArgsSize, 0);
419
    A->setImplicit(true);
420
    return A;
421
  }
422
423
  AcquiredAfterAttr(SourceRange R, ASTContext &Ctx
424
              , Expr * *Args, unsigned ArgsSize
425
              , unsigned SI
426
             )
427
    : InheritableAttr(attr::AcquiredAfter, R, SI, true, true)
428
              , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
429
134
  {
430
134
    std::copy(Args, Args + args_Size, args_);
431
134
  }
432
433
  AcquiredAfterAttr(SourceRange R, ASTContext &Ctx
434
              , unsigned SI
435
             )
436
    : InheritableAttr(attr::AcquiredAfter, R, SI, true, true)
437
              , args_Size(0), args_(nullptr)
438
  {
439
  }
440
441
  AcquiredAfterAttr *clone(ASTContext &C) const;
442
  void printPretty(raw_ostream &OS,
443
                   const PrintingPolicy &Policy) const;
444
  const char *getSpelling() const;
445
  typedef Expr ** args_iterator;
446
87
  args_iterator args_begin() const { return args_; }
447
87
  args_iterator args_end() const { return args_ + args_Size; }
448
1
  unsigned args_size() const { return args_Size; }
449
86
  llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
450
451
452
453
454
289k
  static bool classof(const Attr *A) { return A->getKind() == attr::AcquiredAfter; }
455
};
456
457
class AcquiredBeforeAttr : public InheritableAttr {
458
  unsigned args_Size;
459
  Expr * *args_;
460
461
public:
462
  static AcquiredBeforeAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
463
    auto *A = new (Ctx) AcquiredBeforeAttr(Loc, Ctx, Args, ArgsSize, 0);
464
    A->setImplicit(true);
465
    return A;
466
  }
467
468
  AcquiredBeforeAttr(SourceRange R, ASTContext &Ctx
469
              , Expr * *Args, unsigned ArgsSize
470
              , unsigned SI
471
             )
472
    : InheritableAttr(attr::AcquiredBefore, R, SI, true, true)
473
              , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
474
94
  {
475
94
    std::copy(Args, Args + args_Size, args_);
476
94
  }
477
478
  AcquiredBeforeAttr(SourceRange R, ASTContext &Ctx
479
              , unsigned SI
480
             )
481
    : InheritableAttr(attr::AcquiredBefore, R, SI, true, true)
482
              , args_Size(0), args_(nullptr)
483
  {
484
  }
485
486
  AcquiredBeforeAttr *clone(ASTContext &C) const;
487
  void printPretty(raw_ostream &OS,
488
                   const PrintingPolicy &Policy) const;
489
  const char *getSpelling() const;
490
  typedef Expr ** args_iterator;
491
52
  args_iterator args_begin() const { return args_; }
492
52
  args_iterator args_end() const { return args_ + args_Size; }
493
0
  unsigned args_size() const { return args_Size; }
494
52
  llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
495
496
497
498
499
289k
  static bool classof(const Attr *A) { return A->getKind() == attr::AcquiredBefore; }
500
};
501
502
class AddressSpaceAttr : public TypeAttr {
503
int addressSpace;
504
505
public:
506
  static AddressSpaceAttr *CreateImplicit(ASTContext &Ctx, int AddressSpace, SourceRange Loc = SourceRange()) {
507
    auto *A = new (Ctx) AddressSpaceAttr(Loc, Ctx, AddressSpace, 0);
508
    A->setImplicit(true);
509
    return A;
510
  }
511
512
  AddressSpaceAttr(SourceRange R, ASTContext &Ctx
513
              , int AddressSpace
514
              , unsigned SI
515
             )
516
    : TypeAttr(attr::AddressSpace, R, SI, false)
517
              , addressSpace(AddressSpace)
518
221
  {
519
221
  }
520
521
  AddressSpaceAttr *clone(ASTContext &C) const;
522
  void printPretty(raw_ostream &OS,
523
                   const PrintingPolicy &Policy) const;
524
  const char *getSpelling() const;
525
13
  int getAddressSpace() const {
526
13
    return addressSpace;
527
13
  }
528
529
530
531
  static bool classof(const Attr *A) { return A->getKind() == attr::AddressSpace; }
532
};
533
534
class AliasAttr : public Attr {
535
unsigned aliaseeLength;
536
char *aliasee;
537
538
public:
539
17
  static AliasAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Aliasee, SourceRange Loc = SourceRange()) {
540
17
    auto *A = new (Ctx) AliasAttr(Loc, Ctx, Aliasee, 0);
541
17
    A->setImplicit(true);
542
17
    return A;
543
17
  }
544
545
  AliasAttr(SourceRange R, ASTContext &Ctx
546
              , llvm::StringRef Aliasee
547
              , unsigned SI
548
             )
549
    : Attr(attr::Alias, R, SI, false)
550
              , aliaseeLength(Aliasee.size()),aliasee(new (Ctx, 1) char[aliaseeLength])
551
142
  {
552
142
      if (!Aliasee.empty())
553
142
        std::memcpy(aliasee, Aliasee.data(), aliaseeLength);
554
142
  }
555
556
  AliasAttr *clone(ASTContext &C) const;
557
  void printPretty(raw_ostream &OS,
558
                   const PrintingPolicy &Policy) const;
559
  const char *getSpelling() const;
560
217
  llvm::StringRef getAliasee() const {
561
217
    return llvm::StringRef(aliasee, aliaseeLength);
562
217
  }
563
  unsigned getAliaseeLength() const {
564
    return aliaseeLength;
565
  }
566
  void setAliasee(ASTContext &C, llvm::StringRef S) {
567
    aliaseeLength = S.size();
568
    this->aliasee = new (C, 1) char [aliaseeLength];
569
    if (!S.empty())
570
      std::memcpy(this->aliasee, S.data(), aliaseeLength);
571
  }
572
573
574
575
24.6M
  static bool classof(const Attr *A) { return A->getKind() == attr::Alias; }
576
};
577
578
class AlignMac68kAttr : public InheritableAttr {
579
public:
580
13
  static AlignMac68kAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
581
13
    auto *A = new (Ctx) AlignMac68kAttr(Loc, Ctx, 0);
582
13
    A->setImplicit(true);
583
13
    return A;
584
13
  }
585
586
  AlignMac68kAttr(SourceRange R, ASTContext &Ctx
587
              , unsigned SI
588
             )
589
    : InheritableAttr(attr::AlignMac68k, R, SI, false, false)
590
13
  {
591
13
  }
592
593
  AlignMac68kAttr *clone(ASTContext &C) const;
594
  void printPretty(raw_ostream &OS,
595
                   const PrintingPolicy &Policy) const;
596
  const char *getSpelling() const;
597
598
599
20.2k
  static bool classof(const Attr *A) { return A->getKind() == attr::AlignMac68k; }
600
};
601
602
class AlignValueAttr : public Attr {
603
Expr * alignment;
604
605
public:
606
0
  static AlignValueAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, SourceRange Loc = SourceRange()) {
607
0
    auto *A = new (Ctx) AlignValueAttr(Loc, Ctx, Alignment, 0);
608
0
    A->setImplicit(true);
609
0
    return A;
610
0
  }
611
612
  AlignValueAttr(SourceRange R, ASTContext &Ctx
613
              , Expr * Alignment
614
              , unsigned SI
615
             )
616
    : Attr(attr::AlignValue, R, SI, false)
617
              , alignment(Alignment)
618
308
  {
619
308
  }
620
621
  AlignValueAttr *clone(ASTContext &C) const;
622
  void printPretty(raw_ostream &OS,
623
                   const PrintingPolicy &Policy) const;
624
  const char *getSpelling() const;
625
20
  Expr * getAlignment() const {
626
20
    return alignment;
627
20
  }
628
629
630
631
2.16M
  static bool classof(const Attr *A) { return A->getKind() == attr::AlignValue; }
632
};
633
634
class AlignedAttr : public InheritableAttr {
635
bool isalignmentExpr;
636
union {
637
Expr *alignmentExpr;
638
TypeSourceInfo *alignmentType;
639
};
640
641
public:
642
  enum Spelling {
643
    GNU_aligned = 0,
644
    CXX11_gnu_aligned = 1,
645
    Declspec_align = 2,
646
    Keyword_alignas = 3,
647
    Keyword_Alignas = 4
648
  };
649
650
0
  static AlignedAttr *CreateImplicit(ASTContext &Ctx, Spelling S, bool IsAlignmentExpr, void *Alignment, SourceRange Loc = SourceRange()) {
651
0
    auto *A = new (Ctx) AlignedAttr(Loc, Ctx, IsAlignmentExpr, Alignment, S);
652
0
    A->setImplicit(true);
653
0
    return A;
654
0
  }
655
656
  AlignedAttr(SourceRange R, ASTContext &Ctx
657
              , bool IsAlignmentExpr, void *Alignment
658
              , unsigned SI
659
             )
660
    : InheritableAttr(attr::Aligned, R, SI, false, false)
661
              , isalignmentExpr(IsAlignmentExpr)
662
58.3k
  {
663
58.3k
    if (isalignmentExpr)
664
58.3k
       alignmentExpr = reinterpret_cast<Expr *>(Alignment);
665
0
    else
666
0
       alignmentType = reinterpret_cast<TypeSourceInfo *>(Alignment);
667
58.3k
  }
668
669
  AlignedAttr(SourceRange R, ASTContext &Ctx
670
              , unsigned SI
671
             )
672
    : InheritableAttr(attr::Aligned, R, SI, false, false)
673
              , isalignmentExpr(false)
674
  {
675
  }
676
677
  AlignedAttr *clone(ASTContext &C) const;
678
  void printPretty(raw_ostream &OS,
679
                   const PrintingPolicy &Policy) const;
680
  const char *getSpelling() const;
681
0
  Spelling getSemanticSpelling() const {
682
0
  switch (SpellingListIndex) {
683
0
    default: llvm_unreachable("Unknown spelling list index");
684
0
    case 0: return GNU_aligned;
685
0
    case 1: return CXX11_gnu_aligned;
686
0
    case 2: return Declspec_align;
687
0
    case 3: return Keyword_alignas;
688
0
    case 4: return Keyword_Alignas;
689
0
  }
690
0
  }
691
0
  bool isGNU() const { return SpellingListIndex == 0 ||
692
0
    SpellingListIndex == 1; }
693
7
  bool isC11() const { return SpellingListIndex == 4; }
694
64.2k
  bool isAlignas() const { return SpellingListIndex == 3 ||
695
64.2k
    
SpellingListIndex == 447.7k
; }
696
0
  bool isDeclspec() const { return SpellingListIndex == 2; }
697
  bool isAlignmentDependent() const;
698
  unsigned getAlignment(ASTContext &Ctx) const;
699
779
  bool isAlignmentExpr() const {
700
779
    return isalignmentExpr;
701
779
  }
702
531
  Expr *getAlignmentExpr() const {
703
531
    assert(isalignmentExpr);
704
531
    return alignmentExpr;
705
531
  }
706
0
  TypeSourceInfo *getAlignmentType() const {
707
0
    assert(!isalignmentExpr);
708
0
    return alignmentType;
709
0
  }
710
711
712
713
4.11M
  static bool classof(const Attr *A) { return A->getKind() == attr::Aligned; }
714
};
715
716
class AllocAlignAttr : public InheritableAttr {
717
ParamIdx paramIndex;
718
719
public:
720
  static AllocAlignAttr *CreateImplicit(ASTContext &Ctx, ParamIdx ParamIndex, SourceRange Loc = SourceRange()) {
721
    auto *A = new (Ctx) AllocAlignAttr(Loc, Ctx, ParamIndex, 0);
722
    A->setImplicit(true);
723
    return A;
724
  }
725
726
  AllocAlignAttr(SourceRange R, ASTContext &Ctx
727
              , ParamIdx ParamIndex
728
              , unsigned SI
729
             )
730
    : InheritableAttr(attr::AllocAlign, R, SI, false, false)
731
              , paramIndex(ParamIndex)
732
48
  {
733
48
  }
734
735
  AllocAlignAttr *clone(ASTContext &C) const;
736
  void printPretty(raw_ostream &OS,
737
                   const PrintingPolicy &Policy) const;
738
  const char *getSpelling() const;
739
20
  ParamIdx getParamIndex() const {
740
20
    return paramIndex;
741
20
  }
742
743
744
745
2.51M
  static bool classof(const Attr *A) { return A->getKind() == attr::AllocAlign; }
746
};
747
748
class AllocSizeAttr : public InheritableAttr {
749
ParamIdx elemSizeParam;
750
751
ParamIdx numElemsParam;
752
753
public:
754
  static AllocSizeAttr *CreateImplicit(ASTContext &Ctx, ParamIdx ElemSizeParam, ParamIdx NumElemsParam, SourceRange Loc = SourceRange()) {
755
    auto *A = new (Ctx) AllocSizeAttr(Loc, Ctx, ElemSizeParam, NumElemsParam, 0);
756
    A->setImplicit(true);
757
    return A;
758
  }
759
760
  AllocSizeAttr(SourceRange R, ASTContext &Ctx
761
              , ParamIdx ElemSizeParam
762
              , ParamIdx NumElemsParam
763
              , unsigned SI
764
             )
765
    : InheritableAttr(attr::AllocSize, R, SI, false, false)
766
              , elemSizeParam(ElemSizeParam)
767
              , numElemsParam(NumElemsParam)
768
10.9k
  {
769
10.9k
  }
770
771
  AllocSizeAttr(SourceRange R, ASTContext &Ctx
772
              , ParamIdx ElemSizeParam
773
              , unsigned SI
774
             )
775
    : InheritableAttr(attr::AllocSize, R, SI, false, false)
776
              , elemSizeParam(ElemSizeParam)
777
              , numElemsParam()
778
  {
779
  }
780
781
  AllocSizeAttr *clone(ASTContext &C) const;
782
  void printPretty(raw_ostream &OS,
783
                   const PrintingPolicy &Policy) const;
784
  const char *getSpelling() const;
785
3.34k
  ParamIdx getElemSizeParam() const {
786
3.34k
    return elemSizeParam;
787
3.34k
  }
788
789
4.18k
  ParamIdx getNumElemsParam() const {
790
4.18k
    return numElemsParam;
791
4.18k
  }
792
793
794
795
535k
  static bool classof(const Attr *A) { return A->getKind() == attr::AllocSize; }
796
};
797
798
class AlwaysDestroyAttr : public InheritableAttr {
799
public:
800
  static AlwaysDestroyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
801
    auto *A = new (Ctx) AlwaysDestroyAttr(Loc, Ctx, 0);
802
    A->setImplicit(true);
803
    return A;
804
  }
805
806
  AlwaysDestroyAttr(SourceRange R, ASTContext &Ctx
807
              , unsigned SI
808
             )
809
    : InheritableAttr(attr::AlwaysDestroy, R, SI, false, false)
810
14
  {
811
14
  }
812
813
  AlwaysDestroyAttr *clone(ASTContext &C) const;
814
  void printPretty(raw_ostream &OS,
815
                   const PrintingPolicy &Policy) const;
816
  const char *getSpelling() const;
817
818
819
14
  static bool classof(const Attr *A) { return A->getKind() == attr::AlwaysDestroy; }
820
};
821
822
class AlwaysInlineAttr : public InheritableAttr {
823
public:
824
  enum Spelling {
825
    GNU_always_inline = 0,
826
    CXX11_gnu_always_inline = 1,
827
    Keyword_forceinline = 2
828
  };
829
830
84.0k
  static AlwaysInlineAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
831
84.0k
    auto *A = new (Ctx) AlwaysInlineAttr(Loc, Ctx, S);
832
84.0k
    A->setImplicit(true);
833
84.0k
    return A;
834
84.0k
  }
835
836
  AlwaysInlineAttr(SourceRange R, ASTContext &Ctx
837
              , unsigned SI
838
             )
839
    : InheritableAttr(attr::AlwaysInline, R, SI, false, false)
840
2.72M
  {
841
2.72M
  }
842
843
  AlwaysInlineAttr *clone(ASTContext &C) const;
844
  void printPretty(raw_ostream &OS,
845
                   const PrintingPolicy &Policy) const;
846
  const char *getSpelling() const;
847
  Spelling getSemanticSpelling() const {
848
  switch (SpellingListIndex) {
849
    default: llvm_unreachable("Unknown spelling list index");
850
    case 0: return GNU_always_inline;
851
    case 1: return CXX11_gnu_always_inline;
852
    case 2: return Keyword_forceinline;
853
  }
854
  }
855
856
857
1.93M
  static bool classof(const Attr *A) { return A->getKind() == attr::AlwaysInline; }
858
};
859
860
class AnalyzerNoReturnAttr : public InheritableAttr {
861
public:
862
  static AnalyzerNoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
863
    auto *A = new (Ctx) AnalyzerNoReturnAttr(Loc, Ctx, 0);
864
    A->setImplicit(true);
865
    return A;
866
  }
867
868
  AnalyzerNoReturnAttr(SourceRange R, ASTContext &Ctx
869
              , unsigned SI
870
             )
871
    : InheritableAttr(attr::AnalyzerNoReturn, R, SI, false, false)
872
6
  {
873
6
  }
874
875
  AnalyzerNoReturnAttr *clone(ASTContext &C) const;
876
  void printPretty(raw_ostream &OS,
877
                   const PrintingPolicy &Policy) const;
878
  const char *getSpelling() const;
879
880
881
202k
  static bool classof(const Attr *A) { return A->getKind() == attr::AnalyzerNoReturn; }
882
};
883
884
class AnnotateAttr : public InheritableParamAttr {
885
unsigned annotationLength;
886
char *annotation;
887
888
public:
889
  static AnnotateAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Annotation, SourceRange Loc = SourceRange()) {
890
    auto *A = new (Ctx) AnnotateAttr(Loc, Ctx, Annotation, 0);
891
    A->setImplicit(true);
892
    return A;
893
  }
894
895
  AnnotateAttr(SourceRange R, ASTContext &Ctx
896
              , llvm::StringRef Annotation
897
              , unsigned SI
898
             )
899
    : InheritableParamAttr(attr::Annotate, R, SI, false, false)
900
              , annotationLength(Annotation.size()),annotation(new (Ctx, 1) char[annotationLength])
901
324
  {
902
324
      if (!Annotation.empty())
903
324
        std::memcpy(annotation, Annotation.data(), annotationLength);
904
324
  }
905
906
  AnnotateAttr *clone(ASTContext &C) const;
907
  void printPretty(raw_ostream &OS,
908
                   const PrintingPolicy &Policy) const;
909
  const char *getSpelling() const;
910
704
  llvm::StringRef getAnnotation() const {
911
704
    return llvm::StringRef(annotation, annotationLength);
912
704
  }
913
  unsigned getAnnotationLength() const {
914
    return annotationLength;
915
  }
916
  void setAnnotation(ASTContext &C, llvm::StringRef S) {
917
    annotationLength = S.size();
918
    this->annotation = new (C, 1) char [annotationLength];
919
    if (!S.empty())
920
      std::memcpy(this->annotation, S.data(), annotationLength);
921
  }
922
923
924
925
405k
  static bool classof(const Attr *A) { return A->getKind() == attr::Annotate; }
926
};
927
928
class AnyX86InterruptAttr : public InheritableAttr {
929
public:
930
  static AnyX86InterruptAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
931
    auto *A = new (Ctx) AnyX86InterruptAttr(Loc, Ctx, 0);
932
    A->setImplicit(true);
933
    return A;
934
  }
935
936
  AnyX86InterruptAttr(SourceRange R, ASTContext &Ctx
937
              , unsigned SI
938
             )
939
    : InheritableAttr(attr::AnyX86Interrupt, R, SI, false, false)
940
59
  {
941
59
  }
942
943
  AnyX86InterruptAttr *clone(ASTContext &C) const;
944
  void printPretty(raw_ostream &OS,
945
                   const PrintingPolicy &Policy) const;
946
  const char *getSpelling() const;
947
948
949
4.04M
  static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86Interrupt; }
950
};
951
952
class AnyX86NoCallerSavedRegistersAttr : public InheritableAttr {
953
public:
954
  static AnyX86NoCallerSavedRegistersAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
955
    auto *A = new (Ctx) AnyX86NoCallerSavedRegistersAttr(Loc, Ctx, 0);
956
    A->setImplicit(true);
957
    return A;
958
  }
959
960
  AnyX86NoCallerSavedRegistersAttr(SourceRange R, ASTContext &Ctx
961
              , unsigned SI
962
             )
963
    : InheritableAttr(attr::AnyX86NoCallerSavedRegisters, R, SI, false, false)
964
25
  {
965
25
  }
966
967
  AnyX86NoCallerSavedRegistersAttr *clone(ASTContext &C) const;
968
  void printPretty(raw_ostream &OS,
969
                   const PrintingPolicy &Policy) const;
970
  const char *getSpelling() const;
971
972
973
527k
  static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86NoCallerSavedRegisters; }
974
};
975
976
class AnyX86NoCfCheckAttr : public InheritableAttr {
977
public:
978
  static AnyX86NoCfCheckAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
979
    auto *A = new (Ctx) AnyX86NoCfCheckAttr(Loc, Ctx, 0);
980
    A->setImplicit(true);
981
    return A;
982
  }
983
984
  AnyX86NoCfCheckAttr(SourceRange R, ASTContext &Ctx
985
              , unsigned SI
986
             )
987
    : InheritableAttr(attr::AnyX86NoCfCheck, R, SI, false, false)
988
10
  {
989
10
  }
990
991
  AnyX86NoCfCheckAttr *clone(ASTContext &C) const;
992
  void printPretty(raw_ostream &OS,
993
                   const PrintingPolicy &Policy) const;
994
  const char *getSpelling() const;
995
996
997
527k
  static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86NoCfCheck; }
998
};
999
1000
class ArcWeakrefUnavailableAttr : public InheritableAttr {
1001
public:
1002
  static ArcWeakrefUnavailableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1003
    auto *A = new (Ctx) ArcWeakrefUnavailableAttr(Loc, Ctx, 0);
1004
    A->setImplicit(true);
1005
    return A;
1006
  }
1007
1008
  ArcWeakrefUnavailableAttr(SourceRange R, ASTContext &Ctx
1009
              , unsigned SI
1010
             )
1011
    : InheritableAttr(attr::ArcWeakrefUnavailable, R, SI, false, false)
1012
63
  {
1013
63
  }
1014
1015
  ArcWeakrefUnavailableAttr *clone(ASTContext &C) const;
1016
  void printPretty(raw_ostream &OS,
1017
                   const PrintingPolicy &Policy) const;
1018
  const char *getSpelling() const;
1019
1020
1021
81
  static bool classof(const Attr *A) { return A->getKind() == attr::ArcWeakrefUnavailable; }
1022
};
1023
1024
class ArgumentWithTypeTagAttr : public InheritableAttr {
1025
IdentifierInfo * argumentKind;
1026
1027
ParamIdx argumentIdx;
1028
1029
ParamIdx typeTagIdx;
1030
1031
bool isPointer;
1032
1033
public:
1034
  enum Spelling {
1035
    GNU_argument_with_type_tag = 0,
1036
    CXX11_clang_argument_with_type_tag = 1,
1037
    C2x_clang_argument_with_type_tag = 2,
1038
    GNU_pointer_with_type_tag = 3,
1039
    CXX11_clang_pointer_with_type_tag = 4,
1040
    C2x_clang_pointer_with_type_tag = 5
1041
  };
1042
1043
  static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, ParamIdx ArgumentIdx, ParamIdx TypeTagIdx, bool IsPointer, SourceRange Loc = SourceRange()) {
1044
    auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, IsPointer, S);
1045
    A->setImplicit(true);
1046
    return A;
1047
  }
1048
1049
  static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, ParamIdx ArgumentIdx, ParamIdx TypeTagIdx, SourceRange Loc = SourceRange()) {
1050
    auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, S);
1051
    A->setImplicit(true);
1052
    return A;
1053
  }
1054
1055
  ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx
1056
              , IdentifierInfo * ArgumentKind
1057
              , ParamIdx ArgumentIdx
1058
              , ParamIdx TypeTagIdx
1059
              , bool IsPointer
1060
              , unsigned SI
1061
             )
1062
    : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false)
1063
              , argumentKind(ArgumentKind)
1064
              , argumentIdx(ArgumentIdx)
1065
              , typeTagIdx(TypeTagIdx)
1066
              , isPointer(IsPointer)
1067
73
  {
1068
73
  }
1069
1070
  ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx
1071
              , IdentifierInfo * ArgumentKind
1072
              , ParamIdx ArgumentIdx
1073
              , ParamIdx TypeTagIdx
1074
              , unsigned SI
1075
             )
1076
    : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false)
1077
              , argumentKind(ArgumentKind)
1078
              , argumentIdx(ArgumentIdx)
1079
              , typeTagIdx(TypeTagIdx)
1080
              , isPointer()
1081
  {
1082
  }
1083
1084
  ArgumentWithTypeTagAttr *clone(ASTContext &C) const;
1085
  void printPretty(raw_ostream &OS,
1086
                   const PrintingPolicy &Policy) const;
1087
  const char *getSpelling() const;
1088
  Spelling getSemanticSpelling() const {
1089
  switch (SpellingListIndex) {
1090
    default: llvm_unreachable("Unknown spelling list index");
1091
    case 0: return GNU_argument_with_type_tag;
1092
    case 1: return CXX11_clang_argument_with_type_tag;
1093
    case 2: return C2x_clang_argument_with_type_tag;
1094
    case 3: return GNU_pointer_with_type_tag;
1095
    case 4: return CXX11_clang_pointer_with_type_tag;
1096
    case 5: return C2x_clang_pointer_with_type_tag;
1097
  }
1098
  }
1099
430
  IdentifierInfo * getArgumentKind() const {
1100
430
    return argumentKind;
1101
430
  }
1102
1103
389
  ParamIdx getArgumentIdx() const {
1104
389
    return argumentIdx;
1105
389
  }
1106
1107
423
  ParamIdx getTypeTagIdx() const {
1108
423
    return typeTagIdx;
1109
423
  }
1110
1111
411
  bool getIsPointer() const {
1112
411
    return isPointer;
1113
411
  }
1114
1115
1116
1117
3.87M
  static bool classof(const Attr *A) { return A->getKind() == attr::ArgumentWithTypeTag; }
1118
};
1119
1120
class ArtificialAttr : public InheritableAttr {
1121
public:
1122
  static ArtificialAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1123
    auto *A = new (Ctx) ArtificialAttr(Loc, Ctx, 0);
1124
    A->setImplicit(true);
1125
    return A;
1126
  }
1127
1128
  ArtificialAttr(SourceRange R, ASTContext &Ctx
1129
              , unsigned SI
1130
             )
1131
    : InheritableAttr(attr::Artificial, R, SI, false, false)
1132
36
  {
1133
36
  }
1134
1135
  ArtificialAttr *clone(ASTContext &C) const;
1136
  void printPretty(raw_ostream &OS,
1137
                   const PrintingPolicy &Policy) const;
1138
  const char *getSpelling() const;
1139
1140
1141
34.7k
  static bool classof(const Attr *A) { return A->getKind() == attr::Artificial; }
1142
};
1143
1144
class AsmLabelAttr : public InheritableAttr {
1145
unsigned labelLength;
1146
char *label;
1147
1148
public:
1149
9
  static AsmLabelAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Label, SourceRange Loc = SourceRange()) {
1150
9
    auto *A = new (Ctx) AsmLabelAttr(Loc, Ctx, Label, 0);
1151
9
    A->setImplicit(true);
1152
9
    return A;
1153
9
  }
1154
1155
  AsmLabelAttr(SourceRange R, ASTContext &Ctx
1156
              , llvm::StringRef Label
1157
              , unsigned SI
1158
             )
1159
    : InheritableAttr(attr::AsmLabel, R, SI, false, false)
1160
              , labelLength(Label.size()),label(new (Ctx, 1) char[labelLength])
1161
92.9k
  {
1162
92.9k
      if (!Label.empty())
1163
92.9k
        std::memcpy(label, Label.data(), labelLength);
1164
92.9k
  }
1165
1166
  AsmLabelAttr *clone(ASTContext &C) const;
1167
  void printPretty(raw_ostream &OS,
1168
                   const PrintingPolicy &Policy) const;
1169
  const char *getSpelling() const;
1170
5.87k
  llvm::StringRef getLabel() const {
1171
5.87k
    return llvm::StringRef(label, labelLength);
1172
5.87k
  }
1173
  unsigned getLabelLength() const {
1174
    return labelLength;
1175
  }
1176
  void setLabel(ASTContext &C, llvm::StringRef S) {
1177
    labelLength = S.size();
1178
    this->label = new (C, 1) char [labelLength];
1179
    if (!S.empty())
1180
      std::memcpy(this->label, S.data(), labelLength);
1181
  }
1182
1183
1184
1185
4.94M
  static bool classof(const Attr *A) { return A->getKind() == attr::AsmLabel; }
1186
};
1187
1188
class AssertCapabilityAttr : public InheritableAttr {
1189
  unsigned args_Size;
1190
  Expr * *args_;
1191
1192
public:
1193
  enum Spelling {
1194
    GNU_assert_capability = 0,
1195
    CXX11_clang_assert_capability = 1,
1196
    GNU_assert_shared_capability = 2,
1197
    CXX11_clang_assert_shared_capability = 3
1198
  };
1199
1200
  static AssertCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1201
    auto *A = new (Ctx) AssertCapabilityAttr(Loc, Ctx, Args, ArgsSize, S);
1202
    A->setImplicit(true);
1203
    return A;
1204
  }
1205
1206
  AssertCapabilityAttr(SourceRange R, ASTContext &Ctx
1207
              , Expr * *Args, unsigned ArgsSize
1208
              , unsigned SI
1209
             )
1210
    : InheritableAttr(attr::AssertCapability, R, SI, true, true)
1211
              , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1212
42
  {
1213
42
    std::copy(Args, Args + args_Size, args_);
1214
42
  }
1215
1216
  AssertCapabilityAttr(SourceRange R, ASTContext &Ctx
1217
              , unsigned SI
1218
             )
1219
    : InheritableAttr(attr::AssertCapability, R, SI, true, true)
1220
              , args_Size(0), args_(nullptr)
1221
  {
1222
  }
1223
1224
  AssertCapabilityAttr *clone(ASTContext &C) const;
1225
  void printPretty(raw_ostream &OS,
1226
                   const PrintingPolicy &Policy) const;
1227
  const char *getSpelling() const;
1228
  Spelling getSemanticSpelling() const {
1229
  switch (SpellingListIndex) {
1230
    default: llvm_unreachable("Unknown spelling list index");
1231
    case 0: return GNU_assert_capability;
1232
    case 1: return CXX11_clang_assert_capability;
1233
    case 2: return GNU_assert_shared_capability;
1234
    case 3: return CXX11_clang_assert_shared_capability;
1235
  }
1236
  }
1237
44
  bool isShared() const { return SpellingListIndex == 2 ||
1238
44
    
SpellingListIndex == 334
; }
1239
  typedef Expr ** args_iterator;
1240
58
  args_iterator args_begin() const { return args_; }
1241
58
  args_iterator args_end() const { return args_ + args_Size; }
1242
40
  unsigned args_size() const { return args_Size; }
1243
58
  llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1244
1245
1246
1247
1248
  static bool classof(const Attr *A) { return A->getKind() == attr::AssertCapability; }
1249
};
1250
1251
class AssertExclusiveLockAttr : public InheritableAttr {
1252
  unsigned args_Size;
1253
  Expr * *args_;
1254
1255
public:
1256
  static AssertExclusiveLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1257
    auto *A = new (Ctx) AssertExclusiveLockAttr(Loc, Ctx, Args, ArgsSize, 0);
1258
    A->setImplicit(true);
1259
    return A;
1260
  }
1261
1262
  AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx
1263
              , Expr * *Args, unsigned ArgsSize
1264
              , unsigned SI
1265
             )
1266
    : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true)
1267
              , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1268
21
  {
1269
21
    std::copy(Args, Args + args_Size, args_);
1270
21
  }
1271
1272
  AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx
1273
              , unsigned SI
1274
             )
1275
    : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true)
1276
              , args_Size(0), args_(nullptr)
1277
  {
1278
  }
1279
1280
  AssertExclusiveLockAttr *clone(ASTContext &C) const;
1281
  void printPretty(raw_ostream &OS,
1282
                   const PrintingPolicy &Policy) const;
1283
  const char *getSpelling() const;
1284
  typedef Expr ** args_iterator;
1285
42
  args_iterator args_begin() const { return args_; }
1286
42
  args_iterator args_end() const { return args_ + args_Size; }
1287
32
  unsigned args_size() const { return args_Size; }
1288
42
  llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1289
1290
1291
1292
1293
  static bool classof(const Attr *A) { return A->getKind() == attr::AssertExclusiveLock; }
1294
};
1295
1296
class AssertSharedLockAttr : public InheritableAttr {
1297
  unsigned args_Size;
1298
  Expr * *args_;
1299
1300
public:
1301
  static AssertSharedLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1302
    auto *A = new (Ctx) AssertSharedLockAttr(Loc, Ctx, Args, ArgsSize, 0);
1303
    A->setImplicit(true);
1304
    return A;
1305
  }
1306
1307
  AssertSharedLockAttr(SourceRange R, ASTContext &Ctx
1308
              , Expr * *Args, unsigned ArgsSize
1309
              , unsigned SI
1310
             )
1311
    : InheritableAttr(attr::AssertSharedLock, R, SI, true, true)
1312
              , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1313
19
  {
1314
19
    std::copy(Args, Args + args_Size, args_);
1315
19
  }
1316
1317
  AssertSharedLockAttr(SourceRange R, ASTContext &Ctx
1318
              , unsigned SI
1319
             )
1320
    : InheritableAttr(attr::AssertSharedLock, R, SI, true, true)
1321
              , args_Size(0), args_(nullptr)
1322
  {
1323
  }
1324
1325
  AssertSharedLockAttr *clone(ASTContext &C) const;
1326
  void printPretty(raw_ostream &OS,
1327
                   const PrintingPolicy &Policy) const;
1328
  const char *getSpelling() const;
1329
  typedef Expr ** args_iterator;
1330
16
  args_iterator args_begin() const { return args_; }
1331
16
  args_iterator args_end() const { return args_ + args_Size; }
1332
8
  unsigned args_size() const { return args_Size; }
1333
16
  llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1334
1335
1336
1337
1338
  static bool classof(const Attr *A) { return A->getKind() == attr::AssertSharedLock; }
1339
};
1340
1341
class AssumeAlignedAttr : public InheritableAttr {
1342
Expr * alignment;
1343
1344
Expr * offset;
1345
1346
public:
1347
  static AssumeAlignedAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, Expr * Offset, SourceRange Loc = SourceRange()) {
1348
    auto *A = new (Ctx) AssumeAlignedAttr(Loc, Ctx, Alignment, Offset, 0);
1349
    A->setImplicit(true);
1350
    return A;
1351
  }
1352
1353
  AssumeAlignedAttr(SourceRange R, ASTContext &Ctx
1354
              , Expr * Alignment
1355
              , Expr * Offset
1356
              , unsigned SI
1357
             )
1358
    : InheritableAttr(attr::AssumeAligned, R, SI, false, false)
1359
              , alignment(Alignment)
1360
              , offset(Offset)
1361
46
  {
1362
46
  }
1363
1364
  AssumeAlignedAttr(SourceRange R, ASTContext &Ctx
1365
              , Expr * Alignment
1366
              , unsigned SI
1367
             )
1368
    : InheritableAttr(attr::AssumeAligned, R, SI, false, false)
1369
              , alignment(Alignment)
1370
              , offset()
1371
  {
1372
  }
1373
1374
  AssumeAlignedAttr *clone(ASTContext &C) const;
1375
  void printPretty(raw_ostream &OS,
1376
                   const PrintingPolicy &Policy) const;
1377
  const char *getSpelling() const;
1378
12
  Expr * getAlignment() const {
1379
12
    return alignment;
1380
12
  }
1381
1382
13
  Expr * getOffset() const {
1383
13
    return offset;
1384
13
  }
1385
1386
1387
1388
2.51M
  static bool classof(const Attr *A) { return A->getKind() == attr::AssumeAligned; }
1389
};
1390
1391
class AvailabilityAttr : public InheritableAttr {
1392
IdentifierInfo * platform;
1393
1394
VersionTuple introduced;
1395
1396
1397
VersionTuple deprecated;
1398
1399
1400
VersionTuple obsoleted;
1401
1402
1403
bool unavailable;
1404
1405
unsigned messageLength;
1406
char *message;
1407
1408
bool strict;
1409
1410
unsigned replacementLength;
1411
char *replacement;
1412
1413
public:
1414
  static AvailabilityAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool Unavailable, llvm::StringRef Message, bool Strict, llvm::StringRef Replacement, SourceRange Loc = SourceRange()) {
1415
    auto *A = new (Ctx) AvailabilityAttr(Loc, Ctx, Platform, Introduced, Deprecated, Obsoleted, Unavailable, Message, Strict, Replacement, 0);
1416
    A->setImplicit(true);
1417
    return A;
1418
  }
1419
1420
  AvailabilityAttr(SourceRange R, ASTContext &Ctx
1421
              , IdentifierInfo * Platform
1422
              , VersionTuple Introduced
1423
              , VersionTuple Deprecated
1424
              , VersionTuple Obsoleted
1425
              , bool Unavailable
1426
              , llvm::StringRef Message
1427
              , bool Strict
1428
              , llvm::StringRef Replacement
1429
              , unsigned SI
1430
             )
1431
    : InheritableAttr(attr::Availability, R, SI, false, true)
1432
              , platform(Platform)
1433
              , introduced(Introduced)
1434
              , deprecated(Deprecated)
1435
              , obsoleted(Obsoleted)
1436
              , unavailable(Unavailable)
1437
              , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
1438
              , strict(Strict)
1439
              , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength])
1440
659k
  {
1441
659k
      if (!Message.empty())
1442
37.0k
        std::memcpy(message, Message.data(), messageLength);
1443
659k
      if (!Replacement.empty())
1444
428
        std::memcpy(replacement, Replacement.data(), replacementLength);
1445
659k
  }
1446
1447
  AvailabilityAttr *clone(ASTContext &C) const;
1448
  void printPretty(raw_ostream &OS,
1449
                   const PrintingPolicy &Policy) const;
1450
  const char *getSpelling() const;
1451
1.01M
  IdentifierInfo * getPlatform() const {
1452
1.01M
    return platform;
1453
1.01M
  }
1454
1455
187k
  VersionTuple getIntroduced() const {
1456
187k
    return introduced;
1457
187k
  }
1458
  void setIntroduced(ASTContext &C, VersionTuple V) {
1459
    introduced = V;
1460
  }
1461
1462
124k
  VersionTuple getDeprecated() const {
1463
124k
    return deprecated;
1464
124k
  }
1465
  void setDeprecated(ASTContext &C, VersionTuple V) {
1466
    deprecated = V;
1467
  }
1468
1469
118k
  VersionTuple getObsoleted() const {
1470
118k
    return obsoleted;
1471
118k
  }
1472
  void setObsoleted(ASTContext &C, VersionTuple V) {
1473
    obsoleted = V;
1474
  }
1475
1476
98.3k
  bool getUnavailable() const {
1477
98.3k
    return unavailable;
1478
98.3k
  }
1479
1480
105k
  llvm::StringRef getMessage() const {
1481
105k
    return llvm::StringRef(message, messageLength);
1482
105k
  }
1483
  unsigned getMessageLength() const {
1484
    return messageLength;
1485
  }
1486
  void setMessage(ASTContext &C, llvm::StringRef S) {
1487
    messageLength = S.size();
1488
    this->message = new (C, 1) char [messageLength];
1489
    if (!S.empty())
1490
      std::memcpy(this->message, S.data(), messageLength);
1491
  }
1492
1493
10.6k
  bool getStrict() const {
1494
10.6k
    return strict;
1495
10.6k
  }
1496
1497
31.0k
  llvm::StringRef getReplacement() const {
1498
31.0k
    return llvm::StringRef(replacement, replacementLength);
1499
31.0k
  }
1500
  unsigned getReplacementLength() const {
1501
    return replacementLength;
1502
  }
1503
  void setReplacement(ASTContext &C, llvm::StringRef S) {
1504
    replacementLength = S.size();
1505
    this->replacement = new (C, 1) char [replacementLength];
1506
    if (!S.empty())
1507
      std::memcpy(this->replacement, S.data(), replacementLength);
1508
  }
1509
1510
1.36M
static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
1511
1.36M
    return llvm::StringSwitch<llvm::StringRef>(Platform)
1512
1.36M
             .Case("android", "Android")
1513
1.36M
             .Case("ios", "iOS")
1514
1.36M
             .Case("macos", "macOS")
1515
1.36M
             .Case("tvos", "tvOS")
1516
1.36M
             .Case("watchos", "watchOS")
1517
1.36M
             .Case("ios_app_extension", "iOS (App Extension)")
1518
1.36M
             .Case("macos_app_extension", "macOS (App Extension)")
1519
1.36M
             .Case("tvos_app_extension", "tvOS (App Extension)")
1520
1.36M
             .Case("watchos_app_extension", "watchOS (App Extension)")
1521
1.36M
             .Default(llvm::StringRef());
1522
1.36M
}
1523
408
static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
1524
408
    return llvm::StringSwitch<llvm::StringRef>(Platform)
1525
408
             .Case("ios", "iOS")
1526
408
             .Case("macos", "macOS")
1527
408
             .Case("tvos", "tvOS")
1528
408
             .Case("watchos", "watchOS")
1529
408
             .Case("ios_app_extension", "iOSApplicationExtension")
1530
408
             .Case("macos_app_extension", "macOSApplicationExtension")
1531
408
             .Case("tvos_app_extension", "tvOSApplicationExtension")
1532
408
             .Case("watchos_app_extension", "watchOSApplicationExtension")
1533
408
             .Default(Platform);
1534
408
}
1535
572k
static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
1536
572k
    return llvm::StringSwitch<llvm::StringRef>(Platform)
1537
572k
             .Case("iOS", "ios")
1538
572k
             .Case("macOS", "macos")
1539
572k
             .Case("tvOS", "tvos")
1540
572k
             .Case("watchOS", "watchos")
1541
572k
             .Case("iOSApplicationExtension", "ios_app_extension")
1542
572k
             .Case("macOSApplicationExtension", "macos_app_extension")
1543
572k
             .Case("tvOSApplicationExtension", "tvos_app_extension")
1544
572k
             .Case("watchOSApplicationExtension", "watchos_app_extension")
1545
572k
             .Default(Platform);
1546
572k
} 
1547
1548
13.8M
  static bool classof(const Attr *A) { return A->getKind() == attr::Availability; }
1549
};
1550
1551
class BlocksAttr : public InheritableAttr {
1552
public:
1553
  enum BlockType {
1554
    ByRef
1555
  };
1556
private:
1557
  BlockType type;
1558
1559
public:
1560
  static BlocksAttr *CreateImplicit(ASTContext &Ctx, BlockType Type, SourceRange Loc = SourceRange()) {
1561
    auto *A = new (Ctx) BlocksAttr(Loc, Ctx, Type, 0);
1562
    A->setImplicit(true);
1563
    return A;
1564
  }
1565
1566
  BlocksAttr(SourceRange R, ASTContext &Ctx
1567
              , BlockType Type
1568
              , unsigned SI
1569
             )
1570
    : InheritableAttr(attr::Blocks, R, SI, false, false)
1571
              , type(Type)
1572
521
  {
1573
521
  }
1574
1575
  BlocksAttr *clone(ASTContext &C) const;
1576
  void printPretty(raw_ostream &OS,
1577
                   const PrintingPolicy &Policy) const;
1578
  const char *getSpelling() const;
1579
7
  BlockType getType() const {
1580
7
    return type;
1581
7
  }
1582
1583
513
  static bool ConvertStrToBlockType(StringRef Val, BlockType &Out) {
1584
513
    Optional<BlockType> R = llvm::StringSwitch<Optional<BlockType>>(Val)
1585
513
      .Case("byref", BlocksAttr::ByRef)
1586
513
      .Default(Optional<BlockType>());
1587
513
    if (R) {
1588
513
      Out = *R;
1589
513
      return true;
1590
513
    }
1591
0
    return false;
1592
0
  }
1593
1594
2
  static const char *ConvertBlockTypeToStr(BlockType Val) {
1595
2
    switch(Val) {
1596
2
    case BlocksAttr::ByRef: return "byref";
1597
0
    }
1598
0
    llvm_unreachable("No enumerator with that value");
1599
0
  }
1600
1601
1602
358k
  static bool classof(const Attr *A) { return A->getKind() == attr::Blocks; }
1603
};
1604
1605
class C11NoReturnAttr : public InheritableAttr {
1606
public:
1607
  static C11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1608
    auto *A = new (Ctx) C11NoReturnAttr(Loc, Ctx, 0);
1609
    A->setImplicit(true);
1610
    return A;
1611
  }
1612
1613
  C11NoReturnAttr(SourceRange R, ASTContext &Ctx
1614
              , unsigned SI
1615
             )
1616
    : InheritableAttr(attr::C11NoReturn, R, SI, false, false)
1617
37
  {
1618
37
  }
1619
1620
  C11NoReturnAttr *clone(ASTContext &C) const;
1621
  void printPretty(raw_ostream &OS,
1622
                   const PrintingPolicy &Policy) const;
1623
  const char *getSpelling() const;
1624
1625
1626
5.11M
  static bool classof(const Attr *A) { return A->getKind() == attr::C11NoReturn; }
1627
};
1628
1629
class CDeclAttr : public InheritableAttr {
1630
public:
1631
  static CDeclAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1632
    auto *A = new (Ctx) CDeclAttr(Loc, Ctx, 0);
1633
    A->setImplicit(true);
1634
    return A;
1635
  }
1636
1637
  CDeclAttr(SourceRange R, ASTContext &Ctx
1638
              , unsigned SI
1639
             )
1640
    : InheritableAttr(attr::CDecl, R, SI, false, false)
1641
367
  {
1642
367
  }
1643
1644
  CDeclAttr *clone(ASTContext &C) const;
1645
  void printPretty(raw_ostream &OS,
1646
                   const PrintingPolicy &Policy) const;
1647
  const char *getSpelling() const;
1648
1649
1650
  static bool classof(const Attr *A) { return A->getKind() == attr::CDecl; }
1651
};
1652
1653
class CFAuditedTransferAttr : public InheritableAttr {
1654
public:
1655
25.0k
  static CFAuditedTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1656
25.0k
    auto *A = new (Ctx) CFAuditedTransferAttr(Loc, Ctx, 0);
1657
25.0k
    A->setImplicit(true);
1658
25.0k
    return A;
1659
25.0k
  }
1660
1661
  CFAuditedTransferAttr(SourceRange R, ASTContext &Ctx
1662
              , unsigned SI
1663
             )
1664
    : InheritableAttr(attr::CFAuditedTransfer, R, SI, false, false)
1665
25.0k
  {
1666
25.0k
  }
1667
1668
  CFAuditedTransferAttr *clone(ASTContext &C) const;
1669
  void printPretty(raw_ostream &OS,
1670
                   const PrintingPolicy &Policy) const;
1671
  const char *getSpelling() const;
1672
1673
1674
16.2k
  static bool classof(const Attr *A) { return A->getKind() == attr::CFAuditedTransfer; }
1675
};
1676
1677
class CFConsumedAttr : public InheritableParamAttr {
1678
public:
1679
  static CFConsumedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1680
    auto *A = new (Ctx) CFConsumedAttr(Loc, Ctx, 0);
1681
    A->setImplicit(true);
1682
    return A;
1683
  }
1684
1685
  CFConsumedAttr(SourceRange R, ASTContext &Ctx
1686
              , unsigned SI
1687
             )
1688
    : InheritableParamAttr(attr::CFConsumed, R, SI, false, false)
1689
434
  {
1690
434
  }
1691
1692
  CFConsumedAttr *clone(ASTContext &C) const;
1693
  void printPretty(raw_ostream &OS,
1694
                   const PrintingPolicy &Policy) const;
1695
  const char *getSpelling() const;
1696
1697
1698
2.15M
  static bool classof(const Attr *A) { return A->getKind() == attr::CFConsumed; }
1699
};
1700
1701
class CFReturnsNotRetainedAttr : public InheritableAttr {
1702
public:
1703
  static CFReturnsNotRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1704
    auto *A = new (Ctx) CFReturnsNotRetainedAttr(Loc, Ctx, 0);
1705
    A->setImplicit(true);
1706
    return A;
1707
  }
1708
1709
  CFReturnsNotRetainedAttr(SourceRange R, ASTContext &Ctx
1710
              , unsigned SI
1711
             )
1712
    : InheritableAttr(attr::CFReturnsNotRetained, R, SI, false, false)
1713
77
  {
1714
77
  }
1715
1716
  CFReturnsNotRetainedAttr *clone(ASTContext &C) const;
1717
  void printPretty(raw_ostream &OS,
1718
                   const PrintingPolicy &Policy) const;
1719
  const char *getSpelling() const;
1720
1721
1722
132
  static bool classof(const Attr *A) { return A->getKind() == attr::CFReturnsNotRetained; }
1723
};
1724
1725
class CFReturnsRetainedAttr : public InheritableAttr {
1726
public:
1727
  static CFReturnsRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1728
    auto *A = new (Ctx) CFReturnsRetainedAttr(Loc, Ctx, 0);
1729
    A->setImplicit(true);
1730
    return A;
1731
  }
1732
1733
  CFReturnsRetainedAttr(SourceRange R, ASTContext &Ctx
1734
              , unsigned SI
1735
             )
1736
    : InheritableAttr(attr::CFReturnsRetained, R, SI, false, false)
1737
518
  {
1738
518
  }
1739
1740
  CFReturnsRetainedAttr *clone(ASTContext &C) const;
1741
  void printPretty(raw_ostream &OS,
1742
                   const PrintingPolicy &Policy) const;
1743
  const char *getSpelling() const;
1744
1745
1746
174
  static bool classof(const Attr *A) { return A->getKind() == attr::CFReturnsRetained; }
1747
};
1748
1749
class CFUnknownTransferAttr : public InheritableAttr {
1750
public:
1751
  static CFUnknownTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1752
    auto *A = new (Ctx) CFUnknownTransferAttr(Loc, Ctx, 0);
1753
    A->setImplicit(true);
1754
    return A;
1755
  }
1756
1757
  CFUnknownTransferAttr(SourceRange R, ASTContext &Ctx
1758
              , unsigned SI
1759
             )
1760
    : InheritableAttr(attr::CFUnknownTransfer, R, SI, false, false)
1761
1
  {
1762
1
  }
1763
1764
  CFUnknownTransferAttr *clone(ASTContext &C) const;
1765
  void printPretty(raw_ostream &OS,
1766
                   const PrintingPolicy &Policy) const;
1767
  const char *getSpelling() const;
1768
1769
1770
15.8k
  static bool classof(const Attr *A) { return A->getKind() == attr::CFUnknownTransfer; }
1771
};
1772
1773
class CPUDispatchAttr : public InheritableAttr {
1774
  unsigned cpus_Size;
1775
  IdentifierInfo * *cpus_;
1776
1777
public:
1778
  static CPUDispatchAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * *Cpus, unsigned CpusSize, SourceRange Loc = SourceRange()) {
1779
    auto *A = new (Ctx) CPUDispatchAttr(Loc, Ctx, Cpus, CpusSize, 0);
1780
    A->setImplicit(true);
1781
    return A;
1782
  }
1783
1784
  CPUDispatchAttr(SourceRange R, ASTContext &Ctx
1785
              , IdentifierInfo * *Cpus, unsigned CpusSize
1786
              , unsigned SI
1787
             )
1788
    : InheritableAttr(attr::CPUDispatch, R, SI, false, false)
1789
              , cpus_Size(CpusSize), cpus_(new (Ctx, 16) IdentifierInfo *[cpus_Size])
1790
17
  {
1791
17
    std::copy(Cpus, Cpus + cpus_Size, cpus_);
1792
17
  }
1793
1794
  CPUDispatchAttr(SourceRange R, ASTContext &Ctx
1795
              , unsigned SI
1796
             )
1797
    : InheritableAttr(attr::CPUDispatch, R, SI, false, false)
1798
              , cpus_Size(0), cpus_(nullptr)
1799
  {
1800
  }
1801
1802
  CPUDispatchAttr *clone(ASTContext &C) const;
1803
  void printPretty(raw_ostream &OS,
1804
                   const PrintingPolicy &Policy) const;
1805
  const char *getSpelling() const;
1806
  typedef IdentifierInfo ** cpus_iterator;
1807
11
  cpus_iterator cpus_begin() const { return cpus_; }
1808
8
  cpus_iterator cpus_end() const { return cpus_ + cpus_Size; }
1809
6
  unsigned cpus_size() const { return cpus_Size; }
1810
5
  llvm::iterator_range<cpus_iterator> cpus() const { return llvm::make_range(cpus_begin(), cpus_end()); }
1811
1812
1813
1814
1815
15.7M
  static bool classof(const Attr *A) { return A->getKind() == attr::CPUDispatch; }
1816
};
1817
1818
class CPUSpecificAttr : public InheritableAttr {
1819
  unsigned cpus_Size;
1820
  IdentifierInfo * *cpus_;
1821
1822
public:
1823
  static CPUSpecificAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * *Cpus, unsigned CpusSize, SourceRange Loc = SourceRange()) {
1824
    auto *A = new (Ctx) CPUSpecificAttr(Loc, Ctx, Cpus, CpusSize, 0);
1825
    A->setImplicit(true);
1826
    return A;
1827
  }
1828
1829
  CPUSpecificAttr(SourceRange R, ASTContext &Ctx
1830
              , IdentifierInfo * *Cpus, unsigned CpusSize
1831
              , unsigned SI
1832
             )
1833
    : InheritableAttr(attr::CPUSpecific, R, SI, false, false)
1834
              , cpus_Size(CpusSize), cpus_(new (Ctx, 16) IdentifierInfo *[cpus_Size])
1835
55
  {
1836
55
    std::copy(Cpus, Cpus + cpus_Size, cpus_);
1837
55
  }
1838
1839
  CPUSpecificAttr(SourceRange R, ASTContext &Ctx
1840
              , unsigned SI
1841
             )
1842
    : InheritableAttr(attr::CPUSpecific, R, SI, false, false)
1843
              , cpus_Size(0), cpus_(nullptr)
1844
  {
1845
  }
1846
1847
  CPUSpecificAttr *clone(ASTContext &C) const;
1848
  void printPretty(raw_ostream &OS,
1849
                   const PrintingPolicy &Policy) const;
1850
  const char *getSpelling() const;
1851
  typedef IdentifierInfo ** cpus_iterator;
1852
103
  cpus_iterator cpus_begin() const { return cpus_; }
1853
53
  cpus_iterator cpus_end() const { return cpus_ + cpus_Size; }
1854
63
  unsigned cpus_size() const { return cpus_Size; }
1855
28
  llvm::iterator_range<cpus_iterator> cpus() const { return llvm::make_range(cpus_begin(), cpus_end()); }
1856
1857
1858
1859
    unsigned ActiveArgIndex = 0;
1860
1861
25
    IdentifierInfo *getCurCPUName() const {
1862
25
      return *(cpus_begin() + ActiveArgIndex);
1863
25
    }
1864
  
1865
1866
11.5M
  static bool classof(const Attr *A) { return A->getKind() == attr::CPUSpecific; }
1867
};
1868
1869
class CUDAConstantAttr : public InheritableAttr {
1870
public:
1871
  static CUDAConstantAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1872
    auto *A = new (Ctx) CUDAConstantAttr(Loc, Ctx, 0);
1873
    A->setImplicit(true);
1874
    return A;
1875
  }
1876
1877
  CUDAConstantAttr(SourceRange R, ASTContext &Ctx
1878
              , unsigned SI
1879
             )
1880
    : InheritableAttr(attr::CUDAConstant, R, SI, false, false)
1881
113
  {
1882
113
  }
1883
1884
  CUDAConstantAttr *clone(ASTContext &C) const;
1885
  void printPretty(raw_ostream &OS,
1886
                   const PrintingPolicy &Policy) const;
1887
  const char *getSpelling() const;
1888
1889
1890
763
  static bool classof(const Attr *A) { return A->getKind() == attr::CUDAConstant; }
1891
};
1892
1893
class CUDADeviceAttr : public InheritableAttr {
1894
public:
1895
2.91k
  static CUDADeviceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1896
2.91k
    auto *A = new (Ctx) CUDADeviceAttr(Loc, Ctx, 0);
1897
2.91k
    A->setImplicit(true);
1898
2.91k
    return A;
1899
2.91k
  }
1900
1901
  CUDADeviceAttr(SourceRange R, ASTContext &Ctx
1902
              , unsigned SI
1903
             )
1904
    : InheritableAttr(attr::CUDADevice, R, SI, false, false)
1905
4.34k
  {
1906
4.34k
  }
1907
1908
  CUDADeviceAttr *clone(ASTContext &C) const;
1909
  void printPretty(raw_ostream &OS,
1910
                   const PrintingPolicy &Policy) const;
1911
  const char *getSpelling() const;
1912
1913
1914
37.4k
  static bool classof(const Attr *A) { return A->getKind() == attr::CUDADevice; }
1915
};
1916
1917
class CUDAGlobalAttr : public InheritableAttr {
1918
public:
1919
  static CUDAGlobalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1920
    auto *A = new (Ctx) CUDAGlobalAttr(Loc, Ctx, 0);
1921
    A->setImplicit(true);
1922
    return A;
1923
  }
1924
1925
  CUDAGlobalAttr(SourceRange R, ASTContext &Ctx
1926
              , unsigned SI
1927
             )
1928
    : InheritableAttr(attr::CUDAGlobal, R, SI, false, false)
1929
159
  {
1930
159
  }
1931
1932
  CUDAGlobalAttr *clone(ASTContext &C) const;
1933
  void printPretty(raw_ostream &OS,
1934
                   const PrintingPolicy &Policy) const;
1935
  const char *getSpelling() const;
1936
1937
1938
6.89M
  static bool classof(const Attr *A) { return A->getKind() == attr::CUDAGlobal; }
1939
};
1940
1941
class CUDAHostAttr : public InheritableAttr {
1942
public:
1943
1.93k
  static CUDAHostAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1944
1.93k
    auto *A = new (Ctx) CUDAHostAttr(Loc, Ctx, 0);
1945
1.93k
    A->setImplicit(true);
1946
1.93k
    return A;
1947
1.93k
  }
1948
1949
  CUDAHostAttr(SourceRange R, ASTContext &Ctx
1950
              , unsigned SI
1951
             )
1952
    : InheritableAttr(attr::CUDAHost, R, SI, false, false)
1953
2.64k
  {
1954
2.64k
  }
1955
1956
  CUDAHostAttr *clone(ASTContext &C) const;
1957
  void printPretty(raw_ostream &OS,
1958
                   const PrintingPolicy &Policy) const;
1959
  const char *getSpelling() const;
1960
1961
1962
39.1k
  static bool classof(const Attr *A) { return A->getKind() == attr::CUDAHost; }
1963
};
1964
1965
class CUDAInvalidTargetAttr : public InheritableAttr {
1966
public:
1967
15
  static CUDAInvalidTargetAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1968
15
    auto *A = new (Ctx) CUDAInvalidTargetAttr(Loc, Ctx, 0);
1969
15
    A->setImplicit(true);
1970
15
    return A;
1971
15
  }
1972
1973
  CUDAInvalidTargetAttr(SourceRange R, ASTContext &Ctx
1974
              , unsigned SI
1975
             )
1976
    : InheritableAttr(attr::CUDAInvalidTarget, R, SI, false, false)
1977
15
  {
1978
15
  }
1979
1980
  CUDAInvalidTargetAttr *clone(ASTContext &C) const;
1981
  void printPretty(raw_ostream &OS,
1982
                   const PrintingPolicy &Policy) const;
1983
  const char *getSpelling() const;
1984
1985
1986
51.2k
  static bool classof(const Attr *A) { return A->getKind() == attr::CUDAInvalidTarget; }
1987
};
1988
1989
class CUDALaunchBoundsAttr : public InheritableAttr {
1990
Expr * maxThreads;
1991
1992
Expr * minBlocks;
1993
1994
public:
1995
  static CUDALaunchBoundsAttr *CreateImplicit(ASTContext &Ctx, Expr * MaxThreads, Expr * MinBlocks, SourceRange Loc = SourceRange()) {
1996
    auto *A = new (Ctx) CUDALaunchBoundsAttr(Loc, Ctx, MaxThreads, MinBlocks, 0);
1997
    A->setImplicit(true);
1998
    return A;
1999
  }
2000
2001
  CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx
2002
              , Expr * MaxThreads
2003
              , Expr * MinBlocks
2004
              , unsigned SI
2005
             )
2006
    : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false)
2007
              , maxThreads(MaxThreads)
2008
              , minBlocks(MinBlocks)
2009
60
  {
2010
60
  }
2011
2012
  CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx
2013
              , Expr * MaxThreads
2014
              , unsigned SI
2015
             )
2016
    : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false)
2017
              , maxThreads(MaxThreads)
2018
              , minBlocks()
2019
  {
2020
  }
2021
2022
  CUDALaunchBoundsAttr *clone(ASTContext &C) const;
2023
  void printPretty(raw_ostream &OS,
2024
                   const PrintingPolicy &Policy) const;
2025
  const char *getSpelling() const;
2026
14
  Expr * getMaxThreads() const {
2027
14
    return maxThreads;
2028
14
  }
2029
2030
24
  Expr * getMinBlocks() const {
2031
24
    return minBlocks;
2032
24
  }
2033
2034
2035
2036
2.16M
  static bool classof(const Attr *A) { return A->getKind() == attr::CUDALaunchBounds; }
2037
};
2038
2039
class CUDASharedAttr : public InheritableAttr {
2040
public:
2041
  static CUDASharedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2042
    auto *A = new (Ctx) CUDASharedAttr(Loc, Ctx, 0);
2043
    A->setImplicit(true);
2044
    return A;
2045
  }
2046
2047
  CUDASharedAttr(SourceRange R, ASTContext &Ctx
2048
              , unsigned SI
2049
             )
2050
    : InheritableAttr(attr::CUDAShared, R, SI, false, false)
2051
184
  {
2052
184
  }
2053
2054
  CUDASharedAttr *clone(ASTContext &C) const;
2055
  void printPretty(raw_ostream &OS,
2056
                   const PrintingPolicy &Policy) const;
2057
  const char *getSpelling() const;
2058
2059
2060
1.30k
  static bool classof(const Attr *A) { return A->getKind() == attr::CUDAShared; }
2061
};
2062
2063
class CXX11NoReturnAttr : public InheritableAttr {
2064
public:
2065
  static CXX11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2066
    auto *A = new (Ctx) CXX11NoReturnAttr(Loc, Ctx, 0);
2067
    A->setImplicit(true);
2068
    return A;
2069
  }
2070
2071
  CXX11NoReturnAttr(SourceRange R, ASTContext &Ctx
2072
              , unsigned SI
2073
             )
2074
    : InheritableAttr(attr::CXX11NoReturn, R, SI, false, false)
2075
11.1k
  {
2076
11.1k
  }
2077
2078
  CXX11NoReturnAttr *clone(ASTContext &C) const;
2079
  void printPretty(raw_ostream &OS,
2080
                   const PrintingPolicy &Policy) const;
2081
  const char *getSpelling() const;
2082
2083
2084
5.22M
  static bool classof(const Attr *A) { return A->getKind() == attr::CXX11NoReturn; }
2085
};
2086
2087
class CallableWhenAttr : public InheritableAttr {
2088
public:
2089
  enum ConsumedState {
2090
    Unknown,
2091
    Consumed,
2092
    Unconsumed
2093
  };
2094
private:
2095
  unsigned callableStates_Size;
2096
  ConsumedState *callableStates_;
2097
2098
public:
2099
  static CallableWhenAttr *CreateImplicit(ASTContext &Ctx, ConsumedState *CallableStates, unsigned CallableStatesSize, SourceRange Loc = SourceRange()) {
2100
    auto *A = new (Ctx) CallableWhenAttr(Loc, Ctx, CallableStates, CallableStatesSize, 0);
2101
    A->setImplicit(true);
2102
    return A;
2103
  }
2104
2105
  CallableWhenAttr(SourceRange R, ASTContext &Ctx
2106
              , ConsumedState *CallableStates, unsigned CallableStatesSize
2107
              , unsigned SI
2108
             )
2109
    : InheritableAttr(attr::CallableWhen, R, SI, false, false)
2110
              , callableStates_Size(CallableStatesSize), callableStates_(new (Ctx, 16) ConsumedState[callableStates_Size])
2111
18
  {
2112
18
    std::copy(CallableStates, CallableStates + callableStates_Size, callableStates_);
2113
18
  }
2114
2115
  CallableWhenAttr(SourceRange R, ASTContext &Ctx
2116
              , unsigned SI
2117
             )
2118
    : InheritableAttr(attr::CallableWhen, R, SI, false, false)
2119
              , callableStates_Size(0), callableStates_(nullptr)
2120
  {
2121
  }
2122
2123
  CallableWhenAttr *clone(ASTContext &C) const;
2124
  void printPretty(raw_ostream &OS,
2125
                   const PrintingPolicy &Policy) const;
2126
  const char *getSpelling() const;
2127
  typedef ConsumedState* callableStates_iterator;
2128
204
  callableStates_iterator callableStates_begin() const { return callableStates_; }
2129
204
  callableStates_iterator callableStates_end() const { return callableStates_ + callableStates_Size; }
2130
0
  unsigned callableStates_size() const { return callableStates_Size; }
2131
204
  llvm::iterator_range<callableStates_iterator> callableStates() const { return llvm::make_range(callableStates_begin(), callableStates_end()); }
2132
2133
2134
19
  static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
2135
19
    Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
2136
19
      .Case("unknown", CallableWhenAttr::Unknown)
2137
19
      .Case("consumed", CallableWhenAttr::Consumed)
2138
19
      .Case("unconsumed", CallableWhenAttr::Unconsumed)
2139
19
      .Default(Optional<ConsumedState>());
2140
19
    if (R) {
2141
18
      Out = *R;
2142
18
      return true;
2143
18
    }
2144
1
    return false;
2145
1
  }
2146
2147
2
  static const char *ConvertConsumedStateToStr(ConsumedState Val) {
2148
2
    switch(Val) {
2149
2
    
case CallableWhenAttr::Unknown: return "unknown"0
;
2150
2
    
case CallableWhenAttr::Consumed: return "consumed"1
;
2151
2
    
case CallableWhenAttr::Unconsumed: return "unconsumed"1
;
2152
0
    }
2153
0
    llvm_unreachable("No enumerator with that value");
2154
0
  }
2155
2156
2157
474
  static bool classof(const Attr *A) { return A->getKind() == attr::CallableWhen; }
2158
};
2159
2160
class CapabilityAttr : public InheritableAttr {
2161
unsigned nameLength;
2162
char *name;
2163
2164
public:
2165
  enum Spelling {
2166
    GNU_capability = 0,
2167
    CXX11_clang_capability = 1,
2168
    GNU_shared_capability = 2,
2169
    CXX11_clang_shared_capability = 3
2170
  };
2171
2172
  static CapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
2173
    auto *A = new (Ctx) CapabilityAttr(Loc, Ctx, Name, S);
2174
    A->setImplicit(true);
2175
    return A;
2176
  }
2177
2178
  CapabilityAttr(SourceRange R, ASTContext &Ctx
2179
              , llvm::StringRef Name
2180
              , unsigned SI
2181
             )
2182
    : InheritableAttr(attr::Capability, R, SI, false, false)
2183
              , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
2184
75
  {
2185
75
      if (!Name.empty())
2186
75
        std::memcpy(name, Name.data(), nameLength);
2187
75
  }
2188
2189
  CapabilityAttr *clone(ASTContext &C) const;
2190
  void printPretty(raw_ostream &OS,
2191
                   const PrintingPolicy &Policy) const;
2192
  const char *getSpelling() const;
2193
  Spelling getSemanticSpelling() const {
2194
  switch (SpellingListIndex) {
2195
    default: llvm_unreachable("Unknown spelling list index");
2196
    case 0: return GNU_capability;
2197
    case 1: return CXX11_clang_capability;
2198
    case 2: return GNU_shared_capability;
2199
    case 3: return CXX11_clang_shared_capability;
2200
  }
2201
  }
2202
  bool isShared() const { return SpellingListIndex == 2 ||
2203
    SpellingListIndex == 3; }
2204
3.79k
  llvm::StringRef getName() const {
2205
3.79k
    return llvm::StringRef(name, nameLength);
2206
3.79k
  }
2207
  unsigned getNameLength() const {
2208
    return nameLength;
2209
  }
2210
  void setName(ASTContext &C, llvm::StringRef S) {
2211
    nameLength = S.size();
2212
    this->name = new (C, 1) char [nameLength];
2213
    if (!S.empty())
2214
      std::memcpy(this->name, S.data(), nameLength);
2215
  }
2216
2217
2218
    bool isMutex() const { return getName().equals_lower("mutex"); }
2219
    bool isRole() const { return getName().equals_lower("role"); }
2220
  
2221
2222
10.4k
  static bool classof(const Attr *A) { return A->getKind() == attr::Capability; }
2223
};
2224
2225
class CapturedRecordAttr : public InheritableAttr {
2226
public:
2227
291k
  static CapturedRecordAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2228
291k
    auto *A = new (Ctx) CapturedRecordAttr(Loc, Ctx, 0);
2229
291k
    A->setImplicit(true);
2230
291k
    return A;
2231
291k
  }
2232
2233
  CapturedRecordAttr(SourceRange R, ASTContext &Ctx
2234
              , unsigned SI
2235
             )
2236
    : InheritableAttr(attr::CapturedRecord, R, SI, false, false)
2237
310k
  {
2238
310k
  }
2239
2240
  CapturedRecordAttr *clone(ASTContext &C) const;
2241
  void printPretty(raw_ostream &OS,
2242
                   const PrintingPolicy &Policy) const;
2243
  const char *getSpelling() const;
2244
2245
2246
0
  static bool classof(const Attr *A) { return A->getKind() == attr::CapturedRecord; }
2247
};
2248
2249
class CarriesDependencyAttr : public InheritableParamAttr {
2250
public:
2251
  static CarriesDependencyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2252
    auto *A = new (Ctx) CarriesDependencyAttr(Loc, Ctx, 0);
2253
    A->setImplicit(true);
2254
    return A;
2255
  }
2256
2257
  CarriesDependencyAttr(SourceRange R, ASTContext &Ctx
2258
              , unsigned SI
2259
             )
2260
    : InheritableParamAttr(attr::CarriesDependency, R, SI, false, false)
2261
25
  {
2262
25
  }
2263
2264
  CarriesDependencyAttr *clone(ASTContext &C) const;
2265
  void printPretty(raw_ostream &OS,
2266
                   const PrintingPolicy &Policy) const;
2267
  const char *getSpelling() const;
2268
2269
2270
107k
  static bool classof(const Attr *A) { return A->getKind() == attr::CarriesDependency; }
2271
};
2272
2273
class CleanupAttr : public InheritableAttr {
2274
FunctionDecl * functionDecl;
2275
2276
public:
2277
  static CleanupAttr *CreateImplicit(ASTContext &Ctx, FunctionDecl * FunctionDecl, SourceRange Loc = SourceRange()) {
2278
    auto *A = new (Ctx) CleanupAttr(Loc, Ctx, FunctionDecl, 0);
2279
    A->setImplicit(true);
2280
    return A;
2281
  }
2282
2283
  CleanupAttr(SourceRange R, ASTContext &Ctx
2284
              , FunctionDecl * FunctionDecl
2285
              , unsigned SI
2286
             )
2287
    : InheritableAttr(attr::Cleanup, R, SI, false, false)
2288
              , functionDecl(FunctionDecl)
2289
27
  {
2290
27
  }
2291
2292
  CleanupAttr *clone(ASTContext &C) const;
2293
  void printPretty(raw_ostream &OS,
2294
                   const PrintingPolicy &Policy) const;
2295
  const char *getSpelling() const;
2296
8
  FunctionDecl * getFunctionDecl() const {
2297
8
    return functionDecl;
2298
8
  }
2299
2300
2301
2302
116k
  static bool classof(const Attr *A) { return A->getKind() == attr::Cleanup; }
2303
};
2304
2305
class CodeSegAttr : public InheritableAttr {
2306
unsigned nameLength;
2307
char *name;
2308
2309
public:
2310
  static CodeSegAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
2311
    auto *A = new (Ctx) CodeSegAttr(Loc, Ctx, Name, 0);
2312
    A->setImplicit(true);
2313
    return A;
2314
  }
2315
2316
  CodeSegAttr(SourceRange R, ASTContext &Ctx
2317
              , llvm::StringRef Name
2318
              , unsigned SI
2319
             )
2320
    : InheritableAttr(attr::CodeSeg, R, SI, false, false)
2321
              , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
2322
195
  {
2323
195
      if (!Name.empty())
2324
195
        std::memcpy(name, Name.data(), nameLength);
2325
195
  }
2326
2327
  CodeSegAttr *clone(ASTContext &C) const;
2328
  void printPretty(raw_ostream &OS,
2329
                   const PrintingPolicy &Policy) const;
2330
  const char *getSpelling() const;
2331
271
  llvm::StringRef getName() const {
2332
271
    return llvm::StringRef(name, nameLength);
2333
271
  }
2334
  unsigned getNameLength() const {
2335
    return nameLength;
2336
  }
2337
  void setName(ASTContext &C, llvm::StringRef S) {
2338
    nameLength = S.size();
2339
    this->name = new (C, 1) char [nameLength];
2340
    if (!S.empty())
2341
      std::memcpy(this->name, S.data(), nameLength);
2342
  }
2343
2344
2345
2346
1.87M
  static bool classof(const Attr *A) { return A->getKind() == attr::CodeSeg; }
2347
};
2348
2349
class ColdAttr : public InheritableAttr {
2350
public:
2351
  static ColdAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2352
    auto *A = new (Ctx) ColdAttr(Loc, Ctx, 0);
2353
    A->setImplicit(true);
2354
    return A;
2355
  }
2356
2357
  ColdAttr(SourceRange R, ASTContext &Ctx
2358
              , unsigned SI
2359
             )
2360
    : InheritableAttr(attr::Cold, R, SI, false, false)
2361
34
  {
2362
34
  }
2363
2364
  ColdAttr *clone(ASTContext &C) const;
2365
  void printPretty(raw_ostream &OS,
2366
                   const PrintingPolicy &Policy) const;
2367
  const char *getSpelling() const;
2368
2369
2370
672k
  static bool classof(const Attr *A) { return A->getKind() == attr::Cold; }
2371
};
2372
2373
class CommonAttr : public InheritableAttr {
2374
public:
2375
  static CommonAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2376
    auto *A = new (Ctx) CommonAttr(Loc, Ctx, 0);
2377
    A->setImplicit(true);
2378
    return A;
2379
  }
2380
2381
  CommonAttr(SourceRange R, ASTContext &Ctx
2382
              , unsigned SI
2383
             )
2384
    : InheritableAttr(attr::Common, R, SI, false, false)
2385
7
  {
2386
7
  }
2387
2388
  CommonAttr *clone(ASTContext &C) const;
2389
  void printPretty(raw_ostream &OS,
2390
                   const PrintingPolicy &Policy) const;
2391
  const char *getSpelling() const;
2392
2393
2394
242k
  static bool classof(const Attr *A) { return A->getKind() == attr::Common; }
2395
};
2396
2397
class ConstAttr : public InheritableAttr {
2398
public:
2399
351k
  static ConstAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2400
351k
    auto *A = new (Ctx) ConstAttr(Loc, Ctx, 0);
2401
351k
    A->setImplicit(true);
2402
351k
    return A;
2403
351k
  }
2404
2405
  ConstAttr(SourceRange R, ASTContext &Ctx
2406
              , unsigned SI
2407
             )
2408
    : InheritableAttr(attr::Const, R, SI, false, false)
2409
637k
  {
2410
637k
  }
2411
2412
  ConstAttr *clone(ASTContext &C) const;
2413
  void printPretty(raw_ostream &OS,
2414
                   const PrintingPolicy &Policy) const;
2415
  const char *getSpelling() const;
2416
2417
2418
1.49M
  static bool classof(const Attr *A) { return A->getKind() == attr::Const; }
2419
};
2420
2421
class ConstructorAttr : public InheritableAttr {
2422
int priority;
2423
2424
public:
2425
  static ConstructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) {
2426
    auto *A = new (Ctx) ConstructorAttr(Loc, Ctx, Priority, 0);
2427
    A->setImplicit(true);
2428
    return A;
2429
  }
2430
2431
  ConstructorAttr(SourceRange R, ASTContext &Ctx
2432
              , int Priority
2433
              , unsigned SI
2434
             )
2435
    : InheritableAttr(attr::Constructor, R, SI, false, false)
2436
              , priority(Priority)
2437
56
  {
2438
56
  }
2439
2440
  ConstructorAttr(SourceRange R, ASTContext &Ctx
2441
              , unsigned SI
2442
             )
2443
    : InheritableAttr(attr::Constructor, R, SI, false, false)
2444
              , priority()
2445
  {
2446
  }
2447
2448
  ConstructorAttr *clone(ASTContext &C) const;
2449
  void printPretty(raw_ostream &OS,
2450
                   const PrintingPolicy &Policy) const;
2451
  const char *getSpelling() const;
2452
20
  int getPriority() const {
2453
20
    return priority;
2454
20
  }
2455
2456
  static const int DefaultPriority = 65535;
2457
2458
2459
2460
6.60M
  static bool classof(const Attr *A) { return A->getKind() == attr::Constructor; }
2461
};
2462
2463
class ConsumableAttr : public InheritableAttr {
2464
public:
2465
  enum ConsumedState {
2466
    Unknown,
2467
    Consumed,
2468
    Unconsumed
2469
  };
2470
private:
2471
  ConsumedState defaultState;
2472
2473
public:
2474
  static ConsumableAttr *CreateImplicit(ASTContext &Ctx, ConsumedState DefaultState, SourceRange Loc = SourceRange()) {
2475
    auto *A = new (Ctx) ConsumableAttr(Loc, Ctx, DefaultState, 0);
2476
    A->setImplicit(true);
2477
    return A;
2478
  }
2479
2480
  ConsumableAttr(SourceRange R, ASTContext &Ctx
2481
              , ConsumedState DefaultState
2482
              , unsigned SI
2483
             )
2484
    : InheritableAttr(attr::Consumable, R, SI, false, false)
2485
              , defaultState(DefaultState)
2486
8
  {
2487
8
  }
2488
2489
  ConsumableAttr *clone(ASTContext &C) const;
2490
  void printPretty(raw_ostream &OS,
2491
                   const PrintingPolicy &Policy) const;
2492
  const char *getSpelling() const;
2493
43
  ConsumedState getDefaultState() const {
2494
43
    return defaultState;
2495
43
  }
2496
2497
6
  static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
2498
6
    Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
2499
6
      .Case("unknown", ConsumableAttr::Unknown)
2500
6
      .Case("consumed", ConsumableAttr::Consumed)
2501
6
      .Case("unconsumed", ConsumableAttr::Unconsumed)
2502
6
      .Default(Optional<ConsumedState>());
2503
6
    if (R) {
2504
6
      Out = *R;
2505
6
      return true;
2506
6
    }
2507
0
    return false;
2508
0
  }
2509
2510
1
  static const char *ConvertConsumedStateToStr(ConsumedState Val) {
2511
1
    switch(Val) {
2512
1
    case ConsumableAttr::Unknown: return "unknown";
2513
1
    
case ConsumableAttr::Consumed: return "consumed"0
;
2514
1
    
case ConsumableAttr::Unconsumed: return "unconsumed"0
;
2515
0
    }
2516
0
    llvm_unreachable("No enumerator with that value");
2517
0
  }
2518
2519
2520
323
  static bool classof(const Attr *A) { return A->getKind() == attr::Consumable; }
2521
};
2522
2523
class ConsumableAutoCastAttr : public InheritableAttr {
2524
public:
2525
  static ConsumableAutoCastAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2526
    auto *A = new (Ctx) ConsumableAutoCastAttr(Loc, Ctx, 0);
2527
    A->setImplicit(true);
2528
    return A;
2529
  }
2530
2531
  ConsumableAutoCastAttr(SourceRange R, ASTContext &Ctx
2532
              , unsigned SI
2533
             )
2534
    : InheritableAttr(attr::ConsumableAutoCast, R, SI, false, false)
2535
2
  {
2536
2
  }
2537
2538
  ConsumableAutoCastAttr *clone(ASTContext &C) const;
2539
  void printPretty(raw_ostream &OS,
2540
                   const PrintingPolicy &Policy) const;
2541
  const char *getSpelling() const;
2542
2543
2544
7
  static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableAutoCast; }
2545
};
2546
2547
class ConsumableSetOnReadAttr : public InheritableAttr {
2548
public:
2549
  static ConsumableSetOnReadAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2550
    auto *A = new (Ctx) ConsumableSetOnReadAttr(Loc, Ctx, 0);
2551
    A->setImplicit(true);
2552
    return A;
2553
  }
2554
2555
  ConsumableSetOnReadAttr(SourceRange R, ASTContext &Ctx
2556
              , unsigned SI
2557
             )
2558
    : InheritableAttr(attr::ConsumableSetOnRead, R, SI, false, false)
2559
2
  {
2560
2
  }
2561
2562
  ConsumableSetOnReadAttr *clone(ASTContext &C) const;
2563
  void printPretty(raw_ostream &OS,
2564
                   const PrintingPolicy &Policy) const;
2565
  const char *getSpelling() const;
2566
2567
2568
32
  static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableSetOnRead; }
2569
};
2570
2571
class ConvergentAttr : public InheritableAttr {
2572
public:
2573
  static ConvergentAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2574
    auto *A = new (Ctx) ConvergentAttr(Loc, Ctx, 0);
2575
    A->setImplicit(true);
2576
    return A;
2577
  }
2578
2579
  ConvergentAttr(SourceRange R, ASTContext &Ctx
2580
              , unsigned SI
2581
             )
2582
    : InheritableAttr(attr::Convergent, R, SI, false, false)
2583
2.79k
  {
2584
2.79k
  }
2585
2586
  ConvergentAttr *clone(ASTContext &C) const;
2587
  void printPretty(raw_ostream &OS,
2588
                   const PrintingPolicy &Policy) const;
2589
  const char *getSpelling() const;
2590
2591
2592
527k
  static bool classof(const Attr *A) { return A->getKind() == attr::Convergent; }
2593
};
2594
2595
class DLLExportAttr : public InheritableAttr {
2596
public:
2597
  static DLLExportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2598
    auto *A = new (Ctx) DLLExportAttr(Loc, Ctx, 0);
2599
    A->setImplicit(true);
2600
    return A;
2601
  }
2602
2603
  DLLExportAttr(SourceRange R, ASTContext &Ctx
2604
              , unsigned SI
2605
             )
2606
    : InheritableAttr(attr::DLLExport, R, SI, false, false)
2607
6.90k
  {
2608
6.90k
  }
2609
2610
  DLLExportAttr *clone(ASTContext &C) const;
2611
  void printPretty(raw_ostream &OS,
2612
                   const PrintingPolicy &Policy) const;
2613
  const char *getSpelling() const;
2614
2615
2616
16.6M
  static bool classof(const Attr *A) { return A->getKind() == attr::DLLExport; }
2617
};
2618
2619
class DLLImportAttr : public InheritableAttr {
2620
public:
2621
  static DLLImportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2622
    auto *A = new (Ctx) DLLImportAttr(Loc, Ctx, 0);
2623
    A->setImplicit(true);
2624
    return A;
2625
  }
2626
2627
  DLLImportAttr(SourceRange R, ASTContext &Ctx
2628
              , unsigned SI
2629
             )
2630
    : InheritableAttr(attr::DLLImport, R, SI, false, false)
2631
6.51k
  {
2632
6.51k
  }
2633
2634
  DLLImportAttr *clone(ASTContext &C) const;
2635
  void printPretty(raw_ostream &OS,
2636
                   const PrintingPolicy &Policy) const;
2637
  const char *getSpelling() const;
2638
2639
private:
2640
  bool PropagatedToBaseTemplate = false;
2641
2642
public:
2643
50
  void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; }
2644
671
  bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; }
2645
  
2646
2647
19.9M
  static bool classof(const Attr *A) { return A->getKind() == attr::DLLImport; }
2648
};
2649
2650
class DeprecatedAttr : public InheritableAttr {
2651
unsigned messageLength;
2652
char *message;
2653
2654
unsigned replacementLength;
2655
char *replacement;
2656
2657
public:
2658
  static DeprecatedAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, llvm::StringRef Replacement, SourceRange Loc = SourceRange()) {
2659
    auto *A = new (Ctx) DeprecatedAttr(Loc, Ctx, Message, Replacement, 0);
2660
    A->setImplicit(true);
2661
    return A;
2662
  }
2663
2664
  DeprecatedAttr(SourceRange R, ASTContext &Ctx
2665
              , llvm::StringRef Message
2666
              , llvm::StringRef Replacement
2667
              , unsigned SI
2668
             )
2669
    : InheritableAttr(attr::Deprecated, R, SI, false, false)
2670
              , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2671
              , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength])
2672
15.1k
  {
2673
15.1k
      if (!Message.empty())
2674
5.90k
        std::memcpy(message, Message.data(), messageLength);
2675
15.1k
      if (!Replacement.empty())
2676
68
        std::memcpy(replacement, Replacement.data(), replacementLength);
2677
15.1k
  }
2678
2679
  DeprecatedAttr(SourceRange R, ASTContext &Ctx
2680
              , unsigned SI
2681
             )
2682
    : InheritableAttr(attr::Deprecated, R, SI, false, false)
2683
              , messageLength(0),message(nullptr)
2684
              , replacementLength(0),replacement(nullptr)
2685
  {
2686
  }
2687
2688
  DeprecatedAttr *clone(ASTContext &C) const;
2689
  void printPretty(raw_ostream &OS,
2690
                   const PrintingPolicy &Policy) const;
2691
  const char *getSpelling() const;
2692
3.89k
  llvm::StringRef getMessage() const {
2693
3.89k
    return llvm::StringRef(message, messageLength);
2694
3.89k
  }
2695
  unsigned getMessageLength() const {
2696
    return messageLength;
2697
  }
2698
  void setMessage(ASTContext &C, llvm::StringRef S) {
2699
    messageLength = S.size();
2700
    this->message = new (C, 1) char [messageLength];
2701
    if (!S.empty())
2702
      std::memcpy(this->message, S.data(), messageLength);
2703
  }
2704
2705
2.35k
  llvm::StringRef getReplacement() const {
2706
2.35k
    return llvm::StringRef(replacement, replacementLength);
2707
2.35k
  }
2708
  unsigned getReplacementLength() const {
2709
    return replacementLength;
2710
  }
2711
  void setReplacement(ASTContext &C, llvm::StringRef S) {
2712
    replacementLength = S.size();
2713
    this->replacement = new (C, 1) char [replacementLength];
2714
    if (!S.empty())
2715
      std::memcpy(this->replacement, S.data(), replacementLength);
2716
  }
2717
2718
2719
2720
7.11M
  static bool classof(const Attr *A) { return A->getKind() == attr::Deprecated; }
2721
};
2722
2723
class DestructorAttr : public InheritableAttr {
2724
int priority;
2725
2726
public:
2727
  static DestructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) {
2728
    auto *A = new (Ctx) DestructorAttr(Loc, Ctx, Priority, 0);
2729
    A->setImplicit(true);
2730
    return A;
2731
  }
2732
2733
  DestructorAttr(SourceRange R, ASTContext &Ctx
2734
              , int Priority
2735
              , unsigned SI
2736
             )
2737
    : InheritableAttr(attr::Destructor, R, SI, false, false)
2738
              , priority(Priority)
2739
35
  {
2740
35
  }
2741
2742
  DestructorAttr(SourceRange R, ASTContext &Ctx
2743
              , unsigned SI
2744
             )
2745
    : InheritableAttr(attr::Destructor, R, SI, false, false)
2746
              , priority()
2747
  {
2748
  }
2749
2750
  DestructorAttr *clone(ASTContext &C) const;
2751
  void printPretty(raw_ostream &OS,
2752
                   const PrintingPolicy &Policy) const;
2753
  const char *getSpelling() const;
2754
16
  int getPriority() const {
2755
16
    return priority;
2756
16
  }
2757
2758
  static const int DefaultPriority = 65535;
2759
2760
2761
2762
6.60M
  static bool classof(const Attr *A) { return A->getKind() == attr::Destructor; }
2763
};
2764
2765
class DiagnoseIfAttr : public InheritableAttr {
2766
Expr * cond;
2767
2768
unsigned messageLength;
2769
char *message;
2770
2771
public:
2772
  enum DiagnosticType {
2773
    DT_Error,
2774
    DT_Warning
2775
  };
2776
private:
2777
  DiagnosticType diagnosticType;
2778
2779
bool argDependent;
2780
2781
NamedDecl * parent;
2782
2783
public:
2784
  static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, bool ArgDependent, NamedDecl * Parent, SourceRange Loc = SourceRange()) {
2785
    auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, ArgDependent, Parent, 0);
2786
    A->setImplicit(true);
2787
    return A;
2788
  }
2789
2790
  static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, SourceRange Loc = SourceRange()) {
2791
    auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, 0);
2792
    A->setImplicit(true);
2793
    return A;
2794
  }
2795
2796
  DiagnoseIfAttr(SourceRange R, ASTContext &Ctx
2797
              , Expr * Cond
2798
              , llvm::StringRef Message
2799
              , DiagnosticType DiagnosticType
2800
              , bool ArgDependent
2801
              , NamedDecl * Parent
2802
              , unsigned SI
2803
             )
2804
    : InheritableAttr(attr::DiagnoseIf, R, SI, true, true)
2805
              , cond(Cond)
2806
              , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2807
              , diagnosticType(DiagnosticType)
2808
              , argDependent(ArgDependent)
2809
              , parent(Parent)
2810
5.87k
  {
2811
5.87k
      if (!Message.empty())
2812
5.87k
        std::memcpy(message, Message.data(), messageLength);
2813
5.87k
  }
2814
2815
  DiagnoseIfAttr(SourceRange R, ASTContext &Ctx
2816
              , Expr * Cond
2817
              , llvm::StringRef Message
2818
              , DiagnosticType DiagnosticType
2819
              , unsigned SI
2820
             )
2821
    : InheritableAttr(attr::DiagnoseIf, R, SI, true, true)
2822
              , cond(Cond)
2823
              , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2824
              , diagnosticType(DiagnosticType)
2825
              , argDependent()
2826
              , parent()
2827
  {
2828
      if (!Message.empty())
2829
        std::memcpy(message, Message.data(), messageLength);
2830
  }
2831
2832
  DiagnoseIfAttr *clone(ASTContext &C) const;
2833
  void printPretty(raw_ostream &OS,
2834
                   const PrintingPolicy &Policy) const;
2835
  const char *getSpelling() const;
2836
1.36k
  Expr * getCond() const {
2837
1.36k
    return cond;
2838
1.36k
  }
2839
2840
756
  llvm::StringRef getMessage() const {
2841
756
    return llvm::StringRef(message, messageLength);
2842
756
  }
2843
  unsigned getMessageLength() const {
2844
    return messageLength;
2845
  }
2846
  void setMessage(ASTContext &C, llvm::StringRef S) {
2847
    messageLength = S.size();
2848
    this->message = new (C, 1) char [messageLength];
2849
    if (!S.empty())
2850
      std::memcpy(this->message, S.data(), messageLength);
2851
  }
2852
2853
632
  DiagnosticType getDiagnosticType() const {
2854
632
    return diagnosticType;
2855
632
  }
2856
2857
5.24k
  static bool ConvertStrToDiagnosticType(StringRef Val, DiagnosticType &Out) {
2858
5.24k
    Optional<DiagnosticType> R = llvm::StringSwitch<Optional<DiagnosticType>>(Val)
2859
5.24k
      .Case("error", DiagnoseIfAttr::DT_Error)
2860
5.24k
      .Case("warning", DiagnoseIfAttr::DT_Warning)
2861
5.24k
      .Default(Optional<DiagnosticType>());
2862
5.24k
    if (R) {
2863
5.23k
      Out = *R;
2864
5.23k
      return true;
2865
5.23k
    }
2866
3
    return false;
2867
3
  }
2868
2869
0
  static const char *ConvertDiagnosticTypeToStr(DiagnosticType Val) {
2870
0
    switch(Val) {
2871
0
    case DiagnoseIfAttr::DT_Error: return "error";
2872
0
    case DiagnoseIfAttr::DT_Warning: return "warning";
2873
0
    }
2874
0
    llvm_unreachable("No enumerator with that value");
2875
0
  }
2876
1.84k
  bool getArgDependent() const {
2877
1.84k
    return argDependent;
2878
1.84k
  }
2879
2880
340
  NamedDecl * getParent() const {
2881
340
    return parent;
2882
340
  }
2883
2884
2885
626
    bool isError() const { return diagnosticType == DT_Error; }
2886
    bool isWarning() const { return diagnosticType == DT_Warning; }
2887
  
2888
2889
11.2M
  static bool classof(const Attr *A) { return A->getKind() == attr::DiagnoseIf; }
2890
};
2891
2892
class DisableTailCallsAttr : public InheritableAttr {
2893
public:
2894
  static DisableTailCallsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2895
    auto *A = new (Ctx) DisableTailCallsAttr(Loc, Ctx, 0);
2896
    A->setImplicit(true);
2897
    return A;
2898
  }
2899
2900
  DisableTailCallsAttr(SourceRange R, ASTContext &Ctx
2901
              , unsigned SI
2902
             )
2903
    : InheritableAttr(attr::DisableTailCalls, R, SI, false, false)
2904
54
  {
2905
54
  }
2906
2907
  DisableTailCallsAttr *clone(ASTContext &C) const;
2908
  void printPretty(raw_ostream &OS,
2909
                   const PrintingPolicy &Policy) const;
2910
  const char *getSpelling() const;
2911
2912
2913
165k
  static bool classof(const Attr *A) { return A->getKind() == attr::DisableTailCalls; }
2914
};
2915
2916
class EmptyBasesAttr : public InheritableAttr {
2917
public:
2918
  static EmptyBasesAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2919
    auto *A = new (Ctx) EmptyBasesAttr(Loc, Ctx, 0);
2920
    A->setImplicit(true);
2921
    return A;
2922
  }
2923
2924
  EmptyBasesAttr(SourceRange R, ASTContext &Ctx
2925
              , unsigned SI
2926
             )
2927
    : InheritableAttr(attr::EmptyBases, R, SI, false, false)
2928
9
  {
2929
9
  }
2930
2931
  EmptyBasesAttr *clone(ASTContext &C) const;
2932
  void printPretty(raw_ostream &OS,
2933
                   const PrintingPolicy &Policy) const;
2934
  const char *getSpelling() const;
2935
2936
2937
880
  static bool classof(const Attr *A) { return A->getKind() == attr::EmptyBases; }
2938
};
2939
2940
class EnableIfAttr : public InheritableAttr {
2941
Expr * cond;
2942
2943
unsigned messageLength;
2944
char *message;
2945
2946
public:
2947
  static EnableIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, SourceRange Loc = SourceRange()) {
2948
    auto *A = new (Ctx) EnableIfAttr(Loc, Ctx, Cond, Message, 0);
2949
    A->setImplicit(true);
2950
    return A;
2951
  }
2952
2953
  EnableIfAttr(SourceRange R, ASTContext &Ctx
2954
              , Expr * Cond
2955
              , llvm::StringRef Message
2956
              , unsigned SI
2957
             )
2958
    : InheritableAttr(attr::EnableIf, R, SI, false, false)
2959
              , cond(Cond)
2960
              , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2961
13.1k
  {
2962
13.1k
      if (!Message.empty())
2963
13.1k
        std::memcpy(message, Message.data(), messageLength);
2964
13.1k
  }
2965
2966
  EnableIfAttr *clone(ASTContext &C) const;
2967
  void printPretty(raw_ostream &OS,
2968
                   const PrintingPolicy &Policy) const;
2969
  const char *getSpelling() const;
2970
14.9k
  Expr * getCond() const {
2971
14.9k
    return cond;
2972
14.9k
  }
2973
2974
410
  llvm::StringRef getMessage() const {
2975
410
    return llvm::StringRef(message, messageLength);
2976
410
  }
2977
  unsigned getMessageLength() const {
2978
    return messageLength;
2979
  }
2980
  void setMessage(ASTContext &C, llvm::StringRef S) {
2981
    messageLength = S.size();
2982
    this->message = new (C, 1) char [messageLength];
2983
    if (!S.empty())
2984
      std::memcpy(this->message, S.data(), messageLength);
2985
  }
2986
2987
2988
2989
9.41M
  static bool classof(const Attr *A) { return A->getKind() == attr::EnableIf; }
2990
};
2991
2992
class EnumExtensibilityAttr : public InheritableAttr {
2993
public:
2994
  enum Kind {
2995
    Closed,
2996
    Open
2997
  };
2998
private:
2999
  Kind extensibility;
3000
3001
public:
3002
  static EnumExtensibilityAttr *CreateImplicit(ASTContext &Ctx, Kind Extensibility, SourceRange Loc = SourceRange()) {
3003
    auto *A = new (Ctx) EnumExtensibilityAttr(Loc, Ctx, Extensibility, 0);
3004
    A->setImplicit(true);
3005
    return A;
3006
  }
3007
3008
  EnumExtensibilityAttr(SourceRange R, ASTContext &Ctx
3009
              , Kind Extensibility
3010
              , unsigned SI
3011
             )
3012
    : InheritableAttr(attr::EnumExtensibility, R, SI, false, false)
3013
              , extensibility(Extensibility)
3014
4.98k
  {
3015
4.98k
  }
3016
3017
  EnumExtensibilityAttr *clone(ASTContext &C) const;
3018
  void printPretty(raw_ostream &OS,
3019
                   const PrintingPolicy &Policy) const;
3020
  const char *getSpelling() const;
3021
2.79k
  Kind getExtensibility() const {
3022
2.79k
    return extensibility;
3023
2.79k
  }
3024
3025
2.74k
  static bool ConvertStrToKind(StringRef Val, Kind &Out) {
3026
2.74k
    Optional<Kind> R = llvm::StringSwitch<Optional<Kind>>(Val)
3027
2.74k
      .Case("closed", EnumExtensibilityAttr::Closed)
3028
2.74k
      .Case("open", EnumExtensibilityAttr::Open)
3029
2.74k
      .Default(Optional<Kind>());
3030
2.74k
    if (R) {
3031
2.74k
      Out = *R;
3032
2.74k
      return true;
3033
2.74k
    }
3034
1
    return false;
3035
1
  }
3036
3037
0
  static const char *ConvertKindToStr(Kind Val) {
3038
0
    switch(Val) {
3039
0
    case EnumExtensibilityAttr::Closed: return "closed";
3040
0
    case EnumExtensibilityAttr::Open: return "open";
3041
0
    }
3042
0
    llvm_unreachable("No enumerator with that value");
3043
0
  }
3044
3045
3046
9.79k
  static bool classof(const Attr *A) { return A->getKind() == attr::EnumExtensibility; }
3047
};
3048
3049
class ExclusiveTrylockFunctionAttr : public InheritableAttr {
3050
Expr * successValue;
3051
3052
  unsigned args_Size;
3053
  Expr * *args_;
3054
3055
public:
3056
  static ExclusiveTrylockFunctionAttr *CreateImplicit(ASTContext &Ctx, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
3057
    auto *A = new (Ctx) ExclusiveTrylockFunctionAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, 0);
3058
    A->setImplicit(true);
3059
    return A;
3060
  }
3061
3062
  ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx
3063
              , Expr * SuccessValue
3064
              , Expr * *Args, unsigned ArgsSize
3065
              , unsigned SI
3066
             )
3067
    : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true)
3068
              , successValue(SuccessValue)
3069
              , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
3070
78
  {
3071
78
    std::copy(Args, Args + args_Size, args_);
3072
78
  }
3073
3074
  ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx
3075
              , Expr * SuccessValue
3076
              , unsigned SI
3077
             )
3078
    : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true)
3079
              , successValue(SuccessValue)
3080
              , args_Size(0), args_(nullptr)
3081
  {
3082
  }
3083
3084
  ExclusiveTrylockFunctionAttr *clone(ASTContext &C) const;
3085
  void printPretty(raw_ostream &OS,
3086
                   const PrintingPolicy &Policy) const;
3087
  const char *getSpelling() const;
3088
137
  Expr * getSuccessValue() const {
3089
137
    return successValue;
3090
137
  }
3091
3092
  typedef Expr ** args_iterator;
3093
159
  args_iterator args_begin() const { return args_; }
3094
159
  args_iterator args_end() const { return args_ + args_Size; }
3095
69
  unsigned args_size() const { return args_Size; }
3096
159
  llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
3097
3098
3099
3100
3101
289k
  static bool classof(const Attr *A) { return A->getKind() == attr::ExclusiveTrylockFunction; }
3102
};
3103
3104
class ExternalSourceSymbolAttr : public InheritableAttr {
3105
unsigned languageLength;
3106
char *language;
3107
3108
unsigned definedInLength;
3109
char *definedIn;
3110
3111
bool generatedDeclaration;
3112
3113
public:
3114
  static ExternalSourceSymbolAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Language, llvm::StringRef DefinedIn, bool GeneratedDeclaration, SourceRange Loc = SourceRange()) {
3115
    auto *A = new (Ctx) ExternalSourceSymbolAttr(Loc, Ctx, Language, DefinedIn, GeneratedDeclaration, 0);
3116
    A->setImplicit(true);
3117
    return A;
3118
  }
3119
3120
  ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx
3121
              , llvm::StringRef Language
3122
              , llvm::StringRef DefinedIn
3123
              , bool GeneratedDeclaration
3124
              , unsigned SI
3125
             )
3126
    : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false)
3127
              , languageLength(Language.size()),language(new (Ctx, 1) char[languageLength])
3128
              , definedInLength(DefinedIn.size()),definedIn(new (Ctx, 1) char[definedInLength])
3129
              , generatedDeclaration(GeneratedDeclaration)
3130
60
  {
3131
60
      if (!Language.empty())
3132
49
        std::memcpy(language, Language.data(), languageLength);
3133
60
      if (!DefinedIn.empty())
3134
47
        std::memcpy(definedIn, DefinedIn.data(), definedInLength);
3135
60
  }
3136
3137
  ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx
3138
              , unsigned SI
3139
             )
3140
    : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false)
3141
              , languageLength(0),language(nullptr)
3142
              , definedInLength(0),definedIn(nullptr)
3143
              , generatedDeclaration()
3144
  {
3145
  }
3146
3147
  ExternalSourceSymbolAttr *clone(ASTContext &C) const;
3148
  void printPretty(raw_ostream &OS,
3149
                   const PrintingPolicy &Policy) const;
3150
  const char *getSpelling() const;
3151
28
  llvm::StringRef getLanguage() const {
3152
28
    return llvm::StringRef(language, languageLength);
3153
28
  }
3154
  unsigned getLanguageLength() const {
3155
    return languageLength;
3156
  }
3157
  void setLanguage(ASTContext &C, llvm::StringRef S) {
3158
    languageLength = S.size();
3159
    this->language = new (C, 1) char [languageLength];
3160
    if (!S.empty())
3161
      std::memcpy(this->language, S.data(), languageLength);
3162
  }
3163
3164
46
  llvm::StringRef getDefinedIn() const {
3165
46
    return llvm::StringRef(definedIn, definedInLength);
3166
46
  }
3167
  unsigned getDefinedInLength() const {
3168
    return definedInLength;
3169
  }
3170
  void setDefinedIn(ASTContext &C, llvm::StringRef S) {
3171
    definedInLength = S.size();
3172
    this->definedIn = new (C, 1) char [definedInLength];
3173
    if (!S.empty())
3174
      std::memcpy(this->definedIn, S.data(), definedInLength);
3175
  }
3176
3177
19
  bool getGeneratedDeclaration() const {
3178
19
    return generatedDeclaration;
3179
19
  }
3180
3181
3182
3183
899
  static bool classof(const Attr *A) { return A->getKind() == attr::ExternalSourceSymbol; }
3184
};
3185
3186
class FallThroughAttr : public StmtAttr {
3187
public:
3188
0
  static FallThroughAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3189
0
    auto *A = new (Ctx) FallThroughAttr(Loc, Ctx, 0);
3190
0
    A->setImplicit(true);
3191
0
    return A;
3192
0
  }
3193
3194
  FallThroughAttr(SourceRange R, ASTContext &Ctx
3195
              , unsigned SI
3196
             )
3197
    : StmtAttr(attr::FallThrough, R, SI, false)
3198
72
  {
3199
72
  }
3200
3201
  FallThroughAttr *clone(ASTContext &C) const;
3202
  void printPretty(raw_ostream &OS,
3203
                   const PrintingPolicy &Policy) const;
3204
  const char *getSpelling() const;
3205
3206
3207
86
  static bool classof(const Attr *A) { return A->getKind() == attr::FallThrough; }
3208
};
3209
3210
class FastCallAttr : public InheritableAttr {
3211
public:
3212
  static FastCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3213
    auto *A = new (Ctx) FastCallAttr(Loc, Ctx, 0);
3214
    A->setImplicit(true);
3215
    return A;
3216
  }
3217
3218
  FastCallAttr(SourceRange R, ASTContext &Ctx
3219
              , unsigned SI
3220
             )
3221
    : InheritableAttr(attr::FastCall, R, SI, false, false)
3222
184
  {
3223
184
  }
3224
3225
  FastCallAttr *clone(ASTContext &C) const;
3226
  void printPretty(raw_ostream &OS,
3227
                   const PrintingPolicy &Policy) const;
3228
  const char *getSpelling() const;
3229
3230
3231
307
  static bool classof(const Attr *A) { return A->getKind() == attr::FastCall; }
3232
};
3233
3234
class FinalAttr : public InheritableAttr {
3235
public:
3236
  enum Spelling {
3237
    Keyword_final = 0,
3238
    Keyword_sealed = 1
3239
  };
3240
3241
  static FinalAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
3242
    auto *A = new (Ctx) FinalAttr(Loc, Ctx, S);
3243
    A->setImplicit(true);
3244
    return A;
3245
  }
3246
3247
  FinalAttr(SourceRange R, ASTContext &Ctx
3248
              , unsigned SI
3249
             )
3250
    : InheritableAttr(attr::Final, R, SI, false, false)
3251
4.59k
  {
3252
4.59k
  }
3253
3254
  FinalAttr *clone(ASTContext &C) const;
3255
  void printPretty(raw_ostream &OS,
3256
                   const PrintingPolicy &Policy) const;
3257
  const char *getSpelling() const;
3258
  Spelling getSemanticSpelling() const {
3259
  switch (SpellingListIndex) {
3260
    default: llvm_unreachable("Unknown spelling list index");
3261
    case 0: return Keyword_final;
3262
    case 1: return Keyword_sealed;
3263
  }
3264
  }
3265
27
  bool isSpelledAsSealed() const { return SpellingListIndex == 1; }
3266
3267
3268
1.82M
  static bool classof(const Attr *A) { return A->getKind() == attr::Final; }
3269
};
3270
3271
class FlagEnumAttr : public InheritableAttr {
3272
public:
3273
  static FlagEnumAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3274
    auto *A = new (Ctx) FlagEnumAttr(Loc, Ctx, 0);
3275
    A->setImplicit(true);
3276
    return A;
3277
  }
3278
3279
  FlagEnumAttr(SourceRange R, ASTContext &Ctx
3280
              , unsigned SI
3281
             )
3282
    : InheritableAttr(attr::FlagEnum, R, SI, false, false)
3283
1.91k
  {
3284
1.91k
  }
3285
3286
  FlagEnumAttr *clone(ASTContext &C) const;
3287
  void printPretty(raw_ostream &OS,
3288
                   const PrintingPolicy &Policy) const;
3289
  const char *getSpelling() const;
3290
3291
3292
2.06k
  static bool classof(const Attr *A) { return A->getKind() == attr::FlagEnum; }
3293
};
3294
3295
class FlattenAttr : public InheritableAttr {
3296
public:
3297
  static FlattenAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3298
    auto *A = new (Ctx) FlattenAttr(Loc, Ctx, 0);
3299
    A->setImplicit(true);
3300
    return A;
3301
  }
3302
3303
  FlattenAttr(SourceRange R, ASTContext &Ctx
3304
              , unsigned SI
3305
             )
3306
    : InheritableAttr(attr::Flatten, R, SI, false, false)
3307
10
  {
3308
10
  }
3309
3310
  FlattenAttr *clone(ASTContext &C) const;
3311
  void printPretty(raw_ostream &OS,
3312
                   const PrintingPolicy &Policy) const;
3313
  const char *getSpelling() const;
3314
3315
3316
150k
  static bool classof(const Attr *A) { return A->getKind() == attr::Flatten; }
3317
};
3318
3319
class FormatAttr : public InheritableAttr {
3320
IdentifierInfo * type;
3321
3322
int formatIdx;
3323
3324
int firstArg;
3325
3326
public:
3327
23.7k
  static FormatAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Type, int FormatIdx, int FirstArg, SourceRange Loc = SourceRange()) {
3328
23.7k
    auto *A = new (Ctx) FormatAttr(Loc, Ctx, Type, FormatIdx, FirstArg, 0);
3329
23.7k
    A->setImplicit(true);
3330
23.7k
    return A;
3331
23.7k
  }
3332
3333
  FormatAttr(SourceRange R, ASTContext &Ctx
3334
              , IdentifierInfo * Type
3335
              , int FormatIdx
3336
              , int FirstArg
3337
              , unsigned SI
3338
             )
3339
    : InheritableAttr(attr::Format, R, SI, false, false)
3340
              , type(Type)
3341
              , formatIdx(FormatIdx)
3342
              , firstArg(FirstArg)
3343
74.8k
  {
3344
74.8k
  }
3345
3346
  FormatAttr *clone(ASTContext &C) const;
3347
  void printPretty(raw_ostream &OS,
3348
                   const PrintingPolicy &Policy) const;
3349
  const char *getSpelling() const;
3350
88.9k
  IdentifierInfo * getType() const {
3351
88.9k
    return type;
3352
88.9k
  }
3353
3354
88.2k
  int getFormatIdx() const {
3355
88.2k
    return formatIdx;
3356
88.2k
  }
3357
3358
130k
  int getFirstArg() const {
3359
130k
    return firstArg;
3360
130k
  }
3361
3362
3363
3364
4.42M
  static bool classof(const Attr *A) { return A->getKind() == attr::Format; }
3365
};
3366
3367
class FormatArgAttr : public InheritableAttr {
3368
ParamIdx formatIdx;
3369
3370
public:
3371
1
  static FormatArgAttr *CreateImplicit(ASTContext &Ctx, ParamIdx FormatIdx, SourceRange Loc = SourceRange()) {
3372
1
    auto *A = new (Ctx) FormatArgAttr(Loc, Ctx, FormatIdx, 0);
3373
1
    A->setImplicit(true);
3374
1
    return A;
3375
1
  }
3376
3377
  FormatArgAttr(SourceRange R, ASTContext &Ctx
3378
              , ParamIdx FormatIdx
3379
              , unsigned SI
3380
             )
3381
    : InheritableAttr(attr::FormatArg, R, SI, false, false)
3382
              , formatIdx(FormatIdx)
3383
364
  {
3384
364
  }
3385
3386
  FormatArgAttr *clone(ASTContext &C) const;
3387
  void printPretty(raw_ostream &OS,
3388
                   const PrintingPolicy &Policy) const;
3389
  const char *getSpelling() const;
3390
35
  ParamIdx getFormatIdx() const {
3391
35
    return formatIdx;
3392
35
  }
3393
3394
3395
3396
97
  static bool classof(const Attr *A) { return A->getKind() == attr::FormatArg; }
3397
};
3398
3399
class GNUInlineAttr : public InheritableAttr {
3400
public:
3401
  static GNUInlineAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3402
    auto *A = new (Ctx) GNUInlineAttr(Loc, Ctx, 0);
3403
    A->setImplicit(true);
3404
    return A;
3405
  }
3406
3407
  GNUInlineAttr(SourceRange R, ASTContext &Ctx
3408
              , unsigned SI
3409
             )
3410
    : InheritableAttr(attr::GNUInline, R, SI, false, false)
3411
113
  {
3412
113
  }
3413
3414
  GNUInlineAttr *clone(ASTContext &C) const;
3415
  void printPretty(raw_ostream &OS,
3416
                   const PrintingPolicy &Policy) const;
3417
  const char *getSpelling() const;
3418
3419
3420
3.42M
  static bool classof(const Attr *A) { return A->getKind() == attr::GNUInline; }
3421
};
3422
3423
class GuardedByAttr : public InheritableAttr {
3424
Expr * arg;
3425
3426
public:
3427
  static GuardedByAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) {
3428
    auto *A = new (Ctx) GuardedByAttr(Loc, Ctx, Arg, 0);
3429
    A->setImplicit(true);
3430
    return A;
3431
  }
3432
3433
  GuardedByAttr(SourceRange R, ASTContext &Ctx
3434
              , Expr * Arg
3435
              , unsigned SI
3436
             )
3437
    : InheritableAttr(attr::GuardedBy, R, SI, true, true)
3438
              , arg(Arg)
3439
572
  {
3440
572
  }
3441
3442
  GuardedByAttr *clone(ASTContext &C) const;
3443
  void printPretty(raw_ostream &OS,
3444
                   const PrintingPolicy &Policy) const;
3445
  const char *getSpelling() const;
3446
3.67k
  Expr * getArg() const {
3447
3.67k
    return arg;
3448
3.67k
  }
3449
3450
3451
3452
293k
  static bool classof(const Attr *A) { return A->getKind() == attr::GuardedBy; }
3453
};
3454
3455
class GuardedVarAttr : public InheritableAttr {
3456
public:
3457
  static GuardedVarAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3458
    auto *A = new (Ctx) GuardedVarAttr(Loc, Ctx, 0);
3459
    A->setImplicit(true);
3460
    return A;
3461
  }
3462
3463
  GuardedVarAttr(SourceRange R, ASTContext &Ctx
3464
              , unsigned SI
3465
             )
3466
    : InheritableAttr(attr::GuardedVar, R, SI, false, false)
3467
14
  {
3468
14
  }
3469
3470
  GuardedVarAttr *clone(ASTContext &C) const;
3471
  void printPretty(raw_ostream &OS,
3472
                   const PrintingPolicy &Policy) const;
3473
  const char *getSpelling() const;
3474
3475
3476
2.67k
  static bool classof(const Attr *A) { return A->getKind() == attr::GuardedVar; }
3477
};
3478
3479
class HotAttr : public InheritableAttr {
3480
public:
3481
  static HotAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3482
    auto *A = new (Ctx) HotAttr(Loc, Ctx, 0);
3483
    A->setImplicit(true);
3484
    return A;
3485
  }
3486
3487
  HotAttr(SourceRange R, ASTContext &Ctx
3488
              , unsigned SI
3489
             )
3490
    : InheritableAttr(attr::Hot, R, SI, false, false)
3491
2
  {
3492
2
  }
3493
3494
  HotAttr *clone(ASTContext &C) const;
3495
  void printPretty(raw_ostream &OS,
3496
                   const PrintingPolicy &Policy) const;
3497
  const char *getSpelling() const;
3498
3499
3500
5
  static bool classof(const Attr *A) { return A->getKind() == attr::Hot; }
3501
};
3502
3503
class IBActionAttr : public InheritableAttr {
3504
public:
3505
  static IBActionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3506
    auto *A = new (Ctx) IBActionAttr(Loc, Ctx, 0);
3507
    A->setImplicit(true);
3508
    return A;
3509
  }
3510
3511
  IBActionAttr(SourceRange R, ASTContext &Ctx
3512
              , unsigned SI
3513
             )
3514
    : InheritableAttr(attr::IBAction, R, SI, false, false)
3515
57
  {
3516
57
  }
3517
3518
  IBActionAttr *clone(ASTContext &C) const;
3519
  void printPretty(raw_ostream &OS,
3520
                   const PrintingPolicy &Policy) const;
3521
  const char *getSpelling() const;
3522
3523
3524
  static bool classof(const Attr *A) { return A->getKind() == attr::IBAction; }
3525
};
3526
3527
class IBOutletAttr : public InheritableAttr {
3528
public:
3529
  static IBOutletAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3530
    auto *A = new (Ctx) IBOutletAttr(Loc, Ctx, 0);
3531
    A->setImplicit(true);
3532
    return A;
3533
  }
3534
3535
  IBOutletAttr(SourceRange R, ASTContext &Ctx
3536
              , unsigned SI
3537
             )
3538
    : InheritableAttr(attr::IBOutlet, R, SI, false, false)
3539
38
  {
3540
38
  }
3541
3542
  IBOutletAttr *clone(ASTContext &C) const;
3543
  void printPretty(raw_ostream &OS,
3544
                   const PrintingPolicy &Policy) const;
3545
  const char *getSpelling() const;
3546
3547
3548
32
  static bool classof(const Attr *A) { return A->getKind() == attr::IBOutlet; }
3549
};
3550
3551
class IBOutletCollectionAttr : public InheritableAttr {
3552
TypeSourceInfo * interface_;
3553
3554
public:
3555
  static IBOutletCollectionAttr *CreateImplicit(ASTContext &Ctx, TypeSourceInfo * Interface, SourceRange Loc = SourceRange()) {
3556
    auto *A = new (Ctx) IBOutletCollectionAttr(Loc, Ctx, Interface, 0);
3557
    A->setImplicit(true);
3558
    return A;
3559
  }
3560
3561
  IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx
3562
              , TypeSourceInfo * Interface
3563
              , unsigned SI
3564
             )
3565
    : InheritableAttr(attr::IBOutletCollection, R, SI, false, false)
3566
              , interface_(Interface)
3567
28
  {
3568
28
  }
3569
3570
  IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx
3571
              , unsigned SI
3572
             )
3573
    : InheritableAttr(attr::IBOutletCollection, R, SI, false, false)
3574
              , interface_()
3575
  {
3576
  }
3577
3578
  IBOutletCollectionAttr *clone(ASTContext &C) const;
3579
  void printPretty(raw_ostream &OS,
3580
                   const PrintingPolicy &Policy) const;
3581
  const char *getSpelling() const;
3582
12
  QualType getInterface() const {
3583
12
    return interface_->getType();
3584
12
  }  TypeSourceInfo * getInterfaceLoc() const {
3585
10
    return interface_;
3586
10
  }
3587
3588
3589
3590
182
  static bool classof(const Attr *A) { return A->getKind() == attr::IBOutletCollection; }
3591
};
3592
3593
class IFuncAttr : public Attr {
3594
unsigned resolverLength;
3595
char *resolver;
3596
3597
public:
3598
  static IFuncAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Resolver, SourceRange Loc = SourceRange()) {
3599
    auto *A = new (Ctx) IFuncAttr(Loc, Ctx, Resolver, 0);
3600
    A->setImplicit(true);
3601
    return A;
3602
  }
3603
3604
  IFuncAttr(SourceRange R, ASTContext &Ctx
3605
              , llvm::StringRef Resolver
3606
              , unsigned SI
3607
             )
3608
    : Attr(attr::IFunc, R, SI, false)
3609
              , resolverLength(Resolver.size()),resolver(new (Ctx, 1) char[resolverLength])
3610
12
  {
3611
12
      if (!Resolver.empty())
3612
12
        std::memcpy(resolver, Resolver.data(), resolverLength);
3613
12
  }
3614
3615
  IFuncAttr *clone(ASTContext &C) const;
3616
  void printPretty(raw_ostream &OS,
3617
                   const PrintingPolicy &Policy) const;
3618
  const char *getSpelling() const;
3619
21
  llvm::StringRef getResolver() const {
3620
21
    return llvm::StringRef(resolver, resolverLength);
3621
21
  }
3622
  unsigned getResolverLength() const {
3623
    return resolverLength;
3624
  }
3625
  void setResolver(ASTContext &C, llvm::StringRef S) {
3626
    resolverLength = S.size();
3627
    this->resolver = new (C, 1) char [resolverLength];
3628
    if (!S.empty())
3629
      std::memcpy(this->resolver, S.data(), resolverLength);
3630
  }
3631
3632
3633
3634
18.5M
  static bool classof(const Attr *A) { return A->getKind() == attr::IFunc; }
3635
};
3636
3637
class InitPriorityAttr : public InheritableAttr {
3638
unsigned priority;
3639
3640
public:
3641
  static InitPriorityAttr *CreateImplicit(ASTContext &Ctx, unsigned Priority, SourceRange Loc = SourceRange()) {
3642
    auto *A = new (Ctx) InitPriorityAttr(Loc, Ctx, Priority, 0);
3643
    A->setImplicit(true);
3644
    return A;
3645
  }
3646
3647
  InitPriorityAttr(SourceRange R, ASTContext &Ctx
3648
              , unsigned Priority
3649
              , unsigned SI
3650
             )
3651
    : InheritableAttr(attr::InitPriority, R, SI, false, false)
3652
              , priority(Priority)
3653
820
  {
3654
820
  }
3655
3656
  InitPriorityAttr *clone(ASTContext &C) const;
3657
  void printPretty(raw_ostream &OS,
3658
                   const PrintingPolicy &Policy) const;
3659
  const char *getSpelling() const;
3660
711
  unsigned getPriority() const {
3661
711
    return priority;
3662
711
  }
3663
3664
3665
3666
1.28k
  static bool classof(const Attr *A) { return A->getKind() == attr::InitPriority; }
3667
};
3668
3669
class InitSegAttr : public Attr {
3670
unsigned sectionLength;
3671
char *section;
3672
3673
public:
3674
10
  static InitSegAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Section, SourceRange Loc = SourceRange()) {
3675
10
    auto *A = new (Ctx) InitSegAttr(Loc, Ctx, Section, 0);
3676
10
    A->setImplicit(true);
3677
10
    return A;
3678
10
  }
3679
3680
  InitSegAttr(SourceRange R, ASTContext &Ctx
3681
              , llvm::StringRef Section
3682
              , unsigned SI
3683
             )
3684
    : Attr(attr::InitSeg, R, SI, false)
3685
              , sectionLength(Section.size()),section(new (Ctx, 1) char[sectionLength])
3686
12
  {
3687
12
      if (!Section.empty())
3688
12
        std::memcpy(section, Section.data(), sectionLength);
3689
12
  }
3690
3691
  InitSegAttr *clone(ASTContext &C) const;
3692
  void printPretty(raw_ostream &OS,
3693
                   const PrintingPolicy &Policy) const;
3694
  const char *getSpelling() const;
3695
9
  llvm::StringRef getSection() const {
3696
9
    return llvm::StringRef(section, sectionLength);
3697
9
  }
3698
  unsigned getSectionLength() const {
3699
    return sectionLength;
3700
  }
3701
  void setSection(ASTContext &C, llvm::StringRef S) {
3702
    sectionLength = S.size();
3703
    this->section = new (C, 1) char [sectionLength];
3704
    if (!S.empty())
3705
      std::memcpy(this->section, S.data(), sectionLength);
3706
  }
3707
3708
3709
1
  void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3710
1
    OS << " (" << getSection() << ')';
3711
1
  }
3712
  
3713
3714
820
  static bool classof(const Attr *A) { return A->getKind() == attr::InitSeg; }
3715
};
3716
3717
class IntelOclBiccAttr : public InheritableAttr {
3718
public:
3719
  static IntelOclBiccAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3720
    auto *A = new (Ctx) IntelOclBiccAttr(Loc, Ctx, 0);
3721
    A->setImplicit(true);
3722
    return A;
3723
  }
3724
3725
  IntelOclBiccAttr(SourceRange R, ASTContext &Ctx
3726
              , unsigned SI
3727
             )
3728
    : InheritableAttr(attr::IntelOclBicc, R, SI, false, false)
3729
6
  {
3730
6
  }
3731
3732
  IntelOclBiccAttr *clone(ASTContext &C) const;
3733
  void printPretty(raw_ostream &OS,
3734
                   const PrintingPolicy &Policy) const;
3735
  const char *getSpelling() const;
3736
3737
3738
307
  static bool classof(const Attr *A) { return A->getKind() == attr::IntelOclBicc; }
3739
};
3740
3741
class InternalLinkageAttr : public InheritableAttr {
3742
public:
3743
  static InternalLinkageAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3744
    auto *A = new (Ctx) InternalLinkageAttr(Loc, Ctx, 0);
3745
    A->setImplicit(true);
3746
    return A;
3747
  }
3748
3749
  InternalLinkageAttr(SourceRange R, ASTContext &Ctx
3750
              , unsigned SI
3751
             )
3752
    : InheritableAttr(attr::InternalLinkage, R, SI, false, false)
3753
172
  {
3754
172
  }
3755
3756
  InternalLinkageAttr *clone(ASTContext &C) const;
3757
  void printPretty(raw_ostream &OS,
3758
                   const PrintingPolicy &Policy) const;
3759
  const char *getSpelling() const;
3760
3761
3762
66.8M
  static bool classof(const Attr *A) { return A->getKind() == attr::InternalLinkage; }
3763
};
3764
3765
class LTOVisibilityPublicAttr : public InheritableAttr {
3766
public:
3767
  static LTOVisibilityPublicAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3768
    auto *A = new (Ctx) LTOVisibilityPublicAttr(Loc, Ctx, 0);
3769
    A->setImplicit(true);
3770
    return A;
3771
  }
3772
3773
  LTOVisibilityPublicAttr(SourceRange R, ASTContext &Ctx
3774
              , unsigned SI
3775
             )
3776
    : InheritableAttr(attr::LTOVisibilityPublic, R, SI, false, false)
3777
5
  {
3778
5
  }
3779
3780
  LTOVisibilityPublicAttr *clone(ASTContext &C) const;
3781
  void printPretty(raw_ostream &OS,
3782
                   const PrintingPolicy &Policy) const;
3783
  const char *getSpelling() const;
3784
3785
3786
14
  static bool classof(const Attr *A) { return A->getKind() == attr::LTOVisibilityPublic; }
3787
};
3788
3789
class LayoutVersionAttr : public InheritableAttr {
3790
unsigned version;
3791
3792
public:
3793
  static LayoutVersionAttr *CreateImplicit(ASTContext &Ctx, unsigned Version, SourceRange Loc = SourceRange()) {
3794
    auto *A = new (Ctx) LayoutVersionAttr(Loc, Ctx, Version, 0);
3795
    A->setImplicit(true);
3796
    return A;
3797
  }
3798
3799
  LayoutVersionAttr(SourceRange R, ASTContext &Ctx
3800
              , unsigned Version
3801
              , unsigned SI
3802
             )
3803
    : InheritableAttr(attr::LayoutVersion, R, SI, false, false)
3804
              , version(Version)
3805
1
  {
3806
1
  }
3807
3808
  LayoutVersionAttr *clone(ASTContext &C) const;
3809
  void printPretty(raw_ostream &OS,
3810
                   const PrintingPolicy &Policy) const;
3811
  const char *getSpelling() const;
3812
0
  unsigned getVersion() const {
3813
0
    return version;
3814
0
  }
3815
3816
3817
3818
864
  static bool classof(const Attr *A) { return A->getKind() == attr::LayoutVersion; }
3819
};
3820
3821
class LifetimeBoundAttr : public InheritableAttr {
3822
public:
3823
  static LifetimeBoundAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3824
    auto *A = new (Ctx) LifetimeBoundAttr(Loc, Ctx, 0);
3825
    A->setImplicit(true);
3826
    return A;
3827
  }
3828
3829
  LifetimeBoundAttr(SourceRange R, ASTContext &Ctx
3830
              , unsigned SI
3831
             )
3832
    : InheritableAttr(attr::LifetimeBound, R, SI, false, false)
3833
21
  {
3834
21
  }
3835
3836
  LifetimeBoundAttr *clone(ASTContext &C) const;
3837
  void printPretty(raw_ostream &OS,
3838
                   const PrintingPolicy &Policy) const;
3839
  const char *getSpelling() const;
3840
3841
3842
2.90k
  static bool classof(const Attr *A) { return A->getKind() == attr::LifetimeBound; }
3843
};
3844
3845
class LockReturnedAttr : public InheritableAttr {
3846
Expr * arg;
3847
3848
public:
3849
  static LockReturnedAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) {
3850
    auto *A = new (Ctx) LockReturnedAttr(Loc, Ctx, Arg, 0);
3851
    A->setImplicit(true);
3852
    return A;
3853
  }
3854
3855
  LockReturnedAttr(SourceRange R, ASTContext &Ctx
3856
              , Expr * Arg
3857
              , unsigned SI
3858
             )
3859
    : InheritableAttr(attr::LockReturned, R, SI, true, false)
3860
              , arg(Arg)
3861
87
  {
3862
87
  }
3863
3864
  LockReturnedAttr *clone(ASTContext &C) const;
3865
  void printPretty(raw_ostream &OS,
3866
                   const PrintingPolicy &Policy) const;
3867
  const char *getSpelling() const;
3868
183
  Expr * getArg() const {
3869
183
    return arg;
3870
183
  }
3871
3872
3873
3874
289k
  static bool classof(const Attr *A) { return A->getKind() == attr::LockReturned; }
3875
};
3876
3877
class LocksExcludedAttr : public InheritableAttr {
3878
  unsigned args_Size;
3879
  Expr * *args_;
3880
3881
public:
3882
  static LocksExcludedAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
3883
    auto *A = new (Ctx) LocksExcludedAttr(Loc, Ctx, Args, ArgsSize, 0);
3884
    A->setImplicit(true);
3885
    return A;
3886
  }
3887
3888
  LocksExcludedAttr(SourceRange R, ASTContext &Ctx
3889
              , Expr * *Args, unsigned ArgsSize
3890
              , unsigned SI
3891
             )
3892
    : InheritableAttr(attr::LocksExcluded, R, SI, true, true)
3893
              , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
3894
156
  {
3895
156
    std::copy(Args, Args + args_Size, args_);
3896
156
  }
3897
3898
  LocksExcludedAttr(SourceRange R, ASTContext &Ctx
3899
              , unsigned SI
3900
             )
3901
    : InheritableAttr(attr::LocksExcluded, R, SI, true, true)
3902
              , args_Size(0), args_(nullptr)
3903
  {
3904
  }
3905
3906
  LocksExcludedAttr *clone(ASTContext &C) const;
3907
  void printPretty(raw_ostream &OS,
3908
                   const PrintingPolicy &Policy) const;
3909
  const char *getSpelling() const;
3910
  typedef Expr ** args_iterator;
3911
246
  args_iterator args_begin() const { return args_; }
3912
246
  args_iterator args_end() const { return args_ + args_Size; }
3913
8
  unsigned args_size() const { return args_Size; }
3914
242
  llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
3915
3916
3917
3918
3919
289k
  static bool classof(const Attr *A) { return A->getKind() == attr::LocksExcluded; }
3920
};
3921
3922
class LoopHintAttr : public Attr {
3923
public:
3924
  enum OptionType {
3925
    Vectorize,
3926
    VectorizeWidth,
3927
    Interleave,
3928
    InterleaveCount,
3929
    Unroll,
3930
    UnrollCount,
3931
    UnrollAndJam,
3932
    UnrollAndJamCount,
3933
    Distribute
3934
  };
3935
private:
3936
  OptionType option;
3937
3938
public:
3939
  enum LoopHintState {
3940
    Enable,
3941
    Disable,
3942
    Numeric,
3943
    AssumeSafety,
3944
    Full
3945
  };
3946
private:
3947
  LoopHintState state;
3948
3949
Expr * value;
3950
3951
public:
3952
  enum Spelling {
3953
    Pragma_clang_loop = 0,
3954
    Pragma_unroll = 1,
3955
    Pragma_nounroll = 2,
3956
    Pragma_unroll_and_jam = 3,
3957
    Pragma_nounroll_and_jam = 4
3958
  };
3959
3960
240
  static LoopHintAttr *CreateImplicit(ASTContext &Ctx, Spelling S, OptionType Option, LoopHintState State, Expr * Value, SourceRange Loc = SourceRange()) {
3961
240
    auto *A = new (Ctx) LoopHintAttr(Loc, Ctx, Option, State, Value, S);
3962
240
    A->setImplicit(true);
3963
240
    return A;
3964
240
  }
3965
3966
  LoopHintAttr(SourceRange R, ASTContext &Ctx
3967
              , OptionType Option
3968
              , LoopHintState State
3969
              , Expr * Value
3970
              , unsigned SI
3971
             )
3972
    : Attr(attr::LoopHint, R, SI, false)
3973
              , option(Option)
3974
              , state(State)
3975
              , value(Value)
3976
258
  {
3977
258
  }
3978
3979
  LoopHintAttr *clone(ASTContext &C) const;
3980
  void printPretty(raw_ostream &OS,
3981
                   const PrintingPolicy &Policy) const;
3982
  const char *getSpelling() const;
3983
27
  Spelling getSemanticSpelling() const {
3984
27
  switch (SpellingListIndex) {
3985
27
    
default: 0
llvm_unreachable0
("Unknown spelling list index");
3986
27
    case 0: return Pragma_clang_loop;
3987
27
    
case 1: return Pragma_unroll0
;
3988
27
    
case 2: return Pragma_nounroll0
;
3989
27
    
case 3: return Pragma_unroll_and_jam0
;
3990
27
    
case 4: return Pragma_nounroll_and_jam0
;
3991
27
  }
3992
27
  }
3993
335
  OptionType getOption() const {
3994
335
    return option;
3995
335
  }
3996
3997
  static bool ConvertStrToOptionType(StringRef Val, OptionType &Out) {
3998
    Optional<OptionType> R = llvm::StringSwitch<Optional<OptionType>>(Val)
3999
      .Case("vectorize", LoopHintAttr::Vectorize)
4000
      .Case("vectorize_width", LoopHintAttr::VectorizeWidth)
4001
      .Case("interleave", LoopHintAttr::Interleave)
4002
      .Case("interleave_count", LoopHintAttr::InterleaveCount)
4003
      .Case("unroll", LoopHintAttr::Unroll)
4004
      .Case("unroll_count", LoopHintAttr::UnrollCount)
4005
      .Case("unroll_and_jam", LoopHintAttr::UnrollAndJam)
4006
      .Case("unroll_and_jam_count", LoopHintAttr::UnrollAndJamCount)
4007
      .Case("distribute", LoopHintAttr::Distribute)
4008
      .Default(Optional<OptionType>());
4009
    if (R) {
4010
      Out = *R;
4011
      return true;
4012
    }
4013
    return false;
4014
  }
4015
4016
  static const char *ConvertOptionTypeToStr(OptionType Val) {
4017
    switch(Val) {
4018
    case LoopHintAttr::Vectorize: return "vectorize";
4019
    case LoopHintAttr::VectorizeWidth: return "vectorize_width";
4020
    case LoopHintAttr::Interleave: return "interleave";
4021
    case LoopHintAttr::InterleaveCount: return "interleave_count";
4022
    case LoopHintAttr::Unroll: return "unroll";
4023
    case LoopHintAttr::UnrollCount: return "unroll_count";
4024
    case LoopHintAttr::UnrollAndJam: return "unroll_and_jam";
4025
    case LoopHintAttr::UnrollAndJamCount: return "unroll_and_jam_count";
4026
    case LoopHintAttr::Distribute: return "distribute";
4027
    }
4028
    llvm_unreachable("No enumerator with that value");
4029
  }
4030
128
  LoopHintState getState() const {
4031
128
    return state;
4032
128
  }
4033
4034
  static bool ConvertStrToLoopHintState(StringRef Val, LoopHintState &Out) {
4035
    Optional<LoopHintState> R = llvm::StringSwitch<Optional<LoopHintState>>(Val)
4036
      .Case("enable", LoopHintAttr::Enable)
4037
      .Case("disable", LoopHintAttr::Disable)
4038
      .Case("numeric", LoopHintAttr::Numeric)
4039
      .Case("assume_safety", LoopHintAttr::AssumeSafety)
4040
      .Case("full", LoopHintAttr::Full)
4041
      .Default(Optional<LoopHintState>());
4042
    if (R) {
4043
      Out = *R;
4044
      return true;
4045
    }
4046
    return false;
4047
  }
4048
4049
  static const char *ConvertLoopHintStateToStr(LoopHintState Val) {
4050
    switch(Val) {
4051
    case LoopHintAttr::Enable: return "enable";
4052
    case LoopHintAttr::Disable: return "disable";
4053
    case LoopHintAttr::Numeric: return "numeric";
4054
    case LoopHintAttr::AssumeSafety: return "assume_safety";
4055
    case LoopHintAttr::Full: return "full";
4056
    }
4057
    llvm_unreachable("No enumerator with that value");
4058
  }
4059
173
  Expr * getValue() const {
4060
173
    return value;
4061
173
  }
4062
4063
4064
76
  static const char *getOptionName(int Option) {
4065
76
    switch(Option) {
4066
76
    
case Vectorize: return "vectorize"12
;
4067
76
    
case VectorizeWidth: return "vectorize_width"13
;
4068
76
    
case Interleave: return "interleave"12
;
4069
76
    
case InterleaveCount: return "interleave_count"13
;
4070
76
    
case Unroll: return "unroll"11
;
4071
76
    
case UnrollCount: return "unroll_count"7
;
4072
76
    
case UnrollAndJam: return "unroll_and_jam"0
;
4073
76
    
case UnrollAndJamCount: return "unroll_and_jam_count"0
;
4074
76
    
case Distribute: return "distribute"8
;
4075
0
    }
4076
0
    llvm_unreachable("Unhandled LoopHint option.");
4077
0
  }
4078
4079
42
  void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
4080
42
    unsigned SpellingIndex = getSpellingListIndex();
4081
42
    // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
4082
42
    // "nounroll" is already emitted as the pragma name.
4083
42
    if (SpellingIndex == Pragma_nounroll || 
SpellingIndex == Pragma_nounroll_and_jam41
)
4084
1
      return;
4085
41
    else if (SpellingIndex == Pragma_unroll || 
SpellingIndex == Pragma_unroll_and_jam39
) {
4086
2
      OS << ' ' << getValueString(Policy);
4087
2
      return;
4088
2
    }
4089
39
4090
39
    assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
4091
39
    OS << ' ' << getOptionName(option) << getValueString(Policy);
4092
39
  }
4093
4094
  // Return a string containing the loop hint argument including the
4095
  // enclosing parentheses.
4096
85
  std::string getValueString(const PrintingPolicy &Policy) const {
4097
85
    std::string ValueName;
4098
85
    llvm::raw_string_ostream OS(ValueName);
4099
85
    OS << "(";
4100
85
    if (state == Numeric)
4101
41
      value->printPretty(OS, nullptr, Policy);
4102
44
    else if (state == Enable)
4103
16
      OS << "enable";
4104
28
    else if (state == Full)
4105
5
      OS << "full";
4106
23
    else if (state == AssumeSafety)
4107
2
      OS << "assume_safety";
4108
21
    else
4109
21
      OS << "disable";
4110
85
    OS << ")";
4111
85
    return OS.str();
4112
85
  }
4113
4114
  // Return a string suitable for identifying this attribute in diagnostics.
4115
52
  std::string getDiagnosticName(const PrintingPolicy &Policy) const {
4116
52
    unsigned SpellingIndex = getSpellingListIndex();
4117
52
    if (SpellingIndex == Pragma_nounroll)
4118
3
      return "#pragma nounroll";
4119
49
    else if (SpellingIndex == Pragma_unroll)
4120
10
      return "#pragma unroll" + (option == UnrollCount ? 
getValueString(Policy)6
:
""4
);
4121
39
    else if (SpellingIndex == Pragma_nounroll_and_jam)
4122
1
      return "#pragma nounroll_and_jam";
4123
38
    else if (SpellingIndex == Pragma_unroll_and_jam)
4124
1
      return "#pragma unroll_and_jam" +
4125
1
        (option == UnrollAndJamCount ? getValueString(Policy) : 
""0
);
4126
37
4127
37
    assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
4128
37
    return getOptionName(option) + getValueString(Policy);
4129
37
  }
4130
  
4131
4132
391
  static bool classof(const Attr *A) { return A->getKind() == attr::LoopHint; }
4133
};
4134
4135
class MSABIAttr : public InheritableAttr {
4136
public:
4137
  static MSABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4138
    auto *A = new (Ctx) MSABIAttr(Loc, Ctx, 0);
4139
    A->setImplicit(true);
4140
    return A;
4141
  }
4142
4143
  MSABIAttr(SourceRange R, ASTContext &Ctx
4144
              , unsigned SI
4145
             )
4146
    : InheritableAttr(attr::MSABI, R, SI, false, false)
4147
36
  {
4148
36
  }
4149
4150
  MSABIAttr *clone(ASTContext &C) const;
4151
  void printPretty(raw_ostream &OS,
4152
                   const PrintingPolicy &Policy) const;
4153
  const char *getSpelling() const;
4154
4155
4156
307
  static bool classof(const Attr *A) { return A->getKind() == attr::MSABI; }
4157
};
4158
4159
class MSInheritanceAttr : public InheritableAttr {
4160
bool bestCase;
4161
4162
public:
4163
  enum Spelling {
4164
    Keyword_single_inheritance = 0,
4165
    Keyword_multiple_inheritance = 1,
4166
    Keyword_virtual_inheritance = 2,
4167
    Keyword_unspecified_inheritance = 3
4168
  };
4169
4170
556
  static MSInheritanceAttr *CreateImplicit(ASTContext &Ctx, Spelling S, bool BestCase, SourceRange Loc = SourceRange()) {
4171
556
    auto *A = new (Ctx) MSInheritanceAttr(Loc, Ctx, BestCase, S);
4172
556
    A->setImplicit(true);
4173
556
    return A;
4174
556
  }
4175
4176
0
  static MSInheritanceAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
4177
0
    auto *A = new (Ctx) MSInheritanceAttr(Loc, Ctx, S);
4178
0
    A->setImplicit(true);
4179
0
    return A;
4180
0
  }
4181
4182
  MSInheritanceAttr(SourceRange R, ASTContext &Ctx
4183
              , bool BestCase
4184
              , unsigned SI
4185
             )
4186
    : InheritableAttr(attr::MSInheritance, R, SI, false, false)
4187
              , bestCase(BestCase)
4188
631
  {
4189
631
  }
4190
4191
  MSInheritanceAttr(SourceRange R, ASTContext &Ctx
4192
              , unsigned SI
4193
             )
4194
    : InheritableAttr(attr::MSInheritance, R, SI, false, false)
4195
              , bestCase()
4196
  {
4197
  }
4198
4199
  MSInheritanceAttr *clone(ASTContext &C) const;
4200
  void printPretty(raw_ostream &OS,
4201
                   const PrintingPolicy &Policy) const;
4202
  const char *getSpelling() const;
4203
2.50k
  Spelling getSemanticSpelling() const {
4204
2.50k
  switch (SpellingListIndex) {
4205
2.50k
    
default: 0
llvm_unreachable0
("Unknown spelling list index");
4206
2.50k
    
case 0: return Keyword_single_inheritance1.74k
;
4207
2.50k
    
case 1: return Keyword_multiple_inheritance201
;
4208
2.50k
    
case 2: return Keyword_virtual_inheritance151
;
4209
2.50k
    
case 3: return Keyword_unspecified_inheritance415
;
4210
2.50k
  }
4211
2.50k
  }
4212
74
  bool getBestCase() const {
4213
74
    return bestCase;
4214
74
  }
4215
4216
  static const bool DefaultBestCase = true;
4217
4218
4219
1.51k
  static bool hasVBPtrOffsetField(Spelling Inheritance) {
4220
1.51k
    return Inheritance == Keyword_unspecified_inheritance;
4221
1.51k
  }
4222
4223
  // Only member pointers to functions need a this adjustment, since it can be
4224
  // combined with the field offset for data pointers.
4225
1.41k
  static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
4226
1.41k
    return IsMemberFunction && 
Inheritance >= Keyword_multiple_inheritance1.14k
;
4227
1.41k
  }
4228
4229
1.56k
  static bool hasVBTableOffsetField(Spelling Inheritance) {
4230
1.56k
    return Inheritance >= Keyword_virtual_inheritance;
4231
1.56k
  }
4232
4233
  static bool hasOnlyOneField(bool IsMemberFunction,
4234
624
                              Spelling Inheritance) {
4235
624
    if (IsMemberFunction)
4236
491
      return Inheritance <= Keyword_single_inheritance;
4237
133
    return Inheritance <= Keyword_multiple_inheritance;
4238
133
  }
4239
  
4240
4241
990k
  static bool classof(const Attr *A) { return A->getKind() == attr::MSInheritance; }
4242
};
4243
4244
class MSNoVTableAttr : public InheritableAttr {
4245
public:
4246
  static MSNoVTableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4247
    auto *A = new (Ctx) MSNoVTableAttr(Loc, Ctx, 0);
4248
    A->setImplicit(true);
4249
    return A;
4250
  }
4251
4252
  MSNoVTableAttr(SourceRange R, ASTContext &Ctx
4253
              , unsigned SI
4254
             )
4255
    : InheritableAttr(attr::MSNoVTable, R, SI, false, false)
4256
6
  {
4257
6
  }
4258
4259
  MSNoVTableAttr *clone(ASTContext &C) const;
4260
  void printPretty(raw_ostream &OS,
4261
                   const PrintingPolicy &Policy) const;
4262
  const char *getSpelling() const;
4263
4264
4265
170
  static bool classof(const Attr *A) { return A->getKind() == attr::MSNoVTable; }
4266
};
4267
4268
class MSP430InterruptAttr : public InheritableAttr {
4269
unsigned number;
4270
4271
public:
4272
  static MSP430InterruptAttr *CreateImplicit(ASTContext &Ctx, unsigned Number, SourceRange Loc = SourceRange()) {
4273
    auto *A = new (Ctx) MSP430InterruptAttr(Loc, Ctx, Number, 0);
4274
    A->setImplicit(true);
4275
    return A;
4276
  }
4277
4278
  MSP430InterruptAttr(SourceRange R, ASTContext &Ctx
4279
              , unsigned Number
4280
              , unsigned SI
4281
             )
4282
    : InheritableAttr(attr::MSP430Interrupt, R, SI, false, false)
4283
              , number(Number)
4284
2
  {
4285
2
  }
4286
4287
  MSP430InterruptAttr *clone(ASTContext &C) const;
4288
  void printPretty(raw_ostream &OS,
4289
                   const PrintingPolicy &Policy) const;
4290
  const char *getSpelling() const;
4291
1
  unsigned getNumber() const {
4292
1
    return number;
4293
1
  }
4294
4295
4296
4297
0
  static bool classof(const Attr *A) { return A->getKind() == attr::MSP430Interrupt; }
4298
};
4299
4300
class MSStructAttr : public InheritableAttr {
4301
public:
4302
21
  static MSStructAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4303
21
    auto *A = new (Ctx) MSStructAttr(Loc, Ctx, 0);
4304
21
    A->setImplicit(true);
4305
21
    return A;
4306
21
  }
4307
4308
  MSStructAttr(SourceRange R, ASTContext &Ctx
4309
              , unsigned SI
4310
             )
4311
    : InheritableAttr(attr::MSStruct, R, SI, false, false)
4312
96
  {
4313
96
  }
4314
4315
  MSStructAttr *clone(ASTContext &C) const;
4316
  void printPretty(raw_ostream &OS,
4317
                   const PrintingPolicy &Policy) const;
4318
  const char *getSpelling() const;
4319
4320
4321
270k
  static bool classof(const Attr *A) { return A->getKind() == attr::MSStruct; }
4322
};
4323
4324
class MSVtorDispAttr : public InheritableAttr {
4325
unsigned vdm;
4326
4327
public:
4328
29
  static MSVtorDispAttr *CreateImplicit(ASTContext &Ctx, unsigned Vdm, SourceRange Loc = SourceRange()) {
4329
29
    auto *A = new (Ctx) MSVtorDispAttr(Loc, Ctx, Vdm, 0);
4330
29
    A->setImplicit(true);
4331
29
    return A;
4332
29
  }
4333
4334
  MSVtorDispAttr(SourceRange R, ASTContext &Ctx
4335
              , unsigned Vdm
4336
              , unsigned SI
4337
             )
4338
    : InheritableAttr(attr::MSVtorDisp, R, SI, false, false)
4339
              , vdm(Vdm)
4340
31
  {
4341
31
  }
4342
4343
  MSVtorDispAttr *clone(ASTContext &C) const;
4344
  void printPretty(raw_ostream &OS,
4345
                   const PrintingPolicy &Policy) const;
4346
  const char *getSpelling() const;
4347
0
  unsigned getVdm() const {
4348
0
    return vdm;
4349
0
  }
4350
4351
4352
  enum Mode {
4353
    Never,
4354
    ForVBaseOverride,
4355
    ForVFTable
4356
  };
4357
4358
26
  Mode getVtorDispMode() const { return Mode(vdm); }
4359
  
4360
4361
170
  static bool classof(const Attr *A) { return A->getKind() == attr::MSVtorDisp; }
4362
};
4363
4364
class MaxFieldAlignmentAttr : public InheritableAttr {
4365
unsigned alignment;
4366
4367
public:
4368
50.3k
  static MaxFieldAlignmentAttr *CreateImplicit(ASTContext &Ctx, unsigned Alignment, SourceRange Loc = SourceRange()) {
4369
50.3k
    auto *A = new (Ctx) MaxFieldAlignmentAttr(Loc, Ctx, Alignment, 0);
4370
50.3k
    A->setImplicit(true);
4371
50.3k
    return A;
4372
50.3k
  }
4373
4374
  MaxFieldAlignmentAttr(SourceRange R, ASTContext &Ctx
4375
              , unsigned Alignment
4376
              , unsigned SI
4377
             )
4378
    : InheritableAttr(attr::MaxFieldAlignment, R, SI, false, false)
4379
              , alignment(Alignment)
4380
50.3k
  {
4381
50.3k
  }
4382
4383
  MaxFieldAlignmentAttr *clone(ASTContext &C) const;
4384
  void printPretty(raw_ostream &OS,
4385
                   const PrintingPolicy &Policy) const;
4386
  const char *getSpelling() const;
4387
1.47k
  unsigned getAlignment() const {
4388
1.47k
    return alignment;
4389
1.47k
  }
4390
4391
4392
4393
22.7k
  static bool classof(const Attr *A) { return A->getKind() == attr::MaxFieldAlignment; }
4394
};
4395
4396
class MayAliasAttr : public InheritableAttr {
4397
public:
4398
  static MayAliasAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4399
    auto *A = new (Ctx) MayAliasAttr(Loc, Ctx, 0);
4400
    A->setImplicit(true);
4401
    return A;
4402
  }
4403
4404
  MayAliasAttr(SourceRange R, ASTContext &Ctx
4405
              , unsigned SI
4406
             )
4407
    : InheritableAttr(attr::MayAlias, R, SI, false, false)
4408
5.25k
  {
4409
5.25k
  }
4410
4411
  MayAliasAttr *clone(ASTContext &C) const;
4412
  void printPretty(raw_ostream &OS,
4413
                   const PrintingPolicy &Policy) const;
4414
  const char *getSpelling() const;
4415
4416
4417
82.0k
  static bool classof(const Attr *A) { return A->getKind() == attr::MayAlias; }
4418
};
4419
4420
class MicroMipsAttr : public InheritableAttr {
4421
public:
4422
  static MicroMipsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4423
    auto *A = new (Ctx) MicroMipsAttr(Loc, Ctx, 0);
4424
    A->setImplicit(true);
4425
    return A;
4426
  }
4427
4428
  MicroMipsAttr(SourceRange R, ASTContext &Ctx
4429
              , unsigned SI
4430
             )
4431
    : InheritableAttr(attr::MicroMips, R, SI, false, false)
4432
3
  {
4433
3
  }
4434
4435
  MicroMipsAttr *clone(ASTContext &C) const;
4436
  void printPretty(raw_ostream &OS,
4437
                   const PrintingPolicy &Policy) const;
4438
  const char *getSpelling() const;
4439
4440
4441
42
  static bool classof(const Attr *A) { return A->getKind() == attr::MicroMips; }
4442
};
4443
4444
class MinSizeAttr : public InheritableAttr {
4445
public:
4446
  static MinSizeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4447
    auto *A = new (Ctx) MinSizeAttr(Loc, Ctx, 0);
4448
    A->setImplicit(true);
4449
    return A;
4450
  }
4451
4452
  MinSizeAttr(SourceRange R, ASTContext &Ctx
4453
              , unsigned SI
4454
             )
4455
    : InheritableAttr(attr::MinSize, R, SI, false, false)
4456
35
  {
4457
35
  }
4458
4459
  MinSizeAttr *clone(ASTContext &C) const;
4460
  void printPretty(raw_ostream &OS,
4461
                   const PrintingPolicy &Policy) const;
4462
  const char *getSpelling() const;
4463
4464
4465
533k
  static bool classof(const Attr *A) { return A->getKind() == attr::MinSize; }
4466
};
4467
4468
class MinVectorWidthAttr : public InheritableAttr {
4469
unsigned vectorWidth;
4470
4471
public:
4472
  static MinVectorWidthAttr *CreateImplicit(ASTContext &Ctx, unsigned VectorWidth, SourceRange Loc = SourceRange()) {
4473
    auto *A = new (Ctx) MinVectorWidthAttr(Loc, Ctx, VectorWidth, 0);
4474
    A->setImplicit(true);
4475
    return A;
4476
  }
4477
4478
  MinVectorWidthAttr(SourceRange R, ASTContext &Ctx
4479
              , unsigned VectorWidth
4480
              , unsigned SI
4481
             )
4482
    : InheritableAttr(attr::MinVectorWidth, R, SI, false, false)
4483
              , vectorWidth(VectorWidth)
4484
509k
  {
4485
509k
  }
4486
4487
  MinVectorWidthAttr *clone(ASTContext &C) const;
4488
  void printPretty(raw_ostream &OS,
4489
                   const PrintingPolicy &Policy) const;
4490
  const char *getSpelling() const;
4491
20.4k
  unsigned getVectorWidth() const {
4492
20.4k
    return vectorWidth;
4493
20.4k
  }
4494
4495
4496
4497
1.69M
  static bool classof(const Attr *A) { return A->getKind() == attr::MinVectorWidth; }
4498
};
4499
4500
class Mips16Attr : public InheritableAttr {
4501
public:
4502
  static Mips16Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4503
    auto *A = new (Ctx) Mips16Attr(Loc, Ctx, 0);
4504
    A->setImplicit(true);
4505
    return A;
4506
  }
4507
4508
  Mips16Attr(SourceRange R, ASTContext &Ctx
4509
              , unsigned SI
4510
             )
4511
    : InheritableAttr(attr::Mips16, R, SI, false, false)
4512
9
  {
4513
9
  }
4514
4515
  Mips16Attr *clone(ASTContext &C) const;
4516
  void printPretty(raw_ostream &OS,
4517
                   const PrintingPolicy &Policy) const;
4518
  const char *getSpelling() const;
4519
4520
4521
46
  static bool classof(const Attr *A) { return A->getKind() == attr::Mips16; }
4522
};
4523
4524
class MipsInterruptAttr : public InheritableAttr {
4525
public:
4526
  enum InterruptType {
4527
    sw0,
4528
    sw1,
4529
    hw0,
4530
    hw1,
4531
    hw2,
4532
    hw3,
4533
    hw4,
4534
    hw5,
4535
    eic
4536
  };
4537
private:
4538
  InterruptType interrupt;
4539
4540
public:
4541
  static MipsInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) {
4542
    auto *A = new (Ctx) MipsInterruptAttr(Loc, Ctx, Interrupt, 0);
4543
    A->setImplicit(true);
4544
    return A;
4545
  }
4546
4547
  MipsInterruptAttr(SourceRange R, ASTContext &Ctx
4548
              , InterruptType Interrupt
4549
              , unsigned SI
4550
             )
4551
    : InheritableAttr(attr::MipsInterrupt, R, SI, false, false)
4552
              , interrupt(Interrupt)
4553
20
  {
4554
20
  }
4555
4556
  MipsInterruptAttr *clone(ASTContext &C) const;
4557
  void printPretty(raw_ostream &OS,
4558
                   const PrintingPolicy &Policy) const;
4559
  const char *getSpelling() const;
4560
9
  InterruptType getInterrupt() const {
4561
9
    return interrupt;
4562
9
  }
4563
4564
21
  static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) {
4565
21
    Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val)
4566
21
      .Case("vector=sw0", MipsInterruptAttr::sw0)
4567
21
      .Case("vector=sw1", MipsInterruptAttr::sw1)
4568
21
      .Case("vector=hw0", MipsInterruptAttr::hw0)
4569
21
      .Case("vector=hw1", MipsInterruptAttr::hw1)
4570
21
      .Case("vector=hw2", MipsInterruptAttr::hw2)
4571
21
      .Case("vector=hw3", MipsInterruptAttr::hw3)
4572
21
      .Case("vector=hw4", MipsInterruptAttr::hw4)
4573
21
      .Case("vector=hw5", MipsInterruptAttr::hw5)
4574
21
      .Case("eic", MipsInterruptAttr::eic)
4575
21
      .Case("", MipsInterruptAttr::eic)
4576
21
      .Default(Optional<InterruptType>());
4577
21
    if (R) {
4578
20
      Out = *R;
4579
20
      return true;
4580
20
    }
4581
1
    return false;
4582
1
  }
4583
4584
0
  static const char *ConvertInterruptTypeToStr(InterruptType Val) {
4585
0
    switch(Val) {
4586
0
    case MipsInterruptAttr::sw0: return "vector=sw0";
4587
0
    case MipsInterruptAttr::sw1: return "vector=sw1";
4588
0
    case MipsInterruptAttr::hw0: return "vector=hw0";
4589
0
    case MipsInterruptAttr::hw1: return "vector=hw1";
4590
0
    case MipsInterruptAttr::hw2: return "vector=hw2";
4591
0
    case MipsInterruptAttr::hw3: return "vector=hw3";
4592
0
    case MipsInterruptAttr::hw4: return "vector=hw4";
4593
0
    case MipsInterruptAttr::hw5: return "vector=hw5";
4594
0
    case MipsInterruptAttr::eic: return "eic";
4595
0
    }
4596
0
    llvm_unreachable("No enumerator with that value");
4597
0
  }
4598
4599
4600
51
  static bool classof(const Attr *A) { return A->getKind() == attr::MipsInterrupt; }
4601
};
4602
4603
class MipsLongCallAttr : public InheritableAttr {
4604
public:
4605
  enum Spelling {
4606
    GNU_long_call = 0,
4607
    CXX11_gnu_long_call = 1,
4608
    GNU_far = 2,
4609
    CXX11_gnu_far = 3
4610
  };
4611
4612
  static MipsLongCallAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
4613
    auto *A = new (Ctx) MipsLongCallAttr(Loc, Ctx, S);
4614
    A->setImplicit(true);
4615
    return A;
4616
  }
4617
4618
  MipsLongCallAttr(SourceRange R, ASTContext &Ctx
4619
              , unsigned SI
4620
             )
4621
    : InheritableAttr(attr::MipsLongCall, R, SI, false, false)
4622
14
  {
4623
14
  }
4624
4625
  MipsLongCallAttr *clone(ASTContext &C) const;
4626
  void printPretty(raw_ostream &OS,
4627
                   const PrintingPolicy &Policy) const;
4628
  const char *getSpelling() const;
4629
  Spelling getSemanticSpelling() const {
4630
  switch (SpellingListIndex) {
4631
    default: llvm_unreachable("Unknown spelling list index");
4632
    case 0: return GNU_long_call;
4633
    case 1: return CXX11_gnu_long_call;
4634
    case 2: return GNU_far;
4635
    case 3: return CXX11_gnu_far;
4636
  }
4637
  }
4638
4639
4640
95
  static bool classof(const Attr *A) { return A->getKind() == attr::MipsLongCall; }
4641
};
4642
4643
class MipsShortCallAttr : public InheritableAttr {
4644
public:
4645
  enum Spelling {
4646
    GNU_short_call = 0,
4647
    CXX11_gnu_short_call = 1,
4648
    GNU_near = 2,
4649
    CXX11_gnu_near = 3
4650
  };
4651
4652
  static MipsShortCallAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
4653
    auto *A = new (Ctx) MipsShortCallAttr(Loc, Ctx, S);
4654
    A->setImplicit(true);
4655
    return A;
4656
  }
4657
4658
  MipsShortCallAttr(SourceRange R, ASTContext &Ctx
4659
              , unsigned SI
4660
             )
4661
    : InheritableAttr(attr::MipsShortCall, R, SI, false, false)
4662
14
  {
4663
14
  }
4664
4665
  MipsShortCallAttr *clone(ASTContext &C) const;
4666
  void printPretty(raw_ostream &OS,
4667
                   const PrintingPolicy &Policy) const;
4668
  const char *getSpelling() const;
4669
  Spelling getSemanticSpelling() const {
4670
  switch (SpellingListIndex) {
4671
    default: llvm_unreachable("Unknown spelling list index");
4672
    case 0: return GNU_short_call;
4673
    case 1: return CXX11_gnu_short_call;
4674
    case 2: return GNU_near;
4675
    case 3: return CXX11_gnu_near;
4676
  }
4677
  }
4678
4679
4680
89
  static bool classof(const Attr *A) { return A->getKind() == attr::MipsShortCall; }
4681
};
4682
4683
class ModeAttr : public Attr {
4684
IdentifierInfo * mode;
4685
4686
public:
4687
  static ModeAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Mode, SourceRange Loc = SourceRange()) {
4688
    auto *A = new (Ctx) ModeAttr(Loc, Ctx, Mode, 0);
4689
    A->setImplicit(true);
4690
    return A;
4691
  }
4692
4693
  ModeAttr(SourceRange R, ASTContext &Ctx
4694
              , IdentifierInfo * Mode
4695
              , unsigned SI
4696
             )
4697
    : Attr(attr::Mode, R, SI, false)
4698
              , mode(Mode)
4699
2.41k
  {
4700
2.41k
  }
4701
4702
  ModeAttr *clone(ASTContext &C) const;
4703
  void printPretty(raw_ostream &OS,
4704
                   const PrintingPolicy &Policy) const;
4705
  const char *getSpelling() const;
4706
90
  IdentifierInfo * getMode() const {
4707
90
    return mode;
4708
90
  }
4709
4710
4711
4712
2.15M
  static bool classof(const Attr *A) { return A->getKind() == attr::Mode; }
4713
};
4714
4715
class NSConsumedAttr : public InheritableParamAttr {
4716
public:
4717
153
  static NSConsumedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4718
153
    auto *A = new (Ctx) NSConsumedAttr(Loc, Ctx, 0);
4719
153
    A->setImplicit(true);
4720
153
    return A;
4721
153
  }
4722
4723
  NSConsumedAttr(SourceRange R, ASTContext &Ctx
4724
              , unsigned SI
4725
             )
4726
    : InheritableParamAttr(attr::NSConsumed, R, SI, false, false)
4727
374
  {
4728
374
  }
4729
4730
  NSConsumedAttr *clone(ASTContext &C) const;
4731
  void printPretty(raw_ostream &OS,
4732
                   const PrintingPolicy &Policy) const;
4733
  const char *getSpelling() const;
4734
4735
4736
2.16M
  static bool classof(const Attr *A) { return A->getKind() == attr::NSConsumed; }
4737
};
4738
4739
class NSConsumesSelfAttr : public InheritableAttr {
4740
public:
4741
500
  static NSConsumesSelfAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4742
500
    auto *A = new (Ctx) NSConsumesSelfAttr(Loc, Ctx, 0);
4743
500
    A->setImplicit(true);
4744
500
    return A;
4745
500
  }
4746
4747
  NSConsumesSelfAttr(SourceRange R, ASTContext &Ctx
4748
              , unsigned SI
4749
             )
4750
    : InheritableAttr(attr::NSConsumesSelf, R, SI, false, false)
4751
680
  {
4752
680
  }
4753
4754
  NSConsumesSelfAttr *clone(ASTContext &C) const;
4755
  void printPretty(raw_ostream &OS,
4756
                   const PrintingPolicy &Policy) const;
4757
  const char *getSpelling() const;
4758
4759
4760
1.02k
  static bool classof(const Attr *A) { return A->getKind() == attr::NSConsumesSelf; }
4761
};
4762
4763
class NSReturnsAutoreleasedAttr : public InheritableAttr {
4764
public:
4765
  static NSReturnsAutoreleasedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4766
    auto *A = new (Ctx) NSReturnsAutoreleasedAttr(Loc, Ctx, 0);
4767
    A->setImplicit(true);
4768
    return A;
4769
  }
4770
4771
  NSReturnsAutoreleasedAttr(SourceRange R, ASTContext &Ctx
4772
              , unsigned SI
4773
             )
4774
    : InheritableAttr(attr::NSReturnsAutoreleased, R, SI, false, false)
4775
5
  {
4776
5
  }
4777
4778
  NSReturnsAutoreleasedAttr *clone(ASTContext &C) const;
4779
  void printPretty(raw_ostream &OS,
4780
                   const PrintingPolicy &Policy) const;
4781
  const char *getSpelling() const;
4782
4783
4784
44
  static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsAutoreleased; }
4785
};
4786
4787
class NSReturnsNotRetainedAttr : public InheritableAttr {
4788
public:
4789
3
  static NSReturnsNotRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4790
3
    auto *A = new (Ctx) NSReturnsNotRetainedAttr(Loc, Ctx, 0);
4791
3
    A->setImplicit(true);
4792
3
    return A;
4793
3
  }
4794
4795
  NSReturnsNotRetainedAttr(SourceRange R, ASTContext &Ctx
4796
              , unsigned SI
4797
             )
4798
    : InheritableAttr(attr::NSReturnsNotRetained, R, SI, false, false)
4799
120
  {
4800
120
  }
4801
4802
  NSReturnsNotRetainedAttr *clone(ASTContext &C) const;
4803
  void printPretty(raw_ostream &OS,
4804
                   const PrintingPolicy &Policy) const;
4805
  const char *getSpelling() const;
4806
4807
4808
32.2k
  static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsNotRetained; }
4809
};
4810
4811
class NSReturnsRetainedAttr : public InheritableAttr {
4812
public:
4813
886
  static NSReturnsRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4814
886
    auto *A = new (Ctx) NSReturnsRetainedAttr(Loc, Ctx, 0);
4815
886
    A->setImplicit(true);
4816
886
    return A;
4817
886
  }
4818
4819
  NSReturnsRetainedAttr(SourceRange R, ASTContext &Ctx
4820
              , unsigned SI
4821
             )
4822
    : InheritableAttr(attr::NSReturnsRetained, R, SI, false, false)
4823
2.46k
  {
4824
2.46k
  }
4825
4826
  NSReturnsRetainedAttr *clone(ASTContext &C) const;
4827
  void printPretty(raw_ostream &OS,
4828
                   const PrintingPolicy &Policy) const;
4829
  const char *getSpelling() const;
4830
4831
4832
18.5k
  static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsRetained; }
4833
};
4834
4835
class NakedAttr : public InheritableAttr {
4836
public:
4837
  static NakedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4838
    auto *A = new (Ctx) NakedAttr(Loc, Ctx, 0);
4839
    A->setImplicit(true);
4840
    return A;
4841
  }
4842
4843
  NakedAttr(SourceRange R, ASTContext &Ctx
4844
              , unsigned SI
4845
             )
4846
    : InheritableAttr(attr::Naked, R, SI, false, false)
4847
30
  {
4848
30
  }
4849
4850
  NakedAttr *clone(ASTContext &C) const;
4851
  void printPretty(raw_ostream &OS,
4852
                   const PrintingPolicy &Policy) const;
4853
  const char *getSpelling() const;
4854
4855
4856
9.96M
  static bool classof(const Attr *A) { return A->getKind() == attr::Naked; }
4857
};
4858
4859
class NoAliasAttr : public InheritableAttr {
4860
public:
4861
  static NoAliasAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4862
    auto *A = new (Ctx) NoAliasAttr(Loc, Ctx, 0);
4863
    A->setImplicit(true);
4864
    return A;
4865
  }
4866
4867
  NoAliasAttr(SourceRange R, ASTContext &Ctx
4868
              , unsigned SI
4869
             )
4870
    : InheritableAttr(attr::NoAlias, R, SI, false, false)
4871
2
  {
4872
2
  }
4873
4874
  NoAliasAttr *clone(ASTContext &C) const;
4875
  void printPretty(raw_ostream &OS,
4876
                   const PrintingPolicy &Policy) const;
4877
  const char *getSpelling() const;
4878
4879
4880
520k
  static bool classof(const Attr *A) { return A->getKind() == attr::NoAlias; }
4881
};
4882
4883
class NoCommonAttr : public InheritableAttr {
4884
public:
4885
  static NoCommonAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4886
    auto *A = new (Ctx) NoCommonAttr(Loc, Ctx, 0);
4887
    A->setImplicit(true);
4888
    return A;
4889
  }
4890
4891
  NoCommonAttr(SourceRange R, ASTContext &Ctx
4892
              , unsigned SI
4893
             )
4894
    : InheritableAttr(attr::NoCommon, R, SI, false, false)
4895
4
  {
4896
4
  }
4897
4898
  NoCommonAttr *clone(ASTContext &C) const;
4899
  void printPretty(raw_ostream &OS,
4900
                   const PrintingPolicy &Policy) const;
4901
  const char *getSpelling() const;
4902
4903
4904
863
  static bool classof(const Attr *A) { return A->getKind() == attr::NoCommon; }
4905
};
4906
4907
class NoDebugAttr : public InheritableAttr {
4908
public:
4909
  static NoDebugAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4910
    auto *A = new (Ctx) NoDebugAttr(Loc, Ctx, 0);
4911
    A->setImplicit(true);
4912
    return A;
4913
  }
4914
4915
  NoDebugAttr(SourceRange R, ASTContext &Ctx
4916
              , unsigned SI
4917
             )
4918
    : InheritableAttr(attr::NoDebug, R, SI, false, false)
4919
746k
  {
4920
746k
  }
4921
4922
  NoDebugAttr *clone(ASTContext &C) const;
4923
  void printPretty(raw_ostream &OS,
4924
                   const PrintingPolicy &Policy) const;
4925
  const char *getSpelling() const;
4926
4927
4928
134k
  static bool classof(const Attr *A) { return A->getKind() == attr::NoDebug; }
4929
};
4930
4931
class NoDestroyAttr : public InheritableAttr {
4932
public:
4933
  static NoDestroyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4934
    auto *A = new (Ctx) NoDestroyAttr(Loc, Ctx, 0);
4935
    A->setImplicit(true);
4936
    return A;
4937
  }
4938
4939
  NoDestroyAttr(SourceRange R, ASTContext &Ctx
4940
              , unsigned SI
4941
             )
4942
    : InheritableAttr(attr::NoDestroy, R, SI, false, false)
4943
11
  {
4944
11
  }
4945
4946
  NoDestroyAttr *clone(ASTContext &C) const;
4947
  void printPretty(raw_ostream &OS,
4948
                   const PrintingPolicy &Policy) const;
4949
  const char *getSpelling() const;
4950
4951
4952
1.30k
  static bool classof(const Attr *A) { return A->getKind() == attr::NoDestroy; }
4953
};
4954
4955
class NoDuplicateAttr : public InheritableAttr {
4956
public:
4957
  static NoDuplicateAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4958
    auto *A = new (Ctx) NoDuplicateAttr(Loc, Ctx, 0);
4959
    A->setImplicit(true);
4960
    return A;
4961
  }
4962
4963
  NoDuplicateAttr(SourceRange R, ASTContext &Ctx
4964
              , unsigned SI
4965
             )
4966
    : InheritableAttr(attr::NoDuplicate, R, SI, false, false)
4967
5
  {
4968
5
  }
4969
4970
  NoDuplicateAttr *clone(ASTContext &C) const;
4971
  void printPretty(raw_ostream &OS,
4972
                   const PrintingPolicy &Policy) const;
4973
  const char *getSpelling() const;
4974
4975
4976
668k
  static bool classof(const Attr *A) { return A->getKind() == attr::NoDuplicate; }
4977
};
4978
4979
class NoEscapeAttr : public Attr {
4980
public:
4981
  static NoEscapeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4982
    auto *A = new (Ctx) NoEscapeAttr(Loc, Ctx, 0);
4983
    A->setImplicit(true);
4984
    return A;
4985
  }
4986
4987
  NoEscapeAttr(SourceRange R, ASTContext &Ctx
4988
              , unsigned SI
4989
             )
4990
    : Attr(attr::NoEscape, R, SI, false)
4991
1.83k
  {
4992
1.83k
  }
4993
4994
  NoEscapeAttr *clone(ASTContext &C) const;
4995
  void printPretty(raw_ostream &OS,
4996
                   const PrintingPolicy &Policy) const;
4997
  const char *getSpelling() const;
4998
4999
5000
9.02k
  static bool classof(const Attr *A) { return A->getKind() == attr::NoEscape; }
5001
};
5002
5003
class NoInlineAttr : public InheritableAttr {
5004
public:
5005
22
  static NoInlineAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5006
22
    auto *A = new (Ctx) NoInlineAttr(Loc, Ctx, 0);
5007
22
    A->setImplicit(true);
5008
22
    return A;
5009
22
  }
5010
5011
  NoInlineAttr(SourceRange R, ASTContext &Ctx
5012
              , unsigned SI
5013
             )
5014
    : InheritableAttr(attr::NoInline, R, SI, false, false)
5015
16.1k
  {
5016
16.1k
  }
5017
5018
  NoInlineAttr *clone(ASTContext &C) const;
5019
  void printPretty(raw_ostream &OS,
5020
                   const PrintingPolicy &Policy) const;
5021
  const char *getSpelling() const;
5022
5023
5024
141k
  static bool classof(const Attr *A) { return A->getKind() == attr::NoInline; }
5025
};
5026
5027
class NoInstrumentFunctionAttr : public InheritableAttr {
5028
public:
5029
  static NoInstrumentFunctionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5030
    auto *A = new (Ctx) NoInstrumentFunctionAttr(Loc, Ctx, 0);
5031
    A->setImplicit(true);
5032
    return A;
5033
  }
5034
5035
  NoInstrumentFunctionAttr(SourceRange R, ASTContext &Ctx
5036
              , unsigned SI
5037
             )
5038
    : InheritableAttr(attr::NoInstrumentFunction, R, SI, false, false)
5039
30
  {
5040
30
  }
5041
5042
  NoInstrumentFunctionAttr *clone(ASTContext &C) const;
5043
  void printPretty(raw_ostream &OS,
5044
                   const PrintingPolicy &Policy) const;
5045
  const char *getSpelling() const;
5046
5047
5048
27
  static bool classof(const Attr *A) { return A->getKind() == attr::NoInstrumentFunction; }
5049
};
5050
5051
class NoMicroMipsAttr : public InheritableAttr {
5052
public:
5053
  static NoMicroMipsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5054
    auto *A = new (Ctx) NoMicroMipsAttr(Loc, Ctx, 0);
5055
    A->setImplicit(true);
5056
    return A;
5057
  }
5058
5059
  NoMicroMipsAttr(SourceRange R, ASTContext &Ctx
5060
              , unsigned SI
5061
             )
5062
    : InheritableAttr(attr::NoMicroMips, R, SI, false, false)
5063
2
  {
5064
2
  }
5065
5066
  NoMicroMipsAttr *clone(ASTContext &C) const;
5067
  void printPretty(raw_ostream &OS,
5068
                   const PrintingPolicy &Policy) const;
5069
  const char *getSpelling() const;
5070
5071
5072
37
  static bool classof(const Attr *A) { return A->getKind() == attr::NoMicroMips; }
5073
};
5074
5075
class NoMips16Attr : public InheritableAttr {
5076
public:
5077
  static NoMips16Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5078
    auto *A = new (Ctx) NoMips16Attr(Loc, Ctx, 0);
5079
    A->setImplicit(true);
5080
    return A;
5081
  }
5082
5083
  NoMips16Attr(SourceRange R, ASTContext &Ctx
5084
              , unsigned SI
5085
             )
5086
    : InheritableAttr(attr::NoMips16, R, SI, false, false)
5087
6
  {
5088
6
  }
5089
5090
  NoMips16Attr *clone(ASTContext &C) const;
5091
  void printPretty(raw_ostream &OS,
5092
                   const PrintingPolicy &Policy) const;
5093
  const char *getSpelling() const;
5094
5095
5096
37
  static bool classof(const Attr *A) { return A->getKind() == attr::NoMips16; }
5097
};
5098
5099
class NoReturnAttr : public InheritableAttr {
5100
public:
5101
  static NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5102
    auto *A = new (Ctx) NoReturnAttr(Loc, Ctx, 0);
5103
    A->setImplicit(true);
5104
    return A;
5105
  }
5106
5107
  NoReturnAttr(SourceRange R, ASTContext &Ctx
5108
              , unsigned SI
5109
             )
5110
    : InheritableAttr(attr::NoReturn, R, SI, false, false)
5111
14
  {
5112
14
  }
5113
5114
  NoReturnAttr *clone(ASTContext &C) const;
5115
  void printPretty(raw_ostream &OS,
5116
                   const PrintingPolicy &Policy) const;
5117
  const char *getSpelling() const;
5118
5119
5120
5.64M
  static bool classof(const Attr *A) { return A->getKind() == attr::NoReturn; }
5121
};
5122
5123
class NoSanitizeAttr : public InheritableAttr {
5124
  unsigned sanitizers_Size;
5125
  StringRef *sanitizers_;
5126
5127
public:
5128
  static NoSanitizeAttr *CreateImplicit(ASTContext &Ctx, StringRef *Sanitizers, unsigned SanitizersSize, SourceRange Loc = SourceRange()) {
5129
    auto *A = new (Ctx) NoSanitizeAttr(Loc, Ctx, Sanitizers, SanitizersSize, 0);
5130
    A->setImplicit(true);
5131
    return A;
5132
  }
5133
5134
  NoSanitizeAttr(SourceRange R, ASTContext &Ctx
5135
              , StringRef *Sanitizers, unsigned SanitizersSize
5136
              , unsigned SI
5137
             )
5138
    : InheritableAttr(attr::NoSanitize, R, SI, false, false)
5139
              , sanitizers_Size(SanitizersSize), sanitizers_(new (Ctx, 16) StringRef[sanitizers_Size])
5140
11.2k
  {
5141
22.4k
    for (size_t I = 0, E = sanitizers_Size; I != E;
5142
11.2k
         ++I) {
5143
11.2k
      StringRef Ref = Sanitizers[I];
5144
11.2k
      if (!Ref.empty()) {
5145
11.2k
        char *Mem = new (Ctx, 1) char[Ref.size()];
5146
11.2k
        std::memcpy(Mem, Ref.data(), Ref.size());
5147
11.2k
        sanitizers_[I] = StringRef(Mem, Ref.size());
5148
11.2k
      }
5149
11.2k
    }
5150
11.2k
  }
5151
5152
  NoSanitizeAttr(SourceRange R, ASTContext &Ctx
5153
              , unsigned SI
5154
             )
5155
    : InheritableAttr(attr::NoSanitize, R, SI, false, false)
5156
              , sanitizers_Size(0), sanitizers_(nullptr)
5157
  {
5158
  }
5159
5160
  NoSanitizeAttr *clone(ASTContext &C) const;
5161
  void printPretty(raw_ostream &OS,
5162
                   const PrintingPolicy &Policy) const;
5163
  const char *getSpelling() const;
5164
  typedef StringRef* sanitizers_iterator;
5165
1.01k
  sanitizers_iterator sanitizers_begin() const { return sanitizers_; }
5166
1.01k
  sanitizers_iterator sanitizers_end() const { return sanitizers_ + sanitizers_Size; }
5167
1
  unsigned sanitizers_size() const { return sanitizers_Size; }
5168
1.01k
  llvm::iterator_range<sanitizers_iterator> sanitizers() const { return llvm::make_range(sanitizers_begin(), sanitizers_end()); }
5169
5170
5171
5172
1.00k
    SanitizerMask getMask() const {
5173
1.00k
      SanitizerMask Mask = 0;
5174
1.00k
      for (auto SanitizerName : sanitizers()) {
5175
1.00k
        SanitizerMask ParsedMask =
5176
1.00k
            parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
5177
1.00k
        Mask |= expandSanitizerGroups(ParsedMask);
5178
1.00k
      }
5179
1.00k
      return Mask;
5180
1.00k
    }
5181
  
5182
5183
147k
  static bool classof(const Attr *A) { return A->getKind() == attr::NoSanitize; }
5184
};
5185
5186
class NoSplitStackAttr : public InheritableAttr {
5187
public:
5188
  static NoSplitStackAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5189
    auto *A = new (Ctx) NoSplitStackAttr(Loc, Ctx, 0);
5190
    A->setImplicit(true);
5191
    return A;
5192
  }
5193
5194
  NoSplitStackAttr(SourceRange R, ASTContext &Ctx
5195
              , unsigned SI
5196
             )
5197
    : InheritableAttr(attr::NoSplitStack, R, SI, false, false)
5198
16
  {
5199
16
  }
5200
5201
  NoSplitStackAttr *clone(ASTContext &C) const;
5202
  void printPretty(raw_ostream &OS,
5203
                   const PrintingPolicy &Policy) const;
5204
  const char *getSpelling() const;
5205
5206
5207
4
  static bool classof(const Attr *A) { return A->getKind() == attr::NoSplitStack; }
5208
};
5209
5210
class NoStackProtectorAttr : public InheritableAttr {
5211
public:
5212
  static NoStackProtectorAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5213
    auto *A = new (Ctx) NoStackProtectorAttr(Loc, Ctx, 0);
5214
    A->setImplicit(true);
5215
    return A;
5216
  }
5217
5218
  NoStackProtectorAttr(SourceRange R, ASTContext &Ctx
5219
              , unsigned SI
5220
             )
5221
    : InheritableAttr(attr::NoStackProtector, R, SI, false, false)
5222
10
  {
5223
10
  }
5224
5225
  NoStackProtectorAttr *clone(ASTContext &C) const;
5226
  void printPretty(raw_ostream &OS,
5227
                   const PrintingPolicy &Policy) const;
5228
  const char *getSpelling() const;
5229
5230
5231
145k
  static bool classof(const Attr *A) { return A->getKind() == attr::NoStackProtector; }
5232
};
5233
5234
class NoThreadSafetyAnalysisAttr : public InheritableAttr {
5235
public:
5236
  static NoThreadSafetyAnalysisAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5237
    auto *A = new (Ctx) NoThreadSafetyAnalysisAttr(Loc, Ctx, 0);
5238
    A->setImplicit(true);
5239
    return A;
5240
  }
5241
5242
  NoThreadSafetyAnalysisAttr(SourceRange R, ASTContext &Ctx
5243
              , unsigned SI
5244
             )
5245
    : InheritableAttr(attr::NoThreadSafetyAnalysis, R, SI, false, false)
5246
70
  {
5247
70
  }
5248
5249
  NoThreadSafetyAnalysisAttr *clone(ASTContext &C) const;
5250
  void printPretty(raw_ostream &OS,
5251
                   const PrintingPolicy &Policy) const;
5252
  const char *getSpelling() const;
5253
5254
5255
4.79k
  static bool classof(const Attr *A) { return A->getKind() == attr::NoThreadSafetyAnalysis; }
5256
};
5257
5258
class NoThrowAttr : public InheritableAttr {
5259
public:
5260
469k
  static NoThrowAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5261
469k
    auto *A = new (Ctx) NoThrowAttr(Loc, Ctx, 0);
5262
469k
    A->setImplicit(true);
5263
469k
    return A;
5264
469k
  }
5265
5266
  NoThrowAttr(SourceRange R, ASTContext &Ctx
5267
              , unsigned SI
5268
             )
5269
    : InheritableAttr(attr::NoThrow, R, SI, false, false)
5270
593k
  {
5271
593k
  }
5272
5273
  NoThrowAttr *clone(ASTContext &C) const;
5274
  void printPretty(raw_ostream &OS,
5275
                   const PrintingPolicy &Policy) const;
5276
  const char *getSpelling() const;
5277
5278
5279
1.18M
  static bool classof(const Attr *A) { return A->getKind() == attr::NoThrow; }
5280
};
5281
5282
class NonNullAttr : public InheritableParamAttr {
5283
  unsigned args_Size;
5284
  ParamIdx *args_;
5285
5286
public:
5287
  static NonNullAttr *CreateImplicit(ASTContext &Ctx, ParamIdx *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
5288
    auto *A = new (Ctx) NonNullAttr(Loc, Ctx, Args, ArgsSize, 0);
5289
    A->setImplicit(true);
5290
    return A;
5291
  }
5292
5293
  NonNullAttr(SourceRange R, ASTContext &Ctx
5294
              , ParamIdx *Args, unsigned ArgsSize
5295
              , unsigned SI
5296
             )
5297
    : InheritableParamAttr(attr::NonNull, R, SI, false, true)
5298
              , args_Size(ArgsSize), args_(new (Ctx, 16) ParamIdx[args_Size])
5299
8.29k
  {
5300
8.29k
    std::copy(Args, Args + args_Size, args_);
5301
8.29k
  }
5302
5303
  NonNullAttr(SourceRange R, ASTContext &Ctx
5304
              , unsigned SI
5305
             )
5306
    : InheritableParamAttr(attr::NonNull, R, SI, false, true)
5307
              , args_Size(0), args_(nullptr)
5308
  {
5309
  }
5310
5311
  NonNullAttr *clone(ASTContext &C) const;
5312
  void printPretty(raw_ostream &OS,
5313
                   const PrintingPolicy &Policy) const;
5314
  const char *getSpelling() const;
5315
  typedef ParamIdx* args_iterator;
5316
1.08k
  args_iterator args_begin() const { return args_; }
5317
1.18k
  args_iterator args_end() const { return args_ + args_Size; }
5318
1.54k
  unsigned args_size() const { return args_Size; }
5319
981
  llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
5320
5321
5322
5323
112
    bool isNonNull(unsigned IdxAST) const {
5324
112
      if (!args_size())
5325
10
        return true;
5326
102
      return args_end() != std::find_if(
5327
102
          args_begin(), args_end(),
5328
106
          [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; });
5329
102
    }
5330
  
5331
5332
3.96M
  static bool classof(const Attr *A) { return A->getKind() == attr::NonNull; }
5333
};
5334
5335
class NotTailCalledAttr : public InheritableAttr {
5336
public:
5337
  static NotTailCalledAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5338
    auto *A = new (Ctx) NotTailCalledAttr(Loc, Ctx, 0);
5339
    A->setImplicit(true);
5340
    return A;
5341
  }
5342
5343
  NotTailCalledAttr(SourceRange R, ASTContext &Ctx
5344
              , unsigned SI
5345
             )
5346
    : InheritableAttr(attr::NotTailCalled, R, SI, false, false)
5347
227
  {
5348
227
  }
5349
5350
  NotTailCalledAttr *clone(ASTContext &C) const;
5351
  void printPretty(raw_ostream &OS,
5352
                   const PrintingPolicy &Policy) const;
5353
  const char *getSpelling() const;
5354
5355
5356
7.64M
  static bool classof(const Attr *A) { return A->getKind() == attr::NotTailCalled; }
5357
};
5358
5359
class OMPCaptureKindAttr : public Attr {
5360
unsigned captureKind;
5361
5362
public:
5363
173k
  static OMPCaptureKindAttr *CreateImplicit(ASTContext &Ctx, unsigned CaptureKind, SourceRange Loc = SourceRange()) {
5364
173k
    auto *A = new (Ctx) OMPCaptureKindAttr(Loc, Ctx, CaptureKind, 0);
5365
173k
    A->setImplicit(true);
5366
173k
    return A;
5367
173k
  }
5368
5369
  OMPCaptureKindAttr(SourceRange R, ASTContext &Ctx
5370
              , unsigned CaptureKind
5371
              , unsigned SI
5372
             )
5373
    : Attr(attr::OMPCaptureKind, R, SI, false)
5374
              , captureKind(CaptureKind)
5375
178k
  {
5376
178k
  }
5377
5378
  OMPCaptureKindAttr *clone(ASTContext &C) const;
5379
  void printPretty(raw_ostream &OS,
5380
                   const PrintingPolicy &Policy) const;
5381
  const char *getSpelling() const;
5382
17.4k
  unsigned getCaptureKind() const {
5383
17.4k
    return captureKind;
5384
17.4k
  }
5385
5386
5387
5388
308
  static bool classof(const Attr *A) { return A->getKind() == attr::OMPCaptureKind; }
5389
};
5390
5391
class OMPCaptureNoInitAttr : public InheritableAttr {
5392
public:
5393
70
  static OMPCaptureNoInitAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
5394
70
    auto *A = new (Ctx) OMPCaptureNoInitAttr(Loc, Ctx, 0);
5395
70
    A->setImplicit(true);
5396
70
    return A;
5397
70
  }
5398
5399
  OMPCaptureNoInitAttr(SourceRange R, ASTContext &Ctx
5400
              , unsigned SI
5401
             )
5402
    : InheritableAttr(attr::OMPCaptureNoInit, R, SI, false, false)
5403
88
  {
5404
88
  }
5405
5406
  OMPCaptureNoInitAttr *clone(ASTContext &C) const;
5407
  void printPretty(raw_ostream &OS,
5408
                   const PrintingPolicy &Policy) const;
5409
  const char *getSpelling() const;
5410
5411
5412
172
  static bool classof(const Attr *A) { return A->getKind() == attr::OMPCaptureNoInit; }
5413
};
5414
5415
class OMPDeclareSimdDeclAttr : public Attr {
5416
public:
5417
  enum BranchStateTy {
5418
    BS_Undefined,
5419
    BS_Inbranch,
5420
    BS_Notinbranch
5421
  };
5422
private:
5423
  BranchStateTy branchState;
5424
5425
Expr * simdlen;
5426
5427
  unsigned uniforms_Size;
5428
  Expr * *uniforms_;
5429
5430
  unsigned aligneds_Size;
5431
  Expr * *aligneds_;
5432
5433
  unsigned alignments_Size;
5434
  Expr * *alignments_;
5435
5436
  unsigned linears_Size;
5437
  Expr * *linears_;
5438
5439
  unsigned modifiers_Size;
5440
  unsigned *modifiers_;
5441
5442
  unsigned steps_Size;
5443
  Expr * *steps_;
5444
5445
public:
5446
306
  static OMPDeclareSimdDeclAttr *CreateImplicit(ASTContext &Ctx, BranchStateTy BranchState, Expr * Simdlen, Expr * *Uniforms, unsigned UniformsSize, Expr * *Aligneds, unsigned AlignedsSize, Expr * *Alignments, unsigned AlignmentsSize, Expr * *Linears, unsigned LinearsSize, unsigned *Modifiers, unsigned ModifiersSize, Expr * *Steps, unsigned StepsSize, SourceRange Loc = SourceRange()) {
5447
306
    auto *A = new (Ctx) OMPDeclareSimdDeclAttr(Loc, Ctx, BranchState, Simdlen, Uniforms, UniformsSize, Aligneds, AlignedsSize, Alignments, AlignmentsSize, Linears, LinearsSize, Modifiers, ModifiersSize, Steps, StepsSize, 0);
5448
306
    A->setImplicit(true);
5449
306
    return A;
5450
306
  }
5451
5452
  OMPDeclareSimdDeclAttr(SourceRange R, ASTContext &Ctx
5453
              , BranchStateTy BranchState
5454
              , Expr * Simdlen
5455
              , Expr * *Uniforms, unsigned UniformsSize
5456
              , Expr * *Aligneds, unsigned AlignedsSize
5457
              , Expr * *Alignments, unsigned AlignmentsSize
5458
              , Expr * *Linears, unsigned LinearsSize
5459
              , unsigned *Modifiers, unsigned ModifiersSize
5460
              , Expr * *Steps, unsigned StepsSize
5461
              , unsigned SI
5462
             )
5463
    : Attr(attr::OMPDeclareSimdDecl, R, SI, false)
5464
              , branchState(BranchState)
5465
              , simdlen(Simdlen)
5466
              , uniforms_Size(UniformsSize), uniforms_(new (Ctx, 16) Expr *[uniforms_Size])
5467
              , aligneds_Size(AlignedsSize), aligneds_(new (Ctx, 16) Expr *[aligneds_Size])
5468
              , alignments_Size(AlignmentsSize), alignments_(new (Ctx, 16) Expr *[alignments_Size])
5469
              , linears_Size(LinearsSize), linears_(new (Ctx, 16) Expr *[linears_Size])
5470
              , modifiers_Size(ModifiersSize), modifiers_(new (Ctx, 16) unsigned[modifiers_Size])
5471
              , steps_Size(StepsSize), steps_(new (Ctx, 16) Expr *[steps_Size])
5472
430
  {
5473
430
    std::copy(Uniforms, Uniforms + uniforms_Size, uniforms_);
5474
430
    std::copy(Aligneds, Aligneds + aligneds_Size, aligneds_);
5475
430
    std::copy(Alignments, Alignments + alignments_Size, alignments_);
5476
430
    std::copy(Linears, Linears + linears_Size, linears_);
5477
430
    std::copy(Modifiers, Modifiers + modifiers_Size, modifiers_);
5478
430
    std::copy(Steps, Steps + steps_Size, steps_);
5479
430
  }
5480
5481
  OMPDeclareSimdDeclAttr(SourceRange R, ASTContext &Ctx
5482
              , BranchStateTy BranchState
5483
              , Expr * Simdlen
5484
              , unsigned SI
5485
             )
5486
    : Attr(attr::OMPDeclareSimdDecl, R, SI, false)
5487
              , branchState(BranchState)
5488
              , simdlen(Simdlen)
5489
              , uniforms_Size(0), uniforms_(nullptr)
5490
              , aligneds_Size(0), aligneds_(nullptr)
5491
              , alignments_Size(0), alignments_(nullptr)
5492
              , linears_Size(0), linears_(nullptr)
5493
              , modifiers_Size(0), modifiers_(nullptr)
5494
              , steps_Size(0), steps_(nullptr)
5495
  {
5496
  }
5497
5498
  OMPDeclareSimdDeclAttr *clone(ASTContext &C) const;
5499
  void printPretty(raw_ostream &OS,
5500
                   const PrintingPolicy &Policy) const;
5501
  const char *getSpelling() const;
5502
414
  BranchStateTy getBranchState() const {
5503
414
    return branchState;
5504
414
  }
5505
5506
448
  static bool ConvertStrToBranchStateTy(StringRef Val, BranchStateTy &Out) {
5507
448
    Optional<BranchStateTy> R = llvm::StringSwitch<Optional<BranchStateTy>>(Val)
5508
448
      .Case("", OMPDeclareSimdDeclAttr::BS_Undefined)
5509
448
      .Case("inbranch", OMPDeclareSimdDeclAttr::BS_Inbranch)
5510
448
      .Case("notinbranch", OMPDeclareSimdDeclAttr::BS_Notinbranch)
5511
448
      .Default(Optional<BranchStateTy>());
5512
448
    if (R) {
5513
82
      Out = *R;
5514
82
      return true;
5515
82
    }
5516
366
    return false;
5517
366
  }
5518
5519
20
  static const char *ConvertBranchStateTyToStr(BranchStateTy Val) {
5520
20
    switch(Val) {
5521
20
    
case OMPDeclareSimdDeclAttr::BS_Undefined: return ""0
;
5522
20
    
case OMPDeclareSimdDeclAttr::BS_Inbranch: return "inbranch"10
;
5523
20
    
case OMPDeclareSimdDeclAttr::BS_Notinbranch: return "notinbranch"10
;
5524
0
    }
5525
0
    llvm_unreachable("No enumerator with that value");
5526
0
  }
5527
398
  Expr * getSimdlen() const {
5528
398
    return simdlen;
5529
398
  }
5530
5531
  typedef Expr ** uniforms_iterator;
5532
278
  uniforms_iterator uniforms_begin() const { return uniforms_; }
5533
278
  uniforms_iterator uniforms_end() const { return uniforms_ + uniforms_Size; }
5534
274
  unsigned uniforms_size() const { return uniforms_Size; }
5535
274
  llvm::iterator_range<uniforms_iterator> uniforms() const { return llvm::make_range(uniforms_begin(), uniforms_end()); }
5536
5537
5538
  typedef Expr ** aligneds_iterator;
5539
398
  aligneds_iterator aligneds_begin() const { return aligneds_; }
5540
398
  aligneds_iterator aligneds_end() const { return aligneds_ + aligneds_Size; }
5541
124
  unsigned aligneds_size() const { return aligneds_Size; }
5542
394
  llvm::iterator_range<aligneds_iterator> aligneds() const { return llvm::make_range(aligneds_begin(), aligneds_end()); }
5543
5544
5545
  typedef Expr ** alignments_iterator;
5546
398
  alignments_iterator alignments_begin() const { return alignments_; }
5547
128
  alignments_iterator alignments_end() const { return alignments_ + alignments_Size; }
5548
124
  unsigned alignments_size() const { return alignments_Size; }
5549
124
  llvm::iterator_range<alignments_iterator> alignments() const { return llvm::make_range(alignments_begin(), alignments_end()); }
5550
5551
5552
  typedef Expr ** linears_iterator;
5553
398
  linears_iterator linears_begin() const { return linears_; }
5554
398
  linears_iterator linears_end() const { return linears_ + linears_Size; }
5555
124
  unsigned linears_size() const { return linears_Size; }
5556
394
  llvm::iterator_range<linears_iterator> linears() const { return llvm::make_range(linears_begin(), linears_end()); }
5557
5558
5559
  typedef unsigned* modifiers_iterator;
5560
398
  modifiers_iterator modifiers_begin() const { return modifiers_; }
5561
186
  modifiers_iterator modifiers_end() const { return modifiers_ + modifiers_Size; }
5562
124
  unsigned modifiers_size() const { return modifiers_Size; }
5563
128
  llvm::iterator_range<modifiers_iterator> modifiers() const { return llvm::make_range(modifiers_begin(), modifiers_end()); }
5564
5565
5566
  typedef Expr ** steps_iterator;
5567
398
  steps_iterator steps_begin() const { return steps_; }
5568
128
  steps_iterator steps_end() const { return steps_ + steps_Size; }
5569
124
  unsigned steps_size() const { return steps_Size; }
5570
124
  llvm::iterator_range<steps_iterator> steps() const { return llvm::make_range(steps_begin(), steps_end()); }
5571
5572
5573
5574
    void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
5575
92
        const {
5576
92
      if (getBranchState() != BS_Undefined)
5577
16
        OS << ' ' << ConvertBranchStateTyToStr(getBranchState());
5578
92
      if (auto *E = getSimdlen()) {
5579
28
        OS << " simdlen(";
5580
28
        E->printPretty(OS, nullptr, Policy);
5581
28
        OS << ")";
5582
28
      }
5583
92
      if (uniforms_size() > 0) {
5584
20
        OS << " uniform";
5585
20
        StringRef Sep = "(";
5586
36
        for (auto *E : uniforms()) {
5587
36
          OS << Sep;
5588
36
          E->printPretty(OS, nullptr, Policy);
5589
36
          Sep = ", ";
5590
36
        }
5591
20
        OS << ")";
5592
20
      }
5593
92
      alignments_iterator NI = alignments_begin();
5594
92
      for (auto *E : aligneds()) {
5595
64
        OS << " aligned(";
5596
64
        E->printPretty(OS, nullptr, Policy);
5597
64
        if (*NI) {
5598
28
          OS << ": ";
5599
28
          (*NI)->printPretty(OS, nullptr, Policy);
5600
28
        }
5601
64
        OS << ")";
5602
64
        ++NI;
5603
64
      }
5604
92
      steps_iterator I = steps_begin();
5605
92
      modifiers_iterator MI = modifiers_begin();
5606
92
      for (auto *E : linears()) {
5607
52
        OS << " linear(";
5608
52
        if (*MI != OMPC_LINEAR_unknown)
5609
52
          OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
5610
52
        E->printPretty(OS, nullptr, Policy);
5611
52
        if (*MI != OMPC_LINEAR_unknown)
5612
52
          OS << ")";
5613
52
        if (*I) {
5614
44
          OS << ": ";
5615
44
          (*I)->printPretty(OS, nullptr, Policy);
5616
44
        }
5617
52
        OS << ")";
5618
52
        ++I;
5619
52
        ++MI;
5620
52
      }
5621
92
    }
5622
  
5623
5624
2.16M
  static bool classof(const Attr *A) { return A->getKind() == attr::OMPDeclareSimdDecl; }
5625
};
5626
5627
class OMPDeclareTargetDeclAttr : public InheritableAttr {
5628
public:
5629
  enum MapTypeTy {
5630
    MT_To,
5631
    MT_Link
5632
  };
5633
private:
5634
  MapTypeTy mapType;
5635
5636
public:
5637
306
  static OMPDeclareTargetDeclAttr *CreateImplicit(ASTContext &Ctx, MapTypeTy MapType, SourceRange Loc = SourceRange()) {
5638
306
    auto *A = new (Ctx) OMPDeclareTargetDeclAttr(Loc, Ctx, MapType, 0);
5639
306
    A->setImplicit(true);
5640
306
    return A;
5641
306
  }
5642
5643
  OMPDeclareTargetDeclAttr(SourceRange R, ASTContext &Ctx
5644
              , MapTypeTy MapType
5645
              , unsigned SI
5646
             )
5647
    : InheritableAttr(attr::OMPDeclareTargetDecl, R, SI, false, false)
5648
              , mapType(MapType)
5649
460
  {
5650
460
  }
5651
5652
  OMPDeclareTargetDeclAttr *clone(ASTContext &C) const;
5653
  void printPretty(raw_ostream &OS,