21 #include "llvm/ADT/StringExtras.h"
24 using namespace clang;
30 if (isa<SwitchCase>(St)) {
34 S.
Diag(L, diag::note_fallthrough_insert_semi_fixit)
39 if (FnScope->SwitchStack.empty()) {
50 FnScope->setHasFallthroughStmt();
59 S.
Diag(A.
getLoc(), diag::err_attribute_too_few_arguments) << A << 1;
63 std::vector<StringRef> DiagnosticIdentifiers;
64 for (
unsigned I = 0, E = A.
getNumArgs(); I != E; ++I) {
70 DiagnosticIdentifiers.push_back(RuleName);
73 return ::new (S.
Context) SuppressAttr(
74 S.
Context, A, DiagnosticIdentifiers.data(), DiagnosticIdentifiers.size());
77 SYCLIntelMaxConcurrencyAttr *
82 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
89 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
95 return new (Context) SYCLIntelMaxConcurrencyAttr(Context, CI, E);
106 SYCLIntelInitiationIntervalAttr *
111 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
118 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
124 return new (Context) SYCLIntelInitiationIntervalAttr(Context, CI, E);
135 SYCLIntelMaxInterleavingAttr *
140 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
146 if (ArgVal < 0 || ArgVal > 1) {
147 Diag(E->
getBeginLoc(), diag::err_attribute_argument_is_not_valid) << CI;
152 return new (Context) SYCLIntelMaxInterleavingAttr(Context, CI, E);
163 SYCLIntelLoopCoalesceAttr *
168 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
175 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
181 return new (Context) SYCLIntelLoopCoalesceAttr(Context, CI, E);
192 SYCLIntelSpeculatedIterationsAttr *
197 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
204 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
210 return new (Context) SYCLIntelSpeculatedIterationsAttr(Context, CI, E);
224 return new (S.
Context) SYCLIntelDisableLoopPipeliningAttr(S.
Context, A);
230 if (!
Value.isNonNegative())
232 diag::err_attribute_requires_positive_integer)
246 unsigned &SafelenValue) {
257 SafelenValue = ArgVal->getZExtValue();
259 if (SafelenValue == 0 || SafelenValue == 1) {
267 if (isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) {
284 unsigned SafelenValue = 0;
298 Expr *SafeLenExpr = Expr1;
299 Expr *ArrayExpr = Expr2;
308 SYCLIntelIVDepAttr(Context, CI, SafeLenExpr, ArrayExpr, SafelenValue);
313 template <
typename T>
317 llvm::transform(Attrs, std::back_inserter(FilteredAttrs),
318 [](
const Attr *A) ->
const T * {
319 if (
const auto *
Cast = dyn_cast<T>(A))
320 return Cast->isDependent() ?
nullptr :
Cast;
324 std::remove(FilteredAttrs.begin(), FilteredAttrs.end(),
nullptr),
325 FilteredAttrs.end());
337 if (FilteredAttrs.empty())
341 llvm::stable_sort(SortedAttrs, SYCLIntelIVDepAttr::SafelenCompare);
345 const auto *GlobalMaxItr =
346 llvm::find_if(SortedAttrs, [](
const SYCLIntelIVDepAttr *A) {
347 return !A->getArrayExpr();
349 const SYCLIntelIVDepAttr *GlobalMax =
350 GlobalMaxItr == SortedAttrs.end() ? nullptr : *GlobalMaxItr;
352 for (
const auto *A : FilteredAttrs) {
356 if (GlobalMax && !SYCLIntelIVDepAttr::SafelenCompare(A, GlobalMax)) {
357 S.
Diag(A->getLocation(), diag::warn_ivdep_redundant)
358 << !GlobalMax->isInf() << GlobalMax->getSafelenValue() << !A->isInf()
359 << A->getSafelenValue();
360 S.
Diag(GlobalMax->getLocation(), diag::note_previous_attribute);
364 if (!A->getArrayExpr())
367 const ValueDecl *ArrayDecl = A->getArrayDecl();
368 auto Other = llvm::find_if(SortedAttrs,
369 [ArrayDecl](
const SYCLIntelIVDepAttr *A) {
370 return ArrayDecl == A->getArrayDecl();
372 assert(
Other != SortedAttrs.end() &&
"Should find at least itself");
375 if (*
Other != A && !SYCLIntelIVDepAttr::SafelenCompare(A, *
Other)) {
376 S.
Diag(A->getLocation(), diag::warn_ivdep_redundant)
377 << !(*Other)->isInf() << (*Other)->getSafelenValue() << !A->isInf()
378 << A->getSafelenValue();
379 S.
Diag((*Other)->getLocation(), diag::note_previous_attribute);
400 Attrs, std::back_inserter(OnlyLoopCountAttrs), [](
const Attr *A) {
401 return dyn_cast_or_null<const SYCLIntelLoopCountAttr>(A);
403 OnlyLoopCountAttrs.erase(
404 std::remove(OnlyLoopCountAttrs.begin(), OnlyLoopCountAttrs.end(),
405 static_cast<const SYCLIntelLoopCountAttr *
>(
nullptr)),
406 OnlyLoopCountAttrs.end());
407 if (OnlyLoopCountAttrs.empty())
410 unsigned int MinCount = 0;
411 unsigned int MaxCount = 0;
412 unsigned int AvgCount = 0;
413 unsigned int Count = 0;
414 for (
const auto *A : OnlyLoopCountAttrs) {
415 const auto *At = dyn_cast<SYCLIntelLoopCountAttr>(A);
416 At->isMin() ? MinCount++
417 : At->isMax() ? MaxCount++
418 : At->isAvg() ? AvgCount++
420 if (MinCount > 1 || MaxCount > 1 || AvgCount > 1 || Count > 1)
421 S.
Diag(A->
getLocation(), diag::err_sycl_loop_attr_duplication) << 1 << A;
425 SYCLIntelLoopCountAttr *
429 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
436 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
442 return new (Context) SYCLIntelLoopCountAttr(Context, CI, E);
458 SYCLIntelMaxReinvocationDelayAttr *
463 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
470 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
476 return new (Context) SYCLIntelMaxReinvocationDelayAttr(Context, CI, E);
489 return new (S.
Context) SYCLIntelEnableLoopPipeliningAttr(S.
Context, A);
499 StringRef PragmaName =
500 llvm::StringSwitch<StringRef>(PragmaNameLoc->
Ident->
getName())
501 .Cases(
"unroll",
"nounroll",
"unroll_and_jam",
"nounroll_and_jam",
503 .Default(
"clang loop");
508 if (!isa<DoStmt, ForStmt, CXXForRangeStmt, WhileStmt>(St)) {
509 std::string Pragma =
"#pragma " + std::string(PragmaName);
510 S.
Diag(St->
getBeginLoc(), diag::err_pragma_loop_precedes_nonloop) << Pragma;
514 LoopHintAttr::OptionType Option;
515 LoopHintAttr::LoopHintState
State;
517 auto SetHints = [&Option, &
State](LoopHintAttr::OptionType O,
518 LoopHintAttr::LoopHintState S) {
523 if (PragmaName ==
"nounroll") {
524 SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
525 }
else if (PragmaName ==
"unroll") {
531 SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
533 SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Numeric);
535 SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Numeric);
537 SetHints(LoopHintAttr::Unroll, LoopHintAttr::Enable);
538 }
else if (PragmaName ==
"nounroll_and_jam") {
539 SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Disable);
540 }
else if (PragmaName ==
"unroll_and_jam") {
543 SetHints(LoopHintAttr::UnrollAndJamCount, LoopHintAttr::Numeric);
545 SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Enable);
548 assert(OptionLoc && OptionLoc->
Ident &&
549 "Attribute must have valid option info.");
550 Option = llvm::StringSwitch<LoopHintAttr::OptionType>(
552 .Case(
"vectorize", LoopHintAttr::Vectorize)
553 .Case(
"vectorize_width", LoopHintAttr::VectorizeWidth)
554 .Case(
"interleave", LoopHintAttr::Interleave)
555 .Case(
"vectorize_predicate", LoopHintAttr::VectorizePredicate)
556 .Case(
"interleave_count", LoopHintAttr::InterleaveCount)
557 .Case(
"unroll", LoopHintAttr::Unroll)
558 .Case(
"unroll_count", LoopHintAttr::UnrollCount)
559 .Case(
"pipeline", LoopHintAttr::PipelineDisabled)
560 .Case(
"pipeline_initiation_interval",
561 LoopHintAttr::PipelineInitiationInterval)
562 .Case(
"distribute", LoopHintAttr::Distribute)
563 .Default(LoopHintAttr::Vectorize);
564 if (Option == LoopHintAttr::VectorizeWidth) {
565 assert((ValueExpr || (StateLoc && StateLoc->
Ident)) &&
566 "Attribute must have a valid value expression or argument.");
571 State = LoopHintAttr::ScalableWidth;
573 State = LoopHintAttr::FixedWidth;
574 }
else if (Option == LoopHintAttr::InterleaveCount ||
575 Option == LoopHintAttr::UnrollCount ||
576 Option == LoopHintAttr::PipelineInitiationInterval) {
577 assert(ValueExpr &&
"Attribute must have a valid value expression.");
581 State = LoopHintAttr::Numeric;
582 }
else if (Option == LoopHintAttr::Vectorize ||
583 Option == LoopHintAttr::Interleave ||
584 Option == LoopHintAttr::VectorizePredicate ||
585 Option == LoopHintAttr::Unroll ||
586 Option == LoopHintAttr::Distribute ||
587 Option == LoopHintAttr::PipelineDisabled) {
588 assert(StateLoc && StateLoc->
Ident &&
"Loop hint must have an argument");
590 State = LoopHintAttr::Disable;
591 else if (StateLoc->
Ident->
isStr(
"assume_safety"))
592 State = LoopHintAttr::AssumeSafety;
594 State = LoopHintAttr::Full;
596 State = LoopHintAttr::Enable;
598 llvm_unreachable(
"bad loop hint argument");
600 llvm_unreachable(
"bad loop hint");
603 return LoopHintAttr::CreateImplicit(S.
Context, Option,
State, ValueExpr, A);
608 bool FoundAsmStmt =
false;
609 std::vector<const CallExpr *> CallExprs;
614 CallExprFinder(
Sema &S,
const Stmt *St) : Inherited(S.Context) { Visit(St); }
616 bool foundCallExpr() {
return !CallExprs.empty(); }
617 const std::vector<const CallExpr *> &getCallExprs() {
return CallExprs; }
619 bool foundAsmStmt() {
return FoundAsmStmt; }
621 void VisitCallExpr(
const CallExpr *E) { CallExprs.push_back(E); }
623 void VisitAsmStmt(
const AsmStmt *S) { FoundAsmStmt =
true; }
625 void Visit(
const Stmt *St) {
636 CallExprFinder CEF(S, St);
638 if (!CEF.foundCallExpr() && !CEF.foundAsmStmt()) {
639 S.
Diag(St->
getBeginLoc(), diag::warn_attribute_ignored_no_calls_in_stmt)
647 template <
typename OtherAttr,
int DiagIdx>
651 CallExprFinder OrigCEF(SemaRef, OrigSt);
652 CallExprFinder CEF(SemaRef, CurSt);
661 bool CanSuppressDiag =
662 OrigSt && CEF.getCallExprs().size() == OrigCEF.getCallExprs().size();
664 if (!CEF.foundCallExpr()) {
666 diag::warn_attribute_ignored_no_calls_in_stmt)
670 for (
const auto &Tup :
671 llvm::zip_longest(OrigCEF.getCallExprs(), CEF.getCallExprs())) {
675 if (!CanSuppressDiag || !(*std::get<0>(Tup))->getCalleeDecl()) {
676 const Decl *Callee = (*std::get<1>(Tup))->getCalleeDecl();
678 (Callee->hasAttr<OtherAttr>() || Callee->hasAttr<FlattenAttr>())) {
680 diag::warn_function_stmt_attribute_precedence)
681 << A << (Callee->hasAttr<OtherAttr>() ? DiagIdx : 1);
682 SemaRef.
Diag(Callee->getBeginLoc(), diag::note_conflicting_attribute);
692 return CheckStmtInlineAttr<AlwaysInlineAttr, 0>(*
this, OrigSt, CurSt, A);
697 return CheckStmtInlineAttr<NoInlineAttr, 2>(*
this, OrigSt, CurSt, A);
702 NoInlineAttr NIA(S.
Context, A);
703 if (!NIA.isStmtNoInline()) {
704 S.
Diag(St->
getBeginLoc(), diag::warn_function_attribute_ignored_in_stmt)
705 <<
"[[clang::noinline]]";
717 AlwaysInlineAttr AIA(S.
Context, A);
718 if (!AIA.isClangAlwaysInline()) {
719 S.
Diag(St->
getBeginLoc(), diag::warn_function_attribute_ignored_in_stmt)
720 <<
"[[clang::always_inline]]";
767 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
774 if (ArgVal < CodeAlignAttr::MinimumAlignment ||
775 ArgVal > CodeAlignAttr::MaximumAlignment || !ArgVal.isPowerOf2()) {
776 if (std::optional<int64_t>
Value = ArgVal.trySExtValue())
777 Diag(CI.
getLoc(), diag::err_attribute_power_of_two_in_range)
778 << CI << CodeAlignAttr::MinimumAlignment
779 << CodeAlignAttr::MaximumAlignment <<
Value.value();
781 Diag(CI.
getLoc(), diag::err_attribute_power_of_two_in_range)
782 << CI << CodeAlignAttr::MinimumAlignment
783 << CodeAlignAttr::MaximumAlignment << E;
787 return new (Context) CodeAlignAttr(Context, CI, E);
798 template <
typename LoopAttrT>
800 auto FindFunc = [](
const Attr *A) {
return isa<const LoopAttrT>(A); };
801 const auto *FirstItr = std::find_if(Attrs.begin(), Attrs.end(), FindFunc);
803 if (FirstItr == Attrs.end())
806 const auto *LastFoundItr = FirstItr;
807 std::optional<llvm::APSInt> FirstValue;
810 dyn_cast<ConstantExpr>(cast<LoopAttrT>(*FirstItr)->getAlignment());
816 while (Attrs.end() != (LastFoundItr = std::find_if(LastFoundItr + 1,
817 Attrs.end(), FindFunc))) {
819 dyn_cast<ConstantExpr>(cast<LoopAttrT>(*LastFoundItr)->getAlignment());
826 FirstValue = CAFA->getResultAsAPSInt();
828 if (FirstValue != SecondValue) {
829 S.
Diag((*LastFoundItr)->getLocation(), diag::err_loop_attr_conflict)
831 S.
Diag((*FirstItr)->getLocation(), diag::note_previous_attribute);
840 S.
Diag(A.
getLoc(), diag::warn_unknown_attribute_ignored)
847 #define WANT_STMT_MERGE_LOGIC
848 #include "clang/Sema/AttrParsedAttrImpl.inc"
849 #undef WANT_STMT_MERGE_LOGIC
856 if (Attrs.size() < 2)
860 if (!DiagnoseMutualExclusions(S, Attrs))
887 const LoopHintAttr *StateAttr;
888 const LoopHintAttr *NumericAttr;
889 } HintAttrs[CategoryType::NumberOfCategories] = {};
891 for (
const auto *I : Attrs) {
892 const LoopHintAttr *LH = dyn_cast<LoopHintAttr>(I);
898 CategoryType
Category = CategoryType::NumberOfCategories;
899 LoopHintAttr::OptionType Option = LH->getOption();
901 case LoopHintAttr::Vectorize:
902 case LoopHintAttr::VectorizeWidth:
905 case LoopHintAttr::Interleave:
906 case LoopHintAttr::InterleaveCount:
909 case LoopHintAttr::Unroll:
910 case LoopHintAttr::UnrollCount:
913 case LoopHintAttr::UnrollAndJam:
914 case LoopHintAttr::UnrollAndJamCount:
917 case LoopHintAttr::Distribute:
921 case LoopHintAttr::PipelineDisabled:
922 case LoopHintAttr::PipelineInitiationInterval:
925 case LoopHintAttr::VectorizePredicate:
930 assert(
Category != NumberOfCategories &&
"Unhandled loop hint option");
931 auto &CategoryState = HintAttrs[
Category];
932 const LoopHintAttr *PrevAttr;
933 if (Option == LoopHintAttr::Vectorize ||
934 Option == LoopHintAttr::Interleave || Option == LoopHintAttr::Unroll ||
935 Option == LoopHintAttr::UnrollAndJam ||
936 Option == LoopHintAttr::VectorizePredicate ||
937 Option == LoopHintAttr::PipelineDisabled ||
938 Option == LoopHintAttr::Distribute) {
940 PrevAttr = CategoryState.StateAttr;
941 CategoryState.StateAttr = LH;
944 PrevAttr = CategoryState.NumericAttr;
945 CategoryState.NumericAttr = LH;
952 S.
Diag(OptionLoc, diag::err_pragma_loop_compatibility)
953 <<
true << PrevAttr->getDiagnosticName(Policy)
954 << LH->getDiagnosticName(Policy);
956 if (CategoryState.StateAttr && CategoryState.NumericAttr &&
958 CategoryState.StateAttr->getState() == LoopHintAttr::Disable)) {
963 S.
Diag(OptionLoc, diag::err_pragma_loop_compatibility)
965 << CategoryState.StateAttr->getDiagnosticName(Policy)
966 << CategoryState.NumericAttr->getDiagnosticName(Policy);
971 template <
typename LoopAttrT>
975 bool isIntelFPGAAttr =
true) {
976 const LoopAttrT *LoopAttr =
nullptr;
978 for (
const auto *I : Attrs) {
979 if (LoopAttr && isa<LoopAttrT>(I)) {
981 S.
Diag(I->getLocation(), diag::err_sycl_loop_attr_duplication)
982 << isIntelFPGAAttr << LoopAttr;
984 if (isa<LoopAttrT>(I))
985 LoopAttr = cast<LoopAttrT>(I);
994 template <
typename LoopAttrT>
996 auto FindFunc = [](
const Attr *A) {
return isa<const LoopAttrT>(A); };
997 const auto *FirstItr = std::find_if(Attrs.begin(), Attrs.end(), FindFunc);
999 if (FirstItr == Attrs.end())
1002 const auto *LastFoundItr = FirstItr;
1003 std::optional<llvm::APSInt> FirstValue;
1006 dyn_cast<ConstantExpr>(cast<LoopAttrT>(*FirstItr)->getNExpr());
1012 while (Attrs.end() != (LastFoundItr = std::find_if(LastFoundItr + 1,
1013 Attrs.end(), FindFunc))) {
1015 dyn_cast<ConstantExpr>(cast<LoopAttrT>(*LastFoundItr)->getNExpr());
1022 FirstValue = CAFA->getResultAsAPSInt();
1024 if (FirstValue != SecondValue) {
1025 S.
Diag((*LastFoundItr)->getLocation(), diag::err_loop_attr_conflict)
1027 S.
Diag((*FirstItr)->getLocation(), diag::note_previous_attribute);
1035 CheckForDuplicateAttrs<SYCLIntelInitiationIntervalAttr>(S, Attrs);
1036 CheckForDuplicateAttrs<SYCLIntelMaxConcurrencyAttr>(S, Attrs);
1037 CheckForDuplicationSYCLLoopAttribute<SYCLIntelLoopCoalesceAttr>(S, Attrs);
1038 CheckForDuplicationSYCLLoopAttribute<SYCLIntelDisableLoopPipeliningAttr>(
1040 CheckForDuplicateAttrs<SYCLIntelMaxInterleavingAttr>(S, Attrs);
1041 CheckForDuplicateAttrs<SYCLIntelSpeculatedIterationsAttr>(S, Attrs);
1043 CheckForDuplicationSYCLLoopAttribute<LoopUnrollHintAttr>(S, Attrs,
false);
1045 CheckForDuplicationSYCLLoopAttribute<SYCLIntelNofusionAttr>(S, Attrs);
1046 CheckForDuplicateAttrs<SYCLIntelMaxReinvocationDelayAttr>(S, Attrs);
1047 CheckForDuplicationSYCLLoopAttribute<SYCLIntelEnableLoopPipeliningAttr>(
1057 const LoopUnrollHintAttr *AttrUnroll =
nullptr;
1058 const LoopHintAttr *PragmaUnroll =
nullptr;
1059 for (
const auto *I : Attrs) {
1060 if (
auto *LH = dyn_cast<LoopUnrollHintAttr>(I))
1062 if (
auto *LH = dyn_cast<LoopHintAttr>(I)) {
1063 LoopHintAttr::OptionType Opt = LH->getOption();
1064 if (Opt == LoopHintAttr::Unroll || Opt == LoopHintAttr::UnrollCount)
1069 if (AttrUnroll && PragmaUnroll) {
1072 S.
Diag(
Loc, diag::err_loop_unroll_compatibility)
1073 << PragmaUnroll->getDiagnosticName(Policy)
1074 << AttrUnroll->getDiagnosticName(Policy);
1080 unsigned *UnrollFactor =
nullptr) {
1084 return S.
Diag(E->
getExprLoc(), diag::err_attribute_argument_type)
1088 if (ArgVal->isNonPositive())
1090 diag::err_attribute_requires_positive_integer)
1094 *UnrollFactor = ArgVal->getZExtValue();
1102 ?
new (Context) LoopUnrollHintAttr(Context, A, E)
1106 OpenCLUnrollHintAttr *
1108 unsigned UnrollFactor = 0;
1110 ?
new (Context) OpenCLUnrollHintAttr(Context, A, UnrollFactor)
1128 llvm_unreachable(
"Unknown loop unroll hint");
1145 ? (
unsigned)diag::err_keyword_not_supported_on_target
1147 ? (
unsigned)diag::warn_unhandled_ms_attribute_ignored
1148 : (
unsigned)diag::warn_unknown_attribute_ignored)
1157 case ParsedAttr::AT_AlwaysInline:
1159 case ParsedAttr::AT_CXXAssume:
1161 case ParsedAttr::AT_FallThrough:
1163 case ParsedAttr::AT_LoopHint:
1165 case ParsedAttr::AT_SYCLIntelIVDep:
1167 case ParsedAttr::AT_SYCLIntelInitiationInterval:
1169 case ParsedAttr::AT_SYCLIntelMaxConcurrency:
1171 case ParsedAttr::AT_SYCLIntelLoopCoalesce:
1173 case ParsedAttr::AT_SYCLIntelDisableLoopPipelining:
1175 case ParsedAttr::AT_SYCLIntelMaxInterleaving:
1177 case ParsedAttr::AT_SYCLIntelSpeculatedIterations:
1179 case ParsedAttr::AT_SYCLIntelLoopCount:
1181 case ParsedAttr::AT_OpenCLUnrollHint:
1182 case ParsedAttr::AT_LoopUnrollHint:
1184 case ParsedAttr::AT_Suppress:
1186 case ParsedAttr::AT_NoMerge:
1188 case ParsedAttr::AT_NoInline:
1190 case ParsedAttr::AT_MustTail:
1192 case ParsedAttr::AT_Likely:
1194 case ParsedAttr::AT_Unlikely:
1196 case ParsedAttr::AT_SYCLIntelNofusion:
1198 case ParsedAttr::AT_SYCLIntelMaxReinvocationDelay:
1200 case ParsedAttr::AT_SYCLIntelEnableLoopPipelining:
1202 case ParsedAttr::AT_CodeAlign:
1204 case ParsedAttr::AT_MSConstexpr:
1220 OutAttrs.push_back(A);
1226 CheckForDuplicateLoopAttrs<CodeAlignAttr>(*
this, OutAttrs);
1231 CheckForDuplicateAttrs<SYCLIntelSpeculatedIterationsAttr>(*
this, Attrs);
1232 CheckForDuplicateAttrs<SYCLIntelMaxInterleavingAttr>(*
this, Attrs);
1233 CheckForDuplicateAttrs<SYCLIntelMaxReinvocationDelayAttr>(*
this, Attrs);
1234 CheckForDuplicateAttrs<SYCLIntelInitiationIntervalAttr>(*
this, Attrs);
1235 CheckForDuplicateAttrs<SYCLIntelMaxConcurrencyAttr>(*
this, Attrs);
1240 CheckForDuplicateLoopAttrs<CodeAlignAttr>(*
this, Attrs);
1247 Diag(A.
getLoc(), diag::err_attribute_wrong_number_arguments)
1254 if (DiagnoseUnexpandedParameterPack(Assumption)) {
1262 Assumption = Res.
get();
1275 ExprResult Res = CorrectDelayedTyposInExpr(Assumption);
1279 Res = CheckPlaceholderExpr(Res.
get());
1283 Res = PerformContextuallyConvertToBool(Res.
get());
1287 Assumption = Res.
get();
1290 << AttrName <<
Range;
Defines the clang::ASTContext interface.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
static Attr * handleUnlikely(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static void CheckForDuplicateLoopAttrs(Sema &S, ArrayRef< const Attr * > Attrs)
static Attr * handleSuppressAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static IVDepExprResult HandleIVDepAttrExpr(Sema &S, Expr *E, unsigned &SafelenValue)
static Attr * handleSYCLIntelMaxInterleavingAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static Attr * handleLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange)
static Attr * handleSYCLIntelInitiationIntervalAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static bool CheckLoopUnrollAttrExpr(Sema &S, Expr *E, const AttributeCommonInfo &A, unsigned *UnrollFactor=nullptr)
static Attr * handleSYCLIntelLoopCoalesceAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static void CheckForIncompatibleSYCLLoopAttributes(Sema &S, const SmallVectorImpl< const Attr * > &Attrs)
static Attr * handleMustTailAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleMSConstexprAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleSYCLIntelMaxConcurrencyAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static void CheckForDuplicateSYCLIntelLoopCountAttrs(Sema &S, ArrayRef< const Attr * > Attrs)
static Attr * handleIntelNofusionAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static void CheckForDuplicateAttrs(Sema &S, ArrayRef< const Attr * > Attrs)
static Attr * handleSYCLIntelEnableLoopPipeliningAttr(Sema &S, Stmt *, const ParsedAttr &A)
static Attr * handleFallThroughAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static void CheckForDuplicationSYCLLoopAttribute(Sema &S, const SmallVectorImpl< const Attr * > &Attrs, bool isIntelFPGAAttr=true)
static Attr * handleAlwaysInlineAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleSYCLIntelLoopCountAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static void FilterAttributeList(ArrayRef< const Attr * > Attrs, SmallVectorImpl< const T * > &FilteredAttrs)
static Attr * handleCXXAssumeAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleSYCLIntelDisableLoopPipeliningAttr(Sema &S, Stmt *, const ParsedAttr &A)
static Attr * handleCodeAlignAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static Attr * handleSYCLIntelMaxReinvocationDelayAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static Attr * handleNoMergeAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static void CheckForIncompatibleAttributes(Sema &S, const SmallVectorImpl< const Attr * > &Attrs)
static Attr * handleSYCLIntelSpeculatedIterationsAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static Attr * handleNoInlineAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static bool CheckStmtInlineAttr(Sema &SemaRef, const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
void CheckForIncompatibleUnrollHintAttributes(Sema &S, const SmallVectorImpl< const Attr * > &Attrs, SourceRange Range)
static Attr * handleIntelIVDepAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static Attr * handleLikely(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static void CheckRedundantSYCLIntelIVDepAttrs(Sema &S, ArrayRef< const Attr * > Attrs)
static bool checkSYCLIntelIVDepSafeLen(Sema &S, llvm::APSInt &Value, Expr *E)
static Attr * handleLoopUnrollHint(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Defines the SourceManager interface.
const LangOptions & getLangOpts() const
const TargetInfo & getTargetInfo() const
const TargetInfo * getAuxTargetInfo() const
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
Attr - This represents one attribute.
SourceLocation getLocation() const
bool isCXX11Attribute() const
bool isDeclspecAttribute() const
SourceRange getRange() const
unsigned getAttributeSpellingListIndex() const
const IdentifierInfo * getAttrName() const
bool isRegularKeywordAttribute() const
SourceLocation getLoc() const
const IdentifierInfo * getScopeName() const
Kind getParsedKind() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
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.
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.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
ParsedAttr - Represents a syntactic attribute.
IdentifierLoc * getArgAsIdent(unsigned Arg) const
bool existsInTarget(const TargetInfo &Target) const
Expr * getArgAsExpr(unsigned Arg) const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
AttributeCommonInfo::Kind getKind() const
bool isArgExpr(unsigned Arg) const
ParsedAttributes - A collection of parsed attributes.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Sema - This implements semantic analysis and AST building for C.
void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs, SmallVectorImpl< const Attr * > &OutAttrs)
Process the attributes before creating an attributed statement.
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 ...
ExprResult BuildCXXAssumeExpr(Expr *Assumption, const IdentifierInfo *AttrName, SourceRange Range)
SYCLIntelInitiationIntervalAttr * BuildSYCLIntelInitiationIntervalAttr(const AttributeCommonInfo &CI, Expr *E)
LoopUnrollHintAttr * BuildLoopUnrollHintAttr(const AttributeCommonInfo &A, Expr *E)
SYCLIntelMaxConcurrencyAttr * BuildSYCLIntelMaxConcurrencyAttr(const AttributeCommonInfo &CI, Expr *E)
OpenCLUnrollHintAttr * BuildOpenCLLoopUnrollHintAttr(const AttributeCommonInfo &A, Expr *E)
SYCLIntelSpeculatedIterationsAttr * BuildSYCLIntelSpeculatedIterationsAttr(const AttributeCommonInfo &CI, Expr *E)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
void CheckDeprecatedSYCLAttributeSpelling(const ParsedAttr &A, StringRef NewName="")
Diagnoses an attribute in the 'intelfpga' namespace and suggests using the attribute in the 'intel' n...
const LangOptions & getLangOpts() const
SYCLIntelMaxReinvocationDelayAttr * BuildSYCLIntelMaxReinvocationDelayAttr(const AttributeCommonInfo &CI, Expr *E)
SYCLIntelMaxInterleavingAttr * BuildSYCLIntelMaxInterleavingAttr(const AttributeCommonInfo &CI, Expr *E)
SYCLIntelIVDepAttr * BuildSYCLIntelIVDepAttr(const AttributeCommonInfo &CI, Expr *Expr1, Expr *Expr2)
SYCLIntelLoopCoalesceAttr * BuildSYCLIntelLoopCoalesceAttr(const AttributeCommonInfo &CI, Expr *E)
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
bool CheckRebuiltStmtAttributes(ArrayRef< const Attr * > Attrs)
bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
bool CheckRebuiltAttributedStmtAttributes(ArrayRef< const Attr * > Attrs)
bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
ExprResult ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A, SourceRange Range)
ASTContext & getASTContext() const
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
sema::FunctionScopeInfo * getCurFunction() const
DeclContext * getCurLexicalContext() const
SYCLIntelLoopCountAttr * BuildSYCLIntelLoopCountAttr(const AttributeCommonInfo &CI, Expr *E)
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
RetTy Visit(PTR(Stmt) S, ParamTys... P)
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
Exposes information about the current target.
bool isPointerType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Defines the clang::TargetInfo interface.
constexpr XRayInstrMask None
bool Cast(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
@ AANT_ArgumentIntegerConstant
const FunctionProtoType * T
@ Other
Other implicit parameter.
Wraps an identifier and optional source location for the identifier.
Describes how types, statements, expressions, and declarations should be printed.