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) {
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)
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)
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) ||
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 const Expr *E = FC->getSubExpr();
295 E = TE->getSubExpr();
296 if (isa<CXXTemporaryObjectExpr>(E))
299 if (
const CXXRecordDecl *RD = CE->getType()->getAsCXXRecordDecl())
300 if (!RD->getAttr<WarnUnusedAttr>())
304 else if (
const CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(E)) {
312 Diag(Loc, diag::warn_unused_voidptr)
318 if (E->isGLValue() && E->getType().isVolatileQualified()) {
319 Diag(Loc, diag::warn_unused_volatile) << R1 << R2;
323 DiagRuntimeBehavior(Loc,
nullptr, PDiag(DiagID) << R1 << R2);
335 return getCurFunction()->CompoundScopes.back();
340 const unsigned NumElts = Elts.size();
348 for (; i != NumElts && isa<DeclStmt>(Elts[i]); ++i)
352 for (; i != NumElts && !isa<DeclStmt>(Elts[i]); ++i)
356 Decl *D = *cast<DeclStmt>(Elts[i])->decl_begin();
361 for (
unsigned i = 0; i != NumElts; ++i) {
363 if (isStmtExpr && i == NumElts - 1)
366 DiagnoseUnusedExprResult(Elts[i]);
372 if (NumElts != 0 && !CurrentInstantiationScope &&
373 getCurCompoundScope().HasEmptyLoopBodies) {
374 for (
unsigned i = 0; i != NumElts - 1; ++i)
375 DiagnoseEmptyLoopBody(Elts[i], Elts[i + 1]);
385 assert(LHSVal &&
"missing expression in case statement");
387 if (getCurFunction()->SwitchStack.empty()) {
388 Diag(CaseLoc, diag::err_case_not_in_switch);
393 CorrectDelayedTyposInExpr(LHSVal, [
this](
class Expr *
E) {
395 return VerifyIntegerConstantExpression(E);
397 getCurFunction()->SwitchStack.back()->getCond()) {
398 QualType CondType = CondExpr->getType();
399 llvm::APSInt TempVal;
413 LHSVal = VerifyIntegerConstantExpression(LHSVal).get();
421 RHSVal = VerifyIntegerConstantExpression(RHSVal).get();
426 LHS = ActOnFinishFullExpr(LHSVal, LHSVal->
getExprLoc(),
false,
427 getLangOpts().CPlusPlus11);
431 auto RHS = RHSVal ? ActOnFinishFullExpr(RHSVal, RHSVal->
getExprLoc(),
false,
432 getLangOpts().CPlusPlus11)
439 getCurFunction()->SwitchStack.back()->addSwitchCase(CS);
445 DiagnoseUnusedExprResult(SubStmt);
454 DiagnoseUnusedExprResult(SubStmt);
456 if (getCurFunction()->SwitchStack.empty()) {
457 Diag(DefaultLoc, diag::err_default_not_in_switch);
462 getCurFunction()->SwitchStack.back()->addSwitchCase(DS);
471 Diag(IdentLoc, diag::err_redefinition_of_label) << TheDecl->
getDeclName();
503 CommaVisitor(
Sema &SemaRef) : Inherited(SemaRef.
Context), SemaRef(SemaRef) {}
525 Expr *CondExpr = Cond.
get().second;
526 if (!Diags.isIgnored(diag::warn_comma_operator,
528 CommaVisitor(*this).Visit(CondExpr);
531 DiagnoseEmptyStmtBody(CondExpr->
getLocEnd(), thenStmt,
532 diag::warn_empty_if_body);
534 return BuildIfStmt(IfLoc, IsConstexpr, InitStmt, Cond, thenStmt, ElseLoc,
545 if (IsConstexpr || isa<ObjCAvailabilityCheckExpr>(Cond.
get().second))
546 getCurFunction()->setHasBranchProtectedScope();
548 DiagnoseUnusedExprResult(thenStmt);
549 DiagnoseUnusedExprResult(elseStmt);
553 Cond.
get().second, thenStmt, ElseLoc, elseStmt);
557 struct CaseCompareFunctor {
558 bool operator()(
const std::pair<llvm::APSInt, CaseStmt*> &LHS,
559 const llvm::APSInt &RHS) {
560 return LHS.first < RHS;
562 bool operator()(
const std::pair<llvm::APSInt, CaseStmt*> &LHS,
563 const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
564 return LHS.first < RHS.first;
566 bool operator()(
const llvm::APSInt &LHS,
567 const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
568 return LHS < RHS.first;
575 static bool CmpCaseVals(
const std::pair<llvm::APSInt, CaseStmt*>& lhs,
576 const std::pair<llvm::APSInt, CaseStmt*>& rhs) {
577 if (lhs.first < rhs.first)
580 if (lhs.first == rhs.first &&
581 lhs.second->getCaseLoc().getRawEncoding()
582 < rhs.second->getCaseLoc().getRawEncoding())
589 static bool CmpEnumVals(
const std::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
590 const std::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
592 return lhs.first < rhs.first;
597 static bool EqEnumVals(
const std::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
598 const std::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
600 return lhs.first == rhs.first;
607 expr = cleanups->getSubExpr();
609 if (impcast->getCastKind() != CK_IntegralCast)
break;
610 expr = impcast->getSubExpr();
620 SwitchConvertDiagnoser(
Expr *Cond)
626 return S.
Diag(Loc, diag::err_typecheck_statement_requires_integer) << T;
631 return S.
Diag(Loc, diag::err_switch_incomplete_class_type)
637 return S.
Diag(Loc, diag::err_switch_explicit_conversion) << T << ConvTy;
648 return S.
Diag(Loc, diag::err_switch_multiple_conversions) << T;
659 llvm_unreachable(
"conversion functions are permitted");
661 } SwitchDiagnoser(Cond);
664 PerformContextualImplicitConversion(SwitchLoc, Cond, SwitchDiagnoser);
669 return UsualUnaryConversions(CondResult.
get());
677 getCurFunction()->setHasBranchIntoScope();
681 getCurFunction()->SwitchStack.push_back(SS);
685 static void AdjustAPSInt(llvm::APSInt &Val,
unsigned BitWidth,
bool IsSigned) {
686 Val = Val.extOrTrunc(BitWidth);
687 Val.setIsSigned(IsSigned);
693 unsigned UnpromotedWidth,
bool UnpromotedSign) {
697 if (UnpromotedWidth < Val.getBitWidth()) {
698 llvm::APSInt ConvVal(Val);
700 AdjustAPSInt(ConvVal, Val.getBitWidth(), Val.isSigned());
705 S.
Diag(Loc, diag::warn_case_value_overflow) << Val.toString(10)
706 << ConvVal.toString(10);
716 const Expr *CaseExpr,
717 EnumValsTy::iterator &EI,
718 EnumValsTy::iterator &EIEnd,
719 const llvm::APSInt &Val) {
725 if (
const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
734 if (ED->
hasAttr<FlagEnumAttr>())
737 while (EI != EIEnd && EI->first < Val)
740 if (EI != EIEnd && EI->first == Val)
750 assert(SS == getCurFunction()->SwitchStack.back() &&
751 "switch stack missing push/pop!");
753 getCurFunction()->SwitchStack.pop_back();
756 SS->
setBody(BodyStmt, SwitchLoc);
763 Expr *CondExprBeforePromotion = CondExpr;
785 Diag(SwitchLoc, diag::warn_bool_switch_condition)
792 bool HasDependentValue
801 unsigned CondWidthBeforePromotion
803 bool CondIsSignedBeforePromotion
813 typedef std::vector<std::pair<llvm::APSInt, CaseStmt*> > CaseRangesTy;
814 CaseRangesTy CaseRanges;
818 bool CaseListIsErroneous =
false;
824 if (TheDefaultStmt) {
825 Diag(DS->getDefaultLoc(), diag::err_multiple_default_labels_defined);
832 CaseListIsErroneous =
true;
841 if (Lo->isTypeDependent() || Lo->isValueDependent()) {
842 HasDependentValue =
true;
848 if (getLangOpts().CPlusPlus11) {
854 CaseListIsErroneous =
true;
865 Lo = DefaultLvalueConversion(Lo).get();
866 Lo = ImpCastExprToType(Lo, CondType, CK_IntegralCast).get();
872 CondWidthBeforePromotion, CondIsSignedBeforePromotion);
883 HasDependentValue =
true;
886 CaseRanges.push_back(std::make_pair(LoVal, CS));
888 CaseVals.push_back(std::make_pair(LoVal, CS));
892 if (!HasDependentValue) {
895 llvm::APSInt ConstantCondValue;
896 bool HasConstantCond =
false;
897 if (!HasDependentValue && !TheDefaultStmt) {
900 assert(!HasConstantCond ||
901 (ConstantCondValue.getBitWidth() == CondWidth &&
902 ConstantCondValue.isSigned() == CondIsSigned));
904 bool ShouldCheckConstantCond = HasConstantCond;
907 std::stable_sort(CaseVals.begin(), CaseVals.end(),
CmpCaseVals);
909 if (!CaseVals.empty()) {
910 for (
unsigned i = 0, e = CaseVals.size(); i != e; ++i) {
911 if (ShouldCheckConstantCond &&
912 CaseVals[i].first == ConstantCondValue)
913 ShouldCheckConstantCond =
false;
915 if (i != 0 && CaseVals[i].first == CaseVals[i-1].first) {
918 StringRef PrevString, CurrString;
921 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(PrevCase)) {
922 PrevString = DeclRef->getDecl()->getName();
924 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(CurrCase)) {
925 CurrString = DeclRef->getDecl()->getName();
928 CaseVals[i-1].first.toString(CaseValStr);
930 if (PrevString == CurrString)
931 Diag(CaseVals[i].second->getLHS()->getLocStart(),
932 diag::err_duplicate_case) <<
933 (PrevString.empty() ? StringRef(CaseValStr) : PrevString);
935 Diag(CaseVals[i].second->getLHS()->getLocStart(),
936 diag::err_duplicate_case_differing_expr) <<
937 (PrevString.empty() ? StringRef(CaseValStr) : PrevString) <<
938 (CurrString.empty() ? StringRef(CaseValStr) : CurrString) <<
941 Diag(CaseVals[i-1].second->getLHS()->getLocStart(),
942 diag::note_duplicate_case_prev);
945 CaseListIsErroneous =
true;
952 if (!CaseRanges.empty()) {
955 std::stable_sort(CaseRanges.begin(), CaseRanges.end());
958 std::vector<llvm::APSInt> HiVals;
959 for (
unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
960 llvm::APSInt &LoVal = CaseRanges[i].first;
961 CaseStmt *CR = CaseRanges[i].second;
972 CaseListIsErroneous =
true;
981 Hi = DefaultLvalueConversion(Hi).get();
982 Hi = ImpCastExprToType(Hi, CondType, CK_IntegralCast).get();
988 CondWidthBeforePromotion, CondIsSignedBeforePromotion);
1000 CaseRanges.erase(CaseRanges.begin()+i);
1006 if (ShouldCheckConstantCond &&
1007 LoVal <= ConstantCondValue &&
1008 ConstantCondValue <= HiVal)
1009 ShouldCheckConstantCond =
false;
1011 HiVals.push_back(HiVal);
1017 for (
unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
1018 llvm::APSInt &CRLo = CaseRanges[i].first;
1019 llvm::APSInt &CRHi = HiVals[i];
1020 CaseStmt *CR = CaseRanges[i].second;
1025 llvm::APSInt OverlapVal(32);
1029 CaseValsTy::iterator
I = std::lower_bound(CaseVals.begin(),
1030 CaseVals.end(), CRLo,
1031 CaseCompareFunctor());
1032 if (I != CaseVals.end() && I->first < CRHi) {
1033 OverlapVal = I->first;
1034 OverlapStmt = I->second;
1038 I = std::upper_bound(I, CaseVals.end(), CRHi, CaseCompareFunctor());
1039 if (I != CaseVals.begin() && (I-1)->first >= CRLo) {
1040 OverlapVal = (I-1)->first;
1041 OverlapStmt = (I-1)->second;
1046 if (i && CRLo <= HiVals[i-1]) {
1047 OverlapVal = HiVals[i-1];
1048 OverlapStmt = CaseRanges[i-1].second;
1054 << OverlapVal.toString(10);
1056 diag::note_duplicate_case_prev);
1059 CaseListIsErroneous =
true;
1065 if (!CaseListIsErroneous && ShouldCheckConstantCond) {
1068 Diag(CondExpr->
getExprLoc(), diag::warn_missing_case_for_condition)
1069 << ConstantCondValue.toString(10)
1081 if (!CaseListIsErroneous && !HasConstantCond && ET &&
1089 llvm::APSInt Val = EDI->getInitVal();
1091 EnumVals.push_back(std::make_pair(Val, EDI));
1093 std::stable_sort(EnumVals.begin(), EnumVals.end(),
CmpEnumVals);
1094 auto EI = EnumVals.begin(), EIEnd =
1095 std::unique(EnumVals.begin(), EnumVals.end(),
EqEnumVals);
1098 for (CaseValsTy::const_iterator CI = CaseVals.begin();
1099 CI != CaseVals.end(); CI++) {
1100 Expr *CaseExpr = CI->second->getLHS();
1104 << CondTypeBeforePromotion;
1108 EI = EnumVals.begin();
1109 for (CaseRangesTy::const_iterator RI = CaseRanges.begin();
1110 RI != CaseRanges.end(); RI++) {
1111 Expr *CaseExpr = RI->second->getLHS();
1115 << CondTypeBeforePromotion;
1118 RI->second->getRHS()->EvaluateKnownConstInt(
Context);
1121 CaseExpr = RI->second->getRHS();
1125 << CondTypeBeforePromotion;
1129 auto CI = CaseVals.begin();
1130 auto RI = CaseRanges.begin();
1131 bool hasCasesNotInSwitch =
false;
1135 for (EI = EnumVals.begin(); EI != EIEnd; EI++){
1137 while (CI != CaseVals.end() && CI->first < EI->first)
1140 if (CI != CaseVals.end() && CI->first == EI->first)
1144 for (; RI != CaseRanges.end(); RI++) {
1146 RI->second->getRHS()->EvaluateKnownConstInt(
Context);
1148 if (EI->first <= Hi)
1152 if (RI == CaseRanges.end() || EI->first < RI->first) {
1153 hasCasesNotInSwitch =
true;
1154 UnhandledNames.push_back(EI->second->getDeclName());
1158 if (TheDefaultStmt && UnhandledNames.empty() && ED->
isClosedNonFlag())
1162 if (!UnhandledNames.empty()) {
1164 TheDefaultStmt ? diag::warn_def_missing_case
1165 : diag::warn_missing_case)
1166 << (
int)UnhandledNames.size();
1170 DB << UnhandledNames[
I];
1173 if (!hasCasesNotInSwitch)
1179 DiagnoseEmptyStmtBody(CondExpr->
getLocEnd(), BodyStmt,
1180 diag::warn_empty_switch_body);
1184 if (CaseListIsErroneous)
1193 if (Diags.isIgnored(diag::warn_not_in_enum_assignment, SrcExpr->
getExprLoc()))
1207 const EnumDecl *ED = ET->getDecl();
1212 if (ED->
hasAttr<FlagEnumAttr>()) {
1213 if (!IsValueInFlagEnum(ED, RhsVal,
true))
1219 EnumValsTy EnumVals;
1224 llvm::APSInt Val = EDI->getInitVal();
1226 EnumVals.push_back(std::make_pair(Val, EDI));
1228 if (EnumVals.empty())
1230 std::stable_sort(EnumVals.begin(), EnumVals.end(),
CmpEnumVals);
1231 EnumValsTy::iterator EIend =
1232 std::unique(EnumVals.begin(), EnumVals.end(),
EqEnumVals);
1235 EnumValsTy::const_iterator EI = EnumVals.begin();
1236 while (EI != EIend && EI->first < RhsVal)
1238 if (EI == EIend || EI->first != RhsVal) {
1252 auto CondVal = Cond.
get();
1253 CheckBreakContinueBinding(CondVal.second);
1255 if (CondVal.second &&
1256 !Diags.isIgnored(diag::warn_comma_operator, CondVal.second->getExprLoc()))
1257 CommaVisitor(*this).Visit(CondVal.second);
1259 DiagnoseUnusedExprResult(Body);
1261 if (isa<NullStmt>(Body))
1262 getCurCompoundScope().setHasEmptyLoopBodies();
1272 assert(Cond &&
"ActOnDoStmt(): missing expression");
1274 CheckBreakContinueBinding(Cond);
1275 ExprResult CondResult = CheckBooleanCondition(DoLoc, Cond);
1278 Cond = CondResult.
get();
1280 CondResult = ActOnFinishFullExpr(Cond, DoLoc);
1283 Cond = CondResult.
get();
1285 DiagnoseUnusedExprResult(Body);
1287 return new (
Context)
DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen);
1292 using DeclSetVector =
1293 llvm::SetVector<VarDecl *, llvm::SmallVector<VarDecl *, 8>,
1294 llvm::SmallPtrSet<VarDecl *, 8>>;
1300 DeclSetVector &Decls;
1306 DeclExtractor(
Sema &
S, DeclSetVector &Decls,
1313 bool isSimple() {
return Simple; }
1321 void VisitStmt(
Stmt *
S) {
1378 DeclSetVector &Decls;
1384 DeclMatcher(
Sema &
S, DeclSetVector &Decls,
Stmt *Statement) :
1386 if (!Statement)
return;
1410 void CheckLValueToRValueCast(
Expr *E) {
1413 if (isa<DeclRefExpr>(E)) {
1418 Visit(CO->getCond());
1419 CheckLValueToRValueCast(CO->getTrueExpr());
1420 CheckLValueToRValueCast(CO->getFalseExpr());
1425 dyn_cast<BinaryConditionalOperator>(E)) {
1426 CheckLValueToRValueCast(BCO->getOpaqueValue()->getSourceExpr());
1427 CheckLValueToRValueCast(BCO->getFalseExpr());
1436 if (Decls.count(VD))
1444 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(S))
1446 Visit(OVE->getSourceExpr());
1452 bool FoundDeclInUse() {
return FoundDecl; }
1456 void CheckForLoopConditionalStatement(
Sema &S,
Expr *Second,
1459 if (!Second)
return;
1466 DeclSetVector Decls;
1468 DeclExtractor DE(S, Decls, Ranges);
1472 if (!DE.isSimple())
return;
1475 if (Decls.size() == 0)
return;
1478 for (
auto *VD : Decls)
1482 if (DeclMatcher(S, Decls, Second).FoundDeclInUse() ||
1483 DeclMatcher(S, Decls, Third).FoundDeclInUse() ||
1484 DeclMatcher(S, Decls, Body).FoundDeclInUse())
1488 if (Decls.size() > 4) {
1492 for (
auto *VD : Decls)
1496 for (
auto Range : Ranges)
1499 S.
Diag(Ranges.begin()->getBegin(), PDiag);
1504 bool ProcessIterationStmt(
Sema &S,
Stmt* Statement,
bool &Increment,
1506 if (
auto Cleanups = dyn_cast<ExprWithCleanups>(Statement))
1507 if (!Cleanups->cleanupsHaveSideEffects())
1508 Statement = Cleanups->getSubExpr();
1510 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(Statement)) {
1511 switch (UO->getOpcode()) {
1512 default:
return false;
1530 default:
return false;
1550 bool InSwitch =
false;
1553 BreakContinueFinder(
Sema &S,
const Stmt* Body) :
1564 void VisitBreakStmt(
const BreakStmt* E) {
1584 void VisitForStmt(
const ForStmt *S) {
1591 void VisitWhileStmt(
const WhileStmt *) {
1596 void VisitDoStmt(
const DoStmt *) {
1621 bool ContinueFound() {
return ContinueLoc.
isValid(); }
1622 bool BreakFound() {
return BreakLoc.isValid(); }
1633 void CheckForRedundantIteration(
Sema &S,
Expr *Third,
Stmt *Body) {
1635 if (!Body || !Third)
return;
1645 if (!LastStmt)
return;
1647 bool LoopIncrement, LastIncrement;
1650 if (!ProcessIterationStmt(S, Third, LoopIncrement, LoopDRE))
return;
1651 if (!ProcessIterationStmt(S, LastStmt, LastIncrement, LastDRE))
return;
1655 if (LoopIncrement != LastIncrement ||
1658 if (BreakContinueFinder(S, Body).ContinueFound())
return;
1661 << LastDRE->
getDecl() << LastIncrement;
1669 void Sema::CheckBreakContinueBinding(
Expr *E) {
1672 BreakContinueFinder BCFinder(*
this, E);
1674 if (BCFinder.BreakFound() && BreakParent) {
1676 Diag(BCFinder.GetBreakLoc(), diag::warn_break_binds_to_switch);
1678 Diag(BCFinder.GetBreakLoc(), diag::warn_loop_ctrl_binds_to_inner)
1681 }
else if (BCFinder.ContinueFound() && CurScope->getContinueParent()) {
1682 Diag(BCFinder.GetContinueLoc(), diag::warn_loop_ctrl_binds_to_inner)
1694 if (!getLangOpts().CPlusPlus) {
1695 if (
DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
1699 for (
auto *DI : DS->decls()) {
1704 Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
1705 DI->setInvalidDecl();
1711 CheckBreakContinueBinding(Second.
get().second);
1712 CheckBreakContinueBinding(third.
get());
1714 if (!Second.
get().first)
1715 CheckForLoopConditionalStatement(*
this, Second.
get().second, third.
get(),
1717 CheckForRedundantIteration(*
this, third.
get(), Body);
1719 if (Second.
get().second &&
1720 !Diags.isIgnored(diag::warn_comma_operator,
1721 Second.
get().second->getExprLoc()))
1722 CommaVisitor(*this).Visit(Second.
get().second);
1726 DiagnoseUnusedExprResult(First);
1727 DiagnoseUnusedExprResult(Third);
1728 DiagnoseUnusedExprResult(Body);
1730 if (isa<NullStmt>(Body))
1731 getCurCompoundScope().setHasEmptyLoopBodies();
1735 Body, ForLoc, LParenLoc, RParenLoc);
1749 ExprResult FullExpr = ActOnFinishFullExpr(E);
1760 ExprResult result = CorrectDelayedTyposInExpr(collection);
1763 collection = result.
get();
1769 result = DefaultFunctionArrayLvalueConversion(collection);
1772 collection = result.
get();
1779 return Diag(forLoc, diag::err_collection_expr_type)
1790 (getLangOpts().ObjCAutoRefCount
1791 ? RequireCompleteType(forLoc,
QualType(objectType, 0),
1792 diag::err_arc_collection_forward, collection)
1793 : !isCompleteType(forLoc,
QualType(objectType, 0)))) {
1796 }
else if (iface || !objectType->
qual_empty()) {
1814 method = LookupMethodInQualifiedType(selector, pointerType,
1819 Diag(forLoc, diag::warn_collection_expr_type)
1834 getCurFunction()->setHasBranchProtectedScope();
1837 CheckObjCForCollectionOperand(ForLoc, collection);
1841 if (
DeclStmt *DS = dyn_cast<DeclStmt>(First)) {
1842 if (!DS->isSingleDecl())
1844 diag::err_toomany_element_decls));
1856 diag::err_non_local_variable_decl_in_for));
1862 Expr *DeducedInit = &OpaqueId;
1865 DiagnoseAutoDeductionFailure(D, DeducedInit);
1866 if (FirstType.
isNull()) {
1873 if (!inTemplateInstantiation()) {
1876 Diag(Loc, diag::warn_auto_var_is_id)
1882 Expr *FirstE = cast<Expr>(First);
1885 diag::err_selector_element_not_lvalue)
1888 FirstType =
static_cast<Expr*
>(First)->getType();
1890 Diag(ForLoc, diag::err_selector_element_const_type)
1896 return StmtError(
Diag(ForLoc, diag::err_selector_element_type)
1903 CollectionExprResult = ActOnFinishFullExpr(CollectionExprResult.
get());
1908 nullptr, ForLoc, RParenLoc);
1962 void NoteForRangeBeginEndFunction(
Sema &SemaRef,
Expr *E,
1972 std::string Description;
1973 bool IsTemplate =
false;
1980 SemaRef.
Diag(Loc, diag::note_for_range_begin_end)
1981 << BEF << IsTemplate << Description << E->
getType();
2030 return ActOnObjCForCollectionStmt(ForLoc, First, Range, RParenLoc);
2033 assert(DS &&
"first part of for range not a decl stmt");
2042 DiagnoseUnexpandedParameterPack(Range, UPPC_Expression)) {
2050 if (!ActOnCoroutineBodyStart(S, CoawaitLoc,
"co_await"))
2056 VarDecl *RangeVar = BuildForRangeVarDecl(*
this, RangeLoc,
2060 diag::err_for_range_deduction_failure)) {
2068 StmtResult RangeDecl = ActOnDeclStmt(RangeGroup, RangeLoc, RangeLoc);
2074 return BuildCXXForRangeStmt(ForLoc, CoawaitLoc, ColonLoc, RangeDecl.
get(),
2077 DS, RParenLoc,
Kind);
2113 if (BeginMemberLookup.empty() != EndMemberLookup.
empty()) {
2115 *BEF = BeginMemberLookup.empty() ? BEF_end : BEF_begin;
2117 SemaRef.
Diag(RangeLoc, diag::err_for_range_member_begin_end_mismatch)
2118 << RangeLoc << BeginRange->
getType() << *BEF;
2132 BeginMemberLookup, CandidateSet,
2133 BeginRange, BeginExpr);
2138 << ColonLoc << BEF_begin << BeginRange->
getType();
2151 diag::err_for_range_iter_deduction_failure)) {
2152 NoteForRangeBeginEndFunction(SemaRef, BeginExpr->
get(), *BEF);
2159 EndMemberLookup, CandidateSet,
2164 << ColonLoc << BEF_end << EndRange->
getType();
2168 diag::err_for_range_iter_deduction_failure)) {
2169 NoteForRangeBeginEndFunction(SemaRef, EndExpr->
get(), *BEF);
2192 AdjustedRange = SemaRef.
BuildUnaryOp(S, RangeLoc, UO_Deref, Range);
2197 S, ForLoc, CoawaitLoc, LoopVarDecl, ColonLoc, AdjustedRange.
get(),
2206 SemaRef.
Diag(RangeLoc, diag::err_for_range_dereference)
2209 ColonLoc, AdjustedRange.
get(), RParenLoc,
2215 struct InvalidateOnErrorScope {
2216 InvalidateOnErrorScope(
Sema &SemaRef,
Decl *D,
bool Enabled)
2217 : Trap(SemaRef.Diags), D(D), Enabled(Enabled) {}
2218 ~InvalidateOnErrorScope() {
2219 if (Enabled && Trap.hasErrorOccurred())
2245 Scope *S = getCurScope();
2247 DeclStmt *RangeDS = cast<DeclStmt>(RangeDecl);
2249 QualType RangeVarType = RangeVar->getType();
2251 DeclStmt *LoopVarDS = cast<DeclStmt>(LoopVarDecl);
2256 InvalidateOnErrorScope Invalidate(*
this, LoopVar,
2257 LoopVar->getType()->isUndeducedType());
2263 if (RangeVarType->isDependentType()) {
2269 if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) {
2270 if (
auto *DD = dyn_cast<DecompositionDecl>(LoopVar))
2271 for (
auto *Binding : DD->bindings())
2275 }
else if (!BeginDeclStmt.get()) {
2280 ExprResult BeginRangeRef = BuildDeclRefExpr(RangeVar, RangeVarNonRefType,
2285 ExprResult EndRangeRef = BuildDeclRefExpr(RangeVar, RangeVarNonRefType,
2291 Expr *Range = RangeVar->getInit();
2296 if (RequireCompleteType(RangeLoc, RangeType,
2297 diag::err_for_range_incomplete_type))
2301 VarDecl *BeginVar = BuildForRangeVarDecl(*
this, ColonLoc, AutoType,
2303 VarDecl *EndVar = BuildForRangeVarDecl(*
this, ColonLoc, AutoType,
2315 BeginExpr = BeginRangeRef;
2317 BeginExpr = ActOnCoawaitExpr(S, ColonLoc, BeginExpr.
get());
2322 diag::err_for_range_iter_deduction_failure)) {
2323 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2333 dyn_cast<VariableArrayType>(UnqAT)) {
2356 ExprResult SizeOfVLAExprR = ActOnUnaryExprOrTypeTraitExpr(
2360 VAT->desugar(), RangeLoc))
2366 ExprResult SizeOfEachElementExprR = ActOnUnaryExprOrTypeTraitExpr(
2369 CreateParsedType(VAT->desugar(),
2371 VAT->getElementType(), RangeLoc))
2379 SizeOfVLAExprR.
get(), SizeOfEachElementExprR.
get());
2386 llvm_unreachable(
"Unexpected array type in for-range");
2390 EndExpr = ActOnBinOp(S, ColonLoc, tok::plus, EndRangeRef.
get(),
2395 diag::err_for_range_iter_deduction_failure)) {
2396 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2404 *
this, BeginRangeRef.
get(), EndRangeRef.
get(), RangeType, BeginVar,
2405 EndVar,
ColonLoc, CoawaitLoc, &CandidateSet, &BeginExpr, &EndExpr,
2408 if (Kind == BFRK_Build && RangeStatus == FRS_NoViableFunction &&
2409 BEFFailure == BEF_begin) {
2412 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Range)) {
2414 QualType ArrayTy = PVD->getOriginalType();
2415 QualType PointerTy = PVD->getType();
2418 << RangeLoc << PVD << ArrayTy << PointerTy;
2419 Diag(PVD->getLocation(), diag::note_declared_at);
2429 LoopVarDecl, ColonLoc,
2437 if (RangeStatus == FRS_NoViableFunction) {
2438 Expr *Range = BEFFailure ? EndRangeRef.
get() : BeginRangeRef.
get();
2440 << RangeLoc << Range->
getType() << BEFFailure;
2444 if (RangeStatus != FRS_Success)
2449 "invalid range expression in for loop");
2456 ? diag::warn_for_range_begin_end_types_differ
2457 : diag::ext_for_range_begin_end_types_differ)
2458 << BeginType << EndType;
2459 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2460 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2464 ActOnDeclStmt(ConvertDeclToDeclGroup(BeginVar), ColonLoc, ColonLoc);
2466 ActOnDeclStmt(ConvertDeclToDeclGroup(EndVar), ColonLoc, ColonLoc);
2469 ExprResult BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2474 ExprResult EndRef = BuildDeclRefExpr(EndVar, EndType.getNonReferenceType(),
2480 NotEqExpr = ActOnBinOp(S, ColonLoc, tok::exclaimequal,
2481 BeginRef.
get(), EndRef.
get());
2483 NotEqExpr = CheckBooleanCondition(ColonLoc, NotEqExpr.
get());
2485 NotEqExpr = ActOnFinishFullExpr(NotEqExpr.
get());
2487 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2488 << RangeLoc << 0 << BeginRangeRef.
get()->
getType();
2489 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2491 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2496 BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2501 IncrExpr = ActOnUnaryOp(S, ColonLoc, tok::plusplus, BeginRef.
get());
2502 if (!IncrExpr.isInvalid() && CoawaitLoc.
isValid())
2506 IncrExpr = ActOnCoawaitExpr(S, CoawaitLoc, IncrExpr.get());
2507 if (!IncrExpr.isInvalid())
2508 IncrExpr = ActOnFinishFullExpr(IncrExpr.get());
2509 if (IncrExpr.isInvalid()) {
2510 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2511 << RangeLoc << 2 << BeginRangeRef.
get()->
getType() ;
2512 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2517 BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2522 ExprResult DerefExpr = ActOnUnaryOp(S, ColonLoc, tok::star, BeginRef.
get());
2524 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2525 << RangeLoc << 1 << BeginRangeRef.
get()->
getType();
2526 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2532 if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) {
2533 AddInitializerToDecl(LoopVar, DerefExpr.
get(),
false);
2534 if (LoopVar->isInvalidDecl())
2535 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2541 if (Kind == BFRK_Check)
2545 RangeDS, cast_or_null<DeclStmt>(BeginDeclStmt.get()),
2546 cast_or_null<DeclStmt>(EndDeclStmt.
get()), NotEqExpr.
get(),
2547 IncrExpr.get(), LoopVarDS,
nullptr, ForLoc, CoawaitLoc,
2578 if (
auto Cleanups = dyn_cast<ExprWithCleanups>(InitExpr))
2579 if (!Cleanups->cleanupsHaveSideEffects())
2580 InitExpr = Cleanups->getSubExpr();
2593 while (!isa<CXXOperatorCallExpr>(E) && !isa<UnaryOperator>(E)) {
2597 const MemberExpr *ME = cast<MemberExpr>(Call->getCallee());
2606 bool ReturnsReference =
false;
2607 if (isa<UnaryOperator>(E)) {
2608 ReturnsReference =
true;
2612 QualType ReturnType = FD->getReturnType();
2616 if (ReturnsReference) {
2620 SemaRef.
Diag(VD->
getLocation(), diag::warn_for_range_const_reference_copy)
2621 << VD << VariableType << E->
getType();
2631 SemaRef.
Diag(VD->
getLocation(), diag::warn_for_range_variable_always_copy)
2632 << VD << RangeInitType;
2652 if (!CE->getConstructor()->isCopyConstructor())
2654 }
else if (
const CastExpr *CE = dyn_cast<CastExpr>(InitExpr)) {
2655 if (CE->getCastKind() != CK_LValueToRValue)
2670 << VD << VariableType << InitExpr->
getType();
2686 if (SemaRef.
Diags.
isIgnored(diag::warn_for_range_const_reference_copy,
2688 SemaRef.
Diags.
isIgnored(diag::warn_for_range_variable_always_copy,
2724 if (isa<ObjCForCollectionStmt>(S))
2725 return FinishObjCForCollectionStmt(S, B);
2731 diag::warn_empty_range_based_for_body);
2741 getCurFunction()->setHasBranchIntoScope();
2755 CheckSingleAssignmentConstraints(DestTy, ExprRes);
2759 if (DiagnoseAssignmentResult(ConvTy, StarLoc, DestTy, ETy, E, AA_Passing))
2768 getCurFunction()->setHasIndirectGoto();
2774 const Scope &DestScope) {
2777 S.
Diag(Loc, diag::warn_jump_out_of_seh_finally);
2786 return StmtError(
Diag(ContinueLoc, diag::err_continue_not_in_loop));
2798 return StmtError(
Diag(BreakLoc, diag::err_break_not_in_loop_or_switch));
2801 return StmtError(
Diag(BreakLoc, diag::err_omp_loop_cannot_use_stmt)
2828 bool AllowParamOrMoveConstructible) {
2841 if (isCopyElisionCandidate(ReturnType, VD, AllowParamOrMoveConstructible))
2847 bool AllowParamOrMoveConstructible) {
2862 if (VD->
getKind() != Decl::Var &&
2863 !(AllowParamOrMoveConstructible && VD->
getKind() == Decl::ParmVar))
2873 if (VD->
hasAttr<BlocksAttr>())
return false;
2875 if (AllowParamOrMoveConstructible)
2913 if (AllowNRVO && !NRVOCandidate)
2914 NRVOCandidate = getCopyElisionCandidate(ResultType, Value,
true);
2916 if (AllowNRVO && NRVOCandidate) {
2920 Expr *InitExpr = &AsRvalue;
2923 Value->getLocStart(), Value->getLocStart());
2931 isa<CXXConstructorDecl>(
Step.Function.Function))))
2935 cast<CXXConstructorDecl>(
Step.Function.Function);
2958 Res = Seq.Perform(*
this, Entity, Kind, Value);
2990 bool HasDeducedReturnType =
2993 if (ExprEvalContexts.back().Context ==
2994 ExpressionEvaluationContext::DiscardedStatement &&
2997 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3000 RetValExp = ER.
get();
3005 if (HasDeducedReturnType) {
3013 assert(AT &&
"lost auto type from lambda return type");
3014 if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
3024 if (RetValExp && !isa<InitListExpr>(RetValExp)) {
3028 RetValExp = Result.
get();
3034 if (!CurContext->isDependentContext())
3043 Diag(ReturnLoc, diag::err_lambda_return_init_list)
3055 assert(!FnRetType.isNull());
3057 if (
BlockScopeInfo *CurBlock = dyn_cast<BlockScopeInfo>(CurCap)) {
3059 Diag(ReturnLoc, diag::err_noreturn_block_has_return_expr);
3063 dyn_cast<CapturedRegionScopeInfo>(CurCap)) {
3064 Diag(ReturnLoc, diag::err_return_in_captured_stmt) << CurRegion->getRegionName();
3067 assert(CurLambda &&
"unknown kind of captured scope");
3069 ->getNoReturnAttr()) {
3070 Diag(ReturnLoc, diag::err_noreturn_lambda_has_return_expr);
3078 const VarDecl *NRVOCandidate =
nullptr;
3079 if (FnRetType->isDependentType()) {
3082 }
else if (FnRetType->isVoidType()) {
3083 if (RetValExp && !isa<InitListExpr>(RetValExp) &&
3084 !(getLangOpts().CPlusPlus &&
3087 if (!getLangOpts().CPlusPlus &&
3089 Diag(ReturnLoc, diag::ext_return_has_void_expr) <<
"literal" << 2;
3091 Diag(ReturnLoc, diag::err_return_block_has_expr);
3092 RetValExp =
nullptr;
3095 }
else if (!RetValExp) {
3096 return StmtError(
Diag(ReturnLoc, diag::err_block_return_missing_expr));
3106 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
3109 NRVOCandidate !=
nullptr);
3110 ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate,
3111 FnRetType, RetValExp);
3116 RetValExp = Res.
get();
3117 CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc);
3119 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
3123 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3126 RetValExp = ER.
get();
3135 FunctionScopes.back()->Returns.push_back(Result);
3137 if (FunctionScopes.back()->FirstReturnLoc.isInvalid())
3138 FunctionScopes.back()->FirstReturnLoc = ReturnLoc;
3156 class LocalTypedefNameReferencer
3159 LocalTypedefNameReferencer(
Sema &S) : S(S) {}
3164 bool LocalTypedefNameReferencer::VisitRecordType(
const RecordType *RT) {
3166 if (!R || !R->isLocalClass() || !R->isLocalClass()->isExternallyVisible() ||
3167 R->isDependentType())
3169 for (
auto *TmpD : R->decls())
3170 if (
auto *T = dyn_cast<TypedefNameDecl>(TmpD))
3171 if (T->getAccess() !=
AS_private || R->hasFriends())
3190 TypeLoc OrigResultType = getReturnTypeLoc(FD);
3193 if (RetExpr && isa<InitListExpr>(RetExpr)) {
3197 getCurLambda() ? diag::err_lambda_return_init_list
3198 : diag::err_auto_fn_return_init_list)
3208 assert(AT->
isDeduced() &&
"should have deduced to dependent type");
3221 if (DAR != DAR_Succeeded)
3226 LocalTypedefNameReferencer Referencer(*
this);
3227 Referencer.TraverseType(RetExpr->
getType());
3235 Diag(ReturnLoc, diag::err_auto_fn_return_void_but_not_auto)
3264 Diag(ReturnLoc, diag::err_typecheck_missing_return_type_incompatible)
3268 Diag(ReturnLoc, diag::err_auto_fn_different_deductions)
3285 StmtResult R = BuildReturnStmt(ReturnLoc, RetValExp);
3286 if (R.
isInvalid() || ExprEvalContexts.back().Context ==
3287 ExpressionEvaluationContext::DiscardedStatement)
3291 const_cast<VarDecl*>(cast<ReturnStmt>(R.
get())->getNRVOCandidate())) {
3304 if (RetValExp && DiagnoseUnexpandedParameterPack(RetValExp))
3307 if (isa<CapturingScopeInfo>(getCurFunction()))
3308 return ActOnCapScopeReturnStmt(ReturnLoc, RetValExp);
3312 const AttrVec *Attrs =
nullptr;
3313 bool isObjCMethod =
false;
3320 Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr)
3322 if (FD->
isMain() && RetValExp)
3323 if (isa<CXXBoolLiteralExpr>(RetValExp))
3324 Diag(ReturnLoc, diag::warn_main_returns_bool_literal)
3327 FnRetType = MD->getReturnType();
3328 isObjCMethod =
true;
3330 Attrs = &MD->getAttrs();
3331 if (MD->hasRelatedResultType() && MD->getClassInterface()) {
3343 if (ExprEvalContexts.back().Context ==
3344 ExpressionEvaluationContext::DiscardedStatement &&
3347 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3350 RetValExp = ER.
get();
3357 if (getLangOpts().CPlusPlus14) {
3360 if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
3374 if (isa<InitListExpr>(RetValExp)) {
3378 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3379 int FunctionKind = 0;
3380 if (isa<ObjCMethodDecl>(CurDecl))
3382 else if (isa<CXXConstructorDecl>(CurDecl))
3384 else if (isa<CXXDestructorDecl>(CurDecl))
3387 Diag(ReturnLoc, diag::err_return_init_list)
3392 RetValExp =
nullptr;
3395 unsigned D = diag::ext_return_has_expr;
3397 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3398 if (isa<CXXConstructorDecl>(CurDecl) ||
3399 isa<CXXDestructorDecl>(CurDecl))
3400 D = diag::err_ctor_dtor_returns_void;
3402 D = diag::ext_return_has_void_expr;
3406 Result = IgnoredValueConversions(Result.
get());
3409 RetValExp = Result.
get();
3410 RetValExp = ImpCastExprToType(RetValExp,
3414 if (D == diag::err_ctor_dtor_returns_void) {
3415 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3417 << CurDecl->
getDeclName() << isa<CXXDestructorDecl>(CurDecl)
3421 else if (D != diag::ext_return_has_void_expr ||
3423 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3425 int FunctionKind = 0;
3426 if (isa<ObjCMethodDecl>(CurDecl))
3428 else if (isa<CXXConstructorDecl>(CurDecl))
3430 else if (isa<CXXDestructorDecl>(CurDecl))
3440 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3443 RetValExp = ER.
get();
3448 }
else if (!RetValExp && !HasDependentReturnType) {
3454 DiagID = diag::err_constexpr_return_missing_expr;
3456 }
else if (getLangOpts().
C99) {
3458 DiagID = diag::ext_return_missing_expr;
3461 DiagID = diag::warn_return_missing_expr;
3467 Diag(ReturnLoc, DiagID) << getCurMethodDecl()->getDeclName() << 1;
3471 assert(RetValExp || HasDependentReturnType);
3472 const VarDecl *NRVOCandidate =
nullptr;
3474 QualType RetType = RelatedRetType.
isNull() ? FnRetType : RelatedRetType;
3483 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
3488 NRVOCandidate !=
nullptr);
3489 ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate,
3490 RetType, RetValExp);
3501 if (!RelatedRetType.
isNull()) {
3504 Res = PerformCopyInitialization(Entity, ReturnLoc, RetValExp);
3512 CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc, isObjCMethod, Attrs,
3513 getCurFunctionDecl());
3517 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3520 RetValExp = ER.
get();
3528 FunctionScopes.back()->Returns.push_back(Result);
3530 if (FunctionScopes.back()->FirstReturnLoc.isInvalid())
3531 FunctionScopes.back()->FirstReturnLoc = ReturnLoc;
3540 VarDecl *Var = cast_or_null<VarDecl>(Parm);
3555 if (!getLangOpts().ObjCExceptions)
3556 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@try";
3558 getCurFunction()->setHasBranchProtectedScope();
3559 unsigned NumCatchStmts = CatchStmts.size();
3561 NumCatchStmts, Finally);
3570 Result = ActOnFinishFullExpr(Result.
get());
3573 Throw = Result.
get();
3581 return StmtError(
Diag(AtLoc, diag::err_objc_throw_expects_object)
3592 if (!getLangOpts().ObjCExceptions)
3593 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@throw";
3598 Scope *AtCatchParent = CurScope;
3600 AtCatchParent = AtCatchParent->
getParent();
3602 return StmtError(
Diag(AtLoc, diag::err_rethrow_used_outside_catch));
3604 return BuildObjCAtThrowStmt(AtLoc, Throw);
3609 ExprResult result = DefaultLvalueConversion(operand);
3612 operand = result.
get();
3620 if (getLangOpts().CPlusPlus) {
3621 if (RequireCompleteType(atLoc, type,
3622 diag::err_incomplete_receiver_type))
3623 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
3626 ExprResult result = PerformContextuallyConvertToObjCPointer(operand);
3630 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
3633 operand = result.
get();
3635 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
3642 return ActOnFinishFullExpr(operand);
3649 getCurFunction()->setHasBranchProtectedScope();
3657 Stmt *HandlerBlock) {
3660 CXXCatchStmt(CatchLoc, cast_or_null<VarDecl>(ExDecl), HandlerBlock);
3665 getCurFunction()->setHasBranchProtectedScope();
3670 class CatchHandlerType {
3672 unsigned IsPointer : 1;
3677 enum Unique { ForDenseMap };
3678 CatchHandlerType(
QualType QT, Unique) : QT(QT), IsPointer(
false) {}
3685 if (QT->isPointerType())
3688 if (IsPointer || QT->isReferenceType())
3689 QT = QT->getPointeeType();
3690 QT = QT.getUnqualifiedType();
3696 CatchHandlerType(
QualType QT,
bool IsPointer)
3697 : QT(QT), IsPointer(IsPointer) {}
3699 QualType underlying()
const {
return QT; }
3700 bool isPointer()
const {
return IsPointer; }
3702 friend bool operator==(
const CatchHandlerType &LHS,
3703 const CatchHandlerType &RHS) {
3705 if (LHS.IsPointer != RHS.IsPointer)
3708 return LHS.QT == RHS.QT;
3717 CatchHandlerType::ForDenseMap);
3722 CatchHandlerType::ForDenseMap);
3730 const CatchHandlerType &RHS) {
3737 class CatchTypePublicBases {
3739 const llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> &TypesToCheck;
3740 const bool CheckAgainstPointer;
3746 CatchTypePublicBases(
3748 const llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> &T,
bool C)
3749 : Ctx(Ctx), TypesToCheck(T), CheckAgainstPointer(C),
3750 FoundHandler(nullptr) {}
3752 CXXCatchStmt *getFoundHandler()
const {
return FoundHandler; }
3753 CanQualType getFoundHandlerType()
const {
return FoundHandlerType; }
3757 CatchHandlerType Check(S->
getType(), CheckAgainstPointer);
3758 const auto &M = TypesToCheck;
3759 auto I = M.find(Check);
3761 FoundHandler =
I->second;
3762 FoundHandlerType = Ctx.getCanonicalType(S->
getType());
3776 if (!getLangOpts().CXXExceptions &&
3777 !getSourceManager().isInSystemHeader(TryLoc))
3778 Diag(TryLoc, diag::err_exceptions_disabled) <<
"try";
3781 if (getLangOpts().CUDA)
3782 CUDADiagIfDeviceCode(TryLoc, diag::err_cuda_device_exceptions)
3783 <<
"try" << CurrentCUDATarget();
3785 if (getCurScope() && getCurScope()->isOpenMPSimdDirectiveScope())
3786 Diag(TryLoc, diag::err_omp_simd_region_cannot_use_stmt) <<
"try";
3792 Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
3796 const unsigned NumHandlers = Handlers.size();
3797 assert(!Handlers.empty() &&
3798 "The parser shouldn't call this if there are no handlers.");
3800 llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> HandledTypes;
3801 for (
unsigned i = 0; i < NumHandlers; ++i) {
3808 if (i < NumHandlers - 1)
3817 CatchHandlerType HandlerCHT =
3823 QualType Underlying = HandlerCHT.underlying();
3825 if (!RD->hasDefinition())
3834 CatchTypePublicBases CTPB(
Context, HandledTypes, HandlerCHT.isPointer());
3835 if (RD->lookupInBases(CTPB, Paths)) {
3837 if (!Paths.
isAmbiguous(CTPB.getFoundHandlerType())) {
3839 diag::warn_exception_caught_by_earlier_handler)
3842 diag::note_previous_exception_handler)
3850 auto R = HandledTypes.insert(std::make_pair(H->
getCaughtType(), H));
3854 diag::warn_exception_caught_by_earlier_handler)
3857 diag::note_previous_exception_handler)
3869 assert(TryBlock && Handler);
3875 if (!getLangOpts().Borland) {
3877 Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
3893 Diag(TryLoc, diag::err_seh_try_outside_functions);
3897 Diag(TryLoc, diag::err_seh_try_unsupported);
3906 assert(FilterExpr && Block);
3910 diag::err_filter_expression_integral)
3918 CurrentSEHFinally.push_back(CurScope);
3922 CurrentSEHFinally.pop_back();
3927 CurrentSEHFinally.pop_back();
3933 Scope *SEHTryParent = CurScope;
3935 SEHTryParent = SEHTryParent->
getParent();
3937 return StmtError(
Diag(Loc, diag::err_ms___leave_not_in___try));
3950 QualifierLoc, NameInfo,
3951 cast<CompoundStmt>(Nested));
3960 return BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
3962 GetNameFromUnqualifiedId(Name),
3968 unsigned NumParams) {
3985 assert(NumParams > 0 &&
"CapturedStmt requires context parameter");
3997 for (CaptureIter Cap = Candidates.begin(); Cap != Candidates.end(); ++Cap) {
3999 if (Cap->isThisCapture()) {
4002 CaptureInits.push_back(Cap->getInitExpr());
4004 }
else if (Cap->isVLATypeCapture()) {
4007 CaptureInits.push_back(
nullptr);
4012 Cap->isReferenceCapture()
4015 Cap->getVariable()));
4016 CaptureInits.push_back(Cap->getInitExpr());
4022 unsigned NumParams) {
4024 RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, NumParams);
4038 PushCapturedRegionScope(CurScope, CD, RD, Kind);
4041 PushDeclContext(CurScope, CD);
4045 PushExpressionEvaluationContext(
4046 ExpressionEvaluationContext::PotentiallyEvaluated);
4053 RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, Params.size());
4057 bool ContextIsFound =
false;
4058 unsigned ParamNum = 0;
4061 I !=
E; ++
I, ++ParamNum) {
4062 if (
I->second.isNull()) {
4063 assert(!ContextIsFound &&
4064 "null type has been found already for '__context' parameter");
4072 ContextIsFound =
true;
4082 assert(ContextIsFound &&
"no null type for '__context' parameter");
4083 if (!ContextIsFound) {
4094 PushCapturedRegionScope(CurScope, CD, RD, Kind);
4097 PushDeclContext(CurScope, CD);
4101 PushExpressionEvaluationContext(
4102 ExpressionEvaluationContext::PotentiallyEvaluated);
4106 DiscardCleanupsInEvaluationContext();
4107 PopExpressionEvaluationContext();
4114 ActOnFields(
nullptr, Record->
getLocation(), Record, Fields,
4118 PopFunctionScopeInfo();
4132 getASTContext(), S, static_cast<CapturedRegionKind>(RSI->
CapRegionKind),
4133 Captures, CaptureInits, CD, RD);
4138 DiscardCleanupsInEvaluationContext();
4139 PopExpressionEvaluationContext();
4142 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
void setImplicit(bool I=true)
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.
Scope * getCurScope() const
Retrieve the parser's current scope.
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.
Stmt - This represents one statement.
FunctionType - C99 6.7.5.3 - Function Declarators.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
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.
Decl - This represents one declaration (or definition), e.g.
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 ...
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.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
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.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
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...
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.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
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.
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...
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
Parameter for C++ virtual table pointers.
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.
const DeclStmt * getConditionVariableDeclStmt() const
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
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...
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
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 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)
SourceLocation getLocEnd() const LLVM_READONLY
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...
bool isClosedNonFlag() const
Returns true if this enum is annotated with neither flag_enum nor enum_extensibility(open).
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)
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
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.
void setLocation(SourceLocation L)
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.
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...
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
Source range that this declaration covers.
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.
const Stmt * getBody() const
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
void ActOnCapturedRegionError()
void addNRVOCandidate(VarDecl *VD)
bool isInvalidDecl() const
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 ...
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
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>'.
Represents Objective-C's collection statement.
ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)
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...
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
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.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
DeclStmt * getRangeStmt()
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...
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.
static bool EqEnumVals(const std::pair< llvm::APSInt, EnumConstantDecl * > &lhs, const std::pair< llvm::APSInt, EnumConstantDecl * > &rhs)
EqEnumVals - Comparison preficate for uniqing enumeration values.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
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...
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.
SourceLocation getLocation() const
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.
DeclStmt * getBeginStmt()
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Describes an entity that is being initialized.
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 ':'.
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)
bool isClosed() const
Returns true if this enum is either annotated with enum_extensibility(closed) or isn't annotated with...
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...