Coverage Report

Created: 2024-01-17 10:31

/src/llvm-project/clang/lib/Sema/SemaAttr.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- SemaAttr.cpp - Semantic Analysis for Attributes ------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file implements semantic analysis for non-trivial attributes and
10
// pragmas.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "clang/AST/ASTConsumer.h"
15
#include "clang/AST/Attr.h"
16
#include "clang/AST/Expr.h"
17
#include "clang/Basic/TargetInfo.h"
18
#include "clang/Lex/Preprocessor.h"
19
#include "clang/Sema/Lookup.h"
20
#include "clang/Sema/SemaInternal.h"
21
#include <optional>
22
using namespace clang;
23
24
//===----------------------------------------------------------------------===//
25
// Pragma 'pack' and 'options align'
26
//===----------------------------------------------------------------------===//
27
28
Sema::PragmaStackSentinelRAII::PragmaStackSentinelRAII(Sema &S,
29
                                                       StringRef SlotLabel,
30
                                                       bool ShouldAct)
31
0
    : S(S), SlotLabel(SlotLabel), ShouldAct(ShouldAct) {
32
0
  if (ShouldAct) {
33
0
    S.VtorDispStack.SentinelAction(PSK_Push, SlotLabel);
34
0
    S.DataSegStack.SentinelAction(PSK_Push, SlotLabel);
35
0
    S.BSSSegStack.SentinelAction(PSK_Push, SlotLabel);
36
0
    S.ConstSegStack.SentinelAction(PSK_Push, SlotLabel);
37
0
    S.CodeSegStack.SentinelAction(PSK_Push, SlotLabel);
38
0
    S.StrictGuardStackCheckStack.SentinelAction(PSK_Push, SlotLabel);
39
0
  }
40
0
}
41
42
0
Sema::PragmaStackSentinelRAII::~PragmaStackSentinelRAII() {
43
0
  if (ShouldAct) {
44
0
    S.VtorDispStack.SentinelAction(PSK_Pop, SlotLabel);
45
0
    S.DataSegStack.SentinelAction(PSK_Pop, SlotLabel);
46
0
    S.BSSSegStack.SentinelAction(PSK_Pop, SlotLabel);
47
0
    S.ConstSegStack.SentinelAction(PSK_Pop, SlotLabel);
48
0
    S.CodeSegStack.SentinelAction(PSK_Pop, SlotLabel);
49
0
    S.StrictGuardStackCheckStack.SentinelAction(PSK_Pop, SlotLabel);
50
0
  }
51
0
}
52
53
0
void Sema::AddAlignmentAttributesForRecord(RecordDecl *RD) {
54
0
  AlignPackInfo InfoVal = AlignPackStack.CurrentValue;
55
0
  AlignPackInfo::Mode M = InfoVal.getAlignMode();
56
0
  bool IsPackSet = InfoVal.IsPackSet();
57
0
  bool IsXLPragma = getLangOpts().XLPragmaPack;
58
59
  // If we are not under mac68k/natural alignment mode and also there is no pack
60
  // value, we don't need any attributes.
61
0
  if (!IsPackSet && M != AlignPackInfo::Mac68k && M != AlignPackInfo::Natural)
62
0
    return;
63
64
0
  if (M == AlignPackInfo::Mac68k && (IsXLPragma || InfoVal.IsAlignAttr())) {
65
0
    RD->addAttr(AlignMac68kAttr::CreateImplicit(Context));
66
0
  } else if (IsPackSet) {
67
    // Check to see if we need a max field alignment attribute.
68
0
    RD->addAttr(MaxFieldAlignmentAttr::CreateImplicit(
69
0
        Context, InfoVal.getPackNumber() * 8));
70
0
  }
71
72
0
  if (IsXLPragma && M == AlignPackInfo::Natural)
73
0
    RD->addAttr(AlignNaturalAttr::CreateImplicit(Context));
74
75
0
  if (AlignPackIncludeStack.empty())
76
0
    return;
77
  // The #pragma align/pack affected a record in an included file, so Clang
78
  // should warn when that pragma was written in a file that included the
79
  // included file.
80
0
  for (auto &AlignPackedInclude : llvm::reverse(AlignPackIncludeStack)) {
81
0
    if (AlignPackedInclude.CurrentPragmaLocation !=
82
0
        AlignPackStack.CurrentPragmaLocation)
83
0
      break;
84
0
    if (AlignPackedInclude.HasNonDefaultValue)
85
0
      AlignPackedInclude.ShouldWarnOnInclude = true;
86
0
  }
87
0
}
88
89
0
void Sema::AddMsStructLayoutForRecord(RecordDecl *RD) {
90
0
  if (MSStructPragmaOn)
91
0
    RD->addAttr(MSStructAttr::CreateImplicit(Context));
92
93
  // FIXME: We should merge AddAlignmentAttributesForRecord with
94
  // AddMsStructLayoutForRecord into AddPragmaAttributesForRecord, which takes
95
  // all active pragmas and applies them as attributes to class definitions.
96
0
  if (VtorDispStack.CurrentValue != getLangOpts().getVtorDispMode())
97
0
    RD->addAttr(MSVtorDispAttr::CreateImplicit(
98
0
        Context, unsigned(VtorDispStack.CurrentValue)));
99
0
}
100
101
template <typename Attribute>
102
static void addGslOwnerPointerAttributeIfNotExisting(ASTContext &Context,
103
0
                                                     CXXRecordDecl *Record) {
104
0
  if (Record->hasAttr<OwnerAttr>() || Record->hasAttr<PointerAttr>())
105
0
    return;
106
107
0
  for (Decl *Redecl : Record->redecls())
108
0
    Redecl->addAttr(Attribute::CreateImplicit(Context, /*DerefType=*/nullptr));
109
0
}
Unexecuted instantiation: SemaAttr.cpp:void addGslOwnerPointerAttributeIfNotExisting<clang::PointerAttr>(clang::ASTContext&, clang::CXXRecordDecl*)
Unexecuted instantiation: SemaAttr.cpp:void addGslOwnerPointerAttributeIfNotExisting<clang::OwnerAttr>(clang::ASTContext&, clang::CXXRecordDecl*)
110
111
void Sema::inferGslPointerAttribute(NamedDecl *ND,
112
0
                                    CXXRecordDecl *UnderlyingRecord) {
113
0
  if (!UnderlyingRecord)
114
0
    return;
115
116
0
  const auto *Parent = dyn_cast<CXXRecordDecl>(ND->getDeclContext());
117
0
  if (!Parent)
118
0
    return;
119
120
0
  static llvm::StringSet<> Containers{
121
0
      "array",
122
0
      "basic_string",
123
0
      "deque",
124
0
      "forward_list",
125
0
      "vector",
126
0
      "list",
127
0
      "map",
128
0
      "multiset",
129
0
      "multimap",
130
0
      "priority_queue",
131
0
      "queue",
132
0
      "set",
133
0
      "stack",
134
0
      "unordered_set",
135
0
      "unordered_map",
136
0
      "unordered_multiset",
137
0
      "unordered_multimap",
138
0
  };
139
140
0
  static llvm::StringSet<> Iterators{"iterator", "const_iterator",
141
0
                                     "reverse_iterator",
142
0
                                     "const_reverse_iterator"};
143
144
0
  if (Parent->isInStdNamespace() && Iterators.count(ND->getName()) &&
145
0
      Containers.count(Parent->getName()))
146
0
    addGslOwnerPointerAttributeIfNotExisting<PointerAttr>(Context,
147
0
                                                          UnderlyingRecord);
148
0
}
149
150
0
void Sema::inferGslPointerAttribute(TypedefNameDecl *TD) {
151
152
0
  QualType Canonical = TD->getUnderlyingType().getCanonicalType();
153
154
0
  CXXRecordDecl *RD = Canonical->getAsCXXRecordDecl();
155
0
  if (!RD) {
156
0
    if (auto *TST =
157
0
            dyn_cast<TemplateSpecializationType>(Canonical.getTypePtr())) {
158
159
0
      RD = dyn_cast_or_null<CXXRecordDecl>(
160
0
          TST->getTemplateName().getAsTemplateDecl()->getTemplatedDecl());
161
0
    }
162
0
  }
163
164
0
  inferGslPointerAttribute(TD, RD);
165
0
}
166
167
0
void Sema::inferGslOwnerPointerAttribute(CXXRecordDecl *Record) {
168
0
  static llvm::StringSet<> StdOwners{
169
0
      "any",
170
0
      "array",
171
0
      "basic_regex",
172
0
      "basic_string",
173
0
      "deque",
174
0
      "forward_list",
175
0
      "vector",
176
0
      "list",
177
0
      "map",
178
0
      "multiset",
179
0
      "multimap",
180
0
      "optional",
181
0
      "priority_queue",
182
0
      "queue",
183
0
      "set",
184
0
      "stack",
185
0
      "unique_ptr",
186
0
      "unordered_set",
187
0
      "unordered_map",
188
0
      "unordered_multiset",
189
0
      "unordered_multimap",
190
0
      "variant",
191
0
  };
192
0
  static llvm::StringSet<> StdPointers{
193
0
      "basic_string_view",
194
0
      "reference_wrapper",
195
0
      "regex_iterator",
196
0
  };
197
198
0
  if (!Record->getIdentifier())
199
0
    return;
200
201
  // Handle classes that directly appear in std namespace.
202
0
  if (Record->isInStdNamespace()) {
203
0
    if (Record->hasAttr<OwnerAttr>() || Record->hasAttr<PointerAttr>())
204
0
      return;
205
206
0
    if (StdOwners.count(Record->getName()))
207
0
      addGslOwnerPointerAttributeIfNotExisting<OwnerAttr>(Context, Record);
208
0
    else if (StdPointers.count(Record->getName()))
209
0
      addGslOwnerPointerAttributeIfNotExisting<PointerAttr>(Context, Record);
210
211
0
    return;
212
0
  }
213
214
  // Handle nested classes that could be a gsl::Pointer.
215
0
  inferGslPointerAttribute(Record, Record);
216
0
}
217
218
void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
219
0
                                   SourceLocation PragmaLoc) {
220
0
  PragmaMsStackAction Action = Sema::PSK_Reset;
221
0
  AlignPackInfo::Mode ModeVal = AlignPackInfo::Native;
222
223
0
  switch (Kind) {
224
    // For most of the platforms we support, native and natural are the same.
225
    // With XL, native is the same as power, natural means something else.
226
0
  case POAK_Native:
227
0
  case POAK_Power:
228
0
    Action = Sema::PSK_Push_Set;
229
0
    break;
230
0
  case POAK_Natural:
231
0
    Action = Sema::PSK_Push_Set;
232
0
    ModeVal = AlignPackInfo::Natural;
233
0
    break;
234
235
    // Note that '#pragma options align=packed' is not equivalent to attribute
236
    // packed, it has a different precedence relative to attribute aligned.
237
0
  case POAK_Packed:
238
0
    Action = Sema::PSK_Push_Set;
239
0
    ModeVal = AlignPackInfo::Packed;
240
0
    break;
241
242
0
  case POAK_Mac68k:
243
    // Check if the target supports this.
244
0
    if (!this->Context.getTargetInfo().hasAlignMac68kSupport()) {
245
0
      Diag(PragmaLoc, diag::err_pragma_options_align_mac68k_target_unsupported);
246
0
      return;
247
0
    }
248
0
    Action = Sema::PSK_Push_Set;
249
0
    ModeVal = AlignPackInfo::Mac68k;
250
0
    break;
251
0
  case POAK_Reset:
252
    // Reset just pops the top of the stack, or resets the current alignment to
253
    // default.
254
0
    Action = Sema::PSK_Pop;
255
0
    if (AlignPackStack.Stack.empty()) {
256
0
      if (AlignPackStack.CurrentValue.getAlignMode() != AlignPackInfo::Native ||
257
0
          AlignPackStack.CurrentValue.IsPackAttr()) {
258
0
        Action = Sema::PSK_Reset;
259
0
      } else {
260
0
        Diag(PragmaLoc, diag::warn_pragma_options_align_reset_failed)
261
0
            << "stack empty";
262
0
        return;
263
0
      }
264
0
    }
265
0
    break;
266
0
  }
267
268
0
  AlignPackInfo Info(ModeVal, getLangOpts().XLPragmaPack);
269
270
0
  AlignPackStack.Act(PragmaLoc, Action, StringRef(), Info);
271
0
}
272
273
void Sema::ActOnPragmaClangSection(SourceLocation PragmaLoc,
274
                                   PragmaClangSectionAction Action,
275
                                   PragmaClangSectionKind SecKind,
276
0
                                   StringRef SecName) {
277
0
  PragmaClangSection *CSec;
278
0
  int SectionFlags = ASTContext::PSF_Read;
279
0
  switch (SecKind) {
280
0
    case PragmaClangSectionKind::PCSK_BSS:
281
0
      CSec = &PragmaClangBSSSection;
282
0
      SectionFlags |= ASTContext::PSF_Write | ASTContext::PSF_ZeroInit;
283
0
      break;
284
0
    case PragmaClangSectionKind::PCSK_Data:
285
0
      CSec = &PragmaClangDataSection;
286
0
      SectionFlags |= ASTContext::PSF_Write;
287
0
      break;
288
0
    case PragmaClangSectionKind::PCSK_Rodata:
289
0
      CSec = &PragmaClangRodataSection;
290
0
      break;
291
0
    case PragmaClangSectionKind::PCSK_Relro:
292
0
      CSec = &PragmaClangRelroSection;
293
0
      break;
294
0
    case PragmaClangSectionKind::PCSK_Text:
295
0
      CSec = &PragmaClangTextSection;
296
0
      SectionFlags |= ASTContext::PSF_Execute;
297
0
      break;
298
0
    default:
299
0
      llvm_unreachable("invalid clang section kind");
300
0
  }
301
302
0
  if (Action == PragmaClangSectionAction::PCSA_Clear) {
303
0
    CSec->Valid = false;
304
0
    return;
305
0
  }
306
307
0
  if (llvm::Error E = isValidSectionSpecifier(SecName)) {
308
0
    Diag(PragmaLoc, diag::err_pragma_section_invalid_for_target)
309
0
        << toString(std::move(E));
310
0
    CSec->Valid = false;
311
0
    return;
312
0
  }
313
314
0
  if (UnifySection(SecName, SectionFlags, PragmaLoc))
315
0
    return;
316
317
0
  CSec->Valid = true;
318
0
  CSec->SectionName = std::string(SecName);
319
0
  CSec->PragmaLocation = PragmaLoc;
320
0
}
321
322
void Sema::ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
323
0
                           StringRef SlotLabel, Expr *alignment) {
324
0
  bool IsXLPragma = getLangOpts().XLPragmaPack;
325
  // XL pragma pack does not support identifier syntax.
326
0
  if (IsXLPragma && !SlotLabel.empty()) {
327
0
    Diag(PragmaLoc, diag::err_pragma_pack_identifer_not_supported);
328
0
    return;
329
0
  }
330
331
0
  const AlignPackInfo CurVal = AlignPackStack.CurrentValue;
332
0
  Expr *Alignment = static_cast<Expr *>(alignment);
333
334
  // If specified then alignment must be a "small" power of two.
335
0
  unsigned AlignmentVal = 0;
336
0
  AlignPackInfo::Mode ModeVal = CurVal.getAlignMode();
337
338
0
  if (Alignment) {
339
0
    std::optional<llvm::APSInt> Val;
340
0
    Val = Alignment->getIntegerConstantExpr(Context);
341
342
    // pack(0) is like pack(), which just works out since that is what
343
    // we use 0 for in PackAttr.
344
0
    if (Alignment->isTypeDependent() || !Val ||
345
0
        !(*Val == 0 || Val->isPowerOf2()) || Val->getZExtValue() > 16) {
346
0
      Diag(PragmaLoc, diag::warn_pragma_pack_invalid_alignment);
347
0
      return; // Ignore
348
0
    }
349
350
0
    if (IsXLPragma && *Val == 0) {
351
      // pack(0) does not work out with XL.
352
0
      Diag(PragmaLoc, diag::err_pragma_pack_invalid_alignment);
353
0
      return; // Ignore
354
0
    }
355
356
0
    AlignmentVal = (unsigned)Val->getZExtValue();
357
0
  }
358
359
0
  if (Action == Sema::PSK_Show) {
360
    // Show the current alignment, making sure to show the right value
361
    // for the default.
362
    // FIXME: This should come from the target.
363
0
    AlignmentVal = CurVal.IsPackSet() ? CurVal.getPackNumber() : 8;
364
0
    if (ModeVal == AlignPackInfo::Mac68k &&
365
0
        (IsXLPragma || CurVal.IsAlignAttr()))
366
0
      Diag(PragmaLoc, diag::warn_pragma_pack_show) << "mac68k";
367
0
    else
368
0
      Diag(PragmaLoc, diag::warn_pragma_pack_show) << AlignmentVal;
369
0
  }
370
371
  // MSDN, C/C++ Preprocessor Reference > Pragma Directives > pack:
372
  // "#pragma pack(pop, identifier, n) is undefined"
373
0
  if (Action & Sema::PSK_Pop) {
374
0
    if (Alignment && !SlotLabel.empty())
375
0
      Diag(PragmaLoc, diag::warn_pragma_pack_pop_identifier_and_alignment);
376
0
    if (AlignPackStack.Stack.empty()) {
377
0
      assert(CurVal.getAlignMode() == AlignPackInfo::Native &&
378
0
             "Empty pack stack can only be at Native alignment mode.");
379
0
      Diag(PragmaLoc, diag::warn_pragma_pop_failed) << "pack" << "stack empty";
380
0
    }
381
0
  }
382
383
0
  AlignPackInfo Info(ModeVal, AlignmentVal, IsXLPragma);
384
385
0
  AlignPackStack.Act(PragmaLoc, Action, SlotLabel, Info);
386
0
}
387
388
bool Sema::ConstantFoldAttrArgs(const AttributeCommonInfo &CI,
389
0
                                MutableArrayRef<Expr *> Args) {
390
0
  llvm::SmallVector<PartialDiagnosticAt, 8> Notes;
391
0
  for (unsigned Idx = 0; Idx < Args.size(); Idx++) {
392
0
    Expr *&E = Args.begin()[Idx];
393
0
    assert(E && "error are handled before");
394
0
    if (E->isValueDependent() || E->isTypeDependent())
395
0
      continue;
396
397
    // FIXME: Use DefaultFunctionArrayLValueConversion() in place of the logic
398
    // that adds implicit casts here.
399
0
    if (E->getType()->isArrayType())
400
0
      E = ImpCastExprToType(E, Context.getPointerType(E->getType()),
401
0
                            clang::CK_ArrayToPointerDecay)
402
0
              .get();
403
0
    if (E->getType()->isFunctionType())
404
0
      E = ImplicitCastExpr::Create(Context,
405
0
                                   Context.getPointerType(E->getType()),
406
0
                                   clang::CK_FunctionToPointerDecay, E, nullptr,
407
0
                                   VK_PRValue, FPOptionsOverride());
408
0
    if (E->isLValue())
409
0
      E = ImplicitCastExpr::Create(Context, E->getType().getNonReferenceType(),
410
0
                                   clang::CK_LValueToRValue, E, nullptr,
411
0
                                   VK_PRValue, FPOptionsOverride());
412
413
0
    Expr::EvalResult Eval;
414
0
    Notes.clear();
415
0
    Eval.Diag = &Notes;
416
417
0
    bool Result = E->EvaluateAsConstantExpr(Eval, Context);
418
419
    /// Result means the expression can be folded to a constant.
420
    /// Note.empty() means the expression is a valid constant expression in the
421
    /// current language mode.
422
0
    if (!Result || !Notes.empty()) {
423
0
      Diag(E->getBeginLoc(), diag::err_attribute_argument_n_type)
424
0
          << CI << (Idx + 1) << AANT_ArgumentConstantExpr;
425
0
      for (auto &Note : Notes)
426
0
        Diag(Note.first, Note.second);
427
0
      return false;
428
0
    }
429
0
    assert(Eval.Val.hasValue());
430
0
    E = ConstantExpr::Create(Context, E, Eval.Val);
431
0
  }
432
433
0
  return true;
434
0
}
435
436
void Sema::DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind,
437
0
                                             SourceLocation IncludeLoc) {
438
0
  if (Kind == PragmaAlignPackDiagnoseKind::NonDefaultStateAtInclude) {
439
0
    SourceLocation PrevLocation = AlignPackStack.CurrentPragmaLocation;
440
    // Warn about non-default alignment at #includes (without redundant
441
    // warnings for the same directive in nested includes).
442
    // The warning is delayed until the end of the file to avoid warnings
443
    // for files that don't have any records that are affected by the modified
444
    // alignment.
445
0
    bool HasNonDefaultValue =
446
0
        AlignPackStack.hasValue() &&
447
0
        (AlignPackIncludeStack.empty() ||
448
0
         AlignPackIncludeStack.back().CurrentPragmaLocation != PrevLocation);
449
0
    AlignPackIncludeStack.push_back(
450
0
        {AlignPackStack.CurrentValue,
451
0
         AlignPackStack.hasValue() ? PrevLocation : SourceLocation(),
452
0
         HasNonDefaultValue, /*ShouldWarnOnInclude*/ false});
453
0
    return;
454
0
  }
455
456
0
  assert(Kind == PragmaAlignPackDiagnoseKind::ChangedStateAtExit &&
457
0
         "invalid kind");
458
0
  AlignPackIncludeState PrevAlignPackState =
459
0
      AlignPackIncludeStack.pop_back_val();
460
  // FIXME: AlignPackStack may contain both #pragma align and #pragma pack
461
  // information, diagnostics below might not be accurate if we have mixed
462
  // pragmas.
463
0
  if (PrevAlignPackState.ShouldWarnOnInclude) {
464
    // Emit the delayed non-default alignment at #include warning.
465
0
    Diag(IncludeLoc, diag::warn_pragma_pack_non_default_at_include);
466
0
    Diag(PrevAlignPackState.CurrentPragmaLocation, diag::note_pragma_pack_here);
467
0
  }
468
  // Warn about modified alignment after #includes.
469
0
  if (PrevAlignPackState.CurrentValue != AlignPackStack.CurrentValue) {
470
0
    Diag(IncludeLoc, diag::warn_pragma_pack_modified_after_include);
471
0
    Diag(AlignPackStack.CurrentPragmaLocation, diag::note_pragma_pack_here);
472
0
  }
473
0
}
474
475
46
void Sema::DiagnoseUnterminatedPragmaAlignPack() {
476
46
  if (AlignPackStack.Stack.empty())
477
46
    return;
478
0
  bool IsInnermost = true;
479
480
  // FIXME: AlignPackStack may contain both #pragma align and #pragma pack
481
  // information, diagnostics below might not be accurate if we have mixed
482
  // pragmas.
483
0
  for (const auto &StackSlot : llvm::reverse(AlignPackStack.Stack)) {
484
0
    Diag(StackSlot.PragmaPushLocation, diag::warn_pragma_pack_no_pop_eof);
485
    // The user might have already reset the alignment, so suggest replacing
486
    // the reset with a pop.
487
0
    if (IsInnermost &&
488
0
        AlignPackStack.CurrentValue == AlignPackStack.DefaultValue) {
489
0
      auto DB = Diag(AlignPackStack.CurrentPragmaLocation,
490
0
                     diag::note_pragma_pack_pop_instead_reset);
491
0
      SourceLocation FixItLoc =
492
0
          Lexer::findLocationAfterToken(AlignPackStack.CurrentPragmaLocation,
493
0
                                        tok::l_paren, SourceMgr, LangOpts,
494
0
                                        /*SkipTrailing=*/false);
495
0
      if (FixItLoc.isValid())
496
0
        DB << FixItHint::CreateInsertion(FixItLoc, "pop");
497
0
    }
498
0
    IsInnermost = false;
499
0
  }
500
0
}
501
502
0
void Sema::ActOnPragmaMSStruct(PragmaMSStructKind Kind) {
503
0
  MSStructPragmaOn = (Kind == PMSST_ON);
504
0
}
505
506
void Sema::ActOnPragmaMSComment(SourceLocation CommentLoc,
507
0
                                PragmaMSCommentKind Kind, StringRef Arg) {
508
0
  auto *PCD = PragmaCommentDecl::Create(
509
0
      Context, Context.getTranslationUnitDecl(), CommentLoc, Kind, Arg);
510
0
  Context.getTranslationUnitDecl()->addDecl(PCD);
511
0
  Consumer.HandleTopLevelDecl(DeclGroupRef(PCD));
512
0
}
513
514
void Sema::ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
515
0
                                     StringRef Value) {
516
0
  auto *PDMD = PragmaDetectMismatchDecl::Create(
517
0
      Context, Context.getTranslationUnitDecl(), Loc, Name, Value);
518
0
  Context.getTranslationUnitDecl()->addDecl(PDMD);
519
0
  Consumer.HandleTopLevelDecl(DeclGroupRef(PDMD));
520
0
}
521
522
void Sema::ActOnPragmaFPEvalMethod(SourceLocation Loc,
523
0
                                   LangOptions::FPEvalMethodKind Value) {
524
0
  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
525
0
  switch (Value) {
526
0
  default:
527
0
    llvm_unreachable("invalid pragma eval_method kind");
528
0
  case LangOptions::FEM_Source:
529
0
    NewFPFeatures.setFPEvalMethodOverride(LangOptions::FEM_Source);
530
0
    break;
531
0
  case LangOptions::FEM_Double:
532
0
    NewFPFeatures.setFPEvalMethodOverride(LangOptions::FEM_Double);
533
0
    break;
534
0
  case LangOptions::FEM_Extended:
535
0
    NewFPFeatures.setFPEvalMethodOverride(LangOptions::FEM_Extended);
536
0
    break;
537
0
  }
538
0
  if (getLangOpts().ApproxFunc)
539
0
    Diag(Loc, diag::err_setting_eval_method_used_in_unsafe_context) << 0 << 0;
540
0
  if (getLangOpts().AllowFPReassoc)
541
0
    Diag(Loc, diag::err_setting_eval_method_used_in_unsafe_context) << 0 << 1;
542
0
  if (getLangOpts().AllowRecip)
543
0
    Diag(Loc, diag::err_setting_eval_method_used_in_unsafe_context) << 0 << 2;
544
0
  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
545
0
  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
546
0
  PP.setCurrentFPEvalMethod(Loc, Value);
547
0
}
548
549
void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
550
                                   PragmaMsStackAction Action,
