41 #include "llvm/ADT/STLExtras.h" 42 #include "llvm/ADT/SmallString.h" 43 #include "llvm/ADT/StringExtras.h" 47 using namespace clang;
59 class CheckDefaultArgumentVisitor
60 :
public StmtVisitor<CheckDefaultArgumentVisitor, bool> {
65 CheckDefaultArgumentVisitor(
Expr *defarg,
Sema *s)
66 : DefaultArg(defarg), S(s) {}
76 bool CheckDefaultArgumentVisitor::VisitExpr(
Expr *
Node) {
77 bool IsInvalid =
false;
79 IsInvalid |= Visit(SubStmt);
86 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
DeclRefExpr *DRE) {
88 if (
ParmVarDecl *Param = dyn_cast<ParmVarDecl>(Decl)) {
98 diag::err_param_default_argument_references_param)
99 << Param->getDeclName() << DefaultArg->getSourceRange();
100 }
else if (
VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) {
104 if (VDecl->isLocalVarDecl())
106 diag::err_param_default_argument_references_local)
107 << VDecl->getDeclName() << DefaultArg->getSourceRange();
114 bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
CXXThisExpr *ThisE) {
119 diag::err_param_default_argument_references_this)
123 bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
PseudoObjectExpr *POE) {
131 E = OVE->getSourceExpr();
132 assert(E &&
"pseudo-object binding without source expression?");
140 bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
LambdaExpr *Lambda) {
147 return S->
Diag(Lambda->
getBeginLoc(), diag::err_lambda_capture_default_arg);
160 Proto = Self->ResolveExceptionSpec(CallLoc, Proto);
177 llvm_unreachable(
"should not see unresolved exception specs here");
206 "should not generate implicit declarations for dependent cases");
210 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
212 "Shouldn't collect exceptions when throw-all is guaranteed.");
216 if (ExceptionsSeen.insert(Self->Context.getCanonicalType(E)).second)
217 Exceptions.push_back(E);
245 if (Self->canThrow(S))
253 diag::err_typecheck_decl_incomplete_type)) {
274 CheckCompletedExpr(Arg, EqualLoc);
275 Arg = MaybeCreateExprWithCleanups(Arg);
282 UnparsedDefaultArgInstantiationsMap::iterator InstPos
283 = UnparsedDefaultArgInstantiations.find(Param);
284 if (InstPos != UnparsedDefaultArgInstantiations.end()) {
285 for (
unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
286 InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
289 UnparsedDefaultArgInstantiations.erase(InstPos);
301 if (!param || !DefaultArg)
305 UnparsedDefaultArgLocs.erase(Param);
309 Diag(EqualLoc, diag::err_param_default_argument)
316 if (DiagnoseUnexpandedParameterPack(DefaultArg, UPPC_DefaultArgument)) {
325 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
331 CheckDefaultArgumentVisitor DefaultArgChecker(DefaultArg,
this);
332 if (DefaultArgChecker.Visit(DefaultArg)) {
337 SetParamDefaultArgument(Param, DefaultArg, EqualLoc);
352 UnparsedDefaultArgLocs[Param] = ArgLoc;
364 UnparsedDefaultArgLocs.erase(Param);
388 if (MightBeFunction) {
392 MightBeFunction =
false;
395 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
399 std::unique_ptr<CachedTokens> Toks =
402 if (Toks->size() > 1)
404 Toks->back().getLocation());
406 SR = UnparsedDefaultArgLocs[Param];
416 MightBeFunction =
false;
422 for (
unsigned NumParams = FD->
getNumParams(); NumParams > 0; --NumParams) {
438 bool Invalid =
false;
449 for (; PrevForDefaultArgs;
459 if (S && !isDeclInScope(PrevForDefaultArgs, ScopeDC, S) &&
497 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
500 p < NumParams; ++p) {
504 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
507 if (OldParamHasDfl && NewParamHasDfl) {
508 unsigned DiagDefaultParamID =
509 diag::err_param_default_argument_redefinition;
514 if (getLangOpts().MicrosoftExt) {
524 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
542 for (
auto Older = PrevForDefaultArgs;
544 Older = Older->getPreviousDecl();
545 OldParam = Older->getParamDecl(p);
550 }
else if (OldParamHasDfl) {
568 }
else if (NewParamHasDfl) {
572 diag::err_param_default_argument_template_redecl)
575 diag::note_template_prev_declaration)
606 if (Record->getDescribedClassTemplate())
608 else if (isa<ClassTemplatePartialSpecializationDecl>(Record))
615 diag::err_param_default_argument_member_template_redecl)
625 if (isa<CXXConstructorDecl>(New) &&
628 OldSM = getSpecialMember(cast<CXXMethodDecl>(Old));
629 if (NewSM != OldSM) {
632 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
658 Diag(Def->getLocation(), diag::note_previous_definition);
666 if (isa<CXXDeductionGuideDecl>(New) &&
678 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
696 Diag(Decomp.getLSquareLoc(), diag::err_decomp_decl_context)
697 << Decomp.getSourceRange();
701 if (!TemplateParamLists.empty()) {
704 Diag(TemplateParamLists.front()->getTemplateLoc(),
705 diag::err_decomp_decl_template);
709 Diag(Decomp.getLSquareLoc(),
710 !getLangOpts().CPlusPlus17
711 ? diag::ext_decomp_decl
713 ? diag::ext_decomp_decl_cond
714 : diag::warn_cxx14_compat_decomp_decl)
715 << Decomp.getSourceRange();
732 if (
auto SCS = DS.getStorageClassSpec()) {
735 CPlusPlus20SpecifierLocs.push_back(DS.getStorageClassSpecLoc());
738 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
741 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
743 CPlusPlus20SpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
745 if (DS.hasConstexprSpecifier()) {
746 BadSpecifiers.push_back(
748 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
750 if (DS.isInlineSpecified()) {
751 BadSpecifiers.push_back(
"inline");
752 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
754 if (!BadSpecifiers.empty()) {
755 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
756 Err << (int)BadSpecifiers.size()
757 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
760 for (
auto Loc : BadSpecifierLocs)
762 }
else if (!CPlusPlus20Specifiers.empty()) {
763 auto &&Warn =
Diag(CPlusPlus20SpecifierLocs.front(),
764 getLangOpts().CPlusPlus2a
765 ? diag::warn_cxx17_compat_decomp_decl_spec
766 : diag::ext_decomp_decl_spec);
767 Warn << (int)CPlusPlus20Specifiers.size()
768 << llvm::join(CPlusPlus20Specifiers.begin(),
769 CPlusPlus20Specifiers.end(),
" ");
770 for (
auto Loc : CPlusPlus20SpecifierLocs)
781 getLangOpts().CPlusPlus2a)
782 Diag(DS.getVolatileSpecLoc(),
783 diag::warn_deprecated_volatile_structured_binding);
789 UPPC_DeclarationType))
799 Diag(Decomp.getLSquareLoc(),
803 ? diag::err_decomp_decl_parens
804 : diag::err_decomp_decl_type)
822 ForVisibleRedeclaration);
823 LookupName(Previous, S,
836 FilterLookupForScope(Previous, DC, S, ConsiderLinkage,
838 if (!Previous.
empty()) {
840 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
841 Diag(Old->getLocation(), diag::note_previous_definition);
845 PushOnScopeChains(BD, S,
true);
846 Bindings.push_back(BD);
847 ParsingInitForAutoVars.insert(BD);
853 Decomp.getLSquareLoc());
855 ForVisibleRedeclaration);
858 bool AddToScope =
true;
860 ActOnVariableDeclarator(S, D, DC, TInfo, Previous,
864 CurContext->addHiddenDecl(New);
867 if (isInOpenMPDeclareTargetContext())
868 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
877 if ((int64_t)Bindings.size() != NumElems) {
878 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
879 << DecompType << (
unsigned)Bindings.size() << NumElems.toString(10)
880 << (NumElems < Bindings.size());
885 for (
auto *B : Bindings) {
890 E = GetInit(Loc, E.
get(), I++);
893 B->setBinding(ElemType, E.
get());
905 S, Bindings, Src, DecompType, NumElems, ElemType,
926 S, Bindings, Src, DecompType, llvm::APSInt::get(VT->
getNumElements()),
936 S, Bindings, Src, DecompType, llvm::APSInt::get(2),
947 llvm::raw_svector_ostream OS(SS);
952 Arg.getArgument().print(PrintingPolicy, OS);
962 auto DiagnoseMissing = [&] {
972 return DiagnoseMissing();
982 return DiagnoseMissing();
988 Result.suppressDiagnostics();
990 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
1002 Loc, TraitTy, DiagID,
1008 assert(RD &&
"specialization of class template is not a class?");
1045 return IsTupleLike::NotTupleLike;
1054 : R(R), Args(Args) {}
1056 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1059 } Diagnoser(R, Args);
1070 return IsTupleLike::TupleLike;
1085 S, R, Loc,
"tuple_element", Args,
1086 diag::err_decomp_decl_std_tuple_element_not_specialized))
1092 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1103 struct BindingDiagnosticTrap {
1109 : S(S), Trap(S.
Diags), BD(BD) {}
1110 ~BindingDiagnosticTrap() {
1121 if ((int64_t)Bindings.size() != TupleSize) {
1122 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1123 << DecompType << (
unsigned)Bindings.size() << TupleSize.toString(10)
1124 << (TupleSize < Bindings.size());
1128 if (Bindings.empty())
1137 bool UseMemberGet =
false;
1141 if (MemberGet.isAmbiguous())
1147 dyn_cast<FunctionTemplateDecl>(D->getUnderlyingDecl())) {
1149 if (TPL->
size() != 0 &&
1150 isa<NonTypeTemplateParmDecl>(TPL->
getParam(0))) {
1152 UseMemberGet =
true;
1160 for (
auto *B : Bindings) {
1161 BindingDiagnosticTrap Trap(S, B);
1183 MemberGet, &Args,
nullptr);
1217 B->getDeclName().getAsIdentifierInfo(), RefType,
1221 RefVD->setImplicit();
1223 RefVD->setInlineSpecified();
1224 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1229 E = Seq.
Perform(S, Entity, Kind, Init);
1235 RefVD->setInit(E.
get());
1236 if (!E.
get()->isValueDependent())
1237 RefVD->checkInitIsICE();
1245 B->setBinding(T, E.
get());
1269 ClassWithFields = RD;
1273 Paths.
setOrigin(const_cast<CXXRecordDecl*>(RD));
1281 for (
auto &
P : Paths) {
1285 BestPath->back().Base->getType())) {
1287 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1288 <<
false << RD << BestPath->back().Base->getType()
1289 <<
P.back().Base->getType();
1291 }
else if (
P.Access < BestPath->
Access) {
1297 QualType BaseType = BestPath->back().Base->getType();
1299 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1306 *BestPath, diag::err_decomp_decl_inaccessible_base);
1317 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1318 << (ClassWithFields == RD) << RD << ClassWithFields
1319 << Paths.
front().back().Base->getType();
1330 diag::err_incomplete_type))
1342 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1343 unsigned NumFields =
1344 std::count_if(RD->field_begin(), RD->field_end(),
1345 [](
FieldDecl *FD) {
return !FD->isUnnamedBitfield(); });
1346 assert(Bindings.size() != NumFields);
1347 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1348 << DecompType << (
unsigned)Bindings.size() << NumFields
1349 << (NumFields < Bindings.size());
1357 for (
auto *FD : RD->fields()) {
1358 if (FD->isUnnamedBitfield())
1361 if (FD->isAnonymousStructOrUnion()) {
1364 S.
Diag(FD->getLocation(), diag::note_declared_at);
1369 if (I >= Bindings.size())
1370 return DiagnoseBadNumberOfBindings();
1371 auto *B = Bindings[I++];
1379 Loc, const_cast<CXXRecordDecl *>(OrigRD),
1381 BasePair.
getAccess(), FD->getAccess())));
1404 if (FD->isMutable())
1409 if (I != Bindings.size())
1410 return DiagnoseBadNumberOfBindings();
1458 case IsTupleLike::TupleLike:
1463 case IsTupleLike::NotTupleLike:
1472 << DD << !RD << DecompType;
1491 if (!getLangOpts().CXXExceptions)
1495 "Should only be called if types are otherwise the same.");
1506 NewType =
P->getPointeeType();
1519 if (CheckEquivalentExceptionSpec(
1534 for (p = 0; p < NumParams; ++p) {
1546 unsigned LastMissingDefaultArg = 0;
1547 for (; p < NumParams; ++p) {
1554 diag::err_param_default_argument_missing_name)
1558 diag::err_param_default_argument_missing);
1560 LastMissingDefaultArg = p;
1564 if (LastMissingDefaultArg > 0) {
1569 for (p = 0; p <= LastMissingDefaultArg; ++p) {
1581 template <
typename... Ts>
1591 std::forward<Ts>(DiagArgs)...);
1597 llvm_unreachable(
"unknown CheckConstexprKind");
1606 T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
1614 SemaRef.
Diag(Loc, diag::note_constexpr_dtor_subobject)
1622 if (!Check(B.getBaseTypeLoc(), B.getType(),
nullptr))
1625 if (!Check(FD->getLocation(), FD->getType(), FD))
1635 unsigned ArgIndex = 0;
1638 e = FT->param_type_end();
1639 i != e; ++i, ++ArgIndex) {
1643 diag::err_constexpr_non_literal_param, ArgIndex + 1,
1656 diag::err_constexpr_non_literal_return,
1672 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1699 if (Kind == CheckConstexprKind::CheckValid)
1703 << isa<CXXConstructorDecl>(NewFD)
1705 for (
const auto &I : RD->
vbases())
1706 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
1707 << I.getSourceRange();
1712 if (!isa<CXXConstructorDecl>(NewFD)) {
1719 if (getLangOpts().CPlusPlus2a) {
1720 if (Kind == CheckConstexprKind::Diagnose)
1721 Diag(Method->
getLocation(), diag::warn_cxx17_compat_constexpr_virtual);
1723 if (Kind == CheckConstexprKind::CheckValid)
1732 while (!WrittenVirtual->isVirtualAsWritten())
1734 if (WrittenVirtual != Method)
1735 Diag(WrittenVirtual->getLocation(),
1736 diag::note_overridden_virtual_function);
1746 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(NewFD)) {
1750 if (!Dtor->getParent()->defaultedDestructorIsConstexpr()) {
1751 if (Kind == CheckConstexprKind::CheckValid)
1764 "CheckConstexprFunctionDefinition called on function with no body");
1779 for (
const auto *DclIt : DS->
decls()) {
1780 switch (DclIt->getKind()) {
1781 case Decl::StaticAssert:
1783 case Decl::UsingShadow:
1784 case Decl::UsingDirective:
1785 case Decl::UnresolvedUsingTypename:
1786 case Decl::UnresolvedUsingValue:
1793 case Decl::TypeAlias: {
1796 const auto *TN = cast<TypedefNameDecl>(DclIt);
1797 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1800 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1803 << isa<CXXConstructorDecl>(Dcl);
1811 case Decl::CXXRecord:
1813 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition()) {
1817 ? diag::warn_cxx11_compat_constexpr_type_definition
1818 : diag::ext_constexpr_type_definition)
1819 << isa<CXXConstructorDecl>(Dcl);
1826 case Decl::EnumConstant:
1827 case Decl::IndirectField:
1834 case Decl::Decomposition: {
1839 const auto *VD = cast<VarDecl>(DclIt);
1840 if (VD->isThisDeclarationADefinition()) {
1841 if (VD->isStaticLocal()) {
1843 SemaRef.
Diag(VD->getLocation(),
1844 diag::err_constexpr_local_var_static)
1845 << isa<CXXConstructorDecl>(Dcl)
1851 diag::err_constexpr_local_var_non_literal_type,
1852 isa<CXXConstructorDecl>(Dcl)))
1854 if (!VD->getType()->isDependentType() &&
1855 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1860 ? diag::warn_cxx17_compat_constexpr_local_var_no_init
1861 : diag::ext_constexpr_local_var_no_init)
1862 << isa<CXXConstructorDecl>(Dcl);
1870 SemaRef.
Diag(VD->getLocation(),
1872 ? diag::warn_cxx11_compat_constexpr_local_var
1873 : diag::ext_constexpr_local_var)
1874 << isa<CXXConstructorDecl>(Dcl);
1881 case Decl::NamespaceAlias:
1891 SemaRef.
Diag(DS->
getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
1892 << isa<CXXConstructorDecl>(Dcl) << Dcl->
isConsteval();
1917 llvm::SmallSet<Decl*, 16> &
Inits,
1940 if (!Inits.count(Field)) {
1945 ? diag::warn_cxx17_compat_constexpr_ctor_missing_init
1946 : diag::ext_constexpr_ctor_missing_init);
1950 diag::note_constexpr_ctor_missing_init);
1956 for (
auto *I : RD->
fields())
1959 if (!RD->
isUnion() || Inits.count(I))
1976 case Stmt::NullStmtClass:
1980 case Stmt::DeclStmtClass:
1990 case Stmt::ReturnStmtClass:
1992 if (isa<CXXConstructorDecl>(Dcl)) {
2002 case Stmt::CompoundStmtClass: {
2008 for (
auto *BodyIt : CompStmt->
body()) {
2010 Cxx1yLoc, Cxx2aLoc, Kind))
2016 case Stmt::AttributedStmtClass:
2021 case Stmt::IfStmtClass: {
2026 IfStmt *If = cast<IfStmt>(S);
2028 Cxx1yLoc, Cxx2aLoc,
Kind))
2032 Cxx1yLoc, Cxx2aLoc,
Kind))
2037 case Stmt::WhileStmtClass:
2038 case Stmt::DoStmtClass:
2039 case Stmt::ForStmtClass:
2040 case Stmt::CXXForRangeStmtClass:
2041 case Stmt::ContinueStmtClass:
2051 Cxx1yLoc, Cxx2aLoc, Kind))
2055 case Stmt::SwitchStmtClass:
2056 case Stmt::CaseStmtClass:
2057 case Stmt::DefaultStmtClass:
2058 case Stmt::BreakStmtClass:
2066 Cxx1yLoc, Cxx2aLoc, Kind))
2070 case Stmt::GCCAsmStmtClass:
2071 case Stmt::MSAsmStmtClass:
2073 case Stmt::CXXTryStmtClass:
2079 Cxx1yLoc, Cxx2aLoc, Kind))
2084 case Stmt::CXXCatchStmtClass:
2088 cast<CXXCatchStmt>(S)->getHandlerBlock(),
2089 ReturnStmts, Cxx1yLoc, Cxx2aLoc, Kind))
2105 << isa<CXXConstructorDecl>(Dcl) << Dcl->
isConsteval();
2120 if (isa<CXXTryStmt>(Body)) {
2142 ? diag::ext_constexpr_function_try_block_cxx2a
2143 : diag::warn_cxx17_compat_constexpr_function_try_block)
2144 << isa<CXXConstructorDecl>(Dcl);
2158 Cxx1yLoc, Cxx2aLoc, Kind))
2168 }
else if (Cxx2aLoc.
isValid()) {
2169 SemaRef.
Diag(Cxx2aLoc,
2171 ? diag::warn_cxx17_compat_constexpr_body_invalid_stmt
2172 : diag::ext_constexpr_body_invalid_stmt_cxx2a)
2173 << isa<CXXConstructorDecl>(Dcl);
2174 }
else if (Cxx1yLoc.
isValid()) {
2175 SemaRef.
Diag(Cxx1yLoc,
2177 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
2178 : diag::ext_constexpr_body_invalid_stmt)
2179 << isa<CXXConstructorDecl>(Dcl);
2183 = dyn_cast<CXXConstructorDecl>(Dcl)) {
2192 if (Constructor->getNumCtorInitializers() == 0 &&
2198 ? diag::warn_cxx17_compat_constexpr_union_ctor_no_init
2199 : diag::ext_constexpr_union_ctor_no_init);
2204 }
else if (!Constructor->isDependentContext() &&
2205 !Constructor->isDelegatingConstructor()) {
2206 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
2210 bool AnyAnonStructUnionMembers =
false;
2211 unsigned Fields = 0;
2213 E = RD->
field_end(); I != E; ++I, ++Fields) {
2214 if (I->isAnonymousStructOrUnion()) {
2215 AnyAnonStructUnionMembers =
true;
2223 if (AnyAnonStructUnionMembers ||
2224 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
2228 llvm::SmallSet<Decl*, 16>
Inits;
2229 for (
const auto *I: Constructor->inits()) {
2233 Inits.insert(
ID->chain_begin(),
ID->chain_end());
2236 bool Diagnosed =
false;
2237 for (
auto *I : RD->
fields())
2244 if (ReturnStmts.empty()) {
2255 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2256 : diag::err_constexpr_body_no_return)
2270 }
else if (ReturnStmts.size() > 1) {
2276 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2277 : diag::ext_constexpr_body_multiple_return);
2278 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2279 SemaRef.
Diag(ReturnStmts[I],
2280 diag::note_constexpr_body_previous_return);
2308 diag::ext_constexpr_function_never_constant_expr)
2309 << isa<CXXConstructorDecl>(Dcl);
2310 for (
size_t I = 0, N = Diags.size(); I != N; ++I)
2311 SemaRef.
Diag(Diags[I].first, Diags[I].second);
2328 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2335 return dyn_cast_or_null<CXXRecordDecl>(DC);
2338 return dyn_cast_or_null<CXXRecordDecl>(CurContext);
2355 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2357 if (!getLangOpts().SpellChecking)
2363 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2365 CurDecl = dyn_cast_or_null<CXXRecordDecl>(CurContext);
2367 if (CurDecl && CurDecl->getIdentifier() && II != CurDecl->getIdentifier() &&
2368 3 * II->
getName().edit_distance(CurDecl->getIdentifier()->getName())
2370 II = CurDecl->getIdentifier();
2385 for (
const auto &I : Current->
bases()) {
2397 Queue.push_back(Base);
2403 Current = Queue.pop_back_val();
2431 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2444 ((BaseDecl = BaseDecl->getDefinition()) &&
2446 Diag(BaseLoc, diag::err_circular_inheritance)
2450 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
2459 Access, TInfo, EllipsisLoc);
2464 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2471 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2478 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2480 propagateDLLAttrToBaseClassTemplate(Class, ClassAttr, BaseTemplate,
2489 if (RequireCompleteType(BaseLoc, BaseType,
2490 diag::err_incomplete_base_class, SpecifierRange)) {
2497 assert(BaseDecl &&
"Record type has no declaration");
2499 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2501 assert(CXXBaseDecl &&
"Base type is not a C++ type");
2506 const auto *BaseCSA = CXXBaseDecl->
getAttr<CodeSegAttr>();
2507 const auto *DerivedCSA = Class->
getAttr<CodeSegAttr>();
2508 if ((DerivedCSA || BaseCSA) &&
2509 (!BaseCSA || !DerivedCSA || BaseCSA->getName() != DerivedCSA->getName())) {
2511 Diag(CXXBaseDecl->
getLocation(), diag::note_base_class_specified_here)
2523 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2531 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
2532 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2534 << FA->isSpelledAsSealed();
2546 Access, TInfo, EllipsisLoc);
2563 AdjustDeclIfTemplate(classdecl);
2577 ? (unsigned)diag::warn_unknown_attribute_ignored
2578 : (
unsigned)diag::err_base_specifier_attribute)
2583 GetTypeFromParser(basetype, &TInfo);
2586 DiagnoseUnexpandedParameterPack(SpecifierRange.
getBegin(), TInfo,
2591 Virtual, Access, TInfo,
2612 auto Decl = Rec->getAsCXXRecordDecl();
2615 for (
const auto &BaseSpec : Decl->bases()) {
2617 .getUnqualifiedType();
2618 if (Set.insert(Base).second)
2636 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2640 IndirectBaseSet IndirectBaseTypes;
2643 unsigned NumGoodBases = 0;
2644 bool Invalid =
false;
2645 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2655 Diag(Bases[idx]->getBeginLoc(), diag::err_duplicate_base_class)
2656 << KnownBase->
getType() << Bases[idx]->getSourceRange();
2665 KnownBase = Bases[idx];
2666 Bases[NumGoodBases++] = Bases[idx];
2669 if (Bases.size() > 1)
2673 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
2685 Class->
addAttr(WeakAttr::CreateImplicit(Context));
2691 Class->
setBases(Bases.data(), NumGoodBases);
2694 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2696 QualType BaseType = Bases[idx]->getType();
2706 if (IndirectBaseTypes.count(CanonicalBase)) {
2710 = Class->
isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
2715 Diag(Bases[idx]->getBeginLoc(), diag::warn_inaccessible_base_class)
2716 << BaseType << getAmbiguousPathsDisplayString(Paths)
2717 << Bases[idx]->getSourceRange();
2719 assert(Bases[idx]->isVirtual());
2735 if (!ClassDecl || Bases.empty())
2738 AdjustDeclIfTemplate(ClassDecl);
2739 AttachBaseSpecifiers(cast<CXXRecordDecl>(ClassDecl), Bases);
2763 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2784 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2796 for (
unsigned I = Path.size(); I != 0; --I) {
2797 if (Path[I - 1].
Base->isVirtual()) {
2804 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
2805 BasePathArray.push_back(const_cast<CXXBaseSpecifier*>(Path[I].Base));
2811 assert(BasePathArray.empty() &&
"Base path array must be empty!");
2829 unsigned InaccessibleBaseID,
2830 unsigned AmbigiousBaseConvID,
2834 bool IgnoreAccess) {
2841 bool DerivationOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2842 if (!DerivationOkay)
2847 Path = &Paths.
front();
2852 if (!Path && getLangOpts().MSVCCompat) {
2854 if (PossiblePath.size() == 1) {
2855 Path = &PossiblePath;
2856 if (AmbigiousBaseConvID)
2857 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
2858 << Base << Derived << Range;
2865 if (!IgnoreAccess) {
2868 CheckBaseClassAccess(Loc, Base, Derived, *Path, InaccessibleBaseID)) {
2884 if (AmbigiousBaseConvID) {
2893 bool StillOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2894 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
2901 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
2903 Diag(Loc, AmbigiousBaseConvID)
2904 << Derived << Base << PathDisplayStr << Range << Name;
2913 bool IgnoreAccess) {
2914 return CheckDerivedToBaseConversion(
2915 Derived, Base, diag::err_upcast_to_inaccessible_base,
2916 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
2917 BasePath, IgnoreAccess);
2934 std::string PathDisplayStr;
2935 std::set<unsigned> DisplayedPaths;
2937 Path != Paths.
end(); ++Path) {
2938 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
2941 PathDisplayStr +=
"\n ";
2943 for (CXXBasePath::const_iterator Element = Path->begin();
2944 Element != Path->end(); ++Element)
2945 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
2949 return PathDisplayStr;
2960 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
2963 CurContext->addHiddenDecl(ASDecl);
2964 return ProcessAccessDeclAttributeList(ASDecl, Attrs);
2988 FindHiddenVirtualMethods(MD, OverloadedMethods);
2990 if (!OverloadedMethods.empty()) {
2991 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2992 Diag(OA->getLocation(),
2993 diag::override_keyword_hides_virtual_member_function)
2994 <<
"override" << (OverloadedMethods.size() > 1);
2995 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2996 Diag(FA->getLocation(),
2997 diag::override_keyword_hides_virtual_member_function)
2998 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2999 << (OverloadedMethods.size() > 1);
3001 NoteHiddenVirtualMethods(MD, OverloadedMethods);
3010 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3011 Diag(OA->getLocation(),
3012 diag::override_keyword_only_allowed_on_virtual_member_functions)
3016 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3017 Diag(FA->getLocation(),
3018 diag::override_keyword_only_allowed_on_virtual_member_functions)
3019 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3031 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
3032 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
3045 if (getSourceManager().isMacroArgExpansion(Loc))
3046 SpellingLoc = getSourceManager().getImmediateExpansionRange(Loc).getBegin();
3047 SpellingLoc = getSourceManager().getSpellingLoc(SpellingLoc);
3048 if (SpellingLoc.
isValid() && getSourceManager().isInSystemHeader(SpellingLoc))
3052 unsigned DiagID = isa<CXXDestructorDecl>(MD)
3053 ? diag::warn_destructor_marked_not_override_overriding
3054 : diag::warn_function_marked_not_override_overriding;
3066 FinalAttr *FA = Old->
getAttr<FinalAttr>();
3072 << FA->isSpelledAsSealed();
3081 return !RD->isCompleteDefinition() ||
3082 !RD->hasTrivialDefaultConstructor() ||
3083 !RD->hasTrivialDestructor();
3089 llvm::find_if(list, [](
const ParsedAttr &AL) {
3092 if (Itr != list.
end())
3102 if (Diags.isIgnored(diag::warn_shadow_field, Loc))
3106 std::map<CXXRecordDecl*, NamedDecl*> Bases;
3111 if (Bases.find(
Base) != Bases.end())
3113 for (
const auto Field :
Base->lookup(FieldName)) {
3114 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
3116 assert(Field->getAccess() !=
AS_none);
3117 assert(Bases.find(
Base) == Bases.end());
3118 Bases[
Base] = Field;
3130 for (
const auto &
P : Paths) {
3131 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
3132 auto It = Bases.find(
Base);
3134 if (It == Bases.end())
3136 auto BaseField = It->second;
3137 assert(BaseField->getAccess() !=
AS_private);
3140 Diag(Loc, diag::warn_shadow_field)
3141 << FieldName << RD <<
Base << DeclIsField;
3142 Diag(BaseField->getLocation(), diag::note_shadow_field);
3167 Expr *BitWidth =
static_cast<Expr*
>(BW);
3169 assert(isa<CXXRecordDecl>(CurContext));
3176 if (cast<CXXRecordDecl>(CurContext)->isInterface()) {
3180 unsigned InvalidDecl;
3181 bool ShowDeclName =
true;
3194 ShowDeclName =
false;
3199 ShowDeclName =
false;
3214 Diag(Loc, diag::err_invalid_member_in_interface)
3215 << (InvalidDecl-1) << Name;
3217 Diag(Loc, diag::err_invalid_member_in_interface)
3218 << (InvalidDecl-1) <<
"";
3244 diag::err_storageclass_invalid_for_member);
3264 const char *PrevSpec;
3269 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3273 const char *PrevSpec;
3279 "This is the only DeclSpec that should fail to be applied");
3283 isInstField =
false;
3294 Diag(Loc, diag::err_bad_variable_name)
3303 if (TemplateParameterLists.size()) {
3305 if (TemplateParams->
size()) {
3314 diag::err_template_member_noparams)
3329 if (
DeclContext *DC = computeDeclContext(SS,
false))
3340 if (MSPropertyAttr) {
3341 Member = HandleMSProperty(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3342 BitWidth, InitStyle, AS, *MSPropertyAttr);
3345 isInstField =
false;
3347 Member = HandleField(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3348 BitWidth, InitStyle, AS);
3353 CheckShadowInheritedFields(Loc, Name, cast<CXXRecordDecl>(CurContext));
3355 Member = HandleDeclarator(S, D, TemplateParameterLists);
3363 }
else if (isa<VarDecl>(Member) || isa<VarTemplateDecl>(Member)) {
3366 Diag(Loc, diag::err_static_not_bitfield)
3368 }
else if (isa<TypedefDecl>(Member)) {
3370 Diag(Loc, diag::err_typedef_not_bitfield)
3375 Diag(Loc, diag::err_not_integral_type_bitfield)
3376 << Name << cast<ValueDecl>(Member)->getType()
3386 NonTemplateMember = FunTmpl->getTemplatedDecl();
3387 else if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(Member))
3388 NonTemplateMember = VarTmpl->getTemplatedDecl();
3394 if (NonTemplateMember != Member)
3400 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3401 auto *TD = DG->getDeducedTemplate();
3404 if (AS != TD->getAccess() &&
3405 TD->getDeclContext()->getRedeclContext()->Equals(
3406 DG->getDeclContext()->getRedeclContext())) {
3407 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
3408 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
3411 for (
const auto *D : cast<CXXRecordDecl>(CurContext)->decls()) {
3412 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(D))
3413 LastAccessSpec = AccessSpec;
3415 assert(LastAccessSpec &&
"differing access with no access specifier");
3416 Diag(LastAccessSpec->
getBeginLoc(), diag::note_deduction_guide_access)
3432 if (
CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(Member))
3436 CheckOverrideControl(Member);
3438 assert((Name || isInstField) &&
"No identifier for non-field ?");
3441 FieldDecl *FD = cast<FieldDecl>(Member);
3442 FieldCollector->Add(FD);
3444 if (!Diags.isIgnored(diag::warn_unused_private_field, FD->
getLocation())) {
3452 UnusedPrivateFields.insert(FD);
3460 class UninitializedFieldVisitor
3465 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3468 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3483 UninitializedFieldVisitor(
Sema &S,
3484 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3485 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3486 : Inherited(S.
Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3487 Constructor(
nullptr), InitList(
false), InitListFieldDecl(
nullptr) {}
3490 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3491 bool CheckReferenceOnly) {
3493 bool ReferenceField =
false;
3498 Fields.push_back(FD);
3500 ReferenceField =
true;
3506 if (CheckReferenceOnly && !ReferenceField)
3512 for (
auto I = Fields.rbegin() + 1, E = Fields.rend(); I != E; ++I) {
3513 UsedFieldIndex.push_back((*I)->getFieldIndex());
3516 for (
auto UsedIter = UsedFieldIndex.begin(),
3517 UsedEnd = UsedFieldIndex.end(),
3518 OrigIter = InitFieldIndex.begin(),
3519 OrigEnd = InitFieldIndex.end();
3520 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3521 if (*UsedIter < *OrigIter)
3523 if (*UsedIter > *OrigIter)
3530 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3545 if (isa<VarDecl>(SubME->getMemberDecl()))
3548 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3549 if (!FD->isAnonymousStructOrUnion())
3553 AllPODFields =
false;
3555 Base = SubME->getBase();
3561 if (AddressOf && AllPODFields)
3567 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3568 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
3571 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3581 if (!Decls.count(FoundVD))
3586 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3588 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3593 if (CheckReferenceOnly && !IsReference)
3597 unsigned diag = IsReference
3598 ? diag::warn_reference_field_is_uninit
3599 : diag::warn_field_is_uninit;
3603 diag::note_uninit_in_this_constructor)
3608 void HandleValue(
Expr *E,
bool AddressOf) {
3611 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3612 HandleMemberExpr(ME,
false ,
3618 Visit(CO->getCond());
3619 HandleValue(CO->getTrueExpr(), AddressOf);
3620 HandleValue(CO->getFalseExpr(), AddressOf);
3625 dyn_cast<BinaryConditionalOperator>(E)) {
3626 Visit(BCO->getCond());
3627 HandleValue(BCO->getFalseExpr(), AddressOf);
3632 HandleValue(OVE->getSourceExpr(), AddressOf);
3637 switch (BO->getOpcode()) {
3642 HandleValue(BO->getLHS(), AddressOf);
3643 Visit(BO->getRHS());
3646 Visit(BO->getLHS());
3647 HandleValue(BO->getRHS(), AddressOf);
3656 InitFieldIndex.push_back(0);
3657 for (
auto Child : ILE->
children()) {
3658 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3659 CheckInitListExpr(SubList);
3663 ++InitFieldIndex.back();
3665 InitFieldIndex.pop_back();
3674 DeclsToRemove.clear();
3676 Constructor = FieldConstructor;
3681 InitListFieldDecl = Field;
3682 InitFieldIndex.clear();
3683 CheckInitListExpr(ILE);
3697 HandleMemberExpr(ME,
true ,
false );
3706 Inherited::VisitImplicitCastExpr(E);
3712 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3716 if (ICE->getCastKind() == CK_NoOp)
3717 ArgExpr = ICE->getSubExpr();
3718 HandleValue(ArgExpr,
false );
3721 Inherited::VisitCXXConstructExpr(E);
3726 if (isa<MemberExpr>(Callee)) {
3727 HandleValue(Callee,
false );
3733 Inherited::VisitCXXMemberCallExpr(E);
3739 HandleValue(E->
getArg(0),
false);
3743 Inherited::VisitCallExpr(E);
3749 if (isa<UnresolvedLookupExpr>(Callee))
3750 return Inherited::VisitCXXOperatorCallExpr(E);
3754 HandleValue(Arg->IgnoreParenImpCasts(),
false );
3763 if (!FD->getType()->isReferenceType())
3764 DeclsToRemove.push_back(FD);
3767 HandleValue(E->
getLHS(),
false );
3772 Inherited::VisitBinaryOperator(E);
3782 HandleValue(ME->
getBase(),
true );
3787 Inherited::VisitUnaryOperator(E);
3797 static void DiagnoseUninitializedFields(
3814 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
3817 for (
auto *I : RD->
decls()) {
3818 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
3819 UninitializedFields.insert(FD);
3820 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
3821 UninitializedFields.insert(IFD->getAnonField());
3825 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
3826 for (
auto I : RD->
bases())
3827 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
3829 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3832 UninitializedFieldVisitor UninitializedChecker(SemaRef,
3833 UninitializedFields,
3834 UninitializedBaseClasses);
3836 for (
const auto *FieldInit : Constructor->
inits()) {
3837 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3840 Expr *InitExpr = FieldInit->getInit();
3845 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
3846 InitExpr =
Default->getExpr();
3850 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
3851 FieldInit->getAnyMember(),
3852 FieldInit->getBaseClass());
3854 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
3855 FieldInit->getAnyMember(),
3856 FieldInit->getBaseClass());
3868 PushFunctionScope();
3879 auto *ParamDecl = cast<NamedDecl>(Param.Param);
3880 if (ParamDecl->getDeclName())
3881 PushOnScopeChains(ParamDecl, S,
false);
3888 return CorrectDelayedTyposInExpr(ConstraintExpr);
3898 PopFunctionScopeInfo(
nullptr, D);
3902 "must set init style when field is created");
3911 if (DiagnoseUnexpandedParameterPack(InitExpr, UPPC_Initializer)) {
3928 Init = Seq.Perform(*
this, Entity, Kind, InitExpr);
3938 Init = ActOnFinishFullExpr(Init.
get(), InitLoc,
false);
3944 InitExpr = Init.
get();
3958 DirectBaseSpec =
nullptr;
3959 for (
const auto &
Base : ClassDecl->
bases()) {
3963 DirectBaseSpec = &
Base;
3971 VirtualBaseSpec =
nullptr;
3972 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
3981 Path != Paths.
end(); ++Path) {
3982 if (Path->back().Base->isVirtual()) {
3983 VirtualBaseSpec = Path->back().Base;
3990 return DirectBaseSpec || VirtualBaseSpec;
4004 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
4005 DS, IdLoc, InitList,
4023 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
4024 DS, IdLoc, List, EllipsisLoc);
4033 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
4034 : ClassDecl(ClassDecl) {}
4036 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4038 if (
FieldDecl *Member = dyn_cast<FieldDecl>(ND))
4040 return isa<TypeDecl>(ND);
4045 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
4046 return std::make_unique<MemInitializerValidatorCCC>(*this);
4065 if ((Member = dyn_cast<FieldDecl>(Result.
front())) ||
4082 ExprResult Res = CorrectDelayedTyposInExpr(Init);
4090 AdjustDeclIfTemplate(ConstructorD);
4116 if (
ValueDecl *Member = tryLookupCtorInitMemberDecl(
4117 ClassDecl, SS, TemplateTypeTy, MemberOrBase)) {
4119 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
4123 return BuildMemberInitializer(Member, Init, IdLoc);
4129 if (TemplateTypeTy) {
4130 BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo);
4139 LookupResult R(*
this, MemberOrBase, IdLoc, LookupOrdinaryName);
4140 LookupParsedName(R, S, &SS);
4149 if (SS.
isSet() && isDependentScopeSpecifier(SS)) {
4150 bool NotUnknownSpecialization =
false;
4152 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
4153 NotUnknownSpecialization = !Record->hasAnyDependentBases();
4155 if (!NotUnknownSpecialization) {
4160 *MemberOrBase, IdLoc);
4180 MemInitializerValidatorCCC CCC(ClassDecl);
4183 CCC, CTK_ErrorRecovery, ClassDecl))) {
4189 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4190 << MemberOrBase <<
true);
4191 return BuildMemberInitializer(Member, Init, IdLoc);
4197 DirectBaseSpec, VirtualBaseSpec)) {
4202 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4203 << MemberOrBase <<
false,
4216 if (!TyD && BaseType.
isNull()) {
4217 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
4225 MarkAnyDeclReferenced(TyD->
getLocation(), TyD,
false);
4241 return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, EllipsisLoc);
4249 assert((DirectMember || IndirectMember) &&
4250 "Member must be a FieldDecl or IndirectFieldDecl");
4252 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4259 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4260 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4261 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
4262 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
4273 DiscardCleanupsInEvaluationContext();
4275 bool InitList =
false;
4276 if (isa<InitListExpr>(Init)) {
4293 ExprResult MemberInit = InitSeq.Perform(*
this, MemberEntity, Kind, Args,
4301 MemberInit = ActOnFinishFullExpr(MemberInit.
get(), InitRange.
getBegin(),
4306 Init = MemberInit.
get();
4324 if (!LangOpts.CPlusPlus11)
4325 return Diag(NameLoc, diag::err_delegating_ctor)
4327 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4329 bool InitList =
true;
4331 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4333 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4344 InitRange.getEnd());
4346 ExprResult DelegationInit = InitSeq.Perform(*
this, DelegationEntity, Kind,
4351 assert(cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor() &&
4352 "Delegating constructor with no target?");
4357 DelegationInit = ActOnFinishFullExpr(
4358 DelegationInit.get(), InitRange.getBegin(),
false);
4359 if (DelegationInit.isInvalid())
4369 if (CurContext->isDependentContext())
4370 DelegationInit = Init;
4373 DelegationInit.getAs<
Expr>(),
4374 InitRange.getEnd());
4385 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4400 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4407 if (DiagnoseUnexpandedParameterPack(BaseLoc, BaseTInfo, UPPC_Initializer))
4410 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4420 return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
4429 if (!DirectBaseSpec && !VirtualBaseSpec) {
4438 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4445 DiscardCleanupsInEvaluationContext();
4450 InitRange.
getEnd(), EllipsisLoc);
4457 if (DirectBaseSpec && VirtualBaseSpec)
4458 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4463 BaseSpec = VirtualBaseSpec;
4466 bool InitList =
true;
4468 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4470 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4480 ExprResult BaseInit = InitSeq.Perform(*
this, BaseEntity, Kind, Args,
nullptr);
4487 BaseInit = ActOnFinishFullExpr(BaseInit.
get(), InitRange.
getBegin(),
4499 if (CurContext->isDependentContext())
4506 InitRange.
getEnd(), EllipsisLoc);
4511 if (T.isNull()) T = E->
getType();
4516 TargetType, ExprLoc);
4536 bool IsInheritedVirtualBase,
4540 IsInheritedVirtualBase);
4544 switch (ImplicitInitKind) {
4550 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
None);
4556 bool Moving = ImplicitInitKind ==
IIK_Move;
4578 BasePath.push_back(BaseSpec);
4580 CK_UncheckedDerivedToBase,
4588 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4611 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
4626 bool Moving = ImplicitInitKind ==
IIK_Move;
4634 Expr *MemberExprBase =
4649 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
4651 MemberLookup.resolveKind();
4685 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
4700 "Unhandled implicit init kind!");
4716 InitSeq.
Perform(SemaRef, InitEntity, InitKind,
None);
4739 diag::err_uninitialized_member_in_ctor)
4749 diag::err_uninitialized_member_in_ctor)
4770 CXXMemberInit =
nullptr;
4775 struct BaseAndFieldInfo {
4778 bool AnyErrorsInInits;
4780 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
4782 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
4785 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
4797 bool isImplicitCopyOrMove()
const {
4808 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
4812 AllToInit.push_back(Init);
4821 bool isInactiveUnionMember(
FieldDecl *Field) {
4831 if (isImplicitCopyOrMove())
4849 bool isWithinInactiveUnionMember(
FieldDecl *Field,
4852 return isInactiveUnionMember(Field);
4854 for (
auto *
C : Indirect->
chain()) {
4856 if (Field && isInactiveUnionMember(Field))
4871 if (!ArrayT->getSize())
4874 T = ArrayT->getElementType();
4889 return Info.addFieldInitializer(Init);
4903 if (Info.isWithinInactiveUnionMember(Field, Indirect))
4924 return Info.addFieldInitializer(Init);
4934 if (Info.AnyErrorsInInits)
4945 return Info.addFieldInitializer(Init);
4963 DelegatingCtorDecls.push_back(Constructor);
4965 DiagnoseUninitializedFields(*
this, Constructor);
4975 if (!Initializers.empty()) {
4979 memcpy(baseOrMemberInitializers, Initializers.data(),
4991 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
4999 bool HadError =
false;
5001 for (
unsigned i = 0; i < Initializers.size(); i++) {
5010 for (
auto *
C : F->chain()) {
5013 Info.ActiveUnionMember.insert(std::make_pair(
5017 if (FD->getParent()->isUnion())
5018 Info.ActiveUnionMember.insert(std::make_pair(
5019 FD->getParent()->getCanonicalDecl(), FD->getCanonicalDecl()));
5025 llvm::SmallPtrSet<CXXBaseSpecifier *, 16> DirectVBases;
5026 for (
auto &I : ClassDecl->
bases()) {
5028 DirectVBases.insert(&I);
5032 for (
auto &VBase : ClassDecl->
vbases()) {
5034 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
5042 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
5043 << VBase.getType() << ClassDecl;
5044 DiagnoseAbstractType(ClassDecl);
5047 Info.AllToInit.push_back(
Value);
5048 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
5053 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
5056 &VBase, IsInheritedVirtualBase,
5062 Info.AllToInit.push_back(CXXBaseInit);
5069 if (
Base.isVirtual())
5073 = Info.AllBaseFields.lookup(
Base.getType()->getAs<
RecordType>())) {
5074 Info.AllToInit.push_back(
Value);
5075 }
else if (!AnyErrors) {
5084 Info.AllToInit.push_back(CXXBaseInit);
5089 for (
auto *Mem : ClassDecl->
decls()) {
5090 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
5095 if (F->isUnnamedBitfield())
5101 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
5110 if (Info.isImplicitCopyOrMove())
5113 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
5114 if (F->getType()->isIncompleteArrayType()) {
5116 "Incomplete array type is not valid");
5128 unsigned NumInitializers = Info.AllToInit.size();
5129 if (NumInitializers > 0) {
5133 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
5139 MarkBaseAndMemberDestructorsReferenced(Constructor->
getLocation(),
5150 for (
auto *Field : RD->
fields())
5178 bool ShouldCheckOrder =
false;
5179 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5181 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
5183 ShouldCheckOrder =
true;
5187 if (!ShouldCheckOrder)
5198 for (
const auto &VBase : ClassDecl->
vbases())
5202 for (
const auto &
Base : ClassDecl->
bases()) {
5203 if (
Base.isVirtual())
5209 for (
auto *Field : ClassDecl->
fields()) {
5210 if (Field->isUnnamedBitfield())
5216 unsigned NumIdealInits = IdealInitKeys.size();
5217 unsigned IdealIndex = 0;
5220 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5226 for (; IdealIndex != NumIdealInits; ++IdealIndex)
5227 if (InitKey == IdealInitKeys[IdealIndex])
5233 if (IdealIndex == NumIdealInits && PrevInit) {
5236 diag::warn_initializer_out_of_order);
5249 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
5250 if (InitKey == IdealInitKeys[IdealIndex])
5253 assert(IdealIndex < NumIdealInits &&
5254 "initializer not found in initializer list");
5262 bool CheckRedundantInit(
Sema &S,
5272 diag::err_multiple_mem_initialization)
5273 << Field->getDeclName()
5277 assert(BaseClass &&
"neither field nor base");
5279 diag::err_multiple_base_initialization)
5289 typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5290 typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5292 bool CheckRedundantUnionInit(
Sema &S,
5294 RedundantUnionMap &Unions) {
5301 UnionEntry &En = Unions[
Parent];
5302 if (En.first && En.first != Child) {
5304 diag::err_multiple_mem_union_initialization)
5307 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5308 << 0 << En.second->getSourceRange();
5332 if (!ConstructorDecl)
5335 AdjustDeclIfTemplate(ConstructorDecl);
5341 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5348 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5351 RedundantUnionMap MemberUnions;
5353 bool HadError =
false;
5354 for (
unsigned i = 0; i < MemInits.size(); i++) {
5362 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
5363 CheckRedundantUnionInit(*
this, Init, MemberUnions))
5367 if (CheckRedundantInit(*
this, Init, Members[Key]))
5372 if (MemInits.size() != 1) {
5374 diag::err_delegating_initializer_alone)
5375 << Init->
getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5378 SetDelegatingInitializer(Constructor, MemInits[i]);
5389 SetCtorInitializers(Constructor, AnyErrors, MemInits);
5391 DiagnoseUninitializedFields(*
this, Constructor);
5408 for (
auto *Field : ClassDecl->
fields()) {
5409 if (Field->isInvalidDecl())
5432 assert(Dtor &&
"No dtor found for FieldClassDecl!");
5433 CheckDestructorAccess(Field->getLocation(), Dtor,
5434 PDiag(diag::err_access_dtor_field)
5435 << Field->getDeclName()
5438 MarkFunctionReferenced(Location, Dtor);
5439 DiagnoseUseOfDecl(Dtor, Location);
5444 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5446 llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
5449 for (
const auto &
Base : ClassDecl->
bases()) {
5454 if (
Base.isVirtual()) {
5455 if (!VisitVirtualBases)
5457 DirectVirtualBases.insert(RT);
5468 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5471 CheckDestructorAccess(
Base.getBeginLoc(), Dtor,
5472 PDiag(diag::err_access_dtor_base)
5473 <<
Base.getType() <<
Base.getSourceRange(),
5476 MarkFunctionReferenced(Location, Dtor);
5477 DiagnoseUseOfDecl(Dtor, Location);
5480 if (!VisitVirtualBases)
5484 for (
const auto &VBase : ClassDecl->
vbases()) {
5489 if (DirectVirtualBases.count(RT))
5500 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5501 if (CheckDestructorAccess(
5503 PDiag(diag::err_access_dtor_vbase)
5507 CheckDerivedToBaseConversion(
5509 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5513 MarkFunctionReferenced(Location, Dtor);
5514 DiagnoseUseOfDecl(Dtor, Location);
5523 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5524 SetCtorInitializers(Constructor,
false);
5525 DiagnoseUninitializedFields(*
this, Constructor);
5552 if (!isAbstractType(Loc, T))
5564 if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
5570 if (Diags.isLastDiagnosticIgnored())
5578 llvm::SmallPtrSet<const CXXMethodDecl *, 8> SeenPureMethods;
5580 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5581 MEnd = FinalOverriders.end();
5585 SOEnd = M->second.end();
5586 SO != SOEnd; ++SO) {
5593 if (SO->second.size() != 1)
5596 if (!SO->second.front().Method->isPure())
5599 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5602 Diag(SO->second.front().Method->getLocation(),
5603 diag::note_pure_virtual_function)
5604 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5608 if (!PureVirtualClassDiagSet)
5610 PureVirtualClassDiagSet->insert(RD);
5614 struct AbstractUsageInfo {
5621 : S(S), Record(Record),
5626 void DiagnoseAbstractType() {
5627 if (Invalid)
return;
5635 struct CheckAbstractUsage {
5636 AbstractUsageInfo &Info;
5639 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
5640 : Info(Info), Ctx(Ctx) {}
5644 #define ABSTRACT_TYPELOC(CLASS, PARENT) 5645 #define TYPELOC(CLASS, PARENT) \ 5646 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break; 5647 #include "clang/AST/TypeLocNodes.def" 5653 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
5668 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
5678 #define CheckPolymorphic(Type) \ 5679 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \ 5680 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \ 5695 return Visit(Next, Sel);
5705 T = Info.S.Context.getBaseElementType(T);
5708 if (CT != Info.AbstractType)
return;
5712 Info.S.Diag(Ctx->
getLocation(), diag::err_array_of_abstract_type)
5715 Info.S.Diag(Ctx->
getLocation(), diag::err_abstract_type_in_decl)
5718 Info.DiagnoseAbstractType();
5724 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
5747 for (
auto *D : RD->
decls()) {
5748 if (D->isImplicit())
continue;
5751 if (isa<CXXMethodDecl>(D)) {
5753 }
else if (isa<FunctionTemplateDecl>(D)) {
5754 FunctionDecl *FD = cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
5758 }
else if (isa<FieldDecl>(D)) {
5762 }
else if (isa<VarDecl>(D)) {
5763 VarDecl *VD = cast<VarDecl>(D);
5768 }
else if (isa<CXXRecordDecl>(D)) {
5770 }
else if (isa<ClassTemplateDecl>(D)) {
5772 cast<ClassTemplateDecl>(D)->getTemplatedDecl());
5782 assert(ClassAttr->
getKind() == attr::DLLExport);
5794 for (Decl *Member : Class->
decls()) {
5797 auto *VD = dyn_cast<
VarDecl>(Member);
5798 if (VD && Member->getAttr<DLLExportAttr>() &&
5807 if (Member->getAttr<DLLExportAttr>()) {
5808 if (MD->isUserProvided()) {
5819 }
else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
5820 MD->isCopyAssignmentOperator() ||
5821 MD->isMoveAssignmentOperator()) {
5850 for (Decl *Member : Class->
decls()) {
5853 if (!CD || !CD->isDefaultConstructor())
5855 auto *
Attr = CD->getAttr<DLLExportAttr>();
5868 if (LastExportedDefaultCtor) {
5870 diag::err_attribute_dll_ambiguous_default_ctor)
5872 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
5873 << CD->getDeclName();
5876 LastExportedDefaultCtor = CD;
5882 for (
auto *Method : Class->
methods()) {
5883 if (Method->isUserProvided())
5885 if (
Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method,
true))
5896 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
5897 if (
Attr *TemplateAttr =
5898 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
5899 auto *A = cast<InheritableAttr>(TemplateAttr->clone(getASTContext()));
5900 A->setInherited(
true);
5911 << Class << ClassAttr;
5918 for (Decl *Member : Class->
decls()) {
5919 if (!isa<VarDecl>(Member) && !isa<CXXMethodDecl>(Member))
5922 if (!MemberAttr || MemberAttr->
isInherited() || Member->isInvalidDecl())
5926 diag::err_attribute_dll_member_of_dll_class)
5927 << MemberAttr << ClassAttr;
5929 Member->setInvalidDecl();
5938 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
5943 const bool PropagatedImport =
5945 cast<DLLImportAttr>(ClassAttr)->wasPropagatedToBaseTemplate();
5959 ForceDeclarationOfImplicitMembers(Class);
5964 for (Decl *Member : Class->
decls()) {
5974 if (MD->isDeleted())
5977 if (MD->isInlined()) {
5990 if ((MD->isMoveAssignmentOperator() ||
5991 (Ctor && Ctor->isMoveConstructor())) &&
5998 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->isTrivial())
6005 if (VD && PropagatedImport)
6008 if (!cast<NamedDecl>(Member)->isExternallyVisible())
6016 if (!getLangOpts().DllExportInlines && MD && MD->isInlined() &&
6019 if (ClassExported) {
6020 NewAttr = ::new (getASTContext())
6021 DLLExportStaticLocalAttr(getASTContext(), *ClassAttr);
6023 NewAttr = ::new (getASTContext())
6024 DLLImportStaticLocalAttr(getASTContext(), *ClassAttr);
6027 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
6031 Member->addAttr(NewAttr);
6041 "friend re-decl should not already have a DLLAttr");
6042 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
6044 FD->addAttr(NewAttr);
6051 DelayedDllExportClasses.push_back(Class);
6072 auto *NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
6073 NewAttr->setInherited(
true);
6074 BaseTemplateSpec->
addAttr(NewAttr);
6078 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
6079 ImportAttr->setPropagatedToBaseTemplate();
6085 checkClassLevelDLLAttribute(BaseTemplateSpec);
6100 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
6105 diag::note_template_class_explicit_specialization_was_here)
6106 << BaseTemplateSpec;
6109 diag::note_template_class_instantiation_was_here)
6110 << BaseTemplateSpec;
6123 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
6125 if (Ctor->isDefaultConstructor())
6128 if (Ctor->isCopyConstructor())
6131 if (Ctor->isMoveConstructor())
6135 if (MD->isCopyAssignmentOperator())
6138 if (MD->isMoveAssignmentOperator())
6141 if (isa<CXXDestructorDecl>(FD))
6149 case OO_ExclaimEqual:
6150 return DefaultedComparisonKind::NotEqual;
6154 if (!getLangOpts().CPlusPlus2a)
6156 return DefaultedComparisonKind::ThreeWay;
6161 case OO_GreaterEqual:
6163 if (!getLangOpts().CPlusPlus2a)
6180 cast<CXXConstructorDecl>(MD));
6198 llvm_unreachable(
"Invalid special member.");
6216 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
6217 bool DtorIsTrivialForCall =
false;
6228 CopyCtorIsTrivial =
true;
6230 CopyCtorIsTrivialForCall =
true;
6234 if (CD->isCopyConstructor() && !CD->isDeleted()) {
6235 if (CD->isTrivial())
6236 CopyCtorIsTrivial =
true;
6237 if (CD->isTrivialForCall())
6238 CopyCtorIsTrivialForCall =
true;
6246 DtorIsTrivialForCall =
true;
6248 if (!DD->isDeleted() && DD->isTrivialForCall())
6249 DtorIsTrivialForCall =
true;
6253 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
6267 uint64_t TypeSize = isAArch64 ? 128 : 64;
6269 if (CopyCtorIsTrivial &&
6279 bool HasNonDeletedCopyOrMove =
false;
6285 HasNonDeletedCopyOrMove =
true;
6292 HasNonDeletedCopyOrMove =
true;
6300 if (MD->isDeleted())
6304 if (CD && CD->isCopyOrMoveConstructor())
6305 HasNonDeletedCopyOrMove =
true;
6306 else if (!isa<CXXDestructorDecl>(MD))
6309 if (!MD->isTrivialForCall())
6313 return HasNonDeletedCopyOrMove;
6328 AbstractUsageInfo Info(*
this, Record);
6338 bool Complained =
false;
6339 for (
const auto *F : Record->
fields()) {
6340 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
6343 if (F->getType()->isReferenceType() ||
6344 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
6351 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
6352 << F->getType()->isReferenceType()
6353 << F->getDeclName();
6371 if (((isa<FieldDecl>(D) || isa<UnresolvedUsingValueDecl>(D)) &&
6373 isa<IndirectFieldDecl>(D)) {
6374 Diag((*I)->getLocation(), diag::err_member_name_of_class)
6385 !Record->
hasAttr<FinalAttr>())
6387 diag::warn_non_virtual_dtor) << Context.
getRecordType(Record);
6391 if (FinalAttr *FA = Record->
getAttr<FinalAttr>()) {
6393 << FA->isSpelledAsSealed();
6394 DiagnoseAbstractType(Record);
6399 if (!Record->
hasAttr<FinalAttr>()) {
6401 if (
const FinalAttr *FA = dtor->getAttr<FinalAttr>()) {
6402 Diag(FA->getLocation(), diag::warn_final_dtor_non_final_class)
6403 << FA->isSpelledAsSealed()
6406 (FA->isSpelledAsSealed() ?
" sealed" :
" final"));
6408 diag::note_final_dtor_non_final_class_silence)
6409 << Context.
getRecordType(Record) << FA->isSpelledAsSealed();
6415 if (Record->
hasAttr<TrivialABIAttr>())
6416 checkIllFormedTrivialABIStruct(*Record);
6420 bool HasTrivialABI = Record->
hasAttr<TrivialABIAttr>();
6430 auto CheckForDefaultedFunction = [&](
FunctionDecl *FD) {
6431 if (!FD || FD->isInvalidDecl() || !FD->isExplicitlyDefaulted())
6435 if (DFK.
asComparison() == DefaultedComparisonKind::NotEqual ||
6437 DefaultedSecondaryComparisons.push_back(FD);
6439 CheckExplicitlyDefaultedFunction(S, FD);
6444 CheckForDefaultedFunction(M);
6453 if (!M->isImplicit() && !M->isUserProvided()) {
6454 if (CSM != CXXInvalid) {
6455 M->setTrivial(SpecialMemberIsTrivial(M, CSM));
6458 M->setTrivialForCall(
6460 SpecialMemberIsTrivial(M, CSM, TAH_ConsiderTrivialABI));
6467 if ((CSM == CXXCopyConstructor || CSM == CXXMoveConstructor ||
6468 CSM == CXXDestructor) && M->isUserProvided()) {
6469 M->setTrivialForCall(HasTrivialABI);
6473 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
6474 M->hasAttr<DLLExportAttr>()) {
6477 (CSM == CXXDefaultConstructor || CSM == CXXCopyConstructor ||
6478 CSM == CXXDestructor))
6479 M->dropAttr<DLLExportAttr>();
6481 if (M->hasAttr<DLLExportAttr>()) {
6483 DelayedDllExportMemberFunctions.push_back(M);
6490 if (M->isDefaulted() && M->isConstexpr() && M->size_overridden_methods())
6500 CompleteMemberFunction(Dtor);
6502 bool HasMethodWithOverrideControl =
false,
6503 HasOverridingMethodWithoutOverrideControl =
false;
6504 for (
auto *D : Record->
decls()) {
6505 if (
auto *M = dyn_cast<CXXMethodDecl>(D)) {
6512 DiagnoseHiddenVirtualMethods(M);
6513 if (M->hasAttr<OverrideAttr>())
6514 HasMethodWithOverrideControl =
true;
6515 else if (M->size_overridden_methods() > 0)
6516 HasOverridingMethodWithoutOverrideControl =
true;
6519 if (!isa<CXXDestructorDecl>(M))
6520 CompleteMemberFunction(M);
6521 }
else if (
auto *F = dyn_cast<FriendDecl>(D)) {
6522 CheckForDefaultedFunction(
6523 dyn_cast_or_null<FunctionDecl>(F->getFriendDecl()));
6527 if (HasMethodWithOverrideControl &&
6528 HasOverridingMethodWithoutOverrideControl) {
6532 for (
auto *M : Record->
methods())
6533 DiagnoseAbsenceOfOverrideControl(M);
6538 CheckExplicitlyDefaultedFunction(S, FD);
6554 checkClassLevelDLLAttribute(Record);
6555 checkClassLevelCodeSegAttribute(Record);
6557 bool ClangABICompat4 =
6579 if (getLangOpts().ForceEmitVTables) {
6597 unsigned FieldQuals,
bool ConstRHS) {
6598 unsigned LHSQuals = 0;
6600 LHSQuals = FieldQuals;
6602 unsigned RHSQuals = FieldQuals;
6612 LHSQuals & Qualifiers::Const,
6613 LHSQuals & Qualifiers::Volatile);
6623 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
6629 : S(S), UseLoc(UseLoc) {
6630 bool DiagnosedMultipleConstructedBases =
false;
6632 UsingDecl *ConstructedBaseUsing =
nullptr;
6636 for (
auto *D : Shadow->
redecls()) {
6637 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
6638 auto *DNominatedBase = DShadow->getNominatedBaseClass();
6639 auto *DConstructedBase = DShadow->getConstructedBaseClass();
6641 InheritedFromBases.insert(
6642 std::make_pair(DNominatedBase->getCanonicalDecl(),
6643 DShadow->getNominatedBaseClassShadowDecl()));
6644 if (DShadow->constructsVirtualBase())
6645 InheritedFromBases.insert(
6646 std::make_pair(DConstructedBase->getCanonicalDecl(),
6647 DShadow->getConstructedBaseClassShadowDecl()));
6649 assert(DNominatedBase == DConstructedBase);
6654 if (!ConstructedBase) {
6655 ConstructedBase = DConstructedBase;
6656 ConstructedBaseUsing = D->getUsingDecl();
6657 }
else if (ConstructedBase != DConstructedBase &&
6659 if (!DiagnosedMultipleConstructedBases) {
6660 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
6663 diag::note_ambiguous_inherited_constructor_using)
6665 DiagnosedMultipleConstructedBases =
true;
6667 S.
Diag(D->getUsingDecl()->getLocation(),
6668 diag::note_ambiguous_inherited_constructor_using)
6669 << DConstructedBase;
6673 if (DiagnosedMultipleConstructedBases)
6680 std::pair<CXXConstructorDecl *, bool>
6683 if (It == InheritedFromBases.end())
6684 return std::make_pair(
nullptr,
false);
6688 return std::make_pair(
6690 It->second->constructsVirtualBase());
6693 return std::make_pair(Ctor,
false);
6707 if (InheritedCtor) {
6710 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
6712 return BaseCtor->isConstexpr();
6780 if (Ctor && ClassDecl->
isUnion())
6799 for (
const auto &B : ClassDecl->
bases()) {
6801 if (!BaseType)
continue;
6805 InheritedCtor, Inherited))
6816 for (
const auto *F : ClassDecl->
fields()) {
6817 if (F->isInvalidDecl())
6823 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
6826 ConstArg && !F->isMutable()))
6840 struct ComputingExceptionSpec {
6851 ~ComputingExceptionSpec() {
6870 if (DFK.isSpecialMember())
6872 S, Loc, cast<CXXMethodDecl>(FD), DFK.asSpecialMember(),
nullptr);
6873 if (DFK.isComparison())
6875 DFK.asComparison());
6877 auto *CD = cast<CXXConstructorDecl>(FD);
6878 assert(CD->getInheritedConstructor() &&
6879 "only defaulted functions and inherited constructors have implicit " 6882 S, Loc, CD->getInheritedConstructor().getShadowDecl());
6909 auto ESI = IES.getExceptionSpec();
6912 UpdateExceptionSpec(FD, ESI);
6924 if (DefKind.isSpecialMember()
6925 ? CheckExplicitlyDefaultedSpecialMember(cast<CXXMethodDecl>(FD),
6926 DefKind.asSpecialMember())
6927 : CheckExplicitlyDefaultedComparison(S, FD, DefKind.asComparison()))
6936 "not an explicitly-defaulted special member");
6946 bool HadError =
false;
6958 bool DeleteOnTypeMismatch = getLangOpts().CPlusPlus2a &&
First;
6959 bool ShouldDeleteForTypeMismatch =
false;
6960 unsigned ExpectedParams = 1;
6961 if (CSM == CXXDefaultConstructor || CSM == CXXDestructor)
6971 if (DeleteOnTypeMismatch)
6972 ShouldDeleteForTypeMismatch =
true;
6982 bool CanHaveConstParam =
false;
6983 if (CSM == CXXCopyConstructor)
6985 else if (CSM == CXXCopyAssignment)
6989 if (CSM == CXXCopyAssignment || CSM == CXXMoveAssignment) {
6997 if (!Context.
hasSameType(ReturnType, ExpectedReturnType)) {
6998 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
6999 << (CSM == CXXMoveAssignment) << ExpectedReturnType;
7005 if (DeleteOnTypeMismatch)
7006 ShouldDeleteForTypeMismatch =
true;
7009 << (CSM == CXXMoveAssignment) << getLangOpts().CPlusPlus14;
7017 bool HasConstParam =
false;
7024 if (DeleteOnTypeMismatch)
7025 ShouldDeleteForTypeMismatch =
true;
7028 diag::err_defaulted_special_member_volatile_param) << CSM;
7033 if (HasConstParam && !CanHaveConstParam) {
7034 if (DeleteOnTypeMismatch)
7035 ShouldDeleteForTypeMismatch =
true;
7036 else if (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment) {
7038 diag::err_defaulted_special_member_copy_const_param)
7039 << (CSM == CXXCopyAssignment);
7044 diag::err_defaulted_special_member_move_const_param)
7045 << (CSM == CXXMoveAssignment);
7049 }
else if (ExpectedParams) {
7052 assert(CSM == CXXCopyAssignment &&
"unexpected non-ref argument");
7069 (getLangOpts().
CPlusPlus14 ? !isa<CXXDestructorDecl>(MD)
7070 : isa<CXXConstructorDecl>(MD))) &&
7074 ? diag::err_incorrect_defaulted_consteval
7075 : diag::err_incorrect_defaulted_constexpr)
7097 llvm::makeArrayRef(&ArgType,
7103 if (ShouldDeleteForTypeMismatch || ShouldDeleteSpecialMember(MD, CSM)) {
7106 if (!inTemplateInstantiation() && !HadError) {
7108 if (ShouldDeleteForTypeMismatch) {
7111 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
7114 if (ShouldDeleteForTypeMismatch && !HadError) {
7116 diag::warn_cxx17_compat_defaulted_method_type_mismatch) << CSM;
7122 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
7123 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
7124 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
7145 template<
typename Derived,
typename ResultList,
typename Result,
7147 class DefaultedComparisonVisitor {
7153 : S(S), RD(RD), FD(FD), DCK(DCK) {
7157 Fns.assign(Info->getUnqualifiedLookups().begin(),
7158 Info->getUnqualifiedLookups().end());
7162 ResultList visit() {
7171 llvm_unreachable(
"not a defaulted comparison");
7174 case DefaultedComparisonKind::ThreeWay:
7175 getDerived().visitSubobjects(Results, RD, ParamLvalType.
getQualifiers());
7178 case DefaultedComparisonKind::NotEqual:
7180 Results.add(getDerived().visitExpandedSubobject(
7181 ParamLvalType, getDerived().getCompleteObject()));
7184 llvm_unreachable(
"");
7188 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
7194 bool visitSubobjects(ResultList &Results,
CXXRecordDecl *Record,
7199 if (Results.add(getDerived().visitSubobject(
7201 getDerived().getBase(&
Base))))
7207 if (Field->isAnonymousStructOrUnion()) {
7208 if (visitSubobjects(Results, Field->getType()->getAsCXXRecordDecl(),
7216 if (Field->isMutable())
7221 if (Results.add(getDerived().visitSubobject(
7222 FieldType, getDerived().getField(Field))))
7230 Result visitSubobject(
QualType Type, Subobject Subobj) {
7233 if (
auto *CAT = dyn_cast_or_null<ConstantArrayType>(AT))
7234 return getDerived().visitSubobjectArray(CAT->getElementType(),
7235 CAT->getSize(), Subobj);
7236 return getDerived().visitExpandedSubobject(Type, Subobj);
7241 return getDerived().visitSubobject(Type, Subobj);
7254 struct DefaultedComparisonInfo {
7255 bool Deleted =
false;
7256 bool Constexpr =
true;
7259 static DefaultedComparisonInfo deleted() {
7260 DefaultedComparisonInfo Deleted;
7261 Deleted.Deleted =
true;
7265 bool add(
const DefaultedComparisonInfo &R) {
7266 Deleted |= R.Deleted;
7267 Constexpr &= R.Constexpr;
7275 struct DefaultedComparisonSubobject {
7276 enum { CompleteObject, Member,
Base }
Kind;
7283 class DefaultedComparisonAnalyzer
7284 :
public DefaultedComparisonVisitor<DefaultedComparisonAnalyzer,
7285 DefaultedComparisonInfo,
7286 DefaultedComparisonInfo,
7287 DefaultedComparisonSubobject> {
7289 enum DiagnosticKind { NoDiagnostics, ExplainDeleted, ExplainConstexpr };
7292 DiagnosticKind Diagnose;
7295 using Base = DefaultedComparisonVisitor;
7296 using Result = DefaultedComparisonInfo;
7297 using Subobject = DefaultedComparisonSubobject;
7303 DiagnosticKind Diagnose = NoDiagnostics)
7304 :
Base(S, RD, FD, DCK), Diagnose(Diagnose) {}
7308 DCK == DefaultedComparisonKind::ThreeWay) &&
7313 if (Diagnose == ExplainDeleted) {
7317 return Result::deleted();
7320 return Base::visit();
7324 Subobject getCompleteObject() {
7325 return Subobject{Subobject::CompleteObject,
nullptr, FD->
getLocation()};
7334 return Subobject{Subobject::Member, Field, Field->
getLocation()};
7337 Result visitExpandedSubobject(
QualType Type, Subobject Subobj) {
7342 if (Diagnose == ExplainDeleted) {
7343 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_reference_member)
7346 return Result::deleted();
7351 Expr *Args[] = {&Xi, &Xi};
7355 assert(OO !=
OO_None &&
"not an overloaded operator!");
7356 return visitBinaryOperator(OO, Args, Subobj);
7369 OO, !SpaceshipCandidates));
7376 if (Args[0]->getType()->isOverloadableType())
7388 switch (CandidateSet.BestViableFunction(S, FD->
getLocation(), Best)) {
7394 if ((DCK == DefaultedComparisonKind::NotEqual ||
7396 !Best->RewriteKind) {
7397 if (Diagnose == ExplainDeleted) {
7398 S.
Diag(Best->Function->getLocation(),
7399 diag::note_defaulted_comparison_not_rewritten_callee)
7402 return Result::deleted();
7412 CXXRecordDecl *ArgClass = Args[0]->getType()->getAsCXXRecordDecl();
7413 if (ArgClass && Best->FoundDecl.getDecl() &&
7415 QualType ObjectType = Subobj.Kind == Subobject::Member
7416 ? Args[0]->getType()
7419 ArgClass, Best->FoundDecl, ObjectType, Subobj.Loc,
7420 Diagnose == ExplainDeleted
7421 ? S.
PDiag(diag::note_defaulted_comparison_inaccessible)
7422 << FD << Subobj.
Kind << Subobj.Decl
7424 return Result::deleted();
7432 assert(!BestFD->isDeleted() &&
"wrong overload resolution result");
7434 if (Diagnose == ExplainConstexpr && !BestFD->isConstexpr()) {
7435 if (Subobj.Kind != Subobject::CompleteObject)
7436 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_not_constexpr)
7437 << Subobj.Kind << Subobj.Decl;
7438 S.
Diag(BestFD->getLocation(),
7439 diag::note_defaulted_comparison_not_constexpr_here);
7441 return Result::deleted();
7443 R.Constexpr &= BestFD->isConstexpr();
7447 if (
auto *BestFD = Best->Function) {
7452 if (BestFD->getReturnType()->isUndeducedType() &&
7458 if (Diagnose == NoDiagnostics) {
7461 diag::err_defaulted_comparison_cannot_deduce_undeduced_auto)
7462 << Subobj.Kind << Subobj.Decl;
7465 diag::note_defaulted_comparison_cannot_deduce_undeduced_auto)
7466 << Subobj.Kind << Subobj.Decl;
7467 S.
Diag(BestFD->getLocation(),
7468 diag::note_defaulted_comparison_cannot_deduce_callee)
7469 << Subobj.Kind << Subobj.Decl;
7471 return Result::deleted();
7474 BestFD->getCallResultType())) {
7475 R.Category = Info->Kind;
7477 if (Diagnose == ExplainDeleted) {
7478 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_cannot_deduce)
7479 << Subobj.Kind << Subobj.Decl
7480 << BestFD->getCallResultType().withoutLocalFastQualifiers();
7481 S.
Diag(BestFD->getLocation(),
7482 diag::note_defaulted_comparison_cannot_deduce_callee)
7483 << Subobj.Kind << Subobj.Decl;
7485 return Result::deleted();
7490 assert(Cat &&
"no category for builtin comparison?");
7501 if (Diagnose == ExplainDeleted) {
7504 Kind = OO == OO_EqualEqual ? 1 : 2;
7505 CandidateSet.NoteCandidates(
7507 Subobj.Loc, S.
PDiag(diag::note_defaulted_comparison_ambiguous)
7508 << FD << Kind << Subobj.
Kind << Subobj.Decl),
7511 R = Result::deleted();
7515 if (Diagnose == ExplainDeleted) {
7516 if ((DCK == DefaultedComparisonKind::NotEqual ||
7518 !Best->RewriteKind) {
7519 S.
Diag(Best->Function->getLocation(),
7520 diag::note_defaulted_comparison_not_rewritten_callee)
7524 diag::note_defaulted_comparison_calls_deleted)
7525 << FD << Subobj.
Kind << Subobj.Decl;
7529 R = Result::deleted();
7535 if (OO == OO_Spaceship &&
7539 if (!R.add(visitBinaryOperator(OO_EqualEqual, Args, Subobj,
7541 R.add(visitBinaryOperator(OO_Less, Args, Subobj, &CandidateSet));
7545 if (Diagnose == ExplainDeleted) {
7546 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_no_viable_function)
7547 << FD << Subobj.
Kind << Subobj.Decl;
7551 if (SpaceshipCandidates) {
7552 SpaceshipCandidates->NoteCandidates(
7557 diag::note_defaulted_comparison_no_viable_function_synthesized)
7558 << (OO == OO_EqualEqual ? 0 : 1);
7561 CandidateSet.NoteCandidates(
7566 R = Result::deleted();
7575 struct StmtListResult {
7576 bool IsInvalid =
false;
7583 Stmts.push_back(S.
get());
7590 class DefaultedComparisonSynthesizer
7591 :
public DefaultedComparisonVisitor<DefaultedComparisonSynthesizer,
7592 StmtListResult, StmtResult,
7593 std::pair<ExprResult, ExprResult>> {
7595 unsigned ArrayDepth = 0;
7598 using Base = DefaultedComparisonVisitor;
7599 using ExprPair = std::pair<ExprResult, ExprResult>;
7606 :
Base(S, RD, FD, DCK), Loc(BodyLoc) {}
7612 StmtListResult Stmts = visit();
7613 if (Stmts.IsInvalid)
7619 llvm_unreachable(
"not a defaulted comparison");
7630 auto OldStmts = std::move(Stmts.Stmts);
7631 Stmts.Stmts.clear();
7634 auto FinishCmp = [&] {
7635 if (
Expr *Prior = CmpSoFar.
get()) {
7637 if (RetVal.
isUnset() && Stmts.Stmts.empty())
7640 else if (Stmts.add(buildIfNotCondReturnFalse(Prior)))
7646 for (
Stmt *EAsStmt : llvm::reverse(OldStmts)) {
7650 if (FinishCmp() || Stmts.add(EAsStmt))
7665 std::reverse(Stmts.Stmts.begin(), Stmts.Stmts.end());
7672 case DefaultedComparisonKind::ThreeWay: {
7678 if (StrongOrdering.
isNull())
7683 RetVal = getDecl(EqualVD);
7686 RetVal = buildStaticCastToR(RetVal.
get());
7690 case DefaultedComparisonKind::NotEqual:
7692 RetVal = cast<Expr>(Stmts.Stmts.pop_back_val());
7702 Stmts.Stmts.push_back(ReturnStmt.
get());
7718 ExprPair getCompleteObject() {
7721 if (isa<CXXMethodDecl>(FD)) {
7727 LHS = getParam(Param++);
7735 ExprPair Obj = getCompleteObject();
7736 if (Obj.first.isInvalid() || Obj.second.isInvalid())
7746 ExprPair Obj = getCompleteObject();
7747 if (Obj.first.isInvalid() || Obj.second.isInvalid())
7770 assert(!False.
isInvalid() &&
"should never fail");
7772 if (ReturnFalse.isInvalid())
7790 llvm::raw_svector_ostream OS(Str);
7791 OS <<
"i" << ArrayDepth;
7802 auto IterRef = [&] {
7806 assert(!Ref.
isInvalid() &&
"can't reference our own variable?");
7812 Loc, BO_NE, IterRef(),
7814 assert(!Cond.
isInvalid() &&
"should never fail");
7818 assert(!Inc.isInvalid() &&
"should never fail");
7826 Subobj.first = Index(Subobj.first);
7827 Subobj.second = Index(Subobj.second);
7831 StmtResult Substmt = visitSubobject(Type, Subobj);
7840 if (
Expr *ElemCmp = dyn_cast<Expr>(Substmt.
get())) {
7842 "should have non-expression statement");
7843 Substmt = buildIfNotCondReturnFalse(ElemCmp);
7857 if (Obj.first.isInvalid() || Obj.second.isInvalid())
7865 Obj.second.get(),
true,
7874 llvm_unreachable(
"not a defaulted comparison");
7884 case DefaultedComparisonKind::ThreeWay: {
7889 Op = buildStaticCastToR(Op.
get());
7909 if (VDRef.
get()->getType()->isOverloadableType())
7922 VDRef = getDecl(VD);
7935 case DefaultedComparisonKind::NotEqual:
7941 llvm_unreachable(
"");
7947 assert(!R->
isUndeducedType() &&
"type should have been deduced already");
7978 if (Op == OO_Spaceship) {
7979 Lookup(OO_ExclaimEqual);
7981 Lookup(OO_EqualEqual);
7990 assert(RD &&
"defaulted comparison is not defaulted in a class");
7999 Context, Operators.
pairs()));
8012 if (isa<CXXMethodDecl>(FD))
8013 ExpectedParmType1 = ExpectedParmType2;
8015 if (!Param->getType()->isDependentType() &&
8016 !Context.
hasSameType(Param->getType(), ExpectedParmType1) &&
8017 !Context.
hasSameType(Param->getType(), ExpectedParmType2)) {
8022 << (
int)DCK << Param->getType() << ExpectedParmType1
8023 << !isa<CXXMethodDecl>(FD)
8024 << ExpectedParmType2 << Param->getSourceRange();
8033 Diag(FD->
getLocation(), diag::err_defaulted_comparison_param_mismatch)
8044 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
8045 assert(!MD->
isStatic() &&
"comparison function cannot be a static member");
8049 InsertLoc = getLocForEndOfToken(Loc.getRParenLoc());
8062 FPT->getParamTypes(), EPI));
8072 if (DCK != DefaultedComparisonKind::ThreeWay &&
8075 Diag(FD->
getLocation(), diag::err_defaulted_comparison_return_type_not_bool)
8083 if (DCK == DefaultedComparisonKind::ThreeWay &&
8088 diag::err_defaulted_comparison_deduced_return_type_not_auto)
8100 DefaultedComparisonInfo Info =
8101 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK).visit();
8117 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8118 DefaultedComparisonAnalyzer::ExplainDeleted)
8124 if (!inTemplateInstantiation() && !FD->
isImplicit()) {
8127 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8128 DefaultedComparisonAnalyzer::ExplainDeleted)
8136 if (DCK == DefaultedComparisonKind::ThreeWay &&
8143 QualType Cat = CheckComparisonCategoryType(
8144 Info.Category, RetLoc, ComparisonCategoryUsage::DefaultedOperator);
8164 diag::err_incorrect_defaulted_comparison_constexpr)
8166 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8167 DefaultedComparisonAnalyzer::ExplainConstexpr)
8177 if (First && !FD->
isConstexpr() && Info.Constexpr)
8188 EPI.ExceptionSpec.SourceDecl = FD;
8190 FPT->getParamTypes(), EPI));
8202 pushCodeSynthesisContext(Ctx);
8204 if (
FunctionDecl *EqualEqual = SubstSpaceshipAsEqualEqual(RD, Spaceship))
8205 EqualEqual->setImplicit();
8207 popCodeSynthesisContext();
8228 DefaultedComparisonSynthesizer(*
this, RD, FD, DCK, BodyLoc).build();
8242 L->CompletedImplicitDefinition(FD);
8249 ComputingExceptionSpec CES(S, FD, Loc);
8276 DefaultedComparisonSynthesizer(S, RD, FD, DCK, BodyLoc).build();
8277 if (!Body.isInvalid())
8290 decltype(DelayedOverridingExceptionSpecChecks) Overriding;
8291 decltype(DelayedEquivalentExceptionSpecChecks)
Equivalent;
8293 std::swap(Overriding, DelayedOverridingExceptionSpecChecks);
8294 std::swap(
Equivalent, DelayedEquivalentExceptionSpecChecks);
8298 for (
auto &Check : Overriding)
8299 CheckOverridingFunctionExceptionSpec(Check.first, Check.second);
8304 CheckEquivalentExceptionSpec(Check.second, Check.first);
8310 template<
typename Derived>
8311 struct SpecialMemberVisitor {
8318 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
8322 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
8327 IsConstructor =
true;
8331 IsAssignment =
true;
8336 llvm_unreachable(
"invalid special member kind");
8342 ConstArg = RT->getPointeeType().isConstQualified();
8346 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
8349 bool isMove()
const {
8355 unsigned Quals,
bool IsMutable) {
8357 ConstArg && !IsMutable);
8367 cast<CXXConstructorDecl>(MD)->getInheritedConstructor().getConstructor();
8374 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
8381 return B->getBaseTypeLoc();
8383 return Subobj.get<
FieldDecl*>()->getLocation();
8388 VisitNonVirtualBases,
8393 VisitPotentiallyConstructedBases,
8399 bool visit(BasesToVisit Bases) {
8402 if (Bases == VisitPotentiallyConstructedBases)
8403 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
8405 for (
auto &B : RD->
bases())
8406 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
8407 getDerived().visitBase(&B))
8410 if (Bases == VisitAllBases)
8411 for (
auto &B : RD->
vbases())
8412 if (getDerived().visitBase(&B))
8415 for (
auto *F : RD->
fields())
8416 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
8417 getDerived().visitField(F))
8426 struct SpecialMemberDeletionInfo
8427 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
8432 bool AllFieldsAreConst;
8437 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
8438 Loc(MD->
getLocation()), AllFieldsAreConst(
true) {}
8449 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
8452 bool shouldDeleteForField(
FieldDecl *FD);
8453 bool shouldDeleteForAllConstMembers();
8455 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
8457 bool shouldDeleteForSubobjectCall(Subobject Subobj,
8459 bool IsDtorCallInCtor);
8467 bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
8488 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
8490 bool IsDtorCallInCtor) {
8497 DiagKind = !Decl ? 0 : 1;
8500 else if (!isAccessible(Subobj, Decl))
8518 diag::note_deleted_special_member_class_subobject)
8519 << getEffectiveCSM() << MD->
getParent() <<
true 8520 << Field << DiagKind << IsDtorCallInCtor <<
false;
8524 diag::note_deleted_special_member_class_subobject)
8525 << getEffectiveCSM() << MD->
getParent() <<
false 8526 << Base->
getType() << DiagKind << IsDtorCallInCtor
8540 bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
8543 bool IsMutable = Field && Field->
isMutable();
8561 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
8568 if (IsConstructor) {
8571 false,
false,
false,
false,
false);
8572 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
8579 bool SpecialMemberDeletionInfo::shouldDeleteForVariantObjCPtrMember(
8593 auto *ParentClass = cast<CXXRecordDecl>(FD->
getParent());
8595 diag::note_deleted_special_member_class_subobject)
8596 << getEffectiveCSM() << ParentClass <<
true 8597 << FD << 4 <<
false <<
true;
8614 if (
auto *BaseCtor = SMOR.
getMethod()) {
8619 if (BaseCtor->isDeleted() && Diagnose) {
8621 diag::note_deleted_special_member_class_subobject)
8622 << getEffectiveCSM() << MD->
getParent() <<
false 8623 << Base->
getType() << 1 <<
false 8627 return BaseCtor->isDeleted();
8629 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
8634 bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
8638 if (inUnion() && shouldDeleteForVariantObjCPtrMember(FD, FieldType))
8646 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
8647 << !!ICI << MD->
getParent() << FD << FieldType << 0;
8658 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
8664 AllFieldsAreConst =
false;
8670 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
8674 }
else if (IsAssignment) {
8679 << isMove() << MD->
getParent() << FD << FieldType << 0;
8694 if (!inUnion() && FieldRecord->
isUnion() &&
8696 bool AllVariantFieldsAreConst =
true;
8699 for (
auto *UI : FieldRecord->
fields()) {
8702 if (shouldDeleteForVariantObjCPtrMember(&*UI, UnionFieldType))
8706 AllVariantFieldsAreConst =
false;
8709 if (UnionFieldRecord &&
8710 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
8720 diag::note_deleted_default_ctor_all_const)
8730 if (shouldDeleteForClassSubobject(FieldRecord, FD,
8741 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
8745 bool AnyFields =
false;
8747 if ((AnyFields = !F->isUnnamedBitfield()))
8753 diag::note_deleted_default_ctor_all_const)
8779 (CSM == CXXDefaultConstructor || CSM == CXXCopyAssignment)) {
8788 if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
8797 (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
8803 bool DeletesOnlyMatchingCopy =
8804 getLangOpts().MSVCCompat &&
8808 (!DeletesOnlyMatchingCopy || CSM == CXXCopyConstructor)) {
8809 if (!Diagnose)
return true;
8812 for (
auto *I : RD->
ctors()) {
8813 if (I->isMoveConstructor()) {
8814 UserDeclaredMove = I;
8818 assert(UserDeclaredMove);
8820 (!DeletesOnlyMatchingCopy || CSM == CXXCopyAssignment)) {
8821 if (!Diagnose)
return true;
8824 for (
auto *I : RD->
methods()) {
8825 if (I->isMoveAssignmentOperator()) {
8826 UserDeclaredMove = I;
8830 assert(UserDeclaredMove);
8833 if (UserDeclaredMove) {
8835 diag::note_deleted_copy_user_declared_move)
8836 << (CSM == CXXCopyAssignment) << RD
8848 if (CSM == CXXDestructor && MD->
isVirtual()) {
8853 OperatorDelete,
false)) {
8860 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
8868 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
8869 : SMI.VisitPotentiallyConstructedBases))
8872 if (SMI.shouldDeleteForAllConstMembers())
8875 if (getLangOpts().CUDA) {
8882 assert(ICI || CSM == getSpecialMember(MD));
8885 RealCSM = getSpecialMember(MD);
8887 return inferCUDATargetForImplicitSpecialMember(RD, RealCSM, MD,
8888 SMI.ConstArg, Diagnose);
8896 assert(DFK &&
"not a defaultable function");
8900 ShouldDeleteSpecialMember(cast<CXXMethodDecl>(FD), DFK.
asSpecialMember(),
8903 DefaultedComparisonAnalyzer(
8905 DFK.
asComparison(), DefaultedComparisonAnalyzer::ExplainDeleted)
8927 *Selected =
nullptr;
8931 llvm_unreachable(
"not a special member");
8949 for (
auto *CI : RD->
ctors()) {
8950 if (!CI->isDefaultConstructor())
8957 *Selected = DefCtor;
8990 }
else if (!Selected) {
8998 goto NeedOverloadResolution;
9008 }
else if (!Selected) {
9013 goto NeedOverloadResolution;
9017 NeedOverloadResolution:
9045 llvm_unreachable(
"unknown special method kind");
9049 for (
auto *CI : RD->
ctors())
9050 if (!CI->isImplicit())
9054 typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
9057 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
9087 ConstRHS, TAH, Diagnose ? &Selected :
nullptr))
9095 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
9098 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
9099 }
else if (!Selected)
9100 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
9105 << Kind << SubType.getUnqualifiedType() << CSM;
9107 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
9108 << Kind << SubType.getUnqualifiedType() << CSM;
9113 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
9114 << Kind << SubType.getUnqualifiedType() << CSM;
9132 for (
const auto *FI : RD->
fields()) {
9133 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
9139 if (FI->isAnonymousStructOrUnion()) {
9141 CSM, ConstArg, TAH, Diagnose))
9152 S.
Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI;
9162 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
9167 bool ConstRHS = ConstArg && !FI->isMutable();
9181 bool ConstArg = (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment);
9192 assert(!MD->
isUserProvided() && CSM != CXXInvalid &&
"not special enough");
9196 bool ConstArg =
false;
9202 case CXXDefaultConstructor:
9207 case CXXCopyConstructor:
9208 case CXXCopyAssignment: {
9224 case CXXMoveConstructor:
9225 case CXXMoveAssignment: {
9241 llvm_unreachable(
"not a special member");
9247 diag::note_nontrivial_default_arg)
9266 for (
const auto &BI : RD->bases())
9289 if (CSM == CXXDestructor && MD->
isVirtual()) {
9302 if (RD->getNumVBases()) {
9312 for (
const auto *MI : RD->methods()) {
9313 if (MI->isVirtual()) {
9315 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
9320 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
9328 struct FindHiddenVirtualMethod {
9331 llvm::SmallPtrSet<const CXXMethodDecl *, 8> OverridenAndUsingBaseMethods;
9336 static bool CheckMostOverridenMethods(
9338 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
9342 if (CheckMostOverridenMethods(O, Methods))
9358 bool foundSameNameMethod =
false;
9365 foundSameNameMethod =
true;
9382 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
9383 overloadedMethods.push_back(MD);
9387 if (foundSameNameMethod)
9388 OverloadedMethods.append(overloadedMethods.begin(),
9389 overloadedMethods.end());
9390 return foundSameNameMethod;
9397 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
9415 FindHiddenVirtualMethod FHVM;
9426 ND = shad->getTargetDecl();
9432 OverloadedMethods = FHVM.OverloadedMethods;
9437 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
9440 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
9441 HandleFunctionTypeMismatch(PD, MD->
getType(), overloadedMD->
getType());
9452 if (Diags.isIgnored(diag::warn_overloaded_virtual, MD->
getLocation()))
9456 FindHiddenVirtualMethods(MD, OverloadedMethods);
9457 if (!OverloadedMethods.empty()) {
9459 << MD << (OverloadedMethods.size() > 1);
9461 NoteHiddenVirtualMethods(MD, OverloadedMethods);
9466 auto PrintDiagAndRemoveAttr = [&]() {
9470 diag::ext_cannot_use_trivial_abi) << &RD;
9476 PrintDiagAndRemoveAttr();
9480 for (
const auto &B : RD.
bases()) {
9483 if ((!B.getType()->isDependentType() &&
9484 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) ||
9486 PrintDiagAndRemoveAttr();
9491 for (
const auto *FD : RD.
fields()) {
9496 PrintDiagAndRemoveAttr();
9501 if (!RT->isDependentType() &&
9503 PrintDiagAndRemoveAttr();
9515 AdjustDeclIfTemplate(TagDecl);
9518 if (AL.getKind() != ParsedAttr::AT_Visibility)
9521 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored) << AL;
9524 ActOnFields(S, RLoc, TagDecl, llvm::makeArrayRef(
9526 reinterpret_cast<Decl**>(FieldCollector->getCurFields()),
9527 FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList);
9529 CheckCompletedCXXClass(S, cast<CXXRecordDecl>(TagDecl));
9544 FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Friend->getFriendDecl());
9555 Spaceships.push_back(FD);
9564 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
9565 if (FD->isExplicitlyDefaulted())
9566 Spaceships.push_back(FD);
9577 ++getASTContext().NumImplicitDefaultConstructors;
9580 DeclareImplicitDefaultConstructor(ClassDecl);
9584 ++getASTContext().NumImplicitCopyConstructors;
9591 DeclareImplicitCopyConstructor(ClassDecl);
9602 DeclareImplicitCopyConstructor(ClassDecl);
9606 ++getASTContext().NumImplicitMoveConstructors;
9610 DeclareImplicitMoveConstructor(ClassDecl);
9614 ++getASTContext().NumImplicitCopyAssignmentOperators;
9623 DeclareImplicitCopyAssignment(ClassDecl);
9627 ++getASTContext().NumImplicitMoveAssignmentOperators;
9633 DeclareImplicitMoveAssignment(ClassDecl);
9637 ++getASTContext().NumImplicitDestructors;
9645 DeclareImplicitDestructor(ClassDecl);
9654 if (getLangOpts().CPlusPlus2a) {
9657 DefaultedSpaceships);
9658 for (
auto *FD : DefaultedSpaceships)
9659 DeclareImplicitEqualityComparison(ClassDecl, FD);
9672 D = TD->getTemplatedDecl();
9674 if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
9675 ParameterLists.push_back(PSD->getTemplateParameters());
9678 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
9679 ParameterLists.push_back(DD->getTemplateParameterList(i));
9683 ParameterLists.push_back(FTD->getTemplateParameters());
9687 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
9688 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
9689 ParameterLists.push_back(TD->getTemplateParameterList(i));
9693 ParameterLists.push_back(CTD->getTemplateParameters());
9699 if (Params->size() > 0)
9704 if (Param->getDeclName()) {
9706 IdResolver.AddDecl(Param);
9715 if (!RecordD)
return;
9716 AdjustDeclIfTemplate(RecordD);
9718 PushDeclContext(S, Record);
9722 if (!RecordD)
return;
9735 IdResolver.AddDecl(Param);
9767 IdResolver.AddDecl(Param);
9780 AdjustDeclIfTemplate(MethodD);
9789 CheckConstructor(Constructor);
9793 CheckCXXDefaultArguments(Method);
9801 bool DiagOccured =
false;
9803 [DiagID, &S, &DiagOccured](
DeclSpec::TQ, StringRef QualName,
9849 diagnoseIgnoredQualifiers(
9907 const char *ConstRef
9910 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
9936 FindDeallocationFunctionForDestructor(Loc, RD)) {
9937 Expr *ThisArg =
nullptr;
9942 if (OperatorDelete->isDestroyingOperatorDelete()) {
9943 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
9950 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
9951 assert(!This.
isInvalid() &&
"couldn't form 'this' expr in dtor?");
9952 This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
9953 if (This.isInvalid()) {
9956 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
9959 ThisArg = This.get();
9963 DiagnoseUseOfDecl(OperatorDelete, Loc);
9964 MarkFunctionReferenced(Loc, OperatorDelete);
9988 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
9991 if (TST->isTypeAlias())
9993 << DeclaratorType << 1;
10026 diagnoseIgnoredQualifiers(diag::err_destructor_return_type, TypeQuals,
10147 if (Proto->getNumParams() > 0) {
10153 }
else if (Proto->isVariadic()) {
10160 if (Proto->getReturnType() != ConvType) {
10161 bool NeedsTypedef =
false;
10165 bool PastFunctionChunk =
false;
10167 switch (Chunk.Kind) {
10169 if (!PastFunctionChunk) {
10170 if (Chunk.Fun.HasTrailingReturnType) {
10172 GetTypeFromParser(Chunk.Fun.getTrailingReturnType(), &TRT);
10175 PastFunctionChunk =
true;
10180 NeedsTypedef =
true;
10202 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
10203 DB << Before <<
After;
10205 if (!NeedsTypedef) {
10209 if (After.isInvalid() && ConvTSI) {
10217 }
else if (!Proto->getReturnType()->isDependentType()) {
10218 DB << 1 << Proto->getReturnType();
10220 DB << 2 << Proto->getReturnType();
10231 ConvType = Proto->getReturnType();
10254 if (DS.hasExplicitSpecifier() && !getLangOpts().CPlusPlus2a)
10255 Diag(DS.getExplicitSpecLoc(),
10256 getLangOpts().CPlusPlus11
10257 ? diag::warn_cxx98_compat_explicit_conversion_functions
10258 : diag::ext_explicit_conversion_functions)
10267 assert(Conversion &&
"Expected to receive a conversion function declaration");
10285 ConvType = ConvTypeRef->getPointeeType();
10289 else if (ConvType->isRecordType()) {
10291 if (ConvType == ClassType)
10294 else if (IsDerivedFrom(Conversion->
getLocation(), ClassType, ConvType))
10296 << ClassType << ConvType;
10297 }
else if (ConvType->isVoidType()) {
10299 << ClassType << ConvType;
10304 return ConversionTemplate;
10312 struct BadSpecifierDiagnoser {
10315 ~BadSpecifierDiagnoser() {
10319 template<
typename T>
void check(
SourceLocation SpecLoc, T Spec) {
10323 return check(SpecLoc,
10329 if (!Specifiers.empty()) Specifiers +=
" ";
10330 Specifiers += Spec;
10335 std::string Specifiers;
10347 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
10352 if (!CurContext->getRedeclContext()->Equals(
10355 << GuidedTemplateDecl;
10356 Diag(GuidedTemplateDecl->
getLocation(), diag::note_template_decl_here);
10361 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
10362 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
10363 DS.isNoreturnSpecified() || DS.hasConstexprSpecifier()) {
10364 BadSpecifierDiagnoser Diagnoser(
10366 diag::err_deduction_guide_invalid_specifier);
10368 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
10373 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
10374 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
10375 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
10376 DS.ClearConstexprSpec();
10378 Diagnoser.check(DS.getConstSpecLoc(),
"const");
10379 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
10380 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
10381 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
10382 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
10383 DS.ClearTypeQualifiers();
10385 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
10386 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
10387 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
10388 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
10389 DS.ClearTypeSpecType();
10396 bool FoundFunction =
false;
10402 diag::err_deduction_guide_with_complex_decl)
10406 if (!Chunk.Fun.hasTrailingReturnType()) {
10408 diag::err_deduction_guide_no_trailing_return_type);
10414 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
10416 QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
10417 assert(TSI &&
"deduction guide has valid type but invalid return type?");
10418 bool AcceptableReturnType =
false;
10419 bool MightInstantiateToSpecialization =
false;
10422 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
10423 bool TemplateMatches =
10426 AcceptableReturnType =
true;
10431 MightInstantiateToSpecialization = !(TD && isa<ClassTemplateDecl>(TD) &&
10435 MightInstantiateToSpecialization =
true;
10438 if (!AcceptableReturnType) {
10440 diag::err_deduction_guide_bad_trailing_return_type)
10441 << GuidedTemplate << TSI->
getType()
10442 << MightInstantiateToSpecialization
10448 FoundFunction =
true;
10465 assert(*IsInline != PrevNS->
isInline());
10473 if (*IsInline && II && II->
getName().startswith(
"__atomic") &&
10478 NS->setInline(*IsInline);
10481 for (
auto *I : PrevNS->
decls())
10482 if (
auto *ND = dyn_cast<NamedDecl>(I))
10490 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
10493 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
10508 bool IsInline = InlineLoc.
isValid();
10509 bool IsInvalid =
false;
10510 bool IsStd =
false;
10511 bool AddToKnown =
false;
10527 LookupResult R(*
this, II, IdentLoc, LookupOrdinaryName,
10528 ForExternalRedeclaration);
10529 LookupQualifiedName(R, CurContext->getRedeclContext());
10532 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
10536 if (IsInline != PrevNS->
isInline())
10538 &IsInline, PrevNS);
10539 }
else if (PrevDecl) {
10541 Diag(Loc, diag::err_redefinition_different_kind)
10543 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
10546 }
else if (II->
isStr(
"std") &&
10547 CurContext->getRedeclContext()->isTranslationUnit()) {
10550 PrevNS = getStdNamespace();
10552 AddToKnown = !IsInline;
10555 AddToKnown = !IsInline;
10569 if (PrevNS && IsInline != PrevNS->
isInline())
10571 &IsInline, PrevNS);
10575 StartLoc, Loc, II, PrevNS);
10579 ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
10580 AddPragmaAttributes(DeclRegionScope, Namespc);
10583 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
10584 PushNamespaceVisibilityAttr(
Attr, Loc);
10587 StdNamespace = Namespc;
10589 KnownNamespaces[Namespc] =
false;
10592 PushOnScopeChains(Namespc, DeclRegionScope);
10597 TU->setAnonymousNamespace(Namespc);
10599 cast<NamespaceDecl>(
Parent)->setAnonymousNamespace(Namespc);
10602 CurContext->addDecl(Namespc);
10633 ActOnDocumentableDecl(Namespc);
10640 PushDeclContext(NamespcScope, Namespc);
10648 return AD->getNamespace();
10649 return dyn_cast_or_null<NamespaceDecl>(D);
10655 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
10656 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
10659 if (Namespc->
hasAttr<VisibilityAttr>())
10660 PopPragmaVisibility(
true, RBrace);
10662 if (DeferredExportedNamespaces.erase(Namespc))
10667 return cast_or_null<CXXRecordDecl>(
10676 return cast_or_null<NamespaceDecl>(
10681 if (!StdExperimentalNamespaceCache) {
10682 if (
auto Std = getStdNamespace()) {
10685 if (!LookupQualifiedName(
Result,
Std) ||
10686 !(StdExperimentalNamespaceCache =
10688 Result.suppressDiagnostics();
10691 return StdExperimentalNamespaceCache;
10703 struct InvalidSTLDiagnoser {
10709 const VarDecl *VD =
nullptr) {
10711 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
10712 << TyForDiags << ((int)Sel);
10713 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
10714 assert(!Name.empty());
10718 if (Sel == USS_InvalidMember) {
10719 S.
Diag(VD->getLocation(), diag::note_var_declared_here)
10720 << VD << VD->getSourceRange();
10731 "Looking for comparison category type outside of C++.");
10744 if (Info && FullyCheckedComparisonCategories[static_cast<unsigned>(Kind)]) {
10747 if (RequireCompleteType(Loc, TyForDiags(Info), diag::err_incomplete_type))
10755 std::string NameForDiags =
"std::";
10757 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
10758 << NameForDiags << (int)Usage;
10762 assert(Info->
Kind == Kind);
10770 if (RequireCompleteType(Loc, TyForDiags(Info), diag::err_incomplete_type))
10773 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags(Info)};
10776 return UnsupportedSTLError(USS_NonTrivial);
10784 return UnsupportedSTLError();
10793 !FIt->getType()->isIntegralOrEnumerationType()) {
10794 return UnsupportedSTLError();
10804 return UnsupportedSTLError(USS_MissingMember, MemName);
10807 assert(VD &&
"should not be null!");
10814 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
10820 return UnsupportedSTLError();
10822 MarkVariableReferenced(Loc, VD);
10827 FullyCheckedComparisonCategories[
static_cast<unsigned>(
Kind)] =
true;
10834 if (!StdNamespace) {
10840 &PP.getIdentifierTable().get(
"std"),
10845 return getStdNamespace();
10850 "Looking for std::initializer_list outside of C++.");
10865 if (!Specialization)
10872 Template = dyn_cast_or_null<ClassTemplateDecl>(
10873 TST->getTemplateName().getAsTemplateDecl());
10874 Arguments = TST->getArgs();
10879 if (!StdInitializerList) {
10883 &PP.getIdentifierTable().get(
"initializer_list") ||
10884 !getStdNamespace()->InEnclosingNamespaceSetOf(
10892 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
10896 StdInitializerList = Template;
10911 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
10918 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
10923 Result.suppressDiagnostics();
10926 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
10934 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
10935 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
10943 if (!StdInitializerList) {
10945 if (!StdInitializerList)
10954 CheckTemplateIdType(
TemplateName(StdInitializerList), Loc, Args));
10971 return isStdInitializerList(ArgType,
nullptr);
10978 case Decl::TranslationUnit:
10980 case Decl::LinkageSpec:
10992 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
10994 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
10998 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
10999 return std::make_unique<NamespaceValidatorCCC>(*this);
11010 NamespaceValidatorCCC CCC{};
11015 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
11016 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
11017 Ident->
getName().equals(CorrectedStr);
11019 S.
PDiag(diag::err_using_directive_member_suggest)
11020 << Ident << DC << DroppedSpecifier << SS.getRange(),
11021 S.
PDiag(diag::note_namespace_defined_here));
11024 S.
PDiag(diag::err_using_directive_suggest) << Ident,
11025 S.
PDiag(diag::note_namespace_defined_here));
11027 R.
addDecl(Corrected.getFoundDecl());
11038 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
11039 assert(NamespcName &&
"Invalid NamespcName.");
11040 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
11053 LookupResult R(*
this, NamespcName, IdentLoc, LookupNamespaceName);
11054 LookupParsedName(R, S, &SS);
11063 NamespcName->
isStr(
"std")) {
11064 Diag(IdentLoc, diag::ext_using_undefined_std);
11065 R.
addDecl(getOrCreateStdNamespace());
11075 assert(NS &&
"expected namespace decl");
11078 DiagnoseUseOfDecl(Named, IdentLoc);
11093 while (CommonAncestor && !CommonAncestor->
Encloses(CurContext))
11094 CommonAncestor = CommonAncestor->
getParent();
11098 IdentLoc, Named, CommonAncestor);
11101 !SourceMgr.isInMainFile(SourceMgr.getExpansionLoc(IdentLoc))) {
11102 Diag(IdentLoc, diag::warn_using_directive_in_header);
11105 PushUsingDirective(S, UDir);
11107 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
11111 ProcessDeclAttributeList(S, UDir, AttrList);
11154 getLangOpts().CPlusPlus11
11155 ? diag::warn_cxx98_compat_using_decl_constructor
11156 : diag::err_using_decl_constructor)
11173 llvm_unreachable(
"cannot parse qualified deduction guide name");
11184 ? diag::err_access_decl
11185 : diag::warn_access_decl_deprecated)
11190 if (DiagnoseUnexpandedParameterPack(SS, UPPC_UsingDeclaration) ||
11191 DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC_UsingDeclaration))
11196 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
11203 BuildUsingDeclaration(S, AS, UsingLoc, TypenameLoc.
isValid(), TypenameLoc,
11204 SS, TargetNameInfo, EllipsisLoc, AttrList,
11207 PushOnScopeChains(UD, S,
false);
11222 return Context.
hasSameType(TD1->getUnderlyingType(),
11223 TD2->getUnderlyingType());
11253 if (!getLangOpts().
CPlusPlus11 && CurContext->isRecord()) {
11257 if (isa<EnumDecl>(OrigDC)) OrigDC = OrigDC->
getParent();
11262 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(OrigRec)) {
11263 if (OrigDC == CurContext) {
11265 diag::err_using_decl_nested_name_specifier_is_current_class)
11273 diag::err_using_decl_nested_name_specifier_is_not_base_class)
11275 << cast<CXXRecordDecl>(CurContext)
11283 if (Previous.
empty())
return false;
11286 if (isa<UsingShadowDecl>(Target))
11287 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
11294 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
11295 bool FoundEquivalentDecl =
false;
11302 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D))
11305 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
11310 !isa<IndirectFieldDecl>(Target) &&
11311 !isa<UnresolvedUsingValueDecl>(
Target) &&
11312 DiagnoseClassNameShadow(
11320 PrevShadow = Shadow;
11321 FoundEquivalentDecl =
true;
11322 }
else if (isEquivalentInternalLinkageDeclaration(D, Target)) {
11325 FoundEquivalentDecl =
true;
11329 (isa<TagDecl>(D) ? Tag : NonTag) = D;
11332 if (FoundEquivalentDecl)
11337 switch (CheckOverload(
nullptr, FD, Previous, OldDecl,
11342 case Ovl_NonFunction:
11351 if (CurContext->isRecord())
11367 if (isa<TagDecl>(Target)) {
11369 if (!Tag)
return false;
11373 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
11379 if (!NonTag)
return false;
11392 for (
auto &B : Derived->
bases())
11393 if (B.getType()->getAsCXXRecordDecl() == Base)
11394 return B.isVirtual();
11395 llvm_unreachable(
"not a direct base class");
11405 if (isa<UsingShadowDecl>(Target)) {
11406 Target = cast<UsingShadowDecl>(
Target)->getTargetDecl();
11407 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
11411 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
11412 NonTemplateTarget = TargetTD->getTemplatedDecl();
11415 if (NonTemplateTarget && isa<CXXConstructorDecl>(NonTemplateTarget)) {
11416 bool IsVirtualBase =
11420 Context, CurContext, UD->
getLocation(), UD, Orig, IsVirtualBase);
11434 PushOnScopeChains(Shadow, S);
11436 CurContext->addDecl(Shadow);
11472 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
11480 IdResolver.RemoveDecl(Shadow);
11493 bool &AnyDependentBases) {
11497 for (
auto &Base : Derived->
bases()) {
11499 if (CanonicalDesiredBase == BaseType)
11501 if (BaseType->isDependentType())
11502 AnyDependentBases =
true;
11510 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
11512 : HasTypenameKeyword(HasTypenameKeyword),
11513 IsInstantiation(IsInstantiation), OldNNS(NNS),
11514 RequireMemberOf(RequireMemberOf) {}
11516 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
11520 if (!ND || isa<NamespaceDecl>(ND))
11530 if (RequireMemberOf) {
11532 if (FoundRecord && FoundRecord->isInjectedClassName()) {
11553 bool AnyDependentBases =
false;
11556 AnyDependentBases) &&
11557 !AnyDependentBases)
11568 if (FoundRecord && FoundRecord->isInjectedClassName())
11572 if (isa<TypeDecl>(ND))
11573 return HasTypenameKeyword || !IsInstantiation;
11575 return !HasTypenameKeyword;
11578 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
11579 return std::make_unique<UsingValidatorCCC>(*this);
11583 bool HasTypenameKeyword;
11584 bool IsInstantiation;
11600 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
11602 assert(IdentLoc.isValid() &&
"Invalid TargetName location.");
11611 if (
auto *RD = dyn_cast<CXXRecordDecl>(CurContext))
11617 ForVisibleRedeclaration);
11620 LookupName(Previous, S);
11626 if (!isDeclInScope(D, CurContext, S))
11638 assert(IsInstantiation &&
"no scope in non-instantiation");
11639 if (CurContext->isRecord())
11640 LookupQualifiedName(Previous, CurContext);
11659 if (CheckUsingDeclRedeclaration(UsingLoc, HasTypenameKeyword,
11660 SS, IdentLoc, Previous))
11664 if (CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo,
11668 DeclContext *LookupContext = computeDeclContext(SS);
11671 if (!LookupContext || EllipsisLoc.
isValid()) {
11672 if (HasTypenameKeyword) {
11675 UsingLoc, TypenameLoc,
11677 IdentLoc, NameInfo.
getName(),
11681 QualifierLoc, NameInfo, EllipsisLoc);
11684 CurContext->addDecl(D);
11688 auto Build = [&](
bool Invalid) {
11691 UsingName, HasTypenameKeyword);
11693 CurContext->addDecl(UD);
11697 auto BuildInvalid = [&]{
return Build(
true); };
11698 auto BuildValid = [&]{
return Build(
false); };
11700 if (RequireCompleteDeclContext(SS, LookupContext))
11701 return BuildInvalid();
11710 if (!IsInstantiation)
11715 if (CurContext->isRecord()) {
11720 LookupQualifiedName(R, LookupContext);
11733 if (getLangOpts().
CPlusPlus14 && II && II->isStr(
"gets") &&
11734 CurContext->isStdNamespace() &&
11735 isa<TranslationUnitDecl>(LookupContext) &&
11736 getSourceManager().isInSystemHeader(UsingLoc))
11738 UsingValidatorCCC CCC(HasTypenameKeyword, IsInstantiation, SS.
getScopeRep(),
11742 CTK_ErrorRecovery)) {
11745 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
11746 << NameInfo.
getName() << LookupContext << 0
11751 NamedDecl *ND = Corrected.getCorrectionDecl();
11753 return BuildInvalid();
11759 RD = cast<CXXRecordDecl>(RD->
getParent());
11762 if (Corrected.WillReplaceSpecifier()) {
11764 Builder.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
11771 auto *CurClass = cast<CXXRecordDecl>(CurContext);
11774 UsingName.setNamedTypeInfo(
nullptr);
11775 for (
auto *Ctor : LookupConstructors(RD))
11781 UsingName.setName(ND->getDeclName());
11785 Diag(IdentLoc, diag::err_no_member)
11786 << NameInfo.
getName() << LookupContext << SS.getRange();
11787 return BuildInvalid();
11792 return BuildInvalid();
11794 if (HasTypenameKeyword) {
11797 Diag(IdentLoc, diag::err_using_typename_non_type);
11799 Diag((*I)->getUnderlyingDecl()->getLocation(),
11800 diag::note_using_decl_target);
11801 return BuildInvalid();
11808 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
11810 return BuildInvalid();
11817 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
11819 return BuildInvalid();
11825 if (cast<EnumDecl>(ED->getDeclContext())->isScoped()) {
11826 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
11828 return BuildInvalid();
11835 if (UsingName.getName().getNameKind() ==
11840 if (CheckInheritingConstructorUsingDecl(UD))
11846 if (!CheckUsingShadowDecl(UD, *I, Previous, PrevDecl))
11847 BuildUsingShadowDecl(S, UD, *I, PrevDecl);
11855 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
11856 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
11857 isa<UsingPackDecl>(InstantiatedFrom));
11861 UPD->setAccess(InstantiatedFrom->
getAccess());
11862 CurContext->addDecl(UPD);
11868 assert(!UD->
hasTypename() &&
"expecting a constructor name");
11871 assert(SourceType &&
11872 "Using decl naming constructor doesn't have type in scope spec.");
11873 CXXRecordDecl *TargetClass = cast<CXXRecordDecl>(CurContext);
11876 bool AnyDependentBases =
false;
11878 AnyDependentBases);
11879 if (!Base && !AnyDependentBases) {
11881 diag::err_using_decl_constructor_not_in_direct_base)
11883 <<
QualType(SourceType, 0) << TargetClass;
11898 bool HasTypenameKeyword,
11911 if (!CurContext->getRedeclContext()->isRecord()) {
11917 if (Qual->
isDependent() && !HasTypenameKeyword) {
11918 for (
auto *D : Prev) {
11919 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
11920 bool OldCouldBeEnumerator =
11921 isa<UnresolvedUsingValueDecl>(D) || isa<EnumConstantDecl>(D);
11923 OldCouldBeEnumerator ? diag::err_redefinition
11924 : diag::err_redefinition_different_kind)
11925 << Prev.getLookupName();
11926 Diag(D->getLocation(), diag::note_previous_definition);
11939 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
11940 DTypename = UD->hasTypename();
11941 DQual = UD->getQualifier();
11943 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
11945 DQual = UD->getQualifier();
11947 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
11949 DQual = UD->getQualifier();
11954 if (HasTypenameKeyword != DTypename)
continue;
11963 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
11980 DeclContext *NamedContext = computeDeclContext(SS);
11982 if (!CurContext->isRecord()) {
11990 if ((HasTypename && !NamedContext) ||
11992 auto *RD = NamedContext
11995 if (RD && RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), RD))
11998 Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member)
12010 LookupQualifiedName(R, RD);
12015 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
12023 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
12033 if (getLangOpts().CPlusPlus11) {
12039 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
12054 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
12055 << (getLangOpts().CPlusPlus11 ? 4 : 3)
12068 if (!NamedContext) {
12082 diag::err_using_decl_nested_name_specifier_is_not_class)
12088 RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), NamedContext))
12091 if (getLangOpts().CPlusPlus11) {
12097 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(
12098 cast<CXXRecordDecl>(NamedContext))) {
12099 if (CurContext == NamedContext) {
12101 diag::err_using_decl_nested_name_specifier_is_current_class)
12106 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
12108 diag::err_using_decl_nested_name_specifier_is_not_base_class)
12110 << cast<CXXRecordDecl>(CurContext)
12132 llvm::SmallPtrSet<const CXXRecordDecl *, 4> Bases;
12134 Bases.insert(Base);
12139 if (!cast<CXXRecordDecl>(CurContext)->forallBases(Collect))
12145 return !Bases.count(Base);
12150 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
12151 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
12155 diag::err_using_decl_nested_name_specifier_is_not_base_class)
12157 << cast<CXXRecordDecl>(CurContext)
12172 "got alias-declaration outside of declaration scope");
12177 bool Invalid =
false;
12180 GetTypeFromParser(Type.
get(), &TInfo);
12182 if (DiagnoseClassNameShadow(CurContext, NameInfo))
12185 if (DiagnoseUnexpandedParameterPack(Name.
StartLocation, TInfo,
12186 UPPC_DeclarationType)) {
12193 TemplateParamLists.size()
12194 ? forRedeclarationInCurContext()
12195 : ForVisibleRedeclaration);
12200 Previous.getFoundDecl()->isTemplateParameter()) {
12206 "name in alias declaration must be an identifier");
12216 ProcessDeclAttributeList(S, NewTD, AttrList);
12217 AddPragmaAttributes(S, NewTD);
12219 CheckTypedefForVariablyModifiedType(S, NewTD);
12222 bool Redeclaration =
false;
12225 if (TemplateParamLists.size()) {
12229 if (TemplateParamLists.size() != 1) {
12230 Diag(UsingLoc, diag::err_alias_template_extra_headers)
12231 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
12232 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
12237 if (CheckTemplateDeclScope(S, TemplateParams))
12241 FilterLookupForScope(
Previous, CurContext, S,
false,
12244 Redeclaration =
true;
12247 if (!OldDecl && !Invalid) {
12248 Diag(UsingLoc, diag::err_redefinition_different_kind)
12259 if (TemplateParameterListsAreEqual(TemplateParams,
12262 TPL_TemplateMatch))
12263 OldTemplateParams =
12285 if (CheckTemplateParameterList(TemplateParams, OldTemplateParams,
12286 TPC_TypeAliasTemplate))
12299 else if (OldDecl) {
12301 CheckRedeclarationModuleOwnership(NewDecl, OldDecl);
12306 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
12307 setTagNameForLinkagePurposes(TD, NewTD);
12308 handleTagNumbering(TD, S);
12310 ActOnTypedefNameDecl(S, CurContext, NewTD,
Previous, Redeclaration);
12314 PushOnScopeChains(NewND, S);
12315 ActOnDocumentableDecl(NewND);
12326 LookupResult R(*
this, Ident, IdentLoc, LookupNamespaceName);
12327 LookupParsedName(R, S, &SS);
12334 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
12342 LookupResult PrevR(*
this, Alias, AliasLoc, LookupOrdinaryName,
12343 ForVisibleRedeclaration);
12344 LookupName(PrevR, S);
12348 DiagnoseTemplateParameterShadow(AliasLoc, PrevR.
getFoundDecl());
12353 FilterLookupForScope(PrevR, CurContext, S,
false,
12365 }
else if (isVisible(PrevDecl)) {
12366 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
12368 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
12369 << AD->getNamespace();
12372 }
else if (isVisible(PrevDecl)) {
12374 ? diag::err_redefinition
12375 : diag::err_redefinition_different_kind;
12376 Diag(AliasLoc, DiagID) << Alias;
12383 DiagnoseUseOfDecl(ND, IdentLoc);
12392 PushOnScopeChains(AliasDecl, S);
12397 struct SpecialMemberExceptionSpecInfo
12398 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
12406 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
12411 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
12414 void visitSubobjectCall(Subobject Subobj,
12424 auto *BaseClass = cast<CXXRecordDecl>(RT->getDecl());
12426 if (
auto *BaseCtor = SMOR.getMethod()) {
12427 visitSubobjectCall(Base, BaseCtor);
12431 visitClassSubobject(BaseClass, Base, 0);
12435 bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
12446 ExceptSpec.CalledExpr(E);
12448 ->getAs<RecordType>()) {
12449 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
12455 void SpecialMemberExceptionSpecInfo::visitClassSubobject(
CXXRecordDecl *Class,
12459 bool IsMutable = Field && Field->
isMutable();
12460 visitSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable));
12463 void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
12468 ExceptSpec.CalledDecl(getSubobjectLoc(Subobj), MD);
12476 if (Converted.
isUsable() && !Converted.
get()->isValueDependent()) {
12477 ExplicitSpec.
setKind(Result.getBoolValue()
12489 tryResolveExplicitSpecifier(ES);
12497 ComputingExceptionSpec CES(S, MD, Loc);
12504 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
12506 return Info.ExceptSpec;
12513 diag::err_exception_spec_incomplete_type))
12514 return Info.ExceptSpec;
12531 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
12532 : Info.VisitAllBases);
12534 return Info.ExceptSpec;
12539 struct DeclaringSpecialMember {
12543 bool WasAlreadyBeingDeclared;
12546 : S(S), D(RD, CSM), SavedContext(S, RD) {
12548 if (WasAlreadyBeingDeclared)
12569 ~DeclaringSpecialMember() {
12570 if (!WasAlreadyBeingDeclared) {
12577 bool isAlreadyBeingDeclared()
const {
12578 return WasAlreadyBeingDeclared;
12588 ForExternalRedeclaration);
12595 CheckFunctionDeclaration(S, FD, R,
false);
12598 void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
12604 LangAS AS = getDefaultCXXMethodAddrSpace();
12622 "Should not build implicit default constructor!");
12624 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDefaultConstructor);
12625 if (DSM.isAlreadyBeingDeclared())
12629 CXXDefaultConstructor,
12640 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
12647 if (getLangOpts().
CUDA) {
12648 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDefaultConstructor,
12654 setupImplicitSpecialMemberType(DefaultCon, Context.
VoidTy,
None);
12661 ++getASTContext().NumImplicitDefaultConstructorsDeclared;
12663 Scope *S = getScopeForContext(ClassDecl);
12664 CheckImplicitSpecialMemberDeclaration(S, DefaultCon);
12666 if (ShouldDeleteSpecialMember(DefaultCon, CXXDefaultConstructor))
12667 SetDeclDeleted(DefaultCon, ClassLoc);
12670 PushOnScopeChains(DefaultCon, S,
false);
12671 ClassDecl->
addDecl(DefaultCon);
12681 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
12686 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
12692 ResolveExceptionSpec(CurrentLocation,
12694 MarkVTableUsed(CurrentLocation, ClassDecl);
12699 if (SetCtorInitializers(Constructor,
false)) {
12711 L->CompletedImplicitDefinition(Constructor);
12714 DiagnoseUninitializedFields(*
this, Constructor);
12719 CheckDelayedMemberExceptionSpecs();
12740 ->getInheritedConstructor()
12743 return cast<CXXConstructorDecl>(Ctor);
12758 false, BaseCtor, &ICI);
12761 Context, Derived, UsingLoc, NameInfo, TInfo->
getType(), TInfo,
12774 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
12780 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
12784 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
12791 ParamDecls.push_back(PD);
12796 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
12799 Derived->
addDecl(DerivedCtor);
12801 if (ShouldDeleteSpecialMember(DerivedCtor, CXXDefaultConstructor, &ICI))
12802 SetDeclDeleted(DerivedCtor, UsingLoc);
12804 return DerivedCtor;
12810 ShouldDeleteSpecialMember(Ctor, CXXDefaultConstructor, &ICI,
12829 ResolveExceptionSpec(CurrentLocation,
12831 MarkVTableUsed(CurrentLocation, ClassDecl);
12853 for (
bool VBase : {
false,
true}) {
12855 if (B.isVirtual() != VBase)
12858 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
12863 if (!BaseCtor.first)
12866 MarkFunctionReferenced(CurrentLocation, BaseCtor.first);
12868 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
12872 Context, TInfo, VBase, InitLoc, Init.
get(), InitLoc,
12880 if (SetCtorInitializers(Constructor,
false, Inits)) {
12889 L->CompletedImplicitDefinition(Constructor);
12892 DiagnoseUninitializedFields(*
this, Constructor);
12902 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDestructor);
12903 if (DSM.isAlreadyBeingDeclared())
12925 if (getLangOpts().
CUDA) {
12926 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDestructor,
12932 setupImplicitSpecialMemberType(Destructor, Context.
VoidTy,
None);
12941 ++getASTContext().NumImplicitDestructorsDeclared;
12943 Scope *S = getScopeForContext(ClassDecl);
12944 CheckImplicitSpecialMemberDeclaration(S, Destructor);
12950 ShouldDeleteSpecialMember(Destructor, CXXDestructor))
12951 SetDeclDeleted(Destructor, ClassLoc);
12955 PushOnScopeChains(Destructor, S,
false);
12956 ClassDecl->
addDecl(Destructor);
12966 "DefineImplicitDestructor - call it for implicit default dtor");
12971 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
12977 ResolveExceptionSpec(CurrentLocation,
12979 MarkVTableUsed(CurrentLocation, ClassDecl);
12984 MarkBaseAndMemberDestructorsReferenced(Destructor->
getLocation(),
12987 if (CheckDestructor(Destructor)) {
12999 L->CompletedImplicitDefinition(Destructor);
13007 if (
CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(CurContext)) {
13008 if (Record->isInvalidDecl()) {
13009 DelayedOverridingExceptionSpecChecks.clear();
13010 DelayedEquivalentExceptionSpecChecks.clear();
13018 referenceDLLExportedClassMethods();
13020 if (!DelayedDllExportMemberFunctions.empty()) {
13022 std::swap(DelayedDllExportMemberFunctions, WorkList);
13029 if (M->getParent()->getTemplateSpecializationKind() !=
13031 ActOnFinishInlineFunctionDef(M);
13037 if (!DelayedDllExportClasses.empty()) {
13041 std::swap(DelayedDllExportClasses, WorkList);
13049 "adjusting dtor exception specs was introduced in c++11");
13059 if (DtorType->hasExceptionSpec())
13081 class ExprBuilder {
13082 ExprBuilder(
const ExprBuilder&) =
delete;
13083 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
13086 static Expr *assertNotNull(
Expr *E) {
13087 assert(E &&
"Expression construction must not fail.");
13093 virtual ~ExprBuilder() {}
13098 class RefBuilder:
public ExprBuilder {
13108 : Var(Var), VarType(VarType) {}
13111 class ThisBuilder:
public ExprBuilder {
13118 class CastBuilder:
public ExprBuilder {
13119 const ExprBuilder &Builder;
13127 CK_UncheckedDerivedToBase,
Kind,
13133 : Builder(Builder), Type(Type),
Kind(Kind), Path(Path) {}
13136 class DerefBuilder:
public ExprBuilder {
13137 const ExprBuilder &Builder;
13141 return assertNotNull(
13145 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
13148 class MemberBuilder:
public ExprBuilder {
13149 const ExprBuilder &Builder;
13158 Builder.build(S, Loc), Type, Loc, IsArrow, SS,
SourceLocation(),
13159 nullptr, MemberLookup,
nullptr,
nullptr).
get());
13162 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
13164 : Builder(Builder), Type(Type), IsArrow(IsArrow),
13165 MemberLookup(MemberLookup) {}
13168 class MoveCastBuilder:
public ExprBuilder {
13169 const ExprBuilder &Builder;
13173 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
13176 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
13179 class LvalueConvBuilder:
public ExprBuilder {
13180 const ExprBuilder &Builder;
13184 return assertNotNull(
13188 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
13191 class SubscriptBuilder:
public ExprBuilder {
13192 const ExprBuilder &Base;
13193 const ExprBuilder &Index;
13198 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
13201 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
13202 : Base(Base), Index(Index) {}
13213 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
13222 Expr *From = FromB.build(S, Loc);
13226 Expr *To = ToB.build(S, Loc);
13232 bool NeedsCollectableMemCpy =
13237 StringRef MemCpyName = NeedsCollectableMemCpy ?
13238 "__builtin_objc_memmove_collectable" :
13239 "__builtin_memcpy";
13252 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
13254 Expr *CallArgs[] = {
13258 Loc, CallArgs, Loc);
13260 assert(!Call.
isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
13293 const ExprBuilder &To,
const ExprBuilder &From,
13294 bool CopyingBaseSubobject,
bool Copying,
13295 unsigned Depth = 0) {
13311 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
13326 if (Method->isCopyAssignmentOperator() ||
13327 (!Copying && Method->isMoveAssignmentOperator()))
13346 if (CopyingBaseSubobject) {
13377 Expr *FromInst = From.build(S, Loc);
13380 Loc, FromInst, Loc);
13400 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
13420 llvm::raw_svector_ostream OS(Str);
13421 OS <<
"__i" <<
Depth;
13425 IterationVarName, SizeType,
13434 RefBuilder IterationVarRef(IterationVar, SizeType);
13435 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
13441 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
13442 MoveCastBuilder FromIndexMove(FromIndexCopy);
13443 const ExprBuilder *FromIndex;
13445 FromIndex = &FromIndexCopy;
13447 FromIndex = &FromIndexMove;
13449 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
13454 ToIndex, *FromIndex, CopyingBaseSubobject,
13455 Copying,
Depth + 1);
13457 if (Copy.isInvalid() || !Copy.get())
13473 UnaryOperator(IterationVarRef.build(S, Loc), UO_PreInc, SizeType,
13478 Loc, Loc, InitStmt,
13485 const ExprBuilder &To,
const ExprBuilder &From,
13486 bool CopyingBaseSubobject,
bool Copying) {
13493 CopyingBaseSubobject,
13498 if (!Result.isInvalid() && !Result.get())
13511 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyAssignment);
13512 if (DSM.isAlreadyBeingDeclared())
13516 LangAS AS = getDefaultCXXMethodAddrSpace();
13536 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
13544 if (getLangOpts().
CUDA) {
13545 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyAssignment,
13551 setupImplicitSpecialMemberType(CopyAssignment, RetType, ArgType);
13555 ClassLoc, ClassLoc,
13563 ? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
13567 ++getASTContext().NumImplicitCopyAssignmentOperatorsDeclared;
13569 Scope *S = getScopeForContext(ClassDecl);
13570 CheckImplicitSpecialMemberDeclaration(S, CopyAssignment);
13572 if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment))
13573 SetDeclDeleted(CopyAssignment, ClassLoc);
13576 PushOnScopeChains(CopyAssignment, S,
false);
13577 ClassDecl->
addDecl(CopyAssignment);
13579 return CopyAssignment;
13593 if (RD->hasUserDeclaredDestructor()) {
13594 UserDeclaredOperation = RD->getDestructor();
13595 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
13596 RD->hasUserDeclaredCopyConstructor() &&
13599 for (
auto *I : RD->ctors()) {
13600 if (I->isCopyConstructor()) {
13601 UserDeclaredOperation = I;
13605 assert(UserDeclaredOperation);
13606 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
13607 RD->hasUserDeclaredCopyAssignment() &&
13610 for (
auto *I : RD->methods()) {
13611 if (I->isCopyAssignmentOperator()) {
13612 UserDeclaredOperation = I;
13616 assert(UserDeclaredOperation);
13619 if (UserDeclaredOperation && UserDeclaredOperation->
isUserProvided()) {
13621 isa<CXXDestructorDecl>(UserDeclaredOperation)
13622 ? diag::warn_deprecated_copy_dtor_operation
13623 : diag::warn_deprecated_copy_operation)
13624 << RD << !isa<CXXConstructorDecl>(CopyOp);
13635 "DefineImplicitCopyAssignment called for wrong function");
13649 ResolveExceptionSpec(CurrentLocation,
13689 RefBuilder OtherRef(Other, OtherRefType);
13695 bool Invalid =
false;
13696 for (
auto &Base : ClassDecl->
bases()) {
13706 BasePath.push_back(&Base);
13710 CastBuilder From(OtherRef, Context.
getQualifiedType(BaseType, OtherQuals),
13714 DerefBuilder DerefThis(This);
13715 CastBuilder To(DerefThis,
13731 Statements.push_back(Copy.
getAs<
Expr>());
13735 for (
auto *Field : ClassDecl->
fields()) {
13738 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
13741 if (Field->isInvalidDecl()) {
13747 if (Field->getType()->isReferenceType()) {
13748 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
13749 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
13750 Diag(Field->getLocation(), diag::note_declared_at);
13758 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
13759 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
13760 Diag(Field->getLocation(), diag::note_declared_at);
13766 if (Field->isZeroLengthBitField(Context))
13769 QualType FieldType = Field->getType().getNonReferenceType();
13772 "Incomplete array type is not valid");
13778 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
13781 MemberLookup.resolveKind();
13783 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
13785 MemberBuilder To(This, getCurrentThisType(),
true, MemberLookup);
13798 Statements.push_back(Copy.
getAs<
Stmt>());
13803 ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
13806 if (Return.isInvalid())
13809 Statements.push_back(Return.getAs<
Stmt>());
13820 Body = ActOnCompoundStmt(Loc, Loc, Statements,
13822 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
13825 CopyAssignOperator->
markUsed(Context);
13828 L->CompletedImplicitDefinition(CopyAssignOperator);
13835 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveAssignment);
13836 if (DSM.isAlreadyBeingDeclared())
13843 LangAS AS = getDefaultCXXMethodAddrSpace();
13859 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
13867 if (getLangOpts().
CUDA) {
13868 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveAssignment,
13881 ClassLoc, ClassLoc,
13889 ? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
13893 ++getASTContext().NumImplicitMoveAssignmentOperatorsDeclared;
13895 Scope *S = getScopeForContext(ClassDecl);
13896 CheckImplicitSpecialMemberDeclaration(S, MoveAssignment);
13898 if (ShouldDeleteSpecialMember(MoveAssignment, CXXMoveAssignment)) {
13900 SetDeclDeleted(MoveAssignment, ClassLoc);
13904 PushOnScopeChains(MoveAssignment, S,
false);
13905 ClassDecl->
addDecl(MoveAssignment);
13907 return MoveAssignment;
13926 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
13929 for (
auto &BI : Class->
bases()) {
13930 Worklist.push_back(&BI);
13931 while (!Worklist.empty()) {
13964 if (Existing && Existing != &BI) {
13965 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
13968 << (Base->getCanonicalDecl() ==
13971 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
13972 << (Base->getCanonicalDecl() ==
13973 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
13977 Existing =
nullptr;
13987 for (
auto &BI : Base->
bases())
13988 Worklist.push_back(&BI);
14001 "DefineImplicitMoveAssignment called for wrong function");
14027 ResolveExceptionSpec(CurrentLocation,
14047 RefBuilder OtherRef(Other, OtherRefType);
14049 MoveCastBuilder MoveOther(OtherRef);
14055 bool Invalid =
false;
14056 for (
auto &Base : ClassDecl->
bases()) {
14074 BasePath.push_back(&Base);
14078 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
14081 DerefBuilder DerefThis(This);
14084 CastBuilder To(DerefThis,
14100 Statements.push_back(Move.
getAs<
Expr>());
14104 for (
auto *Field : ClassDecl->
fields()) {
14107 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
14110 if (Field->isInvalidDecl()) {
14116 if (Field->getType()->isReferenceType()) {
14117 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
14118 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
14119 Diag(Field->getLocation(), diag::note_declared_at);
14127 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
14128 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
14129 Diag(Field->getLocation(), diag::note_declared_at);
14135 if (Field->isZeroLengthBitField(Context))
14138 QualType FieldType = Field->getType().getNonReferenceType();
14141 "Incomplete array type is not valid");
14146 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
14149 MemberLookup.resolveKind();
14150 MemberBuilder From(MoveOther, OtherRefType,
14151 false, MemberLookup);
14152 MemberBuilder To(This, getCurrentThisType(),
14153 true, MemberLookup);
14155 assert(!From.build(*
this, Loc)->isLValue() &&
14156 "Member reference with rvalue base must be rvalue except for reference " 14157 "members, which aren't allowed for move assignment.");
14164 if (Move.isInvalid()) {
14170 Statements.push_back(Move.getAs<
Stmt>());
14176 CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
14179 if (Return.isInvalid())
14182 Statements.push_back(Return.getAs<
Stmt>());
14193 Body = ActOnCompoundStmt(Loc, Loc, Statements,
14195 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
14198 MoveAssignOperator->
markUsed(Context);
14201 L->CompletedImplicitDefinition(MoveAssignOperator);
14212 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyConstructor);
14213 if (DSM.isAlreadyBeingDeclared())
14222 LangAS AS = getDefaultCXXMethodAddrSpace();
14229 CXXCopyConstructor,
14241 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
14249 if (getLangOpts().
CUDA) {
14250 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyConstructor,
14256 setupImplicitSpecialMemberType(CopyConstructor, Context.
VoidTy, ArgType);
14260 ClassLoc, ClassLoc,
14268 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
14272 ClassDecl->
hasAttr<TrivialABIAttr>() ||
14274 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor,
14275 TAH_ConsiderTrivialABI)
14279 ++getASTContext().NumImplicitCopyConstructorsDeclared;
14281 Scope *S = getScopeForContext(ClassDecl);
14282 CheckImplicitSpecialMemberDeclaration(S, CopyConstructor);
14284 if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) {
14286 SetDeclDeleted(CopyConstructor, ClassLoc);
14290 PushOnScopeChains(CopyConstructor, S,
false);
14291 ClassDecl->
addDecl(CopyConstructor);
14293 return CopyConstructor;
14302 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
14307 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
14313 ResolveExceptionSpec(CurrentLocation,
14315 MarkVTableUsed(CurrentLocation, ClassDecl);
14327 if (SetCtorInitializers(CopyConstructor,
false)) {
14335 ActOnCompoundStmt(Loc, Loc,
None,
false).getAs<Stmt>());
14336 CopyConstructor->
markUsed(Context);
14340 L->CompletedImplicitDefinition(CopyConstructor);
14348 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveConstructor);
14349 if (DSM.isAlreadyBeingDeclared())
14355 LangAS AS = getDefaultCXXMethodAddrSpace();
14361 CXXMoveConstructor,
14374 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
14382 if (getLangOpts().
CUDA) {
14383 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveConstructor,
14389 setupImplicitSpecialMemberType(MoveConstructor, Context.
VoidTy, ArgType);
14393 ClassLoc, ClassLoc,
14401 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
14405 ClassDecl->
hasAttr<TrivialABIAttr>() ||
14407 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor,
14408 TAH_ConsiderTrivialABI)
14412 ++getASTContext().NumImplicitMoveConstructorsDeclared;
14414 Scope *S = getScopeForContext(ClassDecl);
14415 CheckImplicitSpecialMemberDeclaration(S, MoveConstructor);
14417 if (ShouldDeleteSpecialMember(MoveConstructor, CXXMoveConstructor)) {
14419 SetDeclDeleted(MoveConstructor, ClassLoc);
14423 PushOnScopeChains(MoveConstructor, S,
false);
14424 ClassDecl->
addDecl(MoveConstructor);
14426 return MoveConstructor;
14435 "DefineImplicitMoveConstructor - call it for implicit move ctor");
14440 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
14446 ResolveExceptionSpec(CurrentLocation,
14448 MarkVTableUsed(CurrentLocation, ClassDecl);
14453 if (SetCtorInitializers(MoveConstructor,
false)) {
14460 MoveConstructor->
setBody(ActOnCompoundStmt(
14461 Loc, Loc,
None,
false).getAs<Stmt>());
14462 MoveConstructor->
markUsed(Context);
14466 L->CompletedImplicitDefinition(MoveConstructor);
14481 FunctionDecl *CallOp = Lambda->getLambdaCallOperator();
14482 FunctionDecl *Invoker = Lambda->getLambdaStaticInvoker();
14485 CallOp = InstantiateFunctionDeclaration(
14490 Invoker = InstantiateFunctionDeclaration(
14504 MarkFunctionReferenced(CurrentLocation, CallOp);
14515 Expr *FunctionRef = BuildDeclRefExpr(Invoker, Invoker->
getType(),
14517 assert(FunctionRef &&
"Can't refer to __invoke function?");
14518 Stmt *Return = BuildReturnStmt(Conv->
getLocation(), FunctionRef).
get();
14525 L->CompletedImplicitDefinition(Conv);
14526 L->CompletedImplicitDefinition(Invoker);
14541 Expr *
This = ActOnCXXThis(CurrentLocation).get();
14542 Expr *DerefThis =CreateBuiltinUnaryOp(CurrentLocation, UO_Deref, This).get();
14544 ExprResult BuildBlock = BuildBlockForLambdaConversion(CurrentLocation,
14552 if (!BuildBlock.
isInvalid() && !getLangOpts().ObjCAutoRefCount)
14554 CK_CopyAndAutoreleaseBlockObject,
14558 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
14567 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
14573 Stmt *ReturnS = Return.
get();
14580 L->CompletedImplicitDefinition(Conv);
14587 switch (Args.size()) {
14592 if (!Args[1]->isDefaultArgument())
14597 return !Args[0]->isDefaultArgument();
14608 bool HadMultipleCandidates,
14609 bool IsListInitialization,
14610 bool IsStdInitListInitialization,
14611 bool RequiresZeroInit,
14612 unsigned ConstructKind,
14614 bool Elidable =
false;
14628 Expr *SubExpr = ExprArgs[0];
14633 return BuildCXXConstructExpr(ConstructLoc, DeclInitType,
14634 FoundDecl, Constructor,
14635 Elidable, ExprArgs, HadMultipleCandidates,
14636 IsListInitialization,
14637 IsStdInitListInitialization, RequiresZeroInit,
14638 ConstructKind, ParenRange);
14647 bool HadMultipleCandidates,
14648 bool IsListInitialization,
14649 bool IsStdInitListInitialization,
14650 bool RequiresZeroInit,
14651 unsigned ConstructKind,
14653 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
14654 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
14655 if (DiagnoseUseOfDecl(Constructor, ConstructLoc))
14659 return BuildCXXConstructExpr(
14660 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
14661 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
14662 RequiresZeroInit, ConstructKind, ParenRange);
14672 bool HadMultipleCandidates,
14673 bool IsListInitialization,
14674 bool IsStdInitListInitialization,
14675 bool RequiresZeroInit,
14676 unsigned ConstructKind,
14681 "given constructor for wrong type");
14682 MarkFunctionReferenced(ConstructLoc, Constructor);
14683 if (getLangOpts().
CUDA && !CheckCUDACall(ConstructLoc, Constructor))
14687 Context, DeclInitType, ConstructLoc, Constructor, Elidable,
14688 ExprArgs, HadMultipleCandidates, IsListInitialization,
14689 IsStdInitListInitialization, RequiresZeroInit,
14690 static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
14719 assert((getLangOpts().Modules || (!Lookup.
empty() && Lookup.
size() <= 2)) &&
14720 "more than two lookup results for field name");
14723 assert(isa<CXXRecordDecl>(Lookup[0]) &&
14724 "cannot have other non-field member with same name");
14725 for (
auto L : Lookup)
14726 if (isa<FieldDecl>(L)) {
14727 Pattern = cast<FieldDecl>(L);
14730 assert(Pattern &&
"We must have set the Pattern!");
14733 if (!Pattern->hasInClassInitializer() ||
14734 InstantiateInClassInitializer(Loc, Field, Pattern,
14735 getTemplateInstantiationArgs(Field))) {
14758 Diag(Loc, diag::err_in_class_initializer_not_yet_parsed)
14759 << OutermostClass << Field;
14760 Diag(Field->getEndLoc(), diag::note_in_class_initializer_not_yet_parsed);
14762 if (!isSFINAEContext())
14763 Field->setInvalidDecl();
14784 MarkFunctionReferenced(VD->
getLocation(), Destructor);
14785 CheckDestructorAccess(VD->
getLocation(), Destructor,
14786 PDiag(diag::err_access_dtor_var)
14788 DiagnoseUseOfDecl(Destructor, VD->
getLocation());
14800 diag::err_constexpr_var_requires_const_destruction) << VD;
14801 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
14802 Diag(Notes[I].first, Notes[I].second);
14827 bool AllowExplicit,
14828 bool IsListInitialization) {
14830 unsigned NumArgs = ArgsPtr.size();
14831 Expr **Args = ArgsPtr.data();
14837 if (NumArgs < NumParams)
14838 ConvertedArgs.reserve(NumParams);
14840 ConvertedArgs.reserve(NumArgs);
14843 Proto->isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
14845 bool Invalid = GatherArgumentsForCall(Loc, Constructor,
14847 llvm::makeArrayRef(Args, NumArgs),
14849 CallType, AllowExplicit,
14850 IsListInitialization);
14851 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
14853 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
14855 CheckConstructorCall(Constructor,
14856 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
14866 if (isa<NamespaceDecl>(DC)) {
14868 diag::err_operator_new_delete_declared_in_namespace)
14872 if (isa<TranslationUnitDecl>(DC) &&
14875 diag::err_operator_new_delete_declared_static)
14893 unsigned DependentParamTypeDiag,
14894 unsigned InvalidParamTypeDiag) {
14901 diag::err_operator_new_delete_dependent_result_type)
14914 diag::err_operator_new_delete_invalid_result_type)
14920 diag::err_operator_new_delete_template_too_few_parameters)
14926 diag::err_operator_new_delete_too_few_parameters)
14933 << FnDecl->
getDeclName() << ExpectedFirstParamType;
14944 ExpectedFirstParamType)
14946 << FnDecl->
getDeclName() << ExpectedFirstParamType;
14968 diag::err_operator_new_dependent_param_type,
14969 diag::err_operator_new_param_type))
14976 diag::err_operator_new_default_arg)
15006 SemaRef, FnDecl, SemaRef.
Context.
VoidTy, ExpectedFirstParamType,
15007 diag::err_operator_delete_dependent_param_type,
15008 diag::err_operator_delete_param_type))
15017 diag::err_destroying_operator_delete_not_usual);
15029 "Expected an overloaded operator declaration");
15039 if (Op == OO_Delete || Op == OO_Array_Delete)
15042 if (Op == OO_New || Op == OO_Array_New)
15050 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
15051 if (MethodDecl->isStatic())
15053 diag::err_operator_overload_static) << FnDecl->
getDeclName();
15055 bool ClassOrEnumParam =
false;
15057 QualType ParamType = Param->getType().getNonReferenceType();
15060 ClassOrEnumParam =
true;
15065 if (!ClassOrEnumParam)
15067 diag::err_operator_overload_needs_class_or_enum)
15077 if (Op != OO_Call) {
15079 if (Param->hasDefaultArg())
15080 return Diag(Param->getLocation(),
15081 diag::err_operator_overload_default_arg)
15082 << FnDecl->
getDeclName() << Param->getDefaultArgRange();
15087 {
false,
false,
false }
15088 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 15089 , { Unary, Binary, MemberOnly } 15090 #include "clang/Basic/OperatorKinds.def" 15093 bool CanBeUnaryOperator = OperatorUses[Op][0];
15094 bool CanBeBinaryOperator = OperatorUses[Op][1];
15095 bool MustBeMemberOperator = OperatorUses[Op][2];
15102 + (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
15103 if (Op != OO_Call &&
15104 ((NumParams == 1 && !CanBeUnaryOperator) ||
15105 (NumParams == 2 && !CanBeBinaryOperator) ||
15106 (NumParams < 1) || (NumParams > 2))) {
15109 if (CanBeUnaryOperator && CanBeBinaryOperator) {
15111 }
else if (CanBeUnaryOperator) {
15114 assert(CanBeBinaryOperator &&
15115 "All non-call overloaded operators are unary or binary!");
15119 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
15124 if (Op != OO_Call &&
15126 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
15131 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
15133 diag::err_operator_overload_must_be_member)
15147 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
15154 diag::err_operator_overload_post_incdec_must_be_int)
15155 << LastParam->
getType() << (Op == OO_MinusMinus);
15167 if (TemplateParams->
size() == 1) {
15176 }
else if (TemplateParams->
size() == 2) {
15185 PmArgs->isTemplateParameterPack()) {
15192 diag::ext_string_literal_operator_template);
15199 diag::err_literal_operator_template)
15208 if (isa<CXXMethodDecl>(FnDecl)) {
15209 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
15218 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
15235 diag::err_literal_operator_template_with_params);
15264 diag::err_literal_operator_param)
15281 diag::err_literal_operator_invalid_param)
15291 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
15298 Diag((*Param)->getSourceRange().getBegin(),
15299 diag::err_literal_operator_param)
15300 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
15307 Diag((*Param)->getSourceRange().getBegin(),
15308 diag::err_literal_operator_param)
15309 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
15322 Diag((*Param)->getSourceRange().getBegin(),
15323 diag::err_literal_operator_param)
15324 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
15332 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
15334 Diag((*Param)->getSourceRange().getBegin(),
15335 diag::err_literal_operator_param)
15337 << (*Param)->getSourceRange();
15341 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
15350 if (Param->hasDefaultArg()) {
15351 Diag(Param->getDefaultArgRange().getBegin(),
15352 diag::err_literal_operator_default_argument)
15353 << Param->getDefaultArgRange();
15358 StringRef LiteralName
15360 if (LiteralName[0] !=
'_' &&
15361 !getSourceManager().isInSystemHeader(FnDecl->
getLocation())) {
15383 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
15392 else if (Lang ==
"C++")
15395 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
15406 PushDeclContext(S, D);
15422 return LinkageSpec;
15431 ProcessDeclAttributeList(S, ED, AttrList);
15433 CurContext->addDecl(ED);
15445 bool Invalid =
false;
15459 Diag(Loc, diag::err_catch_rvalue_ref);
15464 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
15470 unsigned DK = diag::err_catch_incomplete;
15474 DK = diag::err_catch_incomplete_ptr;
15479 DK = diag::err_catch_incomplete_ref;
15481 if (!Invalid && (Mode == 0 || !BaseType->
isVoidType()) &&
15482 !BaseType->
isDependentType() && RequireCompleteType(Loc, BaseType, DK))
15486 RequireNonAbstractType(Loc, ExDeclType,
15487 diag::err_abstract_type_in_decl,
15488 AbstractVariableType))
15493 if (!Invalid && getLangOpts().ObjC) {
15499 Diag(Loc, diag::err_objc_object_catch);
15503 if (getLangOpts().ObjCRuntime.isFragile())
15504 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
15513 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(ExDecl))
15520 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
15538 Expr *opaqueValue =
15549 Expr *init = MaybeCreateExprWithCleanups(construct);
15554 FinalizeVarWithDestructor(ExDecl,
recordType);
15573 UPPC_ExceptionType)) {
15581 LookupOrdinaryName,
15582 ForVisibleRedeclaration)) {
15587 if (isDeclInScope(PrevDecl, CurContext, S)) {
15590 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
15592 }
else if (PrevDecl->isTemplateParameter())
15603 VarDecl *ExDecl = BuildExceptionDeclaration(
15610 PushOnScopeChains(ExDecl, S);
15612 CurContext->addDecl(ExDecl);
15614 ProcessDeclAttributes(S, ExDecl, D);
15620 Expr *AssertMessageExpr,
15623 AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) :
nullptr;
15625 if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
15628 return BuildStaticAssertDeclaration(StaticAssertLoc, AssertExpr,
15629 AssertMessage, RParenLoc,
false);
15637 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
15642 ExprResult Converted = PerformContextuallyConvertToBool(AssertExpr);
15647 ActOnFinishFullExpr(Converted.
get(), StaticAssertLoc,
15653 AssertExpr = FullAssertExpr.
get();
15656 if (!Failed && VerifyIntegerConstantExpression(AssertExpr, &Cond,
15657 diag::err_static_assert_expression_is_not_constant,
15661 if (!Failed && !Cond) {
15663 llvm::raw_svector_ostream Msg(MsgBuffer);
15665 AssertMessage->
printPretty(Msg,
nullptr, getPrintingPolicy());
15667 Expr *InnerCond =
nullptr;
15668 std::string InnerCondDescription;
15669 std::tie(InnerCond, InnerCondDescription) =
15670 findFailedBooleanCondition(Converted.
get());
15671 if (InnerCond && isa<ConceptSpecializationExpr>(InnerCond)) {
15674 Diag(StaticAssertLoc, diag::err_static_assert_failed)
15678 DiagnoseUnsatisfiedConstraint(Satisfaction);
15679 }
else if (InnerCond && !isa<CXXBoolLiteralExpr>(InnerCond)
15680 && !isa<IntegerLiteral>(InnerCond)) {
15681 Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed)
15682 << InnerCondDescription << !AssertMessage
15685 Diag(StaticAssertLoc, diag::err_static_assert_failed)
15691 ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
15697 AssertExpr = FullAssertExpr.
get();
15701 AssertExpr, AssertMessage, RParenLoc,
15704 CurContext->addDecl(Decl);
15714 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
15724 if (!CodeSynthesisContexts.empty()) {
15739 getLangOpts().CPlusPlus11 ?
15740 diag::warn_cxx98_compat_unelaborated_friend_type :
15741 diag::ext_unelaborated_friend_type)
15749 diag::warn_cxx98_compat_nonclass_type_friend :
15750 diag::ext_nonclass_type_friend)
15757 diag::warn_cxx98_compat_enum_friend :
15758 diag::ext_enum_friend)
15769 if (getLangOpts().
CPlusPlus11 && LocStart != FriendLoc)
15770 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
15791 bool IsMemberSpecialization =
false;
15792 bool Invalid =
false;
15795 MatchTemplateParametersToScopeSpecifier(
15796 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
15797 IsMemberSpecialization, Invalid)) {
15798 if (TemplateParams->size() > 0) {
15803 return CheckClassTemplate(S, TagSpec, TUK_Friend, TagLoc, SS, Name,
15804 NameLoc, Attr, TemplateParams,
AS_public,
15806 FriendLoc, TempParamLists.size() - 1,
15807 TempParamLists.data()).
get();
15810 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
15812 IsMemberSpecialization =
true;
15816 if (Invalid)
return nullptr;
15818 bool isAllExplicitSpecializations =
true;
15819 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
15820 if (TempParamLists[I]->size()) {
15821 isAllExplicitSpecializations =
false;
15831 if (isAllExplicitSpecializations) {
15833 bool Owned =
false;
15834 bool IsDependent =
false;
15835 return ActOnTag(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc,
15849 QualType T = CheckTypenameType(Keyword, TagLoc, QualifierLoc,
15855 if (isa<DependentNameType>(T)) {
15869 TSI, FriendLoc, TempParamLists);
15871 CurContext->addDecl(Friend);
15875 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
15882 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
15893 TSI, FriendLoc, TempParamLists);
15896 CurContext->addDecl(Friend);
15956 if (DiagnoseUnexpandedParameterPack(Loc, TSI, UPPC_FriendDeclaration))
15974 Diag(Loc, diag::err_tagless_friend_type_template)
15991 if (!TempParams.empty())
16003 CurContext->addDecl(D);
16029 Diag(Loc, diag::err_unexpected_friend);
16056 if (DiagnoseUnexpandedParameterPack(Loc, TInfo, UPPC_FriendDeclaration) ||
16057 DiagnoseUnexpandedParameterPack(NameInfo, UPPC_FriendDeclaration) ||
16058 DiagnoseUnexpandedParameterPack(SS, UPPC_FriendDeclaration))
16064 Scope *DCScope = S;
16066 ForExternalRedeclaration);
16074 (FunctionContainingLocalClass =
16075 cast<CXXRecordDecl>(CurContext)->isLocalClass())) {
16090 Previous.
clear(LookupLocalFriendName);
16091 LookupName(Previous, S,
false);
16093 if (!Previous.
empty()) {
16101 DC = FunctionContainingLocalClass;
16103 adjustContextForLocalExternDecl(DC);
16123 bool isTemplateId =
16144 LookupQualifiedName(Previous, LookupDC);
16146 if (!Previous.
empty()) {
16151 if (isTemplateId) {
16152 if (isa<TranslationUnitDecl>(LookupDC))
break;
16159 DCScope = getScopeForDeclContext(S, DC);
16165 DC = computeDeclContext(SS);
16166 if (!DC)
return nullptr;
16168 if (RequireCompleteDeclContext(SS, DC))
return nullptr;
16170 LookupQualifiedName(Previous, DC);
16174 if (DC->
Equals(CurContext))
16176 getLangOpts().CPlusPlus11 ?
16177 diag::warn_cxx98_compat_friend_is_member :
16178 diag::err_friend_is_member);
16214 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
16241 if (DiagArg >= 0) {
16242 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
16253 DCScope = &FakeDCScope;
16256 bool AddToScope =
true;
16257 NamedDecl *ND = ActOnFunctionDeclarator(DCScope, D, DC, TInfo, Previous,
16258 TemplateParams, AddToScope);
16259 if (!ND)
return nullptr;
16273 if (!CurContext->isDependentContext()) {
16276 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
16277 PushOnScopeChains(ND, EnclosingScope,
false);
16284 CurContext->addDecl(FrD);
16289 if (DC->isRecord()) CheckFriendAccess(ND);
16293 FD = FTD->getTemplatedDecl();
16295 FD = cast<FunctionDecl>(ND);
16306 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
16308 diag::note_previous_declaration);
16310 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
16315 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
16317 << cast<CXXRecordDecl>(CurContext);
16326 AdjustDeclIfTemplate(Dcl);
16328 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
16330 Diag(DelLoc, diag::err_deleted_non_function);
16341 Prev->getPreviousDecl()) &&
16342 !Prev->isDefined()) {
16343 Diag(DelLoc, diag::err_deleted_decl_not_first);
16344 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
16345 Prev->isImplicit() ? diag::note_previous_implicit_declaration
16346 : diag::note_previous_declaration);
16365 Diag(DelLoc, diag::err_deleted_main);
16375 bool IssuedDiagnostic =
false;
16378 if (!IssuedDiagnostic) {
16380 IssuedDiagnostic =
true;
16382 Diag(O->getLocation(), diag::note_overridden_virtual_function);
16388 DiagnoseDeletedDefaultedFunction(MD);
16398 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(Dcl)) {
16399 if (getDefaultedFunctionKind(FTD->getTemplatedDecl()).isComparison()) {
16400 Diag(DefaultLoc, diag::err_defaulted_comparison_template);
16405 Diag(DefaultLoc, diag::err_default_special_members)
16406 << getLangOpts().CPlusPlus2a;
16416 (!FD->isDependentContext() ||
16417 (!isa<CXXConstructorDecl>(FD) &&
16419 Diag(DefaultLoc, diag::err_default_special_members)
16420 << getLangOpts().CPlusPlus2a;
16434 DefKind.
asComparison() != DefaultedComparisonKind::ThreeWay) {
16436 ? diag::warn_cxx17_compat_defaulted_comparison
16437 : diag::ext_defaulted_comparison);
16440 FD->setDefaulted();
16441 FD->setExplicitlyDefaulted();
16444 if (FD->isDependentContext())
16450 FD->setWillHaveBody(
false);
16457 auto *MD = cast<CXXMethodDecl>(FD);
16460 if (
const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern())
16468 if (Primary->getCanonicalDecl()->isDefaulted())
16471 if (CheckExplicitlyDefaultedSpecialMember(MD, DefKind.
asSpecialMember()))
16481 if (isa<ReturnStmt>(SubStmt))
16482 Self.
Diag(SubStmt->getBeginLoc(),
16483 diag::err_return_in_constructor_handler);
16484 if (!isa<Expr>(SubStmt))
16490 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
16502 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
16506 !NewFT->getExtParameterInfo(I).isNoEscape()) {
16508 diag::warn_overriding_method_missing_noescape);
16510 diag::note_overridden_marked_noescape);
16515 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
16516 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
16517 if ((NewCSA || OldCSA) &&
16518 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
16527 if (NewCC == OldCC)
16538 diag::err_conflicting_overriding_cc_attributes)
16564 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
16572 if (NewClassTy.
isNull()) {
16574 diag::err_different_return_type_for_overriding_virtual_function)
16590 if (!RT->isBeingDefined() &&
16591 RequireCompleteType(New->
getLocation(), NewClassTy,
16592 diag::err_covariant_return_incomplete,
16598 if (!IsDerivedFrom(New->
getLocation(), NewClassTy, OldClassTy)) {
16608 if (CheckDerivedToBaseConversion(
16609 NewClassTy, OldClassTy,
16610 diag::err_covariant_return_inaccessible_base,
16611 diag::err_covariant_return_ambiguous_derived_to_base_conv,
16627 diag::err_covariant_return_type_different_qualifications)
16639 diag::err_covariant_return_type_class_type_more_qualified)
16674 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
16675 CheckPureMethod(M, ZeroLoc);
16683 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
16684 return Var->hasGlobalStorage();
16712 PushExpressionEvaluationContext(
16713 ExpressionEvaluationContext::PotentiallyEvaluated, D);
16723 PopExpressionEvaluationContext();
16726 ExitDeclaratorContext(S);
16738 "Parser allowed 'typedef' as storage class of condition decl.");
16740 Decl *Dcl = ActOnDeclarator(S, D);
16744 if (isa<FunctionDecl>(Dcl)) {
16745 Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
16754 if (!ExternalSource)
16758 ExternalSource->ReadUsedVTables(VTables);
16760 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
16761 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
16762 = VTablesUsed.find(VTables[I].Record);
16764 if (Pos != VTablesUsed.end()) {
16765 if (!Pos->second && VTables[I].DefinitionRequired)
16766 Pos->second =
true;
16770 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
16771 NewUses.push_back(
VTableUse(VTables[I].Record, VTables[I].Location));
16774 VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end());
16778 bool DefinitionRequired) {
16782 CurContext->isDependentContext() || isUnevaluatedContext())
16786 if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
16787 !isInOpenMPDeclareTargetContext() &&
16788 !isInOpenMPTargetExecutionDirective()) {
16789 if (!DefinitionRequired)
16790 MarkVirtualMembersReferenced(Loc, Class);
16795 LoadExternalVTableUses();
16797 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
16798 Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
16803 if (DefinitionRequired && !Pos.first->second) {
16804 Pos.first->second =
true;
16822 CheckDestructor(DD);
16834 MarkVirtualMembersReferenced(Loc, Class);
16836 VTableUses.push_back(std::make_pair(Class, Loc));
16840 LoadExternalVTableUses();
16841 if (VTableUses.empty())
16848 bool DefinedAnything =
false;
16849 for (
unsigned I = 0; I != VTableUses.size(); ++I) {
16858 bool DefineVTable =
true;
16864 if (KeyFunction && !KeyFunction->
hasBody()) {
16866 DefineVTable =
false;
16871 "Instantiations don't have key functions");
16873 }
else if (!KeyFunction) {
16878 bool IsExplicitInstantiationDeclaration =
16880 for (
auto R : Class->
redecls()) {
16884 IsExplicitInstantiationDeclaration =
true;
16886 IsExplicitInstantiationDeclaration =
false;
16891 if (IsExplicitInstantiationDeclaration)
16892 DefineVTable =
false;
16898 if (!DefineVTable) {
16899 MarkVirtualMemberExceptionSpecsNeeded(Loc, Class);
16906 DefinedAnything =
true;
16907 MarkVirtualMembersReferenced(Loc, Class);
16909 if (VTablesUsed[Canonical])
16910 Consumer.HandleVTable(Class);
16918 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
16922 ? diag::warn_weak_template_vtable
16923 : diag::warn_weak_vtable)
16928 VTableUses.clear();
16930 return DefinedAnything;
16935 for (
const auto *I : RD->
methods())
16936 if (I->isVirtual() && !I->isPure())
16942 bool ConstexprOnly) {
16946 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
16947 E = FinalOverriders.end();
16950 OE = I->second.end();
16952 assert(OI->second.size() > 0 &&
"no final overrider");
16957 if (!Overrider->isPure() && (!ConstexprOnly || Overrider->isConstexpr()))
16958 MarkFunctionReferenced(Loc, Overrider);
16966 for (
const auto &I : RD->
bases()) {
16968 cast<CXXRecordDecl>(I.getType()->castAs<
RecordType>()->getDecl());
16969 if (Base->getNumVBases() == 0)
16971 MarkVirtualMembersReferenced(Loc, Base);
16982 CollectIvarsToConstructOrDestruct(OID, ivars);
16986 for (
unsigned i = 0; i < ivars.size(); i++) {
16998 InitSeq.Perform(*
this, InitEntity, InitKind,
None);
16999 MemberInit = MaybeCreateExprWithCleanups(MemberInit);
17010 AllToInit.push_back(Member);
17015 ->getAs<RecordType>()) {
17016 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
17018 MarkFunctionReferenced(Field->
getLocation(), Destructor);
17019 CheckDestructorAccess(Field->
getLocation(), Destructor,
17020 PDiag(diag::err_access_dtor_ivar)
17026 AllToInit.data(), AllToInit.size());
17032 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Valid,
17033 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Invalid,
17034 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Current,
17045 (void)Target->
hasBody(FNTarget);
17047 cast_or_null<CXXConstructorDecl>(FNTarget));
17054 if (!Current.insert(Canonical).second)
17060 Valid.insert(Current.begin(), Current.end());
17063 }
else if (TCanonical == Canonical || Invalid.count(TCanonical) ||
17064 Current.count(TCanonical)) {
17066 if (!Invalid.count(TCanonical)) {
17068 diag::warn_delegating_ctor_cycle)
17072 if (TCanonical != Canonical)
17079 assert(FNTarget &&
"Ctor cycle through bodiless function");
17082 cast<CXXConstructorDecl>(FNTarget));
17087 Invalid.insert(Current.begin(), Current.end());
17096 llvm::SmallPtrSet<CXXConstructorDecl*, 4> Valid, Invalid, Current;
17098 for (DelegatingCtorDeclsType::iterator
17099 I = DelegatingCtorDecls.begin(ExternalSource),
17100 E = DelegatingCtorDecls.end();
17104 for (
auto CI = Invalid.begin(), CE = Invalid.end(); CI != CE; ++CI)
17105 (*CI)->setInvalidDecl();
17114 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
17142 FindCXXThisExpr Finder(*
this);
17150 if (checkThisInStaticMemberFunctionExceptionSpec(Method))
17155 if (!Finder.TraverseStmt(E))
17158 return checkThisInStaticMemberFunctionAttributes(Method);
17172 FindCXXThisExpr Finder(*
this);
17194 if (!Finder.TraverseType(E))
17204 FindCXXThisExpr Finder(*
this);
17207 for (
const auto *A : Method->
attrs()) {
17209 Expr *Arg =
nullptr;
17211 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
17213 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
17215 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
17216 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
17217 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
17218 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
17219 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
17220 Arg = ETLF->getSuccessValue();
17221 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
17222 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
17223 Arg = STLF->getSuccessValue();
17224 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
17225 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
17226 Arg = LR->getArg();
17227 else if (
const auto *
LE = dyn_cast<LocksExcludedAttr>(A))
17228 Args = llvm::makeArrayRef(
LE->args_begin(),
LE->args_size());
17229 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
17230 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
17231 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
17232 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
17233 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
17234 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
17235 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
17236 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
17238 if (Arg && !Finder.TraverseStmt(Arg))
17241 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
17242 if (!Finder.TraverseStmt(Args[I]))
17256 Exceptions.clear();
17259 Exceptions.reserve(DynamicExceptions.size());
17260 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
17262 QualType ET = GetTypeFromParser(DynamicExceptions[ei]);
17267 if (!Unexpanded.empty()) {
17269 DynamicExceptionRanges[ei].getBegin(), UPPC_ExceptionType,
17277 if (!CheckSpecifiedExceptionType(ET, DynamicExceptionRanges[ei]))
17278 Exceptions.push_back(ET);
17288 "Parser should have made sure that the expression is boolean");
17289 if (IsTopLevel && DiagnoseUnexpandedParameterPack(NoexceptExpr)) {
17304 Expr *NoexceptExpr) {
17310 MethodD = FunTmpl->getTemplatedDecl();
17319 checkExceptionSpecification(
true, EST, DynamicExceptions,
17320 DynamicExceptionRanges, NoexceptExpr, Exceptions,
17327 checkThisInStaticMemberFunctionExceptionSpec(Method);
17332 CheckOverridingFunctionExceptionSpec(Method, O);
17346 Diag(DeclStart, diag::err_anonymous_property);
17354 CheckExtraCXXDefaultArguments(D);
17357 UPPC_DataMemberType)) {
17368 << getLangOpts().CPlusPlus17;
17371 diag::err_invalid_thread)
17377 ForVisibleRedeclaration);
17378 LookupName(Previous, S);
17399 PrevDecl =
nullptr;
17402 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
17403 PrevDecl =
nullptr;
17410 ProcessDeclAttributes(TUScope, NewPD, D);
17423 PushOnScopeChains(NewPD, S);
17432 auto &Info = InventedParameterInfos.emplace_back();
17436 if (!ExplicitLists.empty()) {
17437 bool IsMemberSpecialization, IsInvalid;
17438 ExplicitParams = MatchTemplateParametersToScopeSpecifier(
17441 ExplicitLists,
false, IsMemberSpecialization, IsInvalid,
17444 if (ExplicitParams) {
17445 Info.AutoTemplateParameterDepth = ExplicitParams->
getDepth();
17446 for (
NamedDecl *Param : *ExplicitParams)
17447 Info.TemplateParams.push_back(Param);
17448 Info.NumExplicitTemplateParams = ExplicitParams->size();
17450 Info.AutoTemplateParameterDepth = TemplateParameterDepth;
17451 Info.NumExplicitTemplateParams = 0;
17456 auto &FSI = InventedParameterInfos.back();
17457 if (FSI.TemplateParams.size() > FSI.NumExplicitTemplateParams) {
17458 if (FSI.NumExplicitTemplateParams != 0) {
17474 InventedParameterInfos.pop_back();
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
Abstract class used to diagnose incomplete types.
A call to an overloaded operator written using operator syntax.
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl)
NamespaceDecl * lookupStdExperimentalNamespace()
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
void setSourceOrder(int Pos)
Set the source order of this initializer.
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
void ActOnFinishDelayedMemberInitializers(Decl *Record)
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCallToStdMove() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
bool hasConstexprDestructor() const
Determine whether this class has a constexpr destructor.
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
SourceLocation getBeginLoc() const
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
Represents a function declaration or definition.
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 bool CheckConstraintSatisfaction(Sema &S, const NamedDecl *Template, ArrayRef< const Expr *> ConstraintExprs, ArrayRef< TemplateArgument > TemplateArgs, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
Name lookup found a set of overloaded functions that met the criteria.
NamespaceDecl * getStdNamespace() const
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
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.
Expr * getInit() const
Get the initializer.
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
void setOrigin(CXXRecordDecl *Rec)
CXXMethodDecl * getMethod() const
no exception specification
static bool checkMemberDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const CXXRecordDecl *OrigRD)
const TypeClass * getTypePtr() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
static bool CheckConstexprReturnType(Sema &SemaRef, const FunctionDecl *FD, Sema::CheckConstexprKind Kind)
Check whether a function's return type is a literal type.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
Information about operator rewrites to consider when adding operator functions to a candidate set...
bool SetTypeQual(TQ T, SourceLocation Loc)
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
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 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.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
const Expr * getInit(unsigned Init) const
The subobject is a base class.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
static UsingPackDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> UsingDecls)
bool CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *MD, DefaultedComparisonKind DCK)
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
Decl * Entity
The entity that is being synthesized.
Expr *const * semantics_iterator
static ClassTemplateDecl * LookupStdInitializerList(Sema &S, SourceLocation Loc)
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
CXXRecordDecl * getCurrentClass(Scope *S, const CXXScopeSpec *SS)
Get the class that is directly named by the current context.
Filter makeFilter()
Create a filter for this result set.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
CXXCatchStmt * getHandler(unsigned i)
IfStmt - This represents an if/then/else.
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt *> Elts, bool isStmtExpr)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
DefaultedComparisonKind asComparison() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD)
Check a completed declaration of an implicit special member.
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
An instance of this object exists for each enum constant that is defined.
bool isRealFloatingType() const
Floating point categories.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class...
static CharSourceRange getTokenRange(SourceRange R)
void addConst()
Add the const type qualifier to this QualType.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
bool isRecordType() const
static TemplateArgumentLoc getTrivialTypeTemplateArgument(Sema &S, SourceLocation Loc, QualType T)
bool isEmpty() const
No scope specifier.
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
void erase()
Erase the last element returned from this iterator.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation)
Builds a using declaration.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
SourceLocation getBeginLoc() const LLVM_READONLY
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, for use in base initialization within a constructor.
void setArgPassingRestrictions(ArgPassingKind Kind)
ComparisonCategoryType Kind
The Kind of the comparison category type.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
ThreadStorageClassSpecifier getTSCSpec() const
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void setPure(bool P=true)
static QualType RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy)
bool isOverrideSpecified() const
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
NamedDecl * getDecl() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static bool isVirtualDirectBase(CXXRecordDecl *Derived, CXXRecordDecl *Base)
Determine whether a direct base class is a virtual base class.
A constructor named via a template-id.
bool isExplicitSpecialization() const
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
static bool lookupStdTypeTraitMember(Sema &S, LookupResult &TraitMemberLookup, SourceLocation Loc, StringRef Trait, TemplateArgumentListInfo &Args, unsigned DiagID)
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
The base class of the type hierarchy.
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.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
SourceLocation getBeginLoc() const LLVM_READONLY
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
One instance of this struct is used for each type in a declarator that is parsed. ...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
Represent a C++ namespace.
static bool isNonlocalVariable(const Decl *D)
Determine whether the given declaration is a global variable or static data member.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
Represents a call to a C++ constructor.
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...
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
Ambiguous candidates found.
SourceLocation getEndLoc() const LLVM_READONLY
NamedDecl * getParam(unsigned Idx)
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
QualType withConst() const
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
const TargetInfo & getTargetInfo() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
const NestedNameSpecifier * Specifier
RefQualifierKind RefQualifier
A container of type source information.
Store information needed for an explicit specifier.
Floating point control options.
constexpr XRayInstrMask Function
static std::string printTemplateArgs(const PrintingPolicy &PrintingPolicy, TemplateArgumentListInfo &Args)
An overloaded operator name, e.g., operator+.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
TSCS getThreadStorageClassSpec() const
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
static Sema::ImplicitExceptionSpecification computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD)
QualType getConversionType() const
Returns the type that this conversion function is converting to.
static void checkMethodTypeQualifiers(Sema &S, Declarator &D, unsigned DiagID)
static InitializedEntity InitializeMemberFromDefaultMemberInitializer(FieldDecl *Member)
Create the initialization entity for a default member initializer.
Abstract base class used for diagnosing integer constant expression violations.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
unsigned getIdentifierNamespace() const
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
IdentifierInfo * getPropertyDataGetter() const
bool implicitCopyAssignmentHasConstParam() const
Determine whether an implicit copy assignment operator for this type would have a parameter with a co...
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
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...
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
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, C99 6.9p3)
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class...
size_t param_size() const
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
SourceLocation getEndLoc() const
Get the end source location.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
SourceLocation getOverrideLoc() const
QualType getElementType() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
void CheckCXXDefaultArguments(FunctionDecl *FD)
CheckCXXDefaultArguments - Verify that the default arguments for a function declaration are well-form...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
RAII object to handle the state changes required to synthesize a function body.
IdentifierInfo * getPropertyDataSetter() const
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> Expansions)
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
This file provides some common utility functions for processing Lambda related AST Constructs...
std::list< CXXBasePath >::iterator paths_iterator
static std::vector< ComparisonCategoryResult > getPossibleResultsForType(ComparisonCategoryType Type)
Return the list of results which are valid for the specified comparison category type.
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
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, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
RAII object that enters a new expression evaluation context.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
Represents a variable declaration or definition.
ActionResult< Stmt * > StmtResult
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Information about one declarator, including the parsed type information and the identifier.
QualType getReturnType() const
DiagnosticsEngine & Diags
Wrapper for source info for member pointers.
unsigned getNumParams() const
bool isEnumeralType() const
void finishedDefaultedOrDeletedMember(CXXMethodDecl *MD)
Indicates that the declaration of a defaulted or deleted special member function is now complete...
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool This(InterpState &S, CodePtr OpPC)
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
void ActOnFinishCXXNonNestedClass()
Extra information about a function prototype.
bool hasInheritedDefaultArg() const
void clear()
Clear the base-paths results.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
TypeSpecifierType
Specifies the kind of type.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared...
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
The "__interface" keyword.
void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD)
Check that the C++ class annoated with "trivial_abi" satisfies all the conditions that are needed for...
RAII class that determines when any errors have occurred between the time the instance was created an...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
SourceLocation getFinalLoc() const
SourceLocation getLAngleLoc() const
bool isZeroLengthBitField(const ASTContext &Ctx) const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
DeclClass * getCorrectionDeclAs() const
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
TypeLoc getNamedTypeLoc() const
bool isInvalidDecl() const
Like System, but searched after the system directories.
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...
Stores a list of template parameters for a TemplateDecl and its derived classes.
void setBegin(SourceLocation b)
static StringRef getTagTypeKindName(TagTypeKind Kind)
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
bool isInterfaceLike() const
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...
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext)
Field is the non-static data member whose default initializer is used by this expression.
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool hasMethodTypeQualifiers() const
Determine whether this method has qualifiers.
bool hasDefinition() const
static StringRef getResultString(ComparisonCategoryResult Kind)
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
bool CheckConstexprFunctionDefinition(const FunctionDecl *FD, CheckConstexprKind Kind)
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
Represents a parameter to a function.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
Defines the clang::Expr interface and subclasses for C++ expressions.
Parse and apply any fixits to the source.
void removeDecl(Decl *D)
Removes a declaration from this context.
noexcept(expression), value-dependent
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
The collection of all-type qualifiers we support.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
bool isRecordingPaths() const
Whether we are recording paths.
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T)
Determine whether the given type is an incomplete or zero-lenfgth array type.
void CheckDelayedMemberExceptionSpecs()
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
SourceLocation getFriendSpecLoc() const
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
bool isRedeclaration() const
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer *> MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
Represents a struct/union/class.
bool hasTrivialCopyConstructorForCall() const
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...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
static QualType getTupleLikeElementType(Sema &S, SourceLocation Loc, unsigned I, QualType T)
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Description of a constructor that was inherited from a base class.
static bool IsEquivalentForUsingDecl(ASTContext &Context, NamedDecl *D1, NamedDecl *D2)
Determine whether a using declaration considers the given declarations as "equivalent", e.g., if they are redeclarations of the same entity or are both typedefs of the same type.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
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.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
unsigned getDepth() const
Retrieve the depth of the template parameter.
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
static bool IsUsingDirectiveInToplevelContext(DeclContext *CurContext)
Determine whether a using statement is in a context where it will be apply in all contexts...
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
void setRecordingPaths(bool RP)
Specify whether we should be recording paths or not.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
void setUninstantiatedDefaultArg(Expr *arg)
void ActOnStartFunctionDeclarationDeclarator(Declarator &D, unsigned TemplateParameterDepth)
Called before parsing a function declarator belonging to a function declaration.
Diagnose issues that are non-constant or that are extensions.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
bool isInline() const
Returns true if this is an inline namespace declaration.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ArrayRef< QualType > getParamTypes() const
The results of name lookup within a DeclContext.
SourceLocation getTypeSpecTypeLoc() const
TypeSourceInfo * getTypeSourceInfo() const
ConstexprSpecKind getConstexprKind() const
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
field_range fields() const
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, ParsedAttributes &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info, FieldDecl *Field, IndirectFieldDecl *Indirect=nullptr)
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
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...
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
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...
Represents a member of a struct/union/class.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr *> Args, bool RequiresADL=true)
Perform lookup for an overloaded binary operator.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
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...
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
bool isAbstractType(SourceLocation Loc, QualType T)
static bool isIncrementDecrementOp(Opcode Op)
bool Zero(InterpState &S, CodePtr OpPC)
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
bool isFunctionDefinition() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getExprLoc() const LLVM_READONLY
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
bool isReferenceType() const
CXXRecordDecl * getStdBadAlloc() const
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class.copy]p25)
void setElaboratedKeywordLoc(SourceLocation Loc)
bool evaluateDestruction(SmallVectorImpl< PartialDiagnosticAt > &Notes) const
Evaluate the destruction of this variable to determine if it constitutes constant destruction...
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
The iterator over UnresolvedSets.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
static void extendLeft(SourceRange &R, SourceRange Before)
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
ParmVarDecl * getParam(unsigned i) const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
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...
std::pair< VarDecl *, Expr * > get() const
LookupResultKind getResultKind() const
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
Represents an access specifier followed by colon ':'.
void ClearStorageClassSpecs()
SourceLocation getBeginLoc() const LLVM_READONLY
void addShadowDecl(UsingShadowDecl *S)
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
SourceLocation getTemplateLoc() const
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
A user-defined literal name, e.g., operator "" _i.
specific_decl_iterator< FieldDecl > field_iterator
SpecialMemberOverloadResult - The overloading result for a special member function.
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
void setImplicitCopyConstructorIsDeleted()
Set that we attempted to declare an implicit copy constructor, but overload resolution failed so we d...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
ArrayRef< ParmVarDecl * > parameters() const
A defaulted 'operator<=>' needed the comparison category.
DeclClass * getAsSingle() const
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl *> &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
bool isFinalSpelledSealed() const
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr *> Exprs, SourceLocation RParenLoc)
Create a paren list.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
Describes an C or C++ initializer list.
Represents a C++ using-declaration.
The argument of this type can be passed directly in registers.
ArrayRef< BindingDecl * > bindings() const
Represents a C++ unqualified-id that has been parsed.
An rvalue reference type, per C++11 [dcl.ref].
bool isCompleteType(SourceLocation Loc, QualType T)
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization. ...
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace...
static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class)
Represents the results of name lookup.
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
TagKind getTagKind() const
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
Microsoft throw(...) extension.
Succeeded, but refers to a deleted function.
A convenient class for passing around template argument information.
void setParamDestroyedInCallee(bool V)
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
void setDefaultedFunctionInfo(DefaultedFunctionInfo *Info)
Wrapper for source info for functions.
bool CheckUsingShadowDecl(UsingDecl *UD, 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...
bool needsOverloadResolutionForCopyAssignment() const
Determine whether we need to eagerly declare a defaulted copy assignment operator for this class...
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...
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
ArrayRef< NamedDecl * > chain() const
An x-value expression is a reference to an object with independent storage but which can be "moved"...
A friend of a previously-undeclared entity.
bool hasNonTrivialDestructorForCall() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
static bool BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, FieldDecl *Field, IndirectFieldDecl *Indirect, CXXCtorInitializer *&CXXMemberInit)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
__ptr16, alignas(...), etc.
const clang::PrintingPolicy & getPrintingPolicy() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
static void NoteIndirectBases(ASTContext &Context, IndirectBaseSet &Set, const QualType &Type)
Recursively add the bases of Type. Don't add Type itself.
semantics_iterator semantics_end()
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier *> Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
LangAS getAddressSpace() const
A set of unresolved declarations.
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt *> Stmts, SourceLocation LB, SourceLocation RB)
void CheckDelegatingCtorCycles()
QualType getExceptionObjectType(QualType T) const
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
bool isRValueReferenceType() const
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...
void setExceptionVariable(bool EV)
The argument of this type cannot be passed directly in registers.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
ActionResult< ParsedType > TypeResult
DeclContextLookupResult slice(size_t N) const
bool isLambda() const
Determine whether this class describes a lambda function object.
Scope - A scope is a transient data structure that is used while parsing the program.
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...
bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
field_iterator field_begin() const
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
Identify whether this function satisfies the formal rules for constexpr functions in the current lanu...
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
void EvaluateImplicitExceptionSpec(SourceLocation Loc, FunctionDecl *FD)
Evaluate the implicit exception specification for a defaulted special member function.
ExprResult ActOnCXXThis(SourceLocation loc)
bool isAnyMemberInitializer() const
Represents a C++ nested-name-specifier or a global scope specifier.
void setNumCtorInitializers(unsigned numCtorInitializers)
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
FieldDecl * getAnyMember() const
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
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'.
TemplateArgumentLoc getArgLoc(unsigned i) const
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
SourceLocation getConstSpecLoc() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
bool CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
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 ...
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
An ordinary object is located at an address in memory.
bool Const(InterpState &S, CodePtr OpPC, const T &Arg)
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification, including the language and (if present) the '{'.
Represents an ObjC class declaration.
const ValueInfo * getValueInfo(ComparisonCategoryResult ValueKind) const
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
Represents a linkage specification.
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)
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
const ComparisonCategoryInfo & getInfoForType(QualType Ty) const
Return the comparison category information as specified by getCategoryForType(Ty).
Member name lookup, which finds the names of class/struct/union members.
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
SourceRange getSourceRange() const LLVM_READONLY
bool isAbstract() const
Determine whether this class has a pure virtual function.
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
unsigned getNumArgs() const
A binding in a decomposition declaration.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
void setKind(ExplicitSpecKind Kind)
init_iterator init_begin()
Retrieve an iterator to the first initializer.
IdentifierInfo * getIdentifier() const
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3).
unsigned getLength() const
Efficiently return the length of this identifier info.
static bool CheckLiteralType(Sema &SemaRef, Sema::CheckConstexprKind Kind, SourceLocation Loc, QualType T, unsigned DiagID, Ts &&...DiagArgs)
Check that the given type is a literal type.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location...
static TemplateArgumentLoc getTrivialIntegralTemplateArgument(Sema &S, SourceLocation Loc, QualType T, uint64_t I)
ArgPassingKind getArgPassingRestrictions() const
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
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 isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
param_iterator param_begin()
Represents the this expression in C++.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, UsingDecl *UD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
Language
The language for the input, used to select and validate the language standard and possible actions...
static bool isValidUDSuffix(const LangOptions &LangOpts, StringRef Suffix)
Determine whether a suffix is a valid ud-suffix.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
ExtInfo withCallingConv(CallingConv cc) const
static StmtResult buildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying)
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
void removeInClassInitializer()
Remove the C++11 in-class initializer from this member.
DefaultedFunctionInfo * getDefaultedFunctionInfo() const
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
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...
DiagnosticsEngine & getDiagnostics() const
static bool checkArrayDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const ConstantArrayType *CAT)
CXXSpecialMember asSpecialMember() const
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), Expr *TrailingRequiresClause=nullptr)
bool isFinalSpecified() const
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
void DiagnoseDeletedDefaultedFunction(FunctionDecl *FD)
Produce notes explaining why a defaulted function was defined as deleted.
CXXSpecialMember
Kinds of C++ special members.
unsigned getFlags() const
getFlags - Return the flags for this scope.
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
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.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
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 adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
void setBases(CXXBaseSpecifier const *const *Bases, unsigned NumBases)
Sets the base classes of this struct or class.
bool isDeclspecPropertyAttribute() const
Is this the Microsoft __declspec(property) attribute?
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
ConditionalOperator - The ?: ternary operator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
Sema - This implements semantic analysis and AST building for C.
StringRef getString() const
Represents the declaration of a typedef-name via a C++11 alias-declaration.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true, bool ConsiderRequiresClauses=true)
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
SourceLocation getUnalignedSpecLoc() const
Represents a prototype with parameter type info, e.g.
virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool hasConstexprSpecifier() const
bool isDynamicClass() const
void ClearConstexprSpec()
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
SourceLocation getBeginLoc() const LLVM_READONLY
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
A RAII object to enter scope of a compound statement.
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
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...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Represents a ValueDecl that came out of a declarator.
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
SourceRange getLocalSourceRange() const
Get the local source range.
static StringRef getCategoryString(ComparisonCategoryType Kind)
static Sema::ImplicitExceptionSpecification ComputeDefaultedSpecialMemberExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD, Sema::CXXSpecialMember CSM, Sema::InheritedConstructorInfo *ICI)
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp)
ExplicitSpecifier getExplicitSpecifier()
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
ExplicitSpecifier ActOnExplicitBoolSpecifier(Expr *E)
ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression found in an explicit(bool)...
DeclarationNameTable DeclarationNames
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
bool hasTrivialMoveConstructorForCall() const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl *> &OverloadedMethods)
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
A conversion function name, e.g., operator int.
SourceRange getRange() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
bool isInlineSpecified() const
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
bool isLiteral() const
Determine whether this class is a literal type.
void setInClassInitializer(Expr *Init)
Set the C++11 in-class initializer for this member.
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared...
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
TST getTypeSpecType() const
SourceLocation getBeginLoc() const LLVM_READONLY
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...
bool hasKeyFunctions() const
Does this ABI use key functions? If so, class data such as the vtable is emitted with strong linkage ...
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
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...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMember > SpecialMemberDecl
bool isMsStruct(const ASTContext &C) const
Get whether or not this is an ms_struct which can be turned on with an attribute, pragma...
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
void setTrivialForCall(bool IT)
static bool checkComplexDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const ComplexType *CT)
SourceLocation getBeginLoc() const
Get the begin source location.
static bool checkArrayLikeDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType)
Allows QualTypes to be sorted and hence used in maps and sets.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
QualType getElementType() const
bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method)
Whether this' shows up in the exception specification of a static member function.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
StringRef getKindName() const
QualType getPointeeType() const
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
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...
bool isVariadic() const
Whether this function is variadic.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
llvm::StringRef getAsString(SyncScope S)
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
Helper class that collects exception specifications for implicitly-declared special member functions...
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
static void DiagnoseBaseOrMemInitializerOrder(Sema &SemaRef, const CXXConstructorDecl *Constructor, ArrayRef< CXXCtorInitializer *> Inits)
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
Declaration of a template type parameter.
unsigned getIndex() const
DeclContext * getEntity() const
bool defaultedMoveConstructorIsDeleted() const
true if a defaulted move constructor for this class would be deleted.
DeclarationNameInfo getNameInfo() const
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
void setRBraceLoc(SourceLocation L)
static bool checkVectorDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const VectorType *VT)
bool defaultedDestructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
OpaquePtr< T > get() const
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
SourceLocation getLocation() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
void freeParams()
Reset the parameter list to having zero parameters.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
std::string getAsString() const
Retrieve the human-readable string for this name.
unsigned getNumInits() const
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
SourceLocation getVolatileSpecLoc() const
SourceLocation getThreadStorageClassSpecLoc() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
void setRBraceLoc(SourceLocation L)
Defines the clang::Preprocessor interface.
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
void ActOnFinishFunctionDeclarationDeclarator(Declarator &D)
Called after parsing a function declarator belonging to a function declaration.
field_iterator field_end() const
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
overridden_method_range overridden_methods() const
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
bool isFileContext() const
SourceLocation getBeginLoc() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
Overload resolution succeeded.
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member, and after instantiating an in-class initializer in a class template.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
CXXTryStmt - A C++ try block, including all handlers.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
ExceptionSpecificationType getExceptionSpecType() const
Gets the ExceptionSpecificationType as declared.
static void DefineImplicitSpecialMember(Sema &S, CXXMethodDecl *MD, SourceLocation DefaultLoc)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
Represents a C++ template name within the type system.
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
const Expr * getExpr() const
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
static DefaultedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups)
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
SourceLocation getStorageClassSpecLoc() const
Defines the clang::TypeLoc interface and its subclasses.
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
void DiscardCleanupsInEvaluationContext()
The argument of this type cannot be passed directly in registers.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
void setInheritConstructors(bool Inherit=true)
Set that this base class's constructors should be inherited.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isFunctionOrMethod() const
static bool isPotentialConstantExpr(const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExpr - Return true if this function's definition might be usable in a constant exp...
StorageClass
Storage classes.
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
InClassInitStyle
In-class initialization styles for non-static data members.
This declaration has an owning module, and is visible when that module is imported.
Declaration of an alias template.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for record diagnostic message.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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.
For a defaulted function, the kind of defaulted function that it is.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
A boolean condition, from 'if', 'while', 'for', or 'do'.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
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...
QualType getRecordType(const RecordDecl *Decl) const
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method)
Integrate another called method into the collected data.
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
void setHasTrivialSpecialMemberForCall()
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool isFriendSpecified() const
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
void addContextNote(SourceLocation UseLoc)
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class...
void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an initializer for the declaration ...
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
static void PopulateKeysForFields(FieldDecl *Field, SmallVectorImpl< const void *> &IdealInits)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class.copy]p25)
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
The triviality of a method affected by "trivial_abi".
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
void exclude(Decl *F)
Exclude a function from being considered by overload resolution.
TypeLoc getReturnLoc() const
static bool RefersToRValueRef(Expr *MemRef)
bool hasValidIntValue() const
True iff we've successfully evaluated the variable as a constant expression and extracted its integer...
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
#define CheckPolymorphic(Type)
CanQualType getCanonicalTypeUnqualified() const
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasGroupingParens() const
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
RecordDecl * getDecl() const
bool hasVariantMembers() const
Determine whether this class has any variant members.
noexcept(expression), evals to 'false'
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
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.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
unsigned size_overridden_methods() const
static void SearchForReturnInStmt(Sema &Self, Stmt *S)
Wrapper for source info for arrays.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter...
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
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.
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
Decl::Kind getDeclKind() const
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
static bool CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef, const FunctionDecl *FnDecl)
bool isComparison() const
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
We are declaring an implicit special member function.
SmallVectorImpl< OverloadCandidate >::iterator iterator
CXXSpecialMember SpecialMember
The special member being declared or defined.
static CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
Represents a call to an inherited base class constructor from an inheriting constructor.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ExceptionSpecificationType Type
The kind of exception specification this is.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
TypeLoc IgnoreParens() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExtProtoInfo getExtProtoInfo() const
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SCS getStorageClassSpec() const
ASTContext & getASTContext() const
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList *> FriendTypeTPLists=None)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
llvm::SmallPtrSet< QualType, 4 > IndirectBaseSet
Use small set to collect indirect bases.
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
Encodes a location in the source.
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static Sema::ImplicitExceptionSpecification ComputeDefaultedComparisonExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD, Sema::DefaultedComparisonKind DCK)
We are computing the exception specification for a defaulted special member function.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
bool hasSameTemplateName(TemplateName X, TemplateName Y)
Determine whether the given template names refer to the same template.
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
unsigned getNumHandlers() const
decl_iterator decls_begin() const
Expr * getSubExpr() const
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void setTrivialForCallFlags(CXXMethodDecl *MD)
Attr * clone(ASTContext &C) const
enum clang::DeclaratorChunk::@219 Kind
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
CastKind getCastKind() const
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents the declaration of a struct/union/class/enum.
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
void CalledStmt(Stmt *S)
Integrate an invoked statement into the collected data.
void referenceDLLExportedClassMethods()
MutableArrayRef< Expr * > MultiExprArg
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
Represents a call to a member function that may be written either with member call syntax (e...
ASTContext & getASTContext() const LLVM_READONLY
bool isModulePrivateSpecified() const
InheritedConstructorInfo(Sema &S, SourceLocation UseLoc, ConstructorUsingShadowDecl *Shadow)
Attempt to be ABI-compatible with code generated by Clang 4.0.x (SVN r291814).
static bool CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, CanQualType ExpectedResultType, CanQualType ExpectedFirstParamType, unsigned DependentParamTypeDiag, unsigned InvalidParamTypeDiag)
Requests that only tied-for-best candidates be shown.
const ComparisonCategoryInfo * lookupInfoForType(QualType Ty) const
QualType getElementType() const
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
void setReferenced(bool R=true)
void DeclareImplicitEqualityComparison(CXXRecordDecl *RD, FunctionDecl *Spaceship)
IdentifierTable & getIdentifierTable()
ParsedAttr - Represents a syntactic attribute.
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...
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
Represents a dependent using declaration which was not marked with typename.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
const DecompositionDeclarator & getDecompositionDeclarator() const
void removeShadowDecl(UsingShadowDecl *S)
void setCtorInitializers(CXXCtorInitializer **Initializers)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
Represents a static or instance method of a struct/union/class.
void setDefaulted(bool D=true)
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
ExprResult DefaultLvalueConversion(Expr *E)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
void setEntity(DeclContext *E)
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckForFunctionMarkedFinal - Checks whether a virtual member function overrides a virtual member fun...
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
const ParmVarDecl * getParamDecl(unsigned i) const
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
void setImplicitMoveConstructorIsDeleted()
Set that we attempted to declare an implicit move constructor, but overload resolution failed so we d...
SourceLocation getLocation() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Name lookup found an unresolvable value declaration and cannot yet complete.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
Qualifiers getMethodQuals() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
static CXXBaseSpecifier * findDirectBaseWithType(CXXRecordDecl *Derived, QualType DesiredBase, bool &AnyDependentBases)
Find the base specifier for a base class with the given type.
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).
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
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...
static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
AccessSpecifier getAccess() const
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
bool isObjCObjectPointerType() const
A class for iterating through a result set and possibly filtering out results.
Direct list-initialization.
Represents a C++11 virt-specifier-seq.
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax...
static ConstructorUsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target, bool IsVirtual)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
bool isFunctionProtoType() const
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)
void setIsParsingBaseSpecifiers()
Requests that all candidates be shown.
bool hasUninstantiatedDefaultArg() const
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList *> Params, FriendUnion Friend, SourceLocation FriendLoc)
CXXRecordDecl * getOrigin() const
Retrieve the type from which this base-paths search began.
static bool BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, CXXBaseSpecifier *BaseSpec, bool IsInheritedVirtualBase, CXXCtorInitializer *&CXXBaseInit)
No entity found met the criteria.
static bool CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl)
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
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.
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
SourceLocation getRAngleLoc() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
SourceLocation getInlineSpecLoc() const
Optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
void setHasInheritedDefaultArg(bool I=true)
bool hasFlexibleArrayMember() const
bool defaultedCopyConstructorIsDeleted() const
true if a defaulted copy constructor for this class would be deleted.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
static bool checkTupleLikeDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, VarDecl *Src, QualType DecompType, const llvm::APSInt &TupleSize)
bool isTrivialForCall() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addArgument(const TemplateArgumentLoc &Loc)
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
TypeLoc getElementLoc() const
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
SourceLocation getLastLocation() const
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
A POD class for pairing a NamedDecl* with an access specifier.
bool isUndeducedAutoType() const
CXXConstructorDecl * getConstructor() const
StringRef getName() const
Return the actual identifier string.
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
static void checkForMultipleExportedDefaultConstructors(Sema &S, CXXRecordDecl *Class)
Decl * ActOnExceptionDeclarator(Scope *S, Declarator &D)
ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch handler.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Base class for declarations which introduce a typedef-name.
const ComparisonCategoryInfo * lookupInfo(ComparisonCategoryType Kind) const
Return the cached comparison category information for the specified 'Kind'.
ast_type_traits::DynTypedNode Node
TLS with a dynamic initializer.
Represents a template argument.
TagTypeKind
The kind of a tag type.
static bool isInvalid(LocType Loc, bool *Invalid)
const ObjCInterfaceDecl * getClassInterface() const
bool hasNonTrivialCopyConstructorForCall() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Dataflow Directional Tag Classes.
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
static void DelegatingCycleHelper(CXXConstructorDecl *Ctor, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Valid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Invalid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Current, Sema &S)
bool isValid() const
Return true if this is a valid SourceLocation object.
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
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.
const TemplateArgument & getArgument() const
not evaluated yet, for special member function
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static const TST TST_auto
method_iterator begin_overridden_methods() const
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
static void AddMostOverridenMethods(const CXXMethodDecl *MD, llvm::SmallPtrSetImpl< const CXXMethodDecl *> &Methods)
Add the most overriden methods from MD to Methods.
QualType getType() const
Get the type for which this source info wrapper provides information.
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
static bool InitializationHasSideEffects(const FieldDecl &FD)
static bool CheckConstexprDestructorSubobjects(Sema &SemaRef, const CXXDestructorDecl *DD, Sema::CheckConstexprKind Kind)
Determine whether a destructor cannot be constexpr due to.
bool hasTrivialDestructorForCall() const
Qualifiers getMethodQualifiers() const
SourceLocation getBaseTypeLoc() const LLVM_READONLY
Get the location at which the base class type was written.
Represents a field injected from an anonymous union/struct into the parent scope. ...
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
QualType getUnderlyingType() const
CanQualType UnsignedLongLongTy
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
AccessSpecifier getAccess() const
const Expr * getInit() const
A decomposition declaration.
MapType::iterator iterator
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
This template specialization was instantiated from a template due to an explicit instantiation declar...
static NamespaceDecl * getNamespaceDecl(NamedDecl *D)
getNamespaceDecl - Returns the namespace a decl represents.
bool hasUserDeclaredConstructor() const
Determine whether this class has any user-declared constructors.
unsigned getIndex() const
Retrieve the index of the template parameter.
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
Represents a dependent using declaration which was marked with typename.
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
bool areArgsDestroyedLeftToRightInCallee() const
Are arguments to a call destroyed left to right in the callee? This is a fundamental language change...
void setWillHaveBody(bool V=true)
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
The name of a declaration.
StmtClass getStmtClass() const
ArrayRef< QualType > exceptions() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
A set of unresolved declarations.
A mapping from each virtual member function to its set of final overriders.
unsigned getNumTemplateParameterLists() const
CXXRecordDecl * Record
The declaration for the comparison category type from the standard library.
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i...
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack...
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
semantics_iterator semantics_begin()
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
SourceLocation getBeginLoc() const LLVM_READONLY
bool isSpecialMember() const
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
friend_range friends() const
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
void PushUsingDirective(UsingDirectiveDecl *UDir)
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
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...
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
unsigned getNumParams() const
void setNameLoc(SourceLocation Loc)
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions)
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
const FunctionDecl * getOperatorDelete() const
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
static FunctionProtoType::ExtProtoInfo getImplicitMethodEPI(Sema &S, CXXMethodDecl *MD)
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
Name lookup found a single declaration that met the criteria.
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class...
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...
unsigned getIntWidth(QualType T) const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Not an overloaded operator.
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool isIncompleteArrayType() 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...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
static bool CheckOperatorNewDeclaration(Sema &SemaRef, const FunctionDecl *FnDecl)
MapType::const_iterator const_iterator
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
Expr * getUninstantiatedDefaultArg()
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static void extendRight(SourceRange &R, SourceRange After)
QualType getCanonicalTypeInternal() const
SourceLocation getVirtualSpecLoc() const
Represents a C++ base or member initializer.
LanguageIDs
Represents the language in a linkage specification.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
This template specialization was declared or defined by an explicit specialization (C++ [temp...
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
void setConstexprKind(ConstexprSpecKind CSK)
bool hasNonTrivialObjCLifetime() const
IndirectFieldDecl * getIndirectMember() const
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
const llvm::APInt & getSize() const
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)
bool isFunctionType() const
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
The template parameter lists that preceded the declarator.
TrivialSubobjectKind
The kind of subobject we are checking for triviality.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
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.
static const void * GetKeyForBase(ASTContext &Context, QualType BaseType)
TypeSourceInfo * getTypeSourceInfo() const
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
static bool CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S, SmallVectorImpl< SourceLocation > &ReturnStmts, SourceLocation &Cxx1yLoc, SourceLocation &Cxx2aLoc, Sema::CheckConstexprKind Kind)
Check the provided statement is allowed in a constexpr function definition.
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static UsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target)
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
TypeLocClass getTypeLocClass() const
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr)
The template argument is a type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Holds information about the various types of exception specification.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
void addDecl(Decl *D)
Add the declaration D into this context.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
void setInherited(bool I)
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Represents a base class of a C++ class.
bool hasTypename() const
Return true if the using declaration has 'typename'.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
This is a scope that can contain a declaration.
bool isObjCObjectType() const
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static const void * GetKeyForMember(ASTContext &Context, CXXCtorInitializer *Member)
A use of a default initializer in a constructor or in aggregate initialization.
EnumDecl * getStdAlignValT() const
bool isSet() const
Deprecated.
bool isLValueReferenceType() const
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
void setInvalidType(bool Val=true)
Reading or writing from this object requires a barrier call.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
QualType getParamType(unsigned i) const
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
TranslationUnitDecl * getTranslationUnitDecl() const
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
void Deallocate(void *Ptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static bool functionDeclHasDefaultArgument(const FunctionDecl *FD)
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
CallingConv getCallConv() const
ThreadStorageClassSpecifier
Thread storage-class-specifier.
void setImplicitMoveAssignmentIsDeleted()
Set that we attempted to declare an implicit move assignment operator, but overload resolution failed...
Describes the sequence of initializations required to initialize a given object or reference with a s...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
ArrayRef< DeclAccessPair > pairs() const
Captures information about "declaration specifiers".
ActionResult< Expr * > ExprResult
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
SourceLocation getRestrictSpecLoc() const
void setDefaultArg(Expr *defarg)
bool isMutable() const
Determines whether this field is mutable (C++ only).
void setEnd(SourceLocation e)
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...
Represents a C++ struct/union/class.
static bool CheckConstexprParameterTypes(Sema &SemaRef, const FunctionDecl *FD, Sema::CheckConstexprKind Kind)
Check whether a function's parameter types are all literal types.
static bool isCompoundAssignmentOp(Opcode Opc)
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
bool hasUserDeclaredMoveConstructor() const
Determine whether this class has had a move constructor declared by the user.
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, 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 ...
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, ArrayRef< CXXCtorInitializer *> Initializers=None)
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier *> Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
CXXCatchStmt - This represents a C++ catch block.
bool LE(InterpState &S, CodePtr OpPC)
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter, but we can't parse it yet because we're inside a class definition.
static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, llvm::APSInt &Size)
void popCodeSynthesisContext()
void setParam(unsigned i, ParmVarDecl *VD)
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
static bool hasOneRealArgument(MultiExprArg Args)
Determine whether the given list arguments contains exactly one "real" (non-default) argument...
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.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void setUnsupportedFriend(bool Unsupported)
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
Declaration of a class template.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool isVirtualSpecified() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
void setInventedTemplateParameterList(TemplateParameterList *Invented)
Sets the template parameter list generated from the explicit template parameters along with any inven...
bool lambdaIsDefaultConstructibleAndAssignable() const
Determine whether this lambda should have an implicit default constructor and copy and move assignmen...
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
SourceManager & getSourceManager() const
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
A template-id, e.g., f<int>.
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant, according to C++ [class.virtual]p5.
bool hasInheritedAssignment() const
Determine whether this class has a using-declaration that names a base class assignment operator...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
AccessSpecifier Access
The access along this inheritance path.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool isInlineSpecified() const
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...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Kind
Lists the kind of concrete classes of Decl.
SourceLocation getAtomicSpecLoc() 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, or computed.
FriendDecl * CheckFriendTypeDecl(SourceLocation LocStart, SourceLocation FriendLoc, TypeSourceInfo *TSInfo)
Perform semantic analysis of the given friend type declaration.
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
static void CheckAbstractClassUsage(AbstractUsageInfo &Info, CXXMethodDecl *MD)
Check for invalid uses of an abstract type in a method declaration.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
unsigned getNumElements() const
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
The top declaration context.
Microsoft __declspec(nothrow) extension.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
SourceLocation getConstexprSpecLoc() const
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD)
Diagnose methods which overload virtual methods in a base class without overriding any...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool implicitCopyConstructorHasConstParam() const
Determine whether an implicit copy constructor for this type would have a parameter with a const-qual...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
void addAddressSpace(LangAS space)
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
No viable function found.
ArrayRef< Binding > bindings() const
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness, issuing any diagnostics required.
DeclaratorContext getContext() const
bool isStaticDataMember() const
Determines whether this is a static data member.
SourceLocation getInnerLocStart() const
Return SourceLocation representing start of source range ignoring outer template declarations.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
bool hasDirectFields() const
Determine whether this class has direct non-static data members.
An instance of this class represents the declaration of a property member.
void DefineDefaultedComparison(SourceLocation Loc, FunctionDecl *FD, DefaultedComparisonKind DCK)
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
A trivial tuple used to represent a source range.
void setLexicalDeclContext(DeclContext *DC)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
bool isTranslationUnit() const
Expr * getRepAsExpr() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
bool tryResolveExplicitSpecifier(ExplicitSpecifier &ExplicitSpec)
tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
Represents a C++ namespace alias.
Decl * 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.
No keyword precedes the qualified type name.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Represents C++ using-directive.
void DiagnoseAbstractType(const CXXRecordDecl *RD)
static Expr * CastForMoving(Sema &SemaRef, Expr *E, QualType T=QualType())
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
Describes an entity that is being initialized.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
attr::Kind getKind() const
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.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
The global specifier '::'. There is no stored value.
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
The object is actually the complete object.
FunctionTypeLoc getFunctionTypeLoc() const
Find the source location information for how the type of this function was written.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void setType(QualType newType)
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
Wrapper for source info for pointers.
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
StmtResult ActOnIfStmt(SourceLocation IfLoc, bool IsConstexpr, Stmt *InitStmt, ConditionResult Cond, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
SourceLocation ColonLoc
Location of ':'.
SourceRange getSourceRange() const LLVM_READONLY
const LangOptions & getLangOpts() const
void WillReplaceSpecifier(bool ForceReplacement)
Wrapper for source info for block pointers.
void setDeletedAsWritten(bool D=true)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions, such as the default constructor, copy constructor, or destructor, to the given C++ class (C++ [special]p1).
ComparisonCategoryType commonComparisonType(ComparisonCategoryType A, ComparisonCategoryType B)
Determine the common comparison type, as defined in C++2a [class.spaceship]p4.
An implicit 'self' parameter.
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
ExceptionSpecInfo ExceptionSpec
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
A deduction-guide name (a template-name)
Declaration of a template function.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
Represents an implicitly-generated value initialization of an object of a given type.
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
void setElaboratedKeywordLoc(SourceLocation Loc)
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
static bool checkLiteralOperatorTemplateParameterList(Sema &SemaRef, FunctionTemplateDecl *TpDecl)
static const ParsedAttr * getMSPropertyAttr(const ParsedAttributesView &list)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool isExternallyVisible() const
QualType getType() const
Return the type wrapped by this type source info.
A single template declaration.
bool isBeingDefined() const
Return true if this decl is currently being defined.
ConstructorUsingShadowDecl * getShadowDecl() const
noexcept(expression), evals to 'true'
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
decl_iterator decls_end() const
The triviality of a method unaffected by "trivial_abi".
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
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 ...
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template)
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.
method_range methods() const
The subobject is a non-static data member.
bool isNoDestroy(const ASTContext &) const
Is destruction of this variable entirely suppressed? If so, the variable need not have a usable destr...
QualType getType() const
Retrieves the type of the base class.
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>, including the values return by builtin <=> operators.
bool defaultedDestructorIsDeleted() const
true if a defaulted destructor for this class would be deleted.