41#include "llvm/ADT/ArrayRef.h"
42#include "llvm/ADT/DenseMap.h"
43#include "llvm/ADT/STLExtras.h"
44#include "llvm/ADT/SmallVector.h"
45#include "llvm/ADT/StringExtras.h"
73 bool HasLeadingEmptyMacro) {
102 Diag(
decl->getLocation(), diag::err_non_variable_decl_in_for);
103 decl->setInvalidDecl();
109 var->setInit(
nullptr);
122 var->setType(
type.withConst());
123 var->setARCPseudoStrong(
true);
139 if (!Op->isComparisonOp())
142 if (Op->getOpcode() == BO_EQ)
144 else if (Op->getOpcode() == BO_NE)
146 else if (Op->getOpcode() == BO_Cmp)
149 assert(Op->isRelationalOp());
152 Loc = Op->getOperatorLoc();
153 CanAssign = Op->getLHS()->IgnoreParenImpCasts()->isLValue();
155 switch (Op->getOperator()) {
159 case OO_ExclaimEqual:
164 case OO_GreaterEqual:
175 Loc = Op->getOperatorLoc();
176 CanAssign = Op->getArg(0)->IgnoreParenImpCasts()->isLValue();
187 S.
Diag(Loc, diag::warn_unused_comparison)
193 if (Kind == Inequality)
194 S.
Diag(Loc, diag::note_inequality_comparison_to_or_assign)
196 else if (Kind == Equality)
197 S.
Diag(Loc, diag::note_equality_comparison_to_assign)
209 StringRef Msg = A->getMessage();
213 return S.
Diag(Loc, diag::warn_unused_return_type)
214 << IsCtor << A << OffendingDecl <<
false << R1 << R2;
216 return S.
Diag(Loc, diag::warn_unused_constructor)
217 << A <<
false << R1 << R2;
218 return S.
Diag(Loc, diag::warn_unused_result) << A <<
false << R1 << R2;
222 return S.
Diag(Loc, diag::warn_unused_return_type)
223 << IsCtor << A << OffendingDecl <<
true << Msg << R1 << R2;
225 return S.
Diag(Loc, diag::warn_unused_constructor)
226 << A <<
true << Msg << R1 << R2;
227 return S.
Diag(Loc, diag::warn_unused_result) << A <<
true << Msg << R1 << R2;
236void DiagnoseUnused(
Sema &S,
const Expr *E, std::optional<unsigned> DiagID) {
237 bool NoDiscardOnly = !DiagID.has_value();
253 const Expr *WarnExpr;
259 if (!NoDiscardOnly) {
280 if (
const FullExpr *Temps = dyn_cast<FullExpr>(E))
281 E = Temps->getSubExpr();
283 E = TempExpr->getSubExpr();
289 if (
const auto *Cast = dyn_cast<CastExpr>(E))
290 if (
Cast->getCastKind() == CK_NoOp ||
291 Cast->getCastKind() == CK_ConstructorConversion ||
292 Cast->getCastKind() == CK_IntegralCast)
293 E =
Cast->getSubExpr()->IgnoreImpCasts();
295 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
299 auto [OffendingDecl, A] = CE->getUnusedResultAttr(S.
Context);
308 if (
const Decl *FD = CE->getCalleeDecl()) {
311 if (FD->hasAttr<PureAttr>()) {
312 S.
Diag(Loc, diag::warn_unused_call) << R1 << R2 <<
"pure";
315 if (FD->hasAttr<ConstAttr>()) {
316 S.
Diag(Loc, diag::warn_unused_call) << R1 << R2 <<
"const";
320 }
else if (
const auto *CE = dyn_cast<CXXConstructExpr>(E)) {
321 auto [OffendingDecl, A] = CE->getUnusedResultAttr(S.
Context);
325 }
else if (
const auto *ILE = dyn_cast<InitListExpr>(E)) {
326 if (
const TagDecl *TD = ILE->getType()->getAsTagDecl()) {
332 }
else if (ShouldSuppress)
337 if (S.
getLangOpts().ObjCAutoRefCount && ME->isDelegateInitCall()) {
338 S.
Diag(Loc, diag::err_arc_unused_init_message) << R1;
342 auto [OffendingDecl, A] = ME->getUnusedResultAttr(S.
Context);
347 const Expr *Source = POE->getSyntacticForm();
350 POE->getNumSemanticExprs() == 1 &&
352 return DiagnoseUnused(S, POE->getSemanticExpr(0), DiagID);
354 DiagID = diag::warn_unused_container_subscript_expr;
356 DiagID = diag::warn_unused_property_expr;
358 = dyn_cast<CXXFunctionalCastExpr>(E)) {
359 const Expr *E = FC->getSubExpr();
361 E = TE->getSubExpr();
365 if (
const CXXRecordDecl *RD = CE->getType()->getAsCXXRecordDecl())
366 if (!RD->getAttr<WarnUnusedAttr>())
382 S.
Diag(Loc, diag::warn_unused_voidptr)
392 S.
Diag(Loc, diag::warn_unused_volatile) << R1 << R2;
399 if (DiagID == diag::warn_unused_comma_left_operand && S.
isSFINAEContext())
403 S.
PDiag(*DiagID) << R1 << R2);
408 if (
const LabelStmt *Label = dyn_cast_if_present<LabelStmt>(S))
409 S = Label->getSubStmt();
411 const Expr *E = dyn_cast_if_present<Expr>(S);
415 DiagnoseUnused(*
this, E, DiagID);
435 StringRef DeferSpelling =
437 if (DeferSpelling.empty())
438 DeferSpelling =
"_Defer";
439 return DeferSpelling;
447 S.
Diag(DeferLoc, diag::warn_redundant_defer)
460 const unsigned NumElts = Elts.size();
465 const unsigned MixedDeclsCodeID =
getLangOpts().C99
466 ? diag::warn_mixed_decls_code
467 : diag::ext_mixed_decls_code;
495 for (
unsigned i = 0; i != NumElts - 1; ++i)
502 for (
unsigned i = 0; i != NumElts - 1; ++i) {
503 Stmt *Inner = Elts[i + 1]->stripLabelLikeStatements();
546 auto CheckAndFinish = [&](
Expr *E) {
553 llvm::APSInt TempVal;
560 ER =
Context.getTargetInfo().getTriple().isBPF()
572 return CheckAndFinish(Val.
get());
586 S.
Diag(KwLoc, diag::err_expansion_stmt_case) << IsDefault;
588 diag::note_enclosing_switch_statement_here);
598 assert((LHSVal.
isInvalid() || LHSVal.
get()) &&
"missing LHS value");
601 "missing RHS value");
604 Diag(CaseLoc, diag::err_case_not_in_switch);
618 Diag(CaseLoc, diag::err_acc_branch_in_out_compute_construct)
624 CaseLoc, DotDotDotLoc, ColonLoc);
637 Diag(DefaultLoc, diag::err_default_not_in_switch);
646 Diag(DefaultLoc, diag::err_acc_branch_in_out_compute_construct)
661 Diag(IdentLoc, diag::err_redefinition_of_label) << TheDecl->
getDeclName();
668 !
Context.getSourceManager().isInSystemHeader(IdentLoc))
669 Diag(IdentLoc, diag::warn_reserved_extern_symbol)
670 << TheDecl << static_cast<int>(Status);
674 if (
getCurScope()->isInOpenACCComputeConstructScope())
705 for (
const auto *A : Attrs) {
706 if (A->getKind() == attr::MustTail) {
721 if (!SemanticAttrs.empty())
731 Expr *E = R->getRetValue();
737 if (!checkMustTailAttr(St, MTA))
743 auto IgnoreImplicitAsWritten = [](
Expr *E) ->
Expr * {
750 R->setRetValue(IgnoreImplicitAsWritten(E));
754bool Sema::checkMustTailAttr(
const Stmt *St,
const Attr &MTA) {
756 "musttail cannot be checked from a dependent context");
759 auto IgnoreParenImplicitAsWritten = [](
const Expr *E) ->
const Expr * {
766 const auto *CE = dyn_cast_or_null<CallExpr>(IgnoreParenImplicitAsWritten(E));
773 if (
const FunctionDecl *CalleeDecl = CE->getDirectCallee();
774 CalleeDecl && CalleeDecl->hasAttr<NotTailCalledAttr>()) {
775 Diag(St->
getBeginLoc(), diag::err_musttail_mismatch) <<
true << CalleeDecl;
776 Diag(CalleeDecl->getLocation(), diag::note_musttail_disabled_by_not_tail_called);
780 if (
const auto *EWC = dyn_cast<ExprWithCleanups>(E)) {
781 if (EWC->cleanupsHaveSideEffects()) {
782 Diag(St->
getBeginLoc(), diag::err_musttail_needs_trivial_args) << &MTA;
793 ft_non_static_member,
794 ft_pointer_to_member,
795 } MemberType = ft_non_member;
798 const FunctionProtoType *
Func;
799 const CXXMethodDecl *
Method =
nullptr;
800 } CallerType, CalleeType;
802 auto GetMethodType = [
this, St, MTA](
const CXXMethodDecl *CMD, FuncType &
Type,
803 bool IsCallee) ->
bool {
806 << IsCallee << isa<CXXDestructorDecl>(CMD);
808 Diag(CMD->getBeginLoc(), diag::note_musttail_structors_forbidden)
814 Type.MemberType = FuncType::ft_static_member;
816 Type.This = CMD->getFunctionObjectParameterType();
817 Type.MemberType = FuncType::ft_non_static_member;
819 Type.Func = CMD->getType()->castAs<FunctionProtoType>();
823 const auto *CallerDecl = dyn_cast<FunctionDecl>(
CurContext);
834 Diag(St->
getBeginLoc(), diag::err_musttail_forbidden_from_this_context)
835 << &MTA << ContextType;
837 }
else if (
const auto *CMD = dyn_cast<CXXMethodDecl>(
CurContext)) {
839 if (!GetMethodType(CMD, CallerType,
false))
843 CallerType.Func = CallerDecl->getType()->getAs<FunctionProtoType>();
846 const Expr *CalleeExpr = CE->getCallee()->IgnoreParens();
847 const auto *CalleeBinOp = dyn_cast<BinaryOperator>(CalleeExpr);
848 SourceLocation CalleeLoc = CE->getCalleeDecl()
849 ? CE->getCalleeDecl()->getBeginLoc()
853 if (
const CXXMethodDecl *CMD =
854 dyn_cast_or_null<CXXMethodDecl>(CE->getCalleeDecl())) {
856 if (!GetMethodType(CMD, CalleeType,
true))
858 }
else if (CalleeBinOp && CalleeBinOp->isPtrMemOp()) {
861 CalleeBinOp->getRHS()->getType()->castAs<MemberPointerType>();
863 Context.getCanonicalTagType(MPT->getMostRecentCXXRecordDecl());
864 CalleeType.Func = MPT->getPointeeType()->castAs<FunctionProtoType>();
865 CalleeType.MemberType = FuncType::ft_pointer_to_member;
878 if (!CalleeType.Func || !CallerType.Func) {
880 if (!CalleeType.Func && CE->getDirectCallee()) {
881 Diag(CE->getDirectCallee()->getBeginLoc(),
882 diag::note_musttail_fix_non_prototype);
884 if (!CallerType.Func)
885 Diag(CallerDecl->getBeginLoc(), diag::note_musttail_fix_non_prototype);
896 if (CallerType.Func->getCallConv() != CalleeType.Func->getCallConv()) {
897 if (
const auto *ND = dyn_cast_or_null<NamedDecl>(CE->getCalleeDecl()))
899 <<
true << ND->getDeclName();
901 Diag(St->
getBeginLoc(), diag::err_musttail_callconv_mismatch) <<
false;
902 Diag(CalleeLoc, diag::note_musttail_callconv_mismatch)
909 if (CalleeType.Func->isVariadic() || CallerType.Func->isVariadic()) {
914 const auto *CalleeDecl = CE->getCalleeDecl();
915 if (CalleeDecl && CalleeDecl->hasAttr<CXX11NoReturnAttr>()) {
921 if (CallerType.This.isNull() != CalleeType.This.isNull()) {
922 if (
const auto *ND = dyn_cast_or_null<NamedDecl>(CE->getCalleeDecl())) {
924 << CallerType.MemberType << CalleeType.MemberType <<
true
925 << ND->getDeclName();
926 Diag(CalleeLoc, diag::note_musttail_callee_defined_here)
927 << ND->getDeclName();
930 << CallerType.MemberType << CalleeType.MemberType <<
false;
935 auto CheckTypesMatch = [
this](FuncType CallerType, FuncType CalleeType,
936 PartialDiagnostic &PD) ->
bool {
944 auto DoTypesMatch = [
this, &PD](QualType A, QualType B,
945 unsigned Select) ->
bool {
946 if (!
Context.hasSimilarType(A, B)) {
953 if (!CallerType.This.isNull() &&
957 if (!DoTypesMatch(CallerType.Func->getReturnType(),
961 if (CallerType.Func->getNumParams() != CalleeType.Func->getNumParams()) {
963 << CalleeType.Func->getNumParams();
967 ArrayRef<QualType> CalleeParams = CalleeType.Func->getParamTypes();
968 ArrayRef<QualType> CallerParams = CallerType.Func->getParamTypes();
969 size_t N = CallerType.Func->getNumParams();
970 for (
size_t I = 0; I < N; I++) {
971 if (!DoTypesMatch(CalleeParams[I], CallerParams[I],
973 PD << static_cast<int>(I) + 1;
981 PartialDiagnostic PD =
PDiag(diag::note_musttail_mismatch);
982 if (!CheckTypesMatch(CallerType, CalleeType, PD)) {
983 if (
const auto *ND = dyn_cast_or_null<NamedDecl>(CE->getCalleeDecl()))
985 <<
true << ND->getDeclName();
996 for (
auto ArgExpr : CE->arguments()) {
998 Context, ArgExpr->getType(),
false);
1007 typedef EvaluatedExprVisitor<CommaVisitor> Inherited;
1010 CommaVisitor(Sema &SemaRef) : Inherited(SemaRef.Context), SemaRef(SemaRef) {}
1011 void VisitBinaryOperator(BinaryOperator *E) {
1014 EvaluatedExprVisitor<CommaVisitor>::VisitBinaryOperator(E);
1028 bool ConstevalOrNegatedConsteval =
1032 Expr *CondExpr = Cond.
get().second;
1033 assert((CondExpr || ConstevalOrNegatedConsteval) &&
1034 "If statement: missing condition");
1038 CommaVisitor(*this).Visit(CondExpr);
1040 if (!ConstevalOrNegatedConsteval && !elseStmt)
1049 if (ConstevalOrNegatedConsteval ||
1051 auto DiagnoseLikelihood = [&](
const Stmt *S) {
1053 Diags.Report(A->getLocation(),
1054 diag::warn_attribute_has_no_effect_on_compile_time_if)
1055 << A << ConstevalOrNegatedConsteval << A->getRange();
1057 diag::note_attribute_has_no_effect_on_compile_time_if_here)
1058 << ConstevalOrNegatedConsteval
1059 <<
SourceRange(IfLoc, (ConstevalOrNegatedConsteval
1065 DiagnoseLikelihood(thenStmt);
1066 DiagnoseLikelihood(elseStmt);
1068 std::tuple<bool, const Attr *, const Attr *> LHC =
1070 if (std::get<0>(LHC)) {
1071 const Attr *ThenAttr = std::get<1>(LHC);
1072 const Attr *ElseAttr = std::get<2>(LHC);
1074 diag::warn_attributes_likelihood_ifstmt_conflict)
1075 << ThenAttr << ThenAttr->
getRange();
1077 << ElseAttr << ElseAttr->
getRange();
1081 if (ConstevalOrNegatedConsteval) {
1087 if (FD && FD->isImmediateFunction())
1091 Diags.Report(IfLoc, diag::warn_consteval_if_always_true) << Immediate;
1103 return BuildIfStmt(IfLoc, StatementKind, LParenLoc, InitStmt, Cond, RParenLoc,
1104 thenStmt, ElseLoc, elseStmt);
1121 Cond.
get().first, Cond.
get().second, LParenLoc,
1122 RParenLoc, thenStmt, ElseLoc, elseStmt);
1126 struct CaseCompareFunctor {
1127 bool operator()(
const std::pair<llvm::APSInt, CaseStmt*> &LHS,
1128 const llvm::APSInt &RHS) {
1129 return LHS.first < RHS;
1131 bool operator()(
const std::pair<llvm::APSInt, CaseStmt*> &LHS,
1132 const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
1133 return LHS.first < RHS.first;
1135 bool operator()(
const llvm::APSInt &LHS,
1136 const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
1137 return LHS < RHS.first;
1145 const std::pair<llvm::APSInt, CaseStmt*>& rhs) {
1146 if (lhs.first < rhs.first)
1149 if (lhs.first == rhs.first &&
1150 lhs.second->getCaseLoc() < rhs.second->getCaseLoc())
1157static bool CmpEnumVals(
const std::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
1158 const std::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
1160 return lhs.first < rhs.first;
1165static bool EqEnumVals(
const std::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
1166 const std::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
1168 return lhs.first == rhs.first;
1174 if (
const auto *FE = dyn_cast<FullExpr>(E))
1175 E = FE->getSubExpr();
1176 while (
const auto *ImpCast = dyn_cast<ImplicitCastExpr>(E)) {
1177 if (ImpCast->getCastKind() != CK_IntegralCast)
break;
1178 E = ImpCast->getSubExpr();
1188 SwitchConvertDiagnoser(
Expr *Cond)
1194 return S.
Diag(Loc, diag::err_typecheck_statement_requires_integer) <<
T;
1199 return S.
Diag(Loc, diag::err_switch_incomplete_class_type)
1205 return S.
Diag(Loc, diag::err_switch_explicit_conversion) <<
T << ConvTy;
1216 return S.
Diag(Loc, diag::err_switch_multiple_conversions) <<
T;
1227 llvm_unreachable(
"conversion functions are permitted");
1229 } SwitchDiagnoser(Cond);
1238 Cond = CondResult.
get();
1251 Expr *CondExpr = Cond.
get().second;
1252 assert((Cond.
isInvalid() || CondExpr) &&
"switch with no condition");
1265 Diag(SwitchLoc, diag::warn_bool_switch_condition)
1273 LParenLoc, RParenLoc);
1274 SS->setSwitchLoc(SwitchLoc);
1280static void AdjustAPSInt(llvm::APSInt &Val,
unsigned BitWidth,
bool IsSigned) {
1281 Val = Val.extOrTrunc(BitWidth);
1282 Val.setIsSigned(IsSigned);
1288 unsigned UnpromotedWidth,
bool UnpromotedSign) {
1296 if (UnpromotedWidth < Val.getBitWidth()) {
1297 llvm::APSInt ConvVal(Val);
1298 AdjustAPSInt(ConvVal, UnpromotedWidth, UnpromotedSign);
1299 AdjustAPSInt(ConvVal, Val.getBitWidth(), Val.isSigned());
1304 S.
Diag(Loc, diag::warn_case_value_overflow) <<
toString(Val, 10)
1315 const Expr *CaseExpr,
1316 EnumValsTy::iterator &EI,
1317 EnumValsTy::iterator &EIEnd,
1318 const llvm::APSInt &Val) {
1324 if (
const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
1333 if (ED->
hasAttr<FlagEnumAttr>())
1336 while (EI != EIEnd && EI->first < Val)
1339 if (EI != EIEnd && EI->first == Val)
1350 const EnumType *CondEnumType = CondType->
getAsCanonical<EnumType>();
1351 const EnumType *CaseEnumType = CaseType->
getAsCanonical<EnumType>();
1352 if (!CondEnumType || !CaseEnumType)
1356 if (!CondEnumType->getDecl()->getIdentifier() &&
1357 !CondEnumType->getDecl()->getTypedefNameForAnonDecl())
1359 if (!CaseEnumType->getDecl()->getIdentifier() &&
1360 !CaseEnumType->getDecl()->getTypedefNameForAnonDecl())
1366 S.
Diag(Case->
getExprLoc(), diag::warn_comparison_of_mixed_enum_types_switch)
1376 assert(SS ==
getCurFunction()->SwitchStack.back().getPointer() &&
1377 "switch stack missing push/pop!");
1406 const Expr *CondExprBeforePromotion = CondExpr;
1412 bool HasDependentValue
1414 unsigned CondWidth = HasDependentValue ? 0 :
Context.getIntWidth(CondType);
1421 unsigned CondWidthBeforePromotion
1422 = HasDependentValue ? 0 :
Context.getIntWidth(CondTypeBeforePromotion);
1423 bool CondIsSignedBeforePromotion
1430 CaseValsTy CaseVals;
1433 typedef std::vector<std::pair<llvm::APSInt, CaseStmt*> > CaseRangesTy;
1434 CaseRangesTy CaseRanges;
1442 bool IsBPF =
Context.getTargetInfo().getTriple().isBPF();
1443 CaseValsTy RelocatedCaseVals;
1448 bool CaseListIsErroneous =
false;
1454 SC = SC->getNextSwitchCase()) {
1456 if (
DefaultStmt *DS = dyn_cast<DefaultStmt>(SC)) {
1457 if (TheDefaultStmt) {
1458 Diag(DS->getDefaultLoc(), diag::err_multiple_default_labels_defined);
1465 CaseListIsErroneous =
true;
1467 TheDefaultStmt = DS;
1475 HasDependentValue =
true;
1481 const Expr *LoBeforePromotion = Lo;
1488 CondIsSignedBeforePromotion);
1500 HasDependentValue =
true;
1503 CaseRanges.push_back(std::make_pair(LoVal, CS));
1506 RelocatedCaseRanges.insert(CS);
1508 RelocatedCaseVals.push_back(std::make_pair(LoVal, CS));
1510 CaseVals.push_back(std::make_pair(LoVal, CS));
1514 if (!HasDependentValue) {
1517 llvm::APSInt ConstantCondValue;
1518 bool HasConstantCond =
false;
1519 if (!TheDefaultStmt) {
1524 ConstantCondValue =
Result.Val.getInt();
1525 assert(!HasConstantCond ||
1526 (ConstantCondValue.getBitWidth() == CondWidth &&
1527 ConstantCondValue.isSigned() == CondIsSigned));
1528 Diag(SwitchLoc, diag::warn_switch_default);
1531 bool ShouldCheckConstantCond = HasConstantCond &&
1532 RelocatedCaseVals.empty() &&
1533 RelocatedCaseRanges.empty();
1538 if (!CaseVals.empty()) {
1539 for (
unsigned i = 0, e = CaseVals.size(); i != e; ++i) {
1540 if (ShouldCheckConstantCond &&
1541 CaseVals[i].first == ConstantCondValue)
1542 ShouldCheckConstantCond =
false;
1544 if (i != 0 && CaseVals[i].first == CaseVals[i-1].first) {
1547 StringRef PrevString, CurrString;
1550 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(PrevCase)) {
1551 PrevString = DeclRef->getDecl()->getName();
1553 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(CurrCase)) {
1554 CurrString = DeclRef->getDecl()->getName();
1557 CaseVals[i-1].first.toString(CaseValStr);
1559 if (PrevString == CurrString)
1560 Diag(CaseVals[i].second->getLHS()->getBeginLoc(),
1561 diag::err_duplicate_case)
1562 << (PrevString.empty() ? CaseValStr.str() : PrevString);
1564 Diag(CaseVals[i].second->getLHS()->getBeginLoc(),
1565 diag::err_duplicate_case_differing_expr)
1566 << (PrevString.empty() ? CaseValStr.str() : PrevString)
1567 << (CurrString.empty() ? CaseValStr.str() : CurrString)
1570 Diag(CaseVals[i - 1].second->getLHS()->getBeginLoc(),
1571 diag::note_duplicate_case_prev);
1574 CaseListIsErroneous =
true;
1581 if (!CaseRanges.empty()) {
1584 llvm::stable_sort(CaseRanges);
1587 std::vector<llvm::APSInt> HiVals;
1588 for (
unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
1589 llvm::APSInt &LoVal = CaseRanges[i].first;
1590 CaseStmt *CR = CaseRanges[i].second;
1593 const Expr *HiBeforePromotion = Hi;
1600 CondWidthBeforePromotion, CondIsSignedBeforePromotion);
1606 if (LoVal > HiVal) {
1609 CaseRanges.erase(CaseRanges.begin()+i);
1615 if (ShouldCheckConstantCond &&
1616 LoVal <= ConstantCondValue &&
1617 ConstantCondValue <= HiVal)
1618 ShouldCheckConstantCond =
false;
1620 HiVals.push_back(HiVal);
1626 std::optional<unsigned> PrevRange;
1627 for (
unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
1628 llvm::APSInt &CRLo = CaseRanges[i].first;
1629 llvm::APSInt &CRHi = HiVals[i];
1630 CaseStmt *CR = CaseRanges[i].second;
1631 if (RelocatedCaseRanges.contains(CR))
1637 llvm::APSInt OverlapVal(32);
1641 CaseValsTy::iterator I =
1642 llvm::lower_bound(CaseVals, CRLo, CaseCompareFunctor());
1643 if (I != CaseVals.end() && I->first < CRHi) {
1644 OverlapVal = I->first;
1645 OverlapStmt = I->second;
1649 I = std::upper_bound(I, CaseVals.end(), CRHi, CaseCompareFunctor());
1650 if (I != CaseVals.begin() && (I-1)->first >= CRLo) {
1651 OverlapVal = (I-1)->first;
1652 OverlapStmt = (I-1)->second;
1657 if (PrevRange && CRLo <= HiVals[*PrevRange]) {
1658 OverlapVal = HiVals[*PrevRange];
1659 OverlapStmt = CaseRanges[*PrevRange].second;
1668 diag::note_duplicate_case_prev);
1671 CaseListIsErroneous =
true;
1677 if (!CaseListIsErroneous && !CaseListIsIncomplete &&
1678 ShouldCheckConstantCond) {
1681 Diag(CondExpr->
getExprLoc(), diag::warn_missing_case_for_condition)
1687 if (!RelocatedCaseVals.empty()) {
1688 llvm::append_range(CaseVals, RelocatedCaseVals);
1698 if (!CaseListIsErroneous && !CaseListIsIncomplete && !HasConstantCond &&
1701 if (!ED->isCompleteDefinition() || ED->enumerators().empty())
1708 for (
auto *EDI : ED->enumerators()) {
1709 llvm::APSInt Val = EDI->getInitVal();
1711 EnumVals.push_back(std::make_pair(Val, EDI));
1714 auto EI = EnumVals.begin(), EIEnd = llvm::unique(EnumVals,
EqEnumVals);
1717 for (CaseValsTy::const_iterator CI = CaseVals.begin();
1718 CI != CaseVals.end(); CI++) {
1719 Expr *CaseExpr = CI->second->getLHS();
1723 << CondTypeBeforePromotion;
1727 EI = EnumVals.begin();
1728 for (CaseRangesTy::const_iterator RI = CaseRanges.begin();
1729 RI != CaseRanges.end(); RI++) {
1731 if (!RelocatedCaseRanges.empty())
1732 EI = EnumVals.begin();
1733 Expr *CaseExpr = RI->second->getLHS();
1737 << CondTypeBeforePromotion;
1740 RI->second->getRHS()->EvaluateKnownConstInt(
Context);
1743 CaseExpr = RI->second->getRHS();
1747 << CondTypeBeforePromotion;
1751 auto CI = CaseVals.begin();
1752 auto RI = CaseRanges.begin();
1753 bool hasCasesNotInSwitch =
false;
1757 for (EI = EnumVals.begin(); EI != EIEnd; EI++) {
1759 switch (EI->second->getAvailability()) {
1776 if (EI->second->hasAttr<UnusedAttr>())
1780 while (CI != CaseVals.end() && CI->first < EI->first)
1783 if (CI != CaseVals.end() && CI->first == EI->first)
1787 for (; RI != CaseRanges.end(); RI++) {
1789 RI->second->getRHS()->EvaluateKnownConstInt(
Context);
1791 if (EI->first <= Hi)
1795 if (RI == CaseRanges.end() || EI->first < RI->first) {
1796 hasCasesNotInSwitch =
true;
1797 UnhandledNames.push_back(EI->second->getDeclName());
1801 if (TheDefaultStmt && UnhandledNames.empty() && ED->isClosedNonFlag())
1805 if (!UnhandledNames.empty()) {
1807 ? diag::warn_def_missing_case
1808 : diag::warn_missing_case)
1811 for (
size_t I = 0, E = std::min(UnhandledNames.size(), (
size_t)3);
1813 DB << UnhandledNames[I];
1816 if (!hasCasesNotInSwitch)
1824 diag::warn_empty_switch_body);
1828 if (CaseListIsErroneous)
1842 Context.hasSameUnqualifiedType(SrcType, DstType))
1849 if (!ED->isClosed())
1852 if (
Diags.isIgnored(diag::warn_not_in_enum_assignment, SrcExpr->
getExprLoc()))
1860 unsigned DstWidth =
Context.getIntWidth(DstType);
1864 if (ED->hasAttr<FlagEnumAttr>()) {
1873 auto &Values = It->second;
1876 Values.reserve(std::distance(ED->enumerator_begin(), ED->enumerator_end()));
1878 for (
auto *EC : ED->enumerators()) {
1879 Values.push_back(EC->getInitVal());
1887 Values.erase(llvm::unique(Values), Values.end());
1890 if (llvm::binary_search(Values, *RHSVal))
1902 CommaVisitor(S).Visit(CondExpr);
1937 auto CondVal = Cond.
get();
1942 WhileLoc, LParenLoc, RParenLoc);
1949 assert(Cond &&
"ActOnDoStmt(): missing expression");
1954 Cond = CondResult.
get();
1959 Cond = CondResult.
get();
1970 return new (
Context)
DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen);
1981 DeclSetVector &Decls;
1987 DeclExtractor(
Sema &S, DeclSetVector &Decls,
1989 Inherited(S.Context),
1994 bool isSimple() {
return Simple; }
1997 void VisitMemberExpr(MemberExpr* E) {
2003 void VisitStmt(Stmt *S) {
Simple =
false; }
2005 void VisitBinaryOperator(BinaryOperator *E) {
2014 void VisitUnaryOperator(UnaryOperator *E) {
2022 void VisitConditionalOperator(ConditionalOperator *E) {
2028 void VisitParenExpr(ParenExpr *E) {
2032 void VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
2037 void VisitIntegerLiteral(IntegerLiteral *E) { }
2038 void VisitFloatingLiteral(FloatingLiteral *E) { }
2039 void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { }
2040 void VisitCharacterLiteral(CharacterLiteral *E) { }
2041 void VisitGNUNullExpr(GNUNullExpr *E) { }
2042 void VisitImaginaryLiteral(ImaginaryLiteral *E) { }
2044 void VisitDeclRefExpr(DeclRefExpr *E) {
2045 VarDecl *VD = dyn_cast<VarDecl>(E->
getDecl());
2062 DeclSetVector &Decls;
2066 typedef EvaluatedExprVisitor<DeclMatcher> Inherited;
2068 DeclMatcher(Sema &S, DeclSetVector &Decls, Stmt *Statement) :
2069 Inherited(S.Context), Decls(Decls), FoundDecl(
false) {
2070 if (!Statement)
return;
2075 void VisitReturnStmt(ReturnStmt *S) {
2079 void VisitBreakStmt(BreakStmt *S) {
2083 void VisitGotoStmt(GotoStmt *S) {
2094 void CheckLValueToRValueCast(Expr *E) {
2101 if (ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E)) {
2102 Visit(CO->getCond());
2103 CheckLValueToRValueCast(CO->getTrueExpr());
2104 CheckLValueToRValueCast(CO->getFalseExpr());
2108 if (BinaryConditionalOperator *BCO =
2109 dyn_cast<BinaryConditionalOperator>(E)) {
2110 CheckLValueToRValueCast(BCO->getOpaqueValue()->getSourceExpr());
2111 CheckLValueToRValueCast(BCO->getFalseExpr());
2118 void VisitDeclRefExpr(DeclRefExpr *E) {
2119 if (
const auto *VD = dyn_cast<VarDecl>(E->
getDecl())) {
2120 if (Decls.count(VD))
2122 }
else if (
const auto *MD = dyn_cast<CXXMethodDecl>(E->
getDecl());
2133 for (
const auto &
Capture : MD->getParent()->captures()) {
2134 if (!
Capture.capturesVariable())
2141 const auto *VD = dyn_cast<VarDecl>(
Capture.getCapturedVar());
2142 if (VD && Decls.count(VD))
2148 void VisitPseudoObjectExpr(PseudoObjectExpr *POE) {
2152 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(S))
2154 Visit(OVE->getSourceExpr());
2160 bool FoundDeclInUse() {
return FoundDecl; }
2164 void CheckForLoopConditionalStatement(
Sema &S,
Expr *Second,
2167 if (!Second)
return;
2174 DeclSetVector Decls;
2176 DeclExtractor DE(S, Decls, Ranges);
2180 if (!DE.isSimple())
return;
2183 if (Decls.size() == 0)
return;
2186 for (
auto *VD : Decls)
2190 if (DeclMatcher(S, Decls, Second).FoundDeclInUse() ||
2191 DeclMatcher(S, Decls, Third).FoundDeclInUse() ||
2192 DeclMatcher(S, Decls, Body).FoundDeclInUse())
2196 if (Decls.size() > 4) {
2200 for (
auto *VD : Decls)
2204 for (
auto Range : Ranges)
2207 S.
Diag(Ranges.begin()->getBegin(), PDiag);
2214 if (
auto Cleanups = dyn_cast<ExprWithCleanups>(Statement))
2215 if (!Cleanups->cleanupsHaveSideEffects())
2218 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(Statement)) {
2219 switch (UO->getOpcode()) {
2220 default:
return false;
2230 DRE = dyn_cast<DeclRefExpr>(UO->getSubExpr());
2238 default:
return false;
2246 DRE = dyn_cast<DeclRefExpr>(
Call->getArg(0));
2256 SourceLocation BreakLoc;
2257 SourceLocation ContinueLoc;
2258 bool InSwitch =
false;
2261 BreakContinueFinder(Sema &S,
const Stmt* Body) :
2262 Inherited(S.Context) {
2266 typedef ConstEvaluatedExprVisitor<BreakContinueFinder> Inherited;
2268 void VisitContinueStmt(
const ContinueStmt* E) {
2272 void VisitBreakStmt(
const BreakStmt* E) {
2277 void VisitSwitchStmt(
const SwitchStmt* S) {
2282 if (
const Stmt *Cond = S->
getCond())
2287 if (
const Stmt *Body = S->
getBody())
2292 void VisitForStmt(
const ForStmt *S) {
2299 void VisitWhileStmt(
const WhileStmt *) {
2304 void VisitDoStmt(
const DoStmt *) {
2309 void VisitCXXForRangeStmt(
const CXXForRangeStmt *S) {
2322 void VisitObjCForCollectionStmt(
const ObjCForCollectionStmt *S) {
2331 bool ContinueFound() {
return ContinueLoc.
isValid(); }
2332 bool BreakFound() {
return BreakLoc.
isValid(); }
2333 SourceLocation GetContinueLoc() {
return ContinueLoc; }
2334 SourceLocation GetBreakLoc() {
return BreakLoc; }
2343 void CheckForRedundantIteration(
Sema &S,
Expr *Third,
Stmt *Body) {
2345 if (!Body || !Third)
return;
2351 if (!LastStmt)
return;
2357 bool LoopIncrement, LastIncrement;
2360 if (!ProcessIterationStmt(S, Third, LoopIncrement, LoopDRE))
return;
2361 if (!ProcessIterationStmt(S, LastStmt, LastIncrement, LastDRE))
return;
2365 if (LoopIncrement != LastIncrement ||
2368 if (BreakContinueFinder(S, Body).ContinueFound())
return;
2371 << LastDRE->
getDecl() << LastIncrement;
2390 const Decl *NonVarSeen =
nullptr;
2391 bool VarDeclSeen =
false;
2392 for (
auto *DI : DS->decls()) {
2393 if (
VarDecl *VD = dyn_cast<VarDecl>(DI)) {
2397 diag_compat::non_local_variable_decl_in_for);
2398 }
else if (!NonVarSeen) {
2412 if (NonVarSeen && !VarDeclSeen)
2414 diag_compat::non_variable_decl_in_for);
2418 if (!Second.
get().first)
2419 CheckForLoopConditionalStatement(*
this, Second.
get().second, third.
get(),
2421 CheckForRedundantIteration(*
this, third.
get(), Body);
2429 Body, ForLoc, LParenLoc, RParenLoc);
2449 if (
Decl->getType()->isUndeducedType()) {
2462 SemaRef.
Diag(Loc, DiagID) <<
Init->getType();
2466 Decl->getTypeSourceInfo()->getTypeLoc(),
Init, InitType, Info);
2469 SemaRef.
Diag(Loc, DiagID) <<
Init->getType();
2476 Decl->setType(InitType);
2494enum BeginEndFunction {
2503void NoteForRangeBeginEndFunction(
Sema &SemaRef,
Expr *E,
2504 BeginEndFunction BEF) {
2505 CallExpr *CE = dyn_cast<CallExpr>(E);
2513 std::string Description;
2514 bool IsTemplate =
false;
2521 SemaRef.
Diag(Loc, diag::note_for_range_begin_end)
2522 << BEF << IsTemplate << Description << E->
getType();
2539 Decl->setCXXForRangeImplicitVar(
true);
2542 Decl->setConstexpr(
true);
2555 const auto DepthStr = std::to_string(S->
getDepth() / 2);
2557 PP.getIdentifierInfo(std::string(
"__range") + DepthStr);
2561 diag::err_for_range_deduction_failure))
2583 return Diag(InitStmt->
getBeginLoc(), diag::err_objc_for_range_init_stmt)
2589 assert(DS &&
"first part of for range not a decl stmt");
2617 if (RangeDecl.isInvalid()) {
2623 ForLoc, CoawaitLoc, InitStmt, ColonLoc, RangeDecl.get(),
2625 nullptr,
nullptr, DS, RParenLoc, Kind,
2626 LifetimeExtendTemps);
2627 if (R.isInvalid()) {
2649 ExprResult *EndExpr, BeginEndFunction *BEF) {
2659 auto BuildBegin = [&] {
2663 BeginMemberLookup, CandidateSet,
2664 BeginRange, BeginExpr);
2669 << ColonLoc << BEF_begin << BeginRange->
getType();
2682 diag::err_for_range_iter_deduction_failure)) {
2683 NoteForRangeBeginEndFunction(SemaRef, BeginExpr->
get(), *BEF);
2689 auto BuildEnd = [&] {
2693 EndMemberLookup, CandidateSet,
2698 << ColonLoc << BEF_end << EndRange->
getType();
2702 diag::err_for_range_iter_deduction_failure)) {
2703 NoteForRangeBeginEndFunction(SemaRef, EndExpr->
get(), *BEF);
2723 if (BeginMemberLookup.
empty() != EndMemberLookup.
empty()) {
2728 auto BuildNonmember = [&](
2738 switch (BuildFound()) {
2745 SemaRef.
PDiag(diag::err_for_range_invalid)
2746 << BeginRange->
getType() << BEFFound),
2753 diag::note_for_range_member_begin_end_ignored)
2754 << BeginRange->
getType() << BEFFound;
2758 llvm_unreachable(
"unexpected ForRangeStatus");
2760 if (BeginMemberLookup.
empty())
2761 return BuildNonmember(BEF_end, EndMemberLookup, BuildEnd, BuildBegin);
2762 return BuildNonmember(BEF_begin, BeginMemberLookup, BuildBegin, BuildEnd);
2794 AdjustedRange = SemaRef.
BuildUnaryOp(S, RangeLoc, UO_Deref, Range);
2799 S, ForLoc, CoawaitLoc, InitStmt, LoopVarDecl, ColonLoc,
2808 SemaRef.
Diag(RangeLoc, diag::err_for_range_dereference)
2811 S, ForLoc, CoawaitLoc, InitStmt, LoopVarDecl, ColonLoc,
2817 if (Temporaries.empty())
2821 for (
auto *MTE : Temporaries)
2830 llvm::function_ref<
StmtResult()> RebuildWithDereference,
2850 QualType RangeType = Range->getType();
2853 diag::err_for_range_incomplete_type))
2858 const auto DepthStr = std::to_string(S->
getDepth() / 2);
2860 BeginName =
PP.getIdentifierInfo(std::string(
"__begin") + DepthStr);
2862 EndName =
PP.getIdentifierInfo(std::string(
"__end") + DepthStr);
2877 BeginExpr = BeginRangeRef;
2884 diag::err_for_range_iter_deduction_failure)) {
2885 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2893 Context, CAT->getSize(),
Context.getPointerDiffType(), RangeLoc);
2895 dyn_cast<VariableArrayType>(UnqAT)) {
2922 VAT->desugar(), RangeLoc))
2932 VAT->getElementType(), RangeLoc))
2940 SizeOfEachElementExprR.
get());
2947 llvm_unreachable(
"Unexpected array type in for-range");
2956 diag::err_for_range_iter_deduction_failure)) {
2957 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2963 BeginEndFunction BEFFailure;
2966 RangeType, BeginVar, EndVar, ColonLoc, CoawaitLoc,
2967 &CandidateSet, &BeginExpr, &EndExpr, &BEFFailure);
2970 BEFFailure == BEF_begin) {
2973 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Range)) {
2975 QualType ArrayTy = PVD->getOriginalType();
2976 QualType PointerTy = PVD->getType();
2978 Diag(Range->getBeginLoc(), diag::err_range_on_array_parameter)
2979 << RangeLoc << PVD << ArrayTy << PointerTy;
2980 Diag(PVD->getLocation(), diag::note_declared_at);
2988 if (RebuildWithDereference) {
2989 assert(RebuildResult);
2992 *RebuildResult = SR;
3000 Expr *Range = BEFFailure ? EndRangeRef.
get() : BeginRangeRef.
get();
3003 PDiag(diag::err_for_range_invalid)
3004 << RangeLoc << Range->getType()
3014 "invalid range expression in for loop");
3016 return {BeginVar, EndVar, BeginExpr.
get(), EndExpr.
get()};
3024 if (
auto *DD = dyn_cast<DecompositionDecl>(LoopVar))
3025 for (
auto *Binding : DD->bindings()) {
3026 if (!Binding->isParameterPack())
3027 Binding->setType(
Context.DependentTy);
3065 }
else if (!BeginDeclStmt.
get()) {
3067 auto RebuildWithDereference = [&] {
3069 *
this, S, ForLoc, CoawaitLoc, InitStmt, LoopVarDecl, ColonLoc,
3074 S, RangeVar, ColonLoc, CoawaitLoc, LifetimeExtendTemps, Kind,
3075 false, &RebuildResult, RebuildWithDereference);
3078 return RebuildResult;
3084 auto [BeginVar, EndVar, BeginExpr, EndExpr] = ForRangeInfo;
3086 QualType BeginType = BeginVar->getType(), EndType = EndVar->getType();
3087 if (!
Context.hasSameType(BeginType, EndType)) {
3088 DiagCompat(RangeLoc, diag_compat::for_range_begin_end_types_differ)
3089 << BeginType << EndType;
3090 NoteForRangeBeginEndFunction(*
this, BeginExpr, BEF_begin);
3091 NoteForRangeBeginEndFunction(*
this, EndExpr, BEF_end);
3111 NotEqExpr =
ActOnBinOp(S, ColonLoc, tok::exclaimequal,
3112 BeginRef.
get(), EndRef.
get());
3119 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
3120 << RangeLoc << diag::InvalidRangeForIterator::OpNotEq
3122 NoteForRangeBeginEndFunction(*
this, BeginExpr, BEF_begin);
3123 if (!
Context.hasSameType(BeginType, EndType))
3124 NoteForRangeBeginEndFunction(*
this, EndExpr, BEF_end);
3135 if (!IncrExpr.isInvalid() && CoawaitLoc.
isValid())
3140 if (!IncrExpr.isInvalid())
3142 if (IncrExpr.isInvalid()) {
3143 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
3144 << RangeLoc << diag::InvalidRangeForIterator::OpAdvance
3146 NoteForRangeBeginEndFunction(*
this, BeginExpr, BEF_begin);
3158 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
3159 << RangeLoc << diag::InvalidRangeForIterator::OpDeref
3161 NoteForRangeBeginEndFunction(*
this, BeginExpr, BEF_begin);
3171 NoteForRangeBeginEndFunction(*
this, BeginExpr, BEF_begin);
3188 LifetimeExtendTemps);
3191 InitStmt, RangeDS, cast_or_null<DeclStmt>(BeginDeclStmt.
get()),
3192 cast_or_null<DeclStmt>(EndDeclStmt.
get()), NotEqExpr.
get(),
3193 IncrExpr.get(), LoopVarDS,
nullptr, ForLoc, CoawaitLoc,
3194 ColonLoc, RParenLoc);
3213 if (
auto Cleanups = dyn_cast<ExprWithCleanups>(InitExpr))
3214 if (!Cleanups->cleanupsHaveSideEffects())
3215 InitExpr = Cleanups->getSubExpr();
3218 dyn_cast<MaterializeTemporaryExpr>(InitExpr);
3249 ReferenceReturnType = ReturnType;
3252 if (!ReferenceReturnType.
isNull()) {
3257 diag::warn_for_range_const_ref_binds_temp_built_from_ref)
3258 << VD << VariableType << ReferenceReturnType;
3271 SemaRef.
Diag(VD->
getLocation(), diag::warn_for_range_ref_binds_ret_temp)
3272 << VD << RangeInitType;
3285 return RD->hasAttr<TrivialABIAttr>();
3302 if (!CE->getConstructor()->isCopyConstructor())
3304 }
else if (
const CastExpr *CE = dyn_cast<CastExpr>(InitExpr)) {
3305 if (CE->getCastKind() != CK_LValueToRValue)
3323 << VD << VariableType;
3345 diag::warn_for_range_const_ref_binds_temp_built_from_ref, Loc) &&
3346 SemaRef.
Diags.
isIgnored(diag::warn_for_range_ref_binds_ret_temp, Loc) &&
3369 ForStmt->getRangeInit()->getType());
3386 diag::warn_empty_range_based_for_body);
3400 if (
getCurScope()->isInOpenACCComputeConstructScope())
3434 if (
getCurScope()->isInOpenACCComputeConstructScope())
3441 const Scope &DestScope,
3442 unsigned DeferJumpKind) {
3445 S.
Diag(Loc, diag::warn_jump_out_of_seh_finally);
3454 if (DestScope.
Contains(*Parent) || &DestScope == Parent)
3455 S.
Diag(Loc, diag::err_jump_out_of_defer_stmt) << DeferJumpKind;
3464 assert(
Target &&
"not a named break/continue?");
3474 S.
Diag(KWLoc, diag::err_acc_branch_in_out_compute_construct)
3487 if (IsContinue && !
Found->isContinueScope()) {
3488 S.
Diag(LabelLoc, diag::err_continue_switch);
3494 S.
Diag(LabelLoc, diag::err_break_continue_label_not_found) << IsContinue;
3513 return StmtError(
Diag(ContinueLoc, diag::err_continue_not_in_loop));
3521 Diag(ContinueLoc, diag::err_acc_branch_in_out_compute_construct)
3525 diag::DeferJumpKind::Continue);
3545 return StmtError(
Diag(BreakLoc, diag::err_break_not_in_loop_or_switch));
3549 return StmtError(
Diag(BreakLoc, diag::err_omp_loop_cannot_use_stmt)
3563 Diag(BreakLoc, diag::err_acc_branch_in_out_compute_construct)
3567 diag::DeferJumpKind::Break);
3578 const auto *DR = dyn_cast<DeclRefExpr>(E->
IgnoreParens());
3579 if (!DR || DR->refersToEnclosingVariableOrCapture())
3581 const auto *VD = dyn_cast<VarDecl>(DR->getDecl());
3604 if (VD->
getKind() == Decl::ParmVar)
3606 else if (VD->
getKind() != Decl::Var)
3619 if (VD->
hasAttr<BlocksAttr>())
3655 auto invalidNRVO = [&] {
3664 if ((ReturnType->
getTypeClass() == Type::TypeClass::Auto &&
3667 return invalidNRVO();
3673 return invalidNRVO();
3679 !
Context.hasSameUnqualifiedType(ReturnType, VDType))
3693 const auto *Step = llvm::find_if(
Seq.steps(), [](
const auto &Step) {
3694 return Step.Kind == InitializationSequence::SK_ConstructorInitialization ||
3695 Step.Kind == InitializationSequence::SK_UserConversion;
3697 if (Step !=
Seq.step_end()) {
3698 const auto *FD = Step->Function.Function;
3709 bool SupressSimplerImplicitMoves) {
3715 Expr *InitExpr = &AsRvalue;
3717 Value->getBeginLoc());
3719 auto Res =
Seq.getFailedOverloadResult();
3730 return Seq.Perform(*
this, Entity, Kind,
Value);
3750 bool SupressSimplerImplicitMoves) {
3758 bool HasDeducedReturnType =
3768 RetValExp = ER.
get();
3774 if (HasDeducedReturnType) {
3787 assert(AT &&
"lost auto type from lambda return type");
3803 RetValExp =
Result.get();
3818 Diag(ReturnLoc, diag::err_lambda_return_init_list)
3820 RetValExp =
nullptr;
3833 if (
auto *CurBlock = dyn_cast<BlockScopeInfo>(CurCap)) {
3835 Diag(ReturnLoc, diag::err_noreturn_has_return_expr)
3836 << diag::FalloffFunctionKind::Block;
3839 }
else if (
auto *CurRegion = dyn_cast<CapturedRegionScopeInfo>(CurCap)) {
3840 Diag(ReturnLoc, diag::err_return_in_captured_stmt) << CurRegion->getRegionName();
3843 assert(CurLambda &&
"unknown kind of captured scope");
3847 Diag(ReturnLoc, diag::err_noreturn_has_return_expr)
3848 << diag::FalloffFunctionKind::Lambda;
3860 if (isa_and_nonnull<InitListExpr>(RetValExp)) {
3861 Diag(ReturnLoc, diag::err_return_block_has_expr)
3862 << (CurLambda !=
nullptr);
3863 RetValExp =
nullptr;
3868 Diag(ReturnLoc, diag::ext_return_has_void_expr) <<
"literal" << 2;
3870 Diag(ReturnLoc, diag::err_return_block_has_expr)
3871 << (CurLambda !=
nullptr);
3872 RetValExp =
nullptr;
3875 }
else if (!RetValExp) {
3876 return StmtError(
Diag(ReturnLoc, diag::err_block_return_missing_expr));
3889 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
3894 RetValExp = Res.
get();
3895 CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc);
3903 RetValExp = ER.
get();
3917 if (
auto *CurBlock = dyn_cast<BlockScopeInfo>(CurCap);
3920 CurBlock->TheDecl->setInvalidDecl();
3940 LocalTypedefNameReferencer(
Sema &S) : S(S) {}
3941 bool VisitRecordType(RecordType *RT)
override;
3946bool LocalTypedefNameReferencer::VisitRecordType(RecordType *RT) {
3947 auto *
R = dyn_cast<CXXRecordDecl>(RT->getDecl());
3948 if (!R || !
R->isLocalClass() || !
R->isLocalClass()->isExternallyVisible() ||
3949 R->isDependentType())
3951 for (
auto *TmpD :
R->decls())
3952 if (
auto *
T = dyn_cast<TypedefNameDecl>(TmpD))
3954 S.MarkAnyDeclReferenced(
T->getLocation(),
T,
false);
3968 Expr *RetExpr,
const AutoType *AT) {
3975 if (isa_and_nonnull<InitListExpr>(RetExpr)) {
3980 : diag::err_auto_fn_return_init_list)
3990 assert(AT->isDeduced() &&
"should have deduced to dependent type");
4004 Diag(ReturnLoc, diag::err_auto_fn_return_void_but_not_auto)
4020 if (FindResult.Expression)
4021 TemplateSpecLoc = FindResult.Expression->getNameLoc();
4025 OrigResultType, RetExpr,
Deduced, Info,
false,
4041 Diag(ReturnLoc, diag::err_typecheck_missing_return_type_incompatible)
4044 Diag(ReturnLoc, diag::err_auto_fn_different_deductions)
4045 << (AT->isDecltypeAuto() ? 1 : 0) << Info.
SecondArg
4059 LocalTypedefNameReferencer(*this).TraverseType(RetExpr->
getType());
4076 diag::warn_qual_return_type,
4088 if (
getCurScope()->isInOpenACCComputeConstructScope())
4090 Diag(ReturnLoc, diag::err_acc_branch_in_out_compute_construct)
4097 "first coroutine location not set");
4098 Diag(ReturnLoc, diag::err_return_in_coroutine);
4103 CheckInvalidBuiltinCountedByRef(RetVal.
get(),
4108 if (R.isInvalid() ||
ExprEvalContexts.back().isDiscardedStatementContext())
4114 CurScope->updateNRVOCandidate(VD);
4117 diag::DeferJumpKind::Return);
4132 [[maybe_unused]]
Scope *CurScope) {
4149 if (DC->isStdNamespace())
4156 bool AllowRecovery) {
4164 bool SupressSimplerImplicitMoves =
4172 SupressSimplerImplicitMoves);
4176 const AttrVec *Attrs =
nullptr;
4177 bool isObjCMethod =
false;
4185 Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr) << FD;
4186 if (FD->
isMain() && RetValExp)
4188 Diag(ReturnLoc, diag::warn_main_returns_bool_literal)
4190 if (FD->
hasAttr<CmseNSEntryAttr>() && RetValExp) {
4192 if (RT->getDecl()->isOrContainsUnion())
4197 FnRetType = MD->getReturnType();
4198 isObjCMethod =
true;
4200 Attrs = &MD->getAttrs();
4201 if (MD->hasRelatedResultType() && MD->getClassInterface()) {
4205 RelatedRetType =
Context.getObjCInterfaceType(MD->getClassInterface());
4206 RelatedRetType =
Context.getObjCObjectPointerType(RelatedRetType);
4212 const auto *ATy = dyn_cast<ArrayType>(RetValExp->
getType());
4213 if (ATy && ATy->getElementType().isWebAssemblyReferenceType()) {
4214 Diag(ReturnLoc, diag::err_wasm_table_art) << 1;
4228 RetValExp = ER.
get();
4254 AT->isDeduced() ? FnRetType :
QualType());
4255 if (Recovery.isInvalid())
4257 RetValExp = Recovery.get();
4273 if (
auto *ILE = dyn_cast<InitListExpr>(RetValExp)) {
4278 int FunctionKind = 0;
4286 Diag(ReturnLoc, diag::err_return_init_list)
4290 RetValExp = AllowRecovery
4292 ILE->getRBraceLoc(), ILE->inits())
4297 unsigned D = diag::ext_return_has_expr;
4302 D = diag::err_ctor_dtor_returns_void;
4304 D = diag::ext_return_has_void_expr;
4311 RetValExp =
Result.get();
4316 if (D == diag::err_ctor_dtor_returns_void) {
4318 Diag(ReturnLoc, D) << CurDecl << isa<CXXDestructorDecl>(CurDecl)
4322 else if (D != diag::ext_return_has_void_expr ||
4326 int FunctionKind = 0;
4344 RetValExp = ER.
get();
4350 }
else if (!RetValExp && !HasDependentReturnType) {
4355 Diag(ReturnLoc, diag::err_constexpr_return_missing_expr)
4361 unsigned DiagID =
getLangOpts().C99 ? diag::ext_return_missing_expr
4362 : diag::warn_return_missing_expr;
4366 "Not in a FunctionDecl or ObjCMethodDecl?");
4367 bool IsMethod = FD ==
nullptr;
4370 Diag(ReturnLoc, DiagID) << ND << IsMethod;
4376 assert(RetValExp || HasDependentReturnType);
4377 QualType RetType = RelatedRetType.
isNull() ? FnRetType : RelatedRetType;
4390 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
4393 RetValExp->
getEndLoc(), RetValExp, RetType);
4404 if (!RelatedRetType.
isNull()) {
4415 CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc, isObjCMethod, Attrs,
4424 RetValExp = ER.
get();
4431 if (
Result->getNRVOCandidate())
4442 Stmt *HandlerBlock) {
4445 CXXCatchStmt(CatchLoc, cast_or_null<VarDecl>(ExDecl), HandlerBlock);
4449class CatchHandlerType {
4451 LLVM_PREFERRED_TYPE(
bool)
4452 unsigned IsPointer : 1;
4454 friend struct llvm::DenseMapInfo<CatchHandlerType>;
4472 CatchHandlerType(
QualType QT,
bool IsPointer)
4473 : QT(QT), IsPointer(IsPointer) {}
4475 QualType underlying()
const {
return QT; }
4476 bool isPointer()
const {
return IsPointer; }
4478 friend bool operator==(
const CatchHandlerType &LHS,
4479 const CatchHandlerType &RHS) {
4481 if (LHS.IsPointer != RHS.IsPointer)
4484 return LHS.QT == RHS.QT;
4490template <>
struct DenseMapInfo<CatchHandlerType> {
4492 return DenseMapInfo<QualType>::getHashValue(
Base.underlying());
4496 const CatchHandlerType &RHS) {
4503class CatchTypePublicBases {
4504 const llvm::DenseMap<QualType, CXXCatchStmt *> &TypesToCheck;
4506 CXXCatchStmt *FoundHandler;
4507 QualType FoundHandlerType;
4508 QualType TestAgainstType;
4511 CatchTypePublicBases(
const llvm::DenseMap<QualType, CXXCatchStmt *> &
T,
4513 : TypesToCheck(
T), FoundHandler(
nullptr), TestAgainstType(QT) {}
4515 CXXCatchStmt *getFoundHandler()
const {
return FoundHandler; }
4516 QualType getFoundHandlerType()
const {
return FoundHandlerType; }
4518 bool operator()(
const CXXBaseSpecifier *S, CXXBasePath &) {
4521 const auto &M = TypesToCheck;
4522 auto I = M.find(Check);
4534 if (I->second->getCaughtType()->isPointerType() ==
4536 FoundHandler = I->second;
4537 FoundHandlerType = Check;
4555 Diag(TryLoc, diag::err_mixing_cxx_try_seh_try) << 0;
4559 const unsigned NumHandlers = Handlers.size();
4560 assert(!Handlers.empty() &&
4561 "The parser shouldn't call this if there are no handlers.");
4563 llvm::DenseMap<QualType, CXXCatchStmt *> HandledBaseTypes;
4564 llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> HandledTypes;
4565 for (
unsigned i = 0; i < NumHandlers; ++i) {
4572 if (i < NumHandlers - 1)
4586 QualType Underlying = HandlerCHT.underlying();
4588 if (!RD->hasDefinition())
4597 CatchTypePublicBases CTPB(HandledBaseTypes,
4599 if (RD->lookupInBases(CTPB, Paths)) {
4604 diag::warn_exception_caught_by_earlier_handler)
4607 diag::note_previous_exception_handler)
4619 auto R = HandledTypes.insert(
4624 diag::warn_exception_caught_by_earlier_handler)
4627 diag::note_previous_exception_handler)
4639 const llvm::Triple &
T =
Context.getTargetInfo().getTriple();
4640 const bool IsOpenMPGPUTarget =
4650 if (IsOpenMPGPUTarget)
4651 targetDiag(Loc, diag::warn_exceptions_not_valid_on_target)
4652 <<
T.str() << IsTry;
4655 Diag(Loc, diag::err_omp_simd_region_cannot_use_exceptions) << IsTry;
4659 if (IsOpenMPGPUTarget)
4672 targetDiag(Loc, diag::err_hlsl_exceptions) << IsTry;
4677 targetDiag(Loc, diag::err_exceptions_disabled) << IsTry;
4682 assert(TryBlock && Handler);
4709 Diag(TryLoc, diag::err_seh_try_outside_functions);
4712 if (!
Context.getTargetInfo().isSEHTrySupported())
4713 Diag(TryLoc, diag::err_seh_try_unsupported);
4720 assert(FilterExpr &&
Block);
4724 Diag(FilterExpr->
getExprLoc(), diag::err_filter_expression_integral)
4746 Scope *SEHTryParent = CurScope;
4748 SEHTryParent = SEHTryParent->
getParent();
4750 return StmtError(
Diag(Loc, diag::err_ms___leave_not_in___try));
4752 diag::DeferJumpKind::SEHLeave);
4764 QualifierLoc, NameInfo,
4782 unsigned NumParams) {
4800 assert(NumParams > 0 &&
"CapturedStmt requires context parameter");
4810 bool HasError =
false;
4819 if (
auto *BD = dyn_cast<BindingDecl>(CapVar)) {
4839 if (
auto *DD = dyn_cast<DecompositionDecl>(CapVar)) {
4840 if (!CapturedDecomposed.insert(DD).second) {
4873 if (
const auto *DD = dyn_cast<DecompositionDecl>(DSAVar))
4874 if (!DD->bindings().empty())
4875 DSAVar = *DD->bindings().begin();
4883 CaptureInits.push_back(
Init.get());
4888static std::optional<int>
4905 unsigned NumParams) {
4907 Diag(Loc, diag::err_sme_openmp_captured_region) << *ErrorIndex;
4940 unsigned OpenMPCaptureLevel) {
4942 Diag(Loc, diag::err_sme_openmp_captured_region) << *ErrorIndex;
4949 bool ContextIsFound =
false;
4950 unsigned ParamNum = 0;
4953 I != E; ++I, ++ParamNum) {
4954 if (I->second.isNull()) {
4955 assert(!ContextIsFound &&
4956 "null type has been found already for '__context' parameter");
4967 ContextIsFound =
true;
4977 assert(ContextIsFound &&
"no null type for '__context' parameter");
4978 if (!ContextIsFound) {
5009 Record->setInvalidDecl();
5035 Captures, CaptureInits, CD, RD);
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines the clang::Expr interface and subclasses for C++ expressions.
Result
Implement __builtin_bit_cast and related operations.
llvm::MachO::Target Target
llvm::MachO::Record Record
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.
This file declares semantic analysis functions specific to BPF.
This file declares semantic analysis for CUDA constructs.
This file declares semantic analysis for HLSL constructs.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
static bool CmpEnumVals(const std::pair< llvm::APSInt, EnumConstantDecl * > &lhs, const std::pair< llvm::APSInt, EnumConstantDecl * > &rhs)
CmpEnumVals - Comparison predicate for sorting enumeration values.
static bool FinishForRangeVarDecl(Sema &SemaRef, VarDecl *Decl, Expr *Init, SourceLocation Loc, int DiagID)
Finish building a variable declaration for a for-range statement.
static bool CmpCaseVals(const std::pair< llvm::APSInt, CaseStmt * > &lhs, const std::pair< llvm::APSInt, CaseStmt * > &rhs)
CmpCaseVals - Comparison predicate for sorting case values.
SmallVector< std::pair< llvm::APSInt, EnumConstantDecl * >, 64 > EnumValsTy
static bool ShouldDiagnoseSwitchCaseNotInEnum(const Sema &S, const EnumDecl *ED, const Expr *CaseExpr, EnumValsTy::iterator &EI, EnumValsTy::iterator &EIEnd, const llvm::APSInt &Val)
Returns true if we should emit a diagnostic about this case expression not being a part of the enum u...
static bool DiagnoseUnusedComparison(Sema &S, const Expr *E)
Diagnose unused comparisons, both builtin and overloaded operators.
static bool CheckRedundantDeferStmt(Sema &S, Stmt *Body)
static void CheckLoopBody(Sema &S, Expr *CondExpr, Stmt *Body)
static Scope * FindLabeledBreakContinueScope(Sema &S, Scope *CurScope, SourceLocation KWLoc, LabelDecl *Target, SourceLocation LabelLoc, bool IsContinue)
static bool EqEnumVals(const std::pair< llvm::APSInt, EnumConstantDecl * > &lhs, const std::pair< llvm::APSInt, EnumConstantDecl * > &rhs)
EqEnumVals - Comparison preficate for uniqing enumeration values.
static std::optional< int > isOpenMPCapturedRegionInArmSMEFunction(Sema const &S, CapturedRegionKind Kind)
static bool hasDeducedReturnType(FunctionDecl *FD)
Determine whether the declared return type of the specified function contains 'auto'.
static bool DiagnoseSwitchCaseInExpansionStmt(Sema &S, SourceLocation KwLoc, bool IsDefault)
static bool ObjCEnumerationCollection(Expr *Collection)
static void DiagnoseForRangeConstVariableCopies(Sema &SemaRef, const VarDecl *VD)
static StmtResult RebuildForRangeWithDereference(Sema &SemaRef, Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, Stmt *LoopVarDecl, SourceLocation ColonLoc, Expr *Range, SourceLocation RangeLoc, SourceLocation RParenLoc)
Speculatively attempt to dereference an invalid range expression.
static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond, const Expr *Case)
static void DiagnoseForRangeReferenceVariableCopies(Sema &SemaRef, const VarDecl *VD, QualType RangeInitType)
static void DiagnoseForRangeVariableCopies(Sema &SemaRef, const CXXForRangeStmt *ForStmt)
DiagnoseForRangeVariableCopies - Diagnose three cases and fixes for them.
static bool CheckSimplerImplicitMovesMSVCWorkaround(const Sema &S, const Expr *E)
static bool VerifyInitializationSequenceCXX98(const Sema &S, const InitializationSequence &Seq)
Verify that the initialization sequence that was picked for the first overload resolution is permissi...
static QualType GetTypeBeforeIntegralPromotion(const Expr *&E)
GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of potentially integral-promoted expr...
static Sema::ForRangeStatus BuildNonArrayForRange(Sema &SemaRef, Expr *BeginRange, Expr *EndRange, QualType RangeType, VarDecl *BeginVar, VarDecl *EndVar, SourceLocation ColonLoc, SourceLocation CoawaitLoc, OverloadCandidateSet *CandidateSet, ExprResult *BeginExpr, ExprResult *EndExpr, BeginEndFunction *BEF)
Create the initialization, compare, and increment steps for the range-based for loop expression.
static bool hasTrivialABIAttr(QualType VariableType)
Determines whether the VariableType's declaration is a record with the clang::trivial_abi attribute.
static void CheckJumpOutOfSEHFinallyOrDefer(Sema &S, SourceLocation Loc, const Scope &DestScope, unsigned DeferJumpKind)
static StringRef GetDeferKeywordSpelling(Sema &S, SourceLocation DeferLoc)
static void AdjustAPSInt(llvm::APSInt &Val, unsigned BitWidth, bool IsSigned)
static bool buildCapturedStmtCaptureList(Sema &S, CapturedRegionScopeInfo *RSI, SmallVectorImpl< CapturedStmt::Capture > &Captures, SmallVectorImpl< Expr * > &CaptureInits)
static bool DiagnoseNoDiscard(Sema &S, const NamedDecl *OffendingDecl, const WarnUnusedResultAttr *A, SourceLocation Loc, SourceRange R1, SourceRange R2, bool IsCtor)
static void checkCaseValue(Sema &S, SourceLocation Loc, const llvm::APSInt &Val, unsigned UnpromotedWidth, bool UnpromotedSign)
Check the specified case value is in range for the given unpromoted switch type.
Defines the Objective-C statement AST node classes.
Defines the clang::TypeLoc interface and its subclasses.
Allows QualTypes to be sorted and hence used in maps and sets.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType getCanonicalTagType(const TagDecl *TD) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Attr - This represents one attribute.
SourceLocation getLocation() const
SourceRange getRange() const
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condition evaluates to false; ...
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
A builtin binary operation expression such as "x + y" or "x <= y".
SourceLocation getExprLoc() const
BreakStmt - This represents a break.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
void setOrigin(const CXXRecordDecl *Rec)
bool isAmbiguous(CanQualType BaseType) const
Determine whether the path from the most-derived type to the given base type is ambiguous (i....
QualType getType() const
Retrieves the type of the base class.
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
Represents binding an expression to a temporary.
CXXCatchStmt - This represents a C++ catch block.
SourceLocation getBeginLoc() const LLVM_READONLY
VarDecl * getExceptionDecl() const
QualType getCaughtType() const
Represents a call to a C++ constructor.
Represents a C++ conversion function within a class.
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
DeclStmt * getBeginStmt()
DeclStmt * getRangeStmt()
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Represents a call to a member function that may be written either with member call syntax (e....
A call to an overloaded operator written using operator syntax.
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
An expression "T()" which creates an rvalue of a non-class type T.
Represents a C++ nested-name-specifier or a global scope specifier.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, CompoundStmt *tryBlock, ArrayRef< Stmt * > handlers)
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CanQual< Type > CreateUnsafe(QualType Other)
Represents the body of a CapturedStmt, and serves as its DeclContext.
static DeclContext * castToDeclContext(const CapturedDecl *D)
void setContextParam(unsigned i, ImplicitParamDecl *P)
void setParam(unsigned i, ImplicitParamDecl *P)
static CapturedDecl * Create(ASTContext &C, DeclContext *DC, unsigned NumParams)
Describes the capture of either a variable, or 'this', or variable-length array type.
This captures a statement into a function.
Stmt * getCapturedStmt()
Retrieve the statement being captured.
static CapturedStmt * Create(const ASTContext &Context, Stmt *S, CapturedRegionKind Kind, ArrayRef< Capture > Captures, ArrayRef< Expr * > CaptureInits, CapturedDecl *CD, RecordDecl *RD)
CaseStmt - Represent a case statement.
static CaseStmt * Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs, SourceLocation caseLoc, SourceLocation ellipsisLoc, SourceLocation colonLoc)
Build a case statement.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
CastKind getCastKind() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression representing the value of the expression if the condition eva...
Expr * getCond() const
getCond - Return the expression representing the condition for the ?
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression representing the value of the expression if the condition eval...
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
Represents the canonical version of C arrays with a specified constant size.
ContinueStmt - This represents a continue.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
void addDecl(Decl *D)
Add the declaration D into this context.
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
bool isExpansionStmt() const
bool isSingleDecl() const
A reference to a declared variable, function, enum, etc.
SourceLocation getLocation() const
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
bool isSingleDecl() const
isSingleDecl - This method returns true if this DeclStmt refers to a single Decl.
const Decl * getSingleDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
static Decl * castFromDeclContext(const DeclContext *)
bool isInvalidDecl() const
SourceLocation getLocation() const
void setImplicit(bool I=true)
void setLocation(SourceLocation L)
DeclContext * getDeclContext()
SourceLocation getTypeSpecEndLoc() const
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
TypeSourceInfo * getTypeSourceInfo() const
SourceLocation getDefaultLoc() const
static DeferStmt * Create(ASTContext &Context, SourceLocation DeferLoc, Stmt *Body)
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
DoStmt - This represents a 'do/while' stmt.
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isClosed() const
Returns true if this enum is either annotated with enum_extensibility(closed) or isn't annotated with...
EvaluatedExprVisitor - This class visits 'Expr *'s.
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
@ SE_AllowSideEffects
Allow any unmodeled side effect.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isUnusedResultAWarning(const Expr *&WarnExpr, SourceLocation &Loc, SourceRange &R1, SourceRange &R2, ASTContext &Ctx) const
isUnusedResultAWarning - Return true if this immediate expression should be warned about if the resul...
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Decl * getReferencedDeclOfCallee()
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool isKnownToHaveBooleanValue(bool Semantic=true) const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
Represents difference between two FPOptions values.
FPOptionsOverride getChangesFrom(const FPOptions &Base) const
Return difference with the given option set.
Represents a member of a struct/union/class.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
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.
ForStmt - This represents a 'for (init;cond;inc)' stmt.
SourceLocation getRParenLoc() const
SourceLocation getBeginLoc() const
FullExpr - Represents a "full-expression" node.
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
void setUsesSEHTry(bool UST)
bool isNoReturn() const
Determines whether this function is known to be 'noreturn', through an attribute on its declaration o...
QualType getReturnType() const
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
Represents a prototype with parameter type info, e.g.
Declaration of a template function.
FunctionType - C99 6.7.5.3 - Function Declarators.
static StringRef getNameForCallConv(CallingConv CC)
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
QualType getReturnType() const
GotoStmt - This represents a direct goto.
One of these records is kept for each identifier that is lexed.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static IfStmt * Create(const ASTContext &Ctx, SourceLocation IL, IfStatementKind Kind, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LPL, SourceLocation RPL, Stmt *Then, SourceLocation EL=SourceLocation(), Stmt *Else=nullptr)
Create an IfStmt.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
IndirectGotoStmt - This represents an indirect goto.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
Describes the sequence of initializations required to initialize a given object or reference with a s...
Describes an entity that is being initialized.
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, QualType Type)
Create the initialization entity for the result of a function.
static InitializedEntity InitializeRelatedResult(ObjCMethodDecl *MD, QualType Type)
Create the initialization entity for a related result.
unsigned allocateManglingNumber() const
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the declaration of a label.
void setLocStart(SourceLocation L)
LabelStmt * getStmt() const
void setStmt(LabelStmt *T)
bool isMSAsmLabel() const
LabelStmt - Represents a label, which has a substatement.
Represents the results of name lookup.
bool empty() const
Return true if no decls were found.
SourceLocation getKwLoc() const
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
This represents a decl that may have a name.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const
Determine if the declaration obeys the reserved identifier rules of the given language.
A C++ nested-name-specifier augmented with source location information.
NullStmt - This is the null statement ";": C99 6.8.3p3.
An expression that sends a message to the given Objective-C object or class.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
const Expr * getSubExpr() const
Represents a parameter to a function.
ParsedAttributes - A collection of parsed attributes.
Wrapper for source info for pointers.
SourceLocation getStarLoc() const
IdentifierTable & getIdentifierTable()
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
ArrayRef< Expr * > semantics()
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
QualType withConst() const
bool isTriviallyCopyConstructibleType(const ASTContext &Context) const
Return true if this is a trivially copyable type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isConstQualified() const
Determine whether this type is const-qualified.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
Represents a struct/union/class.
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
virtual void completeDefinition()
Note that the definition of this type is now complete.
void setCapturedRecord()
Mark the record as a record for captured variables in CapturedStmt construct.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Create a return statement.
static SEHExceptStmt * Create(const ASTContext &C, SourceLocation ExceptLoc, Expr *FilterExpr, Stmt *Block)
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Represents a __leave statement.
static SEHTryStmt * Create(const ASTContext &C, bool isCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Scope - A scope is a transient data structure that is used while parsing the program.
unsigned getDepth() const
Returns the depth of this scope. The translation-unit has scope depth 0.
bool Contains(const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
LabelDecl * getPrecedingLabel() const
Get the label that precedes this scope.
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by.
bool isLoopScope() const
Return true if this scope is a loop.
bool isSEHTryScope() const
Determine whether this scope is a SEH '__try' block.
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
bool isBreakOrContinueScope() const
Determine whether this is a scope which can have 'break' or 'continue' statements embedded into it.
bool isFunctionScope() const
isFunctionScope() - Return true if this scope is a function scope.
bool isOpenACCComputeConstructScope() const
Determine whether this scope is the statement associated with an OpenACC Compute construct directive.
bool isOpenMPLoopScope() const
Determine whether this scope is a loop having OpenMP loop directive attached.
@ SwitchScope
This is a scope that corresponds to a switch statement.
static bool hasPreserveEnumValue(const Stmt *S)
ExprResult verifyCaseExpr(Expr *E)
A generic diagnostic builder for errors which may or may not be deferred.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
Emit a compatibility diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
CUDAFunctionTarget CurrentTarget()
Gets the CUDA target for the current context.
SemaDiagnosticBuilder DiagIfDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as device c...
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
bool inferObjCARCLifetime(ValueDecl *decl)
void ActOnOpenMPLoopInitialization(SourceLocation ForLoc, Stmt *Init)
Check if the current region is an OpenMP loop region and if it is, mark loop control variable,...
void setOpenMPCaptureKind(FieldDecl *FD, const ValueDecl *D, unsigned Level)
Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.) for FD based on DSA for the...
std::pair< VarDecl *, Expr * > get() const
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Sema - This implements semantic analysis and AST building for C.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
SmallVector< Scope *, 2 > CurrentSEHFinally
Stack of active SEH __finally scopes. Can be empty.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Scope * getCurScope() const
Retrieve the parser's current scope.
StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope, LabelDecl *Label, SourceLocation LabelLoc)
void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs, SmallVectorImpl< const Attr * > &OutAttrs)
Process the attributes before creating an attributed statement.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
Unary Operators. 'Tok' is the token for the operator.
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored,...
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc, StringRef Keyword)
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
StmtResult BuildCXXForRangeRangeVar(Scope *S, Expr *Range, QualType Type, bool IsConstexpr=false)
Build the range variable of a range-based for loop or iterating expansion statement and return its De...
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
llvm::DenseMap< const EnumDecl *, llvm::SmallVector< llvm::APSInt > > AssignEnumCache
A cache of enumerator values for enums checked by -Wassign-enum.
StmtResult ActOnForEachLValueExpr(Expr *E)
In an Objective C collection iteration statement: for (x in y) x can be an arbitrary l-value expressi...
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl)
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
@ Switch
An integral condition for a 'switch' statement.
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA)
Check whether the given statement can have musttail applied to it, issuing a diagnostic and returning...
StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope, LabelDecl *Label, SourceLocation LabelLoc)
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, Scope *CurScope)
void setFunctionHasBranchIntoScope()
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
StmtResult BuildIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
Look for instances where it is likely the comma operator is confused with another operator.
void DiagnoseExceptionUse(SourceLocation Loc, bool IsTry)
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
bool DiagIfReachable(SourceLocation Loc, ArrayRef< const Stmt * > Stmts, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the statements's reachability analysis.
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
void ActOnCapturedRegionError()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
void PopExpressionEvaluationContext()
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
FieldDecl * BuildCaptureField(RecordDecl *RD, const sema::Capture &Capture, bool IsOpenMP=false)
Build a FieldDecl suitable to hold the given capture.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
void setFunctionHasIndirectGoto()
ExprResult BuildCaptureInit(const sema::Capture &Capture, SourceLocation ImplicitCaptureLoc, bool IsOpenMPMapping=false)
Initialize the given capture with a suitable expression.
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
NamedReturnInfo getNamedReturnInfo(Expr *&E, SimplerImplicitMoveMode Mode=SimplerImplicitMoveMode::Normal)
Determine whether the given expression might be move-eligible or copy-elidable in either a (co_)retur...
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused,...
FPOptions & getCurFPFeatures()
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
@ UPPC_Expression
An arbitrary expression.
const LangOptions & getLangOpts() const
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
const LangOptions & LangOpts
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
bool DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD, SourceLocation ReturnLoc, Expr *RetExpr, const AutoType *AT)
Deduce the return type for a function from a returned expression, per C++1y [dcl.spec....
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
StmtResult ActOnExprStmtError()
const VarDecl * getCopyElisionCandidate(NamedReturnInfo &Info, QualType ReturnType)
Updates given NamedReturnInfo's move-eligible and copy-elidable statuses, considering the function re...
NamedDecl * getCurFunctionOrMethodDecl() const
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in,...
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, unsigned NumParams)
sema::FunctionScopeInfo * getCurFunction() const
void PushCompoundScope(bool IsStmtExpr)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr)
DiagnoseAssignmentEnum - Warn if assignment to enum is a constant integer not in the range of enum va...
StmtResult ActOnEndOfDeferStmt(Stmt *Body, Scope *CurScope)
ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body, unsigned DiagID)
Emit DiagID if statement located on StmtLoc has a suspicious null statement as a Body,...
void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody)
Warn if a for/while loop statement S, which is followed by PossibleBody, has a suspicious null statem...
ExprResult DefaultLvalueConversion(Expr *E)
void ApplyForRangeOrExpansionStatementLifetimeExtension(VarDecl *RangeVar, ArrayRef< MaterializeTemporaryExpr * > Temporaries)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
void ActOnStartOfDeferStmt(SourceLocation DeferLoc, Scope *CurScope)
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, NamedReturnInfo &NRInfo, bool SupressSimplerImplicitMoves)
ActOnCapScopeReturnStmt - Utility routine to type-check return statements for capturing scopes.
StmtResult ActOnCapturedRegionEnd(Stmt *S)
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity, const NamedReturnInfo &NRInfo, Expr *Value, bool SupressSimplerImplicitMoves=false)
Perform the initialization of a potentially-movable value, which is the result of return value.
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
StmtResult ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection, SourceLocation RParenLoc, BuildForRangeKind Kind, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
bool isSFINAEContext() const
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
Binary Operators. 'Tok' is the token for the operator.
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
void setFunctionHasMustTail()
void setFunctionHasBranchProtectedScope()
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block)
StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc, BuildForRangeKind Kind, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
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 ...
VarDecl * BuildForRangeVarDecl(SourceLocation Loc, QualType Type, IdentifierInfo *Name, bool IsConstexpr)
Helper used by the expansion statements and for-range code to build a variable declaration for e....
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
void ActOnAfterCompoundStatementLeadingPragmas()
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void DiscardCleanupsInEvaluationContext()
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
StmtResult ActOnAttributedStmt(const ParsedAttributes &AttrList, Stmt *SubStmt)
SourceManager & SourceMgr
DiagnosticsEngine & Diags
void ActOnStartSEHFinallyBlock()
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void ActOnAbortSEHFinallyBlock()
friend class InitializationSequence
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
void ActOnDeferStmtError(Scope *CurScope)
QualType SubstAutoTypeDependent(QualType TypeWithAuto)
@ BFRK_Check
Determining whether a for-range statement could be built.
@ BFRK_Build
Initial building of a for-range statement.
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, Decl *ExDecl, Stmt *HandlerBlock)
ActOnCXXCatchBlock - Takes an exception declaration and a handler block and creates a proper catch ha...
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)
ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...
ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc, SourceLocation RangeLoc, const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup, OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr)
Build a call to 'begin' or 'end' for a C++11 for-range statement.
sema::CompoundScopeInfo & getCurCompoundScope() const
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
void ActOnFinishOfCompoundStmt()
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, bool AllowMask) const
IsValueInFlagEnum - Determine if a value is allowed as part of a flag enum.
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
ActOnCXXTryBlock - Takes a try compound-statement and a number of handlers and creates a try statemen...
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
void ActOnDependentForRangeInitializer(VarDecl *LoopVar, BuildForRangeKind BFRK)
Set the type of a for-range declaration whose for-range or expansion initialiser is dependent.
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
ForRangeBeginEndInfo BuildCXXForRangeBeginEndVars(Scope *S, VarDecl *RangeVar, SourceLocation ColonLoc, SourceLocation CoawaitLoc, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps, BuildForRangeKind Kind, bool IsConstexpr, StmtResult *RebuildResult=nullptr, llvm::function_ref< StmtResult()> RebuildWithDereference={}, IdentifierInfo *BeginName=nullptr, IdentifierInfo *EndName=nullptr)
Determine begin-expr and end-expr and build variable declarations for them as per [stmt....
SmallVector< std::pair< Scope *, SourceLocation >, 2 > CurrentDefer
Stack of '_Defer' statements that are currently being parsed, as well as the locations of their '_Def...
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
bool isMacroBodyExpansion(SourceLocation Loc) const
Tests whether the given source location represents the expansion of a macro body.
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
const Stmt * stripLabelLikeStatements() const
Strip off all label-like statements.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
static std::tuple< bool, const Attr *, const Attr * > determineLikelihoodConflict(const Stmt *Then, const Stmt *Else)
static const Attr * getLikelihoodAttr(const Stmt *S)
SourceLocation getBeginLoc() const LLVM_READONLY
SwitchStmt - This represents a 'switch' stmt.
static SwitchStmt * Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a switch statement.
SwitchCase * getSwitchCaseList()
DeclStmt * getConditionVariableDeclStmt()
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
void setAllEnumCasesCovered()
Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a switch over an enum value then ...
Represents the declaration of a struct/union/class/enum.
void startDefinition()
Starts the definition of this tag declaration.
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isRValueReferenceType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool containsErrors() const
Whether this type is an error type.
EnumDecl * castAsEnumDecl() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isObjectType() const
Determine whether this type is an object type.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
TypeClass getTypeClass() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
Represents a C++ unqualified-id that has been parsed.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
const Expr * getInit() const
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
bool hasDependentAlignment() const
Determines if this variable's alignment is dependent.
Represents a C array with a specified size that is not an integer-constant-expression.
static WhileStmt * Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body, SourceLocation WL, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a while statement.
ValueDecl * getVariable() const
bool isVariableCapture() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
bool isVLATypeCapture() const
bool isThisCapture() const
bool isReferenceCapture() const
Retains information about a captured region.
unsigned short OpenMPLevel
unsigned short CapRegionKind
The kind of captured region.
RecordDecl * TheRecordDecl
The captured record type.
CapturedDecl * TheCapturedDecl
The CapturedDecl for this statement.
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
SmallVector< Capture, 4 > Captures
Captures - The captures.
bool HasImplicitReturnType
Contains information about the compound statement currently being parsed.
FPOptions InitialFPFeatures
FP options at the beginning of the compound statement, prior to any pragma.
void setHasEmptyLoopBodies()
Retains information about a function, method, or block that is currently being parsed.
SourceLocation FirstCXXOrObjCTryLoc
First C++ 'try' or ObjC @try statement in the current function.
SourceLocation FirstCoroutineStmtLoc
First coroutine statement in the current function.
enum clang::sema::FunctionScopeInfo::@340304006310276167163023075110222134352007243353 FirstTryType
StringRef getFirstCoroutineStmtKeyword() const
SourceLocation FirstReturnLoc
First 'return' statement in the current function.
SourceLocation FirstSEHTryLoc
First SEH '__try' statement in the current function.
void setHasCXXTry(SourceLocation TryLoc)
SmallVector< CompoundScopeInfo, 4 > CompoundScopes
The stack of currently active compound statement scopes in the function.
void setHasSEHTry(SourceLocation TryLoc)
SmallVector< SwitchInfo, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Provides information about an attempted template argument deduction, whose success or failure was des...
TemplateArgument SecondArg
The second template argument to which the template argument deduction failure refers.
TemplateArgument FirstArg
The first template argument to which the template argument deduction failure refers.
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
@ Simple
Lightweight model that tracks known truth assignments for atoms (e.g., for each assume()) and unresol...
bool This(InterpState &S, CodePtr OpPC)
bool Cast(InterpState &S, CodePtr OpPC)
void checkExprLifetimeMustTailArg(Sema &SemaRef, const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the given expr (and its subobjects) is sufficient, assuming that it is pas...
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
Expr * IgnoreElidableImplicitConstructorSingleStep(Expr *E)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
bool isReservedInAllContexts(ReservedIdentifierStatus Status)
Determine whether an identifier is reserved in all contexts.
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
Expr * IgnoreExprNodes(Expr *E, FnTys &&... Fns)
Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *, Recursively apply each of the f...
@ RQ_None
No ref-qualifier was provided.
@ OCD_AllCandidates
Requests that all candidates be shown.
LambdaCaptureKind
The different capture forms in a lambda introducer.
@ LCK_ByRef
Capturing by reference.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
CapturedRegionKind
The different kinds of captured statement.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
const FunctionProtoType * T
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
bool hasArmZT0State(const FunctionDecl *FD)
Returns whether the given FunctionDecl has Arm ZT0 state.
@ Struct
The "struct" keyword.
@ Relational
This is an <, <=, >, or >= that should be implemented as a rewrite in terms of a <=> comparison.
@ ThreeWay
This is an operator<=> that should be implemented as a series of subobject comparisons.
bool isLambdaConversionOperator(CXXConversionDecl *C)
@ Deduced
The normal deduced case.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Expr * IgnoreParensSingleStep(Expr *E)
Expr * IgnoreImplicitAsWrittenSingleStep(Expr *E)
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor
TemplateDeductionResult
Describes the result of template argument deduction.
@ Success
Template argument deduction was successful.
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
@ AlreadyDiagnosed
Some error which was already diagnosed.
@ Increment
This is a postfix increment operator, 'operator++(int)'.
U cast(CodeGen::Address addr)
@ CaseValue
Expression in a case label.
bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)
Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.
ActionResult< Expr * > ExprResult
@ CapturedContext
Parameter for captured context.
ActionResult< Stmt * > StmtResult
bool hasArmZAState(const FunctionDecl *FD)
Returns whether the given FunctionDecl has Arm ZA state.
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 unsigned
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
EvalResult is a struct with detailed info about an evaluated expression.
Holds the 'begin' and 'end' variables of a range-based for loop or expansion statement; begin-expr an...
@ MoveEligibleAndCopyElidable
bool isMoveEligible() const
bool isCopyElidable() const
const VarDecl * Candidate
A SwitchStmt, along with a flag indicating if its list of case statements is incomplete (because we d...
static unsigned getHashValue(const CatchHandlerType &Base)
static bool isEqual(const CatchHandlerType &LHS, const CatchHandlerType &RHS)