551
0
                                   PragmaFloatControlKind Value) {
552
0
  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
553
0
  if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop) &&
554
0
      !CurContext->getRedeclContext()->isFileContext()) {
555
    // Push and pop can only occur at file or namespace scope, or within a
556
    // language linkage declaration.
557
0
    Diag(Loc, diag::err_pragma_fc_pp_scope);
558
0
    return;
559
0
  }
560
0
  switch (Value) {
561
0
  default:
562
0
    llvm_unreachable("invalid pragma float_control kind");
563
0
  case PFC_Precise:
564
0
    NewFPFeatures.setFPPreciseEnabled(true);
565
0
    FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
566
0
    break;
567
0
  case PFC_NoPrecise:
568
0
    if (CurFPFeatures.getExceptionMode() == LangOptions::FPE_Strict)
569
0
      Diag(Loc, diag::err_pragma_fc_noprecise_requires_noexcept);
570
0
    else if (CurFPFeatures.getAllowFEnvAccess())
571
0
      Diag(Loc, diag::err_pragma_fc_noprecise_requires_nofenv);
572
0
    else
573
0
      NewFPFeatures.setFPPreciseEnabled(false);
574
0
    FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
575
0
    break;
576
0
  case PFC_Except:
577
0
    if (!isPreciseFPEnabled())
578
0
      Diag(Loc, diag::err_pragma_fc_except_requires_precise);
579
0
    else
580
0
      NewFPFeatures.setSpecifiedExceptionModeOverride(LangOptions::FPE_Strict);
581
0
    FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
582
0
    break;
583
0
  case PFC_NoExcept:
584
0
    NewFPFeatures.setSpecifiedExceptionModeOverride(LangOptions::FPE_Ignore);
585
0
    FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
586
0
    break;
587
0
  case PFC_Push:
588
0
    FpPragmaStack.Act(Loc, Sema::PSK_Push_Set, StringRef(), NewFPFeatures);
589
0
    break;
590
0
  case PFC_Pop:
591
0
    if (FpPragmaStack.Stack.empty()) {
592
0
      Diag(Loc, diag::warn_pragma_pop_failed) << "float_control"
593
0
                                              << "stack empty";
594
0
      return;
595
0
    }
596
0
    FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
597
0
    NewFPFeatures = FpPragmaStack.CurrentValue;
598
0
    break;
599
0
  }
