34 #include "llvm/ADT/ArrayRef.h"
35 #include "llvm/ADT/DenseMap.h"
36 #include "llvm/ADT/STLExtras.h"
37 #include "llvm/ADT/SmallPtrSet.h"
38 #include "llvm/ADT/SmallString.h"
39 #include "llvm/ADT/SmallVector.h"
41 using namespace clang;
63 DiscardCleanupsInEvaluationContext();
68 bool HasLeadingEmptyMacro) {
91 if (!decl || decl->isInvalidDecl())
97 Diag(decl->getLocation(), diag::err_non_variable_decl_in_for);
98 decl->setInvalidDecl();
109 if (getLangOpts().ObjCAutoRefCount) {
130 bool IsNotEqual, CanAssign, IsRelational;
133 if (!Op->isComparisonOp())
136 IsRelational = Op->isRelationalOp();
137 Loc = Op->getOperatorLoc();
138 IsNotEqual = Op->getOpcode() == BO_NE;
139 CanAssign = Op->getLHS()->IgnoreParenImpCasts()->isLValue();
141 switch (Op->getOperator()) {
145 case OO_ExclaimEqual:
146 IsRelational =
false;
150 case OO_GreaterEqual:
156 Loc = Op->getOperatorLoc();
157 IsNotEqual = Op->getOperator() == OO_ExclaimEqual;
158 CanAssign = Op->getArg(0)->IgnoreParenImpCasts()->isLValue();
169 S.
Diag(Loc, diag::warn_unused_comparison)
170 << (
unsigned)IsRelational << (
unsigned)IsNotEqual << E->getSourceRange();
174 if (!IsRelational && CanAssign) {
176 S.
Diag(Loc, diag::note_inequality_comparison_to_or_assign)
179 S.
Diag(Loc, diag::note_equality_comparison_to_assign)
187 if (
const LabelStmt *Label = dyn_cast_or_null<LabelStmt>(S))
188 return DiagnoseUnusedExprResult(Label->getSubStmt());
190 const Expr *
E = dyn_cast_or_null<Expr>(
S);
196 if (isUnevaluatedContext())
205 bool ShouldSuppress =
206 SourceMgr.isMacroBodyExpansion(ExprLoc) ||
207 SourceMgr.isInSystemMacro(ExprLoc);
209 const Expr *WarnExpr;
212 if (!E->isUnusedResultAWarning(WarnExpr, Loc, R1, R2,
Context))
225 if (isa<ParenExpr>(E->IgnoreImpCasts()) && Loc.
isMacroID()) {
227 if (findMacroSpelling(SpellLoc,
"UNREFERENCED_PARAMETER"))
234 unsigned DiagID = diag::warn_unused_expr;
236 E = Temps->getSubExpr();
238 E = TempExpr->getSubExpr();
244 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
245 if (E->getType()->isVoidType())
252 if (
const Decl *FD = CE->getCalleeDecl()) {
253 if (
const Attr *A = isa<FunctionDecl>(FD)
254 ? cast<FunctionDecl>(FD)->getUnusedResultAttr()
255 : FD->getAttr<WarnUnusedResultAttr>()) {
256 Diag(Loc, diag::warn_unused_result) << A << R1 << R2;
261 if (FD->hasAttr<PureAttr>()) {
262 Diag(Loc, diag::warn_unused_call) << R1 << R2 <<
"pure";
265 if (FD->hasAttr<ConstAttr>()) {
266 Diag(Loc, diag::warn_unused_call) << R1 << R2 <<
"const";
270 }
else if (ShouldSuppress)
274 if (getLangOpts().ObjCAutoRefCount && ME->isDelegateInitCall()) {
275 Diag(Loc, diag::err_arc_unused_init_message) << R1;
280 if (
const auto *A = MD->getAttr<WarnUnusedResultAttr>()) {
281 Diag(Loc, diag::warn_unused_result) << A << R1 << R2;
286 const Expr *Source = POE->getSyntacticForm();
287 if (isa<ObjCSubscriptRefExpr>(Source))
288 DiagID = diag::warn_unused_container_subscript_expr;
290 DiagID = diag::warn_unused_property_expr;
292 = dyn_cast<CXXFunctionalCastExpr>(E)) {
293 if (isa<CXXConstructExpr>(FC->getSubExpr()) ||
294 isa<CXXTemporaryObjectExpr>(FC->getSubExpr()))
298 else if (
const CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(E)) {
306 Diag(Loc, diag::warn_unused_voidptr)
312 if (E->isGLValue() && E->getType().isVolatileQualified()) {
313 Diag(Loc, diag::warn_unused_volatile) << R1 << R2;
317 DiagRuntimeBehavior(Loc,
nullptr, PDiag(DiagID) << R1 << R2);
329 return getCurFunction()->CompoundScopes.back();
334 const unsigned NumElts = Elts.size();
342 for (; i != NumElts && isa<DeclStmt>(Elts[i]); ++i)
346 for (; i != NumElts && !isa<DeclStmt>(Elts[i]); ++i)
350 Decl *D = *cast<DeclStmt>(Elts[i])->decl_begin();
351 Diag(D->getLocation(), diag::ext_mixed_decls_code);
355 for (
unsigned i = 0; i != NumElts; ++i) {
357 if (isStmtExpr && i == NumElts - 1)
360 DiagnoseUnusedExprResult(Elts[i]);
366 if (NumElts != 0 && !CurrentInstantiationScope &&
367 getCurCompoundScope().HasEmptyLoopBodies) {
368 for (
unsigned i = 0; i != NumElts - 1; ++i)
369 DiagnoseEmptyLoopBody(Elts[i], Elts[i + 1]);
379 assert(LHSVal &&
"missing expression in case statement");
381 if (getCurFunction()->SwitchStack.empty()) {
382 Diag(CaseLoc, diag::err_case_not_in_switch);
387 CorrectDelayedTyposInExpr(LHSVal, [
this](
class Expr *
E) {
389 return VerifyIntegerConstantExpression(E);
391 getCurFunction()->SwitchStack.back()->getCond()) {
392 QualType CondType = CondExpr->getType();
393 llvm::APSInt TempVal;
407 LHSVal = VerifyIntegerConstantExpression(LHSVal).get();
415 RHSVal = VerifyIntegerConstantExpression(RHSVal).get();
420 LHS = ActOnFinishFullExpr(LHSVal, LHSVal->
getExprLoc(),
false,
421 getLangOpts().CPlusPlus11);
425 auto RHS = RHSVal ? ActOnFinishFullExpr(RHSVal, RHSVal->
getExprLoc(),
false,
426 getLangOpts().CPlusPlus11)
433 getCurFunction()->SwitchStack.back()->addSwitchCase(CS);
439 DiagnoseUnusedExprResult(SubStmt);
448 DiagnoseUnusedExprResult(SubStmt);
450 if (getCurFunction()->SwitchStack.empty()) {
451 Diag(DefaultLoc, diag::err_default_not_in_switch);
456 getCurFunction()->SwitchStack.back()->addSwitchCase(DS);
465 Diag(IdentLoc, diag::err_redefinition_of_label) << TheDecl->
getDeclName();
466 Diag(TheDecl->getLocation(), diag::note_previous_definition);
478 TheDecl->setLocation(IdentLoc);
497 CommaVisitor(
Sema &SemaRef) : Inherited(SemaRef.
Context), SemaRef(SemaRef) {}
519 Expr *CondExpr = Cond.
get().second;
520 if (!Diags.isIgnored(diag::warn_comma_operator,
522 CommaVisitor(*this).Visit(CondExpr);
525 DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), thenStmt,
526 diag::warn_empty_if_body);
528 return BuildIfStmt(IfLoc, IsConstexpr, InitStmt, Cond, thenStmt, ElseLoc,
540 getCurFunction()->setHasBranchProtectedScope();
542 DiagnoseUnusedExprResult(thenStmt);
543 DiagnoseUnusedExprResult(elseStmt);
547 Cond.
get().second, thenStmt, ElseLoc, elseStmt);
551 struct CaseCompareFunctor {
552 bool operator()(
const std::pair<llvm::APSInt, CaseStmt*> &LHS,
553 const llvm::APSInt &RHS) {
554 return LHS.first < RHS;
556 bool operator()(
const std::pair<llvm::APSInt, CaseStmt*> &LHS,
557 const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
558 return LHS.first < RHS.first;
560 bool operator()(
const llvm::APSInt &LHS,
561 const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
562 return LHS < RHS.first;
569 static bool CmpCaseVals(
const std::pair<llvm::APSInt, CaseStmt*>& lhs,
570 const std::pair<llvm::APSInt, CaseStmt*>& rhs) {
571 if (lhs.first < rhs.first)
574 if (lhs.first == rhs.first &&
575 lhs.second->getCaseLoc().getRawEncoding()
576 < rhs.second->getCaseLoc().getRawEncoding())
583 static bool CmpEnumVals(
const std::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
584 const std::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
586 return lhs.first < rhs.first;
591 static bool EqEnumVals(
const std::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
592 const std::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
594 return lhs.first == rhs.first;
601 expr = cleanups->getSubExpr();
603 if (impcast->getCastKind() != CK_IntegralCast)
break;
604 expr = impcast->getSubExpr();
614 SwitchConvertDiagnoser(
Expr *Cond)
620 return S.
Diag(Loc, diag::err_typecheck_statement_requires_integer) << T;
625 return S.
Diag(Loc, diag::err_switch_incomplete_class_type)
626 << T << Cond->getSourceRange();
631 return S.
Diag(Loc, diag::err_switch_explicit_conversion) << T << ConvTy;
636 return S.
Diag(Conv->getLocation(), diag::note_switch_conversion)
642 return S.
Diag(Loc, diag::err_switch_multiple_conversions) << T;
647 return S.
Diag(Conv->getLocation(), diag::note_switch_conversion)
653 llvm_unreachable(
"conversion functions are permitted");
655 } SwitchDiagnoser(Cond);
658 PerformContextualImplicitConversion(SwitchLoc, Cond, SwitchDiagnoser);
663 return UsualUnaryConversions(CondResult.
get());
671 getCurFunction()->setHasBranchIntoScope();
675 getCurFunction()->SwitchStack.push_back(SS);
679 static void AdjustAPSInt(llvm::APSInt &Val,
unsigned BitWidth,
bool IsSigned) {
680 Val = Val.extOrTrunc(BitWidth);
681 Val.setIsSigned(IsSigned);
687 unsigned UnpromotedWidth,
bool UnpromotedSign) {
691 if (UnpromotedWidth < Val.getBitWidth()) {
692 llvm::APSInt ConvVal(Val);
694 AdjustAPSInt(ConvVal, Val.getBitWidth(), Val.isSigned());
699 S.
Diag(Loc, diag::warn_case_value_overflow) << Val.toString(10)
700 << ConvVal.toString(10);
710 const Expr *CaseExpr,
713 const llvm::APSInt &Val) {
716 if (
const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
725 if (ED->hasAttr<FlagEnumAttr>()) {
728 while (EI != EIEnd && EI->first < Val)
731 if (EI != EIEnd && EI->first == Val)
742 assert(SS == getCurFunction()->SwitchStack.back() &&
743 "switch stack missing push/pop!");
745 getCurFunction()->SwitchStack.pop_back();
748 SS->
setBody(BodyStmt, SwitchLoc);
755 Expr *CondExprBeforePromotion = CondExpr;
777 Diag(SwitchLoc, diag::warn_bool_switch_condition)
778 << CondExpr->getSourceRange();
784 bool HasDependentValue
793 unsigned CondWidthBeforePromotion
795 bool CondIsSignedBeforePromotion
805 typedef std::vector<std::pair<llvm::APSInt, CaseStmt*> > CaseRangesTy;
806 CaseRangesTy CaseRanges;
810 bool CaseListIsErroneous =
false;
816 if (TheDefaultStmt) {
817 Diag(DS->getDefaultLoc(), diag::err_multiple_default_labels_defined);
824 CaseListIsErroneous =
true;
833 if (Lo->isTypeDependent() || Lo->isValueDependent()) {
834 HasDependentValue =
true;
840 if (getLangOpts().CPlusPlus11) {
846 CaseListIsErroneous =
true;
857 Lo = DefaultLvalueConversion(Lo).get();
858 Lo = ImpCastExprToType(Lo, CondType, CK_IntegralCast).get();
864 CondWidthBeforePromotion, CondIsSignedBeforePromotion);
875 HasDependentValue =
true;
878 CaseRanges.push_back(std::make_pair(LoVal, CS));
880 CaseVals.push_back(std::make_pair(LoVal, CS));
884 if (!HasDependentValue) {
887 llvm::APSInt ConstantCondValue;
888 bool HasConstantCond =
false;
889 if (!HasDependentValue && !TheDefaultStmt) {
892 assert(!HasConstantCond ||
893 (ConstantCondValue.getBitWidth() == CondWidth &&
894 ConstantCondValue.isSigned() == CondIsSigned));
896 bool ShouldCheckConstantCond = HasConstantCond;
899 std::stable_sort(CaseVals.begin(), CaseVals.end(),
CmpCaseVals);
901 if (!CaseVals.empty()) {
902 for (
unsigned i = 0, e = CaseVals.size(); i != e; ++i) {
903 if (ShouldCheckConstantCond &&
904 CaseVals[i].first == ConstantCondValue)
905 ShouldCheckConstantCond =
false;
907 if (i != 0 && CaseVals[i].first == CaseVals[i-1].first) {
910 StringRef PrevString, CurrString;
913 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(PrevCase)) {
914 PrevString = DeclRef->getDecl()->getName();
916 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(CurrCase)) {
917 CurrString = DeclRef->getDecl()->getName();
920 CaseVals[i-1].first.toString(CaseValStr);
922 if (PrevString == CurrString)
923 Diag(CaseVals[i].second->getLHS()->getLocStart(),
924 diag::err_duplicate_case) <<
925 (PrevString.empty() ? StringRef(CaseValStr) : PrevString);
927 Diag(CaseVals[i].second->getLHS()->getLocStart(),
928 diag::err_duplicate_case_differing_expr) <<
929 (PrevString.empty() ? StringRef(CaseValStr) : PrevString) <<
930 (CurrString.empty() ? StringRef(CaseValStr) : CurrString) <<
933 Diag(CaseVals[i-1].second->getLHS()->getLocStart(),
934 diag::note_duplicate_case_prev);
937 CaseListIsErroneous =
true;
944 if (!CaseRanges.empty()) {
947 std::stable_sort(CaseRanges.begin(), CaseRanges.end());
950 std::vector<llvm::APSInt> HiVals;
951 for (
unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
952 llvm::APSInt &LoVal = CaseRanges[i].first;
953 CaseStmt *CR = CaseRanges[i].second;
964 CaseListIsErroneous =
true;
973 Hi = DefaultLvalueConversion(Hi).get();
974 Hi = ImpCastExprToType(Hi, CondType, CK_IntegralCast).get();
980 CondWidthBeforePromotion, CondIsSignedBeforePromotion);
989 Diag(CR->
getLHS()->getLocStart(), diag::warn_case_empty_range)
992 CaseRanges.erase(CaseRanges.begin()+i);
998 if (ShouldCheckConstantCond &&
999 LoVal <= ConstantCondValue &&
1000 ConstantCondValue <= HiVal)
1001 ShouldCheckConstantCond =
false;
1003 HiVals.push_back(HiVal);
1009 for (
unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
1010 llvm::APSInt &CRLo = CaseRanges[i].first;
1011 llvm::APSInt &CRHi = HiVals[i];
1012 CaseStmt *CR = CaseRanges[i].second;
1017 llvm::APSInt OverlapVal(32);
1022 CaseVals.end(), CRLo,
1023 CaseCompareFunctor());
1024 if (I != CaseVals.end() && I->first < CRHi) {
1025 OverlapVal = I->first;
1026 OverlapStmt = I->second;
1030 I = std::upper_bound(I, CaseVals.end(), CRHi, CaseCompareFunctor());
1031 if (I != CaseVals.begin() && (I-1)->first >= CRLo) {
1032 OverlapVal = (I-1)->first;
1033 OverlapStmt = (I-1)->second;
1038 if (i && CRLo <= HiVals[i-1]) {
1039 OverlapVal = HiVals[i-1];
1040 OverlapStmt = CaseRanges[i-1].second;
1045 Diag(CR->
getLHS()->getLocStart(), diag::err_duplicate_case)
1046 << OverlapVal.toString(10);
1048 diag::note_duplicate_case_prev);
1051 CaseListIsErroneous =
true;
1057 if (!CaseListIsErroneous && ShouldCheckConstantCond) {
1060 Diag(CondExpr->
getExprLoc(), diag::warn_missing_case_for_condition)
1061 << ConstantCondValue.toString(10)
1062 << CondExpr->getSourceRange();
1073 if (!CaseListIsErroneous && !HasConstantCond && ET) {
1080 llvm::APSInt Val = EDI->getInitVal();
1082 EnumVals.push_back(std::make_pair(Val, EDI));
1084 std::stable_sort(EnumVals.begin(), EnumVals.end(),
CmpEnumVals);
1085 auto EI = EnumVals.begin(), EIEnd =
1086 std::unique(EnumVals.begin(), EnumVals.end(),
EqEnumVals);
1089 for (CaseValsTy::const_iterator CI = CaseVals.begin();
1090 CI != CaseVals.end(); CI++) {
1091 Expr *CaseExpr = CI->second->getLHS();
1095 << CondTypeBeforePromotion;
1099 EI = EnumVals.begin();
1100 for (CaseRangesTy::const_iterator RI = CaseRanges.begin();
1101 RI != CaseRanges.end(); RI++) {
1102 Expr *CaseExpr = RI->second->getLHS();
1106 << CondTypeBeforePromotion;
1109 RI->second->getRHS()->EvaluateKnownConstInt(
Context);
1112 CaseExpr = RI->second->getRHS();
1116 << CondTypeBeforePromotion;
1120 auto CI = CaseVals.begin();
1121 auto RI = CaseRanges.begin();
1122 bool hasCasesNotInSwitch =
false;
1126 for (EI = EnumVals.begin(); EI != EIEnd; EI++){
1128 while (CI != CaseVals.end() && CI->first < EI->first)
1131 if (CI != CaseVals.end() && CI->first == EI->first)
1135 for (; RI != CaseRanges.end(); RI++) {
1137 RI->second->getRHS()->EvaluateKnownConstInt(
Context);
1139 if (EI->first <= Hi)
1143 if (RI == CaseRanges.end() || EI->first < RI->first) {
1144 hasCasesNotInSwitch =
true;
1145 UnhandledNames.push_back(EI->second->getDeclName());
1149 if (TheDefaultStmt && UnhandledNames.empty())
1153 if (!UnhandledNames.empty()) {
1155 TheDefaultStmt ? diag::warn_def_missing_case
1156 : diag::warn_missing_case)
1157 << (
int)UnhandledNames.size();
1161 DB << UnhandledNames[
I];
1164 if (!hasCasesNotInSwitch)
1170 DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), BodyStmt,
1171 diag::warn_empty_switch_body);
1175 if (CaseListIsErroneous)
1184 if (Diags.isIgnored(diag::warn_not_in_enum_assignment, SrcExpr->
getExprLoc()))
1198 const EnumDecl *ED = ET->getDecl();
1200 if (ED->hasAttr<FlagEnumAttr>()) {
1201 if (!IsValueInFlagEnum(ED, RhsVal,
true))
1207 EnumValsTy EnumVals;
1212 llvm::APSInt Val = EDI->getInitVal();
1214 EnumVals.push_back(std::make_pair(Val, EDI));
1216 if (EnumVals.empty())
1218 std::stable_sort(EnumVals.begin(), EnumVals.end(),
CmpEnumVals);
1220 std::unique(EnumVals.begin(), EnumVals.end(),
EqEnumVals);
1223 EnumValsTy::const_iterator EI = EnumVals.begin();
1224 while (EI != EIend && EI->first < RhsVal)
1226 if (EI == EIend || EI->first != RhsVal) {
1240 auto CondVal = Cond.
get();
1241 CheckBreakContinueBinding(CondVal.second);
1243 if (CondVal.second &&
1244 !Diags.isIgnored(diag::warn_comma_operator, CondVal.second->getExprLoc()))
1245 CommaVisitor(*this).Visit(CondVal.second);
1247 DiagnoseUnusedExprResult(Body);
1249 if (isa<NullStmt>(Body))
1250 getCurCompoundScope().setHasEmptyLoopBodies();
1260 assert(Cond &&
"ActOnDoStmt(): missing expression");
1262 CheckBreakContinueBinding(Cond);
1263 ExprResult CondResult = CheckBooleanCondition(DoLoc, Cond);
1266 Cond = CondResult.
get();
1268 CondResult = ActOnFinishFullExpr(Cond, DoLoc);
1271 Cond = CondResult.
get();
1273 DiagnoseUnusedExprResult(Body);
1275 return new (
Context)
DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen);
1283 llvm::SmallPtrSetImpl<VarDecl*> &Decls;
1289 DeclExtractor(
Sema &
S, llvm::SmallPtrSetImpl<VarDecl*> &Decls,
1296 bool isSimple() {
return Simple; }
1304 void VisitStmt(
Stmt *
S) {
1351 Ranges.push_back(E->getSourceRange());
1361 llvm::SmallPtrSetImpl<VarDecl*> &Decls;
1367 DeclMatcher(
Sema &
S, llvm::SmallPtrSetImpl<VarDecl*> &Decls,
1370 if (!Statement)
return;
1394 void CheckLValueToRValueCast(
Expr *E) {
1397 if (isa<DeclRefExpr>(E)) {
1402 Visit(CO->getCond());
1403 CheckLValueToRValueCast(CO->getTrueExpr());
1404 CheckLValueToRValueCast(CO->getFalseExpr());
1409 dyn_cast<BinaryConditionalOperator>(E)) {
1410 CheckLValueToRValueCast(BCO->getOpaqueValue()->getSourceExpr());
1411 CheckLValueToRValueCast(BCO->getFalseExpr());
1420 if (Decls.count(VD))
1428 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(S))
1430 Visit(OVE->getSourceExpr());
1436 bool FoundDeclInUse() {
return FoundDecl; }
1440 void CheckForLoopConditionalStatement(
Sema &S,
Expr *Second,
1443 if (!Second)
return;
1446 Second->getLocStart()))
1450 llvm::SmallPtrSet<VarDecl*, 8> Decls;
1452 DeclExtractor DE(S, Decls, Ranges);
1456 if (!DE.isSimple())
return;
1459 if (Decls.size() == 0)
return;
1465 if ((*I)->getType().isVolatileQualified() ||
1466 (*I)->hasGlobalStorage())
return;
1468 if (DeclMatcher(S, Decls, Second).FoundDeclInUse() ||
1469 DeclMatcher(S, Decls, Third).FoundDeclInUse() ||
1470 DeclMatcher(S, Decls, Body).FoundDeclInUse())
1474 if (Decls.size() > 4)
1477 PDiag << Decls.size();
1481 PDiag << (*I)->getDeclName();
1492 PDiag << Second->getSourceRange();
1494 S.
Diag(Ranges.begin()->getBegin(), PDiag);
1499 bool ProcessIterationStmt(
Sema &S,
Stmt* Statement,
bool &Increment,
1501 if (
auto Cleanups = dyn_cast<ExprWithCleanups>(Statement))
1502 if (!Cleanups->cleanupsHaveSideEffects())
1503 Statement = Cleanups->getSubExpr();
1505 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(Statement)) {
1506 switch (UO->getOpcode()) {
1507 default:
return false;
1525 default:
return false;
1546 BreakContinueFinder(
Sema &S,
Stmt* Body) :
1561 bool ContinueFound() {
return ContinueLoc.
isValid(); }
1562 bool BreakFound() {
return BreakLoc.isValid(); }
1573 void CheckForRedundantIteration(
Sema &S,
Expr *Third,
Stmt *Body) {
1575 if (!Body || !Third)
return;
1578 Third->getLocStart()))
1585 if (!LastStmt)
return;
1587 bool LoopIncrement, LastIncrement;
1590 if (!ProcessIterationStmt(S, Third, LoopIncrement, LoopDRE))
return;
1591 if (!ProcessIterationStmt(S, LastStmt, LastIncrement, LastDRE))
return;
1595 if (LoopIncrement != LastIncrement ||
1598 if (BreakContinueFinder(S, Body).ContinueFound())
return;
1601 << LastDRE->
getDecl() << LastIncrement;
1609 void Sema::CheckBreakContinueBinding(
Expr *E) {
1612 BreakContinueFinder BCFinder(*
this, E);
1614 if (BCFinder.BreakFound() && BreakParent) {
1616 Diag(BCFinder.GetBreakLoc(), diag::warn_break_binds_to_switch);
1618 Diag(BCFinder.GetBreakLoc(), diag::warn_loop_ctrl_binds_to_inner)
1621 }
else if (BCFinder.ContinueFound() && CurScope->getContinueParent()) {
1622 Diag(BCFinder.GetContinueLoc(), diag::warn_loop_ctrl_binds_to_inner)
1634 if (!getLangOpts().CPlusPlus) {
1635 if (
DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
1639 for (
auto *DI : DS->decls()) {
1644 Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
1645 DI->setInvalidDecl();
1651 CheckBreakContinueBinding(Second.
get().second);
1652 CheckBreakContinueBinding(third.
get());
1654 if (!Second.
get().first)
1655 CheckForLoopConditionalStatement(*
this, Second.
get().second, third.
get(),
1657 CheckForRedundantIteration(*
this, third.
get(), Body);
1659 if (Second.
get().second &&
1660 !Diags.isIgnored(diag::warn_comma_operator,
1661 Second.
get().second->getExprLoc()))
1662 CommaVisitor(*this).Visit(Second.
get().second);
1666 DiagnoseUnusedExprResult(First);
1667 DiagnoseUnusedExprResult(Third);
1668 DiagnoseUnusedExprResult(Body);
1670 if (isa<NullStmt>(Body))
1671 getCurCompoundScope().setHasEmptyLoopBodies();
1675 Body, ForLoc, LParenLoc, RParenLoc);
1689 ExprResult FullExpr = ActOnFinishFullExpr(E);
1700 ExprResult result = CorrectDelayedTyposInExpr(collection);
1703 collection = result.
get();
1709 result = DefaultFunctionArrayLvalueConversion(collection);
1712 collection = result.
get();
1719 return Diag(forLoc, diag::err_collection_expr_type)
1720 << collection->
getType() << collection->getSourceRange();
1730 (getLangOpts().ObjCAutoRefCount
1731 ? RequireCompleteType(forLoc,
QualType(objectType, 0),
1732 diag::err_arc_collection_forward, collection)
1733 : !isCompleteType(forLoc,
QualType(objectType, 0)))) {
1736 }
else if (iface || !objectType->
qual_empty()) {
1754 method = LookupMethodInQualifiedType(selector, pointerType,
1759 Diag(forLoc, diag::warn_collection_expr_type)
1760 << collection->
getType() << selector << collection->getSourceRange();
1776 CheckObjCForCollectionOperand(ForLoc, collection);
1780 if (
DeclStmt *DS = dyn_cast<DeclStmt>(First)) {
1781 if (!DS->isSingleDecl())
1783 diag::err_toomany_element_decls));
1786 if (!D || D->isInvalidDecl())
1795 diag::err_non_local_variable_decl_in_for));
1801 Expr *DeducedInit = &OpaqueId;
1804 DiagnoseAutoDeductionFailure(D, DeducedInit);
1805 if (FirstType.
isNull()) {
1806 D->setInvalidDecl();
1812 if (ActiveTemplateInstantiations.empty()) {
1815 Diag(Loc, diag::warn_auto_var_is_id)
1821 Expr *FirstE = cast<Expr>(First);
1824 diag::err_selector_element_not_lvalue)
1825 << First->getSourceRange());
1827 FirstType =
static_cast<Expr*
>(First)->getType();
1829 Diag(ForLoc, diag::err_selector_element_const_type)
1830 << FirstType << First->getSourceRange();
1835 return StmtError(
Diag(ForLoc, diag::err_selector_element_type)
1836 << FirstType << First->getSourceRange());
1842 CollectionExprResult = ActOnFinishFullExpr(CollectionExprResult.
get());
1847 nullptr, ForLoc, RParenLoc);
1857 Decl->setInvalidDecl();
1871 Decl->setInvalidDecl();
1881 Decl->setInvalidDecl();
1902 void NoteForRangeBeginEndFunction(
Sema &SemaRef,
Expr *E,
1912 std::string Description;
1913 bool IsTemplate =
false;
1920 SemaRef.
Diag(Loc, diag::note_for_range_begin_end)
1921 << BEF << IsTemplate << Description << E->
getType();
1932 Decl->setImplicit();
1970 return ActOnObjCForCollectionStmt(ForLoc, First, Range, RParenLoc);
1973 assert(DS &&
"first part of for range not a decl stmt");
1981 if (LoopVar->isInvalidDecl() || !Range ||
1982 DiagnoseUnexpandedParameterPack(Range, UPPC_Expression)) {
1983 LoopVar->setInvalidDecl();
1989 ExprResult Coawait = ActOnCoawaitExpr(S, CoawaitLoc, Range);
1991 Range = Coawait.
get();
1996 VarDecl *RangeVar = BuildForRangeVarDecl(*
this, RangeLoc,
2000 diag::err_for_range_deduction_failure)) {
2001 LoopVar->setInvalidDecl();
2009 StmtResult RangeDecl = ActOnDeclStmt(RangeGroup, RangeLoc, RangeLoc);
2011 LoopVar->setInvalidDecl();
2015 return BuildCXXForRangeStmt(ForLoc, CoawaitLoc, ColonLoc, RangeDecl.
get(),
2018 DS, RParenLoc,
Kind);
2058 if (BeginMemberLookup.empty() != EndMemberLookup.
empty()) {
2060 *BEF = BeginMemberLookup.empty() ? BEF_end : BEF_begin;
2062 SemaRef.
Diag(RangeLoc, diag::err_for_range_member_begin_end_mismatch)
2063 << RangeLoc << BeginRange->
getType() << *BEF;
2077 BeginMemberLookup, CandidateSet,
2078 BeginRange, BeginExpr);
2082 SemaRef.
Diag(BeginRange->getLocStart(), diag::note_in_for_range)
2083 << ColonLoc << BEF_begin << BeginRange->
getType();
2087 diag::err_for_range_iter_deduction_failure)) {
2088 NoteForRangeBeginEndFunction(SemaRef, BeginExpr->
get(), *BEF);
2095 EndMemberLookup, CandidateSet,
2099 SemaRef.
Diag(EndRange->getLocStart(), diag::note_in_for_range)
2100 << ColonLoc << BEF_end << EndRange->
getType();
2104 diag::err_for_range_iter_deduction_failure)) {
2105 NoteForRangeBeginEndFunction(SemaRef, EndExpr->
get(), *BEF);
2128 AdjustedRange = SemaRef.
BuildUnaryOp(S, RangeLoc, UO_Deref, Range);
2133 S, ForLoc, CoawaitLoc, LoopVarDecl, ColonLoc, AdjustedRange.
get(),
2142 SemaRef.
Diag(RangeLoc, diag::err_for_range_dereference)
2145 ColonLoc, AdjustedRange.
get(), RParenLoc,
2151 struct InvalidateOnErrorScope {
2152 InvalidateOnErrorScope(
Sema &SemaRef,
Decl *D,
bool Enabled)
2153 : Trap(SemaRef.Diags), D(D), Enabled(Enabled) {}
2154 ~InvalidateOnErrorScope() {
2155 if (Enabled && Trap.hasErrorOccurred())
2156 D->setInvalidDecl();
2181 Scope *S = getCurScope();
2183 DeclStmt *RangeDS = cast<DeclStmt>(RangeDecl);
2185 QualType RangeVarType = RangeVar->getType();
2187 DeclStmt *LoopVarDS = cast<DeclStmt>(LoopVarDecl);
2192 InvalidateOnErrorScope Invalidate(*
this, LoopVar,
2193 LoopVar->getType()->isUndeducedType());
2199 if (RangeVarType->isDependentType()) {
2205 if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check)
2207 }
else if (!BeginDeclStmt.get()) {
2212 ExprResult BeginRangeRef = BuildDeclRefExpr(RangeVar, RangeVarNonRefType,
2217 ExprResult EndRangeRef = BuildDeclRefExpr(RangeVar, RangeVarNonRefType,
2223 Expr *Range = RangeVar->getInit();
2228 if (RequireCompleteType(RangeLoc, RangeType,
2229 diag::err_for_range_incomplete_type))
2233 VarDecl *BeginVar = BuildForRangeVarDecl(*
this, ColonLoc, AutoType,
2235 VarDecl *EndVar = BuildForRangeVarDecl(*
this, ColonLoc, AutoType,
2247 BeginExpr = BeginRangeRef;
2249 diag::err_for_range_iter_deduction_failure)) {
2250 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2260 dyn_cast<VariableArrayType>(UnqAT))
2261 BoundExpr = VAT->getSizeExpr();
2265 llvm_unreachable(
"Unexpected array type in for-range");
2269 EndExpr = ActOnBinOp(S, ColonLoc, tok::plus, EndRangeRef.
get(),
2274 diag::err_for_range_iter_deduction_failure)) {
2275 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2284 EndRangeRef.
get(), RangeType,
2285 BeginVar, EndVar,
ColonLoc, &CandidateSet,
2286 &BeginExpr, &EndExpr, &BEFFailure);
2288 if (Kind == BFRK_Build && RangeStatus == FRS_NoViableFunction &&
2289 BEFFailure == BEF_begin) {
2292 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Range)) {
2294 QualType ArrayTy = PVD->getOriginalType();
2295 QualType PointerTy = PVD->getType();
2297 Diag(Range->getLocStart(), diag::err_range_on_array_parameter)
2298 << RangeLoc << PVD << ArrayTy << PointerTy;
2299 Diag(PVD->getLocation(), diag::note_declared_at);
2309 LoopVarDecl, ColonLoc,
2317 if (RangeStatus == FRS_NoViableFunction) {
2318 Expr *Range = BEFFailure ? EndRangeRef.
get() : BeginRangeRef.
get();
2319 Diag(Range->getLocStart(), diag::err_for_range_invalid)
2320 << RangeLoc << Range->
getType() << BEFFailure;
2324 if (RangeStatus != FRS_Success)
2329 "invalid range expression in for loop");
2336 ? diag::warn_for_range_begin_end_types_differ
2337 : diag::ext_for_range_begin_end_types_differ)
2338 << BeginType << EndType;
2339 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2340 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2344 ActOnDeclStmt(ConvertDeclToDeclGroup(BeginVar), ColonLoc, ColonLoc);
2346 ActOnDeclStmt(ConvertDeclToDeclGroup(EndVar), ColonLoc, ColonLoc);
2349 ExprResult BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2354 ExprResult EndRef = BuildDeclRefExpr(EndVar, EndType.getNonReferenceType(),
2360 NotEqExpr = ActOnBinOp(S, ColonLoc, tok::exclaimequal,
2361 BeginRef.
get(), EndRef.
get());
2363 NotEqExpr = CheckBooleanCondition(ColonLoc, NotEqExpr.
get());
2365 NotEqExpr = ActOnFinishFullExpr(NotEqExpr.
get());
2367 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2368 << RangeLoc << 0 << BeginRangeRef.
get()->
getType();
2369 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2371 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2376 BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2381 IncrExpr = ActOnUnaryOp(S, ColonLoc, tok::plusplus, BeginRef.
get());
2382 if (!IncrExpr.isInvalid() && CoawaitLoc.
isValid())
2383 IncrExpr = ActOnCoawaitExpr(S, CoawaitLoc, IncrExpr.get());
2384 if (!IncrExpr.isInvalid())
2385 IncrExpr = ActOnFinishFullExpr(IncrExpr.get());
2386 if (IncrExpr.isInvalid()) {
2387 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2388 << RangeLoc << 2 << BeginRangeRef.
get()->
getType() ;
2389 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2394 BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2399 ExprResult DerefExpr = ActOnUnaryOp(S, ColonLoc, tok::star, BeginRef.
get());
2401 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2402 << RangeLoc << 1 << BeginRangeRef.
get()->
getType();
2403 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2409 if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) {
2410 AddInitializerToDecl(LoopVar, DerefExpr.
get(),
false,
2412 if (LoopVar->isInvalidDecl())
2413 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2419 if (Kind == BFRK_Check)
2423 RangeDS, cast_or_null<DeclStmt>(BeginDeclStmt.get()),
2424 cast_or_null<DeclStmt>(EndDeclStmt.
get()), NotEqExpr.
get(),
2425 IncrExpr.get(), LoopVarDS,
nullptr, ForLoc, CoawaitLoc,
2456 if (
auto Cleanups = dyn_cast<ExprWithCleanups>(InitExpr))
2457 if (!Cleanups->cleanupsHaveSideEffects())
2458 InitExpr = Cleanups->getSubExpr();
2471 while (!isa<CXXOperatorCallExpr>(E) && !isa<UnaryOperator>(E)) {
2475 const MemberExpr *ME = cast<MemberExpr>(Call->getCallee());
2484 bool ReturnsReference =
false;
2485 if (isa<UnaryOperator>(E)) {
2486 ReturnsReference =
true;
2490 QualType ReturnType = FD->getReturnType();
2494 if (ReturnsReference) {
2498 SemaRef.
Diag(VD->getLocation(), diag::warn_for_range_const_reference_copy)
2499 << VD << VariableType << E->
getType();
2509 SemaRef.
Diag(VD->getLocation(), diag::warn_for_range_variable_always_copy)
2510 << VD << RangeInitType;
2530 if (!CE->getConstructor()->isCopyConstructor())
2532 }
else if (
const CastExpr *CE = dyn_cast<CastExpr>(InitExpr)) {
2533 if (CE->getCastKind() != CK_LValueToRValue)
2547 SemaRef.
Diag(VD->getLocation(), diag::warn_for_range_copy)
2548 << VD << VariableType << InitExpr->
getType();
2564 if (SemaRef.
Diags.
isIgnored(diag::warn_for_range_const_reference_copy,
2566 SemaRef.
Diags.
isIgnored(diag::warn_for_range_variable_always_copy,
2602 if (isa<ObjCForCollectionStmt>(S))
2603 return FinishObjCForCollectionStmt(S, B);
2609 diag::warn_empty_range_based_for_body);
2619 getCurFunction()->setHasBranchIntoScope();
2633 CheckSingleAssignmentConstraints(DestTy, ExprRes);
2637 if (DiagnoseAssignmentResult(ConvTy, StarLoc, DestTy, ETy, E, AA_Passing))
2646 getCurFunction()->setHasIndirectGoto();
2652 const Scope &DestScope) {
2655 S.
Diag(Loc, diag::warn_jump_out_of_seh_finally);
2664 return StmtError(
Diag(ContinueLoc, diag::err_continue_not_in_loop));
2676 return StmtError(
Diag(BreakLoc, diag::err_break_not_in_loop_or_switch));
2679 return StmtError(
Diag(BreakLoc, diag::err_omp_loop_cannot_use_stmt)
2706 bool AllowParamOrMoveConstructible) {
2719 if (isCopyElisionCandidate(ReturnType, VD, AllowParamOrMoveConstructible))
2725 bool AllowParamOrMoveConstructible) {
2740 if (VD->getKind() != Decl::Var &&
2741 !(AllowParamOrMoveConstructible && VD->getKind() == Decl::ParmVar))
2748 if (AllowParamOrMoveConstructible)
2755 if (VD->hasAttr<BlocksAttr>())
return false;
2789 if (AllowNRVO && !NRVOCandidate)
2790 NRVOCandidate = getCopyElisionCandidate(ResultType, Value,
true);
2792 if (AllowNRVO && NRVOCandidate) {
2796 Expr *InitExpr = &AsRvalue;
2799 Value->getLocStart(), Value->getLocStart());
2807 isa<CXXConstructorDecl>(
Step.Function.Function))))
2811 cast<CXXConstructorDecl>(
Step.Function.Function);
2834 Res = Seq.Perform(*
this, Entity, Kind, Value);
2866 bool HasDeducedReturnType =
2869 if (ExprEvalContexts.back().Context == DiscardedStatement &&
2872 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
2875 RetValExp = ER.
get();
2880 if (HasDeducedReturnType) {
2888 assert(AT &&
"lost auto type from lambda return type");
2889 if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
2890 FD->setInvalidDecl();
2899 if (RetValExp && !isa<InitListExpr>(RetValExp)) {
2903 RetValExp = Result.
get();
2909 if (!CurContext->isDependentContext())
2918 Diag(ReturnLoc, diag::err_lambda_return_init_list)
2919 << RetValExp->getSourceRange();
2930 assert(!FnRetType.isNull());
2932 if (
BlockScopeInfo *CurBlock = dyn_cast<BlockScopeInfo>(CurCap)) {
2934 Diag(ReturnLoc, diag::err_noreturn_block_has_return_expr);
2938 dyn_cast<CapturedRegionScopeInfo>(CurCap)) {
2939 Diag(ReturnLoc, diag::err_return_in_captured_stmt) << CurRegion->getRegionName();
2942 assert(CurLambda &&
"unknown kind of captured scope");
2944 ->getNoReturnAttr()) {
2945 Diag(ReturnLoc, diag::err_noreturn_lambda_has_return_expr);
2953 const VarDecl *NRVOCandidate =
nullptr;
2954 if (FnRetType->isDependentType()) {
2957 }
else if (FnRetType->isVoidType()) {
2958 if (RetValExp && !isa<InitListExpr>(RetValExp) &&
2959 !(getLangOpts().CPlusPlus &&
2962 if (!getLangOpts().CPlusPlus &&
2964 Diag(ReturnLoc, diag::ext_return_has_void_expr) <<
"literal" << 2;
2966 Diag(ReturnLoc, diag::err_return_block_has_expr);
2967 RetValExp =
nullptr;
2970 }
else if (!RetValExp) {
2971 return StmtError(
Diag(ReturnLoc, diag::err_block_return_missing_expr));
2981 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
2984 NRVOCandidate !=
nullptr);
2985 ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate,
2986 FnRetType, RetValExp);
2991 RetValExp = Res.
get();
2992 CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc);
2994 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
2998 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3001 RetValExp = ER.
get();
3010 FunctionScopes.back()->Returns.push_back(Result);
3012 if (FunctionScopes.back()->FirstReturnLoc.isInvalid())
3013 FunctionScopes.back()->FirstReturnLoc = ReturnLoc;
3031 class LocalTypedefNameReferencer
3034 LocalTypedefNameReferencer(
Sema &S) : S(S) {}
3039 bool LocalTypedefNameReferencer::VisitRecordType(
const RecordType *RT) {
3041 if (!R || !R->isLocalClass() || !R->isLocalClass()->isExternallyVisible() ||
3042 R->isDependentType())
3044 for (
auto *TmpD : R->decls())
3045 if (
auto *T = dyn_cast<TypedefNameDecl>(TmpD))
3046 if (T->getAccess() !=
AS_private || R->hasFriends())
3065 TypeLoc OrigResultType = getReturnTypeLoc(FD);
3068 if (RetExpr && isa<InitListExpr>(RetExpr)) {
3072 getCurLambda() ? diag::err_lambda_return_init_list
3073 : diag::err_auto_fn_return_init_list)
3074 << RetExpr->getSourceRange();
3083 assert(AT->
isDeduced() &&
"should have deduced to dependent type");
3092 if (DAR == DAR_Failed && !FD->isInvalidDecl())
3096 if (DAR != DAR_Succeeded)
3101 LocalTypedefNameReferencer Referencer(*
this);
3102 Referencer.TraverseType(RetExpr->
getType());
3110 Diag(ReturnLoc, diag::err_auto_fn_return_void_but_not_auto)
3125 if (!DeducedT.
isNull() && !FD->isInvalidDecl()) {
3139 Diag(ReturnLoc, diag::err_typecheck_missing_return_type_incompatible)
3143 Diag(ReturnLoc, diag::err_auto_fn_different_deductions)
3149 }
else if (!FD->isInvalidDecl()) {
3160 StmtResult R = BuildReturnStmt(ReturnLoc, RetValExp);
3161 if (R.
isInvalid() || ExprEvalContexts.back().Context == DiscardedStatement)
3165 const_cast<VarDecl*>(cast<ReturnStmt>(R.
get())->getNRVOCandidate())) {
3178 if (RetValExp && DiagnoseUnexpandedParameterPack(RetValExp))
3181 if (isa<CapturingScopeInfo>(getCurFunction()))
3182 return ActOnCapScopeReturnStmt(ReturnLoc, RetValExp);
3186 const AttrVec *Attrs =
nullptr;
3187 bool isObjCMethod =
false;
3192 Attrs = &FD->getAttrs();
3194 Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr)
3197 FnRetType = MD->getReturnType();
3198 isObjCMethod =
true;
3200 Attrs = &MD->getAttrs();
3201 if (MD->hasRelatedResultType() && MD->getClassInterface()) {
3213 if (ExprEvalContexts.back().Context == DiscardedStatement &&
3216 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3219 RetValExp = ER.
get();
3226 if (getLangOpts().CPlusPlus14) {
3229 if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
3230 FD->setInvalidDecl();
3243 if (isa<InitListExpr>(RetValExp)) {
3247 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3248 int FunctionKind = 0;
3249 if (isa<ObjCMethodDecl>(CurDecl))
3251 else if (isa<CXXConstructorDecl>(CurDecl))
3253 else if (isa<CXXDestructorDecl>(CurDecl))
3256 Diag(ReturnLoc, diag::err_return_init_list)
3258 << RetValExp->getSourceRange();
3261 RetValExp =
nullptr;
3264 unsigned D = diag::ext_return_has_expr;
3266 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3267 if (isa<CXXConstructorDecl>(CurDecl) ||
3268 isa<CXXDestructorDecl>(CurDecl))
3269 D = diag::err_ctor_dtor_returns_void;
3271 D = diag::ext_return_has_void_expr;
3275 Result = IgnoredValueConversions(Result.
get());
3278 RetValExp = Result.
get();
3279 RetValExp = ImpCastExprToType(RetValExp,
3283 if (D == diag::err_ctor_dtor_returns_void) {
3284 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3286 << CurDecl->
getDeclName() << isa<CXXDestructorDecl>(CurDecl)
3287 << RetValExp->getSourceRange();
3290 else if (D != diag::ext_return_has_void_expr ||
3292 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3294 int FunctionKind = 0;
3295 if (isa<ObjCMethodDecl>(CurDecl))
3297 else if (isa<CXXConstructorDecl>(CurDecl))
3299 else if (isa<CXXDestructorDecl>(CurDecl))
3304 << RetValExp->getSourceRange();
3309 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3312 RetValExp = ER.
get();
3317 }
else if (!RetValExp && !HasDependentReturnType) {
3323 DiagID = diag::err_constexpr_return_missing_expr;
3324 FD->setInvalidDecl();
3325 }
else if (getLangOpts().
C99) {
3327 DiagID = diag::ext_return_missing_expr;
3330 DiagID = diag::warn_return_missing_expr;
3336 Diag(ReturnLoc, DiagID) << getCurMethodDecl()->getDeclName() << 1;
3340 assert(RetValExp || HasDependentReturnType);
3341 const VarDecl *NRVOCandidate =
nullptr;
3343 QualType RetType = RelatedRetType.
isNull() ? FnRetType : RelatedRetType;
3352 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
3357 NRVOCandidate !=
nullptr);
3358 ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate,
3359 RetType, RetValExp);
3370 if (!RelatedRetType.
isNull()) {
3373 Res = PerformCopyInitialization(Entity, ReturnLoc, RetValExp);
3381 CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc, isObjCMethod, Attrs,
3382 getCurFunctionDecl());
3386 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3389 RetValExp = ER.
get();
3397 FunctionScopes.back()->Returns.push_back(Result);
3399 if (FunctionScopes.back()->FirstReturnLoc.isInvalid())
3400 FunctionScopes.back()->FirstReturnLoc = ReturnLoc;
3409 VarDecl *Var = cast_or_null<VarDecl>(Parm);
3410 if (Var && Var->isInvalidDecl())
3424 if (!getLangOpts().ObjCExceptions)
3425 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@try";
3427 getCurFunction()->setHasBranchProtectedScope();
3428 unsigned NumCatchStmts = CatchStmts.size();
3430 NumCatchStmts, Finally);
3439 Result = ActOnFinishFullExpr(Result.
get());
3442 Throw = Result.
get();
3450 return StmtError(
Diag(AtLoc, diag::error_objc_throw_expects_object)
3451 << Throw->
getType() << Throw->getSourceRange());
3461 if (!getLangOpts().ObjCExceptions)
3462 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@throw";
3467 Scope *AtCatchParent = CurScope;
3469 AtCatchParent = AtCatchParent->
getParent();
3471 return StmtError(
Diag(AtLoc, diag::error_rethrow_used_outside_catch));
3473 return BuildObjCAtThrowStmt(AtLoc, Throw);
3478 ExprResult result = DefaultLvalueConversion(operand);
3481 operand = result.
get();
3489 if (getLangOpts().CPlusPlus) {
3490 if (RequireCompleteType(atLoc, type,
3491 diag::err_incomplete_receiver_type))
3492 return Diag(atLoc, diag::error_objc_synchronized_expects_object)
3493 << type << operand->getSourceRange();
3495 ExprResult result = PerformContextuallyConvertToObjCPointer(operand);
3497 return Diag(atLoc, diag::error_objc_synchronized_expects_object)
3498 << type << operand->getSourceRange();
3500 operand = result.
get();
3502 return Diag(atLoc, diag::error_objc_synchronized_expects_object)
3503 << type << operand->getSourceRange();
3509 return ActOnFinishFullExpr(operand);
3516 getCurFunction()->setHasBranchProtectedScope();
3524 Stmt *HandlerBlock) {
3527 CXXCatchStmt(CatchLoc, cast_or_null<VarDecl>(ExDecl), HandlerBlock);
3532 getCurFunction()->setHasBranchProtectedScope();
3537 class CatchHandlerType {
3539 unsigned IsPointer : 1;
3544 enum Unique { ForDenseMap };
3545 CatchHandlerType(
QualType QT, Unique) : QT(QT), IsPointer(
false) {}
3552 if (QT->isPointerType())
3555 if (IsPointer || QT->isReferenceType())
3556 QT = QT->getPointeeType();
3557 QT = QT.getUnqualifiedType();
3563 CatchHandlerType(
QualType QT,
bool IsPointer)
3564 : QT(QT), IsPointer(IsPointer) {}
3566 QualType underlying()
const {
return QT; }
3567 bool isPointer()
const {
return IsPointer; }
3569 friend bool operator==(
const CatchHandlerType &LHS,
3570 const CatchHandlerType &RHS) {
3572 if (LHS.IsPointer != RHS.IsPointer)
3575 return LHS.QT == RHS.QT;
3584 CatchHandlerType::ForDenseMap);
3589 CatchHandlerType::ForDenseMap);
3597 const CatchHandlerType &RHS) {
3604 class CatchTypePublicBases {
3606 const llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> &TypesToCheck;
3607 const bool CheckAgainstPointer;
3613 CatchTypePublicBases(
3615 const llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> &T,
bool C)
3616 : Ctx(Ctx), TypesToCheck(T), CheckAgainstPointer(C),
3617 FoundHandler(nullptr) {}
3619 CXXCatchStmt *getFoundHandler()
const {
return FoundHandler; }
3620 CanQualType getFoundHandlerType()
const {
return FoundHandlerType; }
3624 CatchHandlerType Check(S->
getType(), CheckAgainstPointer);
3625 const auto &M = TypesToCheck;
3626 auto I = M.find(Check);
3628 FoundHandler =
I->second;
3629 FoundHandlerType = Ctx.getCanonicalType(S->
getType());
3643 if (!getLangOpts().CXXExceptions &&
3644 !getSourceManager().isInSystemHeader(TryLoc))
3645 Diag(TryLoc, diag::err_exceptions_disabled) <<
"try";
3647 if (getCurScope() && getCurScope()->isOpenMPSimdDirectiveScope())
3648 Diag(TryLoc, diag::err_omp_simd_region_cannot_use_stmt) <<
"try";
3654 Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
3658 const unsigned NumHandlers = Handlers.size();
3659 assert(!Handlers.empty() &&
3660 "The parser shouldn't call this if there are no handlers.");
3662 llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> HandledTypes;
3663 for (
unsigned i = 0; i < NumHandlers; ++i) {
3670 if (i < NumHandlers - 1)
3679 CatchHandlerType HandlerCHT =
3685 QualType Underlying = HandlerCHT.underlying();
3687 if (!RD->hasDefinition())
3696 CatchTypePublicBases CTPB(
Context, HandledTypes, HandlerCHT.isPointer());
3697 if (RD->lookupInBases(CTPB, Paths)) {
3699 if (!Paths.
isAmbiguous(CTPB.getFoundHandlerType())) {
3701 diag::warn_exception_caught_by_earlier_handler)
3704 diag::note_previous_exception_handler)
3712 auto R = HandledTypes.insert(std::make_pair(H->
getCaughtType(), H));
3716 diag::warn_exception_caught_by_earlier_handler)
3719 diag::note_previous_exception_handler)
3731 assert(TryBlock && Handler);
3737 if (!getLangOpts().Borland) {
3739 Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
3755 Diag(TryLoc, diag::err_seh_try_outside_functions);
3759 Diag(TryLoc, diag::err_seh_try_unsupported);
3768 assert(FilterExpr && Block);
3772 diag::err_filter_expression_integral)
3780 CurrentSEHFinally.push_back(CurScope);
3784 CurrentSEHFinally.pop_back();
3789 CurrentSEHFinally.pop_back();
3795 Scope *SEHTryParent = CurScope;
3797 SEHTryParent = SEHTryParent->
getParent();
3799 return StmtError(
Diag(Loc, diag::err_ms___leave_not_in___try));
3812 QualifierLoc, NameInfo,
3813 cast<CompoundStmt>(Nested));
3822 return BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
3824 GetNameFromUnqualifiedId(Name),
3830 unsigned NumParams) {
3847 assert(NumParams > 0 &&
"CapturedStmt requires context parameter");
3859 for (CaptureIter Cap = Candidates.begin(); Cap != Candidates.end(); ++Cap) {
3861 if (Cap->isThisCapture()) {
3864 CaptureInits.push_back(Cap->getInitExpr());
3866 }
else if (Cap->isVLATypeCapture()) {
3869 CaptureInits.push_back(
nullptr);
3874 Cap->isReferenceCapture()
3877 Cap->getVariable()));
3878 CaptureInits.push_back(Cap->getInitExpr());
3884 unsigned NumParams) {
3886 RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, NumParams);
3899 PushCapturedRegionScope(CurScope, CD, RD, Kind);
3902 PushDeclContext(CurScope, CD);
3906 PushExpressionEvaluationContext(PotentiallyEvaluated);
3913 RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, Params.size());
3917 bool ContextIsFound =
false;
3918 unsigned ParamNum = 0;
3921 I !=
E; ++
I, ++ParamNum) {
3922 if (
I->second.isNull()) {
3923 assert(!ContextIsFound &&
3924 "null type has been found already for '__context' parameter");
3931 ContextIsFound =
true;
3940 assert(ContextIsFound &&
"no null type for '__context' parameter");
3941 if (!ContextIsFound) {
3951 PushCapturedRegionScope(CurScope, CD, RD, Kind);
3954 PushDeclContext(CurScope, CD);
3958 PushExpressionEvaluationContext(PotentiallyEvaluated);
3962 DiscardCleanupsInEvaluationContext();
3963 PopExpressionEvaluationContext();
3967 Record->setInvalidDecl();
3970 ActOnFields(
nullptr, Record->getLocation(), Record, Fields,
3974 PopFunctionScopeInfo();
3988 getASTContext(), S, static_cast<CapturedRegionKind>(RSI->
CapRegionKind),
3989 Captures, CaptureInits, CD, RD);
3994 DiscardCleanupsInEvaluationContext();
3995 PopExpressionEvaluationContext();
3998 PopFunctionScopeInfo();
unsigned getFlags() const
getFlags - Return the flags for this scope.
A call to an overloaded operator written using operator syntax.
Defines the clang::ASTContext interface.
const SwitchCase * getNextSwitchCase() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
CastKind getCastKind() const
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
SourceLocation getLocStart() const LLVM_READONLY
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
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)
Smart pointer class that efficiently represents Objective-C method names.
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
A (possibly-)qualified type.
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
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)
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
QualType getType() const
Retrieves the type of the base class.
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)
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
const LangOptions & getLangOpts() const
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
FunctionType - C99 6.7.5.3 - Function Declarators.
IfStmt - This represents an if/then/else.
unsigned getIntWidth(QualType T) const
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
StmtResult ActOnExprStmt(ExprResult Arg)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
void setParam(unsigned i, ImplicitParamDecl *P)
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
ActionResult< Expr * > ExprResult
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...
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
bool isRecordType() const
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
bool isNoReturn() const
Determines whether this function is known to be 'noreturn', through an attribute on its declaration o...
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
Represents a C++11 auto or C++14 decltype(auto) type.
Represents an attribute applied to a statement.
bool isEnumeralType() const
ParenExpr - This represents a parethesized expression, e.g.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
static CapturedStmt * Create(const ASTContext &Context, Stmt *S, CapturedRegionKind Kind, ArrayRef< Capture > Captures, ArrayRef< Expr * > CaptureInits, CapturedDecl *CD, RecordDecl *RD)
The base class of the type hierarchy.
Represents Objective-C's @throw statement.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
const Expr * getInit() const
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
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.
bool isDecltypeAuto() const
A container of type source information.
Wrapper for void* pointer.
StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope)
bool isBlockPointerType() const
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.
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)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
DiagnosticsEngine & Diags
ObjCLifetime getObjCLifetime() const
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl)
SourceLocation getLocStart() const LLVM_READONLY
static bool ObjCEnumerationCollection(Expr *Collection)
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.
static Sema::ForRangeStatus BuildNonArrayForRange(Sema &SemaRef, Expr *BeginRange, Expr *EndRange, QualType RangeType, VarDecl *BeginVar, VarDecl *EndVar, SourceLocation ColonLoc, OverloadCandidateSet *CandidateSet, ExprResult *BeginExpr, ExprResult *EndExpr, BeginEndFunction *BEF)
Create the initialization, compare, and increment steps for the range-based for loop expression...
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 en...
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
SourceLocation getDefaultLoc() const
SourceLocation getLocation() const
CapturedDecl * TheCapturedDecl
The CapturedDecl for this statement.
QualType withConst() const
Retrieves a version of this type with const applied.
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.
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.
One of these records is kept for each identifier that is lexed.
const internal::VariadicDynCastAllOfMatcher< Stmt, CaseStmt > caseStmt
Matches case statements inside switch statements.
void DiagnoseUnusedExprResult(const Stmt *S)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
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.
bool isReferenceType() const
QualType getReturnType() const
static bool CmpCaseVals(const std::pair< llvm::APSInt, CaseStmt * > &lhs, const std::pair< llvm::APSInt, CaseStmt * > &rhs)
CmpCaseVals - Comparison predicate for sorting case values.
void setLocStart(SourceLocation L)
ExprResult CheckObjCForCollectionOperand(SourceLocation forLoc, Expr *collection)
bool isSEHTryScope() const
Determine whether this scope is a SEH '__try' block.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void startDefinition()
Starts the definition of this tag declaration.
bool Contains(const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
StmtResult BuildIfStmt(SourceLocation IfLoc, bool IsConstexpr, Stmt *InitStmt, ConditionResult Cond, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
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...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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()
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Represents Objective-C's @catch statement.
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization. ...
SourceLocation getBeginLoc() const
Get the begin source location.
IndirectGotoStmt - This represents an indirect goto.
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...
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.
const TargetInfo & getTargetInfo() const
This is a scope that corresponds to a switch statement.
void ActOnStartSEHFinallyBlock()
QualType getReturnType() const
An x-value expression is a reference to an object with independent storage but which can be "moved"...
field_range fields() const
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
bool isMacroBodyExpansion(SourceLocation Loc) const
Tests whether the given source location represents the expansion of a macro body. ...
A builtin binary operation expression such as "x + y" or "x <= y".
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
RecordDecl * getDecl() const
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, Stmt *tryBlock, ArrayRef< Stmt * > handlers)
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
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
bool isOverloadedOperator() const
isOverloadedOperator - Whether this function declaration represents an C++ overloaded operator...
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
LabelStmt * getStmt() const
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Scope - A scope is a transient data structure that is used while parsing the program.
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 isOpenMPLoopScope() const
Determine whether this scope is a loop having OpenMP loop directive attached.
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
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)
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'.
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 preordor 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.
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.
detail::InMemoryDirectory::const_iterator I
StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, Scope *CurScope)
void setStmt(LabelStmt *T)
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
static SEHTryStmt * Create(const ASTContext &C, bool isCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
Contains information about the compound statement currently being parsed.
SourceLocation FirstCXXTryLoc
First C++ 'try' statement in the current function.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
EnumDecl * getDecl() const
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
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.
ConditionalOperator - The ?: ternary operator.
Sema - This implements semantic analysis and AST building for C.
Expr * getFalseExpr() const
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 }.
Represents a prototype with parameter type info, e.g.
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit, bool TypeMayContainAuto)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
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.
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)
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp)
SourceLocation getTypeSpecStartLoc() const
void ActOnFinishOfCompoundStmt()
StmtResult ActOnAttributedStmt(SourceLocation AttrLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
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.
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
bool isAtCatchScope() const
isAtCatchScope - Return true if this scope is @catch.
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Expr - This represents one expression.
CanQualType getCanonicalFunctionResultType(QualType ResultType) const
Adjust the given function result type.
Allow any unmodeled side effect.
static void buildCapturedStmtCaptureList(SmallVectorImpl< CapturedStmt::Capture > &Captures, SmallVectorImpl< Expr * > &CaptureInits, ArrayRef< CapturingScopeInfo::Capture > Candidates)
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
static void DiagnoseForRangeConstVariableCopies(Sema &SemaRef, const VarDecl *VD)
void setContextParam(unsigned i, ImplicitParamDecl *P)
Defines the clang::Preprocessor interface.
bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD, bool AllowParamOrMoveConstructible)
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
const ParmVarDecl * getParamDecl(unsigned i) const
Represents Objective-C's @synchronized statement.
bool isMSAsmLabel() const
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)
const SwitchCase * getSwitchCaseList() const
QualType getType() const
Get the type for which this source info wrapper provides information.
Expr * getSubExpr() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
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.
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...
QualType getObjCIdType() const
Represents the Objective-CC id type.
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.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
void setHasCXXTry(SourceLocation TryLoc)
Represents a C++ conversion function within a class.
The result type of a method or function.
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()
TypeSourceInfo * getTypeSourceInfo() const
Expr * getTrueExpr() const
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
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.
static CatchHandlerType getEmptyKey()
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
void ActOnStartOfCompoundStmt()
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
static QualType GetTypeBeforeIntegralPromotion(Expr *&expr)
GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of potentially integral-promoted expr...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
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.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
std::pair< VarDecl *, Expr * > get() const
void setHasSEHTry(SourceLocation TryLoc)
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.
DeduceAutoResult
Result type of DeduceAutoType.
Encodes a location in the source.
enumerator_range enumerators() 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...
const TemplateArgument * iterator
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
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...
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, Scope *CurScope)
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isSingleDecl() const
isSingleDecl - This method returns true if this DeclStmt refers to a single Decl. ...
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
bool isSEHTrySupported() const
Whether the target supports SEH __try.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
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...
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.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
bool isLocalVarDecl() const
isLocalVarDecl - Returns true for local variable declarations other than parameters.
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
IdentifierTable & getIdentifierTable()
LabelDecl - Represents the declaration of a label.
const Expr * getCond() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
QualType withConst() const
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.
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
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...
static bool CmpEnumVals(const std::pair< llvm::APSInt, EnumConstantDecl * > &lhs, const std::pair< llvm::APSInt, EnumConstantDecl * > &rhs)
CmpEnumVals - Comparison predicate for sorting enumeration values.
Describes the kind of initialization being performed, along with location information for tokens rela...
SourceLocation getContinueLoc() const
SmallVector< Capture, 4 > Captures
Captures - The captures.
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Requests that all candidates be shown.
const T * castAs() const
Member-template castAs<specific 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.
bool isFileContext() const
SourceRange getSourceRange() const override LLVM_READONLY
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond, Stmt *Body)
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
QualType getType() const
Return the type wrapped by this type source info.
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
const Decl * getSingleDecl() const
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)
QualType getPointeeType() const
void setCapturedRecord()
Mark the record as a record for captured variables in CapturedStmt construct.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
NullStmt - This is the null statement ";": C99 6.8.3p3.
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
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...
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
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()
TypeLoc IgnoreParens() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
QualType getCaughtType() const
static void DiagnoseForRangeVariableCopies(Sema &SemaRef, const CXXForRangeStmt *ForStmt)
DiagnoseForRangeVariableCopies - Diagnose three cases and fixes for them.
SourceLocation getLocStart() const LLVM_READONLY
EnumDecl - Represents an enum.
detail::InMemoryDirectory::const_iterator E
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i...
sema::CompoundScopeInfo & getCurCompoundScope() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
Represents a __leave statement.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
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)
bool empty() const
Return true if no decls were found.
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...
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
const T * getAs() const
Member-template getAs<specific type>'.
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T)
Represents Objective-C's collection statement.
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
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...
void setUsesSEHTry(bool UST)
ActionResult< Stmt * > StmtResult
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
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
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Represents a base class of a C++ class.
static bool DiagnoseUnusedComparison(Sema &S, const Expr *E)
Diagnose unused comparisons, both builtin and overloaded operators.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
GotoStmt - This represents a direct goto.
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.
const Expr * getSubExpr() const
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.
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.
bool isObjCObjectPointerType() const
static bool FinishForRangeVarDecl(Sema &SemaRef, VarDecl *Decl, Expr *Init, SourceLocation Loc, int DiagID)
Finish building a variable declaration for a for-range statement.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
SourceLocation getBreakLoc() const
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.
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...
WhileStmt - This represents a 'while' stmt.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
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.
static bool EqEnumVals(const std::pair< llvm::APSInt, EnumConstantDecl * > &lhs, const std::pair< llvm::APSInt, EnumConstantDecl * > &rhs)
EqEnumVals - Comparison preficate for uniqing enumeration values.
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
VarDecl * getExceptionDecl() const
A reference to a declared variable, function, enum, etc.
BreakStmt - This represents a break.
SourceLocation getStarLoc() const
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...
DeduceAutoResult DeduceAutoType(TypeSourceInfo *AutoType, Expr *&Initializer, QualType &Result)
An l-value expression is a reference to an object with independent storage.
static bool hasDeducedReturnType(FunctionDecl *FD)
Determine whether the declared return type of the specified function contains 'auto'.
SourceLocation getRParenLoc() const
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
A boolean literal, per ([C++ lex.bool] Boolean literals).
Represents a C array with a specified size that is not an integer-constant-expression.
SourceLocation getStartLoc() const
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Describes an entity that is being initialized.
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 ':'.
bool isSingleDecl() const
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.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
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.
bool isPointerType() const
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
QualType getDeducedType() const
Get the type deduced for this auto type, or null if it's either not been deduced or was deduced to a ...