47#include "llvm/ADT/ArrayRef.h"
48#include "llvm/ADT/STLExtras.h"
49#include "llvm/ADT/ScopeExit.h"
50#include "llvm/ADT/SmallString.h"
51#include "llvm/ADT/StringExtras.h"
52#include "llvm/Support/ConvertUTF.h"
53#include "llvm/Support/SaveAndRestore.h"
70class CheckDefaultArgumentVisitor
73 const Expr *DefaultArg;
76 CheckDefaultArgumentVisitor(
Sema &S,
const Expr *DefaultArg)
77 : S(S), DefaultArg(DefaultArg) {}
82 bool VisitLambdaExpr(
const LambdaExpr *Lambda);
87bool CheckDefaultArgumentVisitor::VisitExpr(
const Expr *
Node) {
88 bool IsInvalid =
false;
89 for (
const Stmt *SubStmt :
Node->children())
91 IsInvalid |= Visit(SubStmt);
98bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
const DeclRefExpr *DRE) {
101 if (!isa<VarDecl, BindingDecl>(
Decl))
104 if (
const auto *Param = dyn_cast<ParmVarDecl>(
Decl)) {
115 diag::err_param_default_argument_references_param)
116 << Param->getDeclName() << DefaultArg->getSourceRange();
117 }
else if (
auto *VD =
Decl->getPotentiallyDecomposedVarDecl()) {
132 diag::err_param_default_argument_references_local)
139bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
const CXXThisExpr *ThisE) {
144 diag::err_param_default_argument_references_this)
148bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
153 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E)) {
154 E = OVE->getSourceExpr();
155 assert(E &&
"pseudo-object binding without source expression?");
163bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
const LambdaExpr *Lambda) {
172 return S.
Diag(LC.getLocation(), diag::err_lambda_capture_default_arg);
174 auto *D = cast<VarDecl>(LC.getCapturedVar());
175 Invalid |= Visit(D->getInit());
207 llvm_unreachable(
"should not see unresolved exception specs here");
236 "should not generate implicit declarations for dependent cases");
240 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
242 "Shouldn't collect exceptions when throw-all is guaranteed.");
247 Exceptions.push_back(E);
275 if (
Self->canThrow(S))
282 diag::err_typecheck_decl_incomplete_type))
301 CheckCompletedExpr(Arg, EqualLoc);
314 UnparsedDefaultArgInstantiationsMap::iterator InstPos
317 for (
unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
318 InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
331 if (!param || !DefaultArg)
339 Diag(EqualLoc, diag::err_param_default_argument)
352 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
366 CheckDefaultArgumentVisitor DefaultArgChecker(*
this, DefaultArg);
367 if (DefaultArgChecker.Visit(DefaultArg))
404 Param->
getType().getNonReferenceType());
426 if (MightBeFunction) {
430 MightBeFunction =
false;
433 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
437 std::unique_ptr<CachedTokens> Toks =
440 if (Toks->size() > 1)
442 Toks->back().getLocation());
454 MightBeFunction =
false;
461 return P->hasDefaultArg() && !P->hasInheritedDefaultArg();
482 for (; PrevForDefaultArgs;
530 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
533 p < NumParams; ++p) {
537 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
540 if (OldParamHasDfl && NewParamHasDfl) {
541 unsigned DiagDefaultParamID =
542 diag::err_param_default_argument_redefinition;
557 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
575 for (
auto Older = PrevForDefaultArgs;
577 Older = Older->getPreviousDecl();
578 OldParam = Older->getParamDecl(p);
583 }
else if (OldParamHasDfl) {
601 }
else if (NewParamHasDfl) {
605 diag::err_param_default_argument_template_redecl)
608 diag::note_template_prev_declaration)
639 if (
Record->getDescribedClassTemplate())
641 else if (isa<ClassTemplatePartialSpecializationDecl>(
Record))
648 diag::err_param_default_argument_member_template_redecl)
658 if (isa<CXXConstructorDecl>(New) &&
662 if (NewSM != OldSM) {
665 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
700 if (isa<CXXDeductionGuideDecl>(New) &&
712 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
733 ? diag::warn_cxx23_placeholder_var_definition
734 : diag::ext_placeholder_var_definition);
752 if (!TemplateParamLists.empty()) {
755 Diag(TemplateParamLists.front()->getTemplateLoc(),
756 diag::err_decomp_decl_template);
762 ? diag::ext_decomp_decl
764 ? diag::ext_decomp_decl_cond
765 : diag::warn_cxx14_compat_decomp_decl)
788 if (
auto SCS = DS.getStorageClassSpec()) {
791 CPlusPlus20SpecifierLocs.push_back(DS.getStorageClassSpecLoc());
794 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
797 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
799 CPlusPlus20SpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
801 if (DS.hasConstexprSpecifier()) {
802 BadSpecifiers.push_back(
804 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
806 if (DS.isInlineSpecified()) {
807 BadSpecifiers.push_back(
"inline");
808 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
811 if (!BadSpecifiers.empty()) {
812 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
813 Err << (
int)BadSpecifiers.size()
814 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
817 for (
auto Loc : BadSpecifierLocs)
819 }
else if (!CPlusPlus20Specifiers.empty()) {
820 auto &&Warn =
Diag(CPlusPlus20SpecifierLocs.front(),
822 ? diag::warn_cxx17_compat_decomp_decl_spec
823 : diag::ext_decomp_decl_spec);
824 Warn << (
int)CPlusPlus20Specifiers.size()
825 << llvm::join(CPlusPlus20Specifiers.begin(),
826 CPlusPlus20Specifiers.end(),
" ");
827 for (
auto Loc : CPlusPlus20SpecifierLocs)
839 Diag(DS.getVolatileSpecLoc(),
840 diag::warn_deprecated_volatile_structured_binding);
860 ? diag::err_decomp_decl_parens
861 : diag::err_decomp_decl_type)
872 if (DS.isConstrainedAuto()) {
875 "No other template kind should be possible for a constrained auto");
893 assert(VarName &&
"Cannot have an unnamed binding declaration");
902 Previous.getFoundDecl()->isTemplateParameter()) {
934 auto *Old =
Previous.getRepresentativeDecl();
935 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
936 Diag(Old->getLocation(), diag::note_previous_definition);
954 bool AddToScope =
true;
973 if ((int64_t)
Bindings.size() != NumElems) {
974 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
987 E = GetInit(Loc, E.
get(), I++);
990 B->setBinding(ElemType, E.
get());
999 const llvm::APSInt &NumElems,
1002 S,
Bindings, Src, DecompType, NumElems, ElemType,
1033 S,
Bindings, Src, DecompType, llvm::APSInt::get(2),
1037 return S.CreateBuiltinUnaryOp(Loc, I ? UO_Imag : UO_Real, Base);
1045 llvm::raw_svector_ostream
OS(SS);
1057 return std::string(
OS.str());
1064 auto DiagnoseMissing = [&] {
1074 return DiagnoseMissing();
1084 return DiagnoseMissing();
1085 if (
Result.isAmbiguous())
1090 Result.suppressDiagnostics();
1092 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
1104 Loc, TraitTy, DiagID,
1111 assert(RD &&
"specialization of class template is not a class?");
1130namespace {
enum class IsTupleLike { TupleLike, NotTupleLike,
Error }; }
1133 llvm::APSInt &Size) {
1148 return IsTupleLike::NotTupleLike;
1157 : R(R), Args(Args) {}
1160 return S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1164 } Diagnoser(R, Args);
1169 return IsTupleLike::Error;
1173 return IsTupleLike::Error;
1175 return IsTupleLike::TupleLike;
1190 S, R, Loc,
"tuple_element", Args,
1191 diag::err_decomp_decl_std_tuple_element_not_specialized))
1197 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1209struct InitializingBinding {
1218 ~InitializingBinding() {
1227 const llvm::APSInt &TupleSize) {
1228 if ((int64_t)
Bindings.size() != TupleSize) {
1229 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1245 bool UseMemberGet =
false;
1255 dyn_cast<FunctionTemplateDecl>(D->getUnderlyingDecl())) {
1257 if (TPL->
size() != 0 &&
1258 isa<NonTypeTemplateParmDecl>(TPL->
getParam(0))) {
1260 UseMemberGet =
true;
1269 InitializingBinding InitContext(S, B);
1292 MemberGet, &Args,
nullptr);
1327 B->getDeclName().getAsIdentifierInfo(), RefType,
1331 RefVD->setImplicit();
1333 RefVD->setInlineSpecified();
1334 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1339 E =
Seq.Perform(S, Entity, Kind,
Init);
1345 RefVD->setInit(E.
get());
1354 B->setBinding(T, E.
get());
1369 return Specifier->getType()->getAsCXXRecordDecl()->hasDirectFields();
1378 ClassWithFields = RD;
1390 for (
auto &
P : Paths) {
1394 BestPath->back().Base->getType())) {
1396 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1397 <<
false << RD << BestPath->back().Base->getType()
1398 <<
P.back().Base->getType();
1400 }
else if (
P.Access < BestPath->
Access) {
1406 QualType BaseType = BestPath->back().Base->getType();
1408 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1415 *BestPath, diag::err_decomp_decl_inaccessible_base);
1426 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1427 << (ClassWithFields == RD) << RD << ClassWithFields
1428 << Paths.front().back().Base->getType();
1439 diag::err_incomplete_type))
1451 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1452 unsigned NumFields = llvm::count_if(
1453 RD->
fields(), [](
FieldDecl *FD) { return !FD->isUnnamedBitfield(); });
1454 assert(
Bindings.size() != NumFields);
1455 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1465 for (
auto *FD : RD->
fields()) {
1466 if (FD->isUnnamedBitfield())
1471 if (!FD->getDeclName()) {
1478 if (FD->isAnonymousStructOrUnion()) {
1481 S.
Diag(FD->getLocation(), diag::note_declared_at);
1490 return DiagnoseBadNumberOfBindings();
1501 BasePair.
getAccess(), FD->getAccess())));
1524 if (FD->isMutable())
1530 return DiagnoseBadNumberOfBindings();
1572 llvm::APSInt TupleSize(32);
1574 case IsTupleLike::Error:
1578 case IsTupleLike::TupleLike:
1583 case IsTupleLike::NotTupleLike:
1592 << DD << !RD << DecompType;
1615 "Should only be called if types are otherwise the same.");
1626 NewType =
P->getPointeeType();
1659 if (FTD->isMemberSpecialization())
1683 diag::err_param_default_argument_missing_name)
1687 diag::err_param_default_argument_missing);
1695template <
typename... Ts>
1705 std::forward<Ts>(DiagArgs)...);
1711 llvm_unreachable(
"unknown CheckConstexprKind");
1719 "this check is obsolete for C++23");
1722 T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
1730 SemaRef.
Diag(Loc, diag::note_constexpr_dtor_subobject)
1738 if (!Check(B.getBaseTypeLoc(), B.getType(),
nullptr))
1741 if (!Check(FD->getLocation(), FD->getType(), FD))
1752 "this check is obsolete for C++23");
1753 unsigned ArgIndex = 0;
1756 e = FT->param_type_end();
1757 i != e; ++i, ++ArgIndex) {
1759 assert(PD &&
"null in a parameter list");
1762 diag::err_constexpr_non_literal_param, ArgIndex + 1,
1775 "this check is obsolete for C++23");
1777 diag::err_constexpr_non_literal_return,
1796 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1827 << isa<CXXConstructorDecl>(NewFD)
1829 for (
const auto &I : RD->
vbases())
1830 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
1831 << I.getSourceRange();
1836 if (!isa<CXXConstructorDecl>(NewFD)) {
1841 const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD);
1845 Diag(Method->
getLocation(), diag::warn_cxx17_compat_constexpr_virtual);
1858 if (WrittenVirtual != Method)
1860 diag::note_overridden_virtual_function);
1871 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(NewFD)) {
1876 !Dtor->getParent()->defaultedDestructorIsConstexpr()) {
1891 "CheckConstexprFunctionDefinition called on function with no body");
1906 for (
const auto *DclIt : DS->
decls()) {
1907 switch (DclIt->getKind()) {
1908 case Decl::StaticAssert:
1910 case Decl::UsingShadow:
1911 case Decl::UsingDirective:
1912 case Decl::UnresolvedUsingTypename:
1913 case Decl::UnresolvedUsingValue:
1914 case Decl::UsingEnum:
1922 case Decl::TypeAlias: {
1925 const auto *TN = cast<TypedefNameDecl>(DclIt);
1926 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1929 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1932 << isa<CXXConstructorDecl>(Dcl);
1940 case Decl::CXXRecord:
1942 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition()) {
1946 ? diag::warn_cxx11_compat_constexpr_type_definition
1947 : diag::ext_constexpr_type_definition)
1948 << isa<CXXConstructorDecl>(Dcl);
1955 case Decl::EnumConstant:
1956 case Decl::IndirectField:
1963 case Decl::Decomposition: {
1968 const auto *VD = cast<VarDecl>(DclIt);
1969 if (VD->isThisDeclarationADefinition()) {
1970 if (VD->isStaticLocal()) {
1972 SemaRef.
Diag(VD->getLocation(),
1974 ? diag::warn_cxx20_compat_constexpr_var
1975 : diag::ext_constexpr_static_var)
1976 << isa<CXXConstructorDecl>(Dcl)
1982 if (SemaRef.
LangOpts.CPlusPlus23) {
1984 diag::warn_cxx20_compat_constexpr_var,
1985 isa<CXXConstructorDecl>(Dcl),
1988 SemaRef, Kind, VD->getLocation(), VD->getType(),
1989 diag::err_constexpr_local_var_non_literal_type,
1990 isa<CXXConstructorDecl>(Dcl))) {
1993 if (!VD->getType()->isDependentType() &&
1994 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1999 ? diag::warn_cxx17_compat_constexpr_local_var_no_init
2000 : diag::ext_constexpr_local_var_no_init)
2001 << isa<CXXConstructorDecl>(Dcl);
2009 SemaRef.
Diag(VD->getLocation(),
2011 ? diag::warn_cxx11_compat_constexpr_local_var
2012 : diag::ext_constexpr_local_var)
2013 << isa<CXXConstructorDecl>(Dcl);
2020 case Decl::NamespaceAlias:
2021 case Decl::Function:
2030 SemaRef.
Diag(DS->
getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
2031 << isa<CXXConstructorDecl>(Dcl) << Dcl->
isConsteval();
2056 llvm::SmallSet<Decl*, 16> &Inits,
2064 if (Field->isInvalidDecl())
2067 if (Field->isUnnamedBitfield())
2073 if (Field->isAnonymousStructOrUnion() &&
2074 (Field->getType()->isUnionType()
2075 ? !Field->getType()->getAsCXXRecordDecl()->hasVariantMembers()
2076 : Field->getType()->getAsCXXRecordDecl()->isEmpty()))
2079 if (!Inits.count(Field)) {
2084 ? diag::warn_cxx17_compat_constexpr_ctor_missing_init
2085 : diag::ext_constexpr_ctor_missing_init);
2088 SemaRef.
Diag(Field->getLocation(),
2089 diag::note_constexpr_ctor_missing_init);
2093 }
else if (Field->isAnonymousStructOrUnion()) {
2095 for (
auto *I : RD->
fields())
2098 if (!RD->
isUnion() || Inits.count(I))
2115 switch (S->getStmtClass()) {
2116 case Stmt::NullStmtClass:
2120 case Stmt::DeclStmtClass:
2130 case Stmt::ReturnStmtClass:
2132 if (isa<CXXConstructorDecl>(Dcl)) {
2135 Cxx1yLoc = S->getBeginLoc();
2139 ReturnStmts.push_back(S->getBeginLoc());
2142 case Stmt::AttributedStmtClass:
2146 SemaRef, Dcl, cast<AttributedStmt>(S)->getSubStmt(), ReturnStmts,
2147 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind);
2149 case Stmt::CompoundStmtClass: {
2152 Cxx1yLoc = S->getBeginLoc();
2155 for (
auto *BodyIt : CompStmt->
body()) {
2157 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2163 case Stmt::IfStmtClass: {
2166 Cxx1yLoc = S->getBeginLoc();
2170 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2172 if (
If->getElse() &&
2174 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2179 case Stmt::WhileStmtClass:
2180 case Stmt::DoStmtClass:
2181 case Stmt::ForStmtClass:
2182 case Stmt::CXXForRangeStmtClass:
2183 case Stmt::ContinueStmtClass:
2189 Cxx1yLoc = S->getBeginLoc();
2190 for (
Stmt *SubStmt : S->children()) {
2193 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2198 case Stmt::SwitchStmtClass:
2199 case Stmt::CaseStmtClass:
2200 case Stmt::DefaultStmtClass:
2201 case Stmt::BreakStmtClass:
2205 Cxx1yLoc = S->getBeginLoc();
2206 for (
Stmt *SubStmt : S->children()) {
2209 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2214 case Stmt::LabelStmtClass:
2215 case Stmt::GotoStmtClass:
2217 Cxx2bLoc = S->getBeginLoc();
2218 for (
Stmt *SubStmt : S->children()) {
2221 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2226 case Stmt::GCCAsmStmtClass:
2227 case Stmt::MSAsmStmtClass:
2229 case Stmt::CXXTryStmtClass:
2231 Cxx2aLoc = S->getBeginLoc();
2232 for (
Stmt *SubStmt : S->children()) {
2235 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2240 case Stmt::CXXCatchStmtClass:
2244 SemaRef, Dcl, cast<CXXCatchStmt>(S)->getHandlerBlock(), ReturnStmts,
2245 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2255 Cxx1yLoc = S->getBeginLoc();
2260 SemaRef.
Diag(S->getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
2261 << isa<CXXConstructorDecl>(Dcl) << Dcl->
isConsteval();
2276 if (isa<CXXTryStmt>(Body)) {
2298 ? diag::ext_constexpr_function_try_block_cxx20
2299 : diag::warn_cxx17_compat_constexpr_function_try_block)
2300 << isa<CXXConstructorDecl>(Dcl);
2314 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2325 }
else if (Cxx2bLoc.
isValid()) {
2326 SemaRef.
Diag(Cxx2bLoc,
2328 ? diag::warn_cxx20_compat_constexpr_body_invalid_stmt
2329 : diag::ext_constexpr_body_invalid_stmt_cxx23)
2330 << isa<CXXConstructorDecl>(Dcl);
2331 }
else if (Cxx2aLoc.
isValid()) {
2332 SemaRef.
Diag(Cxx2aLoc,
2334 ? diag::warn_cxx17_compat_constexpr_body_invalid_stmt
2335 : diag::ext_constexpr_body_invalid_stmt_cxx20)
2336 << isa<CXXConstructorDecl>(Dcl);
2337 }
else if (Cxx1yLoc.
isValid()) {
2338 SemaRef.
Diag(Cxx1yLoc,
2340 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
2341 : diag::ext_constexpr_body_invalid_stmt)
2342 << isa<CXXConstructorDecl>(Dcl);
2346 = dyn_cast<CXXConstructorDecl>(Dcl)) {
2355 if (Constructor->getNumCtorInitializers() == 0 &&
2361 ? diag::warn_cxx17_compat_constexpr_union_ctor_no_init
2362 : diag::ext_constexpr_union_ctor_no_init);
2367 }
else if (!Constructor->isDependentContext() &&
2368 !Constructor->isDelegatingConstructor()) {
2369 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
2373 bool AnyAnonStructUnionMembers =
false;
2374 unsigned Fields = 0;
2376 E = RD->
field_end(); I != E; ++I, ++Fields) {
2377 if (I->isAnonymousStructOrUnion()) {
2378 AnyAnonStructUnionMembers =
true;
2386 if (AnyAnonStructUnionMembers ||
2387 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
2391 llvm::SmallSet<Decl*, 16> Inits;
2392 for (
const auto *I: Constructor->inits()) {
2396 Inits.insert(ID->chain_begin(), ID->chain_end());
2399 bool Diagnosed =
false;
2400 for (
auto *I : RD->
fields())
2407 if (ReturnStmts.empty()) {
2418 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2419 : diag::err_constexpr_body_no_return)
2433 }
else if (ReturnStmts.size() > 1) {
2439 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2440 : diag::ext_constexpr_body_multiple_return);
2441 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2442 SemaRef.
Diag(ReturnStmts[I],
2443 diag::note_constexpr_body_previous_return);
2472 diag::ext_constexpr_function_never_constant_expr)
2473 << isa<CXXConstructorDecl>(Dcl) << Dcl->
isConsteval()
2475 for (
size_t I = 0, N =
Diags.size(); I != N; ++I)
2493 Diag(it->second, diag::err_immediate_function_used_before_definition)
2506 "expected an immediate function");
2507 assert(FD->
hasBody() &&
"expected the function to have a body");
2508 struct ImmediateEscalatingExpressionsVisitor
2515 bool ImmediateFnIsConstructor;
2520 : SemaRef(SemaRef), ImmediateFn(FD),
2521 ImmediateFnIsConstructor(isa<CXXConstructorDecl>(FD)) {}
2523 bool shouldVisitImplicitCode()
const {
return true; }
2524 bool shouldVisitLambdaBody()
const {
return false; }
2529 if (CurrentConstructor && CurrentInit) {
2537 SemaRef.
Diag(Loc, diag::note_immediate_function_reason)
2538 << ImmediateFn << Fn << Fn->
isConsteval() << IsCall
2539 << isa<CXXConstructorDecl>(Fn) << ImmediateFnIsConstructor
2540 << (InitializedField !=
nullptr)
2541 << (CurrentInit && !CurrentInit->
isWritten())
2542 << InitializedField << Range;
2544 bool TraverseCallExpr(
CallExpr *E) {
2545 if (
const auto *DR =
2547 DR && DR->isImmediateEscalating()) {
2553 if (!getDerived().TraverseStmt(A))
2560 if (
const auto *ReferencedFn = dyn_cast<FunctionDecl>(E->
getDecl());
2562 Diag(E, ReferencedFn,
false);
2580 return Base::TraverseConstructorInitializer(
Init);
2585 return Base::TraverseCXXConstructorDecl(Ctr);
2588 bool TraverseType(
QualType T) {
return true; }
2589 bool VisitBlockExpr(
BlockExpr *T) {
return true; }
2591 } Visitor(*
this, FD);
2592 Visitor.TraverseDecl(FD);
2611 return dyn_cast_or_null<CXXRecordDecl>(DC);
2614 return dyn_cast_or_null<CXXRecordDecl>(
CurContext);
2639 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2641 CurDecl = dyn_cast_or_null<CXXRecordDecl>(
CurContext);
2661 for (
const auto &I : Current->bases()) {
2673 Queue.push_back(
Base);
2679 Current = Queue.pop_back_val();
2707 if (
Class->isUnion()) {
2708 Diag(
Class->getLocation(), diag::err_base_clause_on_union)
2715 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2727 if (BaseDecl->getCanonicalDecl() ==
Class->getCanonicalDecl() ||
2728 ((BaseDecl = BaseDecl->getDefinition()) &&
2730 Diag(BaseLoc, diag::err_circular_inheritance)
2733 if (BaseDecl->getCanonicalDecl() !=
Class->getCanonicalDecl())
2734 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
2747 if (!
Class->getTypeForDecl()->isDependentType())
2748 Class->setInvalidDecl();
2751 Access, TInfo, EllipsisLoc);
2756 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2763 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2771 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2783 diag::err_incomplete_base_class, SpecifierRange)) {
2784 Class->setInvalidDecl();
2790 assert(BaseDecl &&
"Record type has no declaration");
2792 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2794 assert(CXXBaseDecl &&
"Base type is not a C++ type");
2799 const auto *BaseCSA = CXXBaseDecl->
getAttr<CodeSegAttr>();
2800 const auto *DerivedCSA =
Class->getAttr<CodeSegAttr>();
2801 if ((DerivedCSA || BaseCSA) &&
2802 (!BaseCSA || !DerivedCSA || BaseCSA->getName() != DerivedCSA->getName())) {
2803 Diag(
Class->getLocation(), diag::err_mismatched_code_seg_base);
2804 Diag(CXXBaseDecl->
getLocation(), diag::note_base_class_specified_here)
2816 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2824 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
2825 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2827 << FA->isSpelledAsSealed();
2834 Class->setInvalidDecl();
2839 Access, TInfo, EllipsisLoc);
2861 Class->setIsParsingBaseSpecifiers();
2869 Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
2870 << AL << AL.getRange();
2872 Diag(AL.getLoc(), diag::err_base_specifier_attribute)
2873 << AL << AL.isRegularKeywordAttribute() << AL.getRange();
2889 Class->setInvalidDecl();
2906 auto Decl = Rec->getAsCXXRecordDecl();
2909 for (
const auto &BaseSpec :
Decl->bases()) {
2930 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2937 unsigned NumGoodBases = 0;
2939 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2949 Diag(Bases[idx]->getBeginLoc(), diag::err_duplicate_base_class)
2950 << KnownBase->
getType() << Bases[idx]->getSourceRange();
2959 KnownBase = Bases[idx];
2960 Bases[NumGoodBases++] = Bases[idx];
2965 if (Bases.size() > 1)
2970 if (
Class->isInterface() &&
2987 Class->setBases(Bases.data(), NumGoodBases);
2990 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2992 QualType BaseType = Bases[idx]->getType();
3002 if (IndirectBaseTypes.count(CanonicalBase)) {
3006 =
Class->isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
3010 if (Paths.isAmbiguous(CanonicalBase))
3011 Diag(Bases[idx]->getBeginLoc(), diag::warn_inaccessible_base_class)
3013 << Bases[idx]->getSourceRange();
3015 assert(Bases[idx]->isVirtual());
3031 if (!ClassDecl || Bases.empty())
3092 for (
unsigned I = Path.size(); I != 0; --I) {
3093 if (Path[I - 1].
Base->isVirtual()) {
3100 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
3107 assert(BasePathArray.empty() &&
"Base path array must be empty!");
3108 assert(Paths.isRecordingPaths() &&
"Must record paths!");
3109 return ::BuildBasePathArray(Paths.front(), BasePathArray);
3125 unsigned InaccessibleBaseID,
3126 unsigned AmbiguousBaseConvID,
3130 bool IgnoreAccess) {
3138 if (!DerivationOkay)
3143 Path = &Paths.front();
3150 if (PossiblePath.size() == 1) {
3151 Path = &PossiblePath;
3152 if (AmbiguousBaseConvID)
3153 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
3154 <<
Base << Derived << Range;
3161 if (!IgnoreAccess) {
3180 if (AmbiguousBaseConvID) {
3188 Paths.setRecordingPaths(
true);
3190 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
3199 Diag(Loc, AmbiguousBaseConvID)
3200 << Derived <<
Base << PathDisplayStr << Range << Name;
3209 bool IgnoreAccess) {
3211 Derived,
Base, diag::err_upcast_to_inaccessible_base,
3212 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
3213 BasePath, IgnoreAccess);
3230 std::string PathDisplayStr;
3231 std::set<unsigned> DisplayedPaths;
3233 Path != Paths.end(); ++Path) {
3234 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
3237 PathDisplayStr +=
"\n ";
3239 for (CXXBasePath::const_iterator Element = Path->begin();
3240 Element != Path->end(); ++Element)
3241 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
3245 return PathDisplayStr;
3256 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
3286 if (!OverloadedMethods.empty()) {
3287 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3288 Diag(OA->getLocation(),
3289 diag::override_keyword_hides_virtual_member_function)
3290 <<
"override" << (OverloadedMethods.size() > 1);
3291 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3292 Diag(FA->getLocation(),
3293 diag::override_keyword_hides_virtual_member_function)
3294 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3295 << (OverloadedMethods.size() > 1);
3306 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3307 Diag(OA->getLocation(),
3308 diag::override_keyword_only_allowed_on_virtual_member_functions)
3312 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3313 Diag(FA->getLocation(),
3314 diag::override_keyword_only_allowed_on_virtual_member_functions)
3315 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3327 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
3328 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
3348 auto EmitDiag = [&](
unsigned DiagInconsistent,
unsigned DiagSuggest) {
3357 if (isa<CXXDestructorDecl>(MD))
3359 diag::warn_inconsistent_destructor_marked_not_override_overriding,
3360 diag::warn_suggest_destructor_marked_not_override_overriding);
3362 EmitDiag(diag::warn_inconsistent_function_marked_not_override_overriding,
3363 diag::warn_suggest_function_marked_not_override_overriding);
3372 FinalAttr *FA = Old->
getAttr<FinalAttr>();
3378 << FA->isSpelledAsSealed();
3387 return !RD->isCompleteDefinition() ||
3388 !RD->hasTrivialDefaultConstructor() ||
3389 !RD->hasTrivialDestructor();
3402 std::map<CXXRecordDecl*, NamedDecl*> Bases;
3405 const auto Base =
Specifier->getType()->getAsCXXRecordDecl();
3407 if (Bases.find(
Base) != Bases.end())
3409 for (
const auto Field :
Base->lookup(FieldName)) {
3410 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
3413 assert(Bases.find(
Base) == Bases.end());
3426 for (
const auto &
P : Paths) {
3427 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
3428 auto It = Bases.find(
Base);
3430 if (It == Bases.end())
3432 auto BaseField = It->second;
3433 assert(BaseField->getAccess() !=
AS_private);
3436 Diag(Loc, diag::warn_shadow_field)
3437 << FieldName << RD <<
Base << DeclIsField;
3438 Diag(BaseField->getLocation(), diag::note_shadow_field);
3463 Expr *BitWidth =
static_cast<Expr*
>(BW);
3472 if (cast<CXXRecordDecl>(
CurContext)->isInterface()) {
3476 unsigned InvalidDecl;
3477 bool ShowDeclName =
true;
3487 else switch (Name.getNameKind()) {
3490 ShowDeclName =
false;
3495 ShowDeclName =
false;
3510 Diag(Loc, diag::err_invalid_member_in_interface)
3511 << (InvalidDecl-1) << Name;
3513 Diag(Loc, diag::err_invalid_member_in_interface)
3514 << (InvalidDecl-1) <<
"";
3540 diag::err_storageclass_invalid_for_member);
3560 const char *PrevSpec;
3565 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3569 const char *PrevSpec;
3575 "This is the only DeclSpec that should fail to be applied");
3579 isInstField =
false;
3589 if (!Name.isIdentifier()) {
3590 Diag(Loc, diag::err_bad_variable_name)
3599 if (TemplateParameterLists.size()) {
3601 if (TemplateParams->
size()) {
3610 diag::err_template_member_noparams)
3649 if (MSPropertyAttr) {
3651 BitWidth, InitStyle, AS, *MSPropertyAttr);
3654 isInstField =
false;
3657 BitWidth, InitStyle, AS);
3662 CheckShadowInheritedFields(Loc, Name, cast<CXXRecordDecl>(
CurContext));
3670 if (
Member->isInvalidDecl()) {
3672 }
else if (isa<VarDecl>(
Member) || isa<VarTemplateDecl>(
Member)) {
3675 Diag(Loc, diag::err_static_not_bitfield)
3677 }
else if (isa<TypedefDecl>(
Member)) {
3679 Diag(Loc, diag::err_typedef_not_bitfield)
3684 Diag(Loc, diag::err_not_integral_type_bitfield)
3685 << Name << cast<ValueDecl>(
Member)->getType()
3690 Member->setInvalidDecl();
3695 NonTemplateMember = FunTmpl->getTemplatedDecl();
3697 NonTemplateMember = VarTmpl->getTemplatedDecl();
3703 if (NonTemplateMember !=
Member)
3709 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3710 auto *TD = DG->getDeducedTemplate();
3713 if (AS != TD->getAccess() &&
3714 TD->getDeclContext()->getRedeclContext()->Equals(
3715 DG->getDeclContext()->getRedeclContext())) {
3716 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
3717 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
3720 for (
const auto *D : cast<CXXRecordDecl>(
CurContext)->decls()) {
3721 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(D))
3722 LastAccessSpec = AccessSpec;
3724 assert(LastAccessSpec &&
"differing access with no access specifier");
3725 Diag(LastAccessSpec->
getBeginLoc(), diag::note_deduction_guide_access)
3736 ? FinalAttr::Keyword_sealed
3737 : FinalAttr::Keyword_final));
3747 assert((Name || isInstField) &&
"No identifier for non-field ?");
3757 auto DeclHasUnusedAttr = [](
const QualType &T) {
3758 if (
const TagDecl *TD = T->getAsTagDecl())
3759 return TD->hasAttr<UnusedAttr>();
3761 return TDT->getDecl()->hasAttr<UnusedAttr>();
3769 !DeclHasUnusedAttr(FD->
getType()) &&
3779 class UninitializedFieldVisitor
3784 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3787 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3802 UninitializedFieldVisitor(
Sema &S,
3803 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3804 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3805 : Inherited(S.Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3806 Constructor(nullptr), InitList(
false), InitListFieldDecl(nullptr) {}
3809 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3810 bool CheckReferenceOnly) {
3812 bool ReferenceField =
false;
3817 Fields.push_back(FD);
3819 ReferenceField =
true;
3825 if (CheckReferenceOnly && !ReferenceField)
3831 for (
const FieldDecl *FD : llvm::drop_begin(llvm::reverse(Fields)))
3834 for (
auto UsedIter = UsedFieldIndex.begin(),
3835 UsedEnd = UsedFieldIndex.end(),
3836 OrigIter = InitFieldIndex.begin(),
3837 OrigEnd = InitFieldIndex.end();
3838 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3839 if (*UsedIter < *OrigIter)
3841 if (*UsedIter > *OrigIter)
3848 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3861 dyn_cast<MemberExpr>(
Base->IgnoreParenImpCasts())) {
3863 if (isa<VarDecl>(SubME->getMemberDecl()))
3866 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3871 AllPODFields =
false;
3873 Base = SubME->getBase();
3876 if (!isa<CXXThisExpr>(
Base->IgnoreParenImpCasts())) {
3881 if (AddressOf && AllPODFields)
3887 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3888 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
3891 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3901 if (!Decls.count(FoundVD))
3906 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3908 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3913 if (CheckReferenceOnly && !IsReference)
3917 unsigned diag = IsReference
3918 ? diag::warn_reference_field_is_uninit
3919 : diag::warn_field_is_uninit;
3923 diag::note_uninit_in_this_constructor)
3928 void HandleValue(
Expr *E,
bool AddressOf) {
3931 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3932 HandleMemberExpr(ME,
false ,
3938 Visit(CO->getCond());
3939 HandleValue(CO->getTrueExpr(), AddressOf);
3940 HandleValue(CO->getFalseExpr(), AddressOf);
3945 dyn_cast<BinaryConditionalOperator>(E)) {
3946 Visit(BCO->getCond());
3947 HandleValue(BCO->getFalseExpr(), AddressOf);
3952 HandleValue(OVE->getSourceExpr(), AddressOf);
3957 switch (BO->getOpcode()) {
3962 HandleValue(BO->getLHS(), AddressOf);
3963 Visit(BO->getRHS());
3966 Visit(BO->getLHS());
3967 HandleValue(BO->getRHS(), AddressOf);
3976 InitFieldIndex.push_back(0);
3977 for (
auto *Child : ILE->
children()) {
3978 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3979 CheckInitListExpr(SubList);
3983 ++InitFieldIndex.back();
3985 InitFieldIndex.pop_back();
3994 DeclsToRemove.clear();
4001 InitListFieldDecl =
Field;
4002 InitFieldIndex.clear();
4003 CheckInitListExpr(ILE);
4017 HandleMemberExpr(ME,
true ,
false );
4026 Inherited::VisitImplicitCastExpr(E);
4032 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
4036 if (ICE->getCastKind() == CK_NoOp)
4037 ArgExpr = ICE->getSubExpr();
4038 HandleValue(ArgExpr,
false );
4041 Inherited::VisitCXXConstructExpr(E);
4046 if (isa<MemberExpr>(Callee)) {
4047 HandleValue(Callee,
false );
4053 Inherited::VisitCXXMemberCallExpr(E);
4059 HandleValue(E->
getArg(0),
false);
4063 Inherited::VisitCallExpr(E);
4069 if (isa<UnresolvedLookupExpr>(Callee))
4070 return Inherited::VisitCXXOperatorCallExpr(E);
4074 HandleValue(Arg->IgnoreParenImpCasts(),
false );
4084 DeclsToRemove.push_back(FD);
4087 HandleValue(E->
getLHS(),
false );
4092 Inherited::VisitBinaryOperator(E);
4102 HandleValue(ME->
getBase(),
true );
4107 Inherited::VisitUnaryOperator(E);
4117 static void DiagnoseUninitializedFields(
4137 for (
auto *I : RD->
decls()) {
4138 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
4139 UninitializedFields.insert(FD);
4140 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
4141 UninitializedFields.insert(IFD->getAnonField());
4146 for (
const auto &I : RD->
bases())
4147 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
4149 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
4152 UninitializedFieldVisitor UninitializedChecker(SemaRef,
4153 UninitializedFields,
4154 UninitializedBaseClasses);
4156 for (
const auto *FieldInit :
Constructor->inits()) {
4157 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
4160 Expr *InitExpr = FieldInit->getInit();
4165 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
4166 InitExpr =
Default->getExpr();
4170 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
4171 FieldInit->getAnyMember(),
4172 FieldInit->getBaseClass());
4174 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
4175 FieldInit->getAnyMember(),
4176 FieldInit->getBaseClass());
4199 auto *ParamDecl = cast<NamedDecl>(Param.Param);
4200 if (ParamDecl->getDeclName())
4221 return ConstraintExpr;
4236 return Seq.Perform(*
this, Entity, Kind, InitExpr);
4250 "must set init style when field is created");
4267 assert(
Init.isUsable() &&
"Init should at least have a RecoveryExpr");
4273 if (!
Init.isInvalid())
4275 if (
Init.isInvalid()) {
4293 DirectBaseSpec =
nullptr;
4294 for (
const auto &
Base : ClassDecl->
bases()) {
4298 DirectBaseSpec = &
Base;
4306 VirtualBaseSpec =
nullptr;
4307 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
4316 Path != Paths.end(); ++Path) {
4317 if (Path->back().Base->isVirtual()) {
4318 VirtualBaseSpec = Path->back().Base;
4325 return DirectBaseSpec || VirtualBaseSpec;
4340 DS, IdLoc, InitList,
4359 DS, IdLoc, List, EllipsisLoc);
4368 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
4369 : ClassDecl(ClassDecl) {}
4371 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4374 return Member->getDeclContext()->getRedeclContext()->Equals(ClassDecl);
4375 return isa<TypeDecl>(ND);
4380 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
4381 return std::make_unique<MemInitializerValidatorCCC>(*
this);
4396 return isa<FieldDecl, IndirectFieldDecl>(Elem) &&
4400 if (Found ==
Result.end())
4402 Diag(Loc, diag::err_using_placeholder_variable) << Name;
4407 if (isa<FieldDecl, IndirectFieldDecl>(ND) &&
4418 for (
auto *D : ClassDecl->
lookup(MemberOrBase)) {
4419 if (isa<FieldDecl, IndirectFieldDecl>(D)) {
4422 if (IsPlaceholder && D->getDeclContext() == ND->
getDeclContext())
4427 return cast<ValueDecl>(D);
4428 ND = cast<ValueDecl>(D);
4466 = dyn_cast<CXXConstructorDecl>(ConstructorD);
4490 ClassDecl, SS, TemplateTypeTy, MemberOrBase)) {
4492 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
4502 if (TemplateTypeTy) {
4527 bool NotUnknownSpecialization =
false;
4530 NotUnknownSpecialization = !
Record->hasAnyDependentBases();
4532 if (!NotUnknownSpecialization) {
4557 auto *TempSpec = cast<TemplateSpecializationType>(
4558 UnqualifiedBase->getInjectedClassNameSpecialization());
4560 for (
auto const &
Base : ClassDecl->
bases()) {
4564 BaseTemplate->getTemplateName(), TN)) {
4565 Diag(IdLoc, diag::ext_unqualified_base_class)
4567 BaseType =
Base.getType();
4576 MemInitializerValidatorCCC CCC(ClassDecl);
4585 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4586 << MemberOrBase <<
true);
4593 DirectBaseSpec, VirtualBaseSpec)) {
4598 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4599 << MemberOrBase <<
false,
4612 if (!TyD && BaseType.
isNull()) {
4613 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
4614 << MemberOrBase <<
SourceRange(IdLoc,
Init->getSourceRange().getEnd());
4642 assert((DirectMember || IndirectMember) &&
4643 "Member must be a FieldDecl or IndirectFieldDecl");
4648 if (
Member->isInvalidDecl())
4653 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4655 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
4663 if (
Member->getType()->isDependentType() ||
Init->isTypeDependent()) {
4668 bool InitList =
false;
4669 if (isa<InitListExpr>(
Init)) {
4681 IdLoc,
Init->getBeginLoc(),
Init->getEndLoc())
4725 return Diag(NameLoc, diag::err_delegating_ctor)
4727 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4729 bool InitList =
true;
4733 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4742 NameLoc,
Init->getBeginLoc(),
Init->getEndLoc())
4750 cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor()) &&
4751 "Delegating constructor with no target?");
4757 DelegationInit.
get(), InitRange.
getBegin(),
false);
4775 DelegationInit =
Init;
4790 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4810 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4839 if (!DirectBaseSpec && !VirtualBaseSpec) {
4848 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4860 InitRange.
getEnd(), EllipsisLoc);
4867 if (DirectBaseSpec && VirtualBaseSpec)
4868 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4873 BaseSpec = VirtualBaseSpec;
4876 bool InitList =
true;
4880 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4920 InitRange.
getEnd(), EllipsisLoc);
4930 TargetType, ExprLoc);
4950 bool IsInheritedVirtualBase,
4954 IsInheritedVirtualBase);
4958 switch (ImplicitInitKind) {
4964 BaseInit = InitSeq.
Perform(SemaRef, InitEntity, InitKind, std::nullopt);
4970 bool Moving = ImplicitInitKind ==
IIK_Move;
4971 ParmVarDecl *Param = Constructor->getParamDecl(0);
4977 Constructor->getLocation(), ParamType,
4992 BasePath.push_back(BaseSpec);
4994 CK_UncheckedDerivedToBase,
5002 BaseInit = InitSeq.
Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
5025 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
5034 if (Field->isInvalidDecl())
5040 bool Moving = ImplicitInitKind ==
IIK_Move;
5041 ParmVarDecl *Param = Constructor->getParamDecl(0);
5045 if (Field->isZeroLengthBitField(SemaRef.
Context))
5048 Expr *MemberExprBase =
5061 LookupResult MemberLookup(SemaRef, Field->getDeclName(), Loc,
5063 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
5099 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
5114 "Unhandled implicit init kind!");
5130 InitSeq.
Perform(SemaRef, InitEntity, InitKind, std::nullopt);
5150 if (!Field->getParent()->isUnion()) {
5152 SemaRef.
Diag(Constructor->getLocation(),
5153 diag::err_uninitialized_member_in_ctor)
5154 << (
int)Constructor->isImplicit()
5156 << 0 << Field->getDeclName();
5157 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
5162 SemaRef.
Diag(Constructor->getLocation(),
5163 diag::err_uninitialized_member_in_ctor)
5164 << (
int)Constructor->isImplicit()
5166 << 1 << Field->getDeclName();
5167 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
5184 CXXMemberInit =
nullptr;
5189struct BaseAndFieldInfo {
5192 bool AnyErrorsInInits;
5194 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
5196 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
5199 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
5211 bool isImplicitCopyOrMove()
const {
5222 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
5226 AllToInit.push_back(
Init);
5235 bool isInactiveUnionMember(
FieldDecl *Field) {
5241 ActiveUnionMember.lookup(
Record->getCanonicalDecl()))
5242 return Active !=
Field->getCanonicalDecl();
5245 if (isImplicitCopyOrMove())
5250 if (
Field->hasInClassInitializer())
5254 if (!
Field->isAnonymousStructOrUnion())
5263 bool isWithinInactiveUnionMember(
FieldDecl *Field,
5266 return isInactiveUnionMember(Field);
5268 for (
auto *
C : Indirect->
chain()) {
5270 if (Field && isInactiveUnionMember(Field))
5285 if (!ArrayT->getSize())
5288 T = ArrayT->getElementType();
5297 if (Field->isInvalidDecl())
5302 Info.AllBaseFields.lookup(Field->getCanonicalDecl()))
5303 return Info.addFieldInitializer(
Init);
5317 if (Info.isWithinInactiveUnionMember(Field, Indirect))
5320 if (Field->hasInClassInitializer() && !Info.isImplicitCopyOrMove()) {
5338 return Info.addFieldInitializer(
Init);
5348 if (Info.AnyErrorsInInits)
5359 return Info.addFieldInitializer(
Init);
5366 Constructor->setNumCtorInitializers(1);
5370 Constructor->setCtorInitializers(initializer);
5379 DiagnoseUninitializedFields(*
this, Constructor);
5386 if (Constructor->isDependentContext()) {
5389 if (!Initializers.empty()) {
5390 Constructor->setNumCtorInitializers(Initializers.size());
5393 memcpy(baseOrMemberInitializers, Initializers.data(),
5395 Constructor->setCtorInitializers(baseOrMemberInitializers);
5400 Constructor->setInvalidDecl();
5405 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
5409 CXXRecordDecl *ClassDecl = Constructor->getParent()->getDefinition();
5413 bool HadError =
false;
5415 for (
unsigned i = 0; i < Initializers.size(); i++) {
5418 if (
Member->isBaseInitializer())
5421 Info.AllBaseFields[
Member->getAnyMember()->getCanonicalDecl()] =
Member;
5424 for (
auto *
C : F->chain()) {
5427 Info.ActiveUnionMember.insert(std::make_pair(
5432 Info.ActiveUnionMember.insert(std::make_pair(
5440 for (
auto &I : ClassDecl->
bases()) {
5442 DirectVBases.insert(&I);
5446 for (
auto &VBase : ClassDecl->
vbases()) {
5448 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
5456 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
5457 << VBase.getType() << ClassDecl;
5461 Info.AllToInit.push_back(
Value);
5462 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
5467 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
5470 &VBase, IsInheritedVirtualBase,
5476 Info.AllToInit.push_back(CXXBaseInit);
5483 if (
Base.isVirtual())
5487 = Info.AllBaseFields.lookup(
Base.getType()->getAs<
RecordType>())) {
5488 Info.AllToInit.push_back(
Value);
5489 }
else if (!AnyErrors) {
5498 Info.AllToInit.push_back(CXXBaseInit);
5503 for (
auto *Mem : ClassDecl->
decls()) {
5504 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
5509 if (F->isUnnamedBitfield())
5515 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
5524 if (Info.isImplicitCopyOrMove())
5527 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
5528 if (F->getType()->isIncompleteArrayType()) {
5530 "Incomplete array type is not valid");
5542 unsigned NumInitializers = Info.AllToInit.size();
5543 if (NumInitializers > 0) {
5544 Constructor->setNumCtorInitializers(NumInitializers);
5547 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
5549 Constructor->setCtorInitializers(baseOrMemberInitializers);
5554 Constructor->getParent());
5564 for (
auto *Field : RD->
fields())
5569 IdealInits.push_back(Field->getCanonicalDecl());
5578 if (!
Member->isAnyMemberInitializer())
5581 return Member->getAnyMember()->getCanonicalDecl();
5587 if (
Previous->isAnyMemberInitializer())
5592 if (Current->isAnyMemberInitializer())
5593 Diag << 0 << Current->getAnyMember();
5595 Diag << 1 << Current->getTypeSourceInfo()->getType();
5601 if (Constructor->getDeclContext()->isDependentContext())
5606 bool ShouldCheckOrder =
false;
5607 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5609 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
5610 Init->getSourceLocation())) {
5611 ShouldCheckOrder =
true;
5615 if (!ShouldCheckOrder)
5626 for (
const auto &VBase : ClassDecl->
vbases())
5630 for (
const auto &
Base : ClassDecl->
bases()) {
5631 if (
Base.isVirtual())
5637 for (
auto *Field : ClassDecl->
fields()) {
5638 if (Field->isUnnamedBitfield())
5644 unsigned NumIdealInits = IdealInitKeys.size();
5645 unsigned IdealIndex = 0;
5654 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5659 for (; IdealIndex != NumIdealInits; ++IdealIndex)
5660 if (InitKey == IdealInitKeys[IdealIndex])
5666 if (IdealIndex == NumIdealInits && InitIndex) {
5667 WarnIndexes.push_back(InitIndex);
5670 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
5671 if (InitKey == IdealInitKeys[IdealIndex])
5674 assert(IdealIndex < NumIdealInits &&
5675 "initializer not found in initializer list");
5677 CorrelatedInitOrder.emplace_back(IdealIndex, InitIndex);
5680 if (WarnIndexes.empty())
5684 llvm::sort(CorrelatedInitOrder, llvm::less_first());
5690 Inits[WarnIndexes.front() - 1]->getSourceLocation(),
5691 WarnIndexes.size() == 1 ? diag::warn_initializer_out_of_order
5692 : diag::warn_some_initializers_out_of_order);
5694 for (
unsigned I = 0; I < CorrelatedInitOrder.size(); ++I) {
5695 if (CorrelatedInitOrder[I].second == I)
5701 Inits[I]->getSourceRange(),
5704 Inits[CorrelatedInitOrder[I].second]->getSourceRange()),
5710 if (WarnIndexes.size() == 1) {
5712 Inits[WarnIndexes.front()]);
5718 for (
unsigned WarnIndex : WarnIndexes) {
5721 diag::note_initializer_out_of_order);
5728bool CheckRedundantInit(
Sema &S,
5738 diag::err_multiple_mem_initialization)
5739 <<
Field->getDeclName()
5740 <<
Init->getSourceRange();
5742 const Type *BaseClass =
Init->getBaseClass();
5743 assert(BaseClass &&
"neither field nor base");
5745 diag::err_multiple_base_initialization)
5747 <<
Init->getSourceRange();
5755typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5756typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5758bool CheckRedundantUnionInit(
Sema &S,
5760 RedundantUnionMap &Unions) {
5765 while (
Parent->isAnonymousStructOrUnion() ||
Parent->isUnion()) {
5767 UnionEntry &En = Unions[
Parent];
5768 if (En.first && En.first != Child) {
5770 diag::err_multiple_mem_union_initialization)
5771 <<
Field->getDeclName()
5772 <<
Init->getSourceRange();
5773 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5774 << 0 << En.second->getSourceRange();
5781 if (!
Parent->isAnonymousStructOrUnion())
5798 if (!ConstructorDecl)
5804 = dyn_cast<CXXConstructorDecl>(ConstructorDecl);
5807 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5814 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5817 RedundantUnionMap MemberUnions;
5819 bool HadError =
false;
5820 for (
unsigned i = 0; i < MemInits.size(); i++) {
5824 Init->setSourceOrder(i);
5826 if (
Init->isAnyMemberInitializer()) {
5828 if (CheckRedundantInit(*
this,
Init, Members[Key]) ||
5829 CheckRedundantUnionInit(*
this,
Init, MemberUnions))
5831 }
else if (
Init->isBaseInitializer()) {
5833 if (CheckRedundantInit(*
this,
Init, Members[Key]))
5836 assert(
Init->isDelegatingInitializer());
5838 if (MemInits.size() != 1) {
5840 diag::err_delegating_initializer_alone)
5841 <<
Init->getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5857 DiagnoseUninitializedFields(*
this, Constructor);
5874 for (
auto *Field : ClassDecl->
fields()) {
5875 if (Field->isInvalidDecl())
5902 PDiag(diag::err_access_dtor_field)
5903 << Field->getDeclName()
5912 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5919 if (Dtor && Dtor->
isUsed())
5920 VisitVirtualBases =
false;
5926 for (
const auto &
Base : ClassDecl->
bases()) {
5932 if (
Base.isVirtual()) {
5933 if (!VisitVirtualBases)
5935 DirectVirtualBases.insert(RT);
5952 PDiag(diag::err_access_dtor_base)
5953 <<
Base.getType() <<
Base.getSourceRange(),
5960 if (VisitVirtualBases)
5962 &DirectVirtualBases);
5967 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases) {
5969 for (
const auto &VBase : ClassDecl->
vbases()) {
5974 if (DirectVirtualBases && DirectVirtualBases->count(RT))
5990 PDiag(diag::err_access_dtor_vbase)
5996 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
6010 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
6016 DiagnoseUninitializedFields(*
this, Constructor);
6071 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
6072 MEnd = FinalOverriders.end();
6076 SOEnd = M->second.end();
6077 SO != SOEnd; ++SO) {
6084 if (SO->second.size() != 1)
6087 if (!SO->second.front().Method->isPureVirtual())
6090 if (!SeenPureMethods.insert(SO->second.front().Method).second)
6093 Diag(SO->second.front().Method->getLocation(),
6094 diag::note_pure_virtual_function)
6095 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
6105struct AbstractUsageInfo {
6113 AbstractType(S.Context.getCanonicalType(
6114 S.Context.getTypeDeclType(
Record))),
6117 void DiagnoseAbstractType() {
6126struct CheckAbstractUsage {
6127 AbstractUsageInfo &Info;
6130 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
6131 : Info(Info), Ctx(Ctx) {}
6135#define ABSTRACT_TYPELOC(CLASS, PARENT)
6136#define TYPELOC(CLASS, PARENT) \
6137 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break;
6138#include "clang/AST/TypeLocNodes.def"
6144 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
6159 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
6169#define CheckPolymorphic(Type) \
6170 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \
6171 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \
6186 return Visit(Next, Sel);
6196 T = Info.S.Context.getBaseElementType(T);
6199 if (CT != Info.AbstractType)
return;
6204 Info.S.Diag(Ctx->
getLocation(), diag::err_array_of_abstract_type)
6207 Info.S.Diag(Ctx->
getLocation(), diag::err_abstract_type_in_decl)
6210 Info.DiagnoseAbstractType();
6216 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
6251 for (
auto *D : RD->
decls()) {
6252 if (D->isImplicit())
continue;
6255 if (
auto *FD = dyn_cast<FriendDecl>(D)) {
6256 D = FD->getFriendDecl();
6261 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
6263 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D)) {
6267 }
else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
6270 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
6272 }
else if (
auto *VTD = dyn_cast<VarTemplateDecl>(D)) {
6276 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6278 }
else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(D)) {
6289 assert(ClassAttr->
getKind() == attr::DLLExport);
6299 struct MarkingClassDllexported {
6310 ~MarkingClassDllexported() {
6320 if (!
Member->hasAttr<DLLExportAttr>())
6325 auto *VD = dyn_cast<VarDecl>(
Member);
6326 if (VD && VD->getStorageClass() ==
SC_Static &&
6330 auto *MD = dyn_cast<CXXMethodDecl>(
Member);
6334 if (MD->isUserProvided()) {
6344 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6354 }
else if (MD->isExplicitlyDefaulted()) {
6363 }
else if (!MD->isTrivial() ||
6364 MD->isCopyAssignmentOperator() ||
6365 MD->isMoveAssignmentOperator()) {
6389 auto *CD = dyn_cast<CXXConstructorDecl>(
Member);
6390 if (!CD || !CD->isDefaultConstructor())
6392 auto *
Attr = CD->getAttr<DLLExportAttr>();
6398 if (!
Class->isDependentContext()) {
6405 if (LastExportedDefaultCtor) {
6407 diag::err_attribute_dll_ambiguous_default_ctor)
6409 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
6410 << CD->getDeclName();
6413 LastExportedDefaultCtor = CD;
6419 bool ErrorReported =
false;
6420 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6424 S.
Diag(TD->getLocation(),
6425 diag::err_cuda_device_builtin_surftex_cls_template)
6427 ErrorReported =
true;
6432 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(
Class);
6435 diag::err_cuda_device_builtin_surftex_ref_decl)
6438 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6442 TD = SD->getSpecializedTemplate();
6446 unsigned N = Params->
size();
6449 reportIllegalClassTemplate(S, TD);
6451 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6454 if (N > 0 && !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
6455 reportIllegalClassTemplate(S, TD);
6457 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6461 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6462 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6463 reportIllegalClassTemplate(S, TD);
6465 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6473 bool ErrorReported =
false;
6474 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6478 S.
Diag(TD->getLocation(),
6479 diag::err_cuda_device_builtin_surftex_cls_template)
6481 ErrorReported =
true;
6486 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(
Class);
6489 diag::err_cuda_device_builtin_surftex_ref_decl)
6492 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6496 TD = SD->getSpecializedTemplate();
6500 unsigned N = Params->
size();
6503 reportIllegalClassTemplate(S, TD);
6505 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6508 if (N > 0 && !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
6509 reportIllegalClassTemplate(S, TD);
6511 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6515 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6516 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6517 reportIllegalClassTemplate(S, TD);
6519 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6524 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(2));
6525 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6526 reportIllegalClassTemplate(S, TD);
6528 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6536 for (
auto *Method :
Class->methods()) {
6537 if (Method->isUserProvided())
6550 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(
Class)) {
6551 if (
Attr *TemplateAttr =
6552 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
6553 auto *A = cast<InheritableAttr>(TemplateAttr->clone(
getASTContext()));
6554 A->setInherited(
true);
6569 (!
Class->isExternallyVisible() &&
Class->hasExternalFormalLinkage())) {
6570 Class->dropAttrs<DLLExportAttr, DLLImportAttr>();
6574 if (!
Class->isExternallyVisible()) {
6575 Diag(
Class->getLocation(), diag::err_attribute_dll_not_extern)
6576 <<
Class << ClassAttr;
6584 if (!isa<VarDecl>(
Member) && !isa<CXXMethodDecl>(
Member))
6591 diag::err_attribute_dll_member_of_dll_class)
6592 << MemberAttr << ClassAttr;
6593 Diag(ClassAttr->getLocation(), diag::note_previous_attribute);
6594 Member->setInvalidDecl();
6598 if (
Class->getDescribedClassTemplate())
6603 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
6608 const bool PropagatedImport =
6610 cast<DLLImportAttr>(ClassAttr)->wasPropagatedToBaseTemplate();
6619 Class->dropAttr<DLLExportAttr>();
6653 auto *Ctor = dyn_cast<CXXConstructorDecl>(MD);
6662 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->
isTrivial())
6669 if (VD && PropagatedImport)
6683 if (ClassExported) {
6695 Member->addAttr(NewAttr);
6705 "friend re-decl should not already have a DLLAttr");
6737 NewAttr->setInherited(
true);
6738 BaseTemplateSpec->
addAttr(NewAttr);
6742 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
6743 ImportAttr->setPropagatedToBaseTemplate();
6764 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
6769 diag::note_template_class_explicit_specialization_was_here)
6770 << BaseTemplateSpec;
6773 diag::note_template_class_instantiation_was_here)
6774 << BaseTemplateSpec;
6787 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
6799 if (MD->isCopyAssignmentOperator())
6802 if (MD->isMoveAssignmentOperator())
6805 if (isa<CXXDestructorDecl>(FD))
6813 case OO_ExclaimEqual:
6825 case OO_GreaterEqual:
6848 cast<CXXConstructorDecl>(FD));
6866 llvm_unreachable(
"Invalid special member.");
6884 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
6885 bool DtorIsTrivialForCall =
false;
6896 CopyCtorIsTrivial =
true;
6898 CopyCtorIsTrivialForCall =
true;
6902 if (CD->isCopyConstructor() && !CD->isDeleted() &&
6903 !CD->isIneligibleOrNotSelected()) {
6904 if (CD->isTrivial())
6905 CopyCtorIsTrivial =
true;
6906 if (CD->isTrivialForCall())
6907 CopyCtorIsTrivialForCall =
true;
6915 DtorIsTrivialForCall =
true;
6917 if (!DD->isDeleted() && DD->isTrivialForCall())
6918 DtorIsTrivialForCall =
true;
6922 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
6936 uint64_t TypeSize = isAArch64 ? 128 : 64;
6938 if (CopyCtorIsTrivial &&
6948 bool HasNonDeletedCopyOrMove =
false;
6954 HasNonDeletedCopyOrMove =
true;
6961 HasNonDeletedCopyOrMove =
true;
6969 if (MD->isDeleted() || MD->isIneligibleOrNotSelected())
6972 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6973 if (CD && CD->isCopyOrMoveConstructor())
6974 HasNonDeletedCopyOrMove =
true;
6975 else if (!isa<CXXDestructorDecl>(MD))
6978 if (!MD->isTrivialForCall())
6982 return HasNonDeletedCopyOrMove;
6993 bool IssuedDiagnostic =
false;
6996 if (!IssuedDiagnostic) {
6998 IssuedDiagnostic =
true;
7000 S.
Diag(O->getLocation(), diag::note_overridden_virtual_function);
7003 return IssuedDiagnostic;
7017 if (
Record->isAbstract() && !
Record->isInvalidDecl()) {
7018 AbstractUsageInfo Info(*
this,
Record);
7025 if (!
Record->isInvalidDecl() && !
Record->isDependentType() &&
7026 !
Record->isAggregate() && !
Record->hasUserDeclaredConstructor() &&
7028 bool Complained =
false;
7029 for (
const auto *F :
Record->fields()) {
7030 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
7033 if (F->getType()->isReferenceType() ||
7034 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
7036 Diag(
Record->getLocation(), diag::warn_no_constructor_for_refconst)
7037 << llvm::to_underlying(
Record->getTagKind()) <<
Record;
7041 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
7042 << F->getType()->isReferenceType()
7043 << F->getDeclName();
7048 if (
Record->getIdentifier()) {
7061 if (((isa<FieldDecl>(D) || isa<UnresolvedUsingValueDecl>(D)) &&
7062 Record->hasUserDeclaredConstructor()) ||
7063 isa<IndirectFieldDecl>(D)) {
7064 Diag((*I)->getLocation(), diag::err_member_name_of_class)
7072 if (
Record->isPolymorphic() && !
Record->isDependentType()) {
7075 !
Record->hasAttr<FinalAttr>())
7080 if (
Record->isAbstract()) {
7081 if (FinalAttr *FA =
Record->getAttr<FinalAttr>()) {
7082 Diag(
Record->getLocation(), diag::warn_abstract_final_class)
7083 << FA->isSpelledAsSealed();
7089 if (!
Record->hasAttr<FinalAttr>()) {
7091 if (
const FinalAttr *FA = dtor->getAttr<FinalAttr>()) {
7092 Diag(FA->getLocation(), diag::warn_final_dtor_non_final_class)
7093 << FA->isSpelledAsSealed()
7096 (FA->isSpelledAsSealed() ?
" sealed" :
" final"));
7098 diag::note_final_dtor_non_final_class_silence)
7105 if (
Record->hasAttr<TrivialABIAttr>())
7110 bool HasTrivialABI =
Record->hasAttr<TrivialABIAttr>();
7113 Record->setHasTrivialSpecialMemberForCall();
7123 auto CheckCompletedMemberFunction = [&](
CXXMethodDecl *MD) {
7134 MD->
isDeleted() ? diag::err_deleted_override
7135 : diag::err_non_deleted_override,
7139 if (MD->isDefaulted() && MD->isDeleted())
7148 MD->isConsteval() ? diag::err_consteval_override
7149 : diag::err_non_consteval_override,
7151 return MD->isConsteval() !=
V->isConsteval();
7153 if (MD->isDefaulted() && MD->isDeleted())
7160 auto CheckForDefaultedFunction = [&](
FunctionDecl *FD) ->
bool {
7161 if (!FD || FD->
isInvalidDecl() || !FD->isExplicitlyDefaulted())
7167 DefaultedSecondaryComparisons.push_back(FD);
7177 bool Incomplete = CheckForDefaultedFunction(M);
7180 if (
Record->isDependentType())
7186 if (!M->isImplicit() && !M->isUserProvided()) {
7190 Record->finishedDefaultedOrDeletedMember(M);
7191 M->setTrivialForCall(
7194 Record->setTrivialForCallFlags(M);
7202 M->setTrivialForCall(HasTrivialABI);
7203 Record->setTrivialForCallFlags(M);
7206 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
7207 M->hasAttr<DLLExportAttr>()) {
7212 M->dropAttr<DLLExportAttr>();
7214 if (M->hasAttr<DLLExportAttr>()) {
7223 if (CSM !=
CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
7224 M->isConstexpr() && M->size_overridden_methods())
7228 CheckCompletedMemberFunction(M);
7237 CompleteMemberFunction(Dtor);
7239 bool HasMethodWithOverrideControl =
false,
7240 HasOverridingMethodWithoutOverrideControl =
false;
7241 for (
auto *D :
Record->decls()) {
7242 if (
auto *M = dyn_cast<CXXMethodDecl>(D)) {
7245 if (!
Record->isDependentType()) {
7250 if (M->hasAttr<OverrideAttr>())
7251 HasMethodWithOverrideControl =
true;
7252 else if (M->size_overridden_methods() > 0)
7253 HasOverridingMethodWithoutOverrideControl =
true;
7256 if (!isa<CXXDestructorDecl>(M))
7257 CompleteMemberFunction(M);
7258 }
else if (
auto *F = dyn_cast<FriendDecl>(D)) {
7259 CheckForDefaultedFunction(
7260 dyn_cast_or_null<FunctionDecl>(F->getFriendDecl()));
7264 if (HasOverridingMethodWithoutOverrideControl) {
7265 bool HasInconsistentOverrideControl = HasMethodWithOverrideControl;
7266 for (
auto *M :
Record->methods())
7271 for (
FunctionDecl *FD : DefaultedSecondaryComparisons) {
7275 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD))
7276 CheckCompletedMemberFunction(MD);
7294 Diag(
Record->getLocation(), diag::warn_cxx_ms_struct);
7300 bool ClangABICompat4 =
7308 if (
Record->getArgPassingRestrictions() !=
7310 Record->setArgPassingRestrictions(
7319 Record->setParamDestroyedInCallee(
true);
7320 else if (
Record->hasNonTrivialDestructor())
7321 Record->setParamDestroyedInCallee(CanPass);
7330 if (
Record->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>())
7332 else if (
Record->hasAttr<CUDADeviceBuiltinTextureTypeAttr>())
7348 unsigned FieldQuals,
bool ConstRHS) {
7349 unsigned LHSQuals = 0;
7351 LHSQuals = FieldQuals;
7353 unsigned RHSQuals = FieldQuals;
7374 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
7380 : S(S), UseLoc(UseLoc) {
7381 bool DiagnosedMultipleConstructedBases =
false;
7387 for (
auto *D : Shadow->
redecls()) {
7388 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
7389 auto *DNominatedBase = DShadow->getNominatedBaseClass();
7390 auto *DConstructedBase = DShadow->getConstructedBaseClass();
7392 InheritedFromBases.insert(
7393 std::make_pair(DNominatedBase->getCanonicalDecl(),
7394 DShadow->getNominatedBaseClassShadowDecl()));
7395 if (DShadow->constructsVirtualBase())
7396 InheritedFromBases.insert(
7397 std::make_pair(DConstructedBase->getCanonicalDecl(),
7398 DShadow->getConstructedBaseClassShadowDecl()));
7400 assert(DNominatedBase == DConstructedBase);
7405 if (!ConstructedBase) {
7406 ConstructedBase = DConstructedBase;
7407 ConstructedBaseIntroducer = D->getIntroducer();
7408 }
else if (ConstructedBase != DConstructedBase &&
7410 if (!DiagnosedMultipleConstructedBases) {
7411 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
7414 diag::note_ambiguous_inherited_constructor_using)
7416 DiagnosedMultipleConstructedBases =
true;
7418 S.
Diag(D->getIntroducer()->getLocation(),
7419 diag::note_ambiguous_inherited_constructor_using)
7420 << DConstructedBase;
7424 if (DiagnosedMultipleConstructedBases)
7431 std::pair<CXXConstructorDecl *, bool>
7433 auto It = InheritedFromBases.find(
Base->getCanonicalDecl());
7434 if (It == InheritedFromBases.end())
7435 return std::make_pair(
nullptr,
false);
7439 return std::make_pair(
7441 It->second->constructsVirtualBase());
7444 return std::make_pair(Ctor,
false);
7463 if (InheritedCtor) {
7466 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
7468 return BaseCtor->isConstexpr();
7536 if (Ctor && ClassDecl->
isUnion())
7556 for (
const auto &B : ClassDecl->
bases()) {
7562 InheritedCtor, Inherited))
7575 for (
const auto *F : ClassDecl->
fields()) {
7576 if (F->isInvalidDecl())
7582 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
7585 ConstArg && !F->isMutable()))
7600struct ComputingExceptionSpec {
7611 ~ComputingExceptionSpec() {
7630 if (DFK.isSpecialMember())
7632 S, Loc, cast<CXXMethodDecl>(FD), DFK.asSpecialMember(),
nullptr);
7633 if (DFK.isComparison())
7635 DFK.asComparison());
7637 auto *CD = cast<CXXConstructorDecl>(FD);
7638 assert(CD->getInheritedConstructor() &&
7639 "only defaulted functions and inherited constructors have implicit "
7642 S, Loc, CD->getInheritedConstructor().getShadowDecl());
7669 auto ESI = IES.getExceptionSpec();
7701 "not an explicitly-defaulted special member");
7711 bool HadError =
false;
7724 bool ShouldDeleteForTypeMismatch =
false;
7725 unsigned ExpectedParams = 1;
7736 if (DeleteOnTypeMismatch)
7737 ShouldDeleteForTypeMismatch =
true;
7747 bool CanHaveConstParam =
false;
7756 ReturnType =
Type->getReturnType();
7767 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
7774 if (DeleteOnTypeMismatch)
7775 ShouldDeleteForTypeMismatch =
true;
7791 if (DeleteOnTypeMismatch)
7792 ShouldDeleteForTypeMismatch =
true;
7795 diag::err_defaulted_special_member_explicit_object_mismatch)
7807 bool HasConstParam =
false;
7814 if (DeleteOnTypeMismatch)
7815 ShouldDeleteForTypeMismatch =
true;
7818 diag::err_defaulted_special_member_volatile_param) << CSM;
7823 if (HasConstParam && !CanHaveConstParam) {
7824 if (DeleteOnTypeMismatch)
7825 ShouldDeleteForTypeMismatch =
true;
7828 diag::err_defaulted_special_member_copy_const_param)
7834 diag::err_defaulted_special_member_move_const_param)
7839 }
else if (ExpectedParams) {
7871 : isa<CXXConstructorDecl>(MD))) &&
7876 diag::err_incorrect_defaulted_constexpr_with_vb)
7878 for (
const auto &I : RD->
vbases())
7879 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here);
7898 if (!
Type->hasExceptionSpec()) {
7916 if (ShouldDeleteForTypeMismatch) {
7921 Diag(DefaultLoc, diag::note_replace_equals_default_to_delete)
7925 if (ShouldDeleteForTypeMismatch && !HadError) {
7927 diag::warn_cxx17_compat_defaulted_method_type_mismatch) << CSM;
7933 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
7934 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
7956template<
typename Derived,
typename ResultList,
typename Result,
7958class DefaultedComparisonVisitor {
7963 DefaultedComparisonKind DCK)
7964 : S(S), RD(RD), FD(FD), DCK(DCK) {
7968 Fns.assign(Info->getUnqualifiedLookups().begin(),
7969 Info->getUnqualifiedLookups().end());
7973 ResultList visit() {
7981 case DefaultedComparisonKind::None:
7982 llvm_unreachable(
"not a defaulted comparison");
7984 case DefaultedComparisonKind::Equal:
7985 case DefaultedComparisonKind::ThreeWay:
7986 getDerived().visitSubobjects(Results, RD, ParamLvalType.
getQualifiers());
7989 case DefaultedComparisonKind::NotEqual:
7990 case DefaultedComparisonKind::Relational:
7991 Results.add(getDerived().visitExpandedSubobject(
7992 ParamLvalType, getDerived().getCompleteObject()));
7995 llvm_unreachable(
"");
7999 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
8010 if (Results.add(getDerived().visitSubobject(
8012 getDerived().getBase(&
Base))))
8019 if (
Field->isUnnamedBitfield())
8022 if (
Field->isAnonymousStructOrUnion()) {
8023 if (visitSubobjects(Results,
Field->getType()->getAsCXXRecordDecl(),
8031 if (
Field->isMutable())
8036 if (Results.add(getDerived().visitSubobject(
8037 FieldType, getDerived().getField(Field))))
8045 Result visitSubobject(
QualType Type, Subobject Subobj) {
8048 if (
auto *CAT = dyn_cast_or_null<ConstantArrayType>(AT))
8049 return getDerived().visitSubobjectArray(CAT->getElementType(),
8050 CAT->getSize(), Subobj);
8051 return getDerived().visitExpandedSubobject(
Type, Subobj);
8054 Result visitSubobjectArray(
QualType Type,
const llvm::APInt &Size,
8056 return getDerived().visitSubobject(
Type, Subobj);
8063 DefaultedComparisonKind DCK;
8069struct DefaultedComparisonInfo {
8074 static DefaultedComparisonInfo deleted() {
8075 DefaultedComparisonInfo
Deleted;
8080 bool add(
const DefaultedComparisonInfo &R) {
8090struct DefaultedComparisonSubobject {
8098class DefaultedComparisonAnalyzer
8099 :
public DefaultedComparisonVisitor<DefaultedComparisonAnalyzer,
8100 DefaultedComparisonInfo,
8101 DefaultedComparisonInfo,
8102 DefaultedComparisonSubobject> {
8104 enum DiagnosticKind { NoDiagnostics, ExplainDeleted, ExplainConstexpr };
8107 DiagnosticKind Diagnose;
8110 using Base = DefaultedComparisonVisitor;
8111 using Result = DefaultedComparisonInfo;
8112 using Subobject = DefaultedComparisonSubobject;
8117 DefaultedComparisonKind DCK,
8118 DiagnosticKind Diagnose = NoDiagnostics)
8119 :
Base(S, RD, FD, DCK), Diagnose(Diagnose) {}
8122 if ((DCK == DefaultedComparisonKind::Equal ||
8123 DCK == DefaultedComparisonKind::ThreeWay) &&
8128 if (Diagnose == ExplainDeleted) {
8132 return Result::deleted();
8135 return Base::visit();
8139 Subobject getCompleteObject() {
8140 return Subobject{Subobject::CompleteObject, RD, FD->
getLocation()};
8144 return Subobject{Subobject::Base,
Base->getType()->getAsCXXRecordDecl(),
8145 Base->getBaseTypeLoc()};
8149 return Subobject{Subobject::Member,
Field,
Field->getLocation()};
8152 Result visitExpandedSubobject(
QualType Type, Subobject Subobj) {
8157 if (Diagnose == ExplainDeleted) {
8158 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_reference_member)
8161 return Result::deleted();
8166 Expr *Args[] = {&Xi, &Xi};
8170 assert(OO !=
OO_None &&
"not an overloaded operator!");
8171 return visitBinaryOperator(OO, Args, Subobj);
8185 !SpaceshipCandidates));
8190 CandidateSet.exclude(FD);
8192 if (Args[0]->getType()->isOverloadableType())
8203 switch (CandidateSet.BestViableFunction(S, FD->
getLocation(), Best)) {
8209 if ((DCK == DefaultedComparisonKind::NotEqual ||
8210 DCK == DefaultedComparisonKind::Relational) &&
8211 !Best->RewriteKind) {
8212 if (Diagnose == ExplainDeleted) {
8213 if (Best->Function) {
8214 S.
Diag(Best->Function->getLocation(),
8215 diag::note_defaulted_comparison_not_rewritten_callee)
8218 assert(Best->Conversions.size() == 2 &&
8219 Best->Conversions[0].isUserDefined() &&
8220 "non-user-defined conversion from class to built-in "
8222 S.
Diag(Best->Conversions[0]
8223 .UserDefined.FoundConversionFunction.getDecl()
8225 diag::note_defaulted_comparison_not_rewritten_conversion)
8229 return Result::deleted();
8239 CXXRecordDecl *ArgClass = Args[0]->getType()->getAsCXXRecordDecl();
8240 if (ArgClass && Best->FoundDecl.getDecl() &&
8241 Best->FoundDecl.getDecl()->isCXXClassMember()) {
8242 QualType ObjectType = Subobj.Kind == Subobject::Member
8243 ? Args[0]->getType()
8246 ArgClass, Best->FoundDecl, ObjectType, Subobj.Loc,
8247 Diagnose == ExplainDeleted
8248 ? S.
PDiag(diag::note_defaulted_comparison_inaccessible)
8249 << FD << Subobj.Kind << Subobj.Decl
8251 return Result::deleted();
8254 bool NeedsDeducing =
8262 assert(!BestFD->isDeleted() &&
"wrong overload resolution result");
8264 if (Diagnose == ExplainConstexpr && !BestFD->isConstexpr()) {
8265 if (Subobj.Kind != Subobject::CompleteObject)
8266 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_not_constexpr)
8267 << Subobj.
Kind << Subobj.Decl;
8268 S.
Diag(BestFD->getLocation(),
8269 diag::note_defaulted_comparison_not_constexpr_here);
8271 return Result::deleted();
8273 R.Constexpr &= BestFD->isConstexpr();
8275 if (NeedsDeducing) {
8280 if (BestFD->getReturnType()->isUndeducedType() &&
8286 if (Diagnose == NoDiagnostics) {
8289 diag::err_defaulted_comparison_cannot_deduce_undeduced_auto)
8290 << Subobj.
Kind << Subobj.Decl;
8293 diag::note_defaulted_comparison_cannot_deduce_undeduced_auto)
8294 << Subobj.
Kind << Subobj.Decl;
8295 S.
Diag(BestFD->getLocation(),
8296 diag::note_defaulted_comparison_cannot_deduce_callee)
8297 << Subobj.
Kind << Subobj.Decl;
8299 return Result::deleted();
8302 BestFD->getCallResultType());
8304 if (Diagnose == ExplainDeleted) {
8305 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_cannot_deduce)
8306 << Subobj.
Kind << Subobj.Decl
8307 << BestFD->getCallResultType().withoutLocalFastQualifiers();
8308 S.
Diag(BestFD->getLocation(),
8309 diag::note_defaulted_comparison_cannot_deduce_callee)
8310 << Subobj.
Kind << Subobj.Decl;
8312 return Result::deleted();
8314 R.Category = Info->Kind;
8317 QualType T = Best->BuiltinParamTypes[0];
8318 assert(T == Best->BuiltinParamTypes[1] &&
8319 "builtin comparison for different types?");
8320 assert(Best->BuiltinParamTypes[2].isNull() &&
8321 "invalid builtin comparison");
8323 if (NeedsDeducing) {
8324 std::optional<ComparisonCategoryType> Cat =
8326 assert(Cat &&
"no category for builtin comparison?");
8337 if (Diagnose == ExplainDeleted) {
8340 Kind = OO == OO_EqualEqual ? 1 : 2;
8341 CandidateSet.NoteCandidates(
8343 Subobj.Loc, S.
PDiag(diag::note_defaulted_comparison_ambiguous)
8344 << FD << Kind << Subobj.Kind << Subobj.Decl),
8347 R = Result::deleted();
8351 if (Diagnose == ExplainDeleted) {
8352 if ((DCK == DefaultedComparisonKind::NotEqual ||
8353 DCK == DefaultedComparisonKind::Relational) &&
8354 !Best->RewriteKind) {
8355 S.
Diag(Best->Function->getLocation(),
8356 diag::note_defaulted_comparison_not_rewritten_callee)
8360 diag::note_defaulted_comparison_calls_deleted)
8361 << FD << Subobj.
Kind << Subobj.Decl;
8365 R = Result::deleted();
8371 if (OO == OO_Spaceship &&
8375 if (!R.add(visitBinaryOperator(OO_EqualEqual, Args, Subobj,
8377 R.add(visitBinaryOperator(OO_Less, Args, Subobj, &CandidateSet));
8381 if (Diagnose == ExplainDeleted) {
8382 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_no_viable_function)
8383 << FD << (OO == OO_EqualEqual || OO == OO_ExclaimEqual)
8384 << Subobj.
Kind << Subobj.Decl;
8388 if (SpaceshipCandidates) {
8389 SpaceshipCandidates->NoteCandidates(
8394 diag::note_defaulted_comparison_no_viable_function_synthesized)
8395 << (OO == OO_EqualEqual ? 0 : 1);
8398 CandidateSet.NoteCandidates(
8403 R = Result::deleted();
8412struct StmtListResult {
8413 bool IsInvalid =
false;
8417 IsInvalid |= S.isInvalid();
8420 Stmts.push_back(S.get());
8427class DefaultedComparisonSynthesizer
8428 :
public DefaultedComparisonVisitor<DefaultedComparisonSynthesizer,
8429 StmtListResult, StmtResult,
8430 std::pair<ExprResult, ExprResult>> {
8432 unsigned ArrayDepth = 0;
8435 using Base = DefaultedComparisonVisitor;
8436 using ExprPair = std::pair<ExprResult, ExprResult>;
8441 DefaultedComparisonKind DCK,
8443 :
Base(S, RD, FD, DCK), Loc(BodyLoc) {}
8449 StmtListResult Stmts = visit();
8450 if (Stmts.IsInvalid)
8455 case DefaultedComparisonKind::None:
8456 llvm_unreachable(
"not a defaulted comparison");
8458 case DefaultedComparisonKind::Equal: {
8467 auto OldStmts = std::move(Stmts.Stmts);
8468 Stmts.Stmts.clear();
8471 auto FinishCmp = [&] {
8472 if (
Expr *Prior = CmpSoFar.
get()) {
8474 if (RetVal.
isUnset() && Stmts.Stmts.empty())
8477 else if (Stmts.add(buildIfNotCondReturnFalse(Prior)))
8483 for (
Stmt *EAsStmt : llvm::reverse(OldStmts)) {
8484 Expr *E = dyn_cast<Expr>(EAsStmt);
8487 if (FinishCmp() || Stmts.add(EAsStmt))
8502 std::reverse(Stmts.Stmts.begin(), Stmts.Stmts.end());
8509 case DefaultedComparisonKind::ThreeWay: {
8513 ComparisonCategoryType::StrongOrdering, Loc,
8514 Sema::ComparisonCategoryUsage::DefaultedOperator);
8520 RetVal = getDecl(EqualVD);
8523 RetVal = buildStaticCastToR(RetVal.
get());
8527 case DefaultedComparisonKind::NotEqual:
8528 case DefaultedComparisonKind::Relational:
8529 RetVal = cast<Expr>(Stmts.Stmts.pop_back_val());
8555 ExprPair getCompleteObject() {
8558 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD);
8565 LHS = getParam(Param++);
8573 ExprPair Obj = getCompleteObject();
8574 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8584 ExprPair Obj = getCompleteObject();
8585 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8608 assert(!False.
isInvalid() &&
"should never fail");
8613 return S.
ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc,
nullptr,
8615 Sema::ConditionKind::Boolean),
8628 llvm::raw_svector_ostream OS(Str);
8629 OS <<
"i" << ArrayDepth;
8640 auto IterRef = [&] {
8644 assert(!Ref.
isInvalid() &&
"can't reference our own variable?");
8650 Loc, BO_NE, IterRef(),
8652 assert(!Cond.
isInvalid() &&
"should never fail");
8656 assert(!
Inc.isInvalid() &&
"should never fail");
8664 Subobj.first = Index(Subobj.first);
8665 Subobj.second = Index(Subobj.second);
8678 if (
Expr *ElemCmp = dyn_cast<Expr>(Substmt.
get())) {
8679 assert(DCK == DefaultedComparisonKind::Equal &&
8680 "should have non-expression statement");
8681 Substmt = buildIfNotCondReturnFalse(ElemCmp);
8689 Sema::ConditionKind::Boolean),
8695 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8703 Obj.second.get(),
true,
8711 case DefaultedComparisonKind::None:
8712 llvm_unreachable(
"not a defaulted comparison");
8714 case DefaultedComparisonKind::Equal:
8722 case DefaultedComparisonKind::ThreeWay: {
8727 Op = buildStaticCastToR(Op.
get());
8752 if (
Comp.isInvalid())
8755 nullptr, Loc,
Comp.get(), Sema::ConditionKind::Boolean);
8760 VDRef = getDecl(VD);
8768 return S.
ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc, InitStmt, Cond,
8773 case DefaultedComparisonKind::NotEqual:
8774 case DefaultedComparisonKind::Relational:
8779 llvm_unreachable(
"");
8785 assert(!R->
isUndeducedType() &&
"type should have been deduced already");
8803 Self.LookupOverloadedOperatorName(OO, S, Operators);
8816 if (Op == OO_Spaceship) {
8817 Lookup(OO_ExclaimEqual);
8819 Lookup(OO_EqualEqual);
8846 bool IsMethod = isa<CXXMethodDecl>(FD);
8848 auto *MD = cast<CXXMethodDecl>(FD);
8849 assert(!MD->
isStatic() &&
"comparison function cannot be a static member");
8859 FPT->getParamTypes(), EPI));
8875 InsertLoc = Loc.getRParenLoc();
8880 Diag(Loc, diag::err_defaulted_comparison_non_const)
8889 FPT->getParamTypes(), EPI));
8900 FPT->getParamTypes(), EPI));
8906 (IsMethod ? 1 : 2)) {
8910 <<
int(IsMethod) <<
int(DCK);
8916 if (Param->isExplicitObjectParameter())
8918 QualType ParmTy = Param->getType();
8923 bool Ok = !IsMethod;
8928 CTy = Ref->getPointeeType();
8939 }
else if (
auto *CRD = CTy->getAsRecordDecl()) {
8940 RD = cast<CXXRecordDecl>(CRD);
8956 <<
int(DCK) << ParmTy << RefTy <<
int(!IsMethod) << PlainTy
8957 << Param->getSourceRange();
8959 assert(!IsMethod &&
"should know expected type for method");
8961 diag::err_defaulted_comparison_param_unknown)
8962 <<
int(DCK) << ParmTy << Param->getSourceRange();
8968 Diag(FD->
getLocation(), diag::err_defaulted_comparison_param_mismatch)
8970 << ParmTy << Param->getSourceRange();
8975 assert(RD &&
"must have determined class");
8984 diag::err_defaulted_comparison_not_friend,
int(DCK),
8989 return FD->getCanonicalDecl() ==
8990 F->getFriendDecl()->getCanonicalDecl();
8993 <<
int(DCK) <<
int(0) << RD;
9005 Diag(FD->
getLocation(), diag::err_defaulted_comparison_return_type_not_bool)
9015 RT->getContainedDeducedType() &&
9017 RT->getContainedAutoType()->isConstrained())) {
9019 diag::err_defaulted_comparison_deduced_return_type_not_auto)
9031 DefaultedComparisonInfo Info =
9032 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK).visit();
9046 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
9047 DefaultedComparisonAnalyzer::ExplainDeleted)
9058 diag::note_previous_declaration);
9070 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
9071 DefaultedComparisonAnalyzer::ExplainDeleted)
9121 Diag(FD->
getBeginLoc(), diag::err_defaulted_comparison_constexpr_mismatch)
9123 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
9124 DefaultedComparisonAnalyzer::ExplainConstexpr)
9145 EPI.ExceptionSpec.SourceDecl = FD;
9147 FPT->getParamTypes(), EPI));
9162 EqualEqual->setImplicit();
9177 Scope.addContextNote(UseLoc);
9184 CXXRecordDecl *RD = PT.getNonReferenceType()->getAsCXXRecordDecl();
9188 DefaultedComparisonSynthesizer(*
this, RD, FD, DCK, BodyLoc).build();
9202 L->CompletedImplicitDefinition(FD);
9209 ComputingExceptionSpec CES(S, FD, Loc);
9236 DefaultedComparisonSynthesizer(S, RD, FD, DCK, BodyLoc).build();
9258 for (
auto &Check : Overriding)
9270template<
typename Derived>
9271struct SpecialMemberVisitor {
9278 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
9282 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
9287 IsConstructor =
true;
9291 IsAssignment =
true;
9296 llvm_unreachable(
"invalid special member kind");
9302 ConstArg = RT->getPointeeType().isConstQualified();
9306 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
9309 bool isMove()
const {
9315 unsigned Quals,
bool IsMutable) {
9317 ConstArg && !IsMutable);
9327 cast<CXXConstructorDecl>(MD)->getInheritedConstructor().getConstructor();
9334 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
9341 return B->getBaseTypeLoc();
9343 return Subobj.get<
FieldDecl*>()->getLocation();
9348 VisitNonVirtualBases,
9353 VisitPotentiallyConstructedBases,
9359 bool visit(BasesToVisit Bases) {
9362 if (Bases == VisitPotentiallyConstructedBases)
9363 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
9365 for (
auto &B : RD->
bases())
9366 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
9367 getDerived().visitBase(&B))
9370 if (Bases == VisitAllBases)
9371 for (
auto &B : RD->
vbases())
9372 if (getDerived().visitBase(&B))
9375 for (
auto *F : RD->
fields())
9376 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
9377 getDerived().visitField(F))
9386struct SpecialMemberDeletionInfo
9387 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
9392 bool AllFieldsAreConst;
9397 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
9398 Loc(MD->getLocation()), AllFieldsAreConst(
true) {}
9409 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
9412 bool shouldDeleteForField(
FieldDecl *FD);
9413 bool shouldDeleteForAllConstMembers();
9415 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
9417 bool shouldDeleteForSubobjectCall(Subobject Subobj,
9419 bool IsDtorCallInCtor);
9427bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
9448bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
9450 bool IsDtorCallInCtor) {
9457 DiagKind = !
Decl ? 0 : 1;
9460 else if (!isAccessible(Subobj,
Decl))
9462 else if (!IsDtorCallInCtor && Field &&
Field->getParent()->isUnion() &&
9463 !
Decl->isTrivial()) {
9475 const auto *RD = cast<CXXRecordDecl>(
Field->getParent());
9489 diag::note_deleted_special_member_class_subobject)
9490 << getEffectiveCSM() << MD->
getParent() <<
true
9491 <<
Field << DiagKind << IsDtorCallInCtor <<
false;
9495 diag::note_deleted_special_member_class_subobject)
9496 << getEffectiveCSM() << MD->
getParent() <<
false
9497 <<
Base->getType() << DiagKind << IsDtorCallInCtor
9511bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
9514 bool IsMutable =
Field &&
Field->isMutable();
9531 Field &&
Field->hasInClassInitializer()) &&
9532 shouldDeleteForSubobjectCall(Subobj, lookupIn(
Class, Quals, IsMutable),
9539 if (IsConstructor) {
9542 false,
false,
false,
false,
false);
9543 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
9550bool SpecialMemberDeletionInfo::shouldDeleteForVariantObjCPtrMember(
9564 auto *ParentClass = cast<CXXRecordDecl>(FD->
getParent());
9566 diag::note_deleted_special_member_class_subobject)
9567 << getEffectiveCSM() << ParentClass <<
true
9568 << FD << 4 <<
false <<
true;
9585 if (
auto *BaseCtor = SMOR.
getMethod()) {
9590 if (BaseCtor->isDeleted() &&
Diagnose) {
9592 diag::note_deleted_special_member_class_subobject)
9593 << getEffectiveCSM() << MD->
getParent() <<
false
9594 <<
Base->getType() << 1 <<
false
9598 return BaseCtor->isDeleted();
9600 return shouldDeleteForClassSubobject(BaseClass,
Base, 0);
9605bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
9609 if (inUnion() && shouldDeleteForVariantObjCPtrMember(FD, FieldType))
9617 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
9618 << !!ICI << MD->
getParent() << FD << FieldType << 0;
9628 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
9634 AllFieldsAreConst =
false;
9640 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
9644 }
else if (IsAssignment) {
9649 << isMove() << MD->
getParent() << FD << FieldType << 0;
9664 if (!inUnion() && FieldRecord->
isUnion() &&
9666 bool AllVariantFieldsAreConst =
true;
9669 for (
auto *UI : FieldRecord->
fields()) {
9672 if (shouldDeleteForVariantObjCPtrMember(&*UI, UnionFieldType))
9676 AllVariantFieldsAreConst =
false;
9679 if (UnionFieldRecord &&
9680 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
9690 diag::note_deleted_default_ctor_all_const)
9701 if (shouldDeleteForClassSubobject(FieldRecord, FD,
9712bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
9716 bool AnyFields =
false;
9718 if ((AnyFields = !F->isUnnamedBitfield()))
9724 diag::note_deleted_default_ctor_all_const)
9774 bool DeletesOnlyMatchingCopy =
9783 for (
auto *I : RD->
ctors()) {
9784 if (I->isMoveConstructor()) {
9785 UserDeclaredMove = I;
9789 assert(UserDeclaredMove);
9795 for (
auto *I : RD->
methods()) {
9796 if (I->isMoveAssignmentOperator()) {
9797 UserDeclaredMove = I;
9801 assert(UserDeclaredMove);
9804 if (UserDeclaredMove) {
9806 diag::note_deleted_copy_user_declared_move)
9824 OperatorDelete,
false)) {
9831 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI,
Diagnose);
9839 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
9840 : SMI.VisitPotentiallyConstructedBases))
9843 if (SMI.shouldDeleteForAllConstMembers())
9867 assert(DFK &&
"not a defaultable function");
9874 DefaultedComparisonAnalyzer(
9876 DFK.
asComparison(), DefaultedComparisonAnalyzer::ExplainDeleted)
9898 *Selected =
nullptr;
9902 llvm_unreachable(
"not a special member");
9920 for (
auto *CI : RD->
ctors()) {
9921 if (!CI->isDefaultConstructor())
9928 *Selected = DefCtor;
9961 }
else if (!Selected) {
9969 goto NeedOverloadResolution;
9979 }
else if (!Selected) {
9984 goto NeedOverloadResolution;
9988 NeedOverloadResolution:
10016 llvm_unreachable(
"unknown special method kind");
10020 for (
auto *CI : RD->
ctors())
10021 if (!CI->isImplicit())
10028 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
10058 ConstRHS, TAH,
Diagnose ? &Selected :
nullptr))
10066 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
10069 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
10070 }
else if (!Selected)
10071 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
10076 << Kind << SubType.getUnqualifiedType() << CSM;
10078 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
10079 << Kind << SubType.getUnqualifiedType() << CSM;
10084 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
10085 << Kind << SubType.getUnqualifiedType() << CSM;
10103 for (
const auto *FI : RD->
fields()) {
10104 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
10110 if (FI->isAnonymousStructOrUnion()) {
10123 S.
Diag(FI->getLocation(), diag::note_nontrivial_default_member_init)
10134 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
10139 bool ConstRHS = ConstArg && !FI->isMutable();
10168 bool ConstArg =
false;
10196 ClangABICompat14)) {
10226 llvm_unreachable(
"not a special member");
10232 diag::note_nontrivial_default_arg)
10251 for (
const auto &BI : RD->
bases())
10292 Diag(BS.
getBeginLoc(), diag::note_nontrivial_has_virtual) << RD << 1;
10297 for (
const auto *MI : RD->
methods()) {
10298 if (MI->isVirtual()) {
10300 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
10305 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
10313struct FindHiddenVirtualMethod {
10321 static bool CheckMostOverridenMethods(
10323 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
10327 if (CheckMostOverridenMethods(O, Methods))
10343 bool foundSameNameMethod =
false;
10350 foundSameNameMethod =
true;
10367 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
10368 overloadedMethods.push_back(MD);
10372 if (foundSameNameMethod)
10373 OverloadedMethods.append(overloadedMethods.begin(),
10374 overloadedMethods.end());
10375 return foundSameNameMethod;
10382 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
10400 FindHiddenVirtualMethod FHVM;
10411 ND = shad->getTargetDecl();
10417 OverloadedMethods = FHVM.OverloadedMethods;
10422 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
10425 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
10442 if (!OverloadedMethods.empty()) {
10444 << MD << (OverloadedMethods.size() > 1);
10451 auto PrintDiagAndRemoveAttr = [&](
unsigned N) {
10454 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
10455 diag::ext_cannot_use_trivial_abi) << &RD;
10456 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
10457 diag::note_cannot_use_trivial_abi_reason) << &RD << N;
10463 auto HasNonDeletedCopyOrMoveConstructor = [&]() {
10475 if (CD->isCopyOrMoveConstructor() && !CD->isDeleted())
10480 if (!HasNonDeletedCopyOrMoveConstructor()) {
10481 PrintDiagAndRemoveAttr(0);
10487 PrintDiagAndRemoveAttr(1);
10491 for (
const auto &B : RD.
bases()) {
10494 if (!B.getType()->isDependentType() &&
10495 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) {
10496 PrintDiagAndRemoveAttr(2);
10500 if (B.isVirtual()) {
10501 PrintDiagAndRemoveAttr(3);
10506 for (
const auto *FD : RD.
fields()) {
10511 PrintDiagAndRemoveAttr(4);
10516 if (!RT->isDependentType() &&
10517 !cast<CXXRecordDecl>(RT->getDecl())->canPassInRegisters()) {
10518 PrintDiagAndRemoveAttr(5);
10533 if (AL.getKind() != ParsedAttr::AT_Visibility)
10536 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored) << AL;
10544 LBrac, RBrac, AttrList);
10561 FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Friend->getFriendDecl());
10566 Spaceships.clear();
10572 Spaceships.push_back(FD);
10581 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
10582 if (FD->isExplicitlyDefaulted())
10583 Spaceships.push_back(FD);
10683 DefaultedSpaceships);
10684 for (
auto *FD : DefaultedSpaceships)
10691 llvm::function_ref<
Scope *()> EnterScope) {
10699 DeclContext *LookupDC = dyn_cast<DeclContext>(D);
10702 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
10703 ParameterLists.push_back(DD->getTemplateParameterList(i));
10707 ParameterLists.push_back(FTD->getTemplateParameters());
10708 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
10712 ParameterLists.push_back(VTD->getTemplateParameters());
10713 else if (
auto *PSD = dyn_cast<VarTemplatePartialSpecializationDecl>(D))
10714 ParameterLists.push_back(PSD->getTemplateParameters());
10716 }
else if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
10717 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
10718 ParameterLists.push_back(TD->getTemplateParameterList(i));
10722 ParameterLists.push_back(CTD->getTemplateParameters());
10723 else if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
10724 ParameterLists.push_back(PSD->getTemplateParameters());
10729 unsigned Count = 0;
10730 Scope *InnermostTemplateScope =
nullptr;
10734 if (Params->size() == 0)
10737 InnermostTemplateScope = EnterScope();
10739 if (Param->getDeclName()) {
10740 InnermostTemplateScope->
AddDecl(Param);
10748 if (InnermostTemplateScope) {
10749 assert(LookupDC &&
"no enclosing DeclContext for template lookup");
10757 if (!RecordD)
return;
10764 if (!RecordD)
return;
10838 bool DiagOccured =
false;
10840 [DiagID, &S, &DiagOccured](
DeclSpec::TQ, StringRef QualName,
10847 DiagOccured =
true;
10925 = dyn_cast<CXXRecordDecl>(Constructor->getDeclContext());
10927 return Constructor->setInvalidDecl();
10934 if (!Constructor->isInvalidDecl() &&
10935 Constructor->hasOneParamOrDefaultArgs() &&
10936 Constructor->getTemplateSpecializationKind() !=
10938 QualType ParamType = Constructor->getParamDecl(0)->getType();
10941 SourceLocation ParamLoc = Constructor->getParamDecl(0)->getLocation();
10942 const char *ConstRef
10943 = Constructor->getParamDecl(0)->getIdentifier() ?
"const &"
10945 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
10950 Constructor->setInvalidDecl();
10961 if (!Destructor->getOperatorDelete() && Destructor->isVirtual()) {
10964 if (!Destructor->isImplicit())
10965 Loc = Destructor->getLocation();
10972 Expr *ThisArg =
nullptr;
10977 if (OperatorDelete->isDestroyingOperatorDelete()) {
10978 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
10985 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
10986 assert(!This.isInvalid() &&
"couldn't form 'this' expr in dtor?");
10988 if (This.isInvalid()) {
10991 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
10994 ThisArg = This.get();
11000 Destructor->setOperatorDelete(OperatorDelete, ThisArg);
11023 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
11026 if (TST->isTypeAlias())
11028 << DeclaratorType << 1;
11122 if (After.isInvalid())
11126 R.
setEnd(After.getEnd());
11181 unsigned NumParam = Proto->getNumParams();
11185 if (NumParam == 1) {
11187 if (
const auto *
First =
11188 dyn_cast_if_present<ParmVarDecl>(FTI.
Params[0].
Param);
11189 First &&
First->isExplicitObjectParameter())
11193 if (NumParam != 0) {
11198 }
else if (Proto->isVariadic()) {
11205 if (Proto->getReturnType() != ConvType) {
11206 bool NeedsTypedef =
false;
11210 bool PastFunctionChunk =
false;
11212 switch (Chunk.Kind) {
11214 if (!PastFunctionChunk) {
11215 if (Chunk.Fun.HasTrailingReturnType) {
11220 PastFunctionChunk =
true;
11225 NeedsTypedef =
true;
11245 After.isValid() ? After.getBegin() :
11247 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
11248 DB << Before << After;
11250 if (!NeedsTypedef) {
11254 if (After.isInvalid() && ConvTSI) {
11262 }
else if (!Proto->getReturnType()->isDependentType()) {
11263 DB << 1 << Proto->getReturnType();
11265 DB << 2 << Proto->getReturnType();
11276 ConvType = Proto->getReturnType();
11297 Proto->getExtProtoInfo());
11303 ? diag::warn_cxx98_compat_explicit_conversion_functions
11304 : diag::ext_explicit_conversion_functions)
11313 assert(Conversion &&
"Expected to receive a conversion function declaration");
11336 if (ConvType == ClassType)
11341 << ClassType << ConvType;
11344 << ClassType << ConvType;
11359 return ConversionTemplate;
11384 for (
unsigned Idx = 0; Idx < FTI.
NumParams; Idx++) {
11385 const auto &ParamInfo = FTI.
Params[Idx];
11386 if (!ParamInfo.Param)
11388 ParmVarDecl *Param = cast<ParmVarDecl>(ParamInfo.Param);
11392 ExplicitObjectParam = Param;
11396 diag::err_explicit_object_parameter_must_be_first)
11400 if (!ExplicitObjectParam)
11405 diag::err_explicit_object_default_arg)
11413 diag::err_explicit_object_parameter_nonmember)
11420 diag::err_explicit_object_parameter_nonmember)
11427 diag::err_explicit_object_parameter_mutable)
11436 diag::err_explicit_object_parameter_nonmember)
11446 diag::err_explicit_object_parameter_constructor)
11456struct BadSpecifierDiagnoser {
11459 ~BadSpecifierDiagnoser() {
11463 template<
typename T>
void check(
SourceLocation SpecLoc, T Spec) {
11467 return check(SpecLoc,
11473 if (!Specifiers.empty()) Specifiers +=
" ";
11474 Specifiers += Spec;
11479 std::string Specifiers;
11491 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
11499 << GuidedTemplateDecl;
11505 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
11506 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
11507 DS.isNoreturnSpecified() || DS.hasConstexprSpecifier()) {
11508 BadSpecifierDiagnoser Diagnoser(
11510 diag::err_deduction_guide_invalid_specifier);
11512 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
11513 DS.ClearStorageClassSpecs();
11517 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
11518 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
11519 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
11520 DS.ClearConstexprSpec();
11522 Diagnoser.check(DS.getConstSpecLoc(),
"const");
11523 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
11524 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
11525 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
11526 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
11527 DS.ClearTypeQualifiers();
11529 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
11530 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
11531 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
11532 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
11533 DS.ClearTypeSpecType();
11540 bool FoundFunction =
false;
11546 diag::err_deduction_guide_with_complex_decl)
11550 if (!Chunk.Fun.hasTrailingReturnType())
11552 diag::err_deduction_guide_no_trailing_return_type);
11557 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
11560 assert(TSI &&
"deduction guide has valid type but invalid return type?");
11561 bool AcceptableReturnType =
false;
11562 bool MightInstantiateToSpecialization =
false;
11565 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
11566 bool TemplateMatches =
11568 auto TKind = SpecifiedName.
getKind();
11574 if (SimplyWritten && TemplateMatches)
11575 AcceptableReturnType =
true;
11580 MightInstantiateToSpecialization = !(TD && isa<ClassTemplateDecl>(TD) &&
11584 MightInstantiateToSpecialization =
true;
11587 if (!AcceptableReturnType)
11589 diag::err_deduction_guide_bad_trailing_return_type)
11590 << GuidedTemplate << TSI->
getType()
11591 << MightInstantiateToSpecialization
11596 FoundFunction =
true;
11615 assert(*IsInline != PrevNS->
isInline());
11625 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
11628 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
11646 bool IsInline = InlineLoc.
isValid();
11647 bool IsInvalid =
false;
11648 bool IsStd =
false;
11649 bool AddToKnown =
false;
11660 auto DiagnoseInlineStdNS = [&]() {
11661 assert(IsInline && II->
isStr(
"std") &&
11663 "Precondition of DiagnoseInlineStdNS not met");
11664 Diag(InlineLoc, diag::err_inline_namespace_std)
11684 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
11688 if (IsInline && II->
isStr(
"std") &&
11690 DiagnoseInlineStdNS();
11691 else if (IsInline != PrevNS->
isInline())
11693 &IsInline, PrevNS);
11694 }
else if (PrevDecl) {
11696 Diag(Loc, diag::err_redefinition_different_kind)
11701 }
else if (II->
isStr(
"std") &&
11704 DiagnoseInlineStdNS();
11709 AddToKnown = !IsInline;
11712 AddToKnown = !IsInline;
11726 if (PrevNS && IsInline != PrevNS->
isInline())
11728 &IsInline, PrevNS);
11741 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
11747 KnownNamespaces[Namespc] =
false;
11755 TU->setAnonymousNamespace(Namespc);
11757 cast<NamespaceDecl>(
Parent)->setAnonymousNamespace(Namespc);
11806 return AD->getNamespace();
11807 return dyn_cast_or_null<NamespaceDecl>(D);
11813 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
11814 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
11817 if (Namespc->
hasAttr<VisibilityAttr>())
11820 if (DeferredExportedNamespaces.erase(Namespc))
11825 return cast_or_null<CXXRecordDecl>(
11834 return cast_or_null<NamespaceDecl>(
11839enum UnsupportedSTLSelect {
11846struct InvalidSTLDiagnoser {
11851 QualType operator()(UnsupportedSTLSelect Sel = USS_Other, StringRef Name =
"",
11852 const VarDecl *VD =
nullptr) {
11854 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
11855 << TyForDiags << ((
int)Sel);
11856 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
11857 assert(!Name.empty());
11861 if (Sel == USS_InvalidMember) {
11874 "Looking for comparison category type outside of C++.");
11888 if (Info && FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)]) {
11899 std::string NameForDiags =
"std::";
11901 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
11902 << NameForDiags << (
int)Usage;
11906 assert(Info->
Kind == Kind);
11917 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags(Info)};
11920 return UnsupportedSTLError(USS_NonTrivial);
11925 if (
Base->isEmpty())
11928 return UnsupportedSTLError();
11936 if (std::distance(FIt, FEnd) != 1 ||
11937 !FIt->getType()->isIntegralOrEnumerationType()) {
11938 return UnsupportedSTLError();
11948 return UnsupportedSTLError(USS_MissingMember, MemName);
11951 assert(VD &&
"should not be null!");
11958 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
11964 return UnsupportedSTLError();
11971 FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)] =
true;
11997 "Looking for std::initializer_list outside of C++.");
12011 dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl());
12019 Template = dyn_cast_or_null<ClassTemplateDecl>(
12020 TST->getTemplateName().getAsTemplateDecl());
12021 Arguments = TST->template_arguments().begin();
12039 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
12051 *Element = Arguments[0].getAsType();
12058 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
12065 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
12070 Result.suppressDiagnostics();
12073 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
12081 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
12082 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
12126 case Decl::TranslationUnit:
12128 case Decl::LinkageSpec:
12140 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
12142 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
12146 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
12147 return std::make_unique<NamespaceValidatorCCC>(*
this);
12155 auto *ND = cast<NamespaceDecl>(Corrected.
getFoundDecl());
12156 Module *M = ND->getOwningModule();
12157 assert(M &&
"hidden namespace definition not in a module?");
12161 diag::err_module_unimported_use_header)
12166 diag::err_module_unimported_use)
12176 NamespaceValidatorCCC CCC{};
12186 if (isa_and_nonnull<NamespaceDecl>(Corrected.getFoundDecl()) &&
12187 Corrected.requiresImport()) {
12190 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
12191 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
12192 Ident->
getName().equals(CorrectedStr);
12194 S.
PDiag(diag::err_using_directive_member_suggest)
12195 << Ident << DC << DroppedSpecifier << SS.
getRange(),
12196 S.
PDiag(diag::note_namespace_defined_here));
12199 S.
PDiag(diag::err_using_directive_suggest) << Ident,
12200 S.
PDiag(diag::note_namespace_defined_here));
12202 R.
addDecl(Corrected.getFoundDecl());
12213 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
12214 assert(NamespcName &&
"Invalid NamespcName.");
12215 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
12218 S = S->getDeclParent();
12236 NamespcName->
isStr(
"std")) {
12237 Diag(IdentLoc, diag::ext_using_undefined_std);
12248 assert(
NS &&
"expected namespace decl");
12267 CommonAncestor = CommonAncestor->
getParent();
12271 IdentLoc, Named, CommonAncestor);
12275 Diag(IdentLoc, diag::warn_using_directive_in_header);
12280 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
12313 Diag(Name.getBeginLoc(), diag::err_using_requires_qualname);
12317 switch (Name.getKind()) {
12328 Diag(Name.getBeginLoc(),
12330 ? diag::warn_cxx98_compat_using_decl_constructor
12331 : diag::err_using_decl_constructor)
12339 Diag(Name.getBeginLoc(), diag::err_using_decl_destructor) << SS.
getRange();
12343 Diag(Name.getBeginLoc(), diag::err_using_decl_template_id)
12344 <<
SourceRange(Name.TemplateId->LAngleLoc, Name.TemplateId->RAngleLoc);
12348 llvm_unreachable(
"cannot parse qualified deduction guide name");
12359 ? diag::err_access_decl
12360 : diag::warn_access_decl_deprecated)
12371 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
12379 SS, TargetNameInfo, EllipsisLoc, AttrList,
12393 assert(!SS->
isInvalid() &&
"ScopeSpec is invalid");
12403 ? diag::err_using_enum_is_dependent
12404 : diag::err_unknown_typename)
12412 Diag(IdentLoc, diag::err_using_enum_not_enum) << EnumTy;
12416 if (
auto *Def =
Enum->getDefinition())
12419 if (TSI ==
nullptr)
12442 TD2->getUnderlyingType());
12446 if (isa<UnresolvedUsingIfExistsDecl>(D1) &&
12447 isa<UnresolvedUsingIfExistsDecl>(D2))
12479 if (
auto *Using = dyn_cast<UsingDecl>(BUD)) {
12483 if (isa<EnumDecl>(OrigDC))
12491 Diag(Using->getLocation(),
12492 diag::err_using_decl_nested_name_specifier_is_current_class)
12493 << Using->getQualifierLoc().getSourceRange();
12495 Using->setInvalidDecl();
12499 Diag(Using->getQualifierLoc().getBeginLoc(),
12500 diag::err_using_decl_nested_name_specifier_is_not_base_class)
12501 << Using->getQualifier() << cast<CXXRecordDecl>(
CurContext)
12502 << Using->getQualifierLoc().getSourceRange();
12504 Using->setInvalidDecl();
12509 if (
Previous.empty())
return false;
12512 if (isa<UsingShadowDecl>(
Target))
12513 Target = cast<UsingShadowDecl>(
Target)->getTargetDecl();
12520 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
12521 bool FoundEquivalentDecl =
false;
12524 NamedDecl *D = (*I)->getUnderlyingDecl();
12528 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D) || isa<UsingEnumDecl>(D))
12531 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
12536 !isa<IndirectFieldDecl>(
Target) &&
12537 !isa<UnresolvedUsingValueDecl>(
Target) &&
12546 PrevShadow = Shadow;
12547 FoundEquivalentDecl =
true;
12551 FoundEquivalentDecl =
true;
12555 (isa<TagDecl>(D) ? Tag : NonTag) = D;
12558 if (FoundEquivalentDecl)
12563 if (isa<UnresolvedUsingIfExistsDecl>(
Target) !=
12564 (isa_and_nonnull<UnresolvedUsingIfExistsDecl>(NonTag))) {
12565 if (!NonTag && !Tag)
12568 Diag(
Target->getLocation(), diag::note_using_decl_target);
12569 Diag((NonTag ? NonTag : Tag)->getLocation(),
12570 diag::note_using_decl_conflict);
12599 Diag(
Target->getLocation(), diag::note_using_decl_target);
12607 if (isa<TagDecl>(
Target)) {
12609 if (!Tag)
return false;
12612 Diag(
Target->getLocation(), diag::note_using_decl_target);
12613 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
12619 if (!NonTag)
return false;
12622 Diag(
Target->getLocation(), diag::note_using_decl_target);
12632 for (
auto &B : Derived->
bases())
12633 if (B.getType()->getAsCXXRecordDecl() ==
Base)
12634 return B.isVirtual();
12635 llvm_unreachable(
"not a direct base class");
12644 if (isa<UsingShadowDecl>(
Target)) {
12645 Target = cast<UsingShadowDecl>(
Target)->getTargetDecl();
12646 assert(!isa<UsingShadowDecl>(
Target) &&
"nested shadow declaration");
12650 if (
auto *TargetTD = dyn_cast<TemplateDecl>(
Target))
12651 NonTemplateTarget = TargetTD->getTemplatedDecl();
12654 if (NonTemplateTarget && isa<CXXConstructorDecl>(NonTemplateTarget)) {
12655 UsingDecl *Using = cast<UsingDecl>(BUD);
12656 bool IsVirtualBase =
12658 Using->getQualifier()->getAsRecordDecl());
12712 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
12719 S->RemoveDecl(Shadow);
12733 bool &AnyDependentBases) {
12738 CanQualType BaseType =
Base.getType()->getCanonicalTypeUnqualified();
12739 if (CanonicalDesiredBase == BaseType)
12741 if (BaseType->isDependentType())
12742 AnyDependentBases =
true;
12750 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
12752 : HasTypenameKeyword(HasTypenameKeyword),
12753 IsInstantiation(IsInstantiation), OldNNS(NNS),
12754 RequireMemberOf(RequireMemberOf) {}
12756 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
12760 if (!ND || isa<NamespaceDecl>(ND))
12770 if (RequireMemberOf) {
12771 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
12772 if (FoundRecord && FoundRecord->isInjectedClassName()) {
12793 bool AnyDependentBases =
false;
12796 AnyDependentBases) &&
12797 !AnyDependentBases)
12801 if (!RD || RequireMemberOf->isProvablyNotDerivedFrom(RD))
12807 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
12808 if (FoundRecord && FoundRecord->isInjectedClassName())
12812 if (isa<TypeDecl>(ND))
12813 return HasTypenameKeyword || !IsInstantiation;
12815 return !HasTypenameKeyword;
12818 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
12819 return std::make_unique<UsingValidatorCCC>(*
this);
12823 bool HasTypenameKeyword;
12824 bool IsInstantiation;
12863 bool IsUsingIfExists) {
12864 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
12866 assert(IdentLoc.
isValid() &&
"Invalid TargetName location.");
12875 if (
auto *RD = dyn_cast<CXXRecordDecl>(
CurContext))
12888 assert(IsInstantiation &&
"no scope in non-instantiation");
12916 Diag(UsingLoc, diag::err_using_if_exists_on_ctor);
12922 if (!LookupContext || EllipsisLoc.
isValid()) {
12926 SS, NameInfo, IdentLoc))
12929 if (HasTypenameKeyword) {
12932 UsingLoc, TypenameLoc,
12934 IdentLoc, NameInfo.
getName(),
12938 QualifierLoc, NameInfo, EllipsisLoc);
12946 auto Build = [&](
bool Invalid) {
12949 UsingName, HasTypenameKeyword);
12956 auto BuildInvalid = [&]{
return Build(
true); };
12957 auto BuildValid = [&]{
return Build(
false); };
12960 return BuildInvalid();
12969 if (!IsInstantiation)
12986 if (R.
empty() && IsUsingIfExists)
13003 isa<TranslationUnitDecl>(LookupContext) &&
13006 UsingValidatorCCC CCC(HasTypenameKeyword, IsInstantiation, SS.
getScopeRep(),
13014 << NameInfo.
getName() << LookupContext << 0
13019 NamedDecl *ND = Corrected.getCorrectionDecl();
13021 return BuildInvalid();
13024 auto *RD = dyn_cast<CXXRecordDecl>(ND);
13027 RD = cast<CXXRecordDecl>(RD->
getParent());
13030 if (Corrected.WillReplaceSpecifier()) {
13032 Builder.MakeTrivial(
Context, Corrected.getCorrectionSpecifier(),
13034 QualifierLoc = Builder.getWithLocInContext(
Context);
13039 auto *CurClass = cast<CXXRecordDecl>(
CurContext);
13053 Diag(IdentLoc, diag::err_no_member)
13055 return BuildInvalid();
13060 return BuildInvalid();
13062 if (HasTypenameKeyword) {
13066 Diag(IdentLoc, diag::err_using_typename_non_type);
13068 Diag((*I)->getUnderlyingDecl()->getLocation(),
13069 diag::note_using_decl_target);
13070 return BuildInvalid();
13077 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
13079 return BuildInvalid();
13086 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
13088 return BuildInvalid();
13130 if (UED->getEnumDecl() == ED) {
13131 Diag(UsingLoc, diag::err_using_enum_decl_redeclaration)
13170 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
13171 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
13172 isa<UsingPackDecl>(InstantiatedFrom));
13176 UPD->setAccess(InstantiatedFrom->
getAccess());
13183 assert(!UD->
hasTypename() &&
"expecting a constructor name");
13186 assert(SourceType &&
13187 "Using decl naming constructor doesn't have type in scope spec.");
13191 bool AnyDependentBases =
false;
13193 AnyDependentBases);
13194 if (!
Base && !AnyDependentBases) {
13196 diag::err_using_decl_constructor_not_in_direct_base)
13198 <<
QualType(SourceType, 0) << TargetClass;
13204 Base->setInheritConstructors();
13213 bool HasTypenameKeyword,
13232 if (Qual->
isDependent() && !HasTypenameKeyword) {
13233 for (
auto *D : Prev) {
13234 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
13235 bool OldCouldBeEnumerator =
13236 isa<UnresolvedUsingValueDecl>(D) || isa<EnumConstantDecl>(D);
13238 OldCouldBeEnumerator ? diag::err_redefinition
13239 : diag::err_redefinition_different_kind)
13240 << Prev.getLookupName();
13256 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
13257 DTypename = UD->hasTypename();
13258 DQual = UD->getQualifier();
13260 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
13262 DQual = UD->getQualifier();
13264 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
13266 DQual = UD->getQualifier();
13271 if (HasTypenameKeyword != DTypename)
continue;
13279 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
13300 assert(
bool(NamedContext) == (R || UD) && !(R && UD) &&
13301 "resolvable context must have exactly one set of decls");
13305 bool Cxx20Enumerator =
false;
13306 if (NamedContext) {
13315 if (
auto *ED = dyn_cast<EnumDecl>(NamedContext)) {
13319 if (EC && R && ED->isScoped())
13322 ? diag::warn_cxx17_compat_using_decl_scoped_enumerator
13323 : diag::ext_using_decl_scoped_enumerator)
13327 NamedContext = ED->getDeclContext();
13347 ? diag::warn_cxx17_compat_using_decl_class_member_enumerator
13348 : diag::err_using_decl_can_not_refer_to_class_member)
13351 if (Cxx20Enumerator)
13354 auto *RD = NamedContext
13366 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
13374 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
13390 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
13405 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
13415 if (!NamedContext) {
13431 ? diag::warn_cxx17_compat_using_decl_non_member_enumerator
13432 : diag::err_using_decl_nested_name_specifier_is_not_class)
13435 if (Cxx20Enumerator)
13452 cast<CXXRecordDecl>(NamedContext))) {
13454 if (Cxx20Enumerator) {
13455 Diag(NameLoc, diag::warn_cxx17_compat_using_decl_non_member_enumerator)
13462 diag::err_using_decl_nested_name_specifier_is_current_class)
13467 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
13469 diag::err_using_decl_nested_name_specifier_is_not_base_class)
13494 Bases.insert(
Base);
13499 if (!cast<CXXRecordDecl>(
CurContext)->forallBases(Collect))
13505 return !Bases.count(
Base);
13510 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
13511 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
13515 diag::err_using_decl_nested_name_specifier_is_not_base_class)
13529 S = S->getDeclParent();
13531 if (
Type.isInvalid())
13550 TemplateParamLists.size()
13557 Previous.getFoundDecl()->isTemplateParameter()) {
13563 "name in alias declaration must be an identifier");
13565 Name.StartLocation,
13566 Name.Identifier, TInfo);
13580 bool Redeclaration =
false;
13583 if (TemplateParamLists.size()) {
13587 if (TemplateParamLists.size() != 1) {
13588 Diag(UsingLoc, diag::err_alias_template_extra_headers)
13589 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
13590 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
13602 Redeclaration =
true;
13606 Diag(UsingLoc, diag::err_redefinition_different_kind)
13607 << Name.Identifier;
13621 OldTemplateParams =
13649 Name.Identifier, TemplateParams,
13657 else if (OldDecl) {
13664 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
13692 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
13724 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
13726 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
13727 << AD->getNamespace();
13732 ? diag::err_redefinition
13733 : diag::err_redefinition_different_kind;
13734 Diag(AliasLoc, DiagID) << Alias;
13755struct SpecialMemberExceptionSpecInfo
13756 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
13764 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
13769 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
13772 void visitSubobjectCall(Subobject Subobj,
13782 auto *BaseClass = cast<CXXRecordDecl>(RT->getDecl());
13784 if (
auto *BaseCtor = SMOR.
getMethod()) {
13785 visitSubobjectCall(
Base, BaseCtor);
13789 visitClassSubobject(BaseClass,
Base, 0);
13793bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
13804 ExceptSpec.CalledExpr(E);
13807 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
13817 bool IsMutable =
Field &&
Field->isMutable();
13818 visitSubobjectCall(Subobj, lookupIn(
Class, Quals, IsMutable));
13821void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
13826 ExceptSpec.CalledDecl(getSubobjectLoc(Subobj), MD);
13855 ComputingExceptionSpec CES(S, MD, Loc);
13862 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
13864 return Info.ExceptSpec;
13871 diag::err_exception_spec_incomplete_type))
13872 return Info.ExceptSpec;
13889 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
13890 : Info.VisitAllBases);
13892 return Info.ExceptSpec;
13897struct DeclaringSpecialMember {
13901 bool WasAlreadyBeingDeclared;
13904 : S(S), D(RD, CSM), SavedContext(S, RD) {
13906 if (WasAlreadyBeingDeclared)
13927 ~DeclaringSpecialMember() {
13928 if (!WasAlreadyBeingDeclared) {
13935 bool isAlreadyBeingDeclared()
const {
13936 return WasAlreadyBeingDeclared;
13957void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
13975 cast<CXXRecordDecl>(SpecialMem->
getParent())->isLambda()) {
13991 "Should not build implicit default constructor!");
13994 if (DSM.isAlreadyBeingDeclared())
14018 setupImplicitSpecialMemberType(DefaultCon,
Context.
VoidTy, std::nullopt);
14041 ClassDecl->
addDecl(DefaultCon);
14048 assert((Constructor->isDefaulted() && Constructor->isDefaultConstructor() &&
14049 !Constructor->doesThisDeclarationHaveABody() &&
14050 !Constructor->isDeleted()) &&
14051 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
14052 if (Constructor->willHaveBody() || Constructor->isInvalidDecl())
14056 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
14070 Scope.addContextNote(CurrentLocation);
14073 Constructor->setInvalidDecl();
14078 ? Constructor->getEndLoc()
14079 : Constructor->getLocation();
14081 Constructor->markUsed(
Context);
14084 L->CompletedImplicitDefinition(Constructor);
14087 DiagnoseUninitializedFields(*
this, Constructor);
14113 ->getInheritedConstructor()
14116 return cast<CXXConstructorDecl>(Ctor);
14131 false, BaseCtor, &ICI);
14148 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
14154 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
14158 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
14165 ParamDecls.push_back(PD);
14170 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
14173 Derived->
addDecl(DerivedCtor);
14178 return DerivedCtor;
14191 assert(Constructor->getInheritedConstructor() &&
14192 !Constructor->doesThisDeclarationHaveABody() &&
14193 !Constructor->isDeleted());
14194 if (Constructor->willHaveBody() || Constructor->isInvalidDecl())
14208 Scope.addContextNote(CurrentLocation);
14211 Constructor->getInheritedConstructor().getShadowDecl();
14213 Constructor->getInheritedConstructor().getConstructor();
14227 for (
bool VBase : {
false,
true}) {
14229 if (B.isVirtual() != VBase)
14232 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
14237 if (!BaseCtor.first)
14242 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
14246 Context, TInfo, VBase, InitLoc,
Init.get(), InitLoc,
14255 Constructor->setInvalidDecl();
14260 Constructor->markUsed(
Context);
14263 L->CompletedImplicitDefinition(Constructor);
14266 DiagnoseUninitializedFields(*
this, Constructor);
14276 DeclaringSpecialMember DSM(*
this, ClassDecl,
CXXDestructor);
14277 if (DSM.isAlreadyBeingDeclared())
14299 Destructor->setDefaulted();
14301 setupImplicitSpecialMemberType(Destructor,
Context.
VoidTy, std::nullopt);
14312 Destructor->setTrivialForCall(ClassDecl->
hasAttr<TrivialABIAttr>() ||
14331 ClassDecl->
addDecl(Destructor);
14338 assert((Destructor->isDefaulted() &&
14339 !Destructor->doesThisDeclarationHaveABody() &&
14340 !Destructor->isDeleted()) &&
14341 "DefineImplicitDestructor - call it for implicit default dtor");
14342 if (Destructor->willHaveBody() || Destructor->isInvalidDecl())
14346 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
14357 Scope.addContextNote(CurrentLocation);
14360 Destructor->getParent());
14363 Destructor->setInvalidDecl();
14368 ? Destructor->getEndLoc()
14369 : Destructor->getLocation();
14371 Destructor->markUsed(
Context);
14374 L->CompletedImplicitDefinition(Destructor);
14380 if (Destructor->isInvalidDecl())
14385 "implicit complete dtors unneeded outside MS ABI");
14387 "complete dtor only exists for classes with vbases");
14392 Scope.addContextNote(CurrentLocation);
14402 if (
Record->isInvalidDecl()) {
14423 if (M->getParent()->getTemplateSpecializationKind() !=
14443 "adjusting dtor exception specs was introduced in c++11");
14445 if (Destructor->isDependentContext())
14453 if (DtorType->hasExceptionSpec())
14462 Destructor->setType(
14477 ExprBuilder(
const ExprBuilder&) =
delete;
14478 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
14481 static Expr *assertNotNull(
Expr *E) {
14482 assert(E &&
"Expression construction must not fail.");
14488 virtual ~ExprBuilder() {}
14493class RefBuilder:
public ExprBuilder {
14503 : Var(Var), VarType(VarType) {}
14506class ThisBuilder:
public ExprBuilder {
14513class CastBuilder:
public ExprBuilder {
14514 const ExprBuilder &Builder;
14522 CK_UncheckedDerivedToBase, Kind,
14531class DerefBuilder:
public ExprBuilder {
14532 const ExprBuilder &Builder;
14536 return assertNotNull(
14540 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14543class MemberBuilder:
public ExprBuilder {
14544 const ExprBuilder &Builder;
14554 nullptr, MemberLookup,
nullptr,
nullptr).get());
14557 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
14559 : Builder(Builder),
Type(
Type), IsArrow(IsArrow),
14560 MemberLookup(MemberLookup) {}
14563class MoveCastBuilder:
public ExprBuilder {
14564 const ExprBuilder &Builder;
14568 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
14571 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14574class LvalueConvBuilder:
public ExprBuilder {
14575 const ExprBuilder &Builder;
14579 return assertNotNull(
14583 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14586class SubscriptBuilder:
public ExprBuilder {
14587 const ExprBuilder &
Base;
14588 const ExprBuilder &Index;
14593 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
14596 SubscriptBuilder(
const ExprBuilder &
Base,
const ExprBuilder &Index)
14608 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
14617 Expr *From = FromB.build(S, Loc);
14621 Expr *To = ToB.build(S, Loc);
14627 bool NeedsCollectableMemCpy =
14632 StringRef MemCpyName = NeedsCollectableMemCpy ?
14633 "__builtin_objc_memmove_collectable" :
14634 "__builtin_memcpy";
14647 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
14649 Expr *CallArgs[] = {
14653 Loc, CallArgs, Loc);
14655 assert(!
Call.isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
14688 const ExprBuilder &To,
const ExprBuilder &From,
14689 bool CopyingBaseSubobject,
bool Copying,
14690 unsigned Depth = 0) {
14706 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
14741 if (CopyingBaseSubobject) {
14772 Expr *FromInst = From.build(S, Loc);
14775 Loc, FromInst, Loc);
14776 if (
Call.isInvalid())
14795 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
14796 if (Assignment.isInvalid())
14815 llvm::raw_svector_ostream
OS(Str);
14816 OS <<
"__i" << Depth;
14820 IterationVarName, SizeType,
14829 RefBuilder IterationVarRef(IterationVar, SizeType);
14830 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
14836 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
14837 MoveCastBuilder FromIndexMove(FromIndexCopy);
14838 const ExprBuilder *FromIndex;
14840 FromIndex = &FromIndexCopy;
14842 FromIndex = &FromIndexMove;
14844 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
14849 ToIndex, *FromIndex, CopyingBaseSubobject,
14850 Copying, Depth + 1);
14852 if (
Copy.isInvalid() || !
Copy.get())
14859 S.
Context, IterationVarRefRVal.build(S, Loc),
14873 Loc, Loc, InitStmt,
14880 const ExprBuilder &To,
const ExprBuilder &From,
14881 bool CopyingBaseSubobject,
bool Copying) {
14888 CopyingBaseSubobject,
14907 if (DSM.isAlreadyBeingDeclared())
14943 setupImplicitSpecialMemberType(CopyAssignment, RetType, ArgType);
14953 ClassLoc, ClassLoc,
14977 ClassDecl->
addDecl(CopyAssignment);
14979 return CopyAssignment;
14993 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
14996 for (
auto *I : RD->
ctors()) {
14997 if (I->isCopyConstructor()) {
14998 UserDeclaredOperation = I;
15002 assert(UserDeclaredOperation);
15003 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
15006 for (
auto *I : RD->
methods()) {
15007 if (I->isCopyAssignmentOperator()) {
15008 UserDeclaredOperation = I;
15012 assert(UserDeclaredOperation);
15015 if (UserDeclaredOperation) {
15016 bool UDOIsUserProvided = UserDeclaredOperation->
isUserProvided();
15017 bool UDOIsDestructor = isa<CXXDestructorDecl>(UserDeclaredOperation);
15018 bool IsCopyAssignment = !isa<CXXConstructorDecl>(CopyOp);
15020 (UDOIsUserProvided && UDOIsDestructor)
15021 ? diag::warn_deprecated_copy_with_user_provided_dtor
15022 : (UDOIsUserProvided && !UDOIsDestructor)
15023 ? diag::warn_deprecated_copy_with_user_provided_copy
15024 : (!UDOIsUserProvided && UDOIsDestructor)
15025 ? diag::warn_deprecated_copy_with_dtor
15026 : diag::warn_deprecated_copy;
15028 << RD << IsCopyAssignment;
15039 "DefineImplicitCopyAssignment called for wrong function");
15057 Scope.addContextNote(CurrentLocation);
15092 RefBuilder OtherRef(
Other, OtherRefType);
15095 std::optional<ThisBuilder> This;
15096 std::optional<DerefBuilder> DerefThis;
15097 std::optional<RefBuilder> ExplicitObject;
15098 bool IsArrow =
false;
15104 ExplicitObject.emplace(CopyAssignOperator->
getParamDecl(0), ObjectType);
15108 DerefThis.emplace(*This);
15111 ExprBuilder &ObjectParameter =
15112 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15113 :
static_cast<ExprBuilder &
>(*This);
15117 for (
auto &
Base : ClassDecl->
bases()) {
15120 QualType BaseType =
Base.getType().getUnqualifiedType();
15127 BasePath.push_back(&
Base);
15136 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15137 :
static_cast<ExprBuilder &
>(*DerefThis),
15146 if (
Copy.isInvalid()) {
15152 Statements.push_back(
Copy.getAs<
Expr>());
15156 for (
auto *Field : ClassDecl->
fields()) {
15159 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
15162 if (Field->isInvalidDecl()) {
15168 if (Field->getType()->isReferenceType()) {
15169 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15171 Diag(Field->getLocation(), diag::note_declared_at);
15179 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15181 Diag(Field->getLocation(), diag::note_declared_at);
15187 if (Field->isZeroLengthBitField(
Context))
15190 QualType FieldType = Field->getType().getNonReferenceType();
15193 "Incomplete array type is not valid");
15199 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
15204 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
15205 MemberBuilder To(ObjectParameter, ObjectType, IsArrow, MemberLookup);
15211 if (
Copy.isInvalid()) {
15217 Statements.push_back(
Copy.getAs<
Stmt>());
15223 (ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15224 :
LangOpts.HLSL ?
static_cast<ExprBuilder &
>(*This)
15225 :
static_cast<ExprBuilder &
>(*DerefThis))
15226 .build(*
this, Loc);
15231 Statements.push_back(Return.
getAs<
Stmt>());
15244 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
15250 L->CompletedImplicitDefinition(CopyAssignOperator);
15258 if (DSM.isAlreadyBeingDeclared())
15293 setupImplicitSpecialMemberType(MoveAssignment, RetType, ArgType);
15303 ClassLoc, ClassLoc,
15327 ClassDecl->
addDecl(MoveAssignment);
15329 return MoveAssignment;
15337 assert(!
Class->isDependentContext() &&
"should not define dependent move");
15343 if (
Class->getNumVBases() == 0 ||
Class->hasTrivialMoveAssignment() ||
15344 Class->getNumBases() < 2)
15348 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
15351 for (
auto &BI :
Class->bases()) {
15352 Worklist.push_back(&BI);
15353 while (!Worklist.empty()) {
15359 if (!
Base->hasNonTrivialMoveAssignment())
15384 VBases.insert(std::make_pair(
Base->getCanonicalDecl(), &BI))
15386 if (Existing && Existing != &BI) {
15387 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
15390 << (
Base->getCanonicalDecl() ==
15393 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
15394 << (
Base->getCanonicalDecl() ==
15395 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
15399 Existing =
nullptr;
15409 llvm::append_range(Worklist, llvm::make_pointer_range(
Base->bases()));
15422 "DefineImplicitMoveAssignment called for wrong function");
15452 Scope.addContextNote(CurrentLocation);
15468 RefBuilder OtherRef(
Other, OtherRefType);
15470 MoveCastBuilder MoveOther(OtherRef);
15473 std::optional<ThisBuilder> This;
15474 std::optional<DerefBuilder> DerefThis;
15475 std::optional<RefBuilder> ExplicitObject;
15481 ExplicitObject.emplace(MoveAssignOperator->
getParamDecl(0), ObjectType);
15485 DerefThis.emplace(*This);
15487 ExprBuilder &ObjectParameter =
15488 ExplicitObject ? *ExplicitObject :
static_cast<ExprBuilder &
>(*This);
15492 for (
auto &
Base : ClassDecl->
bases()) {
15503 QualType BaseType =
Base.getType().getUnqualifiedType();
15510 BasePath.push_back(&
Base);
15514 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
15519 ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15520 :
static_cast<ExprBuilder &
>(*DerefThis),
15529 if (Move.isInvalid()) {
15535 Statements.push_back(Move.getAs<
Expr>());
15539 for (
auto *Field : ClassDecl->
fields()) {
15542 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
15545 if (Field->isInvalidDecl()) {
15551 if (Field->getType()->isReferenceType()) {
15552 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15554 Diag(Field->getLocation(), diag::note_declared_at);
15562 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15564 Diag(Field->getLocation(), diag::note_declared_at);
15570 if (Field->isZeroLengthBitField(
Context))
15573 QualType FieldType = Field->getType().getNonReferenceType();
15576 "Incomplete array type is not valid");
15581 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
15585 MemberBuilder From(MoveOther, OtherRefType,
15586 false, MemberLookup);
15587 MemberBuilder To(ObjectParameter, ObjectType, !ExplicitObject,
15590 assert(!From.build(*
this, Loc)->isLValue() &&
15591 "Member reference with rvalue base must be rvalue except for reference "
15592 "members, which aren't allowed for move assignment.");
15599 if (Move.isInvalid()) {
15605 Statements.push_back(Move.getAs<
Stmt>());
15611 (ExplicitObject ?
static_cast<ExprBuilder &
>(*ExplicitObject)
15612 :
static_cast<ExprBuilder &
>(*DerefThis))
15613 .build(*
this, Loc);
15619 Statements.push_back(Return.
getAs<
Stmt>());
15632 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
15638 L->CompletedImplicitDefinition(MoveAssignOperator);
15650 if (DSM.isAlreadyBeingDeclared())
15689 setupImplicitSpecialMemberType(CopyConstructor,
Context.
VoidTy, ArgType);
15717 ClassDecl->
hasAttr<TrivialABIAttr>() ||
15736 ClassDecl->
addDecl(CopyConstructor);
15738 return CopyConstructor;
15747 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
15752 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
15763 Scope.addContextNote(CurrentLocation);
15786 L->CompletedImplicitDefinition(CopyConstructor);
15795 if (DSM.isAlreadyBeingDeclared())
15831 setupImplicitSpecialMemberType(MoveConstructor,
Context.
VoidTy, ArgType);
15841 ClassLoc, ClassLoc,
15853 ClassDecl->
hasAttr<TrivialABIAttr>() ||
15872 ClassDecl->
addDecl(MoveConstructor);
15874 return MoveConstructor;
15883 "DefineImplicitMoveConstructor - call it for implicit move ctor");
15888 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
15899 Scope.addContextNote(CurrentLocation);
15915 L->CompletedImplicitDefinition(MoveConstructor);
15946 if (CallOp != Invoker) {
15965 if (Invoker != CallOp) {
15978 assert(FunctionRef &&
"Can't refer to __invoke function?");
15986 L->CompletedImplicitDefinition(Conv);
15987 if (Invoker != CallOp)
15988 L->CompletedImplicitDefinition(Invoker);
16016 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
16025 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
16031 Stmt *ReturnS = Return.
get();
16038 L->CompletedImplicitDefinition(Conv);
16045 switch (Args.size()) {
16050 if (!Args[1]->isDefaultArgument())
16055 return !Args[0]->isDefaultArgument();
16064 bool HadMultipleCandidates,
bool IsListInitialization,
16065 bool IsStdInitListInitialization,
bool RequiresZeroInit,
16067 bool Elidable =
false;
16086 Expr *SubExpr = ExprArgs[0];
16096 FoundDecl, Constructor,
16097 Elidable, ExprArgs, HadMultipleCandidates,
16098 IsListInitialization,
16099 IsStdInitListInitialization, RequiresZeroInit,
16100 ConstructKind, ParenRange);
16106 bool HadMultipleCandidates,
bool IsListInitialization,
16107 bool IsStdInitListInitialization,
bool RequiresZeroInit,
16109 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
16119 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
16120 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
16121 RequiresZeroInit, ConstructKind, ParenRange);
16129 bool HadMultipleCandidates,
bool IsListInitialization,
16130 bool IsStdInitListInitialization,
bool RequiresZeroInit,
16133 Constructor->getParent(),
16135 "given constructor for wrong type");
16142 Context, DeclInitType, ConstructLoc, Constructor, Elidable, ExprArgs,
16143 HadMultipleCandidates, IsListInitialization,
16144 IsStdInitListInitialization, RequiresZeroInit,
16176 PDiag(diag::err_access_dtor_var)
16181 if (Destructor->isTrivial())
return;
16185 if (Destructor->isConstexpr()) {
16186 bool HasConstantInit =
false;
16193 diag::err_constexpr_var_requires_const_destruction) << VD;
16194 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
16195 Diag(Notes[I].first, Notes[I].second);
16220 bool AllowExplicit,
16221 bool IsListInitialization) {
16223 unsigned NumArgs = ArgsPtr.size();
16224 Expr **Args = ArgsPtr.data();
16230 if (NumArgs < NumParams)
16231 ConvertedArgs.reserve(NumParams);
16233 ConvertedArgs.reserve(NumArgs);
16239 Loc, Constructor, Proto, 0,
llvm::ArrayRef(Args, NumArgs), AllArgs,
16240 CallType, AllowExplicit, IsListInitialization);
16241 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
16245 CheckConstructorCall(Constructor, DeclInitType,
16256 if (isa<NamespaceDecl>(DC)) {
16258 diag::err_operator_new_delete_declared_in_namespace)
16262 if (isa<TranslationUnitDecl>(DC) &&
16265 diag::err_operator_new_delete_declared_static)
16277 return Ctx.getPointerType(Ctx.getCanonicalType(Ctx.getQualifiedType(
16285 unsigned DependentParamTypeDiag,
16286 unsigned InvalidParamTypeDiag) {
16304 return SemaRef.
Diag(
16307 ? diag::err_operator_new_delete_dependent_result_type
16308 : diag::err_operator_new_delete_invalid_result_type)
16315 diag::err_operator_new_delete_template_too_few_parameters)
16321 diag::err_operator_new_delete_too_few_parameters)
16328 if (
const auto *PtrTy =
16333 ExpectedFirstParamType =
16339 ExpectedFirstParamType) {
16344 ? DependentParamTypeDiag
16345 : InvalidParamTypeDiag)
16346 << FnDecl->
getDeclName() << ExpectedFirstParamType;
16369 diag::err_operator_new_dependent_param_type,
16370 diag::err_operator_new_param_type))
16377 diag::err_operator_new_default_arg)
16392 auto *MD = dyn_cast<CXXMethodDecl>(FnDecl);
16407 SemaRef, FnDecl, SemaRef.
Context.
VoidTy, ExpectedFirstParamType,
16408 diag::err_operator_delete_dependent_param_type,
16409 diag::err_operator_delete_param_type))
16418 diag::err_destroying_operator_delete_not_usual);
16430 "Expected an overloaded operator declaration");
16440 if (Op == OO_Delete || Op == OO_Array_Delete)
16443 if (Op == OO_New || Op == OO_Array_New)
16453 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
16454 if (MethodDecl->isStatic()) {
16455 if (Op == OO_Call || Op == OO_Subscript)
16458 ? diag::warn_cxx20_compat_operator_overload_static
16459 : diag::ext_operator_overload_static))
16462 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_static)
16466 bool ClassOrEnumParam =
false;
16468 QualType ParamType = Param->getType().getNonReferenceType();
16471 ClassOrEnumParam =
true;
16476 if (!ClassOrEnumParam)
16478 diag::err_operator_overload_needs_class_or_enum)
16488 if (Op != OO_Call) {
16491 if (Param->hasDefaultArg()) {
16492 FirstDefaultedParam = Param;
16496 if (FirstDefaultedParam) {
16497 if (Op == OO_Subscript) {
16499 ? diag::ext_subscript_overload
16500 : diag::error_subscript_overload)
16505 diag::err_operator_overload_default_arg)
16513 {
false,
false,
false }
16514#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
16515 , { Unary, Binary, MemberOnly }
16516#include "clang/Basic/OperatorKinds.def"
16519 bool CanBeUnaryOperator = OperatorUses[Op][0];
16520 bool CanBeBinaryOperator = OperatorUses[Op][1];
16521 bool MustBeMemberOperator = OperatorUses[Op][2];
16528 (isa<CXXMethodDecl>(FnDecl) &&
16532 if (Op != OO_Call && Op != OO_Subscript &&
16533 ((NumParams == 1 && !CanBeUnaryOperator) ||
16534 (NumParams == 2 && !CanBeBinaryOperator) || (NumParams < 1) ||
16535 (NumParams > 2))) {
16537 unsigned ErrorKind;
16538 if (CanBeUnaryOperator && CanBeBinaryOperator) {
16540 }
else if (CanBeUnaryOperator) {
16543 assert(CanBeBinaryOperator &&
16544 "All non-call overloaded operators are unary or binary!");
16547 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
16548 << FnDecl->
getDeclName() << NumParams << ErrorKind;
16551 if (Op == OO_Subscript && NumParams != 2) {
16553 ? diag::ext_subscript_overload
16554 : diag::error_subscript_overload)
16555 << FnDecl->
getDeclName() << (NumParams == 1 ? 0 : 2);
16560 if (Op != OO_Call &&
16562 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
16567 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
16569 diag::err_operator_overload_must_be_member)
16583 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
16590 diag::err_operator_overload_post_incdec_must_be_int)
16591 << LastParam->
getType() << (Op == OO_MinusMinus);
16603 if (TemplateParams->
size() == 1) {
16605 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(0));
16619 if (SemaRef.
getLangOpts().CPlusPlus20 && PmDecl &&
16624 }
else if (TemplateParams->
size() == 2) {
16626 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
getParam(0));
16628 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(1));
16640 diag::ext_string_literal_operator_template);
16647 diag::err_literal_operator_template)
16656 if (isa<CXXMethodDecl>(FnDecl)) {
16657 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
16666 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
16685 diag::err_literal_operator_template_with_params);
16714 diag::err_literal_operator_param)
16731 diag::err_literal_operator_invalid_param)
16741 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
16748 Diag((*Param)->getSourceRange().getBegin(),
16749 diag::err_literal_operator_param)
16750 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16757 Diag((*Param)->getSourceRange().getBegin(),
16758 diag::err_literal_operator_param)
16759 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16772 Diag((*Param)->getSourceRange().getBegin(),
16773 diag::err_literal_operator_param)
16774 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16782 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
16784 Diag((*Param)->getSourceRange().getBegin(),
16785 diag::err_literal_operator_param)
16787 << (*Param)->getSourceRange();
16791 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
16800 if (Param->hasDefaultArg()) {
16801 Diag(Param->getDefaultArgRange().getBegin(),
16802 diag::err_literal_operator_default_argument)
16803 << Param->getDefaultArgRange();
16818 <<
static_cast<int>(Status)
16835 assert(Lit->
isUnevaluated() &&
"Unexpected string literal kind");
16841 else if (Lang ==
"C++")
16844 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
16864 if (
getLangOpts().CPlusPlusModules && isCurrentModulePurview()) {
16865 Module *GlobalModule = PushImplicitGlobalModuleFragment(ExternLoc);
16892 PopImplicitGlobalModuleFragment();
16895 return LinkageSpec;
16932 Diag(Loc, diag::err_catch_rvalue_ref);
16937 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
16943 unsigned DK = diag::err_catch_incomplete;
16947 DK = diag::err_catch_incomplete_ptr;
16950 BaseType = Ref->getPointeeType();
16952 DK = diag::err_catch_incomplete_ref;
16959 Diag(Loc, diag::err_wasm_reftype_tc) << 1;
16964 Diag(Loc, diag::err_catch_sizeless) << (Mode == 2 ? 1 : 0) << BaseType;
16970 diag::err_abstract_type_in_decl,
16982 Diag(Loc, diag::err_objc_object_catch);
16987 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
17021 Expr *opaqueValue =
17069 assert(!S->isDeclScope(PrevDecl));
17073 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
17075 }
else if (PrevDecl->isTemplateParameter())
17103 Expr *AssertMessageExpr,
17109 AssertMessageExpr, RParenLoc,
false);
17114 case BuiltinType::Char_S:
17115 case BuiltinType::Char_U:
17117 case BuiltinType::Char8:
17120 case BuiltinType::Char16:
17123 case BuiltinType::Char32:
17126 case BuiltinType::WChar_S:
17127 case BuiltinType::WChar_U:
17131 llvm_unreachable(
"Non-character type");
17141 char Arr[UNI_MAX_UTF8_BYTES_PER_CODE_POINT];
17144 llvm::raw_svector_ostream
OS(Str);
17148 if (K == BuiltinType::Char_S || K == BuiltinType::Char_U ||
17149 K == BuiltinType::Char8 ||
Value <= 0x7F) {
17150 StringRef Escaped = escapeCStyle<EscapeChar::Single>(
Value);
17151 if (!Escaped.empty())
17154 OS << static_cast<char>(
Value);
17159 case BuiltinType::Char16:
17160 case BuiltinType::Char32:
17161 case BuiltinType::WChar_S:
17162 case BuiltinType::WChar_U: {
17163 if (llvm::ConvertCodePointToUTF8(
Value, Ptr))
17167 << llvm::format_hex_no_prefix(
Value, TyWidth / 4,
true);
17171 llvm_unreachable(
"Non-character type is passed");
17183 switch (
V.getKind()) {
17189 int64_t BoolValue =
V.getInt().getExtValue();
17190 assert((BoolValue == 0 || BoolValue == 1) &&
17191 "Bool type, but value is not 0 or 1");
17192 llvm::raw_svector_ostream
OS(Str);
17193 OS << (BoolValue ?
"true" :
"false");
17195 llvm::raw_svector_ostream
OS(Str);
17200 switch (BTy->getKind()) {
17201 case BuiltinType::Char_S:
17202 case BuiltinType::Char_U:
17203 case BuiltinType::Char8:
17204 case BuiltinType::Char16:
17205 case BuiltinType::Char32:
17206 case BuiltinType::WChar_S:
17207 case BuiltinType::WChar_U: {
17209 assert(8 <= TyWidth && TyWidth <= 32 &&
"Unexpected integer width");
17210 uint32_t CodeUnit =
static_cast<uint32_t
>(
V.getInt().getZExtValue());
17215 << llvm::format_hex_no_prefix(CodeUnit, 2,
17217 <<
", " <<
V.getInt() <<
')';
17224 V.getInt().toString(Str);
17230 V.getFloat().toString(Str);
17234 if (
V.isNullPointer()) {
17235 llvm::raw_svector_ostream
OS(Str);
17242 llvm::raw_svector_ostream
OS(Str);
17244 V.getComplexFloatReal().toString(Str);
17246 V.getComplexFloatImag().toString(Str);
17251 llvm::raw_svector_ostream
OS(Str);
17253 V.getComplexIntReal().toString(Str);
17255 V.getComplexIntImag().toString(Str);
17278 if (isa<SubstNonTypeTemplateParmExpr>(E))
17282 if (
const auto *UnaryOp = dyn_cast<UnaryOperator>(E))
17286 if (
const auto *BO = dyn_cast<BinaryOperator>(E))
17287 return (BO->isShiftOp() || BO->isAdditiveOp() || BO->isMultiplicativeOp() ||
17288 BO->isBitwiseOp());
17296 if (
const auto *Op = dyn_cast<BinaryOperator>(E);
17297 Op && Op->getOpcode() != BO_LOr) {
17298 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
17299 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
17317 for (
unsigned I = 0; I < 2; I++) {
17318 const Expr *Side = DiagSide[I].Cond;
17322 DiagSide[I].Print =
17324 DiagSide[I].ValueString,
Context);
17326 if (DiagSide[0].Print && DiagSide[1].Print) {
17327 Diag(Op->getExprLoc(), diag::note_expr_evaluates_to)
17328 << DiagSide[0].ValueString << Op->getOpcodeStr()
17329 << DiagSide[1].ValueString << Op->getSourceRange();
17337 bool ErrorOnInvalidMessage) {
17339 assert(!Message->isTypeDependent() && !Message->isValueDependent() &&
17340 "can't evaluate a dependant static assert message");
17342 if (
const auto *SL = dyn_cast<StringLiteral>(Message)) {
17343 assert(SL->isUnevaluated() &&
"expected an unevaluated string");
17344 Result.assign(SL->getString().begin(), SL->getString().end());
17349 QualType T = Message->getType().getNonReferenceType();
17352 Diag(Loc, diag::err_static_assert_invalid_message);
17356 auto FindMember = [&](StringRef
Member,
bool &Empty,
17357 bool Diag =
false) -> std::optional<LookupResult> {
17361 Empty = MemberLookup.
empty();
17364 if (MemberLookup.
empty())
17365 return std::nullopt;
17366 return std::move(MemberLookup);
17369 bool SizeNotFound, DataNotFound;
17370 std::optional<LookupResult> SizeMember = FindMember(
"size", SizeNotFound);
17371 std::optional<LookupResult> DataMember = FindMember(
"data", DataNotFound);
17372 if (SizeNotFound || DataNotFound) {
17373 Diag(Loc, diag::err_static_assert_missing_member_function)
17374 << ((SizeNotFound && DataNotFound) ? 2
17380 if (!SizeMember || !DataMember) {
17382 FindMember(
"size", SizeNotFound,
true);
17384 FindMember(
"data", DataNotFound,
true);
17390 Message, Message->getType(), Message->getBeginLoc(),
false,
17415 Diag(Loc, diag::err_static_assert_invalid_mem_fn_ret_ty) << 0;
17425 Diag(Loc, diag::err_static_assert_invalid_mem_fn_ret_ty) << 1;
17429 if (!ErrorOnInvalidMessage &&
17430 Diags.
isIgnored(diag::warn_static_assert_message_constexpr, Loc))
17435 Status.Diag = &Notes;
17436 if (!Message->EvaluateCharRangeAsString(
Result, EvaluatedSize.
get(),
17437 EvaluatedData.
get(), Ctx, Status) ||
17439 Diag(Message->getBeginLoc(),
17440 ErrorOnInvalidMessage ? diag::err_static_assert_message_constexpr
17441 : diag::warn_static_assert_message_constexpr);
17442 for (
const auto &
Note : Notes)
17444 return !ErrorOnInvalidMessage;
17450 Expr *AssertExpr,
Expr *AssertMessage,
17453 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
17471 AssertExpr = FullAssertExpr.
get();
17474 Expr *BaseExpr = AssertExpr;
17486 diag::err_static_assert_expression_is_not_constant,
17492 if (!Failed && AssertMessage && Cond.getBoolValue()) {
17501 bool InTemplateDefinition =
17504 if (!Failed && !Cond && !InTemplateDefinition) {
17506 llvm::raw_svector_ostream Msg(MsgBuffer);
17507 bool HasMessage = AssertMessage;
17508 if (AssertMessage) {
17512 AssertMessage, Str,
Context,
true) ||
17516 Expr *InnerCond =
nullptr;
17517 std::string InnerCondDescription;
17518 std::tie(InnerCond, InnerCondDescription) =
17520 if (InnerCond && isa<ConceptSpecializationExpr>(InnerCond)) {
17528 }
else if (InnerCond && !isa<CXXBoolLiteralExpr>(InnerCond)
17529 && !isa<IntegerLiteral>(InnerCond)) {
17531 diag::err_static_assert_requirement_failed)
17532 << InnerCondDescription << !HasMessage << Msg.str()
17549 AssertExpr = FullAssertExpr.
get();
17553 AssertExpr, AssertMessage, RParenLoc,
17568 bool IsMemberSpecialization =
false;
17573 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
17574 IsMemberSpecialization,
Invalid)) {
17575 if (TemplateParams->size() > 0) {
17583 FriendLoc, TempParamLists.size() - 1,
17584 TempParamLists.data()).
get();
17587 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
17589 IsMemberSpecialization =
true;
17595 bool isAllExplicitSpecializations =
true;
17596 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
17597 if (TempParamLists[I]->size()) {
17598 isAllExplicitSpecializations =
false;
17608 if (isAllExplicitSpecializations) {
17610 bool Owned =
false;
17611 bool IsDependent =
false;
17632 if (isa<DependentNameType>(T)) {
17646 TSI, FriendLoc, TempParamLists);
17652 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
17659 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
17670 TSI, FriendLoc, TempParamLists);
17712 Diag(FriendLoc, diag::err_friend_not_first_in_declaration);
17740 if (TempParams.size()) {
17757 ? diag::warn_cxx98_compat_unelaborated_friend_type
17758 : diag::ext_unelaborated_friend_type)
17764 ? diag::warn_cxx98_compat_nonclass_type_friend
17765 : diag::ext_nonclass_type_friend)
17782 if (!TempParams.empty())
17819 Diag(Loc, diag::err_unexpected_friend);
17854 Scope *DCScope = S;
17866 (FunctionContainingLocalClass =
17867 cast<CXXRecordDecl>(
CurContext)->isLocalClass())) {
17879 DCScope = S->getFnParent();
17889 DC =
Previous.getRepresentativeDecl()->getDeclContext();
17893 DC = FunctionContainingLocalClass;
17930 if (isTemplateId) {
17931 if (isa<TranslationUnitDecl>(LookupDC))
break;
17945 if (!DC)
return nullptr;
17956 diag::warn_cxx98_compat_friend_is_member :
17957 diag::err_friend_is_member);
17966 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
17993 if (DiagArg >= 0) {
17994 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
18005 DCScope = &FakeDCScope;
18008 bool AddToScope =
true;
18010 TemplateParams, AddToScope);
18011 if (!ND)
return nullptr;
18045 FD = FTD->getTemplatedDecl();
18047 FD = cast<FunctionDecl>(ND);
18067 }
else if (FunctionContainingLocalClass) {
18076 }
else if (isTemplateId) {
18090 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
18092 diag::note_previous_declaration);
18094 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
18099 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
18114 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
18116 Diag(DelLoc, diag::err_deleted_non_function);
18127 Prev->getPreviousDecl()) &&
18128 !Prev->isDefined()) {
18129 Diag(DelLoc, diag::err_deleted_decl_not_first);
18130 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
18131 Prev->isImplicit() ? diag::note_previous_implicit_declaration
18132 : diag::note_previous_declaration);
18155 Diag(DelLoc, diag::err_deleted_main);
18167 auto *FD = dyn_cast<FunctionDecl>(Dcl);
18169 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(Dcl)) {
18171 Diag(DefaultLoc, diag::err_defaulted_comparison_template);
18176 Diag(DefaultLoc, diag::err_default_special_members)
18187 (!FD->isDependentContext() ||
18188 (!isa<CXXConstructorDecl>(FD) &&
18190 Diag(DefaultLoc, diag::err_default_special_members)
18200 ? diag::warn_cxx17_compat_defaulted_comparison
18201 : diag::ext_defaulted_comparison);
18204 FD->setDefaulted();
18205 FD->setExplicitlyDefaulted();
18206 FD->setDefaultLoc(DefaultLoc);
18209 if (FD->isDependentContext())
18215 FD->setWillHaveBody(
false);
18228 if (isa<CXXMethodDecl>(FD)) {
18230 if (
const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern())
18244 auto *MD = cast<CXXMethodDecl>(FD);
18255 for (
Stmt *SubStmt : S->children()) {
18258 if (isa<ReturnStmt>(SubStmt))
18259 Self.Diag(SubStmt->getBeginLoc(),
18260 diag::err_return_in_constructor_handler);
18261 if (!isa<Expr>(SubStmt))
18267 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
18275 switch (BodyKind) {
18284 "Parsed function body should be '= delete;' or '= default;'");
18294 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
18298 !NewFT->getExtParameterInfo(I).isNoEscape()) {
18300 diag::warn_overriding_method_missing_noescape);
18302 diag::note_overridden_marked_noescape);
18308 Diag(New->
getLocation(), diag::err_conflicting_overriding_attributes)
18315 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
18316 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
18317 if ((NewCSA || OldCSA) &&
18318 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
18327 if (NewCC == OldCC)
18338 diag::err_conflicting_overriding_cc_attributes)
18351 diag::err_explicit_object_parameter_nonmember)
18378 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
18386 if (NewClassTy.
isNull()) {
18388 diag::err_different_return_type_for_overriding_virtual_function)
18404 if (!RT->isBeingDefined() &&
18406 diag::err_covariant_return_incomplete,
18423 NewClassTy, OldClassTy,
18424 diag::err_covariant_return_inaccessible_base,
18425 diag::err_covariant_return_ambiguous_derived_to_base_conv,
18441 diag::err_covariant_return_type_different_qualifications)
18453 diag::err_covariant_return_type_class_type_more_qualified)
18488 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
18497 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
18498 return Var->hasGlobalStorage();
18552 "Parser allowed 'typedef' as storage class of condition decl.");
18558 if (isa<FunctionDecl>(Dcl)) {
18574 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
18575 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
18579 if (!Pos->second && VTables[I].DefinitionRequired)
18580 Pos->second =
true;
18584 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
18585 NewUses.push_back(
VTableUse(VTables[I].
Record, VTables[I].Location));
18592 bool DefinitionRequired) {
18595 if (!
Class->isDynamicClass() ||
Class->isDependentContext() ||
18603 if (!DefinitionRequired)
18611 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
18617 if (DefinitionRequired && !Pos.first->second) {
18618 Pos.first->second =
true;
18647 if (
Class->isLocalClass())
18662 bool DefinedAnything =
false;
18663 for (
unsigned I = 0; I !=
VTableUses.size(); ++I) {
18668 Class->getTemplateSpecializationKind();
18672 bool DefineVTable =
true;
18678 if (KeyFunction && !KeyFunction->
hasBody()) {
18680 DefineVTable =
false;
18685 "Instantiations don't have key functions");
18687 }
else if (!KeyFunction) {
18692 bool IsExplicitInstantiationDeclaration =
18694 for (
auto *R :
Class->redecls()) {
18696 = cast<CXXRecordDecl>(R)->getTemplateSpecializationKind();
18698 IsExplicitInstantiationDeclaration =
true;
18700 IsExplicitInstantiationDeclaration =
false;
18705 if (IsExplicitInstantiationDeclaration)
18706 DefineVTable =
false;
18712 if (!DefineVTable) {
18720 DefinedAnything =
true;
18733 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
18740 return DefinedAnything;
18745 for (
const auto *I : RD->
methods())
18746 if (I->isVirtual() && !I->isPureVirtual())
18752 bool ConstexprOnly) {
18756 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
18757 E = FinalOverriders.end();
18760 OE = I->second.end();
18762 assert(OI->second.size() > 0 &&
"no final overrider");
18777 for (
const auto &I : RD->
bases()) {
18780 if (
Base->getNumVBases() == 0)
18797 for (
unsigned i = 0; i < ivars.size(); i++) {
18799 if (Field->isInvalidDecl())
18809 InitSeq.
Perform(*
this, InitEntity, InitKind, std::nullopt);
18821 AllToInit.push_back(
Member);
18826 ->getAs<RecordType>()) {
18827 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
18831 PDiag(diag::err_access_dtor_ivar)
18837 AllToInit.data(), AllToInit.size());
18858 cast_or_null<CXXConstructorDecl>(FNTarget));
18865 if (!Current.insert(Canonical).second)
18870 Target->isInvalidDecl() || Valid.count(TCanonical)) {
18871 Valid.insert(Current.begin(), Current.end());
18874 }
else if (TCanonical == Canonical ||
Invalid.count(TCanonical) ||
18875 Current.count(TCanonical)) {
18877 if (!
Invalid.count(TCanonical)) {
18879 diag::warn_delegating_ctor_cycle)
18883 if (TCanonical != Canonical)
18884 S.
Diag(
Target->getLocation(), diag::note_it_delegates_to);
18887 while (
C->getCanonicalDecl() != Canonical) {
18889 (void)
C->getTargetConstructor()->hasBody(FNTarget);
18890 assert(FNTarget &&
"Ctor cycle through bodiless function");
18893 cast<CXXConstructorDecl>(FNTarget));
18894 S.
Diag(
C->getLocation(), diag::note_which_delegates_to);
18898 Invalid.insert(Current.begin(), Current.end());
18909 for (DelegatingCtorDeclsType::iterator
18915 for (
auto CI =
Invalid.begin(), CE =
Invalid.end(); CI != CE; ++CI)
18916 (*CI)->setInvalidDecl();
18925 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
18953 FindCXXThisExpr Finder(*
this);
18966 if (!Finder.TraverseStmt(E))
18983 FindCXXThisExpr Finder(*
this);
19005 if (!Finder.TraverseType(E))
19015 FindCXXThisExpr Finder(*
this);
19018 for (
const auto *A : Method->
attrs()) {
19020 Expr *Arg =
nullptr;
19022 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
19024 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
19026 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
19028 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
19030 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
19031 Arg = ETLF->getSuccessValue();
19033 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
19034 Arg = STLF->getSuccessValue();
19036 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
19037 Arg = LR->getArg();
19038 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
19040 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
19042 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
19044 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
19046 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
19049 if (Arg && !Finder.TraverseStmt(Arg))
19052 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
19053 if (!Finder.TraverseStmt(Args[I]))
19067 Exceptions.clear();
19070 Exceptions.reserve(DynamicExceptions.size());
19071 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
19078 if (!Unexpanded.empty()) {
19089 Exceptions.push_back(ET);
19099 "Parser should have made sure that the expression is boolean");
19115 Expr *NoexceptExpr) {
19121 MethodD = FunTmpl->getTemplatedDecl();
19131 DynamicExceptionRanges, NoexceptExpr, Exceptions,
19157 Diag(DeclStart, diag::err_anonymous_property);
19182 diag::err_invalid_thread)
19190 switch (
Previous.getResultKind()) {
19197 PrevDecl =
Previous.getRepresentativeDecl();
19210 PrevDecl =
nullptr;
19214 PrevDecl =
nullptr;
19225 Record->setInvalidDecl();
19247 if (!ExplicitLists.empty()) {
19248 bool IsMemberSpecialization, IsInvalid;
19252 ExplicitLists,
false, IsMemberSpecialization, IsInvalid,
19264 if (ExplicitParams && !ExplicitParams->
empty()) {
19265 Info.AutoTemplateParameterDepth = ExplicitParams->
getDepth();
19266 llvm::append_range(Info.TemplateParams, *ExplicitParams);
19267 Info.NumExplicitTemplateParams = ExplicitParams->
size();
19269 Info.AutoTemplateParameterDepth = TemplateParameterDepth;
19270 Info.NumExplicitTemplateParams = 0;
19276 if (FSI.TemplateParams.size() > FSI.NumExplicitTemplateParams) {
19277 if (FSI.NumExplicitTemplateParams != 0) {
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
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.
static Sema::SpecialMemberOverloadResult lookupCallFromSpecialMember(Sema &S, CXXRecordDecl *Class, Sema::CXXSpecialMember CSM, unsigned FieldQuals, bool ConstRHS)
Look up the special member function that would be called by a special member function for a subobject...
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 checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, bool ConstArg, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the members of a class type allow a special member to be trivial.
static Sema::ImplicitExceptionSpecification ComputeDefaultedSpecialMemberExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD, Sema::CXXSpecialMember CSM, Sema::InheritedConstructorInfo *ICI)
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 bool findCircularInheritance(const CXXRecordDecl *Class, const CXXRecordDecl *Current)
Determine whether the given class is a base class of the given class, including looking at dependent ...
static void WriteCharValueForDiagnostic(uint32_t Value, const BuiltinType *BTy, unsigned TyWidth, SmallVectorImpl< char > &Str)
Convert character's value, interpreted as a code unit, to a string.
static void CheckAbstractClassUsage(AbstractUsageInfo &Info, FunctionDecl *FD)
Check for invalid uses of an abstract type in a function declaration.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for record diagnostic message.
static Expr * CastForMoving(Sema &SemaRef, Expr *E)
static void extendLeft(SourceRange &R, SourceRange Before)
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 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 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 findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember 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 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 isNonlocalVariable(const Decl *D)
Determine whether the given declaration is a global variable or static data member.
static bool specialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember 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 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 bool lookupStdTypeTraitMember(Sema &S, LookupResult &TraitMemberLookup, SourceLocation Loc, StringRef Trait, TemplateArgumentListInfo &Args, unsigned DiagID)
static bool checkTrivialSubobjectCall(Sema &S, SourceLocation SubobjLoc, QualType SubType, bool ConstRHS, Sema::CXXSpecialMember CSM, TrivialSubobjectKind Kind, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the special member selected for a given type would be trivial.
static void DiagnoseInvisibleNamespace(const TypoCorrection &Corrected, Sema &S)
static StmtResult buildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying)
static FunctionProtoType::ExtProtoInfo getImplicitMethodEPI(Sema &S, CXXMethodDecl *MD)
static QualType getTupleLikeElementType(Sema &S, SourceLocation Loc, unsigned I, QualType T)
static bool defaultedSpecialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember 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 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.
static bool isInvalid(LocType Loc, bool *Invalid)
Defines various enumerations that describe declaration and type specifiers.
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,...
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 bool isCompoundAssignmentOp(Opcode Opc)
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
A binding in a decomposition declaration.
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Wrapper for source info for block pointers.
This class is used for builtin types like 'int'.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
DeclContext::lookup_iterator Decls
The declarations found inside this base class subobject.
AccessSpecifier Access
The access along this inheritance path.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
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.
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isImmediateEscalating() const
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
ExplicitSpecifier getExplicitSpecifier()
init_iterator init_begin()
Retrieve an iterator to the first initializer.
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), 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
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 defaultedDestructorIsDeleted() const
true if a defaulted destructor for this class would be deleted.
bool hasInheritedAssignment() const
Determine whether this class has a using-declaration that names a base class assignment operator.
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
bool hasTrivialDestructorForCall() const
bool defaultedMoveConstructorIsDeleted() const
true if a defaulted move constructor for this class would be deleted.
bool isLiteral() const
Determine whether this class is a literal type.
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
bool defaultedDestructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
bool isLambda() const
Determine whether this class describes a lambda function object.
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12)
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
bool hasUserDeclaredCopyAssignment() const
Determine whether this class has a user-declared copy assignment operator.
method_range methods() const
CXXRecordDecl * getDefinition() const
bool needsOverloadResolutionForCopyAssignment() const
Determine whether we need to eagerly declare a defaulted copy assignment operator for this class.
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class....
void setImplicitMoveAssignmentIsDeleted()
Set that we attempted to declare an implicit move assignment operator, but overload resolution failed...
bool hasConstexprDestructor() const
Determine whether this class has a constexpr destructor.
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
unsigned getNumBases() const
Retrieves the number of base classes of this class.
bool defaultedCopyConstructorIsDeleted() const
true if a defaulted copy constructor for this class would be deleted.
bool hasTrivialCopyConstructorForCall() const
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
bool lambdaIsDefaultConstructibleAndAssignable() const
Determine whether this lambda should have an implicit default constructor and copy and move assignmen...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11,...
base_class_range vbases()
base_class_iterator vbases_begin()
void setImplicitMoveConstructorIsDeleted()
Set that we attempted to declare an implicit move constructor, but overload resolution failed so we d...
bool isAbstract() const
Determine whether this class has a pure virtual function.
bool hasVariantMembers() const
Determine whether this class has any variant members.
void setImplicitCopyConstructorIsDeleted()
Set that we attempted to declare an implicit copy constructor, but overload resolution failed so we d...
bool isDynamicClass() const
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
bool hasNonTrivialCopyConstructorForCall() const
bool hasDirectFields() const
Determine whether this class has direct non-static data members.
bool hasUserDeclaredCopyConstructor() const
Determine whether this class has a user-declared copy constructor.
bool hasDefinition() const
void setImplicitCopyAssignmentIsDeleted()
Set that we attempted to declare an implicit copy assignment operator, but overload resolution failed...
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class.
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
bool hasNonTrivialDestructorForCall() const
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator,...
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class.
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
SourceLocation getLocation() const
CXXTryStmt - A C++ try block, including all handlers.
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
bool isCallToStdMove() const
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.
CastKind getCastKind() const
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.
const llvm::APInt & getSize() const
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.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
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?
bool isImmediateEscalating() const
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
bool isModulePrivateSpecified() const
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
Expr * getPackIndexingExpr() const
void ClearStorageClassSpecs()
TST getTypeSpecType() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
SourceLocation getExplicitSpecLoc() const
SourceLocation getFriendSpecLoc() const
ParsedType getRepAsType() const
TSCS getThreadStorageClassSpec() const
bool isFriendSpecifiedFirst() const
ParsedAttributes & getAttributes()
SourceLocation getEllipsisLoc() const
SourceLocation getConstSpecLoc() const
SourceRange getExplicitSpecRange() const
Expr * getRepAsExpr() const
bool isInlineSpecified() const
SourceLocation getRestrictSpecLoc() const
bool SetTypeQual(TQ T, SourceLocation Loc)
void ClearConstexprSpec()
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getAtomicSpecLoc() const
SourceLocation getVirtualSpecLoc() const
SourceLocation getConstexprSpecLoc() const
SourceLocation getTypeSpecTypeLoc() const
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
SourceLocation getInlineSpecLoc() const
SourceLocation getUnalignedSpecLoc() const
SourceLocation getVolatileSpecLoc() const
FriendSpecified isFriendSpecified() const
bool hasExplicitSpecifier() const
bool hasConstexprSpecifier() const
static const TST TST_auto
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
SourceLocation getBeginLoc() const LLVM_READONLY
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
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.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
SourceLocation getIdentifierLoc() const
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
bool hasGroupingParens() const
void setInvalidType(bool Val=true)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isRedeclaration() const
DeclaratorContext getContext() const
const DecompositionDeclarator & getDecompositionDeclarator() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isFunctionDefinition() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
The template parameter lists that preceded the declarator.
void setInventedTemplateParameterList(TemplateParameterList *Invented)
Sets the template parameter list generated from the explicit template parameters along with any inven...
IdentifierInfo * getIdentifier() const
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
bool isStaticMember()
Returns true if this declares a static member.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
A decomposition declaration.
ArrayRef< BindingDecl * > bindings() const
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
ArrayRef< Binding > bindings() const
SourceRange getSourceRange() const
SourceLocation getLSquareLoc() const
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,...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList * > FriendTypeTPLists=std::nullopt)
void setUnsupportedFriend(bool Unsupported)
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
static DefaultedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups)
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
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
void setWillHaveBody(bool V=true)
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...
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 isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
void setTrivialForCall(bool IT)
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...
DefaultedFunctionInfo * getDefaultedFunctionInfo() const
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
void setDeletedAsWritten(bool D=true)
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
void setDefaultedFunctionInfo(DefaultedFunctionInfo *Info)
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.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
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.
ArrayRef< NamedDecl * > chain() const
void setInherited(bool I)
Description of a constructor that was inherited from a base class.
ConstructorUsingShadowDecl * getShadowDecl() const
const TypeClass * getTypePtr() const
Describes an C or C++ initializer list.
unsigned getNumInits() const
const Expr * getInit(unsigned Init) const
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
static InitializedEntity InitializeMemberFromDefaultMemberInitializer(FieldDecl *Member)
Create the initialization entity for a default member initializer.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
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 nested inside 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.
@ 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.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
const ObjCInterfaceDecl * getClassInterface() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
Represents an ObjC class declaration.
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, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Expr * getUninstantiatedDefaultArg()
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
void setHasInheritedDefaultArg(bool I=true)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ParsedAttr - Represents a syntactic attribute.
IdentifierInfo * getPropertyDataSetter() const
IdentifierInfo * getPropertyDataGetter() const
static const ParsedAttributesView & none()
const ParsedAttr * getMSPropertyAttr() const
bool hasAttribute(ParsedAttr::Kind K) const
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 isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
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.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
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).
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.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
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 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
CXXSpecialMember asSpecialMember() const
bool isComparison() 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.
A generic diagnostic builder for errors which may or may not be deferred.
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.
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl * > &Ivars)
CollectIvarsToConstructOrDestruct - Collect those ivars which require initialization.
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
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)
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
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.
@ 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.
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMember > SpecialMemberDecl
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.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
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.
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.
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)
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc, CodeSynthesisContext::SynthesisKind CSC=CodeSynthesisContext::ExplicitTemplateArgumentSubstitution)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
void referenceDLLExportedClassMethods()
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckForFunctionMarkedFinal - Checks whether a virtual member function overrides a virtual member fun...
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 ...
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++ [dcl.fct.def.general]p1 function-body: ctor-initializer[opt] compound-statement function-try-bloc...
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.
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.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, AssignmentAction Action, CheckedConversionKind CCK=CCK_ImplicitConversion)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType ...
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
ExprResult ActOnCXXThis(SourceLocation loc)
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation IdentLoc, IdentifierInfo &II, CXXScopeSpec *SS=nullptr)
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>.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
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.
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.
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
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 checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
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...
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
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 CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee)
Check whether we're allowed to call Callee from the current context.
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember 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...
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.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
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
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
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)
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind.
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...
bool CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, SourceLocation DefaultLoc)
void ExitDeclaratorContext(Scope *S)
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, 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...
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 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.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
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)
ActOnBaseSpecifier - Parsed a base specifier.
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
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.
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
@ ForExternalRedeclaration
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclarationName Name, FunctionDecl *&Operator, bool Diagnose=true, bool WantSize=false, bool WantAligned=false)
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.
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)
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
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={})
RedeclarationKind forRedeclarationInCurContext() const
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
void FilterUsingLookup(Scope *S, LookupResult &lookup)
Remove decls we can't actually see from a lookup being used to declare shadow using decls.
void actOnDelayedExceptionSpecification(Decl *Method, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member function (or member function template).
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.
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)
bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMember 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 ...
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,...
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind)
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.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
bool isInOpenMPTargetExecutionDirective() const
Return true inside OpenMP target region.
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.
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted.
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.
bool inferObjCARCLifetime(ValueDecl *decl)
@ 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.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
void CheckExplicitObjectLambda(Declarator &D)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc)
PopPragmaVisibility - Pop the top element of the visibility stack; used for '#pragma GCC visibility' ...
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void DiscardCleanupsInEvaluationContext()
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
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 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...
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)
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.
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)
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 SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
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.
CXXSpecialMember
Kinds of C++ special members.
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
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
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 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.
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.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ Template
A single template declaration.
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...
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.
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
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),...
Expr * getSubExpr() const
static bool isIncrementDecrementOp(Opcode Op)
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Represents a C++ unqualified-id that has been parsed.
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
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 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...
@ 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.
@ 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
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.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
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.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
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::@216 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
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<=>'.
CXXSpecialMember SpecialMember
The special member being declared or defined.
Decl * Entity
The entity that is being synthesized.
Abstract class used to diagnose incomplete types.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
Information about a template-id annotation token.
TemplateNameKind Kind
The kind of template that Template refers to.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
OpaquePtr< T > get() const