600
0
  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
601
0
}
602
603
void Sema::ActOnPragmaMSPointersToMembers(
604
    LangOptions::PragmaMSPointersToMembersKind RepresentationMethod,
605
0
    SourceLocation PragmaLoc) {
606
0
  MSPointerToMemberRepresentationMethod = RepresentationMethod;
607
0
  ImplicitMSInheritanceAttrLoc = PragmaLoc;
608
0
}
609
610
void Sema::ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
611
                                 SourceLocation PragmaLoc,
612
0
                                 MSVtorDispMode Mode) {
613
0
  if (Action & PSK_Pop && VtorDispStack.Stack.empty())
614
0
    Diag(PragmaLoc, diag::warn_pragma_pop_failed) << "vtordisp"
615
0
                                                  << "stack empty";
616
0
  VtorDispStack.Act(PragmaLoc, Action, StringRef(), Mode);
617
0
}
618
619
template <>
620
void Sema::PragmaStack<Sema::AlignPackInfo>::Act(SourceLocation PragmaLocation,
621
                                                 PragmaMsStackAction Action,
622
                                                 llvm::StringRef StackSlotLabel,
623
0
                                                 AlignPackInfo Value) {
624
0
  if (Action == PSK_Reset) {
625
0
    CurrentValue = DefaultValue;
626
0
    CurrentPragmaLocation = PragmaLocation;
627
0
    return;
628
0
  }
629
0
  if (Action & PSK_Push)
630
0
    Stack.emplace_back(Slot(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
631
0
                            PragmaLocation));
632
0
  else if (Action & PSK_Pop) {
633
0
    if (!StackSlotLabel.empty()) {
634
      // If we've got a label, try to find it and jump there.
635
0
      auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
636
0
        return x.StackSlotLabel == StackSlotLabel;
637
0
      });
638
      // We found the label, so pop from there.
639
0
      if (I != Stack.rend()) {
640
0
        CurrentValue = I->Value;
641
0
        CurrentPragmaLocation = I->PragmaLocation;
642
0
        Stack.erase(std::prev(I.base()), Stack.end());
643
0
      }
644
0
    } else if (Value.IsXLStack() && Value.IsAlignAttr() &&
645
0
               CurrentValue.IsPackAttr()) {
646
      // XL '#pragma align(reset)' would pop the stack until
647
      // a current in effect pragma align is popped.
648
0
      auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
649
0
        return x.Value.IsAlignAttr();
650
0
      });
