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"
40 using namespace clang;
62 DiscardCleanupsInEvaluationContext();
67 bool HasLeadingEmptyMacro) {
108 if (getLangOpts().ObjCAutoRefCount) {
129 bool IsNotEqual, CanAssign, IsRelational;
132 if (!Op->isComparisonOp())
135 IsRelational = Op->isRelationalOp();
136 Loc = Op->getOperatorLoc();
137 IsNotEqual = Op->getOpcode() ==
BO_NE;
138 CanAssign = Op->getLHS()->IgnoreParenImpCasts()->isLValue();
140 switch (Op->getOperator()) {
144 case OO_ExclaimEqual:
145 IsRelational =
false;
149 case OO_GreaterEqual:
155 Loc = Op->getOperatorLoc();
156 IsNotEqual = Op->getOperator() == OO_ExclaimEqual;
157 CanAssign = Op->getArg(0)->IgnoreParenImpCasts()->isLValue();
168 S.
Diag(Loc, diag::warn_unused_comparison)
169 << (
unsigned)IsRelational << (
unsigned)IsNotEqual << E->getSourceRange();
173 if (!IsRelational && CanAssign) {
175 S.
Diag(Loc, diag::note_inequality_comparison_to_or_assign)
178 S.
Diag(Loc, diag::note_equality_comparison_to_assign)
186 if (
const LabelStmt *Label = dyn_cast_or_null<LabelStmt>(S))
187 return DiagnoseUnusedExprResult(Label->getSubStmt());
189 const Expr *
E = dyn_cast_or_null<Expr>(
S);
195 if (isUnevaluatedContext())
204 bool ShouldSuppress =
208 const Expr *WarnExpr;
211 if (!E->isUnusedResultAWarning(WarnExpr, Loc, R1, R2,
Context))
224 if (isa<ParenExpr>(E->IgnoreImpCasts()) && Loc.
isMacroID()) {
226 if (findMacroSpelling(SpellLoc,
"UNREFERENCED_PARAMETER"))
233 unsigned DiagID = diag::warn_unused_expr;
235 E = Temps->getSubExpr();
237 E = TempExpr->getSubExpr();
243 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
244 if (E->getType()->isVoidType())
251 if (
const Decl *FD = CE->getCalleeDecl()) {
254 : FD->hasAttr<WarnUnusedResultAttr>()) {
255 Diag(Loc, diag::warn_unused_result) << R1 << R2;
260 if (FD->hasAttr<PureAttr>()) {
261 Diag(Loc, diag::warn_unused_call) << R1 << R2 <<
"pure";
264 if (FD->hasAttr<ConstAttr>()) {
265 Diag(Loc, diag::warn_unused_call) << R1 << R2 <<
"const";
269 }
else if (ShouldSuppress)
273 if (getLangOpts().ObjCAutoRefCount && ME->isDelegateInitCall()) {
274 Diag(Loc, diag::err_arc_unused_init_message) << R1;
279 if (MD->
hasAttr<WarnUnusedResultAttr>()) {
280 Diag(Loc, diag::warn_unused_result) << R1 << R2;
285 const Expr *Source = POE->getSyntacticForm();
286 if (isa<ObjCSubscriptRefExpr>(Source))
287 DiagID = diag::warn_unused_container_subscript_expr;
289 DiagID = diag::warn_unused_property_expr;
291 = dyn_cast<CXXFunctionalCastExpr>(E)) {
292 if (isa<CXXConstructExpr>(FC->getSubExpr()) ||
293 isa<CXXTemporaryObjectExpr>(FC->getSubExpr()))
297 else if (
const CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(E)) {
305 Diag(Loc, diag::warn_unused_voidptr)
311 if (E->isGLValue() && E->getType().isVolatileQualified()) {
312 Diag(Loc, diag::warn_unused_volatile) << R1 << R2;
316 DiagRuntimeBehavior(Loc,
nullptr, PDiag(DiagID) << R1 << R2);
328 return getCurFunction()->CompoundScopes.back();
333 const unsigned NumElts = Elts.size();
341 for (; i != NumElts && isa<DeclStmt>(Elts[i]); ++i)
345 for (; i != NumElts && !isa<DeclStmt>(Elts[i]); ++i)
349 Decl *D = *cast<DeclStmt>(Elts[i])->decl_begin();
354 for (
unsigned i = 0; i != NumElts; ++i) {
356 if (isStmtExpr && i == NumElts - 1)
359 DiagnoseUnusedExprResult(Elts[i]);
365 if (NumElts != 0 && !CurrentInstantiationScope &&
366 getCurCompoundScope().HasEmptyLoopBodies) {
367 for (
unsigned i = 0; i != NumElts - 1; ++i)
368 DiagnoseEmptyLoopBody(Elts[i], Elts[i + 1]);
378 assert(LHSVal &&
"missing expression in case statement");
380 if (getCurFunction()->SwitchStack.empty()) {
381 Diag(CaseLoc, diag::err_case_not_in_switch);
386 CorrectDelayedTyposInExpr(LHSVal, [
this](
class Expr *
E) {
388 return VerifyIntegerConstantExpression(E);
390 getCurFunction()->SwitchStack.back()->getCond()) {
391 QualType CondType = CondExpr->getType();
392 llvm::APSInt TempVal;
406 LHSVal = VerifyIntegerConstantExpression(LHSVal).get();
414 RHSVal = VerifyIntegerConstantExpression(RHSVal).get();
419 LHS = ActOnFinishFullExpr(LHSVal, LHSVal->
getExprLoc(),
false,
420 getLangOpts().CPlusPlus11);
424 auto RHS = RHSVal ? ActOnFinishFullExpr(RHSVal, RHSVal->
getExprLoc(),
false,
425 getLangOpts().CPlusPlus11)
432 getCurFunction()->SwitchStack.back()->addSwitchCase(CS);
438 DiagnoseUnusedExprResult(SubStmt);
447 DiagnoseUnusedExprResult(SubStmt);
449 if (getCurFunction()->SwitchStack.empty()) {
450 Diag(DefaultLoc, diag::err_default_not_in_switch);
455 getCurFunction()->SwitchStack.back()->addSwitchCase(DS);
464 Diag(IdentLoc, diag::err_redefinition_of_label) << TheDecl->
getDeclName();
497 VarDecl *ConditionVar =
nullptr;
499 ConditionVar = cast<VarDecl>(CondVar);
500 CondResult = CheckConditionVariable(ConditionVar, IfLoc,
true);
501 CondResult = ActOnFinishFullExpr(CondResult.get(), IfLoc);
503 Expr *ConditionExpr = CondResult.getAs<
Expr>();
505 DiagnoseUnusedExprResult(thenStmt);
508 DiagnoseEmptyStmtBody(ConditionExpr->getLocEnd(), thenStmt,
509 diag::warn_empty_if_body);
512 DiagnoseUnusedExprResult(elseStmt);
520 thenStmt, ElseLoc, elseStmt);
524 struct CaseCompareFunctor {
525 bool operator()(
const std::pair<llvm::APSInt, CaseStmt*> &LHS,
526 const llvm::APSInt &RHS) {
527 return LHS.first < RHS;
529 bool operator()(
const std::pair<llvm::APSInt, CaseStmt*> &LHS,
530 const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
531 return LHS.first < RHS.first;
533 bool operator()(
const llvm::APSInt &LHS,
534 const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
535 return LHS < RHS.first;
542 static bool CmpCaseVals(
const std::pair<llvm::APSInt, CaseStmt*>& lhs,
543 const std::pair<llvm::APSInt, CaseStmt*>& rhs) {
544 if (lhs.first < rhs.first)
547 if (lhs.first == rhs.first &&
548 lhs.second->getCaseLoc().getRawEncoding()
549 < rhs.second->getCaseLoc().getRawEncoding())
556 static bool CmpEnumVals(
const std::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
557 const std::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
559 return lhs.first < rhs.first;
564 static bool EqEnumVals(
const std::pair<llvm::APSInt, EnumConstantDecl*>& lhs,
565 const std::pair<llvm::APSInt, EnumConstantDecl*>& rhs)
567 return lhs.first == rhs.first;
574 expr = cleanups->getSubExpr();
577 expr = impcast->getSubExpr();
587 VarDecl *ConditionVar =
nullptr;
589 ConditionVar = cast<VarDecl>(CondVar);
590 CondResult = CheckConditionVariable(ConditionVar,
SourceLocation(),
false);
591 if (CondResult.isInvalid())
594 Cond = CondResult.get();
604 SwitchConvertDiagnoser(
Expr *Cond)
610 return S.
Diag(Loc, diag::err_typecheck_statement_requires_integer) << T;
615 return S.
Diag(Loc, diag::err_switch_incomplete_class_type)
616 << T << Cond->getSourceRange();
621 return S.
Diag(Loc, diag::err_switch_explicit_conversion) << T << ConvTy;
632 return S.
Diag(Loc, diag::err_switch_multiple_conversions) << T;
643 llvm_unreachable(
"conversion functions are permitted");
645 } SwitchDiagnoser(Cond);
648 PerformContextualImplicitConversion(SwitchLoc, Cond, SwitchDiagnoser);
650 Cond = CondResult.
get();
653 CondResult = UsualUnaryConversions(Cond);
655 Cond = CondResult.
get();
657 CondResult = ActOnFinishFullExpr(Cond, SwitchLoc);
660 Cond = CondResult.
get();
662 getCurFunction()->setHasBranchIntoScope();
665 getCurFunction()->SwitchStack.push_back(SS);
669 static void AdjustAPSInt(llvm::APSInt &Val,
unsigned BitWidth,
bool IsSigned) {
670 Val = Val.extOrTrunc(BitWidth);
671 Val.setIsSigned(IsSigned);
677 unsigned UnpromotedWidth,
bool UnpromotedSign) {
681 if (UnpromotedWidth < Val.getBitWidth()) {
682 llvm::APSInt ConvVal(Val);
684 AdjustAPSInt(ConvVal, Val.getBitWidth(), Val.isSigned());
689 S.
Diag(Loc, diag::warn_case_value_overflow) << Val.toString(10)
690 << ConvVal.toString(10);
700 const Expr *CaseExpr,
703 const llvm::APSInt &Val) {
706 if (
const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
715 if (ED->
hasAttr<FlagEnumAttr>()) {
718 while (EI != EIEnd && EI->first < Val)
721 if (EI != EIEnd && EI->first == Val)
732 assert(SS == getCurFunction()->SwitchStack.back() &&
733 "switch stack missing push/pop!");
735 getCurFunction()->SwitchStack.pop_back();
738 SS->
setBody(BodyStmt, SwitchLoc);
745 Expr *CondExprBeforePromotion = CondExpr;
767 Diag(SwitchLoc, diag::warn_bool_switch_condition)
768 << CondExpr->getSourceRange();
774 bool HasDependentValue
783 unsigned CondWidthBeforePromotion
785 bool CondIsSignedBeforePromotion
795 typedef std::vector<std::pair<llvm::APSInt, CaseStmt*> > CaseRangesTy;
796 CaseRangesTy CaseRanges;
800 bool CaseListIsErroneous =
false;
806 if (TheDefaultStmt) {
807 Diag(DS->getDefaultLoc(), diag::err_multiple_default_labels_defined);
814 CaseListIsErroneous =
true;
823 if (Lo->isTypeDependent() || Lo->isValueDependent()) {
824 HasDependentValue =
true;
830 if (getLangOpts().CPlusPlus11) {
836 CaseListIsErroneous =
true;
847 Lo = DefaultLvalueConversion(Lo).get();
854 CondWidthBeforePromotion, CondIsSignedBeforePromotion);
865 HasDependentValue =
true;
868 CaseRanges.push_back(std::make_pair(LoVal, CS));
870 CaseVals.push_back(std::make_pair(LoVal, CS));
874 if (!HasDependentValue) {
877 llvm::APSInt ConstantCondValue;
878 bool HasConstantCond =
false;
879 if (!HasDependentValue && !TheDefaultStmt) {
882 assert(!HasConstantCond ||
883 (ConstantCondValue.getBitWidth() == CondWidth &&
884 ConstantCondValue.isSigned() == CondIsSigned));
886 bool ShouldCheckConstantCond = HasConstantCond;
889 std::stable_sort(CaseVals.begin(), CaseVals.end(),
CmpCaseVals);
891 if (!CaseVals.empty()) {
892 for (
unsigned i = 0, e = CaseVals.size(); i != e; ++i) {
893 if (ShouldCheckConstantCond &&
894 CaseVals[i].first == ConstantCondValue)
895 ShouldCheckConstantCond =
false;
897 if (i != 0 && CaseVals[i].first == CaseVals[i-1].first) {
900 StringRef PrevString, CurrString;
903 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(PrevCase)) {
904 PrevString = DeclRef->getDecl()->getName();
906 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(CurrCase)) {
907 CurrString = DeclRef->getDecl()->getName();
910 CaseVals[i-1].first.toString(CaseValStr);
912 if (PrevString == CurrString)
913 Diag(CaseVals[i].second->getLHS()->getLocStart(),
914 diag::err_duplicate_case) <<
915 (PrevString.empty() ? StringRef(CaseValStr) : PrevString);
917 Diag(CaseVals[i].second->getLHS()->getLocStart(),
918 diag::err_duplicate_case_differing_expr) <<
919 (PrevString.empty() ? StringRef(CaseValStr) : PrevString) <<
920 (CurrString.empty() ? StringRef(CaseValStr) : CurrString) <<
923 Diag(CaseVals[i-1].second->getLHS()->getLocStart(),
924 diag::note_duplicate_case_prev);
927 CaseListIsErroneous =
true;
934 if (!CaseRanges.empty()) {
937 std::stable_sort(CaseRanges.begin(), CaseRanges.end());
940 std::vector<llvm::APSInt> HiVals;
941 for (
unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
942 llvm::APSInt &LoVal = CaseRanges[i].first;
943 CaseStmt *CR = CaseRanges[i].second;
954 CaseListIsErroneous =
true;
963 Hi = DefaultLvalueConversion(Hi).get();
970 CondWidthBeforePromotion, CondIsSignedBeforePromotion);
979 Diag(CR->
getLHS()->getLocStart(), diag::warn_case_empty_range)
982 CaseRanges.erase(CaseRanges.begin()+i);
987 if (ShouldCheckConstantCond &&
988 LoVal <= ConstantCondValue &&
989 ConstantCondValue <= HiVal)
990 ShouldCheckConstantCond =
false;
992 HiVals.push_back(HiVal);
998 for (
unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
999 llvm::APSInt &CRLo = CaseRanges[i].first;
1000 llvm::APSInt &CRHi = HiVals[i];
1001 CaseStmt *CR = CaseRanges[i].second;
1006 llvm::APSInt OverlapVal(32);
1011 CaseVals.end(), CRLo,
1012 CaseCompareFunctor());
1013 if (I != CaseVals.end() && I->first < CRHi) {
1014 OverlapVal = I->first;
1015 OverlapStmt = I->second;
1019 I = std::upper_bound(I, CaseVals.end(), CRHi, CaseCompareFunctor());
1020 if (I != CaseVals.begin() && (I-1)->first >= CRLo) {
1021 OverlapVal = (I-1)->first;
1022 OverlapStmt = (I-1)->second;
1027 if (i && CRLo <= HiVals[i-1]) {
1028 OverlapVal = HiVals[i-1];
1029 OverlapStmt = CaseRanges[i-1].second;
1034 Diag(CR->
getLHS()->getLocStart(), diag::err_duplicate_case)
1035 << OverlapVal.toString(10);
1037 diag::note_duplicate_case_prev);
1040 CaseListIsErroneous =
true;
1046 if (!CaseListIsErroneous && ShouldCheckConstantCond) {
1049 Diag(CondExpr->
getExprLoc(), diag::warn_missing_case_for_condition)
1050 << ConstantCondValue.toString(10)
1051 << CondExpr->getSourceRange();
1062 if (!CaseListIsErroneous && !HasConstantCond && ET) {
1069 llvm::APSInt Val = EDI->getInitVal();
1071 EnumVals.push_back(std::make_pair(Val, EDI));
1073 std::stable_sort(EnumVals.begin(), EnumVals.end(),
CmpEnumVals);
1074 auto EI = EnumVals.begin(), EIEnd =
1075 std::unique(EnumVals.begin(), EnumVals.end(),
EqEnumVals);
1078 for (CaseValsTy::const_iterator CI = CaseVals.begin();
1079 CI != CaseVals.end(); CI++) {
1080 Expr *CaseExpr = CI->second->getLHS();
1084 << CondTypeBeforePromotion;
1088 EI = EnumVals.begin();
1089 for (CaseRangesTy::const_iterator RI = CaseRanges.begin();
1090 RI != CaseRanges.end(); RI++) {
1091 Expr *CaseExpr = RI->second->getLHS();
1095 << CondTypeBeforePromotion;
1098 RI->second->getRHS()->EvaluateKnownConstInt(
Context);
1101 CaseExpr = RI->second->getRHS();
1105 << CondTypeBeforePromotion;
1109 auto CI = CaseVals.begin();
1110 auto RI = CaseRanges.begin();
1111 bool hasCasesNotInSwitch =
false;
1115 for (EI = EnumVals.begin(); EI != EIEnd; EI++){
1117 while (CI != CaseVals.end() && CI->first < EI->first)
1120 if (CI != CaseVals.end() && CI->first == EI->first)
1124 for (; RI != CaseRanges.end(); RI++) {
1126 RI->second->getRHS()->EvaluateKnownConstInt(
Context);
1128 if (EI->first <= Hi)
1132 if (RI == CaseRanges.end() || EI->first < RI->first) {
1133 hasCasesNotInSwitch =
true;
1134 UnhandledNames.push_back(EI->second->getDeclName());
1138 if (TheDefaultStmt && UnhandledNames.empty())
1142 if (!UnhandledNames.empty()) {
1144 TheDefaultStmt ? diag::warn_def_missing_case
1145 : diag::warn_missing_case)
1146 << (
int)UnhandledNames.size();
1148 for (
size_t I = 0,
E = std::min(UnhandledNames.size(), (
size_t)3);
1150 DB << UnhandledNames[
I];
1153 if (!hasCasesNotInSwitch)
1159 DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), BodyStmt,
1160 diag::warn_empty_switch_body);
1164 if (CaseListIsErroneous)
1173 if (Diags.isIgnored(diag::warn_not_in_enum_assignment, SrcExpr->
getExprLoc()))
1187 const EnumDecl *ED = ET->getDecl();
1189 if (ED->
hasAttr<FlagEnumAttr>()) {
1190 if (!IsValueInFlagEnum(ED, RhsVal,
true))
1196 EnumValsTy EnumVals;
1201 llvm::APSInt Val = EDI->getInitVal();
1203 EnumVals.push_back(std::make_pair(Val, EDI));
1205 if (EnumVals.empty())
1207 std::stable_sort(EnumVals.begin(), EnumVals.end(),
CmpEnumVals);
1209 std::unique(EnumVals.begin(), EnumVals.end(),
EqEnumVals);
1212 EnumValsTy::const_iterator EI = EnumVals.begin();
1213 while (EI != EIend && EI->first < RhsVal)
1215 if (EI == EIend || EI->first != RhsVal) {
1229 VarDecl *ConditionVar =
nullptr;
1231 ConditionVar = cast<VarDecl>(CondVar);
1232 CondResult = CheckConditionVariable(ConditionVar, WhileLoc,
true);
1233 CondResult = ActOnFinishFullExpr(CondResult.get(), WhileLoc);
1234 if (CondResult.isInvalid())
1237 Expr *ConditionExpr = CondResult.get();
1240 CheckBreakContinueBinding(ConditionExpr);
1242 DiagnoseUnusedExprResult(Body);
1244 if (isa<NullStmt>(Body))
1245 getCurCompoundScope().setHasEmptyLoopBodies();
1255 assert(Cond &&
"ActOnDoStmt(): missing expression");
1257 CheckBreakContinueBinding(Cond);
1258 ExprResult CondResult = CheckBooleanCondition(Cond, DoLoc);
1261 Cond = CondResult.
get();
1263 CondResult = ActOnFinishFullExpr(Cond, DoLoc);
1266 Cond = CondResult.
get();
1268 DiagnoseUnusedExprResult(Body);
1270 return new (
Context)
DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen);
1278 llvm::SmallPtrSetImpl<VarDecl*> &Decls;
1284 DeclExtractor(
Sema &
S, llvm::SmallPtrSetImpl<VarDecl*> &Decls,
1291 bool isSimple() {
return Simple; }
1299 void VisitStmt(
Stmt *
S) {
1346 Ranges.push_back(E->getSourceRange());
1356 llvm::SmallPtrSetImpl<VarDecl*> &Decls;
1362 DeclMatcher(
Sema &
S, llvm::SmallPtrSetImpl<VarDecl*> &Decls,
1365 if (!Statement)
return;
1389 void CheckLValueToRValueCast(
Expr *E) {
1392 if (isa<DeclRefExpr>(E)) {
1397 Visit(CO->getCond());
1398 CheckLValueToRValueCast(CO->getTrueExpr());
1399 CheckLValueToRValueCast(CO->getFalseExpr());
1404 dyn_cast<BinaryConditionalOperator>(E)) {
1405 CheckLValueToRValueCast(BCO->getOpaqueValue()->getSourceExpr());
1406 CheckLValueToRValueCast(BCO->getFalseExpr());
1415 if (Decls.count(VD))
1419 bool FoundDeclInUse() {
return FoundDecl; }
1423 void CheckForLoopConditionalStatement(
Sema &S,
Expr *Second,
1426 if (!Second)
return;
1429 Second->getLocStart()))
1433 llvm::SmallPtrSet<VarDecl*, 8> Decls;
1435 DeclExtractor DE(S, Decls, Ranges);
1439 if (!DE.isSimple())
return;
1442 if (Decls.size() == 0)
return;
1448 if ((*I)->getType().isVolatileQualified() ||
1449 (*I)->hasGlobalStorage())
return;
1451 if (DeclMatcher(S, Decls, Second).FoundDeclInUse() ||
1452 DeclMatcher(S, Decls, Third).FoundDeclInUse() ||
1453 DeclMatcher(S, Decls, Body).FoundDeclInUse())
1457 if (Decls.size() > 4)
1460 PDiag << Decls.size();
1464 PDiag << (*I)->getDeclName();
1475 PDiag << Second->getSourceRange();
1477 S.
Diag(Ranges.begin()->getBegin(), PDiag);
1482 bool ProcessIterationStmt(
Sema &S,
Stmt* Statement,
bool &Increment,
1484 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(Statement)) {
1485 switch (UO->getOpcode()) {
1486 default:
return false;
1504 default:
return false;
1525 BreakContinueFinder(
Sema &S,
Stmt* Body) :
1540 bool ContinueFound() {
return ContinueLoc.
isValid(); }
1541 bool BreakFound() {
return BreakLoc.isValid(); }
1552 void CheckForRedundantIteration(
Sema &S,
Expr *Third,
Stmt *Body) {
1554 if (!Body || !Third)
return;
1557 Third->getLocStart()))
1564 if (!LastStmt)
return;
1566 bool LoopIncrement, LastIncrement;
1569 if (!ProcessIterationStmt(S, Third, LoopIncrement, LoopDRE))
return;
1570 if (!ProcessIterationStmt(S, LastStmt, LastIncrement, LastDRE))
return;
1574 if (LoopIncrement != LastIncrement ||
1577 if (BreakContinueFinder(S, Body).ContinueFound())
return;
1580 << LastDRE->
getDecl() << LastIncrement;
1588 void Sema::CheckBreakContinueBinding(
Expr *E) {
1591 BreakContinueFinder BCFinder(*
this, E);
1593 if (BCFinder.BreakFound() && BreakParent) {
1595 Diag(BCFinder.GetBreakLoc(), diag::warn_break_binds_to_switch);
1597 Diag(BCFinder.GetBreakLoc(), diag::warn_loop_ctrl_binds_to_inner)
1600 }
else if (BCFinder.ContinueFound() && CurScope->getContinueParent()) {
1601 Diag(BCFinder.GetContinueLoc(), diag::warn_loop_ctrl_binds_to_inner)
1612 if (
DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
1616 for (
auto *DI : DS->decls()) {
1621 Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
1622 DI->setInvalidDecl();
1628 CheckBreakContinueBinding(second.
get());
1629 CheckBreakContinueBinding(third.
get());
1631 CheckForLoopConditionalStatement(*
this, second.
get(), third.
get(), Body);
1632 CheckForRedundantIteration(*
this, third.
get(), Body);
1635 VarDecl *ConditionVar =
nullptr;
1637 ConditionVar = cast<VarDecl>(secondVar);
1638 SecondResult = CheckConditionVariable(ConditionVar, ForLoc,
true);
1639 SecondResult = ActOnFinishFullExpr(SecondResult.get(), ForLoc);
1640 if (SecondResult.isInvalid())
1646 DiagnoseUnusedExprResult(First);
1647 DiagnoseUnusedExprResult(Third);
1648 DiagnoseUnusedExprResult(Body);
1650 if (isa<NullStmt>(Body))
1651 getCurCompoundScope().setHasEmptyLoopBodies();
1654 Third, Body, ForLoc, LParenLoc, RParenLoc);
1668 ExprResult FullExpr = ActOnFinishFullExpr(E);
1679 ExprResult result = CorrectDelayedTyposInExpr(collection);
1682 collection = result.
get();
1688 result = DefaultFunctionArrayLvalueConversion(collection);
1691 collection = result.
get();
1698 return Diag(forLoc, diag::err_collection_expr_type)
1699 << collection->
getType() << collection->getSourceRange();
1709 (getLangOpts().ObjCAutoRefCount
1710 ? RequireCompleteType(forLoc,
QualType(objectType, 0),
1711 diag::err_arc_collection_forward, collection)
1712 : !isCompleteType(forLoc,
QualType(objectType, 0)))) {
1715 }
else if (iface || !objectType->
qual_empty()) {
1733 method = LookupMethodInQualifiedType(selector, pointerType,
1738 Diag(forLoc, diag::warn_collection_expr_type)
1739 << collection->
getType() << selector << collection->getSourceRange();
1755 CheckObjCForCollectionOperand(ForLoc, collection);
1759 if (
DeclStmt *DS = dyn_cast<DeclStmt>(First)) {
1760 if (!DS->isSingleDecl())
1762 diag::err_toomany_element_decls));
1774 diag::err_non_local_variable_decl_in_for));
1780 Expr *DeducedInit = &OpaqueId;
1783 DiagnoseAutoDeductionFailure(D, DeducedInit);
1784 if (FirstType.
isNull()) {
1791 if (ActiveTemplateInstantiations.empty()) {
1794 Diag(Loc, diag::warn_auto_var_is_id)
1800 Expr *FirstE = cast<Expr>(First);
1803 diag::err_selector_element_not_lvalue)
1804 << First->getSourceRange());
1806 FirstType =
static_cast<Expr*
>(First)->getType();
1808 Diag(ForLoc, diag::err_selector_element_const_type)
1809 << FirstType << First->getSourceRange();
1814 return StmtError(
Diag(ForLoc, diag::err_selector_element_type)
1815 << FirstType << First->getSourceRange());
1821 CollectionExprResult = ActOnFinishFullExpr(CollectionExprResult.
get());
1826 nullptr, ForLoc, RParenLoc);
1881 void NoteForRangeBeginEndFunction(
Sema &SemaRef,
Expr *E,
1891 std::string Description;
1892 bool IsTemplate =
false;
1899 SemaRef.
Diag(Loc, diag::note_for_range_begin_end)
1900 << BEF << IsTemplate << Description << E->
getType();
1949 return ActOnObjCForCollectionStmt(ForLoc, First, Range, RParenLoc);
1952 assert(DS &&
"first part of for range not a decl stmt");
1961 DiagnoseUnexpandedParameterPack(Range, UPPC_Expression)) {
1968 ExprResult Coawait = ActOnCoawaitExpr(S, CoawaitLoc, Range);
1970 Range = Coawait.
get();
1975 VarDecl *RangeVar = BuildForRangeVarDecl(*
this, RangeLoc,
1979 diag::err_for_range_deduction_failure)) {
1988 StmtResult RangeDecl = ActOnDeclStmt(RangeGroup, RangeLoc, RangeLoc);
1994 return BuildCXXForRangeStmt(ForLoc, CoawaitLoc, ColonLoc, RangeDecl.
get(),
1996 nullptr, DS, RParenLoc,
Kind);
2036 if (BeginMemberLookup.empty() != EndMemberLookup.
empty()) {
2038 *BEF = BeginMemberLookup.empty() ? BEF_end : BEF_begin;
2040 SemaRef.
Diag(RangeLoc, diag::err_for_range_member_begin_end_mismatch)
2041 << RangeLoc << BeginRange->
getType() << *BEF;
2055 BeginMemberLookup, CandidateSet,
2056 BeginRange, BeginExpr);
2060 SemaRef.
Diag(BeginRange->getLocStart(), diag::note_in_for_range)
2061 << ColonLoc << BEF_begin << BeginRange->
getType();
2065 diag::err_for_range_iter_deduction_failure)) {
2066 NoteForRangeBeginEndFunction(SemaRef, BeginExpr->
get(), *BEF);
2073 EndMemberLookup, CandidateSet,
2077 SemaRef.
Diag(EndRange->getLocStart(), diag::note_in_for_range)
2078 << ColonLoc << BEF_end << EndRange->
getType();
2082 diag::err_for_range_iter_deduction_failure)) {
2083 NoteForRangeBeginEndFunction(SemaRef, EndExpr->
get(), *BEF);
2111 S, ForLoc, CoawaitLoc, LoopVarDecl, ColonLoc, AdjustedRange.
get(),
2120 SemaRef.
Diag(RangeLoc, diag::err_for_range_dereference)
2123 ColonLoc, AdjustedRange.
get(), RParenLoc,
2129 struct InvalidateOnErrorScope {
2130 InvalidateOnErrorScope(
Sema &SemaRef,
Decl *D,
bool Enabled)
2131 : Trap(SemaRef.Diags), D(D), Enabled(Enabled) {}
2132 ~InvalidateOnErrorScope() {
2133 if (Enabled && Trap.hasErrorOccurred())
2159 Scope *S = getCurScope();
2161 DeclStmt *RangeDS = cast<DeclStmt>(RangeDecl);
2163 QualType RangeVarType = RangeVar->getType();
2165 DeclStmt *LoopVarDS = cast<DeclStmt>(LoopVarDecl);
2170 InvalidateOnErrorScope Invalidate(*
this, LoopVar,
2171 LoopVar->getType()->isUndeducedType());
2176 if (RangeVarType->isDependentType()) {
2182 if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check)
2184 }
else if (!BeginEndDecl.get()) {
2189 ExprResult BeginRangeRef = BuildDeclRefExpr(RangeVar, RangeVarNonRefType,
2194 ExprResult EndRangeRef = BuildDeclRefExpr(RangeVar, RangeVarNonRefType,
2200 Expr *Range = RangeVar->getInit();
2205 if (RequireCompleteType(RangeLoc, RangeType,
2206 diag::err_for_range_incomplete_type))
2210 VarDecl *BeginVar = BuildForRangeVarDecl(*
this, ColonLoc, AutoType,
2212 VarDecl *EndVar = BuildForRangeVarDecl(*
this, ColonLoc, AutoType,
2224 BeginExpr = BeginRangeRef;
2226 diag::err_for_range_iter_deduction_failure)) {
2227 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2237 dyn_cast<VariableArrayType>(UnqAT))
2238 BoundExpr = VAT->getSizeExpr();
2242 llvm_unreachable(
"Unexpected array type in for-range");
2246 EndExpr = ActOnBinOp(S, ColonLoc, tok::plus, EndRangeRef.
get(),
2251 diag::err_for_range_iter_deduction_failure)) {
2252 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2261 EndRangeRef.
get(), RangeType,
2262 BeginVar, EndVar,
ColonLoc, &CandidateSet,
2263 &BeginExpr, &EndExpr, &BEFFailure);
2265 if (Kind == BFRK_Build && RangeStatus == FRS_NoViableFunction &&
2266 BEFFailure == BEF_begin) {
2269 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Range)) {
2271 QualType ArrayTy = PVD->getOriginalType();
2272 QualType PointerTy = PVD->getType();
2274 Diag(Range->getLocStart(), diag::err_range_on_array_parameter)
2275 << RangeLoc << PVD << ArrayTy << PointerTy;
2276 Diag(PVD->getLocation(), diag::note_declared_at);
2286 LoopVarDecl, ColonLoc,
2294 if (RangeStatus == FRS_NoViableFunction) {
2295 Expr *Range = BEFFailure ? EndRangeRef.
get() : BeginRangeRef.
get();
2296 Diag(Range->getLocStart(), diag::err_for_range_invalid)
2297 << RangeLoc << Range->
getType() << BEFFailure;
2301 if (RangeStatus != FRS_Success)
2306 "invalid range expression in for loop");
2311 Diag(RangeLoc, diag::err_for_range_begin_end_types_differ)
2312 << BeginType << EndType;
2313 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2314 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2317 Decl *BeginEndDecls[] = { BeginVar, EndVar };
2322 BeginEndDecl = ActOnDeclStmt(BeginEndGroup, ColonLoc, ColonLoc);
2325 ExprResult BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2330 ExprResult EndRef = BuildDeclRefExpr(EndVar, EndType.getNonReferenceType(),
2336 NotEqExpr = ActOnBinOp(S, ColonLoc, tok::exclaimequal,
2337 BeginRef.
get(), EndRef.
get());
2338 NotEqExpr = ActOnBooleanCondition(S, ColonLoc, NotEqExpr.get());
2339 NotEqExpr = ActOnFinishFullExpr(NotEqExpr.get());
2340 if (NotEqExpr.isInvalid()) {
2341 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2342 << RangeLoc << 0 << BeginRangeRef.
get()->
getType();
2343 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2345 NoteForRangeBeginEndFunction(*
this, EndExpr.
get(), BEF_end);
2350 BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2355 IncrExpr = ActOnUnaryOp(S, ColonLoc, tok::plusplus, BeginRef.
get());
2356 if (!IncrExpr.isInvalid() && CoawaitLoc.
isValid())
2357 IncrExpr = ActOnCoawaitExpr(S, CoawaitLoc, IncrExpr.get());
2358 if (!IncrExpr.isInvalid())
2359 IncrExpr = ActOnFinishFullExpr(IncrExpr.get());
2360 if (IncrExpr.isInvalid()) {
2361 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2362 << RangeLoc << 2 << BeginRangeRef.
get()->
getType() ;
2363 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2368 BeginRef = BuildDeclRefExpr(BeginVar, BeginRefNonRefType,
2373 ExprResult DerefExpr = ActOnUnaryOp(S, ColonLoc, tok::star, BeginRef.
get());
2375 Diag(RangeLoc, diag::note_for_range_invalid_iterator)
2376 << RangeLoc << 1 << BeginRangeRef.
get()->
getType();
2377 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2383 if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) {
2384 AddInitializerToDecl(LoopVar, DerefExpr.
get(),
false,
2386 if (LoopVar->isInvalidDecl())
2387 NoteForRangeBeginEndFunction(*
this, BeginExpr.
get(), BEF_begin);
2393 if (Kind == BFRK_Check)
2397 RangeDS, cast_or_null<DeclStmt>(BeginEndDecl.get()), NotEqExpr.
get(),
2398 IncrExpr.get(), LoopVarDS,
nullptr, ForLoc, CoawaitLoc,
2440 while (!isa<CXXOperatorCallExpr>(E) && !isa<UnaryOperator>(E)) {
2444 const MemberExpr *ME = cast<MemberExpr>(Call->getCallee());
2453 bool ReturnsReference =
false;
2454 if (isa<UnaryOperator>(E)) {
2455 ReturnsReference =
true;
2459 QualType ReturnType = FD->getReturnType();
2463 if (ReturnsReference) {
2467 SemaRef.
Diag(VD->
getLocation(), diag::warn_for_range_const_reference_copy)
2468 << VD << VariableType << E->
getType();
2478 SemaRef.
Diag(VD->
getLocation(), diag::warn_for_range_variable_always_copy)
2479 << VD << RangeInitType;
2499 if (!CE->getConstructor()->isCopyConstructor())
2501 }
else if (
const CastExpr *CE = dyn_cast<CastExpr>(InitExpr)) {
2517 << VD << VariableType << InitExpr->
getType();
2533 if (SemaRef.
Diags.
isIgnored(diag::warn_for_range_const_reference_copy,
2535 SemaRef.
Diags.
isIgnored(diag::warn_for_range_variable_always_copy,
2571 if (isa<ObjCForCollectionStmt>(S))
2572 return FinishObjCForCollectionStmt(S, B);
2578 diag::warn_empty_range_based_for_body);
2588 getCurFunction()->setHasBranchIntoScope();
2602 CheckSingleAssignmentConstraints(DestTy, ExprRes);
2606 if (DiagnoseAssignmentResult(ConvTy, StarLoc, DestTy, ETy, E, AA_Passing))
2615 getCurFunction()->setHasIndirectGoto();
2621 const Scope &DestScope) {
2624 S.
Diag(Loc, diag::warn_jump_out_of_seh_finally);
2633 return StmtError(
Diag(ContinueLoc, diag::err_continue_not_in_loop));
2645 return StmtError(
Diag(BreakLoc, diag::err_break_not_in_loop_or_switch));
2648 return StmtError(
Diag(BreakLoc, diag::err_omp_loop_cannot_use_stmt)
2675 bool AllowFunctionParameter) {
2688 if (isCopyElisionCandidate(ReturnType, VD, AllowFunctionParameter))
2694 bool AllowFunctionParameter) {
2708 if (VD->
getKind() != Decl::Var &&
2709 !(AllowFunctionParameter && VD->
getKind() == Decl::ParmVar))
2720 if (VD->
hasAttr<BlocksAttr>())
return false;
2751 (NRVOCandidate || getCopyElisionCandidate(ResultType, Value,
true))) {
2755 Expr *InitExpr = &AsRvalue;
2758 Value->getLocStart());
2767 StepEnd = Seq.step_end();
2773 = cast<CXXConstructorDecl>(
Step->Function.Function);
2792 Res = Seq.Perform(*
this, Entity, Kind, Value);
2833 assert(AT &&
"lost auto type from lambda return type");
2834 if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
2844 if (RetValExp && !isa<InitListExpr>(RetValExp)) {
2848 RetValExp = Result.
get();
2854 if (!CurContext->isDependentContext())
2863 Diag(ReturnLoc, diag::err_lambda_return_init_list)
2864 << RetValExp->getSourceRange();
2875 assert(!FnRetType.isNull());
2877 if (
BlockScopeInfo *CurBlock = dyn_cast<BlockScopeInfo>(CurCap)) {
2879 Diag(ReturnLoc, diag::err_noreturn_block_has_return_expr);
2883 dyn_cast<CapturedRegionScopeInfo>(CurCap)) {
2884 Diag(ReturnLoc, diag::err_return_in_captured_stmt) << CurRegion->getRegionName();
2887 assert(CurLambda &&
"unknown kind of captured scope");
2889 ->getNoReturnAttr()) {
2890 Diag(ReturnLoc, diag::err_noreturn_lambda_has_return_expr);
2898 const VarDecl *NRVOCandidate =
nullptr;
2899 if (FnRetType->isDependentType()) {
2902 }
else if (FnRetType->isVoidType()) {
2903 if (RetValExp && !isa<InitListExpr>(RetValExp) &&
2904 !(getLangOpts().CPlusPlus &&
2907 if (!getLangOpts().CPlusPlus &&
2909 Diag(ReturnLoc, diag::ext_return_has_void_expr) <<
"literal" << 2;
2911 Diag(ReturnLoc, diag::err_return_block_has_expr);
2912 RetValExp =
nullptr;
2915 }
else if (!RetValExp) {
2916 return StmtError(
Diag(ReturnLoc, diag::err_block_return_missing_expr));
2926 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
2929 NRVOCandidate !=
nullptr);
2930 ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate,
2931 FnRetType, RetValExp);
2936 RetValExp = Res.
get();
2937 CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc);
2939 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
2943 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
2946 RetValExp = ER.
get();
2955 FunctionScopes.back()->Returns.push_back(Result);
2957 if (FunctionScopes.back()->FirstReturnLoc.isInvalid())
2958 FunctionScopes.back()->FirstReturnLoc = ReturnLoc;
2976 class LocalTypedefNameReferencer
2979 LocalTypedefNameReferencer(
Sema &S) : S(S) {}
2984 bool LocalTypedefNameReferencer::VisitRecordType(
const RecordType *RT) {
2986 if (!R || !R->isLocalClass() || !R->isLocalClass()->isExternallyVisible() ||
2987 R->isDependentType())
2989 for (
auto *TmpD : R->decls())
2990 if (
auto *T = dyn_cast<TypedefNameDecl>(TmpD))
2991 if (T->getAccess() !=
AS_private || R->hasFriends())
3010 TypeLoc OrigResultType = getReturnTypeLoc(FD);
3013 if (RetExpr && isa<InitListExpr>(RetExpr)) {
3017 getCurLambda() ? diag::err_lambda_return_init_list
3018 : diag::err_auto_fn_return_init_list)
3019 << RetExpr->getSourceRange();
3028 assert(AT->
isDeduced() &&
"should have deduced to dependent type");
3041 if (DAR != DAR_Succeeded)
3046 LocalTypedefNameReferencer Referencer(*
this);
3047 Referencer.TraverseType(RetExpr->
getType());
3055 Diag(ReturnLoc, diag::err_auto_fn_return_void_but_not_auto)
3078 Diag(ReturnLoc, diag::err_typecheck_missing_return_type_incompatible)
3082 Diag(ReturnLoc, diag::err_auto_fn_different_deductions)
3099 StmtResult R = BuildReturnStmt(ReturnLoc, RetValExp);
3105 const_cast<VarDecl*>(cast<ReturnStmt>(R.
get())->getNRVOCandidate())) {
3118 if (RetValExp && DiagnoseUnexpandedParameterPack(RetValExp))
3121 if (isa<CapturingScopeInfo>(getCurFunction()))
3122 return ActOnCapScopeReturnStmt(ReturnLoc, RetValExp);
3126 const AttrVec *Attrs =
nullptr;
3127 bool isObjCMethod =
false;
3134 Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr)
3137 FnRetType = MD->getReturnType();
3138 isObjCMethod =
true;
3140 Attrs = &MD->getAttrs();
3141 if (MD->hasRelatedResultType() && MD->getClassInterface()) {
3156 if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
3170 if (isa<InitListExpr>(RetValExp)) {
3174 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3175 int FunctionKind = 0;
3176 if (isa<ObjCMethodDecl>(CurDecl))
3178 else if (isa<CXXConstructorDecl>(CurDecl))
3180 else if (isa<CXXDestructorDecl>(CurDecl))
3183 Diag(ReturnLoc, diag::err_return_init_list)
3185 << RetValExp->getSourceRange();
3188 RetValExp =
nullptr;
3191 unsigned D = diag::ext_return_has_expr;
3193 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3194 if (isa<CXXConstructorDecl>(CurDecl) ||
3195 isa<CXXDestructorDecl>(CurDecl))
3196 D = diag::err_ctor_dtor_returns_void;
3198 D = diag::ext_return_has_void_expr;
3202 Result = IgnoredValueConversions(Result.
get());
3205 RetValExp = Result.
get();
3206 RetValExp = ImpCastExprToType(RetValExp,
3210 if (D == diag::err_ctor_dtor_returns_void) {
3211 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3213 << CurDecl->
getDeclName() << isa<CXXDestructorDecl>(CurDecl)
3214 << RetValExp->getSourceRange();
3217 else if (D != diag::ext_return_has_void_expr ||
3219 NamedDecl *CurDecl = getCurFunctionOrMethodDecl();
3221 int FunctionKind = 0;
3222 if (isa<ObjCMethodDecl>(CurDecl))
3224 else if (isa<CXXConstructorDecl>(CurDecl))
3226 else if (isa<CXXDestructorDecl>(CurDecl))
3231 << RetValExp->getSourceRange();
3236 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3239 RetValExp = ER.
get();
3244 }
else if (!RetValExp && !HasDependentReturnType) {
3250 DiagID = diag::err_constexpr_return_missing_expr;
3252 }
else if (getLangOpts().
C99) {
3254 DiagID = diag::ext_return_missing_expr;
3257 DiagID = diag::warn_return_missing_expr;
3263 Diag(ReturnLoc, DiagID) << getCurMethodDecl()->getDeclName() << 1;
3267 assert(RetValExp || HasDependentReturnType);
3268 const VarDecl *NRVOCandidate =
nullptr;
3270 QualType RetType = RelatedRetType.
isNull() ? FnRetType : RelatedRetType;
3279 NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp,
false);
3284 NRVOCandidate !=
nullptr);
3285 ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate,
3286 RetType, RetValExp);
3297 if (!RelatedRetType.
isNull()) {
3300 Res = PerformCopyInitialization(Entity, ReturnLoc, RetValExp);
3308 CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc, isObjCMethod, Attrs,
3309 getCurFunctionDecl());
3313 ExprResult ER = ActOnFinishFullExpr(RetValExp, ReturnLoc);
3316 RetValExp = ER.
get();
3324 FunctionScopes.back()->Returns.push_back(Result);
3326 if (FunctionScopes.back()->FirstReturnLoc.isInvalid())
3327 FunctionScopes.back()->FirstReturnLoc = ReturnLoc;
3336 VarDecl *Var = cast_or_null<VarDecl>(Parm);
3351 if (!getLangOpts().ObjCExceptions)
3352 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@try";
3354 getCurFunction()->setHasBranchProtectedScope();
3355 unsigned NumCatchStmts = CatchStmts.size();
3357 NumCatchStmts, Finally);
3366 Result = ActOnFinishFullExpr(Result.
get());
3369 Throw = Result.
get();
3377 return StmtError(
Diag(AtLoc, diag::error_objc_throw_expects_object)
3378 << Throw->
getType() << Throw->getSourceRange());
3388 if (!getLangOpts().ObjCExceptions)
3389 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@throw";
3394 Scope *AtCatchParent = CurScope;
3396 AtCatchParent = AtCatchParent->
getParent();
3398 return StmtError(
Diag(AtLoc, diag::error_rethrow_used_outside_catch));
3400 return BuildObjCAtThrowStmt(AtLoc, Throw);
3405 ExprResult result = DefaultLvalueConversion(operand);
3408 operand = result.
get();
3416 if (getLangOpts().CPlusPlus) {
3417 if (RequireCompleteType(atLoc, type,
3418 diag::err_incomplete_receiver_type))
3419 return Diag(atLoc, diag::error_objc_synchronized_expects_object)
3420 << type << operand->getSourceRange();
3422 ExprResult result = PerformContextuallyConvertToObjCPointer(operand);
3424 return Diag(atLoc, diag::error_objc_synchronized_expects_object)
3425 << type << operand->getSourceRange();
3427 operand = result.
get();
3429 return Diag(atLoc, diag::error_objc_synchronized_expects_object)
3430 << type << operand->getSourceRange();
3436 return ActOnFinishFullExpr(operand);
3443 getCurFunction()->setHasBranchProtectedScope();
3451 Stmt *HandlerBlock) {
3454 CXXCatchStmt(CatchLoc, cast_or_null<VarDecl>(ExDecl), HandlerBlock);
3459 getCurFunction()->setHasBranchProtectedScope();
3464 class CatchHandlerType {
3466 unsigned IsPointer : 1;
3471 enum Unique { ForDenseMap };
3472 CatchHandlerType(
QualType QT, Unique) : QT(QT), IsPointer(
false) {}
3479 if (QT->isPointerType())
3482 if (IsPointer || QT->isReferenceType())
3483 QT = QT->getPointeeType();
3484 QT = QT.getUnqualifiedType();
3490 CatchHandlerType(
QualType QT,
bool IsPointer)
3491 : QT(QT), IsPointer(IsPointer) {}
3493 QualType underlying()
const {
return QT; }
3494 bool isPointer()
const {
return IsPointer; }
3496 friend bool operator==(
const CatchHandlerType &LHS,
3497 const CatchHandlerType &RHS) {
3499 if (LHS.IsPointer != RHS.IsPointer)
3502 return LHS.QT == RHS.QT;
3511 CatchHandlerType::ForDenseMap);
3516 CatchHandlerType::ForDenseMap);
3524 const CatchHandlerType &RHS) {
3531 static const bool value =
true;
3536 class CatchTypePublicBases {
3538 const llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> &TypesToCheck;
3539 const bool CheckAgainstPointer;
3545 CatchTypePublicBases(
3547 const llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> &T,
bool C)
3548 : Ctx(Ctx), TypesToCheck(T), CheckAgainstPointer(C),
3549 FoundHandler(
nullptr) {}
3551 CXXCatchStmt *getFoundHandler()
const {
return FoundHandler; }
3552 CanQualType getFoundHandlerType()
const {
return FoundHandlerType; }
3556 CatchHandlerType Check(S->
getType(), CheckAgainstPointer);
3557 auto M = TypesToCheck;
3558 auto I = M.find(Check);
3560 FoundHandler =
I->second;
3575 if (!getLangOpts().CXXExceptions &&
3576 !getSourceManager().isInSystemHeader(TryLoc))
3577 Diag(TryLoc, diag::err_exceptions_disabled) <<
"try";
3579 if (getCurScope() && getCurScope()->isOpenMPSimdDirectiveScope())
3580 Diag(TryLoc, diag::err_omp_simd_region_cannot_use_stmt) <<
"try";
3586 Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
3590 const unsigned NumHandlers = Handlers.size();
3591 assert(!Handlers.empty() &&
3592 "The parser shouldn't call this if there are no handlers.");
3594 llvm::DenseMap<CatchHandlerType, CXXCatchStmt *> HandledTypes;
3595 for (
unsigned i = 0; i < NumHandlers; ++i) {
3602 if (i < NumHandlers - 1)
3611 CatchHandlerType HandlerCHT =
3617 QualType Underlying = HandlerCHT.underlying();
3619 if (!RD->hasDefinition())
3628 CatchTypePublicBases CTPB(
Context, HandledTypes, HandlerCHT.isPointer());
3629 if (RD->lookupInBases(CTPB, Paths)) {
3631 if (!Paths.
isAmbiguous(CTPB.getFoundHandlerType())) {
3633 diag::warn_exception_caught_by_earlier_handler)
3636 diag::note_previous_exception_handler)
3644 auto R = HandledTypes.insert(std::make_pair(H->
getCaughtType(), H));
3648 diag::warn_exception_caught_by_earlier_handler)
3651 diag::note_previous_exception_handler)
3663 assert(TryBlock && Handler);
3669 if (!getLangOpts().Borland) {
3671 Diag(TryLoc, diag::err_mixing_cxx_try_seh_try);
3687 Diag(TryLoc, diag::err_seh_try_outside_functions);
3691 Diag(TryLoc, diag::err_seh_try_unsupported);
3700 assert(FilterExpr && Block);
3704 diag::err_filter_expression_integral)
3712 CurrentSEHFinally.push_back(CurScope);
3716 CurrentSEHFinally.pop_back();
3721 CurrentSEHFinally.pop_back();
3727 Scope *SEHTryParent = CurScope;
3729 SEHTryParent = SEHTryParent->
getParent();
3731 return StmtError(
Diag(Loc, diag::err_ms___leave_not_in___try));
3744 QualifierLoc, NameInfo,
3745 cast<CompoundStmt>(Nested));
3754 return BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
3756 GetNameFromUnqualifiedId(Name),
3762 unsigned NumParams) {
3779 assert(NumParams > 0 &&
"CapturedStmt requires context parameter");
3791 for (CaptureIter Cap = Candidates.begin(); Cap != Candidates.end(); ++Cap) {
3793 if (Cap->isThisCapture()) {
3796 CaptureInits.push_back(Cap->getInitExpr());
3798 }
else if (Cap->isVLATypeCapture()) {
3801 CaptureInits.push_back(
nullptr);
3806 Cap->isReferenceCapture()
3809 Cap->getVariable()));
3810 CaptureInits.push_back(Cap->getInitExpr());
3816 unsigned NumParams) {
3818 RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, NumParams);
3831 PushCapturedRegionScope(CurScope, CD, RD, Kind);
3834 PushDeclContext(CurScope, CD);
3838 PushExpressionEvaluationContext(PotentiallyEvaluated);
3845 RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, Params.size());
3849 bool ContextIsFound =
false;
3850 unsigned ParamNum = 0;
3853 I !=
E; ++
I, ++ParamNum) {
3854 if (
I->second.isNull()) {
3855 assert(!ContextIsFound &&
3856 "null type has been found already for '__context' parameter");
3863 ContextIsFound =
true;
3872 assert(ContextIsFound &&
"no null type for '__context' parameter");
3873 if (!ContextIsFound) {
3883 PushCapturedRegionScope(CurScope, CD, RD, Kind);
3886 PushDeclContext(CurScope, CD);
3890 PushExpressionEvaluationContext(PotentiallyEvaluated);
3894 DiscardCleanupsInEvaluationContext();
3895 PopExpressionEvaluationContext();
3902 ActOnFields(
nullptr, Record->
getLocation(), Record, Fields,
3906 PopFunctionScopeInfo();
3921 CaptureInits, CD, RD);
3926 DiscardCleanupsInEvaluationContext();
3927 PopExpressionEvaluationContext();
3930 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...
StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *BeginEndDecl, Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc, BuildForRangeKind Kind)
BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
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...
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
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.
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)
static unsigned getHashValue(const CatchHandlerType &Base)
bool hasUnusedResultAttr() const
Returns true if this function or its return type has the warn_unused_result attribute.
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.
SmallVectorImpl< Step >::const_iterator step_iterator
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
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 ...
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.
bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD, bool AllowFunctionParameters)
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...
bool isInSystemMacro(SourceLocation loc)
Returns whether Loc is expanded from a macro in a system header.
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.
CK_IntegralCast - A cast between integral types (other than to boolean).
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.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool OdrUse)
Perform marking for a reference to an arbitrary declaration.
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.
VarDecl * getCopyElisionCandidate(QualType ReturnType, Expr *E, bool AllowFunctionParameters)
Determine whether the given expression is a candidate for copy elision in either a return statement o...
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.
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, FullExprArg Second, Decl *SecondVar, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
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.
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. ...
A location where the result (returned value) of evaluating a statement should be stored.
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
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
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.
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.
A class that does preorder depth-first traversal on the entire Clang AST and visits each node...
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.
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.
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)
StmtResult ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
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)
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.
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
Defines the clang::TypeLoc interface and its subclasses.
static DeclContext * castToDeclContext(const CapturedDecl *D)
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, Decl *CondVar)
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.
The result type of a method or function.
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.
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.
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
Source range that this declaration covers.
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)
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.
CapturedRegionKind CapRegionKind
The kind of captured region.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
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 ...
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.
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.
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.
bool isPODType(ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
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...
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)
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
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.
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.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Describes an entity that is being initialized.
CK_ToVoid - Cast to void, discarding the computed value.
void setType(QualType newType)
Wrapper for source info for pointers.
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)
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...
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond, Decl *CondVar, Stmt *Body)
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 ...