31 : S(S), SlotLabel(SlotLabel), ShouldAct(ShouldAct) {
66 }
else if (IsPackSet) {
68 RD->
addAttr(MaxFieldAlignmentAttr::CreateImplicit(
81 if (AlignPackedInclude.CurrentPragmaLocation !=
84 if (AlignPackedInclude.HasNonDefaultValue)
85 AlignPackedInclude.ShouldWarnOnInclude =
true;
97 RD->
addAttr(MSVtorDispAttr::CreateImplicit(
101template <
typename Attribute>
104 if (Record->hasAttr<OwnerAttr>() || Record->hasAttr<PointerAttr>())
107 for (
Decl *Redecl : Record->redecls())
108 Redecl->addAttr(Attribute::CreateImplicit(
Context,
nullptr));
113 if (!UnderlyingRecord)
120 static llvm::StringSet<> Containers{
136 "unordered_multiset",
137 "unordered_multimap",
140 static llvm::StringSet<> Iterators{
"iterator",
"const_iterator",
142 "const_reverse_iterator"};
144 if (
Parent->isInStdNamespace() && Iterators.count(ND->
getName()) &&
145 Containers.count(
Parent->getName()))
146 addGslOwnerPointerAttributeIfNotExisting<PointerAttr>(
Context,
157 dyn_cast<TemplateSpecializationType>(Canonical.
getTypePtr())) {
159 RD = dyn_cast_or_null<CXXRecordDecl>(
160 TST->getTemplateName().getAsTemplateDecl()->getTemplatedDecl());
168 static llvm::StringSet<> StdOwners{
188 "unordered_multiset",
189 "unordered_multimap",
192 static llvm::StringSet<> StdPointers{
198 if (!Record->getIdentifier())
202 if (Record->isInStdNamespace()) {
203 if (Record->hasAttr<OwnerAttr>() || Record->hasAttr<PointerAttr>())
206 if (StdOwners.count(Record->getName()))
207 addGslOwnerPointerAttributeIfNotExisting<OwnerAttr>(
Context, Record);
208 else if (StdPointers.count(Record->getName()))
209 addGslOwnerPointerAttributeIfNotExisting<PointerAttr>(
Context, Record);
245 Diag(PragmaLoc, diag::err_pragma_options_align_mac68k_target_unsupported);
260 Diag(PragmaLoc, diag::warn_pragma_options_align_reset_failed)
299 llvm_unreachable(
"invalid clang section kind");
308 Diag(PragmaLoc, diag::err_pragma_section_invalid_for_target)
323 StringRef SlotLabel,
Expr *alignment) {
326 if (IsXLPragma && !SlotLabel.empty()) {
327 Diag(PragmaLoc, diag::err_pragma_pack_identifer_not_supported);
332 Expr *Alignment =
static_cast<Expr *
>(alignment);
335 unsigned AlignmentVal = 0;
339 std::optional<llvm::APSInt> Val;
345 !(*Val == 0 || Val->isPowerOf2()) || Val->getZExtValue() > 16) {
346 Diag(PragmaLoc, diag::warn_pragma_pack_invalid_alignment);
350 if (IsXLPragma && *Val == 0) {
352 Diag(PragmaLoc, diag::err_pragma_pack_invalid_alignment);
356 AlignmentVal = (
unsigned)Val->getZExtValue();
366 Diag(PragmaLoc, diag::warn_pragma_pack_show) <<
"mac68k";
368 Diag(PragmaLoc, diag::warn_pragma_pack_show) << AlignmentVal;
374 if (Alignment && !SlotLabel.empty())
375 Diag(PragmaLoc, diag::warn_pragma_pack_pop_identifier_and_alignment);
378 "Empty pack stack can only be at Native alignment mode.");
379 Diag(PragmaLoc, diag::warn_pragma_pop_failed) <<
"pack" <<
"stack empty";
391 for (
unsigned Idx = 0; Idx < Args.size(); Idx++) {
392 Expr *&E = Args.begin()[Idx];
393 assert(E &&
"error are handled before");
401 clang::CK_ArrayToPointerDecay)
406 clang::CK_FunctionToPointerDecay, E,
nullptr,
410 clang::CK_LValueToRValue, E,
nullptr,
422 if (!
Result || !Notes.empty()) {
425 for (
auto &
Note : Notes)
445 bool HasNonDefaultValue =
452 HasNonDefaultValue,
false});
465 Diag(IncludeLoc, diag::warn_pragma_pack_non_default_at_include);
470 Diag(IncludeLoc, diag::warn_pragma_pack_modified_after_include);
478 bool IsInnermost =
true;
483 for (
const auto &StackSlot : llvm::reverse(
AlignPackStack.Stack)) {
484 Diag(StackSlot.PragmaPushLocation, diag::warn_pragma_pack_no_pop_eof);
490 diag::note_pragma_pack_pop_instead_reset);
527 llvm_unreachable(
"invalid pragma eval_method kind");
539 Diag(Loc, diag::err_setting_eval_method_used_in_unsafe_context) << 0 << 0;
541 Diag(Loc, diag::err_setting_eval_method_used_in_unsafe_context) << 0 << 1;
543 Diag(Loc, diag::err_setting_eval_method_used_in_unsafe_context) << 0 << 2;
557 Diag(Loc, diag::err_pragma_fc_pp_scope);
562 llvm_unreachable(
"invalid pragma float_control kind");
569 Diag(Loc, diag::err_pragma_fc_noprecise_requires_noexcept);
571 Diag(Loc, diag::err_pragma_fc_noprecise_requires_nofenv);
578 Diag(Loc, diag::err_pragma_fc_except_requires_precise);
592 Diag(Loc, diag::warn_pragma_pop_failed) <<
"float_control"
614 Diag(PragmaLoc, diag::warn_pragma_pop_failed) <<
"vtordisp"
622 llvm::StringRef StackSlotLabel,
623 AlignPackInfo
Value) {
625 CurrentValue = DefaultValue;
626 CurrentPragmaLocation = PragmaLocation;
630 Stack.emplace_back(Slot(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
633 if (!StackSlotLabel.empty()) {
635 auto I = llvm::find_if(llvm::reverse(Stack), [&](
const Slot &x) {
636 return x.StackSlotLabel == StackSlotLabel;
639 if (I != Stack.rend()) {
640 CurrentValue = I->Value;
641 CurrentPragmaLocation = I->PragmaLocation;
642 Stack.erase(std::prev(I.base()), Stack.end());
644 }
else if (
Value.IsXLStack() &&
Value.IsAlignAttr() &&
645 CurrentValue.IsPackAttr()) {
648 auto I = llvm::find_if(llvm::reverse(Stack), [&](
const Slot &x) {
649 return x.Value.IsAlignAttr();
652 if (I != Stack.rend()) {
653 Stack.erase(std::prev(I.base()), Stack.end());
655 CurrentValue = DefaultValue;
656 CurrentPragmaLocation = PragmaLocation;
658 CurrentValue = Stack.back().Value;
659 CurrentPragmaLocation = Stack.back().PragmaLocation;
663 }
else if (!Stack.empty()) {
666 if (
Value.IsXLStack() &&
Value.IsPackAttr() && CurrentValue.IsAlignAttr())
670 CurrentValue = Stack.back().Value;
671 CurrentPragmaLocation = Stack.back().PragmaLocation;
676 CurrentValue =
Value;
677 CurrentPragmaLocation = PragmaLocation;
686 PragmaLocation = A->getLocation();
694 const auto &Section = SectionIt->second;
695 if (Section.SectionFlags == SectionFlags ||
701 Diag(Section.
Decl->getLocation(), diag::note_declared_at)
702 << Section.
Decl->getName();
704 Diag(PragmaLocation, diag::note_pragma_entered_here);
705 if (Section.PragmaSectionLocation.isValid())
706 Diag(Section.PragmaSectionLocation, diag::note_pragma_entered_here);
715 const auto &Section = SectionIt->second;
716 if (Section.SectionFlags == SectionFlags)
719 Diag(PragmaSectionLocation, diag::err_section_conflict)
720 <<
"this" << Section;
722 Diag(Section.Decl->getLocation(), diag::note_declared_at)
723 << Section.Decl->getName();
724 if (Section.PragmaSectionLocation.isValid())
725 Diag(Section.PragmaSectionLocation, diag::note_pragma_entered_here);
737 llvm::StringRef StackSlotLabel,
739 llvm::StringRef PragmaName) {
741 llvm::StringSwitch<PragmaStack<StringLiteral *> *>(PragmaName)
746 if (Action &
PSK_Pop && Stack->Stack.empty())
747 Diag(PragmaLocation, diag::warn_pragma_pop_failed) << PragmaName
753 if (SegmentName->
getString() ==
".drectve" &&
755 Diag(PragmaLocation, diag::warn_attribute_section_drectve) << PragmaName;
758 Stack->Act(PragmaLocation, Action, StackSlotLabel, SegmentName);
766 Diag(PragmaLocation, diag::warn_pragma_pop_failed) <<
"strict_gs_check"
789 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
792 Diag(PragmaLocation, diag::err_pragma_expected_file_scope) <<
"alloc_text";
804 Diag(Loc, diag::err_undeclared_use) << II->
getName();
810 Diag(Loc, diag::err_pragma_alloc_text_not_function);
815 Diag(Loc, diag::err_pragma_alloc_text_c_linkage);
830 if (Lookup.
empty()) {
831 Diag(PragmaLoc, diag::warn_pragma_unused_undeclared_var)
838 Diag(PragmaLoc, diag::warn_pragma_unused_expected_var_arg)
845 Diag(PragmaLoc, diag::warn_used_but_marked_unused) << Name;
848 UnusedAttr::GNU_unused));
858 if (D->
hasAttr<CFAuditedTransferAttr>() ||
859 D->
hasAttr<CFUnknownTransferAttr>())
869std::optional<attr::SubjectMatchRule>
871 using namespace attr;
875#define ATTR_MATCH_RULE(Value, Spelling, IsAbstract)
876#define ATTR_MATCH_SUB_RULE(Value, Spelling, IsAbstract, Parent, IsNegated) \
879#include "clang/Basic/AttrSubMatchRulesList.inc"
884 using namespace attr;
888#define ATTR_MATCH_RULE(Value, Spelling, IsAbstract)
889#define ATTR_MATCH_SUB_RULE(Value, Spelling, IsAbstract, Parent, IsNegated) \
892#include "clang/Basic/AttrSubMatchRulesList.inc"
911 llvm::raw_string_ostream
OS(
Result);
912 for (
const auto &I : llvm::enumerate(Rules)) {
914 OS << (I.index() == Rules.size() - 1 ?
", and " :
", ");
929 StrictSubjectMatchRuleSet;
933 if (StrictSubjectMatchRuleSet.empty()) {
940 llvm::SmallDenseMap<int, std::pair<int, SourceRange>, 2>
941 RulesToFirstSpecifiedNegatedSubRule;
942 for (
const auto &Rule : Rules) {
944 std::optional<attr::SubjectMatchRule> ParentRule =
945 getParentAttrMatcherRule(MatchRule);
948 auto It = Rules.find(*ParentRule);
949 if (It != Rules.end()) {
951 Diag(Rule.second.getBegin(),
952 diag::err_pragma_attribute_matcher_subrule_contradicts_rule)
956 replacementRangeForListElement(*
this, Rule.second));
961 if (isNegatedAttrMatcherSubRule(MatchRule))
962 RulesToFirstSpecifiedNegatedSubRule.insert(
963 std::make_pair(*ParentRule, Rule));
965 bool IgnoreNegatedSubRules =
false;
966 for (
const auto &Rule : Rules) {
968 std::optional<attr::SubjectMatchRule> ParentRule =
969 getParentAttrMatcherRule(MatchRule);
972 auto It = RulesToFirstSpecifiedNegatedSubRule.find(*ParentRule);
973 if (It != RulesToFirstSpecifiedNegatedSubRule.end() &&
974 It->second != Rule) {
977 It->second.second.getBegin(),
979 err_pragma_attribute_matcher_negated_subrule_contradicts_subrule)
984 replacementRangeForListElement(*
this, It->second.second));
986 IgnoreNegatedSubRules =
true;
987 RulesToFirstSpecifiedNegatedSubRule.erase(It);
991 if (!IgnoreNegatedSubRules) {
992 for (
const auto &Rule : Rules)
995 for (
const auto &Rule : Rules) {
1007 for (
const auto &StrictRule : StrictSubjectMatchRuleSet) {
1009 if (Rules.erase(StrictRule.first)) {
1012 if (StrictRule.second)
1013 SubjectMatchRules.push_back(StrictRule.first);
1017 auto RulesToCheck = Rules;
1018 for (
const auto &Rule : RulesToCheck) {
1020 if (
auto ParentRule = getParentAttrMatcherRule(MatchRule)) {
1021 if (llvm::any_of(StrictSubjectMatchRuleSet,
1022 [ParentRule](
const auto &StrictRule) {
1023 return StrictRule.first == *ParentRule &&
1026 SubjectMatchRules.push_back(MatchRule);
1027 Rules.erase(MatchRule);
1033 if (!Rules.empty()) {
1035 Diag(PragmaLoc, diag::err_pragma_attribute_invalid_matchers)
1038 for (
const auto &Rule : Rules) {
1041 replacementRangeForListElement(*
this, Rule.second));
1043 Diagnostic << attrMatcherRuleListToString(ExtraRules);
1047 Diag(PragmaLoc, diag::err_pragma_attr_attr_no_push);
1052 {PragmaLoc, &
Attribute, std::move(SubjectMatchRules),
false});
1065 Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch) << 1;
1078 if (!Entry.IsUsed) {
1079 assert(Entry.Attribute &&
"Expected an attribute");
1080 Diag(Entry.Attribute->getLoc(), diag::warn_pragma_attribute_unused)
1081 << *Entry.Attribute;
1082 Diag(PragmaLoc, diag::note_pragma_attribute_region_ends_here);
1091 Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch)
1092 << 0 << Namespace->getName();
1094 Diag(PragmaLoc, diag::err_pragma_attribute_stack_mismatch) << 1;
1101 for (
auto &Entry : Group.Entries) {
1103 assert(
Attribute &&
"Expected an attribute");
1104 assert(
Attribute->isPragmaClangAttribute() &&
1105 "expected #pragma clang attribute");
1108 bool Applies =
false;
1109 for (
const auto &Rule : Entry.MatchRules) {
1110 if (
Attribute->appliesToDecl(D, Rule)) {
1117 Entry.IsUsed =
true;
1130 diag::note_pragma_attribute_applied_decl_here);
1148 Diag(Loc, diag::err_pragma_expected_file_scope) <<
"optimize";
1158 Diag(Loc, diag::err_pragma_expected_file_scope) <<
"function";
1176 StringRef Name = FD->
getName();
1181 std::tie(Section, Loc) = It->second;
1183 if (!FD->
hasAttr<SectionAttr>())
1198 if (FD->
hasAttr<MinSizeAttr>() || FD->
hasAttr<AlwaysInlineAttr>())
1203 if (!FD->
hasAttr<OptimizeNoneAttr>())
1205 if (!FD->
hasAttr<NoInlineAttr>())
1216typedef std::vector<std::pair<unsigned, SourceLocation> >
VisStack;
1228 unsigned rawType = Stack->back().first;
1231 VisibilityAttr::VisibilityType
type
1232 = (VisibilityAttr::VisibilityType) rawType;
1250 Stack->push_back(std::make_pair(
type, loc));
1257 VisibilityAttr::VisibilityType T;
1258 if (!VisibilityAttr::ConvertStrToVisibilityType(VisType->
getName(), T)) {
1259 Diag(PragmaLoc, diag::warn_attribute_unknown_visibility) << VisType;
1282 llvm_unreachable(
"Should not happen");
1304 Diag(Loc, diag::err_setting_eval_method_used_in_unsafe_context)
1311 NewFPFeatures.setAllowFPReassociateOverride(IsEnabled);
1314 NewFPFeatures.setAllowReciprocalOverride(IsEnabled);
1317 llvm_unreachable(
"unhandled value changing pragma fp");
1326 NewFPFeatures.setConstRoundingModeOverride(FPR);
1334 NewFPFeatures.setSpecifiedExceptionModeOverride(FPE);
1347 Diag(Loc, diag::err_pragma_fenv_requires_precise);
1349 NewFPFeatures.setAllowFEnvAccessOverride(IsEnabled);
1350 NewFPFeatures.setRoundingMathOverride(IsEnabled);
1371 Diag(EndLoc, diag::err_pragma_pop_visibility_mismatch);
1378 const std::pair<unsigned, SourceLocation> *Back = &Stack->back();
1380 if (StartsWithPragma && IsNamespaceEnd) {
1381 Diag(Back->second, diag::err_pragma_push_visibility_mismatch);
1382 Diag(EndLoc, diag::note_surrounding_namespace_ends_here);
1387 Back = &Stack->back();
1389 }
while (StartsWithPragma);
1390 }
else if (!StartsWithPragma && !IsNamespaceEnd) {
1391 Diag(EndLoc, diag::err_pragma_pop_visibility_mismatch);
1392 Diag(Back->second, diag::note_surrounding_namespace_starts_here);
1402template <
typename Ty>
1405 bool SkipArgCountCheck) {
1431 if (!SkipArgCountCheck) {
1451 bool SkipArgCountCheck) {
1452 return ::checkCommonAttributeFeatures(*
this, D, A, SkipArgCountCheck);
1455 bool SkipArgCountCheck) {
1456 return ::checkCommonAttributeFeatures(*
this, S, A, SkipArgCountCheck);
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
std::vector< std::pair< unsigned, SourceLocation > > VisStack
static void PushPragmaVisibility(Sema &S, unsigned type, SourceLocation loc)
static void addGslOwnerPointerAttributeIfNotExisting(ASTContext &Context, CXXRecordDecl *Record)
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
llvm::StringMap< SectionInfo > SectionInfos
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const TargetInfo & getTargetInfo() const
Attr - This represents one attribute.
Represents a C++ struct/union/class.
Represents a character-granular source range.
static CharSourceRange getCharRange(SourceRange R)
static CharSourceRange getTokenRange(SourceRange R)
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
bool isFileContext() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
Represents difference between two FPOptions values.
void setAllowFPContractAcrossStatement()
void setFPPreciseEnabled(bool Value)
void setAllowFPContractWithinStatement()
FPOptions applyOverrides(FPOptions Base)
void setDisallowFPContract()
LangOptions::FPExceptionModeKind getExceptionMode() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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.
Represents a function declaration or definition.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
FPExceptionModeKind
Possible floating point exception behavior.
@ FPE_Ignore
Assume that floating-point exceptions are masked.
@ FPE_Strict
Strictly preserve the floating-point exception semantics.
FPEvalMethodKind
Possible float expression evaluation method choices.
@ FEM_UnsetOnCommandLine
Used only for FE option processing; this is only used to indicate that the user did not specify an ex...
@ FEM_Source
Use the declared type for fp arithmetic.
@ FEM_Double
Use the type double for fp arithmetic.
@ FEM_Extended
Use extended type for fp arithmetic.
PragmaMSPointersToMembersKind
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...
Represents the results of name lookup.
DeclClass * getAsSingle() const
bool empty() const
Return true if no decls were found.
This represents a decl that may have a name.
@ VisibilityForValue
Do an LV computation for, ultimately, a non-type declaration.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
std::optional< Visibility > getExplicitVisibility(ExplicitVisibilityKind kind) const
If visibility was explicitly specified for this declaration, return that visibility.
ParsedAttr - Represents a syntactic attribute.
bool hasCustomParsing() const
unsigned getMinArgs() const
bool checkExactlyNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has exactly as many args as Num.
bool hasVariadicArg() const
bool diagnoseMutualExclusion(class Sema &S, const Decl *D) const
bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const
bool checkAtLeastNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at least as many args as Num.
unsigned getMaxArgs() const
AttributeCommonInfo::Kind getKind() const
bool diagnoseLangOpts(class Sema &S) const
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
void addAtEnd(ParsedAttr *newAttr)
static PragmaDetectMismatchDecl * Create(const ASTContext &C, TranslationUnitDecl *DC, SourceLocation Loc, StringRef Name, StringRef Value)
SourceLocation getLastFPEvalPragmaLocation() const
std::pair< IdentifierInfo *, SourceLocation > getPragmaARCCFCodeAuditedInfo() const
The location of the currently-active #pragma clang arc_cf_code_audited begin.
void setCurrentFPEvalMethod(SourceLocation PragmaLoc, LangOptions::FPEvalMethodKind Val)
A (possibly-)qualified type.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
Represents a struct/union/class.
Scope - A scope is a transient data structure that is used while parsing the program.
unsigned getPackNumber() const
Mode getAlignMode() const
~PragmaStackSentinelRAII()
PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct)
Sema - This implements semantic analysis and AST building for C.
void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn)
#pragma optimize("[optimization-list]", on | off).
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
void ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
void ActOnPragmaAttributePop(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Called on well-formed '#pragma clang attribute pop'.
void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
ActOnPragmaDetectMismatch - Call on well-formed #pragma detect_mismatch.
const Decl * PragmaAttributeCurrentTargetDecl
The declaration that is currently receiving an attribute from the #pragma attribute stack.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode)
Called to set constant rounding mode for floating point operations.
PragmaClangSection PragmaClangRodataSection
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
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 ...
void AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD, SourceLocation Loc)
Adds the 'optnone' attribute to the function declaration if there are no conflicts; Loc represents th...
PragmaStack< FPOptionsOverride > FpPragmaStack
PragmaStack< StringLiteral * > CodeSegStack
void AddRangeBasedOptnone(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based o...
void ActOnPragmaMSComment(SourceLocation CommentLoc, PragmaMSCommentKind Kind, StringRef Arg)
ActOnPragmaMSComment - Called on well formed #pragma comment(kind, "arg").
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
FPOptionsOverride CurFPFeatureOverrides()
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.
void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action, PragmaFloatControlKind Value)
ActOnPragmaFloatControl - Call on well-formed #pragma float_control.
void ActOnPragmaMSPointersToMembers(LangOptions::PragmaMSPointersToMembersKind Kind, SourceLocation PragmaLoc)
ActOnPragmaMSPointersToMembers - called on well formed #pragma pointers_to_members(representation met...
void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, SourceLocation PragmaLoc)
ActOnPragmaUnused - Called on well-formed '#pragma unused'.
void ActOnPragmaMSAllocText(SourceLocation PragmaLocation, StringRef Section, const SmallVector< std::tuple< IdentifierInfo *, SourceLocation > > &Functions)
Called on well-formed #pragma alloc_text().
PragmaStack< bool > StrictGuardStackCheckStack
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute, SourceLocation PragmaLoc, attr::ParsedSubjectMatchRuleSet Rules)
PragmaStack< StringLiteral * > ConstSegStack
void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc)
ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
void ActOnPragmaFPExceptions(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called on well formed '#pragma clang fp' that has option 'exceptions'.
void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord)
Add gsl::Pointer attribute to std::container::iterator.
void ActOnPragmaFPEvalMethod(SourceLocation Loc, LangOptions::FPEvalMethodKind Value)
void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, PragmaClangSectionKind SecKind, StringRef SecName)
ActOnPragmaClangSection - Called on well formed #pragma clang section.
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
void setExceptionMode(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called to set exception behavior for floating point operations.
void PrintPragmaAttributeInstantiationPoint()
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
const LangOptions & getLangOpts() const
SourceLocation CurInitSegLoc
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
bool MSPragmaOptimizeIsOn
The "on" or "off" argument passed by #pragma optimize, that denotes whether the optimizations in the ...
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
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.
const LangOptions & LangOpts
PragmaClangSection PragmaClangRelroSection
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
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...
void AddImplicitMSFunctionNoBuiltinAttr(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based n...
PragmaStack< AlignPackInfo > AlignPackStack
PragmaStack< StringLiteral * > BSSSegStack
llvm::StringMap< std::tuple< StringRef, SourceLocation > > FunctionToSectionMap
Sections used with #pragma alloc_text.
llvm::SmallSetVector< StringRef, 4 > MSFunctionNoBuiltins
Set of no-builtin functions listed by #pragma function.
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...
void AddCFAuditedAttribute(Decl *D)
AddCFAuditedAttribute - Check whether we're currently within '#pragma clang arc_cf_code_audited' and,...
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void ActOnPragmaMSFunction(SourceLocation Loc, const llvm::SmallVectorImpl< StringRef > &NoBuiltins)
Call on well formed #pragma function.
void ActOnPragmaMSStruct(PragmaMSStructKind Kind)
ActOnPragmaMSStruct - Called on well formed #pragma ms_struct [on|off].
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation, StringLiteral *SegmentName)
Called on well-formed #pragma init_seg().
SourceManager & getSourceManager() const
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
PragmaClangSection PragmaClangTextSection
void ActOnPragmaFPValueChangingOption(SourceLocation Loc, PragmaFPKind Kind, bool IsEnabled)
Called on well formed #pragma clang fp reassociate or #pragma clang fp reciprocal.
PragmaClangSection PragmaClangDataSection
llvm::Error isValidSectionSpecifier(StringRef Str)
Used to implement to perform semantic checking on attribute((section("foo"))) specifiers.
void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr, SourceLocation Loc)
PushNamespaceVisibilityAttr - Note that we've entered a namespace with a visibility attribute.
PragmaStack< MSVtorDispMode > VtorDispStack
Whether to insert vtordisps prior to virtual bases in the Microsoft C++ ABI.
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
PragmaAlignPackDiagnoseKind
@ NonDefaultStateAtInclude
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void DiagnoseUnterminatedPragmaAttribute()
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
void ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD)
Only called on function definitions; if there is a MSVC #pragma optimize in scope,...
void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc)
PopPragmaVisibility - Pop the top element of the visibility stack; used for '#pragma GCC visibility' ...
SourceManager & SourceMgr
void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, StringRef SlotLabel, Expr *Alignment)
ActOnPragmaPack - Called on well formed #pragma pack(...).
DiagnosticsEngine & Diags
void DiagnoseUnterminatedPragmaAlignPack()
PragmaStack< StringLiteral * > DataSegStack
void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc)
ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
void ActOnPragmaMSStrictGuardStackCheck(SourceLocation PragmaLocation, PragmaMsStackAction Action, bool Value)
ActOnPragmaMSStrictGuardStackCheck - Called on well formed #pragma strict_gs_check.
PragmaClangSection PragmaClangBSSSection
void ActOnPragmaFPContract(SourceLocation Loc, LangOptions::FPModeKind FPC)
ActOnPragmaFPContract - Called on well formed #pragma {STDC,OPENCL} FP_CONTRACT and #pragma clang fp ...
void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc)
Called on well formed #pragma clang optimize.
void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled)
ActOnPragmaFenvAccess - Called on well formed #pragma STDC FENV_ACCESS.
void AddSectionMSAllocText(FunctionDecl *FD)
Only called on function definitions; if there is a #pragma alloc_text that decides which code section...
void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags, StringLiteral *SegmentName)
Called on well formed #pragma section().
PragmaClangSectionKind
pragma clang section kind
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
SourceLocation getBeginLoc() const LLVM_READONLY
StringRef getString() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool hasAlignMac68kSupport() const
Check whether this target support '#pragma options align=mac68k'.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isFunctionType() const
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
Represents a variable declaration or definition.
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
SubjectMatchRule
A list of all the recognized kinds of attributes.
const char * getSubjectMatchRuleSpelling(SubjectMatchRule Rule)
@ AANT_ArgumentConstantExpr
@ Result
The result type of a method or function.
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
AlignPackInfo CurrentValue
SourceLocation CurrentPragmaLocation
This an attribute introduced by #pragma clang attribute.
SourceLocation PragmaLocation
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
SmallVector< Slot, 2 > Stack
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)