651
      // If we found pragma align so pop from there.
652
0
      if (I != Stack.rend()) {
653
0
        Stack.erase(std::prev(I.base()), Stack.end());
654
0
        if (Stack.empty()) {
655
0
          CurrentValue = DefaultValue;
656
0
          CurrentPragmaLocation = PragmaLocation;
657
0
        } else {
658
0
          CurrentValue = Stack.back().Value;
659
0
          CurrentPragmaLocation = Stack.back().PragmaLocation;
660
0
          Stack.pop_back();
661
0
        }
662
0
      }
663
0
    } else if (!Stack.empty()) {
664
      // xl '#pragma align' sets the baseline, and `#pragma pack` cannot pop
665
      // over the baseline.
666
0
      if (Value.IsXLStack() && Value.IsPackAttr() && CurrentValue.IsAlignAttr())
667
0
        return;
668
669
      // We don't have a label, just pop the last entry.
670
0
      CurrentValue = Stack.back().Value;
671
0
      CurrentPragmaLocation = Stack.back().PragmaLocation;
672
0
      Stack.pop_back();
673
0
    }
674
0
  }
675
0
  if (Action & PSK_Set) {
676
0
    CurrentValue = Value;
677
0
    CurrentPragmaLocation = PragmaLocation;
678
0
  }
