clang: lib/Sema/SemaStmtAttr.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
19#include
20
21using namespace clang;
22using namespace sema;
23
31 S.Diag(L, diag::note_fallthrough_insert_semi_fixit)
33 return nullptr;
34 }
36 if (FnScope->SwitchStack.empty()) {
38 return nullptr;
39 }
40
41
42
45 S.Diag(A.getLoc(), diag::ext_cxx17_attr) << A;
46
47 FnScope->setHasFallthroughStmt();
48 return ::new (S.Context) FallThroughAttr(S.Context, A);
49}
50
55
56 S.Diag(A.getLoc(), diag::err_attribute_too_few_arguments) << A << 1;
57 return nullptr;
58 }
59
60 std::vector DiagnosticIdentifiers;
61 for (unsigned I = 0, E = A.getNumArgs(); I != E; ++I) {
62 StringRef RuleName;
63
65 return nullptr;
66
67 DiagnosticIdentifiers.push_back(RuleName);
68 }
69
70 return ::new (S.Context) SuppressAttr(
71 S.Context, A, DiagnosticIdentifiers.data(), DiagnosticIdentifiers.size());
72}
73
80
81 StringRef PragmaName =
82 llvm::StringSwitch(
84 .Cases({"unroll", "nounroll", "unroll_and_jam", "nounroll_and_jam"},
86 .Default("clang loop");
87
88
89
90
92 std::string Pragma = "#pragma " + std::string(PragmaName);
93 S.Diag(St->getBeginLoc(), diag::err_pragma_loop_precedes_nonloop) << Pragma;
94 return nullptr;
95 }
96
97 LoopHintAttr::OptionType Option;
98 LoopHintAttr::LoopHintState State;
99
100 auto SetHints = [&Option, &State](LoopHintAttr::OptionType O,
101 LoopHintAttr::LoopHintState S) {
102 Option = O;
103 State = S;
104 };
105
106 if (PragmaName == "nounroll") {
107 SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
108 } else if (PragmaName == "unroll") {
109
110 if (ValueExpr) {
114 SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
115 else
116 SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Numeric);
117 } else
118 SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Numeric);
119 } else
120 SetHints(LoopHintAttr::Unroll, LoopHintAttr::Enable);
121 } else if (PragmaName == "nounroll_and_jam") {
122 SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Disable);
123 } else if (PragmaName == "unroll_and_jam") {
124
125 if (ValueExpr)
126 SetHints(LoopHintAttr::UnrollAndJamCount, LoopHintAttr::Numeric);
127 else
128 SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Enable);
129 } else {
130
132 "Attribute must have valid option info.");
133 Option = llvm::StringSwitchLoopHintAttr::OptionType(
135 .Case("vectorize", LoopHintAttr::Vectorize)
136 .Case("vectorize_width", LoopHintAttr::VectorizeWidth)
137 .Case("interleave", LoopHintAttr::Interleave)
138 .Case("vectorize_predicate", LoopHintAttr::VectorizePredicate)
139 .Case("interleave_count", LoopHintAttr::InterleaveCount)
140 .Case("unroll", LoopHintAttr::Unroll)
141 .Case("unroll_count", LoopHintAttr::UnrollCount)
142 .Case("pipeline", LoopHintAttr::PipelineDisabled)
143 .Case("pipeline_initiation_interval",
144 LoopHintAttr::PipelineInitiationInterval)
145 .Case("distribute", LoopHintAttr::Distribute)
146 .Default(LoopHintAttr::Vectorize);
147 if (Option == LoopHintAttr::VectorizeWidth) {
148 assert((ValueExpr || (StateLoc && StateLoc->getIdentifierInfo())) &&
149 "Attribute must have a valid value expression or argument.");
151 false))
152 return nullptr;
155 State = LoopHintAttr::ScalableWidth;
156 else
157 State = LoopHintAttr::FixedWidth;
158 } else if (Option == LoopHintAttr::InterleaveCount ||
159 Option == LoopHintAttr::UnrollCount ||
160 Option == LoopHintAttr::PipelineInitiationInterval) {
161 assert(ValueExpr && "Attribute must have a valid value expression.");
163 false))
164 return nullptr;
165 State = LoopHintAttr::Numeric;
166 } else if (Option == LoopHintAttr::Vectorize ||
167 Option == LoopHintAttr::Interleave ||
168 Option == LoopHintAttr::VectorizePredicate ||
169 Option == LoopHintAttr::Unroll ||
170 Option == LoopHintAttr::Distribute ||
171 Option == LoopHintAttr::PipelineDisabled) {
173 "Loop hint must have an argument");
175 State = LoopHintAttr::Disable;
177 State = LoopHintAttr::AssumeSafety;
179 State = LoopHintAttr::Full;
181 State = LoopHintAttr::Enable;
182 else
183 llvm_unreachable("bad loop hint argument");
184 } else
185 llvm_unreachable("bad loop hint");
186 }
187
188 return LoopHintAttr::CreateImplicit(S.Context, Option, State, ValueExpr, A);
189}
190
191namespace {
193 bool FoundAsmStmt = false;
194 std::vector<const CallExpr *> CallExprs;
195
196public:
197 typedef ConstEvaluatedExprVisitor Inherited;
198
199 CallExprFinder(Sema &S, const Stmt *St) : Inherited(S.Context) { Visit(St); }
200
201 bool foundCallExpr() { return !CallExprs.empty(); }
202 const std::vector<const CallExpr *> &getCallExprs() { return CallExprs; }
203
204 bool foundAsmStmt() { return FoundAsmStmt; }
205
206 void VisitCallExpr(const CallExpr *E) { CallExprs.push_back(E); }
207
208 void VisitAsmStmt(const AsmStmt *S) { FoundAsmStmt = true; }
209
210 void Visit(const Stmt *St) {
211 if (!St)
212 return;
213 ConstEvaluatedExprVisitor::Visit(St);
214 }
215};
216}
217
220 CallExprFinder CEF(S, St);
221
222 if (!CEF.foundCallExpr() && !CEF.foundAsmStmt()) {
223 S.Diag(St->getBeginLoc(), diag::warn_attribute_ignored_no_calls_in_stmt)
224 << A;
225 return nullptr;
226 }
227
229}
230
233 CallExprFinder CEF(S, St);
234
235 if (!CEF.foundCallExpr() && !CEF.foundAsmStmt()) {
236 S.Diag(St->getBeginLoc(), diag::warn_attribute_ignored_no_calls_in_stmt)
237 << A;
238 return nullptr;
239 }
240
241 return ::new (S.Context) NoConvergentAttr(S.Context, A);
242}
243
244template <typename OtherAttr, int DiagIdx>
246 const Stmt *CurSt,
248 CallExprFinder OrigCEF(SemaRef, OrigSt);
249 CallExprFinder CEF(SemaRef, CurSt);
250
251
252
253
254
255
256
257
258 bool CanSuppressDiag =
259 OrigSt && CEF.getCallExprs().size() == OrigCEF.getCallExprs().size();
260
261 if (!CEF.foundCallExpr()) {
263 diag::warn_attribute_ignored_no_calls_in_stmt)
264 << A;
265 }
266
267 for (const auto &Tup :
268 llvm::zip_longest(OrigCEF.getCallExprs(), CEF.getCallExprs())) {
269
270
271
272 if (!CanSuppressDiag || !(*std::get<0>(Tup))->getCalleeDecl()) {
273 const Decl *Callee = (*std::get<1>(Tup))->getCalleeDecl();
274 if (Callee &&
275 (Callee->hasAttr() || Callee->hasAttr())) {
277 diag::warn_function_stmt_attribute_precedence)
278 << A << (Callee->hasAttr() ? DiagIdx : 1);
279 SemaRef.Diag(Callee->getBeginLoc(), diag::note_conflicting_attribute);
280 }
281 }
282 }
283
284 return false;
285}
286
291
296
299 NoInlineAttr NIA(S.Context, A);
300 if (!NIA.isStmtNoInline()) {
301 S.Diag(St->getBeginLoc(), diag::warn_function_attribute_ignored_in_stmt)
302 << "[[clang::noinline]]";
303 return nullptr;
304 }
305
307 return nullptr;
308
310}
311
314 AlwaysInlineAttr AIA(S.Context, A);
315 if (!AIA.isClangAlwaysInline()) {
316 S.Diag(St->getBeginLoc(), diag::warn_function_attribute_ignored_in_stmt)
317 << "[[clang::always_inline]]";
318 return nullptr;
319 }
320
322 return nullptr;
323
324 return ::new (S.Context) AlwaysInlineAttr(S.Context, A);
325}
326
331 return nullptr;
332
334}
335
341
344
346 S.Diag(A.getLoc(), diag::ext_cxx20_attr) << A << Range;
347
349}
350
353
355 S.Diag(A.getLoc(), diag::ext_cxx20_attr) << A << Range;
356
358}
359
363 llvm::APSInt ArgVal;
366 return nullptr;
367 E = Res.get();
368
369
370
371 if (ArgVal < CodeAlignAttr::MinimumAlignment ||
372 ArgVal > CodeAlignAttr::MaximumAlignment || !ArgVal.isPowerOf2()) {
373 if (std::optional<int64_t> Value = ArgVal.trySExtValue())
374 Diag(CI.getLoc(), diag::err_attribute_power_of_two_in_range)
375 << CI << CodeAlignAttr::MinimumAlignment
376 << CodeAlignAttr::MaximumAlignment << Value.value();
377 else
378 Diag(CI.getLoc(), diag::err_attribute_power_of_two_in_range)
379 << CI << CodeAlignAttr::MinimumAlignment
380 << CodeAlignAttr::MaximumAlignment << E;
381 return nullptr;
382 }
383 }
385}
386
392
393
394
395template
398 const auto *FirstItr = llvm::find_if(Attrs, FindFunc);
399
400 if (FirstItr == Attrs.end())
401 return;
402
403 const auto *LastFoundItr = FirstItr;
404 std::optionalllvm::APSInt FirstValue;
405
406 const auto *CAFA =
407 dyn_cast(cast(*FirstItr)->getAlignment());
408
409
410 if (!CAFA)
411 return;
412
413 while (Attrs.end() != (LastFoundItr = std::find_if(LastFoundItr + 1,
414 Attrs.end(), FindFunc))) {
415 const auto *CASA =
416 dyn_cast(cast(*LastFoundItr)->getAlignment());
417
418 if (!CASA)
419 return;
420
421 llvm::APSInt SecondValue = CASA->getResultAsAPSInt();
422 if (!FirstValue)
423 FirstValue = CAFA->getResultAsAPSInt();
424
425 if (FirstValue != SecondValue) {
426 S.Diag((*LastFoundItr)->getLocation(), diag::err_loop_attr_conflict)
427 << *FirstItr;
428 S.Diag((*FirstItr)->getLocation(), diag::note_previous_attribute);
429 }
430 }
431}
432
436 S.Diag(A.getLoc(), diag::warn_unknown_attribute_ignored)
438 return nullptr;
439 }
440 return ::new (S.Context) MSConstexprAttr(S.Context, A);
441}
442
443#define WANT_STMT_MERGE_LOGIC
444#include "clang/Sema/AttrParsedAttrImpl.inc"
445#undef WANT_STMT_MERGE_LOGIC
446
447static void
450
451
452 if (Attrs.size() < 2)
453 return;
454
455
456 if (!DiagnoseMutualExclusions(S, Attrs))
457 return;
458
459 enum CategoryType {
460
461
462
463
464 Vectorize,
465 Interleave,
466 UnrollAndJam,
467 Pipeline,
468
469
470 Unroll,
471
472
473 Distribute,
474
475
476 VectorizePredicate,
477
478 NumberOfCategories
479 };
480
481
482 struct {
483 const LoopHintAttr *StateAttr;
484 const LoopHintAttr *NumericAttr;
485 } HintAttrs[CategoryType::NumberOfCategories] = {};
486
487 for (const auto *I : Attrs) {
488 const LoopHintAttr *LH = dyn_cast(I);
489
490
491 if (!LH)
492 continue;
493
494 CategoryType Category = CategoryType::NumberOfCategories;
495 LoopHintAttr::OptionType Option = LH->getOption();
496 switch (Option) {
497 case LoopHintAttr::Vectorize:
498 case LoopHintAttr::VectorizeWidth:
499 Category = Vectorize;
500 break;
501 case LoopHintAttr::Interleave:
502 case LoopHintAttr::InterleaveCount:
503 Category = Interleave;
504 break;
505 case LoopHintAttr::Unroll:
506 case LoopHintAttr::UnrollCount:
507 Category = Unroll;
508 break;
509 case LoopHintAttr::UnrollAndJam:
510 case LoopHintAttr::UnrollAndJamCount:
511 Category = UnrollAndJam;
512 break;
513 case LoopHintAttr::Distribute:
514
515 Category = Distribute;
516 break;
517 case LoopHintAttr::PipelineDisabled:
518 case LoopHintAttr::PipelineInitiationInterval:
519 Category = Pipeline;
520 break;
521 case LoopHintAttr::VectorizePredicate:
522 Category = VectorizePredicate;
523 break;
524 };
525
526 assert(Category != NumberOfCategories && "Unhandled loop hint option");
527 auto &CategoryState = HintAttrs[Category];
528 const LoopHintAttr *PrevAttr;
529 if (Option == LoopHintAttr::Vectorize ||
530 Option == LoopHintAttr::Interleave || Option == LoopHintAttr::Unroll ||
531 Option == LoopHintAttr::UnrollAndJam ||
532 Option == LoopHintAttr::VectorizePredicate ||
533 Option == LoopHintAttr::PipelineDisabled ||
534 Option == LoopHintAttr::Distribute) {
535
536 PrevAttr = CategoryState.StateAttr;
537 CategoryState.StateAttr = LH;
538 } else {
539
540 PrevAttr = CategoryState.NumericAttr;
541 CategoryState.NumericAttr = LH;
542 }
543
545 SourceLocation OptionLoc = LH->getRange().getBegin();
546 if (PrevAttr)
547
548 S.Diag(OptionLoc, diag::err_pragma_loop_compatibility)
549 << true << PrevAttr->getDiagnosticName(Policy)
550 << LH->getDiagnosticName(Policy);
551
552 if (CategoryState.StateAttr && CategoryState.NumericAttr &&
553 (Category == Unroll || Category == UnrollAndJam ||
554 CategoryState.StateAttr->getState() == LoopHintAttr::Disable)) {
555
556
557
558
559 S.Diag(OptionLoc, diag::err_pragma_loop_compatibility)
560 << false
561 << CategoryState.StateAttr->getDiagnosticName(Policy)
562 << CategoryState.NumericAttr->getDiagnosticName(Policy);
563 }
564 }
565}
566
569
570
571
572
573
574 unsigned UnrollFactor = 0;
577 std::optionalllvm::APSInt ArgVal;
578
580 S.Diag(A.getLoc(), diag::err_attribute_argument_type)
582 return nullptr;
583 }
584
585 int Val = ArgVal->getSExtValue();
586 if (Val <= 0) {
588 diag::err_attribute_requires_positive_integer)
589 << A << 0;
590 return nullptr;
591 }
592 UnrollFactor = static_cast<unsigned>(Val);
593 }
594
595 return ::new (S.Context) OpenCLUnrollHintAttr(S.Context, A, UnrollFactor);
596}
597
600
601 if (A.getSemanticSpelling() == HLSLLoopHintAttr::Spelling::Microsoft_loop &&
603 return nullptr;
604
605 unsigned UnrollFactor = 0;
608
610 false))
611 return nullptr;
612
614
615 assert(ArgVal != std::nullopt && "ArgVal should be an integer constant.");
616 int Val = ArgVal->getSExtValue();
617
618 assert(Val > 0 && "Val should be a positive integer greater than zero.");
619 UnrollFactor = static_cast<unsigned>(Val);
620 }
621 return ::new (S.Context) HLSLLoopHintAttr(S.Context, A, UnrollFactor);
622}
623
626
627 return ::new (S.Context) HLSLControlFlowHintAttr(S.Context, A);
628}
629
633 return nullptr;
634
636 for (unsigned ArgIndex = 0; ArgIndex < AL.getNumArgs(); ++ArgIndex) {
637 AtomicAttr::ConsumedOption Option;
638 StringRef OptionString;
640
643 diag::err_attribute_argument_type)
645 return nullptr;
646 }
647
650 Loc = Ident->getLoc();
651 if (!AtomicAttr::ConvertStrToConsumedOption(OptionString, Option)) {
652 S.Diag(Loc, diag::err_attribute_invalid_atomic_argument) << OptionString;
653 return nullptr;
654 }
655 Options.push_back(Option);
656 }
657
659 AtomicAttr(S.Context, AL, Options.data(), Options.size());
660}
661
665 return nullptr;
666
667
668
669
676 S.Diag(A.getLoc(), diag::err_keyword_not_supported_on_target)
679 S.Diag(A.getLoc(), diag::warn_unhandled_ms_attribute_ignored)
681 } else {
683 }
684 return nullptr;
685 }
686
688 return nullptr;
689
691 case ParsedAttr::AT_AlwaysInline:
693 case ParsedAttr::AT_CXXAssume:
695 case ParsedAttr::AT_FallThrough:
697 case ParsedAttr::AT_LoopHint:
699 case ParsedAttr::AT_HLSLLoopHint:
701 case ParsedAttr::AT_HLSLControlFlowHint:
703 case ParsedAttr::AT_OpenCLUnrollHint:
705 case ParsedAttr::AT_Suppress:
707 case ParsedAttr::AT_NoMerge:
709 case ParsedAttr::AT_NoInline:
711 case ParsedAttr::AT_MustTail:
713 case ParsedAttr::AT_Likely:
715 case ParsedAttr::AT_Unlikely:
717 case ParsedAttr::AT_CodeAlign:
719 case ParsedAttr::AT_MSConstexpr:
721 case ParsedAttr::AT_NoConvergent:
723 case ParsedAttr::AT_Annotate:
725 case ParsedAttr::AT_Atomic:
727 default:
728 if (Attr *AT = nullptr; A.getInfo().handleStmtAttribute(S, St, A, AT) !=
730 return AT;
731 }
732
733
734
737 return nullptr;
738 }
739}
740
743 for (const ParsedAttr &AL : InAttrs) {
745 OutAttrs.push_back(A);
746 }
747
750}
751
756
760 Diag(A.getLoc(), diag::err_attribute_wrong_number_arguments)
763 }
764
766
769 }
770
771 if (Assumption->getDependence() == ExprDependence::None) {
775 Assumption = Res.get();
776 }
777
780 Diag(A.getLoc(), diag::ext_cxx23_attr) << A << Range;
781
782 return Assumption;
783}
784
788 if (!Assumption)
790
794
798
802
803 Assumption = Res.get();
805 Diag(Assumption->getBeginLoc(), diag::warn_assume_side_effects)
806 << AttrName << Range;
807
808 return Assumption;
809}
Defines the clang::ASTContext interface.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static void handleNoMergeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSConstexprAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSuppressAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static Attr * handleNoConvergentAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:231
static void CheckForDuplicateLoopAttrs(Sema &S, ArrayRef< const Attr * > Attrs)
Definition SemaStmtAttr.cpp:396
static Attr * handleMustTailAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:336
static Attr * handleCXXAssumeAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:327
static Attr * ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:662
static Attr * handleLikely(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:342
static Attr * handleNoMergeAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:218
static Attr * handleOpenCLUnrollHint(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:567
static Attr * handleLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange)
Definition SemaStmtAttr.cpp:74
static Attr * handleAtomicAttr(Sema &S, Stmt *St, const ParsedAttr &AL, SourceRange Range)
Definition SemaStmtAttr.cpp:630
static void CheckForIncompatibleAttributes(Sema &S, const SmallVectorImpl< const Attr * > &Attrs)
Definition SemaStmtAttr.cpp:448
static Attr * handleHLSLControlFlowHint(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:624
static bool CheckStmtInlineAttr(Sema &SemaRef, const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
Definition SemaStmtAttr.cpp:245
static Attr * handleHLSLLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:598
static Attr * handleCodeAlignAttr(Sema &S, Stmt *St, const ParsedAttr &A)
Definition SemaStmtAttr.cpp:387
static Attr * handleFallThroughAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:24
static Attr * handleSuppressAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:51
static Attr * handleUnlikely(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:351
static Attr * handleNoInlineAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:297
const LangOptions & getLangOpts() const
const TargetInfo * getAuxTargetInfo() const
const TargetInfo & getTargetInfo() const
Attr - This represents one attribute.
bool isCXX11Attribute() const
bool isDeclspecAttribute() const
SourceRange getRange() const
unsigned getAttributeSpellingListIndex() const
const IdentifierInfo * getScopeName() const
bool isRegularKeywordAttribute() const
SourceLocation getLoc() const
const IdentifierInfo * getAttrName() const
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
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) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
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.
A simple pair of identifier info and location.
SourceLocation getLoc() const
IdentifierInfo * getIdentifierInfo() const
bool isCompatibleWithMSVC() const
ParsedAttr - Represents a syntactic attribute.
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
bool existsInTarget(const TargetInfo &Target) const
IdentifierLoc * getArgAsIdent(unsigned Arg) const
const ParsedAttrInfo & getInfo() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
bool isArgIdent(unsigned Arg) const
Expr * getArgAsExpr(unsigned Arg) const
bool checkAtLeastNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at least as many args as Num.
AttributeCommonInfo::Kind getKind() const
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
ParsedAttributes - A collection of parsed attributes.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
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.
Definition SemaStmtAttr.cpp:741
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)
Definition SemaStmtAttr.cpp:785
ASTContext & getASTContext() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const LangOptions & getLangOpts() const
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
sema::FunctionScopeInfo * getCurFunction() const
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
bool CheckRebuiltStmtAttributes(ArrayRef< const Attr * > Attrs)
Definition SemaStmtAttr.cpp:752
bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
Definition SemaStmtAttr.cpp:287
bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
Definition SemaStmtAttr.cpp:292
void DiagnoseUnknownAttribute(const ParsedAttr &AL)
ExprResult ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A, SourceRange Range)
Definition SemaStmtAttr.cpp:757
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
Attr * CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
Definition SemaStmtAttr.cpp:360
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
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.
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
@ AANT_ArgumentIntegerConstant
@ AANT_ArgumentIdentifier
U cast(CodeGen::Address addr)
ActionResult< Expr * > ExprResult
Describes how types, statements, expressions, and declarations should be printed.