50#include "llvm/ADT/ArrayRef.h"
51#include "llvm/ADT/STLExtras.h"
52#include "llvm/ADT/STLForwardCompat.h"
53#include "llvm/ADT/ScopeExit.h"
54#include "llvm/ADT/SmallString.h"
55#include "llvm/ADT/StringExtras.h"
56#include "llvm/Support/ConvertUTF.h"
57#include "llvm/Support/SaveAndRestore.h"
74class CheckDefaultArgumentVisitor
77 const Expr *DefaultArg;
80 CheckDefaultArgumentVisitor(
Sema &S,
const Expr *DefaultArg)
81 : S(S), DefaultArg(DefaultArg) {}
86 bool VisitLambdaExpr(
const LambdaExpr *Lambda);
91bool CheckDefaultArgumentVisitor::VisitExpr(
const Expr *
Node) {
92 bool IsInvalid =
false;
93 for (
const Stmt *SubStmt :
Node->children())
95 IsInvalid |= Visit(SubStmt);
102bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
const DeclRefExpr *DRE) {
105 if (!isa<VarDecl, BindingDecl>(
Decl))
108 if (
const auto *Param = dyn_cast<ParmVarDecl>(
Decl)) {
119 diag::err_param_default_argument_references_param)
120 << Param->getDeclName() << DefaultArg->getSourceRange();
121 }
else if (
auto *VD =
Decl->getPotentiallyDecomposedVarDecl()) {
136 diag::err_param_default_argument_references_local)
143bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
const CXXThisExpr *ThisE) {
148 diag::err_param_default_argument_references_this)
152bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
157 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(
E)) {
158 E = OVE->getSourceExpr();
159 assert(
E &&
"pseudo-object binding without source expression?");
167bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
const LambdaExpr *Lambda) {
176 return S.
Diag(LC.getLocation(), diag::err_lambda_capture_default_arg);
178 auto *
D = cast<VarDecl>(LC.getCapturedVar());
211 llvm_unreachable(
"should not see unresolved exception specs here");
240 "should not generate implicit declarations for dependent cases");
244 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
246 "Shouldn't collect exceptions when throw-all is guaranteed.");
251 Exceptions.push_back(
E);
279 if (
Self->canThrow(S))
286 diag::err_typecheck_decl_incomplete_type))
305 CheckCompletedExpr(Arg, EqualLoc);
318 UnparsedDefaultArgInstantiationsMap::iterator InstPos
321 for (
unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
322 InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
332 if (!param || !DefaultArg)
340 Diag(EqualLoc, diag::err_param_default_argument)
353 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
367 CheckDefaultArgumentVisitor DefaultArgChecker(*
this, DefaultArg);
368 if (DefaultArgChecker.Visit(DefaultArg))
399 Param->
getType().getNonReferenceType());
412 bool MightBeFunction =
D.isFunctionDeclarationContext();
413 for (
unsigned i = 0, e =
D.getNumTypeObjects(); i != e; ++i) {
416 if (MightBeFunction) {
420 MightBeFunction =
false;
423 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
427 std::unique_ptr<CachedTokens> Toks =
430 if (Toks->size() > 1)
432 Toks->back().getLocation());
444 MightBeFunction =
false;
451 return P->hasDefaultArg() && !P->hasInheritedDefaultArg();
468 for (; PrevForDefaultArgs;
516 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
519 p < NumParams; ++p) {
523 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
526 if (OldParamHasDfl && NewParamHasDfl) {
527 unsigned DiagDefaultParamID =
528 diag::err_param_default_argument_redefinition;
543 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
561 for (
auto Older = PrevForDefaultArgs;
563 Older = Older->getPreviousDecl();
564 OldParam = Older->getParamDecl(p);
569 }
else if (OldParamHasDfl) {
587 }
else if (NewParamHasDfl) {
591 diag::err_param_default_argument_template_redecl)
594 diag::note_template_prev_declaration)
625 if (
Record->getDescribedClassTemplate())
627 else if (isa<ClassTemplatePartialSpecializationDecl>(
Record))
634 diag::err_param_default_argument_member_template_redecl)
644 if (isa<CXXConstructorDecl>(New) &&
648 if (NewSM != OldSM) {
651 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
686 if (isa<CXXDeductionGuideDecl>(New) &&
698 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
719 ? diag::warn_cxx23_placeholder_var_definition
720 : diag::ext_placeholder_var_definition);
726 assert(
D.isDecompositionDeclarator());
732 if (!
D.mayHaveDecompositionDeclarator()) {
738 if (!TemplateParamLists.empty()) {
741 Diag(TemplateParamLists.front()->getTemplateLoc(),
742 diag::err_decomp_decl_template);
748 ? diag::ext_decomp_decl
750 ? diag::ext_decomp_decl_cond
751 : diag::warn_cxx14_compat_decomp_decl)
766 auto &DS =
D.getDeclSpec();
774 if (
auto SCS = DS.getStorageClassSpec()) {
777 CPlusPlus20SpecifierLocs.push_back(DS.getStorageClassSpecLoc());
780 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
783 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
785 CPlusPlus20SpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
787 if (DS.hasConstexprSpecifier()) {
788 BadSpecifiers.push_back(
790 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
792 if (DS.isInlineSpecified()) {
793 BadSpecifiers.push_back(
"inline");
794 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
797 if (!BadSpecifiers.empty()) {
798 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
799 Err << (
int)BadSpecifiers.size()
800 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
803 for (
auto Loc : BadSpecifierLocs)
805 }
else if (!CPlusPlus20Specifiers.empty()) {
806 auto &&Warn =
Diag(CPlusPlus20SpecifierLocs.front(),
808 ? diag::warn_cxx17_compat_decomp_decl_spec
809 : diag::ext_decomp_decl_spec);
810 Warn << (
int)CPlusPlus20Specifiers.size()
811 << llvm::join(CPlusPlus20Specifiers.begin(),
812 CPlusPlus20Specifiers.end(),
" ");
813 for (
auto Loc : CPlusPlus20SpecifierLocs)
825 Diag(DS.getVolatileSpecLoc(),
826 diag::warn_deprecated_volatile_structured_binding);
839 D.hasGroupingParens() ||
D.getNumTypeObjects() > 1 ||
840 (
D.getNumTypeObjects() == 1 &&
843 (
D.hasGroupingParens() ||
844 (
D.getNumTypeObjects() &&
846 ? diag::err_decomp_decl_parens
847 : diag::err_decomp_decl_type)
858 if (DS.isConstrainedAuto()) {
861 "No other template kind should be possible for a constrained auto");
875 for (
auto &B :
D.getDecompositionDeclarator().bindings()) {
879 assert(VarName &&
"Cannot have an unnamed binding declaration");
882 RedeclarationKind::ForVisibleRedeclaration);
888 Previous.getFoundDecl()->isTemplateParameter()) {
899 NamedDecl *ShadowedDecl =
D.getCXXScopeSpec().isEmpty()
922 auto *Old =
Previous.getRepresentativeDecl();
923 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
924 Diag(Old->getLocation(), diag::note_previous_definition);
926 }
else if (ShadowedDecl && !
D.isRedeclaration()) {
939 RedeclarationKind::ForVisibleRedeclaration);
942 bool AddToScope =
true;
951 if (
OpenMP().isInOpenMPDeclareTargetContext())
961 if ((int64_t)
Bindings.size() != NumElems) {
962 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
975 E = GetInit(
Loc,
E.get(), I++);
978 B->setBinding(ElemType,
E.get());
987 const llvm::APSInt &NumElems,
990 S,
Bindings, Src, DecompType, NumElems, ElemType,
1021 S,
Bindings, Src, DecompType, llvm::APSInt::get(2),
1025 return S.CreateBuiltinUnaryOp(Loc, I ? UO_Imag : UO_Real, Base);
1033 llvm::raw_svector_ostream
OS(SS);
1045 return std::string(
OS.str());
1052 auto DiagnoseMissing = [&] {
1062 return DiagnoseMissing();
1072 return DiagnoseMissing();
1073 if (
Result.isAmbiguous())
1078 Result.suppressDiagnostics();
1080 S.
Diag(
Loc, diag::err_std_type_trait_not_class_template) << Trait;
1081 S.
Diag(
Found->getLocation(), diag::note_declared_at);
1092 Loc, TraitTy, DiagID,
1099 assert(RD &&
"specialization of class template is not a class?");
1118namespace {
enum class IsTupleLike { TupleLike, NotTupleLike,
Error }; }
1121 llvm::APSInt &Size) {
1136 return IsTupleLike::NotTupleLike;
1145 : R(R), Args(Args) {}
1148 return S.
Diag(
Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1152 } Diagnoser(R, Args);
1157 return IsTupleLike::Error;
1161 return IsTupleLike::Error;
1163 return IsTupleLike::TupleLike;
1178 S, R,
Loc,
"tuple_element", Args,
1179 diag::err_decomp_decl_std_tuple_element_not_specialized))
1185 S.
Diag(
Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1197struct InitializingBinding {
1206 ~InitializingBinding() {
1215 const llvm::APSInt &TupleSize) {
1216 if ((int64_t)
Bindings.size() != TupleSize) {
1217 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1233 bool UseMemberGet =
false;
1243 dyn_cast<FunctionTemplateDecl>(
D->getUnderlyingDecl())) {
1245 if (TPL->
size() != 0 &&
1246 isa<NonTypeTemplateParmDecl>(TPL->
getParam(0))) {
1248 UseMemberGet =
true;
1257 InitializingBinding InitContext(S, B);
1280 MemberGet, &Args,
nullptr);
1294 Expr *Arg =
E.get();
1315 B->getDeclName().getAsIdentifierInfo(), RefType,
1319 RefVD->setImplicit();
1321 RefVD->setInlineSpecified();
1322 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1327 E =
Seq.Perform(S, Entity, Kind,
Init);
1333 RefVD->setInit(
E.get());
1342 B->setBinding(
T,
E.get());
1357 return Specifier->getType()->getAsCXXRecordDecl()->hasDirectFields();
1366 ClassWithFields = RD;
1378 for (
auto &
P : Paths) {
1382 BestPath->back().Base->getType())) {
1384 S.
Diag(
Loc, diag::err_decomp_decl_multiple_bases_with_members)
1385 <<
false << RD << BestPath->back().Base->getType()
1386 <<
P.back().Base->getType();
1388 }
else if (
P.Access < BestPath->
Access) {
1394 QualType BaseType = BestPath->back().Base->getType();
1396 S.
Diag(
Loc, diag::err_decomp_decl_ambiguous_base)
1403 *BestPath, diag::err_decomp_decl_inaccessible_base);
1414 S.
Diag(
Loc, diag::err_decomp_decl_multiple_bases_with_members)
1415 << (ClassWithFields == RD) << RD << ClassWithFields
1416 << Paths.front().back().Base->getType();
1427 diag::err_incomplete_type))
1439 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1440 unsigned NumFields = llvm::count_if(
1441 RD->
fields(), [](
FieldDecl *FD) { return !FD->isUnnamedBitField(); });
1442 assert(
Bindings.size() != NumFields);
1443 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1453 for (
auto *FD : RD->
fields()) {
1454 if (FD->isUnnamedBitField())
1459 if (!FD->getDeclName()) {
1466 if (FD->isAnonymousStructOrUnion()) {
1469 S.
Diag(FD->getLocation(), diag::note_declared_at);
1478 return DiagnoseBadNumberOfBindings();
1489 BasePair.
getAccess(), FD->getAccess())));
1512 if (FD->isMutable())
1518 return DiagnoseBadNumberOfBindings();
1560 llvm::APSInt TupleSize(32);
1562 case IsTupleLike::Error:
1566 case IsTupleLike::TupleLike:
1571 case IsTupleLike::NotTupleLike:
1580 << DD << !RD << DecompType;
1598 "Should only be called if types are otherwise the same.");
1609 NewType =
P->getPointeeType();
1639 if (FTD->isMemberSpecialization())
1666 Diag(Param->
getLocation(), diag::err_param_default_argument_missing_name)
1676template <
typename... Ts>
1686 std::forward<Ts>(DiagArgs)...);
1692 llvm_unreachable(
"unknown CheckConstexprKind");
1700 "this check is obsolete for C++23");
1719 if (!Check(B.getBaseTypeLoc(), B.getType(),
nullptr))
1722 if (!Check(FD->getLocation(), FD->getType(), FD))
1733 "this check is obsolete for C++23");
1734 unsigned ArgIndex = 0;
1737 e = FT->param_type_end();
1738 i != e; ++i, ++ArgIndex) {
1740 assert(PD &&
"null in a parameter list");
1743 diag::err_constexpr_non_literal_param, ArgIndex + 1,
1756 "this check is obsolete for C++23");
1758 diag::err_constexpr_non_literal_return,
1777 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1803 << isa<CXXConstructorDecl>(NewFD)
1805 for (
const auto &I : RD->
vbases())
1806 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
1807 << I.getSourceRange();
1812 if (!isa<CXXConstructorDecl>(NewFD)) {
1817 const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD);
1821 Diag(Method->
getLocation(), diag::warn_cxx17_compat_constexpr_virtual);
1834 if (WrittenVirtual != Method)
1836 diag::note_overridden_virtual_function);
1847 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(NewFD)) {
1852 !Dtor->getParent()->defaultedDestructorIsConstexpr()) {
1867 "CheckConstexprFunctionDefinition called on function with no body");
1882 for (
const auto *DclIt : DS->
decls()) {
1883 switch (DclIt->getKind()) {
1884 case Decl::StaticAssert:
1886 case Decl::UsingShadow:
1887 case Decl::UsingDirective:
1888 case Decl::UnresolvedUsingTypename:
1889 case Decl::UnresolvedUsingValue:
1890 case Decl::UsingEnum:
1898 case Decl::TypeAlias: {
1901 const auto *TN = cast<TypedefNameDecl>(DclIt);
1902 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1905 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1908 << isa<CXXConstructorDecl>(Dcl);
1916 case Decl::CXXRecord:
1918 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition()) {
1922 ? diag::warn_cxx11_compat_constexpr_type_definition
1923 : diag::ext_constexpr_type_definition)
1924 << isa<CXXConstructorDecl>(Dcl);
1931 case Decl::EnumConstant:
1932 case Decl::IndirectField:
1939 case Decl::Decomposition: {
1944 const auto *VD = cast<VarDecl>(DclIt);
1945 if (VD->isThisDeclarationADefinition()) {
1946 if (VD->isStaticLocal()) {
1950 ? diag::warn_cxx20_compat_constexpr_var
1951 : diag::ext_constexpr_static_var)
1952 << isa<CXXConstructorDecl>(Dcl)
1960 diag::warn_cxx20_compat_constexpr_var,
1961 isa<CXXConstructorDecl>(Dcl),
1964 SemaRef, Kind, VD->getLocation(), VD->getType(),
1965 diag::err_constexpr_local_var_non_literal_type,
1966 isa<CXXConstructorDecl>(Dcl))) {
1969 if (!VD->getType()->isDependentType() &&
1970 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1975 ? diag::warn_cxx17_compat_constexpr_local_var_no_init
1976 : diag::ext_constexpr_local_var_no_init)
1977 << isa<CXXConstructorDecl>(Dcl);
1987 ? diag::warn_cxx11_compat_constexpr_local_var
1988 : diag::ext_constexpr_local_var)
1989 << isa<CXXConstructorDecl>(Dcl);
1996 case Decl::NamespaceAlias:
1997 case Decl::Function:
2007 << isa<CXXConstructorDecl>(Dcl) << Dcl->
isConsteval();
2032 llvm::SmallSet<Decl*, 16> &Inits,
2040 if (Field->isInvalidDecl())
2043 if (Field->isUnnamedBitField())
2049 if (Field->isAnonymousStructOrUnion() &&
2050 (Field->getType()->isUnionType()
2051 ? !Field->getType()->getAsCXXRecordDecl()->hasVariantMembers()
2052 : Field->getType()->getAsCXXRecordDecl()->isEmpty()))
2055 if (!Inits.count(Field)) {
2060 ? diag::warn_cxx17_compat_constexpr_ctor_missing_init
2061 : diag::ext_constexpr_ctor_missing_init);
2065 diag::note_constexpr_ctor_missing_init);
2069 }
else if (Field->isAnonymousStructOrUnion()) {
2071 for (
auto *I : RD->
fields())
2074 if (!RD->
isUnion() || Inits.count(I))
2091 switch (S->getStmtClass()) {
2092 case Stmt::NullStmtClass:
2096 case Stmt::DeclStmtClass:
2106 case Stmt::ReturnStmtClass:
2108 if (isa<CXXConstructorDecl>(Dcl)) {
2111 Cxx1yLoc = S->getBeginLoc();
2115 ReturnStmts.push_back(S->getBeginLoc());
2118 case Stmt::AttributedStmtClass:
2122 SemaRef, Dcl, cast<AttributedStmt>(S)->getSubStmt(), ReturnStmts,
2123 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind);
2125 case Stmt::CompoundStmtClass: {
2128 Cxx1yLoc = S->getBeginLoc();
2131 for (
auto *BodyIt : CompStmt->
body()) {
2133 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2139 case Stmt::IfStmtClass: {
2142 Cxx1yLoc = S->getBeginLoc();
2146 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2148 if (
If->getElse() &&
2150 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2155 case Stmt::WhileStmtClass:
2156 case Stmt::DoStmtClass:
2157 case Stmt::ForStmtClass:
2158 case Stmt::CXXForRangeStmtClass:
2159 case Stmt::ContinueStmtClass:
2165 Cxx1yLoc = S->getBeginLoc();
2166 for (
Stmt *SubStmt : S->children()) {
2169 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2174 case Stmt::SwitchStmtClass:
2175 case Stmt::CaseStmtClass:
2176 case Stmt::DefaultStmtClass:
2177 case Stmt::BreakStmtClass:
2181 Cxx1yLoc = S->getBeginLoc();
2182 for (
Stmt *SubStmt : S->children()) {
2185 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2190 case Stmt::LabelStmtClass:
2191 case Stmt::GotoStmtClass:
2193 Cxx2bLoc = S->getBeginLoc();
2194 for (
Stmt *SubStmt : S->children()) {
2197 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2202 case Stmt::GCCAsmStmtClass:
2203 case Stmt::MSAsmStmtClass:
2205 case Stmt::CXXTryStmtClass:
2207 Cxx2aLoc = S->getBeginLoc();
2208 for (
Stmt *SubStmt : S->children()) {
2211 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2216 case Stmt::CXXCatchStmtClass:
2220 SemaRef, Dcl, cast<CXXCatchStmt>(S)->getHandlerBlock(), ReturnStmts,
2221 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2231 Cxx1yLoc = S->getBeginLoc();
2236 SemaRef.
Diag(S->getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
2237 << isa<CXXConstructorDecl>(Dcl) << Dcl->
isConsteval();
2252 if (isa<CXXTryStmt>(Body)) {
2274 ? diag::ext_constexpr_function_try_block_cxx20
2275 : diag::warn_cxx17_compat_constexpr_function_try_block)
2276 << isa<CXXConstructorDecl>(Dcl);
2290 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2301 }
else if (Cxx2bLoc.
isValid()) {
2304 ? diag::warn_cxx20_compat_constexpr_body_invalid_stmt
2305 : diag::ext_constexpr_body_invalid_stmt_cxx23)
2306 << isa<CXXConstructorDecl>(Dcl);
2307 }
else if (Cxx2aLoc.
isValid()) {
2310 ? diag::warn_cxx17_compat_constexpr_body_invalid_stmt
2311 : diag::ext_constexpr_body_invalid_stmt_cxx20)
2312 << isa<CXXConstructorDecl>(Dcl);
2313 }
else if (Cxx1yLoc.
isValid()) {
2316 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
2317 : diag::ext_constexpr_body_invalid_stmt)
2318 << isa<CXXConstructorDecl>(Dcl);
2322 = dyn_cast<CXXConstructorDecl>(Dcl)) {
2331 if (Constructor->getNumCtorInitializers() == 0 &&
2337 ? diag::warn_cxx17_compat_constexpr_union_ctor_no_init
2338 : diag::ext_constexpr_union_ctor_no_init);
2343 }
else if (!Constructor->isDependentContext() &&
2344 !Constructor->isDelegatingConstructor()) {
2345 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
2349 bool AnyAnonStructUnionMembers =
false;
2350 unsigned Fields = 0;
2353 if (I->isAnonymousStructOrUnion()) {
2354 AnyAnonStructUnionMembers =
true;
2362 if (AnyAnonStructUnionMembers ||
2363 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
2367 llvm::SmallSet<Decl*, 16> Inits;
2368 for (
const auto *I: Constructor->inits()) {
2372 Inits.insert(ID->chain_begin(), ID->chain_end());
2375 bool Diagnosed =
false;
2376 for (
auto *I : RD->
fields())
2383 if (ReturnStmts.empty()) {
2398 }
else if (ReturnStmts.size() > 1) {
2404 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2405 : diag::ext_constexpr_body_multiple_return);
2406 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2408 diag::note_constexpr_body_previous_return);
2439 diag::ext_constexpr_function_never_constant_expr, Dcl->
getLocation());
2444 diag::ext_constexpr_function_never_constant_expr)
2445 << isa<CXXConstructorDecl>(Dcl) << Dcl->
isConsteval()
2447 for (
size_t I = 0, N =
Diags.size(); I != N; ++I)
2472 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2473 : diag::err_constexpr_body_no_return)
2487 Diag(it->second, diag::err_immediate_function_used_before_definition)
2500 "expected an immediate function");
2501 assert(FD->
hasBody() &&
"expected the function to have a body");
2502 struct ImmediateEscalatingExpressionsVisitor
2509 bool ImmediateFnIsConstructor;
2514 : SemaRef(SemaRef), ImmediateFn(FD),
2515 ImmediateFnIsConstructor(isa<CXXConstructorDecl>(FD)) {}
2517 bool shouldVisitImplicitCode()
const {
return true; }
2518 bool shouldVisitLambdaBody()
const {
return false; }
2523 if (CurrentConstructor && CurrentInit) {
2531 SemaRef.
Diag(
Loc, diag::note_immediate_function_reason)
2532 << ImmediateFn << Fn << Fn->isConsteval() << IsCall
2533 << isa<CXXConstructorDecl>(Fn) << ImmediateFnIsConstructor
2534 << (InitializedField !=
nullptr)
2535 << (CurrentInit && !CurrentInit->
isWritten())
2536 << InitializedField <<
Range;
2539 if (
const auto *DR =
2541 DR && DR->isImmediateEscalating()) {
2542 Diag(
E,
E->getDirectCallee(),
true);
2546 for (
Expr *A :
E->arguments())
2547 if (!getDerived().TraverseStmt(A))
2554 if (
const auto *ReferencedFn = dyn_cast<FunctionDecl>(
E->getDecl());
2555 ReferencedFn &&
E->isImmediateEscalating()) {
2556 Diag(
E, ReferencedFn,
false);
2565 if (
E->isImmediateEscalating()) {
2574 return Base::TraverseConstructorInitializer(
Init);
2579 return Base::TraverseCXXConstructorDecl(Ctr);
2582 bool TraverseType(
QualType T) {
return true; }
2583 bool VisitBlockExpr(
BlockExpr *
T) {
return true; }
2585 } Visitor(*
this, FD);
2586 Visitor.TraverseDecl(FD);
2597 return dyn_cast_or_null<CXXRecordDecl>(DC);
2600 return dyn_cast_or_null<CXXRecordDecl>(
CurContext);
2618 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2620 CurDecl = dyn_cast_or_null<CXXRecordDecl>(
CurContext);
2645 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2659 if (BaseDecl->isUnion()) {
2660 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2668 if (
auto *BaseSpec =
2669 dyn_cast<ClassTemplateSpecializationDecl>(BaseDecl)) {
2678 Class->setInvalidDecl();
2682 BaseDecl = BaseDecl->getDefinition();
2683 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2688 const auto *BaseCSA = BaseDecl->getAttr<CodeSegAttr>();
2689 const auto *DerivedCSA =
Class->getAttr<CodeSegAttr>();
2690 if ((DerivedCSA || BaseCSA) &&
2691 (!BaseCSA || !DerivedCSA ||
2692 BaseCSA->getName() != DerivedCSA->getName())) {
2693 Diag(
Class->getLocation(), diag::err_mismatched_code_seg_base);
2694 Diag(BaseDecl->getLocation(), diag::note_base_class_specified_here)
2705 if (BaseDecl->hasFlexibleArrayMember()) {
2706 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2707 << BaseDecl->getDeclName();
2714 if (FinalAttr *FA = BaseDecl->getAttr<FinalAttr>()) {
2715 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2716 << BaseDecl->getDeclName() << FA->isSpelledAsSealed();
2717 Diag(BaseDecl->getLocation(), diag::note_entity_declared_at)
2718 << BaseDecl->getDeclName() << FA->getRange();
2723 if (BaseDecl->isInvalidDecl())
2724 Class->setInvalidDecl();
2732 if (!
Class->isDependentContext())
2733 Class->setInvalidDecl();
2736 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2748 Access, TInfo, EllipsisLoc);
2765 Class->setIsParsingBaseSpecifiers();
2773 Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
2774 << AL << AL.getRange();
2776 Diag(AL.getLoc(), diag::err_base_specifier_attribute)
2777 << AL << AL.isRegularKeywordAttribute() << AL.getRange();
2790 if (
Class->isUnion()) {
2791 Diag(
Class->getLocation(), diag::err_base_clause_on_union)
2801 Class->setInvalidDecl();
2817 auto Decl = Rec->getAsCXXRecordDecl();
2820 for (
const auto &BaseSpec :
Decl->bases()) {
2839 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2846 unsigned NumGoodBases = 0;
2848 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2858 Diag(Bases[idx]->getBeginLoc(), diag::err_duplicate_base_class)
2859 << KnownBase->
getType() << Bases[idx]->getSourceRange();
2868 KnownBase = Bases[idx];
2869 Bases[NumGoodBases++] = Bases[idx];
2874 if (Bases.size() > 1)
2879 if (
Class->isInterface() &&
2896 Class->setBases(Bases.data(), NumGoodBases);
2899 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2901 QualType BaseType = Bases[idx]->getType();
2911 if (IndirectBaseTypes.count(CanonicalBase)) {
2915 =
Class->isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
2919 if (Paths.isAmbiguous(CanonicalBase))
2920 Diag(Bases[idx]->getBeginLoc(), diag::warn_inaccessible_base_class)
2922 << Bases[idx]->getSourceRange();
2924 assert(Bases[idx]->isVirtual());
2937 if (!ClassDecl || Bases.empty())
2994 for (
unsigned I =
Path.size(); I != 0; --I) {
2995 if (
Path[I - 1].
Base->isVirtual()) {
3002 for (
unsigned I = Start,
E =
Path.size(); I !=
E; ++I)
3009 assert(BasePathArray.empty() &&
"Base path array must be empty!");
3010 assert(Paths.isRecordingPaths() &&
"Must record paths!");
3011 return ::BuildBasePathArray(Paths.front(), BasePathArray);
3016 unsigned InaccessibleBaseID,
3017 unsigned AmbiguousBaseConvID,
3021 bool IgnoreAccess) {
3029 if (!DerivationOkay)
3034 Path = &Paths.front();
3041 if (PossiblePath.size() == 1) {
3042 Path = &PossiblePath;
3043 if (AmbiguousBaseConvID)
3044 Diag(
Loc, diag::ext_ms_ambiguous_direct_base)
3052 if (!IgnoreAccess) {
3071 if (AmbiguousBaseConvID) {
3079 Paths.setRecordingPaths(
true);
3081 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
3090 Diag(
Loc, AmbiguousBaseConvID)
3091 << Derived <<
Base << PathDisplayStr <<
Range << Name;
3100 bool IgnoreAccess) {
3102 Derived,
Base, diag::err_upcast_to_inaccessible_base,
3104 BasePath, IgnoreAccess);
3108 std::string PathDisplayStr;
3109 std::set<unsigned> DisplayedPaths;
3112 if (DisplayedPaths.insert(
Path->back().SubobjectNumber).second) {
3115 PathDisplayStr +=
"\n ";
3117 for (CXXBasePath::const_iterator Element =
Path->begin();
3118 Element !=
Path->end(); ++Element)
3119 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
3123 return PathDisplayStr;
3133 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
3162 if (!OverloadedMethods.empty()) {
3163 if (OverrideAttr *OA =
D->
getAttr<OverrideAttr>()) {
3164 Diag(OA->getLocation(),
3165 diag::override_keyword_hides_virtual_member_function)
3166 <<
"override" << (OverloadedMethods.size() > 1);
3167 }
else if (FinalAttr *FA =
D->
getAttr<FinalAttr>()) {
3168 Diag(FA->getLocation(),
3169 diag::override_keyword_hides_virtual_member_function)
3170 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3171 << (OverloadedMethods.size() > 1);
3182 if (OverrideAttr *OA =
D->
getAttr<OverrideAttr>()) {
3183 Diag(OA->getLocation(),
3184 diag::override_keyword_only_allowed_on_virtual_member_functions)
3188 if (FinalAttr *FA =
D->
getAttr<FinalAttr>()) {
3189 Diag(FA->getLocation(),
3190 diag::override_keyword_only_allowed_on_virtual_member_functions)
3191 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3203 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
3204 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
3224 auto EmitDiag = [&](
unsigned DiagInconsistent,
unsigned DiagSuggest) {
3233 if (isa<CXXDestructorDecl>(MD))
3235 diag::warn_inconsistent_destructor_marked_not_override_overriding,
3236 diag::warn_suggest_destructor_marked_not_override_overriding);
3238 EmitDiag(diag::warn_inconsistent_function_marked_not_override_overriding,
3239 diag::warn_suggest_function_marked_not_override_overriding);
3245 FinalAttr *FA = Old->
getAttr<FinalAttr>();
3251 << FA->isSpelledAsSealed();
3260 return !RD->isCompleteDefinition() ||
3261 !RD->hasTrivialDefaultConstructor() ||
3262 !RD->hasTrivialDestructor();
3274 std::map<CXXRecordDecl*, NamedDecl*> Bases;
3277 const auto Base =
Specifier->getType()->getAsCXXRecordDecl();
3279 if (Bases.find(
Base) != Bases.end())
3281 for (
const auto Field :
Base->lookup(FieldName)) {
3282 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
3285 assert(Bases.find(
Base) == Bases.end());
3298 for (
const auto &
P : Paths) {
3299 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
3300 auto It = Bases.find(
Base);
3302 if (It == Bases.end())
3304 auto BaseField = It->second;
3305 assert(BaseField->getAccess() !=
AS_private);
3308 Diag(
Loc, diag::warn_shadow_field)
3309 << FieldName << RD <<
Base << DeclIsField;
3310 Diag(BaseField->getLocation(), diag::note_shadow_field);
3330 Expr *BitWidth =
static_cast<Expr*
>(BW);
3335 bool isFunc =
D.isDeclarationOfFunction();
3337 D.getDeclSpec().getAttributes().getMSPropertyAttr();
3339 if (cast<CXXRecordDecl>(
CurContext)->isInterface()) {
3343 unsigned InvalidDecl;
3344 bool ShowDeclName =
true;
3354 else switch (Name.getNameKind()) {
3357 ShowDeclName =
false;
3362 ShowDeclName =
false;
3377 Diag(
Loc, diag::err_invalid_member_in_interface)
3378 << (InvalidDecl-1) << Name;
3380 Diag(
Loc, diag::err_invalid_member_in_interface)
3381 << (InvalidDecl-1) <<
"";
3402 D.getMutableDeclSpec().ClearStorageClassSpecs();
3407 diag::err_storageclass_invalid_for_member);
3408 D.getMutableDeclSpec().ClearStorageClassSpecs();
3414 !isFunc && TemplateParameterLists.empty();
3426 D.getMutableDeclSpec().ClearConstexprSpec();
3427 const char *PrevSpec;
3429 bool Failed =
D.getMutableDeclSpec().SetTypeQual(
3432 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3436 const char *PrevSpec;
3438 if (
D.getMutableDeclSpec().SetStorageClassSpec(
3442 "This is the only DeclSpec that should fail to be applied");
3446 isInstField =
false;
3456 if (!Name.isIdentifier()) {
3457 Diag(
Loc, diag::err_bad_variable_name)
3464 Diag(
D.getIdentifierLoc(), diag::err_member_with_template_arguments)
3467 D.getName().TemplateId->RAngleLoc)
3468 <<
D.getName().TemplateId->LAngleLoc;
3469 D.SetIdentifier(II,
Loc);
3482 ?
D.getName().TemplateId
3488 Diag(
D.getIdentifierLoc(), diag::err_member_qualification)
3494 if (MSPropertyAttr) {
3496 BitWidth, InitStyle, AS, *MSPropertyAttr);
3499 isInstField =
false;
3502 BitWidth, InitStyle, AS);
3507 CheckShadowInheritedFields(
Loc, Name, cast<CXXRecordDecl>(
CurContext));
3515 if (
Member->isInvalidDecl()) {
3517 }
else if (isa<VarDecl>(
Member) || isa<VarTemplateDecl>(
Member)) {
3520 Diag(
Loc, diag::err_static_not_bitfield)
3522 }
else if (isa<TypedefDecl>(
Member)) {
3524 Diag(
Loc, diag::err_typedef_not_bitfield)
3529 Diag(
Loc, diag::err_not_integral_type_bitfield)
3530 << Name << cast<ValueDecl>(
Member)->getType()
3535 Member->setInvalidDecl();
3540 NonTemplateMember = FunTmpl->getTemplatedDecl();
3542 NonTemplateMember = VarTmpl->getTemplatedDecl();
3548 if (NonTemplateMember !=
Member)
3554 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3555 auto *TD = DG->getDeducedTemplate();
3558 if (AS != TD->getAccess() &&
3559 TD->getDeclContext()->getRedeclContext()->Equals(
3560 DG->getDeclContext()->getRedeclContext())) {
3561 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
3562 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
3565 for (
const auto *
D : cast<CXXRecordDecl>(
CurContext)->decls()) {
3566 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(
D))
3567 LastAccessSpec = AccessSpec;
3569 assert(LastAccessSpec &&
"differing access with no access specifier");
3570 Diag(LastAccessSpec->
getBeginLoc(), diag::note_deduction_guide_access)
3581 ? FinalAttr::Keyword_sealed
3582 : FinalAttr::Keyword_final));
3592 assert((Name || isInstField) &&
"No identifier for non-field ?");
3602 auto DeclHasUnusedAttr = [](
const QualType &
T) {
3604 return TD->hasAttr<UnusedAttr>();
3606 return TDT->getDecl()->hasAttr<UnusedAttr>();
3614 !DeclHasUnusedAttr(FD->
getType()) &&
3624 class UninitializedFieldVisitor
3629 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3632 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3647 UninitializedFieldVisitor(
Sema &S,
3648 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3649 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3650 : Inherited(S.Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3651 Constructor(nullptr), InitList(
false), InitListFieldDecl(nullptr) {}
3654 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3655 bool CheckReferenceOnly) {
3657 bool ReferenceField =
false;
3662 Fields.push_back(FD);
3664 ReferenceField =
true;
3670 if (CheckReferenceOnly && !ReferenceField)
3676 for (
const FieldDecl *FD : llvm::drop_begin(llvm::reverse(Fields)))
3679 for (
auto UsedIter = UsedFieldIndex.begin(),
3680 UsedEnd = UsedFieldIndex.end(),
3681 OrigIter = InitFieldIndex.begin(),
3682 OrigEnd = InitFieldIndex.end();
3683 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3684 if (*UsedIter < *OrigIter)
3686 if (*UsedIter > *OrigIter)
3693 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3706 dyn_cast<MemberExpr>(
Base->IgnoreParenImpCasts())) {
3708 if (isa<VarDecl>(SubME->getMemberDecl()))
3711 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3716 AllPODFields =
false;
3718 Base = SubME->getBase();
3721 if (!isa<CXXThisExpr>(
Base->IgnoreParenImpCasts())) {
3726 if (AddressOf && AllPODFields)
3732 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3733 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
3736 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3746 if (!Decls.count(FoundVD))
3751 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3753 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3758 if (CheckReferenceOnly && !IsReference)
3762 unsigned diag = IsReference
3763 ? diag::warn_reference_field_is_uninit
3764 : diag::warn_field_is_uninit;
3768 diag::note_uninit_in_this_constructor)
3773 void HandleValue(
Expr *
E,
bool AddressOf) {
3777 HandleMemberExpr(ME,
false ,
3783 Visit(CO->getCond());
3784 HandleValue(CO->getTrueExpr(), AddressOf);
3785 HandleValue(CO->getFalseExpr(), AddressOf);
3790 dyn_cast<BinaryConditionalOperator>(
E)) {
3791 Visit(BCO->getCond());
3792 HandleValue(BCO->getFalseExpr(), AddressOf);
3797 HandleValue(OVE->getSourceExpr(), AddressOf);
3802 switch (BO->getOpcode()) {
3807 HandleValue(BO->getLHS(), AddressOf);
3808 Visit(BO->getRHS());
3811 Visit(BO->getLHS());
3812 HandleValue(BO->getRHS(), AddressOf);
3821 InitFieldIndex.push_back(0);
3822 for (
auto *Child : ILE->
children()) {
3823 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3824 CheckInitListExpr(SubList);
3828 ++InitFieldIndex.back();
3830 InitFieldIndex.pop_back();
3839 DeclsToRemove.clear();
3846 InitListFieldDecl =
Field;
3847 InitFieldIndex.clear();
3848 CheckInitListExpr(ILE);
3862 HandleMemberExpr(ME,
true ,
false );
3866 if (
E->getCastKind() == CK_LValueToRValue) {
3867 HandleValue(
E->getSubExpr(),
false );
3871 Inherited::VisitImplicitCastExpr(
E);
3875 if (
E->getConstructor()->isCopyConstructor()) {
3876 Expr *ArgExpr =
E->getArg(0);
3877 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3881 if (ICE->getCastKind() == CK_NoOp)
3882 ArgExpr = ICE->getSubExpr();
3883 HandleValue(ArgExpr,
false );
3886 Inherited::VisitCXXConstructExpr(
E);
3891 if (isa<MemberExpr>(Callee)) {
3892 HandleValue(Callee,
false );
3893 for (
auto *Arg :
E->arguments())
3898 Inherited::VisitCXXMemberCallExpr(
E);
3903 if (
E->isCallToStdMove()) {
3904 HandleValue(
E->getArg(0),
false);
3908 Inherited::VisitCallExpr(
E);
3914 if (isa<UnresolvedLookupExpr>(Callee))
3915 return Inherited::VisitCXXOperatorCallExpr(
E);
3918 for (
auto *Arg :
E->arguments())
3919 HandleValue(Arg->IgnoreParenImpCasts(),
false );
3925 if (
E->getOpcode() == BO_Assign)
3926 if (
MemberExpr *ME = dyn_cast<MemberExpr>(
E->getLHS()))
3929 DeclsToRemove.push_back(FD);
3931 if (
E->isCompoundAssignmentOp()) {
3932 HandleValue(
E->getLHS(),
false );
3937 Inherited::VisitBinaryOperator(
E);
3941 if (
E->isIncrementDecrementOp()) {
3942 HandleValue(
E->getSubExpr(),
false );
3945 if (
E->getOpcode() == UO_AddrOf) {
3946 if (
MemberExpr *ME = dyn_cast<MemberExpr>(
E->getSubExpr())) {
3947 HandleValue(ME->
getBase(),
true );
3952 Inherited::VisitUnaryOperator(
E);
3962 static void DiagnoseUninitializedFields(
3982 for (
auto *I : RD->
decls()) {
3983 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
3984 UninitializedFields.insert(FD);
3985 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
3986 UninitializedFields.insert(IFD->getAnonField());
3991 for (
const auto &I : RD->
bases())
3992 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
3994 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3997 UninitializedFieldVisitor UninitializedChecker(
SemaRef,
3998 UninitializedFields,
3999 UninitializedBaseClasses);
4001 for (
const auto *FieldInit :
Constructor->inits()) {
4002 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
4005 Expr *InitExpr = FieldInit->getInit();
4010 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
4011 InitExpr =
Default->getExpr();
4015 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
4016 FieldInit->getAnyMember(),
4017 FieldInit->getBaseClass());
4019 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
4020 FieldInit->getAnyMember(),
4021 FieldInit->getBaseClass());
4034 if (!
D.isFunctionDeclarator())
4036 auto &FTI =
D.getFunctionTypeInfo();
4041 auto *ParamDecl = cast<NamedDecl>(Param.Param);
4042 if (ParamDecl->getDeclName())
4063 return ConstraintExpr;
4078 return Seq.Perform(*
this, Entity, Kind, InitExpr);
4089 "must set init style when field is created");
4106 assert(
Init.isUsable() &&
"Init should at least have a RecoveryExpr");
4112 if (!
Init.isInvalid())
4114 if (
Init.isInvalid()) {
4132 DirectBaseSpec =
nullptr;
4133 for (
const auto &
Base : ClassDecl->
bases()) {
4137 DirectBaseSpec = &
Base;
4145 VirtualBaseSpec =
nullptr;
4146 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
4156 if (
Path->back().Base->isVirtual()) {
4157 VirtualBaseSpec =
Path->back().Base;
4164 return DirectBaseSpec || VirtualBaseSpec;
4178 DS, IdLoc, InitList,
4196 DS, IdLoc, List, EllipsisLoc);
4205 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
4206 : ClassDecl(ClassDecl) {}
4208 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4211 return Member->getDeclContext()->getRedeclContext()->Equals(ClassDecl);
4212 return isa<TypeDecl>(ND);
4217 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
4218 return std::make_unique<MemInitializerValidatorCCC>(*
this);
4233 return isa<FieldDecl, IndirectFieldDecl>(Elem) &&
4239 Diag(
Loc, diag::err_using_placeholder_variable) << Name;
4244 if (isa<FieldDecl, IndirectFieldDecl>(ND) &&
4255 for (
auto *
D : ClassDecl->
lookup(MemberOrBase)) {
4256 if (isa<FieldDecl, IndirectFieldDecl>(
D)) {
4257 bool IsPlaceholder =
D->isPlaceholderVar(
getLangOpts());
4264 return cast<ValueDecl>(
D);
4265 ND = cast<ValueDecl>(
D);
4302 = dyn_cast<CXXConstructorDecl>(ConstructorD);
4326 ClassDecl, SS, TemplateTypeTy, MemberOrBase)) {
4328 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
4338 if (TemplateTypeTy) {
4363 bool NotUnknownSpecialization =
false;
4366 NotUnknownSpecialization = !
Record->hasAnyDependentBases();
4368 if (!NotUnknownSpecialization) {
4393 auto *TempSpec = cast<TemplateSpecializationType>(
4394 UnqualifiedBase->getInjectedClassNameSpecialization());
4396 for (
auto const &
Base : ClassDecl->
bases()) {
4400 BaseTemplate->getTemplateName(), TN)) {
4401 Diag(IdLoc, diag::ext_unqualified_base_class)
4403 BaseType =
Base.getType();
4412 MemInitializerValidatorCCC CCC(ClassDecl);
4421 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4422 << MemberOrBase <<
true);
4429 DirectBaseSpec, VirtualBaseSpec)) {
4434 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4435 << MemberOrBase <<
false,
4448 if (!TyD && BaseType.
isNull()) {
4449 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
4450 << MemberOrBase <<
SourceRange(IdLoc,
Init->getSourceRange().getEnd());
4478 assert((DirectMember || IndirectMember) &&
4479 "Member must be a FieldDecl or IndirectFieldDecl");
4484 if (
Member->isInvalidDecl())
4489 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4491 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
4499 if (
Member->getType()->isDependentType() ||
Init->isTypeDependent()) {
4504 bool InitList =
false;
4505 if (isa<InitListExpr>(
Init)) {
4517 IdLoc,
Init->getBeginLoc(),
Init->getEndLoc())
4561 return Diag(NameLoc, diag::err_delegating_ctor)
4563 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4565 bool InitList =
true;
4569 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4578 NameLoc,
Init->getBeginLoc(),
Init->getEndLoc())
4586 cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor()) &&
4587 "Delegating constructor with no target?");
4593 DelegationInit.
get(), InitRange.
getBegin(),
false);
4611 DelegationInit =
Init;
4626 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4646 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4675 if (!DirectBaseSpec && !VirtualBaseSpec) {
4684 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4696 InitRange.
getEnd(), EllipsisLoc);
4703 if (DirectBaseSpec && VirtualBaseSpec)
4704 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4709 BaseSpec = VirtualBaseSpec;
4712 bool InitList =
true;
4716 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4756 InitRange.
getEnd(), EllipsisLoc);
4766 TargetType, ExprLoc);
4786 bool IsInheritedVirtualBase,
4790 IsInheritedVirtualBase);
4794 switch (ImplicitInitKind) {
4800 BaseInit = InitSeq.
Perform(
SemaRef, InitEntity, InitKind, std::nullopt);
4806 bool Moving = ImplicitInitKind ==
IIK_Move;
4807 ParmVarDecl *Param = Constructor->getParamDecl(0);
4813 Constructor->getLocation(), ParamType,
4828 BasePath.push_back(BaseSpec);
4830 CK_UncheckedDerivedToBase,
4838 BaseInit = InitSeq.
Perform(
SemaRef, InitEntity, InitKind, CopyCtorArg);
4861 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
4870 if (Field->isInvalidDecl())
4876 bool Moving = ImplicitInitKind ==
IIK_Move;
4877 ParmVarDecl *Param = Constructor->getParamDecl(0);
4884 Expr *MemberExprBase =
4950 "Unhandled implicit init kind!");
4986 if (!Field->getParent()->isUnion()) {
4989 diag::err_uninitialized_member_in_ctor)
4990 << (
int)Constructor->isImplicit()
4992 << 0 << Field->getDeclName();
4993 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
4999 diag::err_uninitialized_member_in_ctor)
5000 << (
int)Constructor->isImplicit()
5002 << 1 << Field->getDeclName();
5003 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
5020 CXXMemberInit =
nullptr;
5025struct BaseAndFieldInfo {
5028 bool AnyErrorsInInits;
5030 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
5032 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
5035 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
5047 bool isImplicitCopyOrMove()
const {
5058 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
5062 AllToInit.push_back(
Init);
5071 bool isInactiveUnionMember(
FieldDecl *Field) {
5077 ActiveUnionMember.lookup(
Record->getCanonicalDecl()))
5078 return Active !=
Field->getCanonicalDecl();
5081 if (isImplicitCopyOrMove())
5086 if (
Field->hasInClassInitializer())
5090 if (!
Field->isAnonymousStructOrUnion())
5099 bool isWithinInactiveUnionMember(
FieldDecl *Field,
5102 return isInactiveUnionMember(Field);
5106 if (Field && isInactiveUnionMember(Field))
5121 if (ArrayT->isZeroSize())
5124 T = ArrayT->getElementType();
5133 if (Field->isInvalidDecl())
5138 Info.AllBaseFields.lookup(Field->getCanonicalDecl()))
5139 return Info.addFieldInitializer(
Init);
5153 if (Info.isWithinInactiveUnionMember(Field,
Indirect))
5156 if (Field->hasInClassInitializer() && !Info.isImplicitCopyOrMove()) {
5174 return Info.addFieldInitializer(
Init);
5184 if (Info.AnyErrorsInInits)
5195 return Info.addFieldInitializer(
Init);
5202 Constructor->setNumCtorInitializers(1);
5206 Constructor->setCtorInitializers(initializer);
5215 DiagnoseUninitializedFields(*
this, Constructor);
5222 if (Constructor->isDependentContext()) {
5225 if (!Initializers.empty()) {
5226 Constructor->setNumCtorInitializers(Initializers.size());
5229 memcpy(baseOrMemberInitializers, Initializers.data(),
5231 Constructor->setCtorInitializers(baseOrMemberInitializers);
5236 Constructor->setInvalidDecl();
5241 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
5245 CXXRecordDecl *ClassDecl = Constructor->getParent()->getDefinition();
5249 bool HadError =
false;
5251 for (
unsigned i = 0; i < Initializers.size(); i++) {
5254 if (
Member->isBaseInitializer())
5257 Info.AllBaseFields[
Member->getAnyMember()->getCanonicalDecl()] =
Member;
5260 for (
auto *
C : F->chain()) {
5263 Info.ActiveUnionMember.insert(std::make_pair(
5268 Info.ActiveUnionMember.insert(std::make_pair(
5276 for (
auto &I : ClassDecl->
bases()) {
5278 DirectVBases.insert(&I);
5282 for (
auto &VBase : ClassDecl->
vbases()) {
5284 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
5292 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
5293 << VBase.getType() << ClassDecl;
5297 Info.AllToInit.push_back(
Value);
5298 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
5303 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
5306 &VBase, IsInheritedVirtualBase,
5312 Info.AllToInit.push_back(CXXBaseInit);
5319 if (
Base.isVirtual())
5323 = Info.AllBaseFields.lookup(
Base.getType()->getAs<
RecordType>())) {
5324 Info.AllToInit.push_back(
Value);
5325 }
else if (!AnyErrors) {
5334 Info.AllToInit.push_back(CXXBaseInit);
5339 for (
auto *Mem : ClassDecl->
decls()) {
5340 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
5345 if (F->isUnnamedBitField())
5351 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
5360 if (Info.isImplicitCopyOrMove())
5363 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
5364 if (F->getType()->isIncompleteArrayType()) {
5366 "Incomplete array type is not valid");
5378 unsigned NumInitializers = Info.AllToInit.size();
5379 if (NumInitializers > 0) {
5380 Constructor->setNumCtorInitializers(NumInitializers);
5383 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
5385 Constructor->setCtorInitializers(baseOrMemberInitializers);
5390 Constructor->getParent());
5400 for (
auto *Field : RD->
fields())
5405 IdealInits.push_back(Field->getCanonicalDecl());
5414 if (!
Member->isAnyMemberInitializer())
5417 return Member->getAnyMember()->getCanonicalDecl();
5423 if (
Previous->isAnyMemberInitializer())
5428 if (Current->isAnyMemberInitializer())
5429 Diag << 0 << Current->getAnyMember();
5431 Diag << 1 << Current->getTypeSourceInfo()->getType();
5437 if (Constructor->getDeclContext()->isDependentContext())
5442 bool ShouldCheckOrder =
false;
5443 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5446 Init->getSourceLocation())) {
5447 ShouldCheckOrder =
true;
5451 if (!ShouldCheckOrder)
5462 for (
const auto &VBase : ClassDecl->
vbases())
5466 for (
const auto &
Base : ClassDecl->
bases()) {
5467 if (
Base.isVirtual())
5473 for (
auto *Field : ClassDecl->
fields()) {
5474 if (Field->isUnnamedBitField())
5480 unsigned NumIdealInits = IdealInitKeys.size();
5481 unsigned IdealIndex = 0;
5490 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5495 for (; IdealIndex != NumIdealInits; ++IdealIndex)
5496 if (InitKey == IdealInitKeys[IdealIndex])
5502 if (IdealIndex == NumIdealInits && InitIndex) {
5503 WarnIndexes.push_back(InitIndex);
5506 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
5507 if (InitKey == IdealInitKeys[IdealIndex])
5510 assert(IdealIndex < NumIdealInits &&
5511 "initializer not found in initializer list");
5513 CorrelatedInitOrder.emplace_back(IdealIndex, InitIndex);
5516 if (WarnIndexes.empty())
5520 llvm::sort(CorrelatedInitOrder, llvm::less_first());
5526 Inits[WarnIndexes.front() - 1]->getSourceLocation(),
5527 WarnIndexes.size() == 1 ? diag::warn_initializer_out_of_order
5528 : diag::warn_some_initializers_out_of_order);
5530 for (
unsigned I = 0; I < CorrelatedInitOrder.size(); ++I) {
5531 if (CorrelatedInitOrder[I].second == I)
5537 Inits[I]->getSourceRange(),
5540 Inits[CorrelatedInitOrder[I].second]->getSourceRange()),
5546 if (WarnIndexes.size() == 1) {
5548 Inits[WarnIndexes.front()]);
5554 for (
unsigned WarnIndex : WarnIndexes) {
5557 diag::note_initializer_out_of_order);
5564bool CheckRedundantInit(
Sema &S,
5574 diag::err_multiple_mem_initialization)
5575 <<
Field->getDeclName()
5576 <<
Init->getSourceRange();
5578 const Type *BaseClass =
Init->getBaseClass();
5579 assert(BaseClass &&
"neither field nor base");
5581 diag::err_multiple_base_initialization)
5583 <<
Init->getSourceRange();
5591typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5592typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5594bool CheckRedundantUnionInit(
Sema &S,
5596 RedundantUnionMap &Unions) {
5601 while (
Parent->isAnonymousStructOrUnion() ||
Parent->isUnion()) {
5603 UnionEntry &En = Unions[
Parent];
5604 if (En.first && En.first != Child) {
5606 diag::err_multiple_mem_union_initialization)
5607 <<
Field->getDeclName()
5608 <<
Init->getSourceRange();
5609 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5610 << 0 << En.second->getSourceRange();
5617 if (!
Parent->isAnonymousStructOrUnion())
5633 if (!ConstructorDecl)
5639 = dyn_cast<CXXConstructorDecl>(ConstructorDecl);
5642 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5649 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5652 RedundantUnionMap MemberUnions;
5654 bool HadError =
false;
5655 for (
unsigned i = 0; i < MemInits.size(); i++) {
5659 Init->setSourceOrder(i);
5661 if (
Init->isAnyMemberInitializer()) {
5663 if (CheckRedundantInit(*
this,
Init, Members[Key]) ||
5664 CheckRedundantUnionInit(*
this,
Init, MemberUnions))
5666 }
else if (
Init->isBaseInitializer()) {
5668 if (CheckRedundantInit(*
this,
Init, Members[Key]))
5671 assert(
Init->isDelegatingInitializer());
5673 if (MemInits.size() != 1) {
5675 diag::err_delegating_initializer_alone)
5676 <<
Init->getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5692 DiagnoseUninitializedFields(*
this, Constructor);
5709 for (
auto *Field : ClassDecl->
fields()) {
5710 if (Field->isInvalidDecl())
5737 PDiag(diag::err_access_dtor_field)
5738 << Field->getDeclName()
5747 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5754 if (Dtor && Dtor->
isUsed())
5755 VisitVirtualBases =
false;
5761 for (
const auto &
Base : ClassDecl->
bases()) {
5767 if (
Base.isVirtual()) {
5768 if (!VisitVirtualBases)
5770 DirectVirtualBases.insert(RT);
5787 PDiag(diag::err_access_dtor_base)
5788 <<
Base.getType() <<
Base.getSourceRange(),
5795 if (VisitVirtualBases)
5797 &DirectVirtualBases);
5802 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases) {
5804 for (
const auto &VBase : ClassDecl->
vbases()) {
5809 if (DirectVirtualBases && DirectVirtualBases->count(RT))
5825 PDiag(diag::err_access_dtor_vbase)
5831 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5845 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5847 !ClassDecl || ClassDecl->isInvalidDecl()) {
5851 DiagnoseUninitializedFields(*
this, Constructor);
5906 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5907 MEnd = FinalOverriders.end();
5911 SOEnd = M->second.end();
5912 SO != SOEnd; ++SO) {
5919 if (SO->second.size() != 1)
5922 if (!SO->second.front().Method->isPureVirtual())
5925 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5928 Diag(SO->second.front().Method->getLocation(),
5929 diag::note_pure_virtual_function)
5930 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5940struct AbstractUsageInfo {
5948 AbstractType(S.Context.getCanonicalType(
5949 S.Context.getTypeDeclType(
Record))),
5952 void DiagnoseAbstractType() {
5961struct CheckAbstractUsage {
5962 AbstractUsageInfo &Info;
5965 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
5966 : Info(Info), Ctx(Ctx) {}
5970#define ABSTRACT_TYPELOC(CLASS, PARENT)
5971#define TYPELOC(CLASS, PARENT) \
5972 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break;
5973#include "clang/AST/TypeLocNodes.def"
5994 for (
unsigned I = 0,
E = TL.
getNumArgs(); I !=
E; ++I) {
6004#define CheckPolymorphic(Type) \
6005 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \
6006 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \
6021 return Visit(Next, Sel);
6031 T = Info.S.Context.getBaseElementType(
T);
6034 if (CT != Info.AbstractType)
return;
6039 Info.S.Diag(Ctx->
getLocation(), diag::err_array_of_abstract_type)
6042 Info.S.Diag(Ctx->
getLocation(), diag::err_abstract_type_in_decl)
6045 Info.DiagnoseAbstractType();
6051 CheckAbstractUsage(*
this,
D).Visit(TL, Sel);
6086 for (
auto *
D : RD->
decls()) {
6090 if (
auto *FD = dyn_cast<FriendDecl>(
D)) {
6091 D = FD->getFriendDecl();
6096 if (
auto *FD = dyn_cast<FunctionDecl>(
D)) {
6098 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
D)) {
6102 }
else if (
auto *FD = dyn_cast<FieldDecl>(
D)) {
6105 }
else if (
auto *VD = dyn_cast<VarDecl>(
D)) {
6107 }
else if (
auto *VTD = dyn_cast<VarTemplateDecl>(
D)) {
6111 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(
D)) {
6113 }
else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(
D)) {
6124 assert(ClassAttr->
getKind() == attr::DLLExport);
6134 struct MarkingClassDllexported {
6145 ~MarkingClassDllexported() {
6155 if (!
Member->hasAttr<DLLExportAttr>())
6160 auto *VD = dyn_cast<VarDecl>(
Member);
6161 if (VD && VD->getStorageClass() ==
SC_Static &&
6165 auto *MD = dyn_cast<CXXMethodDecl>(
Member);
6169 if (MD->isUserProvided()) {
6179 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6189 }
else if (MD->isExplicitlyDefaulted()) {
6198 }
else if (!MD->isTrivial() ||
6199 MD->isCopyAssignmentOperator() ||
6200 MD->isMoveAssignmentOperator()) {
6224 auto *CD = dyn_cast<CXXConstructorDecl>(
Member);
6225 if (!CD || !CD->isDefaultConstructor())
6227 auto *
Attr = CD->getAttr<DLLExportAttr>();
6233 if (!
Class->isDependentContext()) {
6240 if (LastExportedDefaultCtor) {
6242 diag::err_attribute_dll_ambiguous_default_ctor)
6244 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
6245 << CD->getDeclName();
6248 LastExportedDefaultCtor = CD;
6254 bool ErrorReported =
false;
6255 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6259 S.
Diag(TD->getLocation(),
6260 diag::err_cuda_device_builtin_surftex_cls_template)
6262 ErrorReported =
true;
6267 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(
Class);
6270 diag::err_cuda_device_builtin_surftex_ref_decl)
6273 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6277 TD = SD->getSpecializedTemplate();
6281 unsigned N = Params->
size();
6284 reportIllegalClassTemplate(S, TD);
6286 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6289 if (N > 0 && !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
6290 reportIllegalClassTemplate(S, TD);
6292 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6296 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6297 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6298 reportIllegalClassTemplate(S, TD);
6300 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6308 bool ErrorReported =
false;
6309 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6313 S.
Diag(TD->getLocation(),
6314 diag::err_cuda_device_builtin_surftex_cls_template)
6316 ErrorReported =
true;
6321 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(
Class);
6324 diag::err_cuda_device_builtin_surftex_ref_decl)
6327 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6331 TD = SD->getSpecializedTemplate();
6335 unsigned N = Params->
size();
6338 reportIllegalClassTemplate(S, TD);
6340 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6343 if (N > 0 && !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
6344 reportIllegalClassTemplate(S, TD);
6346 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6350 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6351 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6352 reportIllegalClassTemplate(S, TD);
6354 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6359 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(2));
6360 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6361 reportIllegalClassTemplate(S, TD);
6363 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6371 for (
auto *Method :
Class->methods()) {
6372 if (Method->isUserProvided())
6384 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(
Class)) {
6385 if (
Attr *TemplateAttr =
6386 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
6387 auto *A = cast<InheritableAttr>(TemplateAttr->clone(
getASTContext()));
6388 A->setInherited(
true);
6403 (!
Class->isExternallyVisible() &&
Class->hasExternalFormalLinkage())) {
6404 Class->dropAttrs<DLLExportAttr, DLLImportAttr>();
6408 if (!
Class->isExternallyVisible()) {
6409 Diag(
Class->getLocation(), diag::err_attribute_dll_not_extern)
6410 <<
Class << ClassAttr;
6418 if (!isa<VarDecl>(
Member) && !isa<CXXMethodDecl>(
Member))
6425 diag::err_attribute_dll_member_of_dll_class)
6426 << MemberAttr << ClassAttr;
6427 Diag(ClassAttr->getLocation(), diag::note_previous_attribute);
6428 Member->setInvalidDecl();
6432 if (
Class->getDescribedClassTemplate())
6437 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
6442 const bool PropagatedImport =
6444 cast<DLLImportAttr>(ClassAttr)->wasPropagatedToBaseTemplate();
6453 Class->dropAttr<DLLExportAttr>();
6487 auto *Ctor = dyn_cast<CXXConstructorDecl>(MD);
6496 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->
isTrivial())
6503 if (VD && PropagatedImport)
6517 if (ClassExported) {
6529 Member->addAttr(NewAttr);
6539 "friend re-decl should not already have a DLLAttr");
6569 NewAttr->setInherited(
true);
6570 BaseTemplateSpec->
addAttr(NewAttr);
6574 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
6575 ImportAttr->setPropagatedToBaseTemplate();
6596 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
6601 diag::note_template_class_explicit_specialization_was_here)
6602 << BaseTemplateSpec;
6605 diag::note_template_class_instantiation_was_here)
6606 << BaseTemplateSpec;
6612 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
6624 if (MD->isCopyAssignmentOperator())
6627 if (MD->isMoveAssignmentOperator())
6630 if (isa<CXXDestructorDecl>(FD))
6638 case OO_ExclaimEqual:
6650 case OO_GreaterEqual:
6673 cast<CXXConstructorDecl>(FD));
6691 llvm_unreachable(
"Invalid special member.");
6705 return !
D->hasNonTrivialDestructorForCall() &&
6706 !
D->hasNonTrivialCopyConstructorForCall();
6709 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
6710 bool DtorIsTrivialForCall =
false;
6718 if (
D->needsImplicitCopyConstructor()) {
6719 if (!
D->defaultedCopyConstructorIsDeleted()) {
6720 if (
D->hasTrivialCopyConstructor())
6721 CopyCtorIsTrivial =
true;
6722 if (
D->hasTrivialCopyConstructorForCall())
6723 CopyCtorIsTrivialForCall =
true;
6727 if (CD->isCopyConstructor() && !CD->isDeleted() &&
6728 !CD->isIneligibleOrNotSelected()) {
6729 if (CD->isTrivial())
6730 CopyCtorIsTrivial =
true;
6731 if (CD->isTrivialForCall())
6732 CopyCtorIsTrivialForCall =
true;
6737 if (
D->needsImplicitDestructor()) {
6738 if (!
D->defaultedDestructorIsDeleted() &&
6739 D->hasTrivialDestructorForCall())
6740 DtorIsTrivialForCall =
true;
6741 }
else if (
const auto *DD =
D->getDestructor()) {
6742 if (!DD->isDeleted() && DD->isTrivialForCall())
6743 DtorIsTrivialForCall =
true;
6747 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
6761 uint64_t TypeSize = isAArch64 ? 128 : 64;
6763 if (CopyCtorIsTrivial &&
6773 bool HasNonDeletedCopyOrMove =
false;
6775 if (
D->needsImplicitCopyConstructor() &&
6776 !
D->defaultedCopyConstructorIsDeleted()) {
6777 if (!
D->hasTrivialCopyConstructorForCall())
6779 HasNonDeletedCopyOrMove =
true;
6782 if (S.
getLangOpts().CPlusPlus11 &&
D->needsImplicitMoveConstructor() &&
6783 !
D->defaultedMoveConstructorIsDeleted()) {
6784 if (!
D->hasTrivialMoveConstructorForCall())
6786 HasNonDeletedCopyOrMove =
true;
6789 if (
D->needsImplicitDestructor() && !
D->defaultedDestructorIsDeleted() &&
6790 !
D->hasTrivialDestructorForCall())
6794 if (MD->isDeleted() || MD->isIneligibleOrNotSelected())
6797 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6798 if (CD && CD->isCopyOrMoveConstructor())
6799 HasNonDeletedCopyOrMove =
true;
6800 else if (!isa<CXXDestructorDecl>(MD))
6803 if (!MD->isTrivialForCall())
6807 return HasNonDeletedCopyOrMove;
6818 bool IssuedDiagnostic =
false;
6821 if (!IssuedDiagnostic) {
6823 IssuedDiagnostic =
true;
6825 S.
Diag(O->getLocation(), diag::note_overridden_virtual_function);
6828 return IssuedDiagnostic;
6835 if (
Record->isAbstract() && !
Record->isInvalidDecl()) {
6836 AbstractUsageInfo Info(*
this,
Record);
6843 if (!
Record->isInvalidDecl() && !
Record->isDependentType() &&
6844 !
Record->isAggregate() && !
Record->hasUserDeclaredConstructor() &&
6846 bool Complained =
false;
6847 for (
const auto *F :
Record->fields()) {
6848 if (F->hasInClassInitializer() || F->isUnnamedBitField())
6851 if (F->getType()->isReferenceType() ||
6852 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
6854 Diag(
Record->getLocation(), diag::warn_no_constructor_for_refconst)
6855 << llvm::to_underlying(
Record->getTagKind()) <<
Record;
6859 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
6860 << F->getType()->isReferenceType()
6861 << F->getDeclName();
6866 if (
Record->getIdentifier()) {
6879 if (((isa<FieldDecl>(
D) || isa<UnresolvedUsingValueDecl>(
D)) &&
6880 Record->hasUserDeclaredConstructor()) ||
6881 isa<IndirectFieldDecl>(
D)) {
6882 Diag((*I)->getLocation(), diag::err_member_name_of_class)
6883 <<
D->getDeclName();
6890 if (
Record->isPolymorphic() && !
Record->isDependentType()) {
6893 !
Record->hasAttr<FinalAttr>())
6898 if (
Record->isAbstract()) {
6899 if (FinalAttr *FA =
Record->getAttr<FinalAttr>()) {
6900 Diag(
Record->getLocation(), diag::warn_abstract_final_class)
6901 << FA->isSpelledAsSealed();
6907 if (!
Record->hasAttr<FinalAttr>()) {
6909 if (
const FinalAttr *FA = dtor->getAttr<FinalAttr>()) {
6910 Diag(FA->getLocation(), diag::warn_final_dtor_non_final_class)
6911 << FA->isSpelledAsSealed()
6914 (FA->isSpelledAsSealed() ?
" sealed" :
" final"));
6916 diag::note_final_dtor_non_final_class_silence)
6923 if (
Record->hasAttr<TrivialABIAttr>())
6928 bool HasTrivialABI =
Record->hasAttr<TrivialABIAttr>();
6931 Record->setHasTrivialSpecialMemberForCall();
6941 auto CheckCompletedMemberFunction = [&](
CXXMethodDecl *MD) {
6952 MD->
isDeleted() ? diag::err_deleted_override
6953 : diag::err_non_deleted_override,
6957 if (MD->isDefaulted() && MD->isDeleted())
6966 MD->isConsteval() ? diag::err_consteval_override
6967 : diag::err_non_consteval_override,
6969 return MD->isConsteval() !=
V->isConsteval();
6971 if (MD->isDefaulted() && MD->isDeleted())
6978 auto CheckForDefaultedFunction = [&](
FunctionDecl *FD) ->
bool {
6979 if (!FD || FD->
isInvalidDecl() || !FD->isExplicitlyDefaulted())
6985 DefaultedSecondaryComparisons.push_back(FD);
6993 if (!
Record->isInvalidDecl() &&
6994 Record->hasAttr<VTablePointerAuthenticationAttr>())
6999 bool Incomplete = CheckForDefaultedFunction(M);
7002 if (
Record->isDependentType())
7008 if (!M->isImplicit() && !M->isUserProvided()) {
7012 Record->finishedDefaultedOrDeletedMember(M);
7013 M->setTrivialForCall(
7016 Record->setTrivialForCallFlags(M);
7025 M->isUserProvided()) {
7026 M->setTrivialForCall(HasTrivialABI);
7027 Record->setTrivialForCallFlags(M);
7030 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
7031 M->hasAttr<DLLExportAttr>()) {
7037 M->dropAttr<DLLExportAttr>();
7039 if (M->hasAttr<DLLExportAttr>()) {
7045 bool EffectivelyConstexprDestructor =
true;
7049 if (isa<CXXDestructorDecl>(M)) {
7050 auto Check = [](
QualType T,
auto &&Check) ->
bool {
7060 if (!Check(B.getType(), Check))
7063 if (!Check(FD->
getType(), Check))
7067 EffectivelyConstexprDestructor =
7075 M->isDefaulted() && M->isConstexpr() && M->size_overridden_methods() &&
7076 EffectivelyConstexprDestructor)
7080 CheckCompletedMemberFunction(M);
7089 CompleteMemberFunction(Dtor);
7091 bool HasMethodWithOverrideControl =
false,
7092 HasOverridingMethodWithoutOverrideControl =
false;
7093 for (
auto *
D :
Record->decls()) {
7094 if (
auto *M = dyn_cast<CXXMethodDecl>(
D)) {
7097 if (!
Record->isDependentType()) {
7102 if (M->hasAttr<OverrideAttr>())
7103 HasMethodWithOverrideControl =
true;
7104 else if (M->size_overridden_methods() > 0)
7105 HasOverridingMethodWithoutOverrideControl =
true;
7108 if (!isa<CXXDestructorDecl>(M))
7109 CompleteMemberFunction(M);
7110 }
else if (
auto *F = dyn_cast<FriendDecl>(
D)) {
7111 CheckForDefaultedFunction(
7112 dyn_cast_or_null<FunctionDecl>(F->getFriendDecl()));
7116 if (HasOverridingMethodWithoutOverrideControl) {
7117 bool HasInconsistentOverrideControl = HasMethodWithOverrideControl;
7118 for (
auto *M :
Record->methods())
7123 for (
FunctionDecl *FD : DefaultedSecondaryComparisons) {
7127 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD))
7128 CheckCompletedMemberFunction(MD);
7146 Diag(
Record->getLocation(), diag::warn_cxx_ms_struct);
7152 bool ClangABICompat4 =
7160 if (
Record->getArgPassingRestrictions() !=
7162 Record->setArgPassingRestrictions(
7171 Record->setParamDestroyedInCallee(
true);
7172 else if (
Record->hasNonTrivialDestructor())
7173 Record->setParamDestroyedInCallee(CanPass);
7182 if (
Record->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>())
7184 else if (
Record->hasAttr<CUDADeviceBuiltinTextureTypeAttr>())
7202 unsigned LHSQuals = 0;
7205 LHSQuals = FieldQuals;
7207 unsigned RHSQuals = FieldQuals;
7229 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
7235 : S(S), UseLoc(UseLoc) {
7236 bool DiagnosedMultipleConstructedBases =
false;
7242 for (
auto *
D : Shadow->
redecls()) {
7243 auto *DShadow = cast<ConstructorUsingShadowDecl>(
D);
7244 auto *DNominatedBase = DShadow->getNominatedBaseClass();
7245 auto *DConstructedBase = DShadow->getConstructedBaseClass();
7247 InheritedFromBases.insert(
7248 std::make_pair(DNominatedBase->getCanonicalDecl(),
7249 DShadow->getNominatedBaseClassShadowDecl()));
7250 if (DShadow->constructsVirtualBase())
7251 InheritedFromBases.insert(
7252 std::make_pair(DConstructedBase->getCanonicalDecl(),
7253 DShadow->getConstructedBaseClassShadowDecl()));
7255 assert(DNominatedBase == DConstructedBase);
7260 if (!ConstructedBase) {
7261 ConstructedBase = DConstructedBase;
7262 ConstructedBaseIntroducer =
D->getIntroducer();
7263 }
else if (ConstructedBase != DConstructedBase &&
7265 if (!DiagnosedMultipleConstructedBases) {
7266 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
7269 diag::note_ambiguous_inherited_constructor_using)
7271 DiagnosedMultipleConstructedBases =
true;
7274 diag::note_ambiguous_inherited_constructor_using)
7275 << DConstructedBase;
7279 if (DiagnosedMultipleConstructedBases)
7286 std::pair<CXXConstructorDecl *, bool>
7288 auto It = InheritedFromBases.find(
Base->getCanonicalDecl());
7289 if (It == InheritedFromBases.end())
7290 return std::make_pair(
nullptr,
false);
7294 return std::make_pair(
7296 It->second->constructsVirtualBase());
7299 return std::make_pair(Ctor,
false);
7316 if (InheritedCtor) {
7319 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
7321 return BaseCtor->isConstexpr();
7389 if (Ctor && ClassDecl->
isUnion())
7409 for (
const auto &B : ClassDecl->
bases()) {
7415 InheritedCtor, Inherited))
7428 for (
const auto *F : ClassDecl->
fields()) {
7429 if (F->isInvalidDecl())
7432 F->hasInClassInitializer())
7436 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
7439 ConstArg && !F->isMutable()))
7454struct ComputingExceptionSpec {
7465 ~ComputingExceptionSpec() {
7485 if (DFK.isSpecialMember())
7487 S,
Loc, cast<CXXMethodDecl>(FD), DFK.asSpecialMember(),
nullptr);
7488 if (DFK.isComparison())
7490 DFK.asComparison());
7492 auto *CD = cast<CXXConstructorDecl>(FD);
7493 assert(CD->getInheritedConstructor() &&
7494 "only defaulted functions and inherited constructors have implicit "
7497 S,
Loc, CD->getInheritedConstructor().getShadowDecl());
7524 auto ESI = IES.getExceptionSpec();
7556 "not an explicitly-defaulted special member");
7566 bool HadError =
false;
7579 bool ShouldDeleteForTypeMismatch =
false;
7580 unsigned ExpectedParams = 1;
7592 if (DeleteOnTypeMismatch)
7593 ShouldDeleteForTypeMismatch =
true;
7603 bool CanHaveConstParam =
false;
7613 ReturnType =
Type->getReturnType();
7624 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
7626 << ExpectedReturnType;
7632 if (DeleteOnTypeMismatch)
7633 ShouldDeleteForTypeMismatch =
true;
7650 if (!ExplicitObjectParameter.
isNull() &&
7654 if (DeleteOnTypeMismatch)
7655 ShouldDeleteForTypeMismatch =
true;
7658 diag::err_defaulted_special_member_explicit_object_mismatch)
7671 bool HasConstParam =
false;
7678 if (DeleteOnTypeMismatch)
7679 ShouldDeleteForTypeMismatch =
true;
7682 diag::err_defaulted_special_member_volatile_param)
7683 << llvm::to_underlying(CSM);
7688 if (HasConstParam && !CanHaveConstParam) {
7689 if (DeleteOnTypeMismatch)
7690 ShouldDeleteForTypeMismatch =
true;
7694 diag::err_defaulted_special_member_copy_const_param)
7700 diag::err_defaulted_special_member_move_const_param)
7705 }
else if (ExpectedParams) {
7709 "unexpected non-ref argument");
7738 : isa<CXXConstructorDecl>(MD))) &&
7743 diag::err_incorrect_defaulted_constexpr_with_vb)
7744 << llvm::to_underlying(CSM);
7745 for (
const auto &I : RD->
vbases())
7746 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here);
7765 if (!
Type->hasExceptionSpec()) {
7783 << llvm::to_underlying(CSM);
7784 if (ShouldDeleteForTypeMismatch) {
7786 << llvm::to_underlying(CSM);
7790 Diag(DefaultLoc, diag::note_replace_equals_default_to_delete)
7794 if (ShouldDeleteForTypeMismatch && !HadError) {
7796 diag::warn_cxx17_compat_defaulted_method_type_mismatch)
7797 << llvm::to_underlying(CSM);
7804 << llvm::to_underlying(CSM);
7805 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
7827template<
typename Derived,
typename ResultList,
typename Result,
7829class DefaultedComparisonVisitor {
7834 DefaultedComparisonKind DCK)
7835 : S(S), RD(RD), FD(FD), DCK(DCK) {
7839 Fns.assign(Info->getUnqualifiedLookups().begin(),
7840 Info->getUnqualifiedLookups().end());
7844 ResultList visit() {
7852 case DefaultedComparisonKind::None:
7853 llvm_unreachable(
"not a defaulted comparison");
7855 case DefaultedComparisonKind::Equal:
7856 case DefaultedComparisonKind::ThreeWay:
7857 getDerived().visitSubobjects(Results, RD, ParamLvalType.
getQualifiers());
7860 case DefaultedComparisonKind::NotEqual:
7861 case DefaultedComparisonKind::Relational:
7862 Results.add(getDerived().visitExpandedSubobject(
7863 ParamLvalType, getDerived().getCompleteObject()));
7866 llvm_unreachable(
"");
7870 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
7881 if (Results.add(getDerived().visitSubobject(
7883 getDerived().getBase(&
Base))))
7890 if (
Field->isUnnamedBitField())
7893 if (
Field->isAnonymousStructOrUnion()) {
7894 if (visitSubobjects(Results,
Field->getType()->getAsCXXRecordDecl(),
7902 if (
Field->isMutable())
7907 if (Results.add(getDerived().visitSubobject(
7908 FieldType, getDerived().getField(Field))))
7916 Result visitSubobject(
QualType Type, Subobject Subobj) {
7919 if (
auto *CAT = dyn_cast_or_null<ConstantArrayType>(AT))
7920 return getDerived().visitSubobjectArray(CAT->getElementType(),
7921 CAT->getSize(), Subobj);
7922 return getDerived().visitExpandedSubobject(
Type, Subobj);
7925 Result visitSubobjectArray(
QualType Type,
const llvm::APInt &Size,
7927 return getDerived().visitSubobject(
Type, Subobj);
7934 DefaultedComparisonKind DCK;
7940struct DefaultedComparisonInfo {
7945 static DefaultedComparisonInfo deleted() {
7946 DefaultedComparisonInfo
Deleted;
7951 bool add(
const DefaultedComparisonInfo &R) {
7961struct DefaultedComparisonSubobject {
7969class DefaultedComparisonAnalyzer
7970 :
public DefaultedComparisonVisitor<DefaultedComparisonAnalyzer,
7971 DefaultedComparisonInfo,
7972 DefaultedComparisonInfo,
7973 DefaultedComparisonSubobject> {
7975 enum DiagnosticKind { NoDiagnostics, ExplainDeleted, ExplainConstexpr };
7978 DiagnosticKind Diagnose;
7981 using Base = DefaultedComparisonVisitor;
7982 using Result = DefaultedComparisonInfo;
7983 using Subobject = DefaultedComparisonSubobject;
7988 DefaultedComparisonKind DCK,
7989 DiagnosticKind Diagnose = NoDiagnostics)
7990 :
Base(S, RD, FD, DCK), Diagnose(Diagnose) {}
7993 if ((DCK == DefaultedComparisonKind::Equal ||
7994 DCK == DefaultedComparisonKind::ThreeWay) &&
7999 if (Diagnose == ExplainDeleted) {
8003 return Result::deleted();
8006 return Base::visit();
8010 Subobject getCompleteObject() {
8011 return Subobject{Subobject::CompleteObject, RD, FD->
getLocation()};
8015 return Subobject{Subobject::Base,
Base->getType()->getAsCXXRecordDecl(),
8016 Base->getBaseTypeLoc()};
8020 return Subobject{Subobject::Member,
Field,
Field->getLocation()};
8023 Result visitExpandedSubobject(
QualType Type, Subobject Subobj) {
8028 if (Diagnose == ExplainDeleted) {
8029 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_reference_member)
8032 return Result::deleted();
8037 Expr *Args[] = {&Xi, &Xi};
8041 assert(OO !=
OO_None &&
"not an overloaded operator!");
8042 return visitBinaryOperator(OO, Args, Subobj);
8056 !SpaceshipCandidates));
8061 CandidateSet.exclude(FD);
8063 if (Args[0]->getType()->isOverloadableType())
8074 switch (CandidateSet.BestViableFunction(S, FD->
getLocation(), Best)) {
8080 if ((DCK == DefaultedComparisonKind::NotEqual ||
8081 DCK == DefaultedComparisonKind::Relational) &&
8082 !Best->RewriteKind) {
8083 if (Diagnose == ExplainDeleted) {
8084 if (Best->Function) {
8085 S.
Diag(Best->Function->getLocation(),
8086 diag::note_defaulted_comparison_not_rewritten_callee)
8089 assert(Best->Conversions.size() == 2 &&
8090 Best->Conversions[0].isUserDefined() &&
8091 "non-user-defined conversion from class to built-in "
8093 S.
Diag(Best->Conversions[0]
8094 .UserDefined.FoundConversionFunction.getDecl()
8096 diag::note_defaulted_comparison_not_rewritten_conversion)
8100 return Result::deleted();
8110 CXXRecordDecl *ArgClass = Args[0]->getType()->getAsCXXRecordDecl();
8111 if (ArgClass && Best->FoundDecl.getDecl() &&
8112 Best->FoundDecl.getDecl()->isCXXClassMember()) {
8113 QualType ObjectType = Subobj.Kind == Subobject::Member
8114 ? Args[0]->getType()
8117 ArgClass, Best->FoundDecl, ObjectType, Subobj.Loc,
8118 Diagnose == ExplainDeleted
8119 ? S.
PDiag(diag::note_defaulted_comparison_inaccessible)
8120 << FD << Subobj.Kind << Subobj.Decl
8122 return Result::deleted();
8125 bool NeedsDeducing =
8133 assert(!BestFD->isDeleted() &&
"wrong overload resolution result");
8135 if (Diagnose == ExplainConstexpr && !BestFD->isConstexpr()) {
8136 if (Subobj.Kind != Subobject::CompleteObject)
8137 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_not_constexpr)
8138 << Subobj.
Kind << Subobj.Decl;
8139 S.
Diag(BestFD->getLocation(),
8140 diag::note_defaulted_comparison_not_constexpr_here);
8142 return Result::deleted();
8144 R.Constexpr &= BestFD->isConstexpr();
8146 if (NeedsDeducing) {
8151 if (BestFD->getReturnType()->isUndeducedType() &&
8157 if (Diagnose == NoDiagnostics) {
8160 diag::err_defaulted_comparison_cannot_deduce_undeduced_auto)
8161 << Subobj.
Kind << Subobj.Decl;
8164 diag::note_defaulted_comparison_cannot_deduce_undeduced_auto)
8165 << Subobj.
Kind << Subobj.Decl;
8166 S.
Diag(BestFD->getLocation(),
8167 diag::note_defaulted_comparison_cannot_deduce_callee)
8168 << Subobj.
Kind << Subobj.Decl;
8170 return Result::deleted();
8173 BestFD->getCallResultType());
8175 if (Diagnose == ExplainDeleted) {
8176 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_cannot_deduce)
8177 << Subobj.
Kind << Subobj.Decl
8178 << BestFD->getCallResultType().withoutLocalFastQualifiers();
8179 S.
Diag(BestFD->getLocation(),
8180 diag::note_defaulted_comparison_cannot_deduce_callee)
8181 << Subobj.
Kind << Subobj.Decl;
8183 return Result::deleted();
8185 R.Category = Info->Kind;
8188 QualType T = Best->BuiltinParamTypes[0];
8189 assert(
T == Best->BuiltinParamTypes[1] &&
8190 "builtin comparison for different types?");
8191 assert(Best->BuiltinParamTypes[2].isNull() &&
8192 "invalid builtin comparison");
8194 if (NeedsDeducing) {
8195 std::optional<ComparisonCategoryType> Cat =
8197 assert(Cat &&
"no category for builtin comparison?");
8208 if (Diagnose == ExplainDeleted) {
8211 Kind = OO == OO_EqualEqual ? 1 : 2;
8212 CandidateSet.NoteCandidates(
8214 Subobj.Loc, S.
PDiag(diag::note_defaulted_comparison_ambiguous)
8215 << FD <<
Kind << Subobj.Kind << Subobj.Decl),
8218 R = Result::deleted();
8222 if (Diagnose == ExplainDeleted) {
8223 if ((DCK == DefaultedComparisonKind::NotEqual ||
8224 DCK == DefaultedComparisonKind::Relational) &&
8225 !Best->RewriteKind) {
8226 S.
Diag(Best->Function->getLocation(),
8227 diag::note_defaulted_comparison_not_rewritten_callee)
8231 diag::note_defaulted_comparison_calls_deleted)
8232 << FD << Subobj.
Kind << Subobj.Decl;
8236 R = Result::deleted();
8242 if (OO == OO_Spaceship &&
8246 if (!R.add(visitBinaryOperator(OO_EqualEqual, Args, Subobj,
8248 R.add(visitBinaryOperator(OO_Less, Args, Subobj, &CandidateSet));
8252 if (Diagnose == ExplainDeleted) {
8253 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_no_viable_function)
8254 << FD << (OO == OO_EqualEqual || OO == OO_ExclaimEqual)
8255 << Subobj.
Kind << Subobj.Decl;
8259 if (SpaceshipCandidates) {
8260 SpaceshipCandidates->NoteCandidates(
8265 diag::note_defaulted_comparison_no_viable_function_synthesized)
8266 << (OO == OO_EqualEqual ? 0 : 1);
8269 CandidateSet.NoteCandidates(
8274 R = Result::deleted();
8283struct StmtListResult {
8284 bool IsInvalid =
false;
8288 IsInvalid |= S.isInvalid();
8291 Stmts.push_back(S.get());
8298class DefaultedComparisonSynthesizer
8299 :
public DefaultedComparisonVisitor<DefaultedComparisonSynthesizer,
8300 StmtListResult, StmtResult,
8301 std::pair<ExprResult, ExprResult>> {
8303 unsigned ArrayDepth = 0;
8306 using Base = DefaultedComparisonVisitor;
8307 using ExprPair = std::pair<ExprResult, ExprResult>;
8312 DefaultedComparisonKind DCK,
8314 :
Base(S, RD, FD, DCK),
Loc(BodyLoc) {}
8320 StmtListResult Stmts = visit();
8321 if (Stmts.IsInvalid)
8326 case DefaultedComparisonKind::None:
8327 llvm_unreachable(
"not a defaulted comparison");
8329 case DefaultedComparisonKind::Equal: {
8338 auto OldStmts = std::move(Stmts.Stmts);
8339 Stmts.Stmts.clear();
8342 auto FinishCmp = [&] {
8343 if (
Expr *Prior = CmpSoFar.
get()) {
8345 if (RetVal.
isUnset() && Stmts.Stmts.empty())
8348 else if (Stmts.add(buildIfNotCondReturnFalse(Prior)))
8354 for (
Stmt *EAsStmt : llvm::reverse(OldStmts)) {
8355 Expr *
E = dyn_cast<Expr>(EAsStmt);
8358 if (FinishCmp() || Stmts.add(EAsStmt))
8373 std::reverse(Stmts.Stmts.begin(), Stmts.Stmts.end());
8380 case DefaultedComparisonKind::ThreeWay: {
8384 ComparisonCategoryType::StrongOrdering,
Loc,
8385 Sema::ComparisonCategoryUsage::DefaultedOperator);
8391 RetVal = getDecl(EqualVD);
8394 RetVal = buildStaticCastToR(RetVal.
get());
8398 case DefaultedComparisonKind::NotEqual:
8399 case DefaultedComparisonKind::Relational:
8400 RetVal = cast<Expr>(Stmts.Stmts.pop_back_val());
8426 ExprPair getCompleteObject() {
8429 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD);
8436 LHS = getParam(Param++);
8444 ExprPair Obj = getCompleteObject();
8445 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8455 ExprPair Obj = getCompleteObject();
8456 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8479 assert(!
False.isInvalid() &&
"should never fail");
8486 Sema::ConditionKind::Boolean),
8499 llvm::raw_svector_ostream OS(Str);
8500 OS <<
"i" << ArrayDepth;
8511 auto IterRef = [&] {
8515 assert(!Ref.
isInvalid() &&
"can't reference our own variable?");
8521 Loc, BO_NE, IterRef(),
8523 assert(!Cond.
isInvalid() &&
"should never fail");
8527 assert(!
Inc.isInvalid() &&
"should never fail");
8535 Subobj.first = Index(Subobj.first);
8536 Subobj.second = Index(Subobj.second);
8549 if (
Expr *ElemCmp = dyn_cast<Expr>(Substmt.
get())) {
8550 assert(DCK == DefaultedComparisonKind::Equal &&
8551 "should have non-expression statement");
8552 Substmt = buildIfNotCondReturnFalse(ElemCmp);
8560 Sema::ConditionKind::Boolean),
8566 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8574 Obj.second.get(),
true,
8582 case DefaultedComparisonKind::None:
8583 llvm_unreachable(
"not a defaulted comparison");
8585 case DefaultedComparisonKind::Equal:
8593 case DefaultedComparisonKind::ThreeWay: {
8598 Op = buildStaticCastToR(Op.
get());
8623 if (
Comp.isInvalid())
8626 nullptr,
Loc,
Comp.get(), Sema::ConditionKind::Boolean);
8631 VDRef = getDecl(VD);
8644 case DefaultedComparisonKind::NotEqual:
8645 case DefaultedComparisonKind::Relational:
8650 llvm_unreachable(
"");
8656 assert(!R->
isUndeducedType() &&
"type should have been deduced already");
8674 Self.LookupOverloadedOperatorName(OO, S, Operators);
8687 if (Op == OO_Spaceship) {
8688 Lookup(OO_ExclaimEqual);
8690 Lookup(OO_EqualEqual);
8718 bool IsMethod = isa<CXXMethodDecl>(FD);
8720 auto *MD = cast<CXXMethodDecl>(FD);
8721 assert(!MD->
isStatic() &&
"comparison function cannot be a static member");
8731 FPT->getParamTypes(), EPI));
8738 if (!
T.getNonReferenceType().isConstQualified() &&
8748 InsertLoc =
Loc.getRParenLoc();
8753 Diag(
Loc, diag::err_defaulted_comparison_non_const)
8761 T.getNonReferenceType().withConst()));
8767 FPT->getParamTypes(), EPI));
8779 FPT->getParamTypes(), EPI));
8785 (IsMethod ? 1 : 2)) {
8789 <<
int(IsMethod) <<
int(DCK);
8795 QualType ParmTy = Param->getType();
8804 CTy = Ref->getPointeeType();
8814 RD = CTy->getAsCXXRecordDecl();
8815 Ok &= RD !=
nullptr;
8829 <<
int(DCK) << ParmTy << RefTy <<
int(!IsMethod) << PlainTy
8830 << Param->getSourceRange();
8832 assert(!IsMethod &&
"should know expected type for method");
8834 diag::err_defaulted_comparison_param_unknown)
8835 <<
int(DCK) << ParmTy << Param->getSourceRange();
8841 Diag(FD->
getLocation(), diag::err_defaulted_comparison_param_mismatch)
8843 << ParmTy << Param->getSourceRange();
8848 assert(RD &&
"must have determined class");
8857 diag::err_defaulted_comparison_not_friend,
int(DCK),
8862 return FD->getCanonicalDecl() ==
8863 F->getFriendDecl()->getCanonicalDecl();
8866 <<
int(DCK) <<
int(0) << RD;
8878 Diag(FD->
getLocation(), diag::err_defaulted_comparison_return_type_not_bool)
8888 RT->getContainedDeducedType() &&
8890 RT->getContainedAutoType()->isConstrained())) {
8892 diag::err_defaulted_comparison_deduced_return_type_not_auto)
8904 DefaultedComparisonInfo Info =
8905 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK).visit();
8919 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8920 DefaultedComparisonAnalyzer::ExplainDeleted)
8931 diag::note_previous_declaration);
8943 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8944 DefaultedComparisonAnalyzer::ExplainDeleted)
8994 Diag(FD->
getBeginLoc(), diag::err_defaulted_comparison_constexpr_mismatch)
8996 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8997 DefaultedComparisonAnalyzer::ExplainConstexpr)
9018 EPI.ExceptionSpec.SourceDecl = FD;
9020 FPT->getParamTypes(), EPI));
9035 EqualEqual->setImplicit();
9050 Scope.addContextNote(UseLoc);
9057 CXXRecordDecl *RD = PT.getNonReferenceType()->getAsCXXRecordDecl();
9061 DefaultedComparisonSynthesizer(*
this, RD, FD, DCK, BodyLoc).build();
9075 L->CompletedImplicitDefinition(FD);
9082 ComputingExceptionSpec CES(S, FD,
Loc);
9112 DefaultedComparisonSynthesizer(S, RD, FD, DCK, BodyLoc).build();
9134 for (
auto &Check : Overriding)
9146template<
typename Derived>
9147struct SpecialMemberVisitor {
9154 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
9158 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
9160 case CXXSpecialMemberKind::DefaultConstructor:
9161 case CXXSpecialMemberKind::CopyConstructor:
9162 case CXXSpecialMemberKind::MoveConstructor:
9163 IsConstructor =
true;
9165 case CXXSpecialMemberKind::CopyAssignment:
9166 case CXXSpecialMemberKind::MoveAssignment:
9167 IsAssignment =
true;
9169 case CXXSpecialMemberKind::Destructor:
9171 case CXXSpecialMemberKind::Invalid:
9172 llvm_unreachable(
"invalid special member kind");
9178 ConstArg = RT->getPointeeType().isConstQualified();
9182 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
9185 bool isMove()
const {
9186 return CSM == CXXSpecialMemberKind::MoveConstructor ||
9187 CSM == CXXSpecialMemberKind::MoveAssignment;
9192 unsigned Quals,
bool IsMutable) {
9194 ConstArg && !IsMutable);
9202 assert(CSM == CXXSpecialMemberKind::DefaultConstructor);
9204 cast<CXXConstructorDecl>(MD)->getInheritedConstructor().getConstructor();
9211 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
9218 return B->getBaseTypeLoc();
9220 return Subobj.get<
FieldDecl*>()->getLocation();
9225 VisitNonVirtualBases,
9230 VisitPotentiallyConstructedBases,
9236 bool visit(BasesToVisit Bases) {
9239 if (Bases == VisitPotentiallyConstructedBases)
9240 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
9242 for (
auto &B : RD->
bases())
9243 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
9244 getDerived().visitBase(&B))
9247 if (Bases == VisitAllBases)
9248 for (
auto &B : RD->
vbases())
9249 if (getDerived().visitBase(&B))
9252 for (
auto *F : RD->
fields())
9253 if (!F->isInvalidDecl() && !F->isUnnamedBitField() &&
9254 getDerived().visitField(F))
9263struct SpecialMemberDeletionInfo
9264 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
9269 bool AllFieldsAreConst;
9274 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
9275 Loc(MD->getLocation()), AllFieldsAreConst(
true) {}
9280 return ICI ? CXXSpecialMemberKind::Invalid : CSM;
9286 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
9289 bool shouldDeleteForField(
FieldDecl *FD);
9290 bool shouldDeleteForAllConstMembers();
9292 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
9294 bool shouldDeleteForSubobjectCall(Subobject Subobj,
9296 bool IsDtorCallInCtor);
9304bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
9325bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
9327 bool IsDtorCallInCtor) {
9334 DiagKind = !
Decl ? 0 : 1;
9337 else if (!isAccessible(Subobj,
Decl))
9339 else if (!IsDtorCallInCtor && Field &&
Field->getParent()->isUnion() &&
9340 !
Decl->isTrivial()) {
9352 const auto *RD = cast<CXXRecordDecl>(
Field->getParent());
9366 diag::note_deleted_special_member_class_subobject)
9367 << llvm::to_underlying(getEffectiveCSM()) << MD->
getParent()
9368 <<
true <<
Field << DiagKind << IsDtorCallInCtor
9373 diag::note_deleted_special_member_class_subobject)
9374 << llvm::to_underlying(getEffectiveCSM()) << MD->
getParent()
9375 <<
false <<
Base->getType() << DiagKind
9376 << IsDtorCallInCtor <<
false;
9389bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
9392 bool IsMutable =
Field &&
Field->isMutable();
9409 Field->hasInClassInitializer()) &&
9410 shouldDeleteForSubobjectCall(Subobj, lookupIn(
Class, Quals, IsMutable),
9417 if (IsConstructor) {
9420 false,
false,
false,
false);
9421 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
9428bool SpecialMemberDeletionInfo::shouldDeleteForVariantObjCPtrMember(
9443 auto *ParentClass = cast<CXXRecordDecl>(FD->
getParent());
9444 S.
Diag(FD->
getLocation(), diag::note_deleted_special_member_class_subobject)
9445 << llvm::to_underlying(getEffectiveCSM()) << ParentClass
9446 <<
true << FD << 4 <<
false
9464 if (
auto *BaseCtor = SMOR.
getMethod()) {
9469 if (BaseCtor->isDeleted() &&
Diagnose) {
9471 diag::note_deleted_special_member_class_subobject)
9472 << llvm::to_underlying(getEffectiveCSM()) << MD->
getParent()
9473 <<
false <<
Base->getType() << 1
9477 return BaseCtor->isDeleted();
9479 return shouldDeleteForClassSubobject(BaseClass,
Base, 0);
9484bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
9488 if (inUnion() && shouldDeleteForVariantObjCPtrMember(FD, FieldType))
9496 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
9497 << !!ICI << MD->
getParent() << FD << FieldType << 0;
9507 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
9513 AllFieldsAreConst =
false;
9519 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
9523 }
else if (IsAssignment) {
9528 << isMove() << MD->
getParent() << FD << FieldType << 0;
9543 if (!inUnion() && FieldRecord->
isUnion() &&
9545 bool AllVariantFieldsAreConst =
true;
9548 for (
auto *UI : FieldRecord->
fields()) {
9551 if (shouldDeleteForVariantObjCPtrMember(&*UI, UnionFieldType))
9555 AllVariantFieldsAreConst =
false;
9558 if (UnionFieldRecord &&
9559 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
9566 AllVariantFieldsAreConst && !FieldRecord->
field_empty()) {
9569 diag::note_deleted_default_ctor_all_const)
9580 if (shouldDeleteForClassSubobject(FieldRecord, FD,
9591bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
9595 AllFieldsAreConst) {
9596 bool AnyFields =
false;
9598 if ((AnyFields = !F->isUnnamedBitField()))
9604 diag::note_deleted_default_ctor_all_const)
9657 bool DeletesOnlyMatchingCopy =
9662 (!DeletesOnlyMatchingCopy ||
9667 for (
auto *I : RD->
ctors()) {
9668 if (I->isMoveConstructor()) {
9669 UserDeclaredMove = I;
9673 assert(UserDeclaredMove);
9675 (!DeletesOnlyMatchingCopy ||
9680 for (
auto *I : RD->
methods()) {
9681 if (I->isMoveAssignmentOperator()) {
9682 UserDeclaredMove = I;
9686 assert(UserDeclaredMove);
9689 if (UserDeclaredMove) {
9691 diag::note_deleted_copy_user_declared_move)
9709 OperatorDelete,
false)) {
9716 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI,
Diagnose);
9724 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
9725 : SMI.VisitPotentiallyConstructedBases))
9728 if (SMI.shouldDeleteForAllConstMembers())
9752 assert(DFK &&
"not a defaultable function");
9759 DefaultedComparisonAnalyzer(
9761 DFK.
asComparison(), DefaultedComparisonAnalyzer::ExplainDeleted)
9783 *Selected =
nullptr;
9787 llvm_unreachable(
"not a special member");
9805 for (
auto *CI : RD->
ctors()) {
9806 if (!CI->isDefaultConstructor())
9813 *Selected = DefCtor;
9846 }
else if (!Selected) {
9854 goto NeedOverloadResolution;
9864 }
else if (!Selected) {
9869 goto NeedOverloadResolution;
9873 NeedOverloadResolution:
9902 llvm_unreachable(
"unknown special method kind");
9906 for (
auto *CI : RD->
ctors())
9907 if (!CI->isImplicit())
9914 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
9945 ConstRHS, TAH,
Diagnose ? &Selected :
nullptr))
9953 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
9956 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
9957 }
else if (!Selected)
9958 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
9966 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
9972 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
9990 for (
const auto *FI : RD->
fields()) {
9991 if (FI->isInvalidDecl() || FI->isUnnamedBitField())
9997 if (FI->isAnonymousStructOrUnion()) {
10009 FI->hasInClassInitializer()) {
10011 S.
Diag(FI->getLocation(), diag::note_nontrivial_default_member_init)
10022 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
10027 bool ConstRHS = ConstArg && !FI->isMutable();
10050 "not special enough");
10054 bool ConstArg =
false;
10082 ClangABICompat14)) {
10112 llvm_unreachable(
"not a special member");
10118 diag::note_nontrivial_default_arg)
10137 for (
const auto &BI : RD->
bases())
10179 Diag(BS.
getBeginLoc(), diag::note_nontrivial_has_virtual) << RD << 1;
10184 for (
const auto *MI : RD->
methods()) {
10185 if (MI->isVirtual()) {
10187 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
10192 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
10200struct FindHiddenVirtualMethod {
10208 static bool CheckMostOverridenMethods(
10210 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
10214 if (CheckMostOverridenMethods(O, Methods))
10230 bool foundSameNameMethod =
false;
10237 foundSameNameMethod =
true;
10254 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
10255 overloadedMethods.push_back(MD);
10259 if (foundSameNameMethod)
10260 OverloadedMethods.append(overloadedMethods.begin(),
10261 overloadedMethods.end());
10262 return foundSameNameMethod;
10269 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
10285 FindHiddenVirtualMethod FHVM;
10296 ND = shad->getTargetDecl();
10302 OverloadedMethods = FHVM.OverloadedMethods;
10307 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
10310 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
10325 if (!OverloadedMethods.empty()) {
10327 << MD << (OverloadedMethods.size() > 1);
10334 auto PrintDiagAndRemoveAttr = [&](
unsigned N) {
10337 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
10338 diag::ext_cannot_use_trivial_abi) << &RD;
10339 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
10340 diag::note_cannot_use_trivial_abi_reason) << &RD << N;
10346 auto HasNonDeletedCopyOrMoveConstructor = [&]() {
10358 if (CD->isCopyOrMoveConstructor() && !CD->isDeleted())
10363 if (!HasNonDeletedCopyOrMoveConstructor()) {
10364 PrintDiagAndRemoveAttr(0);
10370 PrintDiagAndRemoveAttr(1);
10374 for (
const auto &B : RD.
bases()) {
10377 if (!B.getType()->isDependentType() &&
10378 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) {
10379 PrintDiagAndRemoveAttr(2);
10383 if (B.isVirtual()) {
10384 PrintDiagAndRemoveAttr(3);
10389 for (
const auto *FD : RD.
fields()) {
10394 PrintDiagAndRemoveAttr(4);
10399 if (!RT->isDependentType() &&
10400 !cast<CXXRecordDecl>(RT->getDecl())->canPassInRegisters()) {
10401 PrintDiagAndRemoveAttr(5);
10410 diag::err_incomplete_type_vtable_pointer_auth))
10418 assert(PrimaryBase);
10421 if (!BasePtr.getType()->getAsCXXRecordDecl()->isDynamicClass())
10423 Base = BasePtr.getType()->getAsCXXRecordDecl();
10426 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
10428 Diag(RD.
getAttr<VTablePointerAuthenticationAttr>()->getLocation(),
10429 diag::err_non_top_level_vtable_pointer_auth)
10431 PrimaryBase =
Base;
10435 Diag(RD.
getAttr<VTablePointerAuthenticationAttr>()->getLocation(),
10436 diag::err_non_polymorphic_vtable_pointer_auth)
10449 if (AL.getKind() != ParsedAttr::AT_Visibility)
10452 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored) << AL;
10460 LBrac, RBrac, AttrList);
10482 Spaceships.clear();
10488 Spaceships.push_back(FD);
10497 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
10498 if (FD->isExplicitlyDefaulted())
10499 Spaceships.push_back(FD);
10594 DefaultedSpaceships);
10595 for (
auto *FD : DefaultedSpaceships)
10602 llvm::function_ref<
Scope *()> EnterScope) {
10613 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
10614 ParameterLists.push_back(DD->getTemplateParameterList(i));
10618 ParameterLists.push_back(FTD->getTemplateParameters());
10619 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(
D)) {
10623 ParameterLists.push_back(VTD->getTemplateParameters());
10624 else if (
auto *PSD = dyn_cast<VarTemplatePartialSpecializationDecl>(
D))
10625 ParameterLists.push_back(PSD->getTemplateParameters());
10627 }
else if (
TagDecl *TD = dyn_cast<TagDecl>(
D)) {
10628 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
10629 ParameterLists.push_back(TD->getTemplateParameterList(i));
10633 ParameterLists.push_back(CTD->getTemplateParameters());
10634 else if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(
D))
10635 ParameterLists.push_back(PSD->getTemplateParameters());
10640 unsigned Count = 0;
10641 Scope *InnermostTemplateScope =
nullptr;
10645 if (Params->size() == 0)
10648 InnermostTemplateScope = EnterScope();
10650 if (Param->getDeclName()) {
10651 InnermostTemplateScope->
AddDecl(Param);
10659 if (InnermostTemplateScope) {
10660 assert(LookupDC &&
"no enclosing DeclContext for template lookup");
10668 if (!RecordD)
return;
10675 if (!RecordD)
return;
10732 bool DiagOccured =
false;
10734 [DiagID, &S, &DiagOccured](
DeclSpec::TQ, StringRef QualName,
10741 DiagOccured =
true;
10744 D.setInvalidType();
10750 bool isVirtual =
D.getDeclSpec().isVirtualSpecified();
10758 if (!
D.isInvalidType())
10759 Diag(
D.getIdentifierLoc(), diag::err_constructor_cannot_be)
10760 <<
"virtual" <<
SourceRange(
D.getDeclSpec().getVirtualSpecLoc())
10762 D.setInvalidType();
10765 if (!
D.isInvalidType())
10766 Diag(
D.getIdentifierLoc(), diag::err_constructor_cannot_be)
10767 <<
"static" <<
SourceRange(
D.getDeclSpec().getStorageClassSpecLoc())
10769 D.setInvalidType();
10773 if (
unsigned TypeQuals =
D.getDeclSpec().getTypeQualifiers()) {
10776 D.getDeclSpec().getConstSpecLoc(),
D.getDeclSpec().getVolatileSpecLoc(),
10777 D.getDeclSpec().getRestrictSpecLoc(),
10778 D.getDeclSpec().getAtomicSpecLoc());
10779 D.setInvalidType();
10791 D.setInvalidType();
10810 = dyn_cast<CXXRecordDecl>(Constructor->getDeclContext());
10812 return Constructor->setInvalidDecl();
10819 if (!Constructor->isInvalidDecl() &&
10820 Constructor->hasOneParamOrDefaultArgs() &&
10821 Constructor->getTemplateSpecializationKind() !=
10823 QualType ParamType = Constructor->getParamDecl(0)->getType();
10826 SourceLocation ParamLoc = Constructor->getParamDecl(0)->getLocation();
10827 const char *ConstRef
10828 = Constructor->getParamDecl(0)->getIdentifier() ?
"const &"
10830 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
10835 Constructor->setInvalidDecl();
10854 Expr *ThisArg =
nullptr;
10859 if (OperatorDelete->isDestroyingOperatorDelete()) {
10860 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
10867 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
10868 assert(!This.isInvalid() &&
"couldn't form 'this' expr in dtor?");
10870 if (This.isInvalid()) {
10873 Diag(
Loc, diag::note_implicit_delete_this_in_destructor_here);
10876 ThisArg = This.get();
10882 Destructor->setOperatorDelete(OperatorDelete, ThisArg);
10898 Diag(
D.getIdentifierLoc(), diag::ext_destructor_typedef_name)
10899 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
10902 if (TST->isTypeAlias())
10903 Diag(
D.getIdentifierLoc(), diag::ext_destructor_typedef_name)
10904 << DeclaratorType << 1;
10915 if (!
D.isInvalidType())
10916 Diag(
D.getIdentifierLoc(), diag::err_destructor_cannot_be)
10917 <<
"static" <<
SourceRange(
D.getDeclSpec().getStorageClassSpecLoc())
10923 if (!
D.isInvalidType()) {
10932 if (
D.getDeclSpec().hasTypeSpecifier())
10933 Diag(
D.getIdentifierLoc(), diag::err_destructor_return_type)
10936 else if (
unsigned TypeQuals =
D.getDeclSpec().getTypeQualifiers()) {
10939 D.getDeclSpec().getConstSpecLoc(),
10940 D.getDeclSpec().getVolatileSpecLoc(),
10941 D.getDeclSpec().getRestrictSpecLoc(),
10942 D.getDeclSpec().getAtomicSpecLoc());
10943 D.setInvalidType();
10956 D.setInvalidType();
10961 Diag(
D.getIdentifierLoc(), diag::err_destructor_with_params);
10965 D.setInvalidType();
10970 Diag(
D.getIdentifierLoc(), diag::err_destructor_variadic);
10971 D.setInvalidType();
10978 if (!
D.isInvalidType())
10998 if (After.isInvalid())
11002 R.
setEnd(After.getEnd());
11012 if (!
D.isInvalidType())
11013 Diag(
D.getIdentifierLoc(), diag::err_conv_function_not_member)
11014 <<
SourceRange(
D.getDeclSpec().getStorageClassSpecLoc())
11016 D.setInvalidType();
11034 Diag(
D.getIdentifierLoc(), diag::err_conv_function_return_type)
11037 D.setInvalidType();
11044 Diag(
D.getIdentifierLoc(), diag::err_conv_function_with_complex_decl)
11046 D.setInvalidType();
11051 unsigned NumParam = Proto->getNumParams();
11055 if (NumParam == 1) {
11057 if (
const auto *
First =
11058 dyn_cast_if_present<ParmVarDecl>(FTI.
Params[0].
Param);
11059 First &&
First->isExplicitObjectParameter())
11063 if (NumParam != 0) {
11064 Diag(
D.getIdentifierLoc(), diag::err_conv_function_with_params);
11067 D.setInvalidType();
11068 }
else if (Proto->isVariadic()) {
11069 Diag(
D.getIdentifierLoc(), diag::err_conv_function_variadic);
11070 D.setInvalidType();
11075 if (Proto->getReturnType() != ConvType) {
11076 bool NeedsTypedef =
false;
11080 bool PastFunctionChunk =
false;
11081 for (
auto &Chunk :
D.type_objects()) {
11082 switch (Chunk.Kind) {
11084 if (!PastFunctionChunk) {
11085 if (Chunk.Fun.HasTrailingReturnType) {
11090 PastFunctionChunk =
true;
11095 NeedsTypedef =
true;
11115 After.isValid() ? After.getBegin() :
11116 D.getIdentifierLoc();
11117 auto &&DB =
Diag(
Loc, diag::err_conv_function_with_complex_decl);
11118 DB << Before << After;
11120 if (!NeedsTypedef) {
11124 if (After.isInvalid() && ConvTSI) {
11132 }
else if (!Proto->getReturnType()->isDependentType()) {
11133 DB << 1 << Proto->getReturnType();
11135 DB << 2 << Proto->getReturnType();
11146 ConvType = Proto->getReturnType();
11153 Diag(
D.getIdentifierLoc(), diag::err_conv_function_to_array);
11155 D.setInvalidType();
11157 Diag(
D.getIdentifierLoc(), diag::err_conv_function_to_function);
11159 D.setInvalidType();
11165 if (
D.isInvalidType())
11167 Proto->getExtProtoInfo());
11173 ? diag::warn_cxx98_compat_explicit_conversion_functions
11174 : diag::ext_explicit_conversion_functions)
11179 assert(Conversion &&
"Expected to receive a conversion function declaration");
11202 if (ConvType == ClassType)
11207 << ClassType << ConvType;
11210 << ClassType << ConvType;
11225 return ConversionTemplate;
11243 if (!
D.isFunctionDeclarator())
11250 for (
unsigned Idx = 0; Idx < FTI.
NumParams; Idx++) {
11251 const auto &ParamInfo = FTI.
Params[Idx];
11252 if (!ParamInfo.Param)
11254 ParmVarDecl *Param = cast<ParmVarDecl>(ParamInfo.Param);
11258 ExplicitObjectParam = Param;
11262 diag::err_explicit_object_parameter_must_be_first)
11266 if (!ExplicitObjectParam)
11271 diag::err_explicit_object_default_arg)
11277 D.isStaticMember())) {
11279 diag::err_explicit_object_parameter_nonmember)
11281 D.setInvalidType();
11284 if (
D.getDeclSpec().isVirtualSpecified()) {
11286 diag::err_explicit_object_parameter_nonmember)
11288 D.setInvalidType();
11310 if (
D.getDeclSpec().isFriendSpecified() &&
11311 !isa_and_present<CXXRecordDecl>(
11314 diag::err_explicit_object_parameter_nonmember)
11316 D.setInvalidType();
11321 diag::err_explicit_object_parameter_mutable)
11329 assert(
D.isInvalidType() &&
"Explicit object parameter in non-member "
11330 "should have been diagnosed already");
11338 diag::err_explicit_object_parameter_constructor)
11341 D.setInvalidType();
11348struct BadSpecifierDiagnoser {
11351 ~BadSpecifierDiagnoser() {
11359 return check(SpecLoc,
11365 if (!Specifiers.empty()) Specifiers +=
" ";
11366 Specifiers += Spec;
11371 std::string Specifiers;
11377 TemplateName GuidedTemplate =
D.getName().TemplateName.get().get();
11379 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
11386 Diag(
D.getIdentifierLoc(), diag::err_deduction_guide_wrong_scope)
11387 << GuidedTemplateDecl;
11391 auto &DS =
D.getMutableDeclSpec();
11393 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
11394 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
11395 DS.isNoreturnSpecified() || DS.hasConstexprSpecifier()) {
11396 BadSpecifierDiagnoser Diagnoser(
11397 *
this,
D.getIdentifierLoc(),
11398 diag::err_deduction_guide_invalid_specifier);
11400 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
11401 DS.ClearStorageClassSpecs();
11405 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
11406 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
11407 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
11408 DS.ClearConstexprSpec();
11410 Diagnoser.check(DS.getConstSpecLoc(),
"const");
11411 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
11412 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
11413 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
11414 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
11415 DS.ClearTypeQualifiers();
11417 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
11418 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
11419 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
11420 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
11421 DS.ClearTypeSpecType();
11424 if (
D.isInvalidType())
11428 bool FoundFunction =
false;
11434 diag::err_deduction_guide_with_complex_decl)
11438 if (!Chunk.Fun.hasTrailingReturnType())
11440 diag::err_deduction_guide_no_trailing_return_type);
11445 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
11448 assert(TSI &&
"deduction guide has valid type but invalid return type?");
11449 bool AcceptableReturnType =
false;
11450 bool MightInstantiateToSpecialization =
false;
11453 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
11454 bool TemplateMatches =
11459 assert(
Qualifiers &&
"expected QualifiedTemplate");
11460 bool SimplyWritten = !
Qualifiers->hasTemplateKeyword() &&
11462 if (SimplyWritten && TemplateMatches)
11463 AcceptableReturnType =
true;
11468 MightInstantiateToSpecialization = !(TD && isa<ClassTemplateDecl>(TD) &&
11472 MightInstantiateToSpecialization =
true;
11475 if (!AcceptableReturnType)
11477 diag::err_deduction_guide_bad_trailing_return_type)
11478 << GuidedTemplate << TSI->
getType()
11479 << MightInstantiateToSpecialization
11484 FoundFunction =
true;
11487 if (
D.isFunctionDefinition())
11489 Diag(
D.getIdentifierLoc(), diag::err_deduction_guide_defines_function);
11503 assert(*IsInline != PrevNS->
isInline());
11513 S.
Diag(
Loc, diag::warn_inline_namespace_reopened_noninline)
11516 S.
Diag(
Loc, diag::err_inline_namespace_mismatch);
11534 bool IsInline = InlineLoc.
isValid();
11535 bool IsInvalid =
false;
11536 bool IsStd =
false;
11537 bool AddToKnown =
false;
11548 auto DiagnoseInlineStdNS = [&]() {
11549 assert(IsInline && II->
isStr(
"std") &&
11551 "Precondition of DiagnoseInlineStdNS not met");
11552 Diag(InlineLoc, diag::err_inline_namespace_std)
11568 RedeclarationKind::ForExternalRedeclaration);
11572 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
11576 if (IsInline && II->
isStr(
"std") &&
11578 DiagnoseInlineStdNS();
11579 else if (IsInline != PrevNS->
isInline())
11581 &IsInline, PrevNS);
11582 }
else if (PrevDecl) {
11584 Diag(
Loc, diag::err_redefinition_different_kind)
11589 }
else if (II->
isStr(
"std") &&
11592 DiagnoseInlineStdNS();
11597 AddToKnown = !IsInline;
11600 AddToKnown = !IsInline;
11614 if (PrevNS && IsInline != PrevNS->
isInline())
11616 &IsInline, PrevNS);
11629 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
11635 KnownNamespaces[Namespc] =
false;
11643 TU->setAnonymousNamespace(Namespc);
11645 cast<NamespaceDecl>(
Parent)->setAnonymousNamespace(Namespc);
11694 return AD->getNamespace();
11695 return dyn_cast_or_null<NamespaceDecl>(
D);
11699 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
11700 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
11703 if (Namespc->
hasAttr<VisibilityAttr>())
11706 if (DeferredExportedNamespaces.erase(Namespc))
11711 return cast_or_null<CXXRecordDecl>(
11720 return cast_or_null<NamespaceDecl>(
11725enum UnsupportedSTLSelect {
11732struct InvalidSTLDiagnoser {
11737 QualType operator()(UnsupportedSTLSelect Sel = USS_Other, StringRef Name =
"",
11738 const VarDecl *VD =
nullptr) {
11740 auto D = S.
Diag(
Loc, diag::err_std_compare_type_not_supported)
11741 << TyForDiags << ((
int)Sel);
11742 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
11743 assert(!Name.empty());
11747 if (Sel == USS_InvalidMember) {
11760 "Looking for comparison category type outside of C++.");
11774 if (Info && FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)]) {
11785 std::string NameForDiags =
"std::";
11787 Diag(
Loc, diag::err_implied_comparison_category_type_not_found)
11788 << NameForDiags << (
int)Usage;
11792 assert(Info->
Kind == Kind);
11803 InvalidSTLDiagnoser UnsupportedSTLError{*
this,
Loc, TyForDiags(Info)};
11806 return UnsupportedSTLError(USS_NonTrivial);
11811 if (
Base->isEmpty())
11814 return UnsupportedSTLError();
11822 if (std::distance(FIt, FEnd) != 1 ||
11823 !FIt->getType()->isIntegralOrEnumerationType()) {
11824 return UnsupportedSTLError();
11834 return UnsupportedSTLError(USS_MissingMember, MemName);
11837 assert(VD &&
"should not be null!");
11844 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
11850 return UnsupportedSTLError();
11857 FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)] =
true;
11881 "Looking for std::initializer_list outside of C++.");
11895 dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl());
11904 TST = ICN->getInjectedTST();
11908 Template = dyn_cast_or_null<ClassTemplateDecl>(
11929 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
11941 *Element = Arguments[0].getAsType();
11948 S.
Diag(
Loc, diag::err_implied_std_initializer_list_not_found);
11955 S.
Diag(
Loc, diag::err_implied_std_initializer_list_not_found);
11960 Result.suppressDiagnostics();
11963 S.
Diag(
Found->getLocation(), diag::err_malformed_std_initializer_list);
11971 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
11972 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
12016 case Decl::TranslationUnit:
12018 case Decl::LinkageSpec:
12030 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
12032 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
12036 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
12037 return std::make_unique<NamespaceValidatorCCC>(*
this);
12045 auto *ND = cast<NamespaceDecl>(Corrected.
getFoundDecl());
12046 Module *M = ND->getOwningModule();
12047 assert(M &&
"hidden namespace definition not in a module?");
12051 diag::err_module_unimported_use_header)
12056 diag::err_module_unimported_use)
12066 NamespaceValidatorCCC CCC{};
12076 if (isa_and_nonnull<NamespaceDecl>(Corrected.getFoundDecl()) &&
12077 Corrected.requiresImport()) {
12080 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
12081 bool DroppedSpecifier =
12082 Corrected.WillReplaceSpecifier() && Ident->
getName() == CorrectedStr;
12084 S.
PDiag(diag::err_using_directive_member_suggest)
12085 << Ident << DC << DroppedSpecifier << SS.
getRange(),
12086 S.
PDiag(diag::note_namespace_defined_here));
12089 S.
PDiag(diag::err_using_directive_suggest) << Ident,
12090 S.
PDiag(diag::note_namespace_defined_here));
12092 R.
addDecl(Corrected.getFoundDecl());
12103 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
12104 assert(NamespcName &&
"Invalid NamespcName.");
12105 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
12108 S = S->getDeclParent();
12126 NamespcName->
isStr(
"std")) {
12127 Diag(IdentLoc, diag::ext_using_undefined_std);
12138 assert(
NS &&
"expected namespace decl");
12157 CommonAncestor = CommonAncestor->
getParent();
12161 IdentLoc, Named, CommonAncestor);
12165 Diag(IdentLoc, diag::warn_using_directive_in_header);
12170 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
12203 Diag(Name.getBeginLoc(), diag::err_using_requires_qualname);
12207 switch (Name.getKind()) {
12218 Diag(Name.getBeginLoc(),
12220 ? diag::warn_cxx98_compat_using_decl_constructor
12221 : diag::err_using_decl_constructor)
12229 Diag(Name.getBeginLoc(), diag::err_using_decl_destructor) << SS.
getRange();
12233 Diag(Name.getBeginLoc(), diag::err_using_decl_template_id)
12234 <<
SourceRange(Name.TemplateId->LAngleLoc, Name.TemplateId->RAngleLoc);
12238 llvm_unreachable(
"cannot parse qualified deduction guide name");
12249 ? diag::err_access_decl
12250 : diag::warn_access_decl_deprecated)
12261 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
12269 SS, TargetNameInfo, EllipsisLoc, AttrList,
12283 assert(SS && !SS->
isInvalid() &&
"ScopeSpec is invalid");
12289 ? diag::err_using_enum_is_dependent
12290 : diag::err_unknown_typename)
12296 Diag(IdentLoc, diag::err_using_enum_is_dependent);
12302 Diag(IdentLoc, diag::err_using_enum_not_enum) << EnumTy;
12306 if (
auto *Def =
Enum->getDefinition())
12309 if (TSI ==
nullptr)
12332 TD2->getUnderlyingType());
12336 if (isa<UnresolvedUsingIfExistsDecl>(D1) &&
12337 isa<UnresolvedUsingIfExistsDecl>(D2))
12366 if (
auto *Using = dyn_cast<UsingDecl>(BUD)) {
12370 if (isa<EnumDecl>(OrigDC))
12378 Diag(Using->getLocation(),
12379 diag::err_using_decl_nested_name_specifier_is_current_class)
12380 << Using->getQualifierLoc().getSourceRange();
12382 Using->setInvalidDecl();
12386 Diag(Using->getQualifierLoc().getBeginLoc(),
12387 diag::err_using_decl_nested_name_specifier_is_not_base_class)
12388 << Using->getQualifier() << cast<CXXRecordDecl>(
CurContext)
12389 << Using->getQualifierLoc().getSourceRange();
12391 Using->setInvalidDecl();
12396 if (
Previous.empty())
return false;
12399 if (isa<UsingShadowDecl>(
Target))
12400 Target = cast<UsingShadowDecl>(
Target)->getTargetDecl();
12407 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
12408 bool FoundEquivalentDecl =
false;
12415 if (isa<UsingDecl>(
D) || isa<UsingPackDecl>(
D) || isa<UsingEnumDecl>(
D))
12418 if (
auto *RD = dyn_cast<CXXRecordDecl>(
D)) {
12423 !isa<IndirectFieldDecl>(
Target) &&
12424 !isa<UnresolvedUsingValueDecl>(
Target) &&
12433 PrevShadow = Shadow;
12434 FoundEquivalentDecl =
true;
12438 FoundEquivalentDecl =
true;
12442 (isa<TagDecl>(
D) ? Tag : NonTag) =
D;
12445 if (FoundEquivalentDecl)
12450 if (isa<UnresolvedUsingIfExistsDecl>(
Target) !=
12451 (isa_and_nonnull<UnresolvedUsingIfExistsDecl>(NonTag))) {
12452 if (!NonTag && !Tag)
12455 Diag(
Target->getLocation(), diag::note_using_decl_target);
12456 Diag((NonTag ? NonTag : Tag)->getLocation(),
12457 diag::note_using_decl_conflict);
12486 Diag(
Target->getLocation(), diag::note_using_decl_target);
12494 if (isa<TagDecl>(
Target)) {
12496 if (!Tag)
return false;
12499 Diag(
Target->getLocation(), diag::note_using_decl_target);
12500 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
12506 if (!NonTag)
return false;
12509 Diag(
Target->getLocation(), diag::note_using_decl_target);
12519 for (
auto &B : Derived->
bases())
12520 if (B.getType()->getAsCXXRecordDecl() ==
Base)
12521 return B.isVirtual();
12522 llvm_unreachable(
"not a direct base class");
12530 if (isa<UsingShadowDecl>(
Target)) {
12531 Target = cast<UsingShadowDecl>(
Target)->getTargetDecl();
12532 assert(!isa<UsingShadowDecl>(
Target) &&
"nested shadow declaration");
12536 if (
auto *TargetTD = dyn_cast<TemplateDecl>(
Target))
12537 NonTemplateTarget = TargetTD->getTemplatedDecl();
12540 if (NonTemplateTarget && isa<CXXConstructorDecl>(NonTemplateTarget)) {
12541 UsingDecl *Using = cast<UsingDecl>(BUD);
12542 bool IsVirtualBase =
12544 Using->getQualifier()->getAsRecordDecl());
12571 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
12578 S->RemoveDecl(Shadow);
12592 bool &AnyDependentBases) {
12597 CanQualType BaseType =
Base.getType()->getCanonicalTypeUnqualified();
12598 if (CanonicalDesiredBase == BaseType)
12600 if (BaseType->isDependentType())
12601 AnyDependentBases =
true;
12609 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
12611 : HasTypenameKeyword(HasTypenameKeyword),
12612 IsInstantiation(IsInstantiation), OldNNS(NNS),
12613 RequireMemberOf(RequireMemberOf) {}
12615 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
12619 if (!ND || isa<NamespaceDecl>(ND))
12629 if (RequireMemberOf) {
12630 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
12631 if (FoundRecord && FoundRecord->isInjectedClassName()) {
12652 bool AnyDependentBases =
false;
12655 AnyDependentBases) &&
12656 !AnyDependentBases)
12660 if (!RD || RequireMemberOf->isProvablyNotDerivedFrom(RD))
12666 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
12667 if (FoundRecord && FoundRecord->isInjectedClassName())
12671 if (isa<TypeDecl>(ND))
12672 return HasTypenameKeyword || !IsInstantiation;
12674 return !HasTypenameKeyword;
12677 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
12678 return std::make_unique<UsingValidatorCCC>(*
this);
12682 bool HasTypenameKeyword;
12683 bool IsInstantiation;
12712 bool IsUsingIfExists) {
12713 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
12715 assert(IdentLoc.
isValid() &&
"Invalid TargetName location.");
12724 if (
auto *RD = dyn_cast<CXXRecordDecl>(
CurContext))
12730 RedeclarationKind::ForVisibleRedeclaration);
12737 assert(IsInstantiation &&
"no scope in non-instantiation");
12765 Diag(UsingLoc, diag::err_using_if_exists_on_ctor);
12771 if (!LookupContext || EllipsisLoc.
isValid()) {
12775 SS, NameInfo, IdentLoc))
12778 if (HasTypenameKeyword) {
12781 UsingLoc, TypenameLoc,
12783 IdentLoc, NameInfo.
getName(),
12787 QualifierLoc, NameInfo, EllipsisLoc);
12795 auto Build = [&](
bool Invalid) {
12798 UsingName, HasTypenameKeyword);
12805 auto BuildInvalid = [&]{
return Build(
true); };
12806 auto BuildValid = [&]{
return Build(
false); };
12809 return BuildInvalid();
12818 if (!IsInstantiation)
12835 if (R.
empty() && IsUsingIfExists)
12852 isa<TranslationUnitDecl>(LookupContext) &&
12855 UsingValidatorCCC CCC(HasTypenameKeyword, IsInstantiation, SS.
getScopeRep(),
12863 << NameInfo.
getName() << LookupContext << 0
12868 NamedDecl *ND = Corrected.getCorrectionDecl();
12870 return BuildInvalid();
12873 auto *RD = dyn_cast<CXXRecordDecl>(ND);
12876 RD = cast<CXXRecordDecl>(RD->
getParent());
12879 if (Corrected.WillReplaceSpecifier()) {
12881 Builder.MakeTrivial(
Context, Corrected.getCorrectionSpecifier(),
12883 QualifierLoc = Builder.getWithLocInContext(
Context);
12888 auto *CurClass = cast<CXXRecordDecl>(
CurContext);
12902 Diag(IdentLoc, diag::err_no_member)
12904 return BuildInvalid();
12909 return BuildInvalid();
12911 if (HasTypenameKeyword) {
12915 Diag(IdentLoc, diag::err_using_typename_non_type);
12917 Diag((*I)->getUnderlyingDecl()->getLocation(),
12918 diag::note_using_decl_target);
12919 return BuildInvalid();
12926 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
12928 return BuildInvalid();
12935 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
12940 return BuildInvalid();
12976 RedeclarationKind::ForVisibleRedeclaration);
12982 if (UED->getEnumDecl() == ED) {
12983 Diag(UsingLoc, diag::err_using_enum_decl_redeclaration)
13009 RedeclarationKind::ForVisibleRedeclaration);
13022 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
13023 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
13024 isa<UsingPackDecl>(InstantiatedFrom));
13028 UPD->setAccess(InstantiatedFrom->
getAccess());
13034 assert(!UD->
hasTypename() &&
"expecting a constructor name");
13037 assert(SourceType &&
13038 "Using decl naming constructor doesn't have type in scope spec.");
13042 bool AnyDependentBases =
false;
13044 AnyDependentBases);
13045 if (!
Base && !AnyDependentBases) {
13047 diag::err_using_decl_constructor_not_in_direct_base)
13049 <<
QualType(SourceType, 0) << TargetClass;
13055 Base->setInheritConstructors();
13061 bool HasTypenameKeyword,
13080 if (Qual->
isDependent() && !HasTypenameKeyword) {
13081 for (
auto *
D : Prev) {
13082 if (!isa<TypeDecl>(
D) && !isa<UsingDecl>(
D) && !isa<UsingPackDecl>(
D)) {
13083 bool OldCouldBeEnumerator =
13084 isa<UnresolvedUsingValueDecl>(
D) || isa<EnumConstantDecl>(
D);
13086 OldCouldBeEnumerator ? diag::err_redefinition
13087 : diag::err_redefinition_different_kind)
13088 << Prev.getLookupName();
13104 if (
UsingDecl *UD = dyn_cast<UsingDecl>(
D)) {
13105 DTypename = UD->hasTypename();
13106 DQual = UD->getQualifier();
13108 = dyn_cast<UnresolvedUsingValueDecl>(
D)) {
13110 DQual = UD->getQualifier();
13112 = dyn_cast<UnresolvedUsingTypenameDecl>(
D)) {
13114 DQual = UD->getQualifier();
13119 if (HasTypenameKeyword != DTypename)
continue;
13127 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
13141 assert(
bool(NamedContext) == (R || UD) && !(R && UD) &&
13142 "resolvable context must have exactly one set of decls");
13146 bool Cxx20Enumerator =
false;
13147 if (NamedContext) {
13156 if (
auto *ED = dyn_cast<EnumDecl>(NamedContext)) {
13160 if (EC && R && ED->isScoped())
13163 ? diag::warn_cxx17_compat_using_decl_scoped_enumerator
13164 : diag::ext_using_decl_scoped_enumerator)
13168 NamedContext = ED->getDeclContext();
13188 ? diag::warn_cxx17_compat_using_decl_class_member_enumerator
13189 : diag::err_using_decl_can_not_refer_to_class_member)
13192 if (Cxx20Enumerator)
13195 auto *RD = NamedContext
13207 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
13215 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
13231 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
13246 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
13256 if (!NamedContext) {
13272 ? diag::warn_cxx17_compat_using_decl_non_member_enumerator
13273 : diag::err_using_decl_nested_name_specifier_is_not_class)
13276 if (Cxx20Enumerator)
13293 cast<CXXRecordDecl>(NamedContext))) {
13295 if (Cxx20Enumerator) {
13296 Diag(NameLoc, diag::warn_cxx17_compat_using_decl_non_member_enumerator)
13303 diag::err_using_decl_nested_name_specifier_is_current_class)
13308 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
13310 diag::err_using_decl_nested_name_specifier_is_not_base_class)
13335 Bases.insert(
Base);
13340 if (!cast<CXXRecordDecl>(
CurContext)->forallBases(Collect))
13346 return !Bases.count(
Base);
13351 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
13352 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
13356 diag::err_using_decl_nested_name_specifier_is_not_base_class)
13370 S = S->getDeclParent();
13372 if (
Type.isInvalid())
13391 TemplateParamLists.size()
13393 : RedeclarationKind::ForVisibleRedeclaration);
13398 Previous.getFoundDecl()->isTemplateParameter()) {
13404 "name in alias declaration must be an identifier");
13406 Name.StartLocation,
13407 Name.Identifier, TInfo);
13421 bool Redeclaration =
false;
13424 if (TemplateParamLists.size()) {
13428 if (TemplateParamLists.size() != 1) {
13429 Diag(UsingLoc, diag::err_alias_template_extra_headers)
13430 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
13431 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
13444 Redeclaration =
true;
13448 Diag(UsingLoc, diag::err_redefinition_different_kind)
13449 << Name.Identifier;
13463 OldTemplateParams =
13491 Name.Identifier, TemplateParams,
13499 else if (OldDecl) {
13506 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
13534 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
13543 RedeclarationKind::ForVisibleRedeclaration);
13566 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
13568 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
13569 << AD->getNamespace();
13574 ? diag::err_redefinition
13575 : diag::err_redefinition_different_kind;
13576 Diag(AliasLoc, DiagID) << Alias;
13597struct SpecialMemberExceptionSpecInfo
13598 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
13606 : SpecialMemberVisitor(S, MD, CSM, ICI),
Loc(
Loc), ExceptSpec(S) {}
13611 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
13614 void visitSubobjectCall(Subobject Subobj,
13624 auto *BaseClass = cast<CXXRecordDecl>(RT->getDecl());
13626 if (
auto *BaseCtor = SMOR.
getMethod()) {
13627 visitSubobjectCall(
Base, BaseCtor);
13631 visitClassSubobject(BaseClass,
Base, 0);
13635bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
13647 ExceptSpec.CalledExpr(
E);
13650 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
13660 bool IsMutable =
Field &&
Field->isMutable();
13661 visitSubobjectCall(Subobj, lookupIn(
Class, Quals, IsMutable));
13664void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
13669 ExceptSpec.CalledDecl(getSubobjectLoc(Subobj), MD);
13698 ComputingExceptionSpec CES(S, MD,
Loc);
13705 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
13707 return Info.ExceptSpec;
13714 diag::err_exception_spec_incomplete_type))
13715 return Info.ExceptSpec;
13732 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
13733 : Info.VisitAllBases);
13735 return Info.ExceptSpec;
13740struct DeclaringSpecialMember {
13744 bool WasAlreadyBeingDeclared;
13747 : S(S),
D(RD, CSM), SavedContext(S, RD) {
13749 if (WasAlreadyBeingDeclared)
13770 ~DeclaringSpecialMember() {
13771 if (!WasAlreadyBeingDeclared) {
13778 bool isAlreadyBeingDeclared()
const {
13779 return WasAlreadyBeingDeclared;
13789 RedeclarationKind::ForExternalRedeclaration);
13800void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
13818 cast<CXXRecordDecl>(SpecialMem->
getParent())->isLambda()) {
13834 "Should not build implicit default constructor!");
13836 DeclaringSpecialMember DSM(*
this, ClassDecl,
13838 if (DSM.isAlreadyBeingDeclared())
13861 setupImplicitSpecialMemberType(DefaultCon,
Context.
VoidTy, std::nullopt);
13885 ClassDecl->
addDecl(DefaultCon);
13892 assert((Constructor->isDefaulted() && Constructor->isDefaultConstructor() &&
13893 !Constructor->doesThisDeclarationHaveABody() &&
13894 !Constructor->isDeleted()) &&
13895 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
13896 if (Constructor->willHaveBody() || Constructor->isInvalidDecl())
13900 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
13914 Scope.addContextNote(CurrentLocation);
13917 Constructor->setInvalidDecl();
13922 ? Constructor->getEndLoc()
13923 : Constructor->getLocation();
13925 Constructor->markUsed(
Context);
13928 L->CompletedImplicitDefinition(Constructor);
13931 DiagnoseUninitializedFields(*
this, Constructor);
13957 ->getInheritedConstructor()
13960 return cast<CXXConstructorDecl>(Ctor);
13975 false, BaseCtor, &ICI);
13992 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
13998 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
14002 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
14009 ParamDecls.push_back(PD);
14014 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
14017 Derived->
addDecl(DerivedCtor);
14023 return DerivedCtor;
14037 assert(Constructor->getInheritedConstructor() &&
14038 !Constructor->doesThisDeclarationHaveABody() &&
14039 !Constructor->isDeleted());
14040 if (Constructor->willHaveBody() || Constructor->isInvalidDecl())
14054 Scope.addContextNote(CurrentLocation);
14057 Constructor->getInheritedConstructor().getShadowDecl();
14059 Constructor->getInheritedConstructor().getConstructor();
14073 for (
bool VBase : {
false,
true}) {
14075 if (B.isVirtual() != VBase)
14078 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
14083 if (!BaseCtor.first)
14088 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
14092 Context, TInfo, VBase, InitLoc,
Init.get(), InitLoc,
14101 Constructor->setInvalidDecl();
14106 Constructor->markUsed(
Context);
14109 L->CompletedImplicitDefinition(Constructor);
14112 DiagnoseUninitializedFields(*
this, Constructor);
14122 DeclaringSpecialMember DSM(*
this, ClassDecl,
14124 if (DSM.isAlreadyBeingDeclared())
14185 !
Destructor->doesThisDeclarationHaveABody() &&
14187 "DefineImplicitDestructor - call it for implicit default dtor");
14192 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
14203 Scope.addContextNote(CurrentLocation);
14231 "implicit complete dtors unneeded outside MS ABI");
14233 "complete dtor only exists for classes with vbases");
14238 Scope.addContextNote(CurrentLocation);
14246 if (
Record->isInvalidDecl()) {
14267 if (M->getParent()->getTemplateSpecializationKind() !=
14287 "adjusting dtor exception specs was introduced in c++11");
14297 if (DtorType->hasExceptionSpec())
14321 ExprBuilder(
const ExprBuilder&) =
delete;
14322 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
14326 assert(
E &&
"Expression construction must not fail.");
14332 virtual ~ExprBuilder() {}
14337class RefBuilder:
public ExprBuilder {
14347 : Var(Var), VarType(VarType) {}
14350class ThisBuilder:
public ExprBuilder {
14357class CastBuilder:
public ExprBuilder {
14358 const ExprBuilder &Builder;
14366 CK_UncheckedDerivedToBase,
Kind,
14375class DerefBuilder:
public ExprBuilder {
14376 const ExprBuilder &Builder;
14380 return assertNotNull(
14384 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14387class MemberBuilder:
public ExprBuilder {
14388 const ExprBuilder &Builder;
14398 nullptr, MemberLookup,
nullptr,
nullptr).get());
14401 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
14403 : Builder(Builder),
Type(
Type), IsArrow(IsArrow),
14404 MemberLookup(MemberLookup) {}
14407class MoveCastBuilder:
public ExprBuilder {
14408 const ExprBuilder &Builder;
14415 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14418class LvalueConvBuilder:
public ExprBuilder {
14419 const ExprBuilder &Builder;
14423 return assertNotNull(
14427 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14430class SubscriptBuilder:
public ExprBuilder {
14431 const ExprBuilder &
Base;
14432 const ExprBuilder &Index;
14440 SubscriptBuilder(
const ExprBuilder &
Base,
const ExprBuilder &Index)
14452 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
14461 Expr *From = FromB.build(S,
Loc);
14465 Expr *To = ToB.build(S,
Loc);
14471 bool NeedsCollectableMemCpy =
14472 E->isRecordType() &&
14473 E->castAs<
RecordType>()->getDecl()->hasObjectMember();
14476 StringRef MemCpyName = NeedsCollectableMemCpy ?
14477 "__builtin_objc_memmove_collectable" :
14478 "__builtin_memcpy";
14491 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
14493 Expr *CallArgs[] = {
14499 assert(!
Call.isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
14532 const ExprBuilder &To,
const ExprBuilder &From,
14533 bool CopyingBaseSubobject,
bool Copying,
14534 unsigned Depth = 0) {
14550 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
14585 if (CopyingBaseSubobject) {
14616 Expr *FromInst = From.build(S,
Loc);
14620 if (
Call.isInvalid())
14639 Loc, BO_Assign, To.build(S,
Loc), From.build(S,
Loc));
14640 if (Assignment.isInvalid())
14659 llvm::raw_svector_ostream
OS(Str);
14660 OS <<
"__i" << Depth;
14664 IterationVarName, SizeType,
14673 RefBuilder IterationVarRef(IterationVar, SizeType);
14674 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
14680 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
14681 MoveCastBuilder FromIndexMove(FromIndexCopy);
14682 const ExprBuilder *FromIndex;
14684 FromIndex = &FromIndexCopy;
14686 FromIndex = &FromIndexMove;
14688 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
14693 ToIndex, *FromIndex, CopyingBaseSubobject,
14694 Copying, Depth + 1);
14696 if (
Copy.isInvalid() || !
Copy.get())
14703 S.
Context, IterationVarRefRVal.build(S,
Loc),
14724 const ExprBuilder &To,
const ExprBuilder &From,
14725 bool CopyingBaseSubobject,
bool Copying) {
14727 if (
T->
isArrayType() && !
T.isConstQualified() && !
T.isVolatileQualified() &&
14728 T.isTriviallyCopyableType(S.
Context))
14732 CopyingBaseSubobject,
14750 DeclaringSpecialMember DSM(*
this, ClassDecl,
14752 if (DSM.isAlreadyBeingDeclared())
14787 setupImplicitSpecialMemberType(
CopyAssignment, RetType, ArgType);
14797 ClassLoc, ClassLoc,
14839 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
14842 for (
auto *I : RD->
ctors()) {
14843 if (I->isCopyConstructor()) {
14844 UserDeclaredOperation = I;
14848 assert(UserDeclaredOperation);
14849 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
14852 for (
auto *I : RD->
methods()) {
14853 if (I->isCopyAssignmentOperator()) {
14854 UserDeclaredOperation = I;
14858 assert(UserDeclaredOperation);
14861 if (UserDeclaredOperation) {
14862 bool UDOIsUserProvided = UserDeclaredOperation->
isUserProvided();
14863 bool UDOIsDestructor = isa<CXXDestructorDecl>(UserDeclaredOperation);
14864 bool IsCopyAssignment = !isa<CXXConstructorDecl>(CopyOp);
14866 (UDOIsUserProvided && UDOIsDestructor)
14867 ? diag::warn_deprecated_copy_with_user_provided_dtor
14868 : (UDOIsUserProvided && !UDOIsDestructor)
14869 ? diag::warn_deprecated_copy_with_user_provided_copy
14870 : (!UDOIsUserProvided && UDOIsDestructor)
14871 ? diag::warn_deprecated_copy_with_dtor
14872 : diag::warn_deprecated_copy;
14874 << RD << IsCopyAssignment;
14885 "DefineImplicitCopyAssignment called for wrong function");
14903 Scope.addContextNote(CurrentLocation);
14938 RefBuilder OtherRef(
Other, OtherRefType);
14941 std::optional<ThisBuilder> This;
14942 std::optional<DerefBuilder> DerefThis;
14943 std::optional<RefBuilder> ExplicitObject;
14944 bool IsArrow =
false;
14950 ExplicitObject.emplace(CopyAssignOperator->
getParamDecl(0), ObjectType);
14954 DerefThis.emplace(*This);
14957 ExprBuilder &ObjectParameter =
14958 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
14959 :
static_cast<ExprBuilder &
>(*This);
14963 for (
auto &
Base : ClassDecl->
bases()) {
14966 QualType BaseType =
Base.getType().getUnqualifiedType();
14973 BasePath.push_back(&
Base);
14982 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
14983 :
static_cast<ExprBuilder &
>(*DerefThis),
14992 if (
Copy.isInvalid()) {
14998 Statements.push_back(
Copy.getAs<
Expr>());
15002 for (
auto *Field : ClassDecl->
fields()) {
15005 if (Field->isUnnamedBitField() || Field->getParent()->isUnion())
15008 if (Field->isInvalidDecl()) {
15014 if (Field->getType()->isReferenceType()) {
15015 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15017 Diag(Field->getLocation(), diag::note_declared_at);
15025 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15027 Diag(Field->getLocation(), diag::note_declared_at);
15033 if (Field->isZeroLengthBitField(
Context))
15036 QualType FieldType = Field->getType().getNonReferenceType();
15039 "Incomplete array type is not valid");
15050 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
15051 MemberBuilder To(ObjectParameter, ObjectType, IsArrow, MemberLookup);
15057 if (
Copy.isInvalid()) {
15063 Statements.push_back(
Copy.getAs<
Stmt>());
15069 (ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15070 :
LangOpts.HLSL ?
static_cast<ExprBuilder &
>(*This)
15071 :
static_cast<ExprBuilder &
>(*DerefThis))
15072 .build(*
this,
Loc);
15077 Statements.push_back(Return.
getAs<
Stmt>());
15090 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
15096 L->CompletedImplicitDefinition(CopyAssignOperator);
15103 DeclaringSpecialMember DSM(*
this, ClassDecl,
15105 if (DSM.isAlreadyBeingDeclared())
15139 setupImplicitSpecialMemberType(
MoveAssignment, RetType, ArgType);
15149 ClassLoc, ClassLoc,
15185 assert(!
Class->isDependentContext() &&
"should not define dependent move");
15191 if (
Class->getNumVBases() == 0 ||
Class->hasTrivialMoveAssignment() ||
15192 Class->getNumBases() < 2)
15196 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
15199 for (
auto &BI :
Class->bases()) {
15200 Worklist.push_back(&BI);
15201 while (!Worklist.empty()) {
15207 if (!
Base->hasNonTrivialMoveAssignment())
15232 VBases.insert(std::make_pair(
Base->getCanonicalDecl(), &BI))
15234 if (Existing && Existing != &BI) {
15235 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
15238 << (
Base->getCanonicalDecl() ==
15241 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
15242 << (
Base->getCanonicalDecl() ==
15243 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
15247 Existing =
nullptr;
15257 llvm::append_range(Worklist, llvm::make_pointer_range(
Base->bases()));
15270 "DefineImplicitMoveAssignment called for wrong function");
15300 Scope.addContextNote(CurrentLocation);
15316 RefBuilder OtherRef(
Other, OtherRefType);
15318 MoveCastBuilder MoveOther(OtherRef);
15321 std::optional<ThisBuilder> This;
15322 std::optional<DerefBuilder> DerefThis;
15323 std::optional<RefBuilder> ExplicitObject;
15329 ExplicitObject.emplace(MoveAssignOperator->
getParamDecl(0), ObjectType);
15333 DerefThis.emplace(*This);
15335 ExprBuilder &ObjectParameter =
15336 ExplicitObject ? *ExplicitObject :
static_cast<ExprBuilder &
>(*This);
15340 for (
auto &
Base : ClassDecl->
bases()) {
15351 QualType BaseType =
Base.getType().getUnqualifiedType();
15358 BasePath.push_back(&
Base);
15362 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
15367 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15368 :
static_cast<ExprBuilder &
>(*DerefThis),
15377 if (Move.isInvalid()) {
15383 Statements.push_back(Move.getAs<
Expr>());
15387 for (
auto *Field : ClassDecl->
fields()) {
15390 if (Field->isUnnamedBitField() || Field->getParent()->isUnion())
15393 if (Field->isInvalidDecl()) {
15399 if (Field->getType()->isReferenceType()) {
15400 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15402 Diag(Field->getLocation(), diag::note_declared_at);
15410 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15412 Diag(Field->getLocation(), diag::note_declared_at);
15418 if (Field->isZeroLengthBitField(
Context))
15421 QualType FieldType = Field->getType().getNonReferenceType();
15424 "Incomplete array type is not valid");
15433 MemberBuilder From(MoveOther, OtherRefType,
15434 false, MemberLookup);
15435 MemberBuilder To(ObjectParameter, ObjectType, !ExplicitObject,
15438 assert(!From.build(*
this,
Loc)->isLValue() &&
15439 "Member reference with rvalue base must be rvalue except for reference "
15440 "members, which aren't allowed for move assignment.");
15447 if (Move.isInvalid()) {
15453 Statements.push_back(Move.getAs<
Stmt>());
15459 (ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15460 :
static_cast<ExprBuilder &
>(*DerefThis))
15461 .build(*
this,
Loc);
15467 Statements.push_back(Return.
getAs<
Stmt>());
15480 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
15486 L->CompletedImplicitDefinition(MoveAssignOperator);
15497 DeclaringSpecialMember DSM(*
this, ClassDecl,
15499 if (DSM.isAlreadyBeingDeclared())
15566 ClassDecl->
hasAttr<TrivialABIAttr>() ||
15598 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
15603 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
15614 Scope.addContextNote(CurrentLocation);
15645 DeclaringSpecialMember DSM(*
this, ClassDecl,
15647 if (DSM.isAlreadyBeingDeclared())
15692 ClassLoc, ClassLoc,
15705 ClassDecl->
hasAttr<TrivialABIAttr>() ||
15737 "DefineImplicitMoveConstructor - call it for implicit move ctor");
15742 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
15753 Scope.addContextNote(CurrentLocation);
15800 if (CallOp != Invoker) {
15819 if (Invoker != CallOp) {
15832 assert(FunctionRef &&
"Can't refer to __invoke function?");
15840 L->CompletedImplicitDefinition(Conv);
15841 if (Invoker != CallOp)
15842 L->CompletedImplicitDefinition(Invoker);
15870 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
15879 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
15885 Stmt *ReturnS = Return.
get();
15892 L->CompletedImplicitDefinition(Conv);
15899 switch (Args.size()) {
15904 if (!Args[1]->isDefaultArgument())
15909 return !Args[0]->isDefaultArgument();
15918 bool HadMultipleCandidates,
bool IsListInitialization,
15919 bool IsStdInitListInitialization,
bool RequiresZeroInit,
15921 bool Elidable =
false;
15940 Expr *SubExpr = ExprArgs[0];
15950 FoundDecl, Constructor,
15951 Elidable, ExprArgs, HadMultipleCandidates,
15952 IsListInitialization,
15953 IsStdInitListInitialization, RequiresZeroInit,
15954 ConstructKind, ParenRange);
15960 bool HadMultipleCandidates,
bool IsListInitialization,
15961 bool IsStdInitListInitialization,
bool RequiresZeroInit,
15963 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
15973 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
15974 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
15975 RequiresZeroInit, ConstructKind, ParenRange);
15983 bool HadMultipleCandidates,
bool IsListInitialization,
15984 bool IsStdInitListInitialization,
bool RequiresZeroInit,
15987 Constructor->getParent(),
15989 "given constructor for wrong type");
15996 Context, DeclInitType, ConstructLoc, Constructor, Elidable, ExprArgs,
15997 HadMultipleCandidates, IsListInitialization,
15998 IsStdInitListInitialization, RequiresZeroInit,
16030 PDiag(diag::err_access_dtor_var)
16040 bool HasConstantInit =
false;
16047 diag::err_constexpr_var_requires_const_destruction) << VD;
16048 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
16049 Diag(Notes[I].first, Notes[I].second);
16058 if (!VD->
hasAttr<AlwaysDestroyAttr>())
16070 bool AllowExplicit,
16071 bool IsListInitialization) {
16073 unsigned NumArgs = ArgsPtr.size();
16074 Expr **Args = ArgsPtr.data();
16080 if (NumArgs < NumParams)
16081 ConvertedArgs.reserve(NumParams);
16083 ConvertedArgs.reserve(NumArgs);
16090 CallType, AllowExplicit, IsListInitialization);
16091 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
16095 CheckConstructorCall(Constructor, DeclInitType,
16106 if (isa<NamespaceDecl>(DC)) {
16108 diag::err_operator_new_delete_declared_in_namespace)
16112 if (isa<TranslationUnitDecl>(DC) &&
16115 diag::err_operator_new_delete_declared_static)
16127 return Ctx.getPointerType(Ctx.getCanonicalType(Ctx.getQualifiedType(
16135 unsigned DependentParamTypeDiag,
16136 unsigned InvalidParamTypeDiag) {
16157 ? diag::err_operator_new_delete_dependent_result_type
16158 : diag::err_operator_new_delete_invalid_result_type)
16165 diag::err_operator_new_delete_template_too_few_parameters)
16171 diag::err_operator_new_delete_too_few_parameters)
16178 if (
const auto *PtrTy =
16183 ExpectedFirstParamType =
16189 ExpectedFirstParamType) {
16194 ? DependentParamTypeDiag
16195 : InvalidParamTypeDiag)
16196 << FnDecl->
getDeclName() << ExpectedFirstParamType;
16219 diag::err_operator_new_dependent_param_type,
16220 diag::err_operator_new_param_type))
16227 diag::err_operator_new_default_arg)
16242 auto *MD = dyn_cast<CXXMethodDecl>(FnDecl);
16258 diag::err_operator_delete_dependent_param_type,
16259 diag::err_operator_delete_param_type))
16268 diag::err_destroying_operator_delete_not_usual);
16277 "Expected an overloaded operator declaration");
16287 if (Op == OO_Delete || Op == OO_Array_Delete)
16290 if (Op == OO_New || Op == OO_Array_New)
16300 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
16301 if (MethodDecl->isStatic()) {
16302 if (Op == OO_Call || Op == OO_Subscript)
16305 ? diag::warn_cxx20_compat_operator_overload_static
16306 : diag::ext_operator_overload_static))
16309 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_static)
16313 bool ClassOrEnumParam =
false;
16315 QualType ParamType = Param->getType().getNonReferenceType();
16318 ClassOrEnumParam =
true;
16323 if (!ClassOrEnumParam)
16325 diag::err_operator_overload_needs_class_or_enum)
16335 if (Op != OO_Call) {
16338 if (Param->hasDefaultArg()) {
16339 FirstDefaultedParam = Param;
16343 if (FirstDefaultedParam) {
16344 if (Op == OO_Subscript) {
16346 ? diag::ext_subscript_overload
16347 : diag::error_subscript_overload)
16352 diag::err_operator_overload_default_arg)
16360 {
false,
false,
false }
16361#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
16362 , { Unary, Binary, MemberOnly }
16363#include "clang/Basic/OperatorKinds.def"
16366 bool CanBeUnaryOperator = OperatorUses[Op][0];
16367 bool CanBeBinaryOperator = OperatorUses[Op][1];
16368 bool MustBeMemberOperator = OperatorUses[Op][2];
16375 (isa<CXXMethodDecl>(FnDecl) &&
16379 if (Op != OO_Call && Op != OO_Subscript &&
16380 ((NumParams == 1 && !CanBeUnaryOperator) ||
16381 (NumParams == 2 && !CanBeBinaryOperator) || (NumParams < 1) ||
16382 (NumParams > 2))) {
16384 unsigned ErrorKind;
16385 if (CanBeUnaryOperator && CanBeBinaryOperator) {
16387 }
else if (CanBeUnaryOperator) {
16390 assert(CanBeBinaryOperator &&
16391 "All non-call overloaded operators are unary or binary!");
16394 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
16395 << FnDecl->
getDeclName() << NumParams << ErrorKind;
16398 if (Op == OO_Subscript && NumParams != 2) {
16400 ? diag::ext_subscript_overload
16401 : diag::error_subscript_overload)
16402 << FnDecl->
getDeclName() << (NumParams == 1 ? 0 : 2);
16407 if (Op != OO_Call &&
16409 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
16414 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
16416 diag::err_operator_overload_must_be_member)
16430 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
16437 diag::err_operator_overload_post_incdec_must_be_int)
16438 << LastParam->
getType() << (Op == OO_MinusMinus);
16450 if (TemplateParams->
size() == 1) {
16452 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(0));
16471 }
else if (TemplateParams->
size() == 2) {
16473 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
getParam(0));
16475 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(1));
16487 diag::ext_string_literal_operator_template);
16494 diag::err_literal_operator_template)
16500 if (isa<CXXMethodDecl>(FnDecl)) {
16501 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
16510 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
16529 diag::err_literal_operator_template_with_params);
16558 diag::err_literal_operator_param)
16575 diag::err_literal_operator_invalid_param)
16585 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
16592 Diag((*Param)->getSourceRange().getBegin(),
16593 diag::err_literal_operator_param)
16594 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16601 Diag((*Param)->getSourceRange().getBegin(),
16602 diag::err_literal_operator_param)
16603 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16616 Diag((*Param)->getSourceRange().getBegin(),
16617 diag::err_literal_operator_param)
16618 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16626 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
16628 Diag((*Param)->getSourceRange().getBegin(),
16629 diag::err_literal_operator_param)
16631 << (*Param)->getSourceRange();
16635 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
16644 if (Param->hasDefaultArg()) {
16645 Diag(Param->getDefaultArgRange().getBegin(),
16646 diag::err_literal_operator_default_argument)
16647 << Param->getDefaultArgRange();
16662 <<
static_cast<int>(Status)
16673 assert(Lit->
isUnevaluated() &&
"Unexpected string literal kind");
16679 else if (Lang ==
"C++")
16682 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
16702 if (
getLangOpts().CPlusPlusModules && isCurrentModulePurview()) {
16703 Module *GlobalModule = PushImplicitGlobalModuleFragment(ExternLoc);
16726 PopImplicitGlobalModuleFragment();
16729 return LinkageSpec;
16762 Diag(
Loc, diag::err_catch_rvalue_ref);
16767 Diag(
Loc, diag::err_catch_variably_modified) << ExDeclType;
16773 unsigned DK = diag::err_catch_incomplete;
16777 DK = diag::err_catch_incomplete_ptr;
16780 BaseType = Ref->getPointeeType();
16782 DK = diag::err_catch_incomplete_ref;
16789 Diag(
Loc, diag::err_wasm_reftype_tc) << 1;
16794 Diag(
Loc, diag::err_catch_sizeless) << (Mode == 2 ? 1 : 0) << BaseType;
16800 diag::err_abstract_type_in_decl,
16812 Diag(
Loc, diag::err_objc_object_catch);
16817 Diag(
Loc, diag::warn_objc_pointer_cxx_catch_fragile);
16826 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(ExDecl))
16851 Expr *opaqueValue =
16886 D.getIdentifierLoc());
16893 RedeclarationKind::ForVisibleRedeclaration)) {
16897 assert(!S->isDeclScope(PrevDecl));
16899 Diag(
D.getIdentifierLoc(), diag::err_redefinition)
16900 <<
D.getIdentifier();
16901 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
16903 }
else if (PrevDecl->isTemplateParameter())
16908 if (
D.getCXXScopeSpec().isSet() && !
Invalid) {
16909 Diag(
D.getIdentifierLoc(), diag::err_qualified_catch_declarator)
16910 <<
D.getCXXScopeSpec().getRange();
16915 S, TInfo,
D.
getBeginLoc(),
D.getIdentifierLoc(),
D.getIdentifier());
16931 Expr *AssertMessageExpr,
16937 AssertMessageExpr, RParenLoc,
false);
16942 case BuiltinType::Char_S:
16943 case BuiltinType::Char_U:
16945 case BuiltinType::Char8:
16948 case BuiltinType::Char16:
16951 case BuiltinType::Char32:
16954 case BuiltinType::WChar_S:
16955 case BuiltinType::WChar_U:
16959 llvm_unreachable(
"Non-character type");
16969 char Arr[UNI_MAX_UTF8_BYTES_PER_CODE_POINT];
16972 llvm::raw_svector_ostream
OS(Str);
16976 if (K == BuiltinType::Char_S || K == BuiltinType::Char_U ||
16977 K == BuiltinType::Char8 ||
Value <= 0x7F) {
16978 StringRef Escaped = escapeCStyle<EscapeChar::Single>(
Value);
16979 if (!Escaped.empty())
16982 OS << static_cast<char>(
Value);
16987 case BuiltinType::Char16:
16988 case BuiltinType::Char32:
16989 case BuiltinType::WChar_S:
16990 case BuiltinType::WChar_U: {
16991 if (llvm::ConvertCodePointToUTF8(
Value, Ptr))
16995 << llvm::format_hex_no_prefix(
Value, TyWidth / 4,
true);
16999 llvm_unreachable(
"Non-character type is passed");
17011 switch (
V.getKind()) {
17017 int64_t BoolValue =
V.getInt().getExtValue();
17018 assert((BoolValue == 0 || BoolValue == 1) &&
17019 "Bool type, but value is not 0 or 1");
17020 llvm::raw_svector_ostream
OS(Str);
17021 OS << (BoolValue ?
"true" :
"false");
17023 llvm::raw_svector_ostream
OS(Str);
17028 switch (BTy->getKind()) {
17029 case BuiltinType::Char_S:
17030 case BuiltinType::Char_U:
17031 case BuiltinType::Char8:
17032 case BuiltinType::Char16:
17033 case BuiltinType::Char32:
17034 case BuiltinType::WChar_S:
17035 case BuiltinType::WChar_U: {
17037 assert(8 <= TyWidth && TyWidth <= 32 &&
"Unexpected integer width");
17038 uint32_t CodeUnit =
static_cast<uint32_t
>(
V.getInt().getZExtValue());
17043 << llvm::format_hex_no_prefix(CodeUnit, 2,
17045 <<
", " <<
V.getInt() <<
')';
17052 V.getInt().toString(Str);
17058 V.getFloat().toString(Str);
17062 if (
V.isNullPointer()) {
17063 llvm::raw_svector_ostream
OS(Str);
17070 llvm::raw_svector_ostream
OS(Str);
17072 V.getComplexFloatReal().toString(Str);
17074 V.getComplexFloatImag().toString(Str);
17079 llvm::raw_svector_ostream
OS(Str);
17081 V.getComplexIntReal().toString(Str);
17083 V.getComplexIntImag().toString(Str);
17106 if (isa<SubstNonTypeTemplateParmExpr>(
E))
17110 if (
const auto *UnaryOp = dyn_cast<UnaryOperator>(
E))
17114 if (
const auto *BO = dyn_cast<BinaryOperator>(
E))
17115 return (BO->isShiftOp() || BO->isAdditiveOp() || BO->isMultiplicativeOp() ||
17116 BO->isBitwiseOp());
17122 if (
const auto *Op = dyn_cast<BinaryOperator>(
E);
17123 Op && Op->getOpcode() != BO_LOr) {
17124 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
17125 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
17143 for (
unsigned I = 0; I < 2; I++) {
17144 const Expr *Side = DiagSide[I].Cond;
17148 DiagSide[I].Print =
17150 DiagSide[I].ValueString,
Context);
17152 if (DiagSide[0].Print && DiagSide[1].Print) {
17153 Diag(Op->getExprLoc(), diag::note_expr_evaluates_to)
17154 << DiagSide[0].ValueString << Op->getOpcodeStr()
17155 << DiagSide[1].ValueString << Op->getSourceRange();
17163 bool ErrorOnInvalidMessage) {
17165 assert(!Message->isTypeDependent() && !Message->isValueDependent() &&
17166 "can't evaluate a dependant static assert message");
17168 if (
const auto *SL = dyn_cast<StringLiteral>(Message)) {
17169 assert(SL->isUnevaluated() &&
"expected an unevaluated string");
17170 Result.assign(SL->getString().begin(), SL->getString().end());
17175 QualType T = Message->getType().getNonReferenceType();
17178 Diag(
Loc, diag::err_static_assert_invalid_message);
17182 auto FindMember = [&](StringRef
Member,
bool &
Empty,
17183 bool Diag =
false) -> std::optional<LookupResult> {
17190 if (MemberLookup.
empty())
17191 return std::nullopt;
17192 return std::move(MemberLookup);
17195 bool SizeNotFound, DataNotFound;
17196 std::optional<LookupResult> SizeMember = FindMember(
"size", SizeNotFound);
17197 std::optional<LookupResult> DataMember = FindMember(
"data", DataNotFound);
17198 if (SizeNotFound || DataNotFound) {
17199 Diag(
Loc, diag::err_static_assert_missing_member_function)
17200 << ((SizeNotFound && DataNotFound) ? 2
17206 if (!SizeMember || !DataMember) {
17208 FindMember(
"size", SizeNotFound,
true);
17210 FindMember(
"data", DataNotFound,
true);
17216 Message, Message->getType(), Message->getBeginLoc(),
false,
17241 Diag(
Loc, diag::err_static_assert_invalid_mem_fn_ret_ty) << 0;
17251 Diag(
Loc, diag::err_static_assert_invalid_mem_fn_ret_ty) << 1;
17255 if (!ErrorOnInvalidMessage &&
17261 Status.Diag = &Notes;
17262 if (!Message->EvaluateCharRangeAsString(
Result, EvaluatedSize.
get(),
17263 EvaluatedData.
get(), Ctx, Status) ||
17265 Diag(Message->getBeginLoc(),
17266 ErrorOnInvalidMessage ? diag::err_static_assert_message_constexpr
17267 : diag::warn_static_assert_message_constexpr);
17268 for (
const auto &
Note : Notes)
17270 return !ErrorOnInvalidMessage;
17276 Expr *AssertExpr,
Expr *AssertMessage,
17279 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
17297 AssertExpr = FullAssertExpr.
get();
17300 Expr *BaseExpr = AssertExpr;
17312 diag::err_static_assert_expression_is_not_constant,
17318 if (!Failed && AssertMessage && Cond.getBoolValue()) {
17327 bool InTemplateDefinition =
17330 if (!Failed && !Cond && !InTemplateDefinition) {
17332 llvm::raw_svector_ostream Msg(MsgBuffer);
17333 bool HasMessage = AssertMessage;
17334 if (AssertMessage) {
17338 AssertMessage, Str,
Context,
true) ||
17342 Expr *InnerCond =
nullptr;
17343 std::string InnerCondDescription;
17344 std::tie(InnerCond, InnerCondDescription) =
17346 if (InnerCond && isa<ConceptSpecializationExpr>(InnerCond)) {
17354 }
else if (InnerCond && !isa<CXXBoolLiteralExpr>(InnerCond)
17355 && !isa<IntegerLiteral>(InnerCond)) {
17357 diag::err_static_assert_requirement_failed)
17358 << InnerCondDescription << !HasMessage << Msg.str()
17375 AssertExpr = FullAssertExpr.
get();
17379 AssertExpr, AssertMessage, RParenLoc,
17393 bool IsMemberSpecialization =
false;
17398 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
17399 IsMemberSpecialization,
Invalid)) {
17400 if (TemplateParams->size() > 0) {
17408 FriendLoc, TempParamLists.size() - 1,
17409 TempParamLists.data())
17413 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
17415 IsMemberSpecialization =
true;
17421 bool isAllExplicitSpecializations =
true;
17422 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
17423 if (TempParamLists[I]->size()) {
17424 isAllExplicitSpecializations =
false;
17435 if (isAllExplicitSpecializations) {
17437 bool Owned =
false;
17438 bool IsDependent =
false;
17458 if (isa<DependentNameType>(
T)) {
17473 EllipsisLoc, TempParamLists);
17479 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
17486 unsigned FriendDeclDepth = TempParamLists.front()->getDepth();
17492 Diag(
U.second, diag::friend_template_decl_malformed_pack_expansion)
17501 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
17513 EllipsisLoc, TempParamLists);
17515 Friend->setUnsupportedFriend(
true);
17539 Diag(FriendLoc, diag::err_friend_not_first_in_declaration);
17571 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
17577 if (TempParams.size()) {
17594 ? diag::warn_cxx98_compat_unelaborated_friend_type
17595 : diag::ext_unelaborated_friend_type)
17601 ? diag::warn_cxx98_compat_nonclass_type_friend
17602 : diag::ext_nonclass_type_friend)
17619 if (!TempParams.empty())
17625 TSI, FriendLoc, EllipsisLoc);
17660 Diag(
Loc, diag::err_unexpected_friend);
17695 Scope *DCScope = S;
17697 RedeclarationKind::ForExternalRedeclaration);
17707 (FunctionContainingLocalClass =
17708 cast<CXXRecordDecl>(
CurContext)->isLocalClass())) {
17720 DCScope = S->getFnParent();
17730 DC =
Previous.getRepresentativeDecl()->getDeclContext();
17734 DC = FunctionContainingLocalClass;
17771 if (isTemplateId) {
17772 if (isa<TranslationUnitDecl>(LookupDC))
break;
17786 if (!DC)
return nullptr;
17797 diag::warn_cxx98_compat_friend_is_member :
17798 diag::err_friend_is_member);
17807 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
17834 if (DiagArg >= 0) {
17835 Diag(
Loc, diag::err_introducing_special_friend) << DiagArg;
17846 DCScope = &FakeDCScope;
17849 bool AddToScope =
true;
17851 TemplateParams, AddToScope);
17852 if (!ND)
return nullptr;
17874 D.getIdentifierLoc(), ND,
17886 FD = FTD->getTemplatedDecl();
17888 FD = cast<FunctionDecl>(ND);
17894 if (
D.isFunctionDefinition()) {
17908 }
else if (FunctionContainingLocalClass) {
17917 }
else if (isTemplateId) {
17930 if (
D.isRedeclaration()) {
17931 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
17933 diag::note_previous_declaration);
17934 }
else if (!
D.isFunctionDefinition())
17935 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
17940 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
17956 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
17958 Diag(DelLoc, diag::err_deleted_non_function);
17963 Fn->setWillHaveBody(
false);
17965 if (
const FunctionDecl *Prev = Fn->getPreviousDecl()) {
17969 Prev->getPreviousDecl()) &&
17970 !Prev->isDefined()) {
17971 Diag(DelLoc, diag::err_deleted_decl_not_first);
17972 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
17973 Prev->isImplicit() ? diag::note_previous_implicit_declaration
17974 : diag::note_previous_declaration);
17977 Fn->setInvalidDecl();
17985 Fn = Fn->getCanonicalDecl();
17990 Diag(Fn->getLocation(), diag::err_attribute_dll_deleted) << DLLAttr;
17991 Fn->setInvalidDecl();
17997 Diag(DelLoc, diag::err_deleted_main);
18001 Fn->setImplicitlyInline();
18002 Fn->setDeletedAsWritten(
true, Message);
18009 auto *FD = dyn_cast<FunctionDecl>(Dcl);
18011 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(Dcl)) {
18013 Diag(DefaultLoc, diag::err_defaulted_comparison_template);
18018 Diag(DefaultLoc, diag::err_default_special_members)
18029 (!FD->isDependentContext() ||
18030 (!isa<CXXConstructorDecl>(FD) &&
18032 Diag(DefaultLoc, diag::err_default_special_members)
18042 ? diag::warn_cxx17_compat_defaulted_comparison
18043 : diag::ext_defaulted_comparison);
18046 FD->setDefaulted();
18047 FD->setExplicitlyDefaulted();
18048 FD->setDefaultLoc(DefaultLoc);
18051 if (FD->isDependentContext())
18057 FD->setWillHaveBody(
false);
18070 if (isa<CXXMethodDecl>(FD)) {
18072 if (
const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern())
18086 auto *MD = cast<CXXMethodDecl>(FD);
18097 for (
Stmt *SubStmt : S->children()) {
18100 if (isa<ReturnStmt>(SubStmt))
18101 Self.Diag(SubStmt->getBeginLoc(),
18102 diag::err_return_in_constructor_handler);
18103 if (!isa<Expr>(SubStmt))
18117 switch (BodyKind) {
18126 "Parsed function body should be '= delete;' or '= default;'");
18140 !NewFT->getExtParameterInfo(I).isNoEscape()) {
18142 diag::warn_overriding_method_missing_noescape);
18144 diag::note_overridden_marked_noescape);
18150 Diag(New->
getLocation(), diag::err_conflicting_overriding_attributes)
18157 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
18158 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
18159 if ((NewCSA || OldCSA) &&
18160 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
18171 if (OldFX != NewFXOrig) {
18175 for (
const auto &Diff : Diffs) {
18176 switch (Diff.shouldDiagnoseMethodOverride(*Old, OldFX, *New, NewFX)) {
18181 << Diff.effectName();
18186 NewFX.
insert(Diff.Old, Errs);
18191 NewFT->getParamTypes(), EPI);
18206 if (NewCC == OldCC)
18217 diag::err_conflicting_overriding_cc_attributes)
18230 diag::err_explicit_object_parameter_nonmember)
18257 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
18265 if (NewClassTy.
isNull()) {
18267 diag::err_different_return_type_for_overriding_virtual_function)
18283 if (!RT->isBeingDefined() &&
18285 diag::err_covariant_return_incomplete,
18302 NewClassTy, OldClassTy,
18303 diag::err_covariant_return_inaccessible_base,
18304 diag::err_covariant_return_ambiguous_derived_to_base_conv,
18320 diag::err_covariant_return_type_different_qualifications)
18332 diag::err_covariant_return_type_class_type_more_qualified)
18362 else if (
auto *M = dyn_cast<CXXMethodDecl>(
D))
18400 if (
auto *VD = dyn_cast<VarDecl>(
D);
18427 "Parser allowed 'typedef' as storage class of condition decl.");
18433 if (isa<FunctionDecl>(Dcl)) {
18439 if (
auto *VD = dyn_cast<VarDecl>(Dcl))
18452 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
18453 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
18457 if (!Pos->second && VTables[I].DefinitionRequired)
18458 Pos->second =
true;
18462 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
18463 NewUses.push_back(
VTableUse(VTables[I].
Record, VTables[I].Location));
18470 bool DefinitionRequired) {
18473 if (!
Class->isDynamicClass() ||
Class->isDependentContext() ||
18479 !
OpenMP().isInOpenMPDeclareTargetContext() &&
18480 !
OpenMP().isInOpenMPTargetExecutionDirective()) {
18481 if (!DefinitionRequired)
18489 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
18495 if (DefinitionRequired && !Pos.first->second) {
18496 Pos.first->second =
true;
18525 if (
Class->isLocalClass())
18540 bool DefinedAnything =
false;
18541 for (
unsigned I = 0; I !=
VTableUses.size(); ++I) {
18546 Class->getTemplateSpecializationKind();
18550 bool DefineVTable =
true;
18555 if (
Class->isInCurrentModuleUnit()) {
18556 DefineVTable =
true;
18557 }
else if (KeyFunction && !KeyFunction->
hasBody()) {
18562 DefineVTable =
false;
18567 "Instantiations don't have key functions");
18569 }
else if (!KeyFunction) {
18574 bool IsExplicitInstantiationDeclaration =
18576 for (
auto *R :
Class->redecls()) {
18578 = cast<CXXRecordDecl>(R)->getTemplateSpecializationKind();
18580 IsExplicitInstantiationDeclaration =
true;
18582 IsExplicitInstantiationDeclaration =
false;
18587 if (IsExplicitInstantiationDeclaration)
18588 DefineVTable =
false;
18594 if (!DefineVTable) {
18602 DefinedAnything =
true;
18615 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
18622 return DefinedAnything;
18627 for (
const auto *I : RD->
methods())
18628 if (I->isVirtual() && !I->isPureVirtual())
18634 bool ConstexprOnly) {
18638 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
18639 E = FinalOverriders.end();
18642 OE = I->second.end();
18644 assert(OI->second.size() > 0 &&
"no final overrider");
18659 for (
const auto &I : RD->
bases()) {
18662 if (
Base->getNumVBases() == 0)
18685 cast_or_null<CXXConstructorDecl>(FNTarget));
18692 if (!Current.insert(Canonical).second)
18697 Target->isInvalidDecl() || Valid.count(TCanonical)) {
18698 Valid.insert(Current.begin(), Current.end());
18701 }
else if (TCanonical == Canonical ||
Invalid.count(TCanonical) ||
18702 Current.count(TCanonical)) {
18704 if (!
Invalid.count(TCanonical)) {
18706 diag::warn_delegating_ctor_cycle)
18710 if (TCanonical != Canonical)
18711 S.
Diag(
Target->getLocation(), diag::note_it_delegates_to);
18714 while (
C->getCanonicalDecl() != Canonical) {
18716 (void)
C->getTargetConstructor()->hasBody(FNTarget);
18717 assert(FNTarget &&
"Ctor cycle through bodiless function");
18720 cast<CXXConstructorDecl>(FNTarget));
18721 S.
Diag(
C->getLocation(), diag::note_which_delegates_to);
18725 Invalid.insert(Current.begin(), Current.end());
18736 for (DelegatingCtorDeclsType::iterator
18742 for (
auto CI =
Invalid.begin(), CE =
Invalid.end(); CI != CE; ++CI)
18743 (*CI)->setInvalidDecl();
18752 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
18755 S.
Diag(
E->getLocation(), diag::err_this_static_member_func)
18756 <<
E->isImplicit();
18780 FindCXXThisExpr Finder(*
this);
18793 if (!Finder.TraverseStmt(
E))
18810 FindCXXThisExpr Finder(*
this);
18832 if (!Finder.TraverseType(
E))
18842 FindCXXThisExpr Finder(*
this);
18845 for (
const auto *A : Method->
attrs()) {
18847 Expr *Arg =
nullptr;
18849 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
18851 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
18853 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
18855 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
18857 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
18858 Arg = ETLF->getSuccessValue();
18860 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
18861 Arg = STLF->getSuccessValue();
18863 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
18864 Arg = LR->getArg();
18865 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
18867 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
18869 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
18871 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
18873 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
18876 if (Arg && !Finder.TraverseStmt(Arg))
18879 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
18880 if (!Finder.TraverseStmt(Args[I]))
18894 Exceptions.clear();
18897 Exceptions.reserve(DynamicExceptions.size());
18898 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
18905 if (!Unexpanded.empty()) {
18916 Exceptions.push_back(ET);
18926 "Parser should have made sure that the expression is boolean");
18946 D = FTD->getTemplatedDecl();
18956 DynamicExceptionRanges, NoexceptExpr, Exceptions,
18984 Diag(DeclStart, diag::err_anonymous_property);
18996 D.setInvalidType();
19004 if (
D.getDeclSpec().isInlineSpecified())
19005 Diag(
D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
19007 if (
DeclSpec::TSCS TSCS =
D.getDeclSpec().getThreadStorageClassSpec())
19008 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
19009 diag::err_invalid_thread)
19015 RedeclarationKind::ForVisibleRedeclaration);
19017 switch (
Previous.getResultKind()) {
19024 PrevDecl =
Previous.getRepresentativeDecl();
19037 PrevDecl =
nullptr;
19041 PrevDecl =
nullptr;
19052 Record->setInvalidDecl();
19054 if (
D.getDeclSpec().isModulePrivateSpecified())
19074 if (!ExplicitLists.empty()) {
19075 bool IsMemberSpecialization, IsInvalid;
19079 ExplicitLists,
false, IsMemberSpecialization, IsInvalid,
19091 if (ExplicitParams && !ExplicitParams->
empty()) {
19092 Info.AutoTemplateParameterDepth = ExplicitParams->
getDepth();
19093 llvm::append_range(Info.TemplateParams, *ExplicitParams);
19094 Info.NumExplicitTemplateParams = ExplicitParams->
size();
19096 Info.AutoTemplateParameterDepth = TemplateParameterDepth;
19097 Info.NumExplicitTemplateParams = 0;
19103 if (FSI.TemplateParams.size() > FSI.NumExplicitTemplateParams) {
19104 if (FSI.NumExplicitTemplateParams != 0) {
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
enum clang::sema::@1658::IndirectLocalPathEntry::EntryKind Kind
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
static bool CheckLiteralType(EvalInfo &Info, const Expr *E, const LValue *This=nullptr)
Check that this core constant expression is of literal type, and if not, produce an appropriate diagn...
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Target Target
llvm::MachO::Record Record
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis for CUDA constructs.
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 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 RefersToRValueRef(Expr *MemRef)
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.
static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, llvm::APSInt &Size)
#define CheckPolymorphic(Type)
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 bool checkTrivialSubobjectCall(Sema &S, SourceLocation SubobjLoc, QualType SubType, bool ConstRHS, CXXSpecialMemberKind CSM, TrivialSubobjectKind Kind, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the special member selected for a given type would be trivial.
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 Expr * CastForMoving(Sema &SemaRef, Expr *E)
static void extendLeft(SourceRange &R, SourceRange Before)
static bool checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD, CXXSpecialMemberKind CSM, bool ConstArg, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the members of a class type allow a special member to be trivial.
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 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 findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, CXXSpecialMemberKind CSM, unsigned Quals, bool ConstRHS, Sema::TrivialABIHandling TAH, CXXMethodDecl **Selected)
Perform lookup for a special member of the specified kind, and determine whether it is trivial.
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 bool CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, CanQualType ExpectedResultType, CanQualType ExpectedFirstParamType, unsigned DependentParamTypeDiag, unsigned InvalidParamTypeDiag)
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 Sema::ImplicitExceptionSpecification ComputeDefaultedComparisonExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD, Sema::DefaultedComparisonKind DCK)
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 checkTupleLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, VarDecl *Src, QualType DecompType, const llvm::APSInt &TupleSize)
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 CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
static bool checkMemberDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const CXXRecordDecl *OrigRD)
static void checkForMultipleExportedDefaultConstructors(Sema &S, CXXRecordDecl *Class)
static bool checkSimpleDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType, llvm::function_ref< ExprResult(SourceLocation, Expr *, unsigned)> GetInit)
static TemplateArgumentLoc getTrivialTypeTemplateArgument(Sema &S, SourceLocation Loc, QualType T)
static void findImplicitlyDeclaredEqualityComparisons(ASTContext &Ctx, CXXRecordDecl *RD, llvm::SmallVectorImpl< FunctionDecl * > &Spaceships)
Find the equality comparison functions that should be implicitly declared in a given class definition...
static void PopulateKeysForFields(FieldDecl *Field, SmallVectorImpl< const void * > &IdealInits)
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
static bool ConvertAPValueToString(const APValue &V, QualType T, SmallVectorImpl< char > &Str, ASTContext &Context)
Convert \V to a string we can present to the user in a diagnostic \T is the type of the expression th...
static NamespaceDecl * getNamespaceDecl(NamedDecl *D)
getNamespaceDecl - Returns the namespace a decl represents.
static bool checkArrayDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const ConstantArrayType *CAT)
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 ClassTemplateDecl * LookupStdInitializerList(Sema &S, SourceLocation Loc)
static bool CheckOperatorNewDeclaration(Sema &SemaRef, const FunctionDecl *FnDecl)
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 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.
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 void DefineDefaultedFunction(Sema &S, FunctionDecl *FD, SourceLocation DefaultLoc)
static bool BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, FieldDecl *Field, IndirectFieldDecl *Indirect, CXXCtorInitializer *&CXXMemberInit)
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 lookupStdTypeTraitMember(Sema &S, LookupResult &TraitMemberLookup, SourceLocation Loc, StringRef Trait, TemplateArgumentListInfo &Args, unsigned DiagID)
static void DiagnoseInvisibleNamespace(const TypoCorrection &Corrected, Sema &S)
static StmtResult buildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying)
static FunctionProtoType::ExtProtoInfo getImplicitMethodEPI(Sema &S, CXXMethodDecl *MD)
static QualType getTupleLikeElementType(Sema &S, SourceLocation Loc, unsigned I, QualType T)
static Sema::ImplicitExceptionSpecification ComputeDefaultedSpecialMemberExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD, CXXSpecialMemberKind CSM, Sema::InheritedConstructorInfo *ICI)
static bool checkComplexDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const ComplexType *CT)
static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
static bool InitializationHasSideEffects(const FieldDecl &FD)
static bool CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef, const FunctionDecl *FnDecl)
static bool checkArrayLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType)
static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, DeclStmt *DS, SourceLocation &Cxx1yLoc, Sema::CheckConstexprKind Kind)
Check the given declaration statement is legal within a constexpr function body.
static bool IsEquivalentForUsingDecl(ASTContext &Context, NamedDecl *D1, NamedDecl *D2)
Determine whether a using declaration considers the given declarations as "equivalent",...
static TemplateArgumentLoc getTrivialIntegralTemplateArgument(Sema &S, SourceLocation Loc, QualType T, uint64_t I)
static bool CheckConstexprDestructorSubobjects(Sema &SemaRef, const CXXDestructorDecl *DD, Sema::CheckConstexprKind Kind)
Determine whether a destructor cannot be constexpr due to.
static bool CheckConstexprCtorInitializer(Sema &SemaRef, const FunctionDecl *Dcl, FieldDecl *Field, llvm::SmallSet< Decl *, 16 > &Inits, bool &Diagnosed, Sema::CheckConstexprKind Kind)
Check that the given field is initialized within a constexpr constructor.
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 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.
const NestedNameSpecifier * Specifier
__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)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
virtual void HandleVTable(CXXRecordDecl *RD)
Callback involved at the end of a translation unit to notify the consumer that a vtable for the given...
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 ...
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
unsigned getIntWidth(QualType T) const
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
DeclarationNameTable DeclarationNames
QualType getRecordType(const RecordDecl *Decl) const
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
void Deallocate(void *Ptr) const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const LangOptions & getLangOpts() const
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
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<=>,...
unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built.
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y) const
Determine whether the given template names refer to the same template.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
bool hasAnyFunctionEffects() const
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
const clang::PrintingPolicy & getPrintingPolicy() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built.
unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType getExceptionObjectType(QualType T) const
CanQualType UnsignedLongLongTy
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
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.
const TargetInfo & getTargetInfo() const
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
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)
Wrapper for source info for arrays.
TypeLoc getElementLoc() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Attr - This represents one attribute.
attr::Kind getKind() const
Attr * clone(ASTContext &C) const
SourceLocation getLocation() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
AutoTypeKeyword getKeyword() 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)
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
A binding in a decomposition declaration.
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
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...
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...
std::list< CXXBasePath >::iterator paths_iterator
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.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
ExplicitSpecifier getExplicitSpecifier()
init_iterator init_begin()
Retrieve an iterator to the first initializer.
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), Expr *TrailingRequiresClause=nullptr)
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.
FieldDecl * getAnyMember() const
A use of a default initializer in a constructor or in aggregate initialization.
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, Expr *TrailingRequiresClause=nullptr)
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...
bool isImplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An implicit object member function is a non-static member function without an exp...
unsigned getNumExplicitParams() const
CXXMethodDecl * getMostRecentDecl()
overridden_method_range overridden_methods() const
unsigned size_overridden_methods() const
QualType getFunctionObjectParameterReferenceType() const
Return the type of the object pointed by this.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
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.
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, Expr *TrailingRequiresClause=nullptr)
QualType getFunctionObjectParameterType() const
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
The null pointer literal (C++11 [lex.nullptr])
A call to an overloaded operator written using operator syntax.
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 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.
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 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 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 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.
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 isInterfaceLike() const
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.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
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
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]).
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
static CharSourceRange getTokenRange(SourceRange R)
SourceLocation getBegin() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this 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
const ComparisonCategoryInfo & getInfoForType(QualType Ty) const
Return the comparison category information as specified by getCategoryForType(Ty).
const ComparisonCategoryInfo * lookupInfo(ComparisonCategoryType Kind) const
Return the cached comparison category information for the specified 'Kind'.
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.
const ValueInfo * getValueInfo(ComparisonCategoryResult ValueKind) const
ComparisonCategoryType Kind
The Kind of the comparison category type.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
ConditionalOperator - The ?: ternary operator.
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)
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.
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.
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.
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
bool isStdNamespace() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
Decl::Kind getDeclKind() const
DeclContext * getNonTransparentContext()
decl_iterator decls_begin() const
A reference to a declared variable, function, enum, etc.
SourceLocation getBeginLoc() const LLVM_READONLY
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?
Captures information about "declaration specifiers".
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
Expr * getPackIndexingExpr() const
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
bool isFriendSpecifiedFirst() const
SourceLocation getEllipsisLoc() const
SourceLocation getConstSpecLoc() const
SourceRange getExplicitSpecRange() const
Expr * getRepAsExpr() const
SourceLocation getRestrictSpecLoc() const
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getAtomicSpecLoc() 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 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,...
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 clearIdentifierNamespace()
Clears the namespace of this declaration.
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.
bool isInvalidDecl() const
unsigned getIdentifierNamespace() const
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
@ IDNS_Ordinary
Ordinary names.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
void setLocalOwningModule(Module *M)
void setImplicit(bool I=true)
void setReferenced(bool R=true)
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
@ VisibleWhenImported
This declaration has an owning module, and is visible when that module is imported.
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
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
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
SourceLocation getIdentifierLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
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 isInvalidType() const
A decomposition declaration.
ArrayRef< BindingDecl * > bindings() const
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
SourceRange getSourceRange() const
SourceLocation getLSquareLoc() const
Represents a C++17 deduced template specialization type.
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) ...
bool isLastDiagnosticIgnored() const
Determine whether the previous diagnostic was ignored.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
void setElaboratedKeywordLoc(SourceLocation Loc)
TypeLoc getNamedTypeLoc() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
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
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
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, e.g.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
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.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
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 removeInClassInitializer()
Remove the C++11 in-class initializer from this member.
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.
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,...
void setUnsupportedFriend(bool Unsupported)
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, SourceLocation EllipsisLoc={}, ArrayRef< TemplateParameterList * > FriendTypeTPLists=std::nullopt)
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, StringLiteral *DeletedMessage=nullptr)
Represents a function declaration or definition.
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
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
void setIsPureVirtual(bool P=true)
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
bool isImmediateFunction() const
void setDefaultedOrDeletedInfo(DefaultedOrDeletedFunctionInfo *Info)
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
bool hasCXXExplicitFunctionObjectParameter() const
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
SourceLocation getDefaultLoc() const
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
FunctionTypeLoc getFunctionTypeLoc() const
Find the source location information for how the type of this function was written.
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.
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.
bool isImmediateEscalating() const
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
void setRangeEnd(SourceLocation E)
bool isDefaulted() const
Whether this function is defaulted.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
void setConstexprKind(ConstexprSpecKind CSK)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDefaulted(bool D=true)
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
bool hasOneParamOrDefaultArgs() const
Determine whether this function has a single parameter, or multiple parameters where all but the firs...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
size_t param_size() const
DeclarationNameInfo getNameInfo() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
DefaultedOrDeletedFunctionInfo * getDefalutedOrDeletedInfo() const
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)
An immutable set of FunctionEffects and possibly conditions attached to them.
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.
QualType getParamType(unsigned i) const
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.
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.
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
IfStmt - This represents an if/then/else.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
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.
void setInherited(bool I)
Description of a constructor that was inherited from a base class.
ConstructorUsingShadowDecl * getShadowDecl() const
const TypeClass * getTypePtr() const
Describes an C or C++ initializer list.
unsigned getNumInits() const
const Expr * getInit(unsigned Init) const
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
static InitializedEntity InitializeMemberFromDefaultMemberInitializer(FieldDecl *Member)
Create the initialization entity for a default member initializer.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
The injected class name of a C++ class template or class template partial specialization.
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].
Describes the capture of a variable or of this, or of a C++1y init-capture.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
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.
@ Ver4
Attempt to be ABI-compatible with code generated by Clang 4.0.x (SVN r291814).
@ Ver14
Attempt to be ABI-compatible with code generated by Clang 14.0.x.
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
void push_back(const T &LocalValue)
iterator begin(Source *source, bool LocalOnly=false)
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)
bool isLocalPackExpansion(const Decl *D)
Determine whether D is a pack expansion created in this scope.
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.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ 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.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ Found
Name lookup found a single declaration that met the criteria.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
DeclClass * getAsSingle() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Filter makeFilter()
Create a filter for this result set.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
An instance of this class represents the declaration of a property member.
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
SourceLocation getExprLoc() const LLVM_READONLY
Wrapper for source info for member pointers.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Describes a module or submodule.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
bool isExplicitGlobalModule() const
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isPlaceholderVar(const LangOptions &LangOpts) const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
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, NamedDecl *Namespace)
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 ...
A C++ nested-name-specifier augmented with source location information.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
@ Global
The global specifier '::'. There is no stored value.
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
The basic abstraction for the target Objective-C runtime.
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
@ CSK_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
SmallVectorImpl< OverloadCandidate >::iterator iterator
MapType::iterator iterator
MapType::const_iterator const_iterator
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
Represents a parameter to a function.
void setDefaultArg(Expr *defarg)
SourceLocation getExplicitObjectParamThisLoc() const
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
bool isExplicitObjectParameter() 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()
bool hasAttribute(ParsedAttr::Kind K) 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()
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
ArrayRef< Expr * > semantics()
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType withConst() 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.
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.
bool isWebAssemblyReferenceType() const
Returns true if it is a WebAssembly Reference Type.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
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).
Represents a template name as written in source code.
The collection of all-type qualifiers we support.
void addAddressSpace(LangAS space)
@ OCL_Weak
Reading or writing from this object requires a barrier call.
void removeAddressSpace()
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool hasFlexibleArrayMember() const
field_iterator field_end() const
field_range fields() const
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Scope - A scope is a transient data structure that is used while parsing the program.
void setEntity(DeclContext *E)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ DeclScope
This is a scope that can contain a declaration.
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool inferTargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMemberKind CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
A RAII object to enter scope of a compound statement.
For a defaulted function, the kind of defaulted function that it is.
DefaultedComparisonKind asComparison() const
bool isSpecialMember() const
bool isComparison() const
CXXSpecialMemberKind asSpecialMember() const
Helper class that collects exception specifications for implicitly-declared special member functions.
void CalledStmt(Stmt *S)
Integrate an invoked statement into the collected data.
void 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 EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result, ASTContext &Ctx, bool ErrorOnInvalidMessage)
bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range)
CheckSpecifiedExceptionType - Check if the given type is valid in an exception specification.
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
void DiagnoseAbstractType(const CXXRecordDecl *RD)
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc, const LookupResult *R=nullptr, const UsingDecl *UD=nullptr)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
bool CheckExplicitObjectOverride(CXXMethodDecl *New, const CXXMethodDecl *Old)
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter,...
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
@ LookupLocalFriendName
Look up a friend of a local class.
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
void DiagnoseSentinelCalls(const NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function.
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS=nullptr)
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.
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)
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)
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.
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 ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted.
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, SourceLocation EllipsisLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
Annotation attributes are the only attributes allowed after an access specifier.
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc, CodeSynthesisContext::SynthesisKind CSC=CodeSynthesisContext::ExplicitTemplateArgumentSubstitution)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
void referenceDLLExportedClassMethods()
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member function overrides a virtual...
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
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...
@ 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.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, DeclAccessPair Found, QualType ObjectType, SourceLocation Loc, const PartialDiagnostic &Diag)
Is the given member accessible for the purposes of deciding whether to define a special member functi...
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, const ParsedAttributesView &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
void ActOnFinishFunctionDeclarationDeclarator(Declarator &D)
Called after parsing a function declarator belonging to a function declaration.
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
DiagnosticsEngine & getDiagnostics() const
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
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...
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
void CheckDelayedMemberExceptionSpecs()
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ASTContext & getASTContext() const
ClassTemplateDecl * StdInitializerList
The C++ "std::initializer_list" template, which is defined in <initializer_list>.
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
SmallVector< std::pair< FunctionDecl *, FunctionDecl * >, 2 > DelayedEquivalentExceptionSpecChecks
All the function redeclarations seen during a class definition that had their exception spec checks d...
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
void PopExpressionEvaluationContext()
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace.
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
void ActOnStartFunctionDeclarationDeclarator(Declarator &D, unsigned TemplateParameterDepth)
Called before parsing a function declarator belonging to a function declaration.
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
@ Relational
This is an <, <=, >, or >= that should be implemented as a rewrite in terms of a <=> comparison.
@ NotEqual
This is an operator!= that should be implemented as a rewrite in terms of a == comparison.
@ ThreeWay
This is an operator<=> that should be implemented as a series of subobject comparisons.
@ None
This is not a defaultable comparison operator.
@ Equal
This is an operator== that should be implemented as a series of subobject comparisons.
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.
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, ArrayRef< CXXCtorInitializer * > Initializers=std::nullopt)
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
EnumDecl * getStdAlignValT() const
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
void PushFunctionScope()
Enter a new function scope.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
FPOptions & getCurFPFeatures()
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_UsingDeclaration
A using declaration.
@ UPPC_ExceptionType
The type of an exception.
@ UPPC_Initializer
An initializer.
@ UPPC_BaseType
The base type of a class type.
@ UPPC_FriendDeclaration
A friend declaration.
@ UPPC_DefaultArgument
A default argument.
@ UPPC_DeclarationType
The type of an arbitrary declaration.
@ UPPC_DataMemberType
The type of a data member.
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl, bool IsNested)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
const LangOptions & getLangOpts() const
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl, bool SupportedForCompatibility=false)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier * > Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
void DefineDefaultedComparison(SourceLocation Loc, FunctionDecl *FD, DefaultedComparisonKind DCK)
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules,...
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, QualType ObjectType, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
bool CheckConstexprFunctionDefinition(const FunctionDecl *FD, CheckConstexprKind Kind)
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
NamedDecl * getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R)
Return the declaration shadowed by the given typedef D, or null if it doesn't shadow any declaration ...
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
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.
bool CheckConstraintSatisfaction(const NamedDecl *Template, ArrayRef< const Expr * > ConstraintExprs, const MultiLevelTemplateArgumentList &TemplateArgLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
const LangOptions & LangOpts
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
CXXRecordDecl * getStdBadAlloc() const
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
void CheckCXXDefaultArguments(FunctionDecl *FD)
Helpers for dealing with blocks and functions.
@ DefaultedOperator
A defaulted 'operator<=>' needed the comparison category.
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
NamedDecl * BuildUsingEnumDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation NameLoc, TypeSourceInfo *EnumType, EnumDecl *ED)
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
SmallVector< std::pair< const CXXMethodDecl *, const CXXMethodDecl * >, 2 > DelayedOverridingExceptionSpecChecks
All the overriding functions seen during a class definition that had their exception spec checks dela...
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed.
ExprResult BuildConvertedConstantExpression(Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest=nullptr)
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
bool RequireCompleteEnumDecl(EnumDecl *D, SourceLocation L, CXXScopeSpec *SS=nullptr)
Require that the EnumDecl is completed with its enumerators defined or instantiated.
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 CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
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.
void popCodeSynthesisContext()
CXXRecordDecl * getCurrentClass(Scope *S, const CXXScopeSpec *SS)
Get the class that is directly named by the current context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
Check the validity of a C++ base class specifier.
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
ExprResult DefaultLvalueConversion(Expr *E)
bool CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow)
Determines whether to create a using shadow decl for a particular decl, given the set of decls existi...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
bool CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
void DiagPlaceholderVariableDefinition(SourceLocation Loc)
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
std::unique_ptr< RecordDeclSetTy > PureVirtualClassDiagSet
PureVirtualClassDiagSet - a set of class declarations which we have emitted a list of pure virtual fu...
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclarationName Name, FunctionDecl *&Operator, bool Diagnose=true, bool WantSize=false, bool WantAligned=false)
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.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams, SourceLocation EllipsisLoc)
Handle a friend type declaration.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
@ TAH_ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
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 MarkVirtualBaseDestructorsReferenced(SourceLocation Location, CXXRecordDecl *ClassDecl, llvm::SmallPtrSetImpl< const RecordType * > *DirectVirtualBases=nullptr)
Mark destructors of virtual bases of this class referenced.
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 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.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
void FilterUsingLookup(Scope *S, LookupResult &lookup)
Remove decls we can't actually see from a lookup being used to declare shadow using decls.
Decl * ActOnExceptionDeclarator(Scope *S, Declarator &D)
ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch handler.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
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 ...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
void CheckCompleteVariableDeclaration(VarDecl *VD)
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
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.
@ CCEK_StaticAssertMessageSize
Call to size() in a static assert message.
@ CCEK_ExplicitBool
Condition in an explicit(bool) specifier.
@ CCEK_StaticAssertMessageData
Call to data() in a static assert message.
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
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...
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, Expr *Init, SourceLocation EllipsisLoc)
Handle a C++ member initializer.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
void actOnDelayedExceptionSpecification(Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member or friend function (or function template).
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
void CheckExplicitObjectLambda(Declarator &D)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc)
PopPragmaVisibility - Pop the top element of the visibility stack; used for '#pragma GCC visibility' ...
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void DiscardCleanupsInEvaluationContext()
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > Expansions)
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc, StringLiteral *Message=nullptr)
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class,...
DiagnosticsEngine & Diags
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
NamespaceDecl * getStdNamespace() const
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 BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
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.
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD)
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,...
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
void diagnoseFunctionEffectMergeConflicts(const FunctionEffectSet::Conflicts &Errs, SourceLocation NewLoc, SourceLocation OldLoc)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
Decl * ActOnDeclarator(Scope *S, Declarator &D)
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
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)
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
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.
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
@ 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)
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
ExprResult ActOnCXXThis(SourceLocation Loc)
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
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.
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings=std::nullopt)
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
bool isAbstractType(SourceLocation Loc, QualType T)
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
ASTMutationListener * getASTMutationListener() const
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
void DiagnoseImmediateEscalatingReason(FunctionDecl *FD)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
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 isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
CharSourceRange getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getEnd() const
SourceLocation getBegin() const
void setEnd(SourceLocation e)
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *Message, SourceLocation RParenLoc, bool Failed)
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
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.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
TagKind getTagKind() const
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
bool areArgsDestroyedLeftToRightInCallee() const
Are arguments to a call destroyed left to right in the callee? This is a fundamental language change,...
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool hasKeyFunctions() const
Does this ABI use key functions? If so, class data such as the vtable is emitted with strong linkage ...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
A convenient class for passing around template argument information.
void addArgument(const TemplateArgumentLoc &Loc)
llvm::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() 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
Represents a type template specialization; the template must be a class template, a type alias templa...
ArrayRef< TemplateArgument > template_arguments() const
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
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.
unsigned getIndex() const
unsigned getDepth() const
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.
const Type * getTypeForDecl() const
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceRange getLocalSourceRange() const
Get the local source range.
TypeLocClass getTypeLocClass() const
SourceLocation getEndLoc() const
Get the end source location.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static StringRef getTagTypeKindName(TagTypeKind Kind)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBooleanType() const
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isIncompleteArrayType() const
bool isUndeducedAutoType() const
bool isRValueReferenceType() const
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
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isLValueReferenceType() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
QualType getCanonicalTypeInternal() const
bool containsErrors() const
Whether this type is an error type.
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 isObjCObjectType() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isRealFloatingType() const
Floating point categories.
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
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...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Represents a C++ unqualified-id that has been parsed.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
A set of unresolved declarations.
ArrayRef< DeclAccessPair > pairs() const
The iterator over UnresolvedSets.
A set of unresolved declarations.
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
static UnresolvedUsingIfExistsDecl * Create(ASTContext &Ctx, DeclContext *DC, SourceLocation Loc, DeclarationName Name)
Represents a dependent using declaration which was marked with typename.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
Represents a dependent using declaration which was not marked with typename.
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
Represents a C++ using-declaration.
bool hasTypename() const
Return true if the using declaration has 'typename'.
DeclarationNameInfo getNameInfo() const
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
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.
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)
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isNoDestroy(const ASTContext &) const
Is destruction of this variable entirely suppressed? If so, the variable need not have a usable destr...
bool isInlineSpecified() const
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool hasConstantInitialization() const
Determine whether this variable has constant initialization.
bool evaluateDestruction(SmallVectorImpl< PartialDiagnosticAt > &Notes) const
Evaluate the destruction of this variable to determine if it constitutes constant destruction.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
@ TLS_Dynamic
TLS with a dynamic initializer.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
void setExceptionVariable(bool EV)
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
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.
Defines the clang::TargetInfo interface.
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
bool Inc(InterpState &S, CodePtr OpPC)
1) Pops a pointer from the stack 2) Load the value from the pointer 3) Writes the value increased by ...
bool Zero(InterpState &S, CodePtr OpPC)
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
The JSON file list parser is used to communicate input to InstallAPI.
@ 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.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
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
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
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.
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
LinkageSpecLanguageIDs
Represents the language in a linkage specification.
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 (&&).
@ 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.
@ 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.
std::optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
StorageClass
Storage classes.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
ComparisonCategoryType commonComparisonType(ComparisonCategoryType A, ComparisonCategoryType B)
Determine the common comparison type, as defined in C++2a [class.spaceship]p4.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
Language
The language for the input, used to select and validate the language standard and possible actions.
@ Result
The result type of a method or function.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
void EscapeStringForDiagnostic(StringRef Str, SmallVectorImpl< char > &OutStr)
EscapeStringForDiagnostic - Append Str to the diagnostic buffer, escaping non-printable characters an...
ReservedLiteralSuffixIdStatus
ActionResult< Expr * > ExprResult
TagTypeKind
The kind of a tag type.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
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.
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
@ 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.
ActionResult< Stmt * > StmtResult
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.
ActionResult< ParsedType > TypeResult
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.
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
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 isExternallyVisible(Linkage L)
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)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
MutableArrayRef< Expr * > MultiExprArg
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
bool hasValidIntValue() const
True iff we've successfully evaluated the variable as a constant expression and extracted its integer...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
SourceLocation getEndLoc() const LLVM_READONLY
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)',...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
bool hasMutableQualifier() const
Determine whether this lambda-declarator contains a 'mutable' qualifier.
bool hasMethodTypeQualifiers() const
Determine whether this method has qualifiers.
void freeParams()
Reset the parameter list to having zero parameters.
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
One instance of this struct is used for each type in a declarator that is parsed.
enum clang::DeclaratorChunk::@223 Kind
EvalResult is a struct with detailed info about an evaluated expression.
Holds information about the various types of exception specification.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
FunctionEffectsRef FunctionEffects
RefQualifierKind RefQualifier
FunctionType::ExtInfo ExtInfo
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer points to.
Information about operator rewrites to consider when adding operator functions to a candidate set.
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.
@ DeclaringSpecialMember
We are declaring an implicit special member function.
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Decl * Entity
The entity that is being synthesized.
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Abstract class used to diagnose incomplete types.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
Information about a template-id annotation token.
TemplateNameKind Kind
The kind of template that Template refers to.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.