679
0
}
680
681
bool Sema::UnifySection(StringRef SectionName, int SectionFlags,
682
0
                        NamedDecl *Decl) {
683
0
  SourceLocation PragmaLocation;
684
0
  if (auto A = Decl->getAttr<SectionAttr>())
685
0
    if (A->isImplicit())
686
0
      PragmaLocation = A->getLocation();
687
0
  auto SectionIt = Context.SectionInfos.find(SectionName);
688
0
  if (SectionIt == Context.SectionInfos.end()) {
689
0
    Context.SectionInfos[SectionName] =
690
0
        ASTContext::SectionInfo(Decl, PragmaLocation, SectionFlags);
691
0
    return false;
692
0
  }
693
  // A pre-declared section takes precedence w/o diagnostic.
694
0
  const auto &Section = SectionIt->second;
695
0
  if (Section.SectionFlags == SectionFlags ||
696
0
      ((SectionFlags & ASTContext::PSF_Implicit) &&
697
0
       !(Section.SectionFlags & ASTContext::PSF_Implicit)))
698
0
    return false;
699
0
  Diag(Decl->getLocation(), diag::err_section_conflict) << Decl << Section;
700
0
  if (Section.Decl)
701
0
    Diag(Section.Decl->getLocation(), diag::note_declared_at)
702
0
        << Section.Decl->getName();
703
0
  if (PragmaLocation.isValid())
704
0
    Diag(PragmaLocation, diag::note_pragma_entered_here);
705
0
  if (Section.PragmaSectionLocation.isValid())
706
0
    Diag(Section.PragmaSectionLocation, diag::note_pragma_entered_here);
707
0
  return true;
708
0
}
709
710
bool Sema::UnifySection(StringRef SectionName,
711
                        int SectionFlags,
712
0
                        SourceLocation PragmaSectionLocation) {
713
0
  auto SectionIt = Context.SectionInfos.find(SectionName);
714
0
  if (SectionIt != Context.SectionInfos.end()) {
715
0
    const auto &Section = SectionIt->second;
716
0
    if (Section.SectionFlags == SectionFlags)
717
0
      return false;
718
0
    if (!(Section.SectionFlags & ASTContext::PSF_Implicit)) {
719
0
      Diag(PragmaSectionLocation, diag::err_section_conflict)
720
0
          << "this" << Section;
721
0
      if (Section.Decl)
722
0
        Diag(Section.Decl->getLocation(), diag::note_declared_at)
723
0
            << Section.Decl->getName();
724
0
      if (Section.PragmaSectionLocation.isValid())
725
0
        Diag(Section.PragmaSectionLocation, diag::note_pragma_entered_here);
726
0
      return true;
727
0
    }
728
0
  }
729
0
  Context.SectionInfos[SectionName] =
730
0
      ASTContext::SectionInfo(nullptr, PragmaSectionLocation, SectionFlags);
731
0
  return false;
732
0
}
733
734
/// Called on well formed \#pragma bss_seg().
735
void Sema::ActOnPragmaMSSeg(SourceLocation PragmaLocation,
736
                            PragmaMsStackAction Action,
737
                            llvm::StringRef StackSlotLabel,
738
                            StringLiteral *SegmentName,
739
0
                            llvm::StringRef PragmaName) {
740
0
  PragmaStack<StringLiteral *> *Stack =
741
0
    llvm::StringSwitch<PragmaStack<StringLiteral *> *>(PragmaName)
742
0
        .Case("data_seg", &DataSegStack)
743
0
        .Case("bss_seg", &BSSSegStack)
744
0
        .Case("const_seg", &ConstSegStack)
745
0
        .Case("code_seg", &CodeSegStack);
746
0
  if (Action & PSK_Pop && Stack->Stack.empty())
747
0
    Diag(PragmaLocation, diag::warn_pragma_pop_failed) << PragmaName
748
0
        << "stack empty";
749
0
  if (SegmentName) {
750
0
    if (!checkSectionName(SegmentName->getBeginLoc(), SegmentName->getString()))
751
0
      return;
752
753
0
    if (SegmentName->getString() == ".drectve" &&
754
0
        Context.getTargetInfo().getCXXABI().isMicrosoft())
755
0
      Diag(PragmaLocation, diag::warn_attribute_section_drectve) << PragmaName;
756
0
  }
757
758
0
  Stack->Act(PragmaLocation, Action, StackSlotLabel, SegmentName);
759
0
}
760
761
/// Called on well formed \#pragma strict_gs_check().
762
void Sema::ActOnPragmaMSStrictGuardStackCheck(SourceLocation PragmaLocation,
763
                                              PragmaMsStackAction Action,
764
0
                                              bool Value) {
765
0
  if (Action & PSK_Pop && StrictGuardStackCheckStack.Stack.empty())
766
0
    Diag(PragmaLocation, diag::warn_pragma_pop_failed) << "strict_gs_check"
767
0
                                                       << "stack empty";
768
769
0
  StrictGuardStackCheckStack.Act(PragmaLocation, Action, StringRef(), Value);
770
0
}
771
772
/// Called on well formed \#pragma bss_seg().
773
void Sema::ActOnPragmaMSSection(SourceLocation PragmaLocation,
774
0
                                int SectionFlags, StringLiteral *SegmentName) {
775
0
  UnifySection(SegmentName->getString(), SectionFlags, PragmaLocation);
776
0
}
777
778
void Sema::ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
779
0
                                StringLiteral *SegmentName) {
780
  // There's no stack to maintain, so we just have a current section.  When we
781
  // see the default section, reset our current section back to null so we stop
782
  // tacking on unnecessary attributes.
783
0
  CurInitSeg = SegmentName->getString() == ".CRT$XCU" ? nullptr : SegmentName;
784
0
  CurInitSegLoc = PragmaLocation;
785
0
}
786
787
void Sema::ActOnPragmaMSAllocText(
788
    SourceLocation PragmaLocation, StringRef Section,
789
    const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
790
0
        &Functions) {
791
0
  if (!CurContext->getRedeclContext()->isFileContext()) {
792
0
    Diag(PragmaLocation, diag::err_pragma_expected_file_scope) << "alloc_text";
793
0
    return;
794
0
  }
795
796
0
  for (auto &Function : Functions) {
797
0
    IdentifierInfo *II;
798
0
    SourceLocation Loc;
799
0
    std::tie(II, Loc) = Function;
800
801
0
    DeclarationName DN(II);
802
0
    NamedDecl *ND = LookupSingleName(TUScope, DN, Loc, LookupOrdinaryName);
803
0
    if (!ND) {
804
0
      Diag(Loc, diag::err_undeclared_use) << II->getName();
805
0
      return;
806
0
    }
807
808
0
    auto *FD = dyn_cast<FunctionDecl>(ND->getCanonicalDecl());
809
0
    if (!FD) {
810
0
      Diag(Loc, diag::err_pragma_alloc_text_not_function);
811
0
      return;
812
0
    }
813
814
0
    if (getLangOpts().CPlusPlus && !FD->isInExternCContext()) {
815
0
      Diag(Loc, diag::err_pragma_alloc_text_c_linkage);
816
0
      return;
817
0
    }
818
819
0
    FunctionToSectionMap[II->getName()] = std::make_tuple(Section, Loc);
820
0
  }
821
0
}
822
823
void Sema::ActOnPragmaUnused(const Token &IdTok, Scope *curScope,
824
0
                             SourceLocation PragmaLoc) {
825
826
0
  IdentifierInfo *Name = IdTok.getIdentifierInfo();
827
0
  LookupResult Lookup(*this, Name, IdTok.getLocation(), LookupOrdinaryName);
828
0
  LookupParsedName(Lookup, curScope, nullptr, true);
829
830
0
  if (Lookup.empty()) {
831
0
    Diag(PragmaLoc, diag::warn_pragma_unused_undeclared_var)
832
0
      << Name << SourceRange(IdTok.getLocation());
833
0
    return;
834
0
  }
835
836
0
  VarDecl *VD = Lookup.getAsSingle<VarDecl>();
837
0
  if (!VD) {
838
0
    Diag(PragmaLoc, diag::warn_pragma_unused_expected_var_arg)
839
0
      << Name << SourceRange(IdTok.getLocation());
840
0
    return;
841
0
  }
842
843
  // Warn if this was used before being marked unused.
844
0
  if (VD->isUsed())
845
0
    Diag(PragmaLoc, diag::warn_used_but_marked_unused) << Name;
846
847
0
  VD->addAttr(UnusedAttr::CreateImplicit(Context, IdTok.getLocation(),
848
0
                                         UnusedAttr::GNU_unused));
849
0
}
850
851
19
void Sema::AddCFAuditedAttribute(Decl *D) {
852
19
  IdentifierInfo *Ident;
853
19
  SourceLocation Loc;
854
19
  std::tie(Ident, Loc) = PP.getPragmaARCCFCodeAuditedInfo();
855
19
  if (!Loc.isValid()) return;
856
857
  // Don't add a redundant or conflicting attribute.
858
0
  if (D->hasAttr<CFAuditedTransferAttr>() ||
859
0
      D->hasAttr<CFUnknownTransferAttr>())
860
0
    return;
861
862
0
  AttributeCommonInfo Info(Ident, SourceRange(Loc),
863
0
                           AttributeCommonInfo::Form::Pragma());
864
0
  D->addAttr(CFAuditedTransferAttr::CreateImplicit(Context, Info));
865
0
}
866
867
namespace {
868
869
std::optional<attr::SubjectMatchRule>
870
0
getParentAttrMatcherRule(attr::SubjectMatchRule Rule) {
871
0
  using namespace attr;
872
0
  switch (Rule) {
873
0
  default:
874
0
    return std::nullopt;
875
0
#define ATTR_MATCH_RULE(Value, Spelling, IsAbstract)
876
0
#define ATTR_MATCH_SUB_RULE(Value, Spelling, IsAbstract, Parent, IsNegated)    \
877
0
  case Value:                                                                  \
878
0
    return Parent;
879
0
#include "clang/Basic/AttrSubMatchRulesList.inc"
880
0
  }
881
0
}
882
883
0
bool isNegatedAttrMatcherSubRule(attr::SubjectMatchRule Rule) {
884
0
  using namespace attr;
885
0
  switch (Rule) {
886
0
  default:
887
0
    return false;
888
0
#define ATTR_MATCH_RULE(Value, Spelling, IsAbstract)
889
0
#define ATTR_MATCH_SUB_RULE(Value, Spelling, IsAbstract, Parent, IsNegated)    \
890
0
  case Value:                                                                  \
891
0
    return IsNegated;
892
0
#include "clang/Basic/AttrSubMatchRulesList.inc"
893
0
  }
894
0
}
895
896
CharSourceRange replacementRangeForListElement(const Sema &S,
897
0
                                               SourceRange Range) {
898
  // Make sure that the ',' is removed as well.
899
0
  SourceLocation AfterCommaLoc = Lexer::findLocationAfterToken(
900
0
      Range.getEnd(), tok::comma, S.getSourceManager(), S.getLangOpts(),
901
0
      /*SkipTrailingWhitespaceAndNewLine=*/false);
902
0
  if (AfterCommaLoc.isValid())
903
0
    return CharSourceRange::getCharRange(Range.getBegin(), AfterCommaLoc);
904
0
  else
905
0
    return CharSourceRange::getTokenRange(Range);
906
0
}
907
908
std::string
909
0
attrMatcherRuleListToString(ArrayRef<attr::SubjectMatchRule> Rules) {
910
0
  std::string Result;
911
0
  llvm::raw_string_ostream OS(Result);
912
0
  for (const auto &I : llvm::enumerate(Rules)) {
913
0
    if (I.index())
914
0
      OS << (I.index() == Rules.size() - 1 ? ", and " : ", ");
915
0
    OS << "'" << attr::getSubjectMatchRuleSpelling(I.value()) << "'";
916
0
  }
917
0
  return Result;
918
0
}
919
920
} // end anonymous namespace
921
922
void Sema::ActOnPragmaAttributeAttribute(
923
    ParsedAttr &Attribute, SourceLocation PragmaLoc,
924
0
    attr::ParsedSubjectMatchRuleSet Rules) {
925
0
  Attribute.setIsPragmaClangAttribute();
926
0
  SmallVector<attr::SubjectMatchRule, 4> SubjectMatchRules;
927
  // Gather the subject match rules that are supported by the attribute.
928
0
  SmallVector<std::pair<attr::SubjectMatchRule, bool>, 4>
929
0
      StrictSubjectMatchRuleSet;
930
0
  Attribute.getMatchRules(LangOpts, StrictSubjectMatchRuleSet);
931
932
  // Figure out which subject matching rules are valid.
933
0
  if (StrictSubjectMatchRuleSet.empty()) {
934
    // Check for contradicting match rules. Contradicting match rules are
935
    // either:
936
    //  - a top-level rule and one of its sub-rules. E.g. variable and
937
    //    variable(is_parameter).
938
    //  - a sub-rule and a sibling that's negated. E.g.
939
    //    variable(is_thread_local) and variable(unless(is_parameter))
940
0
    llvm::SmallDenseMap<int, std::pair<int, SourceRange>, 2>
941
0
        RulesToFirstSpecifiedNegatedSubRule;
942
0
    for (const auto &Rule : Rules) {
943
0
      attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);
944
0
      std::optional<attr::SubjectMatchRule> ParentRule =
945
0
          getParentAttrMatcherRule(MatchRule);
946
0
      if (!ParentRule)
947
0
        continue;
948
0
      auto It = Rules.find(*ParentRule);
949
0
      if (It != Rules.end()) {
950
        // A sub-rule contradicts a parent rule.
951
0
        Diag(Rule.second.getBegin(),
952
0
             diag::err_pragma_attribute_matcher_subrule_contradicts_rule)
953
0
            << attr::getSubjectMatchRuleSpelling(MatchRule)
954
0
            << attr::getSubjectMatchRuleSpelling(*ParentRule) << It->second
955
0
            << FixItHint::CreateRemoval(
956
0
                   replacementRangeForListElement(*this, Rule.second));
957
        // Keep going without removing this rule as it won't change the set of
958
        // declarations that receive the attribute.
959
0
        continue;
960
0
      }
961
0
      if (isNegatedAttrMatcherSubRule(MatchRule))
962
0
        RulesToFirstSpecifiedNegatedSubRule.insert(
963
0
            std::make_pair(*ParentRule, Rule));
964
0
    }
965
0
    bool IgnoreNegatedSubRules = false;
966
0
    for (const auto &Rule : Rules) {
967
0
      attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);
968
0
      std::optional<attr::SubjectMatchRule> ParentRule =
969
0
          getParentAttrMatcherRule(MatchRule);
970
0
      if (!ParentRule)
971
0
        continue;
972
0
      auto It = RulesToFirstSpecifiedNegatedSubRule.find(*ParentRule);
973
0
      if (It != RulesToFirstSpecifiedNegatedSubRule.end() &&
974
0
          It->second != Rule) {
975
        // Negated sub-rule contradicts another sub-rule.
976
0
        Diag(
977
0
            It->second.second.getBegin(),
978
0
            diag::
979
0
                err_pragma_attribute_matcher_negated_subrule_contradicts_subrule)
980
0
            << attr::getSubjectMatchRuleSpelling(
981
0
                   attr::SubjectMatchRule(It->second.first))
982
0
            << attr::getSubjectMatchRuleSpelling(MatchRule) << Rule.second
983
0
            << FixItHint::CreateRemoval(
984
0
                   replacementRangeForListElement(*this, It->second.second));
985
        // Keep going but ignore all of the negated sub-rules.
986
0
        IgnoreNegatedSubRules = true;
987
0
        RulesToFirstSpecifiedNegatedSubRule.erase(It);
988
0
      }
989
0
    }
