22 #include "llvm/ADT/SmallPtrSet.h" 23 #include "llvm/ADT/SmallString.h" 48 if (!RD || !RD->getIdentifier() || !RD->getDescribedClassTemplate() ||
61 if (!II || !(II->
isStr(
"__debug") || II->
isStr(
"__profile")) ||
62 !ND->isInStdNamespace())
70 return llvm::StringSwitch<bool>(RD->getIdentifier()->getName())
72 .Case(
"pair", IsInStd)
73 .Case(
"priority_queue", IsInStd)
74 .Case(
"stack", IsInStd)
75 .Case(
"queue", IsInStd)
95 if (Converted.
get()->isValueDependent()) {
103 diag::err_noexcept_needs_constant_expression,
142 if (RT->isRValueReferenceType()) {
146 Diag(Range.
getBegin(), diag::err_rref_in_exception_spec)
159 unsigned DiagID = diag::err_incomplete_in_exception_spec;
160 bool ReturnValueOnError =
true;
162 DiagID = diag::ext_incomplete_in_exception_spec;
163 ReturnValueOnError =
false;
168 return ReturnValueOnError;
199 Diag(Loc, diag::err_exception_spec_not_parsed);
223 Diag(Loc, diag::err_exception_spec_not_parsed);
235 Listener->ResolvedExceptionSpec(FD);
255 bool *MissingExceptionSpecification =
nullptr,
256 bool *MissingEmptyExceptionSpecification =
nullptr,
257 bool AllowNoexceptAllMatchWithNoSpec =
false,
bool IsOperatorNew =
false);
262 if (!isa<CXXDestructorDecl>(Decl) &&
273 return isa<CXXDestructorDecl>(Decl);
287 bool IsOperatorNew = OO == OO_New || OO == OO_Array_New;
288 bool MissingExceptionSpecification =
false;
289 bool MissingEmptyExceptionSpecification =
false;
291 unsigned DiagID = diag::err_mismatched_exception_spec;
292 bool ReturnValueOnError =
true;
294 DiagID = diag::ext_mismatched_exception_spec;
295 ReturnValueOnError =
false;
309 *
this,
PDiag(DiagID),
PDiag(diag::note_previous_declaration),
312 &MissingExceptionSpecification, &MissingEmptyExceptionSpecification,
313 true, IsOperatorNew)) {
330 if (!MissingExceptionSpecification)
331 return ReturnValueOnError;
344 if (MissingEmptyExceptionSpecification && NewProto &&
384 DiagID = diag::ext_ms_missing_exception_specification;
385 ReturnValueOnError =
false;
390 DiagID = diag::ext_missing_exception_specification;
391 ReturnValueOnError =
false;
395 DiagID = diag::ext_missing_exception_specification;
396 ReturnValueOnError =
false;
398 DiagID = diag::err_missing_exception_specification;
399 ReturnValueOnError =
true;
404 llvm::raw_svector_ostream OS(ExceptionSpecString);
412 bool OnFirstException =
true;
413 for (
const auto &E : OldProto->
exceptions()) {
414 if (OnFirstException)
415 OnFirstException =
false;
433 assert(OldProto->
getNoexceptExpr() !=
nullptr &&
"Expected non-null Expr");
438 OS <<
"__attribute__((nothrow))";
445 llvm_unreachable(
"This spec type is compatible with none.");
454 if (!FTLoc.getTypePtr()->hasTrailingReturn())
470 return ReturnValueOnError;
483 unsigned DiagID = diag::err_mismatched_exception_spec;
485 DiagID = diag::ext_mismatched_exception_spec;
487 *
this,
PDiag(DiagID),
PDiag(diag::note_previous_declaration),
488 Old, OldLoc, New, NewLoc);
506 bool *MissingExceptionSpecification,
507 bool *MissingEmptyExceptionSpecification,
508 bool AllowNoexceptAllMatchWithNoSpec,
bool IsOperatorNew) {
509 if (MissingExceptionSpecification)
510 *MissingExceptionSpecification =
false;
512 if (MissingEmptyExceptionSpecification)
513 *MissingEmptyExceptionSpecification =
false;
546 "Shouldn't see unknown exception specifications here");
560 if (!AllowNoexceptAllMatchWithNoSpec &&
573 llvm::FoldingSetNodeID OldFSN, NewFSN;
576 if (OldFSN == NewFSN)
586 llvm::SmallPtrSet<CanQualType, 8> OldTypes, NewTypes;
592 if (OldTypes.count(TypePtr))
593 NewTypes.insert(TypePtr);
600 if (Success && OldTypes.size() == NewTypes.size())
607 if (S.
getLangOpts().CPlusPlus11 && IsOperatorNew) {
610 WithExceptions = New;
612 WithExceptions = Old;
619 if (Name && Name->
getName() ==
"bad_alloc") {
621 if (ExRecord->isInStdNamespace()) {
631 if (MissingExceptionSpecification && OldEST !=
EST_None &&
635 *MissingExceptionSpecification =
true;
637 if (MissingEmptyExceptionSpecification && OldCanThrow ==
CT_Cannot) {
641 *MissingEmptyExceptionSpecification =
true;
647 S.
Diag(NewLoc, DiagID);
649 S.
Diag(OldLoc, NoteID);
742 llvm_unreachable(
"access check dependent for unprivileged context");
744 llvm_unreachable(
"access check delayed in non-declaration");
746 llvm_unreachable(
"unexpected access check result");
783 "Shouldn't see unknown exception specifications here");
806 Diag(SubLoc, NoThrowDiagID);
808 Diag(SuperLoc, NoteID);
816 Diag(SubLoc, DiagID);
818 Diag(SuperLoc, NoteID);
823 "Exception spec subset: non-dynamic case slipped through.");
828 SubI = RefTy->getPointeeType();
831 bool Contained =
false;
845 Diag(SubLoc, DiagID);
847 Diag(SuperLoc, NoteID);
883 auto RetDiag = DiagID;
886 *
this, RetDiag,
PDiag(),
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(),
919 unsigned DiagID = diag::err_incompatible_exception_specs;
920 unsigned NestedDiagID = diag::err_deep_exception_specs_differ;
925 DiagID = diag::warn_incompatible_exception_specs;
926 NestedDiagID = diag::warn_deep_exception_specs_differ;
969 unsigned DiagID = diag::err_override_exception_spec;
971 DiagID = diag::ext_override_exception_spec;
973 PDiag(diag::err_deep_exception_specs_differ),
974 PDiag(diag::note_overridden_virtual_function),
975 PDiag(diag::ext_override_exception_spec),
1000 if (D && isa<FunctionDecl>(D) && D->
hasAttr<NoThrowAttr>())
1006 if (S.
getLangOpts().CPlusPlus17 && E && isa<CallExpr>(E)) {
1007 E = cast<CallExpr>(E)->getCallee();
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))
1062 if (
auto *Dtor = RD->getDestructor()) {
1070 if (
auto *DD = dyn_cast<DecompositionDecl>(VD))
1071 for (
auto *B : DD->bindings())
1072 if (
auto *HD = B->getHoldingVar())
1103 if (!cast<CXXRecordDecl>(RT->
getDecl())->isPolymorphic())
1117 case Expr::ConstantExprClass:
1118 return canThrow(cast<ConstantExpr>(S)->getSubExpr());
1120 case Expr::CXXThrowExprClass:
1124 case Expr::CXXDynamicCastExprClass: {
1127 auto *CE = cast<CXXDynamicCastExpr>(S);
1129 if (CE->getType()->isVariablyModifiedType())
1137 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:
1282 case Expr::CompoundLiteralExprClass:
1283 case Expr::CXXConstCastExprClass:
1284 case Expr::CXXReinterpretCastExprClass:
1285 case Expr::BuiltinBitCastExprClass:
1287 if (cast<Expr>(S)->getType()->isVariablyModifiedType())
1292 case Expr::ArraySubscriptExprClass:
1293 case Expr::OMPArraySectionExprClass:
1294 case Expr::BinaryOperatorClass:
1295 case Expr::DependentCoawaitExprClass:
1296 case Expr::CompoundAssignOperatorClass:
1297 case Expr::CStyleCastExprClass:
1298 case Expr::CXXStaticCastExprClass:
1299 case Expr::CXXFunctionalCastExprClass:
1300 case Expr::ImplicitCastExprClass:
1301 case Expr::MaterializeTemporaryExprClass:
1302 case Expr::UnaryOperatorClass: {
1304 if (
auto *CE = dyn_cast<CastExpr>(S))
1305 if (CE->getType()->isVariablyModifiedType())
1312 case Expr::CXXDefaultArgExprClass:
1313 return canThrow(cast<CXXDefaultArgExpr>(S)->getExpr());
1315 case Expr::CXXDefaultInitExprClass:
1316 return canThrow(cast<CXXDefaultInitExpr>(S)->getExpr());
1318 case Expr::ChooseExprClass: {
1319 auto *CE = cast<ChooseExpr>(S);
1320 if (CE->isTypeDependent() || CE->isValueDependent())
1322 return canThrow(CE->getChosenSubExpr());
1325 case Expr::GenericSelectionExprClass:
1326 if (cast<GenericSelectionExpr>(S)->isResultDependent())
1328 return canThrow(cast<GenericSelectionExpr>(S)->getResultExpr());
1331 case Expr::CXXDependentScopeMemberExprClass:
1332 case Expr::CXXUnresolvedConstructExprClass:
1333 case Expr::DependentScopeDeclRefExprClass:
1334 case Expr::CXXFoldExprClass:
1337 case Expr::AsTypeExprClass:
1338 case Expr::BinaryConditionalOperatorClass:
1339 case Expr::BlockExprClass:
1340 case Expr::CUDAKernelCallExprClass:
1341 case Expr::DeclRefExprClass:
1342 case Expr::ObjCBridgedCastExprClass:
1343 case Expr::ObjCIndirectCopyRestoreExprClass:
1344 case Expr::ObjCProtocolExprClass:
1345 case Expr::ObjCSelectorExprClass:
1346 case Expr::ObjCAvailabilityCheckExprClass:
1347 case Expr::OffsetOfExprClass:
1348 case Expr::PackExpansionExprClass:
1349 case Expr::SubstNonTypeTemplateParmExprClass:
1350 case Expr::SubstNonTypeTemplateParmPackExprClass:
1351 case Expr::FunctionParmPackExprClass:
1352 case Expr::UnaryExprOrTypeTraitExprClass:
1353 case Expr::UnresolvedLookupExprClass:
1354 case Expr::UnresolvedMemberExprClass:
1355 case Expr::TypoExprClass:
1359 case Expr::AddrLabelExprClass:
1360 case Expr::ArrayTypeTraitExprClass:
1361 case Expr::AtomicExprClass:
1362 case Expr::TypeTraitExprClass:
1363 case Expr::CXXBoolLiteralExprClass:
1364 case Expr::CXXNoexceptExprClass:
1365 case Expr::CXXNullPtrLiteralExprClass:
1366 case Expr::CXXPseudoDestructorExprClass:
1367 case Expr::CXXScalarValueInitExprClass:
1368 case Expr::CXXThisExprClass:
1369 case Expr::CXXUuidofExprClass:
1370 case Expr::CharacterLiteralClass:
1371 case Expr::ExpressionTraitExprClass:
1372 case Expr::FloatingLiteralClass:
1373 case Expr::GNUNullExprClass:
1374 case Expr::ImaginaryLiteralClass:
1375 case Expr::ImplicitValueInitExprClass:
1376 case Expr::IntegerLiteralClass:
1377 case Expr::FixedPointLiteralClass:
1378 case Expr::ArrayInitIndexExprClass:
1379 case Expr::NoInitExprClass:
1380 case Expr::ObjCEncodeExprClass:
1381 case Expr::ObjCStringLiteralClass:
1382 case Expr::ObjCBoolLiteralExprClass:
1383 case Expr::OpaqueValueExprClass:
1384 case Expr::PredefinedExprClass:
1385 case Expr::SizeOfPackExprClass:
1386 case Expr::StringLiteralClass:
1387 case Expr::SourceLocExprClass:
1388 case Expr::ConceptSpecializationExprClass:
1389 case Expr::RequiresExprClass:
1393 case Expr::MSPropertyRefExprClass:
1394 case Expr::MSPropertySubscriptExprClass:
1395 llvm_unreachable(
"Invalid class for expression");
1398 case Stmt::AttributedStmtClass:
1399 case Stmt::BreakStmtClass:
1400 case Stmt::CapturedStmtClass:
1401 case Stmt::CaseStmtClass:
1402 case Stmt::CompoundStmtClass:
1403 case Stmt::ContinueStmtClass:
1404 case Stmt::CoreturnStmtClass:
1405 case Stmt::CoroutineBodyStmtClass:
1406 case Stmt::CXXCatchStmtClass:
1407 case Stmt::CXXForRangeStmtClass:
1408 case Stmt::DefaultStmtClass:
1409 case Stmt::DoStmtClass:
1410 case Stmt::ForStmtClass:
1411 case Stmt::GCCAsmStmtClass:
1412 case Stmt::GotoStmtClass:
1413 case Stmt::IndirectGotoStmtClass:
1414 case Stmt::LabelStmtClass:
1415 case Stmt::MSAsmStmtClass:
1416 case Stmt::MSDependentExistsStmtClass:
1417 case Stmt::NullStmtClass:
1418 case Stmt::ObjCAtCatchStmtClass:
1419 case Stmt::ObjCAtFinallyStmtClass:
1420 case Stmt::ObjCAtSynchronizedStmtClass:
1421 case Stmt::ObjCAutoreleasePoolStmtClass:
1422 case Stmt::ObjCForCollectionStmtClass:
1423 case Stmt::OMPAtomicDirectiveClass:
1424 case Stmt::OMPBarrierDirectiveClass:
1425 case Stmt::OMPCancelDirectiveClass:
1426 case Stmt::OMPCancellationPointDirectiveClass:
1427 case Stmt::OMPCriticalDirectiveClass:
1428 case Stmt::OMPDistributeDirectiveClass:
1429 case Stmt::OMPDistributeParallelForDirectiveClass:
1430 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
1431 case Stmt::OMPDistributeSimdDirectiveClass:
1432 case Stmt::OMPFlushDirectiveClass:
1433 case Stmt::OMPForDirectiveClass:
1434 case Stmt::OMPForSimdDirectiveClass:
1435 case Stmt::OMPMasterDirectiveClass:
1436 case Stmt::OMPMasterTaskLoopDirectiveClass:
1437 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
1438 case Stmt::OMPOrderedDirectiveClass:
1439 case Stmt::OMPParallelDirectiveClass:
1440 case Stmt::OMPParallelForDirectiveClass:
1441 case Stmt::OMPParallelForSimdDirectiveClass:
1442 case Stmt::OMPParallelMasterDirectiveClass:
1443 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
1444 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
1445 case Stmt::OMPParallelSectionsDirectiveClass:
1446 case Stmt::OMPSectionDirectiveClass:
1447 case Stmt::OMPSectionsDirectiveClass:
1448 case Stmt::OMPSimdDirectiveClass:
1449 case Stmt::OMPSingleDirectiveClass:
1450 case Stmt::OMPTargetDataDirectiveClass:
1451 case Stmt::OMPTargetDirectiveClass:
1452 case Stmt::OMPTargetEnterDataDirectiveClass:
1453 case Stmt::OMPTargetExitDataDirectiveClass:
1454 case Stmt::OMPTargetParallelDirectiveClass:
1455 case Stmt::OMPTargetParallelForDirectiveClass:
1456 case Stmt::OMPTargetParallelForSimdDirectiveClass:
1457 case Stmt::OMPTargetSimdDirectiveClass:
1458 case Stmt::OMPTargetTeamsDirectiveClass:
1459 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
1460 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
1461 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
1462 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
1463 case Stmt::OMPTargetUpdateDirectiveClass:
1464 case Stmt::OMPTaskDirectiveClass:
1465 case Stmt::OMPTaskgroupDirectiveClass:
1466 case Stmt::OMPTaskLoopDirectiveClass:
1467 case Stmt::OMPTaskLoopSimdDirectiveClass:
1468 case Stmt::OMPTaskwaitDirectiveClass:
1469 case Stmt::OMPTaskyieldDirectiveClass:
1470 case Stmt::OMPTeamsDirectiveClass:
1471 case Stmt::OMPTeamsDistributeDirectiveClass:
1472 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
1473 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
1474 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
1475 case Stmt::ReturnStmtClass:
1476 case Stmt::SEHExceptStmtClass:
1477 case Stmt::SEHFinallyStmtClass:
1478 case Stmt::SEHLeaveStmtClass:
1479 case Stmt::SEHTryStmtClass:
1480 case Stmt::SwitchStmtClass:
1481 case Stmt::WhileStmtClass:
1484 case Stmt::DeclStmtClass: {
1486 for (
const Decl *D : cast<DeclStmt>(S)->decls()) {
1487 if (
auto *VD = dyn_cast<VarDecl>(D))
1491 if (
auto *TND = dyn_cast<TypedefNameDecl>(D))
1492 if (TND->getUnderlyingType()->isVariablyModifiedType())
1494 if (
auto *VD = dyn_cast<ValueDecl>(D))
1495 if (VD->getType()->isVariablyModifiedType())
1501 case Stmt::IfStmtClass: {
1502 auto *IS = cast<IfStmt>(S);
1504 if (
const Stmt *Init = IS->getInit())
1506 if (
const Stmt *CondDS = IS->getConditionVariableDeclStmt())
1526 case Stmt::CXXTryStmtClass: {
1527 auto *TS = cast<CXXTryStmt>(S);
1530 const CXXCatchStmt *FinalHandler = TS->getHandler(TS->getNumHandlers() - 1);
1531 if (!FinalHandler->getExceptionDecl())
1532 return canThrow(FinalHandler->getHandlerBlock());
1536 case Stmt::ObjCAtThrowStmtClass:
1539 case Stmt::ObjCAtTryStmtClass: {
1540 auto *TS = cast<ObjCAtTryStmt>(S);
1545 if (
const Stmt *Finally = TS->getFinallyStmt())
1547 for (
unsigned I = TS->getNumCatchStmts(); I != 0; --I) {
1560 llvm_unreachable(
"Invalid class for statement");
1562 llvm_unreachable(
"Bogus StmtClass");
Represents a function declaration or definition.
no exception specification
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isMemberPointerType() const
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
unsigned getNumExceptions() const
Return the number of types in the exception specification.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
Stmt - This represents one statement.
ExprResult ActOnNoexceptSpec(SourceLocation NoexceptLoc, Expr *NoexceptExpr, ExceptionSpecificationType &EST)
Check the given noexcept-specifier, convert its expression, and compute the appropriate ExceptionSpec...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Defines the SourceManager interface.
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 isRecordType() const
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const FunctionProtoType *Target, SourceLocation TargetLoc, const FunctionProtoType *Source, SourceLocation SourceLoc)
CheckParamExceptionSpec - Check if the parameter and return types of the two functions have equivalen...
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
SourceLocation getBeginLoc() const LLVM_READONLY
Represent a C++ namespace.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
A container of type source information.
Represents a variable declaration or definition.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Information about one declarator, including the parsed type information and the identifier.
unsigned getNumParams() const
const T * getAs() const
Member-template getAs<specific type>'.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
unsigned getDiagID() const
Defines the Objective-C statement AST node classes.
Expr * getExprOperand() const
Defines the clang::Expr interface and subclasses for C++ expressions.
noexcept(expression), value-dependent
The collection of all-type qualifiers we support.
Base wrapper for a particular "section" of type source info.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
One of these records is kept for each identifier that is lexed.
bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID, const FunctionProtoType *Superset, SourceLocation SuperLoc, const FunctionProtoType *Subset, SourceLocation SubLoc)
CheckExceptionSpecSubset - Check whether the second function type's exception specification is a subs...
SmallVector< std::pair< FunctionDecl *, FunctionDecl * >, 2 > DelayedEquivalentExceptionSpecChecks
All the function redeclarations seen during a class definition that had their exception spec checks d...
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
ArrayRef< QualType > getParamTypes() const
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isReferenceType() const
Represents Objective-C's @catch statement.
bool isReplaceableGlobalAllocationFunction(bool *IsAligned=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
static CanThrowResult canSubStmtsThrow(Sema &Self, const Stmt *S)
Microsoft throw(...) extension.
static CanThrowResult canVarDeclThrow(Sema &Self, const VarDecl *VD)
CanThrowResult canThrow(const Stmt *E)
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec...
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument for this lambda expression (which initializes the first ca...
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
static bool CheckSpecForTypesEquivalent(Sema &S, const PartialDiagnostic &DiagID, const PartialDiagnostic &NoteID, QualType Target, SourceLocation TargetLoc, QualType Source, SourceLocation SourceLoc)
Defines the Diagnostic-related interfaces.
void EvaluateImplicitExceptionSpec(SourceLocation Loc, FunctionDecl *FD)
Evaluate the implicit exception specification for a defaulted special member function.
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.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
const LangOptions & getLangOpts() const
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.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
IdentifierInfo * getIdentifier() const
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Sema - This implements semantic analysis and AST building for C.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
FunctionDecl * getExceptionSpecDecl() const
If this function type has an exception specification which hasn't been determined yet (either because...
Represents a prototype with parameter type info, e.g.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
CanThrowResult mergeCanThrow(CanThrowResult CT1, CanThrowResult CT2)
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
QualType getPointeeType() const
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
const T * castAs() const
Member-template castAs<specific type>.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isNullPtrType() const
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
bool handlerCanCatch(QualType HandlerType, QualType ExceptionType)
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
The result type of a method or function.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static CanThrowResult canDynamicCastThrow(const CXXDynamicCastExpr *DC)
bool isConstQualified() const
Determine whether this type is const-qualified.
RecordDecl * getDecl() const
noexcept(expression), evals to 'false'
CanThrowResult
Possible results from evaluation of a noexcept expression.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ExceptionSpecificationType Type
The kind of exception specification this is.
TypeLoc IgnoreParens() const
ExtProtoInfo getExtProtoInfo() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Encodes a location in the source.
QualType getReturnType() const
bool CheckDistantExceptionSpec(QualType T)
CheckDistantExceptionSpec - Check if the given type is a pointer or pointer to member to a function w...
CastKind getCastKind() const
Represents a static or instance method of a struct/union/class.
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
static bool hasImplicitExceptionSpec(FunctionDecl *Decl)
Determine whether a function has an implicitly-generated exception specification. ...
bool isStdNamespace() const
static CanThrowResult canTypeidThrow(Sema &S, const CXXTypeidExpr *DC)
Represents a canonical, potentially-qualified type.
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
bool isLibstdcxxEagerExceptionSpecHack(const Declarator &D)
Determine if we're in a case where we need to (incorrectly) eagerly parse an exception specification ...
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.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
exception_iterator exception_begin() const
StringRef getName() const
Return the actual identifier string.
bool isTypeOperand() const
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
not evaluated yet, for special member function
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
ASTMutationListener * getASTMutationListener() const
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
bool NE(InterpState &S, CodePtr OpPC)
const Expr * getInit() const
StmtClass getStmtClass() const
ArrayRef< QualType > exceptions() const
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i...
A pointer to member type per C++ 8.3.3 - Pointers to members.
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &ESI)
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
bool isFunctionType() const
TypeSourceInfo * getTypeSourceInfo() const
Base for LValueReferenceType and RValueReferenceType.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Holds information about the various types of exception specification.
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.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
bool isObjectType() const
Determine whether this type is an object type.
SourceManager & getSourceManager()
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getParamType(unsigned i) const
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
Represents a C++ struct/union/class.
CXXCatchStmt - This represents a C++ catch block.
bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range)
CheckSpecifiedExceptionType - Check if the given type is valid in an exception specification.
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.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated, or computed.
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
Microsoft __declspec(nothrow) extension.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
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.
bool isPointerType() const
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
static bool exceptionSpecNotKnownYet(const FunctionDecl *FD)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
A trivial tuple used to represent a source range.
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
A boolean literal, per ([C++ lex.bool] Boolean literals).
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
void setType(QualType newType)
SourceLocation getBegin() const
static const FunctionProtoType * GetUnderlyingFunction(QualType T)
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
SourceLocation getLocation() const
QualType getType() const
Return the type wrapped by this type source info.
noexcept(expression), evals to 'true'
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...