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
27 if (isa(St)) {
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(PragmaNameLoc->Ident->getName())
83 .Cases("unroll", "nounroll", "unroll_and_jam", "nounroll_and_jam",
85 .Default("clang loop");
86
87
88
89
90 if (!isa<DoStmt, ForStmt, CXXForRangeStmt, WhileStmt>(St)) {
91 std::string Pragma = "#pragma " + std::string(PragmaName);
92 S.Diag(St->getBeginLoc(), diag::err_pragma_loop_precedes_nonloop) << Pragma;
93 return nullptr;
94 }
95
96 LoopHintAttr::OptionType Option;
97 LoopHintAttr::LoopHintState State;
98
99 auto SetHints = [&Option, &State](LoopHintAttr::OptionType O,
100 LoopHintAttr::LoopHintState S) {
101 Option = O;
102 State = S;
103 };
104
105 if (PragmaName == "nounroll") {
106 SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
107 } else if (PragmaName == "unroll") {
108
109 if (ValueExpr) {
113 SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
114 else
115 SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Numeric);
116 } else
117 SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Numeric);
118 } else
119 SetHints(LoopHintAttr::Unroll, LoopHintAttr::Enable);
120 } else if (PragmaName == "nounroll_and_jam") {
121 SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Disable);
122 } else if (PragmaName == "unroll_and_jam") {
123
124 if (ValueExpr)
125 SetHints(LoopHintAttr::UnrollAndJamCount, LoopHintAttr::Numeric);
126 else
127 SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Enable);
128 } else {
129
130 assert(OptionLoc && OptionLoc->Ident &&
131 "Attribute must have valid option info.");
132 Option = llvm::StringSwitchLoopHintAttr::OptionType(
134 .Case("vectorize", LoopHintAttr::Vectorize)
135 .Case("vectorize_width", LoopHintAttr::VectorizeWidth)
136 .Case("interleave", LoopHintAttr::Interleave)
137 .Case("vectorize_predicate", LoopHintAttr::VectorizePredicate)
138 .Case("interleave_count", LoopHintAttr::InterleaveCount)
139 .Case("unroll", LoopHintAttr::Unroll)
140 .Case("unroll_count", LoopHintAttr::UnrollCount)
141 .Case("pipeline", LoopHintAttr::PipelineDisabled)
142 .Case("pipeline_initiation_interval",
143 LoopHintAttr::PipelineInitiationInterval)
144 .Case("distribute", LoopHintAttr::Distribute)
145 .Default(LoopHintAttr::Vectorize);
146 if (Option == LoopHintAttr::VectorizeWidth) {
147 assert((ValueExpr || (StateLoc && StateLoc->Ident)) &&
148 "Attribute must have a valid value expression or argument.");
150 false))
151 return nullptr;
152 if (StateLoc && StateLoc->Ident && StateLoc->Ident->isStr("scalable"))
153 State = LoopHintAttr::ScalableWidth;
154 else
155 State = LoopHintAttr::FixedWidth;
156 } else if (Option == LoopHintAttr::InterleaveCount ||
157 Option == LoopHintAttr::UnrollCount ||
158 Option == LoopHintAttr::PipelineInitiationInterval) {
159 assert(ValueExpr && "Attribute must have a valid value expression.");
161 false))
162 return nullptr;
163 State = LoopHintAttr::Numeric;
164 } else if (Option == LoopHintAttr::Vectorize ||
165 Option == LoopHintAttr::Interleave ||
166 Option == LoopHintAttr::VectorizePredicate ||
167 Option == LoopHintAttr::Unroll ||
168 Option == LoopHintAttr::Distribute ||
169 Option == LoopHintAttr::PipelineDisabled) {
170 assert(StateLoc && StateLoc->Ident && "Loop hint must have an argument");
171 if (StateLoc->Ident->isStr("disable"))
172 State = LoopHintAttr::Disable;
173 else if (StateLoc->Ident->isStr("assume_safety"))
174 State = LoopHintAttr::AssumeSafety;
175 else if (StateLoc->Ident->isStr("full"))
176 State = LoopHintAttr::Full;
177 else if (StateLoc->Ident->isStr("enable"))
178 State = LoopHintAttr::Enable;
179 else
180 llvm_unreachable("bad loop hint argument");
181 } else
182 llvm_unreachable("bad loop hint");
183 }
184
185 return LoopHintAttr::CreateImplicit(S.Context, Option, State, ValueExpr, A);
186}
187
188namespace {
190 bool FoundAsmStmt = false;
191 std::vector<const CallExpr *> CallExprs;
192
193public:
195
196 CallExprFinder(Sema &S, const Stmt *St) : Inherited(S.Context) { Visit(St); }
197
198 bool foundCallExpr() { return !CallExprs.empty(); }
199 const std::vector<const CallExpr *> &getCallExprs() { return CallExprs; }
200
201 bool foundAsmStmt() { return FoundAsmStmt; }
202
204
205 void VisitAsmStmt(const AsmStmt *S) { FoundAsmStmt = true; }
206
208 if (!St)
209 return;
211 }
212};
213}
214
217 CallExprFinder CEF(S, St);
218
219 if (!CEF.foundCallExpr() && !CEF.foundAsmStmt()) {
220 S.Diag(St->getBeginLoc(), diag::warn_attribute_ignored_no_calls_in_stmt)
221 << A;
222 return nullptr;
223 }
224
226}
227
230 CallExprFinder CEF(S, St);
231
232 if (!CEF.foundCallExpr() && !CEF.foundAsmStmt()) {
233 S.Diag(St->getBeginLoc(), diag::warn_attribute_ignored_no_calls_in_stmt)
234 << A;
235 return nullptr;
236 }
237
238 return ::new (S.Context) NoConvergentAttr(S.Context, A);
239}
240
241template <typename OtherAttr, int DiagIdx>
243 const Stmt *CurSt,
245 CallExprFinder OrigCEF(SemaRef, OrigSt);
246 CallExprFinder CEF(SemaRef, CurSt);
247
248
249
250
251
252
253
254
255 bool CanSuppressDiag =
256 OrigSt && CEF.getCallExprs().size() == OrigCEF.getCallExprs().size();
257
258 if (!CEF.foundCallExpr()) {
260 diag::warn_attribute_ignored_no_calls_in_stmt)
261 << A;
262 }
263
264 for (const auto &Tup :
265 llvm::zip_longest(OrigCEF.getCallExprs(), CEF.getCallExprs())) {
266
267
268
269 if (!CanSuppressDiag || !(*std::get<0>(Tup))->getCalleeDecl()) {
270 const Decl *Callee = (*std::get<1>(Tup))->getCalleeDecl();
271 if (Callee &&
272 (Callee->hasAttr() || Callee->hasAttr())) {
274 diag::warn_function_stmt_attribute_precedence)
275 << A << (Callee->hasAttr() ? DiagIdx : 1);
276 SemaRef.Diag(Callee->getBeginLoc(), diag::note_conflicting_attribute);
277 }
278 }
279 }
280
281 return false;
282}
283
286 return CheckStmtInlineAttr<AlwaysInlineAttr, 0>(*this, OrigSt, CurSt, A);
287}
288
291 return CheckStmtInlineAttr<NoInlineAttr, 2>(*this, OrigSt, CurSt, A);
292}
293
296 NoInlineAttr NIA(S.Context, A);
297 if (!NIA.isStmtNoInline()) {
298 S.Diag(St->getBeginLoc(), diag::warn_function_attribute_ignored_in_stmt)
299 << "[[clang::noinline]]";
300 return nullptr;
301 }
302
304 return nullptr;
305
307}
308
311 AlwaysInlineAttr AIA(S.Context, A);
312 if (!AIA.isClangAlwaysInline()) {
313 S.Diag(St->getBeginLoc(), diag::warn_function_attribute_ignored_in_stmt)
314 << "[[clang::always_inline]]";
315 return nullptr;
316 }
317
319 return nullptr;
320
321 return ::new (S.Context) AlwaysInlineAttr(S.Context, A);
322}
323
328 return nullptr;
329
331}
332
335
337}
338
341
344
346}
347
350
353
355}
356
360 llvm::APSInt ArgVal;
363 return nullptr;
365
366
367
368 if (ArgVal < CodeAlignAttr::MinimumAlignment ||
369 ArgVal > CodeAlignAttr::MaximumAlignment || !ArgVal.isPowerOf2()) {
370 if (std::optional<int64_t> Value = ArgVal.trySExtValue())
371 Diag(CI.getLoc(), diag::err_attribute_power_of_two_in_range)
372 << CI << CodeAlignAttr::MinimumAlignment
373 << CodeAlignAttr::MaximumAlignment << Value.value();
374 else
375 Diag(CI.getLoc(), diag::err_attribute_power_of_two_in_range)
376 << CI << CodeAlignAttr::MinimumAlignment
377 << CodeAlignAttr::MaximumAlignment << E;
378 return nullptr;
379 }
380 }
382}
383
385
388}
389
390
391
392template
394 auto FindFunc = [](const Attr *A) { return isa(A); };
395 const auto *FirstItr = std::find_if(Attrs.begin(), Attrs.end(), FindFunc);
396
397 if (FirstItr == Attrs.end())
398 return;
399
400 const auto *LastFoundItr = FirstItr;
401 std::optionalllvm::APSInt FirstValue;
402
403 const auto *CAFA =
404 dyn_cast(cast(*FirstItr)->getAlignment());
405
406
407 if (!CAFA)
408 return;
409
410 while (Attrs.end() != (LastFoundItr = std::find_if(LastFoundItr + 1,
411 Attrs.end(), FindFunc))) {
412 const auto *CASA =
413 dyn_cast(cast(*LastFoundItr)->getAlignment());
414
415 if (!CASA)
416 return;
417
418 llvm::APSInt SecondValue = CASA->getResultAsAPSInt();
419 if (!FirstValue)
420 FirstValue = CAFA->getResultAsAPSInt();
421
422 if (FirstValue != SecondValue) {
423 S.Diag((*LastFoundItr)->getLocation(), diag::err_loop_attr_conflict)
424 << *FirstItr;
425 S.Diag((*FirstItr)->getLocation(), diag::note_previous_attribute);
426 }
427 }
428 return;
429}
430
434 S.Diag(A.getLoc(), diag::warn_unknown_attribute_ignored)
436 return nullptr;
437 }
438 return ::new (S.Context) MSConstexprAttr(S.Context, A);
439}
440
441#define WANT_STMT_MERGE_LOGIC
442#include "clang/Sema/AttrParsedAttrImpl.inc"
443#undef WANT_STMT_MERGE_LOGIC
444
445static void
448
449
450 if (Attrs.size() < 2)
451 return;
452
453
454 if (!DiagnoseMutualExclusions(S, Attrs))
455 return;
456
457 enum CategoryType {
458
459
460
461
462 Vectorize,
463 Interleave,
464 UnrollAndJam,
465 Pipeline,
466
467
468 Unroll,
469
470
471 Distribute,
472
473
474 VectorizePredicate,
475
476 NumberOfCategories
477 };
478
479
480 struct {
481 const LoopHintAttr *StateAttr;
482 const LoopHintAttr *NumericAttr;
483 } HintAttrs[CategoryType::NumberOfCategories] = {};
484
485 for (const auto *I : Attrs) {
486 const LoopHintAttr *LH = dyn_cast(I);
487
488
489 if (!LH)
490 continue;
491
492 CategoryType Category = CategoryType::NumberOfCategories;
493 LoopHintAttr::OptionType Option = LH->getOption();
494 switch (Option) {
495 case LoopHintAttr::Vectorize:
496 case LoopHintAttr::VectorizeWidth:
498 break;
499 case LoopHintAttr::Interleave:
500 case LoopHintAttr::InterleaveCount:
502 break;
503 case LoopHintAttr::Unroll:
504 case LoopHintAttr::UnrollCount:
506 break;
507 case LoopHintAttr::UnrollAndJam:
508 case LoopHintAttr::UnrollAndJamCount:
510 break;
511 case LoopHintAttr::Distribute:
512
514 break;
515 case LoopHintAttr::PipelineDisabled:
516 case LoopHintAttr::PipelineInitiationInterval:
518 break;
519 case LoopHintAttr::VectorizePredicate:
520 Category = VectorizePredicate;
521 break;
522 };
523
524 assert(Category != NumberOfCategories && "Unhandled loop hint option");
525 auto &CategoryState = HintAttrs[Category];
526 const LoopHintAttr *PrevAttr;
527 if (Option == LoopHintAttr::Vectorize ||
528 Option == LoopHintAttr::Interleave || Option == LoopHintAttr::Unroll ||
529 Option == LoopHintAttr::UnrollAndJam ||
530 Option == LoopHintAttr::VectorizePredicate ||
531 Option == LoopHintAttr::PipelineDisabled ||
532 Option == LoopHintAttr::Distribute) {
533
534 PrevAttr = CategoryState.StateAttr;
535 CategoryState.StateAttr = LH;
536 } else {
537
538 PrevAttr = CategoryState.NumericAttr;
539 CategoryState.NumericAttr = LH;
540 }
541
543 SourceLocation OptionLoc = LH->getRange().getBegin();
544 if (PrevAttr)
545
546 S.Diag(OptionLoc, diag::err_pragma_loop_compatibility)
547 << true << PrevAttr->getDiagnosticName(Policy)
548 << LH->getDiagnosticName(Policy);
549
550 if (CategoryState.StateAttr && CategoryState.NumericAttr &&
552 CategoryState.StateAttr->getState() == LoopHintAttr::Disable)) {
553
554
555
556
557 S.Diag(OptionLoc, diag::err_pragma_loop_compatibility)
558 << false
559 << CategoryState.StateAttr->getDiagnosticName(Policy)
560 << CategoryState.NumericAttr->getDiagnosticName(Policy);
561 }
562 }
563}
564
567
568
569
570
571
572 unsigned UnrollFactor = 0;
575 std::optionalllvm::APSInt ArgVal;
576
578 S.Diag(A.getLoc(), diag::err_attribute_argument_type)
580 return nullptr;
581 }
582
583 int Val = ArgVal->getSExtValue();
584 if (Val <= 0) {
586 diag::err_attribute_requires_positive_integer)
587 << A << 0;
588 return nullptr;
589 }
590 UnrollFactor = static_cast<unsigned>(Val);
591 }
592
593 return ::new (S.Context) OpenCLUnrollHintAttr(S.Context, A, UnrollFactor);
594}
595
598
599 if (A.getSemanticSpelling() == HLSLLoopHintAttr::Spelling::Microsoft_loop &&
601 return nullptr;
602
603 unsigned UnrollFactor = 0;
606
608 false))
609 return nullptr;
610
612
613 assert(ArgVal != std::nullopt && "ArgVal should be an integer constant.");
614 int Val = ArgVal->getSExtValue();
615
616 assert(Val > 0 && "Val should be a positive integer greater than zero.");
617 UnrollFactor = static_cast<unsigned>(Val);
618 }
619 return ::new (S.Context) HLSLLoopHintAttr(S.Context, A, UnrollFactor);
620}
621
624
625 return ::new (S.Context) HLSLControlFlowHintAttr(S.Context, A);
626}
627
631 return nullptr;
632
633
634
635
642 ? (unsigned)diag::err_keyword_not_supported_on_target
644 ? (unsigned)diag::warn_unhandled_ms_attribute_ignored
645 : (unsigned)diag::warn_unknown_attribute_ignored)
647 return nullptr;
648 }
649
651 return nullptr;
652
654 case ParsedAttr::AT_AlwaysInline:
656 case ParsedAttr::AT_CXXAssume:
658 case ParsedAttr::AT_FallThrough:
660 case ParsedAttr::AT_LoopHint:
662 case ParsedAttr::AT_HLSLLoopHint:
664 case ParsedAttr::AT_HLSLControlFlowHint:
666 case ParsedAttr::AT_OpenCLUnrollHint:
668 case ParsedAttr::AT_Suppress:
670 case ParsedAttr::AT_NoMerge:
672 case ParsedAttr::AT_NoInline:
674 case ParsedAttr::AT_MustTail:
676 case ParsedAttr::AT_Likely:
678 case ParsedAttr::AT_Unlikely:
680 case ParsedAttr::AT_CodeAlign:
682 case ParsedAttr::AT_MSConstexpr:
684 case ParsedAttr::AT_NoConvergent:
686 case ParsedAttr::AT_Annotate:
688 default:
689 if (Attr *AT = nullptr; A.getInfo().handleStmtAttribute(S, St, A, AT) !=
691 return AT;
692 }
693
694
695
698 return nullptr;
699 }
700}
701
704 for (const ParsedAttr &AL : InAttrs) {
706 OutAttrs.push_back(A);
707 }
708
710 CheckForDuplicateLoopAttrs(*this, OutAttrs);
711}
712
714 CheckForDuplicateLoopAttrs(*this, Attrs);
715 return false;
716}
717
721 Diag(A.getLoc(), diag::err_attribute_wrong_number_arguments)
724 }
725
727
730 }
731
732 if (Assumption->getDependence() == ExprDependence::None) {
736 Assumption = Res.get();
737 }
738
742
743 return Assumption;
744}
745
752
756
760
761 Assumption = Res.get();
763 Diag(Assumption->getBeginLoc(), diag::warn_assume_side_effects)
764 << AttrName << Range;
765
766 return Assumption;
767}
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)
static void CheckForDuplicateLoopAttrs(Sema &S, ArrayRef< const Attr * > Attrs)
static Attr * handleMustTailAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleCXXAssumeAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleLikely(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleNoMergeAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleOpenCLUnrollHint(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange)
static void CheckForIncompatibleAttributes(Sema &S, const SmallVectorImpl< const Attr * > &Attrs)
static Attr * handleHLSLControlFlowHint(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static bool CheckStmtInlineAttr(Sema &SemaRef, const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
static Attr * handleHLSLLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleCodeAlignAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static Attr * handleFallThroughAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleSuppressAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleUnlikely(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleNoInlineAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
const LangOptions & getLangOpts() const
const TargetInfo * getAuxTargetInfo() const
const TargetInfo & getTargetInfo() const
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
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
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
Decl - This represents one declaration (or definition), e.g.
void VisitCallExpr(PTR(CallExpr) CE)
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...
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.
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.
Expr * getArgAsExpr(unsigned Arg) const
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, 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)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
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)
bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
ExprResult ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A, SourceRange Range)
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)
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
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.
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
@ AANT_ArgumentIntegerConstant
Wraps an identifier and optional source location for the identifier.
Describes how types, statements, expressions, and declarations should be printed.