;
72 boolHasLeadingEmptyMacro) {
95 if(!
decl||
decl->isInvalidDecl())
101 Diag(
decl->getLocation(), diag::err_non_variable_decl_in_for);
102 decl->setInvalidDecl();
108var->setInit(
nullptr);
121var->setType(
type.withConst());
122var->setARCPseudoStrong(
true);
135 enum{ Equality, Inequality, Relational, ThreeWay } Kind;
138 if(!Op->isComparisonOp())
141 if(Op->getOpcode() == BO_EQ)
143 else if(Op->getOpcode() == BO_NE)
145 else if(Op->getOpcode() == BO_Cmp)
148assert(Op->isRelationalOp());
151 Loc= Op->getOperatorLoc();
152CanAssign = Op->getLHS()->IgnoreParenImpCasts()->isLValue();
154 switch(Op->getOperator()) {
158 caseOO_ExclaimEqual:
163 caseOO_GreaterEqual:
174 Loc= Op->getOperatorLoc();
175CanAssign = Op->getArg(0)->IgnoreParenImpCasts()->isLValue();
186S.
Diag(
Loc, diag::warn_unused_comparison)
192 if(Kind == Inequality)
193S.
Diag(
Loc, diag::note_inequality_comparison_to_or_assign)
195 else if(Kind == Equality)
196S.
Diag(
Loc, diag::note_equality_comparison_to_assign)
208StringRef Msg = A->getMessage();
212 returnS.
Diag(
Loc, diag::warn_unused_return_type)
213<< IsCtor << A << OffendingDecl <<
false<< R1 << R2;
215 returnS.
Diag(
Loc, diag::warn_unused_constructor)
216<< A <<
false<< R1 << R2;
217 returnS.
Diag(
Loc, diag::warn_unused_result) << A <<
false<< R1 << R2;
221 returnS.
Diag(
Loc, diag::warn_unused_return_type)
222<< IsCtor << A << OffendingDecl <<
true<< Msg << R1 << R2;
224 returnS.
Diag(
Loc, diag::warn_unused_constructor)
225<< A <<
true<< Msg << R1 << R2;
226 returnS.
Diag(
Loc, diag::warn_unused_result) << A <<
true<< Msg << R1 << R2;
235voidDiagnoseUnused(
Sema&S,
const Expr*
E, std::optional<unsigned> DiagID) {
236 boolNoDiscardOnly = !DiagID.has_value();
252 const Expr*WarnExpr;
258 if(!NoDiscardOnly) {
279 if(
const FullExpr*Temps = dyn_cast<FullExpr>(
E))
280 E= Temps->getSubExpr();
282 E= TempExpr->getSubExpr();
288 if(
const auto*Cast = dyn_cast<CastExpr>(
E))
289 if(
Cast->getCastKind() == CK_NoOp ||
290 Cast->getCastKind() == CK_ConstructorConversion ||
291 Cast->getCastKind() == CK_IntegralCast)
292 E=
Cast->getSubExpr()->IgnoreImpCasts();
294 if(
const CallExpr*CE = dyn_cast<CallExpr>(
E)) {
298 auto[OffendingDecl, A] = CE->getUnusedResultAttr(S.
Context);
300cast_or_null<WarnUnusedResultAttr>(A),
Loc, R1, R2,
308 if(
const Decl*FD = CE->getCalleeDecl()) {
311 if(FD->hasAttr<PureAttr>()) {
312S.
Diag(
Loc, diag::warn_unused_call) << R1 << R2 <<
"pure";
315 if(FD->hasAttr<ConstAttr>()) {
316S.
Diag(
Loc, diag::warn_unused_call) << R1 << R2 <<
"const";
320}
else if(
const auto*CE = dyn_cast<CXXConstructExpr>(
E)) {
322 const NamedDecl*OffendingDecl =
nullptr;
323 const auto*A = Ctor->
getAttr<WarnUnusedResultAttr>();
325OffendingDecl = Ctor->getParent();
326A = OffendingDecl->
getAttr<WarnUnusedResultAttr>();
332}
else if(
const auto*ILE = dyn_cast<InitListExpr>(
E)) {
333 if(
const TagDecl*TD = ILE->getType()->getAsTagDecl()) {
339}
else if(ShouldSuppress)
344 if(S.
getLangOpts().ObjCAutoRefCount && ME->isDelegateInitCall()) {
345S.
Diag(
Loc, diag::err_arc_unused_init_message) << R1;
356 const Expr*Source = POE->getSyntacticForm();
358 if(S.
LangOpts.OpenMP && isa<CallExpr>(Source) &&
359POE->getNumSemanticExprs() == 1 &&
360isa<CallExpr>(POE->getSemanticExpr(0)))
361 returnDiagnoseUnused(S, POE->getSemanticExpr(0), DiagID);
362 if(isa<ObjCSubscriptRefExpr>(Source))
363DiagID = diag::warn_unused_container_subscript_expr;
364 else if(isa<ObjCPropertyRefExpr>(Source))
365DiagID = diag::warn_unused_property_expr;
367= dyn_cast<CXXFunctionalCastExpr>(
E)) {
368 const Expr*
E= FC->getSubExpr();
370 E= TE->getSubExpr();
371 if(isa<CXXTemporaryObjectExpr>(
E))
374 if(
const CXXRecordDecl*RD = CE->getType()->getAsCXXRecordDecl())
375 if(!RD->getAttr<WarnUnusedAttr>())
391S.
Diag(
Loc, diag::warn_unused_voidptr)
401S.
Diag(
Loc, diag::warn_unused_volatile) << R1 << R2;
408 if(DiagID == diag::warn_unused_comma_left_operand && S.
isSFINAEContext())
412S.
PDiag(*DiagID) << R1 << R2);
417DiagnoseUnused(*
this,
E, std::nullopt);
422S =
Label->getSubStmt();
424 const Expr*
E= dyn_cast_if_present<Expr>(S);
428DiagnoseUnused(*
this,
E, DiagID);
453 const unsignedNumElts = Elts.size();
458 const unsignedMixedDeclsCodeID =
getLangOpts().C99
459? diag::warn_mixed_decls_code
460: diag::ext_mixed_decls_code;
465 for(; i != NumElts && isa<DeclStmt>(Elts[i]); ++i)
469 for(; i != NumElts && !isa<DeclStmt>(Elts[i]); ++i)
473 Decl*
D= *cast<DeclStmt>(Elts[i])->decl_begin();
483 for(
unsignedi = 0; i != NumElts - 1; ++i)
519 autoCheckAndFinish = [&](
Expr*
E) {
526llvm::APSInt TempVal;
544Val,
nullptr,
false,
546 if(Converted.
get() == Val.
get())
547Converted = CheckAndFinish(Val.
get());
555assert((LHSVal.
isInvalid() || LHSVal.
get()) &&
"missing LHS value");
558 "missing RHS value");
561 Diag(CaseLoc, diag::err_case_not_in_switch);
572 Diag(CaseLoc, diag::err_acc_branch_in_out_compute_construct)
578CaseLoc, DotDotDotLoc, ColonLoc);
584cast<CaseStmt>(S)->setSubStmt(SubStmt);
591 Diag(DefaultLoc, diag::err_default_not_in_switch);
597 Diag(DefaultLoc, diag::err_acc_branch_in_out_compute_construct)
612 Diag(IdentLoc, diag::err_redefinition_of_label) << TheDecl->
getDeclName();
620 Diag(IdentLoc, diag::warn_reserved_extern_symbol)
621<< TheDecl << static_cast<int>(Status);
625 if(
getCurScope()->isInOpenACCComputeConstructScope())
632 if(isa<OpenACCUpdateConstruct>(SubStmt)) {
656 for(
const auto*A : Attrs) {
657 if(A->getKind() == attr::MustTail) {
672 if(!SemanticAttrs.empty())
688 if(!checkMustTailAttr(St, MTA))
694 autoIgnoreImplicitAsWritten = [](
Expr*
E) ->
Expr* {
705boolSema::checkMustTailAttr(
const Stmt*St,
const Attr&MTA) {
707 "musttail cannot be checked from a dependent context");
710 autoIgnoreParenImplicitAsWritten = [](
const Expr*
E) ->
const Expr* {
716 const Expr*
E= cast<ReturnStmt>(St)->getRetValue();
717 const auto*CE = dyn_cast_or_null<CallExpr>(IgnoreParenImplicitAsWritten(
E));
724 if(
const auto*EWC = dyn_cast<ExprWithCleanups>(
E)) {
725 if(EWC->cleanupsHaveSideEffects()) {
726 Diag(St->
getBeginLoc(), diag::err_musttail_needs_trivial_args) << &MTA;
737ft_non_static_member,
738ft_pointer_to_member,
739} MemberType = ft_non_member;
744} CallerType, CalleeType;
746 autoGetMethodType = [
this, St, MTA](
const CXXMethodDecl*CMD, FuncType &
Type,
747 boolIsCallee) ->
bool{
748 if(isa<CXXConstructorDecl, CXXDestructorDecl>(CMD)) {
750<< IsCallee << isa<CXXDestructorDecl>(CMD);
752 Diag(CMD->getBeginLoc(), diag::note_musttail_structors_forbidden)
753<< isa<CXXDestructorDecl>(CMD);
758 Type.MemberType = FuncType::ft_static_member;
760 Type.This = CMD->getFunctionObjectParameterType();
761 Type.MemberType = FuncType::ft_non_static_member;
767 const auto*CallerDecl = dyn_cast<FunctionDecl>(
CurContext);
778 Diag(St->
getBeginLoc(), diag::err_musttail_forbidden_from_this_context)
781}
else if(
const auto*CMD = dyn_cast<CXXMethodDecl>(
CurContext)) {
783 if(!GetMethodType(CMD, CallerType,
false))
791 const auto*CalleeBinOp = dyn_cast<BinaryOperator>(CalleeExpr);
793? CE->getCalleeDecl()->getBeginLoc()
798dyn_cast_or_null<CXXMethodDecl>(CE->getCalleeDecl())) {
800 if(!GetMethodType(CMD, CalleeType,
true))
802}
else if(CalleeBinOp && CalleeBinOp->isPtrMemOp()) {
806CalleeType.This =
QualType(MPT->getClass(), 0);
808CalleeType.MemberType = FuncType::ft_pointer_to_member;
809}
else if(isa<CXXPseudoDestructorExpr>(CalleeExpr)) {
821 if(!CalleeType.Func || !CallerType.Func) {
822 Diag(St->
getBeginLoc(), diag::err_musttail_needs_prototype) << &MTA;
823 if(!CalleeType.Func && CE->getDirectCallee()) {
824 Diag(CE->getDirectCallee()->getBeginLoc(),
825diag::note_musttail_fix_non_prototype);
827 if(!CallerType.Func)
828 Diag(CallerDecl->getBeginLoc(), diag::note_musttail_fix_non_prototype);
839 if(CallerType.Func->getCallConv() != CalleeType.Func->getCallConv()) {
840 if(
const auto*ND = dyn_cast_or_null<NamedDecl>(CE->getCalleeDecl()))
842<<
true<< ND->getDeclName();
844 Diag(St->
getBeginLoc(), diag::err_musttail_callconv_mismatch) <<
false;
845 Diag(CalleeLoc, diag::note_musttail_callconv_mismatch)
852 if(CalleeType.Func->isVariadic() || CallerType.Func->isVariadic()) {
857 const auto*CalleeDecl = CE->getCalleeDecl();
858 if(CalleeDecl && CalleeDecl->hasAttr<CXX11NoReturnAttr>()) {
864 if(CallerType.This.isNull() != CalleeType.This.isNull()) {
865 if(
const auto*ND = dyn_cast_or_null<NamedDecl>(CE->getCalleeDecl())) {
867<< CallerType.MemberType << CalleeType.MemberType <<
true 868<< ND->getDeclName();
869 Diag(CalleeLoc, diag::note_musttail_callee_defined_here)
870<< ND->getDeclName();
873<< CallerType.MemberType << CalleeType.MemberType <<
false;
878 autoCheckTypesMatch = [
this](FuncType CallerType, FuncType CalleeType,
888 unsignedSelect) ->
bool{
896 if(!CallerType.This.isNull() &&
900 if(!DoTypesMatch(CallerType.Func->getReturnType(),
904 if(CallerType.Func->getNumParams() != CalleeType.Func->getNumParams()) {
906<< CalleeType.Func->getNumParams();
912 size_tN = CallerType.Func->getNumParams();
913 for(
size_tI = 0; I < N; I++) {
914 if(!DoTypesMatch(CalleeParams[I], CallerParams[I],
916PD << static_cast<int>(I) + 1;
925 if(!CheckTypesMatch(CallerType, CalleeType, PD)) {
926 if(
const auto*ND = dyn_cast_or_null<NamedDecl>(CE->getCalleeDecl()))
928<<
true<< ND->getDeclName();
931 Diag(CalleeLoc, PD);
939 for(
autoArgExpr : CE->arguments()) {
941 Context, ArgExpr->getType(),
false);
953CommaVisitor(
Sema&SemaRef) : Inherited(SemaRef.Context), SemaRef(SemaRef) {}
955 if(
E->getOpcode() == BO_Comma)
971 boolConstevalOrNegatedConsteval =
975 Expr*CondExpr = Cond.
get().second;
976assert((CondExpr || ConstevalOrNegatedConsteval) &&
977 "If statement: missing condition");
981CommaVisitor(*this).Visit(CondExpr);
983 if(!ConstevalOrNegatedConsteval && !elseStmt)
986 if(ConstevalOrNegatedConsteval ||
988 autoDiagnoseLikelihood = [&](
const Stmt*S) {
991diag::warn_attribute_has_no_effect_on_compile_time_if)
992<< A << ConstevalOrNegatedConsteval << A->getRange();
994diag::note_attribute_has_no_effect_on_compile_time_if_here)
995<< ConstevalOrNegatedConsteval
996<<
SourceRange(IfLoc, (ConstevalOrNegatedConsteval
1002DiagnoseLikelihood(thenStmt);
1003DiagnoseLikelihood(elseStmt);
1005std::tuple<bool, const Attr *, const Attr *> LHC =
1007 if(std::get<0>(LHC)) {
1008 const Attr*ThenAttr = std::get<1>(LHC);
1009 const Attr*ElseAttr = std::get<2>(LHC);
1011diag::warn_attributes_likelihood_ifstmt_conflict)
1012<< ThenAttr << ThenAttr->
getRange();
1014<< ElseAttr << ElseAttr->
getRange();
1018 if(ConstevalOrNegatedConsteval) {
1024 if(FD && FD->isImmediateFunction())
1028 Diags.
Report(IfLoc, diag::warn_consteval_if_always_true) << Immediate;
1035 if(isa<OpenACCUpdateConstruct>(thenStmt)) {
1040 return BuildIfStmt(IfLoc, StatementKind, LParenLoc, InitStmt, Cond, RParenLoc,
1041thenStmt, ElseLoc, elseStmt);
1054isa<ObjCAvailabilityCheckExpr>(Cond.
get().second))
1058Cond.
get().first, Cond.
get().second, LParenLoc,
1059RParenLoc, thenStmt, ElseLoc, elseStmt);
1063 structCaseCompareFunctor {
1064 booloperator()(
conststd::pair<llvm::APSInt, CaseStmt*> &LHS,
1065 constllvm::APSInt &RHS) {
1066 returnLHS.first < RHS;
1068 booloperator()(
conststd::pair<llvm::APSInt, CaseStmt*> &LHS,
1069 conststd::pair<llvm::APSInt, CaseStmt*> &RHS) {
1070 returnLHS.first < RHS.first;
1072 booloperator()(
constllvm::APSInt &LHS,
1073 conststd::pair<llvm::APSInt, CaseStmt*> &RHS) {
1074 returnLHS < RHS.first;
1081static bool CmpCaseVals(
conststd::pair<llvm::APSInt, CaseStmt*>& lhs,
1082 conststd::pair<llvm::APSInt, CaseStmt*>& rhs) {
1083 if(lhs.first < rhs.first)
1086 if(lhs.first == rhs.first &&
1087lhs.second->getCaseLoc() < rhs.second->getCaseLoc())
1094static bool CmpEnumVals(
conststd::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
1095 conststd::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
1097 returnlhs.first < rhs.first;
1102static bool EqEnumVals(
conststd::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
1103 conststd::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
1105 returnlhs.first == rhs.first;
1111 if(
const auto*FE = dyn_cast<FullExpr>(
E))
1112 E= FE->getSubExpr();
1113 while(
const auto*ImpCast = dyn_cast<ImplicitCastExpr>(
E)) {
1114 if(ImpCast->getCastKind() != CK_IntegralCast)
break;
1115 E= ImpCast->getSubExpr();
1125SwitchConvertDiagnoser(
Expr*Cond)
1131 returnS.
Diag(
Loc, diag::err_typecheck_statement_requires_integer) <<
T;
1136 returnS.
Diag(
Loc, diag::err_switch_incomplete_class_type)
1142 returnS.
Diag(
Loc, diag::err_switch_explicit_conversion) <<
T<< ConvTy;
1153 returnS.
Diag(
Loc, diag::err_switch_multiple_conversions) <<
T;
1164llvm_unreachable(
"conversion functions are permitted");
1166} SwitchDiagnoser(Cond);
1175Cond = CondResult.
get();
1188 Expr*CondExpr = Cond.
get().second;
1189assert((Cond.
isInvalid() || CondExpr) &&
"switch with no condition");
1202 Diag(SwitchLoc, diag::warn_bool_switch_condition)
1210LParenLoc, RParenLoc);
1216static void AdjustAPSInt(llvm::APSInt &Val,
unsignedBitWidth,
boolIsSigned) {
1217Val = Val.extOrTrunc(BitWidth);
1218Val.setIsSigned(IsSigned);
1224 unsignedUnpromotedWidth,
boolUnpromotedSign) {
1232 if(UnpromotedWidth < Val.getBitWidth()) {
1233llvm::APSInt ConvVal(Val);
1234 AdjustAPSInt(ConvVal, UnpromotedWidth, UnpromotedSign);
1235 AdjustAPSInt(ConvVal, Val.getBitWidth(), Val.isSigned());
1251 const Expr*CaseExpr,
1252EnumValsTy::iterator &EI,
1253EnumValsTy::iterator &EIEnd,
1254 constllvm::APSInt &Val) {
1260 if(
const VarDecl*VD = dyn_cast<VarDecl>(DRE->getDecl())) {
1269 if(ED->
hasAttr<FlagEnumAttr>())
1272 while(EI != EIEnd && EI->first < Val)
1275 if(EI != EIEnd && EI->first == Val)
1288 if(!CondEnumType || !CaseEnumType)
1295 if(!CaseEnumType->getDecl()->getIdentifier() &&
1296!CaseEnumType->getDecl()->getTypedefNameForAnonDecl())
1302S.
Diag(Case->
getExprLoc(), diag::warn_comparison_of_mixed_enum_types_switch)
1312assert(SS ==
getCurFunction()->SwitchStack.back().getPointer() &&
1313 "switch stack missing push/pop!");
1323 if(isa<OpenACCUpdateConstruct>(BodyStmt)) {
1328SS->
setBody(BodyStmt, SwitchLoc);
1342 const Expr*CondExprBeforePromotion = CondExpr;
1348 boolHasDependentValue
1357 unsignedCondWidthBeforePromotion
1359 boolCondIsSignedBeforePromotion
1366CaseValsTy CaseVals;
1369 typedefstd::vector<std::pair<llvm::APSInt, CaseStmt*> > CaseRangesTy;
1370CaseRangesTy CaseRanges;
1374 boolCaseListIsErroneous =
false;
1382 if(
DefaultStmt*DS = dyn_cast<DefaultStmt>(SC)) {
1383 if(TheDefaultStmt) {
1384 Diag(DS->getDefaultLoc(), diag::err_multiple_default_labels_defined);
1391CaseListIsErroneous =
true;
1393TheDefaultStmt = DS;
1401HasDependentValue =
true;
1407 const Expr*LoBeforePromotion = Lo;
1414CondIsSignedBeforePromotion);
1426HasDependentValue =
true;
1429CaseRanges.push_back(std::make_pair(LoVal, CS));
1431CaseVals.push_back(std::make_pair(LoVal, CS));
1435 if(!HasDependentValue) {
1438llvm::APSInt ConstantCondValue;
1439 boolHasConstantCond =
false;
1440 if(!TheDefaultStmt) {
1444 if(
Result.Val.isInt())
1445ConstantCondValue =
Result.Val.getInt();
1446assert(!HasConstantCond ||
1447(ConstantCondValue.getBitWidth() == CondWidth &&
1448ConstantCondValue.isSigned() == CondIsSigned));
1449 Diag(SwitchLoc, diag::warn_switch_default);
1451 boolShouldCheckConstantCond = HasConstantCond;
1456 if(!CaseVals.empty()) {
1457 for(
unsignedi = 0, e = CaseVals.size(); i != e; ++i) {
1458 if(ShouldCheckConstantCond &&
1459CaseVals[i].first == ConstantCondValue)
1460ShouldCheckConstantCond =
false;
1462 if(i != 0 && CaseVals[i].first == CaseVals[i-1].first) {
1465StringRef PrevString, CurrString;
1468 if(
DeclRefExpr*DeclRef = dyn_cast<DeclRefExpr>(PrevCase)) {
1469PrevString = DeclRef->getDecl()->getName();
1471 if(
DeclRefExpr*DeclRef = dyn_cast<DeclRefExpr>(CurrCase)) {
1472CurrString = DeclRef->getDecl()->getName();
1475CaseVals[i-1].first.toString(CaseValStr);
1477 if(PrevString == CurrString)
1478 Diag(CaseVals[i].second->getLHS()->getBeginLoc(),
1479diag::err_duplicate_case)
1480<< (PrevString.empty() ? CaseValStr.str() : PrevString);
1482 Diag(CaseVals[i].second->getLHS()->getBeginLoc(),
1483diag::err_duplicate_case_differing_expr)
1484<< (PrevString.empty() ? CaseValStr.str() : PrevString)
1485<< (CurrString.empty() ? CaseValStr.str() : CurrString)
1488 Diag(CaseVals[i - 1].second->getLHS()->getBeginLoc(),
1489diag::note_duplicate_case_prev);
1492CaseListIsErroneous =
true;
1499 if(!CaseRanges.empty()) {
1502llvm::stable_sort(CaseRanges);
1505std::vector<llvm::APSInt> HiVals;
1506 for(
unsignedi = 0, e = CaseRanges.size(); i != e; ++i) {
1507llvm::APSInt &LoVal = CaseRanges[i].first;
1508 CaseStmt*CR = CaseRanges[i].second;
1511 const Expr*HiBeforePromotion = Hi;
1518CondWidthBeforePromotion, CondIsSignedBeforePromotion);
1524 if(LoVal > HiVal) {
1527CaseRanges.erase(CaseRanges.begin()+i);
1533 if(ShouldCheckConstantCond &&
1534LoVal <= ConstantCondValue &&
1535ConstantCondValue <= HiVal)
1536ShouldCheckConstantCond =
false;
1538HiVals.push_back(HiVal);
1544 for(
unsignedi = 0, e = CaseRanges.size(); i != e; ++i) {
1545llvm::APSInt &CRLo = CaseRanges[i].first;
1546llvm::APSInt &CRHi = HiVals[i];
1547 CaseStmt*CR = CaseRanges[i].second;
1552llvm::APSInt OverlapVal(32);
1556CaseValsTy::iterator I =
1557llvm::lower_bound(CaseVals, CRLo, CaseCompareFunctor());
1558 if(I != CaseVals.end() && I->first < CRHi) {
1559OverlapVal = I->first;
1560OverlapStmt = I->second;
1564I = std::upper_bound(I, CaseVals.end(), CRHi, CaseCompareFunctor());
1565 if(I != CaseVals.begin() && (I-1)->first >= CRLo) {
1566OverlapVal = (I-1)->first;
1567OverlapStmt = (I-1)->second;
1572 if(i && CRLo <= HiVals[i-1]) {
1573OverlapVal = HiVals[i-1];
1574OverlapStmt = CaseRanges[i-1].second;
1582diag::note_duplicate_case_prev);
1585CaseListIsErroneous =
true;
1591 if(!CaseListIsErroneous && !CaseListIsIncomplete &&
1592ShouldCheckConstantCond) {
1595 Diag(CondExpr->
getExprLoc(), diag::warn_missing_case_for_condition)
1596<<
toString(ConstantCondValue, 10)
1608 if(!CaseListIsErroneous && !CaseListIsIncomplete && !HasConstantCond &&
1617llvm::APSInt Val = EDI->getInitVal();
1619EnumVals.push_back(std::make_pair(Val, EDI));
1622 autoEI = EnumVals.begin(), EIEnd =
1623std::unique(EnumVals.begin(), EnumVals.end(),
EqEnumVals);
1626 for(CaseValsTy::const_iterator CI = CaseVals.begin();
1627CI != CaseVals.end(); CI++) {
1628 Expr*CaseExpr = CI->second->getLHS();
1632<< CondTypeBeforePromotion;
1636EI = EnumVals.begin();
1637 for(CaseRangesTy::const_iterator RI = CaseRanges.begin();
1638RI != CaseRanges.end(); RI++) {
1639 Expr*CaseExpr = RI->second->getLHS();
1643<< CondTypeBeforePromotion;
1646RI->second->getRHS()->EvaluateKnownConstInt(
Context);
1649CaseExpr = RI->second->getRHS();
1653<< CondTypeBeforePromotion;
1657 autoCI = CaseVals.begin();
1658 autoRI = CaseRanges.begin();
1659 boolhasCasesNotInSwitch =
false;
1663 for(EI = EnumVals.begin(); EI != EIEnd; EI++) {
1665 switch(EI->second->getAvailability()) {
1678 if(EI->second->hasAttr<UnusedAttr>())
1682 while(CI != CaseVals.end() && CI->first < EI->first)
1685 if(CI != CaseVals.end() && CI->first == EI->first)
1689 for(; RI != CaseRanges.end(); RI++) {
1691RI->second->getRHS()->EvaluateKnownConstInt(
Context);
1693 if(EI->first <= Hi)
1697 if(RI == CaseRanges.end() || EI->first < RI->first) {
1698hasCasesNotInSwitch =
true;
1699UnhandledNames.push_back(EI->second->getDeclName());
1703 if(TheDefaultStmt && UnhandledNames.empty() && ED->
isClosedNonFlag())
1707 if(!UnhandledNames.empty()) {
1709? diag::warn_def_missing_case
1710: diag::warn_missing_case)
1713 for(
size_tI = 0,
E= std::min(UnhandledNames.size(), (
size_t)3);
1715DB << UnhandledNames[I];
1718 if(!hasCasesNotInSwitch)
1725diag::warn_empty_switch_body);
1729 if(CaseListIsErroneous)
1752 const EnumDecl*ED = ET->getDecl();
1757 if(ED->
hasAttr<FlagEnumAttr>()) {
1759 Diag(SrcExpr->
getExprLoc(), diag::warn_not_in_enum_assignment)
1769llvm::APSInt Val = EDI->getInitVal();
1771EnumVals.push_back(std::make_pair(Val, EDI));
1773 if(EnumVals.empty())
1776EnumValsTy::iterator EIend =
1777std::unique(EnumVals.begin(), EnumVals.end(),
EqEnumVals);
1780EnumValsTy::const_iterator EI = EnumVals.begin();
1781 while(EI != EIend && EI->first < RhsVal)
1783 if(EI == EIend || EI->first != RhsVal) {
1784 Diag(SrcExpr->
getExprLoc(), diag::warn_not_in_enum_assignment)
1798 autoCondVal = Cond.
get();
1799CheckBreakContinueBinding(CondVal.second);
1801 if(CondVal.second &&
1802!
Diags.
isIgnored(diag::warn_comma_operator, CondVal.second->getExprLoc()))
1803CommaVisitor(*this).Visit(CondVal.second);
1809 if(isa<OpenACCUpdateConstruct>(Body)) {
1814 if(isa<NullStmt>(Body))
1818WhileLoc, LParenLoc, RParenLoc);
1825assert(Cond &&
"ActOnDoStmt(): missing expression");
1827CheckBreakContinueBinding(Cond);
1831Cond = CondResult.
get();
1836Cond = CondResult.
get();
1841CommaVisitor(*this).Visit(Cond);
1847 if(isa<OpenACCUpdateConstruct>(Body)) {
1852 return new(
Context)
DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen);
1863DeclSetVector &Decls;
1869DeclExtractor(
Sema&S, DeclSetVector &Decls,
1871Inherited(S.Context),
1876 boolisSimple() {
returnSimple; }
1885 voidVisitStmt(
Stmt*S) { Simple =
false; }
1888Visit(
E->getLHS());
1889Visit(
E->getRHS());
1893Visit(
E->getSubExpr());
1898 if(
E->getOpcode() == UO_Deref)
1901Visit(
E->getSubExpr());
1905Visit(
E->getCond());
1906Visit(
E->getTrueExpr());
1907Visit(
E->getFalseExpr());
1911Visit(
E->getSubExpr());
1915Visit(
E->getOpaqueValue()->getSourceExpr());
1916Visit(
E->getFalseExpr());
1927 VarDecl*VD = dyn_cast<VarDecl>(
E->getDecl());
1944DeclSetVector &Decls;
1950DeclMatcher(
Sema&S, DeclSetVector &Decls,
Stmt*Statement) :
1951Inherited(S.Context), Decls(Decls), FoundDecl(
false) {
1952 if(!Statement)
return;
1970 if(
E->getCastKind() == CK_LValueToRValue)
1971CheckLValueToRValueCast(
E->getSubExpr());
1973Visit(
E->getSubExpr());
1976 voidCheckLValueToRValueCast(
Expr*
E) {
1979 if(isa<DeclRefExpr>(
E)) {
1984Visit(CO->getCond());
1985CheckLValueToRValueCast(CO->getTrueExpr());
1986CheckLValueToRValueCast(CO->getFalseExpr());
1991dyn_cast<BinaryConditionalOperator>(
E)) {
1992CheckLValueToRValueCast(BCO->getOpaqueValue()->getSourceExpr());
1993CheckLValueToRValueCast(BCO->getFalseExpr());
2001 if(
VarDecl*VD = dyn_cast<VarDecl>(
E->getDecl()))
2002 if(Decls.count(VD))
2010 if(
auto*OVE = dyn_cast<OpaqueValueExpr>(S))
2012Visit(OVE->getSourceExpr());
2018 boolFoundDeclInUse() {
returnFoundDecl; }
2022 voidCheckForLoopConditionalStatement(
Sema&S,
Expr*Second,
2025 if(!Second)
return;
2032DeclSetVector Decls;
2034DeclExtractor DE(S, Decls, Ranges);
2038 if(!DE.isSimple())
return;
2041 if(Decls.size() == 0)
return;
2044 for(
auto*VD : Decls)
2048 if(DeclMatcher(S, Decls, Second).FoundDeclInUse() ||
2049DeclMatcher(S, Decls, Third).FoundDeclInUse() ||
2050DeclMatcher(S, Decls, Body).FoundDeclInUse())
2054 if(Decls.size() > 4) {
2058 for(
auto*VD : Decls)
2062 for(
auto Range: Ranges)
2065S.
Diag(Ranges.begin()->getBegin(), PDiag);
2070 boolProcessIterationStmt(
Sema&S,
Stmt* Statement,
bool&Increment,
2072 if(
autoCleanups = dyn_cast<ExprWithCleanups>(Statement))
2073 if(!Cleanups->cleanupsHaveSideEffects())
2076 if(
UnaryOperator*UO = dyn_cast<UnaryOperator>(Statement)) {
2077 switch(UO->getOpcode()) {
2078 default:
return false;
2088DRE = dyn_cast<DeclRefExpr>(UO->getSubExpr());
2096 default:
return false;
2104DRE = dyn_cast<DeclRefExpr>(
Call->getArg(0));
2116 boolInSwitch =
false;
2119BreakContinueFinder(
Sema&S,
const Stmt* Body) :
2120Inherited(S.Context) {
2127ContinueLoc =
E->getContinueLoc();
2132BreakLoc =
E->getBreakLoc();
2135 voidVisitSwitchStmt(
const SwitchStmt* S) {
2136 if(
const Stmt*
Init= S->getInit())
2138 if(
const Stmt*CondVar = S->getConditionVariableDeclStmt())
2140 if(
const Stmt*Cond = S->getCond())
2145 if(
const Stmt*Body = S->getBody())
2150 voidVisitForStmt(
const ForStmt*S) {
2153 if(
const Stmt*
Init= S->getInit())
2157 voidVisitWhileStmt(
const WhileStmt*) {
2162 voidVisitDoStmt(
const DoStmt*) {
2170 if(
const Stmt*
Init= S->getInit())
2172 if(
const Stmt*
Range= S->getRangeStmt())
2174 if(
const Stmt*
Begin= S->getBeginStmt())
2176 if(
const Stmt*End = S->getEndStmt())
2183 if(
const Stmt*Element = S->getElement())
2185 if(
const Stmt*Collection = S->getCollection())
2189 boolContinueFound() {
returnContinueLoc.
isValid(); }
2190 boolBreakFound() {
returnBreakLoc.
isValid(); }
2201 voidCheckForRedundantIteration(
Sema&S,
Expr*Third,
Stmt*Body) {
2203 if(!Body || !Third)
return;
2213 if(!LastStmt)
return;
2215 boolLoopIncrement, LastIncrement;
2218 if(!ProcessIterationStmt(S, Third, LoopIncrement, LoopDRE))
return;
2219 if(!ProcessIterationStmt(S, LastStmt, LastIncrement, LastDRE))
return;
2223 if(LoopIncrement != LastIncrement ||
2226 if(BreakContinueFinder(S, Body).ContinueFound())
return;
2228S.
Diag(LastDRE->
getLocation(), diag::warn_redundant_loop_iteration)
2229<< LastDRE->
getDecl() << LastIncrement;
2237voidSema::CheckBreakContinueBinding(
Expr*
E) {
2240BreakContinueFinder BCFinder(*
this,
E);
2242 if(BCFinder.BreakFound() && BreakParent) {
2244 Diag(BCFinder.GetBreakLoc(), diag::warn_break_binds_to_switch);
2246 Diag(BCFinder.GetBreakLoc(), diag::warn_loop_ctrl_binds_to_inner)
2250 Diag(BCFinder.GetContinueLoc(), diag::warn_loop_ctrl_binds_to_inner)
2267 const Decl*NonVarSeen =
nullptr;
2268 boolVarDeclSeen =
false;
2269 for(
auto*DI : DS->decls()) {
2270 if(
VarDecl*VD = dyn_cast<VarDecl>(DI)) {
2271VarDeclSeen =
true;
2273 Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
2274DI->setInvalidDecl();
2276}
else if(!NonVarSeen) {
2286 if(NonVarSeen && !VarDeclSeen)
2287 Diag(NonVarSeen->
getLocation(), diag::err_non_variable_decl_in_for);
2291CheckBreakContinueBinding(Second.
get().second);
2292CheckBreakContinueBinding(third.
get());
2294 if(!Second.
get().first)
2295CheckForLoopConditionalStatement(*
this, Second.
get().second, third.
get(),
2297CheckForRedundantIteration(*
this, third.
get(), Body);
2299 if(Second.
get().second &&
2301Second.
get().second->getExprLoc()))
2302CommaVisitor(*this).Visit(Second.
get().second);
2305 if(isa<NullStmt>(Body))
2310Body, ForLoc, LParenLoc, RParenLoc);
2330 if(
Decl->getType()->isUndeducedType()) {
2342 if(!isa<InitListExpr>(
Init) &&
Init->getType()->isVoidType()) {
2343SemaRef.
Diag(
Loc, DiagID) <<
Init->getType();
2347 Decl->getTypeSourceInfo()->getTypeLoc(),
Init, InitType, Info);
2350SemaRef.
Diag(
Loc, DiagID) <<
Init->getType();
2353 if(InitType.
isNull()) {
2357 Decl->setType(InitType);
2375enumBeginEndFunction {
2384voidNoteForRangeBeginEndFunction(
Sema&SemaRef,
Expr*
E,
2385BeginEndFunction BEF) {
2394std::string Description;
2395 boolIsTemplate =
false;
2398FunTmpl->getTemplateParameters(), *
D->getTemplateSpecializationArgs());
2402SemaRef.
Diag(
Loc, diag::note_for_range_begin_end)
2403<< BEF << IsTemplate << Description <<
E->
getType();
2437 return Diag(InitStmt->
getBeginLoc(), diag::err_objc_for_range_init_stmt)
2443assert(DS &&
"first part of for range not a decl stmt");
2470 const autoDepthStr = std::to_string(S->getDepth() / 2);
2472 VarDecl*RangeVar = BuildForRangeVarDecl(*
this, RangeLoc,
2474std::string(
"__range") + DepthStr);
2476diag::err_for_range_deduction_failure)) {
2491ForLoc, CoawaitLoc, InitStmt, ColonLoc, RangeDecl.
get(),
2493 nullptr,
nullptr, DS, RParenLoc, Kind,
2494LifetimeExtendTemps);
2517 ExprResult*EndExpr, BeginEndFunction *BEF) {
2527 autoBuildBegin = [&] {
2531BeginMemberLookup, CandidateSet,
2532BeginRange, BeginExpr);
2537<< ColonLoc << BEF_begin << BeginRange->
getType();
2545BeginExpr->
get());
2550diag::err_for_range_iter_deduction_failure)) {
2551NoteForRangeBeginEndFunction(SemaRef, BeginExpr->
get(), *BEF);
2557 autoBuildEnd = [&] {
2561EndMemberLookup, CandidateSet,
2566<< ColonLoc << BEF_end << EndRange->
getType();
2570diag::err_for_range_iter_deduction_failure)) {
2571NoteForRangeBeginEndFunction(SemaRef, EndExpr->
get(), *BEF);
2591 if(BeginMemberLookup.
empty() != EndMemberLookup.
empty()) {
2596 autoBuildNonmember = [&](
2606 switch(BuildFound()) {
2613SemaRef.
PDiag(diag::err_for_range_invalid)
2614<< BeginRange->
getType() << BEFFound),
2621diag::note_for_range_member_begin_end_ignored)
2622<< BeginRange->
getType() << BEFFound;
2626llvm_unreachable(
"unexpected ForRangeStatus");
2628 if(BeginMemberLookup.
empty())
2629 returnBuildNonmember(BEF_end, EndMemberLookup, BuildEnd, BuildBegin);
2630 returnBuildNonmember(BEF_begin, BeginMemberLookup, BuildBegin, BuildEnd);
2667S, ForLoc, CoawaitLoc, InitStmt, LoopVarDecl, ColonLoc,
2676SemaRef.
Diag(RangeLoc, diag::err_for_range_dereference)
2679S, ForLoc, CoawaitLoc, InitStmt, LoopVarDecl, ColonLoc,
2700 DeclStmt*RangeDS = cast<DeclStmt>(RangeDecl);
2704 DeclStmt*LoopVarDS = cast<DeclStmt>(LoopVarDecl);
2718 if(
auto*DD = dyn_cast<DecompositionDecl>(LoopVar))
2719 for(
auto*Binding : DD->bindings()) {
2720 if(!Binding->isParameterPack())
2725}
else if(!BeginDeclStmt.
get()) {
2747diag::err_for_range_incomplete_type))
2754 for(
auto*MTE : LifetimeExtendTemps)
2760 const autoDepthStr = std::to_string(S->getDepth() / 2);
2761 VarDecl*BeginVar = BuildForRangeVarDecl(*
this, ColonLoc,
AutoType,
2762std::string(
"__begin") + DepthStr);
2764std::string(
"__end") + DepthStr);
2775BeginExpr = BeginRangeRef;
2782diag::err_for_range_iter_deduction_failure)) {
2783NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2793dyn_cast<VariableArrayType>(UnqAT)) {
2820VAT->desugar(), RangeLoc))
2831VAT->getElementType(), RangeLoc))
2834 if(SizeOfEachElementExprR.
isInvalid())
2839SizeOfVLAExprR.
get(), SizeOfEachElementExprR.
get());
2846llvm_unreachable(
"Unexpected array type in for-range");
2850EndExpr =
ActOnBinOp(S, ColonLoc, tok::plus, EndRangeRef.
get(),
2855diag::err_for_range_iter_deduction_failure)) {
2856NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2862BeginEndFunction BEFFailure;
2864*
this, BeginRangeRef.
get(), EndRangeRef.
get(), RangeType, BeginVar,
2865EndVar, ColonLoc, CoawaitLoc, &CandidateSet, &BeginExpr, &EndExpr,
2869BEFFailure == BEF_begin) {
2874 QualTypeArrayTy = PVD->getOriginalType();
2875 QualTypePointerTy = PVD->getType();
2877 Diag(
Range->getBeginLoc(), diag::err_range_on_array_parameter)
2878<< RangeLoc << PVD << ArrayTy << PointerTy;
2879 Diag(PVD->getLocation(), diag::note_declared_at);
2888CoawaitLoc, InitStmt,
2889LoopVarDecl, ColonLoc,
2898 Expr*
Range= BEFFailure ? EndRangeRef.
get() : BeginRangeRef.
get();
2901 PDiag(diag::err_for_range_invalid)
2902<< RangeLoc <<
Range->getType()
2912 "invalid range expression in for loop");
2919? diag::warn_for_range_begin_end_types_differ
2920: diag::ext_for_range_begin_end_types_differ)
2921<< BeginType << EndType;
2922NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2923NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2943NotEqExpr =
ActOnBinOp(S, ColonLoc, tok::exclaimequal,
2944BeginRef.
get(), EndRef.
get());
2951 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2952<< RangeLoc << 0 << BeginRangeRef.
get()->
getType();
2953NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2955NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2965IncrExpr =
ActOnUnaryOp(S, ColonLoc, tok::plusplus, BeginRef.
get());
2966 if(!IncrExpr.isInvalid() && CoawaitLoc.
isValid())
2971 if(!IncrExpr.isInvalid())
2973 if(IncrExpr.isInvalid()) {
2974 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2975<< RangeLoc << 2 << BeginRangeRef.
get()->
getType() ;
2976NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2988 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2989<< RangeLoc << 1 << BeginRangeRef.
get()->
getType();
2990NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
3000NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
3015InitStmt, RangeDS, cast_or_null<DeclStmt>(BeginDeclStmt.
get()),
3016cast_or_null<DeclStmt>(EndDeclStmt.
get()), NotEqExpr.
get(),
3017IncrExpr.get(), LoopVarDS,
nullptr, ForLoc, CoawaitLoc,
3018ColonLoc, RParenLoc);
3037 if(
autoCleanups = dyn_cast<ExprWithCleanups>(InitExpr))
3038 if(!Cleanups->cleanupsHaveSideEffects())
3039InitExpr = Cleanups->getSubExpr();
3042dyn_cast<MaterializeTemporaryExpr>(InitExpr);
3052 while(!isa<CXXOperatorCallExpr>(
E) && !isa<UnaryOperator>(
E)) {
3066 if(isa<UnaryOperator>(
E)) {
3073ReferenceReturnType = ReturnType;
3076 if(!ReferenceReturnType.
isNull()) {
3081diag::warn_for_range_const_ref_binds_temp_built_from_ref)
3082<< VD << VariableType << ReferenceReturnType;
3087SemaRef.
Diag(VD->
getBeginLoc(), diag::note_use_type_or_non_reference)
3088<< NonReferenceType << NewReferenceType << VD->
getSourceRange()
3095SemaRef.
Diag(VD->
getLocation(), diag::warn_for_range_ref_binds_ret_temp)
3096<< VD << RangeInitType;
3099SemaRef.
Diag(VD->
getBeginLoc(), diag::note_use_non_reference_type)
3109 returnRD->hasAttr<TrivialABIAttr>();
3126 if(!CE->getConstructor()->isCopyConstructor())
3128}
else if(
const CastExpr*CE = dyn_cast<CastExpr>(InitExpr)) {
3129 if(CE->getCastKind() != CK_LValueToRValue)
3147<< VD << VariableType;
3168diag::warn_for_range_const_ref_binds_temp_built_from_ref,
3170SemaRef.
Diags.
isIgnored(diag::warn_for_range_ref_binds_ret_temp,
3195 ForStmt->getRangeInit()->getType());
3205 if(isa<ObjCForCollectionStmt>(S))
3212diag::warn_empty_range_based_for_body);
3226 if(
getCurScope()->isInOpenACCComputeConstructScope())
3245 E= ExprRes.
get();
3254 E= ExprRes.
get();
3260 if(
getCurScope()->isInOpenACCComputeConstructScope())
3267 const Scope&DestScope) {
3270S.
Diag(
Loc, diag::warn_jump_out_of_seh_finally);
3279 return StmtError(
Diag(ContinueLoc, diag::err_continue_not_in_loop));
3281 if(S->isConditionVarScope()) {
3285 return StmtError(
Diag(ContinueLoc, diag::err_continue_from_cond_var_init));
3291 if(S->isOpenACCComputeConstructScope())
3293 Diag(ContinueLoc, diag::err_acc_branch_in_out_compute_construct)
3306 return StmtError(
Diag(BreakLoc, diag::err_break_not_in_loop_or_switch));
3308 if(S->isOpenMPLoopScope())
3309 return StmtError(
Diag(BreakLoc, diag::err_omp_loop_cannot_use_stmt)
3319 if(S->isOpenACCComputeConstructScope() ||
3320(S->isLoopScope() && S->getParent() &&
3321S->getParent()->isOpenACCComputeConstructScope()))
3323 Diag(BreakLoc, diag::err_acc_branch_in_out_compute_construct)
3337 const auto*DR = dyn_cast<DeclRefExpr>(
E->
IgnoreParens());
3338 if(!DR || DR->refersToEnclosingVariableOrCapture())
3340 const auto*VD = dyn_cast<VarDecl>(DR->getDecl());
3363 if(VD->
getKind() == Decl::ParmVar)
3365 else if(VD->
getKind() != Decl::Var)
3378 if(VD->
hasAttr<BlocksAttr>())
3414 autoinvalidNRVO = [&] {
3423 if((ReturnType->
getTypeClass() == Type::TypeClass::Auto &&
3426 returninvalidNRVO();
3432 returninvalidNRVO();
3452 const auto*Step = llvm::find_if(
Seq.steps(), [](
const auto&Step) {
3453return Step.Kind == InitializationSequence::SK_ConstructorInitialization ||
3454Step.Kind == InitializationSequence::SK_UserConversion;
3456 if(Step !=
Seq.step_end()) {
3457 const auto*FD = Step->Function.Function;
3458 if(isa<CXXConstructorDecl>(FD)
3460: cast<CXXMethodDecl>(FD)->getRefQualifier() ==
RQ_None)
3468 boolSupressSimplerImplicitMoves) {
3474 Expr*InitExpr = &AsRvalue;
3476 Value->getBeginLoc());
3478 autoRes =
Seq.getFailedOverloadResult();
3489 return Seq.Perform(*
this, Entity, Kind,
Value);
3509 boolSupressSimplerImplicitMoves) {
3517 boolHasDeducedReturnType =
3527RetValExp = ER.
get();
3533 if(HasDeducedReturnType) {
3546assert(AT &&
"lost auto type from lambda return type");
3558 if(RetValExp && !isa<InitListExpr>(RetValExp)) {
3560 if(
Result.isInvalid())
3562RetValExp =
Result.get();
3577 Diag(ReturnLoc, diag::err_lambda_return_init_list)
3591 if(
auto*CurBlock = dyn_cast<BlockScopeInfo>(CurCap)) {
3593 Diag(ReturnLoc, diag::err_noreturn_block_has_return_expr);
3596}
else if(
auto*CurRegion = dyn_cast<CapturedRegionScopeInfo>(CurCap)) {
3597 Diag(ReturnLoc, diag::err_return_in_captured_stmt) << CurRegion->getRegionName();
3600assert(CurLambda &&
"unknown kind of captured scope");
3604 Diag(ReturnLoc, diag::err_noreturn_lambda_has_return_expr);
3616 if(RetValExp && !isa<InitListExpr>(RetValExp) &&
3622 Diag(ReturnLoc, diag::ext_return_has_void_expr) <<
"literal"<< 2;
3624 Diag(ReturnLoc, diag::err_return_block_has_expr);
3625RetValExp =
nullptr;
3628}
else if(!RetValExp) {
3629 return StmtError(
Diag(ReturnLoc, diag::err_block_return_missing_expr));
3642Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
3647RetValExp = Res.
get();
3648CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc);
3656RetValExp = ER.
get();
3670 if(
auto*CurBlock = dyn_cast<BlockScopeInfo>(CurCap);
3673CurBlock->TheDecl->setInvalidDecl();
3693LocalTypedefNameReferencer(
Sema&S) : S(S) {}
3694 boolVisitRecordType(
RecordType*RT)
override;
3699boolLocalTypedefNameReferencer::VisitRecordType(
RecordType*RT) {
3700 auto*R = dyn_cast<CXXRecordDecl>(RT->
getDecl());
3701 if(!R || !R->isLocalClass() || !R->isLocalClass()->isExternallyVisible() ||
3702R->isDependentType())
3704 for(
auto*TmpD : R->decls())
3705 if(
auto*
T= dyn_cast<TypedefNameDecl>(TmpD))
3706 if(
T->getAccess() !=
AS_private|| R->hasFriends())
3728 if(isa_and_nonnull<InitListExpr>(RetExpr)) {
3733: diag::err_auto_fn_return_init_list)
3743assert(AT->
isDeduced() &&
"should have deduced to dependent type");
3757 Diag(ReturnLoc, diag::err_auto_fn_return_void_but_not_auto)
3758<< OrigResultType.
getType();
3773 if(FindResult.Expression)
3774TemplateSpecLoc = FindResult.Expression->getNameLoc();
3778OrigResultType, RetExpr, Deduced, Info,
false,
3779 false, &FailedTSC);
3794 Diag(ReturnLoc, diag::err_typecheck_missing_return_type_incompatible)
3797 Diag(ReturnLoc, diag::err_auto_fn_different_deductions)
3803 Diag(RetExpr->
getExprLoc(), diag::err_auto_fn_deduction_failure)
3812LocalTypedefNameReferencer(*this).TraverseType(RetExpr->
getType());
3835RetValExp,
nullptr,
true);
3839 if(
getCurScope()->isInOpenACCComputeConstructScope())
3841 Diag(ReturnLoc, diag::err_acc_branch_in_out_compute_construct)
3848 "first coroutine location not set");
3849 Diag(ReturnLoc, diag::err_return_in_coroutine);
3854CheckInvalidBuiltinCountedByRef(RetVal.
get(), ReturnArgKind);
3862 const_cast<VarDecl*
>(cast<ReturnStmt>(R.
get())->getNRVOCandidate());
3886 boolAllowRecovery) {
3894 boolSupressSimplerImplicitMoves =
3902SupressSimplerImplicitMoves);
3906 const AttrVec*Attrs =
nullptr;
3907 boolisObjCMethod =
false;
3914 Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr) << FD;
3915 if(FD->
isMain() && RetValExp)
3916 if(isa<CXXBoolLiteralExpr>(RetValExp))
3917 Diag(ReturnLoc, diag::warn_main_returns_bool_literal)
3919 if(FD->
hasAttr<CmseNSEntryAttr>() && RetValExp) {
3920 if(
const auto*RT = dyn_cast<RecordType>(FnRetType.
getCanonicalType())) {
3922 Diag(RetValExp->
getBeginLoc(), diag::warn_cmse_nonsecure_union) << 1;
3927isObjCMethod =
true;
3941 const auto*ATy = dyn_cast<ArrayType>(RetValExp->
getType());
3942 if(ATy && ATy->getElementType().isWebAssemblyReferenceType()) {
3943 Diag(ReturnLoc, diag::err_wasm_table_art) << 1;
3957RetValExp = ER.
get();
3983AT->isDeduced() ? FnRetType :
QualType());
3984 if(Recovery.isInvalid())
3986RetValExp = Recovery.get();
4002 if(
auto*ILE = dyn_cast<InitListExpr>(RetValExp)) {
4007 intFunctionKind = 0;
4008 if(isa<ObjCMethodDecl>(CurDecl))
4010 else if(isa<CXXConstructorDecl>(CurDecl))
4012 else if(isa<CXXDestructorDecl>(CurDecl))
4015 Diag(ReturnLoc, diag::err_return_init_list)
4019RetValExp = AllowRecovery
4021ILE->getRBraceLoc(), ILE->inits())
4026 unsigned D= diag::ext_return_has_expr;
4029 if(isa<CXXConstructorDecl>(CurDecl) ||
4030isa<CXXDestructorDecl>(CurDecl))
4031 D= diag::err_ctor_dtor_returns_void;
4033 D= diag::ext_return_has_void_expr;
4038 if(
Result.isInvalid())
4040RetValExp =
Result.get();
4045 if(
D== diag::err_ctor_dtor_returns_void) {
4047 Diag(ReturnLoc,
D) << CurDecl << isa<CXXDestructorDecl>(CurDecl)
4051 else if(
D!= diag::ext_return_has_void_expr ||
4055 intFunctionKind = 0;
4056 if(isa<ObjCMethodDecl>(CurDecl))
4058 else if(isa<CXXConstructorDecl>(CurDecl))
4060 else if(isa<CXXDestructorDecl>(CurDecl))
4063 Diag(ReturnLoc,
D)
4073RetValExp = ER.
get();
4079}
else if(!RetValExp && !HasDependentReturnType) {
4086 Diag(ReturnLoc, diag::err_constexpr_return_missing_expr)
4092 unsignedDiagID =
getLangOpts().C99 ? diag::ext_return_missing_expr
4093: diag::warn_return_missing_expr;
4097 "Not in a FunctionDecl or ObjCMethodDecl?");
4098 boolIsMethod = FD ==
nullptr;
4101 Diag(ReturnLoc, DiagID) << ND << IsMethod;
4107assert(RetValExp || HasDependentReturnType);
4108 QualTypeRetType = RelatedRetType.
isNull() ? FnRetType : RelatedRetType;
4121Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
4124RetValExp->
getEndLoc(), RetValExp, RetType);
4135 if(!RelatedRetType.
isNull()) {
4146CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc, isObjCMethod, Attrs,
4155RetValExp = ER.
get();
4162 if(
Result->getNRVOCandidate())
4173 Stmt*HandlerBlock) {
4176 CXXCatchStmt(CatchLoc, cast_or_null<VarDecl>(ExDecl), HandlerBlock);
4180classCatchHandlerType {
4182LLVM_PREFERRED_TYPE(
bool)
4183 unsignedIsPointer : 1;
4187 friend structllvm::DenseMapInfo<CatchHandlerType>;
4188 enumUnique { ForDenseMap };
4189CatchHandlerType(
QualTypeQT, Unique) : QT(QT), IsPointer(
false) {}
4207CatchHandlerType(
QualTypeQT,
boolIsPointer)
4208: QT(QT), IsPointer(IsPointer) {}
4210 QualTypeunderlying()
const{
returnQT; }
4211 boolisPointer()
const{
returnIsPointer; }
4213 friend bool operator==(
constCatchHandlerType &LHS,
4214 constCatchHandlerType &RHS) {
4216 if(LHS.IsPointer != RHS.IsPointer)
4219 returnLHS.QT == RHS.QT;
4225template<>
structDenseMapInfo<CatchHandlerType> {
4227 returnCatchHandlerType(DenseMapInfo<QualType>::getEmptyKey(),
4228CatchHandlerType::ForDenseMap);
4232 returnCatchHandlerType(DenseMapInfo<QualType>::getTombstoneKey(),
4233CatchHandlerType::ForDenseMap);
4237 returnDenseMapInfo<QualType>::getHashValue(
Base.underlying());
4240 static bool isEqual(
constCatchHandlerType &LHS,
4241 constCatchHandlerType &RHS) {
4248classCatchTypePublicBases {
4249 constllvm::DenseMap<QualType, CXXCatchStmt *> &TypesToCheck;
4256CatchTypePublicBases(
constllvm::DenseMap<QualType, CXXCatchStmt *> &
T,
4258: TypesToCheck(
T), FoundHandler(nullptr), TestAgainstType(QT) {}
4260 CXXCatchStmt*getFoundHandler()
const{
returnFoundHandler; }
4261 QualTypegetFoundHandlerType()
const{
returnFoundHandlerType; }
4264 if(S->getAccessSpecifier() == AccessSpecifier::AS_public) {
4265 QualTypeCheck = S->getType().getCanonicalType();
4266 const auto&M = TypesToCheck;
4267 autoI = M.find(Check);
4279 if(I->second->getCaughtType()->isPointerType() ==
4281FoundHandler = I->second;
4282FoundHandlerType = Check;
4295 const boolIsOpenMPGPUTarget =
4296 getLangOpts().OpenMPIsTargetDevice && (
T.isNVPTX() ||
T.isAMDGCN());
4299 if(!IsOpenMPGPUTarget && !
getLangOpts().CXXExceptions &&
4302 targetDiag(TryLoc, diag::err_exceptions_disabled) <<
"try";
4307 if(IsOpenMPGPUTarget)
4308 targetDiag(TryLoc, diag::warn_try_not_valid_on_target) <<
T.str();
4313<<
"try"<< llvm::to_underlying(
CUDA().CurrentTarget());
4316 Diag(TryLoc, diag::err_omp_simd_region_cannot_use_stmt) <<
"try";
4322 Diag(TryLoc, diag::err_mixing_cxx_try_seh_try) << 0;
4326 const unsignedNumHandlers = Handlers.size();
4327assert(!Handlers.empty() &&
4328 "The parser shouldn't call this if there are no handlers.");
4330llvm::DenseMap<QualType, CXXCatchStmt *> HandledBaseTypes;
4331llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> HandledTypes;
4332 for(
unsignedi = 0; i < NumHandlers; ++i) {
4339 if(i < NumHandlers - 1)
4353 QualTypeUnderlying = HandlerCHT.underlying();
4355 if(!RD->hasDefinition())
4363Paths.setOrigin(RD);
4364CatchTypePublicBases CTPB(HandledBaseTypes,
4366 if(RD->lookupInBases(CTPB, Paths)) {
4368 if(!Paths.isAmbiguous(
4371diag::warn_exception_caught_by_earlier_handler)
4374diag::note_previous_exception_handler)
4386 autoR = HandledTypes.insert(
4391diag::warn_exception_caught_by_earlier_handler)
4394diag::note_previous_exception_handler)
4407assert(TryBlock && Handler);
4434 Diag(TryLoc, diag::err_seh_try_outside_functions);
4438 Diag(TryLoc, diag::err_seh_try_unsupported);
4445assert(FilterExpr &&
Block);
4449 Diag(FilterExpr->
getExprLoc(), diag::err_filter_expression_integral)
4471 Scope*SEHTryParent = CurScope;
4473SEHTryParent = SEHTryParent->
getParent();
4488QualifierLoc, NameInfo,
4489cast<CompoundStmt>(Nested));
4506 unsignedNumParams) {
4524assert(NumParams > 0 &&
"CapturedStmt requires context parameter");
4568CaptureInits.push_back(
Init.get());
4573staticstd::optional<int>
4590 unsignedNumParams) {
4592 Diag(
Loc, diag::err_sme_openmp_captured_region) << *ErrorIndex;
4624 unsignedOpenMPCaptureLevel) {
4626 Diag(
Loc, diag::err_sme_openmp_captured_region) << *ErrorIndex;
4633 boolContextIsFound =
false;
4634 unsignedParamNum = 0;
4637I !=
E; ++I, ++ParamNum) {
4638 if(I->second.isNull()) {
4639assert(!ContextIsFound &&
4640 "null type has been found already for '__context' parameter");
4650ContextIsFound =
true;
4660assert(ContextIsFound &&
"no null type for '__context' parameter");
4661 if(!ContextIsFound) {
4717Captures, 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.
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 for CUDA 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 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 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 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.
static void CheckJumpOutOfSEHFinally(Sema &S, SourceLocation Loc, const Scope &DestScope)
Defines the Objective-C statement AST node classes.
enum clang::format::@1315::AnnotatingParser::Context::@350 ContextType
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 ...
SourceManager & getSourceManager()
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
unsigned getIntWidth(QualType T) const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
const TargetInfo & getTargetInfo() const
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
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)
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
bool isDecltypeAuto() const
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
BreakStmt - This represents a break.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a base class of a C++ class.
Represents binding an expression to a temporary.
A boolean literal, per ([C++ lex.bool] Boolean literals).
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++ constructor within a class.
Represents a C++ conversion function within a class.
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
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....
Represents a static or instance method of a struct/union/class.
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, bool DelayTypeCreation=false)
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)
Builds a canonical type from a QualType.
QualType withConst() const
Retrieves a version of this type with const applied.
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...
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)
ConditionalOperator - The ?: ternary operator.
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 isStdNamespace() const
bool isFunctionOrMethod() const
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
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
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
SourceLocation getDefaultLoc() const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
DoStmt - This represents a 'do/while' stmt.
Recursive AST visitor that supports extension via dynamic dispatch.
enumerator_range enumerators() const
bool isClosed() const
Returns true if this enum is either annotated with enum_extensibility(closed) or isn't annotated with...
bool isClosedNonFlag() const
Returns true if this enum is annotated with neither flag_enum nor enum_extensibility(open).
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getDecl() const
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, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) 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, e.g.
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.
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
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
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
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.
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
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
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.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
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, 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.
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.
A pointer to member type per C++ 8.3.3 - Pointers to members.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
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.
Represents Objective-C's collection statement.
An expression that sends a message to the given Objective-C object or class.
ObjCMethodDecl - Represents an instance or class method declaration.
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type.
QualType getReturnType() const
ObjCInterfaceDecl * getClassInterface()
Represents a pointer to an Objective C object.
Wrapper for void* pointer.
void * getAsOpaquePtr() const
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.
ParenExpr - This represents a parenthesized expression, e.g.
Represents a parameter to a function.
ParsedAttributes - A collection of parsed attributes.
Wrapper for source info for pointers.
SourceLocation getStarLoc() const
IdentifierTable & getIdentifierTable()
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 withRestrict() const
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.
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)
bool isOrContainsUnion() const
Returns whether this record is a union, or contains (at any nesting level) a union member.
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.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
void setRetValue(Expr *E)
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.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
bool Contains(const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
unsigned getFlags() const
getFlags - Return the flags for this scope.
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by.
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.
void updateNRVOCandidate(VarDecl *VD)
@ SwitchScope
This is a scope that corresponds to a switch statement.
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
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.
void DiagnoseDiscardedExprMarkedNodiscard(const Expr *E)
DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is semantically a discarded-value exp...
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 ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
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...
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA)
Check whether the given statement can have musttail applied to it, issuing a diagnostic and returning...
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, Scope *CurScope)
void setFunctionHasBranchIntoScope()
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
FieldDecl * BuildCaptureField(RecordDecl *RD, const sema::Capture &Capture)
Build a FieldDecl suitable to hold the given capture.
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.
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
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.
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...
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused,...
FPOptions & getCurFPFeatures()
@ UPPC_Expression
An arbitrary expression.
const LangOptions & getLangOpts() const
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....
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
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...
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.
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...
ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
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)
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.
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.
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
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.
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 ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope)
@ CCEK_CaseValue
Expression in a case label.
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)
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
StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope)
void ActOnStartSEHFinallyBlock()
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void ActOnAbortSEHFinallyBlock()
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...
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
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
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
const SwitchCase * getNextSwitchCase() const
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()
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.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool isSEHTrySupported() const
Whether the target supports SEH __try.
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.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isRValueReferenceType() const
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.
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,...
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),...
Represents a C++ unqualified-id that has been parsed.
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.
WhileStmt - This represents a 'while' stmt.
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.
llvm::PointerIntPair< SwitchStmt *, 1, bool > SwitchInfo
A SwitchStmt, along with a flag indicating if its list of case statements is incomplete (because we d...
SourceLocation FirstCXXOrObjCTryLoc
First C++ 'try' or ObjC @try statement in the current function.
SourceLocation FirstCoroutineStmtLoc
First coroutine statement in the current function.
StringRef getFirstCoroutineStmtKeyword() const
SourceLocation FirstReturnLoc
First 'return' statement in the current function.
enum clang::sema::FunctionScopeInfo::@245 FirstTryType
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.
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...
The JSON file list parser is used to communicate input to InstallAPI.
Expr * IgnoreElidableImplicitConstructorSingleStep(Expr *E)
@ 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.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
CapturedRegionKind
The different kinds of captured statement.
@ Result
The result type of a method or function.
bool hasArmZT0State(const FunctionDecl *FD)
Returns whether the given FunctionDecl has Arm ZT0 state.
ActionResult< Expr * > ExprResult
@ Struct
The "struct" keyword.
bool isLambdaConversionOperator(CXXConversionDecl *C)
ActionResult< Stmt * > StmtResult
@ 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)
const FunctionProtoType * T
Expr * IgnoreImplicitAsWrittenSingleStep(Expr *E)
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
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.
bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)
Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.
@ CapturedContext
Parameter for captured context.
bool hasArmZAState(const FunctionDecl *FD)
Returns whether the given FunctionDecl has Arm ZA state.
Diagnostic wrappers for TextAPI types for error reporting.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
EvalResult is a struct with detailed info about an evaluated expression.
@ MoveEligibleAndCopyElidable
bool isMoveEligible() const
bool isCopyElidable() const
const VarDecl * Candidate
static CatchHandlerType getEmptyKey()
static CatchHandlerType getTombstoneKey()
static unsigned getHashValue(const CatchHandlerType &Base)
static bool isEqual(const CatchHandlerType &LHS, const CatchHandlerType &RHS)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4