52#include "llvm/ADT/ArrayRef.h"
53#include "llvm/ADT/STLExtras.h"
54#include "llvm/ADT/StringExtras.h"
55#include "llvm/Support/ConvertUTF.h"
56#include "llvm/Support/SaveAndRestore.h"
73class CheckDefaultArgumentVisitor
76 const Expr *DefaultArg;
79 CheckDefaultArgumentVisitor(Sema &S,
const Expr *DefaultArg)
80 : S(S), DefaultArg(DefaultArg) {}
82 bool VisitExpr(
const Expr *Node);
83 bool VisitDeclRefExpr(
const DeclRefExpr *DRE);
84 bool VisitCXXThisExpr(
const CXXThisExpr *ThisE);
85 bool VisitLambdaExpr(
const LambdaExpr *Lambda);
86 bool VisitPseudoObjectExpr(
const PseudoObjectExpr *POE);
87 bool VisitCoawaitExpr(
const CoawaitExpr *E);
88 bool VisitCoyieldExpr(
const CoyieldExpr *E);
92bool CheckDefaultArgumentVisitor::VisitExpr(
const Expr *Node) {
93 bool IsInvalid =
false;
94 for (
const Stmt *SubStmt : Node->
children())
96 IsInvalid |= Visit(SubStmt);
103bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
const DeclRefExpr *DRE) {
109 if (
const auto *Param = dyn_cast<ParmVarDecl>(Decl)) {
120 diag::err_param_default_argument_references_param)
122 }
else if (
auto *VD =
Decl->getPotentiallyDecomposedVarDecl()) {
137 diag::err_param_default_argument_references_local)
144bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
const CXXThisExpr *ThisE) {
149 diag::err_param_default_argument_references_this)
153bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
154 const PseudoObjectExpr *POE) {
158 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E)) {
159 E = OVE->getSourceExpr();
160 assert(E &&
"pseudo-object binding without source expression?");
168bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
const LambdaExpr *Lambda) {
175 for (
const LambdaCapture &LC : Lambda->
captures()) {
177 return S.
Diag(LC.getLocation(), diag::err_lambda_capture_default_arg);
180 Invalid |= Visit(D->getInit());
185bool CheckDefaultArgumentVisitor::VisitCoawaitExpr(
const CoawaitExpr *E) {
195bool CheckDefaultArgumentVisitor::VisitCoyieldExpr(
const CoyieldExpr *E) {
212 Proto = Self->ResolveExceptionSpec(CallLoc, Proto);
229 llvm_unreachable(
"should not see unresolved exception specs here");
258 "should not generate implicit declarations for dependent cases");
262 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
264 "Shouldn't collect exceptions when throw-all is guaranteed.");
268 if (ExceptionsSeen.insert(Self->Context.getCanonicalType(E)).second)
269 Exceptions.push_back(E);
297 if (Self->canThrow(S))
304 diag::err_typecheck_decl_incomplete_type))
323 CheckCompletedExpr(Arg, EqualLoc);
332 Param->setDefaultArg(Arg);
336 UnparsedDefaultArgInstantiationsMap::iterator InstPos
339 for (
auto &Instantiation : InstPos->second)
340 Instantiation->setUninstantiatedDefaultArg(Arg);
350 if (!param || !DefaultArg)
358 Diag(EqualLoc, diag::err_param_default_argument)
372 if (Param->isParameterPack()) {
373 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
376 Param->setDefaultArg(
nullptr);
391 CheckDefaultArgumentVisitor DefaultArgChecker(*
this, DefaultArg);
392 if (DefaultArgChecker.Visit(DefaultArg))
405 Param->setUnparsedDefaultArg();
415 Param->setInvalidDecl();
420 Param->getType().getNonReferenceType());
423 Param->getType().getNonReferenceType());
425 Param->setDefaultArg(RE.
get());
440 if (MightBeFunction) {
444 MightBeFunction =
false;
447 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
450 if (Param->hasUnparsedDefaultArg()) {
451 std::unique_ptr<CachedTokens> Toks =
454 if (Toks->size() > 1)
456 Toks->back().getLocation());
459 Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
461 }
else if (Param->getDefaultArg()) {
462 Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
463 << Param->getDefaultArg()->getSourceRange();
464 Param->setDefaultArg(
nullptr);
468 MightBeFunction =
false;
475 return P->hasDefaultArg() && !P->hasInheritedDefaultArg();
487 ?
New->getLexicalDeclContext()
488 :
New->getDeclContext();
492 for (; PrevForDefaultArgs;
495 PrevForDefaultArgs =
New->isLocalExternDecl()
503 !
New->isCXXClassMember()) {
548 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
551 p < NumParams; ++p) {
555 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
558 if (OldParamHasDfl && NewParamHasDfl) {
559 unsigned DiagDefaultParamID =
560 diag::err_param_default_argument_redefinition;
575 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
593 for (
auto Older = PrevForDefaultArgs;
595 Older = Older->getPreviousDecl();
596 OldParam = Older->getParamDecl(p);
601 }
else if (OldParamHasDfl) {
607 !
New->getLexicalDeclContext()->isDependentContext()) {
619 }
else if (NewParamHasDfl) {
620 if (
New->getDescribedFunctionTemplate()) {
623 diag::err_param_default_argument_template_redecl)
626 diag::note_template_prev_declaration)
628 }
else if (
New->getTemplateSpecializationKind()
642 <<
New->getDeclName()
644 }
else if (
New->getDeclContext()
645 ->getEnclosingNonExpansionStatementContext()
646 ->isDependentContext()) {
658 = dyn_cast<CXXRecordDecl>(
New->getDeclContext())) {
659 if (
Record->getDescribedClassTemplate())
668 diag::err_param_default_argument_member_template_redecl)
684 if (NewSM != OldSM) {
685 auto It = llvm::find_if(
New->parameters(), [](
const ParmVarDecl *P) {
686 return P->hasDefaultArg();
688 assert(It !=
New->param_end());
690 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
701 Diag(
New->getLocation(), diag::err_constexpr_redecl_mismatch)
711 (
New->isInlineSpecified() ||
716 Diag(
New->getLocation(), diag::err_inline_decl_follows_def) <<
New;
726 !
New->isFunctionTemplateSpecialization() &&
isVisible(Old)) {
727 Diag(
New->getLocation(), diag::err_deduction_guide_redeclared);
737 Diag(
New->getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
749 if (
New->isThisDeclarationInstantiatedFromAFriendDefinition() &&
757 DiagCompat(Loc, diag_compat::placeholder_var_definition);
775 if (!TemplateParamLists.empty()) {
781 Diag(TemplateParamLists.front()->getTemplateLoc(),
782 diag::err_decomp_decl_template);
788 DiagID = diag::compat_pre_cxx17_decomp_decl;
791 ? diag::compat_cxx26_decomp_decl_cond
792 : diag::compat_pre_cxx26_decomp_decl_cond;
794 DiagID = diag::compat_cxx17_decomp_decl;
815 Diag(Loc, diag::err_decomp_decl_spec) << Name;
818 auto DiagCpp20Specifier = [&](StringRef Name,
SourceLocation Loc) {
819 DiagCompat(Loc, diag_compat::decomp_decl_spec) << Name;
822 if (
auto SCS = DS.getStorageClassSpec()) {
825 DS.getStorageClassSpecLoc());
828 DS.getStorageClassSpecLoc());
830 if (
auto TSCS = DS.getThreadStorageClassSpec())
832 DS.getThreadStorageClassSpecLoc());
834 if (DS.isInlineSpecified())
835 DiagBadSpecifier(
"inline", DS.getInlineSpecLoc());
842 DS.getConstexprSpecLoc());
853 Diag(DS.getVolatileSpecLoc(),
854 diag::warn_deprecated_volatile_structured_binding);
874 ? diag::err_decomp_decl_parens
875 : diag::err_decomp_decl_type)
881 if (R->isFunctionType())
897 if (DS.isConstrainedAuto()) {
900 "No other template kind should be possible for a constrained auto");
918 assert(VarName &&
"Cannot have an unnamed binding declaration");
927 Previous.getFoundDecl()->isTemplateParameter()) {
933 if (B.EllipsisLoc.isValid()) {
935 Diag(B.EllipsisLoc, diag::err_pack_outside_template);
936 QT =
Context.getPackExpansionType(
Context.DependentTy, std::nullopt,
942 if (BD->isParameterPack()) {
944 CSI->LocalPacks.push_back(BD);
973 auto *Old =
Previous.getRepresentativeDecl();
974 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
975 Diag(Old->getLocation(), diag::note_previous_definition);
993 bool AddToScope =
true;
1002 if (
OpenMP().isInOpenMPDeclareTargetContext())
1003 OpenMP().checkDeclIsAllowedInOpenMPTarget(
nullptr,
New);
1013 unsigned MemberCount) {
1014 auto BindingWithPackItr = llvm::find_if(
1016 bool HasPack = BindingWithPackItr !=
Bindings.end();
1019 IsValid =
Bindings.size() == MemberCount;
1022 IsValid = MemberCount >=
Bindings.size() - 1;
1025 if (IsValid && HasPack) {
1027 unsigned PackSize = MemberCount -
Bindings.size() + 1;
1033 for (
unsigned I = 0; I < PackSize; ++I) {
1038 NestedBDs[I] = NestedBD;
1051 S.
Diag(DD->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1053 << (MemberCount <
Bindings.size());
1068 for (
auto *B : DD->flat_bindings()) {
1073 E = GetInit(Loc, E.
get(), I++);
1076 B->setBinding(ElemType, E.
get());
1085 const llvm::APSInt &NumElems,
1088 S,
Bindings, Src, DecompType, NumElems, ElemType,
1119 S,
Bindings, Src, DecompType, llvm::APSInt::get(2),
1123 return S.CreateBuiltinUnaryOp(Loc, I ? UO_Imag : UO_Real, Base);
1131 llvm::raw_svector_ostream OS(SS);
1143 return std::string(OS.str());
1148 auto DiagnoseMissing = [&] {
1158 return DiagnoseMissing();
1168 return DiagnoseMissing();
1169 if (
Result.isAmbiguous())
1174 Result.suppressDiagnostics();
1176 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
1177 S.
Diag(
Found->getLocation(), diag::note_declared_at);
1191 Loc, TraitTy, DiagID,
1201 assert(RD &&
"specialization of class template is not a class?");
1206static TemplateArgumentLoc
1213static TemplateArgumentLoc
1218namespace {
enum class IsTupleLike { TupleLike, NotTupleLike, Error }; }
1221 unsigned &OutSize) {
1231 return IsTupleLike::NotTupleLike;
1239 return IsTupleLike::NotTupleLike;
1248 : R(R), Args(Args) {}
1251 return S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1255 } Diagnoser(R, Args);
1260 return IsTupleLike::Error;
1265 return IsTupleLike::Error;
1269 if (Size < 0 || Size >=
UINT_MAX) {
1272 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_invalid)
1275 << StringRef(Str.data(), Str.size());
1276 return IsTupleLike::Error;
1279 OutSize = Size.getExtValue();
1280 return IsTupleLike::TupleLike;
1294 diag::err_decomp_decl_std_tuple_element_not_specialized);
1303 auto *TD = R.getAsSingle<
TypeDecl>();
1305 R.suppressDiagnostics();
1306 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1310 S.
Diag(R.getRepresentativeDecl()->getLocation(), diag::note_declared_at);
1319struct InitializingBinding {
1321 InitializingBinding(Sema &S, BindingDecl *BD) : S(S) {
1322 Sema::CodeSynthesisContext Ctx;
1328 ~InitializingBinding() {
1337 unsigned NumElems) {
1351 bool UseMemberGet =
false;
1361 dyn_cast<FunctionTemplateDecl>(D->getUnderlyingDecl())) {
1363 if (TPL->
size() != 0 &&
1366 UseMemberGet =
true;
1374 for (
auto *B : DD->flat_bindings()) {
1375 InitializingBinding InitContext(S, B);
1398 MemberGet, &Args,
nullptr);
1440 B->getDeclName().getAsIdentifierInfo(),
U,
1445 if (
const auto *CIAttr = Src->
getAttr<ConstInitAttr>())
1446 BindingVD->addAttr(CIAttr->clone(S.
Context));
1447 BindingVD->setImplicit();
1449 BindingVD->setInlineSpecified();
1450 BindingVD->getLexicalDeclContext()->addHiddenDecl(BindingVD);
1455 E =
Seq.Perform(S, Entity, Kind,
Init);
1461 BindingVD->setInit(E.
get());
1469 B->setBinding(
T, E.
get());
1484 return Specifier->getType()->getAsCXXRecordDecl()->hasDirectFields();
1493 ClassWithFields = RD;
1505 for (
auto &P : Paths) {
1509 BestPath->back().Base->getType())) {
1511 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1512 <<
false << RD << BestPath->back().Base->getType()
1513 << P.back().Base->getType();
1515 }
else if (P.Access < BestPath->
Access) {
1521 QualType BaseType = BestPath->back().Base->getType();
1523 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1530 *BestPath, diag::err_decomp_decl_inaccessible_base);
1533 ClassWithFields = BaseType->getAsCXXRecordDecl();
1541 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1542 << (ClassWithFields == RD) << RD << ClassWithFields
1543 << Paths.
front().back().Base->getType();
1554 const auto *RD = cast_or_null<CXXRecordDecl>(BasePair.
getDecl());
1558 for (
auto *FD : RD->fields()) {
1559 if (FD->isUnnamedBitField())
1564 if (!FD->getDeclName()) {
1565 if (RD->isLambda()) {
1566 S.
Diag(Loc, diag::err_decomp_decl_lambda);
1567 S.
Diag(RD->getLocation(), diag::note_lambda_decl);
1571 if (FD->isAnonymousStructOrUnion()) {
1572 S.
Diag(Loc, diag::err_decomp_decl_anon_union_member)
1574 S.
Diag(FD->getLocation(), diag::note_declared_at);
1587 BasePair.
getAccess(), FD->getAccess())));
1596 diag::err_incomplete_type))
1602 const auto *RD = cast_or_null<CXXRecordDecl>(BasePair.
getDecl());
1609 unsigned NumFields = llvm::count_if(
1610 RD->fields(), [](
FieldDecl *FD) { return !FD->isUnnamedBitField(); });
1617 auto FlatBindings = DD->flat_bindings();
1618 assert(llvm::range_size(FlatBindings) == NumFields);
1619 auto FlatBindingsItr = FlatBindings.begin();
1625 for (
auto *FD : RD->fields()) {
1630 assert(FlatBindingsItr != FlatBindings.end());
1672 if (B->getType().isNull())
1673 B->setType(
Context.DependentTy);
1685 if (
auto *CAT =
Context.getAsConstantArrayType(DecompType)) {
1706 case IsTupleLike::Error:
1710 case IsTupleLike::TupleLike:
1715 case IsTupleLike::NotTupleLike:
1724 << DD << !RD << DecompType;
1739 assert(!
T->isDependentType());
1744 T =
Context.getQualifiedType(Unqual, Quals);
1747 return static_cast<unsigned>(CAT->getSize().getZExtValue());
1749 return VT->getNumElements();
1755 case IsTupleLike::Error:
1756 return std::nullopt;
1757 case IsTupleLike::TupleLike:
1759 case IsTupleLike::NotTupleLike:
1764 if (!OrigRD || OrigRD->
isUnion())
1765 return std::nullopt;
1768 return std::nullopt;
1773 const auto *RD = cast_or_null<CXXRecordDecl>(BasePair.
getDecl());
1775 return std::nullopt;
1777 unsigned NumFields = llvm::count_if(
1778 RD->fields(), [](
FieldDecl *FD) { return !FD->isUnnamedBitField(); });
1781 return std::nullopt;
1792 "Should only be called if types are otherwise the same.");
1800 NewType = R->getPointeeType();
1819 New->setInvalidDecl();
1833 if (FTD->isMemberSpecialization())
1842 if (Param->hasDefaultArg())
1853 if (Param->hasDefaultArg() || Param->isParameterPack() ||
1857 if (Param->isInvalidDecl())
1859 else if (Param->getIdentifier())
1860 Diag(Param->getLocation(), diag::err_param_default_argument_missing_name)
1861 << Param->getIdentifier();
1863 Diag(Param->getLocation(), diag::err_param_default_argument_missing);
1870template <
typename... Ts>
1874 if (
T->isDependentType())
1880 std::forward<Ts>(DiagArgs)...);
1883 return !
T->isLiteralType(SemaRef.
Context);
1886 llvm_unreachable(
"unknown CheckConstexprKind");
1894 "this check is obsolete for C++23");
1897 T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
1905 SemaRef.
Diag(Loc, diag::note_constexpr_dtor_subobject)
1913 if (!Check(B.getBaseTypeLoc(), B.getType(),
nullptr))
1916 if (!Check(FD->getLocation(), FD->getType(), FD))
1927 "this check is obsolete for C++23");
1928 unsigned ArgIndex = 0;
1931 e = FT->param_type_end();
1932 i != e; ++i, ++ArgIndex) {
1934 assert(PD &&
"null in a parameter list");
1937 diag::err_constexpr_non_literal_param, ArgIndex + 1,
1950 "this check is obsolete for C++23");
1952 diag::err_constexpr_non_literal_return,
1971 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1999 for (
const auto &I : RD->
vbases())
2000 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
2001 << I.getSourceRange();
2015 Diag(
Method->getLocation(), diag::warn_cxx17_compat_constexpr_virtual);
2021 Diag(
Method->getLocation(), diag::err_constexpr_virtual);
2028 if (WrittenVirtual !=
Method)
2030 diag::note_overridden_virtual_function);
2041 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(NewFD)) {
2046 !Dtor->getParent()->defaultedDestructorIsConstexpr()) {
2061 "CheckConstexprFunctionDefinition called on function with no body");
2076 for (
const auto *DclIt : DS->
decls()) {
2077 switch (DclIt->getKind()) {
2078 case Decl::StaticAssert:
2080 case Decl::UsingShadow:
2081 case Decl::UsingDirective:
2082 case Decl::UnresolvedUsingTypename:
2083 case Decl::UnresolvedUsingValue:
2084 case Decl::UsingEnum:
2092 case Decl::TypeAlias: {
2096 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
2099 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
2110 case Decl::CXXRecord:
2115 diag_compat::constexpr_type_definition)
2123 case Decl::EnumConstant:
2124 case Decl::IndirectField:
2131 case Decl::Decomposition: {
2137 if (VD->isThisDeclarationADefinition()) {
2138 if (VD->isStaticLocal()) {
2141 diag_compat::constexpr_static_var)
2148 if (SemaRef.
LangOpts.CPlusPlus23) {
2150 diag::warn_cxx20_compat_constexpr_var,
2153 SemaRef, Kind, VD->getLocation(), VD->getType(),
2154 diag::err_constexpr_local_var_non_literal_type,
2158 if (!VD->getType()->isDependentType() &&
2159 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
2162 diag_compat::constexpr_local_var_no_init)
2171 SemaRef.
DiagCompat(VD->getLocation(), diag_compat::constexpr_local_var)
2179 case Decl::NamespaceAlias:
2180 case Decl::Function:
2189 SemaRef.
Diag(DS->
getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
2223 if (Field->isInvalidDecl())
2226 if (Field->isUnnamedBitField())
2232 if (Field->isAnonymousStructOrUnion() &&
2233 (Field->getType()->isUnionType()
2234 ? !Field->getType()->getAsCXXRecordDecl()->hasVariantMembers()
2235 : Field->getType()->getAsCXXRecordDecl()->isEmpty()))
2238 if (!
Inits.count(Field)) {
2242 diag_compat::constexpr_ctor_missing_init);
2245 SemaRef.
Diag(Field->getLocation(),
2246 diag::note_constexpr_ctor_missing_init);
2250 }
else if (Field->isAnonymousStructOrUnion()) {
2251 const auto *RD = Field->getType()->castAsRecordDecl();
2252 for (
auto *I : RD->fields())
2255 if (!RD->isUnion() ||
Inits.count(I))
2271 auto CheckChildren = [&] {
2275 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2283 case Stmt::NullStmtClass:
2287 case Stmt::DeclStmtClass: {
2292 if (DS->isSingleDecl()) {
2293 if (
auto *ESD = dyn_cast<CXXExpansionStmtDecl>(DS->getSingleDecl())) {
2295 if (!ESD->getInstantiations())
2297 for (
auto *BodyIt : ESD->getInstantiations()->getInstantiations()) {
2299 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2314 case Stmt::ReturnStmtClass:
2326 case Stmt::AttributedStmtClass:
2331 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind);
2333 case Stmt::CompoundStmtClass:
2337 return CheckChildren();
2339 case Stmt::IfStmtClass: {
2346 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2348 if (
If->getElse() &&
2350 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2355 case Stmt::WhileStmtClass:
2356 case Stmt::DoStmtClass:
2357 case Stmt::ForStmtClass:
2358 case Stmt::CXXForRangeStmtClass:
2359 case Stmt::ContinueStmtClass:
2366 case Stmt::SwitchStmtClass:
2367 case Stmt::CaseStmtClass:
2368 case Stmt::DefaultStmtClass:
2369 case Stmt::BreakStmtClass:
2374 return CheckChildren();
2376 case Stmt::LabelStmtClass:
2377 case Stmt::GotoStmtClass:
2378 case Stmt::IndirectGotoStmtClass:
2381 return CheckChildren();
2383 case Stmt::GCCAsmStmtClass:
2384 case Stmt::MSAsmStmtClass:
2386 case Stmt::CXXTryStmtClass:
2389 return CheckChildren();
2391 case Stmt::CXXCatchStmtClass:
2396 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind);
2446 diag_compat::constexpr_function_try_block)
2461 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2472 }
else if (Cxx2bLoc.
isValid()) {
2473 SemaRef.
DiagCompat(Cxx2bLoc, diag_compat::cxx23_constexpr_body_invalid_stmt)
2475 }
else if (Cxx2aLoc.
isValid()) {
2476 SemaRef.
DiagCompat(Cxx2aLoc, diag_compat::cxx20_constexpr_body_invalid_stmt)
2478 }
else if (Cxx1yLoc.
isValid()) {
2479 SemaRef.
DiagCompat(Cxx1yLoc, diag_compat::cxx14_constexpr_body_invalid_stmt)
2484 = dyn_cast<CXXConstructorDecl>(Dcl)) {
2497 diag_compat::constexpr_union_ctor_no_init);
2506 bool AnyAnonStructUnionMembers =
false;
2507 unsigned Fields = 0;
2509 E = RD->
field_end(); I != E; ++I, ++Fields) {
2510 if (I->isAnonymousStructOrUnion()) {
2511 AnyAnonStructUnionMembers =
true;
2519 if (AnyAnonStructUnionMembers ||
2529 Inits.insert(ID->chain_begin(), ID->chain_end());
2532 bool Diagnosed =
false;
2533 for (
auto *I : RD->
fields())
2540 if (ReturnStmts.empty()) {
2555 }
else if (ReturnStmts.size() > 1) {
2559 diag_compat::constexpr_body_multiple_return);
2560 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2561 SemaRef.
Diag(ReturnStmts[I],
2562 diag::note_constexpr_body_previous_return);
2590 !SemaRef.
getLangOpts().CheckConstexprFunctionBodies ||
2593 diag::ext_constexpr_function_never_constant_expr, Dcl->
getLocation());
2598 diag::ext_constexpr_function_never_constant_expr)
2601 for (
const auto &
Diag : Diags)
2617 if (SemaRef.
getLangOpts().CPlusPlus23 && !IsVoidOrDependentType)
2624 bool OK = SemaRef.
getLangOpts().CPlusPlus14 && IsVoidOrDependentType;
2626 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2627 : diag::err_constexpr_body_no_return)
2641 Diag(it->second, diag::err_immediate_function_used_before_definition)
2654 "expected an immediate function");
2655 assert(FD->
hasBody() &&
"expected the function to have a body");
2660 bool ImmediateFnIsConstructor;
2667 ShouldVisitImplicitCode =
true;
2668 ShouldVisitLambdaBody =
false;
2674 if (CurrentConstructor && CurrentInit) {
2682 SemaRef.Diag(Loc, diag::note_immediate_function_reason)
2683 << ImmediateFn << Fn << Fn->isConsteval() << IsCall
2685 << (InitializedField !=
nullptr)
2686 << (CurrentInit && !CurrentInit->
isWritten())
2687 << InitializedField << Range;
2689 bool TraverseCallExpr(
CallExpr *E)
override {
2690 if (
const auto *DR =
2692 DR && DR->isImmediateEscalating()) {
2698 if (!TraverseStmt(A))
2705 if (
const auto *ReferencedFn = dyn_cast<FunctionDecl>(E->
getDecl());
2707 Diag(E, ReferencedFn,
false);
2730 return DynamicRecursiveASTVisitor::TraverseCXXConstructorDecl(Ctr);
2733 bool TraverseType(
QualType T,
bool TraverseQualifier)
override {
2736 bool VisitBlockExpr(
BlockExpr *
T)
override {
return true; }
2738 } Visitor(*
this, FD);
2739 Visitor.TraverseDecl(FD);
2750 return dyn_cast_or_null<CXXRecordDecl>(DC);
2753 return dyn_cast_or_null<CXXRecordDecl>(
CurContext);
2771 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2773 CurDecl = dyn_cast_or_null<CXXRecordDecl>(
CurContext);
2792 if (BaseType->containsErrors()) {
2797 if (EllipsisLoc.
isValid() && !BaseType->containsUnexpandedParameterPack()) {
2798 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2812 if (BaseDecl->isUnion()) {
2813 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2817 if (BaseType.hasQualifiers()) {
2819 BaseType.getQualifiers().getAsString(
Context.getPrintingPolicy());
2820 Diag(BaseLoc, diag::warn_qual_base_type)
2821 << Quals << llvm::count(Quals,
' ') + 1 << BaseType;
2822 Diag(BaseLoc, diag::note_base_class_specified_here) << BaseType;
2826 if (
Context.getTargetInfo().getCXXABI().isMicrosoft() ||
2827 Context.getTargetInfo().getTriple().isPS()) {
2829 if (
auto *BaseSpec =
2830 dyn_cast<ClassTemplateSpecializationDecl>(BaseDecl)) {
2839 Class->setInvalidDecl();
2843 BaseDecl = BaseDecl->getDefinition();
2844 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2849 const auto *BaseCSA = BaseDecl->getAttr<CodeSegAttr>();
2850 const auto *DerivedCSA =
Class->getAttr<CodeSegAttr>();
2851 if ((DerivedCSA || BaseCSA) &&
2852 (!BaseCSA || !DerivedCSA ||
2853 BaseCSA->getName() != DerivedCSA->getName())) {
2854 Diag(
Class->getLocation(), diag::err_mismatched_code_seg_base);
2855 Diag(BaseDecl->getLocation(), diag::note_base_class_specified_here)
2866 if (BaseDecl->hasFlexibleArrayMember()) {
2867 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2868 << BaseDecl->getDeclName();
2875 if (FinalAttr *FA = BaseDecl->getAttr<FinalAttr>()) {
2876 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2877 << BaseDecl->getDeclName() << FA->isSpelledAsSealed();
2878 Diag(BaseDecl->getLocation(), diag::note_entity_declared_at)
2879 << BaseDecl->getDeclName() << FA->getRange();
2884 if (BaseDecl->isInvalidDecl())
2885 Class->setInvalidDecl();
2886 }
else if (BaseType->isDependentType()) {
2893 if (!
Class->isDependentContext())
2894 Class->setInvalidDecl();
2897 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2909 Access, TInfo, EllipsisLoc);
2926 Class->setIsParsingBaseSpecifiers();
2936 Diag(AL.getLoc(), diag::err_base_specifier_attribute)
2937 << AL << AL.isRegularKeywordAttribute() << AL.getRange();
2950 if (
Class->isUnion()) {
2951 Diag(
Class->getLocation(), diag::err_base_clause_on_union)
2961 Class->setInvalidDecl();
2978 for (
const auto &BaseSpec :
Decl->bases()) {
2979 QualType Base = Context.getCanonicalType(BaseSpec.getType())
2980 .getUnqualifiedType();
2997 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
3004 unsigned NumGoodBases = 0;
3008 Diag(Bases[1]->getBeginLoc(), diag::err_hlsl_mult_inheritance);
3010 Bases = Bases.take_front();
3014 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
3024 Diag(Bases[idx]->getBeginLoc(), diag::err_duplicate_base_class)
3025 << KnownBase->
getType() << Bases[idx]->getSourceRange();
3029 Context.Deallocate(Bases[idx]);
3034 KnownBase = Bases[idx];
3035 Bases[NumGoodBases++] = Bases[idx];
3040 if (Bases.size() > 1)
3044 if (
Class->isInterface() &&
3045 (!RD->isInterfaceLike() ||
3051 << RD->getSourceRange();
3054 if (RD->hasAttr<WeakAttr>())
3061 Class->setBases(Bases.data(), NumGoodBases);
3064 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
3066 QualType BaseType = Bases[idx]->getType();
3070 if (BaseType->isDependentType())
3074 .getUnqualifiedType();
3076 if (IndirectBaseTypes.count(CanonicalBase)) {
3080 =
Class->isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
3085 Diag(Bases[idx]->getBeginLoc(), diag::warn_inaccessible_base_class)
3087 << Bases[idx]->getSourceRange();
3089 assert(Bases[idx]->isVirtual());
3094 Context.Deallocate(Bases[idx]);
3102 if (!ClassDecl || Bases.empty())
3114 if (!
Base || !Derived)
3142 Base->getAsCXXRecordDecl(), Paths);
3148 Base->getAsCXXRecordDecl(), Paths);
3157 for (
unsigned I = Path.size(); I != 0; --I) {
3158 if (Path[I - 1].
Base->isVirtual()) {
3165 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
3172 assert(BasePathArray.empty() &&
"Base path array must be empty!");
3174 return ::BuildBasePathArray(Paths.
front(), BasePathArray);
3179 unsigned InaccessibleBaseID,
3180 unsigned AmbiguousBaseConvID,
3184 bool IgnoreAccess) {
3192 if (!DerivationOkay)
3197 Path = &Paths.
front();
3204 if (PossiblePath.size() == 1) {
3205 Path = &PossiblePath;
3206 if (AmbiguousBaseConvID)
3207 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
3208 <<
Base << Derived << Range;
3215 if (!IgnoreAccess) {
3234 if (AmbiguousBaseConvID) {
3244 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
3253 Diag(Loc, AmbiguousBaseConvID)
3254 << Derived <<
Base << PathDisplayStr << Range << Name;
3263 bool IgnoreAccess) {
3265 Derived,
Base, diag::err_upcast_to_inaccessible_base,
3266 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
3267 BasePath, IgnoreAccess);
3271 std::string PathDisplayStr;
3272 std::set<unsigned> DisplayedPaths;
3274 if (DisplayedPaths.insert(Path.back().SubobjectNumber).second) {
3277 PathDisplayStr +=
"\n ";
3281 PathDisplayStr +=
" -> " + Element.Base->getType().getAsString();
3285 return PathDisplayStr;
3295 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
3324 if (!OverloadedMethods.empty()) {
3325 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3326 Diag(OA->getLocation(),
3327 diag::override_keyword_hides_virtual_member_function)
3328 <<
"override" << (OverloadedMethods.size() > 1);
3329 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3330 Diag(FA->getLocation(),
3331 diag::override_keyword_hides_virtual_member_function)
3332 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3333 << (OverloadedMethods.size() > 1);
3344 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3345 Diag(OA->getLocation(),
3346 diag::override_keyword_only_allowed_on_virtual_member_functions)
3350 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3351 Diag(FA->getLocation(),
3352 diag::override_keyword_only_allowed_on_virtual_member_functions)
3353 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3365 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
3366 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
3380 SpellingLoc =
getSourceManager().getImmediateExpansionRange(Loc).getBegin();
3386 auto EmitDiag = [&](
unsigned DiagInconsistent,
unsigned DiagSuggest) {
3397 diag::warn_inconsistent_destructor_marked_not_override_overriding,
3398 diag::warn_suggest_destructor_marked_not_override_overriding);
3400 EmitDiag(diag::warn_inconsistent_function_marked_not_override_overriding,
3401 diag::warn_suggest_function_marked_not_override_overriding);
3407 FinalAttr *FA = Old->
getAttr<FinalAttr>();
3411 Diag(
New->getLocation(), diag::err_final_function_overridden)
3412 <<
New->getDeclName()
3413 << FA->isSpelledAsSealed();
3422 return !RD->isCompleteDefinition() || !RD->hasTrivialDefaultConstructor() ||
3423 !RD->hasTrivialDestructor();
3427void Sema::CheckShadowInheritedFields(
const SourceLocation &Loc,
3428 DeclarationName FieldName,
3429 const CXXRecordDecl *RD,
3431 if (Diags.isIgnored(diag::warn_shadow_field, Loc))
3435 std::map<CXXRecordDecl*, NamedDecl*> Bases;
3436 auto FieldShadowed = [&](
const CXXBaseSpecifier *
Specifier,
3437 CXXBasePath &Path) {
3438 const auto Base =
Specifier->getType()->getAsCXXRecordDecl();
3440 if (Bases.find(Base) != Bases.end())
3442 for (
const auto Field :
Base->lookup(FieldName)) {
3446 assert(Bases.find(Base) == Bases.end());
3454 CXXBasePaths Paths(
true,
true,
3459 for (
const auto &P : Paths) {
3460 auto Base = P.back().Base->getType()->getAsCXXRecordDecl();
3461 auto It = Bases.find(Base);
3463 if (It == Bases.end())
3465 auto BaseField = It->second;
3466 assert(BaseField->getAccess() !=
AS_private);
3469 Diag(Loc, diag::warn_shadow_field)
3470 << FieldName << RD <<
Base << DeclIsField;
3471 Diag(BaseField->getLocation(), diag::note_shadow_field);
3477template <
typename AttrType>
3479 if (
const TagDecl *TD =
T->getAsTagDecl())
3480 return TD->hasAttr<AttrType>();
3482 return TDT->getDecl()->hasAttr<AttrType>();
3525 unsigned InvalidDecl;
3526 bool ShowDeclName =
true;
3539 ShowDeclName =
false;
3544 ShowDeclName =
false;
3559 Diag(Loc, diag::err_invalid_member_in_interface)
3560 << (InvalidDecl-1) << Name;
3562 Diag(Loc, diag::err_invalid_member_in_interface)
3563 << (InvalidDecl-1) <<
"";
3573 Diag(Loc, diag::err_hlsl_cstor_dstor);
3601 diag::err_storageclass_invalid_for_member);
3608 !isFunc && TemplateParameterLists.empty();
3621 const char *PrevSpec;
3626 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3630 const char *PrevSpec;
3634 Context.getPrintingPolicy())) {
3636 "This is the only DeclSpec that should fail to be applied");
3640 isInstField =
false;
3651 Diag(Loc, diag::err_bad_variable_name)
3688 if (MSPropertyAttr) {
3690 BitWidth, InitStyle, AS, *MSPropertyAttr);
3693 isInstField =
false;
3696 BitWidth, InitStyle, AS);
3709 if (
Member->isInvalidDecl()) {
3714 Diag(Loc, diag::err_static_not_bitfield)
3718 Diag(Loc, diag::err_typedef_not_bitfield)
3723 Diag(Loc, diag::err_not_integral_type_bitfield)
3724 << Name << cast<ValueDecl>(
Member)->getType()
3729 Member->setInvalidDecl();
3734 NonTemplateMember = FunTmpl->getTemplatedDecl();
3736 NonTemplateMember = VarTmpl->getTemplatedDecl();
3742 if (NonTemplateMember !=
Member)
3748 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3749 auto *TD = DG->getDeducedTemplate();
3752 if (AS != TD->getAccess() &&
3753 TD->getDeclContext()->getRedeclContext()->Equals(
3754 DG->getDeclContext()->getRedeclContext())) {
3755 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
3756 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
3760 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(D))
3761 LastAccessSpec = AccessSpec;
3763 assert(LastAccessSpec &&
"differing access with no access specifier");
3764 Diag(LastAccessSpec->
getBeginLoc(), diag::note_deduction_guide_access)
3775 ? FinalAttr::Keyword_sealed
3776 : FinalAttr::Keyword_final));
3786 assert((Name || isInstField) &&
"No identifier for non-field ?");
3792 if (!
Diags.isIgnored(diag::warn_unused_private_field, FD->
getLocation()) &&
3804 class UninitializedFieldVisitor
3809 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3812 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3827 UninitializedFieldVisitor(
Sema &S,
3828 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3829 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3830 : Inherited(S.Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3834 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3835 bool CheckReferenceOnly) {
3837 bool ReferenceField =
false;
3842 Fields.push_back(FD);
3844 ReferenceField =
true;
3850 if (CheckReferenceOnly && !ReferenceField)
3855 auto UsedFields = llvm::drop_begin(llvm::reverse(Fields));
3856 auto UsedIter = UsedFields.begin();
3857 const auto UsedEnd = UsedFields.end();
3859 for (
const unsigned Orig : InitFieldIndex) {
3860 if (UsedIter == UsedEnd)
3862 const unsigned UsedIndex = (*UsedIter)->getFieldIndex();
3863 if (UsedIndex < Orig)
3865 if (UsedIndex > Orig)
3873 void HandleMemberExpr(MemberExpr *ME,
bool CheckReferenceOnly,
3880 MemberExpr *FieldME = ME;
3885 while (MemberExpr *SubME =
3886 dyn_cast<MemberExpr>(
Base->IgnoreParenImpCasts())) {
3891 if (FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3896 AllPODFields =
false;
3898 Base = SubME->getBase();
3906 if (AddressOf && AllPODFields)
3911 if (ImplicitCastExpr *BaseCast = dyn_cast<ImplicitCastExpr>(Base)) {
3916 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3917 QualType
T = BaseCast->getType();
3926 if (!Decls.count(FoundVD))
3931 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3933 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3938 if (CheckReferenceOnly && !IsReference)
3942 unsigned diag = IsReference
3943 ? diag::warn_reference_field_is_uninit
3944 : diag::warn_field_is_uninit;
3948 diag::note_uninit_in_this_constructor)
3953 void HandleValue(Expr *E,
bool AddressOf) {
3956 if (MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3957 HandleMemberExpr(ME,
false ,
3962 if (ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E)) {
3963 Visit(CO->getCond());
3964 HandleValue(CO->getTrueExpr(), AddressOf);
3965 HandleValue(CO->getFalseExpr(), AddressOf);
3969 if (BinaryConditionalOperator *BCO =
3970 dyn_cast<BinaryConditionalOperator>(E)) {
3971 Visit(BCO->getCond());
3972 HandleValue(BCO->getFalseExpr(), AddressOf);
3976 if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E)) {
3977 HandleValue(OVE->getSourceExpr(), AddressOf);
3981 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
3982 switch (BO->getOpcode()) {
3987 HandleValue(BO->getLHS(), AddressOf);
3988 Visit(BO->getRHS());
3991 Visit(BO->getLHS());
3992 HandleValue(BO->getRHS(), AddressOf);
4000 void CheckInitListExpr(InitListExpr *ILE) {
4001 InitFieldIndex.push_back(0);
4002 for (
auto *Child : ILE->
children()) {
4003 if (InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
4004 CheckInitListExpr(SubList);
4008 ++InitFieldIndex.back();
4010 InitFieldIndex.pop_back();
4013 void CheckInitializer(Expr *E,
const CXXConstructorDecl *FieldConstructor,
4014 FieldDecl *Field,
const Type *BaseClass) {
4017 for (ValueDecl* VD : DeclsToRemove)
4019 DeclsToRemove.clear();
4022 InitListExpr *ILE = dyn_cast<InitListExpr>(E);
4026 InitListFieldDecl =
Field;
4027 InitFieldIndex.clear();
4028 CheckInitListExpr(ILE);
4040 void VisitMemberExpr(MemberExpr *ME) {
4042 HandleMemberExpr(ME,
true ,
false );
4045 void VisitImplicitCastExpr(ImplicitCastExpr *E) {
4051 Inherited::VisitImplicitCastExpr(E);
4054 void VisitCXXConstructExpr(CXXConstructExpr *E) {
4056 Expr *ArgExpr = E->
getArg(0);
4057 if (InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
4060 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(ArgExpr))
4061 if (ICE->getCastKind() == CK_NoOp)
4062 ArgExpr = ICE->getSubExpr();
4063 HandleValue(ArgExpr,
false );
4066 Inherited::VisitCXXConstructExpr(E);
4069 void VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
4072 HandleValue(Callee,
false );
4078 Inherited::VisitCXXMemberCallExpr(E);
4081 void VisitCallExpr(CallExpr *E) {
4084 HandleValue(E->
getArg(0),
false);
4088 Inherited::VisitCallExpr(E);
4091 void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
4095 return Inherited::VisitCXXOperatorCallExpr(E);
4099 HandleValue(Arg->IgnoreParenImpCasts(),
false );
4102 void VisitBinaryOperator(BinaryOperator *E) {
4106 if (MemberExpr *ME = dyn_cast<MemberExpr>(E->
getLHS()))
4107 if (FieldDecl *FD = dyn_cast<FieldDecl>(ME->
getMemberDecl()))
4109 DeclsToRemove.push_back(FD);
4112 HandleValue(E->
getLHS(),
false );
4117 Inherited::VisitBinaryOperator(E);
4120 void VisitUnaryOperator(UnaryOperator *E) {
4126 if (MemberExpr *ME = dyn_cast<MemberExpr>(E->
getSubExpr())) {
4127 HandleValue(ME->
getBase(),
true );
4132 Inherited::VisitUnaryOperator(E);
4142 static void DiagnoseUninitializedFields(
4143 Sema &SemaRef,
const CXXConstructorDecl *
Constructor) {
4159 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
4162 for (
auto *I : RD->
decls()) {
4163 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
4164 UninitializedFields.insert(FD);
4165 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
4166 UninitializedFields.insert(IFD->getAnonField());
4170 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
4171 for (
const auto &I : RD->
bases()) {
4176 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
4179 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
4182 UninitializedFieldVisitor UninitializedChecker(SemaRef,
4183 UninitializedFields,
4184 UninitializedBaseClasses);
4186 for (
const auto *FieldInit :
Constructor->inits()) {
4187 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
4190 Expr *InitExpr = FieldInit->getInit();
4194 if (CXXDefaultInitExpr *
Default =
4195 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
4196 InitExpr =
Default->getExpr();
4200 UninitializedChecker.CheckInitializer(InitExpr,
Constructor,
4201 FieldInit->getAnyMember(),
4202 FieldInit->getBaseClass());
4204 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
4205 FieldInit->getAnyMember(),
4206 FieldInit->getBaseClass());
4227 if (ParamDecl->getDeclName())
4244 return ConstraintExpr;
4265 return Seq.Perform(*
this, Entity, Kind, InitExpr);
4283 "must set init style when field is created");
4320 DirectBaseSpec =
nullptr;
4321 for (
const auto &
Base : ClassDecl->
bases()) {
4325 DirectBaseSpec = &
Base;
4333 VirtualBaseSpec =
nullptr;
4334 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
4343 if (Path.back().Base->isVirtual()) {
4344 VirtualBaseSpec = Path.back().Base;
4351 return DirectBaseSpec || VirtualBaseSpec;
4365 DS, IdLoc, InitList,
4383 DS, IdLoc, List, EllipsisLoc);
4392 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
4393 : ClassDecl(ClassDecl) {}
4395 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4398 return Member->getDeclContext()->getRedeclContext()->Equals(ClassDecl);
4404 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
4405 return std::make_unique<MemInitializerValidatorCCC>(*
this);
4409 CXXRecordDecl *ClassDecl;
4426 Diag(Loc, diag::err_using_placeholder_variable) << Name;
4442 for (
auto *D : ClassDecl->
lookup(MemberOrBase)) {
4444 bool IsPlaceholder = D->isPlaceholderVar(
getLangOpts());
4446 if (IsPlaceholder && D->getDeclContext() == ND->
getDeclContext())
4477 if (!ConstructorD || !
Init)
4483 = dyn_cast<CXXConstructorDecl>(ConstructorD);
4507 ClassDecl, SS, TemplateTypeTy, MemberOrBase)) {
4509 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
4519 if (TemplateTypeTy) {
4521 if (BaseType.isNull())
4530 if (BaseType.isNull())
4538 if (R.isAmbiguous())
return true;
4541 R.suppressDiagnostics();
4544 bool NotUnknownSpecialization =
false;
4547 NotUnknownSpecialization = !
Record->hasAnyDependentBases();
4549 if (!NotUnknownSpecialization) {
4555 if (BaseType.isNull())
4558 TInfo =
Context.CreateTypeSourceInfo(BaseType);
4568 R.setLookupName(MemberOrBase);
4575 UnqualifiedBase->getCanonicalInjectedSpecializationType(
Context));
4577 for (
auto const &
Base : ClassDecl->
bases()) {
4579 Base.getType()->getAs<TemplateSpecializationType>();
4581 Context.hasSameTemplateName(BaseTemplate->getTemplateName(), TN,
4583 Diag(IdLoc, diag::ext_unqualified_base_class)
4585 BaseType =
Base.getType();
4594 MemInitializerValidatorCCC CCC(ClassDecl);
4595 if (R.empty() && BaseType.isNull() &&
4597 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, &SS,
4604 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4605 << MemberOrBase <<
true);
4612 DirectBaseSpec, VirtualBaseSpec)) {
4617 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4618 << MemberOrBase <<
false,
4631 if (!TyD && BaseType.isNull()) {
4632 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
4633 << MemberOrBase <<
SourceRange(IdLoc,
Init->getSourceRange().getEnd());
4638 if (BaseType.isNull()) {
4643 if (
const auto *TD = dyn_cast<TagDecl>(TyD)) {
4649 TL.setNameLoc(IdLoc);
4650 }
else if (
auto *TN = dyn_cast<TypedefNameDecl>(TyD)) {
4656 }
else if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TyD)) {
4665 BaseType =
Context.getTypeDeclType(TyD);
4673 TInfo =
Context.getTrivialTypeSourceInfo(BaseType, IdLoc);
4683 assert((DirectMember || IndirectMember) &&
4684 "Member must be a FieldDecl or IndirectFieldDecl");
4689 if (
Member->isInvalidDecl())
4694 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4696 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
4697 }
else if (
auto *ParenListInit = dyn_cast<CXXParenListInitExpr>(
Init)) {
4700 Args = ParenListInit->getUserSpecifiedInitExprs();
4708 if (
Member->getType()->isDependentType() ||
Init->isTypeDependent()) {
4713 bool InitList =
false;
4726 IdLoc,
Init->getBeginLoc(),
Init->getEndLoc())
4770 return Diag(NameLoc, diag::err_delegating_ctor)
4772 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4774 bool InitList =
true;
4778 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4789 NameLoc,
Init->getBeginLoc(),
Init->getEndLoc())
4798 "Delegating constructor with no target?");
4804 DelegationInit.
get(), InitRange.
getBegin(),
false);
4809 InitRange.
getEnd(), Args, ClassType);
4821 DelegationInit =
Init;
4835 if (!BaseType->isDependentType() && !BaseType->isRecordType())
4836 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4850 (BaseType->isDependentType() ||
Init->isTypeDependent());
4855 if (!BaseType->containsUnexpandedParameterPack()) {
4856 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4884 if (!DirectBaseSpec && !VirtualBaseSpec) {
4893 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4894 << BaseType <<
Context.getCanonicalTagType(ClassDecl)
4905 InitRange.
getEnd(), EllipsisLoc);
4912 if (DirectBaseSpec && VirtualBaseSpec)
4913 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4918 BaseSpec = VirtualBaseSpec;
4921 bool InitList =
true;
4925 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4965 InitRange.
getEnd(), EllipsisLoc);
4975 TargetType, ExprLoc);
4995 bool IsInheritedVirtualBase,
4999 IsInheritedVirtualBase);
5003 switch (ImplicitInitKind) {
5009 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, {});
5015 bool Moving = ImplicitInitKind ==
IIK_Move;
5017 QualType ParamType = Param->getType().getNonReferenceType();
5037 BasePath.push_back(BaseSpec);
5039 CK_UncheckedDerivedToBase,
5047 BaseInit = InitSeq.
Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
5079 if (Field->isInvalidDecl())
5085 bool Moving = ImplicitInitKind ==
IIK_Move;
5087 QualType ParamType = Param->getType().getNonReferenceType();
5090 if (Field->isZeroLengthBitField())
5093 Expr *MemberExprBase =
5106 LookupResult MemberLookup(SemaRef, Field->getDeclName(), Loc,
5142 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
5157 "Unhandled implicit init kind!");
5170 ExprResult MemberInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, {});
5173 if (MemberInit.isInvalid())
5190 if (!Field->getParent()->isUnion()) {
5193 diag::err_uninitialized_member_in_ctor)
5196 << Field->getDeclName();
5197 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
5203 diag::err_uninitialized_member_in_ctor)
5206 << Field->getDeclName();
5207 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
5224 CXXMemberInit =
nullptr;
5229struct BaseAndFieldInfo {
5231 CXXConstructorDecl *Ctor;
5232 bool AnyErrorsInInits;
5234 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
5235 SmallVector<CXXCtorInitializer*, 8> AllToInit;
5236 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
5238 BaseAndFieldInfo(Sema &S, CXXConstructorDecl *Ctor,
bool ErrorsInInits)
5239 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
5251 bool isImplicitCopyOrMove()
const {
5262 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
5265 bool addFieldInitializer(CXXCtorInitializer *
Init) {
5266 AllToInit.push_back(
Init);
5275 bool isInactiveUnionMember(FieldDecl *Field) {
5280 if (FieldDecl *Active =
5281 ActiveUnionMember.lookup(
Record->getCanonicalDecl()))
5282 return Active !=
Field->getCanonicalDecl();
5285 if (isImplicitCopyOrMove())
5290 if (
Field->hasInClassInitializer())
5294 if (!
Field->isAnonymousStructOrUnion())
5296 CXXRecordDecl *FieldRD =
Field->getType()->getAsCXXRecordDecl();
5303 bool isWithinInactiveUnionMember(FieldDecl *Field,
5304 IndirectFieldDecl *Indirect) {
5306 return isInactiveUnionMember(Field);
5308 for (
auto *
C : Indirect->
chain()) {
5309 FieldDecl *
Field = dyn_cast<FieldDecl>(
C);
5310 if (Field && isInactiveUnionMember(Field))
5321 if (
T->isIncompleteArrayType())
5325 if (ArrayT->isZeroSize())
5328 T = ArrayT->getElementType();
5337 if (Field->isInvalidDecl())
5342 Info.AllBaseFields.lookup(Field->getCanonicalDecl()))
5343 return Info.addFieldInitializer(
Init);
5357 if (Info.isWithinInactiveUnionMember(Field, Indirect))
5360 if (Field->hasInClassInitializer() && !Info.isImplicitCopyOrMove()) {
5378 return Info.addFieldInitializer(
Init);
5388 if (Info.AnyErrorsInInits)
5399 return Info.addFieldInitializer(
Init);
5426 if (Class->isInvalidDecl())
5428 if (Class->hasIrrelevantDestructor())
5437 if (Field->isInvalidDecl())
5447 if (!FieldClassDecl)
5451 if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion())
5459 S.
PDiag(diag::err_access_dtor_field)
5460 << Field->getDeclName() << FieldType);
5473 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5480 if (Dtor && Dtor->isUsed())
5481 VisitVirtualBases =
false;
5487 for (
const auto &
Base : ClassDecl->
bases()) {
5488 auto *BaseClassDecl =
Base.getType()->getAsCXXRecordDecl();
5493 if (
Base.isVirtual()) {
5494 if (!VisitVirtualBases)
5496 DirectVirtualBases.insert(BaseClassDecl);
5505 S.
PDiag(diag::err_access_dtor_base)
5506 <<
Base.getType() <<
Base.getSourceRange(),
5513 if (VisitVirtualBases)
5515 &DirectVirtualBases);
5523 if (!Initializers.empty()) {
5524 Constructor->setNumCtorInitializers(Initializers.size());
5527 memcpy(baseOrMemberInitializers, Initializers.data(),
5529 Constructor->setCtorInitializers(baseOrMemberInitializers);
5539 BaseAndFieldInfo Info(*
this,
Constructor, AnyErrors);
5547 bool HadError =
false;
5550 if (
Member->isBaseInitializer())
5551 Info.AllBaseFields[
Member->getBaseClass()->getAsCanonical<RecordType>()] =
5554 Info.AllBaseFields[
Member->getAnyMember()->getCanonicalDecl()] =
Member;
5557 for (
auto *
C : F->chain()) {
5560 Info.ActiveUnionMember.insert(std::make_pair(
5565 Info.ActiveUnionMember.insert(std::make_pair(
5573 for (
auto &I : ClassDecl->
bases()) {
5575 DirectVBases.insert(&I);
5579 for (
auto &VBase : ClassDecl->
vbases()) {
5581 VBase.getType()->getAsCanonical<RecordType>())) {
5589 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
5590 << VBase.getType() << ClassDecl;
5594 Info.AllToInit.push_back(
Value);
5595 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
5600 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
5603 &VBase, IsInheritedVirtualBase,
5609 Info.AllToInit.push_back(CXXBaseInit);
5616 if (
Base.isVirtual())
5620 Base.getType()->getAsCanonical<RecordType>())) {
5621 Info.AllToInit.push_back(
Value);
5622 }
else if (!AnyErrors) {
5631 Info.AllToInit.push_back(CXXBaseInit);
5636 for (
auto *Mem : ClassDecl->
decls()) {
5637 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
5642 if (F->isUnnamedBitField())
5648 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
5657 if (Info.isImplicitCopyOrMove())
5660 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
5661 if (F->getType()->isIncompleteArrayType()) {
5663 "Incomplete array type is not valid");
5675 unsigned NumInitializers = Info.AllToInit.size();
5676 if (NumInitializers > 0) {
5677 Constructor->setNumCtorInitializers(NumInitializers);
5680 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
5682 Constructor->setCtorInitializers(baseOrMemberInitializers);
5708 if (
const RecordType *RT = Field->getType()->getAsCanonical<RecordType>()) {
5716 IdealInits.push_back(Field->getCanonicalDecl());
5720 return Context.getCanonicalType(BaseType).getTypePtr();
5725 if (!
Member->isAnyMemberInitializer())
5728 return Member->getAnyMember()->getCanonicalDecl();
5734 if (
Previous->isAnyMemberInitializer())
5748 if (
Constructor->getDeclContext()->isDependentContext())
5753 bool ShouldCheckOrder =
false;
5755 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
5756 Init->getSourceLocation())) {
5757 ShouldCheckOrder =
true;
5761 if (!ShouldCheckOrder)
5772 for (
const auto &VBase : ClassDecl->
vbases())
5776 for (
const auto &
Base : ClassDecl->
bases()) {
5777 if (
Base.isVirtual())
5783 for (
auto *Field : ClassDecl->
fields()) {
5784 if (Field->isUnnamedBitField())
5790 unsigned NumIdealInits = IdealInitKeys.size();
5791 unsigned IdealIndex = 0;
5800 for (
unsigned InitIndex = 0; InitIndex !=
Inits.size(); ++InitIndex) {
5805 for (; IdealIndex != NumIdealInits; ++IdealIndex)
5806 if (InitKey == IdealInitKeys[IdealIndex])
5812 if (IdealIndex == NumIdealInits && InitIndex) {
5813 WarnIndexes.push_back(InitIndex);
5816 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
5817 if (InitKey == IdealInitKeys[IdealIndex])
5820 assert(IdealIndex < NumIdealInits &&
5821 "initializer not found in initializer list");
5823 CorrelatedInitOrder.emplace_back(IdealIndex, InitIndex);
5826 if (WarnIndexes.empty())
5830 llvm::sort(CorrelatedInitOrder, llvm::less_first());
5836 Inits[WarnIndexes.front() - 1]->getSourceLocation(),
5837 WarnIndexes.size() == 1 ? diag::warn_initializer_out_of_order
5838 : diag::warn_some_initializers_out_of_order);
5840 for (
unsigned I = 0; I < CorrelatedInitOrder.size(); ++I) {
5841 if (CorrelatedInitOrder[I].second == I)
5847 Inits[I]->getSourceRange(),
5850 Inits[CorrelatedInitOrder[I].second]->getSourceRange()),
5856 if (WarnIndexes.size() == 1) {
5858 Inits[WarnIndexes.front()]);
5864 for (
unsigned WarnIndex : WarnIndexes) {
5867 diag::note_initializer_out_of_order);
5874bool CheckRedundantInit(Sema &S,
5875 CXXCtorInitializer *
Init,
5876 CXXCtorInitializer *&PrevInit) {
5882 if (FieldDecl *Field =
Init->getAnyMember())
5884 diag::err_multiple_mem_initialization)
5885 <<
Field->getDeclName()
5886 <<
Init->getSourceRange();
5888 const Type *BaseClass =
Init->getBaseClass();
5889 assert(BaseClass &&
"neither field nor base");
5891 diag::err_multiple_base_initialization)
5892 << QualType(BaseClass, 0)
5893 <<
Init->getSourceRange();
5901typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5902typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5904bool CheckRedundantUnionInit(Sema &S,
5905 CXXCtorInitializer *
Init,
5906 RedundantUnionMap &Unions) {
5907 FieldDecl *
Field =
Init->getAnyMember();
5908 RecordDecl *Parent =
Field->getParent();
5909 NamedDecl *Child =
Field;
5913 UnionEntry &En = Unions[Parent];
5914 if (En.first && En.first != Child) {
5916 diag::err_multiple_mem_union_initialization)
5917 <<
Field->getDeclName()
5918 <<
Init->getSourceRange();
5919 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5920 << 0 << En.second->getSourceRange();
5943 if (!ConstructorDecl)
5949 = dyn_cast<CXXConstructorDecl>(ConstructorDecl);
5952 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5959 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5962 RedundantUnionMap MemberUnions;
5964 bool HadError =
false;
5965 for (
unsigned i = 0; i < MemInits.size(); i++) {
5969 Init->setSourceOrder(i);
5971 if (
Init->isAnyMemberInitializer()) {
5973 if (CheckRedundantInit(*
this,
Init, Members[Key]) ||
5974 CheckRedundantUnionInit(*
this,
Init, MemberUnions))
5976 }
else if (
Init->isBaseInitializer()) {
5978 if (CheckRedundantInit(*
this,
Init, Members[Key]))
5981 assert(
Init->isDelegatingInitializer());
5983 if (MemInits.size() != 1) {
5985 diag::err_delegating_initializer_alone)
5986 <<
Init->getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
6018 for (
auto *Field : ClassDecl->
fields()) {
6027 llvm::SmallPtrSetImpl<const CXXRecordDecl *> *DirectVirtualBases) {
6029 for (
const auto &VBase : ClassDecl->
vbases()) {
6030 auto *BaseClassDecl = VBase.getType()->getAsCXXRecordDecl();
6035 if (DirectVirtualBases && DirectVirtualBases->count(BaseClassDecl))
6044 PDiag(diag::err_access_dtor_vbase)
6045 << CT << VBase.getType(),
6048 CT, VBase.getType(), diag::err_access_dtor_vbase, 0,
6062 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
6064 !ClassDecl || ClassDecl->isInvalidDecl()) {
6076 const auto *RD =
Context.getBaseElementType(
T)->getAsCXXRecordDecl();
6113 if (
Diags.isLastDiagnosticIgnored())
6123 for (
const auto &M : FinalOverriders) {
6124 for (
const auto &SO : M.second) {
6130 if (SO.second.size() != 1)
6134 if (!
Method->isPureVirtual())
6137 if (!SeenPureMethods.insert(
Method).second)
6140 Diag(
Method->getLocation(), diag::note_pure_virtual_function)
6151struct AbstractUsageInfo {
6161 void DiagnoseAbstractType() {
6170struct CheckAbstractUsage {
6171 AbstractUsageInfo &Info;
6172 const NamedDecl *Ctx;
6174 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
6175 : Info(Info), Ctx(Ctx) {}
6179#define ABSTRACT_TYPELOC(CLASS, PARENT)
6180#define TYPELOC(CLASS, PARENT) \
6181 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break;
6182#include "clang/AST/TypeLocNodes.def"
6188 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
6203 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
6204 TemplateArgumentLoc TAL = TL.
getArgLoc(I);
6213#define CheckPolymorphic(Type) \
6214 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \
6215 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \
6230 return Visit(
Next, Sel);
6238 if (
T->isArrayType()) {
6243 if (CT != Info.AbstractType)
return;
6254 Info.DiagnoseAbstractType();
6258void AbstractUsageInfo::CheckType(
const NamedDecl *D, TypeLoc TL,
6260 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
6295 for (
auto *D : RD->
decls()) {
6296 if (D->isImplicit())
continue;
6299 if (
auto *FD = dyn_cast<FriendDecl>(D)) {
6300 D = FD->getFriendDecl();
6305 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
6307 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D)) {
6311 }
else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
6314 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
6316 }
else if (
auto *VTD = dyn_cast<VarTemplateDecl>(D)) {
6320 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6322 }
else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(D)) {
6333 assert(ClassAttr->
getKind() == attr::DLLExport);
6343 struct MarkingClassDllexported {
6354 ~MarkingClassDllexported() {
6357 } MarkingDllexportedContext(S, Class, ClassAttr->
getLocation());
6364 if (!
Member->hasAttr<DLLExportAttr>())
6369 auto *VD = dyn_cast<VarDecl>(
Member);
6370 if (VD && VD->getStorageClass() ==
SC_Static &&
6374 auto *MD = dyn_cast<CXXMethodDecl>(
Member);
6378 if (MD->isUserProvided()) {
6388 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6391 CD->getAttr<DLLExportAttr>()->getLocation(), CD);
6399 }
else if (MD->isExplicitlyDefaulted()) {
6408 }
else if (!MD->isTrivial() ||
6409 MD->isCopyAssignmentOperator() ||
6410 MD->isMoveAssignmentOperator()) {
6431 if (Class->isInvalidDecl())
6438 if (
auto *NestedClass = dyn_cast<CXXRecordDecl>(
Member)) {
6439 if (NestedClass->isThisDeclarationADefinition())
6445 auto *CD = dyn_cast<CXXConstructorDecl>(
Member);
6446 if (!CD || !CD->isDefaultConstructor())
6448 auto *
Attr = CD->getAttr<DLLExportAttr>();
6454 if (!Class->isDependentContext()) {
6459 if (LastExportedDefaultCtor) {
6461 diag::err_attribute_dll_ambiguous_default_ctor)
6463 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
6464 << CD->getDeclName();
6467 LastExportedDefaultCtor = CD;
6473 bool ErrorReported =
false;
6474 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6478 S.
Diag(TD->getLocation(),
6479 diag::err_cuda_device_builtin_surftex_cls_template)
6481 ErrorReported =
true;
6486 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(Class);
6488 S.
Diag(Class->getLocation(),
6489 diag::err_cuda_device_builtin_surftex_ref_decl)
6491 S.
Diag(Class->getLocation(),
6492 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6496 TD = SD->getSpecializedTemplate();
6500 unsigned N = Params->
size();
6503 reportIllegalClassTemplate(S, TD);
6505 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6509 reportIllegalClassTemplate(S, TD);
6511 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6515 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6516 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6517 reportIllegalClassTemplate(S, TD);
6519 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6527 bool ErrorReported =
false;
6528 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6532 S.
Diag(TD->getLocation(),
6533 diag::err_cuda_device_builtin_surftex_cls_template)
6535 ErrorReported =
true;
6540 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(Class);
6542 S.
Diag(Class->getLocation(),
6543 diag::err_cuda_device_builtin_surftex_ref_decl)
6545 S.
Diag(Class->getLocation(),
6546 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6550 TD = SD->getSpecializedTemplate();
6554 unsigned N = Params->
size();
6557 reportIllegalClassTemplate(S, TD);
6559 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6563 reportIllegalClassTemplate(S, TD);
6565 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6569 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6570 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6571 reportIllegalClassTemplate(S, TD);
6573 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6578 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(2));
6579 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6580 reportIllegalClassTemplate(S, TD);
6582 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6591 if (
Method->isUserProvided())
6602 if (
Context.getTargetInfo().shouldDLLImportComdatSymbols() && !ClassAttr) {
6603 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(
Class)) {
6604 if (
Attr *TemplateAttr =
6605 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
6607 A->setInherited(
true);
6620 if ((
Context.getTargetInfo().getCXXABI().isMicrosoft() ||
6621 Context.getTargetInfo().getTriple().isPS()) &&
6622 (!
Class->isExternallyVisible() &&
Class->hasExternalFormalLinkage())) {
6623 Class->dropAttrs<DLLExportAttr, DLLImportAttr>();
6627 if (!
Class->isExternallyVisible()) {
6628 Diag(
Class->getLocation(), diag::err_attribute_dll_not_extern)
6629 <<
Class << ClassAttr;
6633 if (
Context.getTargetInfo().shouldDLLImportComdatSymbols() &&
6644 diag::err_attribute_dll_member_of_dll_class)
6645 << MemberAttr << ClassAttr;
6646 Diag(ClassAttr->getLocation(), diag::note_previous_attribute);
6647 Member->setInvalidDecl();
6651 if (
Class->getDescribedClassTemplate())
6656 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
6661 const bool PropagatedImport =
6671 !
Context.getTargetInfo().getTriple().isOSCygMing()) {
6672 if (
auto *DEA =
Class->getAttr<DLLExportAttr>()) {
6673 Class->addAttr(DLLExportOnDeclAttr::Create(
Context, DEA->getLoc()));
6674 Class->dropAttr<DLLExportAttr>();
6684 if (ClassExported &&
getLangOpts().DllExportInlines) {
6687 if (
auto *S = dyn_cast<ConstructorUsingShadowDecl>(D))
6688 Shadows.push_back(S);
6710 if (
Member->hasAttr<ExcludeFromExplicitInstantiationAttr>())
6725 if (ClassExported &&
getLangOpts().DllExportInlines) {
6742 diag::warn_dllexport_inherited_ctor_unsupported)
6748 .areArgsDestroyedLeftToRightInCallee()) {
6749 bool HasCalleeCleanupParam =
false;
6751 if (P->needsDestruction(
Context)) {
6752 HasCalleeCleanupParam =
true;
6755 if (HasCalleeCleanupParam) {
6757 diag::warn_dllexport_inherited_ctor_unsupported)
6779 if (!
Context.getTargetInfo().shouldDLLImportComdatSymbols() &&
6782 if (
auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6783 !CD || !CD->getInheritedConstructor())
6790 auto *Ctor = dyn_cast<CXXConstructorDecl>(MD);
6807 if (VD && PropagatedImport)
6821 if (ClassExported) {
6833 Member->addAttr(NewAttr);
6843 "friend re-decl should not already have a DLLAttr");
6873 NewAttr->setInherited(
true);
6874 BaseTemplateSpec->
addAttr(NewAttr);
6878 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
6879 ImportAttr->setPropagatedToBaseTemplate();
6900 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
6905 diag::note_template_class_explicit_specialization_was_here)
6906 << BaseTemplateSpec;
6909 diag::note_template_class_instantiation_was_here)
6910 << BaseTemplateSpec;
6919struct DefaultedFunctionFPFeaturesRAII {
6922 : SavedFPFeatures(S) {
6929 ~DefaultedFunctionFPFeaturesRAII() =
default;
6963 llvm_unreachable(
"Invalid special member.");
6981 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
6982 bool DtorIsTrivialForCall =
false;
6993 CopyCtorIsTrivial =
true;
6995 CopyCtorIsTrivialForCall =
true;
6999 if (CD->isCopyConstructor() && !CD->isDeleted() &&
7000 !CD->isIneligibleOrNotSelected()) {
7001 if (CD->isTrivial())
7002 CopyCtorIsTrivial =
true;
7003 if (CD->isTrivialForCall())
7004 CopyCtorIsTrivialForCall =
true;
7012 DtorIsTrivialForCall =
true;
7014 if (!DD->isDeleted() && DD->isTrivialForCall())
7015 DtorIsTrivialForCall =
true;
7019 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
7033 uint64_t TypeSize = isAArch64 ? 128 : 64;
7045 bool HasNonDeletedCopyOrMove =
false;
7051 HasNonDeletedCopyOrMove =
true;
7058 HasNonDeletedCopyOrMove =
true;
7066 if (MD->isDeleted() || MD->isIneligibleOrNotSelected())
7069 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
7070 if (CD && CD->isCopyOrMoveConstructor())
7071 HasNonDeletedCopyOrMove =
true;
7075 if (!MD->isTrivialForCall())
7079 return HasNonDeletedCopyOrMove;
7090 bool IssuedDiagnostic =
false;
7093 if (!IssuedDiagnostic) {
7095 IssuedDiagnostic =
true;
7097 S.
Diag(O->getLocation(), diag::note_overridden_virtual_function);
7100 return IssuedDiagnostic;
7107 if (
Record->isAbstract() && !
Record->isInvalidDecl()) {
7108 AbstractUsageInfo Info(*
this,
Record);
7115 if (!
Record->isInvalidDecl() && !
Record->isDependentType() &&
7116 !
Record->isAggregate() && !
Record->hasUserDeclaredConstructor() &&
7118 bool Complained =
false;
7119 for (
const auto *F :
Record->fields()) {
7120 if (F->hasInClassInitializer() || F->isUnnamedBitField())
7123 if (F->getType()->isReferenceType() ||
7124 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
7126 Diag(
Record->getLocation(), diag::warn_no_constructor_for_refconst)
7131 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
7132 << F->getType()->isReferenceType()
7133 << F->getDeclName();
7138 if (
Record->getIdentifier()) {
7153 Record->hasUserDeclaredConstructor()) ||
7155 Diag(Element->getLocation(), diag::err_member_name_of_class)
7163 if (
Record->isPolymorphic() && !
Record->isDependentType()) {
7166 !
Record->hasAttr<FinalAttr>())
7168 diag::warn_non_virtual_dtor)
7172 if (
Record->isAbstract()) {
7173 if (FinalAttr *FA =
Record->getAttr<FinalAttr>()) {
7174 Diag(
Record->getLocation(), diag::warn_abstract_final_class)
7175 << FA->isSpelledAsSealed();
7181 if (!
Record->hasAttr<FinalAttr>()) {
7183 if (
const FinalAttr *FA = dtor->getAttr<FinalAttr>()) {
7184 Diag(FA->getLocation(), diag::warn_final_dtor_non_final_class)
7185 << FA->isSpelledAsSealed()
7188 (FA->isSpelledAsSealed() ?
" sealed" :
" final"));
7190 diag::note_final_dtor_non_final_class_silence)
7191 <<
Context.getCanonicalTagType(
Record) << FA->isSpelledAsSealed();
7197 if (
Record->hasAttr<TrivialABIAttr>())
7202 bool HasTrivialABI =
Record->hasAttr<TrivialABIAttr>();
7205 Record->setHasTrivialSpecialMemberForCall();
7215 auto CheckCompletedMemberFunction = [&](
CXXMethodDecl *MD) {
7226 MD->
isDeleted() ? diag::err_deleted_override
7227 : diag::err_non_deleted_override,
7229 return MD->isDeleted() != V->isDeleted();
7241 : diag::err_non_consteval_override,
7243 return MD->isConsteval() != V->isConsteval();
7252 auto CheckForDefaultedFunction = [&](
FunctionDecl *FD) ->
bool {
7259 DefaultedSecondaryComparisons.push_back(FD);
7267 if (!
Record->isInvalidDecl() &&
7268 Record->hasAttr<VTablePointerAuthenticationAttr>())
7273 bool Incomplete = CheckForDefaultedFunction(M);
7276 if (
Record->isDependentType())
7282 if (!M->isImplicit() && !M->isUserProvided()) {
7286 Record->finishedDefaultedOrDeletedMember(M);
7287 M->setTrivialForCall(
7291 Record->setTrivialForCallFlags(M);
7300 M->isUserProvided()) {
7301 M->setTrivialForCall(HasTrivialABI);
7302 Record->setTrivialForCallFlags(M);
7305 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
7306 M->hasAttr<DLLExportAttr>()) {
7312 M->dropAttr<DLLExportAttr>();
7314 if (M->hasAttr<DLLExportAttr>()) {
7320 bool EffectivelyConstexprDestructor =
true;
7325 llvm::SmallDenseSet<QualType> Visited;
7326 auto Check = [&Visited](
QualType T,
auto &&Check) ->
bool {
7327 if (!Visited.insert(
T->getCanonicalTypeUnqualified()).second)
7330 T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
7338 if (!Check(B.getType(), Check))
7341 if (!Check(FD->
getType(), Check))
7345 EffectivelyConstexprDestructor =
7353 M->isDefaulted() && M->isConstexpr() && M->size_overridden_methods() &&
7354 EffectivelyConstexprDestructor)
7358 CheckCompletedMemberFunction(M);
7367 CompleteMemberFunction(Dtor);
7369 bool HasMethodWithOverrideControl =
false,
7370 HasOverridingMethodWithoutOverrideControl =
false;
7371 for (
auto *D :
Record->decls()) {
7372 if (
auto *M = dyn_cast<CXXMethodDecl>(D)) {
7375 if (!
Record->isDependentType()) {
7381 if (M->hasAttr<OverrideAttr>()) {
7382 HasMethodWithOverrideControl =
true;
7383 }
else if (M->size_overridden_methods() > 0) {
7384 HasOverridingMethodWithoutOverrideControl =
true;
7387 if (M->isVirtualAsWritten() &&
Record->isEffectivelyFinal()) {
7388 Diag(M->getLocation(), diag::warn_unnecessary_virtual_specifier)
7395 CompleteMemberFunction(M);
7396 }
else if (
auto *F = dyn_cast<FriendDecl>(D)) {
7397 CheckForDefaultedFunction(
7398 dyn_cast_or_null<FunctionDecl>(F->getFriendDecl()));
7402 if (HasOverridingMethodWithoutOverrideControl) {
7403 bool HasInconsistentOverrideControl = HasMethodWithOverrideControl;
7404 for (
auto *M :
Record->methods())
7409 for (
FunctionDecl *FD : DefaultedSecondaryComparisons) {
7413 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD))
7414 CheckCompletedMemberFunction(MD);
7435 if (
Context.getLangOpts().getLayoutCompatibility() ==
7439 Diag(
Record->getLocation(), diag::warn_cxx_ms_struct);
7445 bool ClangABICompat4 =
7446 Context.getLangOpts().isCompatibleWith(LangOptions::ClangABI::Ver4);
7448 Context.getTargetInfo().getCallingConvKind(ClangABICompat4);
7453 if (
Record->getArgPassingRestrictions() !=
7455 Record->setArgPassingRestrictions(
7463 if (
Context.getTargetInfo().getCXXABI().areArgsDestroyedLeftToRightInCallee())
7464 Record->setParamDestroyedInCallee(
true);
7465 else if (
Record->hasNonTrivialDestructor())
7466 Record->setParamDestroyedInCallee(CanPass);
7475 if (
Record->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>())
7477 else if (
Record->hasAttr<CUDADeviceBuiltinTextureTypeAttr>())
7483 TypeAwareDecls{{OO_New, {}},
7486 {OO_Array_New, {}}};
7487 for (
auto *D :
Record->decls()) {
7494 auto CheckMismatchedTypeAwareAllocators =
7497 auto &NewDecls = TypeAwareDecls[NewKind];
7498 auto &DeleteDecls = TypeAwareDecls[DeleteKind];
7499 if (NewDecls.empty() == DeleteDecls.empty())
7502 Context.DeclarationNames.getCXXOperatorName(
7503 NewDecls.empty() ? DeleteKind : NewKind);
7505 Context.DeclarationNames.getCXXOperatorName(
7506 NewDecls.empty() ? NewKind : DeleteKind);
7508 diag::err_type_aware_allocator_missing_matching_operator)
7511 for (
auto MD : NewDecls)
7513 diag::note_unmatched_type_aware_allocator_declared)
7515 for (
auto MD : DeleteDecls)
7517 diag::note_unmatched_type_aware_allocator_declared)
7520 CheckMismatchedTypeAwareAllocators(OO_New, OO_Delete);
7521 CheckMismatchedTypeAwareAllocators(OO_Array_New, OO_Array_Delete);
7537 unsigned LHSQuals = 0;
7540 LHSQuals = FieldQuals;
7542 unsigned RHSQuals = FieldQuals;
7564 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
7570 : S(S), UseLoc(UseLoc) {
7571 bool DiagnosedMultipleConstructedBases =
false;
7577 for (
auto *D : Shadow->
redecls()) {
7578 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
7579 auto *DNominatedBase = DShadow->getNominatedBaseClass();
7580 auto *DConstructedBase = DShadow->getConstructedBaseClass();
7582 InheritedFromBases.insert(
7583 std::make_pair(DNominatedBase->getCanonicalDecl(),
7584 DShadow->getNominatedBaseClassShadowDecl()));
7585 if (DShadow->constructsVirtualBase())
7586 InheritedFromBases.insert(
7587 std::make_pair(DConstructedBase->getCanonicalDecl(),
7588 DShadow->getConstructedBaseClassShadowDecl()));
7590 assert(DNominatedBase == DConstructedBase);
7595 if (!ConstructedBase) {
7596 ConstructedBase = DConstructedBase;
7597 ConstructedBaseIntroducer = D->getIntroducer();
7598 }
else if (ConstructedBase != DConstructedBase &&
7600 if (!DiagnosedMultipleConstructedBases) {
7601 S.Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
7602 << Shadow->getTargetDecl();
7603 S.Diag(ConstructedBaseIntroducer->getLocation(),
7604 diag::note_ambiguous_inherited_constructor_using)
7606 DiagnosedMultipleConstructedBases = true;
7608 S.Diag(D->getIntroducer()->getLocation(),
7609 diag::note_ambiguous_inherited_constructor_using)
7610 << DConstructedBase;
7614 if (DiagnosedMultipleConstructedBases)
7615 Shadow->setInvalidDecl();
7621 std::pair<CXXConstructorDecl *, bool>
7623 auto It = InheritedFromBases.find(
Base->getCanonicalDecl());
7624 if (It == InheritedFromBases.end())
7625 return std::make_pair(
nullptr,
false);
7629 return std::make_pair(
7630 S.findInheritingConstructor(UseLoc, Ctor, It->second),
7631 It->second->constructsVirtualBase());
7634 return std::make_pair(Ctor,
false);
7651 if (InheritedCtor) {
7654 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
7656 return BaseCtor->isConstexpr();
7724 if (Ctor && ClassDecl->
isUnion())
7744 for (
const auto &B : ClassDecl->
bases()) {
7745 auto *BaseClassDecl = B.getType()->getAsCXXRecordDecl();
7749 InheritedCtor, Inherited))
7762 for (
const auto *F : ClassDecl->
fields()) {
7763 if (F->isInvalidDecl())
7766 F->hasInClassInitializer())
7769 if (
const RecordType *RecordTy = BaseType->getAsCanonical<RecordType>()) {
7770 auto *FieldRecDecl =
7773 BaseType.getCVRQualifiers(),
7774 ConstArg && !F->isMutable()))
7789struct ComputingExceptionSpec {
7792 ComputingExceptionSpec(Sema &S, FunctionDecl *FD, SourceLocation Loc)
7794 Sema::CodeSynthesisContext Ctx;
7800 ~ComputingExceptionSpec() {
7806static Sema::ImplicitExceptionSpecification
7810 Sema::InheritedConstructorInfo *ICI);
7812static Sema::ImplicitExceptionSpecification
7817static Sema::ImplicitExceptionSpecification
7822static Sema::ImplicitExceptionSpecification
7825 if (DFK.isSpecialMember())
7828 if (DFK.isComparison())
7830 DFK.asComparison());
7831 if (DFK.isPostfixOperator())
7833 S, Loc, FD, DFK.asPostfixOperator());
7836 assert(CD->getInheritedConstructor() &&
7837 "only defaulted functions and inherited constructors have implicit "
7840 S, Loc, CD->getInheritedConstructor().getShadowDecl());
7867 auto ESI = IES.getExceptionSpec();
7885 PT.getNonReferenceType()->getAsCXXRecordDecl()) {
7913 "not an explicitly-defaulted special member");
7923 bool HadError =
false;
7936 bool ShouldDeleteForTypeMismatch =
false;
7937 unsigned ExpectedParams = 1;
7949 if (DeleteOnTypeMismatch)
7950 ShouldDeleteForTypeMismatch =
true;
7960 bool CanHaveConstParam =
false;
7970 ReturnType =
Type->getReturnType();
7975 std::nullopt, RD,
false);
7976 DeclType =
Context.getAddrSpaceQualType(
7978 QualType ExpectedReturnType =
Context.getLValueReferenceType(DeclType);
7980 if (!
Context.hasSameType(ReturnType, ExpectedReturnType)) {
7981 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
7983 << ExpectedReturnType;
7989 if (DeleteOnTypeMismatch)
7990 ShouldDeleteForTypeMismatch =
true;
8007 if (!ExplicitObjectParameter.
isNull() &&
8010 Context.getCanonicalTagType(RD)))) {
8011 if (DeleteOnTypeMismatch)
8012 ShouldDeleteForTypeMismatch =
true;
8015 diag::err_defaulted_special_member_explicit_object_mismatch)
8028 bool HasConstParam =
false;
8029 if (ExpectedParams &&
ArgType->isReferenceType()) {
8035 if (DeleteOnTypeMismatch)
8036 ShouldDeleteForTypeMismatch =
true;
8039 diag::err_defaulted_special_member_volatile_param)
8045 if (HasConstParam && !CanHaveConstParam) {
8046 if (DeleteOnTypeMismatch)
8047 ShouldDeleteForTypeMismatch =
true;
8051 diag::err_defaulted_special_member_copy_const_param)
8057 diag::err_defaulted_special_member_move_const_param)
8062 }
else if (ExpectedParams) {
8066 "unexpected non-ref argument");
8100 diag::err_incorrect_defaulted_constexpr_with_vb)
8102 for (
const auto &I : RD->
vbases())
8103 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here);
8121 if (!
Type->hasExceptionSpec()) {
8130 Context.getFunctionType(ReturnType,
Type->getParamTypes(), EPI));
8139 if (ShouldDeleteForTypeMismatch) {
8144 Diag(DefaultLoc, diag::note_replace_equals_default_to_delete)
8148 if (ShouldDeleteForTypeMismatch && !HadError) {
8150 diag::warn_cxx17_compat_defaulted_method_type_mismatch)
8157 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
8158 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
8180template<
typename Derived,
typename ResultList,
typename Result,
8182class DefaultedComparisonVisitor {
8186 : S(S), RD(RD), FD(FD), DCK(DCK) {
8190 Fns.assign(Info->getUnqualifiedLookups().begin(),
8191 Info->getUnqualifiedLookups().end());
8195 ResultList visit() {
8204 llvm_unreachable(
"not a defaulted comparison");
8208 getDerived().visitSubobjects(Results, RD, ParamLvalType.
getQualifiers());
8213 Results.add(getDerived().visitExpandedSubobject(
8214 ParamLvalType, getDerived().getCompleteObject()));
8217 llvm_unreachable(
"");
8221 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
8227 bool visitSubobjects(ResultList &Results, CXXRecordDecl *
Record,
8231 for (CXXBaseSpecifier &Base :
Record->bases())
8232 if (Results.add(getDerived().visitSubobject(
8234 getDerived().getBase(&Base))))
8238 for (FieldDecl *Field :
Record->fields()) {
8241 if (
Field->isUnnamedBitField())
8243 if (
Field->isInvalidDecl())
8246 if (
Field->isAnonymousStructOrUnion()) {
8247 if (visitSubobjects(Results,
Field->getType()->getAsCXXRecordDecl(),
8254 Qualifiers FieldQuals = Quals;
8255 if (
Field->isMutable())
8257 QualType FieldType =
8260 if (Results.add(getDerived().visitSubobject(
8261 FieldType, getDerived().getField(Field))))
8269 Result visitSubobject(QualType
Type, Subobject Subobj) {
8272 if (
auto *CAT = dyn_cast_or_null<ConstantArrayType>(AT))
8273 return getDerived().visitSubobjectArray(CAT->getElementType(),
8274 CAT->getSize(), Subobj);
8275 return getDerived().visitExpandedSubobject(
Type, Subobj);
8278 Result visitSubobjectArray(QualType
Type,
const llvm::APInt &Size,
8280 return getDerived().visitSubobject(
Type, Subobj);
8288 UnresolvedSet<16> Fns;
8293struct DefaultedComparisonInfo {
8298 static DefaultedComparisonInfo deleted() {
8299 DefaultedComparisonInfo
Deleted;
8304 bool add(
const DefaultedComparisonInfo &R) {
8314struct DefaultedComparisonSubobject {
8322class DefaultedComparisonAnalyzer
8323 :
public DefaultedComparisonVisitor<DefaultedComparisonAnalyzer,
8324 DefaultedComparisonInfo,
8325 DefaultedComparisonInfo,
8326 DefaultedComparisonSubobject> {
8328 enum DiagnosticKind { NoDiagnostics, ExplainDeleted, ExplainConstexpr };
8331 DiagnosticKind Diagnose;
8334 using Base = DefaultedComparisonVisitor;
8335 using Result = DefaultedComparisonInfo;
8336 using Subobject = DefaultedComparisonSubobject;
8340 DefaultedComparisonAnalyzer(Sema &S, CXXRecordDecl *RD, FunctionDecl *FD,
8342 DiagnosticKind Diagnose = NoDiagnostics)
8343 :
Base(S, RD, FD, DCK), Diagnose(Diagnose) {}
8346 if ((DCK == DefaultedComparisonKind::Equal ||
8347 DCK == DefaultedComparisonKind::ThreeWay) &&
8352 if (Diagnose == ExplainDeleted) {
8356 return Result::deleted();
8359 return Base::visit();
8363 Subobject getCompleteObject() {
8364 return Subobject{Subobject::CompleteObject, RD, FD->
getLocation()};
8367 Subobject getBase(CXXBaseSpecifier *Base) {
8368 return Subobject{Subobject::Base,
Base->getType()->getAsCXXRecordDecl(),
8369 Base->getBaseTypeLoc()};
8372 Subobject getField(FieldDecl *Field) {
8373 return Subobject{Subobject::Member,
Field,
Field->getLocation()};
8376 Result visitExpandedSubobject(QualType
Type, Subobject Subobj) {
8380 if (
Type->isReferenceType()) {
8381 if (Diagnose == ExplainDeleted) {
8382 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_reference_member)
8385 return Result::deleted();
8390 Expr *Args[] = {&Xi, &Xi};
8394 assert(OO !=
OO_None &&
"not an overloaded operator!");
8395 return visitBinaryOperator(OO, Args, Subobj);
8401 OverloadCandidateSet *SpaceshipCandidates =
nullptr) {
8405 OverloadCandidateSet CandidateSet(
8407 OverloadCandidateSet::OperatorRewriteInfo(
8409 !SpaceshipCandidates));
8414 CandidateSet.exclude(FD);
8416 if (Args[0]->
getType()->isOverloadableType())
8427 switch (CandidateSet.BestViableFunction(S, FD->
getLocation(), Best)) {
8433 if ((DCK == DefaultedComparisonKind::NotEqual ||
8434 DCK == DefaultedComparisonKind::Relational) &&
8435 !Best->RewriteKind) {
8436 if (Diagnose == ExplainDeleted) {
8437 if (Best->Function) {
8438 S.
Diag(Best->Function->getLocation(),
8439 diag::note_defaulted_comparison_not_rewritten_callee)
8442 assert(Best->Conversions.size() == 2 &&
8443 Best->Conversions[0].isUserDefined() &&
8444 "non-user-defined conversion from class to built-in "
8446 S.
Diag(Best->Conversions[0]
8447 .UserDefined.FoundConversionFunction.getDecl()
8449 diag::note_defaulted_comparison_not_rewritten_conversion)
8453 return Result::deleted();
8463 CXXRecordDecl *ArgClass = Args[0]->getType()->getAsCXXRecordDecl();
8464 if (ArgClass && Best->FoundDecl.getDecl() &&
8465 Best->FoundDecl.getDecl()->isCXXClassMember()) {
8466 QualType ObjectType = Subobj.Kind == Subobject::Member
8467 ? Args[0]->getType()
8470 ArgClass, Best->FoundDecl, ObjectType, Subobj.Loc,
8471 Diagnose == ExplainDeleted
8472 ? S.
PDiag(diag::note_defaulted_comparison_inaccessible)
8473 << FD << Subobj.Kind << Subobj.Decl
8475 return Result::deleted();
8478 bool NeedsDeducing =
8481 if (FunctionDecl *BestFD = Best->Function) {
8486 assert(!BestFD->isDeleted() &&
"wrong overload resolution result");
8488 if (Diagnose == ExplainConstexpr && !BestFD->isConstexpr()) {
8489 if (Subobj.Kind != Subobject::CompleteObject)
8490 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_not_constexpr)
8491 << Subobj.
Kind << Subobj.Decl;
8492 S.
Diag(BestFD->getLocation(),
8493 diag::note_defaulted_comparison_not_constexpr_here);
8495 return Result::deleted();
8497 R.Constexpr &= BestFD->isConstexpr();
8499 if (NeedsDeducing) {
8504 if (BestFD->getReturnType()->isUndeducedType() &&
8510 if (Diagnose == NoDiagnostics) {
8513 diag::err_defaulted_comparison_cannot_deduce_undeduced_auto)
8514 << Subobj.
Kind << Subobj.Decl;
8517 diag::note_defaulted_comparison_cannot_deduce_undeduced_auto)
8518 << Subobj.
Kind << Subobj.Decl;
8519 S.
Diag(BestFD->getLocation(),
8520 diag::note_defaulted_comparison_cannot_deduce_callee)
8521 << Subobj.
Kind << Subobj.Decl;
8523 return Result::deleted();
8526 BestFD->getCallResultType());
8528 if (Diagnose == ExplainDeleted) {
8529 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_cannot_deduce)
8530 << Subobj.
Kind << Subobj.Decl
8531 << BestFD->getCallResultType().withoutLocalFastQualifiers();
8532 S.
Diag(BestFD->getLocation(),
8533 diag::note_defaulted_comparison_cannot_deduce_callee)
8534 << Subobj.
Kind << Subobj.Decl;
8536 return Result::deleted();
8538 R.Category = Info->Kind;
8541 QualType
T = Best->BuiltinParamTypes[0];
8542 assert(
T == Best->BuiltinParamTypes[1] &&
8543 "builtin comparison for different types?");
8544 assert(Best->BuiltinParamTypes[2].isNull() &&
8545 "invalid builtin comparison");
8550 if (Diagnose == ExplainDeleted) {
8552 diag::note_defaulted_comparison_vector_types)
8554 S.
Diag(Subobj.Decl->getLocation(), diag::note_declared_at);
8556 return Result::deleted();
8559 if (NeedsDeducing) {
8560 std::optional<ComparisonCategoryType> Cat =
8562 assert(Cat &&
"no category for builtin comparison?");
8573 if (Diagnose == ExplainDeleted) {
8576 Kind = OO == OO_EqualEqual ? 1 : 2;
8577 CandidateSet.NoteCandidates(
8579 Subobj.Loc, S.
PDiag(diag::note_defaulted_comparison_ambiguous)
8580 << FD << Kind << Subobj.Kind << Subobj.Decl),
8583 R = Result::deleted();
8587 if (Diagnose == ExplainDeleted) {
8588 if ((DCK == DefaultedComparisonKind::NotEqual ||
8589 DCK == DefaultedComparisonKind::Relational) &&
8590 !Best->RewriteKind) {
8591 S.
Diag(Best->Function->getLocation(),
8592 diag::note_defaulted_comparison_not_rewritten_callee)
8595 S.
Diag(Subobj.Loc, diag::note_defaulted_function_calls_deleted)
8596 << FD << 4 << Subobj.
Kind << Subobj.Decl;
8600 R = Result::deleted();
8606 if (OO == OO_Spaceship &&
8610 if (!
R.add(visitBinaryOperator(OO_EqualEqual, Args, Subobj,
8612 R.add(visitBinaryOperator(OO_Less, Args, Subobj, &CandidateSet));
8616 if (Diagnose == ExplainDeleted) {
8617 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_no_viable_function)
8618 << FD << (OO == OO_EqualEqual || OO == OO_ExclaimEqual)
8619 << Subobj.
Kind << Subobj.Decl;
8623 if (SpaceshipCandidates) {
8624 SpaceshipCandidates->NoteCandidates(
8629 diag::note_defaulted_comparison_no_viable_function_synthesized)
8630 << (OO == OO_EqualEqual ? 0 : 1);
8633 CandidateSet.NoteCandidates(
8638 R = Result::deleted();
8647struct StmtListResult {
8648 bool IsInvalid =
false;
8649 llvm::SmallVector<Stmt*, 16> Stmts;
8652 IsInvalid |= S.isInvalid();
8655 Stmts.push_back(S.get());
8662class DefaultedComparisonSynthesizer
8663 :
public DefaultedComparisonVisitor<DefaultedComparisonSynthesizer,
8664 StmtListResult, StmtResult,
8665 std::pair<ExprResult, ExprResult>> {
8667 unsigned ArrayDepth = 0;
8670 using Base = DefaultedComparisonVisitor;
8671 using ExprPair = std::pair<ExprResult, ExprResult>;
8675 DefaultedComparisonSynthesizer(Sema &S, CXXRecordDecl *RD, FunctionDecl *FD,
8677 SourceLocation BodyLoc)
8678 :
Base(S, RD, FD, DCK), Loc(BodyLoc) {}
8682 Sema::CompoundScopeRAII CompoundScope(S);
8684 StmtListResult Stmts = visit();
8685 if (Stmts.IsInvalid)
8690 case DefaultedComparisonKind::None:
8691 llvm_unreachable(
"not a defaulted comparison");
8693 case DefaultedComparisonKind::Equal: {
8702 auto OldStmts = std::move(Stmts.Stmts);
8703 Stmts.Stmts.clear();
8706 auto FinishCmp = [&] {
8707 if (Expr *Prior = CmpSoFar.
get()) {
8709 if (RetVal.
isUnset() && Stmts.Stmts.empty())
8712 else if (Stmts.add(buildIfNotCondReturnFalse(Prior)))
8718 for (Stmt *EAsStmt : llvm::reverse(OldStmts)) {
8719 Expr *E = dyn_cast<Expr>(EAsStmt);
8722 if (FinishCmp() || Stmts.add(EAsStmt))
8731 CmpSoFar = S.CreateBuiltinBinOp(Loc, BO_LAnd, E, CmpSoFar.
get());
8737 std::reverse(Stmts.Stmts.begin(), Stmts.Stmts.end());
8740 RetVal = S.ActOnCXXBoolLiteral(Loc, tok::kw_true);
8744 case DefaultedComparisonKind::ThreeWay: {
8748 ComparisonCategoryType::StrongOrdering, Loc,
8749 Sema::ComparisonCategoryUsage::DefaultedOperator);
8752 VarDecl *EqualVD = S.Context.CompCategories.getInfoForType(
StrongOrdering)
8753 .getValueInfo(ComparisonCategoryResult::Equal)
8755 RetVal = getDecl(EqualVD);
8758 RetVal = buildStaticCastToR(RetVal.
get());
8762 case DefaultedComparisonKind::NotEqual:
8763 case DefaultedComparisonKind::Relational:
8764 RetVal =
cast<Expr>(Stmts.Stmts.pop_back_val());
8771 StmtResult ReturnStmt = S.BuildReturnStmt(Loc, RetVal.
get());
8772 if (ReturnStmt.isInvalid())
8774 Stmts.Stmts.push_back(ReturnStmt.get());
8776 return S.ActOnCompoundStmt(Loc, Loc, Stmts.Stmts,
false);
8781 return S.BuildDeclarationNameExpr(
8782 CXXScopeSpec(), DeclarationNameInfo(VD->
getDeclName(), Loc), VD);
8790 ExprPair getCompleteObject() {
8793 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD);
8794 MD && MD->isImplicitObjectMemberFunction()) {
8796 LHS = S.ActOnCXXThis(Loc);
8798 LHS = S.CreateBuiltinUnaryOp(Loc, UO_Deref, LHS.
get());
8800 LHS = getParam(Param++);
8807 ExprPair getBase(CXXBaseSpecifier *Base) {
8808 ExprPair Obj = getCompleteObject();
8809 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8812 const auto CastToBase = [&](Expr *E) {
8813 QualType ToType = S.Context.getQualifiedType(
8815 return S.ImpCastExprToType(E, ToType, CK_DerivedToBase,
VK_LValue, &Path);
8817 return {CastToBase(Obj.first.get()), CastToBase(Obj.second.get())};
8820 ExprPair getField(FieldDecl *Field) {
8821 ExprPair Obj = getCompleteObject();
8822 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8826 DeclarationNameInfo NameInfo(
Field->getDeclName(), Loc);
8827 return {S.BuildFieldReferenceExpr(Obj.first.get(),
false, Loc,
8828 CXXScopeSpec(), Field,
Found, NameInfo),
8829 S.BuildFieldReferenceExpr(Obj.second.get(),
false, Loc,
8830 CXXScopeSpec(), Field,
Found, NameInfo)};
8840 ExprResult NotCond = S.CreateBuiltinUnaryOp(Loc, UO_LNot, Cond.
get());
8845 assert(!
False.isInvalid() &&
"should never fail");
8847 if (ReturnFalse.isInvalid())
8850 return S.ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc,
nullptr,
8851 S.ActOnCondition(
nullptr, Loc, NotCond.
get(),
8852 Sema::ConditionKind::Boolean),
8853 Loc, ReturnFalse.get(), SourceLocation(),
nullptr);
8858 QualType SizeType = S.Context.getSizeType();
8859 Size =
Size.zextOrTrunc(S.Context.getTypeSize(SizeType));
8862 IdentifierInfo *IterationVarName =
nullptr;
8865 llvm::raw_svector_ostream
OS(Str);
8866 OS <<
"i" << ArrayDepth;
8867 IterationVarName = &S.Context.Idents.get(
OS.str());
8870 S.Context, S.CurContext, Loc, Loc, IterationVarName, SizeType,
8871 S.Context.getTrivialTypeSourceInfo(SizeType, Loc),
SC_None);
8872 llvm::APInt
Zero(S.Context.getTypeSize(SizeType), 0);
8875 Stmt *
Init =
new (S.Context) DeclStmt(DeclGroupRef(IterationVar), Loc, Loc);
8877 auto IterRef = [&] {
8879 CXXScopeSpec(), DeclarationNameInfo(IterationVarName, Loc),
8881 assert(!Ref.
isInvalid() &&
"can't reference our own variable?");
8887 Loc, BO_NE, IterRef(),
8889 assert(!Cond.
isInvalid() &&
"should never fail");
8892 ExprResult Inc = S.CreateBuiltinUnaryOp(Loc, UO_PreInc, IterRef());
8893 assert(!
Inc.isInvalid() &&
"should never fail");
8899 return S.CreateBuiltinArraySubscriptExpr(E.get(), Loc, IterRef(), Loc);
8901 Subobj.first = Index(Subobj.first);
8902 Subobj.second = Index(Subobj.second);
8909 if (Substmt.isInvalid())
8915 if (Expr *ElemCmp = dyn_cast<Expr>(Substmt.get())) {
8916 assert(DCK == DefaultedComparisonKind::Equal &&
8917 "should have non-expression statement");
8918 Substmt = buildIfNotCondReturnFalse(ElemCmp);
8919 if (Substmt.isInvalid())
8924 return S.ActOnForStmt(Loc, Loc,
Init,
8925 S.ActOnCondition(
nullptr, Loc, Cond.
get(),
8926 Sema::ConditionKind::Boolean),
8927 S.MakeFullDiscardedValueExpr(
Inc.get()), Loc,
8932 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8938 if (
Type->isOverloadableType())
8939 Op = S.CreateOverloadedBinOp(Loc, Opc, Fns, Obj.first.get(),
8940 Obj.second.get(),
true,
8943 Op = S.CreateBuiltinBinOp(Loc, Opc, Obj.first.get(), Obj.second.get());
8948 case DefaultedComparisonKind::None:
8949 llvm_unreachable(
"not a defaulted comparison");
8951 case DefaultedComparisonKind::Equal:
8954 Op = S.PerformContextuallyConvertToBool(Op.
get());
8959 case DefaultedComparisonKind::ThreeWay: {
8964 Op = buildStaticCastToR(Op.
get());
8969 IdentifierInfo *Name = &S.Context.Idents.get(
"cmp");
8972 S.Context.getTrivialTypeSourceInfo(R, Loc),
SC_None);
8973 S.AddInitializerToDecl(VD, Op.
get(),
false);
8974 Stmt *InitStmt =
new (S.Context) DeclStmt(DeclGroupRef(VD), Loc, Loc);
8980 llvm::APInt ZeroVal(S.Context.getIntWidth(S.Context.IntTy), 0);
8985 Comp = S.CreateOverloadedBinOp(Loc, BO_NE, Fns, VDRef.
get(),
Zero,
true,
8988 Comp = S.CreateBuiltinBinOp(Loc, BO_NE, VDRef.
get(),
Zero);
8989 if (
Comp.isInvalid())
8991 Sema::ConditionResult Cond = S.ActOnCondition(
8992 nullptr, Loc,
Comp.get(), Sema::ConditionKind::Boolean);
8997 VDRef = getDecl(VD);
9000 StmtResult ReturnStmt = S.BuildReturnStmt(Loc, VDRef.
get());
9001 if (ReturnStmt.isInvalid())
9005 return S.ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc, InitStmt, Cond,
9006 Loc, ReturnStmt.get(),
9007 SourceLocation(),
nullptr);
9010 case DefaultedComparisonKind::NotEqual:
9011 case DefaultedComparisonKind::Relational:
9016 llvm_unreachable(
"");
9022 assert(!
R->isUndeducedType() &&
"type should have been deduced already");
9027 return S.BuildCXXNamedCast(Loc, tok::kw_static_cast,
9028 S.Context.getTrivialTypeSourceInfo(R, Loc), E,
9029 SourceRange(Loc, Loc), SourceRange(Loc, Loc));
9040 Self.LookupOverloadedOperatorName(OO, S, Operators);
9053 if (Op == OO_Spaceship) {
9054 Lookup(OO_ExclaimEqual);
9056 Lookup(OO_EqualEqual);
9087 assert(!MD->isStatic() &&
"comparison function cannot be a static member");
9089 if (MD->getRefQualifier() ==
RQ_RValue) {
9090 Diag(MD->getLocation(), diag::err_ref_qualifier_comparison_operator);
9096 MD->setType(
Context.getFunctionType(FPT->getReturnType(),
9097 FPT->getParamTypes(), EPI));
9103 QualType T = MD->getFunctionObjectParameterReferenceType();
9104 if (!
T.getNonReferenceType().isConstQualified() &&
9105 (MD->isImplicitObjectMemberFunction() ||
T->isLValueReferenceType())) {
9107 if (MD->isExplicitObjectMemberFunction()) {
9108 Loc = MD->getParamDecl(0)->getBeginLoc();
9110 MD->getParamDecl(0)->getExplicitObjectParamThisLoc());
9112 Loc = MD->getLocation();
9118 if (!MD->isImplicit()) {
9119 Diag(Loc, diag::err_defaulted_comparison_non_const)
9124 if (MD->isExplicitObjectMemberFunction()) {
9125 assert(
T->isLValueReferenceType());
9126 MD->getParamDecl(0)->setType(
Context.getLValueReferenceType(
9127 T.getNonReferenceType().withConst()));
9132 MD->setType(
Context.getFunctionType(FPT->getReturnType(),
9133 FPT->getParamTypes(), EPI));
9137 if (MD->isVolatile()) {
9138 Diag(MD->getLocation(), diag::err_volatile_comparison_operator);
9144 MD->setType(
Context.getFunctionType(FPT->getReturnType(),
9145 FPT->getParamTypes(), EPI));
9151 (IsMethod ? 1 : 2)) {
9155 <<
int(IsMethod) <<
int(DCK);
9161 QualType ParmTy = Param->getType();
9168 ExpectedTy =
Context.getCanonicalTagType(RD);
9170 CTy = Ref->getPointeeType();
9180 RD = CTy->getAsCXXRecordDecl();
9181 Ok &= RD !=
nullptr;
9195 <<
int(DCK) << ParmTy << RefTy <<
int(!IsMethod) << PlainTy
9196 << Param->getSourceRange();
9198 assert(!IsMethod &&
"should know expected type for method");
9200 diag::err_defaulted_comparison_param_unknown)
9201 <<
int(DCK) << ParmTy << Param->getSourceRange();
9207 Diag(FD->
getLocation(), diag::err_defaulted_comparison_param_mismatch)
9209 << ParmTy << Param->getSourceRange();
9214 assert(RD &&
"must have determined class");
9223 diag::err_defaulted_comparison_not_friend,
int(DCK),
9228 return declaresSameEntity(F->getFriendDecl(), FD);
9231 <<
int(DCK) <<
int(0) << RD;
9243 Diag(FD->
getLocation(), diag::err_defaulted_comparison_return_type_not_bool)
9253 RT->getContainedDeducedType() &&
9255 RT->getContainedAutoType()->isConstrained())) {
9257 diag::err_defaulted_comparison_deduced_return_type_not_auto)
9269 DefaultedComparisonInfo Info =
9270 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK).visit();
9284 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
9285 DefaultedComparisonAnalyzer::ExplainDeleted)
9296 diag::note_previous_declaration);
9308 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
9309 DefaultedComparisonAnalyzer::ExplainDeleted)
9331 Context.adjustDeducedFunctionResultType(
9359 Diag(FD->
getBeginLoc(), diag::err_defaulted_comparison_constexpr_mismatch)
9361 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
9362 DefaultedComparisonAnalyzer::ExplainConstexpr)
9383 EPI.ExceptionSpec.SourceDecl = FD;
9385 FPT->getParamTypes(), EPI));
9400 EqualEqual->setImplicit();
9419 Scope.addContextNote(UseLoc);
9421 DefaultedFunctionFPFeaturesRAII RestoreFP(S, FD);
9427 StmtResult Body = BuildBody(BodyLoc);
9428 if (Body.isInvalid()) {
9441 L->CompletedImplicitDefinition(FD);
9450 CXXRecordDecl *RD = PT.getNonReferenceType()->getAsCXXRecordDecl();
9451 return DefaultedComparisonSynthesizer(*
this, RD, FD, DCK, BodyLoc).build();
9463 ComputingExceptionSpec CES(S, FD, Loc);
9488 StmtResult Body = BuildBody(BodyLoc);
9489 if (!Body.isInvalid())
9501static Sema::ImplicitExceptionSpecification
9510 return DefaultedComparisonSynthesizer(S, RD, FD, DCK, BodyLoc).build();
9521struct DefaultedPostfixOperatorInfo {
9533 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
9534 return MD->getFunctionObjectParameterReferenceType();
9548 llvm::function_ref<
void(
const FunctionDecl *)> CheckConstexpr) {
9550 auto InaccessibleDiag = [&](
unsigned Step) {
9552 ? S.
PDiag(diag::note_defaulted_postfix_operator_inaccessible)
9564 Seq.Diagnose(S, Entity, InitKind, Obj);
9571 RD, Step.Function.FoundDecl,
C, Loc,
9572 InaccessibleDiag(diag::DefaultedPostfixOperatorStep::Constructor)))
9574 CheckConstexpr(Step.Function.Function);
9580 if (Dtor->isDeleted()) {
9582 S.
Diag(Loc, diag::note_defaulted_function_calls_deleted)
9583 << FD << diag::DefaultedPostfixOperatorStep::Destructor
9591 InaccessibleDiag(diag::DefaultedPostfixOperatorStep::Destructor));
9600static DefaultedPostfixOperatorInfo
9604 DefaultedPostfixOperatorInfo Info;
9617 Expr *Args[] = {&Obj};
9620 Info.Deleted =
true;
9623 auto InaccessibleDiag = [&](
unsigned Step) {
9625 ? S.
PDiag(diag::note_defaulted_postfix_operator_inaccessible)
9629 auto NoteCallsDeleted = [&](
unsigned Step,
FunctionDecl *Callee) {
9632 S.
Diag(Loc, diag::note_defaulted_function_calls_deleted)
9637 auto CheckConstexpr = [&](
const FunctionDecl *Callee) {
9638 if (!Callee->isConstexpr())
9639 Info.Constexpr =
false;
9652 S, FD, RD,
C, &Obj, Diagnose, CheckConstexpr))
9659 unsigned PrefixStep =
9660 IsIncrement ? diag::DefaultedPostfixOperatorStep::PrefixIncrement
9661 : diag::DefaultedPostfixOperatorStep::PrefixDecrement;
9664 Fns.
assign(DFI->getUnqualifiedLookups().begin(),
9665 DFI->getUnqualifiedLookups().end());
9668 CandidateSet, IsIncrement ? OO_PlusPlus : OO_MinusMinus, Fns, Args);
9676 if (RD && Best->FoundDecl.getDecl() &&
9679 InaccessibleDiag(PrefixStep)))
9681 CheckConstexpr(Prefix);
9682 }
else if (!Best->Conversions.empty() &&
9683 Best->Conversions[0].isUserDefined()) {
9685 CheckConstexpr(Best->Conversions[0].UserDefined.ConversionFunction);
9693 Loc, S.
PDiag(diag::note_defaulted_postfix_operator_ambiguous)
9694 << FD << !IsIncrement <<
C),
9699 NoteCallsDeleted(PrefixStep, Best->Function);
9707 S.
Diag(Loc, diag::note_defaulted_postfix_operator_no_viable)
9708 << FD << !IsIncrement <<
C;
9718 "not a defaulted postfix operator");
9733 "lookup scope is not equivalent to the function-body");
9751 auto *MD = dyn_cast<CXXMethodDecl>(FD);
9768 assert((
C->isRecordType() ||
C->isEnumeralType()) &&
9769 "postfix operator for a non-class, non-enumeration type");
9774 !
Context.hasSameUnqualifiedType(Referent,
C) ||
9776 if (MD && MD->isImplicitObjectMemberFunction()) {
9779 Diag(MD->getLocation(), diag::err_defaulted_postfix_operator_const)
9783 diag::err_defaulted_postfix_operator_param)
9784 << (int)Kind << !MD << FirstParamType
9794 diag::err_defaulted_postfix_operator_deduced_return_type)
9800 if (!
Context.hasSameType(ReturnType,
C)) {
9801 Diag(FD->
getLocation(), diag::err_defaulted_postfix_operator_return_type)
9808 diag::err_defaulted_postfix_operator_incomplete,
9813 DefaultedPostfixOperatorInfo Info =
9834 diag::err_non_first_default_postfix_operator_deletes)
9845 diag::err_non_first_default_postfix_operator_in_class)
9848 diag::note_previous_declaration);
9858 Diag(FD->
getLocation(), diag::warn_defaulted_postfix_operator_deleted)
9907 EPI.ExceptionSpec.SourceDecl = FD;
9909 FPT->getParamTypes(), EPI));
9933 auto BuildObject = [&]() ->
Expr * {
9934 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD);
9935 MD && MD->isImplicitObjectMemberFunction()) {
9937 assert(
This.isUsable() &&
"no 'this' in an implicit object member");
9944 assert(!
Invalid &&
"invalid use of a parameter in its function's body");
9954 Expr *InitArgs[] = {BuildObject()};
9963 assert(TmpStmt.isUsable() &&
"failed to build a declaration statement");
9966 Expr *Obj = BuildObject();
9971 Fns.
assign(DFI->getUnqualifiedLookups().begin(),
9972 DFI->getUnqualifiedLookups().end());
9978 if (PrefixStmt.isInvalid())
9984 if (Return.isInvalid())
9991 Stmt *Stmts[] = {TmpStmt.get(), PrefixStmt.get(), Return.get()};
10023 for (
auto &Check : Overriding)
10035template<
typename Derived>
10036struct SpecialMemberVisitor {
10043 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
10047 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
10052 IsConstructor =
true;
10056 IsAssignment =
true;
10061 llvm_unreachable(
"invalid special member kind");
10065 if (const ReferenceType *RT =
10066 MD->getNonObjectParameter(0)->getType()->getAs<ReferenceType>())
10067 ConstArg = RT->getPointeeType().isConstQualified();
10071 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
10074 bool isMove()
const {
10075 return CSM == CXXSpecialMemberKind::MoveConstructor ||
10076 CSM == CXXSpecialMemberKind::MoveAssignment;
10080 Sema::SpecialMemberOverloadResult lookupIn(CXXRecordDecl *
Class,
10081 unsigned Quals,
bool IsMutable) {
10083 ConstArg && !IsMutable);
10088 Sema::SpecialMemberOverloadResult lookupInheritedCtor(CXXRecordDecl *
Class) {
10091 assert(CSM == CXXSpecialMemberKind::DefaultConstructor);
10100 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
10103 static SourceLocation getSubobjectLoc(Subobject Subobj) {
10106 if (
auto *B = dyn_cast<CXXBaseSpecifier *>(Subobj))
10107 return B->getBaseTypeLoc();
10112 enum BasesToVisit {
10114 VisitNonVirtualBases,
10119 VisitPotentiallyConstructedBases,
10125 bool visit(BasesToVisit Bases) {
10128 if (Bases == VisitPotentiallyConstructedBases)
10129 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
10131 for (
auto &B : RD->
bases())
10132 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
10133 getDerived().visitBase(&B))
10136 if (Bases == VisitAllBases)
10137 for (
auto &B : RD->
vbases())
10138 if (getDerived().visitBase(&B))
10141 for (
auto *F : RD->
fields())
10142 if (!F->isInvalidDecl() && !F->isUnnamedBitField() &&
10143 getDerived().visitField(F))
10152struct SpecialMemberDeletionInfo
10153 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
10156 SourceLocation Loc;
10158 bool AllFieldsAreConst;
10160 SpecialMemberDeletionInfo(Sema &S, CXXMethodDecl *MD,
10162 Sema::InheritedConstructorInfo *ICI,
bool Diagnose)
10163 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
10164 Loc(MD->getLocation()), AllFieldsAreConst(
true) {}
10169 return ICI ? CXXSpecialMemberKind::Invalid : CSM;
10172 bool shouldDeleteForVariantObjCPtrMember(FieldDecl *FD, QualType FieldType);
10174 bool shouldDeleteForVariantPtrAuthMember(
const FieldDecl *FD);
10176 bool visitBase(CXXBaseSpecifier *Base) {
return shouldDeleteForBase(Base); }
10177 bool visitField(FieldDecl *Field) {
return shouldDeleteForField(Field); }
10179 bool shouldDeleteForBase(CXXBaseSpecifier *Base);
10180 bool shouldDeleteForField(FieldDecl *FD);
10181 bool shouldDeleteForAllConstMembers();
10183 bool shouldDeleteForClassSubobject(CXXRecordDecl *
Class, Subobject Subobj,
10185 bool shouldDeleteForSubobjectCall(Subobject Subobj,
10186 Sema::SpecialMemberOverloadResult SMOR,
10187 bool IsDtorCallInCtor);
10189 bool isAccessible(Subobject Subobj, CXXMethodDecl *D);
10195bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
10196 CXXMethodDecl *target) {
10201 if (CXXBaseSpecifier *base = dyn_cast<CXXBaseSpecifier *>(Subobj)) {
10216bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
10217 Subobject Subobj, Sema::SpecialMemberOverloadResult SMOR,
10218 bool IsDtorCallInCtor) {
10220 FieldDecl *
Field = dyn_cast<FieldDecl *>(Subobj);
10229 } DiagKind = NotSet;
10232 if (CSM == CXXSpecialMemberKind::DefaultConstructor && Field &&
10233 Field->getParent()->isUnion()) {
10243 DiagKind = !
Decl ? NoDecl : DeletedDecl;
10245 DiagKind = MultipleDecl;
10246 else if (!isAccessible(Subobj, Decl))
10247 DiagKind = InaccessibleDecl;
10248 else if (!IsDtorCallInCtor && Field &&
Field->getParent()->isUnion() &&
10249 !
Decl->isTrivial()) {
10255 if (CSM == CXXSpecialMemberKind::DefaultConstructor) {
10263 DiagKind = NonTrivialDecl;
10265 DiagKind = NonTrivialDecl;
10269 if (DiagKind == NotSet)
10275 diag::note_deleted_special_member_class_subobject)
10277 << DiagKind << IsDtorCallInCtor <<
false;
10281 diag::note_deleted_special_member_class_subobject)
10282 << getEffectiveCSM() << MD->
getParent() <<
false
10283 <<
Base->getType() << DiagKind << IsDtorCallInCtor
10287 if (DiagKind == DeletedDecl)
10297bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
10298 CXXRecordDecl *
Class, Subobject Subobj,
unsigned Quals) {
10299 FieldDecl *
Field = dyn_cast<FieldDecl *>(Subobj);
10300 bool IsMutable =
Field &&
Field->isMutable();
10316 if (!(CSM == CXXSpecialMemberKind::DefaultConstructor && Field &&
10317 Field->hasInClassInitializer()) &&
10318 shouldDeleteForSubobjectCall(Subobj, lookupIn(
Class, Quals, IsMutable),
10325 if (IsConstructor) {
10326 Sema::SpecialMemberOverloadResult SMOR =
10328 false,
false,
false,
false);
10329 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
10336bool SpecialMemberDeletionInfo::shouldDeleteForVariantObjCPtrMember(
10337 FieldDecl *FD, QualType FieldType) {
10346 if (CSM == CXXSpecialMemberKind::DefaultConstructor &&
10352 S.
Diag(FD->
getLocation(), diag::note_deleted_special_member_class_subobject)
10353 << getEffectiveCSM() << ParentClass <<
true << FD << 4
10360bool SpecialMemberDeletionInfo::shouldDeleteForVariantPtrAuthMember(
10361 const FieldDecl *FD) {
10370 if (CSM == CXXSpecialMemberKind::DefaultConstructor ||
10371 CSM == CXXSpecialMemberKind::Destructor)
10376 S.
Diag(FD->
getLocation(), diag::note_deleted_special_member_class_subobject)
10377 << getEffectiveCSM() << ParentClass <<
true << FD << 4
10386bool SpecialMemberDeletionInfo::shouldDeleteForBase(CXXBaseSpecifier *Base) {
10387 CXXRecordDecl *BaseClass =
Base->getType()->getAsCXXRecordDecl();
10394 Sema::SpecialMemberOverloadResult SMOR = lookupInheritedCtor(BaseClass);
10395 if (
auto *BaseCtor = SMOR.
getMethod()) {
10400 if (BaseCtor->isDeleted() && Diagnose) {
10402 diag::note_deleted_special_member_class_subobject)
10403 << getEffectiveCSM() << MD->
getParent() <<
false
10404 <<
Base->getType() << 1 <<
false
10408 return BaseCtor->isDeleted();
10410 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
10415bool SpecialMemberDeletionInfo::shouldDeleteForField(FieldDecl *FD) {
10419 if (inUnion() && shouldDeleteForVariantObjCPtrMember(FD, FieldType))
10422 if (inUnion() && shouldDeleteForVariantPtrAuthMember(FD))
10425 if (CSM == CXXSpecialMemberKind::DefaultConstructor) {
10430 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
10431 << !!ICI << MD->
getParent() << FD << FieldType << 0;
10441 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
10447 AllFieldsAreConst =
false;
10448 }
else if (CSM == CXXSpecialMemberKind::CopyConstructor) {
10453 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
10457 }
else if (IsAssignment) {
10462 << isMove() << MD->
getParent() << FD << FieldType << 0;
10477 if (!inUnion() && FieldRecord->
isUnion() &&
10479 bool AllVariantFieldsAreConst =
true;
10482 for (
auto *UI : FieldRecord->
fields()) {
10485 if (shouldDeleteForVariantObjCPtrMember(&*UI, UnionFieldType))
10488 if (shouldDeleteForVariantPtrAuthMember(&*UI))
10492 AllVariantFieldsAreConst =
false;
10495 if (UnionFieldRecord &&
10496 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
10502 if (CSM == CXXSpecialMemberKind::DefaultConstructor &&
10503 AllVariantFieldsAreConst && !FieldRecord->
field_empty()) {
10506 diag::note_deleted_default_ctor_all_const)
10517 if (shouldDeleteForClassSubobject(FieldRecord, FD,
10528bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
10531 if (CSM == CXXSpecialMemberKind::DefaultConstructor && inUnion() &&
10532 AllFieldsAreConst) {
10533 bool AnyFields =
false;
10535 if ((AnyFields = !F->isUnnamedBitField()))
10541 diag::note_deleted_default_ctor_all_const)
10587 bool DeletesOnlyMatchingCopy =
10592 (!DeletesOnlyMatchingCopy ||
10597 for (
auto *I : RD->
ctors()) {
10598 if (I->isMoveConstructor()) {
10599 UserDeclaredMove = I;
10603 assert(UserDeclaredMove);
10605 (!DeletesOnlyMatchingCopy ||
10610 for (
auto *I : RD->
methods()) {
10611 if (I->isMoveAssignmentOperator()) {
10612 UserDeclaredMove = I;
10616 assert(UserDeclaredMove);
10619 if (UserDeclaredMove) {
10621 diag::note_deleted_copy_user_declared_move)
10638 Context.DeclarationNames.getCXXOperatorName(OO_Delete);
10643 OperatorDelete, IDP,
10651 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI,
Diagnose);
10659 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
10660 : SMI.VisitPotentiallyConstructedBases))
10663 if (SMI.shouldDeleteForAllConstMembers())
10674 auto RealCSM = CSM;
10678 return CUDA().inferTargetForImplicitSpecialMember(RD, RealCSM, MD,
10687 assert(DFK &&
"not a defaultable function");
10700 DefaultedComparisonAnalyzer(
10702 DFK.
asComparison(), DefaultedComparisonAnalyzer::ExplainDeleted)
10723 *Selected =
nullptr;
10727 llvm_unreachable(
"not a special member");
10745 for (
auto *CI : RD->
ctors()) {
10746 if (!CI->isDefaultConstructor())
10753 *Selected = DefCtor;
10786 }
else if (!Selected) {
10794 goto NeedOverloadResolution;
10804 }
else if (!Selected) {
10809 goto NeedOverloadResolution;
10813 NeedOverloadResolution:
10842 llvm_unreachable(
"unknown special method kind");
10846 for (
auto *CI : RD->
ctors())
10847 if (!CI->isImplicit())
10854 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
10884 ConstRHS, TAH, Diagnose ? &Selected :
nullptr))
10892 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
10895 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
10896 }
else if (!Selected)
10897 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
10902 << Kind << SubType.getUnqualifiedType() << CSM;
10904 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
10905 << Kind << SubType.getUnqualifiedType() << CSM;
10910 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
10911 << Kind << SubType.getUnqualifiedType() << CSM;
10927 for (
const auto *FI : RD->
fields()) {
10928 if (FI->isInvalidDecl() || FI->isUnnamedBitField())
10934 if (FI->isAnonymousStructOrUnion()) {
10936 CSM, ConstArg, TAH, Diagnose))
10946 FI->hasInClassInitializer()) {
10948 S.
Diag(FI->getLocation(), diag::note_nontrivial_default_member_init)
10959 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
10964 bool ConstRHS = ConstArg && !FI->isMutable();
10988 "not special enough");
10992 bool ConstArg =
false;
11016 const bool ClangABICompat14 =
11017 Context.getLangOpts().isCompatibleWith(LangOptions::ClangABI::Ver14);
11020 ClangABICompat14)) {
11024 <<
Context.getLValueReferenceType(
11025 Context.getCanonicalTagType(RD).withConst());
11043 <<
Context.getRValueReferenceType(
Context.getCanonicalTagType(RD));
11050 llvm_unreachable(
"not a special member");
11056 diag::note_nontrivial_default_arg)
11075 for (
const auto &BI : RD->
bases())
11117 Diag(BS.
getBeginLoc(), diag::note_nontrivial_has_virtual) << RD << 1;
11122 for (
const auto *MI : RD->
methods()) {
11123 if (MI->isVirtual()) {
11125 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
11130 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
11138struct FindHiddenVirtualMethod {
11146 static bool CheckMostOverridenMethods(
11148 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
11152 if (CheckMostOverridenMethods(O, Methods))
11162 auto *BaseRecord = Specifier->getType()->castAsRecordDecl();
11166 bool foundSameNameMethod =
false;
11168 for (Path.
Decls = BaseRecord->lookup(Name).begin();
11173 foundSameNameMethod =
true;
11190 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
11191 overloadedMethods.push_back(MD);
11195 if (foundSameNameMethod)
11196 OverloadedMethods.append(overloadedMethods.begin(),
11197 overloadedMethods.end());
11198 return foundSameNameMethod;
11205 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
11221 FindHiddenVirtualMethod FHVM;
11230 ND = shad->getTargetDecl();
11236 OverloadedMethods = FHVM.OverloadedMethods;
11241 for (
const CXXMethodDecl *overloadedMD : OverloadedMethods) {
11243 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
11245 Diag(overloadedMD->getLocation(), PD);
11258 if (!OverloadedMethods.empty()) {
11260 << MD << (OverloadedMethods.size() > 1);
11267 auto PrintDiagAndRemoveAttr = [&](
unsigned N) {
11270 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
11271 diag::ext_cannot_use_trivial_abi) << &RD;
11272 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
11273 diag::note_cannot_use_trivial_abi_reason) << &RD << N;
11280 PrintDiagAndRemoveAttr(1);
11284 for (
const auto &B : RD.
bases()) {
11287 if (!B.getType()->isDependentType() &&
11288 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) {
11289 PrintDiagAndRemoveAttr(2);
11293 if (B.isVirtual()) {
11294 PrintDiagAndRemoveAttr(3);
11299 for (
const auto *FD : RD.
fields()) {
11304 PrintDiagAndRemoveAttr(4);
11310 PrintDiagAndRemoveAttr(6);
11314 if (
const auto *RT =
11316 if (!RT->isDependentType() &&
11318 ->canPassInRegisters()) {
11319 PrintDiagAndRemoveAttr(5);
11328 auto HasNonDeletedCopyOrMoveConstructor = [&]() {
11340 if (CD->isCopyOrMoveConstructor() && !CD->isDeleted())
11345 if (!HasNonDeletedCopyOrMoveConstructor()) {
11346 PrintDiagAndRemoveAttr(0);
11354 diag::err_incomplete_type_vtable_pointer_auth))
11362 assert(PrimaryBase);
11365 if (!BasePtr.getType()->getAsCXXRecordDecl()->isDynamicClass())
11367 Base = BasePtr.getType()->getAsCXXRecordDecl();
11370 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
11372 Diag(RD.
getAttr<VTablePointerAuthenticationAttr>()->getLocation(),
11373 diag::err_non_top_level_vtable_pointer_auth)
11375 PrimaryBase =
Base;
11379 Diag(RD.
getAttr<VTablePointerAuthenticationAttr>()->getLocation(),
11380 diag::err_non_polymorphic_vtable_pointer_auth)
11393 if (AL.getKind() != ParsedAttr::AT_Visibility)
11396 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored) << AL;
11404 LBrac, RBrac, AttrList);
11426 Spaceships.clear();
11432 Spaceships.push_back(FD);
11441 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
11442 if (FD->isExplicitlyDefaulted())
11443 Spaceships.push_back(FD);
11473 else if (
Context.getTargetInfo().getCXXABI().isMicrosoft() &&
11538 DefaultedSpaceships);
11539 for (
auto *FD : DefaultedSpaceships)
11546 llvm::function_ref<
Scope *()> EnterScope) {
11554 DeclContext *LookupDC = dyn_cast<DeclContext>(D);
11558 ParameterLists.push_back(TPL);
11562 ParameterLists.push_back(FTD->getTemplateParameters());
11563 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
11567 ParameterLists.push_back(VTD->getTemplateParameters());
11568 else if (
auto *PSD = dyn_cast<VarTemplatePartialSpecializationDecl>(D))
11569 ParameterLists.push_back(PSD->getTemplateParameters());
11571 }
else if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
11573 ParameterLists.push_back(TPL);
11577 ParameterLists.push_back(CTD->getTemplateParameters());
11578 else if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
11579 ParameterLists.push_back(PSD->getTemplateParameters());
11584 unsigned Count = 0;
11585 Scope *InnermostTemplateScope =
nullptr;
11589 if (Params->size() == 0)
11592 InnermostTemplateScope = EnterScope();
11594 if (Param->getDeclName()) {
11595 InnermostTemplateScope->
AddDecl(Param);
11603 if (InnermostTemplateScope) {
11604 assert(LookupDC &&
"no enclosing DeclContext for template lookup");
11612 if (!RecordD)
return;
11619 if (!RecordD)
return;
11628 if (Param->getDeclName())
11647 if (Param->getDeclName())
11667 if (!
Method->isInvalidDecl())
11676 bool DiagOccurred =
false;
11678 [DiagID, &S, &DiagOccurred](
DeclSpec::TQ, StringRef QualName,
11685 DiagOccurred =
true;
11703 S.
Diag(PointerLoc, diag::err_invalid_ctor_dtor_decl)
11771 = dyn_cast<CXXRecordDecl>(
Constructor->getDeclContext());
11782 !
Constructor->isFunctionTemplateSpecialization()) {
11784 Constructor->getParamDecl(0)->getType()->getCanonicalTypeUnqualified();
11786 if (ParamType == ClassTy) {
11788 const char *ConstRef
11789 =
Constructor->getParamDecl(0)->getIdentifier() ?
"const &"
11791 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
11813 Context.DeclarationNames.getCXXOperatorName(OO_Delete);
11816 Loc, RD,
true,
false, Name)) {
11817 Expr *ThisArg =
nullptr;
11822 if (OperatorDelete->isDestroyingOperatorDelete()) {
11823 unsigned AddressParamIndex = 0;
11824 if (OperatorDelete->isTypeAwareOperatorNewOrDelete())
11825 ++AddressParamIndex;
11827 OperatorDelete->getParamDecl(AddressParamIndex)->getType();
11834 OperatorDelete->getParamDecl(AddressParamIndex)->getLocation());
11835 assert(!
This.isInvalid() &&
"couldn't form 'this' expr in dtor?");
11838 if (
This.isInvalid()) {
11841 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
11844 ThisArg =
This.get();
11850 Destructor->setOperatorDelete(OperatorDelete, ThisArg);
11853 Context.getTargetInfo().callGlobalDeleteInDeletingDtor(
11865 if (GlobalOperatorDelete) {
11867 Destructor->setOperatorGlobalDelete(GlobalOperatorDelete);
11871 if (
Context.getTargetInfo().emitVectorDeletingDtors(
11873 bool DestructorIsExported =
Destructor->hasAttr<DLLExportAttr>();
11876 Context.DeclarationNames.getCXXOperatorName(OO_Array_Delete);
11879 false, VDeleteName);
11885 Destructor->setGlobalOperatorArrayDelete(GlobalArrOperatorDelete);
11886 if (GlobalArrOperatorDelete &&
11887 (
Context.classMaybeNeedsVectorDeletingDestructor(RD) ||
11888 DestructorIsExported))
11890 }
else if (!ArrOperatorDelete) {
11893 true, VDeleteName);
11895 Destructor->setOperatorArrayDelete(ArrOperatorDelete);
11896 if (ArrOperatorDelete &&
11897 (
Context.classMaybeNeedsVectorDeletingDestructor(RD) ||
11898 DestructorIsExported))
11917 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
11918 else if (
const TemplateSpecializationType *TST =
11919 DeclaratorType->
getAs<TemplateSpecializationType>())
11920 if (TST->isTypeAlias())
11922 << DeclaratorType << 1;
12012 if (R.getEnd().isInvalid())
12013 R.setEnd(Before.
getEnd());
12017 if (After.isInvalid())
12019 if (R.getBegin().isInvalid())
12020 R.setBegin(After.getBegin());
12021 R.setEnd(After.getEnd());
12070 unsigned NumParam = Proto->getNumParams();
12074 if (NumParam == 1) {
12076 if (
const auto *
First =
12077 dyn_cast_if_present<ParmVarDecl>(FTI.
Params[0].
Param);
12078 First &&
First->isExplicitObjectParameter())
12082 if (NumParam != 0) {
12087 }
else if (Proto->isVariadic()) {
12094 if (Proto->getReturnType() != ConvType) {
12095 bool NeedsTypedef =
false;
12099 bool PastFunctionChunk =
false;
12101 switch (Chunk.Kind) {
12103 if (!PastFunctionChunk) {
12104 if (Chunk.Fun.HasTrailingReturnType) {
12109 PastFunctionChunk =
true;
12114 NeedsTypedef =
true;
12134 After.isValid() ? After.getBegin() :
12136 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
12137 DB << Before << After;
12139 if (!NeedsTypedef) {
12143 if (After.isInvalid() && ConvTSI) {
12151 }
else if (!Proto->getReturnType()->isDependentType()) {
12152 DB << 1 << Proto->getReturnType();
12154 DB << 2 << Proto->getReturnType();
12165 ConvType = Proto->getReturnType();
12173 ConvType =
Context.getPointerType(ConvType);
12177 ConvType =
Context.getPointerType(ConvType);
12185 R =
Context.getFunctionType(ConvType, {}, Proto->getExtProtoInfo());
12190 diag_compat::explicit_conversion_functions)
12195 assert(Conversion &&
"Expected to receive a conversion function declaration");
12216 ConvType =
Context.getCanonicalType(ConvType).getUnqualifiedType();
12217 if (ConvType == ClassType)
12222 << ClassType << ConvType;
12225 << ClassType << ConvType;
12236 << ConvType->
castAs<AutoType>()->getKeyword()
12240 return ConversionTemplate;
12265 for (
unsigned Idx = 0; Idx < FTI.
NumParams; Idx++) {
12266 const auto &ParamInfo = FTI.
Params[Idx];
12267 if (!ParamInfo.Param)
12270 if (!Param->isExplicitObjectParameter())
12273 ExplicitObjectParam = Param;
12276 Diag(Param->getLocation(),
12277 diag::err_explicit_object_parameter_must_be_first)
12278 << IsLambda << Param->getSourceRange();
12281 if (!ExplicitObjectParam)
12286 diag::err_explicit_object_default_arg)
12295 diag::err_explicit_object_parameter_nonmember)
12302 diag::err_explicit_object_parameter_nonmember)
12327 !isa_and_present<CXXRecordDecl>(
12330 diag::err_explicit_object_parameter_nonmember)
12337 diag::err_explicit_object_parameter_mutable)
12345 assert(D.
isInvalidType() &&
"Explicit object parameter in non-member "
12346 "should have been diagnosed already");
12354 diag::err_explicit_object_parameter_constructor)
12364struct BadSpecifierDiagnoser {
12367 ~BadSpecifierDiagnoser() {
12371 template<
typename T>
void check(SourceLocation SpecLoc,
T Spec) {
12375 return check(SpecLoc,
12378 void check(SourceLocation SpecLoc,
const char *Spec) {
12380 Diagnostic << SourceRange(SpecLoc, SpecLoc);
12381 if (!Specifiers.empty()) Specifiers +=
" ";
12382 Specifiers += Spec;
12386 Sema::SemaDiagnosticBuilder Diagnostic;
12387 std::string Specifiers;
12395 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
12400 if (!
CurContext->getRedeclContext()->Equals(
12403 << GuidedTemplateDecl;
12409 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
12410 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
12411 DS.isNoreturnSpecified() || DS.hasConstexprSpecifier()) {
12412 BadSpecifierDiagnoser Diagnoser(
12414 diag::err_deduction_guide_invalid_specifier);
12416 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
12417 DS.ClearStorageClassSpecs();
12421 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
12422 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
12423 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
12424 DS.ClearConstexprSpec();
12426 Diagnoser.check(DS.getConstSpecLoc(),
"const");
12427 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
12428 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
12429 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
12430 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
12431 DS.ClearTypeQualifiers();
12433 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
12434 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
12435 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
12436 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
12437 DS.ClearTypeSpecType();
12444 bool FoundFunction =
false;
12450 diag::err_deduction_guide_with_complex_decl)
12454 if (!Chunk.Fun.hasTrailingReturnType())
12456 diag::err_deduction_guide_no_trailing_return_type);
12461 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
12464 assert(TSI &&
"deduction guide has valid type but invalid return type?");
12465 bool AcceptableReturnType =
false;
12466 bool MightInstantiateToSpecialization =
false;
12469 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
12470 bool TemplateMatches =
Context.hasSameTemplateName(
12471 SpecifiedName, GuidedTemplate,
true);
12479 if (SimplyWritten && TemplateMatches)
12480 AcceptableReturnType =
true;
12485 MightInstantiateToSpecialization =
12489 MightInstantiateToSpecialization =
true;
12492 if (!AcceptableReturnType)
12494 diag::err_deduction_guide_bad_trailing_return_type)
12495 << GuidedTemplate << TSI->
getType()
12496 << MightInstantiateToSpecialization
12501 FoundFunction =
true;
12520 assert(*IsInline != PrevNS->
isInline());
12530 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
12533 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
12551 bool IsInline = InlineLoc.
isValid();
12552 bool IsInvalid =
false;
12553 bool IsStd =
false;
12554 bool AddToKnown =
false;
12565 auto DiagnoseInlineStdNS = [&]() {
12566 assert(IsInline && II->
isStr(
"std") &&
12567 CurContext->getRedeclContext()->isTranslationUnit() &&
12568 "Precondition of DiagnoseInlineStdNS not met");
12569 Diag(InlineLoc, diag::err_inline_namespace_std)
12588 R.isSingleResult() ? R.getRepresentativeDecl() :
nullptr;
12589 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
12593 if (IsInline && II->
isStr(
"std") &&
12594 CurContext->getRedeclContext()->isTranslationUnit())
12595 DiagnoseInlineStdNS();
12596 else if (IsInline != PrevNS->
isInline())
12598 &IsInline, PrevNS);
12599 }
else if (PrevDecl) {
12601 Diag(Loc, diag::err_redefinition_different_kind)
12606 }
else if (II->
isStr(
"std") &&
12607 CurContext->getRedeclContext()->isTranslationUnit()) {
12609 DiagnoseInlineStdNS();
12614 AddToKnown = !IsInline;
12617 AddToKnown = !IsInline;
12631 if (PrevNS && IsInline != PrevNS->
isInline())
12633 &IsInline, PrevNS);
12640 if (PrevNS && !
CurContext->getRedeclContext()->Equals(
12644 Context, SemanticContext, IsInline, StartLoc, Loc, II, PrevNS, IsNested);
12654 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
12660 KnownNamespaces[Namespc] =
false;
12668 TU->setAnonymousNamespace(Namespc);
12720 return dyn_cast_or_null<NamespaceDecl>(D);
12724 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
12725 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
12728 if (Namespc->
hasAttr<VisibilityAttr>())
12731 if (DeferredExportedNamespaces.erase(Namespc))
12736 return cast_or_null<CXXRecordDecl>(
12745 return cast_or_null<NamespaceDecl>(
12751enum UnsupportedSTLSelect {
12758struct InvalidSTLDiagnoser {
12763 QualType operator()(UnsupportedSTLSelect Sel = USS_Other, StringRef Name =
"",
12764 const VarDecl *VD =
nullptr) {
12766 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
12767 << TyForDiags << ((
int)Sel);
12768 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
12769 assert(!Name.empty());
12773 if (Sel == USS_InvalidMember) {
12786 "Looking for comparison category type outside of C++.");
12801 if (Info && FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)]) {
12812 std::string NameForDiags =
"std::";
12814 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
12815 << NameForDiags << (int)Usage;
12819 assert(Info->
Kind == Kind);
12830 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags(Info)};
12833 return UnsupportedSTLError(USS_NonTrivial);
12838 if (
Base->isEmpty())
12841 return UnsupportedSTLError();
12849 if (std::distance(FIt, FEnd) != 1 ||
12850 !FIt->getType()->isIntegralOrEnumerationType()) {
12851 return UnsupportedSTLError();
12861 return UnsupportedSTLError(USS_MissingMember, MemName);
12864 assert(VD &&
"should not be null!");
12871 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
12877 return UnsupportedSTLError();
12884 FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)] =
true;
12894 &
PP.getIdentifierTable().get(
"std"),
12907 const char *ClassName,
12909 const Decl **MalformedDecl) {
12917 auto ReportMatchingNameAsMalformed = [&](
NamedDecl *D) {
12918 if (!MalformedDecl)
12926 *MalformedDecl = D;
12931 if (
const TemplateSpecializationType *TST =
12933 Template = dyn_cast_or_null<ClassTemplateDecl>(
12934 TST->getTemplateName().getAsTemplateDecl());
12935 Arguments = TST->template_arguments();
12936 }
else if (
const auto *TT = SugaredType->
getAs<TagType>()) {
12938 Arguments = TT->getTemplateArgs(S.
Context);
12942 ReportMatchingNameAsMalformed(SugaredType->
getAsTagDecl());
12946 if (!*CachedDecl) {
12965 *MalformedDecl = TemplateClass;
12973 if (
Template->getCanonicalDecl() != (*CachedDecl)->getCanonicalDecl())
12978 QualType ArgType = Arguments[0].getAsType();
12984 if (S.
getLangOpts().ObjCAutoRefCount && ArgType->isObjCLifetimeType() &&
12985 !ArgType.getObjCLifetime()) {
12990 *TypeArg = ArgType;
12998 "Looking for std::initializer_list outside of C++.");
13008 const Decl **MalformedDecl) {
13010 "Looking for std::type_identity outside of C++.");
13020 const char *ClassName,
13021 bool *WasMalformed) {
13032 Result.suppressDiagnostics();
13035 S.
Diag(
Found->getLocation(), diag::err_malformed_std_class_template)
13038 *WasMalformed =
true;
13047 S.
Diag(
Template->getLocation(), diag::err_malformed_std_class_template)
13050 *WasMalformed =
true;
13065 Loc, Args,
nullptr,
13071 bool WasMalformed =
false;
13076 Diag(Loc, diag::err_implied_std_initializer_list_not_found);
13104 ArgType = RT->getPointeeType().getUnqualifiedType();
13113 case Decl::TranslationUnit:
13115 case Decl::LinkageSpec:
13125class NamespaceValidatorCCC final :
public CorrectionCandidateCallback {
13127 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
13133 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
13134 return std::make_unique<NamespaceValidatorCCC>(*
this);
13143 Module *M = ND->getOwningModule();
13144 assert(M &&
"hidden namespace definition not in a module?");
13148 diag::err_module_unimported_use_header)
13153 diag::err_module_unimported_use)
13163 NamespaceValidatorCCC CCC{};
13165 S.
CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), Sc, &SS, CCC,
13173 if (isa_and_nonnull<NamespaceDecl>(Corrected.getFoundDecl()) &&
13174 Corrected.requiresImport()) {
13177 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
13178 bool DroppedSpecifier =
13179 Corrected.WillReplaceSpecifier() && Ident->
getName() == CorrectedStr;
13181 S.
PDiag(diag::err_using_directive_member_suggest)
13182 << Ident << DC << DroppedSpecifier << SS.
getRange(),
13183 S.
PDiag(diag::note_namespace_defined_here));
13186 S.
PDiag(diag::err_using_directive_suggest) << Ident,
13187 S.
PDiag(diag::note_namespace_defined_here));
13189 R.addDecl(Corrected.getFoundDecl());
13200 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
13201 assert(NamespcName &&
"Invalid NamespcName.");
13202 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
13213 if (R.isAmbiguous())
13222 NamespcName->
isStr(
"std")) {
13223 Diag(IdentLoc, diag::ext_using_undefined_std);
13233 NamedDecl *Named = R.getRepresentativeDecl();
13235 assert(
NS &&
"expected namespace decl");
13254 CommonAncestor = CommonAncestor->
getParent();
13258 IdentLoc, Named, CommonAncestor);
13262 Diag(IdentLoc, diag::warn_using_directive_in_header);
13267 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
13317 ? diag::warn_cxx98_compat_using_decl_constructor
13318 : diag::err_using_decl_constructor)
13335 llvm_unreachable(
"cannot parse qualified deduction guide name");
13346 ? diag::err_access_decl
13347 : diag::warn_access_decl_deprecated)
13358 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
13366 SS, TargetNameInfo, EllipsisLoc, AttrList,
13385 ? diag::err_using_enum_is_dependent
13386 : diag::err_unknown_typename)
13394 Diag(IdentLoc, diag::err_using_enum_is_dependent);
13400 Diag(IdentLoc, diag::err_using_enum_not_enum) << EnumTy;
13404 if (TSI ==
nullptr)
13405 TSI =
Context.getTrivialTypeSourceInfo(EnumTy, IdentLoc);
13426 return Context.hasSameType(TD1->getUnderlyingType(),
13427 TD2->getUnderlyingType());
13461 if (
auto *Using = dyn_cast<UsingDecl>(BUD)) {
13473 Diag(Using->getLocation(),
13474 diag::err_using_decl_nested_name_specifier_is_current_class)
13475 << Using->getQualifierLoc().getSourceRange();
13477 Using->setInvalidDecl();
13481 Diag(Using->getQualifierLoc().getBeginLoc(),
13482 diag::err_using_decl_nested_name_specifier_is_not_base_class)
13484 << Using->getQualifierLoc().getSourceRange();
13486 Using->setInvalidDecl();
13491 if (
Previous.empty())
return false;
13502 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
13503 bool FoundEquivalentDecl =
false;
13505 NamedDecl *D = Element->getUnderlyingDecl();
13512 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
13527 PrevShadow = Shadow;
13528 FoundEquivalentDecl =
true;
13532 FoundEquivalentDecl =
true;
13539 if (FoundEquivalentDecl)
13545 (isa_and_nonnull<UnresolvedUsingIfExistsDecl>(NonTag))) {
13546 if (!NonTag && !Tag)
13549 Diag(
Target->getLocation(), diag::note_using_decl_target);
13550 Diag((NonTag ? NonTag : Tag)->getLocation(),
13551 diag::note_using_decl_conflict);
13580 Diag(
Target->getLocation(), diag::note_using_decl_target);
13590 if (!Tag)
return false;
13593 Diag(
Target->getLocation(), diag::note_using_decl_target);
13594 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
13600 if (!NonTag)
return false;
13603 Diag(
Target->getLocation(), diag::note_using_decl_target);
13613 for (
auto &B : Derived->
bases())
13614 if (B.getType()->getAsCXXRecordDecl() ==
Base)
13615 return B.isVirtual();
13616 llvm_unreachable(
"not a direct base class");
13630 if (
auto *TargetTD = dyn_cast<TemplateDecl>(
Target))
13631 NonTemplateTarget = TargetTD->getTemplatedDecl();
13636 bool IsVirtualBase =
13638 Using->getQualifier().getAsRecordDecl());
13686 bool &AnyDependentBases) {
13690 CanQualType BaseType =
Base.getType()->getCanonicalTypeUnqualified();
13691 if (CanonicalDesiredBase == BaseType)
13693 if (BaseType->isDependentType())
13694 AnyDependentBases =
true;
13700class UsingValidatorCCC final :
public CorrectionCandidateCallback {
13702 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
13703 NestedNameSpecifier NNS, CXXRecordDecl *RequireMemberOf)
13704 : HasTypenameKeyword(HasTypenameKeyword),
13705 IsInstantiation(IsInstantiation), OldNNS(NNS),
13706 RequireMemberOf(RequireMemberOf) {}
13708 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
13722 if (RequireMemberOf) {
13723 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
13724 if (FoundRecord && FoundRecord->isInjectedClassName()) {
13738 if (
Specifier.getKind() != NestedNameSpecifier::Kind::Type ||
13744 bool AnyDependentBases =
false;
13747 AnyDependentBases) &&
13748 !AnyDependentBases)
13758 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
13759 if (FoundRecord && FoundRecord->isInjectedClassName())
13764 return HasTypenameKeyword || !IsInstantiation;
13766 return !HasTypenameKeyword;
13769 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
13770 return std::make_unique<UsingValidatorCCC>(*
this);
13774 bool HasTypenameKeyword;
13775 bool IsInstantiation;
13776 NestedNameSpecifier OldNNS;
13777 CXXRecordDecl *RequireMemberOf;
13804 bool IsUsingIfExists) {
13805 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
13807 assert(IdentLoc.
isValid() &&
"Invalid TargetName location.");
13816 if (
auto *RD = dyn_cast<CXXRecordDecl>(
CurContext))
13817 UsingName.
setName(
Context.DeclarationNames.getCXXConstructorName(
13818 Context.getCanonicalTagType(RD)));
13829 assert(IsInstantiation &&
"no scope in non-instantiation");
13857 Diag(UsingLoc, diag::err_using_if_exists_on_ctor);
13863 if (!LookupContext || EllipsisLoc.
isValid()) {
13867 SS, NameInfo, IdentLoc))
13871 Previous.getFoundDecl()->isTemplateParameter())
13874 if (HasTypenameKeyword) {
13877 UsingLoc, TypenameLoc,
13879 IdentLoc, NameInfo.
getName(),
13883 QualifierLoc, NameInfo, EllipsisLoc);
13891 auto Build = [&](
bool Invalid) {
13894 UsingName, HasTypenameKeyword);
13901 auto BuildInvalid = [&]{
return Build(
true); };
13902 auto BuildValid = [&]{
return Build(
false); };
13905 return BuildInvalid();
13914 if (!IsInstantiation)
13915 R.setHideTags(
false);
13920 R.setBaseObjectType(
13931 if (R.empty() && IsUsingIfExists)
13949 PP.NeedsStdLibCxxWorkaroundBefore(2016'12'21) &&
13952 UsingValidatorCCC CCC(HasTypenameKeyword, IsInstantiation, SS.
getScopeRep(),
13955 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, &SS, CCC,
13960 << NameInfo.
getName() << LookupContext << 0
13965 NamedDecl *ND = Corrected.getCorrectionDecl();
13967 return BuildInvalid();
13970 auto *RD = dyn_cast<CXXRecordDecl>(ND);
13976 if (Corrected.WillReplaceSpecifier()) {
13980 QualifierLoc = Builder.getWithLocInContext(
Context);
13986 UsingName.
setName(
Context.DeclarationNames.getCXXConstructorName(
13987 Context.getCanonicalTagType(CurClass)));
13999 Diag(IdentLoc, diag::err_no_member)
14001 return BuildInvalid();
14005 if (R.isAmbiguous())
14006 return BuildInvalid();
14008 if (HasTypenameKeyword) {
14012 Diag(IdentLoc, diag::err_using_typename_non_type);
14015 diag::note_using_decl_target);
14016 return BuildInvalid();
14022 if (IsInstantiation && R.getAsSingle<
TypeDecl>()) {
14023 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
14024 Diag(R.getFoundDecl()->getLocation(), diag::note_using_decl_target);
14025 return BuildInvalid();
14032 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
14037 return BuildInvalid();
14047 R.suppressDiagnostics();
14069 if (
CurContext->getRedeclContext()->isRecord()) {
14079 if (UED->getEnumDecl() == ED) {
14080 Diag(UsingLoc, diag::err_using_enum_decl_redeclaration)
14092 EnumLoc, NameLoc, EnumType);
14125 UPD->setAccess(InstantiatedFrom->
getAccess());
14131 assert(!UD->
hasTypename() &&
"expecting a constructor name");
14137 bool AnyDependentBases =
false;
14140 if (!
Base && !AnyDependentBases) {
14141 Diag(UD->
getUsingLoc(), diag::err_using_decl_constructor_not_in_direct_base)
14148 Base->setInheritConstructors();
14154 bool HasTypenameKeyword,
14167 if (!
CurContext->getRedeclContext()->isRecord()) {
14174 for (
auto *D : Prev) {
14176 bool OldCouldBeEnumerator =
14179 OldCouldBeEnumerator ? diag::err_redefinition
14180 : diag::err_redefinition_different_kind)
14181 << Prev.getLookupName();
14194 if (
const auto *UD = dyn_cast<UsingDecl>(D)) {
14195 DTypename = UD->hasTypename();
14196 DQual = UD->getQualifier();
14197 }
else if (
const auto *UD = dyn_cast<UnresolvedUsingValueDecl>(D)) {
14199 DQual = UD->getQualifier();
14200 }
else if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
14202 DQual = UD->getQualifier();
14208 if (HasTypenameKeyword != DTypename)
continue;
14216 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
14230 assert(
bool(NamedContext) == (R || UD) && !(R && UD) &&
14231 "resolvable context must have exactly one set of decls");
14235 bool Cxx20Enumerator =
false;
14236 if (NamedContext) {
14245 if (
auto *ED = dyn_cast<EnumDecl>(NamedContext)) {
14249 if (EC && R && ED->isScoped())
14254 NamedContext = ED->getDeclContext();
14274 ? diag::warn_cxx17_compat_using_decl_class_member_enumerator
14275 : diag::err_using_decl_can_not_refer_to_class_member)
14278 if (Cxx20Enumerator)
14281 auto *RD = NamedContext
14290 }
else if (R->getAsSingle<
TypeDecl>()) {
14293 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
14294 << diag::MemClassWorkaround::AliasDecl
14301 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
14302 << diag::MemClassWorkaround::TypedefDecl
14307 }
else if (R->getAsSingle<
VarDecl>()) {
14317 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
14318 << diag::MemClassWorkaround::ReferenceDecl << FixIt;
14331 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
14333 ? diag::MemClassWorkaround::ConstexprVar
14334 : diag::MemClassWorkaround::ConstVar)
14343 if (!NamedContext) {
14359 ? diag::warn_cxx17_compat_using_decl_non_member_enumerator
14360 : diag::err_using_decl_nested_name_specifier_is_not_class)
14363 if (Cxx20Enumerator)
14384 if (Cxx20Enumerator) {
14385 Diag(NameLoc, diag::warn_cxx17_compat_using_decl_non_member_enumerator)
14392 diag::err_using_decl_nested_name_specifier_is_current_class)
14399 diag::err_using_decl_nested_name_specifier_is_not_base_class)
14415 if (
Type.isInvalid())
14434 TemplateParamLists.size()
14441 Previous.getFoundDecl()->isTemplateParameter()) {
14447 "name in alias declaration must be an identifier");
14470 if (TemplateParamLists.size()) {
14475 if (TemplateParamLists.size() != 1) {
14476 Diag(UsingLoc, diag::err_alias_template_extra_headers)
14477 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
14478 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
14482 auto It = llvm::find_if(
14483 llvm::reverse(TemplateParamLists),
14485 assert(It != TemplateParamLists.rend() &&
14486 "if all template parameter lists were empty, this should have "
14487 "been rejected as an explicit specialization");
14488 TemplateParams = *It;
14503 Diag(UsingLoc, diag::err_redefinition_different_kind)
14518 OldTemplateParams =
14554 else if (OldDecl) {
14561 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
14584 if (R.isAmbiguous())
14589 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
14593 assert(!R.isAmbiguous() && !R.empty());
14621 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
14623 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
14624 << AD->getNamespace();
14629 ? diag::err_redefinition
14630 : diag::err_redefinition_different_kind;
14631 Diag(AliasLoc, DiagID) << Alias;
14652struct SpecialMemberExceptionSpecInfo
14653 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
14661 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
14666 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
14669 void visitSubobjectCall(Subobject Subobj,
14674bool SpecialMemberExceptionSpecInfo::visitBase(CXXBaseSpecifier *Base) {
14675 auto *BaseClass =
Base->getType()->getAsCXXRecordDecl();
14679 Sema::SpecialMemberOverloadResult SMOR = lookupInheritedCtor(BaseClass);
14680 if (
auto *BaseCtor = SMOR.
getMethod()) {
14681 visitSubobjectCall(Base, BaseCtor);
14685 visitClassSubobject(BaseClass, Base, 0);
14689bool SpecialMemberExceptionSpecInfo::visitField(FieldDecl *FD) {
14690 if (CSM == CXXSpecialMemberKind::DefaultConstructor &&
14709void SpecialMemberExceptionSpecInfo::visitClassSubobject(CXXRecordDecl *
Class,
14712 FieldDecl *
Field = dyn_cast<FieldDecl *>(Subobj);
14713 bool IsMutable =
Field &&
Field->isMutable();
14714 visitSubobjectCall(Subobj, lookupIn(
Class, Quals, IsMutable));
14717void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
14718 Subobject Subobj, Sema::SpecialMemberOverloadResult SMOR) {
14721 if (CXXMethodDecl *MD = SMOR.
getMethod())
14722 ExceptSpec.
CalledDecl(getSubobjectLoc(Subobj), MD);
14751 ComputingExceptionSpec CES(S, MD, Loc);
14758 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
14760 return Info.ExceptSpec;
14767 diag::err_exception_spec_incomplete_type))
14768 return Info.ExceptSpec;
14785 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
14786 : Info.VisitAllBases);
14788 return Info.ExceptSpec;
14793struct DeclaringSpecialMember {
14796 Sema::ContextRAII SavedContext;
14797 bool WasAlreadyBeingDeclared;
14800 : S(S), D(RD, CSM), SavedContext(S, RD) {
14802 if (WasAlreadyBeingDeclared)
14809 Sema::CodeSynthesisContext Ctx;
14810 Ctx.Kind = Sema::CodeSynthesisContext::DeclaringSpecialMember;
14817 Ctx.PointOfInstantiation = RD->getLocation();
14819 Ctx.SpecialMember = CSM;
14820 S.pushCodeSynthesisContext(Ctx);
14823 ~DeclaringSpecialMember() {
14824 if (!WasAlreadyBeingDeclared) {
14831 bool isAlreadyBeingDeclared()
const {
14832 return WasAlreadyBeingDeclared;
14844 if (
auto *Acceptable = R.getAcceptableDecl(D))
14845 R.addDecl(Acceptable);
14847 R.suppressDiagnostics();
14853void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
14859 LangAS AS = getDefaultCXXMethodAddrSpace();
14864 auto QT = Context.getFunctionType(ResultTy, Args, EPI);
14872 Context.getTrivialTypeSourceInfo(SpecialMem->
getType());
14886 "Should not build implicit default constructor!");
14888 DeclaringSpecialMember DSM(*
this, ClassDecl,
14890 if (DSM.isAlreadyBeingDeclared())
14900 =
Context.DeclarationNames.getCXXConstructorName(ClassType);
14912 setupImplicitSpecialMemberType(DefaultCon,
Context.VoidTy, {});
14915 CUDA().inferTargetForImplicitSpecialMember(
14936 ClassDecl->
addDecl(DefaultCon);
14943 DefaultedFunctionFPFeaturesRAII RestoreFP(*
this,
Constructor);
14947 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
14952 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
14966 Scope.addContextNote(CurrentLocation);
15013 ->getInheritedConstructor()
15020 Context.getTrivialTypeSourceInfo(BaseCtor->
getType(), UsingLoc);
15031 false, BaseCtor, &ICI);
15048 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
15054 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
15058 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
15065 ParamDecls.push_back(PD);
15070 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
15073 Derived->
addDecl(DerivedCtor);
15079 return DerivedCtor;
15110 Scope.addContextNote(CurrentLocation);
15113 Constructor->getInheritedConstructor().getShadowDecl();
15115 Constructor->getInheritedConstructor().getConstructor();
15129 for (
bool VBase : {
false,
true}) {
15131 if (B.isVirtual() != VBase)
15134 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
15139 if (!BaseCtor.first)
15144 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
15146 auto *TInfo =
Context.getTrivialTypeSourceInfo(B.getType(), InitLoc);
15148 Context, TInfo, VBase, InitLoc,
Init.get(), InitLoc,
15182 DeclaringSpecialMember DSM(*
this, ClassDecl,
15184 if (DSM.isAlreadyBeingDeclared())
15194 =
Context.DeclarationNames.getCXXDestructorName(ClassType);
15209 CUDA().inferTargetForImplicitSpecialMember(
15243 DefaultedFunctionFPFeaturesRAII RestoreFP(*
this,
Destructor);
15245 !
Destructor->doesThisDeclarationHaveABody() &&
15247 "DefineImplicitDestructor - call it for implicit default dtor");
15252 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
15263 Scope.addContextNote(CurrentLocation);
15290 assert(
Context.getTargetInfo().getCXXABI().isMicrosoft() &&
15291 "implicit complete dtors unneeded outside MS ABI");
15293 "complete dtor only exists for classes with vbases");
15298 Scope.addContextNote(CurrentLocation);
15306 if (
Record->isInvalidDecl()) {
15327 if (M->getParent()->getTemplateSpecializationKind() !=
15347 "adjusting dtor exception specs was introduced in c++11");
15357 if (DtorType->hasExceptionSpec())
15380 ExprBuilder(
const ExprBuilder&) =
delete;
15381 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
15384 static Expr *assertNotNull(
Expr *E) {
15385 assert(E &&
"Expression construction must not fail.");
15391 virtual ~ExprBuilder() {}
15393 virtual Expr *build(Sema &S, SourceLocation Loc)
const = 0;
15396class RefBuilder:
public ExprBuilder {
15401 Expr *build(Sema &S, SourceLocation Loc)
const override {
15405 RefBuilder(VarDecl *Var, QualType VarType)
15406 : Var(Var), VarType(VarType) {}
15409class ThisBuilder:
public ExprBuilder {
15411 Expr *build(Sema &S, SourceLocation Loc)
const override {
15416class CastBuilder:
public ExprBuilder {
15417 const ExprBuilder &Builder;
15423 Expr *build(Sema &S, SourceLocation Loc)
const override {
15425 CK_UncheckedDerivedToBase, Kind,
15434class DerefBuilder:
public ExprBuilder {
15435 const ExprBuilder &Builder;
15438 Expr *build(Sema &S, SourceLocation Loc)
const override {
15439 return assertNotNull(
15443 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
15446class MemberBuilder:
public ExprBuilder {
15447 const ExprBuilder &Builder;
15451 LookupResult &MemberLookup;
15454 Expr *build(Sema &S, SourceLocation Loc)
const override {
15456 Builder.build(S, Loc),
Type, Loc, IsArrow, SS, SourceLocation(),
15457 nullptr, MemberLookup,
nullptr,
nullptr).get());
15460 MemberBuilder(
const ExprBuilder &Builder, QualType
Type,
bool IsArrow,
15461 LookupResult &MemberLookup)
15462 : Builder(Builder),
Type(
Type), IsArrow(IsArrow),
15463 MemberLookup(MemberLookup) {}
15466class MoveCastBuilder:
public ExprBuilder {
15467 const ExprBuilder &Builder;
15470 Expr *build(Sema &S, SourceLocation Loc)
const override {
15471 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
15474 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
15477class LvalueConvBuilder:
public ExprBuilder {
15478 const ExprBuilder &Builder;
15481 Expr *build(Sema &S, SourceLocation Loc)
const override {
15482 return assertNotNull(
15486 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
15489class SubscriptBuilder:
public ExprBuilder {
15490 const ExprBuilder &
Base;
15491 const ExprBuilder &Index;
15494 Expr *build(Sema &S, SourceLocation Loc)
const override {
15496 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
15499 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
15511 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
15520 Expr *From = FromB.build(S, Loc);
15524 Expr *To = ToB.build(S, Loc);
15529 bool NeedsCollectableMemCpy =
false;
15530 if (
auto *RD =
T->getBaseElementTypeUnsafe()->getAsRecordDecl())
15534 StringRef MemCpyName = NeedsCollectableMemCpy ?
15535 "__builtin_objc_memmove_collectable" :
15536 "__builtin_memcpy";
15549 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
15551 Expr *CallArgs[] = {
15555 Loc, CallArgs, Loc);
15557 assert(!
Call.isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
15590 const ExprBuilder &To,
const ExprBuilder &From,
15591 bool CopyingBaseSubobject,
bool Copying,
15592 unsigned Depth = 0) {
15607 if (
auto *ClassDecl =
T->getAsCXXRecordDecl()) {
15621 if (Method->isCopyAssignmentOperator() ||
15622 (!Copying && Method->isMoveAssignmentOperator()))
15641 if (CopyingBaseSubobject) {
15670 Expr *FromInst = From.build(S, Loc);
15673 Loc, FromInst, Loc);
15674 if (
Call.isInvalid())
15693 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
15713 llvm::raw_svector_ostream OS(Str);
15714 OS <<
"__i" << Depth;
15718 IterationVarName, SizeType,
15727 RefBuilder IterationVarRef(IterationVar, SizeType);
15728 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
15734 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
15735 MoveCastBuilder FromIndexMove(FromIndexCopy);
15736 const ExprBuilder *FromIndex;
15738 FromIndex = &FromIndexCopy;
15740 FromIndex = &FromIndexMove;
15742 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
15747 ToIndex, *FromIndex, CopyingBaseSubobject,
15748 Copying, Depth + 1);
15750 if (
Copy.isInvalid() || !
Copy.get())
15757 S.
Context, IterationVarRefRVal.build(S, Loc),
15771 Loc, Loc, InitStmt,
15778 const ExprBuilder &To,
const ExprBuilder &From,
15779 bool CopyingBaseSubobject,
bool Copying) {
15781 if (
T->isArrayType() && !
T.hasQualifiers() &&
15782 T.isTriviallyCopyableType(S.
Context))
15786 CopyingBaseSubobject,
15804 DeclaringSpecialMember DSM(*
this, ClassDecl,
15806 if (DSM.isAlreadyBeingDeclared())
15810 std::nullopt, ClassDecl,
15844 CUDA().inferTargetForImplicitSpecialMember(
15851 ClassLoc, ClassLoc,
15864 ++
getASTContext().NumImplicitCopyAssignmentOperatorsDeclared;
15896 for (
auto *I : RD->
ctors()) {
15897 if (I->isCopyConstructor()) {
15898 UserDeclaredOperation = I;
15902 assert(UserDeclaredOperation);
15906 for (
auto *I : RD->
methods()) {
15907 if (I->isCopyAssignmentOperator()) {
15908 UserDeclaredOperation = I;
15912 assert(UserDeclaredOperation);
15915 if (UserDeclaredOperation) {
15916 bool UDOIsUserProvided = UserDeclaredOperation->
isUserProvided();
15920 (UDOIsUserProvided && UDOIsDestructor)
15921 ? diag::warn_deprecated_copy_with_user_provided_dtor
15922 : (UDOIsUserProvided && !UDOIsDestructor)
15923 ? diag::warn_deprecated_copy_with_user_provided_copy
15924 : (!UDOIsUserProvided && UDOIsDestructor)
15925 ? diag::warn_deprecated_copy_with_dtor
15926 : diag::warn_deprecated_copy;
15928 << RD << IsCopyAssignment;
15934 DefaultedFunctionFPFeaturesRAII RestoreFP(*
this, CopyAssignOperator);
15940 "DefineImplicitCopyAssignment called for wrong function");
15958 Scope.addContextNote(CurrentLocation);
15993 RefBuilder OtherRef(
Other, OtherRefType);
15996 std::optional<ThisBuilder>
This;
15997 std::optional<DerefBuilder> DerefThis;
15998 std::optional<RefBuilder> ExplicitObject;
15999 bool IsArrow =
false;
16005 ExplicitObject.emplace(CopyAssignOperator->
getParamDecl(0), ObjectType);
16009 DerefThis.emplace(*
This);
16012 ExprBuilder &ObjectParameter =
16013 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
16014 :
static_cast<ExprBuilder &
>(*This);
16018 for (
auto &
Base : ClassDecl->
bases()) {
16021 QualType BaseType =
Base.getType().getUnqualifiedType();
16022 if (!BaseType->isRecordType()) {
16028 BasePath.push_back(&
Base);
16032 CastBuilder From(OtherRef,
Context.getQualifiedType(BaseType, OtherQuals),
16037 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
16038 :
static_cast<ExprBuilder &
>(*DerefThis),
16047 if (
Copy.isInvalid()) {
16053 Statements.push_back(
Copy.getAs<
Expr>());
16060 ExprBuilder &To = ExplicitObject
16061 ?
static_cast<ExprBuilder &
>(*ExplicitObject)
16062 :
static_cast<ExprBuilder &
>(*DerefThis);
16069 *
this, Loc,
Context.getCanonicalTagType(ClassDecl), To, OtherRef);
16070 if (
Copy.isInvalid()) {
16074 Statements.push_back(
Copy.getAs<
Stmt>());
16078 for (
auto *Field : ClassDecl->
fields()) {
16080 if (Field->isUnnamedBitField() || Field->getParent()->isUnion())
16083 if (Field->isInvalidDecl()) {
16089 if (Field->getType()->isReferenceType()) {
16090 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
16091 <<
Context.getCanonicalTagType(ClassDecl) << 0
16092 << Field->getDeclName();
16093 Diag(Field->getLocation(), diag::note_declared_at);
16100 if (!BaseType->isRecordType() && BaseType.isConstQualified()) {
16101 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
16102 <<
Context.getCanonicalTagType(ClassDecl) << 1
16103 << Field->getDeclName();
16104 Diag(Field->getLocation(), diag::note_declared_at);
16110 if (Field->isZeroLengthBitField())
16113 QualType FieldType = Field->getType().getNonReferenceType();
16116 "Incomplete array type is not valid");
16121 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
16126 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
16127 MemberBuilder To(ObjectParameter, ObjectType, IsArrow, MemberLookup);
16133 if (
Copy.isInvalid()) {
16139 Statements.push_back(
Copy.getAs<
Stmt>());
16145 (ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
16146 :
LangOpts.HLSL ?
static_cast<ExprBuilder &
>(*This)
16147 :
static_cast<ExprBuilder &
>(*DerefThis))
16148 .build(*
this, Loc);
16153 Statements.push_back(Return.
getAs<
Stmt>());
16166 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
16172 L->CompletedImplicitDefinition(CopyAssignOperator);
16179 DeclaringSpecialMember DSM(*
this, ClassDecl,
16181 if (DSM.isAlreadyBeingDeclared())
16188 std::nullopt, ClassDecl,
16218 CUDA().inferTargetForImplicitSpecialMember(
16225 ClassLoc, ClassLoc,
16238 ++
getASTContext().NumImplicitMoveAssignmentOperatorsDeclared;
16261 assert(!Class->isDependentContext() &&
"should not define dependent move");
16267 if (Class->getNumVBases() == 0 || Class->hasTrivialMoveAssignment() ||
16268 Class->getNumBases() < 2)
16272 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
16275 for (
auto &BI : Class->bases()) {
16276 Worklist.push_back(&BI);
16277 while (!Worklist.empty()) {
16283 if (!
Base->hasNonTrivialMoveAssignment())
16308 VBases.insert(std::make_pair(
Base->getCanonicalDecl(), &BI))
16310 if (Existing && Existing != &BI) {
16311 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
16314 << (
Base->getCanonicalDecl() ==
16317 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
16318 << (
Base->getCanonicalDecl() ==
16319 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
16323 Existing =
nullptr;
16333 llvm::append_range(Worklist, llvm::make_pointer_range(
Base->bases()));
16341 DefaultedFunctionFPFeaturesRAII RestoreFP(*
this, MoveAssignOperator);
16347 "DefineImplicitMoveAssignment called for wrong function");
16377 Scope.addContextNote(CurrentLocation);
16393 RefBuilder OtherRef(
Other, OtherRefType);
16395 MoveCastBuilder MoveOther(OtherRef);
16398 std::optional<ThisBuilder>
This;
16399 std::optional<DerefBuilder> DerefThis;
16400 std::optional<RefBuilder> ExplicitObject;
16402 bool IsArrow =
false;
16407 ExplicitObject.emplace(MoveAssignOperator->
getParamDecl(0), ObjectType);
16411 DerefThis.emplace(*
This);
16414 ExprBuilder &ObjectParameter =
16415 ExplicitObject ? *ExplicitObject :
static_cast<ExprBuilder &
>(*This);
16419 for (
auto &
Base : ClassDecl->
bases()) {
16430 QualType BaseType =
Base.getType().getUnqualifiedType();
16431 if (!BaseType->isRecordType()) {
16437 BasePath.push_back(&
Base);
16441 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
16446 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
16447 :
static_cast<ExprBuilder &
>(*DerefThis),
16456 if (Move.isInvalid()) {
16462 Statements.push_back(Move.getAs<
Expr>());
16469 ExprBuilder &To = ExplicitObject
16470 ?
static_cast<ExprBuilder &
>(*ExplicitObject)
16471 :
static_cast<ExprBuilder &
>(*DerefThis);
16478 *
this, Loc,
Context.getCanonicalTagType(ClassDecl), To, OtherRef);
16479 if (
Copy.isInvalid()) {
16483 Statements.push_back(
Copy.getAs<
Stmt>());
16487 for (
auto *Field : ClassDecl->
fields()) {
16489 if (Field->isUnnamedBitField() || Field->getParent()->isUnion())
16492 if (Field->isInvalidDecl()) {
16498 if (Field->getType()->isReferenceType()) {
16499 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
16500 <<
Context.getCanonicalTagType(ClassDecl) << 0
16501 << Field->getDeclName();
16502 Diag(Field->getLocation(), diag::note_declared_at);
16509 if (!BaseType->isRecordType() && BaseType.isConstQualified()) {
16510 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
16511 <<
Context.getCanonicalTagType(ClassDecl) << 1
16512 << Field->getDeclName();
16513 Diag(Field->getLocation(), diag::note_declared_at);
16519 if (Field->isZeroLengthBitField())
16522 QualType FieldType = Field->getType().getNonReferenceType();
16525 "Incomplete array type is not valid");
16530 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
16534 MemberBuilder From(MoveOther, OtherRefType,
16535 false, MemberLookup);
16536 MemberBuilder To(ObjectParameter, ObjectType, IsArrow, MemberLookup);
16538 assert(!From.build(*
this, Loc)->isLValue() &&
16539 "Member reference with rvalue base must be rvalue except for reference "
16540 "members, which aren't allowed for move assignment.");
16547 if (Move.isInvalid()) {
16553 Statements.push_back(Move.getAs<
Stmt>());
16559 (ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
16560 :
LangOpts.HLSL ?
static_cast<ExprBuilder &
>(*This)
16561 :
static_cast<ExprBuilder &
>(*DerefThis))
16562 .build(*
this, Loc);
16568 Statements.push_back(Return.
getAs<
Stmt>());
16581 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
16587 L->CompletedImplicitDefinition(MoveAssignOperator);
16598 DeclaringSpecialMember DSM(*
this, ClassDecl,
16600 if (DSM.isAlreadyBeingDeclared())
16604 std::nullopt, ClassDecl,
16621 =
Context.DeclarationNames.getCXXConstructorName(
16622 Context.getCanonicalType(ClassType));
16641 CUDA().inferTargetForImplicitSpecialMember(
16667 ClassDecl->
hasAttr<TrivialABIAttr>() ||
16700 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
16705 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
16716 Scope.addContextNote(CurrentLocation);
16746 DeclaringSpecialMember DSM(*
this, ClassDecl,
16748 if (DSM.isAlreadyBeingDeclared())
16752 std::nullopt, ClassDecl,
16765 =
Context.DeclarationNames.getCXXConstructorName(
16766 Context.getCanonicalType(ClassType));
16786 CUDA().inferTargetForImplicitSpecialMember(
16793 ClassLoc, ClassLoc,
16806 ClassDecl->
hasAttr<TrivialABIAttr>() ||
16839 "DefineImplicitMoveConstructor - call it for implicit move ctor");
16844 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
16855 Scope.addContextNote(CurrentLocation);
16901 if (CallOp != Invoker) {
16920 if (Invoker != CallOp) {
16933 assert(FunctionRef &&
"Can't refer to __invoke function?");
16941 L->CompletedImplicitDefinition(Conv);
16942 if (Invoker != CallOp)
16943 L->CompletedImplicitDefinition(Invoker);
16971 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
16980 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
16986 Stmt *ReturnS = Return.
get();
16993 L->CompletedImplicitDefinition(Conv);
17000 switch (Args.size()) {
17005 if (!Args[1]->isDefaultArgument())
17010 return !Args[0]->isDefaultArgument();
17019 bool HadMultipleCandidates,
bool IsListInitialization,
17020 bool IsStdInitListInitialization,
bool RequiresZeroInit,
17022 bool Elidable =
false;
17041 Expr *SubExpr = ExprArgs[0];
17052 Elidable, ExprArgs, HadMultipleCandidates,
17053 IsListInitialization,
17054 IsStdInitListInitialization, RequiresZeroInit,
17055 ConstructKind, ParenRange);
17061 bool HadMultipleCandidates,
bool IsListInitialization,
17062 bool IsStdInitListInitialization,
bool RequiresZeroInit,
17064 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
17074 ConstructLoc, DeclInitType,
Constructor, Elidable, ExprArgs,
17075 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
17076 RequiresZeroInit, ConstructKind, ParenRange);
17084 bool HadMultipleCandidates,
bool IsListInitialization,
17085 bool IsStdInitListInitialization,
bool RequiresZeroInit,
17090 "given constructor for wrong type");
17098 HadMultipleCandidates, IsListInitialization,
17099 IsStdInitListInitialization, RequiresZeroInit,
17131 PDiag(diag::err_access_dtor_var)
17141 bool HasConstantInit =
false;
17149 diag::err_constexpr_var_requires_const_destruction) << VD;
17160 if (!VD->
hasAttr<AlwaysDestroyAttr>())
17172 bool AllowExplicit,
17173 bool IsListInitialization) {
17175 unsigned NumArgs = ArgsPtr.size();
17176 Expr **Args = ArgsPtr.data();
17182 if (NumArgs < NumParams)
17183 ConvertedArgs.reserve(NumParams);
17185 ConvertedArgs.reserve(NumArgs);
17193 CallType, AllowExplicit, IsListInitialization);
17194 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
17205 bool SeenTypedOperators =
Context.hasSeenTypeAwareOperatorNewOrDelete();
17212 if (DeallocType.
isNull())
17223 constexpr unsigned RequiredParameterCount =
17226 if (NumParams != RequiredParameterCount)
17231 if (llvm::any_of(FnDecl->
parameters().drop_front(),
17233 return ParamDecl->getType()->isDependentType();
17238 if (SpecializedTypeIdentity.
isNull())
17242 ArgTypes.reserve(NumParams);
17248 ArgTypes.push_back(SpecializedTypeIdentity);
17269 diag::err_operator_new_delete_declared_in_namespace)
17276 diag::err_operator_new_delete_declared_static)
17286 Qualifiers PtrQuals = PtrTy->getPointeeType().getQualifiers();
17289 PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals)));
17296 bool *WasMalformed) {
17297 const Decl *MalformedDecl =
nullptr;
17300 nullptr, &MalformedDecl))
17303 if (!MalformedDecl)
17307 *WasMalformed =
true;
17325 SemaRef, FD,
nullptr);
17326 unsigned DestroyingDeleteIdx = IsPotentiallyTypeAware + 1;
17335 unsigned DependentParamTypeDiag,
unsigned InvalidParamTypeDiag) {
17336 auto NormalizeType = [&SemaRef](
QualType T) {
17340 if (
const auto PtrTy =
T->template getAs<PointerType>())
17347 unsigned FirstNonTypeParam = 0;
17348 bool MalformedTypeIdentity =
false;
17350 SemaRef, FnDecl, &MalformedTypeIdentity);
17351 unsigned MinimumMandatoryArgumentCount = 1;
17352 unsigned SizeParameterIndex = 0;
17353 if (IsPotentiallyTypeAware) {
17357 SemaRef.
Diag(FnDecl->
getLocation(), diag::warn_ext_type_aware_allocators);
17360 SizeParameterIndex = 1;
17361 MinimumMandatoryArgumentCount =
17364 SizeParameterIndex = 2;
17365 MinimumMandatoryArgumentCount =
17368 FirstNonTypeParam = 1;
17371 bool IsPotentiallyDestroyingDelete =
17374 if (IsPotentiallyDestroyingDelete) {
17375 ++MinimumMandatoryArgumentCount;
17376 ++SizeParameterIndex;
17379 if (NumParams < MinimumMandatoryArgumentCount)
17381 diag::err_operator_new_delete_too_few_parameters)
17382 << IsPotentiallyTypeAware << IsPotentiallyDestroyingDelete
17383 << FnDecl->
getDeclName() << MinimumMandatoryArgumentCount;
17385 for (
unsigned Idx = 0; Idx < MinimumMandatoryArgumentCount; ++Idx) {
17389 diag::err_operator_new_default_arg)
17394 QualType CanResultType = NormalizeType(FnType->getReturnType());
17395 QualType CanExpectedResultType = NormalizeType(ExpectedResultType);
17396 QualType CanExpectedSizeOrAddressParamType =
17397 NormalizeType(ExpectedSizeOrAddressParamType);
17400 if (CanResultType != CanExpectedResultType) {
17403 return SemaRef.
Diag(
17405 CanResultType->isDependentType()
17406 ? diag::err_operator_new_delete_dependent_result_type
17407 : diag::err_operator_new_delete_invalid_result_type)
17414 diag::err_operator_new_delete_template_too_few_parameters)
17418 auto FallbackType) ->
bool {
17422 << IsPotentiallyTypeAware << IsPotentiallyDestroyingDelete
17428 auto ActualParamType =
17430 if (ActualParamType == CanExpectedTy)
17432 unsigned Diagnostic = ActualParamType->isDependentType()
17433 ? DependentParamTypeDiag
17434 : InvalidParamTypeDiag;
17436 << IsPotentiallyTypeAware << IsPotentiallyDestroyingDelete
17442 if (CheckType(FirstNonTypeParam, CanExpectedSizeOrAddressParamType,
"size_t"))
17449 if (!IsPotentiallyTypeAware)
17458 if (CheckType(SizeParameterIndex + 1, StdAlignValT,
"std::align_val_t"))
17462 return MalformedTypeIdentity;
17481 SizeTy, diag::err_operator_new_dependent_param_type,
17482 diag::err_operator_new_param_type);
17494 auto *MD = dyn_cast<CXXMethodDecl>(FnDecl);
17495 auto ConstructDestroyingDeleteAddressType = [&]() {
17508 SemaRef, MD,
nullptr)) {
17512 AddressParamType == ConstructDestroyingDeleteAddressType()) {
17523 diag::err_type_aware_destroying_operator_delete)
17524 << Param->getSourceRange();
17546 diag::err_operator_delete_dependent_param_type,
17547 diag::err_operator_delete_param_type))
17556 diag::err_destroying_operator_delete_not_usual);
17566 "Expected an overloaded operator declaration");
17576 if (Op == OO_Delete || Op == OO_Array_Delete)
17579 if (Op == OO_New || Op == OO_Array_New)
17589 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
17590 if (MethodDecl->isStatic()) {
17591 if (Op == OO_Call || Op == OO_Subscript)
17595 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_static)
17599 bool ClassOrEnumParam =
false;
17601 QualType ParamType = Param->getType().getNonReferenceType();
17604 ClassOrEnumParam =
true;
17609 if (!ClassOrEnumParam)
17611 diag::err_operator_overload_needs_class_or_enum)
17621 if (Op != OO_Call) {
17624 if (Param->hasDefaultArg()) {
17625 FirstDefaultedParam = Param;
17629 if (FirstDefaultedParam) {
17630 if (Op == OO_Subscript) {
17632 ? diag::ext_subscript_overload
17633 : diag::error_subscript_overload)
17638 diag::err_operator_overload_default_arg)
17646 {
false,
false,
false }
17647#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
17648 , { Unary, Binary, MemberOnly }
17649#include "clang/Basic/OperatorKinds.def"
17652 bool CanBeUnaryOperator = OperatorUses[Op][0];
17653 bool CanBeBinaryOperator = OperatorUses[Op][1];
17654 bool MustBeMemberOperator = OperatorUses[Op][2];
17665 if (Op != OO_Call && Op != OO_Subscript &&
17666 ((NumParams == 1 && !CanBeUnaryOperator) ||
17667 (NumParams == 2 && !CanBeBinaryOperator) || (NumParams < 1) ||
17668 (NumParams > 2))) {
17670 unsigned ErrorKind;
17671 if (CanBeUnaryOperator && CanBeBinaryOperator) {
17673 }
else if (CanBeUnaryOperator) {
17676 assert(CanBeBinaryOperator &&
17677 "All non-call overloaded operators are unary or binary!");
17680 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
17681 << FnDecl->
getDeclName() << NumParams << ErrorKind;
17684 if (Op == OO_Subscript && NumParams != 2) {
17686 ? diag::ext_subscript_overload
17687 : diag::error_subscript_overload)
17688 << FnDecl->
getDeclName() << (NumParams == 1 ? 0 : 2);
17693 if (Op != OO_Call &&
17695 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
17702 diag::err_operator_overload_must_be_member)
17716 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
17723 diag::err_operator_overload_post_incdec_must_be_int)
17724 << LastParam->
getType() << (Op == OO_MinusMinus);
17736 if (TemplateParams->
size() == 1) {
17738 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(0));
17752 if (SemaRef.
getLangOpts().CPlusPlus20 && PmDecl &&
17755 PmDecl->
getType()->
getAs<DeducedTemplateSpecializationType>()))
17757 }
else if (TemplateParams->
size() == 2) {
17759 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
getParam(0));
17761 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(1));
17767 if (
const auto *TArgs =
17769 TArgs && TArgs->getDepth() == PmType->
getDepth() &&
17770 TArgs->getIndex() == PmType->
getIndex()) {
17773 diag::ext_string_literal_operator_template);
17780 diag::err_literal_operator_template)
17787 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
17796 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
17815 diag::err_literal_operator_template_with_params);
17825 QualType ParamType = Param->getType().getUnqualifiedType();
17837 QualType InnerType = Ptr->getPointeeType();
17843 Diag(Param->getSourceRange().getBegin(),
17844 diag::err_literal_operator_param)
17845 << ParamType <<
"'const char *'" << Param->getSourceRange();
17850 Diag(Param->getSourceRange().getBegin(), diag::err_literal_operator_param)
17851 << ParamType <<
Context.LongDoubleTy << Param->getSourceRange();
17855 Diag(Param->getSourceRange().getBegin(), diag::err_literal_operator_param)
17856 << ParamType <<
Context.UnsignedLongLongTy << Param->getSourceRange();
17860 Diag(Param->getSourceRange().getBegin(),
17861 diag::err_literal_operator_invalid_param)
17862 << ParamType << Param->getSourceRange();
17871 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
17878 Diag((*Param)->getSourceRange().getBegin(),
17879 diag::err_literal_operator_param)
17880 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
17887 Diag((*Param)->getSourceRange().getBegin(),
17888 diag::err_literal_operator_param)
17889 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
17902 Diag((*Param)->getSourceRange().getBegin(),
17903 diag::err_literal_operator_param)
17904 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
17912 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
17913 if (!
Context.hasSameType(SecondParamType,
Context.getSizeType())) {
17914 Diag((*Param)->getSourceRange().getBegin(),
17915 diag::err_literal_operator_param)
17916 << SecondParamType <<
Context.getSizeType()
17917 << (*Param)->getSourceRange();
17921 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
17930 if (Param->hasDefaultArg()) {
17931 Diag(Param->getDefaultArgRange().getBegin(),
17932 diag::err_literal_operator_default_argument)
17933 << Param->getDefaultArgRange();
17948 <<
static_cast<int>(Status)
17959 assert(Lit->
isUnevaluated() &&
"Unexpected string literal kind");
17965 else if (Lang ==
"C++")
17968 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
17988 if (
getLangOpts().CPlusPlusModules && isCurrentModulePurview()) {
17989 Module *GlobalModule = PushImplicitGlobalModuleFragment(ExternLoc);
18012 PopImplicitGlobalModuleFragment();
18015 return LinkageSpec;
18039 ExDeclType =
Context.getArrayDecayedType(ExDeclType);
18041 ExDeclType =
Context.getPointerType(ExDeclType);
18048 Diag(Loc, diag::err_catch_rvalue_ref);
18053 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
18059 unsigned DK = diag::err_catch_incomplete;
18061 BaseType = Ptr->getPointeeType();
18063 DK = diag::err_catch_incomplete_ptr;
18066 BaseType = Ref->getPointeeType();
18068 DK = diag::err_catch_incomplete_ref;
18070 if (!
Invalid && (Mode == 0 || !BaseType->isVoidType()) &&
18074 if (!
Invalid && BaseType.isWebAssemblyReferenceType()) {
18075 Diag(Loc, diag::err_wasm_reftype_tc) << 1;
18085 Diag(Loc, diag::err_throw_or_catch_address_space_qualified_ptr)
18086 << 1 << 0 << ExDeclType;
18089 }
else if (Mode == 2) {
18093 Diag(Loc, diag::err_throw_or_catch_address_space_qualified_ptr)
18094 << 1 << 0 << ExDeclType;
18097 Diag(Loc, diag::err_throw_or_catch_address_space_qualified_ptr)
18098 << 1 << 1 << ExDeclType;
18103 if (!
Invalid && Mode != 1 && BaseType->isSizelessType()) {
18104 Diag(Loc, diag::err_catch_sizeless) << (Mode == 2 ? 1 : 0) << BaseType;
18110 diag::err_abstract_type_in_decl,
18119 T = RT->getPointeeType();
18121 if (
T->isObjCObjectType()) {
18122 Diag(Loc, diag::err_objc_object_catch);
18124 }
else if (
T->isObjCObjectPointerType()) {
18127 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
18136 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(ExDecl))
18161 Expr *opaqueValue =
18211 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
18213 }
else if (PrevDecl->isTemplateParameter())
18241 Expr *AssertMessageExpr,
18247 AssertMessageExpr, RParenLoc,
false);
18252 case BuiltinType::Char_S:
18253 case BuiltinType::Char_U:
18255 case BuiltinType::Char8:
18258 case BuiltinType::Char16:
18261 case BuiltinType::Char32:
18264 case BuiltinType::WChar_S:
18265 case BuiltinType::WChar_U:
18269 llvm_unreachable(
"Non-character type");
18279 char Arr[UNI_MAX_UTF8_BYTES_PER_CODE_POINT];
18282 llvm::raw_svector_ostream OS(Str);
18286 if (K == BuiltinType::Char_S || K == BuiltinType::Char_U ||
18287 K == BuiltinType::Char8 ||
Value <= 0x7F) {
18289 if (!Escaped.empty())
18292 OS << static_cast<char>(
Value);
18297 case BuiltinType::Char16:
18298 case BuiltinType::Char32:
18299 case BuiltinType::WChar_S:
18300 case BuiltinType::WChar_U: {
18301 if (llvm::ConvertCodePointToUTF8(
Value, Ptr))
18305 << llvm::format_hex_no_prefix(
Value, TyWidth / 4,
true);
18309 llvm_unreachable(
"Non-character type is passed");
18321 switch (
V.getKind()) {
18323 if (
T->isBooleanType()) {
18327 int64_t BoolValue =
V.getInt().getExtValue();
18328 assert((BoolValue == 0 || BoolValue == 1) &&
18329 "Bool type, but value is not 0 or 1");
18330 llvm::raw_svector_ostream OS(Str);
18331 OS << (BoolValue ?
"true" :
"false");
18333 llvm::raw_svector_ostream OS(Str);
18338 switch (BTy->getKind()) {
18339 case BuiltinType::Char_S:
18340 case BuiltinType::Char_U:
18341 case BuiltinType::Char8:
18342 case BuiltinType::Char16:
18343 case BuiltinType::Char32:
18344 case BuiltinType::WChar_S:
18345 case BuiltinType::WChar_U: {
18346 unsigned TyWidth = Context.getIntWidth(
T);
18347 assert(8 <= TyWidth && TyWidth <= 32 &&
"Unexpected integer width");
18353 << llvm::format_hex_no_prefix(CodeUnit, 2,
18355 <<
", " <<
V.getInt() <<
')';
18362 V.getInt().toString(Str);
18368 V.getFloat().toString(Str);
18372 if (
V.isNullPointer()) {
18373 llvm::raw_svector_ostream OS(Str);
18380 llvm::raw_svector_ostream OS(Str);
18382 V.getComplexFloatReal().toString(Str);
18384 V.getComplexFloatImag().toString(Str);
18389 llvm::raw_svector_ostream OS(Str);
18391 V.getComplexIntReal().toString(Str);
18393 V.getComplexIntImag().toString(Str);
18420 if (
const auto *UnaryOp = dyn_cast<UnaryOperator>(E))
18424 if (
const auto *BO = dyn_cast<BinaryOperator>(E))
18425 return (BO->isShiftOp() || BO->isAdditiveOp() || BO->isMultiplicativeOp() ||
18426 BO->isBitwiseOp());
18434 if (
const auto *Op = dyn_cast<BinaryOperator>(E);
18435 Op && Op->getOpcode() != BO_LOr) {
18436 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
18437 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
18455 for (
auto &DiagSide : DiagSides) {
18456 const Expr *Side = DiagSide.Cond;
18461 DiagSide.Result.Val, Side->
getType(), DiagSide.ValueString,
Context);
18463 if (DiagSides[0].Print && DiagSides[1].Print) {
18464 Diag(Op->getExprLoc(), diag::note_expr_evaluates_to)
18465 << DiagSides[0].ValueString << Op->getOpcodeStr()
18466 << DiagSides[1].ValueString << Op->getSourceRange();
18468 }
else if (
const auto *RE = dyn_cast<RequiresExpr>(E)) {
18475template <
typename ResultType>
18479 bool ErrorOnInvalidMessage) {
18482 assert(!Message->isTypeDependent() && !Message->isValueDependent() &&
18483 "can't evaluate a dependant static assert message");
18485 if (
const auto *SL = dyn_cast<StringLiteral>(Message)) {
18486 assert(SL->isUnevaluated() &&
"expected an unevaluated string");
18487 if constexpr (std::is_same_v<APValue, ResultType>) {
18492 assert(CAT &&
"string literal isn't an array");
18496 for (
unsigned I = 0; I < SL->getLength(); I++) {
18497 Value = SL->getCodeUnit(I);
18501 Result.assign(SL->getString().begin(), SL->getString().end());
18507 QualType T = Message->getType().getNonReferenceType();
18508 auto *RD =
T->getAsCXXRecordDecl();
18510 SemaRef.
Diag(Loc, diag::err_user_defined_msg_invalid) << EvalContext;
18514 auto FindMember = [&](StringRef
Member) -> std::optional<LookupResult> {
18518 if (MemberLookup.
empty())
18519 return std::nullopt;
18520 return std::move(MemberLookup);
18523 std::optional<LookupResult> SizeMember = FindMember(
"size");
18524 std::optional<LookupResult> DataMember = FindMember(
"data");
18525 if (!SizeMember || !DataMember) {
18526 SemaRef.
Diag(Loc, diag::err_user_defined_msg_missing_member_function)
18528 << ((!SizeMember && !DataMember) ? 2
18536 Message, Message->getType(), Message->getBeginLoc(),
false,
18562 SemaRef.
Diag(Loc, diag::err_user_defined_msg_invalid_mem_fn_ret_ty)
18563 << EvalContext << 0;
18573 SemaRef.
Diag(Loc, diag::err_user_defined_msg_invalid_mem_fn_ret_ty)
18574 << EvalContext << 1;
18578 if (!ErrorOnInvalidMessage &&
18579 SemaRef.
Diags.
isIgnored(diag::warn_user_defined_msg_constexpr, Loc))
18584 Status.Diag = &Notes;
18586 if (!Message->EvaluateCharRangeAsString(
Result, EvaluatedSize.
get(),
18587 EvaluatedData.
get(), Ctx, SProxy,
18590 SemaRef.
Diag(Message->getBeginLoc(),
18591 ErrorOnInvalidMessage ? diag::err_user_defined_msg_constexpr
18592 : diag::warn_user_defined_msg_constexpr)
18594 for (
const auto &
Note : Notes)
18596 return !ErrorOnInvalidMessage;
18603 bool ErrorOnInvalidMessage) {
18605 ErrorOnInvalidMessage);
18610 bool ErrorOnInvalidMessage) {
18612 ErrorOnInvalidMessage);
18616 Expr *AssertExpr,
Expr *AssertMessage,
18619 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
18637 AssertExpr = FullAssertExpr.
get();
18640 Expr *BaseExpr = AssertExpr;
18652 diag::err_static_assert_expression_is_not_constant,
18658 if (!Failed && AssertMessage && Cond.getBoolValue()) {
18668 bool InTemplateDefinition =
18671 if (!Failed && !Cond && !InTemplateDefinition) {
18673 llvm::raw_svector_ostream Msg(MsgBuffer);
18674 bool HasMessage = AssertMessage;
18675 if (AssertMessage) {
18683 Expr *InnerCond =
nullptr;
18684 std::string InnerCondDescription;
18685 std::tie(InnerCond, InnerCondDescription) =
18687 if (
const auto *ConceptIDExpr =
18688 dyn_cast_or_null<ConceptSpecializationExpr>(InnerCond)) {
18690 ConceptIDExpr->getSatisfaction();
18701 diag::err_static_assert_requirement_failed)
18702 << InnerCondDescription << !HasMessage << Msg.str()
18719 AssertExpr = FullAssertExpr.
get();
18723 AssertExpr, AssertMessage, RParenLoc,
18731 if (
const auto *PIT = dyn_cast<PackIndexingType>(
T))
18732 return PIT->getPattern();
18736static const TemplateSpecializationType *
18739 if (
const auto *ICNT = dyn_cast<InjectedClassNameType>(
T))
18740 T = ICNT->getDecl()->getCanonicalTemplateSpecializationType(Context);
18742 const auto *TST = dyn_cast<TemplateSpecializationType>(
T);
18746 TemplateDecl *TD = TST->getTemplateName().getAsTemplateDecl();
18768 if (
const auto *TST =
18770 if (isa_and_nonnull<TypeAliasTemplateDecl>(
18771 TST->getTemplateName().getAsTemplateDecl())) {
18772 S.
Diag(Loc, diag::err_dependent_friend_not_member_of_template_spec)
18779 S.
Diag(Loc, diag::err_dependent_friend_not_member_of_template_spec) << NNS;
18781 S.
Diag(Loc, diag::err_dependent_friend_not_member);
18788 bool IsInstantiation) {
18794 "nested-name-specifier of dependent friend must be a type");
18800 const TemplateSpecializationType *TST =
18812 llvm::SmallBitVector UsedParameters(Params->size());
18814 true, Params->getDepth(),
18817 for (
unsigned I = 0, N = UsedParameters.size(); I != N; ++I)
18818 if (!UsedParameters[I])
18819 UndeducedParameters.push_back(Params->getParam(I));
18822 if (UndeducedParameters.empty())
18825 Diag(Loc, diag::err_dependent_friend_undeduced_params)
18826 << (UndeducedParameters.size() > 1) <<
QualType(TST, 0);
18828 for (
NamedDecl *Param : UndeducedParameters) {
18829 if (Param->getDeclName())
18830 Diag(Param->getLocation(), diag::note_non_deducible_parameter)
18831 << Param->getDeclName();
18833 Diag(Param->getLocation(), diag::note_non_deducible_parameter)
18847 bool IsMemberSpecialization =
false;
18852 TempParamLists,
true,
18853 IsMemberSpecialization,
Invalid);
18858 if (TemplateParams) {
18859 Diag(NameLoc, diag::err_not_class_template_specialization) << 0;
18864 if (TemplateParams) {
18865 if (TemplateParams->
size() > 0) {
18873 FriendLoc, TempParamLists.size() - 1, TempParamLists.data(),
18874 IsMemberSpecialization);
18887 bool IsAllExplicitSpecializations =
18889 return List->
size() == 0;
18898 if (!TemplateId && IsAllExplicitSpecializations) {
18900 bool Owned =
false;
18901 bool IsDependent =
false;
18918 NameLoc, &TSI,
true);
18923 FriendLoc, EllipsisLoc);
18929 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
18932 if (TemplateParams)
18933 TPLs = TPLs.drop_back();
18953 TSI =
Context.CreateTypeSourceInfo(
T);
18966 }
else if (Unexpanded.empty()) {
18967 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
18973 if (!TempParamLists.empty()) {
18974 unsigned FriendDeclDepth = TempParamLists.front()->getDepth();
18976 if (std::optional<std::pair<unsigned, unsigned>> DI =
18978 DI && DI->first >= FriendDeclDepth) {
18979 auto *ND = dyn_cast<NamedDecl *>(
U.first);
18982 Diag(
U.second, diag::friend_template_decl_malformed_pack_expansion)
18992 if (TempParamLists.empty())
19000 if (TemplateParams)
19033 Diag(FriendLoc, diag::err_friend_not_first_in_declaration);
19065 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
19070 if (!
T->isElaboratedTypeSpecifier()) {
19071 if (TempParams.size()) {
19083 }
else if (
const RecordDecl *RD =
T->getAsRecordDecl()) {
19088 ? diag::warn_cxx98_compat_unelaborated_friend_type
19089 : diag::ext_unelaborated_friend_type)
19094 DiagCompat(FriendLoc, diag_compat::nonclass_type_friend)
19111 if (!TempParams.empty()) {
19117 TempParams, EllipsisLoc);
19120 TSI, FriendLoc, EllipsisLoc);
19155 Diag(Loc, diag::err_unexpected_friend);
19197 if (IsNamespaceOrGlobal) {
19207 Scope *DCScope = S;
19217 (FunctionContainingLocalClass =
19240 DC =
Previous.getRepresentativeDecl()->getDeclContext();
19244 DC = FunctionContainingLocalClass;
19281 if (isTemplateId) {
19296 if (!DC)
return nullptr;
19307 diag::warn_cxx98_compat_friend_is_member :
19308 diag::err_friend_is_member);
19341 if (DiagArg >= 0) {
19342 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
19358 DCScope = &FakeDCScope;
19361 bool AddToScope =
true;
19363 TemplateParams, AddToScope);
19364 if (!ND)
return nullptr;
19391 Friend->setInvalidDecl();
19397 assert(FD &&
"Expected a function declaration!");
19404 if (!TPLs.empty() && SS.
isValid())
19418 if (!TemplateParams.empty() && SS.
isValid() &&
19437 }
else if (FunctionContainingLocalClass) {
19446 }
else if (isTemplateId) {
19460 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
19462 diag::note_previous_declaration);
19464 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
19474 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
19476 Diag(DelLoc, diag::err_deleted_non_function);
19481 Fn->setWillHaveBody(
false);
19483 if (
const FunctionDecl *Prev = Fn->getPreviousDecl()) {
19487 Prev->getPreviousDecl()) &&
19488 !Prev->isDefined()) {
19489 Diag(DelLoc, diag::err_deleted_decl_not_first);
19490 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
19491 Prev->isImplicit() ? diag::note_previous_implicit_declaration
19492 : diag::note_previous_declaration);
19495 Fn->setInvalidDecl();
19503 Fn = Fn->getCanonicalDecl();
19508 Diag(Fn->getLocation(), diag::err_attribute_dll_deleted) << DLLAttr;
19509 Fn->setInvalidDecl();
19515 Diag(DelLoc, diag::err_deleted_main);
19519 Fn->setImplicitlyInline();
19520 Fn->setDeletedAsWritten(
true, Message);
19528 unsigned DefaultableKinds = diag::DefaultableFunctionKinds::Default;
19530 DefaultableKinds = diag::DefaultableFunctionKinds::Cxx29;
19532 DefaultableKinds = diag::DefaultableFunctionKinds::Cxx20;
19534 auto *FD = dyn_cast<FunctionDecl>(Dcl);
19536 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(Dcl)) {
19538 FTD->getTemplatedDecl()->getDefaultedFunctionKind();
19540 Diag(DefaultLoc, diag::err_defaulted_operator_template)
19546 Diag(DefaultLoc, diag::err_default_special_members) << DefaultableKinds;
19556 (!FD->isDependentContext() ||
19560 if (OO == OO_PlusPlus || OO == OO_MinusMinus)
19561 Diag(DefaultLoc, diag::err_defaulted_prefix_operator)
19562 << (OO == OO_MinusMinus);
19564 Diag(DefaultLoc, diag::err_default_special_members) << DefaultableKinds;
19572 DiagCompat(DefaultLoc, diag_compat::defaulted_comparison);
19577 DiagCompat(DefaultLoc, diag_compat::defaulted_postfix_operator);
19579 FD->setDefaulted();
19580 FD->setExplicitlyDefaulted();
19581 FD->setDefaultLoc(DefaultLoc);
19584 if (FD->isDependentContext()) {
19598 else if (!FD->getDefaultedOrDeletedInfo())
19599 FD->setDefaultedOrDeletedInfo(
19609 FD->setWillHaveBody(
false);
19624 if (
const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern())
19639 FD->setDefaultedOrDeletedInfo(
19653 else if (!FD->isDeleted())
19672 Self.Diag(SubStmt->getBeginLoc(),
19673 diag::err_return_in_constructor_handler);
19680 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
19688 switch (BodyKind) {
19697 "Parsed function body should be '= delete;' or '= default;'");
19707 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
19711 !NewFT->getExtParameterInfo(I).isNoEscape()) {
19712 Diag(
New->getParamDecl(I)->getLocation(),
19713 diag::warn_overriding_method_missing_noescape);
19715 diag::note_overridden_marked_noescape);
19721 Diag(
New->getLocation(), diag::err_conflicting_overriding_attributes)
19728 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
19729 const auto *NewCSA =
New->getAttr<CodeSegAttr>();
19730 if ((NewCSA || OldCSA) &&
19731 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
19732 Diag(
New->getLocation(), diag::err_mismatched_code_seg_override);
19738 if (
Context.hasAnyFunctionEffects()) {
19740 const auto NewFXOrig =
New->getFunctionEffects();
19742 if (OldFX != NewFXOrig) {
19746 for (
const auto &Diff : Diffs) {
19747 switch (Diff.shouldDiagnoseMethodOverride(*Old, OldFX, *
New, NewFX)) {
19751 Diag(
New->getLocation(), diag::warn_conflicting_func_effect_override)
19752 << Diff.effectName();
19757 NewFX.
insert(Diff.Old.value(), Errs);
19762 NewFT->getParamTypes(), EPI);
19763 New->setType(ModQT);
19764 if (Errs.empty()) {
19767 Diag(
New->getLocation(), diag::warn_mismatched_func_effect_override)
19768 << Diff.effectName();
19785 if (NewCC == OldCC)
19796 diag::err_conflicting_overriding_cc_attributes)
19806 if (!
New->isExplicitObjectMemberFunction())
19808 Diag(
New->getParamDecl(0)->getBeginLoc(),
19809 diag::err_explicit_object_parameter_nonmember)
19810 <<
New->getSourceRange() << 1 <<
false;
19812 New->setInvalidDecl();
19821 if (
Context.hasSameType(NewTy, OldTy) ||
19836 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
19846 diag::err_different_return_type_for_overriding_virtual_function)
19847 <<
New->getDeclName() << NewTy << OldTy
19848 <<
New->getReturnTypeSourceRange();
19855 if (!
Context.hasSameUnqualifiedType(NewClassTy, OldClassTy)) {
19864 diag::err_covariant_return_incomplete,
19865 New->getDeclName()))
19871 Diag(
New->getLocation(), diag::err_covariant_return_not_derived)
19872 <<
New->getDeclName() << NewTy << OldTy
19873 <<
New->getReturnTypeSourceRange();
19881 NewClassTy, OldClassTy,
19882 diag::err_covariant_return_inaccessible_base,
19883 diag::err_covariant_return_ambiguous_derived_to_base_conv,
19884 New->getLocation(),
New->getReturnTypeSourceRange(),
19885 New->getDeclName(),
nullptr)) {
19899 diag::err_covariant_return_type_different_qualifications)
19900 <<
New->getDeclName() << NewTy << OldTy
19901 <<
New->getReturnTypeSourceRange();
19911 diag::err_covariant_return_type_class_type_not_same_or_less_qualified)
19912 <<
New->getDeclName() << NewTy << OldTy
19913 <<
New->getReturnTypeSourceRange();
19925 Method->setRangeEnd(EndLoc);
19927 if (
Method->isVirtual() ||
Method->getParent()->isDependentContext()) {
19928 Method->setIsPureVirtual();
19932 if (!
Method->isInvalidDecl())
19933 Diag(
Method->getLocation(), diag::err_non_virtual_pure)
19934 <<
Method->getDeclName() << InitRange;
19941 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
19984 "Parser allowed 'typedef' as storage class of condition decl.");
19996 if (
auto *VD = dyn_cast<VarDecl>(Dcl))
20010 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos =
20014 if (!Pos->second && VTable.DefinitionRequired)
20015 Pos->second =
true;
20019 VTablesUsed[VTable.Record] = VTable.DefinitionRequired;
20020 NewUses.push_back(
VTableUse(VTable.Record, VTable.Location));
20027 bool DefinitionRequired) {
20030 if (!
Class->isDynamicClass() ||
Class->isDependentContext() ||
20036 !
OpenMP().isInOpenMPDeclareTargetContext() &&
20037 !
OpenMP().isInOpenMPTargetExecutionDirective()) {
20038 if (!DefinitionRequired)
20046 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
20052 if (DefinitionRequired && !Pos.first->second) {
20053 Pos.first->second =
true;
20063 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
20084 if (
Class->isLocalClass())
20099 bool DefinedAnything =
false;
20100 for (
unsigned I = 0; I !=
VTableUses.size(); ++I) {
20105 Class->getTemplateSpecializationKind();
20109 bool DefineVTable =
true;
20114 if (
Class->isInCurrentModuleUnit()) {
20115 DefineVTable =
true;
20116 }
else if (KeyFunction && !KeyFunction->
hasBody()) {
20121 DefineVTable =
false;
20126 "Instantiations don't have key functions");
20128 }
else if (!KeyFunction) {
20133 bool IsExplicitInstantiationDeclaration =
20135 for (
auto *R :
Class->redecls()) {
20139 IsExplicitInstantiationDeclaration =
true;
20141 IsExplicitInstantiationDeclaration =
false;
20146 if (IsExplicitInstantiationDeclaration) {
20147 const bool HasExcludeFromExplicitInstantiation =
20155 return method->hasAttr<ExcludeFromExplicitInstantiationAttr>();
20157 if (!HasExcludeFromExplicitInstantiation)
20158 DefineVTable =
false;
20165 if (!DefineVTable) {
20173 DefinedAnything =
true;
20181 !(
Class->isInNamedModule() &&
Class->shouldEmitInExternalSource()))
20187 if (
Context.getTargetInfo().getCXXABI().hasKeyFunctions() &&
20188 Class->isExternallyVisible() &&
20189 !(
Class->getOwningModule() &&
20190 Class->getOwningModule()->isInterfaceOrPartition()) &&
20195 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
20202 return DefinedAnything;
20207 for (
const auto *I : RD->
methods())
20208 if (I->isVirtual() && !I->isPureVirtual())
20214 bool ConstexprOnly) {
20218 for (
const auto &FinalOverrider : FinalOverriders) {
20219 for (
const auto &OverridingMethod : FinalOverrider.second) {
20220 assert(OverridingMethod.second.size() > 0 &&
"no final overrider");
20221 CXXMethodDecl *Overrider = OverridingMethod.second.front().Method;
20235 for (
const auto &I : RD->
bases()) {
20236 const auto *
Base = I.getType()->castAsCXXRecordDecl();
20237 if (
Base->getNumVBases() == 0)
20258 (void)
Target->hasBody(FNTarget);
20260 cast_or_null<CXXConstructorDecl>(FNTarget));
20265 *TCanonical =
Target?
Target->getCanonicalDecl() :
nullptr;
20267 if (!Current.insert(Canonical).second)
20272 Target->isInvalidDecl() ||
Valid.count(TCanonical)) {
20273 Valid.insert_range(Current);
20276 }
else if (TCanonical == Canonical ||
Invalid.count(TCanonical) ||
20277 Current.count(TCanonical)) {
20279 if (!
Invalid.count(TCanonical)) {
20281 diag::warn_delegating_ctor_cycle)
20285 if (TCanonical != Canonical)
20286 S.
Diag(
Target->getLocation(), diag::note_it_delegates_to);
20289 while (
C->getCanonicalDecl() != Canonical) {
20291 (void)
C->getTargetConstructor()->hasBody(FNTarget);
20292 assert(FNTarget &&
"Ctor cycle through bodiless function");
20296 S.
Diag(
C->getLocation(), diag::note_which_delegates_to);
20300 Invalid.insert_range(Current);
20311 for (DelegatingCtorDeclsType::iterator
20318 CI->setInvalidDecl();
20327 explicit FindCXXThisExpr(
Sema &S) : S(S) {}
20355 FindCXXThisExpr Finder(*
this);
20368 if (!Finder.TraverseStmt(
const_cast<Expr *
>(TRC.ConstraintExpr)))
20385 FindCXXThisExpr Finder(*
this);
20407 if (!Finder.TraverseType(E))
20417 FindCXXThisExpr Finder(*
this);
20420 for (
const auto *A :
Method->attrs()) {
20422 Expr *Arg =
nullptr;
20424 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
20426 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
20428 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
20430 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
20432 else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
20433 Arg = LR->getArg();
20434 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
20436 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
20438 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
20440 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A)) {
20441 Arg = AC->getSuccessValue();
20443 }
else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
20446 if (Arg && !Finder.TraverseStmt(Arg))
20449 for (
Expr *A : Args) {
20450 if (!Finder.TraverseStmt(A))
20464 Exceptions.clear();
20467 Exceptions.reserve(DynamicExceptions.size());
20468 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
20475 if (!Unexpanded.empty()) {
20486 Exceptions.push_back(ET);
20496 "Parser should have made sure that the expression is boolean");
20516 D = FTD->getTemplatedDecl();
20526 DynamicExceptionRanges, NoexceptExpr, Exceptions,
20530 Context.adjustExceptionSpec(FD, ESI,
true);
20554 Diag(DeclStart, diag::err_anonymous_property);
20568 TInfo =
Context.getTrivialTypeSourceInfo(
T, Loc);
20579 diag::err_invalid_thread)
20587 switch (
Previous.getResultKind()) {
20594 PrevDecl =
Previous.getRepresentativeDecl();
20607 PrevDecl =
nullptr;
20611 PrevDecl =
nullptr;
20622 Record->setInvalidDecl();
20644 if (!ExplicitLists.empty()) {
20645 bool IsMemberSpecialization, IsInvalid;
20649 ExplicitLists,
false, IsMemberSpecialization, IsInvalid,
20661 if (ExplicitParams && !ExplicitParams->
empty()) {
20662 Info.AutoTemplateParameterDepth = ExplicitParams->
getDepth();
20663 llvm::append_range(Info.TemplateParams, *ExplicitParams);
20664 Info.NumExplicitTemplateParams = ExplicitParams->
size();
20666 Info.AutoTemplateParameterDepth = TemplateParameterDepth;
20667 Info.NumExplicitTemplateParams = 0;
20673 if (FSI.TemplateParams.size() > FSI.NumExplicitTemplateParams) {
20674 if (FSI.NumExplicitTemplateParams != 0) {
20695 assert(
Context.getTargetInfo().getCXXABI().isMicrosoft());
20705 if (NumParams == 0)
20714 for (
unsigned I = IsCopy ? 1 : 0; I != NumParams; ++I) {
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...
Result
Implement __builtin_bit_cast and related operations.
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)
static AccessResult DeduceTemplateArguments(Sema &S, FriendTemplateDecl *FTD, DeclContext *DC, const TemplateSpecializationType *TST, ArrayRef< TemplateParameterList * > TPLs, TemplateSpecCandidateSet *FailedTSC, MultiLevelTemplateArgumentList &DeducedArgs)
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 StmtResult buildDefaultedPostfixOperatorBody(Sema &S, FunctionDecl *FD, PostfixOperatorKind Kind, SourceLocation Loc)
Build the body of a defaulted postfix increment or decrement operator function.
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 Sema::ImplicitExceptionSpecification ComputeDefaultedComparisonExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD, DefaultedComparisonKind DCK)
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 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 const TemplateSpecializationType * GetClassTemplateSpecializationType(ASTContext &Context, QualType T)
static bool checkTupleLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, VarDecl *Src, QualType DecompType, unsigned NumElems)
static void defineDefaultedFunctionWithSynthesizedBody(Sema &S, SourceLocation UseLoc, FunctionDecl *FD, llvm::function_ref< StmtResult(SourceLocation BodyLoc)> BuildBody)
Define a defaulted function whose body is synthesized by BuildBody: a defaulted comparison operator f...
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)
static Sema::ImplicitExceptionSpecification ComputeDefaultedPostfixOperatorExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD, PostfixOperatorKind Kind)
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 QualType IgnorePackIndexing(QualType T)
static bool isStdClassTemplate(Sema &S, QualType SugaredType, QualType *TypeArg, const char *ClassName, ClassTemplateDecl **CachedDecl, const Decl **MalformedDecl)
static bool canCopyAndDestroyForDefaultedPostfixOperator(Sema &S, FunctionDecl *FD, CXXRecordDecl *RD, QualType C, Expr *Obj, bool Diagnose, llvm::function_ref< void(const FunctionDecl *)> CheckConstexpr)
Determine whether the implicit definition of the defaulted postfix increment or decrement operator fu...
static QualType getPostfixOperatorFirstParamType(const FunctionDecl *FD)
Get the type of the first parameter of a postfix increment or decrement operator function,...
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 DefaultedPostfixOperatorInfo analyzeDefaultedPostfixOperator(Sema &S, FunctionDecl *FD, PostfixOperatorKind Kind, QualType C, bool Diagnose)
Determine whether a defaulted postfix increment or decrement operator function for type C should be d...
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 Sema::ImplicitExceptionSpecification computeExceptionSpecFromSynthesizedBody(Sema &S, SourceLocation Loc, FunctionDecl *FD, llvm::function_ref< StmtResult(SourceLocation BodyLoc)> BuildBody)
Compute the exception specification of a defaulted function whose body is synthesized by BuildBody: a...
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 void DiagnoseDependentFriendNotMember(Sema &S, SourceLocation Loc, NestedNameSpecifier NNS)
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 void MarkUsedTemplateParameters(ASTContext &Ctx, const TemplateArgument &TemplateArg, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark the template parameters that are used by this template argument.
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],...
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
bool containsErrors() const
unsigned record_size() const
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.
void setDecomposedDecl(DecompositionDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
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...
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.
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...
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...
void setCtorClosureDefaultArgs(ArrayRef< CXXDefaultArgExpr * > Args)
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={})
ArrayRef< CXXDefaultArgExpr * > getCtorClosureDefaultArgs() const
ExplicitSpecifier getExplicitSpecifier() const
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
A default argument (C++ [dcl.fct.default]).
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={})
const FunctionDecl * getOperatorDelete() const
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...
CXXSpecialMemberKind getSpecialMemberKind() const
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.
CastKind getCastKind() const
static CharSourceRange getTokenRange(SourceRange R)
QuantityType getQuantity() const
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
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.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
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)
SourceLocation getBeginLoc() const LLVM_READONLY
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.
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
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
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
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 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)
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setLexicalDeclContext(DeclContext *DC)
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...
void setTypeSourceInfo(TypeSourceInfo *TI)
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
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.
SourceLocation getEndLoc() const LLVM_READONLY
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
bool hasGroupingParens() const
void setInvalidType(bool Val=true)
void DropFirstTypeObject()
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.
FPOptions applyOverrides(FPOptions Base)
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={})
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, FriendUnion Friend, SourceLocation FriendLoc, ArrayRef< TemplateParameterList * > FriendTPLists, SourceLocation EllipsisLoc={}, TemplateName Template={})
For a defaulted function, the kind of defaulted function that it is.
CXXSpecialMemberKind asSpecialMember() const
bool isComparison() const
bool isPostfixOperator() const
PostfixOperatorKind asPostfixOperator() const
bool isSpecialMember() const
DefaultedComparisonKind asComparison() const
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, FPOptionsOverride FPFeatures, 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
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
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)
FunctionDecl * getDefinition()
Get the definition for this declaration.
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
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.
DefaultedFunctionKind getDefaultedFunctionKind() const
Determine the kind of defaulting that would be done for a given function.
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.
RAII class that temporarily sets the "ignore all warnings" state on a DiagnosticsEngine and restores ...
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)
A single step in the initialization sequence.
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.
@ SK_ConstructorInitialization
Perform initialization via a constructor.
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)
Create the initialization entity for a member subobject.
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
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 InitializeMemberImplicit(FieldDecl *Member)
Create the initialization entity for a member subobject with implicit field initializer.
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 addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Filter makeFilter()
Create a filter for this result set.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
UnresolvedSetImpl::iterator iterator
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
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.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
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.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
TypeLoc getAsTypeLoc() const
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...
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
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.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
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_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
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.
LangAS getAddressSpace() const
Return the address space of this 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.
Records and restores the CurFPFeatures state on entry/exit of compound statements.
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.
sema::CapturingScopeInfo * getEnclosingLambdaOrBlock() const
Get the innermost lambda or block enclosing the current location, if any.
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
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,...
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.
@ 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.
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.
PragmaStack< FPOptionsOverride > FpPragmaStack
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 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...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
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()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc, Scope *S=nullptr)
Mark the given declaration as explicitly defaulted.
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
void CleanupVarDeclMarking()
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.
void LookupOverloadedUnaryOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr * > Args, bool RequiresADL=true)
Perform lookup for an overloaded unary operator.
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
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 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()
void DiagnoseUnsatisfiedRequiresExpr(const RequiresExpr *RequiresExpr, bool First=true)
@ 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.
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
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)
bool BuildCtorClosureDefaultArgs(SourceLocation Loc, CXXConstructorDecl *Ctor, bool IsCopy=false)
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 ...
bool CheckExplicitlyDefaultedPostfixOperator(Scope *S, FunctionDecl *FD, PostfixOperatorKind Kind)
Check a defaulted postfix increment or decrement operator function (C++2d [over.inc....
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.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
bool DiagnosePackIndexingInFriendNNS(SourceLocation Loc, NestedNameSpecifierLoc NNSLoc)
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
Check the validity of a C++ base class specifier.
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 CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
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,...
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.
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr, Scope *S=nullptr)
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.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
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)
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 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 DefineDefaultedPostfixOperator(SourceLocation Loc, FunctionDecl *FD, PostfixOperatorKind Kind)
Synthesize the body of a defaulted postfix increment or decrement operator function (C++2d [over....
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
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.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
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...
bool CheckDependentFriend(SourceLocation Loc, NestedNameSpecifierLoc NNSLoc, ArrayRef< TemplateParameterList * > TPLs, bool IsInstantiation)
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)
ExprResult BuildCXXCtorDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
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)
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.
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
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)
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, bool IsMemberSpecialization, SkipBodyInfo *SkipBody=nullptr)
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.
llvm::DenseMap< SpecialMemberCacheKey, SpecialMemberOverloadResult > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, SourceLocation EllipsisLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists, TemplateIdAnnotation *TemplateId)
Handle a friend tag declaration where the scope specifier was templated.
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)
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply.
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)
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.
SourceLocation getEnd() const
SourceLocation getBegin() const
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...
NestedNameSpecifierLoc getPrefix() const
If this type represents a qualified-id, this returns it's nested name specifier.
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...
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
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)
TypeLocClass getTypeLocClass() const
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.
void assign(Iter I, Iter E)
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.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
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.
bool evaluateConstantDestruction(SmallVectorImpl< PartialDiagnosticAt > &Notes, SemaProxy &SProxy) const
Evaluate the destruction of a variable that is required by the language to have constant destruction.
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
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 isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
void setNRVOVariable(bool NRVO)
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
const APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
@ 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)
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.
Top level wrappers for InstallAPI frontend operations.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
TypeSpecifierType
Specifies the kind of 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.
@ Default
Set to the current date and time.
@ 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
OptionalUnsigned< unsigned > UnsignedOrNone
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.
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.
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.
MutableArrayRef< ParsedTemplateArgument > ASTTemplateArgsPtr
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.
PostfixOperatorKind
Kinds of defaulted postfix increment and decrement operator functions (C++2d [over....
@ None
This is not a defaultable postfix increment or decrement operator.
@ Increment
This is a postfix increment operator, 'operator++(int)'.
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.
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 unsigned
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t int64_t
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
Represents an element in a path from a derived class to a base class.
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...
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/unaligned/atomic.
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.
A simple structure that captures a vtable use for the purposes of the ExternalSemaSource.
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.
unsigned NumArgs
NumArgs - The number of template arguments.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
OpaquePtr< T > get() const