22#include "llvm/ADT/SmallPtrSet.h"
23#include "llvm/ADT/SmallString.h"
46 auto *RD = dyn_cast<CXXRecordDecl>(
CurContext);
51 if (!RD || !RD->getIdentifier() || !RD->getDescribedClassTemplate() ||
52 !
D.getIdentifier() || !
D.getIdentifier()->isStr(
"swap"))
55 auto *ND = dyn_cast<NamespaceDecl>(RD->getDeclContext());
59 bool IsInStd = ND->isStdNamespace();
64 if (!II || !(II->
isStr(
"__debug") || II->
isStr(
"__profile")) ||
65 !ND->isInStdNamespace())
73 return llvm::StringSwitch<bool>(RD->getIdentifier()->getName())
75 .Case(
"pair", IsInStd)
76 .Case(
"priority_queue", IsInStd)
77 .Case(
"stack", IsInStd)
78 .Case(
"queue", IsInStd)
100 llvm::APSInt
Value{1};
141 if (RT->isRValueReferenceType()) {
145 Diag(
Range.getBegin(), diag::err_rref_in_exception_spec)
158 unsigned DiagID = diag::err_incomplete_in_exception_spec;
159 bool ReturnValueOnError =
true;
161 DiagID = diag::ext_incomplete_in_exception_spec;
162 ReturnValueOnError =
false;
167 return ReturnValueOnError;
171 Diag(
Range.getBegin(), diag::err_wasm_reftype_exception_spec);
178 Diag(
Range.getBegin(), diag::err_sizeless_in_exception_spec)
179 << (
Kind == 2 ? 1 : 0) << PointeeT <<
Range;
209 Diag(
Loc, diag::err_exception_spec_not_parsed);
233 Diag(
Loc, diag::err_exception_spec_not_parsed);
245 Listener->ResolvedExceptionSpec(FD);
259 return DC->
isRecord() && cast<RecordDecl>(DC)->isBeingDefined();
263 Sema &S,
const PartialDiagnostic &DiagID,
const PartialDiagnostic &NoteID,
264 const FunctionProtoType *Old, SourceLocation OldLoc,
265 const FunctionProtoType *New, SourceLocation NewLoc,
266 bool *MissingExceptionSpecification =
nullptr,
267 bool *MissingEmptyExceptionSpecification =
nullptr,
268 bool AllowNoexceptAllMatchWithNoSpec =
false,
bool IsOperatorNew =
false);
273 if (!isa<CXXDestructorDecl>(
Decl) &&
274 Decl->getDeclName().getCXXOverloadedOperator() != OO_Delete &&
275 Decl->getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)
283 if (!
Decl->getTypeSourceInfo())
284 return isa<CXXDestructorDecl>(
Decl);
298 bool IsOperatorNew = OO == OO_New || OO == OO_Array_New;
299 bool MissingExceptionSpecification =
false;
300 bool MissingEmptyExceptionSpecification =
false;
302 unsigned DiagID = diag::err_mismatched_exception_spec;
303 bool ReturnValueOnError =
true;
305 DiagID = diag::ext_mismatched_exception_spec;
306 ReturnValueOnError =
false;
320 *
this,
PDiag(DiagID),
PDiag(diag::note_previous_declaration),
323 &MissingExceptionSpecification, &MissingEmptyExceptionSpecification,
324 true, IsOperatorNew)) {
341 if (!MissingExceptionSpecification)
342 return ReturnValueOnError;
354 if (MissingEmptyExceptionSpecification &&
360 NewProto->getReturnType(), NewProto->getParamTypes(),
387 NewProto->getReturnType(), NewProto->getParamTypes(),
388 NewProto->getExtProtoInfo().withExceptionSpec(ESI)));
392 DiagID = diag::ext_missing_exception_specification;
393 ReturnValueOnError =
false;
398 DiagID = diag::ext_missing_exception_specification;
399 ReturnValueOnError =
false;
407 DiagID = diag::ext_missing_exception_specification;
408 ReturnValueOnError =
false;
410 DiagID = diag::err_missing_exception_specification;
411 ReturnValueOnError =
true;
416 llvm::raw_svector_ostream
OS(ExceptionSpecString);
417 switch (OldProto->getExceptionSpecType()) {
424 bool OnFirstException =
true;
425 for (
const auto &
E : OldProto->exceptions()) {
426 if (OnFirstException)
427 OnFirstException =
false;
445 assert(OldProto->getNoexceptExpr() !=
nullptr &&
"Expected non-null Expr");
450 OS <<
"__attribute__((nothrow))";
457 llvm_unreachable(
"This spec type is compatible with none.");
466 if (!FTLoc.getTypePtr()->hasTrailingReturn())
482 return ReturnValueOnError;
491 unsigned DiagID = diag::err_mismatched_exception_spec;
493 DiagID = diag::ext_mismatched_exception_spec;
495 *
this,
PDiag(DiagID),
PDiag(diag::note_previous_declaration),
496 Old, OldLoc, New, NewLoc);
514 bool *MissingExceptionSpecification,
515 bool *MissingEmptyExceptionSpecification,
516 bool AllowNoexceptAllMatchWithNoSpec,
bool IsOperatorNew) {
517 if (MissingExceptionSpecification)
518 *MissingExceptionSpecification =
false;
520 if (MissingEmptyExceptionSpecification)
521 *MissingEmptyExceptionSpecification =
false;
554 "Shouldn't see unknown exception specifications here");
568 if (!AllowNoexceptAllMatchWithNoSpec &&
581 llvm::FoldingSetNodeID OldFSN, NewFSN;
584 if (OldFSN == NewFSN)
600 if (OldTypes.count(TypePtr))
601 NewTypes.insert(TypePtr);
608 if (
Success && OldTypes.size() == NewTypes.size())
615 if (S.
getLangOpts().CPlusPlus11 && IsOperatorNew) {
618 WithExceptions = New;
620 WithExceptions = Old;
627 if (Name && Name->getName() ==
"bad_alloc") {
629 if (ExRecord->isInStdNamespace()) {
639 if (MissingExceptionSpecification && OldEST !=
EST_None &&
643 *MissingExceptionSpecification =
true;
645 if (MissingEmptyExceptionSpecification && OldCanThrow ==
CT_Cannot) {
649 *MissingEmptyExceptionSpecification =
true;
655 S.
Diag(NewLoc, DiagID);
657 S.
Diag(OldLoc, NoteID);
750 llvm_unreachable(
"access check dependent for unprivileged context");
752 llvm_unreachable(
"access check delayed in non-declaration");
754 llvm_unreachable(
"unexpected access check result");
786 "Shouldn't see unknown exception specifications here");
803 SkipSupersetFirstParameter, SuperLoc, Subset,
804 SkipSubsetFirstParameter, SubLoc);
810 Diag(SubLoc, NoThrowDiagID);
812 Diag(SuperLoc, NoteID);
820 Diag(SubLoc, DiagID);
822 Diag(SuperLoc, NoteID);
827 "Exception spec subset: non-dynamic case slipped through.");
832 SubI = RefTy->getPointeeType();
835 bool Contained =
false;
849 Diag(SubLoc, DiagID);
851 Diag(SuperLoc, NoteID);
857 SkipSupersetFirstParameter, SuperLoc, Subset,
858 SkipSupersetFirstParameter, SubLoc);
882 auto RetDiag = DiagID;
885 *
this, RetDiag,
PDiag(),
892 assert((
Target->getNumParams() - (
unsigned)SkipTargetFirstParameter) ==
893 (Source->
getNumParams() - (
unsigned)SkipSourceFirstParameter) &&
894 "Functions have different argument counts.");
895 for (
unsigned i = 0,
E =
Target->getNumParams(); i !=
E; ++i) {
896 auto ParamDiag = DiagID;
899 *
this, ParamDiag,
PDiag(),
900 Target->getParamType(i + (SkipTargetFirstParameter ? 1 : 0)),
901 TargetLoc, Source->
getParamType(SkipSourceFirstParameter ? 1 : 0),
920 unsigned DiagID = diag::err_incompatible_exception_specs;
921 unsigned NestedDiagID = diag::err_deep_exception_specs_differ;
926 DiagID = diag::warn_incompatible_exception_specs;
927 NestedDiagID = diag::warn_deep_exception_specs_differ;
971 unsigned DiagID = diag::err_override_exception_spec;
973 DiagID = diag::ext_override_exception_spec;
975 PDiag(DiagID),
PDiag(diag::err_deep_exception_specs_differ),
976 PDiag(diag::note_overridden_virtual_function),
977 PDiag(diag::ext_override_exception_spec),
986 for (
const Stmt *SubStmt : S->children()) {
1000 if (isa_and_nonnull<FunctionDecl>(
D) &&
D->hasAttr<NoThrowAttr>())
1006 if (S.getLangOpts().CPlusPlus17 && isa_and_nonnull<CallExpr>(
E)) {
1007 E = cast<CallExpr>(
E)->getCallee();
1012 E =
E->IgnoreParenImpCasts();
1015 if (
auto *Op = dyn_cast<BinaryOperator>(
E)) {
1016 assert(Op->getOpcode() == BO_PtrMemD || Op->getOpcode() == BO_PtrMemI);
1017 T = Op->getRHS()->getType()
1020 T = cast<MemberExpr>(
E)->getMemberDecl()->getType();
1023 }
else if (
const ValueDecl *VD = dyn_cast_or_null<ValueDecl>(
D))
1043 if (
Loc.isValid() || (
Loc.isInvalid() &&
E))
1044 FT = S.ResolveExceptionSpec(
Loc.isInvalid() ?
E->getBeginLoc() :
Loc, FT);
1063 if (
auto *Dtor = RD->getDestructor()) {
1071 if (
auto *DD = dyn_cast<DecompositionDecl>(VD))
1072 for (
auto *B : DD->bindings())
1073 if (
auto *HD = B->getHoldingVar())
1115 switch (S->getStmtClass()) {
1116 case Expr::ConstantExprClass:
1117 return canThrow(cast<ConstantExpr>(S)->getSubExpr());
1119 case Expr::CXXThrowExprClass:
1123 case Expr::CXXDynamicCastExprClass: {
1126 auto *CE = cast<CXXDynamicCastExpr>(S);
1128 if (CE->getType()->isVariablyModifiedType())
1136 case Expr::CXXTypeidExprClass:
1145 case Expr::CallExprClass:
1146 case Expr::CXXMemberCallExprClass:
1147 case Expr::CXXOperatorCallExprClass:
1148 case Expr::UserDefinedLiteralClass: {
1149 const CallExpr *CE = cast<CallExpr>(S);
1162 case Expr::CXXConstructExprClass:
1163 case Expr::CXXTemporaryObjectExprClass: {
1164 auto *CE = cast<CXXConstructExpr>(S);
1166 if (CE->getType()->isVariablyModifiedType())
1174 case Expr::CXXInheritedCtorInitExprClass: {
1175 auto *ICIE = cast<CXXInheritedCtorInitExpr>(S);
1179 case Expr::LambdaExprClass: {
1180 const LambdaExpr *Lambda = cast<LambdaExpr>(S);
1185 Cap != CapEnd; ++Cap)
1190 case Expr::CXXNewExprClass: {
1191 auto *NE = cast<CXXNewExpr>(S);
1193 if (NE->isTypeDependent())
1202 case Expr::CXXDeleteExprClass: {
1203 auto *DE = cast<CXXDeleteExpr>(S);
1205 QualType DTy = DE->getDestroyedType();
1211 const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
1222 case Expr::CXXBindTemporaryExprClass: {
1223 auto *BTE = cast<CXXBindTemporaryExpr>(S);
1226 canCalleeThrow(*
this, BTE, BTE->getTemporary()->getDestructor());
1232 case Expr::PseudoObjectExprClass: {
1233 auto *POE = cast<PseudoObjectExpr>(S);
1235 for (
const Expr *
E : POE->semantics()) {
1245 case Expr::ObjCMessageExprClass:
1246 case Expr::ObjCPropertyRefExprClass:
1247 case Expr::ObjCSubscriptRefExprClass:
1253 case Expr::ObjCArrayLiteralClass:
1254 case Expr::ObjCDictionaryLiteralClass:
1255 case Expr::ObjCBoxedExprClass:
1260 case Expr::CoawaitExprClass:
1261 case Expr::ConditionalOperatorClass:
1262 case Expr::CoyieldExprClass:
1263 case Expr::CXXRewrittenBinaryOperatorClass:
1264 case Expr::CXXStdInitializerListExprClass:
1265 case Expr::DesignatedInitExprClass:
1266 case Expr::DesignatedInitUpdateExprClass:
1267 case Expr::ExprWithCleanupsClass:
1268 case Expr::ExtVectorElementExprClass:
1269 case Expr::InitListExprClass:
1270 case Expr::ArrayInitLoopExprClass:
1271 case Expr::MemberExprClass:
1272 case Expr::ObjCIsaExprClass:
1273 case Expr::ObjCIvarRefExprClass:
1274 case Expr::ParenExprClass:
1275 case Expr::ParenListExprClass:
1276 case Expr::ShuffleVectorExprClass:
1277 case Expr::StmtExprClass:
1278 case Expr::ConvertVectorExprClass:
1279 case Expr::VAArgExprClass:
1280 case Expr::CXXParenListInitExprClass:
1283 case Expr::CompoundLiteralExprClass:
1284 case Expr::CXXConstCastExprClass:
1285 case Expr::CXXAddrspaceCastExprClass:
1286 case Expr::CXXReinterpretCastExprClass:
1287 case Expr::BuiltinBitCastExprClass:
1289 if (cast<Expr>(S)->getType()->isVariablyModifiedType())
1294 case Expr::ArraySubscriptExprClass:
1295 case Expr::MatrixSubscriptExprClass:
1296 case Expr::ArraySectionExprClass:
1297 case Expr::OMPArrayShapingExprClass:
1298 case Expr::OMPIteratorExprClass:
1299 case Expr::BinaryOperatorClass:
1300 case Expr::DependentCoawaitExprClass:
1301 case Expr::CompoundAssignOperatorClass:
1302 case Expr::CStyleCastExprClass:
1303 case Expr::CXXStaticCastExprClass:
1304 case Expr::CXXFunctionalCastExprClass:
1305 case Expr::ImplicitCastExprClass:
1306 case Expr::MaterializeTemporaryExprClass:
1307 case Expr::UnaryOperatorClass: {
1309 if (
auto *CE = dyn_cast<CastExpr>(S))
1310 if (CE->getType()->isVariablyModifiedType())
1317 case Expr::CXXDefaultArgExprClass:
1318 return canThrow(cast<CXXDefaultArgExpr>(S)->getExpr());
1320 case Expr::CXXDefaultInitExprClass:
1321 return canThrow(cast<CXXDefaultInitExpr>(S)->getExpr());
1323 case Expr::ChooseExprClass: {
1324 auto *CE = cast<ChooseExpr>(S);
1325 if (CE->isTypeDependent() || CE->isValueDependent())
1327 return canThrow(CE->getChosenSubExpr());
1330 case Expr::GenericSelectionExprClass:
1331 if (cast<GenericSelectionExpr>(S)->isResultDependent())
1333 return canThrow(cast<GenericSelectionExpr>(S)->getResultExpr());
1336 case Expr::CXXDependentScopeMemberExprClass:
1337 case Expr::CXXUnresolvedConstructExprClass:
1338 case Expr::DependentScopeDeclRefExprClass:
1339 case Expr::CXXFoldExprClass:
1340 case Expr::RecoveryExprClass:
1343 case Expr::AsTypeExprClass:
1344 case Expr::BinaryConditionalOperatorClass:
1345 case Expr::BlockExprClass:
1346 case Expr::CUDAKernelCallExprClass:
1347 case Expr::DeclRefExprClass:
1348 case Expr::ObjCBridgedCastExprClass:
1349 case Expr::ObjCIndirectCopyRestoreExprClass:
1350 case Expr::ObjCProtocolExprClass:
1351 case Expr::ObjCSelectorExprClass:
1352 case Expr::ObjCAvailabilityCheckExprClass:
1353 case Expr::OffsetOfExprClass:
1354 case Expr::PackExpansionExprClass:
1355 case Expr::SubstNonTypeTemplateParmExprClass:
1356 case Expr::SubstNonTypeTemplateParmPackExprClass:
1357 case Expr::FunctionParmPackExprClass:
1358 case Expr::UnaryExprOrTypeTraitExprClass:
1359 case Expr::UnresolvedLookupExprClass:
1360 case Expr::UnresolvedMemberExprClass:
1361 case Expr::TypoExprClass:
1365 case Expr::AddrLabelExprClass:
1366 case Expr::ArrayTypeTraitExprClass:
1367 case Expr::AtomicExprClass:
1368 case Expr::TypeTraitExprClass:
1369 case Expr::CXXBoolLiteralExprClass:
1370 case Expr::CXXNoexceptExprClass:
1371 case Expr::CXXNullPtrLiteralExprClass:
1372 case Expr::CXXPseudoDestructorExprClass:
1373 case Expr::CXXScalarValueInitExprClass:
1374 case Expr::CXXThisExprClass:
1375 case Expr::CXXUuidofExprClass:
1376 case Expr::CharacterLiteralClass:
1377 case Expr::ExpressionTraitExprClass:
1378 case Expr::FloatingLiteralClass:
1379 case Expr::GNUNullExprClass:
1380 case Expr::ImaginaryLiteralClass:
1381 case Expr::ImplicitValueInitExprClass:
1382 case Expr::IntegerLiteralClass:
1383 case Expr::FixedPointLiteralClass:
1384 case Expr::ArrayInitIndexExprClass:
1385 case Expr::NoInitExprClass:
1386 case Expr::ObjCEncodeExprClass:
1387 case Expr::ObjCStringLiteralClass:
1388 case Expr::ObjCBoolLiteralExprClass:
1389 case Expr::OpaqueValueExprClass:
1390 case Expr::PredefinedExprClass:
1391 case Expr::SizeOfPackExprClass:
1392 case Expr::PackIndexingExprClass:
1393 case Expr::StringLiteralClass:
1394 case Expr::SourceLocExprClass:
1395 case Expr::EmbedExprClass:
1396 case Expr::ConceptSpecializationExprClass:
1397 case Expr::RequiresExprClass:
1401 case Expr::MSPropertyRefExprClass:
1402 case Expr::MSPropertySubscriptExprClass:
1403 llvm_unreachable(
"Invalid class for expression");
1406 case Stmt::OpenACCComputeConstructClass:
1407 case Stmt::OpenACCLoopConstructClass:
1408 case Stmt::AttributedStmtClass:
1409 case Stmt::BreakStmtClass:
1410 case Stmt::CapturedStmtClass:
1411 case Stmt::CaseStmtClass:
1412 case Stmt::CompoundStmtClass:
1413 case Stmt::ContinueStmtClass:
1414 case Stmt::CoreturnStmtClass:
1415 case Stmt::CoroutineBodyStmtClass:
1416 case Stmt::CXXCatchStmtClass:
1417 case Stmt::CXXForRangeStmtClass:
1418 case Stmt::DefaultStmtClass:
1419 case Stmt::DoStmtClass:
1420 case Stmt::ForStmtClass:
1421 case Stmt::GCCAsmStmtClass:
1422 case Stmt::GotoStmtClass:
1423 case Stmt::IndirectGotoStmtClass:
1424 case Stmt::LabelStmtClass:
1425 case Stmt::MSAsmStmtClass:
1426 case Stmt::MSDependentExistsStmtClass:
1427 case Stmt::NullStmtClass:
1428 case Stmt::ObjCAtCatchStmtClass:
1429 case Stmt::ObjCAtFinallyStmtClass:
1430 case Stmt::ObjCAtSynchronizedStmtClass:
1431 case Stmt::ObjCAutoreleasePoolStmtClass:
1432 case Stmt::ObjCForCollectionStmtClass:
1433 case Stmt::OMPAtomicDirectiveClass:
1434 case Stmt::OMPAssumeDirectiveClass:
1435 case Stmt::OMPBarrierDirectiveClass:
1436 case Stmt::OMPCancelDirectiveClass:
1437 case Stmt::OMPCancellationPointDirectiveClass:
1438 case Stmt::OMPCriticalDirectiveClass:
1439 case Stmt::OMPDistributeDirectiveClass:
1440 case Stmt::OMPDistributeParallelForDirectiveClass:
1441 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
1442 case Stmt::OMPDistributeSimdDirectiveClass:
1443 case Stmt::OMPFlushDirectiveClass:
1444 case Stmt::OMPDepobjDirectiveClass:
1445 case Stmt::OMPScanDirectiveClass:
1446 case Stmt::OMPForDirectiveClass:
1447 case Stmt::OMPForSimdDirectiveClass:
1448 case Stmt::OMPMasterDirectiveClass:
1449 case Stmt::OMPMasterTaskLoopDirectiveClass:
1450 case Stmt::OMPMaskedTaskLoopDirectiveClass:
1451 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
1452 case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
1453 case Stmt::OMPOrderedDirectiveClass:
1454 case Stmt::OMPCanonicalLoopClass:
1455 case Stmt::OMPParallelDirectiveClass:
1456 case Stmt::OMPParallelForDirectiveClass:
1457 case Stmt::OMPParallelForSimdDirectiveClass:
1458 case Stmt::OMPParallelMasterDirectiveClass:
1459 case Stmt::OMPParallelMaskedDirectiveClass:
1460 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
1461 case Stmt::OMPParallelMaskedTaskLoopDirectiveClass:
1462 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
1463 case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass:
1464 case Stmt::OMPParallelSectionsDirectiveClass:
1465 case Stmt::OMPSectionDirectiveClass:
1466 case Stmt::OMPSectionsDirectiveClass:
1467 case Stmt::OMPSimdDirectiveClass:
1468 case Stmt::OMPTileDirectiveClass:
1469 case Stmt::OMPUnrollDirectiveClass:
1470 case Stmt::OMPReverseDirectiveClass:
1471 case Stmt::OMPInterchangeDirectiveClass:
1472 case Stmt::OMPSingleDirectiveClass:
1473 case Stmt::OMPTargetDataDirectiveClass:
1474 case Stmt::OMPTargetDirectiveClass:
1475 case Stmt::OMPTargetEnterDataDirectiveClass:
1476 case Stmt::OMPTargetExitDataDirectiveClass:
1477 case Stmt::OMPTargetParallelDirectiveClass:
1478 case Stmt::OMPTargetParallelForDirectiveClass:
1479 case Stmt::OMPTargetParallelForSimdDirectiveClass:
1480 case Stmt::OMPTargetSimdDirectiveClass:
1481 case Stmt::OMPTargetTeamsDirectiveClass:
1482 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
1483 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
1484 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
1485 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
1486 case Stmt::OMPTargetUpdateDirectiveClass:
1487 case Stmt::OMPScopeDirectiveClass:
1488 case Stmt::OMPTaskDirectiveClass:
1489 case Stmt::OMPTaskgroupDirectiveClass:
1490 case Stmt::OMPTaskLoopDirectiveClass:
1491 case Stmt::OMPTaskLoopSimdDirectiveClass:
1492 case Stmt::OMPTaskwaitDirectiveClass:
1493 case Stmt::OMPTaskyieldDirectiveClass:
1494 case Stmt::OMPErrorDirectiveClass:
1495 case Stmt::OMPTeamsDirectiveClass:
1496 case Stmt::OMPTeamsDistributeDirectiveClass:
1497 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
1498 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
1499 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
1500 case Stmt::OMPInteropDirectiveClass:
1501 case Stmt::OMPDispatchDirectiveClass:
1502 case Stmt::OMPMaskedDirectiveClass:
1503 case Stmt::OMPMetaDirectiveClass:
1504 case Stmt::OMPGenericLoopDirectiveClass:
1505 case Stmt::OMPTeamsGenericLoopDirectiveClass:
1506 case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
1507 case Stmt::OMPParallelGenericLoopDirectiveClass:
1508 case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
1509 case Stmt::ReturnStmtClass:
1510 case Stmt::SEHExceptStmtClass:
1511 case Stmt::SEHFinallyStmtClass:
1512 case Stmt::SEHLeaveStmtClass:
1513 case Stmt::SEHTryStmtClass:
1514 case Stmt::SwitchStmtClass:
1515 case Stmt::WhileStmtClass:
1518 case Stmt::DeclStmtClass: {
1520 for (
const Decl *
D : cast<DeclStmt>(S)->decls()) {
1521 if (
auto *VD = dyn_cast<VarDecl>(
D))
1525 if (
auto *TND = dyn_cast<TypedefNameDecl>(
D))
1526 if (TND->getUnderlyingType()->isVariablyModifiedType())
1528 if (
auto *VD = dyn_cast<ValueDecl>(
D))
1529 if (VD->getType()->isVariablyModifiedType())
1535 case Stmt::IfStmtClass: {
1536 auto *IS = cast<IfStmt>(S);
1538 if (
const Stmt *
Init = IS->getInit())
1540 if (
const Stmt *CondDS = IS->getConditionVariableDeclStmt())
1546 if (std::optional<const Stmt *> Case = IS->getNondiscardedCase(
Context))
1560 case Stmt::CXXTryStmtClass: {
1561 auto *TS = cast<CXXTryStmt>(S);
1564 const CXXCatchStmt *FinalHandler = TS->getHandler(TS->getNumHandlers() - 1);
1570 case Stmt::ObjCAtThrowStmtClass:
1573 case Stmt::ObjCAtTryStmtClass: {
1574 auto *TS = cast<ObjCAtTryStmt>(S);
1579 if (
const Stmt *Finally = TS->getFinallyStmt())
1581 for (
unsigned I = TS->getNumCatchStmts(); I != 0; --I) {
1593 case Stmt::SYCLUniqueStableNameExprClass:
1596 llvm_unreachable(
"Invalid class for statement");
1598 llvm_unreachable(
"Bogus StmtClass");
Defines the Diagnostic-related interfaces.
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
Defines the clang::Expr interface and subclasses for C++ expressions.
llvm::MachO::Target Target
Defines the SourceManager interface.
Defines the Objective-C statement AST node classes.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TypeLoc interface and its subclasses.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
SourceManager & getSourceManager()
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
A boolean literal, per ([C++ lex.bool] Boolean literals).
CXXCatchStmt - This represents a C++ catch block.
Stmt * getHandlerBlock() const
VarDecl * getExceptionDecl() const
Represents a C++ destructor within a class.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a C++ struct/union/class.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
bool isTypeOperand() const
Expr * getExprOperand() const
bool isPotentiallyEvaluated() const
Determine whether this typeid has a type operand which is potentially evaluated, per C++11 [expr....
bool hasNullCheck() const
Whether this is of a form like "typeid(*ptr)" that can throw a std::bad_typeid if a pointer is a null...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CastKind getCastKind() const
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
SourceLocation getLocation() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
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.
Represents a function declaration or definition.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
bool hasCXXExplicitFunctionObjectParameter() const
bool isExternC() const
Determines whether this function is a function with external, C linkage.
bool isReplaceableGlobalAllocationFunction(std::optional< unsigned > *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
Represents a prototype with parameter type info, e.g.
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
QualType getParamType(unsigned i) const
unsigned getNumExceptions() const
Return the number of types in the exception specification.
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
ArrayRef< QualType > exceptions() const
exception_iterator exception_begin() const
FunctionDecl * getExceptionSpecDecl() const
If this function type has an exception specification which hasn't been determined yet (either because...
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument for this lambda expression.
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument for this lambda expression (which initializes the first ca...
A pointer to member type per C++ 8.3.3 - Pointers to members.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents Objective-C's @catch statement.
unsigned getDiagID() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isWebAssemblyReferenceType() const
Returns true if it is a WebAssembly Reference Type.
bool isConstQualified() const
Determine whether this type is const-qualified.
The collection of all-type qualifiers we support.
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Sema - This implements semantic analysis and AST building for C.
bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range)
CheckSpecifiedExceptionType - Check if the given type is valid in an exception specification.
void EvaluateImplicitExceptionSpec(SourceLocation Loc, FunctionDecl *FD)
Evaluate the implicit exception specification for a defaulted special member function.
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
SmallVector< std::pair< FunctionDecl *, FunctionDecl * >, 2 > DelayedEquivalentExceptionSpecChecks
All the function redeclarations seen during a class definition that had their exception spec checks d...
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const FunctionProtoType *Target, bool SkipTargetFirstParameter, SourceLocation TargetLoc, const FunctionProtoType *Source, bool SkipSourceFirstParameter, SourceLocation SourceLoc)
CheckParamExceptionSpec - Check if the parameter and return types of the two functions have equivalen...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const LangOptions & getLangOpts() const
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr, ExceptionSpecificationType &EST)
Check the given noexcept-specifier, convert its expression, and compute the appropriate ExceptionSpec...
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
SmallVector< std::pair< const CXXMethodDecl *, const CXXMethodDecl * >, 2 > DelayedOverridingExceptionSpecChecks
All the overriding functions seen during a class definition that had their exception spec checks dela...
bool isLibstdcxxEagerExceptionSpecHack(const Declarator &D)
Determine if we're in a case where we need to (incorrectly) eagerly parse an exception specification ...
bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID, const FunctionProtoType *Superset, bool SkipSupersetFirstParameter, SourceLocation SuperLoc, const FunctionProtoType *Subset, bool SkipSubsetFirstParameter, SourceLocation SubLoc)
CheckExceptionSpecSubset - Check whether the second function type's exception specification is a subs...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
CanThrowResult canThrow(const Stmt *E)
@ CCEK_Noexcept
Condition in a noexcept(bool) specifier.
bool handlerCanCatch(QualType HandlerType, QualType ExceptionType)
bool CheckDistantExceptionSpec(QualType T)
CheckDistantExceptionSpec - Check if the given type is a pointer or pointer to member to a function w...
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec.
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
ASTMutationListener * getASTMutationListener() const
static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D, SourceLocation Loc=SourceLocation())
Determine whether the callee of a particular function call can throw.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
Base wrapper for a particular "section" of type source info.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
A container of type source information.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
bool isReferenceType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isMemberPointerType() const
bool isObjectType() const
Determine whether this type is an object type.
bool isFunctionType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
const Expr * getInit() const
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
The JSON file list parser is used to communicate input to InstallAPI.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
CanThrowResult
Possible results from evaluation of a noexcept expression.
static const FunctionProtoType * GetUnderlyingFunction(QualType T)
bool isDynamicExceptionSpec(ExceptionSpecificationType ESpecType)
static bool CheckEquivalentExceptionSpecImpl(Sema &S, const PartialDiagnostic &DiagID, const PartialDiagnostic &NoteID, const FunctionProtoType *Old, SourceLocation OldLoc, const FunctionProtoType *New, SourceLocation NewLoc, bool *MissingExceptionSpecification=nullptr, bool *MissingEmptyExceptionSpecification=nullptr, bool AllowNoexceptAllMatchWithNoSpec=false, bool IsOperatorNew=false)
CheckEquivalentExceptionSpec - Check if the two types have compatible exception specifications.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
static bool hasImplicitExceptionSpec(FunctionDecl *Decl)
Determine whether a function has an implicitly-generated exception specification.
CanThrowResult mergeCanThrow(CanThrowResult CT1, CanThrowResult CT2)
@ Result
The result type of a method or function.
static CanThrowResult canVarDeclThrow(Sema &Self, const VarDecl *VD)
static CanThrowResult canDynamicCastThrow(const CXXDynamicCastExpr *DC)
static CanThrowResult canSubStmtsThrow(Sema &Self, const Stmt *S)
const FunctionProtoType * T
static CanThrowResult canTypeidThrow(Sema &S, const CXXTypeidExpr *DC)
static bool CheckSpecForTypesEquivalent(Sema &S, const PartialDiagnostic &DiagID, const PartialDiagnostic &NoteID, QualType Target, SourceLocation TargetLoc, QualType Source, SourceLocation SourceLoc)
@ Success
Template argument deduction was successful.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
static bool exceptionSpecNotKnownYet(const FunctionDecl *FD)
Holds information about the various types of exception specification.
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.