990
991
0
    if (!IgnoreNegatedSubRules) {
992
0
      for (const auto &Rule : Rules)
993
0
        SubjectMatchRules.push_back(attr::SubjectMatchRule(Rule.first));
994
0
    } else {
995
0
      for (const auto &Rule : Rules) {
996
0
        if (!isNegatedAttrMatcherSubRule(attr::SubjectMatchRule(Rule.first)))
997
0
          SubjectMatchRules.push_back(attr::SubjectMatchRule(Rule.first));
998
0
      }
999
0
    }
1000
0
    Rules.clear();
1001
0
  } else {
1002
    // Each rule in Rules must be a strict subset of the attribute's
1003
    // SubjectMatch rules.  I.e. we're allowed to use
1004
    // `apply_to=variables(is_global)` on an attrubute with SubjectList<[Var]>,
1005
    // but should not allow `apply_to=variables` on an attribute which has
1006
    // `SubjectList<[GlobalVar]>`.
1007
0
    for (const auto &StrictRule : StrictSubjectMatchRuleSet) {
1008
      // First, check for exact match.
1009
0
      if (Rules.erase(StrictRule.first)) {
1010
        // Add the rule to the set of attribute receivers only if it's supported
1011
        // in the current language mode.
1012
0
        if (StrictRule.second)
1013
0
          SubjectMatchRules.push_back(StrictRule.first);
1014
0
      }
1015
0
    }
1016
    // Check remaining rules for subset matches.
1017
0
    auto RulesToCheck = Rules;
1018
0
    for (const auto &Rule : RulesToCheck) {
1019
0
      attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);
1020
0
      if (auto ParentRule = getParentAttrMatcherRule(MatchRule)) {
1021
0
        if (llvm::any_of(StrictSubjectMatchRuleSet,
1022
0
                         [ParentRule](const auto &StrictRule) {
1023
0
                           return StrictRule.first == *ParentRule &&
1024
0
                                  StrictRule.second; // IsEnabled
1025
0
                         })) {
1026
0
          SubjectMatchRules.push_back(MatchRule);
1027
0
          Rules.erase(MatchRule);
1028
0
        }
1029
0
      }
1030
0
    }
1031
0
  }
1032
1033
0
  if (!Rules.empty()) {
1034
0
    auto Diagnostic =
1035
0
        Diag(PragmaLoc, diag::err_pragma_attribute_invalid_matchers)
1036
0
        << Attribute;
1037
0
    SmallVector<attr::SubjectMatchRule, 2> ExtraRules;
1038
0
    for (const auto &Rule : Rules) {
1039
0
      ExtraRules.push_back(attr::SubjectMatchRule(Rule.first));
1040
0
      Diagnostic << FixItHint::CreateRemoval(
1041
0
          replacementRangeForListElement(*this, Rule.second));
1042
0
    }
1043
0
    Diagnostic << attrMatcherRuleListToString(ExtraRules);
1044
0
  }
1045
1046
0
  if (PragmaAttributeStack.empty()) {
1047
0
    Diag(PragmaLoc, diag::err_pragma_attr_attr_no_push);
1048
0
    return;
1049
0
  }
1050
1051
0
  PragmaAttributeStack.back().Entries.push_back(
1052
0
      {PragmaLoc, &Attribute, std::move(SubjectMatchRules), /*IsUsed=*/false});
1053
0
}
1054
1055
void Sema::ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc,
1056
0
                                         const IdentifierInfo *Namespace) {
1057
0
  PragmaAttributeStack.emplace_back();
1058
0
  PragmaAttributeStack.back().Loc = PragmaLoc;
1059
0
  PragmaAttributeStack.back().Namespace = Namespace;
1060
0
}
1061
1062
void Sema::ActOnPragmaAttributePop(SourceLocation PragmaLoc,
1063
0
                                   const IdentifierInfo *Namespace) {
1064
0
  if (PragmaAttributeStack.empty()) {
1065
0
    Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch) << 1;
1066
0
    return;
1067
0
  }
1068
1069
  // Dig back through the stack trying to find the most recently pushed group
1070
  // that in Namespace. Note that this works fine if no namespace is present,
1071
  // think of push/pops without namespaces as having an implicit "nullptr"
1072
  // namespace.
1073
0
  for (size_t Index = PragmaAttributeStack.size(); Index;) {
1074
0
    --Index;
1075
0
    if (PragmaAttributeStack[Index].Namespace == Namespace) {
1076
0
      for (const PragmaAttributeEntry &Entry :
1077
0
           PragmaAttributeStack[Index].Entries) {
1078
0
        if (!Entry.IsUsed) {
1079
0
          assert(Entry.Attribute && "Expected an attribute");
1080
0
          Diag(Entry.Attribute->getLoc(), diag::warn_pragma_attribute_unused)
1081
0
              << *Entry.Attribute;
1082
0
          Diag(PragmaLoc, diag::note_pragma_attribute_region_ends_here);
1083
0
        }
1084
0
      }
1085
0
      PragmaAttributeStack.erase(PragmaAttributeStack.begin() + Index);
1086
0
      return;
1087
0
    }
1088
0
  }
1089
1090
0
  if (Namespace)
1091
0
    Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch)
1092
0
        << 0 << Namespace->getName();
1093
0
  else
1094
0
    Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch) << 1;
