35 #include "llvm/ADT/ArrayRef.h" 36 #include "llvm/ADT/DenseMap.h" 37 #include "llvm/ADT/STLExtras.h" 38 #include "llvm/ADT/SmallPtrSet.h" 39 #include "llvm/ADT/SmallString.h" 40 #include "llvm/ADT/SmallVector.h" 42 using namespace clang;
49 FE = ActOnFinishFullExpr(FE.
get(), FE.
get()->getExprLoc(),
64 DiscardCleanupsInEvaluationContext();
69 bool HasLeadingEmptyMacro) {
70 return new (Context)
NullStmt(SemiLoc, HasLeadingEmptyMacro);
80 return new (Context)
DeclStmt(DG, StartLoc, EndLoc);
110 if (getLangOpts().ObjCAutoRefCount) {
135 if (!Op->isComparisonOp())
138 if (Op->getOpcode() == BO_EQ)
140 else if (Op->getOpcode() == BO_NE)
142 else if (Op->getOpcode() == BO_Cmp)
145 assert(Op->isRelationalOp());
148 Loc = Op->getOperatorLoc();
149 CanAssign = Op->getLHS()->IgnoreParenImpCasts()->isLValue();
151 switch (Op->getOperator()) {
155 case OO_ExclaimEqual:
160 case OO_GreaterEqual:
171 Loc = Op->getOperatorLoc();
172 CanAssign = Op->getArg(0)->IgnoreParenImpCasts()->isLValue();
183 S.
Diag(Loc, diag::warn_unused_comparison)
189 if (Kind == Inequality)
190 S.
Diag(Loc, diag::note_inequality_comparison_to_or_assign)
193 S.
Diag(Loc, diag::note_equality_comparison_to_assign)
202 return DiagnoseUnusedExprResult(
Label->getSubStmt());
204 const Expr *E = dyn_cast_or_null<Expr>(S);
210 if (isUnevaluatedContext())
219 bool ShouldSuppress =
220 SourceMgr.isMacroBodyExpansion(ExprLoc) ||
221 SourceMgr.isInSystemMacro(ExprLoc);
223 const Expr *WarnExpr;
226 if (!E->isUnusedResultAWarning(WarnExpr, Loc, R1, R2, Context))
239 if (isa<ParenExpr>(E->IgnoreImpCasts()) && Loc.
isMacroID()) {
241 if (findMacroSpelling(SpellLoc,
"UNREFERENCED_PARAMETER"))
248 unsigned DiagID = diag::warn_unused_expr;
250 E = Temps->getSubExpr();
252 E = TempExpr->getSubExpr();
258 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
259 if (E->getType()->isVoidType())
266 if (
const Decl *FD = CE->getCalleeDecl()) {
267 if (
const Attr *A = isa<FunctionDecl>(FD)
268 ? cast<FunctionDecl>(FD)->getUnusedResultAttr()
269 : FD->getAttr<WarnUnusedResultAttr>()) {
270 Diag(Loc, diag::warn_unused_result) << A << R1 << R2;
275 if (FD->hasAttr<PureAttr>()) {
276 Diag(Loc, diag::warn_unused_call) << R1 << R2 <<
"pure";
279 if (FD->hasAttr<ConstAttr>()) {
280 Diag(Loc, diag::warn_unused_call) << R1 << R2 <<
"const";
284 }
else if (ShouldSuppress)
288 if (getLangOpts().ObjCAutoRefCount && ME->isDelegateInitCall()) {
289 Diag(Loc, diag::err_arc_unused_init_message) << R1;
294 if (
const auto *A = MD->
getAttr<WarnUnusedResultAttr>()) {
295 Diag(Loc, diag::warn_unused_result) << A << R1 << R2;
300 const Expr *Source = POE->getSyntacticForm();
301 if (isa<ObjCSubscriptRefExpr>(Source))
302 DiagID = diag::warn_unused_container_subscript_expr;
304 DiagID = diag::warn_unused_property_expr;
306 = dyn_cast<CXXFunctionalCastExpr>(E)) {
307 const Expr *E = FC->getSubExpr();
309 E = TE->getSubExpr();
310 if (isa<CXXTemporaryObjectExpr>(E))
313 if (
const CXXRecordDecl *RD = CE->getType()->getAsCXXRecordDecl())
314 if (!RD->getAttr<WarnUnusedAttr>())
318 else if (
const CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(E)) {
326 Diag(Loc, diag::warn_unused_voidptr)
332 if (E->isGLValue() && E->getType().isVolatileQualified()) {
333 Diag(Loc, diag::warn_unused_volatile) << R1 << R2;
337 DiagRuntimeBehavior(Loc,
nullptr, PDiag(DiagID) << R1 << R2);
349 return getCurFunction()->CompoundScopes.back();
354 const unsigned NumElts = Elts.size();
362 for (; i != NumElts && isa<DeclStmt>(Elts[i]); ++i)
366 for (; i != NumElts && !isa<DeclStmt>(Elts[i]); ++i)
370 Decl *D = *cast<DeclStmt>(Elts[i])->decl_begin();
375 for (
unsigned i = 0; i != NumElts; ++i) {
377 if (isStmtExpr && i == NumElts - 1)
380 DiagnoseUnusedExprResult(Elts[i]);
386 if (NumElts != 0 && !CurrentInstantiationScope &&
387 getCurCompoundScope().HasEmptyLoopBodies) {
388 for (
unsigned i = 0; i != NumElts - 1; ++i)
389 DiagnoseEmptyLoopBody(Elts[i], Elts[i + 1]);
399 assert(LHSVal &&
"missing expression in case statement");
401 if (getCurFunction()->SwitchStack.empty()) {
402 Diag(CaseLoc, diag::err_case_not_in_switch);
407 CorrectDelayedTyposInExpr(LHSVal, [
this](
class Expr *E) {
409 return VerifyIntegerConstantExpression(E);
411 getCurFunction()->SwitchStack.back()->getCond()) {
412 QualType CondType = CondExpr->getType();
413 llvm::APSInt TempVal;
427 LHSVal = VerifyIntegerConstantExpression(LHSVal).get();
435 RHSVal = VerifyIntegerConstantExpression(RHSVal).get();
440 LHS = ActOnFinishFullExpr(LHSVal, LHSVal->
getExprLoc(),
false,
441 getLangOpts().CPlusPlus11);
445 auto RHS = RHSVal ? ActOnFinishFullExpr(RHSVal, RHSVal->
getExprLoc(),
false,
446 getLangOpts().CPlusPlus11)
453 getCurFunction()->SwitchStack.back()->addSwitchCase(CS);
459 DiagnoseUnusedExprResult(SubStmt);
468 DiagnoseUnusedExprResult(SubStmt);
470 if (getCurFunction()->SwitchStack.empty()) {
471 Diag(DefaultLoc, diag::err_default_not_in_switch);
476 getCurFunction()->SwitchStack.back()->addSwitchCase(DS);
485 Diag(IdentLoc, diag::err_redefinition_of_label) << TheDecl->
getDeclName();
517 CommaVisitor(
Sema &SemaRef) : Inherited(SemaRef.
Context), SemaRef(SemaRef) {}
539 Expr *CondExpr = Cond.
get().second;
540 if (!Diags.isIgnored(diag::warn_comma_operator,
542 CommaVisitor(*this).Visit(CondExpr);
545 DiagnoseEmptyStmtBody(CondExpr->
getLocEnd(), thenStmt,
546 diag::warn_empty_if_body);
548 return BuildIfStmt(IfLoc, IsConstexpr, InitStmt, Cond, thenStmt, ElseLoc,
559 if (IsConstexpr || isa<ObjCAvailabilityCheckExpr>(Cond.
get().second))
560 getCurFunction()->setHasBranchProtectedScope();
562 DiagnoseUnusedExprResult(thenStmt);
563 DiagnoseUnusedExprResult(elseStmt);
566 IfStmt(Context, IfLoc, IsConstexpr, InitStmt, Cond.
get().first,
567 Cond.
get().second, thenStmt, ElseLoc, elseStmt);
571 struct CaseCompareFunctor {
572 bool operator()(
const std::pair<llvm::APSInt, CaseStmt*> &LHS,
573 const llvm::APSInt &RHS) {
574 return LHS.first < RHS;
576 bool operator()(
const std::pair<llvm::APSInt, CaseStmt*> &LHS,
577 const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
578 return LHS.first < RHS.first;
580 bool operator()(
const llvm::APSInt &LHS,
581 const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
582 return LHS < RHS.first;
589 static bool CmpCaseVals(
const std::pair<llvm::APSInt, CaseStmt*>& lhs,
590 const std::pair<llvm::APSInt, CaseStmt*>& rhs) {
591 if (lhs.first < rhs.first)
594 if (lhs.first == rhs.first &&
595 lhs.second->getCaseLoc().getRawEncoding()
596 < rhs.second->getCaseLoc().getRawEncoding())
603 static bool CmpEnumVals(
const std::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
604 const std::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
606 return lhs.first < rhs.first;
611 static bool EqEnumVals(
const std::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
612 const std::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
614 return lhs.first == rhs.first;
620 if (
const auto *CleanUps = dyn_cast<ExprWithCleanups>(E))
621 E = CleanUps->getSubExpr();
622 while (
const auto *ImpCast = dyn_cast<ImplicitCastExpr>(E)) {
623 if (ImpCast->getCastKind() != CK_IntegralCast)
break;
624 E = ImpCast->getSubExpr();
634 SwitchConvertDiagnoser(
Expr *Cond)
640 return S.
Diag(Loc, diag::err_typecheck_statement_requires_integer) <<
T;
645 return S.
Diag(Loc, diag::err_switch_incomplete_class_type)
651 return S.
Diag(Loc, diag::err_switch_explicit_conversion) << T << ConvTy;
662 return S.
Diag(Loc, diag::err_switch_multiple_conversions) <<
T;
673 llvm_unreachable(
"conversion functions are permitted");
675 } SwitchDiagnoser(Cond);
678 PerformContextualImplicitConversion(SwitchLoc, Cond, SwitchDiagnoser);
683 return UsualUnaryConversions(CondResult.
get());
691 getCurFunction()->setHasBranchIntoScope();
695 getCurFunction()->SwitchStack.push_back(SS);
699 static void AdjustAPSInt(llvm::APSInt &Val,
unsigned BitWidth,
bool IsSigned) {
700 Val = Val.extOrTrunc(BitWidth);
701 Val.setIsSigned(IsSigned);
707 unsigned UnpromotedWidth,
bool UnpromotedSign) {
711 if (UnpromotedWidth < Val.getBitWidth()) {
712 llvm::APSInt ConvVal(Val);
714 AdjustAPSInt(ConvVal, Val.getBitWidth(), Val.isSigned());
719 S.
Diag(Loc, diag::warn_case_value_overflow) << Val.toString(10)
720 << ConvVal.toString(10);
730 const Expr *CaseExpr,
731 EnumValsTy::iterator &EI,
732 EnumValsTy::iterator &EIEnd,
733 const llvm::APSInt &Val) {
739 if (
const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
748 if (ED->
hasAttr<FlagEnumAttr>())
751 while (EI != EIEnd && EI->first < Val)
754 if (EI != EIEnd && EI->first == Val)
767 if (!CondEnumType || !CaseEnumType)
774 if (!CaseEnumType->getDecl()->getIdentifier() &&
775 !CaseEnumType->getDecl()->getTypedefNameForAnonDecl())
781 S.
Diag(Case->
getExprLoc(), diag::warn_comparison_of_mixed_enum_types_switch)
790 assert(SS == getCurFunction()->SwitchStack.back() &&
791 "switch stack missing push/pop!");
793 getCurFunction()->SwitchStack.pop_back();
796 SS->
setBody(BodyStmt, SwitchLoc);
803 const Expr *CondExprBeforePromotion = CondExpr;
825 Diag(SwitchLoc, diag::warn_bool_switch_condition)
832 bool HasDependentValue
834 unsigned CondWidth = HasDependentValue ? 0 : Context.
getIntWidth(CondType);
841 unsigned CondWidthBeforePromotion
842 = HasDependentValue ? 0 : Context.
getIntWidth(CondTypeBeforePromotion);
843 bool CondIsSignedBeforePromotion
853 typedef std::vector<std::pair<llvm::APSInt, CaseStmt*> > CaseRangesTy;
854 CaseRangesTy CaseRanges;
858 bool CaseListIsErroneous =
false;
864 if (TheDefaultStmt) {
865 Diag(DS->getDefaultLoc(), diag::err_multiple_default_labels_defined);
872 CaseListIsErroneous =
true;
881 if (Lo->isTypeDependent() || Lo->isValueDependent()) {
882 HasDependentValue =
true;
896 CaseListIsErroneous =
true;
903 LoVal = Lo->EvaluateKnownConstInt(Context);
907 Lo = DefaultLvalueConversion(Lo).get();
908 Lo = ImpCastExprToType(Lo, CondType, CK_IntegralCast).get();
914 CondWidthBeforePromotion, CondIsSignedBeforePromotion);
925 HasDependentValue =
true;
928 CaseRanges.push_back(std::make_pair(LoVal, CS));
930 CaseVals.push_back(std::make_pair(LoVal, CS));
934 if (!HasDependentValue) {
937 llvm::APSInt ConstantCondValue;
938 bool HasConstantCond =
false;
939 if (!HasDependentValue && !TheDefaultStmt) {
940 HasConstantCond = CondExpr->
EvaluateAsInt(ConstantCondValue, Context,
942 assert(!HasConstantCond ||
943 (ConstantCondValue.getBitWidth() == CondWidth &&
944 ConstantCondValue.isSigned() == CondIsSigned));
946 bool ShouldCheckConstantCond = HasConstantCond;
949 std::stable_sort(CaseVals.begin(), CaseVals.end(),
CmpCaseVals);
951 if (!CaseVals.empty()) {
952 for (
unsigned i = 0, e = CaseVals.size(); i != e; ++i) {
953 if (ShouldCheckConstantCond &&
954 CaseVals[i].first == ConstantCondValue)
955 ShouldCheckConstantCond =
false;
957 if (i != 0 && CaseVals[i].first == CaseVals[i-1].first) {
960 StringRef PrevString, CurrString;
963 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(PrevCase)) {
964 PrevString = DeclRef->getDecl()->getName();
966 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(CurrCase)) {
967 CurrString = DeclRef->getDecl()->getName();
970 CaseVals[i-1].first.toString(CaseValStr);
972 if (PrevString == CurrString)
973 Diag(CaseVals[i].second->getLHS()->getLocStart(),
974 diag::err_duplicate_case) <<
975 (PrevString.empty() ? StringRef(CaseValStr) : PrevString);
977 Diag(CaseVals[i].second->getLHS()->getLocStart(),
978 diag::err_duplicate_case_differing_expr) <<
979 (PrevString.empty() ? StringRef(CaseValStr) : PrevString) <<
980 (CurrString.empty() ? StringRef(CaseValStr) : CurrString) <<
983 Diag(CaseVals[i-1].second->getLHS()->getLocStart(),
984 diag::note_duplicate_case_prev);
987 CaseListIsErroneous =
true;
994 if (!CaseRanges.empty()) {
997 std::stable_sort(CaseRanges.begin(), CaseRanges.end());
1000 std::vector<llvm::APSInt> HiVals;
1001 for (
unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
1002 llvm::APSInt &LoVal = CaseRanges[i].first;
1003 CaseStmt *CR = CaseRanges[i].second;
1014 CaseListIsErroneous =
true;
1023 Hi = DefaultLvalueConversion(Hi).get();
1024 Hi = ImpCastExprToType(Hi, CondType, CK_IntegralCast).get();
1030 CondWidthBeforePromotion, CondIsSignedBeforePromotion);
1038 if (LoVal > HiVal) {
1042 CaseRanges.erase(CaseRanges.begin()+i);
1048 if (ShouldCheckConstantCond &&
1049 LoVal <= ConstantCondValue &&
1050 ConstantCondValue <= HiVal)
1051 ShouldCheckConstantCond =
false;
1053 HiVals.push_back(HiVal);
1059 for (
unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
1060 llvm::APSInt &CRLo = CaseRanges[i].first;
1061 llvm::APSInt &CRHi = HiVals[i];
1062 CaseStmt *CR = CaseRanges[i].second;
1067 llvm::APSInt OverlapVal(32);
1071 CaseValsTy::iterator I = std::lower_bound(CaseVals.begin(),
1072 CaseVals.end(), CRLo,
1073 CaseCompareFunctor());
1074 if (I != CaseVals.end() && I->first < CRHi) {
1075 OverlapVal = I->first;
1076 OverlapStmt = I->second;
1080 I = std::upper_bound(I, CaseVals.end(), CRHi, CaseCompareFunctor());
1081 if (I != CaseVals.begin() && (I-1)->first >= CRLo) {
1082 OverlapVal = (I-1)->first;
1083 OverlapStmt = (I-1)->second;
1088 if (i && CRLo <= HiVals[i-1]) {
1089 OverlapVal = HiVals[i-1];
1090 OverlapStmt = CaseRanges[i-1].second;
1096 << OverlapVal.toString(10);
1098 diag::note_duplicate_case_prev);
1101 CaseListIsErroneous =
true;
1107 if (!CaseListIsErroneous && ShouldCheckConstantCond) {
1110 Diag(CondExpr->
getExprLoc(), diag::warn_missing_case_for_condition)
1111 << ConstantCondValue.toString(10)
1123 if (!CaseListIsErroneous && !HasConstantCond && ET &&
1131 llvm::APSInt Val = EDI->getInitVal();
1133 EnumVals.push_back(std::make_pair(Val, EDI));
1135 std::stable_sort(EnumVals.begin(), EnumVals.end(),
CmpEnumVals);
1136 auto EI = EnumVals.begin(), EIEnd =
1137 std::unique(EnumVals.begin(), EnumVals.end(),
EqEnumVals);
1140 for (CaseValsTy::const_iterator CI = CaseVals.begin();
1141 CI != CaseVals.end(); CI++) {
1142 Expr *CaseExpr = CI->second->getLHS();
1146 << CondTypeBeforePromotion;
1150 EI = EnumVals.begin();
1151 for (CaseRangesTy::const_iterator RI = CaseRanges.begin();
1152 RI != CaseRanges.end(); RI++) {
1153 Expr *CaseExpr = RI->second->getLHS();
1157 << CondTypeBeforePromotion;
1160 RI->second->getRHS()->EvaluateKnownConstInt(Context);
1163 CaseExpr = RI->second->getRHS();
1167 << CondTypeBeforePromotion;
1171 auto CI = CaseVals.begin();
1172 auto RI = CaseRanges.begin();
1173 bool hasCasesNotInSwitch =
false;
1177 for (EI = EnumVals.begin(); EI != EIEnd; EI++){
1179 while (CI != CaseVals.end() && CI->first < EI->first)
1182 if (CI != CaseVals.end() && CI->first == EI->first)
1186 for (; RI != CaseRanges.end(); RI++) {
1188 RI->second->getRHS()->EvaluateKnownConstInt(Context);
1190 if (EI->first <= Hi)
1194 if (RI == CaseRanges.end() || EI->first < RI->first) {
1195 hasCasesNotInSwitch =
true;
1196 UnhandledNames.push_back(EI->second->getDeclName());
1200 if (TheDefaultStmt && UnhandledNames.empty() && ED->
isClosedNonFlag())
1204 if (!UnhandledNames.empty()) {
1206 TheDefaultStmt ? diag::warn_def_missing_case
1207 : diag::warn_missing_case)
1208 << (
int)UnhandledNames.size();
1210 for (
size_t I = 0, E =
std::min(UnhandledNames.size(), (
size_t)3);
1212 DB << UnhandledNames[I];
1215 if (!hasCasesNotInSwitch)
1221 DiagnoseEmptyStmtBody(CondExpr->
getLocEnd(), BodyStmt,
1222 diag::warn_empty_switch_body);
1226 if (CaseListIsErroneous)
1235 if (Diags.isIgnored(diag::warn_not_in_enum_assignment, SrcExpr->
getExprLoc()))
1249 const EnumDecl *ED = ET->getDecl();
1254 if (ED->
hasAttr<FlagEnumAttr>()) {
1255 if (!IsValueInFlagEnum(ED, RhsVal,
true))
1261 EnumValsTy EnumVals;
1266 llvm::APSInt Val = EDI->getInitVal();
1268 EnumVals.push_back(std::make_pair(Val, EDI));
1270 if (EnumVals.empty())
1272 std::stable_sort(EnumVals.begin(), EnumVals.end(),
CmpEnumVals);
1273 EnumValsTy::iterator EIend =
1274 std::unique(EnumVals.begin(), EnumVals.end(),
EqEnumVals);
1277 EnumValsTy::const_iterator EI = EnumVals.begin();
1278 while (EI != EIend && EI->first < RhsVal)
1280 if (EI == EIend || EI->first != RhsVal) {
1294 auto CondVal = Cond.
get();
1295 CheckBreakContinueBinding(CondVal.second);
1297 if (CondVal.second &&
1298 !Diags.isIgnored(diag::warn_comma_operator, CondVal.second->getExprLoc()))
1299 CommaVisitor(*this).Visit(CondVal.second);
1301 DiagnoseUnusedExprResult(Body);
1303 if (isa<NullStmt>(Body))
1304 getCurCompoundScope().setHasEmptyLoopBodies();
1306 return new (Context)
1307 WhileStmt(Context, CondVal.first, CondVal.second, Body, WhileLoc);
1314 assert(Cond &&
"ActOnDoStmt(): missing expression");
1316 CheckBreakContinueBinding(Cond);
1317 ExprResult CondResult = CheckBooleanCondition(DoLoc, Cond);
1320 Cond = CondResult.
get();
1322 CondResult = ActOnFinishFullExpr(Cond, DoLoc);
1325 Cond = CondResult.
get();
1327 DiagnoseUnusedExprResult(Body);
1329 return new (Context)
DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen);
1334 using DeclSetVector =
1335 llvm::SetVector<VarDecl *, llvm::SmallVector<VarDecl *, 8>,
1336 llvm::SmallPtrSet<VarDecl *, 8>>;
1342 DeclSetVector &Decls;
1348 DeclExtractor(
Sema &S, DeclSetVector &Decls,
1355 bool isSimple() {
return Simple; }
1363 void VisitStmt(
Stmt *S) {
1420 DeclSetVector &Decls;
1426 DeclMatcher(
Sema &S, DeclSetVector &Decls,
Stmt *Statement) :
1427 Inherited(S.
Context), Decls(Decls), FoundDecl(
false) {
1428 if (!Statement)
return;
1452 void CheckLValueToRValueCast(
Expr *E) {
1455 if (isa<DeclRefExpr>(E)) {
1460 Visit(CO->getCond());
1461 CheckLValueToRValueCast(CO->getTrueExpr());
1462 CheckLValueToRValueCast(CO->getFalseExpr());
1467 dyn_cast<BinaryConditionalOperator>(E)) {
1468 CheckLValueToRValueCast(BCO->getOpaqueValue()->getSourceExpr());
1469 CheckLValueToRValueCast(BCO->getFalseExpr());
1478 if (Decls.count(VD))
1486 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(S))
1488 Visit(OVE->getSourceExpr());
1494 bool FoundDeclInUse() {
return FoundDecl; }
1498 void CheckForLoopConditionalStatement(
Sema &S,
Expr *Second,
1501 if (!Second)
return;
1508 DeclSetVector Decls;
1510 DeclExtractor DE(S, Decls, Ranges);
1514 if (!DE.isSimple())
return;
1517 if (Decls.size() == 0)
return;
1520 for (
auto *VD : Decls)
1521 if (VD->getType().isVolatileQualified() || VD->hasGlobalStorage())
1524 if (DeclMatcher(S, Decls, Second).FoundDeclInUse() ||
1525 DeclMatcher(S, Decls, Third).FoundDeclInUse() ||
1526 DeclMatcher(S, Decls, Body).FoundDeclInUse())
1530 if (Decls.size() > 4) {
1533 PDiag << (unsigned)Decls.size();
1534 for (
auto *VD : Decls)
1535 PDiag << VD->getDeclName();
1538 for (
auto Range : Ranges)
1541 S.
Diag(Ranges.begin()->getBegin(), PDiag);
1546 bool ProcessIterationStmt(
Sema &S,
Stmt* Statement,
bool &Increment,
1548 if (
auto Cleanups = dyn_cast<ExprWithCleanups>(Statement))
1549 if (!Cleanups->cleanupsHaveSideEffects())
1550 Statement = Cleanups->getSubExpr();
1552 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(Statement)) {
1553 switch (UO->getOpcode()) {
1554 default:
return false;
1572 default:
return false;
1592 bool InSwitch =
false;
1595 BreakContinueFinder(
Sema &S,
const Stmt* Body) :
1606 void VisitBreakStmt(
const BreakStmt* E) {
1626 void VisitForStmt(
const ForStmt *S) {
1633 void VisitWhileStmt(
const WhileStmt *) {
1638 void VisitDoStmt(
const DoStmt *) {
1663 bool ContinueFound() {
return ContinueLoc.
isValid(); }
1664 bool BreakFound() {
return BreakLoc.
isValid(); }
1675 void CheckForRedundantIteration(
Sema &S,
Expr *Third,
Stmt *Body) {
1677 if (!Body || !Third)
return;
1687 if (!LastStmt)
return;
1689 bool LoopIncrement, LastIncrement;
1692 if (!ProcessIterationStmt(S, Third, LoopIncrement, LoopDRE))
return;
1693 if (!ProcessIterationStmt(S, LastStmt, LastIncrement, LastDRE))
return;
1697 if (LoopIncrement != LastIncrement ||
1700 if (BreakContinueFinder(S, Body).ContinueFound())
return;
1703 << LastDRE->
getDecl() << LastIncrement;
1711 void Sema::CheckBreakContinueBinding(
Expr *E) {
1714 BreakContinueFinder BCFinder(*
this, E);
1716 if (BCFinder.BreakFound() && BreakParent) {
1718 Diag(BCFinder.GetBreakLoc(), diag::warn_break_binds_to_switch);
1720 Diag(BCFinder.GetBreakLoc(), diag::warn_loop_ctrl_binds_to_inner)
1723 }
else if (BCFinder.ContinueFound() && CurScope->getContinueParent()) {
1724 Diag(BCFinder.GetContinueLoc(), diag::warn_loop_ctrl_binds_to_inner)
1736 if (!getLangOpts().CPlusPlus) {
1737 if (
DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
1741 for (
auto *DI : DS->decls()) {
1746 Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
1747 DI->setInvalidDecl();
1753 CheckBreakContinueBinding(Second.
get().second);
1754 CheckBreakContinueBinding(third.
get());
1756 if (!Second.
get().first)
1757 CheckForLoopConditionalStatement(*
this, Second.
get().second, third.
get(),
1759 CheckForRedundantIteration(*
this, third.
get(), Body);
1761 if (Second.
get().second &&
1762 !Diags.isIgnored(diag::warn_comma_operator,
1763 Second.
get().second->getExprLoc()))
1764 CommaVisitor(*this).Visit(Second.
get().second);
1768 DiagnoseUnusedExprResult(First);
1769 DiagnoseUnusedExprResult(Third);
1770 DiagnoseUnusedExprResult(Body);
1772 if (isa<NullStmt>(Body))
1773 getCurCompoundScope().setHasEmptyLoopBodies();
1775 return new (Context)
1776 ForStmt(Context, First, Second.
get().second, Second.
get().first, Third,
1777 Body, ForLoc, LParenLoc, RParenLoc);
1791 ExprResult FullExpr = ActOnFinishFullExpr(E);
1802 ExprResult result = CorrectDelayedTyposInExpr(collection);
1805 collection = result.
get();
1811 result = DefaultFunctionArrayLvalueConversion(collection);
1814 collection = result.
get();
1821 return Diag(forLoc, diag::err_collection_expr_type)
1832 (getLangOpts().ObjCAutoRefCount
1833 ? RequireCompleteType(forLoc,
QualType(objectType, 0),
1834 diag::err_arc_collection_forward, collection)
1835 : !isCompleteType(forLoc,
QualType(objectType, 0)))) {
1838 }
else if (iface || !objectType->
qual_empty()) {
1840 &Context.
Idents.
get(
"countByEnumeratingWithState"),
1856 method = LookupMethodInQualifiedType(selector, pointerType,
1861 Diag(forLoc, diag::warn_collection_expr_type)
1876 getCurFunction()->setHasBranchProtectedScope();
1879 CheckObjCForCollectionOperand(ForLoc, collection);
1883 if (
DeclStmt *DS = dyn_cast<DeclStmt>(First)) {
1884 if (!DS->isSingleDecl())
1886 diag::err_toomany_element_decls));
1898 diag::err_non_local_variable_decl_in_for));
1904 Expr *DeducedInit = &OpaqueId;
1907 DiagnoseAutoDeductionFailure(D, DeducedInit);
1908 if (FirstType.
isNull()) {
1915 if (!inTemplateInstantiation()) {
1918 Diag(Loc, diag::warn_auto_var_is_id)
1924 Expr *FirstE = cast<Expr>(First);
1927 diag::err_selector_element_not_lvalue)
1930 FirstType =
static_cast<Expr*
>(First)->getType();
1932 Diag(ForLoc, diag::err_selector_element_const_type)
1938 return StmtError(
Diag(ForLoc, diag::err_selector_element_type)
1945 CollectionExprResult = ActOnFinishFullExpr(CollectionExprResult.
get());
1950 nullptr, ForLoc, RParenLoc);
2004 void NoteForRangeBeginEndFunction(
Sema &SemaRef,
Expr *E,
2014 std::string Description;
2015 bool IsTemplate =
false;
2022 SemaRef.
Diag(Loc, diag::note_for_range_begin_end)
2023 << BEF << IsTemplate << Description << E->
getType();
2072 return ActOnObjCForCollectionStmt(ForLoc, First, Range, RParenLoc);
2075 assert(DS &&
"first part of for range not a decl stmt");
2084 DiagnoseUnexpandedParameterPack(Range, UPPC_Expression)) {
2092 if (!ActOnCoroutineBodyStart(S, CoawaitLoc,
"co_await"))
2098 VarDecl *RangeVar = BuildForRangeVarDecl(*
this, RangeLoc,
2102 diag::err_for_range_deduction_failure)) {
2110 StmtResult RangeDecl = ActOnDeclStmt(RangeGroup, RangeLoc, RangeLoc);
2116 return BuildCXXForRangeStmt(ForLoc, CoawaitLoc, ColonLoc, RangeDecl.
get(),
2119 DS, RParenLoc,
Kind);
2155 if (BeginMemberLookup.empty() != EndMemberLookup.
empty()) {
2157 *BEF = BeginMemberLookup.empty() ? BEF_end : BEF_begin;
2159 SemaRef.
Diag(RangeLoc, diag::err_for_range_member_begin_end_mismatch)
2160 << RangeLoc << BeginRange->
getType() << *BEF;
2174 BeginMemberLookup, CandidateSet,
2175 BeginRange, BeginExpr);
2180 << ColonLoc << BEF_begin << BeginRange->
getType();
2193 diag::err_for_range_iter_deduction_failure)) {
2194 NoteForRangeBeginEndFunction(SemaRef, BeginExpr->
get(), *BEF);
2201 EndMemberLookup, CandidateSet,
2206 << ColonLoc << BEF_end << EndRange->
getType();
2210 diag::err_for_range_iter_deduction_failure)) {
2211 NoteForRangeBeginEndFunction(SemaRef, EndExpr->
get(), *BEF);
2234 AdjustedRange = SemaRef.
BuildUnaryOp(S, RangeLoc, UO_Deref, Range);
2239 S, ForLoc, CoawaitLoc, LoopVarDecl, ColonLoc, AdjustedRange.
get(),
2248 SemaRef.
Diag(RangeLoc, diag::err_for_range_dereference)
2251 ColonLoc, AdjustedRange.
get(), RParenLoc,
2257 struct InvalidateOnErrorScope {
2258 InvalidateOnErrorScope(
Sema &SemaRef,
Decl *D,
bool Enabled)
2259 : Trap(SemaRef.
Diags), D(D), Enabled(Enabled) {}
2260 ~InvalidateOnErrorScope() {
2261 if (Enabled && Trap.hasErrorOccurred())
2287 Scope *S = getCurScope();
2289 DeclStmt *RangeDS = cast<DeclStmt>(RangeDecl);
2291 QualType RangeVarType = RangeVar->getType();
2293 DeclStmt *LoopVarDS = cast<DeclStmt>(LoopVarDecl);
2298 InvalidateOnErrorScope Invalidate(*
this, LoopVar,
2299 LoopVar->getType()->isUndeducedType());
2305 if (RangeVarType->isDependentType()) {
2307 RangeVar->markUsed(Context);
2311 if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) {
2312 if (
auto *DD = dyn_cast<DecompositionDecl>(LoopVar))
2313 for (
auto *Binding : DD->bindings())
2315 LoopVar->setType(SubstAutoType(LoopVar->getType(), Context.
DependentTy));
2317 }
else if (!BeginDeclStmt.get()) {
2322 ExprResult BeginRangeRef = BuildDeclRefExpr(RangeVar, RangeVarNonRefType,
2327 ExprResult EndRangeRef = BuildDeclRefExpr(RangeVar, RangeVarNonRefType,
2333 Expr *Range = RangeVar->getInit();
2338 if (RequireCompleteType(RangeLoc, RangeType,
2339 diag::err_for_range_incomplete_type))
2343 VarDecl *BeginVar = BuildForRangeVarDecl(*
this, ColonLoc, AutoType,
2345 VarDecl *EndVar = BuildForRangeVarDecl(*
this, ColonLoc, AutoType,
2357 BeginExpr = BeginRangeRef;
2359 BeginExpr = ActOnCoawaitExpr(S, ColonLoc, BeginExpr.
get());
2364 diag::err_for_range_iter_deduction_failure)) {
2365 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2375 dyn_cast<VariableArrayType>(UnqAT)) {
2398 ExprResult SizeOfVLAExprR = ActOnUnaryExprOrTypeTraitExpr(
2402 VAT->desugar(), RangeLoc))
2408 ExprResult SizeOfEachElementExprR = ActOnUnaryExprOrTypeTraitExpr(
2411 CreateParsedType(VAT->desugar(),
2413 VAT->getElementType(), RangeLoc))
2421 SizeOfVLAExprR.
get(), SizeOfEachElementExprR.
get());
2428 llvm_unreachable(
"Unexpected array type in for-range");
2432 EndExpr = ActOnBinOp(S, ColonLoc, tok::plus, EndRangeRef.
get(),
2437 diag::err_for_range_iter_deduction_failure)) {
2438 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2446 *
this, BeginRangeRef.
get(), EndRangeRef.
get(), RangeType, BeginVar,
2447 EndVar,
ColonLoc, CoawaitLoc, &CandidateSet, &BeginExpr, &EndExpr,
2450 if (Kind == BFRK_Build && RangeStatus == FRS_NoViableFunction &&
2451 BEFFailure == BEF_begin) {
2454 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Range)) {
2455 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
2456 QualType ArrayTy = PVD->getOriginalType();
2457 QualType PointerTy = PVD->getType();
2460 << RangeLoc << PVD << ArrayTy << PointerTy;
2461 Diag(PVD->getLocation(), diag::note_declared_at);
2471 LoopVarDecl, ColonLoc,
2479 if (RangeStatus == FRS_NoViableFunction) {
2480 Expr *Range = BEFFailure ? EndRangeRef.
get() : BeginRangeRef.
get();
2482 << RangeLoc << Range->
getType() << BEFFailure;
2486 if (RangeStatus != FRS_Success)
2491 "invalid range expression in for loop");
2498 ? diag::warn_for_range_begin_end_types_differ
2499 : diag::ext_for_range_begin_end_types_differ)
2500 << BeginType << EndType;
2501 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2502 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2506 ActOnDeclStmt(ConvertDeclToDeclGroup(BeginVar), ColonLoc, ColonLoc);
2508 ActOnDeclStmt(ConvertDeclToDeclGroup(EndVar), ColonLoc, ColonLoc);
2511 ExprResult BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2516 ExprResult EndRef = BuildDeclRefExpr(EndVar, EndType.getNonReferenceType(),
2522 NotEqExpr = ActOnBinOp(S, ColonLoc, tok::exclaimequal,
2523 BeginRef.
get(), EndRef.
get());
2525 NotEqExpr = CheckBooleanCondition(ColonLoc, NotEqExpr.
get());
2527 NotEqExpr = ActOnFinishFullExpr(NotEqExpr.
get());
2529 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2530 << RangeLoc << 0 << BeginRangeRef.
get()->getType();
2531 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2533 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2538 BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2543 IncrExpr = ActOnUnaryOp(S, ColonLoc, tok::plusplus, BeginRef.
get());
2544 if (!IncrExpr.isInvalid() && CoawaitLoc.
isValid())
2548 IncrExpr = ActOnCoawaitExpr(S, CoawaitLoc, IncrExpr.get());
2549 if (!IncrExpr.isInvalid())
2550 IncrExpr = ActOnFinishFullExpr(IncrExpr.get());
2551 if (IncrExpr.isInvalid()) {
2552 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2553 << RangeLoc << 2 << BeginRangeRef.
get()->getType() ;
2554 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2559 BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2564 ExprResult DerefExpr = ActOnUnaryOp(S, ColonLoc, tok::star, BeginRef.
get());
2566 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2567 << RangeLoc << 1 << BeginRangeRef.
get()->getType();
2568 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2574 if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) {
2575 AddInitializerToDecl(LoopVar, DerefExpr.
get(),
false);
2576 if (LoopVar->isInvalidDecl())
2577 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2583 if (Kind == BFRK_Check)
2587 RangeDS, cast_or_null<DeclStmt>(BeginDeclStmt.get()),
2588 cast_or_null<DeclStmt>(EndDeclStmt.
get()), NotEqExpr.
get(),
2589 IncrExpr.get(), LoopVarDS,
nullptr, ForLoc, CoawaitLoc,
2620 if (
auto Cleanups = dyn_cast<ExprWithCleanups>(InitExpr))
2621 if (!Cleanups->cleanupsHaveSideEffects())
2622 InitExpr = Cleanups->getSubExpr();
2635 while (!isa<CXXOperatorCallExpr>(E) && !isa<UnaryOperator>(E)) {
2639 const MemberExpr *ME = cast<MemberExpr>(Call->getCallee());
2648 bool ReturnsReference =
false;
2649 if (isa<UnaryOperator>(E)) {
2650 ReturnsReference =
true;
2654 QualType ReturnType = FD->getReturnType();
2658 if (ReturnsReference) {
2662 SemaRef.
Diag(VD->
getLocation(), diag::warn_for_range_const_reference_copy)
2663 << VD << VariableType << E->
getType();
2673 SemaRef.
Diag(VD->
getLocation(), diag::warn_for_range_variable_always_copy)
2674 << VD << RangeInitType;
2694 if (!CE->getConstructor()->isCopyConstructor())
2696 }
else if (
const CastExpr *CE = dyn_cast<CastExpr>(InitExpr)) {
2697 if (CE->getCastKind() != CK_LValueToRValue)
2712 << VD << VariableType << InitExpr->
getType();
2728 if (SemaRef.
Diags.
isIgnored(diag::warn_for_range_const_reference_copy,
2730 SemaRef.
Diags.
isIgnored(diag::warn_for_range_variable_always_copy,
2766 if (isa<ObjCForCollectionStmt>(S))
2767 return FinishObjCForCollectionStmt(S, B);
2773 diag::warn_empty_range_based_for_body);
2783 getCurFunction()->setHasBranchIntoScope();
2785 return new (Context)
GotoStmt(TheDecl, GotoLoc, LabelLoc);
2797 CheckSingleAssignmentConstraints(DestTy, ExprRes);
2801 if (DiagnoseAssignmentResult(ConvTy, StarLoc, DestTy, ETy, E, AA_Passing))
2810 getCurFunction()->setHasIndirectGoto();
2816 const Scope &DestScope) {
2819 S.
Diag(Loc, diag::warn_jump_out_of_seh_finally);
2828 return StmtError(
Diag(ContinueLoc, diag::err_continue_not_in_loop));
2840 return StmtError(
Diag(BreakLoc, diag::err_break_not_in_loop_or_switch));
2843 return StmtError(
Diag(BreakLoc, diag::err_omp_loop_cannot_use_stmt)
2847 return new (Context)
BreakStmt(BreakLoc);
2870 bool AllowParamOrMoveConstructible) {
2883 if (isCopyElisionCandidate(ReturnType, VD, AllowParamOrMoveConstructible))
2889 bool AllowParamOrMoveConstructible) {
2904 if (VD->
getKind() != Decl::Var &&
2905 !(AllowParamOrMoveConstructible && VD->
getKind() == Decl::ParmVar))
2915 if (VD->
hasAttr<BlocksAttr>())
return false;
2917 if (AllowParamOrMoveConstructible)
2955 if (AllowNRVO && !NRVOCandidate)
2956 NRVOCandidate = getCopyElisionCandidate(ResultType, Value,
true);
2958 if (AllowNRVO && NRVOCandidate) {
2962 Expr *InitExpr = &AsRvalue;
2965 Value->getLocStart(), Value->getLocStart());
2973 isa<CXXConstructorDecl>(
Step.Function.Function))))
2977 cast<CXXConstructorDecl>(
Step.Function.Function);
3000 Res = Seq.Perform(*
this, Entity, Kind, Value);
3032 bool HasDeducedReturnType =
3035 if (ExprEvalContexts.back().Context ==
3036 ExpressionEvaluationContext::DiscardedStatement &&
3039 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3042 RetValExp = ER.
get();
3044 return new (Context)
ReturnStmt(ReturnLoc, RetValExp,
nullptr);
3047 if (HasDeducedReturnType) {
3055 assert(AT &&
"lost auto type from lambda return type");
3056 if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
3066 if (RetValExp && !isa<InitListExpr>(RetValExp)) {
3067 ExprResult Result = DefaultFunctionArrayLvalueConversion(RetValExp);
3070 RetValExp = Result.
get();
3076 if (!CurContext->isDependentContext())
3085 Diag(ReturnLoc, diag::err_lambda_return_init_list)
3089 FnRetType = Context.
VoidTy;
3097 assert(!FnRetType.isNull());
3099 if (
BlockScopeInfo *CurBlock = dyn_cast<BlockScopeInfo>(CurCap)) {
3101 Diag(ReturnLoc, diag::err_noreturn_block_has_return_expr);
3105 dyn_cast<CapturedRegionScopeInfo>(CurCap)) {
3106 Diag(ReturnLoc, diag::err_return_in_captured_stmt) << CurRegion->getRegionName();
3109 assert(CurLambda &&
"unknown kind of captured scope");
3111 ->getNoReturnAttr()) {
3112 Diag(ReturnLoc, diag::err_noreturn_lambda_has_return_expr);
3120 const VarDecl *NRVOCandidate =
nullptr;
3121 if (FnRetType->isDependentType()) {
3124 }
else if (FnRetType->isVoidType()) {
3125 if (RetValExp && !isa<InitListExpr>(RetValExp) &&
3126 !(getLangOpts().CPlusPlus &&
3129 if (!getLangOpts().CPlusPlus &&
3131 Diag(ReturnLoc, diag::ext_return_has_void_expr) <<
"literal" << 2;
3133 Diag(ReturnLoc, diag::err_return_block_has_expr);
3134 RetValExp =
nullptr;
3137 }
else if (!RetValExp) {
3138 return StmtError(
Diag(ReturnLoc, diag::err_block_return_missing_expr));
3148 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
3151 NRVOCandidate !=
nullptr);
3152 ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate,
3153 FnRetType, RetValExp);
3158 RetValExp = Res.
get();
3159 CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc);
3161 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
3165 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3168 RetValExp = ER.
get();
3177 FunctionScopes.back()->Returns.push_back(Result);
3179 if (FunctionScopes.back()->FirstReturnLoc.isInvalid())
3180 FunctionScopes.back()->FirstReturnLoc = ReturnLoc;
3198 class LocalTypedefNameReferencer
3201 LocalTypedefNameReferencer(
Sema &S) : S(S) {}
3206 bool LocalTypedefNameReferencer::VisitRecordType(
const RecordType *RT) {
3208 if (!R || !R->isLocalClass() || !R->isLocalClass()->isExternallyVisible() ||
3209 R->isDependentType())
3211 for (
auto *TmpD : R->decls())
3212 if (
auto *
T = dyn_cast<TypedefNameDecl>(TmpD))
3213 if (
T->getAccess() !=
AS_private || R->hasFriends())
3238 TypeLoc OrigResultType = getReturnTypeLoc(FD);
3241 if (RetExpr && isa<InitListExpr>(RetExpr)) {
3245 getCurLambda() ? diag::err_lambda_return_init_list
3246 : diag::err_auto_fn_return_init_list)
3256 assert(AT->
isDeduced() &&
"should have deduced to dependent type");
3269 if (DAR != DAR_Succeeded)
3274 LocalTypedefNameReferencer Referencer(*
this);
3275 Referencer.TraverseType(RetExpr->
getType());
3283 Diag(ReturnLoc, diag::err_auto_fn_return_void_but_not_auto)
3288 Deduced = SubstAutoType(OrigResultType.
getType(), Context.
VoidTy);
3312 Diag(ReturnLoc, diag::err_typecheck_missing_return_type_incompatible)
3316 Diag(ReturnLoc, diag::err_auto_fn_different_deductions)
3333 StmtResult R = BuildReturnStmt(ReturnLoc, RetValExp);
3334 if (R.
isInvalid() || ExprEvalContexts.back().Context ==
3335 ExpressionEvaluationContext::DiscardedStatement)
3339 const_cast<VarDecl*>(cast<ReturnStmt>(R.
get())->getNRVOCandidate())) {
3352 if (RetValExp && DiagnoseUnexpandedParameterPack(RetValExp))
3355 if (isa<CapturingScopeInfo>(getCurFunction()))
3356 return ActOnCapScopeReturnStmt(ReturnLoc, RetValExp);
3360 const AttrVec *Attrs =
nullptr;
3361 bool isObjCMethod =
false;
3364 FnRetType = FD->getReturnType();
3366 Attrs = &FD->getAttrs();
3367 if (FD->isNoReturn())
3368 Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr)
3369 << FD->getDeclName();
3370 if (FD->isMain() && RetValExp)
3371 if (isa<CXXBoolLiteralExpr>(RetValExp))
3372 Diag(ReturnLoc, diag::warn_main_returns_bool_literal)
3375 FnRetType = MD->getReturnType();
3376 isObjCMethod =
true;
3378 Attrs = &MD->getAttrs();
3379 if (MD->hasRelatedResultType() && MD->getClassInterface()) {
3391 if (ExprEvalContexts.back().Context ==
3392 ExpressionEvaluationContext::DiscardedStatement &&
3395 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3398 RetValExp = ER.
get();
3400 return new (Context)
ReturnStmt(ReturnLoc, RetValExp,
nullptr);
3405 if (getLangOpts().CPlusPlus14) {
3408 if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
3422 if (isa<InitListExpr>(RetValExp)) {
3426 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3427 int FunctionKind = 0;
3428 if (isa<ObjCMethodDecl>(CurDecl))
3430 else if (isa<CXXConstructorDecl>(CurDecl))
3432 else if (isa<CXXDestructorDecl>(CurDecl))
3435 Diag(ReturnLoc, diag::err_return_init_list)
3440 RetValExp =
nullptr;
3443 unsigned D = diag::ext_return_has_expr;
3445 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3446 if (isa<CXXConstructorDecl>(CurDecl) ||
3447 isa<CXXDestructorDecl>(CurDecl))
3448 D = diag::err_ctor_dtor_returns_void;
3450 D = diag::ext_return_has_void_expr;
3454 Result = IgnoredValueConversions(Result.
get());
3457 RetValExp = Result.
get();
3458 RetValExp = ImpCastExprToType(RetValExp,
3459 Context.
VoidTy, CK_ToVoid).get();
3462 if (D == diag::err_ctor_dtor_returns_void) {
3463 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3465 << CurDecl->
getDeclName() << isa<CXXDestructorDecl>(CurDecl)
3469 else if (D != diag::ext_return_has_void_expr ||
3471 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3473 int FunctionKind = 0;
3474 if (isa<ObjCMethodDecl>(CurDecl))
3476 else if (isa<CXXConstructorDecl>(CurDecl))
3478 else if (isa<CXXDestructorDecl>(CurDecl))
3488 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3491 RetValExp = ER.
get();
3495 Result =
new (Context)
ReturnStmt(ReturnLoc, RetValExp,
nullptr);
3496 }
else if (!RetValExp && !HasDependentReturnType) {
3502 DiagID = diag::err_constexpr_return_missing_expr;
3504 }
else if (getLangOpts().
C99) {
3506 DiagID = diag::ext_return_missing_expr;
3509 DiagID = diag::warn_return_missing_expr;
3515 Diag(ReturnLoc, DiagID) << getCurMethodDecl()->getDeclName() << 1;
3517 Result =
new (Context)
ReturnStmt(ReturnLoc);
3519 assert(RetValExp || HasDependentReturnType);
3520 const VarDecl *NRVOCandidate =
nullptr;
3522 QualType RetType = RelatedRetType.
isNull() ? FnRetType : RelatedRetType;
3531 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
3536 NRVOCandidate !=
nullptr);
3537 ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate,
3538 RetType, RetValExp);
3549 if (!RelatedRetType.
isNull()) {
3552 Res = PerformCopyInitialization(Entity, ReturnLoc, RetValExp);
3560 CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc, isObjCMethod, Attrs,
3561 getCurFunctionDecl());
3565 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3568 RetValExp = ER.
get();
3570 Result =
new (Context)
ReturnStmt(ReturnLoc, RetValExp, NRVOCandidate);
3576 FunctionScopes.back()->Returns.push_back(Result);
3578 if (FunctionScopes.back()->FirstReturnLoc.isInvalid())
3579 FunctionScopes.back()->FirstReturnLoc = ReturnLoc;
3588 VarDecl *Var = cast_or_null<VarDecl>(Parm);
3603 if (!getLangOpts().ObjCExceptions)
3604 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@try";
3606 getCurFunction()->setHasBranchProtectedScope();
3607 unsigned NumCatchStmts = CatchStmts.size();
3609 NumCatchStmts, Finally);
3614 ExprResult Result = DefaultLvalueConversion(Throw);
3618 Result = ActOnFinishFullExpr(Result.
get());
3621 Throw = Result.
get();
3629 return StmtError(
Diag(AtLoc, diag::err_objc_throw_expects_object)
3640 if (!getLangOpts().ObjCExceptions)
3641 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@throw";
3646 Scope *AtCatchParent = CurScope;
3648 AtCatchParent = AtCatchParent->
getParent();
3650 return StmtError(
Diag(AtLoc, diag::err_rethrow_used_outside_catch));
3652 return BuildObjCAtThrowStmt(AtLoc, Throw);
3657 ExprResult result = DefaultLvalueConversion(operand);
3660 operand = result.
get();
3668 if (getLangOpts().CPlusPlus) {
3669 if (RequireCompleteType(atLoc, type,
3670 diag::err_incomplete_receiver_type))
3671 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
3674 ExprResult result = PerformContextuallyConvertToObjCPointer(operand);
3678 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
3681 operand = result.
get();
3683 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
3690 return ActOnFinishFullExpr(operand);
3697 getCurFunction()->setHasBranchProtectedScope();
3705 Stmt *HandlerBlock) {
3707 return new (Context)
3708 CXXCatchStmt(CatchLoc, cast_or_null<VarDecl>(ExDecl), HandlerBlock);
3713 getCurFunction()->setHasBranchProtectedScope();
3718 class CatchHandlerType {
3720 unsigned IsPointer : 1;
3725 enum Unique { ForDenseMap };
3726 CatchHandlerType(
QualType QT, Unique) : QT(QT), IsPointer(
false) {}
3732 CatchHandlerType(
QualType Q) : QT(Q), IsPointer(
false) {
3744 CatchHandlerType(
QualType QT,
bool IsPointer)
3745 : QT(QT), IsPointer(IsPointer) {}
3747 QualType underlying()
const {
return QT; }
3748 bool isPointer()
const {
return IsPointer; }
3750 friend bool operator==(
const CatchHandlerType &LHS,
3751 const CatchHandlerType &RHS) {
3753 if (LHS.IsPointer != RHS.IsPointer)
3756 return LHS.QT == RHS.QT;
3765 CatchHandlerType::ForDenseMap);
3770 CatchHandlerType::ForDenseMap);
3778 const CatchHandlerType &RHS) {
3785 class CatchTypePublicBases {
3787 const llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> &TypesToCheck;
3788 const bool CheckAgainstPointer;
3794 CatchTypePublicBases(
3796 const llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> &
T,
bool C)
3797 : Ctx(Ctx), TypesToCheck(T), CheckAgainstPointer(C),
3798 FoundHandler(
nullptr) {}
3800 CXXCatchStmt *getFoundHandler()
const {
return FoundHandler; }
3801 CanQualType getFoundHandlerType()
const {
return FoundHandlerType; }
3805 CatchHandlerType Check(S->
getType(), CheckAgainstPointer);
3806 const auto &M = TypesToCheck;
3807 auto I = M.find(Check);
3809 FoundHandler = I->second;
3824 if (!getLangOpts().CXXExceptions &&
3825 !getSourceManager().isInSystemHeader(TryLoc))
3826 Diag(TryLoc, diag::err_exceptions_disabled) <<
"try";
3829 if (getLangOpts().CUDA)
3830 CUDADiagIfDeviceCode(TryLoc, diag::err_cuda_device_exceptions)
3831 <<
"try" << CurrentCUDATarget();
3833 if (getCurScope() && getCurScope()->isOpenMPSimdDirectiveScope())
3834 Diag(TryLoc, diag::err_omp_simd_region_cannot_use_stmt) <<
"try";
3840 Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
3844 const unsigned NumHandlers = Handlers.size();
3845 assert(!Handlers.empty() &&
3846 "The parser shouldn't call this if there are no handlers.");
3848 llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> HandledTypes;
3849 for (
unsigned i = 0; i < NumHandlers; ++i) {
3856 if (i < NumHandlers - 1)
3865 CatchHandlerType HandlerCHT =
3871 QualType Underlying = HandlerCHT.underlying();
3873 if (!RD->hasDefinition())
3882 CatchTypePublicBases CTPB(Context, HandledTypes, HandlerCHT.isPointer());
3883 if (RD->lookupInBases(CTPB, Paths)) {
3885 if (!Paths.
isAmbiguous(CTPB.getFoundHandlerType())) {
3887 diag::warn_exception_caught_by_earlier_handler)
3890 diag::note_previous_exception_handler)
3898 auto R = HandledTypes.insert(std::make_pair(H->
getCaughtType(), H));
3902 diag::warn_exception_caught_by_earlier_handler)
3905 diag::note_previous_exception_handler)
3917 assert(TryBlock && Handler);
3923 if (!getLangOpts().Borland) {
3925 Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
3941 Diag(TryLoc, diag::err_seh_try_outside_functions);
3945 Diag(TryLoc, diag::err_seh_try_unsupported);
3954 assert(FilterExpr && Block);
3958 diag::err_filter_expression_integral)
3966 CurrentSEHFinally.push_back(CurScope);
3970 CurrentSEHFinally.pop_back();
3975 CurrentSEHFinally.pop_back();
3981 Scope *SEHTryParent = CurScope;
3983 SEHTryParent = SEHTryParent->
getParent();
3985 return StmtError(
Diag(Loc, diag::err_ms___leave_not_in___try));
3998 QualifierLoc, NameInfo,
3999 cast<CompoundStmt>(Nested));
4008 return BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
4010 GetNameFromUnqualifiedId(Name),
4016 unsigned NumParams) {
4033 assert(NumParams > 0 &&
"CapturedStmt requires context parameter");
4045 for (CaptureIter Cap = Candidates.begin(); Cap != Candidates.end(); ++Cap) {
4047 if (Cap->isThisCapture()) {
4050 CaptureInits.push_back(Cap->getInitExpr());
4052 }
else if (Cap->isVLATypeCapture()) {
4055 CaptureInits.push_back(
nullptr);
4060 Cap->isReferenceCapture()
4063 Cap->getVariable()));
4064 CaptureInits.push_back(Cap->getInitExpr());
4070 unsigned NumParams) {
4072 RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, NumParams);
4086 PushCapturedRegionScope(CurScope, CD, RD, Kind);
4089 PushDeclContext(CurScope, CD);
4093 PushExpressionEvaluationContext(
4094 ExpressionEvaluationContext::PotentiallyEvaluated);
4101 RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, Params.size());
4105 bool ContextIsFound =
false;
4106 unsigned ParamNum = 0;
4109 I != E; ++I, ++ParamNum) {
4110 if (I->second.isNull()) {
4111 assert(!ContextIsFound &&
4112 "null type has been found already for '__context' parameter");
4120 ContextIsFound =
true;
4130 assert(ContextIsFound &&
"no null type for '__context' parameter");
4131 if (!ContextIsFound) {
4142 PushCapturedRegionScope(CurScope, CD, RD, Kind);
4145 PushDeclContext(CurScope, CD);
4149 PushExpressionEvaluationContext(
4150 ExpressionEvaluationContext::PotentiallyEvaluated);
4154 DiscardCleanupsInEvaluationContext();
4155 PopExpressionEvaluationContext();
4162 ActOnFields(
nullptr, Record->
getLocation(), Record, Fields,
4166 PopFunctionScopeInfo();
4180 getASTContext(), S, static_cast<CapturedRegionKind>(RSI->
CapRegionKind),
4181 Captures, CaptureInits, CD, RD);
4186 DiscardCleanupsInEvaluationContext();
4187 PopExpressionEvaluationContext();
4190 PopFunctionScopeInfo();
A call to an overloaded operator written using operator syntax.
SourceLocation getStartLoc() const
Defines the clang::ASTContext interface.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
QualType withConst() const
Retrieves a version of this type with const applied.
void setImplicit(bool I=true)
An instance of this class is created to represent a function declaration or definition.
SourceLocation getLocStart() const LLVM_READONLY
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
void setOrigin(CXXRecordDecl *Rec)
bool isClosedNonFlag() const
Returns true if this enum is annotated with neither flag_enum nor enum_extensibility(open).
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
A (possibly-)qualified type.
bool isBlockPointerType() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
bool isLambdaConversionOperator(CXXConversionDecl *C)
bool isOverloadedOperator() const
isOverloadedOperator - Whether this function declaration represents an C++ overloaded operator...
Instantiation or recovery rebuild of a for-range statement.
static void AdjustAPSInt(llvm::APSInt &Val, unsigned BitWidth, bool IsSigned)
void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, unsigned NumParams)
StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, Decl *ExDecl, Stmt *HandlerBlock)
ActOnCXXCatchBlock - Takes an exception declaration and a handler block and creates a proper catch ha...
bool operator==(CanQual< T > x, CanQual< U > y)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
static unsigned getHashValue(const CatchHandlerType &Base)
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
Stmt - This represents one statement.
FunctionType - C99 6.7.5.3 - Function Declarators.
IfStmt - This represents an if/then/else.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt *> Elts, bool isStmtExpr)
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
StmtResult ActOnExprStmt(ExprResult Arg)
void setParam(unsigned i, ImplicitParamDecl *P)
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
ActionResult< Expr * > ExprResult
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
bool isRecordType() const
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Stmt *InitStmt, ConditionResult Cond)
SmallVector< Scope *, 2 > CurrentSEHFinally
Stack of active SEH __finally scopes. Can be empty.
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
bool isDecltypeAuto() const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
CanQualType getCanonicalFunctionResultType(QualType ResultType) const
Adjust the given function result type.
Represents a C++11 auto or C++14 decltype(auto) type.
Represents an attribute applied to a statement.
ParenExpr - This represents a parethesized expression, e.g.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
The base class of the type hierarchy.
Represents Objective-C's @throw statement.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represents a call to a C++ constructor.
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
virtual void completeDefinition()
completeDefinition - Notes that the definition of this type is now complete.
QualType withConst() const
const TargetInfo & getTargetInfo() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
A container of type source information.
Wrapper for void* pointer.
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr *> Attrs, Stmt *SubStmt)
StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope)
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
Represents a C++ constructor within a class.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Determining whether a for-range statement could be built.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Retains information about a function, method, or block that is currently being parsed.
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
This file provides some common utility functions for processing Lambda related AST Constructs...
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
enumerator_range enumerators() const
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization. ...
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
QualType getReturnType() const
DiagnosticsEngine & Diags
bool isEnumeralType() const
const AstTypeMatcher< PointerType > pointerType
Matches pointer types, but does not match Objective-C object pointer types.
const T * getAs() const
Member-template getAs<specific type>'.
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl)
SourceLocation getLocStart() const LLVM_READONLY
static bool ObjCEnumerationCollection(Expr *Collection)
SourceLocation getStarLoc() const
RAII class that determines when any errors have occurred between the time the instance was created an...
ObjCMethodDecl - Represents an instance or class method declaration.
bool isInvalidDecl() const
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, QualType Type, bool NRVO)
Create the initialization entity for the result of a function.
Defines the Objective-C statement AST node classes.
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement. ...
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input)
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
CapturedDecl * TheCapturedDecl
The CapturedDecl for this statement.
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.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
LabelStmt - Represents a label, which has a substatement.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
RecordDecl - Represents a struct/union/class.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
One of these records is kept for each identifier that is lexed.
bool isAtCatchScope() const
isAtCatchScope - Return true if this scope is @catch.
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Expr * getFalseExpr() const
void DiagnoseUnusedExprResult(const Stmt *S)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused...
Represents a class type in Objective C.
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
static StmtResult RebuildForRangeWithDereference(Sema &SemaRef, Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *LoopVarDecl, SourceLocation ColonLoc, Expr *Range, SourceLocation RangeLoc, SourceLocation RParenLoc)
Speculatively attempt to dereference an invalid range expression.
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
QualType getCaughtType() const
field_range fields() const
void setLocStart(SourceLocation L)
ExprResult CheckObjCForCollectionOperand(SourceLocation forLoc, Expr *collection)
void startDefinition()
Starts the definition of this tag declaration.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
bool isReferenceType() const
StmtResult BuildIfStmt(SourceLocation IfLoc, bool IsConstexpr, Stmt *InitStmt, ConditionResult Cond, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
VarDecl * getCopyElisionCandidate(QualType ReturnType, Expr *E, bool AllowParamOrMoveConstructible)
Determine whether the given expression is a candidate for copy elision in either a return statement o...
std::pair< VarDecl *, Expr * > get() const
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by...
SourceLocation FirstSEHTryLoc
First SEH '__try' statement in the current function.
void ActOnAbortSEHFinallyBlock()
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
StmtResult ActOnAttributedStmt(SourceLocation AttrLoc, ArrayRef< const Attr *> Attrs, Stmt *SubStmt)
Represents Objective-C's @catch statement.
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
IndirectGotoStmt - This represents an indirect goto.
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 CapturedStmt * Create(const ASTContext &Context, Stmt *S, CapturedRegionKind Kind, ArrayRef< Capture > Captures, ArrayRef< Expr *> CaptureInits, CapturedDecl *CD, RecordDecl *RD)
Represents a C++ unqualified-id that has been parsed.
An rvalue reference type, per C++11 [dcl.ref].
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Represents the results of name lookup.
This is a scope that corresponds to a switch statement.
void ActOnStartSEHFinallyBlock()
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
Parameter for captured context.
SourceLocation getRParenLoc() const
static void buildCapturedStmtCaptureList(SmallVectorImpl< CapturedStmt::Capture > &Captures, SmallVectorImpl< Expr *> &CaptureInits, ArrayRef< CapturingScopeInfo::Capture > Candidates)
An x-value expression is a reference to an object with independent storage but which can be "moved"...
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, 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...
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt *> Stmts, SourceLocation LB, SourceLocation RB)
StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope)
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
SmallVector< std::pair< llvm::APSInt, EnumConstantDecl * >, 64 > EnumValsTy
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Scope - A scope is a transient data structure that is used while parsing the program.
static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond, const Expr *Case)
SourceLocation getContinueLoc() const
bool isMacroBodyExpansion(SourceLocation Loc) const
Tests whether the given source location represents the expansion of a macro body. ...
Represents a C++ nested-name-specifier or a global scope specifier.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
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.
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
Represents binding an expression to a temporary.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
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'.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
static CatchHandlerType getTombstoneKey()
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block)
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
Perform initialization via a constructor.
Perform a user-defined conversion, either via a conversion function or via a constructor.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
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.
This represents the body of a CapturedStmt, and serves as its DeclContext.
Represents an ObjC class declaration.
Member name lookup, which finds the names of class/struct/union members.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
SourceLocation getTypeSpecStartLoc() const
StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc, BuildForRangeKind Kind)
BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, Scope *CurScope)
void setStmt(LabelStmt *T)
static SEHTryStmt * Create(const ASTContext &C, bool isCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
bool isSEHTrySupported() const
Whether the target supports SEH __try.
Contains information about the compound statement currently being parsed.
SourceLocation FirstCXXTryLoc
First C++ 'try' statement in the current function.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
unsigned getFlags() const
getFlags - Return the flags for this scope.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
StmtResult ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection, SourceLocation RParenLoc, BuildForRangeKind Kind)
ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
const internal::VariadicDynCastAllOfMatcher< Stmt, CaseStmt > caseStmt
Matches case statements inside switch statements.
ConditionalOperator - The ?: ternary operator.
Sema - This implements semantic analysis and AST building for C.
A little helper class used to produce diagnostics.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
Describes the capture of either a variable, or 'this', or variable-length array type.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
Retains information about a captured region.
bool inferObjCARCLifetime(ValueDecl *decl)
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
SourceLocation getLocEnd() const LLVM_READONLY
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp)
SourceLocation getLocation() const
void ActOnFinishOfCompoundStmt()
bool isClosed() const
Returns true if this enum is either annotated with enum_extensibility(closed) or isn't annotated with...
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Scope * getCurScope() const
Retrieve the parser's current scope.
SourceLocation getBeginLoc() const
Get the begin source location.
Allows QualTypes to be sorted and hence used in maps and sets.
Retains information about a block that is currently being parsed.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Type source information for an attributed type.
Expr - This represents one expression.
Allow any unmodeled side effect.
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
const FunctionProtoType * T
SourceLocation getDefaultLoc() const
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
const T * castAs() const
Member-template castAs<specific type>.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
VarDecl * getExceptionDecl() const
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
static void DiagnoseForRangeConstVariableCopies(Sema &SemaRef, const VarDecl *VD)
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
void setContextParam(unsigned i, ImplicitParamDecl *P)
bool isSEHTryScope() const
Determine whether this scope is a SEH '__try' block.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Defines the clang::Preprocessor interface.
bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD, bool AllowParamOrMoveConstructible)
ObjCLifetime getObjCLifetime() const
bool isFileContext() const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
Represents Objective-C's @synchronized statement.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
Defines the clang::TypeLoc interface and its subclasses.
static DeclContext * castToDeclContext(const CapturedDecl *D)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
bool isFunctionOrMethod() const
static CapturedDecl * Create(ASTContext &C, DeclContext *DC, unsigned NumParams)
static bool isEqual(const CatchHandlerType &LHS, const CatchHandlerType &RHS)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
An expression that sends a message to the given Objective-C object or class.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
void setLocation(SourceLocation L)
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
void setHasCXXTry(SourceLocation TryLoc)
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const Expr * getSubExpr() const
unsigned short CapRegionKind
The kind of captured region.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
llvm::iterator_range< semantics_iterator > semantics()
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool Contains(const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
DoStmt - This represents a 'do/while' stmt.
bool isConstQualified() const
Determine whether this type is const-qualified.
RecordDecl * getDecl() const
static CatchHandlerType getEmptyKey()
void ActOnStartOfCompoundStmt()
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
SelectorTable & Selectors
Assigning into this object requires the old value to be released and the new value to be retained...
This captures a statement into a function.
static bool EqEnumVals(const std::pair< llvm::APSInt, EnumConstantDecl *> &lhs, const std::pair< llvm::APSInt, EnumConstantDecl *> &rhs)
EqEnumVals - Comparison preficate for uniqing enumeration values.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
TypeLoc IgnoreParens() const
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
void setHasSEHTry(SourceLocation TryLoc)
bool isOpenMPLoopScope() const
Determine whether this scope is a loop having OpenMP loop directive attached.
DeduceAutoResult
Result type of DeduceAutoType.
Encodes a location in the source.
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Expr * getSubExpr() const
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...
CastKind getCastKind() const
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
const SwitchCase * getSwitchCaseList() const
StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, Scope *CurScope)
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
StmtResult ActOnForEachLValueExpr(Expr *E)
In an Objective C collection iteration statement: for (x in y) x can be an arbitrary l-value expressi...
Represents a call to a member function that may be written either with member call syntax (e...
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
IdentifierTable & getIdentifierTable()
LabelDecl - Represents the declaration of a label.
StmtResult ActOnCapturedRegionEnd(Stmt *S)
void setAllEnumCasesCovered()
Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a switch over an enum value then ...
bool DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD, SourceLocation ReturnLoc, Expr *&RetExpr, AutoType *AT)
Deduce the return type for a function from a returned expression, per C++1y [dcl.spec.auto]p6.
static QualType GetTypeBeforeIntegralPromotion(const Expr *&E)
GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of potentially integral-promoted expr...
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
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...
const ParmVarDecl * getParamDecl(unsigned i) const
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
bool isObjCObjectPointerType() const
SmallVector< Capture, 4 > Captures
Captures - The captures.
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
bool isMSAsmLabel() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Stmt * getCapturedStmt()
Retrieve the statement being captured.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
sema::CompoundScopeInfo & getCurCompoundScope() const
Requests that all candidates be shown.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond, Stmt *Body)
EnumDecl * getDecl() const
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static void DiagnoseForRangeReferenceVariableCopies(Sema &SemaRef, const VarDecl *VD, QualType RangeInitType)
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
LabelStmt * getStmt() const
void setCapturedRecord()
Mark the record as a record for captured variables in CapturedStmt construct.
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
NullStmt - This is the null statement ";": C99 6.8.3p3.
Dataflow Directional Tag Classes.
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
bool isValid() const
Return true if this is a valid SourceLocation object.
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
A single step in the initialization sequence.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
QualType getType() const
Get the type for which this source info wrapper provides information.
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
void ActOnCapturedRegionError()
void addNRVOCandidate(VarDecl *VD)
void setARCPseudoStrong(bool ps)
StmtResult ActOnExprStmtError()
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
const Expr * getInit() const
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
bool isSingleDecl() const
static void DiagnoseForRangeVariableCopies(Sema &SemaRef, const CXXForRangeStmt *ForStmt)
DiagnoseForRangeVariableCopies - Diagnose three cases and fixes for them.
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
SourceLocation getLocStart() const LLVM_READONLY
EnumDecl - Represents an enum.
const Decl * getSingleDecl() const
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i...
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
bool isSingleDecl() const
isSingleDecl - This method returns true if this DeclStmt refers to a single Decl. ...
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
const Stmt * getBody() const
Represents a __leave statement.
Represents a pointer to an Objective C object.
SwitchStmt - This represents a 'switch' stmt.
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
unsigned getIntWidth(QualType T) const
RecordDecl * TheRecordDecl
The captured record type.
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, Expr *LHSVal, SourceLocation DotDotDotLoc, Expr *RHSVal, SourceLocation ColonLoc)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Represents Objective-C's collection statement.
ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
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...
TypeSourceInfo * getTypeSourceInfo() const
void setUsesSEHTry(bool UST)
static bool CmpEnumVals(const std::pair< llvm::APSInt, EnumConstantDecl *> &lhs, const std::pair< llvm::APSInt, EnumConstantDecl *> &rhs)
CmpEnumVals - Comparison predicate for sorting enumeration values.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
ActionResult< Stmt * > StmtResult
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
DeduceAutoResult DeduceAutoType(TypeSourceInfo *AutoType, Expr *&Initializer, QualType &Result, Optional< unsigned > DependentDeductionDepth=None)
Represents Objective-C's @finally statement.
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.
void addDecl(Decl *D)
Add the declaration D into this context.
SourceLocation getExprLoc() const LLVM_READONLY
Represents a base class of a C++ class.
static bool DiagnoseUnusedComparison(Sema &S, const Expr *E)
Diagnose unused comparisons, both builtin and overloaded operators.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
DeclStmt * getRangeStmt()
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
GotoStmt - This represents a direct goto.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
static bool CmpCaseVals(const std::pair< llvm::APSInt, CaseStmt *> &lhs, const std::pair< llvm::APSInt, CaseStmt *> &rhs)
CmpCaseVals - Comparison predicate for sorting case values.
const SwitchCase * getNextSwitchCase() const
ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity, const VarDecl *NRVOCandidate, QualType ResultType, Expr *Value, bool AllowNRVO=true)
Perform the initialization of a potentially-movable value, which is the result of return value...
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static InitializedEntity InitializeRelatedResult(ObjCMethodDecl *MD, QualType Type)
Create the initialization entity for a related result.
Describes the sequence of initializations required to initialize a given object or reference with a s...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
TypedefNameDecl * getTypedefNameForAnonDecl() const
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp)
ActOnCapScopeReturnStmt - Utility routine to type-check return statements for capturing scopes...
Represents a C++ struct/union/class.
ContinueStmt - This represents a continue.
Expr * getTrueExpr() const
static bool FinishForRangeVarDecl(Sema &SemaRef, VarDecl *Decl, Expr *Init, SourceLocation Loc, int DiagID)
Finish building a variable declaration for a for-range statement.
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, Stmt *tryBlock, ArrayRef< Stmt *> handlers)
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
CXXCatchStmt - This represents a C++ catch block.
VarDecl * getLoopVariable()
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
WhileStmt - This represents a 'while' stmt.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
SourceLocation getBreakLoc() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
bool HasImplicitReturnType
Whether the target type of return statements in this context is deduced (e.g.
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
A reference to a declared variable, function, enum, etc.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool isPointerType() const
BreakStmt - This represents a break.
SourceManager & SourceMgr
CapturedRegionKind
The different kinds of captured statement.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
bool isLocalVarDecl() const
isLocalVarDecl - Returns true for local variable declarations other than parameters.
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
static bool hasDeducedReturnType(FunctionDecl *FD)
Determine whether the declared return type of the specified function contains 'auto'.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
A boolean literal, per ([C++ lex.bool] Boolean literals).
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
Represents a C array with a specified size that is not an integer-constant-expression.
DeclStmt * getBeginStmt()
Describes an entity that is being initialized.
const Expr * getCond() const
SourceLocation getLocStart() const LLVM_READONLY
void setType(QualType newType)
Wrapper for source info for pointers.
StmtResult ActOnIfStmt(SourceLocation IfLoc, bool IsConstexpr, Stmt *InitStmt, ConditionResult Cond, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
SourceLocation ColonLoc
Location of ':'.
Represents Objective-C's @autoreleasepool Statement.
static SEHExceptStmt * Create(const ASTContext &C, SourceLocation ExceptLoc, Expr *FilterExpr, Stmt *Block)
Represents the canonical version of C arrays with a specified constant size.
Declaration of a template function.
static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)
Attr - This represents one attribute.
SourceLocation getLocation() const
QualType getType() const
Return the type wrapped by this type source info.
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
static void CheckJumpOutOfSEHFinally(Sema &S, SourceLocation Loc, const Scope &DestScope)
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
const DeclStmt * getConditionVariableDeclStmt() const
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
QualType getType() const
Retrieves the type of the base class.