clang  13.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);
37  }
38 }
39 
41  if (ShouldAct) {
42  S.VtorDispStack.SentinelAction(PSK_Pop, SlotLabel);
43  S.DataSegStack.SentinelAction(PSK_Pop, SlotLabel);
44  S.BSSSegStack.SentinelAction(PSK_Pop, SlotLabel);
45  S.ConstSegStack.SentinelAction(PSK_Pop, SlotLabel);
46  S.CodeSegStack.SentinelAction(PSK_Pop, SlotLabel);
47  }
48 }
49 
51  AlignPackInfo InfoVal = AlignPackStack.CurrentValue;
52  AlignPackInfo::Mode M = InfoVal.getAlignMode();
53  bool IsPackSet = InfoVal.IsPackSet();
54  bool IsXLPragma = getLangOpts().XLPragmaPack;
55 
56  // If we are not under mac68k/natural alignment mode and also there is no pack
57  // value, we don't need any attributes.
58  if (!IsPackSet && M != AlignPackInfo::Mac68k && M != AlignPackInfo::Natural)
59  return;
60 
61  if (M == AlignPackInfo::Mac68k && (IsXLPragma || InfoVal.IsAlignAttr())) {
62  RD->addAttr(AlignMac68kAttr::CreateImplicit(Context));
63  } else if (IsPackSet) {
64  // Check to see if we need a max field alignment attribute.
65  RD->addAttr(MaxFieldAlignmentAttr::CreateImplicit(
66  Context, InfoVal.getPackNumber() * 8));
67  }
68 
69  if (IsXLPragma && M == AlignPackInfo::Natural)
70  RD->addAttr(AlignNaturalAttr::CreateImplicit(Context));
71 
72  if (AlignPackIncludeStack.empty())
73  return;
74  // The #pragma align/pack affected a record in an included file, so Clang
75  // should warn when that pragma was written in a file that included the
76  // included file.
77  for (auto &AlignPackedInclude : llvm::reverse(AlignPackIncludeStack)) {
78  if (AlignPackedInclude.CurrentPragmaLocation !=
79  AlignPackStack.CurrentPragmaLocation)
80  break;
81  if (AlignPackedInclude.HasNonDefaultValue)
82  AlignPackedInclude.ShouldWarnOnInclude = true;
83  }
84 }
85 
87  if (MSStructPragmaOn)
88  RD->addAttr(MSStructAttr::CreateImplicit(Context));
89 
90  // FIXME: We should merge AddAlignmentAttributesForRecord with
91  // AddMsStructLayoutForRecord into AddPragmaAttributesForRecord, which takes
92  // all active pragmas and applies them as attributes to class definitions.
93  if (VtorDispStack.CurrentValue != getLangOpts().getVtorDispMode())
94  RD->addAttr(MSVtorDispAttr::CreateImplicit(
95  Context, unsigned(VtorDispStack.CurrentValue)));
96 }
97 
98 template <typename Attribute>
100  CXXRecordDecl *Record) {
101  if (Record->hasAttr<OwnerAttr>() || Record->hasAttr<PointerAttr>())
102  return;
103 
104  for (Decl *Redecl : Record->redecls())
105  Redecl->addAttr(Attribute::CreateImplicit(Context, /*DerefType=*/nullptr));
106 }
107 
109  CXXRecordDecl *UnderlyingRecord) {
110  if (!UnderlyingRecord)
111  return;
112 
113  const auto *Parent = dyn_cast<CXXRecordDecl>(ND->getDeclContext());
114  if (!Parent)
115  return;
116 
117  static llvm::StringSet<> Containers{
118  "array",
119  "basic_string",
120  "deque",
121  "forward_list",
122  "vector",
123  "list",
124  "map",
125  "multiset",
126  "multimap",
127  "priority_queue",
128  "queue",
129  "set",
130  "stack",
131  "unordered_set",
132  "unordered_map",
133  "unordered_multiset",
134  "unordered_multimap",
135  };
136 
137  static llvm::StringSet<> Iterators{"iterator", "const_iterator",
138  "reverse_iterator",
139  "const_reverse_iterator"};
140 
141  if (Parent->isInStdNamespace() && Iterators.count(ND->getName()) &&
142  Containers.count(Parent->getName()))
143  addGslOwnerPointerAttributeIfNotExisting<PointerAttr>(Context,
144  UnderlyingRecord);
145 }
146 
148 
149  QualType Canonical = TD->getUnderlyingType().getCanonicalType();
150 
151  CXXRecordDecl *RD = Canonical->getAsCXXRecordDecl();
152  if (!RD) {
153  if (auto *TST =
154  dyn_cast<TemplateSpecializationType>(Canonical.getTypePtr())) {
155 
156  RD = dyn_cast_or_null<CXXRecordDecl>(
157  TST->getTemplateName().getAsTemplateDecl()->getTemplatedDecl());
158  }
159  }
160 
161  inferGslPointerAttribute(TD, RD);
162 }
163 
165  static llvm::StringSet<> StdOwners{
166  "any",
167  "array",
168  "basic_regex",
169  "basic_string",
170  "deque",
171  "forward_list",
172  "vector",
173  "list",
174  "map",
175  "multiset",
176  "multimap",
177  "optional",
178  "priority_queue",
179  "queue",
180  "set",
181  "stack",
182  "unique_ptr",
183  "unordered_set",
184  "unordered_map",
185  "unordered_multiset",
186  "unordered_multimap",
187  "variant",
188  };
189  static llvm::StringSet<> StdPointers{
190  "basic_string_view",
191  "reference_wrapper",
192  "regex_iterator",
193  };
194 
195  if (!Record->getIdentifier())
196  return;
197 
198  // Handle classes that directly appear in std namespace.
199  if (Record->isInStdNamespace()) {
200  if (Record->hasAttr<OwnerAttr>() || Record->hasAttr<PointerAttr>())
201  return;
202 
203  if (StdOwners.count(Record->getName()))
204  addGslOwnerPointerAttributeIfNotExisting<OwnerAttr>(Context, Record);
205  else if (StdPointers.count(Record->getName()))
206  addGslOwnerPointerAttributeIfNotExisting<PointerAttr>(Context, Record);
207 
208  return;
209  }
210 
211  // Handle nested classes that could be a gsl::Pointer.
212  inferGslPointerAttribute(Record, Record);
213 }
214 
216  SourceLocation PragmaLoc) {
219 
220  switch (Kind) {
221  // For most of the platforms we support, native and natural are the same.
222  // With XL, native is the same as power, natural means something else.
223  //
224  // FIXME: This is not true on Darwin/PPC.
225  case POAK_Native:
226  case POAK_Power:
227  Action = Sema::PSK_Push_Set;
228  break;
229  case POAK_Natural:
230  Action = Sema::PSK_Push_Set;
231  ModeVal = AlignPackInfo::Natural;
232  break;
233 
234  // Note that '#pragma options align=packed' is not equivalent to attribute
235  // packed, it has a different precedence relative to attribute aligned.
236  case POAK_Packed:
237  Action = Sema::PSK_Push_Set;
238  ModeVal = AlignPackInfo::Packed;
239  break;
240 
241  case POAK_Mac68k:
242  // Check if the target supports this.
244  Diag(PragmaLoc, diag::err_pragma_options_align_mac68k_target_unsupported);
245  return;
246  }
247  Action = Sema::PSK_Push_Set;
248  ModeVal = AlignPackInfo::Mac68k;
249  break;
250  case POAK_Reset:
251  // Reset just pops the top of the stack, or resets the current alignment to
252  // default.
253  Action = Sema::PSK_Pop;
254  if (AlignPackStack.Stack.empty()) {
255  if (AlignPackStack.CurrentValue.getAlignMode() != AlignPackInfo::Native ||
256  AlignPackStack.CurrentValue.IsPackAttr()) {
257  Action = Sema::PSK_Reset;
258  } else {
259  Diag(PragmaLoc, diag::warn_pragma_options_align_reset_failed)
260  << "stack empty";
261  return;
262  }
263  }
264  break;
265  }
266 
267  AlignPackInfo Info(ModeVal, getLangOpts().XLPragmaPack);
268 
269  AlignPackStack.Act(PragmaLoc, Action, StringRef(), Info);
270 }
271 
273  PragmaClangSectionKind SecKind, StringRef SecName) {
274  PragmaClangSection *CSec;
275  int SectionFlags = ASTContext::PSF_Read;
276  switch (SecKind) {
277  case PragmaClangSectionKind::PCSK_BSS:
278  CSec = &PragmaClangBSSSection;
280  break;
281  case PragmaClangSectionKind::PCSK_Data:
282  CSec = &PragmaClangDataSection;
283  SectionFlags |= ASTContext::PSF_Write;
284  break;
285  case PragmaClangSectionKind::PCSK_Rodata:
286  CSec = &PragmaClangRodataSection;
287  break;
288  case PragmaClangSectionKind::PCSK_Relro:
289  CSec = &PragmaClangRelroSection;
290  break;
291  case PragmaClangSectionKind::PCSK_Text:
292  CSec = &PragmaClangTextSection;
293  SectionFlags |= ASTContext::PSF_Execute;
294  break;
295  default:
296  llvm_unreachable("invalid clang section kind");
297  }
298 
299  if (Action == PragmaClangSectionAction::PCSA_Clear) {
300  CSec->Valid = false;
301  return;
302  }
303 
304  if (llvm::Error E =
306  Diag(PragmaLoc, diag::err_pragma_section_invalid_for_target)
307  << toString(std::move(E));
308  CSec->Valid = false;
309  return;
310  }
311 
312  if (UnifySection(SecName, SectionFlags, PragmaLoc))
313  return;
314 
315  CSec->Valid = true;
316  CSec->SectionName = std::string(SecName);
317  CSec->PragmaLocation = PragmaLoc;
318 }
319 
321  StringRef SlotLabel, Expr *alignment) {
322  bool IsXLPragma = getLangOpts().XLPragmaPack;
323  // XL pragma pack does not support identifier syntax.
324  if (IsXLPragma && !SlotLabel.empty()) {
325  Diag(PragmaLoc, diag::err_pragma_pack_identifer_not_supported);
326  return;
327  }
328 
329  const AlignPackInfo CurVal = AlignPackStack.CurrentValue;
330  Expr *Alignment = static_cast<Expr *>(alignment);
331 
332  // If specified then alignment must be a "small" power of two.
333  unsigned AlignmentVal = 0;
334  AlignPackInfo::Mode ModeVal = CurVal.getAlignMode();
335 
336  if (Alignment) {
338  Val = Alignment->getIntegerConstantExpr(Context);
339 
340  // pack(0) is like pack(), which just works out since that is what
341  // we use 0 for in PackAttr.
342  if (Alignment->isTypeDependent() || Alignment->isValueDependent() || !Val ||
343  !(*Val == 0 || Val->isPowerOf2()) || Val->getZExtValue() > 16) {
344  Diag(PragmaLoc, diag::warn_pragma_pack_invalid_alignment);
345  return; // Ignore
346  }
347 
348  if (IsXLPragma && *Val == 0) {
349  // pack(0) does not work out with XL.
350  Diag(PragmaLoc, diag::err_pragma_pack_invalid_alignment);
351  return; // Ignore
352  }
353 
354  AlignmentVal = (unsigned)Val->getZExtValue();
355  }
356 
357  if (Action == Sema::PSK_Show) {
358  // Show the current alignment, making sure to show the right value
359  // for the default.
360  // FIXME: This should come from the target.
361  AlignmentVal = CurVal.IsPackSet() ? CurVal.getPackNumber() : 8;
362  if (ModeVal == AlignPackInfo::Mac68k &&
363  (IsXLPragma || CurVal.IsAlignAttr()))
364  Diag(PragmaLoc, diag::warn_pragma_pack_show) << "mac68k";
365  else
366  Diag(PragmaLoc, diag::warn_pragma_pack_show) << AlignmentVal;
367  }
368 
369  // MSDN, C/C++ Preprocessor Reference > Pragma Directives > pack:
370  // "#pragma pack(pop, identifier, n) is undefined"
371  if (Action & Sema::PSK_Pop) {
372  if (Alignment && !SlotLabel.empty())
373  Diag(PragmaLoc, diag::warn_pragma_pack_pop_identifier_and_alignment);
374  if (AlignPackStack.Stack.empty()) {
375  assert(CurVal.getAlignMode() == AlignPackInfo::Native &&
376  "Empty pack stack can only be at Native alignment mode.");
377  Diag(PragmaLoc, diag::warn_pragma_pop_failed) << "pack" << "stack empty";
378  }
379  }
380 
381  AlignPackInfo Info(ModeVal, AlignmentVal, IsXLPragma);
382 
383  AlignPackStack.Act(PragmaLoc, Action, SlotLabel, Info);
384 }
385 
387  SourceLocation IncludeLoc) {
389  SourceLocation PrevLocation = AlignPackStack.CurrentPragmaLocation;
390  // Warn about non-default alignment at #includes (without redundant
391  // warnings for the same directive in nested includes).
392  // The warning is delayed until the end of the file to avoid warnings
393  // for files that don't have any records that are affected by the modified
394  // alignment.
395  bool HasNonDefaultValue =
396  AlignPackStack.hasValue() &&
397  (AlignPackIncludeStack.empty() ||
398  AlignPackIncludeStack.back().CurrentPragmaLocation != PrevLocation);
399  AlignPackIncludeStack.push_back(
400  {AlignPackStack.CurrentValue,
401  AlignPackStack.hasValue() ? PrevLocation : SourceLocation(),
402  HasNonDefaultValue, /*ShouldWarnOnInclude*/ false});
403  return;
404  }
405 
407  "invalid kind");
408  AlignPackIncludeState PrevAlignPackState =
409  AlignPackIncludeStack.pop_back_val();
410  // FIXME: AlignPackStack may contain both #pragma align and #pragma pack
411  // information, diagnostics below might not be accurate if we have mixed
412  // pragmas.
413  if (PrevAlignPackState.ShouldWarnOnInclude) {
414  // Emit the delayed non-default alignment at #include warning.
415  Diag(IncludeLoc, diag::warn_pragma_pack_non_default_at_include);
416  Diag(PrevAlignPackState.CurrentPragmaLocation, diag::note_pragma_pack_here);
417  }
418  // Warn about modified alignment after #includes.
419  if (PrevAlignPackState.CurrentValue != AlignPackStack.CurrentValue) {
420  Diag(IncludeLoc, diag::warn_pragma_pack_modified_after_include);
421  Diag(AlignPackStack.CurrentPragmaLocation, diag::note_pragma_pack_here);
422  }
423 }
424 
426  if (AlignPackStack.Stack.empty())
427  return;
428  bool IsInnermost = true;
429 
430  // FIXME: AlignPackStack may contain both #pragma align and #pragma pack
431  // information, diagnostics below might not be accurate if we have mixed
432  // pragmas.
433  for (const auto &StackSlot : llvm::reverse(AlignPackStack.Stack)) {
434  Diag(StackSlot.PragmaPushLocation, diag::warn_pragma_pack_no_pop_eof);
435  // The user might have already reset the alignment, so suggest replacing
436  // the reset with a pop.
437  if (IsInnermost &&
438  AlignPackStack.CurrentValue == AlignPackStack.DefaultValue) {
439  auto DB = Diag(AlignPackStack.CurrentPragmaLocation,
440  diag::note_pragma_pack_pop_instead_reset);
441  SourceLocation FixItLoc =
442  Lexer::findLocationAfterToken(AlignPackStack.CurrentPragmaLocation,
443  tok::l_paren, SourceMgr, LangOpts,
444  /*SkipTrailing=*/false);
445  if (FixItLoc.isValid())
446  DB << FixItHint::CreateInsertion(FixItLoc, "pop");
447  }
448  IsInnermost = false;
449  }
450 }
451 
454 }
455 
457  PragmaMSCommentKind Kind, StringRef Arg) {
458  auto *PCD = PragmaCommentDecl::Create(
459  Context, Context.getTranslationUnitDecl(), CommentLoc, Kind, Arg);
462 }
463 
465  StringRef Value) {
470 }
471 
473  PragmaMsStackAction Action,
475  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
476  if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop) &&
478  // Push and pop can only occur at file or namespace scope.
479  Diag(Loc, diag::err_pragma_fc_pp_scope);
480  return;
481  }
482  switch (Value) {
483  default:
484  llvm_unreachable("invalid pragma float_control kind");
485  case PFC_Precise:
486  NewFPFeatures.setFPPreciseEnabled(true);
487  FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
488  break;
489  case PFC_NoPrecise:
490  if (CurFPFeatures.getFPExceptionMode() == LangOptions::FPE_Strict)
491  Diag(Loc, diag::err_pragma_fc_noprecise_requires_noexcept);
492  else if (CurFPFeatures.getAllowFEnvAccess())
493  Diag(Loc, diag::err_pragma_fc_noprecise_requires_nofenv);
494  else
495  NewFPFeatures.setFPPreciseEnabled(false);
496  FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
497  break;
498  case PFC_Except:
499  if (!isPreciseFPEnabled())
500  Diag(Loc, diag::err_pragma_fc_except_requires_precise);
501  else
502  NewFPFeatures.setFPExceptionModeOverride(LangOptions::FPE_Strict);
503  FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
504  break;
505  case PFC_NoExcept:
506  NewFPFeatures.setFPExceptionModeOverride(LangOptions::FPE_Ignore);
507  FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
508  break;
509  case PFC_Push:
510  FpPragmaStack.Act(Loc, Sema::PSK_Push_Set, StringRef(), NewFPFeatures);
511  break;
512  case PFC_Pop:
513  if (FpPragmaStack.Stack.empty()) {
514  Diag(Loc, diag::warn_pragma_pop_failed) << "float_control"
515  << "stack empty";
516  return;
517  }
518  FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
519  NewFPFeatures = FpPragmaStack.CurrentValue;
520  break;
521  }
522  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
523 }
524 
526  LangOptions::PragmaMSPointersToMembersKind RepresentationMethod,
527  SourceLocation PragmaLoc) {
528  MSPointerToMemberRepresentationMethod = RepresentationMethod;
529  ImplicitMSInheritanceAttrLoc = PragmaLoc;
530 }
531 
533  SourceLocation PragmaLoc,
534  MSVtorDispMode Mode) {
535  if (Action & PSK_Pop && VtorDispStack.Stack.empty())
536  Diag(PragmaLoc, diag::warn_pragma_pop_failed) << "vtordisp"
537  << "stack empty";
538  VtorDispStack.Act(PragmaLoc, Action, StringRef(), Mode);
539 }
540 
541 template <>
543  PragmaMsStackAction Action,
544  llvm::StringRef StackSlotLabel,
545  AlignPackInfo Value) {
546  if (Action == PSK_Reset) {
547  CurrentValue = DefaultValue;
548  CurrentPragmaLocation = PragmaLocation;
549  return;
550  }
551  if (Action & PSK_Push)
552  Stack.emplace_back(Slot(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
553  PragmaLocation));
554  else if (Action & PSK_Pop) {
555  if (!StackSlotLabel.empty()) {
556  // If we've got a label, try to find it and jump there.
557  auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
558  return x.StackSlotLabel == StackSlotLabel;
559  });
560  // We found the label, so pop from there.
561  if (I != Stack.rend()) {
562  CurrentValue = I->Value;
563  CurrentPragmaLocation = I->PragmaLocation;
564  Stack.erase(std::prev(I.base()), Stack.end());
565  }
566  } else if (Value.IsXLStack() && Value.IsAlignAttr() &&
567  CurrentValue.IsPackAttr()) {
568  // XL '#pragma align(reset)' would pop the stack until
569  // a current in effect pragma align is popped.
570  auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
571  return x.Value.IsAlignAttr();
572  });
573  // If we found pragma align so pop from there.
574  if (I != Stack.rend()) {
575  Stack.erase(std::prev(I.base()), Stack.end());
576  if (Stack.empty()) {
577  CurrentValue = DefaultValue;
578  CurrentPragmaLocation = PragmaLocation;
579  } else {
580  CurrentValue = Stack.back().Value;
581  CurrentPragmaLocation = Stack.back().PragmaLocation;
582  Stack.pop_back();
583  }
584  }
585  } else if (!Stack.empty()) {
586  // xl '#pragma align' sets the baseline, and `#pragma pack` cannot pop
587  // over the baseline.
588  if (Value.IsXLStack() && Value.IsPackAttr() && CurrentValue.IsAlignAttr())
589  return;
590 
591  // We don't have a label, just pop the last entry.
592  CurrentValue = Stack.back().Value;
593  CurrentPragmaLocation = Stack.back().PragmaLocation;
594  Stack.pop_back();
595  }
596  }
597  if (Action & PSK_Set) {
598  CurrentValue = Value;
599  CurrentPragmaLocation = PragmaLocation;
600  }
601 }
602 
603 bool Sema::UnifySection(StringRef SectionName, int SectionFlags,
604  NamedDecl *Decl) {
605  SourceLocation PragmaLocation;
606  if (auto A = Decl->getAttr<SectionAttr>())
607  if (A->isImplicit())
608  PragmaLocation = A->getLocation();
609  auto SectionIt = Context.SectionInfos.find(SectionName);
610  if (SectionIt == Context.SectionInfos.end()) {
611  Context.SectionInfos[SectionName] =
612  ASTContext::SectionInfo(Decl, PragmaLocation, SectionFlags);
613  return false;
614  }
615  // A pre-declared section takes precedence w/o diagnostic.
616  const auto &Section = SectionIt->second;
617  if (Section.SectionFlags == SectionFlags ||
618  ((SectionFlags & ASTContext::PSF_Implicit) &&
619  !(Section.SectionFlags & ASTContext::PSF_Implicit)))
620  return false;
621  Diag(Decl->getLocation(), diag::err_section_conflict) << Decl << Section;
622  if (Section.Decl)
623  Diag(Section.Decl->getLocation(), diag::note_declared_at)
624  << Section.Decl->getName();
625  if (PragmaLocation.isValid())
626  Diag(PragmaLocation, diag::note_pragma_entered_here);
627  if (Section.PragmaSectionLocation.isValid())
628  Diag(Section.PragmaSectionLocation, diag::note_pragma_entered_here);
629  return true;
630 }
631 
632 bool Sema::UnifySection(StringRef SectionName,
633  int SectionFlags,
634  SourceLocation PragmaSectionLocation) {
635  auto SectionIt = Context.SectionInfos.find(SectionName);
636  if (SectionIt != Context.SectionInfos.end()) {
637  const auto &Section = SectionIt->second;
638  if (Section.SectionFlags == SectionFlags)
639  return false;
640  if (!(Section.SectionFlags & ASTContext::PSF_Implicit)) {
641  Diag(PragmaSectionLocation, diag::err_section_conflict)
642  << "this" << Section;
643  if (Section.Decl)
644  Diag(Section.Decl->getLocation(), diag::note_declared_at)
645  << Section.Decl->getName();
646  if (Section.PragmaSectionLocation.isValid())
647  Diag(Section.PragmaSectionLocation, diag::note_pragma_entered_here);
648  return true;
649  }
650  }
651  Context.SectionInfos[SectionName] =
652  ASTContext::SectionInfo(nullptr, PragmaSectionLocation, SectionFlags);
653  return false;
654 }
655 
656 /// Called on well formed \#pragma bss_seg().
658  PragmaMsStackAction Action,
659  llvm::StringRef StackSlotLabel,
660  StringLiteral *SegmentName,
661  llvm::StringRef PragmaName) {
663  llvm::StringSwitch<PragmaStack<StringLiteral *> *>(PragmaName)
664  .Case("data_seg", &DataSegStack)
665  .Case("bss_seg", &BSSSegStack)
666  .Case("const_seg", &ConstSegStack)
667  .Case("code_seg", &CodeSegStack);
668  if (Action & PSK_Pop && Stack->Stack.empty())
669  Diag(PragmaLocation, diag::warn_pragma_pop_failed) << PragmaName
670  << "stack empty";
671  if (SegmentName) {
672  if (!checkSectionName(SegmentName->getBeginLoc(), SegmentName->getString()))
673  return;
674 
675  if (SegmentName->getString() == ".drectve" &&
677  Diag(PragmaLocation, diag::warn_attribute_section_drectve) << PragmaName;
678  }
679 
680  Stack->Act(PragmaLocation, Action, StackSlotLabel, SegmentName);
681 }
682 
683 /// Called on well formed \#pragma bss_seg().
685  int SectionFlags, StringLiteral *SegmentName) {
686  UnifySection(SegmentName->getString(), SectionFlags, PragmaLocation);
687 }
688 
690  StringLiteral *SegmentName) {
691  // There's no stack to maintain, so we just have a current section. When we
692  // see the default section, reset our current section back to null so we stop
693  // tacking on unnecessary attributes.
694  CurInitSeg = SegmentName->getString() == ".CRT$XCU" ? nullptr : SegmentName;
695  CurInitSegLoc = PragmaLocation;
696 }
697 
698 void Sema::ActOnPragmaUnused(const Token &IdTok, Scope *curScope,
699  SourceLocation PragmaLoc) {
700 
701  IdentifierInfo *Name = IdTok.getIdentifierInfo();
702  LookupResult Lookup(*this, Name, IdTok.getLocation(), LookupOrdinaryName);
703  LookupParsedName(Lookup, curScope, nullptr, true);
704 
705  if (Lookup.empty()) {
706  Diag(PragmaLoc, diag::warn_pragma_unused_undeclared_var)
707  << Name << SourceRange(IdTok.getLocation());
708  return;
709  }
710 
711  VarDecl *VD = Lookup.getAsSingle<VarDecl>();
712  if (!VD) {
713  Diag(PragmaLoc, diag::warn_pragma_unused_expected_var_arg)
714  << Name << SourceRange(IdTok.getLocation());
715  return;
716  }
717 
718  // Warn if this was used before being marked unused.
719  if (VD->isUsed())
720  Diag(PragmaLoc, diag::warn_used_but_marked_unused) << Name;
721 
722  VD->addAttr(UnusedAttr::CreateImplicit(Context, IdTok.getLocation(),
724  UnusedAttr::GNU_unused));
725 }
726 
728  IdentifierInfo *Ident;
729  SourceLocation Loc;
730  std::tie(Ident, Loc) = PP.getPragmaARCCFCodeAuditedInfo();
731  if (!Loc.isValid()) return;
732 
733  // Don't add a redundant or conflicting attribute.
734  if (D->hasAttr<CFAuditedTransferAttr>() ||
735  D->hasAttr<CFUnknownTransferAttr>())
736  return;
737 
738  AttributeCommonInfo Info(Ident, SourceRange(Loc),
740  D->addAttr(CFAuditedTransferAttr::CreateImplicit(Context, Info));
741 }
742 
743 namespace {
744 
746 getParentAttrMatcherRule(attr::SubjectMatchRule Rule) {
747  using namespace attr;
748  switch (Rule) {
749  default:
750  return None;
751 #define ATTR_MATCH_RULE(Value, Spelling, IsAbstract)
752 #define ATTR_MATCH_SUB_RULE(Value, Spelling, IsAbstract, Parent, IsNegated) \
753  case Value: \
754  return Parent;
755 #include "clang/Basic/AttrSubMatchRulesList.inc"
756  }
757 }
758 
759 bool isNegatedAttrMatcherSubRule(attr::SubjectMatchRule Rule) {
760  using namespace attr;
761  switch (Rule) {
762  default:
763  return false;
764 #define ATTR_MATCH_RULE(Value, Spelling, IsAbstract)
765 #define ATTR_MATCH_SUB_RULE(Value, Spelling, IsAbstract, Parent, IsNegated) \
766  case Value: \
767  return IsNegated;
768 #include "clang/Basic/AttrSubMatchRulesList.inc"
769  }
770 }
771 
772 CharSourceRange replacementRangeForListElement(const Sema &S,
773  SourceRange Range) {
774  // Make sure that the ',' is removed as well.
776  Range.getEnd(), tok::comma, S.getSourceManager(), S.getLangOpts(),
777  /*SkipTrailingWhitespaceAndNewLine=*/false);
778  if (AfterCommaLoc.isValid())
779  return CharSourceRange::getCharRange(Range.getBegin(), AfterCommaLoc);
780  else
781  return CharSourceRange::getTokenRange(Range);
782 }
783 
784 std::string
785 attrMatcherRuleListToString(ArrayRef<attr::SubjectMatchRule> Rules) {
786  std::string Result;
787  llvm::raw_string_ostream OS(Result);
788  for (const auto &I : llvm::enumerate(Rules)) {
789  if (I.index())
790  OS << (I.index() == Rules.size() - 1 ? ", and " : ", ");
791  OS << "'" << attr::getSubjectMatchRuleSpelling(I.value()) << "'";
792  }
793  return OS.str();
794 }
795 
796 } // end anonymous namespace
797 
799  ParsedAttr &Attribute, SourceLocation PragmaLoc,
801  Attribute.setIsPragmaClangAttribute();
802  SmallVector<attr::SubjectMatchRule, 4> SubjectMatchRules;
803  // Gather the subject match rules that are supported by the attribute.
805  StrictSubjectMatchRuleSet;
806  Attribute.getMatchRules(LangOpts, StrictSubjectMatchRuleSet);
807 
808  // Figure out which subject matching rules are valid.
809  if (StrictSubjectMatchRuleSet.empty()) {
810  // Check for contradicting match rules. Contradicting match rules are
811  // either:
812  // - a top-level rule and one of its sub-rules. E.g. variable and
813  // variable(is_parameter).
814  // - a sub-rule and a sibling that's negated. E.g.
815  // variable(is_thread_local) and variable(unless(is_parameter))
816  llvm::SmallDenseMap<int, std::pair<int, SourceRange>, 2>
817  RulesToFirstSpecifiedNegatedSubRule;
818  for (const auto &Rule : Rules) {
819  attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);
821  getParentAttrMatcherRule(MatchRule);
822  if (!ParentRule)
823  continue;
824  auto It = Rules.find(*ParentRule);
825  if (It != Rules.end()) {
826  // A sub-rule contradicts a parent rule.
827  Diag(Rule.second.getBegin(),
828  diag::err_pragma_attribute_matcher_subrule_contradicts_rule)
830  << attr::getSubjectMatchRuleSpelling(*ParentRule) << It->second
832  replacementRangeForListElement(*this, Rule.second));
833  // Keep going without removing this rule as it won't change the set of
834  // declarations that receive the attribute.
835  continue;
836  }
837  if (isNegatedAttrMatcherSubRule(MatchRule))
838  RulesToFirstSpecifiedNegatedSubRule.insert(
839  std::make_pair(*ParentRule, Rule));
840  }
841  bool IgnoreNegatedSubRules = false;
842  for (const auto &Rule : Rules) {
843  attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);
845  getParentAttrMatcherRule(MatchRule);
846  if (!ParentRule)
847  continue;
848  auto It = RulesToFirstSpecifiedNegatedSubRule.find(*ParentRule);
849  if (It != RulesToFirstSpecifiedNegatedSubRule.end() &&
850  It->second != Rule) {
851  // Negated sub-rule contradicts another sub-rule.
852  Diag(
853  It->second.second.getBegin(),
854  diag::
855  err_pragma_attribute_matcher_negated_subrule_contradicts_subrule)
857  attr::SubjectMatchRule(It->second.first))
858  << attr::getSubjectMatchRuleSpelling(MatchRule) << Rule.second
860  replacementRangeForListElement(*this, It->second.second));
861  // Keep going but ignore all of the negated sub-rules.
862  IgnoreNegatedSubRules = true;
863  RulesToFirstSpecifiedNegatedSubRule.erase(It);
864  }
865  }
866 
867  if (!IgnoreNegatedSubRules) {
868  for (const auto &Rule : Rules)
869  SubjectMatchRules.push_back(attr::SubjectMatchRule(Rule.first));
870  } else {
871  for (const auto &Rule : Rules) {
872  if (!isNegatedAttrMatcherSubRule(attr::SubjectMatchRule(Rule.first)))
873  SubjectMatchRules.push_back(attr::SubjectMatchRule(Rule.first));
874  }
875  }
876  Rules.clear();
877  } else {
878  for (const auto &Rule : StrictSubjectMatchRuleSet) {
879  if (Rules.erase(Rule.first)) {
880  // Add the rule to the set of attribute receivers only if it's supported
881  // in the current language mode.
882  if (Rule.second)
883  SubjectMatchRules.push_back(Rule.first);
884  }
885  }
886  }
887 
888  if (!Rules.empty()) {
889  auto Diagnostic =
890  Diag(PragmaLoc, diag::err_pragma_attribute_invalid_matchers)
891  << Attribute;
893  for (const auto &Rule : Rules) {
894  ExtraRules.push_back(attr::SubjectMatchRule(Rule.first));
896  replacementRangeForListElement(*this, Rule.second));
897  }
898  Diagnostic << attrMatcherRuleListToString(ExtraRules);
899  }
900 
901  if (PragmaAttributeStack.empty()) {
902  Diag(PragmaLoc, diag::err_pragma_attr_attr_no_push);
903  return;
904  }
905 
906  PragmaAttributeStack.back().Entries.push_back(
907  {PragmaLoc, &Attribute, std::move(SubjectMatchRules), /*IsUsed=*/false});
908 }
909 
911  const IdentifierInfo *Namespace) {
912  PragmaAttributeStack.emplace_back();
913  PragmaAttributeStack.back().Loc = PragmaLoc;
914  PragmaAttributeStack.back().Namespace = Namespace;
915 }
916 
918  const IdentifierInfo *Namespace) {
919  if (PragmaAttributeStack.empty()) {
920  Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch) << 1;
921  return;
922  }
923 
924  // Dig back through the stack trying to find the most recently pushed group
925  // that in Namespace. Note that this works fine if no namespace is present,
926  // think of push/pops without namespaces as having an implicit "nullptr"
927  // namespace.
928  for (size_t Index = PragmaAttributeStack.size(); Index;) {
929  --Index;
930  if (PragmaAttributeStack[Index].Namespace == Namespace) {
931  for (const PragmaAttributeEntry &Entry :
932  PragmaAttributeStack[Index].Entries) {
933  if (!Entry.IsUsed) {
934  assert(Entry.Attribute && "Expected an attribute");
935  Diag(Entry.Attribute->getLoc(), diag::warn_pragma_attribute_unused)
936  << *Entry.Attribute;
937  Diag(PragmaLoc, diag::note_pragma_attribute_region_ends_here);
938  }
939  }
940  PragmaAttributeStack.erase(PragmaAttributeStack.begin() + Index);
941  return;
942  }
943  }
944 
945  if (Namespace)
946  Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch)
947  << 0 << Namespace->getName();
948  else
949  Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch) << 1;
950 }
951 
953  if (PragmaAttributeStack.empty())
954  return;
955  for (auto &Group : PragmaAttributeStack) {
956  for (auto &Entry : Group.Entries) {
957  ParsedAttr *Attribute = Entry.Attribute;
958  assert(Attribute && "Expected an attribute");
959  assert(Attribute->isPragmaClangAttribute() &&
960  "expected #pragma clang attribute");
961 
962  // Ensure that the attribute can be applied to the given declaration.
963  bool Applies = false;
964  for (const auto &Rule : Entry.MatchRules) {
965  if (Attribute->appliesToDecl(D, Rule)) {
966  Applies = true;
967  break;
968  }
969  }
970  if (!Applies)
971  continue;
972  Entry.IsUsed = true;
974  ParsedAttributesView Attrs;
975  Attrs.addAtEnd(Attribute);
976  ProcessDeclAttributeList(S, D, Attrs);
978  }
979  }
980 }
981 
983  assert(PragmaAttributeCurrentTargetDecl && "Expected an active declaration");
985  diag::note_pragma_attribute_applied_decl_here);
986 }
987 
989  if (PragmaAttributeStack.empty())
990  return;
991  Diag(PragmaAttributeStack.back().Loc, diag::err_pragma_attribute_no_pop_eof);
992 }
993 
994 void Sema::ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc) {
995  if(On)
997  else
998  OptimizeOffPragmaLocation = PragmaLoc;
999 }
1000 
1002  // In the future, check other pragmas if they're implemented (e.g. pragma
1003  // optimize 0 will probably map to this functionality too).
1006 }
1007 
1009  SourceLocation Loc) {
1010  // Don't add a conflicting attribute. No diagnostic is needed.
1011  if (FD->hasAttr<MinSizeAttr>() || FD->hasAttr<AlwaysInlineAttr>())
1012  return;
1013 
1014  // Add attributes only if required. Optnone requires noinline as well, but if
1015  // either is already present then don't bother adding them.
1016  if (!FD->hasAttr<OptimizeNoneAttr>())
1017  FD->addAttr(OptimizeNoneAttr::CreateImplicit(Context, Loc));
1018  if (!FD->hasAttr<NoInlineAttr>())
1019  FD->addAttr(NoInlineAttr::CreateImplicit(Context, Loc));
1020 }
1021 
1022 typedef std::vector<std::pair<unsigned, SourceLocation> > VisStack;
1023 enum : unsigned { NoVisibility = ~0U };
1024 
1026  if (!VisContext)
1027  return;
1028 
1029  NamedDecl *ND = dyn_cast<NamedDecl>(D);
1031  return;
1032 
1033  VisStack *Stack = static_cast<VisStack*>(VisContext);
1034  unsigned rawType = Stack->back().first;
1035  if (rawType == NoVisibility) return;
1036 
1037  VisibilityAttr::VisibilityType type
1038  = (VisibilityAttr::VisibilityType) rawType;
1039  SourceLocation loc = Stack->back().second;
1040 
1041  D->addAttr(VisibilityAttr::CreateImplicit(Context, type, loc));
1042 }
1043 
1044 /// FreeVisContext - Deallocate and null out VisContext.
1046  delete static_cast<VisStack*>(VisContext);
1047  VisContext = nullptr;
1048 }
1049 
1050 static void PushPragmaVisibility(Sema &S, unsigned type, SourceLocation loc) {
1051  // Put visibility on stack.
1052  if (!S.VisContext)
1053  S.VisContext = new VisStack;
1054 
1055  VisStack *Stack = static_cast<VisStack*>(S.VisContext);
1056  Stack->push_back(std::make_pair(type, loc));
1057 }
1058 
1060  SourceLocation PragmaLoc) {
1061  if (VisType) {
1062  // Compute visibility to use.
1063  VisibilityAttr::VisibilityType T;
1064  if (!VisibilityAttr::ConvertStrToVisibilityType(VisType->getName(), T)) {
1065  Diag(PragmaLoc, diag::warn_attribute_unknown_visibility) << VisType;
1066  return;
1067  }
1068  PushPragmaVisibility(*this, T, PragmaLoc);
1069  } else {
1070  PopPragmaVisibility(false, PragmaLoc);
1071  }
1072 }
1073 
1076  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1077  switch (FPC) {
1078  case LangOptions::FPM_On:
1079  NewFPFeatures.setAllowFPContractWithinStatement();
1080  break;
1081  case LangOptions::FPM_Fast:
1082  NewFPFeatures.setAllowFPContractAcrossStatement();
1083  break;
1084  case LangOptions::FPM_Off:
1085  NewFPFeatures.setDisallowFPContract();
1086  break;
1088  llvm_unreachable("Should not happen");
1089  }
1090  FpPragmaStack.Act(Loc, Sema::PSK_Set, StringRef(), NewFPFeatures);
1091  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
1092 }
1093 
1095  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1096  NewFPFeatures.setAllowFPReassociateOverride(IsEnabled);
1097  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
1098  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
1099 }
1100 
1101 void Sema::setRoundingMode(SourceLocation Loc, llvm::RoundingMode FPR) {
1102  // C2x: 7.6.2p3 If the FE_DYNAMIC mode is specified and FENV_ACCESS is "off",
1103  // the translator may assume that the default rounding mode is in effect.
1104  if (FPR == llvm::RoundingMode::Dynamic &&
1105  !CurFPFeatures.getAllowFEnvAccess() &&
1106  CurFPFeatures.getFPExceptionMode() == LangOptions::FPE_Ignore)
1107  FPR = llvm::RoundingMode::NearestTiesToEven;
1108 
1109  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1110  NewFPFeatures.setRoundingModeOverride(FPR);
1111  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
1112  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
1113 }
1114 
1117  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1118  NewFPFeatures.setFPExceptionModeOverride(FPE);
1119  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
1120  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
1121 }
1122 
1123 void Sema::ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled) {
1124  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
1125  auto LO = getLangOpts();
1126  if (IsEnabled) {
1127  // Verify Microsoft restriction:
1128  // You can't enable fenv_access unless precise semantics are enabled.
1129  // Precise semantics can be enabled either by the float_control
1130  // pragma, or by using the /fp:precise or /fp:strict compiler options
1131  if (!isPreciseFPEnabled())
1132  Diag(Loc, diag::err_pragma_fenv_requires_precise);
1133  NewFPFeatures.setAllowFEnvAccessOverride(true);
1134  // Enabling FENV access sets the RoundingMode to Dynamic.
1135  // and ExceptionBehavior to Strict
1136  NewFPFeatures.setRoundingModeOverride(llvm::RoundingMode::Dynamic);
1137  NewFPFeatures.setFPExceptionModeOverride(LangOptions::FPE_Strict);
1138  } else {
1139  NewFPFeatures.setAllowFEnvAccessOverride(false);
1140  }
1141  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
1142  CurFPFeatures = NewFPFeatures.applyOverrides(LO);
1143 }
1144 
1147  setExceptionMode(Loc, FPE);
1148 }
1149 
1150 void Sema::PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
1151  SourceLocation Loc) {
1152  // Visibility calculations will consider the namespace's visibility.
1153  // Here we just want to note that we're in a visibility context
1154  // which overrides any enclosing #pragma context, but doesn't itself
1155  // contribute visibility.
1156  PushPragmaVisibility(*this, NoVisibility, Loc);
1157 }
1158 
1159 void Sema::PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc) {
1160  if (!VisContext) {
1161  Diag(EndLoc, diag::err_pragma_pop_visibility_mismatch);
1162  return;
1163  }
1164 
1165  // Pop visibility from stack
1166  VisStack *Stack = static_cast<VisStack*>(VisContext);
1167 
1168  const std::pair<unsigned, SourceLocation> *Back = &Stack->back();
1169  bool StartsWithPragma = Back->first != NoVisibility;
1170  if (StartsWithPragma && IsNamespaceEnd) {
1171  Diag(Back->second, diag::err_pragma_push_visibility_mismatch);
1172  Diag(EndLoc, diag::note_surrounding_namespace_ends_here);
1173 
1174  // For better error recovery, eat all pushes inside the namespace.
1175  do {
1176  Stack->pop_back();
1177  Back = &Stack->back();
1178  StartsWithPragma = Back->first != NoVisibility;
1179  } while (StartsWithPragma);
1180  } else if (!StartsWithPragma && !IsNamespaceEnd) {
1181  Diag(EndLoc, diag::err_pragma_pop_visibility_mismatch);
1182  Diag(Back->second, diag::note_surrounding_namespace_starts_here);
1183  return;
1184  }
1185 
1186  Stack->pop_back();
1187  // To simplify the implementation, never keep around an empty stack.
1188  if (Stack->empty())
1189  FreeVisContext();
1190 }
clang::Sema::UnifySection
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
Definition: SemaAttr.cpp:603
clang::Sema::CurContext
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:414
clang::FPOptionsOverride::setAllowFPContractAcrossStatement
void setAllowFPContractAcrossStatement()
Definition: LangOptions.h:580
clang::Sema::PragmaOptionsAlignKind
PragmaOptionsAlignKind
Definition: Sema.h:9821
clang::Sema::PragmaClangRelroSection
PragmaClangSection PragmaClangRelroSection
Definition: Sema.h:466
clang::Decl::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclBase.h:422
type
clang::Sema::ActOnPragmaUnused
void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, SourceLocation PragmaLoc)
ActOnPragmaUnused - Called on well-formed '#pragma unused'.
Definition: SemaAttr.cpp:698
clang::Sema::inferGslOwnerPointerAttribute
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
Definition: SemaAttr.cpp:164
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:547
clang::Sema::ActOnPragmaMSInitSeg
void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation, StringLiteral *SegmentName)
Called on well-formed #pragma init_seg().
Definition: SemaAttr.cpp:689
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:96
clang::Sema::CurInitSeg
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
Definition: Sema.h:716
clang::Sema::FreeVisContext
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
Definition: SemaAttr.cpp:1045
clang::Decl::Decl
Decl()=delete
clang::Sema::SourceMgr
SourceManager & SourceMgr
Definition: Sema.h:405
clang::Sema::DataSegStack
PragmaStack< StringLiteral * > DataSegStack
Definition: Sema.h:682
clang::PFC_Pop
@ PFC_Pop
Definition: PragmaKinds.h:35
clang::Sema::AlignPackInfo::IsPackSet
bool IsPackSet() const
Definition: Sema.h:539
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:657
SemaInternal.h
clang::Sema::ActOnPragmaFloatControl
void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action, PragmaFloatControlKind Value)
ActOnPragmaFloatControl - Call on well-formed #pragma float_control.
Definition: SemaAttr.cpp:472
clang::StringLiteral::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1930
llvm::SmallVector< attr::SubjectMatchRule, 4 >
Lookup.h
clang::ParsedAttr::appliesToDecl
bool appliesToDecl(const Decl *D, attr::SubjectMatchRule MatchRule) const
Definition: ParsedAttr.cpp:162
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:89
clang::Sema::ActOnPragmaDetectMismatch
void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
ActOnPragmaDetectMismatch - Call on well-formed #pragma detect_mismatch.
Definition: SemaAttr.cpp:464
clang::Sema::CodeSegStack
PragmaStack< StringLiteral * > CodeSegStack
Definition: Sema.h:685
clang::TargetCXXABI::isMicrosoft
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Definition: TargetCXXABI.h:169
clang::Sema::AddPushedVisibilityAttribute
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
Definition: SemaAttr.cpp:1025
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:223
TargetInfo.h
clang::Sema::DiagnoseUnterminatedPragmaAttribute
void DiagnoseUnterminatedPragmaAttribute()
Definition: SemaAttr.cpp:988
clang::Sema::PragmaStack::Stack
SmallVector< Slot, 2 > Stack
Definition: Sema.h:656
clang::Sema::FpPragmaStack
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition: Sema.h:688
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:661
Attr.h
clang::Sema::AlignPackInfo::Packed
@ Packed
Definition: Sema.h:484
clang::Sema::PragmaStack
Definition: Sema.h:582
clang::Token::getIdentifierInfo
IdentifierInfo * getIdentifierInfo() const
Definition: Token.h:179
clang::QualType::getCanonicalType
QualType getCanonicalType() const
Definition: Type.h:6459
clang::LookupResult
Represents the results of name lookup.
Definition: Lookup.h:46
clang::TargetInfo::getCXXABI
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Definition: TargetInfo.h:1153
clang::Sema::Diag
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: Sema.cpp:1767
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:443
clang::LangOptions::FPM_On
@ FPM_On
Definition: LangOptions.h:200
clang::ASTContext::PSF_Execute
@ PSF_Execute
Definition: ASTContext.h:3095
clang::ASTContext::PSF_Write
@ PSF_Write
Definition: ASTContext.h:3094
clang::Sema::getSourceManager
SourceManager & getSourceManager() const
Definition: Sema.h:1526
clang::Sema::ActOnPragmaAttributePop
void ActOnPragmaAttributePop(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Called on well-formed '#pragma clang attribute pop'.
Definition: SemaAttr.cpp:917
clang::Sema::PSK_Push_Set
@ PSK_Push_Set
Definition: Sema.h:475
llvm::Optional
Definition: LLVM.h:37
clang::Sema::setRoundingMode
void setRoundingMode(SourceLocation Loc, llvm::RoundingMode)
Called to set constant rounding mode for floating point operations.
Definition: SemaAttr.cpp:1101
clang::Sema::AddMsStructLayoutForRecord
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
Definition: SemaAttr.cpp:86
clang::Sema::AlignPackIncludeState::CurrentValue
AlignPackInfo CurrentValue
Definition: Sema.h:676
clang::Decl::getAttr
T * getAttr() const
Definition: DeclBase.h:543
clang::Sema::AlignPackInfo::Mode
Mode
Definition: Sema.h:484
clang::Sema::ActOnPragmaMSSection
void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags, StringLiteral *SegmentName)
Called on well formed #pragma section().
Definition: SemaAttr.cpp:684
clang::FPOptionsOverride::setFPPreciseEnabled
void setFPPreciseEnabled(bool Value)
Definition: LangOptions.h:588
VisStack
std::vector< std::pair< unsigned, SourceLocation > > VisStack
Definition: SemaAttr.cpp:1022
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:910
clang::Token
Token - This structure provides full information about a lexed token.
Definition: Token.h:34
clang::ParsedAttr::setIsPragmaClangAttribute
void setIsPragmaClangAttribute()
Definition: ParsedAttr.h:448
clang::Sema::POAK_Natural
@ POAK_Natural
Definition: Sema.h:9823
clang::ASTContext::getTranslationUnitDecl
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:967
clang::Sema::setExceptionMode
void setExceptionMode(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called to set exception behavior for floating point operations.
Definition: SemaAttr.cpp:1115
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:1123
clang::attr::SubjectMatchRule
SubjectMatchRule
A list of all the recognized kinds of attributes.
Definition: AttrSubjectMatchRules.h:19
clang::Sema::Context
ASTContext & Context
Definition: Sema.h:402
Preprocessor.h
clang::Sema::ActOnPragmaOptimize
void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc)
Called on well formed #pragma clang optimize.
Definition: SemaAttr.cpp:994
clang::Sema::PSK_Set
@ PSK_Set
Definition: Sema.h:471
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:1150
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:952
clang::Diagnostic
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Definition: Diagnostic.h:1532
clang::Sema::getLangOpts
const LangOptions & getLangOpts() const
Definition: Sema.h:1521
clang::ASTContext::PSF_ZeroInit
@ PSF_ZeroInit
Definition: ASTContext.h:3097
U
clang::CharSourceRange::getCharRange
static CharSourceRange getCharRange(SourceRange R)
Definition: SourceLocation.h:267
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:15510
clang::NamedDecl::getExplicitVisibility
Optional< Visibility > getExplicitVisibility(ExplicitVisibilityKind kind) const
If visibility was explicitly specified for this declaration, return that visibility.
Definition: Decl.cpp:1186
clang::Sema::isPreciseFPEnabled
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition: Sema.h:9908
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:398
clang::Sema::PSK_Reset
@ PSK_Reset
Definition: Sema.h:470
clang::Sema::CurFPFeatureOverrides
FPOptionsOverride CurFPFeatureOverrides()
Definition: Sema.h:689
clang::Sema::ActOnPragmaOptionsAlign
void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc)
ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
Definition: SemaAttr.cpp:215
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:394
clang::Sema::VisContext
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:720
clang::threadSafety::sx::toString
std::string toString(const til::SExpr *E)
Definition: ThreadSafetyCommon.h:89
clang::ASTContext::PSF_Read
@ PSF_Read
Definition: ASTContext.h:3093
clang::FPOptionsOverride
Represents difference between two FPOptions values.
Definition: LangOptions.h:550
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:187
clang::LangOptions::FPExceptionModeKind
FPExceptionModeKind
Possible floating point exception behavior.
Definition: LangOptions.h:214
clang::Sema::AlignPackInfo::Native
@ Native
Definition: Sema.h:484
clang::Sema::PragmaStackSentinelRAII::PragmaStackSentinelRAII
PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct)
Definition: SemaAttr.cpp:27
clang::Sema::ActOnPragmaPack
void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, StringRef SlotLabel, Expr *Alignment)
ActOnPragmaPack - Called on well formed #pragma pack(...).
Definition: SemaAttr.cpp:320
clang::FPOptionsOverride::applyOverrides
FPOptions applyOverrides(FPOptions Base)
Definition: LangOptions.h:615
clang::Sema::AlignPackInfo
Definition: Sema.h:480
clang::Sema::MSStructPragmaOn
bool MSStructPragmaOn
Definition: Sema.h:424
clang::Sema::PragmaClangSection::SectionName
std::string SectionName
Definition: Sema.h:458
clang::Sema::Diags
DiagnosticsEngine & Diags
Definition: Sema.h:404
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:1074
clang::TypedefNameDecl::getUnderlyingType
QualType getUnderlyingType() const
Definition: Decl.h:3182
clang::DeclContext::isTranslationUnit
bool isTranslationUnit() const
Definition: DeclBase.h:1890
clang::Sema::PSK_Push
@ PSK_Push
Definition: Sema.h:472
clang::ParsedAttr
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:196
clang::attr::getSubjectMatchRuleSpelling
const char * getSubjectMatchRuleSpelling(SubjectMatchRule Rule)
Definition: Attributes.cpp:28
clang::ParsedAttributesView::addAtEnd
void addAtEnd(ParsedAttr *newAttr)
Definition: ParsedAttr.h:828
Expr.h
clang::Sema::ProcessDeclAttributeList
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AL, bool IncludeCXX11Attributes=true)
clang::Redeclarable::redecls
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: Redeclarable.h:294
clang::PragmaDetectMismatchDecl::Create
static PragmaDetectMismatchDecl * Create(const ASTContext &C, TranslationUnitDecl *DC, SourceLocation Loc, StringRef Name, StringRef Value)
Definition: Decl.cpp:4736
clang::Sema::PragmaClangTextSection
PragmaClangSection PragmaClangTextSection
Definition: Sema.h:467
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:834
clang::PFC_Precise
@ PFC_Precise
Definition: PragmaKinds.h:30
clang::StringLiteral
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1755
clang::Sema::AlignPackIncludeStack
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
Definition: Sema.h:680
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:1753
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:2433
clang::DeclContext::isNamespace
bool isNamespace() const
Definition: DeclBase.h:1899
clang::Sema::PragmaStackSentinelRAII::~PragmaStackSentinelRAII
~PragmaStackSentinelRAII()
Definition: SemaAttr.cpp:40
clang::PFC_Push
@ PFC_Push
Definition: PragmaKinds.h:34
x
IRgen optimization opportunities The common pattern of short x
Definition: README.txt:7
clang::Sema::PragmaClangSectionAction
PragmaClangSectionAction
Definition: Sema.h:452
clang::Sema::AlignPackInfo::Natural
@ Natural
Definition: Sema.h:484
clang::Sema::CurInitSegLoc
SourceLocation CurInitSegLoc
Definition: Sema.h:717
clang::Sema::ActOnPragmaVisibility
void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc)
ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
Definition: SemaAttr.cpp:1059
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:400
clang::PragmaCommentDecl::Create
static PragmaCommentDecl * Create(const ASTContext &C, TranslationUnitDecl *DC, SourceLocation CommentLoc, PragmaMSCommentKind CommentKind, StringRef Arg)
Definition: Decl.cpp:4713
clang::PFC_NoExcept
@ PFC_NoExcept
Definition: PragmaKinds.h:33
clang::Sema::PragmaStack::Act
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition: Sema.h:595
clang::Sema::PSK_Show
@ PSK_Show
Definition: Sema.h:474
clang::transformer::EditKind::Range
@ Range
clang::LangOptions::FPModeKind
FPModeKind
Definition: LangOptions.h:195
clang::Sema::PragmaClangSection
Definition: Sema.h:457
clang::Sema::ActOnPragmaFPExceptions
void ActOnPragmaFPExceptions(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called on well formed '#pragma clang fp' that has option 'exceptions'.
Definition: SemaAttr.cpp:1145
clang::Sema::PragmaClangBSSSection
PragmaClangSection PragmaClangBSSSection
Definition: Sema.h:463
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::Sema::BSSSegStack
PragmaStack< StringLiteral * > BSSSegStack
Definition: Sema.h:683
clang::TargetInfo::hasAlignMac68kSupport
bool hasAlignMac68kSupport() const
Check whether this target support '#pragma options align=mac68k'.
Definition: TargetInfo.h:784
clang::Sema::POAK_Reset
@ POAK_Reset
Definition: Sema.h:9827
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:677
clang::Sema::PrintPragmaAttributeInstantiationPoint
void PrintPragmaAttributeInstantiationPoint()
Definition: SemaAttr.cpp:982
clang::Sema::ActOnPragmaMSVtorDisp
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition: SemaAttr.cpp:532
clang::Sema::ActOnPragmaMSStruct
void ActOnPragmaMSStruct(PragmaMSStructKind Kind)
ActOnPragmaMSStruct - Called on well formed #pragma ms_struct [on|off].
Definition: SemaAttr.cpp:452
clang::Sema::PragmaAttributeEntry
This an attribute introduced by #pragma clang attribute.
Definition: Sema.h:723
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:244
clang::ASTContext::PSF_Implicit
@ PSF_Implicit
Definition: ASTContext.h:3096
clang::Sema::MSPointerToMemberRepresentationMethod
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition: Sema.h:428
clang::DeclContext::addDecl
void addDecl(Decl *D)
Add the declaration D into this context.
Definition: DeclBase.cpp:1576
clang::Sema::AlignPackInfo::IsAlignAttr
bool IsAlignAttr() const
Definition: Sema.h:533
clang::CharSourceRange::getTokenRange
static CharSourceRange getTokenRange(SourceRange R)
Definition: SourceLocation.h:263
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:1656
clang::Sema::DiagnoseNonDefaultPragmaAlignPack
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
Definition: SemaAttr.cpp:386
llvm::ArrayRef
Definition: LLVM.h:31
Value
Value
Definition: UninitializedValues.cpp:102
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::AttributeCommonInfo
Definition: AttributeCommonInfo.h:22
clang::Sema::PragmaAttributeStack
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition: Sema.h:739
clang::Sema::ActOnPragmaMSComment
void ActOnPragmaMSComment(SourceLocation CommentLoc, PragmaMSCommentKind Kind, StringRef Arg)
ActOnPragmaMSComment - Called on well formed #pragma comment(kind, "arg").
Definition: SemaAttr.cpp:456
clang::DeclGroupRef
Definition: DeclGroup.h:51
clang::Sema::Consumer
ASTConsumer & Consumer
Definition: Sema.h:403
clang::PFC_NoPrecise
@ PFC_NoPrecise
Definition: PragmaKinds.h:31
clang::CharSourceRange
Represents a character-granular source range.
Definition: SourceLocation.h:255
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:343
clang::LangOptions::FPM_FastHonorPragmas
@ FPM_FastHonorPragmas
Definition: LangOptions.h:206
ASTConsumer.h
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:59
clang::Sema::ImplicitMSInheritanceAttrLoc
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition: Sema.h:434
clang::Token::getLocation
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
Definition: Token.h:126
clang::ASTContext::getTargetInfo
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:671
clang::Sema::DiagnoseUnterminatedPragmaAlignPack
void DiagnoseUnterminatedPragmaAlignPack()
Definition: SemaAttr.cpp:425
clang::Sema::PragmaStack::CurrentValue
ValueType CurrentValue
Definition: Sema.h:658
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:446
clang::Sema::POAK_Power
@ POAK_Power
Definition: Sema.h:9825
clang::attr::ParsedSubjectMatchRuleSet
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
Definition: AttrSubjectMatchRules.h:26
clang::Sema::ActOnPragmaClangSection
void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, PragmaClangSectionKind SecKind, StringRef SecName)
ActOnPragmaClangSection - Called on well formed #pragma clang section.
Definition: SemaAttr.cpp:272
clang::ASTContext::SectionInfos
llvm::StringMap< SectionInfo > SectionInfos
Definition: ASTContext.h:3113
clang::Sema::PragmaMsStackAction
PragmaMsStackAction
Definition: Sema.h:469
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:1159
addGslOwnerPointerAttributeIfNotExisting
static void addGslOwnerPointerAttributeIfNotExisting(ASTContext &Context, CXXRecordDecl *Record)
Definition: SemaAttr.cpp:99
clang::Sema::ConstSegStack
PragmaStack< StringLiteral * > ConstSegStack
Definition: Sema.h:684
clang::IdentifierInfo::getName
StringRef getName() const
Return the actual identifier string.
Definition: IdentifierTable.h:160
clang::LangOptions::PragmaMSPointersToMembersKind
PragmaMSPointersToMembersKind
Definition: LangOptions.h:97
clang
Dataflow Directional Tag Classes.
Definition: CalledOnceCheck.h:17
clang::Sema::inferGslPointerAttribute
void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord)
Add gsl::Pointer attribute to std::container::iterator.
Definition: SemaAttr.cpp:108
clang::Sema::PragmaClangSection::Valid
bool Valid
Definition: Sema.h:459
clang::Sema::AlignPackInfo::Mac68k
@ Mac68k
Definition: Sema.h:484
clang::Sema::POAK_Packed
@ POAK_Packed
Definition: Sema.h:9824
PushPragmaVisibility
static void PushPragmaVisibility(Sema &S, unsigned type, SourceLocation loc)
Definition: SemaAttr.cpp:1050
clang::Sema::PSK_Pop
@ PSK_Pop
Definition: Sema.h:473
clang::Sema::AlignPackInfo::getPackNumber
unsigned getPackNumber() const
Definition: Sema.h:537
clang::Sema::PragmaAlignPackDiagnoseKind::NonDefaultStateAtInclude
@ NonDefaultStateAtInclude
clang::Sema::PragmaClangSection::PragmaLocation
SourceLocation PragmaLocation
Definition: Sema.h:460
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:1008
clang::Sema::PragmaClangSectionKind
PragmaClangSectionKind
pragma clang section kind
Definition: Sema.h:443
clang::FPOptionsOverride::setDisallowFPContract
void setDisallowFPContract()
Definition: LangOptions.h:584
clang::ParsedAttr::getMatchRules
void getMatchRules(const LangOptions &LangOpts, SmallVectorImpl< std::pair< attr::SubjectMatchRule, bool >> &MatchRules) const
Definition: ParsedAttr.cpp:167
clang::Sema::AddCFAuditedAttribute
void AddCFAuditedAttribute(Decl *D)
AddCFAuditedAttribute - Check whether we're currently within '#pragma clang arc_cf_code_audited' and,...
Definition: SemaAttr.cpp:727
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:216
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:46
clang::FixItHint::CreateRemoval
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
Definition: Diagnostic.h:122
clang::LangOptions::FPE_Strict
@ FPE_Strict
Strictly preserve the floating-point exception semantics.
Definition: LangOptions.h:220
unsigned
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:748
clang::AttributeCommonInfo::AS_Pragma
@ AS_Pragma
#pragma ...
Definition: AttributeCommonInfo.h:45
clang::TargetInfo::isValidSectionSpecifier
virtual llvm::Error isValidSectionSpecifier(StringRef SR) const
An optional hook that targets can implement to perform semantic checking on attribute((section("foo")...
Definition: TargetInfo.h:1126
clang::TypedefNameDecl
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3127
clang::PragmaMSStructKind
PragmaMSStructKind
Definition: PragmaKinds.h:23
clang::Sema::AlignPackStack
PragmaStack< AlignPackInfo > AlignPackStack
Definition: Sema.h:673
clang::LookupResult::getAsSingle
DeclClass * getAsSingle() const
Definition: Lookup.h:507
clang::Sema::AlignPackInfo::getAlignMode
Mode getAlignMode() const
Definition: Sema.h:535
clang::Sema::POAK_Mac68k
@ POAK_Mac68k
Definition: Sema.h:9826
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6420
clang::Sema::checkSectionName
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
clang::Sema::PragmaAlignPackDiagnoseKind
PragmaAlignPackDiagnoseKind
Definition: Sema.h:9843
clang::Sema::ActOnPragmaMSPointersToMembers
void ActOnPragmaMSPointersToMembers(LangOptions::PragmaMSPointersToMembersKind Kind, SourceLocation PragmaLoc)
ActOnPragmaMSPointersToMembers - called on well formed #pragma pointers_to_members(representation met...
Definition: SemaAttr.cpp:525
Parent
NodeId Parent
Definition: ASTDiff.cpp:192
clang::NamedDecl::VisibilityForValue
@ VisibilityForValue
Do an LV computation for, ultimately, a non-type declaration.
Definition: Decl.h:405
clang::LangOptions::FPM_Off
@ FPM_Off
Definition: LangOptions.h:197
clang::Sema::PragmaClangDataSection
PragmaClangSection PragmaClangDataSection
Definition: Sema.h:464
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:3902
clang::Sema::AlignPackIncludeState
Definition: Sema.h:675
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:1001
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:1273
clang::Sema::PragmaAttributeCurrentTargetDecl
const Decl * PragmaAttributeCurrentTargetDecl
The declaration that is currently receiving an attribute from the #pragma attribute stack.
Definition: Sema.h:743
clang::ParsedAttributesView
Definition: ParsedAttr.h:818
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:50
clang::FPOptionsOverride::setAllowFPContractWithinStatement
void setAllowFPContractWithinStatement()
Definition: LangOptions.h:576
clang::PMSST_ON
@ PMSST_ON
Definition: PragmaKinds.h:25
clang::Sema::PragmaClangRodataSection
PragmaClangSection PragmaClangRodataSection
Definition: Sema.h:465
clang::Sema::PP
Preprocessor & PP
Definition: Sema.h:401
clang::Sema::AlignPackIncludeState::ShouldWarnOnInclude
bool ShouldWarnOnInclude
Definition: Sema.h:678
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:430
clang::ASTContext::SectionInfo
Definition: ASTContext.h:3101
clang::Decl::addAttr
void addAttr(Attr *A)
Definition: DeclBase.cpp:881
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1811
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3806
clang::LangOptions::FPM_Fast
@ FPM_Fast
Definition: LangOptions.h:203
clang::Sema::VtorDispStack
PragmaStack< MSVtorDispMode > VtorDispStack
Whether to insert vtordisps prior to virtual bases in the Microsoft C++ ABI.
Definition: Sema.h:672
NoVisibility
@ NoVisibility
Definition: SemaAttr.cpp:1023
clang::Sema::PragmaAlignPackDiagnoseKind::ChangedStateAtExit
@ ChangedStateAtExit
clang::StringLiteral::getString
StringRef getString() const
Definition: Expr.h:1838
clang::Sema::POAK_Native
@ POAK_Native
Definition: Sema.h:9822
clang::Sema::PragmaStack::SentinelAction
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition: Sema.h:644
clang::ento::ObjKind::OS
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
clang::DiagnosticsEngine::Report
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1508
clang::Sema::ActOnPragmaFPReassociate
void ActOnPragmaFPReassociate(SourceLocation Loc, bool IsEnabled)
Called on well formed #pragma clang fp reassociate.
Definition: SemaAttr.cpp:1094
clang::Sema::ActOnPragmaAttributeAttribute
void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute, SourceLocation PragmaLoc, attr::ParsedSubjectMatchRuleSet Rules)
Definition: SemaAttr.cpp:798
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:439
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:250