1095
0
}
1096
1097
5.13k
void Sema::AddPragmaAttributes(Scope *S, Decl *D) {
1098
5.13k
  if (PragmaAttributeStack.empty())
1099
5.13k
    return;
1100
0
  for (auto &Group : PragmaAttributeStack) {
1101
0
    for (auto &Entry : Group.Entries) {
1102
0
      ParsedAttr *Attribute = Entry.Attribute;
1103
0
      assert(Attribute && "Expected an attribute");
1104
0
      assert(Attribute->isPragmaClangAttribute() &&
1105
0
             "expected #pragma clang attribute");
1106
1107
      // Ensure that the attribute can be applied to the given declaration.
1108
0
      bool Applies = false;
1109
0
      for (const auto &Rule : Entry.MatchRules) {
1110
0
        if (Attribute->appliesToDecl(D, Rule)) {
1111
0
          Applies = true;
1112
0
          break;
1113
0
        }
1114
0
      }
1115
0
      if (!Applies)
1116
0
        continue;
1117
0
      Entry.IsUsed = true;
1118
0
      PragmaAttributeCurrentTargetDecl = D;
1119
0
      ParsedAttributesView Attrs;
1120
0
      Attrs.addAtEnd(Attribute);
1121
0
      ProcessDeclAttributeList(S, D, Attrs);
1122
0
      PragmaAttributeCurrentTargetDecl = nullptr;
1123
0
    }
1124
0
  }
1125
0
}
1126
1127
0
void Sema::PrintPragmaAttributeInstantiationPoint() {
1128
0
  assert(PragmaAttributeCurrentTargetDecl && "Expected an active declaration");
1129
0
  Diags.Report(PragmaAttributeCurrentTargetDecl->getBeginLoc(),
1130
0
               diag::note_pragma_attribute_applied_decl_here);
1131
0
}
1132
1133
46
void Sema::DiagnoseUnterminatedPragmaAttribute() {
1134
46
  if (PragmaAttributeStack.empty())
1135
46
    return;
1136
0
  Diag(PragmaAttributeStack.back().Loc, diag::err_pragma_attribute_no_pop_eof);
1137
0
}
1138
1139
0
void Sema::ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc) {
1140
0
  if(On)
1141
0
    OptimizeOffPragmaLocation = SourceLocation();
1142
0
  else
1143
0
    OptimizeOffPragmaLocation = PragmaLoc;
1144
0
}
1145
1146
0
void Sema::ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn) {
1147
0
  if (!CurContext->getRedeclContext()->isFileContext()) {
1148
0
    Diag(Loc, diag::err_pragma_expected_file_scope) << "optimize";
1149
0
    return;
1150
0
  }
1151
1152
0
  MSPragmaOptimizeIsOn = IsOn;
1153
0
}
1154
1155
void Sema::ActOnPragmaMSFunction(
1156
0
    SourceLocation Loc, const llvm::SmallVectorImpl<StringRef> &NoBuiltins) {
1157
0
  if (!CurContext->getRedeclContext()->isFileContext()) {
1158
0
    Diag(Loc, diag::err_pragma_expected_file_scope) << "function";
1159
0
    return;
1160
0
  }
1161
1162
0
  MSFunctionNoBuiltins.insert(NoBuiltins.begin(), NoBuiltins.end());
1163
0
}
1164
1165
0
void Sema::AddRangeBasedOptnone(FunctionDecl *FD) {
1166
  // In the future, check other pragmas if they're implemented (e.g. pragma
1167
  // optimize 0 will probably map to this functionality too).
1168
0
  if(OptimizeOffPragmaLocation.isValid())
1169
0
    AddOptnoneAttributeIfNoConflicts(FD, OptimizeOffPragmaLocation);
1170
0
}
1171
1172
0
void Sema::AddSectionMSAllocText(FunctionDecl *FD) {
1173
0
  if (!FD->getIdentifier())
1174
0
    return;
1175
1176
0
  StringRef Name = FD->getName();
1177
0
  auto It = FunctionToSectionMap.find(Name);
1178
0
  if (It != FunctionToSectionMap.end()) {
1179
0
    StringRef Section;
1180
0
    SourceLocation Loc;
1181
0
    std::tie(Section, Loc) = It->second;
1182
1183
0
    if (!FD->hasAttr<SectionAttr>())
1184
0
      FD->addAttr(SectionAttr::CreateImplicit(Context, Section));
1185
0
  }
1186
0
}
1187
1188
0
void Sema::ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD) {
1189
  // Don't modify the function attributes if it's "on". "on" resets the
1190
  // optimizations to the ones listed on the command line
1191
0
  if (!MSPragmaOptimizeIsOn)
1192
0
    AddOptnoneAttributeIfNoConflicts(FD, FD->getBeginLoc());
1193
0
}
1194
1195
void Sema::AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD,
1196
0
                                            SourceLocation Loc) {
1197
  // Don't add a conflicting attribute. No diagnostic is needed.
1198
0
  if (FD->hasAttr<MinSizeAttr>() || FD->hasAttr<AlwaysInlineAttr>())
1199
0
    return;
1200
1201
  // Add attributes only if required. Optnone requires noinline as well, but if
1202
  // either is already present then don't bother adding them.
1203
0
  if (!FD->hasAttr<OptimizeNoneAttr>())
1204
0
    FD->addAttr(OptimizeNoneAttr::CreateImplicit(Context, Loc));
1205
0
  if (!FD->hasAttr<NoInlineAttr>())
1206
0
    FD->addAttr(NoInlineAttr::CreateImplicit(Context, Loc));
1207
0
}
1208
1209
0
void Sema::AddImplicitMSFunctionNoBuiltinAttr(FunctionDecl *FD) {
1210
0
  SmallVector<StringRef> V(MSFunctionNoBuiltins.begin(),
1211
0
                           MSFunctionNoBuiltins.end());
1212
0
  if (!MSFunctionNoBuiltins.empty())
1213
0
    FD->addAttr(NoBuiltinAttr::CreateImplicit(Context, V.data(), V.size()));
1214
0
}
1215
1216
typedef std::vector<std::pair<unsigned, SourceLocation> > VisStack;
1217
enum : unsigned { NoVisibility = ~0U };
1218
1219
5.08k
void Sema::AddPushedVisibilityAttribute(Decl *D) {
1220
5.08k
  if (!VisContext)
1221
5.08k
    return;
1222
1223
0
  NamedDecl *ND = dyn_cast<NamedDecl>(D);
1224
0
  if (ND && ND->getExplicitVisibility(NamedDecl::VisibilityForValue))
1225
0
    return;
1226
1227
0
  VisStack *Stack = static_cast<VisStack*>(VisContext);
1228
0
  unsigned rawType = Stack->back().first;
1229
0
  if (rawType == NoVisibility) return;
1230
1231
0
  VisibilityAttr::VisibilityType type
1232
0
    = (VisibilityAttr::VisibilityType) rawType;
1233
0
  SourceLocation loc = Stack->back().second;
1234
1235
0
  D->addAttr(VisibilityAttr::CreateImplicit(Context, type, loc));
1236
0
}
1237
1238
/// FreeVisContext - Deallocate and null out VisContext.
1239
0
void Sema::FreeVisContext() {
1240
0
  delete static_cast<VisStack*>(VisContext);
1241
0
  VisContext = nullptr;
1242
0
}
1243
1244
0
static void PushPragmaVisibility(Sema &S, unsigned type, SourceLocation loc) {
1245
  // Put visibility on stack.
1246
0
  if (!S.VisContext)
1247
0
    S.VisContext = new VisStack;
1248
1249
0
  VisStack *Stack = static_cast<VisStack*>(S.VisContext);
1250
0
  Stack->push_back(std::make_pair(type, loc));
1251
0
}
1252
1253
void Sema::ActOnPragmaVisibility(const IdentifierInfo* VisType,
1254
0
                                 SourceLocation PragmaLoc) {
1255
0
  if (VisType) {
1256
    // Compute visibility to use.
1257
0
    VisibilityAttr::VisibilityType T;
1258
0
    if (!VisibilityAttr::ConvertStrToVisibilityType(VisType->getName(), T)) {
1259
0
      Diag(PragmaLoc, diag::warn_attribute_unknown_visibility) << VisType;
1260
0
      return;
1261
0
    }
1262
0
    PushPragmaVisibility(*this, T, PragmaLoc);
1263
0
  } else {
1264
0
    PopPragmaVisibility(false, PragmaLoc);
1265
0
  }
1266
0
}
1267
1268
void Sema::ActOnPragmaFPContract(SourceLocation Loc,
1269
0
                                 LangOptions::FPModeKind FPC) {
1270
0
  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1271
0
  switch (FPC) {
1272
0
  case LangOptions::FPM_On:
1273
0
    NewFPFeatures.setAllowFPContractWithinStatement();
1274
0
    break;
1275
0
  case LangOptions::FPM_Fast:
1276
0
    NewFPFeatures.setAllowFPContractAcrossStatement();
1277
0
    break;
1278
0
  case LangOptions::FPM_Off:
1279
0
    NewFPFeatures.setDisallowFPContract();
1280
0
    break;
1281
0
  case LangOptions::FPM_FastHonorPragmas:
1282
0
    llvm_unreachable("Should not happen");
1283
0
  }
1284
0
  FpPragmaStack.Act(Loc, Sema::PSK_Set, StringRef(), NewFPFeatures);
1285
0
  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
1286
0
}
1287
1288
void Sema::ActOnPragmaFPValueChangingOption(SourceLocation Loc,
1289
0
                                            PragmaFPKind Kind, bool IsEnabled) {
1290
0
  if (IsEnabled) {
1291
    // For value unsafe context, combining this pragma with eval method
1292
    // setting is not recommended. See comment in function FixupInvocation#506.
1293
0
    int Reason = -1;
1294
0
    if (getLangOpts().getFPEvalMethod() != LangOptions::FEM_UnsetOnCommandLine)
1295
      // Eval method set using the option 'ffp-eval-method'.
1296
0
      Reason = 1;
1297
0
    if (PP.getLastFPEvalPragmaLocation().isValid())
1298
      // Eval method set using the '#pragma clang fp eval_method'.
1299
      // We could have both an option and a pragma used to the set the eval
1300
      // method. The pragma overrides the option in the command line. The Reason
1301
      // of the diagnostic is overriden too.
1302
0
      Reason = 0;
1303
0
    if (Reason != -1)
1304
0
      Diag(Loc, diag::err_setting_eval_method_used_in_unsafe_context)
1305
0
          << Reason << (Kind == PFK_Reassociate ? 4 : 5);
1306
0
  }
1307
1308
0
  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1309
0
  switch (Kind) {
1310
0
  case PFK_Reassociate:
1311
0
    NewFPFeatures.setAllowFPReassociateOverride(IsEnabled);
1312
0
    break;
1313
0
  case PFK_Reciprocal:
1314
0
    NewFPFeatures.setAllowReciprocalOverride(IsEnabled);
1315
0
    break;
1316
0
  default:
1317
0
    llvm_unreachable("unhandled value changing pragma fp");
1318
0
  }
1319
1320
0
  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
1321
0
  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
1322
0
}
1323
1324
0
void Sema::ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode FPR) {
1325
0
  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1326
0
  NewFPFeatures.setConstRoundingModeOverride(FPR);
1327
0
  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
1328
0
  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
1329
0
}
1330
1331
void Sema::setExceptionMode(SourceLocation Loc,
1332
0
                            LangOptions::FPExceptionModeKind FPE) {
1333
0
  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1334
0
  NewFPFeatures.setSpecifiedExceptionModeOverride(FPE);
1335
0
  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
1336
0
  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
1337
0
}
1338
1339
0
void Sema::ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled) {
1340
0
  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1341
0
  if (IsEnabled) {
1342
    // Verify Microsoft restriction:
1343
    // You can't enable fenv_access unless precise semantics are enabled.
1344
    // Precise semantics can be enabled either by the float_control
1345
    // pragma, or by using the /fp:precise or /fp:strict compiler options
1346
0
    if (!isPreciseFPEnabled())
1347
0
      Diag(Loc, diag::err_pragma_fenv_requires_precise);
1348
0
  }
1349
0
  NewFPFeatures.setAllowFEnvAccessOverride(IsEnabled);
1350
0
  NewFPFeatures.setRoundingMathOverride(IsEnabled);
1351
0
  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
1352
0
  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
1353
0
}
1354
1355
void Sema::ActOnPragmaCXLimitedRange(SourceLocation Loc,
1356
0
                                     LangOptions::ComplexRangeKind Range) {
1357
0
  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1358
0
  NewFPFeatures.setComplexRangeOverride(Range);
1359
0
  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
1360
0
  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
1361
0
}
1362
1363
void Sema::ActOnPragmaFPExceptions(SourceLocation Loc,
1364
0
                                   LangOptions::FPExceptionModeKind FPE) {
1365
0
  setExceptionMode(Loc, FPE);
1366
0
}
1367
1368
void Sema::PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
1369
0
                                       SourceLocation Loc) {
1370
  // Visibility calculations will consider the namespace's visibility.
1371
  // Here we just want to note that we're in a visibility context
1372
  // which overrides any enclosing #pragma context, but doesn't itself
1373
  // contribute visibility.
1374
0
  PushPragmaVisibility(*this, NoVisibility, Loc);
1375
0
}
1376
1377
0
void Sema::PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc) {
1378
0
  if (!VisContext) {
1379
0
    Diag(EndLoc, diag::err_pragma_pop_visibility_mismatch);
1380
0
    return;
1381
0
  }
1382
1383
  // Pop visibility from stack
1384
0
  VisStack *Stack = static_cast<VisStack*>(VisContext);
1385
1386
0
  const std::pair<unsigned, SourceLocation> *Back = &Stack->back();
1387
0
  bool StartsWithPragma = Back->first != NoVisibility;
1388
0
  if (StartsWithPragma && IsNamespaceEnd) {
1389
0
    Diag(Back->second, diag::err_pragma_push_visibility_mismatch);
1390
0
    Diag(EndLoc, diag::note_surrounding_namespace_ends_here);
1391
1392
    // For better error recovery, eat all pushes inside the namespace.
1393
0
    do {
1394
0
      Stack->pop_back();
1395
0
      Back = &Stack->back();
1396
0
      StartsWithPragma = Back->first != NoVisibility;
1397
0
    } while (StartsWithPragma);
1398
0
  } else if (!StartsWithPragma && !IsNamespaceEnd) {
1399
0
    Diag(EndLoc, diag::err_pragma_pop_visibility_mismatch);
1400
0
    Diag(Back->second, diag::note_surrounding_namespace_starts_here);
1401
0
    return;
1402
0
  }
1403
1404
0
  Stack->pop_back();
1405
  // To simplify the implementation, never keep around an empty stack.
1406
0
  if (Stack->empty())
1407
0
    FreeVisContext();
1408
0
}
1409
1410
template <typename Ty>
1411
static bool checkCommonAttributeFeatures(Sema &S, const Ty *Node,
1412
                                         const ParsedAttr &A,
1413
0
                                         bool SkipArgCountCheck) {
1414
  // Several attributes carry different semantics than the parsing requires, so
1415
  // those are opted out of the common argument checks.
1416
  //
1417
  // We also bail on unknown and ignored attributes because those are handled
1418
  // as part of the target-specific handling logic.
1419
0
  if (A.getKind() == ParsedAttr::UnknownAttribute)
1420
0
    return false;
1421
  // Check whether the attribute requires specific language extensions to be
1422
  // enabled.
1423
0
  if (!A.diagnoseLangOpts(S))
1424
0
    return true;
1425
  // Check whether the attribute appertains to the given subject.
1426
0
  if (!A.diagnoseAppertainsTo(S, Node))
1427
0
    return true;
1428
  // Check whether the attribute is mutually exclusive with other attributes
1429
  // that have already been applied to the declaration.
1430
0
  if (!A.diagnoseMutualExclusion(S, Node))
1431
0
    return true;
1432
  // Check whether the attribute exists in the target architecture.
1433
0
  if (S.CheckAttrTarget(A))
1434
0
    return true;
1435
1436
0
  if (A.hasCustomParsing())
1437
0
    return false;
1438
1439
0
  if (!SkipArgCountCheck) {
1440
0
    if (A.getMinArgs() == A.getMaxArgs()) {
1441
      // If there are no optional arguments, then checking for the argument
1442
      // count is trivial.
1443
0
      if (!A.checkExactlyNumArgs(S, A.getMinArgs()))
1444
0
        return true;
1445
0
    } else {
1446
      // There are optional arguments, so checking is slightly more involved.
1447
0
      if (A.getMinArgs() && !A.checkAtLeastNumArgs(S, A.getMinArgs()))
1448
0
        return true;
1449
0
      else if (!A.hasVariadicArg() && A.getMaxArgs() &&
1450
0
               !A.checkAtMostNumArgs(S, A.getMaxArgs()))
1451
0
        return true;
1452
0
    }
1453
0
  }
1454
1455
0
  return false;
1456
0
}
Unexecuted instantiation: SemaAttr.cpp:bool checkCommonAttributeFeatures<clang::Decl>(clang::Sema&, clang::Decl const*, clang::ParsedAttr const&, bool)
Unexecuted instantiation: SemaAttr.cpp:bool checkCommonAttributeFeatures<clang::Stmt>(clang::Sema&, clang::Stmt const*, clang::ParsedAttr const&, bool)
1457
1458
bool Sema::checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
1459
0
                                        bool SkipArgCountCheck) {
1460
0
  return ::checkCommonAttributeFeatures(*this, D, A, SkipArgCountCheck);
1461
0
}
1462
bool Sema::checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
1463
0
                                        bool SkipArgCountCheck) {
1464
0
  return ::checkCommonAttributeFeatures(*this, S, A, SkipArgCountCheck);
1465
0
}