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