51#include "llvm/ADT/ArrayRef.h"
52#include "llvm/ADT/STLExtras.h"
53#include "llvm/ADT/StringExtras.h"
54#include "llvm/Support/ConvertUTF.h"
55#include "llvm/Support/SaveAndRestore.h"
72class CheckDefaultArgumentVisitor
75 const Expr *DefaultArg;
78 CheckDefaultArgumentVisitor(Sema &S,
const Expr *DefaultArg)
79 : S(S), DefaultArg(DefaultArg) {}
81 bool VisitExpr(
const Expr *Node);
82 bool VisitDeclRefExpr(
const DeclRefExpr *DRE);
83 bool VisitCXXThisExpr(
const CXXThisExpr *ThisE);
84 bool VisitLambdaExpr(
const LambdaExpr *Lambda);
85 bool VisitPseudoObjectExpr(
const PseudoObjectExpr *POE);
89bool CheckDefaultArgumentVisitor::VisitExpr(
const Expr *Node) {
90 bool IsInvalid =
false;
91 for (
const Stmt *SubStmt : Node->
children())
93 IsInvalid |= Visit(SubStmt);
100bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
const DeclRefExpr *DRE) {
101 const ValueDecl *
Decl = dyn_cast<ValueDecl>(DRE->
getDecl());
106 if (
const auto *Param = dyn_cast<ParmVarDecl>(Decl)) {
117 diag::err_param_default_argument_references_param)
119 }
else if (
auto *VD =
Decl->getPotentiallyDecomposedVarDecl()) {
134 diag::err_param_default_argument_references_local)
141bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
const CXXThisExpr *ThisE) {
146 diag::err_param_default_argument_references_this)
150bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
151 const PseudoObjectExpr *POE) {
155 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E)) {
156 E = OVE->getSourceExpr();
157 assert(E &&
"pseudo-object binding without source expression?");
165bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
const LambdaExpr *Lambda) {
172 for (
const LambdaCapture &LC : Lambda->
captures()) {
174 return S.
Diag(LC.getLocation(), diag::err_lambda_capture_default_arg);
177 Invalid |= Visit(D->getInit());
192 Proto = Self->ResolveExceptionSpec(CallLoc, Proto);
209 llvm_unreachable(
"should not see unresolved exception specs here");
238 "should not generate implicit declarations for dependent cases");
242 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
244 "Shouldn't collect exceptions when throw-all is guaranteed.");
248 if (ExceptionsSeen.insert(Self->Context.getCanonicalType(E)).second)
249 Exceptions.push_back(E);
277 if (Self->canThrow(S))
284 diag::err_typecheck_decl_incomplete_type))
303 CheckCompletedExpr(Arg, EqualLoc);
312 Param->setDefaultArg(Arg);
316 UnparsedDefaultArgInstantiationsMap::iterator InstPos
319 for (
unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
320 InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
330 if (!param || !DefaultArg)
338 Diag(EqualLoc, diag::err_param_default_argument)
350 if (Param->isParameterPack()) {
351 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
354 Param->setDefaultArg(
nullptr);
365 CheckDefaultArgumentVisitor DefaultArgChecker(*
this, DefaultArg);
366 if (DefaultArgChecker.Visit(DefaultArg))
379 Param->setUnparsedDefaultArg();
389 Param->setInvalidDecl();
394 Param->getType().getNonReferenceType());
397 Param->getType().getNonReferenceType());
399 Param->setDefaultArg(RE.
get());
414 if (MightBeFunction) {
418 MightBeFunction =
false;
421 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
424 if (Param->hasUnparsedDefaultArg()) {
425 std::unique_ptr<CachedTokens> Toks =
428 if (Toks->size() > 1)
430 Toks->back().getLocation());
433 Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
435 }
else if (Param->getDefaultArg()) {
436 Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
437 << Param->getDefaultArg()->getSourceRange();
438 Param->setDefaultArg(
nullptr);
442 MightBeFunction =
false;
449 return P->hasDefaultArg() && !P->hasInheritedDefaultArg();
461 ?
New->getLexicalDeclContext()
462 :
New->getDeclContext();
466 for (; PrevForDefaultArgs;
469 PrevForDefaultArgs =
New->isLocalExternDecl()
477 !
New->isCXXClassMember()) {
514 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
517 p < NumParams; ++p) {
521 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
524 if (OldParamHasDfl && NewParamHasDfl) {
525 unsigned DiagDefaultParamID =
526 diag::err_param_default_argument_redefinition;
541 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
559 for (
auto Older = PrevForDefaultArgs;
561 Older = Older->getPreviousDecl();
562 OldParam = Older->getParamDecl(p);
567 }
else if (OldParamHasDfl) {
573 !
New->getLexicalDeclContext()->isDependentContext()) {
585 }
else if (NewParamHasDfl) {
586 if (
New->getDescribedFunctionTemplate()) {
589 diag::err_param_default_argument_template_redecl)
592 diag::note_template_prev_declaration)
594 }
else if (
New->getTemplateSpecializationKind()
608 <<
New->getDeclName()
610 }
else if (
New->getDeclContext()->isDependentContext()) {
622 = dyn_cast<CXXRecordDecl>(
New->getDeclContext())) {
623 if (
Record->getDescribedClassTemplate())
632 diag::err_param_default_argument_member_template_redecl)
646 if (NewSM != OldSM) {
649 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
660 Diag(
New->getLocation(), diag::err_constexpr_redecl_mismatch)
670 (
New->isInlineSpecified() ||
675 Diag(
New->getLocation(), diag::err_inline_decl_follows_def) <<
New;
685 !
New->isFunctionTemplateSpecialization() &&
isVisible(Old)) {
686 Diag(
New->getLocation(), diag::err_deduction_guide_redeclared);
696 Diag(
New->getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
708 if (
New->isThisDeclarationInstantiatedFromAFriendDefinition() &&
717 ? diag::warn_cxx23_placeholder_var_definition
718 : diag::ext_placeholder_var_definition);
736 if (!TemplateParamLists.empty()) {
742 Diag(TemplateParamLists.front()->getTemplateLoc(),
743 diag::err_decomp_decl_template);
749 DiagID = diag::compat_pre_cxx17_decomp_decl;
752 ? diag::compat_cxx26_decomp_decl_cond
753 : diag::compat_pre_cxx26_decomp_decl_cond;
755 DiagID = diag::compat_cxx17_decomp_decl;
776 Diag(Loc, diag::err_decomp_decl_spec) << Name;
779 auto DiagCpp20Specifier = [&](StringRef Name,
SourceLocation Loc) {
780 DiagCompat(Loc, diag_compat::decomp_decl_spec) << Name;
783 if (
auto SCS = DS.getStorageClassSpec()) {
786 DS.getStorageClassSpecLoc());
789 DS.getStorageClassSpecLoc());
791 if (
auto TSCS = DS.getThreadStorageClassSpec())
793 DS.getThreadStorageClassSpecLoc());
795 if (DS.isInlineSpecified())
796 DiagBadSpecifier(
"inline", DS.getInlineSpecLoc());
803 DS.getConstexprSpecLoc());
814 Diag(DS.getVolatileSpecLoc(),
815 diag::warn_deprecated_volatile_structured_binding);
835 ? diag::err_decomp_decl_parens
836 : diag::err_decomp_decl_type)
847 if (DS.isConstrainedAuto()) {
850 "No other template kind should be possible for a constrained auto");
868 assert(VarName &&
"Cannot have an unnamed binding declaration");
877 Previous.getFoundDecl()->isTemplateParameter()) {
883 if (B.EllipsisLoc.isValid()) {
885 Diag(B.EllipsisLoc, diag::err_pack_outside_template);
886 QT =
Context.getPackExpansionType(
Context.DependentTy, std::nullopt,
918 auto *Old =
Previous.getRepresentativeDecl();
919 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
920 Diag(Old->getLocation(), diag::note_previous_definition);
938 bool AddToScope =
true;
947 if (
OpenMP().isInOpenMPDeclareTargetContext())
948 OpenMP().checkDeclIsAllowedInOpenMPTarget(
nullptr,
New);
958 unsigned MemberCount) {
959 auto BindingWithPackItr = llvm::find_if(
961 bool HasPack = BindingWithPackItr !=
Bindings.end();
964 IsValid =
Bindings.size() == MemberCount;
967 IsValid = MemberCount >=
Bindings.size() - 1;
970 if (IsValid && HasPack) {
972 unsigned PackSize = MemberCount -
Bindings.size() + 1;
978 for (
unsigned I = 0; I < PackSize; ++I) {
983 NestedBDs[I] = NestedBD;
1013 for (
auto *B : DD->flat_bindings()) {
1018 E = GetInit(Loc, E.
get(), I++);
1021 B->setBinding(ElemType, E.
get());
1030 const llvm::APSInt &NumElems,
1033 S,
Bindings, Src, DecompType, NumElems, ElemType,
1064 S,
Bindings, Src, DecompType, llvm::APSInt::get(2),
1068 return S.CreateBuiltinUnaryOp(Loc, I ? UO_Imag : UO_Real, Base);
1076 llvm::raw_svector_ostream OS(SS);
1088 return std::string(OS.str());
1093 auto DiagnoseMissing = [&] {
1103 return DiagnoseMissing();
1113 return DiagnoseMissing();
1114 if (Result.isAmbiguous())
1119 Result.suppressDiagnostics();
1121 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
1122 S.
Diag(
Found->getLocation(), diag::note_declared_at);
1136 Loc, TraitTy, DiagID,
1146 assert(RD &&
"specialization of class template is not a class?");
1151static TemplateArgumentLoc
1158static TemplateArgumentLoc
1163namespace {
enum class IsTupleLike { TupleLike, NotTupleLike, Error }; }
1166 unsigned &OutSize) {
1176 return IsTupleLike::NotTupleLike;
1184 return IsTupleLike::NotTupleLike;
1193 : R(R), Args(Args) {}
1196 return S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1200 } Diagnoser(R, Args);
1205 return IsTupleLike::Error;
1210 return IsTupleLike::Error;
1214 if (Size < 0 || Size >=
UINT_MAX) {
1217 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_invalid)
1220 << StringRef(Str.data(), Str.size());
1221 return IsTupleLike::Error;
1224 OutSize = Size.getExtValue();
1225 return IsTupleLike::TupleLike;
1239 diag::err_decomp_decl_std_tuple_element_not_specialized);
1251 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1264struct InitializingBinding {
1266 InitializingBinding(Sema &S, BindingDecl *BD) : S(S) {
1267 Sema::CodeSynthesisContext Ctx;
1273 ~InitializingBinding() {
1282 unsigned NumElems) {
1296 bool UseMemberGet =
false;
1306 dyn_cast<FunctionTemplateDecl>(D->getUnderlyingDecl())) {
1308 if (TPL->
size() != 0 &&
1311 UseMemberGet =
true;
1319 for (
auto *B : DD->flat_bindings()) {
1320 InitializingBinding InitContext(S, B);
1343 MemberGet, &Args,
nullptr);
1381 B->getDeclName().getAsIdentifierInfo(), RefType,
1385 RefVD->setImplicit();
1387 RefVD->setInlineSpecified();
1388 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1393 E =
Seq.Perform(S, Entity, Kind,
Init);
1399 RefVD->setInit(E.
get());
1408 B->setBinding(
T, E.
get());
1423 return Specifier->getType()->getAsCXXRecordDecl()->hasDirectFields();
1432 ClassWithFields = RD;
1444 for (
auto &P : Paths) {
1448 BestPath->back().Base->getType())) {
1450 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1451 <<
false << RD << BestPath->back().Base->getType()
1452 << P.back().Base->getType();
1454 }
else if (P.Access < BestPath->
Access) {
1460 QualType BaseType = BestPath->back().Base->getType();
1462 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1469 *BestPath, diag::err_decomp_decl_inaccessible_base);
1472 ClassWithFields = BaseType->getAsCXXRecordDecl();
1480 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1481 << (ClassWithFields == RD) << RD << ClassWithFields
1482 << Paths.
front().back().Base->getType();
1493 const auto *RD = cast_or_null<CXXRecordDecl>(BasePair.
getDecl());
1497 for (
auto *FD : RD->fields()) {
1498 if (FD->isUnnamedBitField())
1503 if (!FD->getDeclName()) {
1504 if (RD->isLambda()) {
1505 S.
Diag(Loc, diag::err_decomp_decl_lambda);
1506 S.
Diag(RD->getLocation(), diag::note_lambda_decl);
1510 if (FD->isAnonymousStructOrUnion()) {
1511 S.
Diag(Loc, diag::err_decomp_decl_anon_union_member)
1513 S.
Diag(FD->getLocation(), diag::note_declared_at);
1526 BasePair.
getAccess(), FD->getAccess())));
1535 diag::err_incomplete_type))
1541 const auto *RD = cast_or_null<CXXRecordDecl>(BasePair.
getDecl());
1548 unsigned NumFields = llvm::count_if(
1549 RD->fields(), [](
FieldDecl *FD) { return !FD->isUnnamedBitField(); });
1556 auto FlatBindings = DD->flat_bindings();
1557 assert(llvm::range_size(FlatBindings) == NumFields);
1558 auto FlatBindingsItr = FlatBindings.begin();
1564 for (
auto *FD : RD->fields()) {
1569 assert(FlatBindingsItr != FlatBindings.end());
1611 if (B->getType().isNull())
1612 B->setType(
Context.DependentTy);
1624 if (
auto *CAT =
Context.getAsConstantArrayType(DecompType)) {
1645 case IsTupleLike::Error:
1649 case IsTupleLike::TupleLike:
1654 case IsTupleLike::NotTupleLike:
1663 << DD << !RD << DecompType;
1678 assert(!
T->isDependentType());
1683 T =
Context.getQualifiedType(Unqual, Quals);
1686 return static_cast<unsigned>(CAT->getSize().getZExtValue());
1688 return VT->getNumElements();
1694 case IsTupleLike::Error:
1695 return std::nullopt;
1696 case IsTupleLike::TupleLike:
1698 case IsTupleLike::NotTupleLike:
1703 if (!OrigRD || OrigRD->
isUnion())
1704 return std::nullopt;
1707 return std::nullopt;
1712 const auto *RD = cast_or_null<CXXRecordDecl>(BasePair.
getDecl());
1714 return std::nullopt;
1716 unsigned NumFields = llvm::count_if(
1717 RD->fields(), [](
FieldDecl *FD) { return !FD->isUnnamedBitField(); });
1720 return std::nullopt;
1731 "Should only be called if types are otherwise the same.");
1758 New->setInvalidDecl();
1772 if (FTD->isMemberSpecialization())
1781 if (Param->hasDefaultArg())
1792 if (Param->hasDefaultArg() || Param->isParameterPack() ||
1796 if (Param->isInvalidDecl())
1798 else if (Param->getIdentifier())
1799 Diag(Param->getLocation(), diag::err_param_default_argument_missing_name)
1800 << Param->getIdentifier();
1802 Diag(Param->getLocation(), diag::err_param_default_argument_missing);
1809template <
typename... Ts>
1813 if (
T->isDependentType())
1819 std::forward<Ts>(DiagArgs)...);
1822 return !
T->isLiteralType(SemaRef.
Context);
1825 llvm_unreachable(
"unknown CheckConstexprKind");
1833 "this check is obsolete for C++23");
1836 T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
1844 SemaRef.
Diag(Loc, diag::note_constexpr_dtor_subobject)
1852 if (!Check(B.getBaseTypeLoc(), B.getType(),
nullptr))
1855 if (!Check(FD->getLocation(), FD->getType(), FD))
1866 "this check is obsolete for C++23");
1867 unsigned ArgIndex = 0;
1870 e = FT->param_type_end();
1871 i != e; ++i, ++ArgIndex) {
1873 assert(PD &&
"null in a parameter list");
1876 diag::err_constexpr_non_literal_param, ArgIndex + 1,
1889 "this check is obsolete for C++23");
1891 diag::err_constexpr_non_literal_return,
1910 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1938 for (
const auto &I : RD->
vbases())
1939 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
1940 << I.getSourceRange();
1954 Diag(
Method->getLocation(), diag::warn_cxx17_compat_constexpr_virtual);
1960 Diag(
Method->getLocation(), diag::err_constexpr_virtual);
1967 if (WrittenVirtual !=
Method)
1969 diag::note_overridden_virtual_function);
1980 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(NewFD)) {
1985 !Dtor->getParent()->defaultedDestructorIsConstexpr()) {
2000 "CheckConstexprFunctionDefinition called on function with no body");
2015 for (
const auto *DclIt : DS->
decls()) {
2016 switch (DclIt->getKind()) {
2017 case Decl::StaticAssert:
2019 case Decl::UsingShadow:
2020 case Decl::UsingDirective:
2021 case Decl::UnresolvedUsingTypename:
2022 case Decl::UnresolvedUsingValue:
2023 case Decl::UsingEnum:
2031 case Decl::TypeAlias: {
2035 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
2038 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
2049 case Decl::CXXRecord:
2054 diag_compat::constexpr_type_definition)
2062 case Decl::EnumConstant:
2063 case Decl::IndirectField:
2070 case Decl::Decomposition: {
2076 if (VD->isThisDeclarationADefinition()) {
2077 if (VD->isStaticLocal()) {
2080 diag_compat::constexpr_static_var)
2087 if (SemaRef.
LangOpts.CPlusPlus23) {
2089 diag::warn_cxx20_compat_constexpr_var,
2092 SemaRef, Kind, VD->getLocation(), VD->getType(),
2093 diag::err_constexpr_local_var_non_literal_type,
2097 if (!VD->getType()->isDependentType() &&
2098 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
2101 diag_compat::constexpr_local_var_no_init)
2110 SemaRef.
DiagCompat(VD->getLocation(), diag_compat::constexpr_local_var)
2118 case Decl::NamespaceAlias:
2119 case Decl::Function:
2128 SemaRef.
Diag(DS->
getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
2162 if (Field->isInvalidDecl())
2165 if (Field->isUnnamedBitField())
2171 if (Field->isAnonymousStructOrUnion() &&
2172 (Field->getType()->isUnionType()
2173 ? !Field->getType()->getAsCXXRecordDecl()->hasVariantMembers()
2174 : Field->getType()->getAsCXXRecordDecl()->isEmpty()))
2177 if (!Inits.count(Field)) {
2181 diag_compat::constexpr_ctor_missing_init);
2184 SemaRef.
Diag(Field->getLocation(),
2185 diag::note_constexpr_ctor_missing_init);
2189 }
else if (Field->isAnonymousStructOrUnion()) {
2190 const auto *RD = Field->getType()->castAsRecordDecl();
2191 for (
auto *I : RD->fields())
2194 if (!RD->isUnion() || Inits.count(I))
2212 case Stmt::NullStmtClass:
2216 case Stmt::DeclStmtClass:
2226 case Stmt::ReturnStmtClass:
2238 case Stmt::AttributedStmtClass:
2243 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind);
2245 case Stmt::CompoundStmtClass: {
2251 for (
auto *BodyIt : CompStmt->
body()) {
2253 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2259 case Stmt::IfStmtClass: {
2266 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2268 if (
If->getElse() &&
2270 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2275 case Stmt::WhileStmtClass:
2276 case Stmt::DoStmtClass:
2277 case Stmt::ForStmtClass:
2278 case Stmt::CXXForRangeStmtClass:
2279 case Stmt::ContinueStmtClass:
2289 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2294 case Stmt::SwitchStmtClass:
2295 case Stmt::CaseStmtClass:
2296 case Stmt::DefaultStmtClass:
2297 case Stmt::BreakStmtClass:
2305 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2310 case Stmt::LabelStmtClass:
2311 case Stmt::GotoStmtClass:
2317 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2322 case Stmt::GCCAsmStmtClass:
2323 case Stmt::MSAsmStmtClass:
2325 case Stmt::CXXTryStmtClass:
2331 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2336 case Stmt::CXXCatchStmtClass:
2341 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2393 diag_compat::constexpr_function_try_block)
2408 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2419 }
else if (Cxx2bLoc.
isValid()) {
2420 SemaRef.
DiagCompat(Cxx2bLoc, diag_compat::cxx23_constexpr_body_invalid_stmt)
2422 }
else if (Cxx2aLoc.
isValid()) {
2423 SemaRef.
DiagCompat(Cxx2aLoc, diag_compat::cxx20_constexpr_body_invalid_stmt)
2425 }
else if (Cxx1yLoc.
isValid()) {
2426 SemaRef.
DiagCompat(Cxx1yLoc, diag_compat::cxx14_constexpr_body_invalid_stmt)
2431 = dyn_cast<CXXConstructorDecl>(Dcl)) {
2444 diag_compat::constexpr_union_ctor_no_init);
2451 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
2455 bool AnyAnonStructUnionMembers =
false;
2456 unsigned Fields = 0;
2458 E = RD->
field_end(); I != E; ++I, ++Fields) {
2459 if (I->isAnonymousStructOrUnion()) {
2460 AnyAnonStructUnionMembers =
true;
2468 if (AnyAnonStructUnionMembers ||
2478 Inits.insert(ID->chain_begin(), ID->chain_end());
2481 bool Diagnosed =
false;
2482 for (
auto *I : RD->
fields())
2489 if (ReturnStmts.empty()) {
2504 }
else if (ReturnStmts.size() > 1) {
2508 diag_compat::constexpr_body_multiple_return);
2509 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2510 SemaRef.
Diag(ReturnStmts[I],
2511 diag::note_constexpr_body_previous_return);
2539 !SemaRef.
getLangOpts().CheckConstexprFunctionBodies ||
2542 diag::ext_constexpr_function_never_constant_expr, Dcl->
getLocation());
2547 diag::ext_constexpr_function_never_constant_expr)
2550 for (
size_t I = 0, N = Diags.size(); I != N; ++I)
2551 SemaRef.
Diag(Diags[I].first, Diags[I].second);
2566 if (SemaRef.
getLangOpts().CPlusPlus23 && !IsVoidOrDependentType)
2573 bool OK = SemaRef.
getLangOpts().CPlusPlus14 && IsVoidOrDependentType;
2575 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2576 : diag::err_constexpr_body_no_return)
2590 Diag(it->second, diag::err_immediate_function_used_before_definition)
2603 "expected an immediate function");
2604 assert(FD->
hasBody() &&
"expected the function to have a body");
2609 bool ImmediateFnIsConstructor;
2616 ShouldVisitImplicitCode =
true;
2617 ShouldVisitLambdaBody =
false;
2623 if (CurrentConstructor && CurrentInit) {
2631 SemaRef.Diag(Loc, diag::note_immediate_function_reason)
2632 << ImmediateFn << Fn << Fn->isConsteval() << IsCall
2634 << (InitializedField !=
nullptr)
2635 << (CurrentInit && !CurrentInit->
isWritten())
2636 << InitializedField << Range;
2638 bool TraverseCallExpr(
CallExpr *E)
override {
2639 if (
const auto *DR =
2641 DR && DR->isImmediateEscalating()) {
2647 if (!TraverseStmt(A))
2654 if (
const auto *ReferencedFn = dyn_cast<FunctionDecl>(E->
getDecl());
2656 Diag(E, ReferencedFn,
false);
2679 return DynamicRecursiveASTVisitor::TraverseCXXConstructorDecl(Ctr);
2682 bool TraverseType(
QualType T,
bool TraverseQualifier)
override {
2685 bool VisitBlockExpr(
BlockExpr *
T)
override {
return true; }
2687 } Visitor(*
this, FD);
2688 Visitor.TraverseDecl(FD);
2699 return dyn_cast_or_null<CXXRecordDecl>(DC);
2702 return dyn_cast_or_null<CXXRecordDecl>(
CurContext);
2720 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2722 CurDecl = dyn_cast_or_null<CXXRecordDecl>(
CurContext);
2741 if (BaseType->containsErrors()) {
2746 if (EllipsisLoc.
isValid() && !BaseType->containsUnexpandedParameterPack()) {
2747 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2761 if (BaseDecl->isUnion()) {
2762 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2766 if (BaseType.hasQualifiers()) {
2768 BaseType.getQualifiers().getAsString(
Context.getPrintingPolicy());
2769 Diag(BaseLoc, diag::warn_qual_base_type)
2770 << Quals << llvm::count(Quals,
' ') + 1 << BaseType;
2771 Diag(BaseLoc, diag::note_base_class_specified_here) << BaseType;
2775 if (
Context.getTargetInfo().getCXXABI().isMicrosoft() ||
2776 Context.getTargetInfo().getTriple().isPS()) {
2778 if (
auto *BaseSpec =
2779 dyn_cast<ClassTemplateSpecializationDecl>(BaseDecl)) {
2788 Class->setInvalidDecl();
2792 BaseDecl = BaseDecl->getDefinition();
2793 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2798 const auto *BaseCSA = BaseDecl->getAttr<CodeSegAttr>();
2799 const auto *DerivedCSA =
Class->getAttr<CodeSegAttr>();
2800 if ((DerivedCSA || BaseCSA) &&
2801 (!BaseCSA || !DerivedCSA ||
2802 BaseCSA->getName() != DerivedCSA->getName())) {
2803 Diag(
Class->getLocation(), diag::err_mismatched_code_seg_base);
2804 Diag(BaseDecl->getLocation(), diag::note_base_class_specified_here)
2815 if (BaseDecl->hasFlexibleArrayMember()) {
2816 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2817 << BaseDecl->getDeclName();
2824 if (FinalAttr *FA = BaseDecl->getAttr<FinalAttr>()) {
2825 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2826 << BaseDecl->getDeclName() << FA->isSpelledAsSealed();
2827 Diag(BaseDecl->getLocation(), diag::note_entity_declared_at)
2828 << BaseDecl->getDeclName() << FA->getRange();
2833 if (BaseDecl->isInvalidDecl())
2834 Class->setInvalidDecl();
2835 }
else if (BaseType->isDependentType()) {
2842 if (!
Class->isDependentContext())
2843 Class->setInvalidDecl();
2846 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2858 Access, TInfo, EllipsisLoc);
2875 Class->setIsParsingBaseSpecifiers();
2885 Diag(AL.getLoc(), diag::err_base_specifier_attribute)
2886 << AL << AL.isRegularKeywordAttribute() << AL.getRange();
2899 if (
Class->isUnion()) {
2900 Diag(
Class->getLocation(), diag::err_base_clause_on_union)
2910 Class->setInvalidDecl();
2927 for (
const auto &BaseSpec :
Decl->bases()) {
2928 QualType Base = Context.getCanonicalType(BaseSpec.getType())
2929 .getUnqualifiedType();
2946 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2953 unsigned NumGoodBases = 0;
2955 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2965 Diag(Bases[idx]->getBeginLoc(), diag::err_duplicate_base_class)
2966 << KnownBase->
getType() << Bases[idx]->getSourceRange();
2970 Context.Deallocate(Bases[idx]);
2975 KnownBase = Bases[idx];
2976 Bases[NumGoodBases++] = Bases[idx];
2981 if (Bases.size() > 1)
2985 if (
Class->isInterface() &&
2986 (!RD->isInterfaceLike() ||
2992 << RD->getSourceRange();
2995 if (RD->hasAttr<WeakAttr>())
3002 Class->setBases(Bases.data(), NumGoodBases);
3005 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
3007 QualType BaseType = Bases[idx]->getType();
3011 if (BaseType->isDependentType())
3015 .getUnqualifiedType();
3017 if (IndirectBaseTypes.count(CanonicalBase)) {
3021 =
Class->isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
3026 Diag(Bases[idx]->getBeginLoc(), diag::warn_inaccessible_base_class)
3028 << Bases[idx]->getSourceRange();
3030 assert(Bases[idx]->isVirtual());
3035 Context.Deallocate(Bases[idx]);
3043 if (!ClassDecl || Bases.empty())
3055 if (!
Base || !Derived)
3083 Base->getAsCXXRecordDecl(), Paths);
3089 Base->getAsCXXRecordDecl(), Paths);
3098 for (
unsigned I = Path.size(); I != 0; --I) {
3099 if (Path[I - 1].
Base->isVirtual()) {
3106 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
3113 assert(BasePathArray.empty() &&
"Base path array must be empty!");
3115 return ::BuildBasePathArray(Paths.
front(), BasePathArray);
3120 unsigned InaccessibleBaseID,
3121 unsigned AmbiguousBaseConvID,
3125 bool IgnoreAccess) {
3133 if (!DerivationOkay)
3138 Path = &Paths.
front();
3145 if (PossiblePath.size() == 1) {
3146 Path = &PossiblePath;
3147 if (AmbiguousBaseConvID)
3148 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
3149 <<
Base << Derived << Range;
3156 if (!IgnoreAccess) {
3175 if (AmbiguousBaseConvID) {
3185 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
3194 Diag(Loc, AmbiguousBaseConvID)
3195 << Derived <<
Base << PathDisplayStr << Range << Name;
3204 bool IgnoreAccess) {
3206 Derived,
Base, diag::err_upcast_to_inaccessible_base,
3207 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
3208 BasePath, IgnoreAccess);
3212 std::string PathDisplayStr;
3213 std::set<unsigned> DisplayedPaths;
3215 Path != Paths.
end(); ++Path) {
3216 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
3219 PathDisplayStr +=
"\n ";
3222 for (CXXBasePath::const_iterator Element = Path->begin();
3223 Element != Path->end(); ++Element)
3224 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
3228 return PathDisplayStr;
3238 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
3267 if (!OverloadedMethods.empty()) {
3268 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3269 Diag(OA->getLocation(),
3270 diag::override_keyword_hides_virtual_member_function)
3271 <<
"override" << (OverloadedMethods.size() > 1);
3272 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3273 Diag(FA->getLocation(),
3274 diag::override_keyword_hides_virtual_member_function)
3275 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3276 << (OverloadedMethods.size() > 1);
3287 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3288 Diag(OA->getLocation(),
3289 diag::override_keyword_only_allowed_on_virtual_member_functions)
3293 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3294 Diag(FA->getLocation(),
3295 diag::override_keyword_only_allowed_on_virtual_member_functions)
3296 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3308 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
3309 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
3323 SpellingLoc =
getSourceManager().getImmediateExpansionRange(Loc).getBegin();
3329 auto EmitDiag = [&](
unsigned DiagInconsistent,
unsigned DiagSuggest) {
3340 diag::warn_inconsistent_destructor_marked_not_override_overriding,
3341 diag::warn_suggest_destructor_marked_not_override_overriding);
3343 EmitDiag(diag::warn_inconsistent_function_marked_not_override_overriding,
3344 diag::warn_suggest_function_marked_not_override_overriding);
3350 FinalAttr *FA = Old->
getAttr<FinalAttr>();
3354 Diag(
New->getLocation(), diag::err_final_function_overridden)
3355 <<
New->getDeclName()
3356 << FA->isSpelledAsSealed();
3365 return !RD->isCompleteDefinition() ||
3366 !RD->hasTrivialDefaultConstructor() ||
3367 !RD->hasTrivialDestructor();
3371void Sema::CheckShadowInheritedFields(
const SourceLocation &Loc,
3372 DeclarationName FieldName,
3373 const CXXRecordDecl *RD,
3375 if (Diags.isIgnored(diag::warn_shadow_field, Loc))
3379 std::map<CXXRecordDecl*, NamedDecl*> Bases;
3380 auto FieldShadowed = [&](
const CXXBaseSpecifier *
Specifier,
3381 CXXBasePath &Path) {
3382 const auto Base =
Specifier->getType()->getAsCXXRecordDecl();
3384 if (Bases.find(Base) != Bases.end())
3386 for (
const auto Field :
Base->lookup(FieldName)) {
3390 assert(Bases.find(Base) == Bases.end());
3398 CXXBasePaths Paths(
true,
true,
3403 for (
const auto &P : Paths) {
3404 auto Base = P.back().Base->getType()->getAsCXXRecordDecl();
3405 auto It = Bases.find(Base);
3407 if (It == Bases.end())
3409 auto BaseField = It->second;
3410 assert(BaseField->getAccess() !=
AS_private);
3413 Diag(Loc, diag::warn_shadow_field)
3414 << FieldName << RD <<
Base << DeclIsField;
3415 Diag(BaseField->getLocation(), diag::note_shadow_field);
3421template <
typename AttrType>
3423 if (
const TagDecl *TD =
T->getAsTagDecl())
3424 return TD->hasAttr<AttrType>();
3426 return TDT->getDecl()->hasAttr<AttrType>();
3469 unsigned InvalidDecl;
3470 bool ShowDeclName =
true;
3483 ShowDeclName =
false;
3488 ShowDeclName =
false;
3503 Diag(Loc, diag::err_invalid_member_in_interface)
3504 << (InvalidDecl-1) << Name;
3506 Diag(Loc, diag::err_invalid_member_in_interface)
3507 << (InvalidDecl-1) <<
"";
3533 diag::err_storageclass_invalid_for_member);
3540 !isFunc && TemplateParameterLists.empty();
3553 const char *PrevSpec;
3558 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3562 const char *PrevSpec;
3566 Context.getPrintingPolicy())) {
3568 "This is the only DeclSpec that should fail to be applied");
3572 isInstField =
false;
3583 Diag(Loc, diag::err_bad_variable_name)
3620 if (MSPropertyAttr) {
3622 BitWidth, InitStyle, AS, *MSPropertyAttr);
3625 isInstField =
false;
3628 BitWidth, InitStyle, AS);
3641 if (
Member->isInvalidDecl()) {
3646 Diag(Loc, diag::err_static_not_bitfield)
3650 Diag(Loc, diag::err_typedef_not_bitfield)
3655 Diag(Loc, diag::err_not_integral_type_bitfield)
3656 << Name << cast<ValueDecl>(
Member)->getType()
3661 Member->setInvalidDecl();
3666 NonTemplateMember = FunTmpl->getTemplatedDecl();
3668 NonTemplateMember = VarTmpl->getTemplatedDecl();
3674 if (NonTemplateMember !=
Member)
3680 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3681 auto *TD = DG->getDeducedTemplate();
3684 if (AS != TD->getAccess() &&
3685 TD->getDeclContext()->getRedeclContext()->Equals(
3686 DG->getDeclContext()->getRedeclContext())) {
3687 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
3688 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
3692 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(D))
3693 LastAccessSpec = AccessSpec;
3695 assert(LastAccessSpec &&
"differing access with no access specifier");
3696 Diag(LastAccessSpec->
getBeginLoc(), diag::note_deduction_guide_access)
3707 ? FinalAttr::Keyword_sealed
3708 : FinalAttr::Keyword_final));
3718 assert((Name || isInstField) &&
"No identifier for non-field ?");
3724 if (!
Diags.isIgnored(diag::warn_unused_private_field, FD->
getLocation()) &&
3736 class UninitializedFieldVisitor
3741 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3744 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3759 UninitializedFieldVisitor(
Sema &S,
3760 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3761 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3762 : Inherited(S.Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3766 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3767 bool CheckReferenceOnly) {
3769 bool ReferenceField =
false;
3774 Fields.push_back(FD);
3776 ReferenceField =
true;
3782 if (CheckReferenceOnly && !ReferenceField)
3787 auto UsedFields = llvm::drop_begin(llvm::reverse(Fields));
3788 auto UsedIter = UsedFields.begin();
3789 const auto UsedEnd = UsedFields.end();
3791 for (
const unsigned Orig : InitFieldIndex) {
3792 if (UsedIter == UsedEnd)
3794 const unsigned UsedIndex = (*UsedIter)->getFieldIndex();
3795 if (UsedIndex < Orig)
3797 if (UsedIndex > Orig)
3805 void HandleMemberExpr(MemberExpr *ME,
bool CheckReferenceOnly,
3812 MemberExpr *FieldME = ME;
3817 while (MemberExpr *SubME =
3818 dyn_cast<MemberExpr>(
Base->IgnoreParenImpCasts())) {
3823 if (FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3828 AllPODFields =
false;
3830 Base = SubME->getBase();
3838 if (AddressOf && AllPODFields)
3843 if (ImplicitCastExpr *BaseCast = dyn_cast<ImplicitCastExpr>(Base)) {
3848 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3849 QualType
T = BaseCast->getType();
3858 if (!Decls.count(FoundVD))
3863 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3865 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3870 if (CheckReferenceOnly && !IsReference)
3874 unsigned diag = IsReference
3875 ? diag::warn_reference_field_is_uninit
3876 : diag::warn_field_is_uninit;
3880 diag::note_uninit_in_this_constructor)
3885 void HandleValue(Expr *E,
bool AddressOf) {
3888 if (MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3889 HandleMemberExpr(ME,
false ,
3894 if (ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E)) {
3895 Visit(CO->getCond());
3896 HandleValue(CO->getTrueExpr(), AddressOf);
3897 HandleValue(CO->getFalseExpr(), AddressOf);
3901 if (BinaryConditionalOperator *BCO =
3902 dyn_cast<BinaryConditionalOperator>(E)) {
3903 Visit(BCO->getCond());
3904 HandleValue(BCO->getFalseExpr(), AddressOf);
3908 if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E)) {
3909 HandleValue(OVE->getSourceExpr(), AddressOf);
3913 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
3914 switch (BO->getOpcode()) {
3919 HandleValue(BO->getLHS(), AddressOf);
3920 Visit(BO->getRHS());
3923 Visit(BO->getLHS());
3924 HandleValue(BO->getRHS(), AddressOf);
3932 void CheckInitListExpr(InitListExpr *ILE) {
3933 InitFieldIndex.push_back(0);
3934 for (
auto *Child : ILE->
children()) {
3935 if (InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3936 CheckInitListExpr(SubList);
3940 ++InitFieldIndex.back();
3942 InitFieldIndex.pop_back();
3945 void CheckInitializer(Expr *E,
const CXXConstructorDecl *FieldConstructor,
3946 FieldDecl *Field,
const Type *BaseClass) {
3949 for (ValueDecl* VD : DeclsToRemove)
3951 DeclsToRemove.clear();
3954 InitListExpr *ILE = dyn_cast<InitListExpr>(E);
3958 InitListFieldDecl =
Field;
3959 InitFieldIndex.clear();
3960 CheckInitListExpr(ILE);
3972 void VisitMemberExpr(MemberExpr *ME) {
3974 HandleMemberExpr(ME,
true ,
false );
3977 void VisitImplicitCastExpr(ImplicitCastExpr *E) {
3983 Inherited::VisitImplicitCastExpr(E);
3986 void VisitCXXConstructExpr(CXXConstructExpr *E) {
3988 Expr *ArgExpr = E->
getArg(0);
3989 if (InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3992 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(ArgExpr))
3993 if (ICE->getCastKind() == CK_NoOp)
3994 ArgExpr = ICE->getSubExpr();
3995 HandleValue(ArgExpr,
false );
3998 Inherited::VisitCXXConstructExpr(E);
4001 void VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
4004 HandleValue(Callee,
false );
4010 Inherited::VisitCXXMemberCallExpr(E);
4013 void VisitCallExpr(CallExpr *E) {
4016 HandleValue(E->
getArg(0),
false);
4020 Inherited::VisitCallExpr(E);
4023 void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
4027 return Inherited::VisitCXXOperatorCallExpr(E);
4031 HandleValue(Arg->IgnoreParenImpCasts(),
false );
4034 void VisitBinaryOperator(BinaryOperator *E) {
4038 if (MemberExpr *ME = dyn_cast<MemberExpr>(E->
getLHS()))
4039 if (FieldDecl *FD = dyn_cast<FieldDecl>(ME->
getMemberDecl()))
4041 DeclsToRemove.push_back(FD);
4044 HandleValue(E->
getLHS(),
false );
4049 Inherited::VisitBinaryOperator(E);
4052 void VisitUnaryOperator(UnaryOperator *E) {
4058 if (MemberExpr *ME = dyn_cast<MemberExpr>(E->
getSubExpr())) {
4059 HandleValue(ME->
getBase(),
true );
4064 Inherited::VisitUnaryOperator(E);
4074 static void DiagnoseUninitializedFields(
4075 Sema &SemaRef,
const CXXConstructorDecl *
Constructor) {
4091 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
4094 for (
auto *I : RD->
decls()) {
4095 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
4096 UninitializedFields.insert(FD);
4097 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
4098 UninitializedFields.insert(IFD->getAnonField());
4102 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
4103 for (
const auto &I : RD->
bases())
4104 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
4106 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
4109 UninitializedFieldVisitor UninitializedChecker(SemaRef,
4110 UninitializedFields,
4111 UninitializedBaseClasses);
4113 for (
const auto *FieldInit :
Constructor->inits()) {
4114 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
4117 Expr *InitExpr = FieldInit->getInit();
4121 if (CXXDefaultInitExpr *
Default =
4122 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
4123 InitExpr =
Default->getExpr();
4127 UninitializedChecker.CheckInitializer(InitExpr,
Constructor,
4128 FieldInit->getAnyMember(),
4129 FieldInit->getBaseClass());
4131 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
4132 FieldInit->getAnyMember(),
4133 FieldInit->getBaseClass());
4154 if (ParamDecl->getDeclName())
4171 return ConstraintExpr;
4186 return Seq.Perform(*
this, Entity, Kind, InitExpr);
4204 "must set init style when field is created");
4241 DirectBaseSpec =
nullptr;
4242 for (
const auto &
Base : ClassDecl->
bases()) {
4246 DirectBaseSpec = &
Base;
4254 VirtualBaseSpec =
nullptr;
4255 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
4264 Path != Paths.
end(); ++Path) {
4265 if (Path->back().Base->isVirtual()) {
4266 VirtualBaseSpec = Path->back().Base;
4273 return DirectBaseSpec || VirtualBaseSpec;
4287 DS, IdLoc, InitList,
4305 DS, IdLoc, List, EllipsisLoc);
4314 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
4315 : ClassDecl(ClassDecl) {}
4317 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4320 return Member->getDeclContext()->getRedeclContext()->Equals(ClassDecl);
4326 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
4327 return std::make_unique<MemInitializerValidatorCCC>(*
this);
4331 CXXRecordDecl *ClassDecl;
4348 Diag(Loc, diag::err_using_placeholder_variable) << Name;
4364 for (
auto *D : ClassDecl->
lookup(MemberOrBase)) {
4366 bool IsPlaceholder = D->isPlaceholderVar(
getLangOpts());
4368 if (IsPlaceholder && D->getDeclContext() == ND->
getDeclContext())
4399 if (!ConstructorD || !
Init)
4405 = dyn_cast<CXXConstructorDecl>(ConstructorD);
4429 ClassDecl, SS, TemplateTypeTy, MemberOrBase)) {
4431 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
4441 if (TemplateTypeTy) {
4443 if (BaseType.isNull())
4466 bool NotUnknownSpecialization =
false;
4469 NotUnknownSpecialization = !
Record->hasAnyDependentBases();
4471 if (!NotUnknownSpecialization) {
4477 if (BaseType.isNull())
4480 TInfo =
Context.CreateTypeSourceInfo(BaseType);
4497 UnqualifiedBase->getCanonicalInjectedSpecializationType(
Context));
4499 for (
auto const &
Base : ClassDecl->
bases()) {
4501 Base.getType()->getAs<TemplateSpecializationType>();
4503 Context.hasSameTemplateName(BaseTemplate->getTemplateName(), TN,
4505 Diag(IdLoc, diag::ext_unqualified_base_class)
4507 BaseType =
Base.getType();
4516 MemInitializerValidatorCCC CCC(ClassDecl);
4517 if (R.
empty() && BaseType.isNull() &&
4526 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4527 << MemberOrBase <<
true);
4534 DirectBaseSpec, VirtualBaseSpec)) {
4539 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4540 << MemberOrBase <<
false,
4553 if (!TyD && BaseType.isNull()) {
4554 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
4555 << MemberOrBase <<
SourceRange(IdLoc,
Init->getSourceRange().getEnd());
4560 if (BaseType.isNull()) {
4565 if (
const auto *TD = dyn_cast<TagDecl>(TyD)) {
4571 TL.setNameLoc(IdLoc);
4572 }
else if (
auto *TN = dyn_cast<TypedefNameDecl>(TyD)) {
4578 }
else if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TyD)) {
4587 BaseType =
Context.getTypeDeclType(TyD);
4595 TInfo =
Context.getTrivialTypeSourceInfo(BaseType, IdLoc);
4605 assert((DirectMember || IndirectMember) &&
4606 "Member must be a FieldDecl or IndirectFieldDecl");
4611 if (
Member->isInvalidDecl())
4616 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4618 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
4626 if (
Member->getType()->isDependentType() ||
Init->isTypeDependent()) {
4631 bool InitList =
false;
4644 IdLoc,
Init->getBeginLoc(),
Init->getEndLoc())
4688 return Diag(NameLoc, diag::err_delegating_ctor)
4690 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4692 bool InitList =
true;
4696 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4707 NameLoc,
Init->getBeginLoc(),
Init->getEndLoc())
4716 "Delegating constructor with no target?");
4722 DelegationInit.
get(), InitRange.
getBegin(),
false);
4727 InitRange.
getEnd(), Args, ClassType);
4739 DelegationInit =
Init;
4753 if (!BaseType->isDependentType() && !BaseType->isRecordType())
4754 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4768 (BaseType->isDependentType() ||
Init->isTypeDependent());
4773 if (!BaseType->containsUnexpandedParameterPack()) {
4774 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4802 if (!DirectBaseSpec && !VirtualBaseSpec) {
4811 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4812 << BaseType <<
Context.getCanonicalTagType(ClassDecl)
4823 InitRange.
getEnd(), EllipsisLoc);
4830 if (DirectBaseSpec && VirtualBaseSpec)
4831 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4836 BaseSpec = VirtualBaseSpec;
4839 bool InitList =
true;
4843 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4883 InitRange.
getEnd(), EllipsisLoc);
4893 TargetType, ExprLoc);
4913 bool IsInheritedVirtualBase,
4917 IsInheritedVirtualBase);
4921 switch (ImplicitInitKind) {
4927 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, {});
4933 bool Moving = ImplicitInitKind ==
IIK_Move;
4935 QualType ParamType = Param->getType().getNonReferenceType();
4955 BasePath.push_back(BaseSpec);
4957 CK_UncheckedDerivedToBase,
4965 BaseInit = InitSeq.
Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4997 if (Field->isInvalidDecl())
5003 bool Moving = ImplicitInitKind ==
IIK_Move;
5005 QualType ParamType = Param->getType().getNonReferenceType();
5008 if (Field->isZeroLengthBitField())
5011 Expr *MemberExprBase =
5024 LookupResult MemberLookup(SemaRef, Field->getDeclName(), Loc,
5062 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
5077 "Unhandled implicit init kind!");
5092 ExprResult MemberInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, {});
5095 if (MemberInit.isInvalid())
5112 if (!Field->getParent()->isUnion()) {
5115 diag::err_uninitialized_member_in_ctor)
5118 << Field->getDeclName();
5119 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
5125 diag::err_uninitialized_member_in_ctor)
5128 << Field->getDeclName();
5129 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
5146 CXXMemberInit =
nullptr;
5151struct BaseAndFieldInfo {
5153 CXXConstructorDecl *Ctor;
5154 bool AnyErrorsInInits;
5156 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
5157 SmallVector<CXXCtorInitializer*, 8> AllToInit;
5158 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
5160 BaseAndFieldInfo(Sema &S, CXXConstructorDecl *Ctor,
bool ErrorsInInits)
5161 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
5173 bool isImplicitCopyOrMove()
const {
5184 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
5187 bool addFieldInitializer(CXXCtorInitializer *
Init) {
5188 AllToInit.push_back(
Init);
5197 bool isInactiveUnionMember(FieldDecl *Field) {
5202 if (FieldDecl *Active =
5203 ActiveUnionMember.lookup(
Record->getCanonicalDecl()))
5204 return Active !=
Field->getCanonicalDecl();
5207 if (isImplicitCopyOrMove())
5212 if (
Field->hasInClassInitializer())
5216 if (!
Field->isAnonymousStructOrUnion())
5218 CXXRecordDecl *FieldRD =
Field->getType()->getAsCXXRecordDecl();
5225 bool isWithinInactiveUnionMember(FieldDecl *Field,
5226 IndirectFieldDecl *Indirect) {
5228 return isInactiveUnionMember(Field);
5230 for (
auto *
C : Indirect->
chain()) {
5231 FieldDecl *
Field = dyn_cast<FieldDecl>(
C);
5232 if (Field && isInactiveUnionMember(Field))
5243 if (
T->isIncompleteArrayType())
5247 if (ArrayT->isZeroSize())
5250 T = ArrayT->getElementType();
5259 if (Field->isInvalidDecl())
5264 Info.AllBaseFields.lookup(Field->getCanonicalDecl()))
5265 return Info.addFieldInitializer(
Init);
5279 if (Info.isWithinInactiveUnionMember(Field, Indirect))
5282 if (Field->hasInClassInitializer() && !Info.isImplicitCopyOrMove()) {
5300 return Info.addFieldInitializer(
Init);
5310 if (Info.AnyErrorsInInits)
5321 return Info.addFieldInitializer(
Init);
5348 if (Class->isInvalidDecl())
5350 if (Class->hasIrrelevantDestructor())
5359 if (Field->isInvalidDecl())
5369 if (!FieldClassDecl)
5373 if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion())
5381 S.
PDiag(diag::err_access_dtor_field)
5382 << Field->getDeclName() << FieldType);
5395 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5402 if (Dtor && Dtor->
isUsed())
5403 VisitVirtualBases =
false;
5409 for (
const auto &
Base : ClassDecl->
bases()) {
5410 auto *BaseClassDecl =
Base.getType()->getAsCXXRecordDecl();
5415 if (
Base.isVirtual()) {
5416 if (!VisitVirtualBases)
5418 DirectVirtualBases.insert(BaseClassDecl);
5427 S.
PDiag(diag::err_access_dtor_base)
5428 <<
Base.getType() <<
Base.getSourceRange(),
5435 if (VisitVirtualBases)
5437 &DirectVirtualBases);
5445 if (!Initializers.empty()) {
5446 Constructor->setNumCtorInitializers(Initializers.size());
5449 memcpy(baseOrMemberInitializers, Initializers.data(),
5451 Constructor->setCtorInitializers(baseOrMemberInitializers);
5461 BaseAndFieldInfo Info(*
this,
Constructor, AnyErrors);
5469 bool HadError =
false;
5471 for (
unsigned i = 0; i < Initializers.size(); i++) {
5474 if (
Member->isBaseInitializer())
5475 Info.AllBaseFields[
Member->getBaseClass()->getAsCanonical<RecordType>()] =
5478 Info.AllBaseFields[
Member->getAnyMember()->getCanonicalDecl()] =
Member;
5481 for (
auto *
C : F->chain()) {
5484 Info.ActiveUnionMember.insert(std::make_pair(
5489 Info.ActiveUnionMember.insert(std::make_pair(
5497 for (
auto &I : ClassDecl->
bases()) {
5499 DirectVBases.insert(&I);
5503 for (
auto &VBase : ClassDecl->
vbases()) {
5505 VBase.getType()->getAsCanonical<RecordType>())) {
5513 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
5514 << VBase.getType() << ClassDecl;
5518 Info.AllToInit.push_back(
Value);
5519 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
5524 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
5527 &VBase, IsInheritedVirtualBase,
5533 Info.AllToInit.push_back(CXXBaseInit);
5540 if (
Base.isVirtual())
5544 Base.getType()->getAsCanonical<RecordType>())) {
5545 Info.AllToInit.push_back(
Value);
5546 }
else if (!AnyErrors) {
5555 Info.AllToInit.push_back(CXXBaseInit);
5560 for (
auto *Mem : ClassDecl->
decls()) {
5561 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
5566 if (F->isUnnamedBitField())
5572 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
5581 if (Info.isImplicitCopyOrMove())
5584 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
5585 if (F->getType()->isIncompleteArrayType()) {
5587 "Incomplete array type is not valid");
5599 unsigned NumInitializers = Info.AllToInit.size();
5600 if (NumInitializers > 0) {
5601 Constructor->setNumCtorInitializers(NumInitializers);
5604 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
5606 Constructor->setCtorInitializers(baseOrMemberInitializers);
5632 if (
const RecordType *RT = Field->getType()->getAsCanonical<RecordType>()) {
5640 IdealInits.push_back(Field->getCanonicalDecl());
5644 return Context.getCanonicalType(BaseType).getTypePtr();
5649 if (!
Member->isAnyMemberInitializer())
5652 return Member->getAnyMember()->getCanonicalDecl();
5658 if (
Previous->isAnyMemberInitializer())
5672 if (
Constructor->getDeclContext()->isDependentContext())
5677 bool ShouldCheckOrder =
false;
5678 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5680 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
5681 Init->getSourceLocation())) {
5682 ShouldCheckOrder =
true;
5686 if (!ShouldCheckOrder)
5697 for (
const auto &VBase : ClassDecl->
vbases())
5701 for (
const auto &
Base : ClassDecl->
bases()) {
5702 if (
Base.isVirtual())
5708 for (
auto *Field : ClassDecl->
fields()) {
5709 if (Field->isUnnamedBitField())
5715 unsigned NumIdealInits = IdealInitKeys.size();
5716 unsigned IdealIndex = 0;
5725 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5730 for (; IdealIndex != NumIdealInits; ++IdealIndex)
5731 if (InitKey == IdealInitKeys[IdealIndex])
5737 if (IdealIndex == NumIdealInits && InitIndex) {
5738 WarnIndexes.push_back(InitIndex);
5741 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
5742 if (InitKey == IdealInitKeys[IdealIndex])
5745 assert(IdealIndex < NumIdealInits &&
5746 "initializer not found in initializer list");
5748 CorrelatedInitOrder.emplace_back(IdealIndex, InitIndex);
5751 if (WarnIndexes.empty())
5755 llvm::sort(CorrelatedInitOrder, llvm::less_first());
5761 Inits[WarnIndexes.front() - 1]->getSourceLocation(),
5762 WarnIndexes.size() == 1 ? diag::warn_initializer_out_of_order
5763 : diag::warn_some_initializers_out_of_order);
5765 for (
unsigned I = 0; I < CorrelatedInitOrder.size(); ++I) {
5766 if (CorrelatedInitOrder[I].second == I)
5772 Inits[I]->getSourceRange(),
5775 Inits[CorrelatedInitOrder[I].second]->getSourceRange()),
5781 if (WarnIndexes.size() == 1) {
5783 Inits[WarnIndexes.front()]);
5789 for (
unsigned WarnIndex : WarnIndexes) {
5792 diag::note_initializer_out_of_order);
5799bool CheckRedundantInit(Sema &S,
5800 CXXCtorInitializer *
Init,
5801 CXXCtorInitializer *&PrevInit) {
5807 if (FieldDecl *Field =
Init->getAnyMember())
5809 diag::err_multiple_mem_initialization)
5810 <<
Field->getDeclName()
5811 <<
Init->getSourceRange();
5813 const Type *BaseClass =
Init->getBaseClass();
5814 assert(BaseClass &&
"neither field nor base");
5816 diag::err_multiple_base_initialization)
5817 << QualType(BaseClass, 0)
5818 <<
Init->getSourceRange();
5826typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5827typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5829bool CheckRedundantUnionInit(Sema &S,
5830 CXXCtorInitializer *
Init,
5831 RedundantUnionMap &Unions) {
5832 FieldDecl *
Field =
Init->getAnyMember();
5833 RecordDecl *Parent =
Field->getParent();
5834 NamedDecl *Child =
Field;
5838 UnionEntry &En = Unions[Parent];
5839 if (En.first && En.first != Child) {
5841 diag::err_multiple_mem_union_initialization)
5842 <<
Field->getDeclName()
5843 <<
Init->getSourceRange();
5844 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5845 << 0 << En.second->getSourceRange();
5868 if (!ConstructorDecl)
5874 = dyn_cast<CXXConstructorDecl>(ConstructorDecl);
5877 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5884 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5887 RedundantUnionMap MemberUnions;
5889 bool HadError =
false;
5890 for (
unsigned i = 0; i < MemInits.size(); i++) {
5894 Init->setSourceOrder(i);
5896 if (
Init->isAnyMemberInitializer()) {
5898 if (CheckRedundantInit(*
this,
Init, Members[Key]) ||
5899 CheckRedundantUnionInit(*
this,
Init, MemberUnions))
5901 }
else if (
Init->isBaseInitializer()) {
5903 if (CheckRedundantInit(*
this,
Init, Members[Key]))
5906 assert(
Init->isDelegatingInitializer());
5908 if (MemInits.size() != 1) {
5910 diag::err_delegating_initializer_alone)
5911 <<
Init->getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5943 for (
auto *Field : ClassDecl->
fields()) {
5952 llvm::SmallPtrSetImpl<const CXXRecordDecl *> *DirectVirtualBases) {
5954 for (
const auto &VBase : ClassDecl->
vbases()) {
5955 auto *BaseClassDecl = VBase.getType()->getAsCXXRecordDecl();
5960 if (DirectVirtualBases && DirectVirtualBases->count(BaseClassDecl))
5969 PDiag(diag::err_access_dtor_vbase)
5970 << CT << VBase.getType(),
5973 CT, VBase.getType(), diag::err_access_dtor_vbase, 0,
5987 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5989 !ClassDecl || ClassDecl->isInvalidDecl()) {
6001 const auto *RD =
Context.getBaseElementType(
T)->getAsCXXRecordDecl();
6038 if (
Diags.isLastDiagnosticIgnored())
6048 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
6049 MEnd = FinalOverriders.end();
6053 SOEnd = M->second.end();
6054 SO != SOEnd; ++SO) {
6061 if (SO->second.size() != 1)
6064 if (!SO->second.front().Method->isPureVirtual())
6067 if (!SeenPureMethods.insert(SO->second.front().Method).second)
6070 Diag(SO->second.front().Method->getLocation(),
6071 diag::note_pure_virtual_function)
6072 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
6082struct AbstractUsageInfo {
6092 void DiagnoseAbstractType() {
6101struct CheckAbstractUsage {
6102 AbstractUsageInfo &Info;
6103 const NamedDecl *Ctx;
6105 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
6106 : Info(Info), Ctx(Ctx) {}
6110#define ABSTRACT_TYPELOC(CLASS, PARENT)
6111#define TYPELOC(CLASS, PARENT) \
6112 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break;
6113#include "clang/AST/TypeLocNodes.def"
6119 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
6134 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
6135 TemplateArgumentLoc TAL = TL.
getArgLoc(I);
6144#define CheckPolymorphic(Type) \
6145 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \
6146 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \
6161 return Visit(
Next, Sel);
6169 if (
T->isArrayType()) {
6173 CanQualType CT =
T->getCanonicalTypeUnqualified().getUnqualifiedType();
6174 if (CT != Info.AbstractType)
return;
6185 Info.DiagnoseAbstractType();
6189void AbstractUsageInfo::CheckType(
const NamedDecl *D, TypeLoc TL,
6191 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
6226 for (
auto *D : RD->
decls()) {
6227 if (D->isImplicit())
continue;
6230 if (
auto *FD = dyn_cast<FriendDecl>(D)) {
6231 D = FD->getFriendDecl();
6236 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
6238 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D)) {
6242 }
else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
6245 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
6247 }
else if (
auto *VTD = dyn_cast<VarTemplateDecl>(D)) {
6251 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6253 }
else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(D)) {
6264 assert(ClassAttr->
getKind() == attr::DLLExport);
6274 struct MarkingClassDllexported {
6285 ~MarkingClassDllexported() {
6288 } MarkingDllexportedContext(S, Class, ClassAttr->
getLocation());
6295 if (!
Member->hasAttr<DLLExportAttr>())
6300 auto *VD = dyn_cast<VarDecl>(
Member);
6301 if (VD && VD->getStorageClass() ==
SC_Static &&
6305 auto *MD = dyn_cast<CXXMethodDecl>(
Member);
6309 if (MD->isUserProvided()) {
6319 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6329 }
else if (MD->isExplicitlyDefaulted()) {
6338 }
else if (!MD->isTrivial() ||
6339 MD->isCopyAssignmentOperator() ||
6340 MD->isMoveAssignmentOperator()) {
6364 auto *CD = dyn_cast<CXXConstructorDecl>(
Member);
6365 if (!CD || !CD->isDefaultConstructor())
6367 auto *
Attr = CD->getAttr<DLLExportAttr>();
6373 if (!Class->isDependentContext()) {
6380 if (LastExportedDefaultCtor) {
6382 diag::err_attribute_dll_ambiguous_default_ctor)
6384 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
6385 << CD->getDeclName();
6388 LastExportedDefaultCtor = CD;
6394 bool ErrorReported =
false;
6395 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6399 S.
Diag(TD->getLocation(),
6400 diag::err_cuda_device_builtin_surftex_cls_template)
6402 ErrorReported =
true;
6407 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(Class);
6409 S.
Diag(Class->getLocation(),
6410 diag::err_cuda_device_builtin_surftex_ref_decl)
6412 S.
Diag(Class->getLocation(),
6413 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6417 TD = SD->getSpecializedTemplate();
6421 unsigned N = Params->
size();
6424 reportIllegalClassTemplate(S, TD);
6426 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6430 reportIllegalClassTemplate(S, TD);
6432 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6436 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6437 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6438 reportIllegalClassTemplate(S, TD);
6440 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6448 bool ErrorReported =
false;
6449 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6453 S.
Diag(TD->getLocation(),
6454 diag::err_cuda_device_builtin_surftex_cls_template)
6456 ErrorReported =
true;
6461 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(Class);
6463 S.
Diag(Class->getLocation(),
6464 diag::err_cuda_device_builtin_surftex_ref_decl)
6466 S.
Diag(Class->getLocation(),
6467 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6471 TD = SD->getSpecializedTemplate();
6475 unsigned N = Params->
size();
6478 reportIllegalClassTemplate(S, TD);
6480 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6484 reportIllegalClassTemplate(S, TD);
6486 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6490 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6491 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6492 reportIllegalClassTemplate(S, TD);
6494 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6499 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(2));
6500 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6501 reportIllegalClassTemplate(S, TD);
6503 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6512 if (
Method->isUserProvided())
6523 if (
Context.getTargetInfo().shouldDLLImportComdatSymbols() && !ClassAttr) {
6524 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(
Class)) {
6525 if (
Attr *TemplateAttr =
6526 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
6528 A->setInherited(
true);
6541 if ((
Context.getTargetInfo().getCXXABI().isMicrosoft() ||
6542 Context.getTargetInfo().getTriple().isPS()) &&
6543 (!
Class->isExternallyVisible() &&
Class->hasExternalFormalLinkage())) {
6544 Class->dropAttrs<DLLExportAttr, DLLImportAttr>();
6548 if (!
Class->isExternallyVisible()) {
6549 Diag(
Class->getLocation(), diag::err_attribute_dll_not_extern)
6550 <<
Class << ClassAttr;
6554 if (
Context.getTargetInfo().shouldDLLImportComdatSymbols() &&
6565 diag::err_attribute_dll_member_of_dll_class)
6566 << MemberAttr << ClassAttr;
6567 Diag(ClassAttr->getLocation(), diag::note_previous_attribute);
6568 Member->setInvalidDecl();
6572 if (
Class->getDescribedClassTemplate())
6577 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
6582 const bool PropagatedImport =
6592 !
Context.getTargetInfo().getTriple().isOSCygMing()) {
6593 if (
auto *DEA =
Class->getAttr<DLLExportAttr>()) {
6594 Class->addAttr(DLLExportOnDeclAttr::Create(
Context, DEA->getLoc()));
6595 Class->dropAttr<DLLExportAttr>();
6622 if (!
Context.getTargetInfo().shouldDLLImportComdatSymbols() &&
6630 auto *Ctor = dyn_cast<CXXConstructorDecl>(MD);
6647 if (VD && PropagatedImport)
6661 if (ClassExported) {
6673 Member->addAttr(NewAttr);
6683 "friend re-decl should not already have a DLLAttr");
6713 NewAttr->setInherited(
true);
6714 BaseTemplateSpec->
addAttr(NewAttr);
6718 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
6719 ImportAttr->setPropagatedToBaseTemplate();
6740 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
6745 diag::note_template_class_explicit_specialization_was_here)
6746 << BaseTemplateSpec;
6749 diag::note_template_class_instantiation_was_here)
6750 << BaseTemplateSpec;
6756 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
6768 if (MD->isCopyAssignmentOperator())
6771 if (MD->isMoveAssignmentOperator())
6782 case OO_ExclaimEqual:
6794 case OO_GreaterEqual:
6835 llvm_unreachable(
"Invalid special member.");
6853 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
6854 bool DtorIsTrivialForCall =
false;
6865 CopyCtorIsTrivial =
true;
6867 CopyCtorIsTrivialForCall =
true;
6871 if (CD->isCopyConstructor() && !CD->isDeleted() &&
6872 !CD->isIneligibleOrNotSelected()) {
6873 if (CD->isTrivial())
6874 CopyCtorIsTrivial =
true;
6875 if (CD->isTrivialForCall())
6876 CopyCtorIsTrivialForCall =
true;
6884 DtorIsTrivialForCall =
true;
6886 if (!DD->isDeleted() && DD->isTrivialForCall())
6887 DtorIsTrivialForCall =
true;
6891 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
6905 uint64_t TypeSize = isAArch64 ? 128 : 64;
6917 bool HasNonDeletedCopyOrMove =
false;
6923 HasNonDeletedCopyOrMove =
true;
6930 HasNonDeletedCopyOrMove =
true;
6938 if (MD->isDeleted() || MD->isIneligibleOrNotSelected())
6941 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6942 if (CD && CD->isCopyOrMoveConstructor())
6943 HasNonDeletedCopyOrMove =
true;
6947 if (!MD->isTrivialForCall())
6951 return HasNonDeletedCopyOrMove;
6962 bool IssuedDiagnostic =
false;
6965 if (!IssuedDiagnostic) {
6967 IssuedDiagnostic =
true;
6969 S.
Diag(O->getLocation(), diag::note_overridden_virtual_function);
6972 return IssuedDiagnostic;
6979 if (
Record->isAbstract() && !
Record->isInvalidDecl()) {
6980 AbstractUsageInfo Info(*
this,
Record);
6987 if (!
Record->isInvalidDecl() && !
Record->isDependentType() &&
6988 !
Record->isAggregate() && !
Record->hasUserDeclaredConstructor() &&
6990 bool Complained =
false;
6991 for (
const auto *F :
Record->fields()) {
6992 if (F->hasInClassInitializer() || F->isUnnamedBitField())
6995 if (F->getType()->isReferenceType() ||
6996 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
6998 Diag(
Record->getLocation(), diag::warn_no_constructor_for_refconst)
7003 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
7004 << F->getType()->isReferenceType()
7005 << F->getDeclName();
7010 if (
Record->getIdentifier()) {
7027 Record->hasUserDeclaredConstructor()) ||
7029 Diag((*I)->getLocation(), diag::err_member_name_of_class)
7037 if (
Record->isPolymorphic() && !
Record->isDependentType()) {
7040 !
Record->hasAttr<FinalAttr>())
7042 diag::warn_non_virtual_dtor)
7046 if (
Record->isAbstract()) {
7047 if (FinalAttr *FA =
Record->getAttr<FinalAttr>()) {
7048 Diag(
Record->getLocation(), diag::warn_abstract_final_class)
7049 << FA->isSpelledAsSealed();
7055 if (!
Record->hasAttr<FinalAttr>()) {
7057 if (
const FinalAttr *FA = dtor->getAttr<FinalAttr>()) {
7058 Diag(FA->getLocation(), diag::warn_final_dtor_non_final_class)
7059 << FA->isSpelledAsSealed()
7062 (FA->isSpelledAsSealed() ?
" sealed" :
" final"));
7064 diag::note_final_dtor_non_final_class_silence)
7065 <<
Context.getCanonicalTagType(
Record) << FA->isSpelledAsSealed();
7071 if (
Record->hasAttr<TrivialABIAttr>())
7076 bool HasTrivialABI =
Record->hasAttr<TrivialABIAttr>();
7079 Record->setHasTrivialSpecialMemberForCall();
7089 auto CheckCompletedMemberFunction = [&](
CXXMethodDecl *MD) {
7100 MD->
isDeleted() ? diag::err_deleted_override
7101 : diag::err_non_deleted_override,
7103 return MD->isDeleted() != V->isDeleted();
7115 : diag::err_non_consteval_override,
7117 return MD->isConsteval() != V->isConsteval();
7126 auto CheckForDefaultedFunction = [&](
FunctionDecl *FD) ->
bool {
7127 if (!FD || FD->
isInvalidDecl() || !FD->isExplicitlyDefaulted())
7133 DefaultedSecondaryComparisons.push_back(FD);
7141 if (!
Record->isInvalidDecl() &&
7142 Record->hasAttr<VTablePointerAuthenticationAttr>())
7147 bool Incomplete = CheckForDefaultedFunction(M);
7150 if (
Record->isDependentType())
7156 if (!M->isImplicit() && !M->isUserProvided()) {
7160 Record->finishedDefaultedOrDeletedMember(M);
7161 M->setTrivialForCall(
7165 Record->setTrivialForCallFlags(M);
7174 M->isUserProvided()) {
7175 M->setTrivialForCall(HasTrivialABI);
7176 Record->setTrivialForCallFlags(M);
7179 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
7180 M->hasAttr<DLLExportAttr>()) {
7186 M->dropAttr<DLLExportAttr>();
7188 if (M->hasAttr<DLLExportAttr>()) {
7194 bool EffectivelyConstexprDestructor =
true;
7199 llvm::SmallDenseSet<QualType> Visited;
7200 auto Check = [&Visited](
QualType T,
auto &&Check) ->
bool {
7201 if (!Visited.insert(
T->getCanonicalTypeUnqualified()).second)
7204 T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
7212 if (!Check(B.getType(), Check))
7215 if (!Check(FD->
getType(), Check))
7219 EffectivelyConstexprDestructor =
7227 M->isDefaulted() && M->isConstexpr() && M->size_overridden_methods() &&
7228 EffectivelyConstexprDestructor)
7232 CheckCompletedMemberFunction(M);
7241 CompleteMemberFunction(Dtor);
7243 bool HasMethodWithOverrideControl =
false,
7244 HasOverridingMethodWithoutOverrideControl =
false;
7245 for (
auto *D :
Record->decls()) {
7246 if (
auto *M = dyn_cast<CXXMethodDecl>(D)) {
7249 if (!
Record->isDependentType()) {
7255 if (M->hasAttr<OverrideAttr>()) {
7256 HasMethodWithOverrideControl =
true;
7257 }
else if (M->size_overridden_methods() > 0) {
7258 HasOverridingMethodWithoutOverrideControl =
true;
7261 if (M->isVirtualAsWritten() &&
Record->isEffectivelyFinal()) {
7262 Diag(M->getLocation(), diag::warn_unnecessary_virtual_specifier)
7269 CompleteMemberFunction(M);
7270 }
else if (
auto *F = dyn_cast<FriendDecl>(D)) {
7271 CheckForDefaultedFunction(
7272 dyn_cast_or_null<FunctionDecl>(F->getFriendDecl()));
7276 if (HasOverridingMethodWithoutOverrideControl) {
7277 bool HasInconsistentOverrideControl = HasMethodWithOverrideControl;
7278 for (
auto *M :
Record->methods())
7283 for (
FunctionDecl *FD : DefaultedSecondaryComparisons) {
7287 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD))
7288 CheckCompletedMemberFunction(MD);
7309 if (
Context.getLangOpts().getLayoutCompatibility() ==
7313 Diag(
Record->getLocation(), diag::warn_cxx_ms_struct);
7319 bool ClangABICompat4 =
7320 Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver4;
7322 Context.getTargetInfo().getCallingConvKind(ClangABICompat4);
7327 if (
Record->getArgPassingRestrictions() !=
7329 Record->setArgPassingRestrictions(
7337 if (
Context.getTargetInfo().getCXXABI().areArgsDestroyedLeftToRightInCallee())
7338 Record->setParamDestroyedInCallee(
true);
7339 else if (
Record->hasNonTrivialDestructor())
7340 Record->setParamDestroyedInCallee(CanPass);
7349 if (
Record->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>())
7351 else if (
Record->hasAttr<CUDADeviceBuiltinTextureTypeAttr>())
7357 TypeAwareDecls{{OO_New, {}},
7360 {OO_Array_New, {}}};
7361 for (
auto *D :
Record->decls()) {
7368 auto CheckMismatchedTypeAwareAllocators =
7371 auto &NewDecls = TypeAwareDecls[NewKind];
7372 auto &DeleteDecls = TypeAwareDecls[DeleteKind];
7373 if (NewDecls.empty() == DeleteDecls.empty())
7376 Context.DeclarationNames.getCXXOperatorName(
7377 NewDecls.empty() ? DeleteKind : NewKind);
7379 Context.DeclarationNames.getCXXOperatorName(
7380 NewDecls.empty() ? NewKind : DeleteKind);
7382 diag::err_type_aware_allocator_missing_matching_operator)
7385 for (
auto MD : NewDecls)
7387 diag::note_unmatched_type_aware_allocator_declared)
7389 for (
auto MD : DeleteDecls)
7391 diag::note_unmatched_type_aware_allocator_declared)
7394 CheckMismatchedTypeAwareAllocators(OO_New, OO_Delete);
7395 CheckMismatchedTypeAwareAllocators(OO_Array_New, OO_Array_Delete);
7411 unsigned LHSQuals = 0;
7414 LHSQuals = FieldQuals;
7416 unsigned RHSQuals = FieldQuals;
7438 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
7444 : S(S), UseLoc(UseLoc) {
7445 bool DiagnosedMultipleConstructedBases =
false;
7451 for (
auto *D : Shadow->
redecls()) {
7452 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
7453 auto *DNominatedBase = DShadow->getNominatedBaseClass();
7454 auto *DConstructedBase = DShadow->getConstructedBaseClass();
7456 InheritedFromBases.insert(
7457 std::make_pair(DNominatedBase->getCanonicalDecl(),
7458 DShadow->getNominatedBaseClassShadowDecl()));
7459 if (DShadow->constructsVirtualBase())
7460 InheritedFromBases.insert(
7461 std::make_pair(DConstructedBase->getCanonicalDecl(),
7462 DShadow->getConstructedBaseClassShadowDecl()));
7464 assert(DNominatedBase == DConstructedBase);
7469 if (!ConstructedBase) {
7470 ConstructedBase = DConstructedBase;
7471 ConstructedBaseIntroducer = D->getIntroducer();
7472 }
else if (ConstructedBase != DConstructedBase &&
7474 if (!DiagnosedMultipleConstructedBases) {
7475 S.Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
7476 << Shadow->getTargetDecl();
7477 S.Diag(ConstructedBaseIntroducer->getLocation(),
7478 diag::note_ambiguous_inherited_constructor_using)
7480 DiagnosedMultipleConstructedBases = true;
7482 S.Diag(D->getIntroducer()->getLocation(),
7483 diag::note_ambiguous_inherited_constructor_using)
7484 << DConstructedBase;
7488 if (DiagnosedMultipleConstructedBases)
7489 Shadow->setInvalidDecl();
7495 std::pair<CXXConstructorDecl *, bool>
7497 auto It = InheritedFromBases.find(
Base->getCanonicalDecl());
7498 if (It == InheritedFromBases.end())
7499 return std::make_pair(
nullptr,
false);
7503 return std::make_pair(
7504 S.findInheritingConstructor(UseLoc, Ctor, It->second),
7505 It->second->constructsVirtualBase());
7508 return std::make_pair(Ctor,
false);
7525 if (InheritedCtor) {
7528 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
7530 return BaseCtor->isConstexpr();
7598 if (Ctor && ClassDecl->
isUnion())
7618 for (
const auto &B : ClassDecl->
bases()) {
7619 auto *BaseClassDecl = B.getType()->getAsCXXRecordDecl();
7623 InheritedCtor, Inherited))
7636 for (
const auto *F : ClassDecl->
fields()) {
7637 if (F->isInvalidDecl())
7640 F->hasInClassInitializer())
7643 if (
const RecordType *RecordTy = BaseType->getAsCanonical<RecordType>()) {
7644 auto *FieldRecDecl =
7647 BaseType.getCVRQualifiers(),
7648 ConstArg && !F->isMutable()))
7663struct ComputingExceptionSpec {
7666 ComputingExceptionSpec(Sema &S, FunctionDecl *FD, SourceLocation Loc)
7668 Sema::CodeSynthesisContext Ctx;
7674 ~ComputingExceptionSpec() {
7680static Sema::ImplicitExceptionSpecification
7684 Sema::InheritedConstructorInfo *ICI);
7686static Sema::ImplicitExceptionSpecification
7691static Sema::ImplicitExceptionSpecification
7694 if (DFK.isSpecialMember())
7697 if (DFK.isComparison())
7699 DFK.asComparison());
7702 assert(CD->getInheritedConstructor() &&
7703 "only defaulted functions and inherited constructors have implicit "
7706 S, Loc, CD->getInheritedConstructor().getShadowDecl());
7733 auto ESI = IES.getExceptionSpec();
7751 PT.getNonReferenceType()->getAsCXXRecordDecl()) {
7772 "not an explicitly-defaulted special member");
7782 bool HadError =
false;
7795 bool ShouldDeleteForTypeMismatch =
false;
7796 unsigned ExpectedParams = 1;
7808 if (DeleteOnTypeMismatch)
7809 ShouldDeleteForTypeMismatch =
true;
7819 bool CanHaveConstParam =
false;
7829 ReturnType =
Type->getReturnType();
7834 std::nullopt, RD,
false);
7835 DeclType =
Context.getAddrSpaceQualType(
7837 QualType ExpectedReturnType =
Context.getLValueReferenceType(DeclType);
7839 if (!
Context.hasSameType(ReturnType, ExpectedReturnType)) {
7840 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
7842 << ExpectedReturnType;
7848 if (DeleteOnTypeMismatch)
7849 ShouldDeleteForTypeMismatch =
true;
7866 if (!ExplicitObjectParameter.
isNull() &&
7869 Context.getCanonicalTagType(RD)))) {
7870 if (DeleteOnTypeMismatch)
7871 ShouldDeleteForTypeMismatch =
true;
7874 diag::err_defaulted_special_member_explicit_object_mismatch)
7887 bool HasConstParam =
false;
7888 if (ExpectedParams &&
ArgType->isReferenceType()) {
7894 if (DeleteOnTypeMismatch)
7895 ShouldDeleteForTypeMismatch =
true;
7898 diag::err_defaulted_special_member_volatile_param)
7904 if (HasConstParam && !CanHaveConstParam) {
7905 if (DeleteOnTypeMismatch)
7906 ShouldDeleteForTypeMismatch =
true;
7910 diag::err_defaulted_special_member_copy_const_param)
7916 diag::err_defaulted_special_member_move_const_param)
7921 }
else if (ExpectedParams) {
7925 "unexpected non-ref argument");
7959 diag::err_incorrect_defaulted_constexpr_with_vb)
7961 for (
const auto &I : RD->
vbases())
7962 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here);
7981 if (!
Type->hasExceptionSpec()) {
7990 Context.getFunctionType(ReturnType,
Type->getParamTypes(), EPI));
7999 if (ShouldDeleteForTypeMismatch) {
8004 Diag(DefaultLoc, diag::note_replace_equals_default_to_delete)
8008 if (ShouldDeleteForTypeMismatch && !HadError) {
8010 diag::warn_cxx17_compat_defaulted_method_type_mismatch)
8017 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
8018 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
8040template<
typename Derived,
typename ResultList,
typename Result,
8042class DefaultedComparisonVisitor {
8047 DefaultedComparisonKind DCK)
8048 : S(S), RD(RD), FD(FD), DCK(DCK) {
8052 Fns.assign(Info->getUnqualifiedLookups().begin(),
8053 Info->getUnqualifiedLookups().end());
8057 ResultList visit() {
8065 case DefaultedComparisonKind::None:
8066 llvm_unreachable(
"not a defaulted comparison");
8068 case DefaultedComparisonKind::Equal:
8069 case DefaultedComparisonKind::ThreeWay:
8070 getDerived().visitSubobjects(Results, RD, ParamLvalType.
getQualifiers());
8073 case DefaultedComparisonKind::NotEqual:
8074 case DefaultedComparisonKind::Relational:
8075 Results.add(getDerived().visitExpandedSubobject(
8076 ParamLvalType, getDerived().getCompleteObject()));
8079 llvm_unreachable(
"");
8083 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
8089 bool visitSubobjects(ResultList &Results, CXXRecordDecl *
Record,
8093 for (CXXBaseSpecifier &Base :
Record->bases())
8094 if (Results.add(getDerived().visitSubobject(
8096 getDerived().getBase(&Base))))
8100 for (FieldDecl *Field :
Record->fields()) {
8103 if (
Field->isUnnamedBitField())
8106 if (
Field->isAnonymousStructOrUnion()) {
8107 if (visitSubobjects(Results,
Field->getType()->getAsCXXRecordDecl(),
8114 Qualifiers FieldQuals = Quals;
8115 if (
Field->isMutable())
8117 QualType FieldType =
8120 if (Results.add(getDerived().visitSubobject(
8121 FieldType, getDerived().getField(Field))))
8129 Result visitSubobject(QualType
Type, Subobject Subobj) {
8132 if (
auto *CAT = dyn_cast_or_null<ConstantArrayType>(AT))
8133 return getDerived().visitSubobjectArray(CAT->getElementType(),
8134 CAT->getSize(), Subobj);
8135 return getDerived().visitExpandedSubobject(
Type, Subobj);
8138 Result visitSubobjectArray(QualType
Type,
const llvm::APInt &Size,
8140 return getDerived().visitSubobject(
Type, Subobj);
8147 DefaultedComparisonKind DCK;
8148 UnresolvedSet<16> Fns;
8153struct DefaultedComparisonInfo {
8158 static DefaultedComparisonInfo deleted() {
8159 DefaultedComparisonInfo
Deleted;
8164 bool add(
const DefaultedComparisonInfo &R) {
8174struct DefaultedComparisonSubobject {
8182class DefaultedComparisonAnalyzer
8183 :
public DefaultedComparisonVisitor<DefaultedComparisonAnalyzer,
8184 DefaultedComparisonInfo,
8185 DefaultedComparisonInfo,
8186 DefaultedComparisonSubobject> {
8188 enum DiagnosticKind { NoDiagnostics, ExplainDeleted, ExplainConstexpr };
8191 DiagnosticKind Diagnose;
8194 using Base = DefaultedComparisonVisitor;
8195 using Result = DefaultedComparisonInfo;
8196 using Subobject = DefaultedComparisonSubobject;
8200 DefaultedComparisonAnalyzer(Sema &S, CXXRecordDecl *RD, FunctionDecl *FD,
8201 DefaultedComparisonKind DCK,
8202 DiagnosticKind Diagnose = NoDiagnostics)
8203 :
Base(S, RD, FD, DCK), Diagnose(Diagnose) {}
8206 if ((DCK == DefaultedComparisonKind::Equal ||
8207 DCK == DefaultedComparisonKind::ThreeWay) &&
8212 if (Diagnose == ExplainDeleted) {
8216 return Result::deleted();
8219 return Base::visit();
8223 Subobject getCompleteObject() {
8224 return Subobject{Subobject::CompleteObject, RD, FD->
getLocation()};
8227 Subobject getBase(CXXBaseSpecifier *Base) {
8228 return Subobject{Subobject::Base,
Base->getType()->getAsCXXRecordDecl(),
8229 Base->getBaseTypeLoc()};
8232 Subobject getField(FieldDecl *Field) {
8233 return Subobject{Subobject::Member,
Field,
Field->getLocation()};
8236 Result visitExpandedSubobject(QualType
Type, Subobject Subobj) {
8240 if (
Type->isReferenceType()) {
8241 if (Diagnose == ExplainDeleted) {
8242 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_reference_member)
8245 return Result::deleted();
8250 Expr *Args[] = {&Xi, &Xi};
8254 assert(OO !=
OO_None &&
"not an overloaded operator!");
8255 return visitBinaryOperator(OO, Args, Subobj);
8261 OverloadCandidateSet *SpaceshipCandidates =
nullptr) {
8265 OverloadCandidateSet CandidateSet(
8267 OverloadCandidateSet::OperatorRewriteInfo(
8269 !SpaceshipCandidates));
8274 CandidateSet.exclude(FD);
8276 if (Args[0]->
getType()->isOverloadableType())
8287 switch (CandidateSet.BestViableFunction(S, FD->
getLocation(), Best)) {
8293 if ((DCK == DefaultedComparisonKind::NotEqual ||
8294 DCK == DefaultedComparisonKind::Relational) &&
8295 !Best->RewriteKind) {
8296 if (Diagnose == ExplainDeleted) {
8297 if (Best->Function) {
8298 S.
Diag(Best->Function->getLocation(),
8299 diag::note_defaulted_comparison_not_rewritten_callee)
8302 assert(Best->Conversions.size() == 2 &&
8303 Best->Conversions[0].isUserDefined() &&
8304 "non-user-defined conversion from class to built-in "
8306 S.
Diag(Best->Conversions[0]
8307 .UserDefined.FoundConversionFunction.getDecl()
8309 diag::note_defaulted_comparison_not_rewritten_conversion)
8313 return Result::deleted();
8323 CXXRecordDecl *ArgClass = Args[0]->getType()->getAsCXXRecordDecl();
8324 if (ArgClass && Best->FoundDecl.getDecl() &&
8325 Best->FoundDecl.getDecl()->isCXXClassMember()) {
8326 QualType ObjectType = Subobj.Kind == Subobject::Member
8327 ? Args[0]->getType()
8330 ArgClass, Best->FoundDecl, ObjectType, Subobj.Loc,
8331 Diagnose == ExplainDeleted
8332 ? S.
PDiag(diag::note_defaulted_comparison_inaccessible)
8333 << FD << Subobj.Kind << Subobj.Decl
8335 return Result::deleted();
8338 bool NeedsDeducing =
8341 if (FunctionDecl *BestFD = Best->Function) {
8346 assert(!BestFD->isDeleted() &&
"wrong overload resolution result");
8348 if (Diagnose == ExplainConstexpr && !BestFD->isConstexpr()) {
8349 if (Subobj.Kind != Subobject::CompleteObject)
8350 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_not_constexpr)
8351 << Subobj.
Kind << Subobj.Decl;
8352 S.
Diag(BestFD->getLocation(),
8353 diag::note_defaulted_comparison_not_constexpr_here);
8355 return Result::deleted();
8357 R.Constexpr &= BestFD->isConstexpr();
8359 if (NeedsDeducing) {
8364 if (BestFD->getReturnType()->isUndeducedType() &&
8370 if (Diagnose == NoDiagnostics) {
8373 diag::err_defaulted_comparison_cannot_deduce_undeduced_auto)
8374 << Subobj.
Kind << Subobj.Decl;
8377 diag::note_defaulted_comparison_cannot_deduce_undeduced_auto)
8378 << Subobj.
Kind << Subobj.Decl;
8379 S.
Diag(BestFD->getLocation(),
8380 diag::note_defaulted_comparison_cannot_deduce_callee)
8381 << Subobj.
Kind << Subobj.Decl;
8383 return Result::deleted();
8386 BestFD->getCallResultType());
8388 if (Diagnose == ExplainDeleted) {
8389 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_cannot_deduce)
8390 << Subobj.
Kind << Subobj.Decl
8391 << BestFD->getCallResultType().withoutLocalFastQualifiers();
8392 S.
Diag(BestFD->getLocation(),
8393 diag::note_defaulted_comparison_cannot_deduce_callee)
8394 << Subobj.
Kind << Subobj.Decl;
8396 return Result::deleted();
8398 R.Category = Info->Kind;
8401 QualType
T = Best->BuiltinParamTypes[0];
8402 assert(
T == Best->BuiltinParamTypes[1] &&
8403 "builtin comparison for different types?");
8404 assert(Best->BuiltinParamTypes[2].isNull() &&
8405 "invalid builtin comparison");
8410 if (Diagnose == ExplainDeleted) {
8412 diag::note_defaulted_comparison_vector_types)
8414 S.
Diag(Subobj.Decl->getLocation(), diag::note_declared_at);
8416 return Result::deleted();
8419 if (NeedsDeducing) {
8420 std::optional<ComparisonCategoryType> Cat =
8422 assert(Cat &&
"no category for builtin comparison?");
8433 if (Diagnose == ExplainDeleted) {
8436 Kind = OO == OO_EqualEqual ? 1 : 2;
8437 CandidateSet.NoteCandidates(
8439 Subobj.Loc, S.
PDiag(diag::note_defaulted_comparison_ambiguous)
8440 << FD << Kind << Subobj.Kind << Subobj.Decl),
8443 R = Result::deleted();
8447 if (Diagnose == ExplainDeleted) {
8448 if ((DCK == DefaultedComparisonKind::NotEqual ||
8449 DCK == DefaultedComparisonKind::Relational) &&
8450 !Best->RewriteKind) {
8451 S.
Diag(Best->Function->getLocation(),
8452 diag::note_defaulted_comparison_not_rewritten_callee)
8456 diag::note_defaulted_comparison_calls_deleted)
8457 << FD << Subobj.
Kind << Subobj.Decl;
8461 R = Result::deleted();
8467 if (OO == OO_Spaceship &&
8471 if (!R.add(visitBinaryOperator(OO_EqualEqual, Args, Subobj,
8473 R.add(visitBinaryOperator(OO_Less, Args, Subobj, &CandidateSet));
8477 if (Diagnose == ExplainDeleted) {
8478 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_no_viable_function)
8479 << FD << (OO == OO_EqualEqual || OO == OO_ExclaimEqual)
8480 << Subobj.
Kind << Subobj.Decl;
8484 if (SpaceshipCandidates) {
8485 SpaceshipCandidates->NoteCandidates(
8490 diag::note_defaulted_comparison_no_viable_function_synthesized)
8491 << (OO == OO_EqualEqual ? 0 : 1);
8494 CandidateSet.NoteCandidates(
8499 R = Result::deleted();
8508struct StmtListResult {
8509 bool IsInvalid =
false;
8510 llvm::SmallVector<Stmt*, 16> Stmts;
8513 IsInvalid |= S.isInvalid();
8516 Stmts.push_back(S.get());
8523class DefaultedComparisonSynthesizer
8524 :
public DefaultedComparisonVisitor<DefaultedComparisonSynthesizer,
8525 StmtListResult, StmtResult,
8526 std::pair<ExprResult, ExprResult>> {
8528 unsigned ArrayDepth = 0;
8531 using Base = DefaultedComparisonVisitor;
8532 using ExprPair = std::pair<ExprResult, ExprResult>;
8536 DefaultedComparisonSynthesizer(Sema &S, CXXRecordDecl *RD, FunctionDecl *FD,
8537 DefaultedComparisonKind DCK,
8538 SourceLocation BodyLoc)
8539 :
Base(S, RD, FD, DCK), Loc(BodyLoc) {}
8543 Sema::CompoundScopeRAII CompoundScope(S);
8545 StmtListResult Stmts = visit();
8546 if (Stmts.IsInvalid)
8551 case DefaultedComparisonKind::None:
8552 llvm_unreachable(
"not a defaulted comparison");
8554 case DefaultedComparisonKind::Equal: {
8563 auto OldStmts = std::move(Stmts.Stmts);
8564 Stmts.Stmts.clear();
8567 auto FinishCmp = [&] {
8568 if (Expr *Prior = CmpSoFar.
get()) {
8570 if (RetVal.
isUnset() && Stmts.Stmts.empty())
8573 else if (Stmts.add(buildIfNotCondReturnFalse(Prior)))
8579 for (Stmt *EAsStmt : llvm::reverse(OldStmts)) {
8580 Expr *E = dyn_cast<Expr>(EAsStmt);
8583 if (FinishCmp() || Stmts.add(EAsStmt))
8592 CmpSoFar = S.CreateBuiltinBinOp(Loc, BO_LAnd, E, CmpSoFar.
get());
8598 std::reverse(Stmts.Stmts.begin(), Stmts.Stmts.end());
8601 RetVal = S.ActOnCXXBoolLiteral(Loc, tok::kw_true);
8605 case DefaultedComparisonKind::ThreeWay: {
8609 ComparisonCategoryType::StrongOrdering, Loc,
8610 Sema::ComparisonCategoryUsage::DefaultedOperator);
8613 VarDecl *EqualVD = S.Context.CompCategories.getInfoForType(
StrongOrdering)
8614 .getValueInfo(ComparisonCategoryResult::Equal)
8616 RetVal = getDecl(EqualVD);
8619 RetVal = buildStaticCastToR(RetVal.
get());
8623 case DefaultedComparisonKind::NotEqual:
8624 case DefaultedComparisonKind::Relational:
8625 RetVal =
cast<Expr>(Stmts.Stmts.pop_back_val());
8632 StmtResult ReturnStmt = S.BuildReturnStmt(Loc, RetVal.
get());
8633 if (ReturnStmt.isInvalid())
8635 Stmts.Stmts.push_back(ReturnStmt.get());
8637 return S.ActOnCompoundStmt(Loc, Loc, Stmts.Stmts,
false);
8642 return S.BuildDeclarationNameExpr(
8643 CXXScopeSpec(), DeclarationNameInfo(VD->
getDeclName(), Loc), VD);
8651 ExprPair getCompleteObject() {
8654 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD);
8655 MD && MD->isImplicitObjectMemberFunction()) {
8657 LHS = S.ActOnCXXThis(Loc);
8659 LHS = S.CreateBuiltinUnaryOp(Loc, UO_Deref, LHS.
get());
8661 LHS = getParam(Param++);
8668 ExprPair getBase(CXXBaseSpecifier *Base) {
8669 ExprPair Obj = getCompleteObject();
8670 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8673 const auto CastToBase = [&](Expr *E) {
8674 QualType ToType = S.Context.getQualifiedType(
8676 return S.ImpCastExprToType(E, ToType, CK_DerivedToBase,
VK_LValue, &Path);
8678 return {CastToBase(Obj.first.get()), CastToBase(Obj.second.get())};
8681 ExprPair getField(FieldDecl *Field) {
8682 ExprPair Obj = getCompleteObject();
8683 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8687 DeclarationNameInfo NameInfo(
Field->getDeclName(), Loc);
8688 return {S.BuildFieldReferenceExpr(Obj.first.get(),
false, Loc,
8689 CXXScopeSpec(), Field,
Found, NameInfo),
8690 S.BuildFieldReferenceExpr(Obj.second.get(),
false, Loc,
8691 CXXScopeSpec(), Field,
Found, NameInfo)};
8698 if (
Cond.isInvalid())
8701 ExprResult NotCond = S.CreateBuiltinUnaryOp(Loc, UO_LNot,
Cond.get());
8706 assert(!
False.isInvalid() &&
"should never fail");
8708 if (ReturnFalse.isInvalid())
8711 return S.ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc,
nullptr,
8712 S.ActOnCondition(
nullptr, Loc, NotCond.
get(),
8713 Sema::ConditionKind::Boolean),
8714 Loc, ReturnFalse.get(), SourceLocation(),
nullptr);
8719 QualType SizeType = S.Context.getSizeType();
8720 Size =
Size.zextOrTrunc(S.Context.getTypeSize(SizeType));
8723 IdentifierInfo *IterationVarName =
nullptr;
8726 llvm::raw_svector_ostream
OS(Str);
8727 OS <<
"i" << ArrayDepth;
8728 IterationVarName = &S.Context.Idents.get(
OS.str());
8731 S.Context, S.CurContext, Loc, Loc, IterationVarName, SizeType,
8732 S.Context.getTrivialTypeSourceInfo(SizeType, Loc),
SC_None);
8733 llvm::APInt
Zero(S.Context.getTypeSize(SizeType), 0);
8736 Stmt *
Init =
new (S.Context) DeclStmt(DeclGroupRef(IterationVar), Loc, Loc);
8738 auto IterRef = [&] {
8740 CXXScopeSpec(), DeclarationNameInfo(IterationVarName, Loc),
8742 assert(!Ref.
isInvalid() &&
"can't reference our own variable?");
8748 Loc, BO_NE, IterRef(),
8750 assert(!
Cond.isInvalid() &&
"should never fail");
8753 ExprResult Inc = S.CreateBuiltinUnaryOp(Loc, UO_PreInc, IterRef());
8754 assert(!
Inc.isInvalid() &&
"should never fail");
8760 return S.CreateBuiltinArraySubscriptExpr(E.get(), Loc, IterRef(), Loc);
8762 Subobj.first = Index(Subobj.first);
8763 Subobj.second = Index(Subobj.second);
8770 if (Substmt.isInvalid())
8776 if (Expr *ElemCmp = dyn_cast<Expr>(Substmt.get())) {
8777 assert(DCK == DefaultedComparisonKind::Equal &&
8778 "should have non-expression statement");
8779 Substmt = buildIfNotCondReturnFalse(ElemCmp);
8780 if (Substmt.isInvalid())
8785 return S.ActOnForStmt(Loc, Loc,
Init,
8786 S.ActOnCondition(
nullptr, Loc,
Cond.get(),
8787 Sema::ConditionKind::Boolean),
8788 S.MakeFullDiscardedValueExpr(
Inc.get()), Loc,
8793 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8799 if (
Type->isOverloadableType())
8800 Op = S.CreateOverloadedBinOp(Loc, Opc, Fns, Obj.first.get(),
8801 Obj.second.get(),
true,
8804 Op = S.CreateBuiltinBinOp(Loc, Opc, Obj.first.get(), Obj.second.get());
8809 case DefaultedComparisonKind::None:
8810 llvm_unreachable(
"not a defaulted comparison");
8812 case DefaultedComparisonKind::Equal:
8815 Op = S.PerformContextuallyConvertToBool(Op.
get());
8820 case DefaultedComparisonKind::ThreeWay: {
8825 Op = buildStaticCastToR(Op.
get());
8830 IdentifierInfo *Name = &S.Context.Idents.get(
"cmp");
8833 S.Context.getTrivialTypeSourceInfo(R, Loc),
SC_None);
8834 S.AddInitializerToDecl(VD, Op.
get(),
false);
8835 Stmt *InitStmt =
new (S.Context) DeclStmt(DeclGroupRef(VD), Loc, Loc);
8841 llvm::APInt ZeroVal(S.Context.getIntWidth(S.Context.IntTy), 0);
8846 Comp = S.CreateOverloadedBinOp(Loc, BO_NE, Fns, VDRef.
get(),
Zero,
true,
8849 Comp = S.CreateBuiltinBinOp(Loc, BO_NE, VDRef.
get(),
Zero);
8850 if (
Comp.isInvalid())
8852 Sema::ConditionResult
Cond = S.ActOnCondition(
8853 nullptr, Loc,
Comp.get(), Sema::ConditionKind::Boolean);
8854 if (
Cond.isInvalid())
8858 VDRef = getDecl(VD);
8861 StmtResult ReturnStmt = S.BuildReturnStmt(Loc, VDRef.
get());
8862 if (ReturnStmt.isInvalid())
8866 return S.ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc, InitStmt,
Cond,
8867 Loc, ReturnStmt.get(),
8868 SourceLocation(),
nullptr);
8871 case DefaultedComparisonKind::NotEqual:
8872 case DefaultedComparisonKind::Relational:
8877 llvm_unreachable(
"");
8883 assert(!R->
isUndeducedType() &&
"type should have been deduced already");
8888 return S.BuildCXXNamedCast(Loc, tok::kw_static_cast,
8889 S.Context.getTrivialTypeSourceInfo(R, Loc), E,
8890 SourceRange(Loc, Loc), SourceRange(Loc, Loc));
8901 Self.LookupOverloadedOperatorName(OO, S, Operators);
8914 if (Op == OO_Spaceship) {
8915 Lookup(OO_ExclaimEqual);
8917 Lookup(OO_EqualEqual);
8948 assert(!MD->isStatic() &&
"comparison function cannot be a static member");
8950 if (MD->getRefQualifier() ==
RQ_RValue) {
8951 Diag(MD->getLocation(), diag::err_ref_qualifier_comparison_operator);
8957 MD->setType(
Context.getFunctionType(FPT->getReturnType(),
8958 FPT->getParamTypes(), EPI));
8964 QualType T = MD->getFunctionObjectParameterReferenceType();
8965 if (!
T.getNonReferenceType().isConstQualified() &&
8966 (MD->isImplicitObjectMemberFunction() ||
T->isLValueReferenceType())) {
8968 if (MD->isExplicitObjectMemberFunction()) {
8969 Loc = MD->getParamDecl(0)->getBeginLoc();
8971 MD->getParamDecl(0)->getExplicitObjectParamThisLoc());
8973 Loc = MD->getLocation();
8975 InsertLoc = Loc.getRParenLoc();
8979 if (!MD->isImplicit()) {
8980 Diag(Loc, diag::err_defaulted_comparison_non_const)
8985 if (MD->isExplicitObjectMemberFunction()) {
8986 assert(
T->isLValueReferenceType());
8987 MD->getParamDecl(0)->setType(
Context.getLValueReferenceType(
8988 T.getNonReferenceType().withConst()));
8993 MD->setType(
Context.getFunctionType(FPT->getReturnType(),
8994 FPT->getParamTypes(), EPI));
8998 if (MD->isVolatile()) {
8999 Diag(MD->getLocation(), diag::err_volatile_comparison_operator);
9005 MD->setType(
Context.getFunctionType(FPT->getReturnType(),
9006 FPT->getParamTypes(), EPI));
9012 (IsMethod ? 1 : 2)) {
9016 <<
int(IsMethod) <<
int(DCK);
9022 QualType ParmTy = Param->getType();
9029 ExpectedTy =
Context.getCanonicalTagType(RD);
9031 CTy = Ref->getPointeeType();
9041 RD = CTy->getAsCXXRecordDecl();
9042 Ok &= RD !=
nullptr;
9056 <<
int(DCK) << ParmTy << RefTy <<
int(!IsMethod) << PlainTy
9057 << Param->getSourceRange();
9059 assert(!IsMethod &&
"should know expected type for method");
9061 diag::err_defaulted_comparison_param_unknown)
9062 <<
int(DCK) << ParmTy << Param->getSourceRange();
9068 Diag(FD->
getLocation(), diag::err_defaulted_comparison_param_mismatch)
9070 << ParmTy << Param->getSourceRange();
9075 assert(RD &&
"must have determined class");
9084 diag::err_defaulted_comparison_not_friend,
int(DCK),
9089 return declaresSameEntity(F->getFriendDecl(), FD);
9092 <<
int(DCK) <<
int(0) << RD;
9104 Diag(FD->
getLocation(), diag::err_defaulted_comparison_return_type_not_bool)
9114 RT->getContainedDeducedType() &&
9116 RT->getContainedAutoType()->isConstrained())) {
9118 diag::err_defaulted_comparison_deduced_return_type_not_auto)
9130 DefaultedComparisonInfo Info =
9131 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK).visit();
9145 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
9146 DefaultedComparisonAnalyzer::ExplainDeleted)
9157 diag::note_previous_declaration);
9169 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
9170 DefaultedComparisonAnalyzer::ExplainDeleted)
9192 Context.adjustDeducedFunctionResultType(
9220 Diag(FD->
getBeginLoc(), diag::err_defaulted_comparison_constexpr_mismatch)
9222 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
9223 DefaultedComparisonAnalyzer::ExplainConstexpr)
9244 EPI.ExceptionSpec.SourceDecl = FD;
9246 FPT->getParamTypes(), EPI));
9261 EqualEqual->setImplicit();
9276 Scope.addContextNote(UseLoc);
9283 CXXRecordDecl *RD = PT.getNonReferenceType()->getAsCXXRecordDecl();
9287 DefaultedComparisonSynthesizer(*
this, RD, FD, DCK, BodyLoc).build();
9301 L->CompletedImplicitDefinition(FD);
9308 ComputingExceptionSpec CES(S, FD, Loc);
9338 DefaultedComparisonSynthesizer(S, RD, FD, DCK, BodyLoc).build();
9339 if (!Body.isInvalid())
9360 for (
auto &Check : Overriding)
9372template<
typename Derived>
9373struct SpecialMemberVisitor {
9380 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
9384 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
9389 IsConstructor =
true;
9393 IsAssignment =
true;
9398 llvm_unreachable(
"invalid special member kind");
9402 if (const ReferenceType *RT =
9403 MD->getNonObjectParameter(0)->getType()->getAs<ReferenceType>())
9404 ConstArg = RT->getPointeeType().isConstQualified();
9408 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
9411 bool isMove()
const {
9412 return CSM == CXXSpecialMemberKind::MoveConstructor ||
9413 CSM == CXXSpecialMemberKind::MoveAssignment;
9417 Sema::SpecialMemberOverloadResult lookupIn(CXXRecordDecl *
Class,
9418 unsigned Quals,
bool IsMutable) {
9420 ConstArg && !IsMutable);
9425 Sema::SpecialMemberOverloadResult lookupInheritedCtor(CXXRecordDecl *
Class) {
9428 assert(CSM == CXXSpecialMemberKind::DefaultConstructor);
9437 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
9440 static SourceLocation getSubobjectLoc(Subobject Subobj) {
9443 if (
auto *B = dyn_cast<CXXBaseSpecifier *>(Subobj))
9444 return B->getBaseTypeLoc();
9451 VisitNonVirtualBases,
9456 VisitPotentiallyConstructedBases,
9462 bool visit(BasesToVisit Bases) {
9465 if (Bases == VisitPotentiallyConstructedBases)
9466 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
9468 for (
auto &B : RD->
bases())
9469 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
9470 getDerived().visitBase(&B))
9473 if (Bases == VisitAllBases)
9474 for (
auto &B : RD->
vbases())
9475 if (getDerived().visitBase(&B))
9478 for (
auto *F : RD->
fields())
9479 if (!F->isInvalidDecl() && !F->isUnnamedBitField() &&
9480 getDerived().visitField(F))
9489struct SpecialMemberDeletionInfo
9490 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
9495 bool AllFieldsAreConst;
9497 SpecialMemberDeletionInfo(Sema &S, CXXMethodDecl *MD,
9499 Sema::InheritedConstructorInfo *ICI,
bool Diagnose)
9500 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
9501 Loc(MD->getLocation()), AllFieldsAreConst(
true) {}
9506 return ICI ? CXXSpecialMemberKind::Invalid : CSM;
9509 bool shouldDeleteForVariantObjCPtrMember(FieldDecl *FD, QualType FieldType);
9511 bool shouldDeleteForVariantPtrAuthMember(
const FieldDecl *FD);
9513 bool visitBase(CXXBaseSpecifier *Base) {
return shouldDeleteForBase(Base); }
9514 bool visitField(FieldDecl *Field) {
return shouldDeleteForField(Field); }
9516 bool shouldDeleteForBase(CXXBaseSpecifier *Base);
9517 bool shouldDeleteForField(FieldDecl *FD);
9518 bool shouldDeleteForAllConstMembers();
9520 bool shouldDeleteForClassSubobject(CXXRecordDecl *
Class, Subobject Subobj,
9522 bool shouldDeleteForSubobjectCall(Subobject Subobj,
9523 Sema::SpecialMemberOverloadResult SMOR,
9524 bool IsDtorCallInCtor);
9526 bool isAccessible(Subobject Subobj, CXXMethodDecl *D);
9532bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
9533 CXXMethodDecl *target) {
9538 if (CXXBaseSpecifier *base = Subobj.dyn_cast<CXXBaseSpecifier*>()) {
9553bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
9554 Subobject Subobj, Sema::SpecialMemberOverloadResult SMOR,
9555 bool IsDtorCallInCtor) {
9557 FieldDecl *
Field = Subobj.dyn_cast<FieldDecl*>();
9566 } DiagKind = NotSet;
9569 if (CSM == CXXSpecialMemberKind::DefaultConstructor && Field &&
9570 Field->getParent()->isUnion()) {
9580 DiagKind = !
Decl ? NoDecl : DeletedDecl;
9582 DiagKind = MultipleDecl;
9583 else if (!isAccessible(Subobj, Decl))
9584 DiagKind = InaccessibleDecl;
9585 else if (!IsDtorCallInCtor && Field &&
Field->getParent()->isUnion() &&
9586 !
Decl->isTrivial()) {
9592 if (CSM == CXXSpecialMemberKind::DefaultConstructor) {
9600 DiagKind = NonTrivialDecl;
9602 DiagKind = NonTrivialDecl;
9606 if (DiagKind == NotSet)
9612 diag::note_deleted_special_member_class_subobject)
9614 << DiagKind << IsDtorCallInCtor <<
false;
9618 diag::note_deleted_special_member_class_subobject)
9619 << getEffectiveCSM() << MD->
getParent() <<
false
9620 <<
Base->getType() << DiagKind << IsDtorCallInCtor
9624 if (DiagKind == DeletedDecl)
9634bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
9635 CXXRecordDecl *
Class, Subobject Subobj,
unsigned Quals) {
9636 FieldDecl *
Field = Subobj.dyn_cast<FieldDecl*>();
9637 bool IsMutable =
Field &&
Field->isMutable();
9653 if (!(CSM == CXXSpecialMemberKind::DefaultConstructor && Field &&
9654 Field->hasInClassInitializer()) &&
9655 shouldDeleteForSubobjectCall(Subobj, lookupIn(
Class, Quals, IsMutable),
9662 if (IsConstructor) {
9663 Sema::SpecialMemberOverloadResult SMOR =
9665 false,
false,
false,
false);
9666 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
9673bool SpecialMemberDeletionInfo::shouldDeleteForVariantObjCPtrMember(
9674 FieldDecl *FD, QualType FieldType) {
9683 if (CSM == CXXSpecialMemberKind::DefaultConstructor &&
9689 S.
Diag(FD->
getLocation(), diag::note_deleted_special_member_class_subobject)
9690 << getEffectiveCSM() << ParentClass <<
true << FD << 4
9697bool SpecialMemberDeletionInfo::shouldDeleteForVariantPtrAuthMember(
9698 const FieldDecl *FD) {
9707 if (CSM == CXXSpecialMemberKind::DefaultConstructor ||
9708 CSM == CXXSpecialMemberKind::Destructor)
9713 S.
Diag(FD->
getLocation(), diag::note_deleted_special_member_class_subobject)
9714 << getEffectiveCSM() << ParentClass <<
true << FD << 4
9723bool SpecialMemberDeletionInfo::shouldDeleteForBase(CXXBaseSpecifier *Base) {
9724 CXXRecordDecl *BaseClass =
Base->getType()->getAsCXXRecordDecl();
9731 Sema::SpecialMemberOverloadResult SMOR = lookupInheritedCtor(BaseClass);
9732 if (
auto *BaseCtor = SMOR.
getMethod()) {
9737 if (BaseCtor->isDeleted() && Diagnose) {
9739 diag::note_deleted_special_member_class_subobject)
9740 << getEffectiveCSM() << MD->
getParent() <<
false
9741 <<
Base->getType() << 1 <<
false
9745 return BaseCtor->isDeleted();
9747 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
9752bool SpecialMemberDeletionInfo::shouldDeleteForField(FieldDecl *FD) {
9756 if (inUnion() && shouldDeleteForVariantObjCPtrMember(FD, FieldType))
9759 if (inUnion() && shouldDeleteForVariantPtrAuthMember(FD))
9762 if (CSM == CXXSpecialMemberKind::DefaultConstructor) {
9767 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
9768 << !!ICI << MD->
getParent() << FD << FieldType << 0;
9778 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
9784 AllFieldsAreConst =
false;
9785 }
else if (CSM == CXXSpecialMemberKind::CopyConstructor) {
9790 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
9794 }
else if (IsAssignment) {
9799 << isMove() << MD->
getParent() << FD << FieldType << 0;
9814 if (!inUnion() && FieldRecord->
isUnion() &&
9816 bool AllVariantFieldsAreConst =
true;
9819 for (
auto *UI : FieldRecord->
fields()) {
9822 if (shouldDeleteForVariantObjCPtrMember(&*UI, UnionFieldType))
9825 if (shouldDeleteForVariantPtrAuthMember(&*UI))
9829 AllVariantFieldsAreConst =
false;
9832 if (UnionFieldRecord &&
9833 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
9839 if (CSM == CXXSpecialMemberKind::DefaultConstructor &&
9840 AllVariantFieldsAreConst && !FieldRecord->
field_empty()) {
9843 diag::note_deleted_default_ctor_all_const)
9854 if (shouldDeleteForClassSubobject(FieldRecord, FD,
9865bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
9868 if (CSM == CXXSpecialMemberKind::DefaultConstructor && inUnion() &&
9869 AllFieldsAreConst) {
9870 bool AnyFields =
false;
9872 if ((AnyFields = !F->isUnnamedBitField()))
9878 diag::note_deleted_default_ctor_all_const)
9924 bool DeletesOnlyMatchingCopy =
9929 (!DeletesOnlyMatchingCopy ||
9934 for (
auto *I : RD->
ctors()) {
9935 if (I->isMoveConstructor()) {
9936 UserDeclaredMove = I;
9940 assert(UserDeclaredMove);
9942 (!DeletesOnlyMatchingCopy ||
9947 for (
auto *I : RD->
methods()) {
9948 if (I->isMoveAssignmentOperator()) {
9949 UserDeclaredMove = I;
9953 assert(UserDeclaredMove);
9956 if (UserDeclaredMove) {
9958 diag::note_deleted_copy_user_declared_move)
9975 Context.DeclarationNames.getCXXOperatorName(OO_Delete);
9980 OperatorDelete, IDP,
9988 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI,
Diagnose);
9996 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
9997 : SMI.VisitPotentiallyConstructedBases))
10000 if (SMI.shouldDeleteForAllConstMembers())
10011 auto RealCSM = CSM;
10015 return CUDA().inferTargetForImplicitSpecialMember(RD, RealCSM, MD,
10024 assert(DFK &&
"not a defaultable function");
10031 DefaultedComparisonAnalyzer(
10033 DFK.
asComparison(), DefaultedComparisonAnalyzer::ExplainDeleted)
10054 *Selected =
nullptr;
10058 llvm_unreachable(
"not a special member");
10076 for (
auto *CI : RD->
ctors()) {
10077 if (!CI->isDefaultConstructor())
10084 *Selected = DefCtor;
10117 }
else if (!Selected) {
10125 goto NeedOverloadResolution;
10135 }
else if (!Selected) {
10140 goto NeedOverloadResolution;
10144 NeedOverloadResolution:
10173 llvm_unreachable(
"unknown special method kind");
10177 for (
auto *CI : RD->
ctors())
10178 if (!CI->isImplicit())
10185 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
10215 ConstRHS, TAH, Diagnose ? &Selected :
nullptr))
10223 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
10226 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
10227 }
else if (!Selected)
10228 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
10233 << Kind << SubType.getUnqualifiedType() << CSM;
10235 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
10236 << Kind << SubType.getUnqualifiedType() << CSM;
10241 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
10242 << Kind << SubType.getUnqualifiedType() << CSM;
10258 for (
const auto *FI : RD->
fields()) {
10259 if (FI->isInvalidDecl() || FI->isUnnamedBitField())
10265 if (FI->isAnonymousStructOrUnion()) {
10267 CSM, ConstArg, TAH, Diagnose))
10277 FI->hasInClassInitializer()) {
10279 S.
Diag(FI->getLocation(), diag::note_nontrivial_default_member_init)
10290 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
10295 bool ConstRHS = ConstArg && !FI->isMutable();
10319 "not special enough");
10323 bool ConstArg =
false;
10347 const bool ClangABICompat14 =
Context.getLangOpts().getClangABICompat() <=
10348 LangOptions::ClangABI::Ver14;
10351 ClangABICompat14)) {
10355 <<
Context.getLValueReferenceType(
10356 Context.getCanonicalTagType(RD).withConst());
10374 <<
Context.getRValueReferenceType(
Context.getCanonicalTagType(RD));
10381 llvm_unreachable(
"not a special member");
10387 diag::note_nontrivial_default_arg)
10406 for (
const auto &BI : RD->
bases())
10448 Diag(BS.
getBeginLoc(), diag::note_nontrivial_has_virtual) << RD << 1;
10453 for (
const auto *MI : RD->
methods()) {
10454 if (MI->isVirtual()) {
10456 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
10461 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
10469struct FindHiddenVirtualMethod {
10477 static bool CheckMostOverridenMethods(
10479 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
10483 if (CheckMostOverridenMethods(O, Methods))
10493 auto *BaseRecord = Specifier->getType()->castAsRecordDecl();
10497 bool foundSameNameMethod =
false;
10499 for (Path.
Decls = BaseRecord->lookup(Name).begin();
10504 foundSameNameMethod =
true;
10521 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
10522 overloadedMethods.push_back(MD);
10526 if (foundSameNameMethod)
10527 OverloadedMethods.append(overloadedMethods.begin(),
10528 overloadedMethods.end());
10529 return foundSameNameMethod;
10536 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
10552 FindHiddenVirtualMethod FHVM;
10563 ND = shad->getTargetDecl();
10569 OverloadedMethods = FHVM.OverloadedMethods;
10574 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
10577 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
10592 if (!OverloadedMethods.empty()) {
10594 << MD << (OverloadedMethods.size() > 1);
10601 auto PrintDiagAndRemoveAttr = [&](
unsigned N) {
10604 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
10605 diag::ext_cannot_use_trivial_abi) << &RD;
10606 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
10607 diag::note_cannot_use_trivial_abi_reason) << &RD << N;
10614 PrintDiagAndRemoveAttr(1);
10618 for (
const auto &B : RD.
bases()) {
10621 if (!B.getType()->isDependentType() &&
10622 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) {
10623 PrintDiagAndRemoveAttr(2);
10627 if (B.isVirtual()) {
10628 PrintDiagAndRemoveAttr(3);
10633 for (
const auto *FD : RD.
fields()) {
10638 PrintDiagAndRemoveAttr(4);
10644 PrintDiagAndRemoveAttr(6);
10648 if (
const auto *RT =
10650 if (!RT->isDependentType() &&
10652 ->canPassInRegisters()) {
10653 PrintDiagAndRemoveAttr(5);
10662 auto HasNonDeletedCopyOrMoveConstructor = [&]() {
10674 if (CD->isCopyOrMoveConstructor() && !CD->isDeleted())
10679 if (!HasNonDeletedCopyOrMoveConstructor()) {
10680 PrintDiagAndRemoveAttr(0);
10688 diag::err_incomplete_type_vtable_pointer_auth))
10696 assert(PrimaryBase);
10699 if (!BasePtr.getType()->getAsCXXRecordDecl()->isDynamicClass())
10701 Base = BasePtr.getType()->getAsCXXRecordDecl();
10704 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
10706 Diag(RD.
getAttr<VTablePointerAuthenticationAttr>()->getLocation(),
10707 diag::err_non_top_level_vtable_pointer_auth)
10709 PrimaryBase =
Base;
10713 Diag(RD.
getAttr<VTablePointerAuthenticationAttr>()->getLocation(),
10714 diag::err_non_polymorphic_vtable_pointer_auth)
10727 if (AL.getKind() != ParsedAttr::AT_Visibility)
10730 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored) << AL;
10738 LBrac, RBrac, AttrList);
10760 Spaceships.clear();
10766 Spaceships.push_back(FD);
10775 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
10776 if (FD->isExplicitlyDefaulted())
10777 Spaceships.push_back(FD);
10807 else if (
Context.getTargetInfo().getCXXABI().isMicrosoft() &&
10872 DefaultedSpaceships);
10873 for (
auto *FD : DefaultedSpaceships)
10880 llvm::function_ref<
Scope *()> EnterScope) {
10888 DeclContext *LookupDC = dyn_cast<DeclContext>(D);
10891 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
10892 ParameterLists.push_back(DD->getTemplateParameterList(i));
10896 ParameterLists.push_back(FTD->getTemplateParameters());
10897 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
10901 ParameterLists.push_back(VTD->getTemplateParameters());
10902 else if (
auto *PSD = dyn_cast<VarTemplatePartialSpecializationDecl>(D))
10903 ParameterLists.push_back(PSD->getTemplateParameters());
10905 }
else if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
10906 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
10907 ParameterLists.push_back(TD->getTemplateParameterList(i));
10911 ParameterLists.push_back(CTD->getTemplateParameters());
10912 else if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
10913 ParameterLists.push_back(PSD->getTemplateParameters());
10918 unsigned Count = 0;
10919 Scope *InnermostTemplateScope =
nullptr;
10923 if (Params->size() == 0)
10926 InnermostTemplateScope = EnterScope();
10928 if (Param->getDeclName()) {
10929 InnermostTemplateScope->
AddDecl(Param);
10937 if (InnermostTemplateScope) {
10938 assert(LookupDC &&
"no enclosing DeclContext for template lookup");
10946 if (!RecordD)
return;
10953 if (!RecordD)
return;
10962 if (Param->getDeclName())
10981 if (Param->getDeclName())
11001 if (!
Method->isInvalidDecl())
11010 bool DiagOccured =
false;
11012 [DiagID, &S, &DiagOccured](
DeclSpec::TQ, StringRef QualName,
11019 DiagOccured =
true;
11037 S.
Diag(PointerLoc, diag::err_invalid_ctor_dtor_decl)
11105 = dyn_cast<CXXRecordDecl>(
Constructor->getDeclContext());
11116 !
Constructor->isFunctionTemplateSpecialization()) {
11118 Constructor->getParamDecl(0)->getType()->getCanonicalTypeUnqualified();
11120 if (ParamType == ClassTy) {
11122 const char *ConstRef
11123 =
Constructor->getParamDecl(0)->getIdentifier() ?
"const &"
11125 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
11147 Context.DeclarationNames.getCXXOperatorName(OO_Delete);
11150 Loc, RD,
true,
false, Name)) {
11151 Expr *ThisArg =
nullptr;
11156 if (OperatorDelete->isDestroyingOperatorDelete()) {
11157 unsigned AddressParamIndex = 0;
11158 if (OperatorDelete->isTypeAwareOperatorNewOrDelete())
11159 ++AddressParamIndex;
11161 OperatorDelete->getParamDecl(AddressParamIndex)->getType();
11168 OperatorDelete->getParamDecl(AddressParamIndex)->getLocation());
11169 assert(!
This.isInvalid() &&
"couldn't form 'this' expr in dtor?");
11172 if (
This.isInvalid()) {
11175 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
11178 ThisArg =
This.get();
11184 Destructor->setOperatorDelete(OperatorDelete, ThisArg);
11187 Context.getTargetInfo().callGlobalDeleteInDeletingDtor(
11199 if (GlobalOperatorDelete) {
11201 Destructor->setOperatorGlobalDelete(GlobalOperatorDelete);
11205 if (
Context.getTargetInfo().emitVectorDeletingDtors(
11209 Context.DeclarationNames.getCXXOperatorName(OO_Array_Delete);
11212 false, VDeleteName);
11218 Destructor->setGlobalOperatorArrayDelete(GlobalArrOperatorDelete);
11219 if (GlobalArrOperatorDelete &&
11220 Context.classNeedsVectorDeletingDestructor(RD))
11222 }
else if (!ArrOperatorDelete) {
11225 true, VDeleteName);
11227 Destructor->setOperatorArrayDelete(ArrOperatorDelete);
11228 if (ArrOperatorDelete &&
Context.classNeedsVectorDeletingDestructor(RD))
11247 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
11248 else if (
const TemplateSpecializationType *TST =
11249 DeclaratorType->
getAs<TemplateSpecializationType>())
11250 if (TST->isTypeAlias())
11252 << DeclaratorType << 1;
11347 if (After.isInvalid())
11351 R.
setEnd(After.getEnd());
11400 unsigned NumParam = Proto->getNumParams();
11404 if (NumParam == 1) {
11406 if (
const auto *
First =
11407 dyn_cast_if_present<ParmVarDecl>(FTI.
Params[0].
Param);
11408 First &&
First->isExplicitObjectParameter())
11412 if (NumParam != 0) {
11417 }
else if (Proto->isVariadic()) {
11424 if (Proto->getReturnType() != ConvType) {
11425 bool NeedsTypedef =
false;
11429 bool PastFunctionChunk =
false;
11431 switch (Chunk.Kind) {
11433 if (!PastFunctionChunk) {
11434 if (Chunk.Fun.HasTrailingReturnType) {
11439 PastFunctionChunk =
true;
11444 NeedsTypedef =
true;
11464 After.isValid() ? After.getBegin() :
11466 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
11467 DB << Before << After;
11469 if (!NeedsTypedef) {
11473 if (After.isInvalid() && ConvTSI) {
11481 }
else if (!Proto->getReturnType()->isDependentType()) {
11482 DB << 1 << Proto->getReturnType();
11484 DB << 2 << Proto->getReturnType();
11495 ConvType = Proto->getReturnType();
11503 ConvType =
Context.getPointerType(ConvType);
11507 ConvType =
Context.getPointerType(ConvType);
11515 R =
Context.getFunctionType(ConvType, {}, Proto->getExtProtoInfo());
11521 ? diag::warn_cxx98_compat_explicit_conversion_functions
11522 : diag::ext_explicit_conversion_functions)
11527 assert(Conversion &&
"Expected to receive a conversion function declaration");
11548 ConvType =
Context.getCanonicalType(ConvType).getUnqualifiedType();
11549 if (ConvType == ClassType)
11554 << ClassType << ConvType;
11557 << ClassType << ConvType;
11568 << ConvType->
castAs<AutoType>()->getKeyword()
11572 return ConversionTemplate;
11597 for (
unsigned Idx = 0; Idx < FTI.
NumParams; Idx++) {
11598 const auto &ParamInfo = FTI.
Params[Idx];
11599 if (!ParamInfo.Param)
11602 if (!Param->isExplicitObjectParameter())
11605 ExplicitObjectParam = Param;
11608 Diag(Param->getLocation(),
11609 diag::err_explicit_object_parameter_must_be_first)
11610 << IsLambda << Param->getSourceRange();
11613 if (!ExplicitObjectParam)
11618 diag::err_explicit_object_default_arg)
11626 diag::err_explicit_object_parameter_nonmember)
11633 diag::err_explicit_object_parameter_nonmember)
11658 !isa_and_present<CXXRecordDecl>(
11661 diag::err_explicit_object_parameter_nonmember)
11668 diag::err_explicit_object_parameter_mutable)
11676 assert(D.
isInvalidType() &&
"Explicit object parameter in non-member "
11677 "should have been diagnosed already");
11685 diag::err_explicit_object_parameter_constructor)
11695struct BadSpecifierDiagnoser {
11698 ~BadSpecifierDiagnoser() {
11702 template<
typename T>
void check(SourceLocation SpecLoc,
T Spec) {
11706 return check(SpecLoc,
11709 void check(SourceLocation SpecLoc,
const char *Spec) {
11711 Diagnostic << SourceRange(SpecLoc, SpecLoc);
11712 if (!Specifiers.empty()) Specifiers +=
" ";
11713 Specifiers += Spec;
11717 Sema::SemaDiagnosticBuilder Diagnostic;
11718 std::string Specifiers;
11726 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
11731 if (!
CurContext->getRedeclContext()->Equals(
11734 << GuidedTemplateDecl;
11740 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
11741 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
11742 DS.isNoreturnSpecified() || DS.hasConstexprSpecifier()) {
11743 BadSpecifierDiagnoser Diagnoser(
11745 diag::err_deduction_guide_invalid_specifier);
11747 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
11748 DS.ClearStorageClassSpecs();
11752 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
11753 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
11754 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
11755 DS.ClearConstexprSpec();
11757 Diagnoser.check(DS.getConstSpecLoc(),
"const");
11758 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
11759 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
11760 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
11761 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
11762 DS.ClearTypeQualifiers();
11764 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
11765 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
11766 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
11767 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
11768 DS.ClearTypeSpecType();
11775 bool FoundFunction =
false;
11781 diag::err_deduction_guide_with_complex_decl)
11785 if (!Chunk.Fun.hasTrailingReturnType())
11787 diag::err_deduction_guide_no_trailing_return_type);
11792 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
11795 assert(TSI &&
"deduction guide has valid type but invalid return type?");
11796 bool AcceptableReturnType =
false;
11797 bool MightInstantiateToSpecialization =
false;
11800 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
11801 bool TemplateMatches =
Context.hasSameTemplateName(
11802 SpecifiedName, GuidedTemplate,
true);
11806 assert(
Qualifiers &&
"expected QualifiedTemplate");
11807 bool SimplyWritten =
11809 if (SimplyWritten && TemplateMatches)
11810 AcceptableReturnType =
true;
11815 MightInstantiateToSpecialization =
11819 MightInstantiateToSpecialization =
true;
11822 if (!AcceptableReturnType)
11824 diag::err_deduction_guide_bad_trailing_return_type)
11825 << GuidedTemplate << TSI->
getType()
11826 << MightInstantiateToSpecialization
11831 FoundFunction =
true;
11850 assert(*IsInline != PrevNS->
isInline());
11860 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
11863 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
11881 bool IsInline = InlineLoc.
isValid();
11882 bool IsInvalid =
false;
11883 bool IsStd =
false;
11884 bool AddToKnown =
false;
11895 auto DiagnoseInlineStdNS = [&]() {
11896 assert(IsInline && II->
isStr(
"std") &&
11897 CurContext->getRedeclContext()->isTranslationUnit() &&
11898 "Precondition of DiagnoseInlineStdNS not met");
11899 Diag(InlineLoc, diag::err_inline_namespace_std)
11919 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
11923 if (IsInline && II->
isStr(
"std") &&
11924 CurContext->getRedeclContext()->isTranslationUnit())
11925 DiagnoseInlineStdNS();
11926 else if (IsInline != PrevNS->
isInline())
11928 &IsInline, PrevNS);
11929 }
else if (PrevDecl) {
11931 Diag(Loc, diag::err_redefinition_different_kind)
11936 }
else if (II->
isStr(
"std") &&
11937 CurContext->getRedeclContext()->isTranslationUnit()) {
11939 DiagnoseInlineStdNS();
11944 AddToKnown = !IsInline;
11947 AddToKnown = !IsInline;
11961 if (PrevNS && IsInline != PrevNS->
isInline())
11963 &IsInline, PrevNS);
11976 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
11982 KnownNamespaces[Namespc] =
false;
11990 TU->setAnonymousNamespace(Namespc);
12042 return dyn_cast_or_null<NamespaceDecl>(D);
12046 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
12047 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
12050 if (Namespc->
hasAttr<VisibilityAttr>())
12053 if (DeferredExportedNamespaces.erase(Namespc))
12058 return cast_or_null<CXXRecordDecl>(
12067 return cast_or_null<NamespaceDecl>(
12073enum UnsupportedSTLSelect {
12080struct InvalidSTLDiagnoser {
12085 QualType operator()(UnsupportedSTLSelect Sel = USS_Other, StringRef Name =
"",
12086 const VarDecl *VD =
nullptr) {
12088 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
12089 << TyForDiags << ((
int)Sel);
12090 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
12091 assert(!Name.empty());
12095 if (Sel == USS_InvalidMember) {
12108 "Looking for comparison category type outside of C++.");
12123 if (Info && FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)]) {
12134 std::string NameForDiags =
"std::";
12136 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
12137 << NameForDiags << (int)Usage;
12141 assert(Info->
Kind == Kind);
12152 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags(Info)};
12155 return UnsupportedSTLError(USS_NonTrivial);
12160 if (
Base->isEmpty())
12163 return UnsupportedSTLError();
12171 if (std::distance(FIt, FEnd) != 1 ||
12172 !FIt->getType()->isIntegralOrEnumerationType()) {
12173 return UnsupportedSTLError();
12183 return UnsupportedSTLError(USS_MissingMember, MemName);
12186 assert(VD &&
"should not be null!");
12193 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
12199 return UnsupportedSTLError();
12206 FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)] =
true;
12216 &
PP.getIdentifierTable().get(
"std"),
12229 const char *ClassName,
12231 const Decl **MalformedDecl) {
12239 auto ReportMatchingNameAsMalformed = [&](
NamedDecl *D) {
12240 if (!MalformedDecl)
12248 *MalformedDecl = D;
12253 if (
const TemplateSpecializationType *TST =
12255 Template = dyn_cast_or_null<ClassTemplateDecl>(
12256 TST->getTemplateName().getAsTemplateDecl());
12257 Arguments = TST->template_arguments();
12258 }
else if (
const auto *TT = SugaredType->
getAs<TagType>()) {
12260 Arguments = TT->getTemplateArgs(S.
Context);
12264 ReportMatchingNameAsMalformed(SugaredType->
getAsTagDecl());
12268 if (!*CachedDecl) {
12287 *MalformedDecl = TemplateClass;
12295 if (
Template->getCanonicalDecl() != (*CachedDecl)->getCanonicalDecl())
12300 QualType ArgType = Arguments[0].getAsType();
12306 if (S.
getLangOpts().ObjCAutoRefCount && ArgType->isObjCLifetimeType() &&
12307 !ArgType.getObjCLifetime()) {
12312 *TypeArg = ArgType;
12320 "Looking for std::initializer_list outside of C++.");
12330 const Decl **MalformedDecl) {
12332 "Looking for std::type_identity outside of C++.");
12342 const char *ClassName,
12343 bool *WasMalformed) {
12354 Result.suppressDiagnostics();
12357 S.
Diag(
Found->getLocation(), diag::err_malformed_std_class_template)
12360 *WasMalformed =
true;
12369 S.
Diag(
Template->getLocation(), diag::err_malformed_std_class_template)
12372 *WasMalformed =
true;
12387 Loc, Args,
nullptr,
12393 bool WasMalformed =
false;
12398 Diag(Loc, diag::err_implied_std_initializer_list_not_found);
12426 ArgType = RT->getPointeeType().getUnqualifiedType();
12435 case Decl::TranslationUnit:
12437 case Decl::LinkageSpec:
12447class NamespaceValidatorCCC final :
public CorrectionCandidateCallback {
12449 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
12455 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
12456 return std::make_unique<NamespaceValidatorCCC>(*
this);
12465 Module *M = ND->getOwningModule();
12466 assert(M &&
"hidden namespace definition not in a module?");
12470 diag::err_module_unimported_use_header)
12475 diag::err_module_unimported_use)
12485 NamespaceValidatorCCC CCC{};
12495 if (isa_and_nonnull<NamespaceDecl>(Corrected.getFoundDecl()) &&
12496 Corrected.requiresImport()) {
12499 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
12500 bool DroppedSpecifier =
12501 Corrected.WillReplaceSpecifier() && Ident->
getName() == CorrectedStr;
12503 S.
PDiag(diag::err_using_directive_member_suggest)
12504 << Ident << DC << DroppedSpecifier << SS.
getRange(),
12505 S.
PDiag(diag::note_namespace_defined_here));
12508 S.
PDiag(diag::err_using_directive_suggest) << Ident,
12509 S.
PDiag(diag::note_namespace_defined_here));
12511 R.
addDecl(Corrected.getFoundDecl());
12522 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
12523 assert(NamespcName &&
"Invalid NamespcName.");
12524 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
12544 NamespcName->
isStr(
"std")) {
12545 Diag(IdentLoc, diag::ext_using_undefined_std);
12557 assert(
NS &&
"expected namespace decl");
12576 CommonAncestor = CommonAncestor->
getParent();
12580 IdentLoc, Named, CommonAncestor);
12584 Diag(IdentLoc, diag::warn_using_directive_in_header);
12589 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
12639 ? diag::warn_cxx98_compat_using_decl_constructor
12640 : diag::err_using_decl_constructor)
12657 llvm_unreachable(
"cannot parse qualified deduction guide name");
12668 ? diag::err_access_decl
12669 : diag::warn_access_decl_deprecated)
12680 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
12688 SS, TargetNameInfo, EllipsisLoc, AttrList,
12707 ? diag::err_using_enum_is_dependent
12708 : diag::err_unknown_typename)
12716 Diag(IdentLoc, diag::err_using_enum_is_dependent);
12722 Diag(IdentLoc, diag::err_using_enum_not_enum) << EnumTy;
12726 if (TSI ==
nullptr)
12727 TSI =
Context.getTrivialTypeSourceInfo(EnumTy, IdentLoc);
12748 return Context.hasSameType(TD1->getUnderlyingType(),
12749 TD2->getUnderlyingType());
12783 if (
auto *Using = dyn_cast<UsingDecl>(BUD)) {
12795 Diag(Using->getLocation(),
12796 diag::err_using_decl_nested_name_specifier_is_current_class)
12797 << Using->getQualifierLoc().getSourceRange();
12799 Using->setInvalidDecl();
12803 Diag(Using->getQualifierLoc().getBeginLoc(),
12804 diag::err_using_decl_nested_name_specifier_is_not_base_class)
12806 << Using->getQualifierLoc().getSourceRange();
12808 Using->setInvalidDecl();
12813 if (
Previous.empty())
return false;
12824 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
12825 bool FoundEquivalentDecl =
false;
12828 NamedDecl *D = (*I)->getUnderlyingDecl();
12835 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
12850 PrevShadow = Shadow;
12851 FoundEquivalentDecl =
true;
12855 FoundEquivalentDecl =
true;
12862 if (FoundEquivalentDecl)
12868 (isa_and_nonnull<UnresolvedUsingIfExistsDecl>(NonTag))) {
12869 if (!NonTag && !Tag)
12872 Diag(
Target->getLocation(), diag::note_using_decl_target);
12873 Diag((NonTag ? NonTag : Tag)->getLocation(),
12874 diag::note_using_decl_conflict);
12903 Diag(
Target->getLocation(), diag::note_using_decl_target);
12913 if (!Tag)
return false;
12916 Diag(
Target->getLocation(), diag::note_using_decl_target);
12917 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
12923 if (!NonTag)
return false;
12926 Diag(
Target->getLocation(), diag::note_using_decl_target);
12936 for (
auto &B : Derived->
bases())
12937 if (B.getType()->getAsCXXRecordDecl() ==
Base)
12938 return B.isVirtual();
12939 llvm_unreachable(
"not a direct base class");
12953 if (
auto *TargetTD = dyn_cast<TemplateDecl>(
Target))
12954 NonTemplateTarget = TargetTD->getTemplatedDecl();
12959 bool IsVirtualBase =
12961 Using->getQualifier().getAsRecordDecl());
13009 bool &AnyDependentBases) {
13014 CanQualType BaseType =
Base.getType()->getCanonicalTypeUnqualified();
13015 if (CanonicalDesiredBase == BaseType)
13017 if (BaseType->isDependentType())
13018 AnyDependentBases =
true;
13024class UsingValidatorCCC final :
public CorrectionCandidateCallback {
13026 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
13027 NestedNameSpecifier NNS, CXXRecordDecl *RequireMemberOf)
13028 : HasTypenameKeyword(HasTypenameKeyword),
13029 IsInstantiation(IsInstantiation), OldNNS(NNS),
13030 RequireMemberOf(RequireMemberOf) {}
13032 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
13046 if (RequireMemberOf) {
13047 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
13048 if (FoundRecord && FoundRecord->isInjectedClassName()) {
13062 if (
Specifier.getKind() != NestedNameSpecifier::Kind::Type ||
13068 bool AnyDependentBases =
false;
13071 AnyDependentBases) &&
13072 !AnyDependentBases)
13082 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
13083 if (FoundRecord && FoundRecord->isInjectedClassName())
13088 return HasTypenameKeyword || !IsInstantiation;
13090 return !HasTypenameKeyword;
13093 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
13094 return std::make_unique<UsingValidatorCCC>(*
this);
13098 bool HasTypenameKeyword;
13099 bool IsInstantiation;
13100 NestedNameSpecifier OldNNS;
13101 CXXRecordDecl *RequireMemberOf;
13128 bool IsUsingIfExists) {
13129 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
13131 assert(IdentLoc.
isValid() &&
"Invalid TargetName location.");
13140 if (
auto *RD = dyn_cast<CXXRecordDecl>(
CurContext))
13141 UsingName.
setName(
Context.DeclarationNames.getCXXConstructorName(
13142 Context.getCanonicalTagType(RD)));
13153 assert(IsInstantiation &&
"no scope in non-instantiation");
13181 Diag(UsingLoc, diag::err_using_if_exists_on_ctor);
13187 if (!LookupContext || EllipsisLoc.
isValid()) {
13191 SS, NameInfo, IdentLoc))
13195 Previous.getFoundDecl()->isTemplateParameter())
13198 if (HasTypenameKeyword) {
13201 UsingLoc, TypenameLoc,
13203 IdentLoc, NameInfo.
getName(),
13207 QualifierLoc, NameInfo, EllipsisLoc);
13215 auto Build = [&](
bool Invalid) {
13218 UsingName, HasTypenameKeyword);
13225 auto BuildInvalid = [&]{
return Build(
true); };
13226 auto BuildValid = [&]{
return Build(
false); };
13229 return BuildInvalid();
13238 if (!IsInstantiation)
13255 if (R.
empty() && IsUsingIfExists)
13273 PP.NeedsStdLibCxxWorkaroundBefore(2016'12'21) &&
13276 UsingValidatorCCC CCC(HasTypenameKeyword, IsInstantiation, SS.
getScopeRep(),
13284 << NameInfo.
getName() << LookupContext << 0
13289 NamedDecl *ND = Corrected.getCorrectionDecl();
13291 return BuildInvalid();
13294 auto *RD = dyn_cast<CXXRecordDecl>(ND);
13300 if (Corrected.WillReplaceSpecifier()) {
13304 QualifierLoc = Builder.getWithLocInContext(
Context);
13310 UsingName.
setName(
Context.DeclarationNames.getCXXConstructorName(
13311 Context.getCanonicalTagType(CurClass)));
13323 Diag(IdentLoc, diag::err_no_member)
13325 return BuildInvalid();
13330 return BuildInvalid();
13332 if (HasTypenameKeyword) {
13336 Diag(IdentLoc, diag::err_using_typename_non_type);
13338 Diag((*I)->getUnderlyingDecl()->getLocation(),
13339 diag::note_using_decl_target);
13340 return BuildInvalid();
13347 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
13349 return BuildInvalid();
13356 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
13361 return BuildInvalid();
13393 if (
CurContext->getRedeclContext()->isRecord()) {
13403 if (UED->getEnumDecl() == ED) {
13404 Diag(UsingLoc, diag::err_using_enum_decl_redeclaration)
13416 EnumLoc, NameLoc, EnumType);
13449 UPD->setAccess(InstantiatedFrom->
getAccess());
13455 assert(!UD->
hasTypename() &&
"expecting a constructor name");
13461 bool AnyDependentBases =
false;
13464 if (!
Base && !AnyDependentBases) {
13465 Diag(UD->
getUsingLoc(), diag::err_using_decl_constructor_not_in_direct_base)
13472 Base->setInheritConstructors();
13478 bool HasTypenameKeyword,
13491 if (!
CurContext->getRedeclContext()->isRecord()) {
13498 for (
auto *D : Prev) {
13500 bool OldCouldBeEnumerator =
13503 OldCouldBeEnumerator ? diag::err_redefinition
13504 : diag::err_redefinition_different_kind)
13505 << Prev.getLookupName();
13520 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
13521 DTypename = UD->hasTypename();
13522 DQual = UD->getQualifier();
13524 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
13526 DQual = UD->getQualifier();
13528 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
13530 DQual = UD->getQualifier();
13535 if (HasTypenameKeyword != DTypename)
continue;
13543 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
13557 assert(
bool(NamedContext) == (R || UD) && !(R && UD) &&
13558 "resolvable context must have exactly one set of decls");
13562 bool Cxx20Enumerator =
false;
13563 if (NamedContext) {
13572 if (
auto *ED = dyn_cast<EnumDecl>(NamedContext)) {
13576 if (EC && R && ED->isScoped())
13579 ? diag::warn_cxx17_compat_using_decl_scoped_enumerator
13580 : diag::ext_using_decl_scoped_enumerator)
13584 NamedContext = ED->getDeclContext();
13604 ? diag::warn_cxx17_compat_using_decl_class_member_enumerator
13605 : diag::err_using_decl_can_not_refer_to_class_member)
13608 if (Cxx20Enumerator)
13611 auto *RD = NamedContext
13623 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
13624 << diag::MemClassWorkaround::AliasDecl
13631 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
13632 << diag::MemClassWorkaround::TypedefDecl
13647 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
13648 << diag::MemClassWorkaround::ReferenceDecl << FixIt;
13661 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
13663 ? diag::MemClassWorkaround::ConstexprVar
13664 : diag::MemClassWorkaround::ConstVar)
13673 if (!NamedContext) {
13689 ? diag::warn_cxx17_compat_using_decl_non_member_enumerator
13690 : diag::err_using_decl_nested_name_specifier_is_not_class)
13693 if (Cxx20Enumerator)
13714 if (Cxx20Enumerator) {
13715 Diag(NameLoc, diag::warn_cxx17_compat_using_decl_non_member_enumerator)
13722 diag::err_using_decl_nested_name_specifier_is_current_class)
13729 diag::err_using_decl_nested_name_specifier_is_not_base_class)
13745 if (
Type.isInvalid())
13764 TemplateParamLists.size()
13771 Previous.getFoundDecl()->isTemplateParameter()) {
13777 "name in alias declaration must be an identifier");
13800 if (TemplateParamLists.size()) {
13804 if (TemplateParamLists.size() != 1) {
13805 Diag(UsingLoc, diag::err_alias_template_extra_headers)
13806 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
13807 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
13824 Diag(UsingLoc, diag::err_redefinition_different_kind)
13839 OldTemplateParams =
13875 else if (OldDecl) {
13882 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
13910 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
13942 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
13944 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
13945 << AD->getNamespace();
13950 ? diag::err_redefinition
13951 : diag::err_redefinition_different_kind;
13952 Diag(AliasLoc, DiagID) << Alias;
13973struct SpecialMemberExceptionSpecInfo
13974 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
13982 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
13987 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
13990 void visitSubobjectCall(Subobject Subobj,
13995bool SpecialMemberExceptionSpecInfo::visitBase(CXXBaseSpecifier *Base) {
13996 auto *BaseClass =
Base->getType()->getAsCXXRecordDecl();
14000 Sema::SpecialMemberOverloadResult SMOR = lookupInheritedCtor(BaseClass);
14001 if (
auto *BaseCtor = SMOR.
getMethod()) {
14002 visitSubobjectCall(Base, BaseCtor);
14006 visitClassSubobject(BaseClass, Base, 0);
14010bool SpecialMemberExceptionSpecInfo::visitField(FieldDecl *FD) {
14011 if (CSM == CXXSpecialMemberKind::DefaultConstructor &&
14030void SpecialMemberExceptionSpecInfo::visitClassSubobject(CXXRecordDecl *
Class,
14033 FieldDecl *
Field = Subobj.dyn_cast<FieldDecl*>();
14034 bool IsMutable =
Field &&
Field->isMutable();
14035 visitSubobjectCall(Subobj, lookupIn(
Class, Quals, IsMutable));
14038void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
14039 Subobject Subobj, Sema::SpecialMemberOverloadResult SMOR) {
14042 if (CXXMethodDecl *MD = SMOR.
getMethod())
14043 ExceptSpec.
CalledDecl(getSubobjectLoc(Subobj), MD);
14072 ComputingExceptionSpec CES(S, MD, Loc);
14079 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
14081 return Info.ExceptSpec;
14088 diag::err_exception_spec_incomplete_type))
14089 return Info.ExceptSpec;
14106 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
14107 : Info.VisitAllBases);
14109 return Info.ExceptSpec;
14114struct DeclaringSpecialMember {
14117 Sema::ContextRAII SavedContext;
14118 bool WasAlreadyBeingDeclared;
14121 : S(S), D(RD, CSM), SavedContext(S, RD) {
14123 if (WasAlreadyBeingDeclared)
14130 Sema::CodeSynthesisContext Ctx;
14131 Ctx.Kind = Sema::CodeSynthesisContext::DeclaringSpecialMember;
14138 Ctx.PointOfInstantiation = RD->getLocation();
14140 Ctx.SpecialMember = CSM;
14141 S.pushCodeSynthesisContext(Ctx);
14144 ~DeclaringSpecialMember() {
14145 if (!WasAlreadyBeingDeclared) {
14152 bool isAlreadyBeingDeclared()
const {
14153 return WasAlreadyBeingDeclared;
14174void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
14180 LangAS AS = getDefaultCXXMethodAddrSpace();
14185 auto QT = Context.getFunctionType(ResultTy, Args, EPI);
14193 Context.getTrivialTypeSourceInfo(SpecialMem->
getType());
14207 "Should not build implicit default constructor!");
14209 DeclaringSpecialMember DSM(*
this, ClassDecl,
14211 if (DSM.isAlreadyBeingDeclared())
14221 =
Context.DeclarationNames.getCXXConstructorName(ClassType);
14233 setupImplicitSpecialMemberType(DefaultCon,
Context.VoidTy, {});
14236 CUDA().inferTargetForImplicitSpecialMember(
14257 ClassDecl->
addDecl(DefaultCon);
14267 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
14272 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
14286 Scope.addContextNote(CurrentLocation);
14329 ->getInheritedConstructor()
14336 Context.getTrivialTypeSourceInfo(BaseCtor->
getType(), UsingLoc);
14347 false, BaseCtor, &ICI);
14364 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
14370 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
14374 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
14381 ParamDecls.push_back(PD);
14386 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
14389 Derived->
addDecl(DerivedCtor);
14395 return DerivedCtor;
14426 Scope.addContextNote(CurrentLocation);
14429 Constructor->getInheritedConstructor().getShadowDecl();
14431 Constructor->getInheritedConstructor().getConstructor();
14445 for (
bool VBase : {
false,
true}) {
14447 if (B.isVirtual() != VBase)
14450 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
14455 if (!BaseCtor.first)
14460 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
14462 auto *TInfo =
Context.getTrivialTypeSourceInfo(B.getType(), InitLoc);
14464 Context, TInfo, VBase, InitLoc,
Init.get(), InitLoc,
14494 DeclaringSpecialMember DSM(*
this, ClassDecl,
14496 if (DSM.isAlreadyBeingDeclared())
14506 =
Context.DeclarationNames.getCXXDestructorName(ClassType);
14521 CUDA().inferTargetForImplicitSpecialMember(
14556 !
Destructor->doesThisDeclarationHaveABody() &&
14558 "DefineImplicitDestructor - call it for implicit default dtor");
14563 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
14574 Scope.addContextNote(CurrentLocation);
14601 assert(
Context.getTargetInfo().getCXXABI().isMicrosoft() &&
14602 "implicit complete dtors unneeded outside MS ABI");
14604 "complete dtor only exists for classes with vbases");
14609 Scope.addContextNote(CurrentLocation);
14617 if (
Record->isInvalidDecl()) {
14638 if (M->getParent()->getTemplateSpecializationKind() !=
14658 "adjusting dtor exception specs was introduced in c++11");
14668 if (DtorType->hasExceptionSpec())
14691 ExprBuilder(
const ExprBuilder&) =
delete;
14692 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
14695 static Expr *assertNotNull(
Expr *E) {
14696 assert(E &&
"Expression construction must not fail.");
14702 virtual ~ExprBuilder() {}
14704 virtual Expr *build(Sema &S, SourceLocation Loc)
const = 0;
14707class RefBuilder:
public ExprBuilder {
14712 Expr *build(Sema &S, SourceLocation Loc)
const override {
14716 RefBuilder(VarDecl *Var, QualType VarType)
14717 : Var(Var), VarType(VarType) {}
14720class ThisBuilder:
public ExprBuilder {
14722 Expr *build(Sema &S, SourceLocation Loc)
const override {
14727class CastBuilder:
public ExprBuilder {
14728 const ExprBuilder &Builder;
14734 Expr *build(Sema &S, SourceLocation Loc)
const override {
14736 CK_UncheckedDerivedToBase, Kind,
14745class DerefBuilder:
public ExprBuilder {
14746 const ExprBuilder &Builder;
14749 Expr *build(Sema &S, SourceLocation Loc)
const override {
14750 return assertNotNull(
14754 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14757class MemberBuilder:
public ExprBuilder {
14758 const ExprBuilder &Builder;
14762 LookupResult &MemberLookup;
14765 Expr *build(Sema &S, SourceLocation Loc)
const override {
14767 Builder.build(S, Loc),
Type, Loc, IsArrow, SS, SourceLocation(),
14768 nullptr, MemberLookup,
nullptr,
nullptr).get());
14771 MemberBuilder(
const ExprBuilder &Builder, QualType
Type,
bool IsArrow,
14772 LookupResult &MemberLookup)
14773 : Builder(Builder),
Type(
Type), IsArrow(IsArrow),
14774 MemberLookup(MemberLookup) {}
14777class MoveCastBuilder:
public ExprBuilder {
14778 const ExprBuilder &Builder;
14781 Expr *build(Sema &S, SourceLocation Loc)
const override {
14782 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
14785 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14788class LvalueConvBuilder:
public ExprBuilder {
14789 const ExprBuilder &Builder;
14792 Expr *build(Sema &S, SourceLocation Loc)
const override {
14793 return assertNotNull(
14797 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14800class SubscriptBuilder:
public ExprBuilder {
14801 const ExprBuilder &
Base;
14802 const ExprBuilder &Index;
14805 Expr *build(Sema &S, SourceLocation Loc)
const override {
14807 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
14810 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
14822 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
14831 Expr *From = FromB.build(S, Loc);
14835 Expr *To = ToB.build(S, Loc);
14840 bool NeedsCollectableMemCpy =
false;
14841 if (
auto *RD =
T->getBaseElementTypeUnsafe()->getAsRecordDecl())
14845 StringRef MemCpyName = NeedsCollectableMemCpy ?
14846 "__builtin_objc_memmove_collectable" :
14847 "__builtin_memcpy";
14860 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
14862 Expr *CallArgs[] = {
14866 Loc, CallArgs, Loc);
14868 assert(!
Call.isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
14901 const ExprBuilder &To,
const ExprBuilder &From,
14902 bool CopyingBaseSubobject,
bool Copying,
14903 unsigned Depth = 0) {
14918 if (
auto *ClassDecl =
T->getAsCXXRecordDecl()) {
14932 if (Method->isCopyAssignmentOperator() ||
14933 (!Copying && Method->isMoveAssignmentOperator()))
14952 if (CopyingBaseSubobject) {
14981 Expr *FromInst = From.build(S, Loc);
14984 Loc, FromInst, Loc);
14985 if (
Call.isInvalid())
15004 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
15024 llvm::raw_svector_ostream OS(Str);
15025 OS <<
"__i" << Depth;
15029 IterationVarName, SizeType,
15038 RefBuilder IterationVarRef(IterationVar, SizeType);
15039 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
15045 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
15046 MoveCastBuilder FromIndexMove(FromIndexCopy);
15047 const ExprBuilder *FromIndex;
15049 FromIndex = &FromIndexCopy;
15051 FromIndex = &FromIndexMove;
15053 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
15058 ToIndex, *FromIndex, CopyingBaseSubobject,
15059 Copying, Depth + 1);
15061 if (
Copy.isInvalid() || !
Copy.get())
15068 S.
Context, IterationVarRefRVal.build(S, Loc),
15082 Loc, Loc, InitStmt,
15089 const ExprBuilder &To,
const ExprBuilder &From,
15090 bool CopyingBaseSubobject,
bool Copying) {
15092 if (
T->isArrayType() && !
T.isConstQualified() && !
T.isVolatileQualified() &&
15093 T.isTriviallyCopyableType(S.
Context))
15097 CopyingBaseSubobject,
15102 if (!Result.isInvalid() && !Result.get())
15115 DeclaringSpecialMember DSM(*
this, ClassDecl,
15117 if (DSM.isAlreadyBeingDeclared())
15121 std::nullopt, ClassDecl,
15155 CUDA().inferTargetForImplicitSpecialMember(
15162 ClassLoc, ClassLoc,
15175 ++
getASTContext().NumImplicitCopyAssignmentOperatorsDeclared;
15207 for (
auto *I : RD->
ctors()) {
15208 if (I->isCopyConstructor()) {
15209 UserDeclaredOperation = I;
15213 assert(UserDeclaredOperation);
15217 for (
auto *I : RD->
methods()) {
15218 if (I->isCopyAssignmentOperator()) {
15219 UserDeclaredOperation = I;
15223 assert(UserDeclaredOperation);
15226 if (UserDeclaredOperation) {
15227 bool UDOIsUserProvided = UserDeclaredOperation->
isUserProvided();
15231 (UDOIsUserProvided && UDOIsDestructor)
15232 ? diag::warn_deprecated_copy_with_user_provided_dtor
15233 : (UDOIsUserProvided && !UDOIsDestructor)
15234 ? diag::warn_deprecated_copy_with_user_provided_copy
15235 : (!UDOIsUserProvided && UDOIsDestructor)
15236 ? diag::warn_deprecated_copy_with_dtor
15237 : diag::warn_deprecated_copy;
15239 << RD << IsCopyAssignment;
15250 "DefineImplicitCopyAssignment called for wrong function");
15268 Scope.addContextNote(CurrentLocation);
15303 RefBuilder OtherRef(
Other, OtherRefType);
15306 std::optional<ThisBuilder>
This;
15307 std::optional<DerefBuilder> DerefThis;
15308 std::optional<RefBuilder> ExplicitObject;
15309 bool IsArrow =
false;
15315 ExplicitObject.emplace(CopyAssignOperator->
getParamDecl(0), ObjectType);
15319 DerefThis.emplace(*
This);
15322 ExprBuilder &ObjectParameter =
15323 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15324 :
static_cast<ExprBuilder &
>(*This);
15328 for (
auto &
Base : ClassDecl->
bases()) {
15331 QualType BaseType =
Base.getType().getUnqualifiedType();
15332 if (!BaseType->isRecordType()) {
15338 BasePath.push_back(&
Base);
15342 CastBuilder From(OtherRef,
Context.getQualifiedType(BaseType, OtherQuals),
15347 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15348 :
static_cast<ExprBuilder &
>(*DerefThis),
15357 if (
Copy.isInvalid()) {
15363 Statements.push_back(
Copy.getAs<
Expr>());
15367 for (
auto *Field : ClassDecl->
fields()) {
15370 if (Field->isUnnamedBitField() || Field->getParent()->isUnion())
15373 if (Field->isInvalidDecl()) {
15379 if (Field->getType()->isReferenceType()) {
15380 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15381 <<
Context.getCanonicalTagType(ClassDecl) << 0
15382 << Field->getDeclName();
15383 Diag(Field->getLocation(), diag::note_declared_at);
15390 if (!BaseType->isRecordType() && BaseType.isConstQualified()) {
15391 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15392 <<
Context.getCanonicalTagType(ClassDecl) << 1
15393 << Field->getDeclName();
15394 Diag(Field->getLocation(), diag::note_declared_at);
15400 if (Field->isZeroLengthBitField())
15403 QualType FieldType = Field->getType().getNonReferenceType();
15406 "Incomplete array type is not valid");
15412 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
15417 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
15418 MemberBuilder To(ObjectParameter, ObjectType, IsArrow, MemberLookup);
15424 if (
Copy.isInvalid()) {
15430 Statements.push_back(
Copy.getAs<
Stmt>());
15436 (ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15437 :
LangOpts.HLSL ?
static_cast<ExprBuilder &
>(*This)
15438 :
static_cast<ExprBuilder &
>(*DerefThis))
15439 .build(*
this, Loc);
15444 Statements.push_back(Return.
getAs<
Stmt>());
15457 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
15463 L->CompletedImplicitDefinition(CopyAssignOperator);
15470 DeclaringSpecialMember DSM(*
this, ClassDecl,
15472 if (DSM.isAlreadyBeingDeclared())
15479 std::nullopt, ClassDecl,
15509 CUDA().inferTargetForImplicitSpecialMember(
15516 ClassLoc, ClassLoc,
15529 ++
getASTContext().NumImplicitMoveAssignmentOperatorsDeclared;
15552 assert(!Class->isDependentContext() &&
"should not define dependent move");
15558 if (Class->getNumVBases() == 0 || Class->hasTrivialMoveAssignment() ||
15559 Class->getNumBases() < 2)
15563 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
15566 for (
auto &BI : Class->bases()) {
15567 Worklist.push_back(&BI);
15568 while (!Worklist.empty()) {
15574 if (!
Base->hasNonTrivialMoveAssignment())
15599 VBases.insert(std::make_pair(
Base->getCanonicalDecl(), &BI))
15601 if (Existing && Existing != &BI) {
15602 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
15605 << (
Base->getCanonicalDecl() ==
15608 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
15609 << (
Base->getCanonicalDecl() ==
15610 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
15614 Existing =
nullptr;
15624 llvm::append_range(Worklist, llvm::make_pointer_range(
Base->bases()));
15637 "DefineImplicitMoveAssignment called for wrong function");
15667 Scope.addContextNote(CurrentLocation);
15683 RefBuilder OtherRef(
Other, OtherRefType);
15685 MoveCastBuilder MoveOther(OtherRef);
15688 std::optional<ThisBuilder>
This;
15689 std::optional<DerefBuilder> DerefThis;
15690 std::optional<RefBuilder> ExplicitObject;
15692 bool IsArrow =
false;
15697 ExplicitObject.emplace(MoveAssignOperator->
getParamDecl(0), ObjectType);
15701 DerefThis.emplace(*
This);
15704 ExprBuilder &ObjectParameter =
15705 ExplicitObject ? *ExplicitObject :
static_cast<ExprBuilder &
>(*This);
15709 for (
auto &
Base : ClassDecl->
bases()) {
15720 QualType BaseType =
Base.getType().getUnqualifiedType();
15721 if (!BaseType->isRecordType()) {
15727 BasePath.push_back(&
Base);
15731 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
15736 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15737 :
static_cast<ExprBuilder &
>(*DerefThis),
15746 if (Move.isInvalid()) {
15752 Statements.push_back(Move.getAs<
Expr>());
15756 for (
auto *Field : ClassDecl->
fields()) {
15759 if (Field->isUnnamedBitField() || Field->getParent()->isUnion())
15762 if (Field->isInvalidDecl()) {
15768 if (Field->getType()->isReferenceType()) {
15769 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15770 <<
Context.getCanonicalTagType(ClassDecl) << 0
15771 << Field->getDeclName();
15772 Diag(Field->getLocation(), diag::note_declared_at);
15779 if (!BaseType->isRecordType() && BaseType.isConstQualified()) {
15780 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15781 <<
Context.getCanonicalTagType(ClassDecl) << 1
15782 << Field->getDeclName();
15783 Diag(Field->getLocation(), diag::note_declared_at);
15789 if (Field->isZeroLengthBitField())
15792 QualType FieldType = Field->getType().getNonReferenceType();
15795 "Incomplete array type is not valid");
15800 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
15804 MemberBuilder From(MoveOther, OtherRefType,
15805 false, MemberLookup);
15806 MemberBuilder To(ObjectParameter, ObjectType, IsArrow, MemberLookup);
15808 assert(!From.build(*
this, Loc)->isLValue() &&
15809 "Member reference with rvalue base must be rvalue except for reference "
15810 "members, which aren't allowed for move assignment.");
15817 if (Move.isInvalid()) {
15823 Statements.push_back(Move.getAs<
Stmt>());
15829 (ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15830 :
LangOpts.HLSL ?
static_cast<ExprBuilder &
>(*This)
15831 :
static_cast<ExprBuilder &
>(*DerefThis))
15832 .build(*
this, Loc);
15838 Statements.push_back(Return.
getAs<
Stmt>());
15851 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
15857 L->CompletedImplicitDefinition(MoveAssignOperator);
15868 DeclaringSpecialMember DSM(*
this, ClassDecl,
15870 if (DSM.isAlreadyBeingDeclared())
15874 std::nullopt, ClassDecl,
15891 =
Context.DeclarationNames.getCXXConstructorName(
15892 Context.getCanonicalType(ClassType));
15911 CUDA().inferTargetForImplicitSpecialMember(
15937 ClassDecl->
hasAttr<TrivialABIAttr>() ||
15969 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
15974 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
15985 Scope.addContextNote(CurrentLocation);
16015 DeclaringSpecialMember DSM(*
this, ClassDecl,
16017 if (DSM.isAlreadyBeingDeclared())
16021 std::nullopt, ClassDecl,
16034 =
Context.DeclarationNames.getCXXConstructorName(
16035 Context.getCanonicalType(ClassType));
16055 CUDA().inferTargetForImplicitSpecialMember(
16062 ClassLoc, ClassLoc,
16075 ClassDecl->
hasAttr<TrivialABIAttr>() ||
16107 "DefineImplicitMoveConstructor - call it for implicit move ctor");
16112 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
16123 Scope.addContextNote(CurrentLocation);
16165 CallOp->getDescribedFunctionTemplate(), TemplateArgs, CurrentLocation);
16169 if (CallOp != Invoker) {
16178 if (CallOp->isInvalidDecl())
16188 if (Invoker != CallOp) {
16201 assert(FunctionRef &&
"Can't refer to __invoke function?");
16209 L->CompletedImplicitDefinition(Conv);
16210 if (Invoker != CallOp)
16211 L->CompletedImplicitDefinition(Invoker);
16239 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
16248 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
16254 Stmt *ReturnS = Return.
get();
16261 L->CompletedImplicitDefinition(Conv);
16268 switch (Args.size()) {
16273 if (!Args[1]->isDefaultArgument())
16278 return !Args[0]->isDefaultArgument();
16287 bool HadMultipleCandidates,
bool IsListInitialization,
16288 bool IsStdInitListInitialization,
bool RequiresZeroInit,
16290 bool Elidable =
false;
16309 Expr *SubExpr = ExprArgs[0];
16320 Elidable, ExprArgs, HadMultipleCandidates,
16321 IsListInitialization,
16322 IsStdInitListInitialization, RequiresZeroInit,
16323 ConstructKind, ParenRange);
16329 bool HadMultipleCandidates,
bool IsListInitialization,
16330 bool IsStdInitListInitialization,
bool RequiresZeroInit,
16332 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
16342 ConstructLoc, DeclInitType,
Constructor, Elidable, ExprArgs,
16343 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
16344 RequiresZeroInit, ConstructKind, ParenRange);
16352 bool HadMultipleCandidates,
bool IsListInitialization,
16353 bool IsStdInitListInitialization,
bool RequiresZeroInit,
16358 "given constructor for wrong type");
16366 HadMultipleCandidates, IsListInitialization,
16367 IsStdInitListInitialization, RequiresZeroInit,
16399 PDiag(diag::err_access_dtor_var)
16409 bool HasConstantInit =
false;
16416 diag::err_constexpr_var_requires_const_destruction) << VD;
16417 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
16418 Diag(Notes[I].first, Notes[I].second);
16427 if (!VD->
hasAttr<AlwaysDestroyAttr>())
16439 bool AllowExplicit,
16440 bool IsListInitialization) {
16442 unsigned NumArgs = ArgsPtr.size();
16443 Expr **Args = ArgsPtr.data();
16449 if (NumArgs < NumParams)
16450 ConvertedArgs.reserve(NumParams);
16452 ConvertedArgs.reserve(NumArgs);
16460 CallType, AllowExplicit, IsListInitialization);
16461 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
16472 bool SeenTypedOperators =
Context.hasSeenTypeAwareOperatorNewOrDelete();
16479 if (DeallocType.
isNull())
16490 constexpr unsigned RequiredParameterCount =
16493 if (NumParams != RequiredParameterCount)
16498 if (llvm::any_of(FnDecl->
parameters().drop_front(),
16500 return ParamDecl->getType()->isDependentType();
16505 if (SpecializedTypeIdentity.
isNull())
16509 ArgTypes.reserve(NumParams);
16515 ArgTypes.push_back(SpecializedTypeIdentity);
16536 diag::err_operator_new_delete_declared_in_namespace)
16543 diag::err_operator_new_delete_declared_static)
16553 Qualifiers PtrQuals = PtrTy->getPointeeType().getQualifiers();
16556 PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals)));
16563 bool *WasMalformed) {
16564 const Decl *MalformedDecl =
nullptr;
16567 nullptr, &MalformedDecl))
16570 if (!MalformedDecl)
16574 *WasMalformed =
true;
16592 SemaRef, FD,
nullptr);
16593 unsigned DestroyingDeleteIdx = IsPotentiallyTypeAware + 1;
16602 unsigned DependentParamTypeDiag,
unsigned InvalidParamTypeDiag) {
16603 auto NormalizeType = [&SemaRef](
QualType T) {
16607 if (
const auto PtrTy =
T->template getAs<PointerType>())
16614 unsigned FirstNonTypeParam = 0;
16615 bool MalformedTypeIdentity =
false;
16617 SemaRef, FnDecl, &MalformedTypeIdentity);
16618 unsigned MinimumMandatoryArgumentCount = 1;
16619 unsigned SizeParameterIndex = 0;
16620 if (IsPotentiallyTypeAware) {
16624 SemaRef.
Diag(FnDecl->
getLocation(), diag::warn_ext_type_aware_allocators);
16627 SizeParameterIndex = 1;
16628 MinimumMandatoryArgumentCount =
16631 SizeParameterIndex = 2;
16632 MinimumMandatoryArgumentCount =
16635 FirstNonTypeParam = 1;
16638 bool IsPotentiallyDestroyingDelete =
16641 if (IsPotentiallyDestroyingDelete) {
16642 ++MinimumMandatoryArgumentCount;
16643 ++SizeParameterIndex;
16646 if (NumParams < MinimumMandatoryArgumentCount)
16648 diag::err_operator_new_delete_too_few_parameters)
16649 << IsPotentiallyTypeAware << IsPotentiallyDestroyingDelete
16650 << FnDecl->
getDeclName() << MinimumMandatoryArgumentCount;
16652 for (
unsigned Idx = 0; Idx < MinimumMandatoryArgumentCount; ++Idx) {
16656 diag::err_operator_new_default_arg)
16661 QualType CanResultType = NormalizeType(FnType->getReturnType());
16662 QualType CanExpectedResultType = NormalizeType(ExpectedResultType);
16663 QualType CanExpectedSizeOrAddressParamType =
16664 NormalizeType(ExpectedSizeOrAddressParamType);
16667 if (CanResultType != CanExpectedResultType) {
16670 return SemaRef.
Diag(
16672 CanResultType->isDependentType()
16673 ? diag::err_operator_new_delete_dependent_result_type
16674 : diag::err_operator_new_delete_invalid_result_type)
16681 diag::err_operator_new_delete_template_too_few_parameters)
16685 auto FallbackType) ->
bool {
16689 << IsPotentiallyTypeAware << IsPotentiallyDestroyingDelete
16695 auto ActualParamType =
16697 if (ActualParamType == CanExpectedTy)
16699 unsigned Diagnostic = ActualParamType->isDependentType()
16700 ? DependentParamTypeDiag
16701 : InvalidParamTypeDiag;
16703 << IsPotentiallyTypeAware << IsPotentiallyDestroyingDelete
16709 if (CheckType(FirstNonTypeParam, CanExpectedSizeOrAddressParamType,
"size_t"))
16716 if (!IsPotentiallyTypeAware)
16725 if (CheckType(SizeParameterIndex + 1, StdAlignValT,
"std::align_val_t"))
16729 return MalformedTypeIdentity;
16748 SizeTy, diag::err_operator_new_dependent_param_type,
16749 diag::err_operator_new_param_type);
16761 auto *MD = dyn_cast<CXXMethodDecl>(FnDecl);
16762 auto ConstructDestroyingDeleteAddressType = [&]() {
16775 SemaRef, MD,
nullptr)) {
16779 AddressParamType == ConstructDestroyingDeleteAddressType()) {
16790 diag::err_type_aware_destroying_operator_delete)
16791 << Param->getSourceRange();
16813 diag::err_operator_delete_dependent_param_type,
16814 diag::err_operator_delete_param_type))
16823 diag::err_destroying_operator_delete_not_usual);
16833 "Expected an overloaded operator declaration");
16843 if (Op == OO_Delete || Op == OO_Array_Delete)
16846 if (Op == OO_New || Op == OO_Array_New)
16856 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
16857 if (MethodDecl->isStatic()) {
16858 if (Op == OO_Call || Op == OO_Subscript)
16861 ? diag::warn_cxx20_compat_operator_overload_static
16862 : diag::ext_operator_overload_static))
16865 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_static)
16869 bool ClassOrEnumParam =
false;
16871 QualType ParamType = Param->getType().getNonReferenceType();
16874 ClassOrEnumParam =
true;
16879 if (!ClassOrEnumParam)
16881 diag::err_operator_overload_needs_class_or_enum)
16891 if (Op != OO_Call) {
16894 if (Param->hasDefaultArg()) {
16895 FirstDefaultedParam = Param;
16899 if (FirstDefaultedParam) {
16900 if (Op == OO_Subscript) {
16902 ? diag::ext_subscript_overload
16903 : diag::error_subscript_overload)
16908 diag::err_operator_overload_default_arg)
16916 {
false,
false,
false }
16917#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
16918 , { Unary, Binary, MemberOnly }
16919#include "clang/Basic/OperatorKinds.def"
16922 bool CanBeUnaryOperator = OperatorUses[Op][0];
16923 bool CanBeBinaryOperator = OperatorUses[Op][1];
16924 bool MustBeMemberOperator = OperatorUses[Op][2];
16935 if (Op != OO_Call && Op != OO_Subscript &&
16936 ((NumParams == 1 && !CanBeUnaryOperator) ||
16937 (NumParams == 2 && !CanBeBinaryOperator) || (NumParams < 1) ||
16938 (NumParams > 2))) {
16940 unsigned ErrorKind;
16941 if (CanBeUnaryOperator && CanBeBinaryOperator) {
16943 }
else if (CanBeUnaryOperator) {
16946 assert(CanBeBinaryOperator &&
16947 "All non-call overloaded operators are unary or binary!");
16950 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
16951 << FnDecl->
getDeclName() << NumParams << ErrorKind;
16954 if (Op == OO_Subscript && NumParams != 2) {
16956 ? diag::ext_subscript_overload
16957 : diag::error_subscript_overload)
16958 << FnDecl->
getDeclName() << (NumParams == 1 ? 0 : 2);
16963 if (Op != OO_Call &&
16965 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
16972 diag::err_operator_overload_must_be_member)
16986 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
16993 diag::err_operator_overload_post_incdec_must_be_int)
16994 << LastParam->
getType() << (Op == OO_MinusMinus);
17006 if (TemplateParams->
size() == 1) {
17008 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(0));
17022 if (SemaRef.
getLangOpts().CPlusPlus20 && PmDecl &&
17025 PmDecl->
getType()->
getAs<DeducedTemplateSpecializationType>()))
17027 }
else if (TemplateParams->
size() == 2) {
17029 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
getParam(0));
17031 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(1));
17037 if (
const auto *TArgs =
17039 TArgs && TArgs->getDepth() == PmType->
getDepth() &&
17040 TArgs->getIndex() == PmType->
getIndex()) {
17043 diag::ext_string_literal_operator_template);
17050 diag::err_literal_operator_template)
17057 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
17066 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
17085 diag::err_literal_operator_template_with_params);
17095 QualType ParamType = Param->getType().getUnqualifiedType();
17113 Diag(Param->getSourceRange().getBegin(),
17114 diag::err_literal_operator_param)
17115 << ParamType <<
"'const char *'" << Param->getSourceRange();
17120 Diag(Param->getSourceRange().getBegin(), diag::err_literal_operator_param)
17121 << ParamType <<
Context.LongDoubleTy << Param->getSourceRange();
17125 Diag(Param->getSourceRange().getBegin(), diag::err_literal_operator_param)
17126 << ParamType <<
Context.UnsignedLongLongTy << Param->getSourceRange();
17130 Diag(Param->getSourceRange().getBegin(),
17131 diag::err_literal_operator_invalid_param)
17132 << ParamType << Param->getSourceRange();
17141 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
17148 Diag((*Param)->getSourceRange().getBegin(),
17149 diag::err_literal_operator_param)
17150 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
17157 Diag((*Param)->getSourceRange().getBegin(),
17158 diag::err_literal_operator_param)
17159 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
17172 Diag((*Param)->getSourceRange().getBegin(),
17173 diag::err_literal_operator_param)
17174 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
17182 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
17183 if (!
Context.hasSameType(SecondParamType,
Context.getSizeType())) {
17184 Diag((*Param)->getSourceRange().getBegin(),
17185 diag::err_literal_operator_param)
17186 << SecondParamType <<
Context.getSizeType()
17187 << (*Param)->getSourceRange();
17191 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
17200 if (Param->hasDefaultArg()) {
17201 Diag(Param->getDefaultArgRange().getBegin(),
17202 diag::err_literal_operator_default_argument)
17203 << Param->getDefaultArgRange();
17218 <<
static_cast<int>(Status)
17229 assert(Lit->
isUnevaluated() &&
"Unexpected string literal kind");
17235 else if (Lang ==
"C++")
17238 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
17258 if (
getLangOpts().CPlusPlusModules && isCurrentModulePurview()) {
17259 Module *GlobalModule = PushImplicitGlobalModuleFragment(ExternLoc);
17282 PopImplicitGlobalModuleFragment();
17285 return LinkageSpec;
17309 ExDeclType =
Context.getArrayDecayedType(ExDeclType);
17311 ExDeclType =
Context.getPointerType(ExDeclType);
17318 Diag(Loc, diag::err_catch_rvalue_ref);
17323 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
17329 unsigned DK = diag::err_catch_incomplete;
17331 BaseType = Ptr->getPointeeType();
17333 DK = diag::err_catch_incomplete_ptr;
17336 BaseType = Ref->getPointeeType();
17338 DK = diag::err_catch_incomplete_ref;
17340 if (!
Invalid && (Mode == 0 || !BaseType->isVoidType()) &&
17344 if (!
Invalid && BaseType.isWebAssemblyReferenceType()) {
17345 Diag(Loc, diag::err_wasm_reftype_tc) << 1;
17349 if (!
Invalid && Mode != 1 && BaseType->isSizelessType()) {
17350 Diag(Loc, diag::err_catch_sizeless) << (Mode == 2 ? 1 : 0) << BaseType;
17356 diag::err_abstract_type_in_decl,
17365 T = RT->getPointeeType();
17367 if (
T->isObjCObjectType()) {
17368 Diag(Loc, diag::err_objc_object_catch);
17370 }
else if (
T->isObjCObjectPointerType()) {
17373 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
17382 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(ExDecl))
17407 Expr *opaqueValue =
17457 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
17459 }
else if (PrevDecl->isTemplateParameter())
17487 Expr *AssertMessageExpr,
17493 AssertMessageExpr, RParenLoc,
false);
17498 case BuiltinType::Char_S:
17499 case BuiltinType::Char_U:
17501 case BuiltinType::Char8:
17504 case BuiltinType::Char16:
17507 case BuiltinType::Char32:
17510 case BuiltinType::WChar_S:
17511 case BuiltinType::WChar_U:
17515 llvm_unreachable(
"Non-character type");
17525 char Arr[UNI_MAX_UTF8_BYTES_PER_CODE_POINT];
17528 llvm::raw_svector_ostream OS(Str);
17532 if (K == BuiltinType::Char_S || K == BuiltinType::Char_U ||
17533 K == BuiltinType::Char8 ||
Value <= 0x7F) {
17535 if (!Escaped.empty())
17538 OS << static_cast<char>(
Value);
17543 case BuiltinType::Char16:
17544 case BuiltinType::Char32:
17545 case BuiltinType::WChar_S:
17546 case BuiltinType::WChar_U: {
17547 if (llvm::ConvertCodePointToUTF8(
Value, Ptr))
17551 << llvm::format_hex_no_prefix(
Value, TyWidth / 4,
true);
17555 llvm_unreachable(
"Non-character type is passed");
17567 switch (
V.getKind()) {
17569 if (
T->isBooleanType()) {
17573 int64_t BoolValue =
V.getInt().getExtValue();
17574 assert((BoolValue == 0 || BoolValue == 1) &&
17575 "Bool type, but value is not 0 or 1");
17576 llvm::raw_svector_ostream OS(Str);
17577 OS << (BoolValue ?
"true" :
"false");
17579 llvm::raw_svector_ostream OS(Str);
17584 switch (BTy->getKind()) {
17585 case BuiltinType::Char_S:
17586 case BuiltinType::Char_U:
17587 case BuiltinType::Char8:
17588 case BuiltinType::Char16:
17589 case BuiltinType::Char32:
17590 case BuiltinType::WChar_S:
17591 case BuiltinType::WChar_U: {
17592 unsigned TyWidth = Context.getIntWidth(
T);
17593 assert(8 <= TyWidth && TyWidth <= 32 &&
"Unexpected integer width");
17594 uint32_t CodeUnit =
static_cast<uint32_t
>(
V.getInt().getZExtValue());
17599 << llvm::format_hex_no_prefix(CodeUnit, 2,
17601 <<
", " <<
V.getInt() <<
')';
17608 V.getInt().toString(Str);
17614 V.getFloat().toString(Str);
17618 if (
V.isNullPointer()) {
17619 llvm::raw_svector_ostream OS(Str);
17626 llvm::raw_svector_ostream OS(Str);
17628 V.getComplexFloatReal().toString(Str);
17630 V.getComplexFloatImag().toString(Str);
17635 llvm::raw_svector_ostream OS(Str);
17637 V.getComplexIntReal().toString(Str);
17639 V.getComplexIntImag().toString(Str);
17666 if (
const auto *UnaryOp = dyn_cast<UnaryOperator>(E))
17670 if (
const auto *BO = dyn_cast<BinaryOperator>(E))
17671 return (BO->isShiftOp() || BO->isAdditiveOp() || BO->isMultiplicativeOp() ||
17672 BO->isBitwiseOp());
17678 if (
const auto *Op = dyn_cast<BinaryOperator>(E);
17679 Op && Op->getOpcode() != BO_LOr) {
17680 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
17681 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
17699 for (
unsigned I = 0; I < 2; I++) {
17700 const Expr *Side = DiagSide[I].Cond;
17704 DiagSide[I].Print =
17706 DiagSide[I].ValueString,
Context);
17708 if (DiagSide[0].Print && DiagSide[1].Print) {
17709 Diag(Op->getExprLoc(), diag::note_expr_evaluates_to)
17710 << DiagSide[0].ValueString << Op->getOpcodeStr()
17711 << DiagSide[1].ValueString << Op->getSourceRange();
17718template <
typename ResultType>
17722 bool ErrorOnInvalidMessage) {
17725 assert(!Message->isTypeDependent() && !Message->isValueDependent() &&
17726 "can't evaluate a dependant static assert message");
17728 if (
const auto *SL = dyn_cast<StringLiteral>(Message)) {
17729 assert(SL->isUnevaluated() &&
"expected an unevaluated string");
17730 if constexpr (std::is_same_v<APValue, ResultType>) {
17735 assert(CAT &&
"string literal isn't an array");
17739 for (
unsigned I = 0; I < SL->getLength(); I++) {
17740 Value = SL->getCodeUnit(I);
17744 Result.assign(SL->getString().begin(), SL->getString().end());
17750 QualType T = Message->getType().getNonReferenceType();
17751 auto *RD =
T->getAsCXXRecordDecl();
17753 SemaRef.
Diag(Loc, diag::err_user_defined_msg_invalid) << EvalContext;
17757 auto FindMember = [&](StringRef
Member) -> std::optional<LookupResult> {
17763 if (MemberLookup.
empty())
17764 return std::nullopt;
17765 return std::move(MemberLookup);
17768 std::optional<LookupResult> SizeMember = FindMember(
"size");
17769 std::optional<LookupResult> DataMember = FindMember(
"data");
17770 if (!SizeMember || !DataMember) {
17771 SemaRef.
Diag(Loc, diag::err_user_defined_msg_missing_member_function)
17773 << ((!SizeMember && !DataMember) ? 2
17781 Message, Message->getType(), Message->getBeginLoc(),
false,
17807 SemaRef.
Diag(Loc, diag::err_user_defined_msg_invalid_mem_fn_ret_ty)
17808 << EvalContext << 0;
17818 SemaRef.
Diag(Loc, diag::err_user_defined_msg_invalid_mem_fn_ret_ty)
17819 << EvalContext << 1;
17823 if (!ErrorOnInvalidMessage &&
17824 SemaRef.
Diags.
isIgnored(diag::warn_user_defined_msg_constexpr, Loc))
17829 Status.Diag = &Notes;
17830 if (!Message->EvaluateCharRangeAsString(Result, EvaluatedSize.
get(),
17831 EvaluatedData.
get(), Ctx, Status) ||
17833 SemaRef.
Diag(Message->getBeginLoc(),
17834 ErrorOnInvalidMessage ? diag::err_user_defined_msg_constexpr
17835 : diag::warn_user_defined_msg_constexpr)
17837 for (
const auto &
Note : Notes)
17839 return !ErrorOnInvalidMessage;
17846 bool ErrorOnInvalidMessage) {
17848 ErrorOnInvalidMessage);
17853 bool ErrorOnInvalidMessage) {
17855 ErrorOnInvalidMessage);
17859 Expr *AssertExpr,
Expr *AssertMessage,
17862 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
17880 AssertExpr = FullAssertExpr.
get();
17883 Expr *BaseExpr = AssertExpr;
17895 diag::err_static_assert_expression_is_not_constant,
17901 if (!Failed && AssertMessage &&
Cond.getBoolValue()) {
17911 bool InTemplateDefinition =
17914 if (!Failed && !
Cond && !InTemplateDefinition) {
17916 llvm::raw_svector_ostream Msg(MsgBuffer);
17917 bool HasMessage = AssertMessage;
17918 if (AssertMessage) {
17926 Expr *InnerCond =
nullptr;
17927 std::string InnerCondDescription;
17928 std::tie(InnerCond, InnerCondDescription) =
17930 if (
const auto *ConceptIDExpr =
17931 dyn_cast_or_null<ConceptSpecializationExpr>(InnerCond)) {
17933 ConceptIDExpr->getSatisfaction();
17944 diag::err_static_assert_requirement_failed)
17945 << InnerCondDescription << !HasMessage << Msg.str()
17962 AssertExpr = FullAssertExpr.
get();
17966 AssertExpr, AssertMessage, RParenLoc,
17980 bool IsMemberSpecialization =
false;
17985 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
17986 IsMemberSpecialization,
Invalid)) {
17987 if (TemplateParams->size() > 0) {
17995 FriendLoc, TempParamLists.size() - 1,
17996 TempParamLists.data())
18000 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
18002 IsMemberSpecialization =
true;
18008 bool isAllExplicitSpecializations =
true;
18009 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
18010 if (TempParamLists[I]->size()) {
18011 isAllExplicitSpecializations =
false;
18022 if (isAllExplicitSpecializations) {
18024 bool Owned =
false;
18025 bool IsDependent =
false;
18042 NameLoc, &TSI,
true);
18048 EllipsisLoc, TempParamLists);
18054 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
18061 unsigned FriendDeclDepth = TempParamLists.front()->getDepth();
18064 DI && DI->first >= FriendDeclDepth) {
18065 auto *ND = dyn_cast<NamedDecl *>(
U.first);
18068 Diag(
U.second, diag::friend_template_decl_malformed_pack_expansion)
18077 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
18089 EllipsisLoc, TempParamLists);
18091 Friend->setUnsupportedFriend(
true);
18115 Diag(FriendLoc, diag::err_friend_not_first_in_declaration);
18147 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
18152 if (!
T->isElaboratedTypeSpecifier()) {
18153 if (TempParams.size()) {
18165 }
else if (
const RecordDecl *RD =
T->getAsRecordDecl()) {
18170 ? diag::warn_cxx98_compat_unelaborated_friend_type
18171 : diag::ext_unelaborated_friend_type)
18176 DiagCompat(FriendLoc, diag_compat::nonclass_type_friend)
18193 if (!TempParams.empty())
18199 TSI, FriendLoc, EllipsisLoc);
18234 Diag(Loc, diag::err_unexpected_friend);
18269 Scope *DCScope = S;
18281 (FunctionContainingLocalClass =
18304 DC =
Previous.getRepresentativeDecl()->getDeclContext();
18308 DC = FunctionContainingLocalClass;
18345 if (isTemplateId) {
18360 if (!DC)
return nullptr;
18371 diag::warn_cxx98_compat_friend_is_member :
18372 diag::err_friend_is_member);
18408 if (DiagArg >= 0) {
18409 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
18420 DCScope = &FakeDCScope;
18423 bool AddToScope =
true;
18425 TemplateParams, AddToScope);
18426 if (!ND)
return nullptr;
18460 FD = FTD->getTemplatedDecl();
18482 }
else if (FunctionContainingLocalClass) {
18491 }
else if (isTemplateId) {
18505 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
18507 diag::note_previous_declaration);
18509 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
18514 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
18530 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
18532 Diag(DelLoc, diag::err_deleted_non_function);
18537 Fn->setWillHaveBody(
false);
18539 if (
const FunctionDecl *Prev = Fn->getPreviousDecl()) {
18543 Prev->getPreviousDecl()) &&
18544 !Prev->isDefined()) {
18545 Diag(DelLoc, diag::err_deleted_decl_not_first);
18546 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
18547 Prev->isImplicit() ? diag::note_previous_implicit_declaration
18548 : diag::note_previous_declaration);
18551 Fn->setInvalidDecl();
18559 Fn = Fn->getCanonicalDecl();
18564 Diag(Fn->getLocation(), diag::err_attribute_dll_deleted) << DLLAttr;
18565 Fn->setInvalidDecl();
18571 Diag(DelLoc, diag::err_deleted_main);
18575 Fn->setImplicitlyInline();
18576 Fn->setDeletedAsWritten(
true, Message);
18583 auto *FD = dyn_cast<FunctionDecl>(Dcl);
18585 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(Dcl)) {
18587 Diag(DefaultLoc, diag::err_defaulted_comparison_template);
18592 Diag(DefaultLoc, diag::err_default_special_members)
18603 (!FD->isDependentContext() ||
18606 Diag(DefaultLoc, diag::err_default_special_members)
18616 ? diag::warn_cxx17_compat_defaulted_comparison
18617 : diag::ext_defaulted_comparison);
18620 FD->setDefaulted();
18621 FD->setExplicitlyDefaulted();
18622 FD->setDefaultLoc(DefaultLoc);
18625 if (FD->isDependentContext())
18631 FD->setWillHaveBody(
false);
18646 if (
const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern())
18675 Self.Diag(SubStmt->getBeginLoc(),
18676 diag::err_return_in_constructor_handler);
18683 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
18691 switch (BodyKind) {
18700 "Parsed function body should be '= delete;' or '= default;'");
18710 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
18714 !NewFT->getExtParameterInfo(I).isNoEscape()) {
18715 Diag(
New->getParamDecl(I)->getLocation(),
18716 diag::warn_overriding_method_missing_noescape);
18718 diag::note_overridden_marked_noescape);
18724 Diag(
New->getLocation(), diag::err_conflicting_overriding_attributes)
18731 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
18732 const auto *NewCSA =
New->getAttr<CodeSegAttr>();
18733 if ((NewCSA || OldCSA) &&
18734 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
18735 Diag(
New->getLocation(), diag::err_mismatched_code_seg_override);
18741 if (
Context.hasAnyFunctionEffects()) {
18743 const auto NewFXOrig =
New->getFunctionEffects();
18745 if (OldFX != NewFXOrig) {
18749 for (
const auto &Diff : Diffs) {
18750 switch (Diff.shouldDiagnoseMethodOverride(*Old, OldFX, *
New, NewFX)) {
18754 Diag(
New->getLocation(), diag::warn_conflicting_func_effect_override)
18755 << Diff.effectName();
18760 NewFX.
insert(Diff.Old.value(), Errs);
18765 NewFT->getParamTypes(), EPI);
18766 New->setType(ModQT);
18767 if (Errs.empty()) {
18770 Diag(
New->getLocation(), diag::warn_mismatched_func_effect_override)
18771 << Diff.effectName();
18788 if (NewCC == OldCC)
18799 diag::err_conflicting_overriding_cc_attributes)
18809 if (!
New->isExplicitObjectMemberFunction())
18811 Diag(
New->getParamDecl(0)->getBeginLoc(),
18812 diag::err_explicit_object_parameter_nonmember)
18813 <<
New->getSourceRange() << 1 <<
false;
18815 New->setInvalidDecl();
18824 if (
Context.hasSameType(NewTy, OldTy) ||
18839 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
18849 diag::err_different_return_type_for_overriding_virtual_function)
18850 <<
New->getDeclName() << NewTy << OldTy
18851 <<
New->getReturnTypeSourceRange();
18858 if (!
Context.hasSameUnqualifiedType(NewClassTy, OldClassTy)) {
18867 diag::err_covariant_return_incomplete,
18868 New->getDeclName()))
18874 Diag(
New->getLocation(), diag::err_covariant_return_not_derived)
18875 <<
New->getDeclName() << NewTy << OldTy
18876 <<
New->getReturnTypeSourceRange();
18884 NewClassTy, OldClassTy,
18885 diag::err_covariant_return_inaccessible_base,
18886 diag::err_covariant_return_ambiguous_derived_to_base_conv,
18887 New->getLocation(),
New->getReturnTypeSourceRange(),
18888 New->getDeclName(),
nullptr)) {
18902 diag::err_covariant_return_type_different_qualifications)
18903 <<
New->getDeclName() << NewTy << OldTy
18904 <<
New->getReturnTypeSourceRange();
18914 diag::err_covariant_return_type_class_type_not_same_or_less_qualified)
18915 <<
New->getDeclName() << NewTy << OldTy
18916 <<
New->getReturnTypeSourceRange();
18928 Method->setRangeEnd(EndLoc);
18930 if (
Method->isVirtual() ||
Method->getParent()->isDependentContext()) {
18931 Method->setIsPureVirtual();
18935 if (!
Method->isInvalidDecl())
18936 Diag(
Method->getLocation(), diag::err_non_virtual_pure)
18937 <<
Method->getDeclName() << InitRange;
18944 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
18987 "Parser allowed 'typedef' as storage class of condition decl.");
18999 if (
auto *VD = dyn_cast<VarDecl>(Dcl))
19012 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
19013 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
19017 if (!Pos->second && VTables[I].DefinitionRequired)
19018 Pos->second =
true;
19022 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
19023 NewUses.push_back(
VTableUse(VTables[I].
Record, VTables[I].Location));
19030 bool DefinitionRequired) {
19033 if (!
Class->isDynamicClass() ||
Class->isDependentContext() ||
19039 !
OpenMP().isInOpenMPDeclareTargetContext() &&
19040 !
OpenMP().isInOpenMPTargetExecutionDirective()) {
19041 if (!DefinitionRequired)
19049 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
19055 if (DefinitionRequired && !Pos.first->second) {
19056 Pos.first->second =
true;
19066 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
19085 if (
Class->isLocalClass())
19100 bool DefinedAnything =
false;
19101 for (
unsigned I = 0; I !=
VTableUses.size(); ++I) {
19106 Class->getTemplateSpecializationKind();
19110 bool DefineVTable =
true;
19115 if (
Class->isInCurrentModuleUnit()) {
19116 DefineVTable =
true;
19117 }
else if (KeyFunction && !KeyFunction->
hasBody()) {
19122 DefineVTable =
false;
19127 "Instantiations don't have key functions");
19129 }
else if (!KeyFunction) {
19134 bool IsExplicitInstantiationDeclaration =
19136 for (
auto *R :
Class->redecls()) {
19140 IsExplicitInstantiationDeclaration =
true;
19142 IsExplicitInstantiationDeclaration =
false;
19147 if (IsExplicitInstantiationDeclaration)
19148 DefineVTable =
false;
19154 if (!DefineVTable) {
19162 DefinedAnything =
true;
19171 if (
Context.getTargetInfo().getCXXABI().hasKeyFunctions() &&
19175 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
19182 return DefinedAnything;
19187 for (
const auto *I : RD->
methods())
19188 if (I->isVirtual() && !I->isPureVirtual())
19194 bool ConstexprOnly) {
19198 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
19199 E = FinalOverriders.end();
19202 OE = I->second.end();
19204 assert(OI->second.size() > 0 &&
"no final overrider");
19219 for (
const auto &I : RD->
bases()) {
19220 const auto *
Base = I.getType()->castAsCXXRecordDecl();
19221 if (
Base->getNumVBases() == 0)
19242 (void)
Target->hasBody(FNTarget);
19244 cast_or_null<CXXConstructorDecl>(FNTarget));
19249 *TCanonical =
Target?
Target->getCanonicalDecl() :
nullptr;
19251 if (!Current.insert(Canonical).second)
19256 Target->isInvalidDecl() ||
Valid.count(TCanonical)) {
19257 Valid.insert_range(Current);
19260 }
else if (TCanonical == Canonical ||
Invalid.count(TCanonical) ||
19261 Current.count(TCanonical)) {
19263 if (!
Invalid.count(TCanonical)) {
19265 diag::warn_delegating_ctor_cycle)
19269 if (TCanonical != Canonical)
19270 S.
Diag(
Target->getLocation(), diag::note_it_delegates_to);
19273 while (
C->getCanonicalDecl() != Canonical) {
19275 (void)
C->getTargetConstructor()->hasBody(FNTarget);
19276 assert(FNTarget &&
"Ctor cycle through bodiless function");
19280 S.
Diag(
C->getLocation(), diag::note_which_delegates_to);
19284 Invalid.insert_range(Current);
19295 for (DelegatingCtorDeclsType::iterator
19301 for (
auto CI =
Invalid.begin(), CE =
Invalid.end(); CI != CE; ++CI)
19302 (*CI)->setInvalidDecl();
19311 explicit FindCXXThisExpr(
Sema &S) : S(S) {}
19339 FindCXXThisExpr Finder(*
this);
19352 if (!Finder.TraverseStmt(
const_cast<Expr *
>(TRC.ConstraintExpr)))
19369 FindCXXThisExpr Finder(*
this);
19391 if (!Finder.TraverseType(E))
19401 FindCXXThisExpr Finder(*
this);
19404 for (
const auto *A :
Method->attrs()) {
19406 Expr *Arg =
nullptr;
19408 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
19410 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
19412 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
19414 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
19416 else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
19417 Arg = LR->getArg();
19418 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
19420 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
19422 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
19424 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A)) {
19425 Arg = AC->getSuccessValue();
19427 }
else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
19430 if (Arg && !Finder.TraverseStmt(Arg))
19433 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
19434 if (!Finder.TraverseStmt(Args[I]))
19448 Exceptions.clear();
19451 Exceptions.reserve(DynamicExceptions.size());
19452 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
19459 if (!Unexpanded.empty()) {
19470 Exceptions.push_back(ET);
19480 "Parser should have made sure that the expression is boolean");
19500 D = FTD->getTemplatedDecl();
19510 DynamicExceptionRanges, NoexceptExpr, Exceptions,
19514 Context.adjustExceptionSpec(FD, ESI,
true);
19538 Diag(DeclStart, diag::err_anonymous_property);
19552 TInfo =
Context.getTrivialTypeSourceInfo(
T, Loc);
19563 diag::err_invalid_thread)
19571 switch (
Previous.getResultKind()) {
19578 PrevDecl =
Previous.getRepresentativeDecl();
19591 PrevDecl =
nullptr;
19595 PrevDecl =
nullptr;
19606 Record->setInvalidDecl();
19628 if (!ExplicitLists.empty()) {
19629 bool IsMemberSpecialization, IsInvalid;
19633 ExplicitLists,
false, IsMemberSpecialization, IsInvalid,
19645 if (ExplicitParams && !ExplicitParams->
empty()) {
19646 Info.AutoTemplateParameterDepth = ExplicitParams->
getDepth();
19647 llvm::append_range(Info.TemplateParams, *ExplicitParams);
19648 Info.NumExplicitTemplateParams = ExplicitParams->
size();
19650 Info.AutoTemplateParameterDepth = TemplateParameterDepth;
19651 Info.NumExplicitTemplateParams = 0;
19657 if (FSI.TemplateParams.size() > FSI.NumExplicitTemplateParams) {
19658 if (FSI.NumExplicitTemplateParams != 0) {
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
static bool CheckLiteralType(EvalInfo &Info, const Expr *E, const LValue *This=nullptr)
Check that this core constant expression is of literal type, and if not, produce an appropriate diagn...
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.
llvm::MachO::Target Target
llvm::MachO::Record Record
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
@ ForExternalRedeclaration
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
static void ProcessAPINotes(Sema &S, Decl *D, const api_notes::CommonEntityInfo &Info, VersionedInfoMetadata Metadata)
This file declares semantic analysis for CUDA constructs.
static void DiagnoseUnsatisfiedConstraint(Sema &S, ArrayRef< UnsatisfiedConstraintRecord > Records, SourceLocation Loc, bool First=true, concepts::NestedRequirement *Req=nullptr)
static LookupResult lookupMember(Sema &S, const char *Name, CXXRecordDecl *RD, SourceLocation Loc, bool &Res)
static bool findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, CXXSpecialMemberKind CSM, unsigned Quals, bool ConstRHS, TrivialABIHandling TAH, CXXMethodDecl **Selected)
Perform lookup for a special member of the specified kind, and determine whether it is trivial.
static void checkMoveAssignmentForRepeatedMove(Sema &S, CXXRecordDecl *Class, SourceLocation CurrentLocation)
Check if we're implicitly defining a move assignment operator for a class with virtual bases.
static void checkMethodTypeQualifiers(Sema &S, Declarator &D, unsigned DiagID)
static void DelegatingCycleHelper(CXXConstructorDecl *Ctor, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Valid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Invalid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Current, Sema &S)
static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *Body, Sema::CheckConstexprKind Kind)
Check the body for the given constexpr function declaration only contains the permitted types of stat...
llvm::SmallPtrSet< QualType, 4 > IndirectBaseSet
Use small set to collect indirect bases.
static void checkCUDADeviceBuiltinSurfaceClassTemplate(Sema &S, CXXRecordDecl *Class)
static bool checkVectorDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const VectorType *VT)
static void SearchForReturnInStmt(Sema &Self, Stmt *S)
static bool checkSimpleDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElemsAPS, QualType ElemType, llvm::function_ref< ExprResult(SourceLocation, Expr *, unsigned)> GetInit)
static CXXDestructorDecl * LookupDestructorIfRelevant(Sema &S, CXXRecordDecl *Class)
static void extendRight(SourceRange &R, SourceRange After)
static void DiagnoseNamespaceInlineMismatch(Sema &S, SourceLocation KeywordLoc, SourceLocation Loc, IdentifierInfo *II, bool *IsInline, NamespaceDecl *PrevNS)
Diagnose a mismatch in 'inline' qualifiers when a namespace is reopened.
static bool IsPotentiallyTypeAwareOperatorNewOrDelete(Sema &SemaRef, const FunctionDecl *FD, bool *WasMalformed)
static bool RefersToRValueRef(Expr *MemRef)
static bool CheckConstexprCtorInitializer(Sema &SemaRef, const FunctionDecl *Dcl, FieldDecl *Field, llvm::SmallPtrSet< Decl *, 16 > &Inits, bool &Diagnosed, Sema::CheckConstexprKind Kind)
Check that the given field is initialized within a constexpr constructor.
static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy)
static bool isVirtualDirectBase(CXXRecordDecl *Derived, CXXRecordDecl *Base)
Determine whether a direct base class is a virtual base class.
#define CheckPolymorphic(Type)
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
static void WriteCharValueForDiagnostic(uint32_t Value, const BuiltinType *BTy, unsigned TyWidth, SmallVectorImpl< char > &Str)
Convert character's value, interpreted as a code unit, to a string.
static void CheckAbstractClassUsage(AbstractUsageInfo &Info, FunctionDecl *FD)
Check for invalid uses of an abstract type in a function declaration.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for record diagnostic message.
static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, unsigned &OutSize)
static Expr * CastForMoving(Sema &SemaRef, Expr *E)
static bool IsPotentiallyDestroyingOperatorDelete(Sema &SemaRef, const FunctionDecl *FD)
static void extendLeft(SourceRange &R, SourceRange Before)
static bool specialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, CXXSpecialMemberKind CSM, unsigned Quals, bool ConstRHS, CXXConstructorDecl *InheritedCtor=nullptr, Sema::InheritedConstructorInfo *Inherited=nullptr)
Is the special member function which would be selected to perform the specified operation on the spec...
static void diagnoseInvalidDeclaratorChunks(Sema &S, Declarator &D, unsigned Kind)
static bool canPassInRegisters(Sema &S, CXXRecordDecl *D, TargetInfo::CallingConvKind CCK)
Determine whether a type is permitted to be passed or returned in registers, per C++ [class....
static void lookupOperatorsForDefaultedComparison(Sema &Self, Scope *S, UnresolvedSetImpl &Operators, OverloadedOperatorKind Op)
Perform the unqualified lookups that might be needed to form a defaulted comparison function for the ...
static void WriteCharTypePrefix(BuiltinType::Kind BTK, llvm::raw_ostream &OS)
static bool EvaluateAsStringImpl(Sema &SemaRef, Expr *Message, ResultType &Result, ASTContext &Ctx, Sema::StringEvaluationContext EvalContext, bool ErrorOnInvalidMessage)
static void diagnoseDeprecatedCopyOperation(Sema &S, CXXMethodDecl *CopyOp)
Diagnose an implicit copy operation for a class which is odr-used, but which is deprecated because th...
static void AddMostOverridenMethods(const CXXMethodDecl *MD, llvm::SmallPtrSetImpl< const CXXMethodDecl * > &Methods)
Add the most overridden methods from MD to Methods.
static DeclAccessPair findDecomposableBaseClass(Sema &S, SourceLocation Loc, const CXXRecordDecl *RD, CXXCastPath &BasePath)
Find the base class to decompose in a built-in decomposition of a class type.
static const void * GetKeyForBase(ASTContext &Context, QualType BaseType)
static QualType BuildStdClassTemplate(Sema &S, ClassTemplateDecl *CTD, QualType TypeParam, SourceLocation Loc)
static NamespaceDecl * getNamespaceDecl(NamespaceBaseDecl *D)
getNamespaceDecl - Returns the namespace a decl represents.
static Sema::ImplicitExceptionSpecification ComputeDefaultedComparisonExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD, Sema::DefaultedComparisonKind DCK)
static bool isDestroyingDeleteT(QualType Type)
static StmtResult buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying, unsigned Depth=0)
Builds a statement that copies/moves the given entity from From to To.
static void checkCUDADeviceBuiltinTextureClassTemplate(Sema &S, CXXRecordDecl *Class)
static void AddInitializerToDiag(const Sema::SemaDiagnosticBuilder &Diag, const CXXCtorInitializer *Previous, const CXXCtorInitializer *Current)
static bool BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, CXXBaseSpecifier *BaseSpec, bool IsInheritedVirtualBase, CXXCtorInitializer *&CXXBaseInit)
static bool IsUnusedPrivateField(const FieldDecl *FD)
static void NoteIndirectBases(ASTContext &Context, IndirectBaseSet &Set, const QualType &Type)
Recursively add the bases of Type. Don't add Type itself.
static bool CheckConstexprMissingReturn(Sema &SemaRef, const FunctionDecl *Dcl)
static bool CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S, SmallVectorImpl< SourceLocation > &ReturnStmts, SourceLocation &Cxx1yLoc, SourceLocation &Cxx2aLoc, SourceLocation &Cxx2bLoc, Sema::CheckConstexprKind Kind)
Check the provided statement is allowed in a constexpr function definition.
static bool functionDeclHasDefaultArgument(const FunctionDecl *FD)
static bool CheckConstexprParameterTypes(Sema &SemaRef, const FunctionDecl *FD, Sema::CheckConstexprKind Kind)
Check whether a function's parameter types are all literal types.
static bool IsUsingDirectiveInToplevelContext(DeclContext *CurContext)
Determine whether a using statement is in a context where it will be apply in all contexts.
static bool checkTupleLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, VarDecl *Src, QualType DecompType, unsigned NumElems)
static CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
static bool checkMemberDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const CXXRecordDecl *OrigRD)
static bool HasAttribute(const QualType &T)
static bool CheckOperatorNewDeclaration(Sema &SemaRef, FunctionDecl *FnDecl)
static void checkForMultipleExportedDefaultConstructors(Sema &S, CXXRecordDecl *Class)
static bool CheckOperatorNewDeleteTypes(Sema &SemaRef, FunctionDecl *FnDecl, AllocationOperatorKind OperatorKind, CanQualType ExpectedResultType, CanQualType ExpectedSizeOrAddressParamType, unsigned DependentParamTypeDiag, unsigned InvalidParamTypeDiag)
static bool checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD, CXXSpecialMemberKind CSM, bool ConstArg, TrivialABIHandling TAH, bool Diagnose)
Check whether the members of a class type allow a special member to be trivial.
static TemplateArgumentLoc getTrivialTypeTemplateArgument(Sema &S, SourceLocation Loc, QualType T)
static void findImplicitlyDeclaredEqualityComparisons(ASTContext &Ctx, CXXRecordDecl *RD, llvm::SmallVectorImpl< FunctionDecl * > &Spaceships)
Find the equality comparison functions that should be implicitly declared in a given class definition...
static void PopulateKeysForFields(FieldDecl *Field, SmallVectorImpl< const void * > &IdealInits)
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
static bool ConvertAPValueToString(const APValue &V, QualType T, SmallVectorImpl< char > &Str, ASTContext &Context)
Convert \V to a string we can present to the user in a diagnostic \T is the type of the expression th...
static bool checkArrayDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const ConstantArrayType *CAT)
static ClassTemplateDecl * LookupStdClassTemplate(Sema &S, SourceLocation Loc, const char *ClassName, bool *WasMalformed)
static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class)
static bool UsefulToPrintExpr(const Expr *E)
Some Expression types are not useful to print notes about, e.g.
static bool FindBaseInitializer(Sema &SemaRef, CXXRecordDecl *ClassDecl, QualType BaseType, const CXXBaseSpecifier *&DirectBaseSpec, const CXXBaseSpecifier *&VirtualBaseSpec)
Find the direct and/or virtual base specifiers that correspond to the given base type,...
static bool checkLiteralOperatorTemplateParameterList(Sema &SemaRef, FunctionTemplateDecl *TpDecl)
static bool ReportOverrides(Sema &S, unsigned DiagID, const CXXMethodDecl *MD, llvm::function_ref< bool(const CXXMethodDecl *)> Report)
Report an error regarding overriding, along with any relevant overridden methods.
static bool CheckBindingsCount(Sema &S, DecompositionDecl *DD, QualType DecompType, ArrayRef< BindingDecl * > Bindings, unsigned MemberCount)
static bool CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl)
static const void * GetKeyForMember(ASTContext &Context, CXXCtorInitializer *Member)
static std::string printTemplateArgs(const PrintingPolicy &PrintingPolicy, TemplateArgumentListInfo &Args, const TemplateParameterList *Params)
static bool CheckConstexprReturnType(Sema &SemaRef, const FunctionDecl *FD, Sema::CheckConstexprKind Kind)
Check whether a function's return type is a literal type.
static void DiagnoseBaseOrMemInitializerOrder(Sema &SemaRef, const CXXConstructorDecl *Constructor, ArrayRef< CXXCtorInitializer * > Inits)
static Sema::ImplicitExceptionSpecification computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD)
static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T)
Determine whether the given type is an incomplete or zero-lenfgth array type.
static void MarkFieldDestructorReferenced(Sema &S, SourceLocation Location, FieldDecl *Field)
TrivialSubobjectKind
The kind of subobject we are checking for triviality.
@ TSK_CompleteObject
The object is actually the complete object.
@ TSK_Field
The subobject is a non-static data member.
@ TSK_BaseClass
The subobject is a base class.
static bool hasOneRealArgument(MultiExprArg Args)
Determine whether the given list arguments contains exactly one "real" (non-default) argument.
static StmtResult buildMemcpyForAssignmentOp(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &ToB, const ExprBuilder &FromB)
When generating a defaulted copy or move assignment operator, if a field should be copied with __buil...
static bool isStdClassTemplate(Sema &S, QualType SugaredType, QualType *TypeArg, const char *ClassName, ClassTemplateDecl **CachedDecl, const Decl **MalformedDecl)
static void DefineDefaultedFunction(Sema &S, FunctionDecl *FD, SourceLocation DefaultLoc)
static bool BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, FieldDecl *Field, IndirectFieldDecl *Indirect, CXXCtorInitializer *&CXXMemberInit)
static void MarkBaseDestructorsReferenced(Sema &S, SourceLocation Location, CXXRecordDecl *ClassDecl)
static bool CheckMemberDecompositionFields(Sema &S, SourceLocation Loc, const CXXRecordDecl *OrigRD, QualType DecompType, DeclAccessPair BasePair)
static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info, FieldDecl *Field, IndirectFieldDecl *Indirect=nullptr)
static CXXBaseSpecifier * findDirectBaseWithType(CXXRecordDecl *Derived, QualType DesiredBase, bool &AnyDependentBases)
Find the base specifier for a base class with the given type.
static Sema::SpecialMemberOverloadResult lookupCallFromSpecialMember(Sema &S, CXXRecordDecl *Class, CXXSpecialMemberKind CSM, unsigned FieldQuals, bool ConstRHS)
Look up the special member function that would be called by a special member function for a subobject...
static bool defaultedSpecialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, CXXSpecialMemberKind CSM, bool ConstArg, CXXConstructorDecl *InheritedCtor=nullptr, Sema::InheritedConstructorInfo *Inherited=nullptr)
Determine whether the specified special member function would be constexpr if it were implicitly defi...
static bool checkTrivialSubobjectCall(Sema &S, SourceLocation SubobjLoc, QualType SubType, bool ConstRHS, CXXSpecialMemberKind CSM, TrivialSubobjectKind Kind, TrivialABIHandling TAH, bool Diagnose)
Check whether the special member selected for a given type would be trivial.
static void DiagnoseInvisibleNamespace(const TypoCorrection &Corrected, Sema &S)
static StmtResult buildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying)
static FunctionProtoType::ExtProtoInfo getImplicitMethodEPI(Sema &S, CXXMethodDecl *MD)
static QualType getTupleLikeElementType(Sema &S, SourceLocation Loc, unsigned I, QualType T)
static Sema::ImplicitExceptionSpecification ComputeDefaultedSpecialMemberExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD, CXXSpecialMemberKind CSM, Sema::InheritedConstructorInfo *ICI)
static QualType getStdTrait(Sema &S, SourceLocation Loc, StringRef Trait, TemplateArgumentListInfo &Args, unsigned DiagID)
static bool checkComplexDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const ComplexType *CT)
static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
static bool InitializationHasSideEffects(const FieldDecl &FD)
static bool CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef, const FunctionDecl *FnDecl)
static bool checkArrayLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType)
static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, DeclStmt *DS, SourceLocation &Cxx1yLoc, Sema::CheckConstexprKind Kind)
Check the given declaration statement is legal within a constexpr function body.
static bool IsEquivalentForUsingDecl(ASTContext &Context, NamedDecl *D1, NamedDecl *D2)
Determine whether a using declaration considers the given declarations as "equivalent",...
static TemplateArgumentLoc getTrivialIntegralTemplateArgument(Sema &S, SourceLocation Loc, QualType T, uint64_t I)
static bool CheckConstexprDestructorSubobjects(Sema &SemaRef, const CXXDestructorDecl *DD, Sema::CheckConstexprKind Kind)
Determine whether a destructor cannot be constexpr due to.
static bool isProvablyNotDerivedFrom(Sema &SemaRef, CXXRecordDecl *Record, const BaseSet &Bases)
Determines if the given class is provably not derived from all of the prospective base classes.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, NamedDecl *Dest)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, ArrayRef< TemplateArgument > Ps, ArrayRef< TemplateArgument > As, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, bool NumberOfArgumentsMustMatch, bool PartialOrdering, PackFold PackFold, bool *HasDeducedAnyParam)
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter,...
static bool isInvalid(LocType Loc, bool *Invalid)
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TypeLoc interface and its subclasses.
Allows QualTypes to be sorted and hence used in maps and sets.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
std::pair< CXXConstructorDecl *, bool > findConstructorForBase(CXXRecordDecl *Base, CXXConstructorDecl *Ctor) const
Find the constructor to use for inherited construction of a base class, and whether that base class c...
InheritedConstructorInfo(Sema &S, SourceLocation UseLoc, ConstructorUsingShadowDecl *Shadow)
a trap message and trap category.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
DeclarationNameTable DeclarationNames
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const LangOptions & getLangOpts() const
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const clang::PrintingPolicy & getPrintingPolicy() const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const
Make an APSInt of the appropriate width and signedness for the given Value and integer Type.
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
const TargetInfo & getTargetInfo() const
CanQualType getCanonicalTagType(const TagDecl *TD) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Represents an access specifier followed by colon ':'.
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
TypeLoc getElementLoc() const
QualType getElementType() const
Attr - This represents one attribute.
attr::Kind getKind() const
Attr * clone(ASTContext &C) const
SourceLocation getLocation() const
Represents a C++ declaration that introduces decls from somewhere else.
unsigned shadow_size() const
Return the number of shadowed declarations associated with this using declaration.
void addShadowDecl(UsingShadowDecl *S)
shadow_iterator shadow_begin() const
void removeShadowDecl(UsingShadowDecl *S)
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
static bool isCompoundAssignmentOp(Opcode Opc)
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
A binding in a decomposition declaration.
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T)
void setBinding(QualType DeclaredType, Expr *Binding)
Set the binding for this BindingDecl, along with its declared type (which should be a possibly-cv-qua...
void setDecomposedDecl(ValueDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Wrapper for source info for block pointers.
This class is used for builtin types like 'int'.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
DeclContext::lookup_iterator Decls
The declarations found inside this base class subobject.
AccessSpecifier Access
The access along this inheritance path.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
const CXXRecordDecl * getOrigin() const
Retrieve the type from which this base-paths search began.
bool isRecordingPaths() const
Whether we are recording paths.
void setRecordingPaths(bool RP)
Specify whether we should be recording paths or not.
void setOrigin(const CXXRecordDecl *Rec)
void clear()
Clear the base-paths results.
std::list< CXXBasePath >::iterator paths_iterator
bool isAmbiguous(CanQualType BaseType) const
Determine whether the path from the most-derived type to the given base type is ambiguous (i....
Represents a base class of a C++ class.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
QualType getType() const
Retrieves the type of the base class.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
A boolean literal, per ([C++ lex.bool] Boolean literals).
CXXCatchStmt - This represents a C++ catch block.
Represents a call to a C++ constructor.
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isImmediateEscalating() const
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
ExplicitSpecifier getExplicitSpecifier()
init_iterator init_begin()
Retrieve an iterator to the first initializer.
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), const AssociatedConstraint &TrailingRequiresClause={})
Represents a C++ conversion function within a class.
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Represents a C++ base or member initializer.
bool isWritten() const
Determine whether this initializer is explicitly written in the source code.
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
bool isAnyMemberInitializer() const
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
FieldDecl * getAnyMember() const
Represents a C++ destructor within a class.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, const AssociatedConstraint &TrailingRequiresClause={})
A mapping from each virtual member function to its set of final overriders.
Represents a call to an inherited base class constructor from an inheriting constructor.
Represents a call to a member function that may be written either with member call syntax (e....
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Represents a static or instance method of a struct/union/class.
bool isExplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An explicit object member function is a non-static member function with an explic...
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, const AssociatedConstraint &TrailingRequiresClause={})
unsigned getNumExplicitParams() const
CXXMethodDecl * getMostRecentDecl()
overridden_method_range overridden_methods() const
unsigned size_overridden_methods() const
method_iterator begin_overridden_methods() const
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
QualType getFunctionObjectParameterType() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
The null pointer literal (C++11 [lex.nullptr])
Represents a C++ struct/union/class.
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
friend_range friends() const
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class....
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
bool implicitCopyConstructorHasConstParam() const
Determine whether an implicit copy constructor for this type would have a parameter with a const-qual...
bool defaultedDestructorIsDeleted() const
true if a defaulted destructor for this class would be deleted.
bool hasInheritedAssignment() const
Determine whether this class has a using-declaration that names a base class assignment operator.
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
bool hasTrivialDestructorForCall() const
bool defaultedMoveConstructorIsDeleted() const
true if a defaulted move constructor for this class would be deleted.
bool isLiteral() const
Determine whether this class is a literal type.
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
bool defaultedDestructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
bool isLambda() const
Determine whether this class describes a lambda function object.
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12)
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
bool hasUserDeclaredCopyAssignment() const
Determine whether this class has a user-declared copy assignment operator.
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
method_range methods() const
CXXRecordDecl * getDefinition() const
bool needsOverloadResolutionForCopyAssignment() const
Determine whether we need to eagerly declare a defaulted copy assignment operator for this class.
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class....
void setImplicitMoveAssignmentIsDeleted()
Set that we attempted to declare an implicit move assignment operator, but overload resolution failed...
bool hasConstexprDestructor() const
Determine whether this class has a constexpr destructor.
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
unsigned getNumBases() const
Retrieves the number of base classes of this class.
bool defaultedCopyConstructorIsDeleted() const
true if a defaulted copy constructor for this class would be deleted.
bool hasTrivialCopyConstructorForCall() const
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
bool lambdaIsDefaultConstructibleAndAssignable() const
Determine whether this lambda should have an implicit default constructor and copy and move assignmen...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11,...
base_class_range vbases()
base_class_iterator vbases_begin()
void setImplicitMoveConstructorIsDeleted()
Set that we attempted to declare an implicit move constructor, but overload resolution failed so we d...
bool isAbstract() const
Determine whether this class has a pure virtual function.
bool hasVariantMembers() const
Determine whether this class has any variant members.
void setImplicitCopyConstructorIsDeleted()
Set that we attempted to declare an implicit copy constructor, but overload resolution failed so we d...
bool isDynamicClass() const
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
bool hasNonTrivialCopyConstructorForCall() const
bool hasDirectFields() const
Determine whether this class has direct non-static data members.
bool hasUserDeclaredCopyConstructor() const
Determine whether this class has a user-declared copy constructor.
bool hasDefinition() const
void setImplicitCopyAssignmentIsDeleted()
Set that we attempted to declare an implicit copy assignment operator, but overload resolution failed...
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
bool hasNonTrivialDestructorForCall() const
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator,...
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class.
CXXRecordDecl * getDefinitionOrSelf() const
bool hasUserDeclaredMoveConstructor() const
Determine whether this class has had a move constructor declared by the user.
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared.
bool hasTrivialMoveConstructorForCall() const
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
bool implicitCopyAssignmentHasConstParam() const
Determine whether an implicit copy assignment operator for this type would have a parameter with a co...
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
Represents the this expression in C++.
SourceLocation getBeginLoc() const
SourceLocation getLocation() const
CXXTryStmt - A C++ try block, including all handlers.
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
bool isCallToStdMove() const
QualType withConst() const
Retrieves a version of this type with const applied.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CastKind getCastKind() const
static CharSourceRange getTokenRange(SourceRange R)
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
bool isExplicitSpecialization() const
const ComparisonCategoryInfo * lookupInfoForType(QualType Ty) const
static StringRef getCategoryString(ComparisonCategoryType Kind)
static StringRef getResultString(ComparisonCategoryResult Kind)
static std::vector< ComparisonCategoryResult > getPossibleResultsForType(ComparisonCategoryType Type)
Return the list of results which are valid for the specified comparison category type.
const CXXRecordDecl * Record
The declaration for the comparison category type from the standard library.
ComparisonCategoryType Kind
The Kind of the comparison category type.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Represents the canonical version of C arrays with a specified constant size.
llvm::APInt getSize() const
Return the constant array size as an APInt.
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared.
static ConstructorUsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target, bool IsVirtual)
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
AccessSpecifier getAccess() const
The results of name lookup within a DeclContext.
DeclListNode::iterator iterator
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
lookup_result::iterator lookup_iterator
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
DeclContextLookupResult lookup_result
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void removeDecl(Decl *D)
Removes a declaration from this context.
void addDecl(Decl *D)
Add the declaration D into this context.
decl_iterator decls_end() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically encloses the declaration context DC.
Decl::Kind getDeclKind() const
DeclContext * getNonTransparentContext()
decl_iterator decls_begin() const
A reference to a declared variable, function, enum, etc.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
SourceLocation getBeginLoc() const
bool isImmediateEscalating() const
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
bool isModulePrivateSpecified() const
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
ThreadStorageClassSpecifier TSCS
Expr * getPackIndexingExpr() const
void ClearStorageClassSpecs()
TST getTypeSpecType() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
SourceLocation getExplicitSpecLoc() const
SourceLocation getFriendSpecLoc() const
ParsedType getRepAsType() const
TSCS getThreadStorageClassSpec() const
bool isFriendSpecifiedFirst() const
ParsedAttributes & getAttributes()
SourceLocation getEllipsisLoc() const
SourceLocation getConstSpecLoc() const
SourceRange getExplicitSpecRange() const
Expr * getRepAsExpr() const
bool isInlineSpecified() const
SourceLocation getRestrictSpecLoc() const
bool SetTypeQual(TQ T, SourceLocation Loc)
void ClearConstexprSpec()
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getAtomicSpecLoc() const
SourceLocation getVirtualSpecLoc() const
SourceLocation getConstexprSpecLoc() const
SourceLocation getTypeSpecTypeLoc() const
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
SourceLocation getInlineSpecLoc() const
SourceLocation getUnalignedSpecLoc() const
SourceLocation getVolatileSpecLoc() const
FriendSpecified isFriendSpecified() const
bool hasExplicitSpecifier() const
bool hasConstexprSpecifier() const
static const TST TST_auto
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
SourceLocation getBeginLoc() const LLVM_READONLY
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
bool isInStdNamespace() const
SourceLocation getEndLoc() const LLVM_READONLY
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Kind
Lists the kind of concrete classes of Decl.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
@ FOK_Undeclared
A friend of a previously-undeclared entity.
@ FOK_None
Not a friend object.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
DeclContext * getNonTransparentDeclContext()
Return the non transparent context.
bool isInvalidDecl() const
unsigned getIdentifierNamespace() const
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
@ IDNS_Ordinary
Ordinary names.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
void setLocalOwningModule(Module *M)
void setImplicit(bool I=true)
void setReferenced(bool R=true)
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
@ VisibleWhenImported
This declaration has an owning module, and is visible when that module is imported.
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
bool isAnyOperatorNewOrDelete() const
std::string getAsString() const
Retrieve the human-readable string for this name.
const IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Represents a ValueDecl that came out of a declarator.
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
SourceLocation getIdentifierLoc() const
void SetIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
bool hasGroupingParens() const
void setInvalidType(bool Val=true)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isRedeclaration() const
DeclaratorContext getContext() const
const DecompositionDeclarator & getDecompositionDeclarator() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isFunctionDefinition() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
The template parameter lists that preceded the declarator.
void setInventedTemplateParameterList(TemplateParameterList *Invented)
Sets the template parameter list generated from the explicit template parameters along with any inven...
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
bool isStaticMember()
Returns true if this declares a static member.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
const IdentifierInfo * getIdentifier() const
A decomposition declaration.
ArrayRef< BindingDecl * > bindings() const
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
ArrayRef< Binding > bindings() const
SourceRange getSourceRange() const
SourceLocation getLSquareLoc() const
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
virtual bool TraverseConstructorInitializer(MaybeConst< CXXCtorInitializer > *Init)
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
RAII object that enters a new expression evaluation context.
An instance of this object exists for each enum constant that is defined.
enumerator_range enumerators() const
EvaluatedExprVisitor - This class visits 'Expr *'s.
Store information needed for an explicit specifier.
const Expr * getExpr() const
void setKind(ExplicitSpecKind Kind)
This represents one expression.
static bool isPotentialConstantExpr(const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExpr - Return true if this function's definition might be usable in a constant exp...
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
bool isMutable() const
Determines whether this field is mutable (C++ only).
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
void setInClassInitializer(Expr *NewInit)
Set the C++11 in-class initializer for this member.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
bool isUnnamedBitField() const
Determines whether this is an unnamed bitfield.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, SourceLocation EllipsisLoc={}, ArrayRef< TemplateParameterList * > FriendTypeTPLists={})
void setUnsupportedFriend(bool Unsupported)
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, StringLiteral *DeletedMessage=nullptr)
Represents a function declaration or definition.
static constexpr unsigned RequiredTypeAwareDeleteParameterCount
Count of mandatory parameters for type aware operator delete.
const ParmVarDecl * getParamDecl(unsigned i) const
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
ExceptionSpecificationType getExceptionSpecType() const
Gets the ExceptionSpecificationType as declared.
bool isTrivialForCall() const
ConstexprSpecKind getConstexprKind() const
DefaultedOrDeletedFunctionInfo * getDefaultedOrDeletedInfo() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
bool isImmediateFunction() const
void setDefaultedOrDeletedInfo(DefaultedOrDeletedFunctionInfo *Info)
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
bool hasCXXExplicitFunctionObjectParameter() const
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
SourceLocation getDefaultLoc() const
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
param_iterator param_begin()
const ParmVarDecl * getNonObjectParameter(unsigned I) const
bool isVariadic() const
Whether this function is variadic.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
bool isDeleted() const
Whether this function has been deleted.
void setBodyContainsImmediateEscalatingExpressions(bool Set)
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
FunctionEffectsRef getFunctionEffects() const
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
static constexpr unsigned RequiredTypeAwareNewParameterCount
Count of mandatory parameters for type aware operator new.
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
bool isImmediateEscalating() const
void setIsDestroyingOperatorDelete(bool IsDestroyingDelete)
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
void setIsTypeAwareOperatorNewOrDelete(bool IsTypeAwareOperator=true)
bool isDefaulted() const
Whether this function is defaulted.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
void setConstexprKind(ConstexprSpecKind CSK)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDefaulted(bool D=true)
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
bool hasOneParamOrDefaultArgs() const
Determine whether this function has a single parameter, or multiple parameters where all but the firs...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
size_t param_size() const
DeclarationNameInfo getNameInfo() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
A mutable set of FunctionEffects and possibly conditions attached to them.
bool insert(const FunctionEffectWithCondition &NewEC, Conflicts &Errs)
SmallVector< Conflict > Conflicts
An immutable set of FunctionEffects and possibly conditions attached to them.
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, ValueDecl *ParamPack, SourceLocation NameLoc, ArrayRef< ValueDecl * > Params)
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
const QualType * param_type_iterator
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > exceptions() const
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type?
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Wrapper for source info for functions.
unsigned getNumParams() const
ParmVarDecl * getParam(unsigned i) const
void setParam(unsigned i, ParmVarDecl *VD)
TypeLoc getReturnLoc() const
ExtInfo withCallingConv(CallingConv cc) const
FunctionType - C99 6.7.5.3 - Function Declarators.
CallingConv getCallConv() const
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
unsigned getLength() const
Efficiently return the length of this identifier info.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
ReservedLiteralSuffixIdStatus isReservedLiteralSuffixId() const
Determine whether this is a name reserved for future standardization or the implementation (C++ [usrl...
bool isPlaceholder() const
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
IfStmt - This represents an if/then/else.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
Represents an implicitly-generated value initialization of an object of a given type.
Represents a field injected from an anonymous union/struct into the parent scope.
ArrayRef< NamedDecl * > chain() const
void setInherited(bool I)
Description of a constructor that was inherited from a base class.
ConstructorUsingShadowDecl * getShadowDecl() const
const TypeClass * getTypePtr() const
Describes an C or C++ initializer list.
unsigned getNumInits() const
const Expr * getInit(unsigned Init) const
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
static InitializedEntity InitializeMemberFromDefaultMemberInitializer(FieldDecl *Member)
Create the initialization entity for a default member initializer.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
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'.
An lvalue reference type, per C++11 [dcl.ref].
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
capture_range captures() const
Retrieve this lambda's captures.
@ Default
Use default layout rules of the target.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
Represents a linkage specification.
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LinkageSpecLanguageIDs Lang, bool HasBraces)
void setRBraceLoc(SourceLocation L)
A class for iterating through a result set and possibly filtering out results.
void erase()
Erase the last element returned from this iterator.
Represents the results of name lookup.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
DeclClass * getAsSingle() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Filter makeFilter()
Create a filter for this result set.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
UnresolvedSetImpl::iterator iterator
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
An instance of this class represents the declaration of a property member.
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
SourceLocation getExprLoc() const LLVM_READONLY
Wrapper for source info for member pointers.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Describes a module or submodule.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
bool isExplicitGlobalModule() const
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isPlaceholderVar(const LangOptions &LangOpts) const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
Represents a C++ namespace alias.
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamespaceBaseDecl *Namespace)
Represents C++ namespaces and their aliases.
NamespaceDecl * getNamespace()
Represent a C++ namespace.
bool isInline() const
Returns true if this is an inline namespace declaration.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested)
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace that inhabits this namespace, if any.
void setRBraceLoc(SourceLocation L)
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NestedNameSpecifier getCanonical() const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
const Type * getAsType() const
@ Global
The global specifier '::'. There is no stored value.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
The basic abstraction for the target Objective-C runtime.
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
@ CSK_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
SmallVectorImpl< OverloadCandidate >::iterator iterator
MapType::iterator iterator
MapType::const_iterator const_iterator
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
Represents a parameter to a function.
void setDefaultArg(Expr *defarg)
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
void setUninstantiatedDefaultArg(Expr *arg)
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
bool hasUninstantiatedDefaultArg() const
bool hasInheritedDefaultArg() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Expr * getUninstantiatedDefaultArg()
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
void setHasInheritedDefaultArg(bool I=true)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ParsedAttr - Represents a syntactic attribute.
IdentifierInfo * getPropertyDataSetter() const
IdentifierInfo * getPropertyDataGetter() const
static const ParsedAttributesView & none()
const ParsedAttr * getMSPropertyAttr() const
bool hasAttribute(ParsedAttr::Kind K) const
bool isAddressDiscriminated() const
Wrapper for source info for pointers.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
IdentifierTable & getIdentifierTable()
ArrayRef< Expr * > semantics()
A (possibly-)qualified type.
bool hasAddressDiscriminatedPointerAuth() const
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
PointerAuthQualifier getPointerAuth() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
void addConst()
Add the const type qualifier to this QualType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isConstQualified() const
Determine whether this type is const-qualified.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
bool isAtLeastAsQualifiedAs(QualType Other, const ASTContext &Ctx) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
Represents a template name as written in source code.
The collection of all-type qualifiers we support.
void removeCVRQualifiers(unsigned mask)
void addAddressSpace(LangAS space)
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
void removeAddressSpace()
LangAS getAddressSpace() const
void setObjCLifetime(ObjCLifetime type)
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool hasFlexibleArrayMember() const
bool hasObjectMember() const
field_iterator field_end() const
field_range fields() const
specific_decl_iterator< FieldDecl > field_iterator
RecordDecl * getDefinitionOrSelf() const
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
field_iterator field_begin() const
RedeclarableTemplateDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
void setEntity(DeclContext *E)
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ DeclScope
This is a scope that can contain a declaration.
void PushUsingDirective(UsingDirectiveDecl *UDir)
A generic diagnostic builder for errors which may or may not be deferred.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
Emit a compatibility diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
A RAII object to enter scope of a compound statement.
For a defaulted function, the kind of defaulted function that it is.
DefaultedComparisonKind asComparison() const
bool isSpecialMember() const
bool isComparison() const
CXXSpecialMemberKind asSpecialMember() const
Helper class that collects exception specifications for implicitly-declared special member functions.
void CalledStmt(Stmt *S)
Integrate an invoked statement into the collected data.
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method)
Integrate another called method into the collected data.
SpecialMemberOverloadResult - The overloading result for a special member function.
CXXMethodDecl * getMethod() const
RAII object to handle the state changes required to synthesize a function body.
Abstract base class used for diagnosing integer constant expression violations.
Sema - This implements semantic analysis and AST building for C.
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
Attr * getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, bool IsDefinition)
Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a containing class.
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range)
CheckSpecifiedExceptionType - Check if the given type is valid in an exception specification.
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
void DiagnoseAbstractType(const CXXRecordDecl *RD)
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc, const LookupResult *R=nullptr, const UsingDecl *UD=nullptr)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
bool CheckExplicitObjectOverride(CXXMethodDecl *New, const CXXMethodDecl *Old)
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter,...
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
@ LookupLocalFriendName
Look up a friend of a local class.
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
void DiagnoseSentinelCalls(const NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function.
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
void EvaluateImplicitExceptionSpec(SourceLocation Loc, FunctionDecl *FD)
Evaluate the implicit exception specification for a defaulted special member function.
void PrintContextStack(InstantiationContextDiagFuncRef DiagFunc)
ExplicitSpecifier ActOnExplicitBoolSpecifier(Expr *E)
ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression found in an explicit(bool)...
bool DiagRedefinedPlaceholderFieldDecl(SourceLocation Loc, RecordDecl *ClassDecl, const IdentifierInfo *Name)
void ActOnFinishCXXNonNestedClass()
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclarationName Name, FunctionDecl *&Operator, ImplicitDeallocationParameters, bool Diagnose=true)
void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class)
Force the declaration of any implicitly-declared members of this class.
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc, Expr *DefaultArg)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc, TemplateIdAnnotation *TemplateId, bool IsMemberSpecialization)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
void DiagnoseStaticAssertDetails(const Expr *E)
Try to print more useful information about a failed static_assert with expression \E.
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings={})
void CheckDelegatingCtorCycles()
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
void CheckExplicitObjectMemberFunction(Declarator &D, DeclarationName Name, QualType R, bool IsLambda, DeclContext *DC=nullptr)
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class,...
AccessResult CheckFriendAccess(NamedDecl *D)
Checks access to the target of a friend declaration.
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
QualType tryBuildStdTypeIdentity(QualType Type, SourceLocation Loc)
Looks for the std::type_identity template and instantiates it with Type, or returns a null type if ty...
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr * > Args, bool RequiresADL=true)
Perform lookup for an overloaded binary operator.
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD)
Check a completed declaration of an implicit special member.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, QualType DeclInitType, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr * > &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicCallType::DoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted.
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, SourceLocation EllipsisLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
Annotation attributes are the only attributes allowed after an access specifier.
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc, CodeSynthesisContext::SynthesisKind CSC=CodeSynthesisContext::ExplicitTemplateArgumentSubstitution)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
void referenceDLLExportedClassMethods()
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member function overrides a virtual...
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
bool CheckOverridingFunctionAttributes(CXXMethodDecl *New, const CXXMethodDecl *Old)
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic=false)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions,...
bool tryResolveExplicitSpecifier(ExplicitSpecifier &ExplicitSpec)
tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
bool IsCXXTriviallyRelocatableType(QualType T)
Determines if a type is trivially relocatable according to the C++26 rules.
@ Other
C++26 [dcl.fct.def.general]p1 function-body: ctor-initializer[opt] compound-statement function-try-bl...
@ Delete
deleted-function-body
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
HandleField - Analyze a field of a C struct or a C++ data member.
FPOptionsOverride CurFPFeatureOverrides()
void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD)
Diagnose methods which overload virtual methods in a base class without overriding any.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, BaseUsingDecl *BUD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD, bool Diagnose, bool LookForGlobal, DeclarationName Name)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, DeclAccessPair Found, QualType ObjectType, SourceLocation Loc, const PartialDiagnostic &Diag)
Is the given member accessible for the purposes of deciding whether to define a special member functi...
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, const ParsedAttributesView &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
void ActOnFinishFunctionDeclarationDeclarator(Declarator &D)
Called after parsing a function declarator belonging to a function declaration.
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
DiagnosticsEngine & getDiagnostics() const
void DiagnoseTypeTraitDetails(const Expr *E)
If E represents a built-in type trait, or a known standard type trait, try to print more information ...
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool isStdTypeIdentity(QualType Ty, QualType *TypeArgument, const Decl **MalformedDecl=nullptr)
Tests whether Ty is an instance of std::type_identity and, if it is and TypeArgument is not NULL,...
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, TrivialABIHandling TAH=TrivialABIHandling::IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
void CheckDelayedMemberExceptionSpecs()
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ASTContext & getASTContext() const
ClassTemplateDecl * StdInitializerList
The C++ "std::initializer_list" template, which is defined in <initializer_list>.
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
SmallVector< std::pair< FunctionDecl *, FunctionDecl * >, 2 > DelayedEquivalentExceptionSpecChecks
All the function redeclarations seen during a class definition that had their exception spec checks d...
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
void PopExpressionEvaluationContext()
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
void ActOnStartFunctionDeclarationDeclarator(Declarator &D, unsigned TemplateParameterDepth)
Called before parsing a function declarator belonging to a function declaration.
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
@ Relational
This is an <, <=, >, or >= that should be implemented as a rewrite in terms of a <=> comparison.
@ NotEqual
This is an operator!= that should be implemented as a rewrite in terms of a == comparison.
@ ThreeWay
This is an operator<=> that should be implemented as a series of subobject comparisons.
@ None
This is not a defaultable comparison operator.
@ Equal
This is an operator== that should be implemented as a series of subobject comparisons.
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool UseMemberUsingDeclRules)
Determine whether the given New declaration is an overload of the declarations in Old.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
ValueDecl * tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl, CXXScopeSpec &SS, ParsedType TemplateTypeTy, IdentifierInfo *MemberOrBase)
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation, bool IsUsingIfExists)
Builds a using declaration.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool pushCodeSynthesisContext(CodeSynthesisContext Ctx)
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
EnumDecl * getStdAlignValT() const
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
void PushFunctionScope()
Enter a new function scope.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
FPOptions & getCurFPFeatures()
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_UsingDeclaration
A using declaration.
@ UPPC_ExceptionType
The type of an exception.
@ UPPC_Initializer
An initializer.
@ UPPC_BaseType
The base type of a class type.
@ UPPC_FriendDeclaration
A friend declaration.
@ UPPC_DefaultArgument
A default argument.
@ UPPC_DeclarationType
The type of an arbitrary declaration.
@ UPPC_DataMemberType
The type of a data member.
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl, bool IsNested)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
const LangOptions & getLangOpts() const
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl, bool SupportedForCompatibility=false)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier * > Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
void DefineDefaultedComparison(SourceLocation Loc, FunctionDecl *FD, DefaultedComparisonKind DCK)
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules,...
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, QualType ObjectType, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
bool CheckConstexprFunctionDefinition(const FunctionDecl *FD, CheckConstexprKind Kind)
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
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.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
NamedDecl * getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R)
Return the declaration shadowed by the given typedef D, or null if it doesn't shadow any declaration ...
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
const LangOptions & LangOpts
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
CXXRecordDecl * getStdBadAlloc() const
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
void CheckCXXDefaultArguments(FunctionDecl *FD)
Helpers for dealing with blocks and functions.
@ DefaultedOperator
A defaulted 'operator<=>' needed the comparison category.
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
NamedDecl * BuildUsingEnumDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation NameLoc, TypeSourceInfo *EnumType, EnumDecl *ED)
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
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...
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed.
ExprResult BuildConvertedConstantExpression(Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest=nullptr)
bool RequireCompleteEnumDecl(EnumDecl *D, SourceLocation L, CXXScopeSpec *SS=nullptr)
Require that the EnumDecl is completed with its enumerators defined or instantiated.
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
void MarkVirtualBaseDestructorsReferenced(SourceLocation Location, CXXRecordDecl *ClassDecl, llvm::SmallPtrSetImpl< const CXXRecordDecl * > *DirectVirtualBases=nullptr)
Mark destructors of virtual bases of this class referenced.
void ExitDeclaratorContext(Scope *S)
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMemberKind CSM)
Diagnose why the specified class does not have a trivial special member of the given kind.
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, const CXXScopeSpec &SS)
void popCodeSynthesisContext()
CXXRecordDecl * getCurrentClass(Scope *S, const CXXScopeSpec *SS)
Get the class that is directly named by the current context.
bool EvaluateAsString(Expr *Message, APValue &Result, ASTContext &Ctx, StringEvaluationContext EvalContext, bool ErrorOnInvalidMessage)
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
Check the validity of a C++ base class specifier.
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
ExprResult DefaultLvalueConversion(Expr *E)
bool CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow)
Determines whether to create a using shadow decl for a particular decl, given the set of decls existi...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
bool CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
void DiagPlaceholderVariableDefinition(SourceLocation Loc)
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
std::unique_ptr< RecordDeclSetTy > PureVirtualClassDiagSet
PureVirtualClassDiagSet - a set of class declarations which we have emitted a list of pure virtual fu...
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
ClassTemplateDecl * StdTypeIdentity
The C++ "std::type_identity" template, which is defined in <type_traits>.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams, SourceLocation EllipsisLoc)
Handle a friend type declaration.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived, CXXRecordDecl *Base, CXXBasePaths &Paths)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD)
Check that the C++ class annoated with "trivial_abi" satisfies all the conditions that are needed for...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
unsigned ActOnReenterTemplateScope(Decl *Template, llvm::function_ref< Scope *()> EnterScope)
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
FunctionDecl * SubstSpaceshipAsEqualEqual(CXXRecordDecl *RD, FunctionDecl *Spaceship)
Substitute the name and return type of a defaulted 'operator<=>' to form an implicit 'operator=='.
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
void diagnoseFunctionEffectMergeConflicts(const FunctionEffectSet::Conflicts &Errs, SourceLocation NewLoc, SourceLocation OldLoc)
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
bool CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *MD, DefaultedComparisonKind DCK)
bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method)
Whether this' shows up in the exception specification of a static member function.
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, ExprResult Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
void FilterUsingLookup(Scope *S, LookupResult &lookup)
Remove decls we can't actually see from a lookup being used to declare shadow using decls.
Decl * ActOnExceptionDeclarator(Scope *S, Declarator &D)
ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch handler.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr, SourceLocation Loc)
PushNamespaceVisibilityAttr - Note that we've entered a namespace with a visibility attribute.
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer * > MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, AssignmentAction Action, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType ...
void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an initializer for the declaration ...
FunctionDecl * BuildTypeAwareUsualDelete(FunctionTemplateDecl *FnDecl, QualType AllocType, SourceLocation)
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
void DiagnoseUnknownAttribute(const ParsedAttr &AL)
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
void CheckCompleteVariableDeclaration(VarDecl *VD)
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
QualType CheckTemplateIdType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, Scope *Scope, bool ForNestedNameSpecifier)
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL,...
RedeclarationKind forRedeclarationInCurContext() const
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, Expr *Init, SourceLocation EllipsisLoc)
Handle a C++ member initializer.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
void actOnDelayedExceptionSpecification(Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member or friend function (or function template).
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
void CheckExplicitObjectLambda(Declarator &D)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc)
PopPragmaVisibility - Pop the top element of the visibility stack; used for '#pragma GCC visibility' ...
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void DiscardCleanupsInEvaluationContext()
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AvailabilityMergeKind::Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > Expansions)
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc, StringLiteral *Message=nullptr)
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class,...
DiagnosticsEngine & Diags
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
TypeAwareAllocationMode ShouldUseTypeAwareOperatorNewOrDelete() const
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
NamespaceDecl * getStdNamespace() const
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
void DeclareImplicitEqualityComparison(CXXRecordDecl *RD, FunctionDecl *Spaceship)
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMemberKind SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name,...
ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val)
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
friend class InitializationSequence
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope.
ExprResult ConvertMemberDefaultInitExpression(FieldDecl *FD, Expr *InitExpr, SourceLocation InitLoc)
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
void checkIncorrectVTablePointerAuthenticationAttribute(CXXRecordDecl &RD)
Check that VTable Pointer authentication is only being set on the first first instantiation of the vt...
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
void DiagnoseDeletedDefaultedFunction(FunctionDecl *FD)
Produce notes explaining why a defaulted function was defined as deleted.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
UnsignedOrNone GetDecompositionElementCount(QualType DecompType, SourceLocation Loc)
Decl * ActOnDeclarator(Scope *S, Declarator &D)
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, const ParsedAttr &MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old)
A wrapper function for checking the semantic restrictions of a redeclaration within a module.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
@ CheckValid
Identify whether this function satisfies the formal rules for constexpr functions in the current lanu...
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
IdentifierResolver IdResolver
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
ExprResult ActOnCXXThis(SourceLocation Loc)
CXXConstructorDecl * findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor, ConstructorUsingShadowDecl *DerivedShadow)
Given a derived-class using shadow declaration for a constructor and the correspnding base class cons...
void warnOnReservedIdentifier(const NamedDecl *D)
bool CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, SourceLocation DefaultLoc)
bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS)
Determine whether the identifier II is a typo for the name of the class type currently being defined.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
bool isAbstractType(SourceLocation Loc, QualType T)
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
ASTMutationListener * getASTMutationListener() const
bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, ArrayRef< CXXCtorInitializer * > Initializers={})
void DiagnoseImmediateEscalatingReason(FunctionDecl *FD)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getEnd() const
SourceLocation getBegin() const
void setEnd(SourceLocation e)
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *Message, SourceLocation RParenLoc, bool Failed)
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
static bool isValidUDSuffix(const LangOptions &LangOpts, StringRef Suffix)
Determine whether a suffix is a valid ud-suffix.
StringLiteral - This represents a string literal expression, e.g.
bool isUnevaluated() const
StringRef getString() const
Represents the declaration of a struct/union/class/enum.
bool isBeingDefined() const
Return true if this decl is currently being defined.
StringRef getKindName() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TagKind getTagKind() const
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
void setElaboratedKeywordLoc(SourceLocation Loc)
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
A convenient class for passing around template argument information.
void addArgument(const TemplateArgumentLoc &Loc)
ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
TypeSourceInfo * getTypeSourceInfo() const
Represents a template argument.
@ Type
The template argument is a type.
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
SourceRange getSourceRange() const LLVM_READONLY
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
SourceLocation getTemplateLoc() const
unsigned getNumArgs() const
TemplateArgumentLoc getArgLoc(unsigned i) const
Declaration of a template type parameter.
unsigned getIndex() const
Retrieve the index of the template parameter.
unsigned getDepth() const
Retrieve the depth of the template parameter.
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
Declaration of an alias template.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Represents a declaration of a type.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceRange getLocalSourceRange() const
Get the local source range.
TypeLocClass getTypeLocClass() const
SourceLocation getEndLoc() const
Get the end source location.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
bool isBooleanType() const
const TemplateSpecializationType * getAsNonAliasTemplateSpecializationType() const
Look through sugar for an instance of TemplateSpecializationType which is not a type alias,...
bool isIncompleteArrayType() const
bool isUndeducedAutoType() const
bool isRValueReferenceType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isPointerType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
bool isLValueReferenceType() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
QualType getCanonicalTypeInternal() const
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isFunctionProtoType() const
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isFunctionType() const
bool isStructureOrClassType() const
bool isRealFloatingType() const
Floating point categories.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
Wrapper for source info for typedefs.
Simple class containing the result of Sema::CorrectTypo.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
SourceRange getCorrectionRange() const
void WillReplaceSpecifier(bool ForceReplacement)
DeclClass * getCorrectionDeclAs() const
NestedNameSpecifier getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
Expr * getSubExpr() const
static bool isIncrementDecrementOp(Opcode Op)
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Represents a C++ unqualified-id that has been parsed.
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
const IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId,...
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
A set of unresolved declarations.
ArrayRef< DeclAccessPair > pairs() const
The iterator over UnresolvedSets.
A set of unresolved declarations.
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
static UnresolvedUsingIfExistsDecl * Create(ASTContext &Ctx, DeclContext *DC, SourceLocation Loc, DeclarationName Name)
Wrapper for source info for unresolved typename using decls.
Represents a dependent using declaration which was marked with typename.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
Represents a dependent using declaration which was not marked with typename.
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
Represents a C++ using-declaration.
bool hasTypename() const
Return true if the using declaration has 'typename'.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
DeclarationNameInfo getNameInfo() const
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Represents C++ using-directive.
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
Represents a C++ using-enum-declaration.
static UsingEnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, SourceLocation EnumL, SourceLocation NameL, TypeSourceInfo *EnumType)
static UsingPackDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > UsingDecls)
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
static UsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, DeclarationName Name, BaseUsingDecl *Introducer, NamedDecl *Target)
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isNoDestroy(const ASTContext &) const
Is destruction of this variable entirely suppressed?
bool isInlineSpecified() const
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool evaluateDestruction(SmallVectorImpl< PartialDiagnosticAt > &Notes) const
Evaluate the destruction of this variable to determine if it constitutes constant destruction.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
@ TLS_Dynamic
TLS with a dynamic initializer.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
void setExceptionVariable(bool EV)
Declaration of a variable template.
Represents a GCC generic vector type.
unsigned getNumElements() const
QualType getElementType() const
Represents a C++11 virt-specifier-seq.
SourceLocation getOverrideLoc() const
SourceLocation getLastLocation() const
bool isOverrideSpecified() const
SourceLocation getFinalLoc() const
bool isFinalSpecified() const
bool isFinalSpelledSealed() const
Retains information about a function, method, or block that is currently being parsed.
bool FoundImmediateEscalatingExpression
Whether we found an immediate-escalating expression.
Provides information about an attempted template argument deduction, whose success or failure was des...
Defines the clang::TargetInfo interface.
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
bool Inc(InterpState &S, CodePtr OpPC, bool CanOverflow)
1) Pops a pointer from the stack 2) Load the value from the pointer 3) Writes the value increased by ...
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
The JSON file list parser is used to communicate input to InstallAPI.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
@ TST_typename_pack_indexing
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
@ NonFunction
This is not an overload because the lookup results contain a non-function.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
ConstexprSpecKind
Define the kind of constexpr specifier.
LinkageSpecLanguageIDs
Represents the language in a linkage specification.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ Found
Name lookup found a single declaration that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
LLVM_READONLY auto escapeCStyle(CharT Ch) -> StringRef
Return C-style escaped string for special characters, or an empty string if there is no such mapping.
@ Comparison
A comparison.
InClassInitStyle
In-class initialization styles for non-static data members.
@ ICIS_ListInit
Direct list-initialization.
@ ICIS_NoInit
No in-class initializer.
@ RQ_None
No ref-qualifier was provided.
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ OK_Ordinary
An ordinary object is located at an address in memory.
@ Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ IK_DeductionGuideName
A deduction-guide name (a template-name)
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_ConstructorTemplateId
A constructor named via a template-id.
@ IK_ConstructorName
A constructor name.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ IK_ConversionFunctionId
A conversion function name, e.g., operator int.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
std::optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
ActionResult< Decl * > DeclResult
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
StorageClass
Storage classes.
ComparisonCategoryType commonComparisonType(ComparisonCategoryType A, ComparisonCategoryType B)
Determine the common comparison type, as defined in C++2a [class.spaceship]p4.
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
MutableArrayRef< Expr * > MultiExprArg
Language
The language for the input, used to select and validate the language standard and possible actions.
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
std::pair< unsigned, unsigned > getDepthAndIndex(const NamedDecl *ND)
Retrieve the depth and index of a template parameter.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
ActionResult< CXXCtorInitializer * > MemInitResult
const FunctionProtoType * T
llvm::Expected< QualType > ExpectedType
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
ActionResult< CXXBaseSpecifier * > BaseResult
void EscapeStringForDiagnostic(StringRef Str, SmallVectorImpl< char > &OutStr)
EscapeStringForDiagnostic - Append Str to the diagnostic buffer, escaping non-printable characters an...
ReservedLiteralSuffixIdStatus
TagTypeKind
The kind of a tag type.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Keyword
The name has been typo-corrected to a keyword.
@ Type
The name was classified as a type.
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ CanPassInRegs
The argument of this type can be passed directly in registers.
@ CanNeverPassInRegs
The argument of this type cannot be passed directly in registers.
@ CannotPassInRegs
The argument of this type cannot be passed directly in registers.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
CXXSpecialMemberKind
Kinds of C++ special members.
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
@ TNK_Concept_template
The name refers to a concept.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor
@ ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
@ IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
@ Success
Template argument deduction was successful.
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
TypeAwareAllocationMode typeAwareAllocationModeFromBool(bool IsTypeAwareAllocation)
U cast(CodeGen::Address addr)
@ StaticAssertMessageData
Call to data() in a static assert message.
@ StaticAssertMessageSize
Call to size() in a static assert message.
@ ExplicitBool
Condition in an explicit(bool) specifier.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ None
No keyword precedes the qualified type name.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
bool isLambdaMethod(const DeclContext *DC)
bool isExternallyVisible(Linkage L)
ActionResult< Expr * > ExprResult
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)
ActionResult< Stmt * > StmtResult
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
bool hasValidIntValue() const
True iff we've successfully evaluated the variable as a constant expression and extracted its integer...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
SourceLocation getEndLoc() const LLVM_READONLY
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)',...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
bool hasMutableQualifier() const
Determine whether this lambda-declarator contains a 'mutable' qualifier.
bool hasMethodTypeQualifiers() const
Determine whether this method has qualifiers.
void freeParams()
Reset the parameter list to having zero parameters.
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
One instance of this struct is used for each type in a declarator that is parsed.
SourceRange getSourceRange() const
enum clang::DeclaratorChunk::@340323374315200305336204205154073066142310370142 Kind
EvalResult is a struct with detailed info about an evaluated expression.
Holds information about the various types of exception specification.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
FunctionEffectsRef FunctionEffects
RefQualifierKind RefQualifier
FunctionType::ExtInfo ExtInfo
static StringRef getTagTypeKindName(TagTypeKind Kind)
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
Describes how types, statements, expressions, and declarations should be printed.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
@ MarkingClassDllexported
We are marking a class as __dllexport.
@ InitializingStructuredBinding
We are initializing a structured binding.
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Decl * Entity
The entity that is being synthesized.
Abstract class used to diagnose incomplete types.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
Information about a template-id annotation token.
TemplateNameKind Kind
The kind of template that Template refers to.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
OpaquePtr< T > get() const