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) {
148 diag::err_lambda_capture_default_arg);
161 Proto = Self->ResolveExceptionSpec(CallLoc, Proto);
178 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(E))
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 (NewGuide && NewGuide->isExplicitSpecified() !=
667 cast<CXXDeductionGuideDecl>(Old)->isExplicitSpecified()) {
669 << NewGuide->isExplicitSpecified();
679 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
697 Diag(Decomp.getLSquareLoc(), diag::err_decomp_decl_context)
698 << Decomp.getSourceRange();
702 if (!TemplateParamLists.empty()) {
705 Diag(TemplateParamLists.front()->getTemplateLoc(),
706 diag::err_decomp_decl_template);
710 Diag(Decomp.getLSquareLoc(),
711 !getLangOpts().CPlusPlus17
712 ? diag::ext_decomp_decl
714 ? diag::ext_decomp_decl_cond
715 : diag::warn_cxx14_compat_decomp_decl)
716 << Decomp.getSourceRange();
728 if (
auto SCS = DS.getStorageClassSpec()) {
730 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
732 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
734 BadSpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
736 if (DS.isConstexprSpecified()) {
737 BadSpecifiers.push_back(
"constexpr");
738 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
740 if (DS.isInlineSpecified()) {
741 BadSpecifiers.push_back(
"inline");
742 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
744 if (!BadSpecifiers.empty()) {
745 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
746 Err << (int)BadSpecifiers.size()
747 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
750 for (
auto Loc : BadSpecifierLocs)
762 UPPC_DeclarationType))
772 Diag(Decomp.getLSquareLoc(),
776 ? diag::err_decomp_decl_parens
777 : diag::err_decomp_decl_type)
795 ForVisibleRedeclaration);
796 LookupName(Previous, S,
809 FilterLookupForScope(Previous, DC, S, ConsiderLinkage,
811 if (!Previous.
empty()) {
813 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
814 Diag(Old->getLocation(), diag::note_previous_definition);
818 PushOnScopeChains(BD, S,
true);
819 Bindings.push_back(BD);
820 ParsingInitForAutoVars.insert(BD);
826 Decomp.getLSquareLoc());
828 ForVisibleRedeclaration);
831 bool AddToScope =
true;
833 ActOnVariableDeclarator(S, D, DC, TInfo, Previous,
837 CurContext->addHiddenDecl(New);
840 if (isInOpenMPDeclareTargetContext())
841 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
850 if ((int64_t)Bindings.size() != NumElems) {
851 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
852 << DecompType << (
unsigned)Bindings.size() << NumElems.toString(10)
853 << (NumElems < Bindings.size());
858 for (
auto *B : Bindings) {
863 E = GetInit(Loc, E.
get(), I++);
866 B->setBinding(ElemType, E.
get());
875 const llvm::APSInt &NumElems,
878 S, Bindings, Src, DecompType, NumElems, ElemType,
899 S, Bindings, Src, DecompType, llvm::APSInt::get(VT->
getNumElements()),
909 S, Bindings, Src, DecompType, llvm::APSInt::get(2),
920 llvm::raw_svector_ostream OS(SS);
925 Arg.getArgument().print(PrintingPolicy, OS);
935 auto DiagnoseMissing = [&] {
945 return DiagnoseMissing();
955 return DiagnoseMissing();
961 Result.suppressDiagnostics();
963 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
975 Loc, TraitTy, DiagID,
981 assert(RD &&
"specialization of class template is not a class?");
1003 llvm::APSInt &Size) {
1016 return IsTupleLike::NotTupleLike;
1025 : R(R), Args(Args) {}
1027 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1030 } Diagnoser(R, Args);
1046 return IsTupleLike::TupleLike;
1061 S, R, Loc,
"tuple_element", Args,
1062 diag::err_decomp_decl_std_tuple_element_not_specialized))
1068 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1079 struct BindingDiagnosticTrap {
1085 : S(S), Trap(S.
Diags), BD(BD) {}
1086 ~BindingDiagnosticTrap() {
1096 const llvm::APSInt &TupleSize) {
1097 if ((int64_t)Bindings.size() != TupleSize) {
1098 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1099 << DecompType << (
unsigned)Bindings.size() << TupleSize.toString(10)
1100 << (TupleSize < Bindings.size());
1104 if (Bindings.empty())
1113 bool UseMemberGet =
false;
1117 if (MemberGet.isAmbiguous())
1119 UseMemberGet = !MemberGet.empty();
1124 for (
auto *B : Bindings) {
1125 BindingDiagnosticTrap Trap(S, B);
1147 MemberGet, &Args,
nullptr);
1181 B->getDeclName().getAsIdentifierInfo(), RefType,
1185 RefVD->setImplicit();
1187 RefVD->setInlineSpecified();
1188 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1193 E = Seq.
Perform(S, Entity, Kind, Init);
1199 RefVD->setInit(E.
get());
1200 RefVD->checkInitIsICE();
1208 B->setBinding(T, E.
get());
1232 ClassWithFields = RD;
1236 Paths.
setOrigin(const_cast<CXXRecordDecl*>(RD));
1244 for (
auto &
P : Paths) {
1248 BestPath->back().Base->getType())) {
1250 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1251 <<
false << RD << BestPath->back().Base->getType()
1252 <<
P.back().Base->getType();
1254 }
else if (
P.Access < BestPath->
Access) {
1260 QualType BaseType = BestPath->back().Base->getType();
1262 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1269 S.
Diag(Loc, diag::err_decomp_decl_non_public_base)
1271 for (
auto &BS : *BestPath) {
1272 if (BS.Base->getAccessSpecifier() !=
AS_public) {
1273 S.
Diag(BS.Base->getLocStart(), diag::note_access_constrained_by_path)
1275 << (BS.Base->getAccessSpecifierAsWritten() ==
AS_none);
1290 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1291 << (ClassWithFields == RD) << RD << ClassWithFields
1292 << Paths.
front().back().Base->getType();
1296 return ClassWithFields;
1309 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1310 unsigned NumFields =
1312 [](
FieldDecl *FD) {
return !FD->isUnnamedBitfield(); });
1313 assert(Bindings.size() != NumFields);
1314 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1315 << DecompType << (
unsigned)Bindings.size() << NumFields
1316 << (NumFields < Bindings.size());
1323 for (
auto *FD : RD->
fields()) {
1324 if (FD->isUnnamedBitfield())
1327 if (FD->isAnonymousStructOrUnion()) {
1330 S.
Diag(FD->getLocation(), diag::note_declared_at);
1335 if (I >= Bindings.size())
1336 return DiagnoseBadNumberOfBindings();
1337 auto *B = Bindings[I++];
1341 S.
Diag(Loc, diag::err_decomp_decl_non_public_member) << FD << DecompType;
1344 bool Implicit =
true;
1345 for (
const auto *D : RD->
decls()) {
1348 if (isa<AccessSpecDecl>(D)) {
1354 S.
Diag(FD->getLocation(), diag::note_access_natural)
1380 if (FD->isMutable())
1385 if (I != Bindings.size())
1386 return DiagnoseBadNumberOfBindings();
1428 llvm::APSInt TupleSize(32);
1434 case IsTupleLike::TupleLike:
1439 case IsTupleLike::NotTupleLike:
1448 << DD << !RD << DecompType;
1467 if (!getLangOpts().CXXExceptions)
1471 "Should only be called if types are otherwise the same.");
1482 NewType =
P->getPointeeType();
1495 if (CheckEquivalentExceptionSpec(
1510 for (p = 0; p < NumParams; ++p) {
1522 unsigned LastMissingDefaultArg = 0;
1523 for (; p < NumParams; ++p) {
1530 diag::err_param_default_argument_missing_name)
1534 diag::err_param_default_argument_missing);
1536 LastMissingDefaultArg = p;
1540 if (LastMissingDefaultArg > 0) {
1545 for (p = 0; p <= LastMissingDefaultArg; ++p) {
1559 unsigned ArgIndex = 0;
1563 i != e; ++i, ++ArgIndex) {
1566 if (!(*i)->isDependentType() &&
1568 diag::err_constexpr_non_literal_param,
1570 isa<CXXConstructorDecl>(FD)))
1586 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1606 << isa<CXXConstructorDecl>(NewFD)
1608 for (
const auto &I : RD->
vbases())
1609 Diag(I.getLocStart(),
1610 diag::note_constexpr_virtual_base_here) << I.getSourceRange();
1615 if (!isa<CXXConstructorDecl>(NewFD)) {
1628 while (!WrittenVirtual->isVirtualAsWritten())
1630 if (WrittenVirtual != Method)
1631 Diag(WrittenVirtual->getLocation(),
1632 diag::note_overridden_virtual_function);
1640 diag::err_constexpr_non_literal_return))
1661 for (
const auto *DclIt : DS->
decls()) {
1662 switch (DclIt->getKind()) {
1663 case Decl::StaticAssert:
1665 case Decl::UsingShadow:
1666 case Decl::UsingDirective:
1667 case Decl::UnresolvedUsingTypename:
1668 case Decl::UnresolvedUsingValue:
1675 case Decl::TypeAlias: {
1678 const auto *TN = cast<TypedefNameDecl>(DclIt);
1679 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1681 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1684 << isa<CXXConstructorDecl>(Dcl);
1691 case Decl::CXXRecord:
1693 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition())
1696 ? diag::warn_cxx11_compat_constexpr_type_definition
1697 : diag::ext_constexpr_type_definition)
1698 << isa<CXXConstructorDecl>(Dcl);
1701 case Decl::EnumConstant:
1702 case Decl::IndirectField:
1709 case Decl::Decomposition: {
1713 const auto *VD = cast<VarDecl>(DclIt);
1714 if (VD->isThisDeclarationADefinition()) {
1715 if (VD->isStaticLocal()) {
1716 SemaRef.
Diag(VD->getLocation(),
1717 diag::err_constexpr_local_var_static)
1718 << isa<CXXConstructorDecl>(Dcl)
1722 if (!VD->getType()->isDependentType() &&
1724 VD->getLocation(), VD->getType(),
1725 diag::err_constexpr_local_var_non_literal_type,
1726 isa<CXXConstructorDecl>(Dcl)))
1728 if (!VD->getType()->isDependentType() &&
1729 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1730 SemaRef.
Diag(VD->getLocation(),
1731 diag::err_constexpr_local_var_no_init)
1732 << isa<CXXConstructorDecl>(Dcl);
1736 SemaRef.
Diag(VD->getLocation(),
1738 ? diag::warn_cxx11_compat_constexpr_local_var
1739 : diag::ext_constexpr_local_var)
1740 << isa<CXXConstructorDecl>(Dcl);
1744 case Decl::NamespaceAlias:
1753 SemaRef.
Diag(DS->
getLocStart(), diag::err_constexpr_body_invalid_stmt)
1754 << isa<CXXConstructorDecl>(Dcl);
1773 llvm::SmallSet<Decl*, 16> &
Inits,
1790 if (!Inits.count(Field)) {
1792 SemaRef.
Diag(Dcl->
getLocation(), diag::err_constexpr_ctor_missing_init);
1795 SemaRef.
Diag(Field->
getLocation(), diag::note_constexpr_ctor_missing_init);
1798 for (
auto *I : RD->
fields())
1801 if (!RD->
isUnion() || Inits.count(I))
1814 case Stmt::NullStmtClass:
1818 case Stmt::DeclStmtClass:
1828 case Stmt::ReturnStmtClass:
1830 if (isa<CXXConstructorDecl>(Dcl)) {
1840 case Stmt::CompoundStmtClass: {
1846 for (
auto *BodyIt : CompStmt->
body()) {
1854 case Stmt::AttributedStmtClass:
1859 case Stmt::IfStmtClass: {
1864 IfStmt *If = cast<IfStmt>(S);
1875 case Stmt::WhileStmtClass:
1876 case Stmt::DoStmtClass:
1877 case Stmt::ForStmtClass:
1878 case Stmt::CXXForRangeStmtClass:
1879 case Stmt::ContinueStmtClass:
1893 case Stmt::SwitchStmtClass:
1894 case Stmt::CaseStmtClass:
1895 case Stmt::DefaultStmtClass:
1896 case Stmt::BreakStmtClass:
1919 << isa<CXXConstructorDecl>(Dcl);
1928 if (isa<CXXTryStmt>(Body)) {
1939 << isa<CXXConstructorDecl>(Dcl);
1949 for (
auto *BodyIt : CompBody->
body()) {
1954 if (Cxx1yLoc.isValid())
1956 getLangOpts().CPlusPlus14
1957 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
1958 : diag::ext_constexpr_body_invalid_stmt)
1959 << isa<CXXConstructorDecl>(Dcl);
1962 = dyn_cast<CXXConstructorDecl>(Dcl)) {
1971 if (Constructor->getNumCtorInitializers() == 0 &&
1976 }
else if (!Constructor->isDependentContext() &&
1977 !Constructor->isDelegatingConstructor()) {
1978 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
1982 bool AnyAnonStructUnionMembers =
false;
1983 unsigned Fields = 0;
1985 E = RD->
field_end(); I != E; ++I, ++Fields) {
1986 if (I->isAnonymousStructOrUnion()) {
1987 AnyAnonStructUnionMembers =
true;
1995 if (AnyAnonStructUnionMembers ||
1996 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
2000 llvm::SmallSet<Decl*, 16>
Inits;
2001 for (
const auto *I: Constructor->inits()) {
2005 Inits.insert(
ID->chain_begin(),
ID->chain_end());
2008 bool Diagnosed =
false;
2009 for (
auto *I : RD->
fields())
2016 if (ReturnStmts.empty()) {
2021 bool OK = getLangOpts().CPlusPlus14 &&
2025 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2026 : diag::err_constexpr_body_no_return);
2029 }
else if (ReturnStmts.size() > 1) {
2030 Diag(ReturnStmts.back(),
2031 getLangOpts().CPlusPlus14
2032 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2033 : diag::ext_constexpr_body_multiple_return);
2034 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2035 Diag(ReturnStmts[I], diag::note_constexpr_body_previous_return);
2051 Diag(Dcl->
getLocation(), diag::ext_constexpr_function_never_constant_expr)
2052 << isa<CXXConstructorDecl>(Dcl);
2053 for (
size_t I = 0, N = Diags.size(); I != N; ++I)
2054 Diag(Diags[I].first, Diags[I].second);
2071 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2078 return dyn_cast_or_null<CXXRecordDecl>(DC);
2081 return dyn_cast_or_null<CXXRecordDecl>(CurContext);
2098 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2100 if (!getLangOpts().SpellChecking)
2106 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2108 CurDecl = dyn_cast_or_null<CXXRecordDecl>(CurContext);
2110 if (CurDecl && CurDecl->getIdentifier() && II != CurDecl->getIdentifier() &&
2111 3 * II->
getName().edit_distance(CurDecl->getIdentifier()->getName())
2113 II = CurDecl->getIdentifier();
2128 for (
const auto &I : Current->
bases()) {
2140 Queue.push_back(Base);
2146 Current = Queue.pop_back_val();
2174 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2187 ((BaseDecl = BaseDecl->getDefinition()) &&
2189 Diag(BaseLoc, diag::err_circular_inheritance)
2193 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
2202 Access, TInfo, EllipsisLoc);
2207 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2214 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2221 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2223 propagateDLLAttrToBaseClassTemplate(Class, ClassAttr, BaseTemplate,
2232 if (RequireCompleteType(BaseLoc, BaseType,
2233 diag::err_incomplete_base_class, SpecifierRange)) {
2240 assert(BaseDecl &&
"Record type has no declaration");
2242 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2244 assert(CXXBaseDecl &&
"Base type is not a C++ type");
2249 const auto *BaseCSA = CXXBaseDecl->
getAttr<CodeSegAttr>();
2250 const auto *DerivedCSA = Class->
getAttr<CodeSegAttr>();
2251 if ((DerivedCSA || BaseCSA) &&
2252 (!BaseCSA || !DerivedCSA || BaseCSA->getName() != DerivedCSA->getName())) {
2254 Diag(CXXBaseDecl->
getLocation(), diag::note_base_class_specified_here)
2266 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2274 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
2275 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2277 << FA->isSpelledAsSealed();
2289 Access, TInfo, EllipsisLoc);
2306 AdjustDeclIfTemplate(classdecl);
2320 ? diag::warn_unknown_attribute_ignored
2321 : diag::err_base_specifier_attribute)
2326 GetTypeFromParser(basetype, &TInfo);
2329 DiagnoseUnexpandedParameterPack(SpecifierRange.
getBegin(), TInfo,
2334 Virtual, Access, TInfo,
2355 auto Decl = Rec->getAsCXXRecordDecl();
2358 for (
const auto &BaseSpec : Decl->bases()) {
2360 .getUnqualifiedType();
2361 if (Set.insert(Base).second)
2379 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2383 IndirectBaseSet IndirectBaseTypes;
2386 unsigned NumGoodBases = 0;
2387 bool Invalid =
false;
2388 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2398 Diag(Bases[idx]->getLocStart(),
2399 diag::err_duplicate_base_class)
2401 << Bases[idx]->getSourceRange();
2410 KnownBase = Bases[idx];
2411 Bases[NumGoodBases++] = Bases[idx];
2414 if (Bases.size() > 1)
2418 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
2430 Class->
addAttr(WeakAttr::CreateImplicit(Context));
2436 Class->
setBases(Bases.data(), NumGoodBases);
2439 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2441 QualType BaseType = Bases[idx]->getType();
2451 if (IndirectBaseTypes.count(CanonicalBase)) {
2455 = Class->
isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
2460 Diag(Bases[idx]->getLocStart (), diag::warn_inaccessible_base_class)
2461 << BaseType << getAmbiguousPathsDisplayString(Paths)
2462 << Bases[idx]->getSourceRange();
2464 assert(Bases[idx]->isVirtual());
2480 if (!ClassDecl || Bases.empty())
2483 AdjustDeclIfTemplate(ClassDecl);
2484 AttachBaseSpecifiers(cast<CXXRecordDecl>(ClassDecl), Bases);
2508 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2529 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2541 for (
unsigned I = Path.size(); I != 0; --I) {
2542 if (Path[I - 1].
Base->isVirtual()) {
2549 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
2550 BasePathArray.push_back(const_cast<CXXBaseSpecifier*>(Path[I].Base));
2556 assert(BasePathArray.empty() &&
"Base path array must be empty!");
2574 unsigned InaccessibleBaseID,
2575 unsigned AmbigiousBaseConvID,
2579 bool IgnoreAccess) {
2586 bool DerivationOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2587 if (!DerivationOkay)
2592 Path = &Paths.
front();
2597 if (!Path && getLangOpts().MSVCCompat) {
2599 if (PossiblePath.size() == 1) {
2600 Path = &PossiblePath;
2601 if (AmbigiousBaseConvID)
2602 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
2603 << Base << Derived << Range;
2610 if (!IgnoreAccess) {
2613 CheckBaseClassAccess(Loc, Base, Derived, *Path, InaccessibleBaseID)) {
2629 if (AmbigiousBaseConvID) {
2638 bool StillOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2639 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
2646 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
2648 Diag(Loc, AmbigiousBaseConvID)
2649 << Derived << Base << PathDisplayStr << Range << Name;
2658 bool IgnoreAccess) {
2659 return CheckDerivedToBaseConversion(
2660 Derived, Base, diag::err_upcast_to_inaccessible_base,
2661 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
2662 BasePath, IgnoreAccess);
2679 std::string PathDisplayStr;
2680 std::set<unsigned> DisplayedPaths;
2682 Path != Paths.
end(); ++Path) {
2683 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
2686 PathDisplayStr +=
"\n ";
2688 for (CXXBasePath::const_iterator Element = Path->begin();
2689 Element != Path->end(); ++Element)
2690 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
2694 return PathDisplayStr;
2705 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
2708 CurContext->addHiddenDecl(ASDecl);
2709 return ProcessAccessDeclAttributeList(ASDecl, Attrs);
2733 FindHiddenVirtualMethods(MD, OverloadedMethods);
2735 if (!OverloadedMethods.empty()) {
2736 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2737 Diag(OA->getLocation(),
2738 diag::override_keyword_hides_virtual_member_function)
2739 <<
"override" << (OverloadedMethods.size() > 1);
2740 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2741 Diag(FA->getLocation(),
2742 diag::override_keyword_hides_virtual_member_function)
2743 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2744 << (OverloadedMethods.size() > 1);
2746 NoteHiddenVirtualMethods(MD, OverloadedMethods);
2755 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2756 Diag(OA->getLocation(),
2757 diag::override_keyword_only_allowed_on_virtual_member_functions)
2761 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2762 Diag(FA->getLocation(),
2763 diag::override_keyword_only_allowed_on_virtual_member_functions)
2764 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2776 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
2777 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
2790 if (getSourceManager().isMacroArgExpansion(Loc))
2791 SpellingLoc = getSourceManager().getImmediateExpansionRange(Loc).getBegin();
2792 SpellingLoc = getSourceManager().getSpellingLoc(SpellingLoc);
2793 if (SpellingLoc.
isValid() && getSourceManager().isInSystemHeader(SpellingLoc))
2797 unsigned DiagID = isa<CXXDestructorDecl>(MD)
2798 ? diag::warn_destructor_marked_not_override_overriding
2799 : diag::warn_function_marked_not_override_overriding;
2811 FinalAttr *FA = Old->
getAttr<FinalAttr>();
2817 << FA->isSpelledAsSealed();
2826 return !RD->isCompleteDefinition() ||
2827 !RD->hasTrivialDefaultConstructor() ||
2828 !RD->hasTrivialDestructor();
2834 llvm::find_if(list, [](
const ParsedAttr &AL) {
2837 if (Itr != list.
end())
2846 if (Diags.isIgnored(diag::warn_shadow_field, Loc))
2850 std::map<CXXRecordDecl*, NamedDecl*> Bases;
2855 if (Bases.find(
Base) != Bases.end())
2857 for (
const auto Field :
Base->lookup(FieldName)) {
2858 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
2860 assert(Field->getAccess() !=
AS_none);
2861 assert(Bases.find(
Base) == Bases.end());
2862 Bases[
Base] = Field;
2874 for (
const auto &
P : Paths) {
2875 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
2876 auto It = Bases.find(
Base);
2878 if (It == Bases.end())
2880 auto BaseField = It->second;
2881 assert(BaseField->getAccess() !=
AS_private);
2884 Diag(Loc, diag::warn_shadow_field)
2885 << FieldName << RD <<
Base;
2886 Diag(BaseField->getLocation(), diag::note_shadow_field);
2911 Expr *BitWidth =
static_cast<Expr*
>(BW);
2913 assert(isa<CXXRecordDecl>(CurContext));
2920 if (cast<CXXRecordDecl>(CurContext)->isInterface()) {
2924 unsigned InvalidDecl;
2925 bool ShowDeclName =
true;
2938 ShowDeclName =
false;
2943 ShowDeclName =
false;
2958 Diag(Loc, diag::err_invalid_member_in_interface)
2959 << (InvalidDecl-1) << Name;
2961 Diag(Loc, diag::err_invalid_member_in_interface)
2962 << (InvalidDecl-1) <<
"";
2988 diag::err_storageclass_invalid_for_member);
3008 const char *PrevSpec;
3013 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3017 const char *PrevSpec;
3023 "This is the only DeclSpec that should fail to be applied");
3027 isInstField =
false;
3038 Diag(Loc, diag::err_bad_variable_name)
3047 if (TemplateParameterLists.size()) {
3049 if (TemplateParams->
size()) {
3058 diag::err_template_member_noparams)
3073 if (
DeclContext *DC = computeDeclContext(SS,
false))
3084 if (MSPropertyAttr) {
3085 Member = HandleMSProperty(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3086 BitWidth, InitStyle, AS, *MSPropertyAttr);
3089 isInstField =
false;
3091 Member = HandleField(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3092 BitWidth, InitStyle, AS);
3097 CheckShadowInheritedFields(Loc, Name, cast<CXXRecordDecl>(CurContext));
3099 Member = HandleDeclarator(S, D, TemplateParameterLists);
3107 }
else if (isa<VarDecl>(Member) || isa<VarTemplateDecl>(Member)) {
3110 Diag(Loc, diag::err_static_not_bitfield)
3112 }
else if (isa<TypedefDecl>(Member)) {
3114 Diag(Loc, diag::err_typedef_not_bitfield)
3119 Diag(Loc, diag::err_not_integral_type_bitfield)
3120 << Name << cast<ValueDecl>(Member)->getType()
3130 NonTemplateMember = FunTmpl->getTemplatedDecl();
3131 else if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(Member))
3132 NonTemplateMember = VarTmpl->getTemplatedDecl();
3138 if (NonTemplateMember != Member)
3144 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3145 auto *TD = DG->getDeducedTemplate();
3146 if (AS != TD->getAccess()) {
3147 Diag(DG->getLocStart(), diag::err_deduction_guide_wrong_access);
3148 Diag(TD->getLocStart(), diag::note_deduction_guide_template_access)
3151 for (
const auto *D : cast<CXXRecordDecl>(CurContext)->decls()) {
3152 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(D))
3153 LastAccessSpec = AccessSpec;
3155 assert(LastAccessSpec &&
"differing access with no access specifier");
3156 Diag(LastAccessSpec->
getLocStart(), diag::note_deduction_guide_access)
3170 if (
CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(Member))
3174 CheckOverrideControl(Member);
3176 assert((Name || isInstField) &&
"No identifier for non-field ?");
3179 FieldDecl *FD = cast<FieldDecl>(Member);
3180 FieldCollector->Add(FD);
3182 if (!Diags.isIgnored(diag::warn_unused_private_field, FD->
getLocation())) {
3190 UnusedPrivateFields.insert(FD);
3198 class UninitializedFieldVisitor
3203 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3206 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3221 UninitializedFieldVisitor(
Sema &S,
3222 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3223 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3224 : Inherited(S.
Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3225 Constructor(
nullptr), InitList(
false), InitListFieldDecl(
nullptr) {}
3228 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3229 bool CheckReferenceOnly) {
3231 bool ReferenceField =
false;
3236 Fields.push_back(FD);
3238 ReferenceField =
true;
3244 if (CheckReferenceOnly && !ReferenceField)
3250 for (
auto I = Fields.rbegin() + 1, E = Fields.rend(); I != E; ++I) {
3251 UsedFieldIndex.push_back((*I)->getFieldIndex());
3254 for (
auto UsedIter = UsedFieldIndex.begin(),
3255 UsedEnd = UsedFieldIndex.end(),
3256 OrigIter = InitFieldIndex.begin(),
3257 OrigEnd = InitFieldIndex.end();
3258 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3259 if (*UsedIter < *OrigIter)
3261 if (*UsedIter > *OrigIter)
3268 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3283 if (isa<VarDecl>(SubME->getMemberDecl()))
3286 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3287 if (!FD->isAnonymousStructOrUnion())
3291 AllPODFields =
false;
3293 Base = SubME->getBase();
3299 if (AddressOf && AllPODFields)
3305 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3306 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
3309 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3319 if (!Decls.count(FoundVD))
3324 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3326 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3331 if (CheckReferenceOnly && !IsReference)
3335 unsigned diag = IsReference
3336 ? diag::warn_reference_field_is_uninit
3337 : diag::warn_field_is_uninit;
3341 diag::note_uninit_in_this_constructor)
3346 void HandleValue(
Expr *E,
bool AddressOf) {
3349 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3350 HandleMemberExpr(ME,
false ,
3356 Visit(CO->getCond());
3357 HandleValue(CO->getTrueExpr(), AddressOf);
3358 HandleValue(CO->getFalseExpr(), AddressOf);
3363 dyn_cast<BinaryConditionalOperator>(E)) {
3364 Visit(BCO->getCond());
3365 HandleValue(BCO->getFalseExpr(), AddressOf);
3370 HandleValue(OVE->getSourceExpr(), AddressOf);
3375 switch (BO->getOpcode()) {
3380 HandleValue(BO->getLHS(), AddressOf);
3381 Visit(BO->getRHS());
3384 Visit(BO->getLHS());
3385 HandleValue(BO->getRHS(), AddressOf);
3394 InitFieldIndex.push_back(0);
3395 for (
auto Child : ILE->
children()) {
3396 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3397 CheckInitListExpr(SubList);
3401 ++InitFieldIndex.back();
3403 InitFieldIndex.pop_back();
3412 DeclsToRemove.clear();
3414 Constructor = FieldConstructor;
3419 InitListFieldDecl = Field;
3420 InitFieldIndex.clear();
3421 CheckInitListExpr(ILE);
3435 HandleMemberExpr(ME,
true ,
false );
3444 Inherited::VisitImplicitCastExpr(E);
3450 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3454 if (ICE->getCastKind() == CK_NoOp)
3455 ArgExpr = ICE->getSubExpr();
3456 HandleValue(ArgExpr,
false );
3459 Inherited::VisitCXXConstructExpr(E);
3464 if (isa<MemberExpr>(Callee)) {
3465 HandleValue(Callee,
false );
3471 Inherited::VisitCXXMemberCallExpr(E);
3477 HandleValue(E->
getArg(0),
false);
3481 Inherited::VisitCallExpr(E);
3487 if (isa<UnresolvedLookupExpr>(Callee))
3488 return Inherited::VisitCXXOperatorCallExpr(E);
3492 HandleValue(Arg->IgnoreParenImpCasts(),
false );
3501 if (!FD->getType()->isReferenceType())
3502 DeclsToRemove.push_back(FD);
3505 HandleValue(E->
getLHS(),
false );
3510 Inherited::VisitBinaryOperator(E);
3520 HandleValue(ME->
getBase(),
true );
3525 Inherited::VisitUnaryOperator(E);
3535 static void DiagnoseUninitializedFields(
3552 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
3555 for (
auto *I : RD->
decls()) {
3556 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
3557 UninitializedFields.insert(FD);
3558 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
3559 UninitializedFields.insert(IFD->getAnonField());
3563 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
3564 for (
auto I : RD->
bases())
3565 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
3567 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3570 UninitializedFieldVisitor UninitializedChecker(SemaRef,
3571 UninitializedFields,
3572 UninitializedBaseClasses);
3574 for (
const auto *FieldInit : Constructor->
inits()) {
3575 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3578 Expr *InitExpr = FieldInit->getInit();
3583 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
3584 InitExpr =
Default->getExpr();
3588 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
3589 FieldInit->getAnyMember(),
3590 FieldInit->getBaseClass());
3592 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
3593 FieldInit->getAnyMember(),
3594 FieldInit->getBaseClass());
3606 PushFunctionScope();
3616 PopFunctionScopeInfo(
nullptr, D);
3620 "must set init style when field is created");
3629 if (DiagnoseUnexpandedParameterPack(InitExpr, UPPC_Initializer)) {
3646 Init = Seq.Perform(*
this, Entity, Kind, InitExpr);
3656 Init = ActOnFinishFullExpr(Init.
get(), InitLoc);
3662 InitExpr = Init.
get();
3676 DirectBaseSpec =
nullptr;
3677 for (
const auto &
Base : ClassDecl->
bases()) {
3681 DirectBaseSpec = &
Base;
3689 VirtualBaseSpec =
nullptr;
3690 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
3699 Path != Paths.
end(); ++Path) {
3700 if (Path->back().Base->isVirtual()) {
3701 VirtualBaseSpec = Path->back().Base;
3708 return DirectBaseSpec || VirtualBaseSpec;
3722 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
3723 DS, IdLoc, InitList,
3742 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
3743 DS, IdLoc, List, EllipsisLoc);
3752 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
3753 : ClassDecl(ClassDecl) {}
3755 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
3757 if (
FieldDecl *Member = dyn_cast<FieldDecl>(ND))
3759 return isa<TypeDecl>(ND);
3781 ExprResult Res = CorrectDelayedTyposInExpr(Init);
3789 AdjustDeclIfTemplate(ConstructorD);
3816 if (!Result.
empty()) {
3818 if ((Member = dyn_cast<FieldDecl>(Result.
front())) ||
3821 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
3825 return BuildMemberInitializer(Member, Init, IdLoc);
3833 if (TemplateTypeTy) {
3834 BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo);
3841 LookupResult R(*
this, MemberOrBase, IdLoc, LookupOrdinaryName);
3842 LookupParsedName(R, S, &SS);
3851 if (SS.
isSet() && isDependentScopeSpecifier(SS)) {
3852 bool NotUnknownSpecialization =
false;
3854 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
3855 NotUnknownSpecialization = !Record->hasAnyDependentBases();
3857 if (!NotUnknownSpecialization) {
3862 *MemberOrBase, IdLoc);
3883 (Corr = CorrectTypo(
3885 llvm::make_unique<MemInitializerValidatorCCC>(ClassDecl),
3886 CTK_ErrorRecovery, ClassDecl))) {
3892 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3893 << MemberOrBase <<
true);
3894 return BuildMemberInitializer(Member, Init, IdLoc);
3900 DirectBaseSpec, VirtualBaseSpec)) {
3905 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3906 << MemberOrBase <<
false,
3912 diag::note_base_class_specified_here)
3921 if (!TyD && BaseType.
isNull()) {
3922 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
3930 MarkAnyDeclReferenced(TyD->
getLocation(), TyD,
false);
3946 return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, EllipsisLoc);
3954 assert((DirectMember || IndirectMember) &&
3955 "Member must be a FieldDecl or IndirectFieldDecl");
3957 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
3964 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
3965 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
3966 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
3967 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
3978 DiscardCleanupsInEvaluationContext();
3980 bool InitList =
false;
3981 if (isa<InitListExpr>(Init)) {
3998 ExprResult MemberInit = InitSeq.Perform(*
this, MemberEntity, Kind, Args,
4006 MemberInit = ActOnFinishFullExpr(MemberInit.
get(), InitRange.
getBegin());
4010 Init = MemberInit.
get();
4028 if (!LangOpts.CPlusPlus11)
4029 return Diag(NameLoc, diag::err_delegating_ctor)
4031 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4033 bool InitList =
true;
4035 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4037 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4048 InitRange.getEnd());
4050 ExprResult DelegationInit = InitSeq.Perform(*
this, DelegationEntity, Kind,
4055 assert(cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor() &&
4056 "Delegating constructor with no target?");
4061 DelegationInit = ActOnFinishFullExpr(DelegationInit.get(),
4062 InitRange.getBegin());
4063 if (DelegationInit.isInvalid())
4073 if (CurContext->isDependentContext())
4074 DelegationInit = Init;
4077 DelegationInit.getAs<
Expr>(),
4078 InitRange.getEnd());
4089 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4104 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4111 if (DiagnoseUnexpandedParameterPack(BaseLoc, BaseTInfo, UPPC_Initializer))
4114 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4124 return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
4133 if (!DirectBaseSpec && !VirtualBaseSpec) {
4142 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4149 DiscardCleanupsInEvaluationContext();
4154 InitRange.
getEnd(), EllipsisLoc);
4161 if (DirectBaseSpec && VirtualBaseSpec)
4162 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4167 BaseSpec = VirtualBaseSpec;
4170 bool InitList =
true;
4172 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4174 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4184 ExprResult BaseInit = InitSeq.Perform(*
this, BaseEntity, Kind, Args,
nullptr);
4191 BaseInit = ActOnFinishFullExpr(BaseInit.
get(), InitRange.
getBegin());
4202 if (CurContext->isDependentContext())
4209 InitRange.
getEnd(), EllipsisLoc);
4214 if (T.isNull()) T = E->
getType();
4219 TargetType, ExprLoc);
4239 bool IsInheritedVirtualBase,
4243 IsInheritedVirtualBase);
4247 switch (ImplicitInitKind) {
4253 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
None);
4259 bool Moving = ImplicitInitKind ==
IIK_Move;
4281 BasePath.push_back(BaseSpec);
4283 CK_UncheckedDerivedToBase,
4291 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4314 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
4329 bool Moving = ImplicitInitKind ==
IIK_Move;
4337 Expr *MemberExprBase =
4352 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
4354 MemberLookup.resolveKind();
4388 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
4403 "Unhandled implicit init kind!");
4419 InitSeq.
Perform(SemaRef, InitEntity, InitKind,
None);
4442 diag::err_uninitialized_member_in_ctor)
4452 diag::err_uninitialized_member_in_ctor)
4473 CXXMemberInit =
nullptr;
4478 struct BaseAndFieldInfo {
4481 bool AnyErrorsInInits;
4483 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
4485 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
4488 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
4500 bool isImplicitCopyOrMove()
const {
4511 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
4515 AllToInit.push_back(Init);
4524 bool isInactiveUnionMember(
FieldDecl *Field) {
4534 if (isImplicitCopyOrMove())
4552 bool isWithinInactiveUnionMember(
FieldDecl *Field,
4555 return isInactiveUnionMember(Field);
4557 for (
auto *
C : Indirect->
chain()) {
4559 if (Field && isInactiveUnionMember(Field))
4574 if (!ArrayT->getSize())
4577 T = ArrayT->getElementType();
4592 return Info.addFieldInitializer(Init);
4606 if (Info.isWithinInactiveUnionMember(Field, Indirect))
4627 return Info.addFieldInitializer(Init);
4637 if (Info.AnyErrorsInInits)
4648 return Info.addFieldInitializer(Init);
4666 DelegatingCtorDecls.push_back(Constructor);
4668 DiagnoseUninitializedFields(*
this, Constructor);
4678 if (!Initializers.empty()) {
4682 memcpy(baseOrMemberInitializers, Initializers.data(),
4694 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
4702 bool HadError =
false;
4704 for (
unsigned i = 0; i < Initializers.size(); i++) {
4713 for (
auto *
C : F->chain()) {
4716 Info.ActiveUnionMember.insert(std::make_pair(
4720 if (FD->getParent()->isUnion())
4721 Info.ActiveUnionMember.insert(std::make_pair(
4722 FD->getParent()->getCanonicalDecl(), FD->getCanonicalDecl()));
4728 llvm::SmallPtrSet<CXXBaseSpecifier *, 16> DirectVBases;
4729 for (
auto &I : ClassDecl->
bases()) {
4731 DirectVBases.insert(&I);
4735 for (
auto &VBase : ClassDecl->
vbases()) {
4737 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
4745 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
4746 << VBase.getType() << ClassDecl;
4747 DiagnoseAbstractType(ClassDecl);
4750 Info.AllToInit.push_back(
Value);
4751 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
4756 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
4759 &VBase, IsInheritedVirtualBase,
4765 Info.AllToInit.push_back(CXXBaseInit);
4772 if (
Base.isVirtual())
4776 = Info.AllBaseFields.lookup(
Base.getType()->getAs<
RecordType>())) {
4777 Info.AllToInit.push_back(
Value);
4778 }
else if (!AnyErrors) {
4787 Info.AllToInit.push_back(CXXBaseInit);
4792 for (
auto *Mem : ClassDecl->
decls()) {
4793 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
4798 if (F->isUnnamedBitfield())
4804 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
4813 if (Info.isImplicitCopyOrMove())
4816 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
4817 if (F->getType()->isIncompleteArrayType()) {
4819 "Incomplete array type is not valid");
4831 unsigned NumInitializers = Info.AllToInit.size();
4832 if (NumInitializers > 0) {
4836 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
4842 MarkBaseAndMemberDestructorsReferenced(Constructor->
getLocation(),
4853 for (
auto *Field : RD->
fields())
4881 bool ShouldCheckOrder =
false;
4882 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4884 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
4886 ShouldCheckOrder =
true;
4890 if (!ShouldCheckOrder)
4901 for (
const auto &VBase : ClassDecl->
vbases())
4905 for (
const auto &
Base : ClassDecl->
bases()) {
4906 if (
Base.isVirtual())
4912 for (
auto *Field : ClassDecl->
fields()) {
4913 if (Field->isUnnamedBitfield())
4919 unsigned NumIdealInits = IdealInitKeys.size();
4920 unsigned IdealIndex = 0;
4923 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4929 for (; IdealIndex != NumIdealInits; ++IdealIndex)
4930 if (InitKey == IdealInitKeys[IdealIndex])
4936 if (IdealIndex == NumIdealInits && PrevInit) {
4939 diag::warn_initializer_out_of_order);
4952 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
4953 if (InitKey == IdealInitKeys[IdealIndex])
4956 assert(IdealIndex < NumIdealInits &&
4957 "initializer not found in initializer list");
4965 bool CheckRedundantInit(
Sema &S,
4975 diag::err_multiple_mem_initialization)
4976 << Field->getDeclName()
4980 assert(BaseClass &&
"neither field nor base");
4982 diag::err_multiple_base_initialization)
4992 typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
4993 typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
4995 bool CheckRedundantUnionInit(
Sema &S,
4997 RedundantUnionMap &Unions) {
5004 UnionEntry &En = Unions[
Parent];
5005 if (En.first && En.first != Child) {
5007 diag::err_multiple_mem_union_initialization)
5010 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5011 << 0 << En.second->getSourceRange();
5035 if (!ConstructorDecl)
5038 AdjustDeclIfTemplate(ConstructorDecl);
5044 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5051 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5054 RedundantUnionMap MemberUnions;
5056 bool HadError =
false;
5057 for (
unsigned i = 0; i < MemInits.size(); i++) {
5065 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
5066 CheckRedundantUnionInit(*
this, Init, MemberUnions))
5070 if (CheckRedundantInit(*
this, Init, Members[Key]))
5075 if (MemInits.size() != 1) {
5077 diag::err_delegating_initializer_alone)
5078 << Init->
getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5081 SetDelegatingInitializer(Constructor, MemInits[i]);
5092 SetCtorInitializers(Constructor, AnyErrors, MemInits);
5094 DiagnoseUninitializedFields(*
this, Constructor);
5111 for (
auto *Field : ClassDecl->
fields()) {
5112 if (Field->isInvalidDecl())
5135 assert(Dtor &&
"No dtor found for FieldClassDecl!");
5136 CheckDestructorAccess(Field->getLocation(), Dtor,
5137 PDiag(diag::err_access_dtor_field)
5138 << Field->getDeclName()
5141 MarkFunctionReferenced(Location, Dtor);
5142 DiagnoseUseOfDecl(Dtor, Location);
5147 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5149 llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
5152 for (
const auto &
Base : ClassDecl->
bases()) {
5157 if (
Base.isVirtual()) {
5158 if (!VisitVirtualBases)
5160 DirectVirtualBases.insert(RT);
5171 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5174 CheckDestructorAccess(
Base.getLocStart(), Dtor,
5175 PDiag(diag::err_access_dtor_base)
5177 <<
Base.getSourceRange(),
5180 MarkFunctionReferenced(Location, Dtor);
5181 DiagnoseUseOfDecl(Dtor, Location);
5184 if (!VisitVirtualBases)
5188 for (
const auto &VBase : ClassDecl->
vbases()) {
5193 if (DirectVirtualBases.count(RT))
5204 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5205 if (CheckDestructorAccess(
5207 PDiag(diag::err_access_dtor_vbase)
5211 CheckDerivedToBaseConversion(
5213 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5217 MarkFunctionReferenced(Location, Dtor);
5218 DiagnoseUseOfDecl(Dtor, Location);
5227 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5228 SetCtorInitializers(Constructor,
false);
5229 DiagnoseUninitializedFields(*
this, Constructor);
5256 if (!isAbstractType(Loc, T))
5268 if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
5274 if (Diags.isLastDiagnosticIgnored())
5282 llvm::SmallPtrSet<const CXXMethodDecl *, 8> SeenPureMethods;
5284 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5285 MEnd = FinalOverriders.end();
5289 SOEnd = M->second.end();
5290 SO != SOEnd; ++SO) {
5297 if (SO->second.size() != 1)
5300 if (!SO->second.front().Method->isPure())
5303 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5306 Diag(SO->second.front().Method->getLocation(),
5307 diag::note_pure_virtual_function)
5308 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5312 if (!PureVirtualClassDiagSet)
5314 PureVirtualClassDiagSet->insert(RD);
5318 struct AbstractUsageInfo {
5325 : S(S), Record(Record),
5330 void DiagnoseAbstractType() {
5331 if (Invalid)
return;
5339 struct CheckAbstractUsage {
5340 AbstractUsageInfo &Info;
5343 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
5344 : Info(Info), Ctx(Ctx) {}
5348 #define ABSTRACT_TYPELOC(CLASS, PARENT) 5349 #define TYPELOC(CLASS, PARENT) \ 5350 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break; 5351 #include "clang/AST/TypeLocNodes.def" 5357 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
5372 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
5382 #define CheckPolymorphic(Type) \ 5383 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \ 5384 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \ 5399 return Visit(Next, Sel);
5409 T = Info.S.Context.getBaseElementType(T);
5412 if (CT != Info.AbstractType)
return;
5416 Info.S.Diag(Ctx->
getLocation(), diag::err_array_of_abstract_type)
5419 Info.S.Diag(Ctx->
getLocation(), diag::err_abstract_type_in_decl)
5422 Info.DiagnoseAbstractType();
5428 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
5451 for (
auto *D : RD->
decls()) {
5452 if (D->isImplicit())
continue;
5455 if (isa<CXXMethodDecl>(D)) {
5457 }
else if (isa<FunctionTemplateDecl>(D)) {
5458 FunctionDecl *FD = cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
5462 }
else if (isa<FieldDecl>(D)) {
5466 }
else if (isa<VarDecl>(D)) {
5467 VarDecl *VD = cast<VarDecl>(D);
5472 }
else if (isa<CXXRecordDecl>(D)) {
5474 }
else if (isa<ClassTemplateDecl>(D)) {
5476 cast<ClassTemplateDecl>(D)->getTemplatedDecl());
5486 assert(ClassAttr->
getKind() == attr::DLLExport);
5495 for (Decl *Member : Class->
decls()) {
5498 auto *VD = dyn_cast<
VarDecl>(Member);
5499 if (VD && Member->getAttr<DLLExportAttr>() &&
5508 if (Member->getAttr<DLLExportAttr>()) {
5509 if (MD->isUserProvided()) {
5520 }
else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
5521 MD->isCopyAssignmentOperator() ||
5522 MD->isMoveAssignmentOperator()) {
5551 for (Decl *Member : Class->
decls()) {
5554 if (!CD || !CD->isDefaultConstructor())
5556 auto *
Attr = CD->getAttr<DLLExportAttr>();
5569 if (LastExportedDefaultCtor) {
5571 diag::err_attribute_dll_ambiguous_default_ctor)
5573 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
5574 << CD->getDeclName();
5577 LastExportedDefaultCtor = CD;
5583 for (
auto *Method : Class->
methods()) {
5584 if (Method->isUserProvided())
5586 if (
Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method,
true))
5597 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
5598 if (
Attr *TemplateAttr =
5599 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
5600 auto *A = cast<InheritableAttr>(TemplateAttr->clone(getASTContext()));
5601 A->setInherited(
true);
5612 << Class << ClassAttr;
5619 for (Decl *Member : Class->
decls()) {
5620 if (!isa<VarDecl>(Member) && !isa<CXXMethodDecl>(Member))
5623 if (!MemberAttr || MemberAttr->
isInherited() || Member->isInvalidDecl())
5627 diag::err_attribute_dll_member_of_dll_class)
5628 << MemberAttr << ClassAttr;
5630 Member->setInvalidDecl();
5639 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
5644 const bool PropagatedImport =
5646 cast<DLLImportAttr>(ClassAttr)->wasPropagatedToBaseTemplate();
5658 ForceDeclarationOfImplicitMembers(Class);
5663 for (Decl *Member : Class->
decls()) {
5673 if (MD->isDeleted())
5676 if (MD->isInlined()) {
5686 if ((MD->isMoveAssignmentOperator() ||
5687 (Ctor && Ctor->isMoveConstructor())) &&
5694 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->isTrivial())
5701 if (VD && PropagatedImport)
5704 if (!cast<NamedDecl>(Member)->isExternallyVisible())
5709 cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5710 NewAttr->setInherited(
true);
5721 "friend re-decl should not already have a DLLAttr");
5722 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5723 NewAttr->setInherited(
true);
5724 FD->addAttr(NewAttr);
5731 DelayedDllExportClasses.push_back(Class);
5752 auto *NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5753 NewAttr->setInherited(
true);
5754 BaseTemplateSpec->
addAttr(NewAttr);
5758 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
5759 ImportAttr->setPropagatedToBaseTemplate();
5765 checkClassLevelDLLAttribute(BaseTemplateSpec);
5780 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
5785 diag::note_template_class_explicit_specialization_was_here)
5786 << BaseTemplateSpec;
5789 diag::note_template_class_instantiation_was_here)
5790 << BaseTemplateSpec;
5799 cast<CXXConstructorDecl>(MD));
5817 llvm_unreachable(
"Invalid special member.");
5835 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
5836 bool DtorIsTrivialForCall =
false;
5847 CopyCtorIsTrivial =
true;
5849 CopyCtorIsTrivialForCall =
true;
5853 if (CD->isCopyConstructor() && !CD->isDeleted()) {
5854 if (CD->isTrivial())
5855 CopyCtorIsTrivial =
true;
5856 if (CD->isTrivialForCall())
5857 CopyCtorIsTrivialForCall =
true;
5865 DtorIsTrivialForCall =
true;
5867 if (!DD->isDeleted() && DD->isTrivialForCall())
5868 DtorIsTrivialForCall =
true;
5872 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
5885 if (CopyCtorIsTrivial &&
5895 bool HasNonDeletedCopyOrMove =
false;
5901 HasNonDeletedCopyOrMove =
true;
5908 HasNonDeletedCopyOrMove =
true;
5916 if (MD->isDeleted())
5920 if (CD && CD->isCopyOrMoveConstructor())
5921 HasNonDeletedCopyOrMove =
true;
5922 else if (!isa<CXXDestructorDecl>(MD))
5925 if (!MD->isTrivialForCall())
5929 return HasNonDeletedCopyOrMove;
5940 AbstractUsageInfo Info(*
this, Record);
5950 bool Complained =
false;
5951 for (
const auto *F : Record->
fields()) {
5952 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
5955 if (F->getType()->isReferenceType() ||
5956 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
5963 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
5964 << F->getType()->isReferenceType()
5965 << F->getDeclName();
5983 if (((isa<FieldDecl>(D) || isa<UnresolvedUsingValueDecl>(D)) &&
5985 isa<IndirectFieldDecl>(D)) {
5986 Diag((*I)->getLocation(), diag::err_member_name_of_class)
5997 !Record->
hasAttr<FinalAttr>())
5999 diag::warn_non_virtual_dtor) << Context.
getRecordType(Record);
6003 if (FinalAttr *FA = Record->
getAttr<FinalAttr>()) {
6005 << FA->isSpelledAsSealed();
6006 DiagnoseAbstractType(Record);
6011 if (Record->
hasAttr<TrivialABIAttr>())
6012 checkIllFormedTrivialABIStruct(*Record);
6016 bool HasTrivialABI = Record->
hasAttr<TrivialABIAttr>();
6021 bool HasMethodWithOverrideControl =
false,
6022 HasOverridingMethodWithoutOverrideControl =
false;
6024 for (
auto *M : Record->
methods()) {
6028 DiagnoseHiddenVirtualMethods(M);
6029 if (M->hasAttr<OverrideAttr>())
6030 HasMethodWithOverrideControl =
true;
6031 else if (M->size_overridden_methods() > 0)
6032 HasOverridingMethodWithoutOverrideControl =
true;
6034 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted())
6035 CheckExplicitlyDefaultedSpecialMember(M);
6040 if (!M->isImplicit() && !M->isUserProvided()) {
6041 if (CSM != CXXInvalid) {
6042 M->setTrivial(SpecialMemberIsTrivial(M, CSM));
6045 M->setTrivialForCall(
6047 SpecialMemberIsTrivial(M, CSM, TAH_ConsiderTrivialABI));
6054 if ((CSM == CXXCopyConstructor || CSM == CXXMoveConstructor ||
6055 CSM == CXXDestructor) && M->isUserProvided()) {
6056 M->setTrivialForCall(HasTrivialABI);
6060 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
6061 M->hasAttr<DLLExportAttr>()) {
6064 (CSM == CXXDefaultConstructor || CSM == CXXCopyConstructor ||
6065 CSM == CXXDestructor))
6066 M->dropAttr<DLLExportAttr>();
6068 if (M->hasAttr<DLLExportAttr>()) {
6070 ActOnFinishInlineFunctionDef(M);
6076 if (HasMethodWithOverrideControl &&
6077 HasOverridingMethodWithoutOverrideControl) {
6080 for (
auto *M : Record->
methods())
6081 DiagnoseAbsenceOfOverrideControl(M);
6098 checkClassLevelDLLAttribute(Record);
6099 checkClassLevelCodeSegAttribute(Record);
6101 bool ClangABICompat4 =
6123 if (getLangOpts().ForceEmitVTables) {
6141 unsigned FieldQuals,
bool ConstRHS) {
6142 unsigned LHSQuals = 0;
6144 LHSQuals = FieldQuals;
6146 unsigned RHSQuals = FieldQuals;
6156 LHSQuals & Qualifiers::Const,
6157 LHSQuals & Qualifiers::Volatile);
6167 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
6173 : S(S), UseLoc(UseLoc) {
6174 bool DiagnosedMultipleConstructedBases =
false;
6176 UsingDecl *ConstructedBaseUsing =
nullptr;
6180 for (
auto *D : Shadow->
redecls()) {
6181 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
6182 auto *DNominatedBase = DShadow->getNominatedBaseClass();
6183 auto *DConstructedBase = DShadow->getConstructedBaseClass();
6185 InheritedFromBases.insert(
6186 std::make_pair(DNominatedBase->getCanonicalDecl(),
6187 DShadow->getNominatedBaseClassShadowDecl()));
6188 if (DShadow->constructsVirtualBase())
6189 InheritedFromBases.insert(
6190 std::make_pair(DConstructedBase->getCanonicalDecl(),
6191 DShadow->getConstructedBaseClassShadowDecl()));
6193 assert(DNominatedBase == DConstructedBase);
6198 if (!ConstructedBase) {
6199 ConstructedBase = DConstructedBase;
6200 ConstructedBaseUsing = D->getUsingDecl();
6201 }
else if (ConstructedBase != DConstructedBase &&
6203 if (!DiagnosedMultipleConstructedBases) {
6204 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
6207 diag::note_ambiguous_inherited_constructor_using)
6209 DiagnosedMultipleConstructedBases =
true;
6211 S.
Diag(D->getUsingDecl()->getLocation(),
6212 diag::note_ambiguous_inherited_constructor_using)
6213 << DConstructedBase;
6217 if (DiagnosedMultipleConstructedBases)
6224 std::pair<CXXConstructorDecl *, bool>
6227 if (It == InheritedFromBases.end())
6228 return std::make_pair(
nullptr,
false);
6232 return std::make_pair(
6234 It->second->constructsVirtualBase());
6237 return std::make_pair(Ctor,
false);
6251 if (InheritedCtor) {
6254 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
6256 return BaseCtor->isConstexpr();
6320 if (Ctor && ClassDecl->
isUnion())
6339 for (
const auto &B : ClassDecl->
bases()) {
6341 if (!BaseType)
continue;
6345 InheritedCtor, Inherited))
6356 for (
const auto *F : ClassDecl->
fields()) {
6357 if (F->isInvalidDecl())
6363 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
6366 ConstArg && !F->isMutable()))
6388 auto *CD = cast<CXXConstructorDecl>(MD);
6389 assert(CD->getInheritedConstructor() &&
6390 "only special members have implicit exception specs");
6392 S, Loc, CD->getInheritedConstructor().getShadowDecl());
6419 auto ESI = IES.getExceptionSpec();
6422 UpdateExceptionSpec(MD, ESI);
6438 "not an explicitly-defaulted special member");
6444 bool HadError =
false;
6453 unsigned ExpectedParams = 1;
6454 if (CSM == CXXDefaultConstructor || CSM == CXXDestructor)
6471 bool CanHaveConstParam =
false;
6472 if (CSM == CXXCopyConstructor)
6474 else if (CSM == CXXCopyAssignment)
6478 if (CSM == CXXCopyAssignment || CSM == CXXMoveAssignment) {
6483 if (!Context.
hasSameType(ReturnType, ExpectedReturnType)) {
6484 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
6485 << (CSM == CXXMoveAssignment) << ExpectedReturnType;
6492 << (CSM == CXXMoveAssignment) << getLangOpts().CPlusPlus14;
6499 bool HasConstParam =
false;
6507 diag::err_defaulted_special_member_volatile_param) << CSM;
6511 if (HasConstParam && !CanHaveConstParam) {
6512 if (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment) {
6514 diag::err_defaulted_special_member_copy_const_param)
6515 << (CSM == CXXCopyAssignment);
6519 diag::err_defaulted_special_member_move_const_param)
6520 << (CSM == CXXMoveAssignment);
6524 }
else if (ExpectedParams) {
6527 assert(CSM == CXXCopyAssignment &&
"unexpected non-ref argument");
6541 if ((getLangOpts().
CPlusPlus14 ? !isa<CXXDestructorDecl>(MD)
6542 : isa<CXXConstructorDecl>(MD)) &&
6545 Diag(MD->
getLocStart(), diag::err_incorrect_defaulted_constexpr) << CSM;
6562 DelayedDefaultedMemberExceptionSpecs.push_back(std::make_pair(MD, Type));
6564 CheckExplicitlyDefaultedMemberExceptionSpec(MD, Type);
6579 llvm::makeArrayRef(&ArgType,
6584 if (ShouldDeleteSpecialMember(MD, CSM)) {
6591 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
6592 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
6623 CheckEquivalentExceptionSpec(
6624 PDiag(diag::err_incorrect_defaulted_exception_spec)
6625 << getSpecialMember(MD), PDiag(),
6631 decltype(DelayedExceptionSpecChecks) Checks;
6632 decltype(DelayedDefaultedMemberExceptionSpecs) Specs;
6634 std::swap(Checks, DelayedExceptionSpecChecks);
6635 std::swap(Specs, DelayedDefaultedMemberExceptionSpecs);
6639 for (
auto &Check : Checks)
6640 CheckOverridingFunctionExceptionSpec(Check.first, Check.second);
6644 for (
auto &Spec : Specs)
6645 CheckExplicitlyDefaultedMemberExceptionSpec(Spec.first, Spec.second);
6651 template<
typename Derived>
6652 struct SpecialMemberVisitor {
6659 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
6663 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
6668 IsConstructor =
true;
6672 IsAssignment =
true;
6677 llvm_unreachable(
"invalid special member kind");
6683 ConstArg = RT->getPointeeType().isConstQualified();
6687 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
6690 bool isMove()
const {
6696 unsigned Quals,
bool IsMutable) {
6698 ConstArg && !IsMutable);
6708 cast<CXXConstructorDecl>(MD)->getInheritedConstructor().getConstructor();
6715 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
6722 return B->getBaseTypeLoc();
6724 return Subobj.get<
FieldDecl*>()->getLocation();
6729 VisitNonVirtualBases,
6734 VisitPotentiallyConstructedBases,
6740 bool visit(BasesToVisit Bases) {
6743 if (Bases == VisitPotentiallyConstructedBases)
6744 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
6746 for (
auto &B : RD->
bases())
6747 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
6748 getDerived().visitBase(&B))
6751 if (Bases == VisitAllBases)
6752 for (
auto &B : RD->
vbases())
6753 if (getDerived().visitBase(&B))
6756 for (
auto *F : RD->
fields())
6757 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
6758 getDerived().visitField(F))
6767 struct SpecialMemberDeletionInfo
6768 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
6773 bool AllFieldsAreConst;
6778 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
6779 Loc(MD->
getLocation()), AllFieldsAreConst(
true) {}
6788 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
6791 bool shouldDeleteForField(
FieldDecl *FD);
6792 bool shouldDeleteForAllConstMembers();
6794 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
6796 bool shouldDeleteForSubobjectCall(Subobject Subobj,
6798 bool IsDtorCallInCtor);
6806 bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
6826 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
6828 bool IsDtorCallInCtor) {
6835 DiagKind = !Decl ? 0 : 1;
6838 else if (!isAccessible(Subobj, Decl))
6856 diag::note_deleted_special_member_class_subobject)
6857 << getEffectiveCSM() << MD->
getParent() <<
true 6858 << Field << DiagKind << IsDtorCallInCtor;
6862 diag::note_deleted_special_member_class_subobject)
6863 << getEffectiveCSM() << MD->
getParent() <<
false 6864 << Base->
getType() << DiagKind << IsDtorCallInCtor;
6877 bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
6880 bool IsMutable = Field && Field->
isMutable();
6898 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
6905 if (IsConstructor) {
6908 false,
false,
false,
false,
false);
6909 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
6927 if (
auto *BaseCtor = SMOR.
getMethod()) {
6932 if (BaseCtor->isDeleted() && Diagnose) {
6934 diag::note_deleted_special_member_class_subobject)
6935 << getEffectiveCSM() << MD->
getParent() <<
false 6936 << Base->
getType() << 1 <<
false;
6939 return BaseCtor->isDeleted();
6941 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
6946 bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
6955 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
6956 << !!ICI << MD->
getParent() << FD << FieldType << 0;
6967 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
6973 AllFieldsAreConst =
false;
6979 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
6983 }
else if (IsAssignment) {
6988 << isMove() << MD->
getParent() << FD << FieldType << 0;
7003 if (!inUnion() && FieldRecord->
isUnion() &&
7005 bool AllVariantFieldsAreConst =
true;
7008 for (
auto *UI : FieldRecord->
fields()) {
7012 AllVariantFieldsAreConst =
false;
7015 if (UnionFieldRecord &&
7016 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
7026 diag::note_deleted_default_ctor_all_const)
7036 if (shouldDeleteForClassSubobject(FieldRecord, FD,
7047 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
7051 bool AnyFields =
false;
7053 if ((AnyFields = !F->isUnnamedBitfield()))
7059 diag::note_deleted_default_ctor_all_const)
7084 (CSM == CXXDefaultConstructor || CSM == CXXCopyAssignment)) {
7093 if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
7102 (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
7108 bool DeletesOnlyMatchingCopy =
7109 getLangOpts().MSVCCompat &&
7113 (!DeletesOnlyMatchingCopy || CSM == CXXCopyConstructor)) {
7114 if (!Diagnose)
return true;
7117 for (
auto *I : RD->
ctors()) {
7118 if (I->isMoveConstructor()) {
7119 UserDeclaredMove = I;
7123 assert(UserDeclaredMove);
7125 (!DeletesOnlyMatchingCopy || CSM == CXXCopyAssignment)) {
7126 if (!Diagnose)
return true;
7129 for (
auto *I : RD->
methods()) {
7130 if (I->isMoveAssignmentOperator()) {
7131 UserDeclaredMove = I;
7135 assert(UserDeclaredMove);
7138 if (UserDeclaredMove) {
7140 diag::note_deleted_copy_user_declared_move)
7141 << (CSM == CXXCopyAssignment) << RD
7153 if (CSM == CXXDestructor && MD->
isVirtual()) {
7158 OperatorDelete,
false)) {
7165 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
7173 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
7174 : SMI.VisitPotentiallyConstructedBases))
7177 if (SMI.shouldDeleteForAllConstMembers())
7180 if (getLangOpts().CUDA) {
7183 return inferCUDATargetForImplicitSpecialMember(RD, CSM, MD, SMI.ConstArg,
7207 *Selected =
nullptr;
7211 llvm_unreachable(
"not a special member");
7229 for (
auto *CI : RD->
ctors()) {
7230 if (!CI->isDefaultConstructor())
7237 *Selected = DefCtor;
7270 }
else if (!Selected) {
7278 goto NeedOverloadResolution;
7288 }
else if (!Selected) {
7293 goto NeedOverloadResolution;
7297 NeedOverloadResolution:
7325 llvm_unreachable(
"unknown special method kind");
7329 for (
auto *CI : RD->
ctors())
7330 if (!CI->isImplicit())
7334 typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
7337 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
7367 ConstRHS, TAH, Diagnose ? &Selected :
nullptr))
7375 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
7378 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
7379 }
else if (!Selected)
7380 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
7385 << Kind << SubType.getUnqualifiedType() << CSM;
7387 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
7388 << Kind << SubType.getUnqualifiedType() << CSM;
7393 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
7394 << Kind << SubType.getUnqualifiedType() << CSM;
7412 for (
const auto *FI : RD->
fields()) {
7413 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
7419 if (FI->isAnonymousStructOrUnion()) {
7421 CSM, ConstArg, TAH, Diagnose))
7432 S.
Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI;
7442 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
7447 bool ConstRHS = ConstArg && !FI->isMutable();
7461 bool ConstArg = (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment);
7472 assert(!MD->
isUserProvided() && CSM != CXXInvalid &&
"not special enough");
7476 bool ConstArg =
false;
7482 case CXXDefaultConstructor:
7487 case CXXCopyConstructor:
7488 case CXXCopyAssignment: {
7504 case CXXMoveConstructor:
7505 case CXXMoveAssignment: {
7521 llvm_unreachable(
"not a special member");
7527 diag::note_nontrivial_default_arg)
7546 for (
const auto &BI : RD->bases())
7569 if (CSM == CXXDestructor && MD->
isVirtual()) {
7582 if (RD->getNumVBases()) {
7592 for (
const auto *MI : RD->methods()) {
7593 if (MI->isVirtual()) {
7595 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
7600 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
7608 struct FindHiddenVirtualMethod {
7611 llvm::SmallPtrSet<const CXXMethodDecl *, 8> OverridenAndUsingBaseMethods;
7616 static bool CheckMostOverridenMethods(
7618 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
7622 if (CheckMostOverridenMethods(O, Methods))
7638 bool foundSameNameMethod =
false;
7645 foundSameNameMethod =
true;
7662 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
7663 overloadedMethods.push_back(MD);
7667 if (foundSameNameMethod)
7668 OverloadedMethods.append(overloadedMethods.begin(),
7669 overloadedMethods.end());
7670 return foundSameNameMethod;
7677 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
7695 FindHiddenVirtualMethod FHVM;
7706 ND = shad->getTargetDecl();
7712 OverloadedMethods = FHVM.OverloadedMethods;
7717 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
7720 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
7721 HandleFunctionTypeMismatch(PD, MD->
getType(), overloadedMD->
getType());
7732 if (Diags.isIgnored(diag::warn_overloaded_virtual, MD->
getLocation()))
7736 FindHiddenVirtualMethods(MD, OverloadedMethods);
7737 if (!OverloadedMethods.empty()) {
7739 << MD << (OverloadedMethods.size() > 1);
7741 NoteHiddenVirtualMethods(MD, OverloadedMethods);
7746 auto PrintDiagAndRemoveAttr = [&]() {
7750 diag::ext_cannot_use_trivial_abi) << &RD;
7756 PrintDiagAndRemoveAttr();
7760 for (
const auto &B : RD.
bases()) {
7763 if ((!B.getType()->isDependentType() &&
7764 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) ||
7766 PrintDiagAndRemoveAttr();
7771 for (
const auto *FD : RD.
fields()) {
7776 PrintDiagAndRemoveAttr();
7781 if (!RT->isDependentType() &&
7783 PrintDiagAndRemoveAttr();
7795 AdjustDeclIfTemplate(TagDecl);
7798 if (AL.getKind() != ParsedAttr::AT_Visibility)
7801 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored)
7805 ActOnFields(S, RLoc, TagDecl, llvm::makeArrayRef(
7807 reinterpret_cast<Decl**>(FieldCollector->getCurFields()),
7808 FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList);
7810 CheckCompletedCXXClass(cast<CXXRecordDecl>(TagDecl));
7823 DeclareImplicitDefaultConstructor(ClassDecl);
7834 DeclareImplicitCopyConstructor(ClassDecl);
7845 DeclareImplicitCopyConstructor(ClassDecl);
7853 DeclareImplicitMoveConstructor(ClassDecl);
7866 DeclareImplicitCopyAssignment(ClassDecl);
7876 DeclareImplicitMoveAssignment(ClassDecl);
7888 DeclareImplicitDestructor(ClassDecl);
7901 D = TD->getTemplatedDecl();
7903 if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
7904 ParameterLists.push_back(PSD->getTemplateParameters());
7907 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
7908 ParameterLists.push_back(DD->getTemplateParameterList(i));
7912 ParameterLists.push_back(FTD->getTemplateParameters());
7916 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
7917 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
7918 ParameterLists.push_back(TD->getTemplateParameterList(i));
7922 ParameterLists.push_back(CTD->getTemplateParameters());
7928 if (Params->size() > 0)
7933 if (Param->getDeclName()) {
7935 IdResolver.AddDecl(Param);
7944 if (!RecordD)
return;
7945 AdjustDeclIfTemplate(RecordD);
7947 PushDeclContext(S, Record);
7951 if (!RecordD)
return;
7964 IdResolver.AddDecl(Param);
7996 IdResolver.AddDecl(Param);
8009 AdjustDeclIfTemplate(MethodD);
8018 CheckConstructor(Constructor);
8022 CheckCXXDefaultArguments(Method);
8057 diagnoseIgnoredQualifiers(
8126 const char *ConstRef
8129 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
8155 FindDeallocationFunctionForDestructor(Loc, RD)) {
8156 Expr *ThisArg =
nullptr;
8161 if (OperatorDelete->isDestroyingOperatorDelete()) {
8162 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
8169 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
8170 assert(!This.
isInvalid() &&
"couldn't form 'this' expr in dtor?");
8171 This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
8172 if (This.isInvalid()) {
8175 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
8178 ThisArg = This.get();
8182 MarkFunctionReferenced(Loc, OperatorDelete);
8206 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
8209 if (TST->isTypeAlias())
8211 << DeclaratorType << 1;
8244 diagnoseIgnoredQualifiers(diag::err_destructor_return_type, TypeQuals,
8390 bool NeedsTypedef =
false;
8394 bool PastFunctionChunk =
false;
8396 switch (Chunk.Kind) {
8398 if (!PastFunctionChunk) {
8399 if (Chunk.Fun.HasTrailingReturnType) {
8401 GetTypeFromParser(Chunk.Fun.getTrailingReturnType(), &TRT);
8404 PastFunctionChunk =
true;
8409 NeedsTypedef =
true;
8431 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
8432 DB << Before <<
After;
8434 if (!NeedsTypedef) {
8438 if (After.isInvalid() && ConvTSI) {
8483 if (DS.isExplicitSpecified())
8484 Diag(DS.getExplicitSpecLoc(),
8485 getLangOpts().CPlusPlus11
8486 ? diag::warn_cxx98_compat_explicit_conversion_functions
8487 : diag::ext_explicit_conversion_functions)
8496 assert(Conversion &&
"Expected to receive a conversion function declaration");
8514 ConvType = ConvTypeRef->getPointeeType();
8518 else if (ConvType->isRecordType()) {
8520 if (ConvType == ClassType)
8523 else if (IsDerivedFrom(Conversion->
getLocation(), ClassType, ConvType))
8525 << ClassType << ConvType;
8526 }
else if (ConvType->isVoidType()) {
8528 << ClassType << ConvType;
8533 return ConversionTemplate;
8541 struct BadSpecifierDiagnoser {
8544 ~BadSpecifierDiagnoser() {
8548 template<
typename T>
void check(
SourceLocation SpecLoc, T Spec) {
8552 return check(SpecLoc,
8558 if (!Specifiers.empty()) Specifiers +=
" ";
8564 std::string Specifiers;
8576 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
8581 if (!CurContext->getRedeclContext()->Equals(
8584 << GuidedTemplateDecl;
8585 Diag(GuidedTemplateDecl->
getLocation(), diag::note_template_decl_here);
8590 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
8591 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
8592 DS.isNoreturnSpecified() || DS.isConstexprSpecified()) {
8593 BadSpecifierDiagnoser Diagnoser(
8595 diag::err_deduction_guide_invalid_specifier);
8597 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
8602 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
8603 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
8604 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
8605 DS.ClearConstexprSpec();
8607 Diagnoser.check(DS.getConstSpecLoc(),
"const");
8608 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
8609 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
8610 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
8611 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
8612 DS.ClearTypeQualifiers();
8614 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
8615 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
8616 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
8617 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
8618 DS.ClearTypeSpecType();
8625 bool FoundFunction =
false;
8631 diag::err_deduction_guide_with_complex_decl)
8635 if (!Chunk.Fun.hasTrailingReturnType()) {
8637 diag::err_deduction_guide_no_trailing_return_type);
8643 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
8645 QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
8646 assert(TSI &&
"deduction guide has valid type but invalid return type?");
8647 bool AcceptableReturnType =
false;
8648 bool MightInstantiateToSpecialization =
false;
8651 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
8652 bool TemplateMatches =
8655 AcceptableReturnType =
true;
8660 MightInstantiateToSpecialization = !(TD && isa<ClassTemplateDecl>(TD) &&
8664 MightInstantiateToSpecialization =
true;
8667 if (!AcceptableReturnType) {
8669 diag::err_deduction_guide_bad_trailing_return_type)
8670 << GuidedTemplate << TSI->
getType() << MightInstantiateToSpecialization
8676 FoundFunction =
true;
8693 assert(*IsInline != PrevNS->
isInline());
8701 if (*IsInline && II && II->
getName().startswith(
"__atomic") &&
8706 NS->setInline(*IsInline);
8709 for (
auto *I : PrevNS->
decls())
8710 if (
auto *ND = dyn_cast<NamedDecl>(I))
8718 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
8721 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
8736 bool IsInline = InlineLoc.
isValid();
8737 bool IsInvalid =
false;
8739 bool AddToKnown =
false;
8755 LookupResult R(*
this, II, IdentLoc, LookupOrdinaryName,
8756 ForExternalRedeclaration);
8757 LookupQualifiedName(R, CurContext->getRedeclContext());
8760 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
8764 if (IsInline != PrevNS->
isInline())
8767 }
else if (PrevDecl) {
8769 Diag(Loc, diag::err_redefinition_different_kind)
8771 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
8774 }
else if (II->
isStr(
"std") &&
8775 CurContext->getRedeclContext()->isTranslationUnit()) {
8778 PrevNS = getStdNamespace();
8780 AddToKnown = !IsInline;
8783 AddToKnown = !IsInline;
8797 if (PrevNS && IsInline != PrevNS->
isInline())
8803 StartLoc, Loc, II, PrevNS);
8807 ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
8808 AddPragmaAttributes(DeclRegionScope, Namespc);
8811 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
8812 PushNamespaceVisibilityAttr(
Attr, Loc);
8815 StdNamespace = Namespc;
8817 KnownNamespaces[Namespc] =
false;
8820 PushOnScopeChains(Namespc, DeclRegionScope);
8825 TU->setAnonymousNamespace(Namespc);
8827 cast<NamespaceDecl>(
Parent)->setAnonymousNamespace(Namespc);
8830 CurContext->addDecl(Namespc);
8861 ActOnDocumentableDecl(Namespc);
8868 PushDeclContext(NamespcScope, Namespc);
8876 return AD->getNamespace();
8877 return dyn_cast_or_null<NamespaceDecl>(D);
8883 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
8884 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
8887 if (Namespc->
hasAttr<VisibilityAttr>())
8888 PopPragmaVisibility(
true, RBrace);
8892 return cast_or_null<CXXRecordDecl>(
8901 return cast_or_null<NamespaceDecl>(
8906 if (!StdExperimentalNamespaceCache) {
8907 if (
auto Std = getStdNamespace()) {
8910 if (!LookupQualifiedName(
Result,
Std) ||
8911 !(StdExperimentalNamespaceCache =
8913 Result.suppressDiagnostics();
8916 return StdExperimentalNamespaceCache;
8928 struct InvalidSTLDiagnoser {
8934 const VarDecl *VD =
nullptr) {
8936 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
8937 << TyForDiags << ((int)Sel);
8938 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
8939 assert(!Name.empty());
8943 if (Sel == USS_InvalidMember) {
8944 S.
Diag(VD->getLocation(), diag::note_var_declared_here)
8945 << VD << VD->getSourceRange();
8955 "Looking for comparison category type outside of C++.");
8960 if (Info && FullyCheckedComparisonCategories[static_cast<unsigned>(Kind)])
8965 std::string NameForDiags =
"std::";
8967 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
8972 assert(Info->
Kind == Kind);
8988 if (RequireCompleteType(Loc, TyForDiags, diag::err_incomplete_type))
8991 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags};
8994 return UnsupportedSTLError(USS_NonTrivial);
9002 return UnsupportedSTLError();
9011 !FIt->getType()->isIntegralOrEnumerationType()) {
9012 return UnsupportedSTLError();
9022 return UnsupportedSTLError(USS_MissingMember, MemName);
9025 assert(VD &&
"should not be null!");
9032 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
9038 return UnsupportedSTLError();
9040 MarkVariableReferenced(Loc, VD);
9045 FullyCheckedComparisonCategories[
static_cast<unsigned>(
Kind)] =
true;
9052 if (!StdNamespace) {
9058 &PP.getIdentifierTable().get(
"std"),
9063 return getStdNamespace();
9068 "Looking for std::initializer_list outside of C++.");
9083 if (!Specialization)
9090 Template = dyn_cast_or_null<ClassTemplateDecl>(
9091 TST->getTemplateName().getAsTemplateDecl());
9092 Arguments = TST->getArgs();
9097 if (!StdInitializerList) {
9101 &PP.getIdentifierTable().get(
"initializer_list") ||
9102 !getStdNamespace()->InEnclosingNamespaceSetOf(
9110 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
9114 StdInitializerList = Template;
9129 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
9136 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
9141 Result.suppressDiagnostics();
9144 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
9152 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
9153 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
9161 if (!StdInitializerList) {
9163 if (!StdInitializerList)
9172 CheckTemplateIdType(
TemplateName(StdInitializerList), Loc, Args));
9189 return isStdInitializerList(ArgType,
nullptr);
9196 case Decl::TranslationUnit:
9198 case Decl::LinkageSpec:
9210 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
9212 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
9226 llvm::make_unique<NamespaceValidatorCCC>(),
9229 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
9230 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
9231 Ident->
getName().equals(CorrectedStr);
9233 S.
PDiag(diag::err_using_directive_member_suggest)
9234 << Ident << DC << DroppedSpecifier << SS.getRange(),
9235 S.
PDiag(diag::note_namespace_defined_here));
9238 S.
PDiag(diag::err_using_directive_suggest) << Ident,
9239 S.
PDiag(diag::note_namespace_defined_here));
9241 R.
addDecl(Corrected.getFoundDecl());
9252 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9253 assert(NamespcName &&
"Invalid NamespcName.");
9254 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
9267 LookupResult R(*
this, NamespcName, IdentLoc, LookupNamespaceName);
9268 LookupParsedName(R, S, &SS);
9277 NamespcName->
isStr(
"std")) {
9278 Diag(IdentLoc, diag::ext_using_undefined_std);
9279 R.
addDecl(getOrCreateStdNamespace());
9289 assert(NS &&
"expected namespace decl");
9292 DiagnoseUseOfDecl(Named, IdentLoc);
9307 while (CommonAncestor && !CommonAncestor->
Encloses(CurContext))
9308 CommonAncestor = CommonAncestor->
getParent();
9312 IdentLoc, Named, CommonAncestor);
9315 !SourceMgr.isInMainFile(SourceMgr.getExpansionLoc(IdentLoc))) {
9316 Diag(IdentLoc, diag::warn_using_directive_in_header);
9319 PushUsingDirective(S, UDir);
9321 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
9325 ProcessDeclAttributeList(S, UDir, AttrList);
9368 getLangOpts().CPlusPlus11 ?
9369 diag::warn_cxx98_compat_using_decl_constructor :
9370 diag::err_using_decl_constructor)
9388 llvm_unreachable(
"cannot parse qualified deduction guide name");
9399 getLangOpts().CPlusPlus11 ? diag::err_access_decl
9400 : diag::warn_access_decl_deprecated)
9405 if (DiagnoseUnexpandedParameterPack(SS, UPPC_UsingDeclaration) ||
9406 DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC_UsingDeclaration))
9411 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
9418 BuildUsingDeclaration(S, AS, UsingLoc, TypenameLoc.
isValid(), TypenameLoc,
9419 SS, TargetNameInfo, EllipsisLoc, AttrList,
9422 PushOnScopeChains(UD, S,
false);
9437 return Context.
hasSameType(TD1->getUnderlyingType(),
9438 TD2->getUnderlyingType());
9468 if (!getLangOpts().
CPlusPlus11 && CurContext->isRecord()) {
9472 if (isa<EnumDecl>(OrigDC)) OrigDC = OrigDC->
getParent();
9477 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(OrigRec)) {
9478 if (OrigDC == CurContext) {
9480 diag::err_using_decl_nested_name_specifier_is_current_class)
9488 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9490 << cast<CXXRecordDecl>(CurContext)
9498 if (Previous.
empty())
return false;
9501 if (isa<UsingShadowDecl>(Target))
9502 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
9509 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
9510 bool FoundEquivalentDecl =
false;
9517 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D))
9520 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
9525 !isa<IndirectFieldDecl>(Target) &&
9526 !isa<UnresolvedUsingValueDecl>(
Target) &&
9527 DiagnoseClassNameShadow(
9535 PrevShadow = Shadow;
9536 FoundEquivalentDecl =
true;
9537 }
else if (isEquivalentInternalLinkageDeclaration(D, Target)) {
9540 FoundEquivalentDecl =
true;
9544 (isa<TagDecl>(D) ? Tag : NonTag) = D;
9547 if (FoundEquivalentDecl)
9552 switch (CheckOverload(
nullptr, FD, Previous, OldDecl,
9557 case Ovl_NonFunction:
9566 if (CurContext->isRecord())
9582 if (isa<TagDecl>(Target)) {
9584 if (!Tag)
return false;
9588 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
9594 if (!NonTag)
return false;
9607 for (
auto &B : Derived->
bases())
9608 if (B.getType()->getAsCXXRecordDecl() == Base)
9609 return B.isVirtual();
9610 llvm_unreachable(
"not a direct base class");
9620 if (isa<UsingShadowDecl>(Target)) {
9621 Target = cast<UsingShadowDecl>(
Target)->getTargetDecl();
9622 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
9626 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
9627 NonTemplateTarget = TargetTD->getTemplatedDecl();
9630 if (isa<CXXConstructorDecl>(NonTemplateTarget)) {
9631 bool IsVirtualBase =
9635 Context, CurContext, UD->
getLocation(), UD, Orig, IsVirtualBase);
9649 PushOnScopeChains(Shadow, S);
9651 CurContext->addDecl(Shadow);
9687 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
9695 IdResolver.RemoveDecl(Shadow);
9708 bool &AnyDependentBases) {
9711 for (
auto &Base : Derived->
bases()) {
9713 if (CanonicalDesiredBase == BaseType)
9715 if (BaseType->isDependentType())
9716 AnyDependentBases =
true;
9724 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
9726 : HasTypenameKeyword(HasTypenameKeyword),
9727 IsInstantiation(IsInstantiation), OldNNS(NNS),
9728 RequireMemberOf(RequireMemberOf) {}
9730 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
9734 if (!ND || isa<NamespaceDecl>(ND))
9744 if (RequireMemberOf) {
9746 if (FoundRecord && FoundRecord->isInjectedClassName()) {
9767 bool AnyDependentBases =
false;
9770 AnyDependentBases) &&
9782 if (FoundRecord && FoundRecord->isInjectedClassName())
9786 if (isa<TypeDecl>(ND))
9787 return HasTypenameKeyword || !IsInstantiation;
9789 return !HasTypenameKeyword;
9793 bool HasTypenameKeyword;
9794 bool IsInstantiation;
9810 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9812 assert(IdentLoc.isValid() &&
"Invalid TargetName location.");
9821 if (
auto *RD = dyn_cast<CXXRecordDecl>(CurContext))
9827 ForVisibleRedeclaration);
9830 LookupName(Previous, S);
9836 if (!isDeclInScope(D, CurContext, S))
9848 assert(IsInstantiation &&
"no scope in non-instantiation");
9849 if (CurContext->isRecord())
9850 LookupQualifiedName(Previous, CurContext);
9869 if (CheckUsingDeclRedeclaration(UsingLoc, HasTypenameKeyword,
9870 SS, IdentLoc, Previous))
9874 if (CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo,
9878 DeclContext *LookupContext = computeDeclContext(SS);
9881 if (!LookupContext || EllipsisLoc.
isValid()) {
9882 if (HasTypenameKeyword) {
9885 UsingLoc, TypenameLoc,
9891 QualifierLoc, NameInfo, EllipsisLoc);
9894 CurContext->addDecl(D);
9898 auto Build = [&](
bool Invalid) {
9901 UsingName, HasTypenameKeyword);
9903 CurContext->addDecl(UD);
9907 auto BuildInvalid = [&]{
return Build(
true); };
9908 auto BuildValid = [&]{
return Build(
false); };
9910 if (RequireCompleteDeclContext(SS, LookupContext))
9911 return BuildInvalid();
9920 if (!IsInstantiation)
9925 if (CurContext->isRecord()) {
9930 LookupQualifiedName(R, LookupContext);
9943 if (getLangOpts().
CPlusPlus14 && II && II->isStr(
"gets") &&
9944 CurContext->isStdNamespace() &&
9945 isa<TranslationUnitDecl>(LookupContext) &&
9946 getSourceManager().isInSystemHeader(UsingLoc))
9950 llvm::make_unique<UsingValidatorCCC>(
9951 HasTypenameKeyword, IsInstantiation, SS.getScopeRep(),
9953 CTK_ErrorRecovery)) {
9956 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
9957 << NameInfo.
getName() << LookupContext << 0
9962 NamedDecl *ND = Corrected.getCorrectionDecl();
9964 return BuildInvalid();
9970 RD = cast<CXXRecordDecl>(RD->
getParent());
9973 if (Corrected.WillReplaceSpecifier()) {
9975 Builder.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
9982 auto *CurClass = cast<CXXRecordDecl>(CurContext);
9985 UsingName.setNamedTypeInfo(
nullptr);
9986 for (
auto *Ctor : LookupConstructors(RD))
9992 UsingName.setName(ND->getDeclName());
9996 Diag(IdentLoc, diag::err_no_member)
9997 << NameInfo.
getName() << LookupContext << SS.getRange();
9998 return BuildInvalid();
10003 return BuildInvalid();
10005 if (HasTypenameKeyword) {
10008 Diag(IdentLoc, diag::err_using_typename_non_type);
10010 Diag((*I)->getUnderlyingDecl()->getLocation(),
10011 diag::note_using_decl_target);
10012 return BuildInvalid();
10019 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
10021 return BuildInvalid();
10028 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
10030 return BuildInvalid();
10036 if (cast<EnumDecl>(ED->getDeclContext())->isScoped()) {
10037 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
10039 return BuildInvalid();
10046 if (UsingName.getName().getNameKind() ==
10051 if (CheckInheritingConstructorUsingDecl(UD))
10057 if (!CheckUsingShadowDecl(UD, *I, Previous, PrevDecl))
10058 BuildUsingShadowDecl(S, UD, *I, PrevDecl);
10066 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
10067 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
10068 isa<UsingPackDecl>(InstantiatedFrom));
10072 UPD->setAccess(InstantiatedFrom->
getAccess());
10073 CurContext->addDecl(UPD);
10079 assert(!UD->
hasTypename() &&
"expecting a constructor name");
10082 assert(SourceType &&
10083 "Using decl naming constructor doesn't have type in scope spec.");
10084 CXXRecordDecl *TargetClass = cast<CXXRecordDecl>(CurContext);
10087 bool AnyDependentBases =
false;
10089 AnyDependentBases);
10090 if (!Base && !AnyDependentBases) {
10092 diag::err_using_decl_constructor_not_in_direct_base)
10094 <<
QualType(SourceType, 0) << TargetClass;
10109 bool HasTypenameKeyword,
10122 if (!CurContext->getRedeclContext()->isRecord()) {
10128 if (Qual->
isDependent() && !HasTypenameKeyword) {
10129 for (
auto *D : Prev) {
10130 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
10131 bool OldCouldBeEnumerator =
10132 isa<UnresolvedUsingValueDecl>(D) || isa<EnumConstantDecl>(D);
10134 OldCouldBeEnumerator ? diag::err_redefinition
10135 : diag::err_redefinition_different_kind)
10136 << Prev.getLookupName();
10137 Diag(D->getLocation(), diag::note_previous_definition);
10150 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
10151 DTypename = UD->hasTypename();
10152 DQual = UD->getQualifier();
10154 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
10156 DQual = UD->getQualifier();
10158 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
10160 DQual = UD->getQualifier();
10165 if (HasTypenameKeyword != DTypename)
continue;
10174 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
10191 DeclContext *NamedContext = computeDeclContext(SS);
10193 if (!CurContext->isRecord()) {
10201 if ((HasTypename && !NamedContext) ||
10203 auto *RD = NamedContext
10206 if (RD && RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), RD))
10209 Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member)
10221 LookupQualifiedName(R, RD);
10226 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
10234 getLocForEndOfToken(NameInfo.
getLocEnd());
10235 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
10245 if (getLangOpts().CPlusPlus11) {
10251 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
10266 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
10267 << (getLangOpts().CPlusPlus11 ? 4 : 3)
10280 if (!NamedContext) {
10294 diag::err_using_decl_nested_name_specifier_is_not_class)
10300 RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), NamedContext))
10303 if (getLangOpts().CPlusPlus11) {
10309 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(
10310 cast<CXXRecordDecl>(NamedContext))) {
10311 if (CurContext == NamedContext) {
10313 diag::err_using_decl_nested_name_specifier_is_current_class)
10318 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
10320 diag::err_using_decl_nested_name_specifier_is_not_base_class)
10322 << cast<CXXRecordDecl>(CurContext)
10344 llvm::SmallPtrSet<const CXXRecordDecl *, 4> Bases;
10346 Bases.insert(Base);
10351 if (!cast<CXXRecordDecl>(CurContext)->forallBases(Collect))
10357 return !Bases.count(Base);
10362 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
10363 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
10367 diag::err_using_decl_nested_name_specifier_is_not_base_class)
10369 << cast<CXXRecordDecl>(CurContext)
10384 "got alias-declaration outside of declaration scope");
10389 bool Invalid =
false;
10392 GetTypeFromParser(Type.
get(), &TInfo);
10394 if (DiagnoseClassNameShadow(CurContext, NameInfo))
10397 if (DiagnoseUnexpandedParameterPack(Name.
StartLocation, TInfo,
10398 UPPC_DeclarationType)) {
10405 TemplateParamLists.size()
10406 ? forRedeclarationInCurContext()
10407 : ForVisibleRedeclaration);
10412 Previous.getFoundDecl()->isTemplateParameter()) {
10418 "name in alias declaration must be an identifier");
10428 ProcessDeclAttributeList(S, NewTD, AttrList);
10429 AddPragmaAttributes(S, NewTD);
10431 CheckTypedefForVariablyModifiedType(S, NewTD);
10434 bool Redeclaration =
false;
10437 if (TemplateParamLists.size()) {
10441 if (TemplateParamLists.size() != 1) {
10442 Diag(UsingLoc, diag::err_alias_template_extra_headers)
10443 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
10444 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
10449 if (CheckTemplateDeclScope(S, TemplateParams))
10453 FilterLookupForScope(
Previous, CurContext, S,
false,
10456 Redeclaration =
true;
10459 if (!OldDecl && !Invalid) {
10460 Diag(UsingLoc, diag::err_redefinition_different_kind)
10471 if (TemplateParameterListsAreEqual(TemplateParams,
10474 TPL_TemplateMatch))
10496 if (CheckTemplateParameterList(TemplateParams, OldTemplateParams,
10497 TPC_TypeAliasTemplate))
10510 else if (OldDecl) {
10512 CheckRedeclarationModuleOwnership(NewDecl, OldDecl);
10517 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
10518 setTagNameForLinkagePurposes(TD, NewTD);
10519 handleTagNumbering(TD, S);
10521 ActOnTypedefNameDecl(S, CurContext, NewTD,
Previous, Redeclaration);
10525 PushOnScopeChains(NewND, S);
10526 ActOnDocumentableDecl(NewND);
10537 LookupResult R(*
this, Ident, IdentLoc, LookupNamespaceName);
10538 LookupParsedName(R, S, &SS);
10545 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
10553 LookupResult PrevR(*
this, Alias, AliasLoc, LookupOrdinaryName,
10554 ForVisibleRedeclaration);
10555 LookupName(PrevR, S);
10559 DiagnoseTemplateParameterShadow(AliasLoc, PrevR.
getFoundDecl());
10564 FilterLookupForScope(PrevR, CurContext, S,
false,
10576 }
else if (isVisible(PrevDecl)) {
10577 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
10579 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
10580 << AD->getNamespace();
10583 }
else if (isVisible(PrevDecl)) {
10585 ? diag::err_redefinition
10586 : diag::err_redefinition_different_kind;
10587 Diag(AliasLoc, DiagID) << Alias;
10594 DiagnoseUseOfDecl(ND, IdentLoc);
10603 PushOnScopeChains(AliasDecl, S);
10608 struct SpecialMemberExceptionSpecInfo
10609 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
10617 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
10622 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
10625 void visitSubobjectCall(Subobject Subobj,
10635 auto *BaseClass = cast<CXXRecordDecl>(RT->getDecl());
10637 if (
auto *BaseCtor = SMOR.getMethod()) {
10638 visitSubobjectCall(Base, BaseCtor);
10642 visitClassSubobject(BaseClass, Base, 0);
10646 bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
10657 ExceptSpec.CalledExpr(E);
10659 ->getAs<RecordType>()) {
10660 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
10666 void SpecialMemberExceptionSpecInfo::visitClassSubobject(
CXXRecordDecl *Class,
10670 bool IsMutable = Field && Field->
isMutable();
10671 visitSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable));
10674 void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
10679 ExceptSpec.CalledDecl(getSubobjectLoc(Subobj), MD);
10691 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, Loc);
10693 return Info.ExceptSpec;
10710 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
10711 : Info.VisitAllBases);
10713 return Info.ExceptSpec;
10718 struct DeclaringSpecialMember {
10722 bool WasAlreadyBeingDeclared;
10725 : S(S), D(RD, CSM), SavedContext(S, RD) {
10727 if (WasAlreadyBeingDeclared)
10748 ~DeclaringSpecialMember() {
10749 if (!WasAlreadyBeingDeclared) {
10756 bool isAlreadyBeingDeclared()
const {
10757 return WasAlreadyBeingDeclared;
10767 ForExternalRedeclaration);
10774 CheckFunctionDeclaration(S, FD, R,
false);
10786 "Should not build implicit default constructor!");
10788 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDefaultConstructor);
10789 if (DSM.isAlreadyBeingDeclared())
10793 CXXDefaultConstructor,
10804 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
10805 nullptr,
false,
true,
10810 if (getLangOpts().CUDA) {
10811 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDefaultConstructor,
10828 Scope *S = getScopeForContext(ClassDecl);
10829 CheckImplicitSpecialMemberDeclaration(S, DefaultCon);
10831 if (ShouldDeleteSpecialMember(DefaultCon, CXXDefaultConstructor))
10832 SetDeclDeleted(DefaultCon, ClassLoc);
10835 PushOnScopeChains(DefaultCon, S,
false);
10836 ClassDecl->
addDecl(DefaultCon);
10846 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
10851 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
10857 ResolveExceptionSpec(CurrentLocation,
10859 MarkVTableUsed(CurrentLocation, ClassDecl);
10864 if (SetCtorInitializers(Constructor,
false)) {
10876 L->CompletedImplicitDefinition(Constructor);
10879 DiagnoseUninitializedFields(*
this, Constructor);
10884 CheckDelayedMemberExceptionSpecs();
10905 ->getInheritedConstructor()
10908 return cast<CXXConstructorDecl>(Ctor);
10923 false, BaseCtor, &ICI);
10926 Context, Derived, UsingLoc, NameInfo, TInfo->
getType(), TInfo,
10937 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
10943 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
10947 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
10954 ParamDecls.push_back(PD);
10959 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
10962 Derived->
addDecl(DerivedCtor);
10964 if (ShouldDeleteSpecialMember(DerivedCtor, CXXDefaultConstructor, &ICI))
10965 SetDeclDeleted(DerivedCtor, UsingLoc);
10967 return DerivedCtor;
10973 ShouldDeleteSpecialMember(Ctor, CXXDefaultConstructor, &ICI,
10992 ResolveExceptionSpec(CurrentLocation,
10994 MarkVTableUsed(CurrentLocation, ClassDecl);
11016 for (
bool VBase : {
false,
true}) {
11018 if (B.isVirtual() != VBase)
11021 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
11026 if (!BaseCtor.first)
11029 MarkFunctionReferenced(CurrentLocation, BaseCtor.first);
11031 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
11035 Context, TInfo, VBase, InitLoc, Init.
get(), InitLoc,
11043 if (SetCtorInitializers(Constructor,
false, Inits)) {
11052 L->CompletedImplicitDefinition(Constructor);
11055 DiagnoseUninitializedFields(*
this, Constructor);
11065 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDestructor);
11066 if (DSM.isAlreadyBeingDeclared())
11083 if (getLangOpts().CUDA) {
11084 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDestructor,
11103 Scope *S = getScopeForContext(ClassDecl);
11104 CheckImplicitSpecialMemberDeclaration(S, Destructor);
11110 ShouldDeleteSpecialMember(Destructor, CXXDestructor))
11111 SetDeclDeleted(Destructor, ClassLoc);
11115 PushOnScopeChains(Destructor, S,
false);
11116 ClassDecl->
addDecl(Destructor);
11126 "DefineImplicitDestructor - call it for implicit default dtor");
11131 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
11137 ResolveExceptionSpec(CurrentLocation,
11139 MarkVTableUsed(CurrentLocation, ClassDecl);
11144 MarkBaseAndMemberDestructorsReferenced(Destructor->
getLocation(),
11147 if (CheckDestructor(Destructor)) {
11159 L->CompletedImplicitDefinition(Destructor);
11167 if (
CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(CurContext)) {
11168 if (Record->isInvalidDecl()) {
11169 DelayedDefaultedMemberExceptionSpecs.clear();
11170 DelayedExceptionSpecChecks.clear();
11178 referenceDLLExportedClassMethods();
11182 if (!DelayedDllExportClasses.empty()) {
11186 std::swap(DelayedDllExportClasses, WorkList);
11195 "adjusting dtor exception specs was introduced in c++11");
11202 getAs<FunctionProtoType>();
11225 class ExprBuilder {
11226 ExprBuilder(
const ExprBuilder&) =
delete;
11227 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
11230 static Expr *assertNotNull(
Expr *E) {
11231 assert(E &&
"Expression construction must not fail.");
11237 virtual ~ExprBuilder() {}
11242 class RefBuilder:
public ExprBuilder {
11252 : Var(Var), VarType(VarType) {}
11255 class ThisBuilder:
public ExprBuilder {
11262 class CastBuilder:
public ExprBuilder {
11263 const ExprBuilder &Builder;
11271 CK_UncheckedDerivedToBase,
Kind,
11277 : Builder(Builder), Type(Type),
Kind(Kind), Path(Path) {}
11280 class DerefBuilder:
public ExprBuilder {
11281 const ExprBuilder &Builder;
11285 return assertNotNull(
11289 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11292 class MemberBuilder:
public ExprBuilder {
11293 const ExprBuilder &Builder;
11302 Builder.build(S, Loc), Type, Loc, IsArrow, SS,
SourceLocation(),
11303 nullptr, MemberLookup,
nullptr,
nullptr).
get());
11306 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
11308 : Builder(Builder), Type(Type), IsArrow(IsArrow),
11309 MemberLookup(MemberLookup) {}
11312 class MoveCastBuilder:
public ExprBuilder {
11313 const ExprBuilder &Builder;
11317 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
11320 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11323 class LvalueConvBuilder:
public ExprBuilder {
11324 const ExprBuilder &Builder;
11328 return assertNotNull(
11332 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11335 class SubscriptBuilder:
public ExprBuilder {
11336 const ExprBuilder &Base;
11337 const ExprBuilder &Index;
11342 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
11345 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
11346 : Base(Base), Index(Index) {}
11357 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
11366 Expr *From = FromB.build(S, Loc);
11370 Expr *To = ToB.build(S, Loc);
11376 bool NeedsCollectableMemCpy =
11380 StringRef MemCpyName = NeedsCollectableMemCpy ?
11381 "__builtin_objc_memmove_collectable" :
11382 "__builtin_memcpy";
11395 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
11397 Expr *CallArgs[] = {
11401 Loc, CallArgs, Loc);
11403 assert(!Call.
isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
11436 const ExprBuilder &To,
const ExprBuilder &From,
11437 bool CopyingBaseSubobject,
bool Copying,
11438 unsigned Depth = 0) {
11454 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
11469 if (Method->isCopyAssignmentOperator() ||
11470 (!Copying && Method->isMoveAssignmentOperator()))
11489 if (CopyingBaseSubobject) {
11520 Expr *FromInst = From.build(S, Loc);
11523 Loc, FromInst, Loc);
11543 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
11563 llvm::raw_svector_ostream OS(Str);
11564 OS <<
"__i" <<
Depth;
11568 IterationVarName, SizeType,
11577 RefBuilder IterationVarRef(IterationVar, SizeType);
11578 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
11584 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
11585 MoveCastBuilder FromIndexMove(FromIndexCopy);
11586 const ExprBuilder *FromIndex;
11588 FromIndex = &FromIndexCopy;
11590 FromIndex = &FromIndexMove;
11592 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
11597 ToIndex, *FromIndex, CopyingBaseSubobject,
11598 Copying,
Depth + 1);
11600 if (Copy.isInvalid() || !Copy.get())
11616 UnaryOperator(IterationVarRef.build(S, Loc), UO_PreInc, SizeType,
11621 Loc, Loc, InitStmt,
11628 const ExprBuilder &To,
const ExprBuilder &From,
11629 bool CopyingBaseSubobject,
bool Copying) {
11636 CopyingBaseSubobject,
11641 if (!Result.isInvalid() && !Result.get())
11654 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyAssignment);
11655 if (DSM.isAlreadyBeingDeclared())
11682 if (getLangOpts().CUDA) {
11683 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyAssignment,
11696 ClassLoc, ClassLoc,
11704 ? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
11710 Scope *S = getScopeForContext(ClassDecl);
11711 CheckImplicitSpecialMemberDeclaration(S, CopyAssignment);
11713 if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment))
11714 SetDeclDeleted(CopyAssignment, ClassLoc);
11717 PushOnScopeChains(CopyAssignment, S,
false);
11718 ClassDecl->
addDecl(CopyAssignment);
11720 return CopyAssignment;
11734 if (RD->hasUserDeclaredDestructor()) {
11735 UserDeclaredOperation = RD->getDestructor();
11736 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
11737 RD->hasUserDeclaredCopyConstructor() &&
11740 for (
auto *I : RD->ctors()) {
11741 if (I->isCopyConstructor()) {
11742 UserDeclaredOperation = I;
11746 assert(UserDeclaredOperation);
11747 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
11748 RD->hasUserDeclaredCopyAssignment() &&
11751 for (
auto *I : RD->methods()) {
11752 if (I->isCopyAssignmentOperator()) {
11753 UserDeclaredOperation = I;
11757 assert(UserDeclaredOperation);
11760 if (UserDeclaredOperation) {
11762 diag::warn_deprecated_copy_operation)
11763 << RD << !isa<CXXConstructorDecl>(CopyOp)
11764 << isa<CXXDestructorDecl>(UserDeclaredOperation);
11775 "DefineImplicitCopyAssignment called for wrong function");
11789 ResolveExceptionSpec(CurrentLocation,
11829 RefBuilder OtherRef(Other, OtherRefType);
11835 bool Invalid =
false;
11836 for (
auto &Base : ClassDecl->
bases()) {
11846 BasePath.push_back(&Base);
11850 CastBuilder From(OtherRef, Context.
getQualifiedType(BaseType, OtherQuals),
11854 DerefBuilder DerefThis(This);
11855 CastBuilder To(DerefThis,
11871 Statements.push_back(Copy.
getAs<
Expr>());
11875 for (
auto *Field : ClassDecl->
fields()) {
11878 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
11881 if (Field->isInvalidDecl()) {
11887 if (Field->getType()->isReferenceType()) {
11888 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
11889 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
11890 Diag(Field->getLocation(), diag::note_declared_at);
11898 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
11899 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
11900 Diag(Field->getLocation(), diag::note_declared_at);
11906 if (Field->isZeroLengthBitField(Context))
11909 QualType FieldType = Field->getType().getNonReferenceType();
11912 "Incomplete array type is not valid");
11918 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
11921 MemberLookup.resolveKind();
11923 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
11925 MemberBuilder To(This, getCurrentThisType(),
true, MemberLookup);
11938 Statements.push_back(Copy.
getAs<
Stmt>());
11943 ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
11946 if (Return.isInvalid())
11949 Statements.push_back(Return.getAs<
Stmt>());
11960 Body = ActOnCompoundStmt(Loc, Loc, Statements,
11962 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
11965 CopyAssignOperator->
markUsed(Context);
11968 L->CompletedImplicitDefinition(CopyAssignOperator);
11975 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveAssignment);
11976 if (DSM.isAlreadyBeingDeclared())
12003 if (getLangOpts().CUDA) {
12004 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveAssignment,
12017 ClassLoc, ClassLoc,
12025 ? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
12031 Scope *S = getScopeForContext(ClassDecl);
12032 CheckImplicitSpecialMemberDeclaration(S, MoveAssignment);
12034 if (ShouldDeleteSpecialMember(MoveAssignment, CXXMoveAssignment)) {
12036 SetDeclDeleted(MoveAssignment, ClassLoc);
12040 PushOnScopeChains(MoveAssignment, S,
false);
12041 ClassDecl->
addDecl(MoveAssignment);
12043 return MoveAssignment;
12062 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
12065 for (
auto &BI : Class->
bases()) {
12066 Worklist.push_back(&BI);
12067 while (!Worklist.empty()) {
12100 if (Existing && Existing != &BI) {
12101 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
12104 << (Base->getCanonicalDecl() ==
12107 S.
Diag(BI.getLocStart(), diag::note_vbase_moved_here)
12108 << (Base->getCanonicalDecl() ==
12109 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
12113 Existing =
nullptr;
12123 for (
auto &BI : Base->
bases())
12124 Worklist.push_back(&BI);
12137 "DefineImplicitMoveAssignment called for wrong function");
12163 ResolveExceptionSpec(CurrentLocation,
12175 getAs<RValueReferenceType>()->getPointeeType();
12177 "Bad argument type of defaulted move assignment");
12185 RefBuilder OtherRef(Other, OtherRefType);
12187 MoveCastBuilder MoveOther(OtherRef);
12193 bool Invalid =
false;
12194 for (
auto &Base : ClassDecl->
bases()) {
12212 BasePath.push_back(&Base);
12216 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
12219 DerefBuilder DerefThis(This);
12222 CastBuilder To(DerefThis,
12238 Statements.push_back(Move.
getAs<
Expr>());
12242 for (
auto *Field : ClassDecl->
fields()) {
12245 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
12248 if (Field->isInvalidDecl()) {
12254 if (Field->getType()->isReferenceType()) {
12255 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12256 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
12257 Diag(Field->getLocation(), diag::note_declared_at);
12265 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12266 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
12267 Diag(Field->getLocation(), diag::note_declared_at);
12273 if (Field->isZeroLengthBitField(Context))
12276 QualType FieldType = Field->getType().getNonReferenceType();
12279 "Incomplete array type is not valid");
12284 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
12287 MemberLookup.resolveKind();
12288 MemberBuilder From(MoveOther, OtherRefType,
12289 false, MemberLookup);
12290 MemberBuilder To(This, getCurrentThisType(),
12291 true, MemberLookup);
12293 assert(!From.build(*
this, Loc)->isLValue() &&
12294 "Member reference with rvalue base must be rvalue except for reference " 12295 "members, which aren't allowed for move assignment.");
12302 if (Move.isInvalid()) {
12308 Statements.push_back(Move.getAs<
Stmt>());
12314 CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
12317 if (Return.isInvalid())
12320 Statements.push_back(Return.getAs<
Stmt>());
12331 Body = ActOnCompoundStmt(Loc, Loc, Statements,
12333 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
12336 MoveAssignOperator->
markUsed(Context);
12339 L->CompletedImplicitDefinition(MoveAssignOperator);
12350 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyConstructor);
12351 if (DSM.isAlreadyBeingDeclared())
12362 CXXCopyConstructor,
12374 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12380 if (getLangOpts().CUDA) {
12381 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyConstructor,
12395 ClassLoc, ClassLoc,
12403 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
12407 ClassDecl->
hasAttr<TrivialABIAttr>() ||
12409 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor,
12410 TAH_ConsiderTrivialABI)
12416 Scope *S = getScopeForContext(ClassDecl);
12417 CheckImplicitSpecialMemberDeclaration(S, CopyConstructor);
12419 if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) {
12421 SetDeclDeleted(CopyConstructor, ClassLoc);
12425 PushOnScopeChains(CopyConstructor, S,
false);
12426 ClassDecl->
addDecl(CopyConstructor);
12428 return CopyConstructor;
12437 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
12442 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
12448 ResolveExceptionSpec(CurrentLocation,
12450 MarkVTableUsed(CurrentLocation, ClassDecl);
12462 if (SetCtorInitializers(CopyConstructor,
false)) {
12470 ActOnCompoundStmt(Loc, Loc,
None,
false).getAs<Stmt>());
12471 CopyConstructor->
markUsed(Context);
12475 L->CompletedImplicitDefinition(CopyConstructor);
12483 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveConstructor);
12484 if (DSM.isAlreadyBeingDeclared())
12491 CXXMoveConstructor,
12504 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12510 if (getLangOpts().CUDA) {
12511 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveConstructor,
12525 ClassLoc, ClassLoc,
12533 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
12537 ClassDecl->
hasAttr<TrivialABIAttr>() ||
12539 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor,
12540 TAH_ConsiderTrivialABI)
12546 Scope *S = getScopeForContext(ClassDecl);
12547 CheckImplicitSpecialMemberDeclaration(S, MoveConstructor);
12549 if (ShouldDeleteSpecialMember(MoveConstructor, CXXMoveConstructor)) {
12551 SetDeclDeleted(MoveConstructor, ClassLoc);
12555 PushOnScopeChains(MoveConstructor, S,
false);
12556 ClassDecl->
addDecl(MoveConstructor);
12558 return MoveConstructor;
12567 "DefineImplicitMoveConstructor - call it for implicit move ctor");
12572 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
12578 ResolveExceptionSpec(CurrentLocation,
12580 MarkVTableUsed(CurrentLocation, ClassDecl);
12585 if (SetCtorInitializers(MoveConstructor,
false)) {
12592 MoveConstructor->
setBody(ActOnCompoundStmt(
12593 Loc, Loc,
None,
false).getAs<Stmt>());
12594 MoveConstructor->
markUsed(Context);
12598 L->CompletedImplicitDefinition(MoveConstructor);
12613 FunctionDecl *CallOp = Lambda->getLambdaCallOperator();
12614 FunctionDecl *Invoker = Lambda->getLambdaStaticInvoker();
12617 CallOp = InstantiateFunctionDeclaration(
12622 Invoker = InstantiateFunctionDeclaration(
12636 MarkFunctionReferenced(CurrentLocation, CallOp);
12647 Expr *FunctionRef = BuildDeclRefExpr(Invoker, Invoker->
getType(),
12649 assert(FunctionRef &&
"Can't refer to __invoke function?");
12650 Stmt *Return = BuildReturnStmt(Conv->
getLocation(), FunctionRef).
get();
12657 L->CompletedImplicitDefinition(Conv);
12658 L->CompletedImplicitDefinition(Invoker);
12673 Expr *This = ActOnCXXThis(CurrentLocation).get();
12674 Expr *DerefThis =CreateBuiltinUnaryOp(CurrentLocation, UO_Deref, This).get();
12676 ExprResult BuildBlock = BuildBlockForLambdaConversion(CurrentLocation,
12684 if (!BuildBlock.
isInvalid() && !getLangOpts().ObjCAutoRefCount)
12686 CK_CopyAndAutoreleaseBlockObject,
12690 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12699 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12705 Stmt *ReturnS = Return.
get();
12712 L->CompletedImplicitDefinition(Conv);
12719 switch (Args.size()) {
12724 if (!Args[1]->isDefaultArgument())
12729 return !Args[0]->isDefaultArgument();
12740 bool HadMultipleCandidates,
12741 bool IsListInitialization,
12742 bool IsStdInitListInitialization,
12743 bool RequiresZeroInit,
12744 unsigned ConstructKind,
12746 bool Elidable =
false;
12760 Expr *SubExpr = ExprArgs[0];
12765 return BuildCXXConstructExpr(ConstructLoc, DeclInitType,
12766 FoundDecl, Constructor,
12767 Elidable, ExprArgs, HadMultipleCandidates,
12768 IsListInitialization,
12769 IsStdInitListInitialization, RequiresZeroInit,
12770 ConstructKind, ParenRange);
12779 bool HadMultipleCandidates,
12780 bool IsListInitialization,
12781 bool IsStdInitListInitialization,
12782 bool RequiresZeroInit,
12783 unsigned ConstructKind,
12785 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
12786 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
12787 if (DiagnoseUseOfDecl(Constructor, ConstructLoc))
12791 return BuildCXXConstructExpr(
12792 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
12793 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
12794 RequiresZeroInit, ConstructKind, ParenRange);
12804 bool HadMultipleCandidates,
12805 bool IsListInitialization,
12806 bool IsStdInitListInitialization,
12807 bool RequiresZeroInit,
12808 unsigned ConstructKind,
12813 "given constructor for wrong type");
12814 MarkFunctionReferenced(ConstructLoc, Constructor);
12815 if (getLangOpts().CUDA && !CheckCUDACall(ConstructLoc, Constructor))
12819 Context, DeclInitType, ConstructLoc, Constructor, Elidable,
12820 ExprArgs, HadMultipleCandidates, IsListInitialization,
12821 IsStdInitListInitialization, RequiresZeroInit,
12822 static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
12851 assert((getLangOpts().Modules || (!Lookup.
empty() && Lookup.
size() <= 2)) &&
12852 "more than two lookup results for field name");
12855 assert(isa<CXXRecordDecl>(Lookup[0]) &&
12856 "cannot have other non-field member with same name");
12857 for (
auto L : Lookup)
12858 if (isa<FieldDecl>(L)) {
12859 Pattern = cast<FieldDecl>(L);
12862 assert(Pattern &&
"We must have set the Pattern!");
12865 if (!Pattern->hasInClassInitializer() ||
12866 InstantiateInClassInitializer(Loc, Field, Pattern,
12867 getTemplateInstantiationArgs(Field))) {
12890 Diag(Loc, diag::err_in_class_initializer_not_yet_parsed)
12891 << OutermostClass << Field;
12892 Diag(Field->getLocEnd(), diag::note_in_class_initializer_not_yet_parsed);
12894 if (!isSFINAEContext())
12895 Field->setInvalidDecl();
12908 MarkFunctionReferenced(VD->
getLocation(), Destructor);
12909 CheckDestructorAccess(VD->
getLocation(), Destructor,
12910 PDiag(diag::err_access_dtor_var)
12913 DiagnoseUseOfDecl(Destructor, VD->
getLocation());
12937 bool AllowExplicit,
12938 bool IsListInitialization) {
12940 unsigned NumArgs = ArgsPtr.size();
12941 Expr **Args = ArgsPtr.data();
12945 assert(Proto &&
"Constructor without a prototype?");
12949 if (NumArgs < NumParams)
12950 ConvertedArgs.reserve(NumParams);
12952 ConvertedArgs.reserve(NumArgs);
12955 Proto->
isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
12957 bool Invalid = GatherArgumentsForCall(Loc, Constructor,
12959 llvm::makeArrayRef(Args, NumArgs),
12961 CallType, AllowExplicit,
12962 IsListInitialization);
12963 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
12965 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
12967 CheckConstructorCall(Constructor,
12968 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
12978 if (isa<NamespaceDecl>(DC)) {
12980 diag::err_operator_new_delete_declared_in_namespace)
12984 if (isa<TranslationUnitDecl>(DC) &&
12987 diag::err_operator_new_delete_declared_static)
13005 unsigned DependentParamTypeDiag,
13006 unsigned InvalidParamTypeDiag) {
13013 diag::err_operator_new_delete_dependent_result_type)
13026 diag::err_operator_new_delete_invalid_result_type)
13032 diag::err_operator_new_delete_template_too_few_parameters)
13038 diag::err_operator_new_delete_too_few_parameters)
13045 << FnDecl->
getDeclName() << ExpectedFirstParamType;
13056 ExpectedFirstParamType)
13058 << FnDecl->
getDeclName() << ExpectedFirstParamType;
13080 diag::err_operator_new_dependent_param_type,
13081 diag::err_operator_new_param_type))
13088 diag::err_operator_new_default_arg)
13118 SemaRef, FnDecl, SemaRef.
Context.
VoidTy, ExpectedFirstParamType,
13119 diag::err_operator_delete_dependent_param_type,
13120 diag::err_operator_delete_param_type))
13128 diag::err_destroying_operator_delete_not_usual);
13140 "Expected an overloaded operator declaration");
13150 if (Op == OO_Delete || Op == OO_Array_Delete)
13153 if (Op == OO_New || Op == OO_Array_New)
13161 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
13162 if (MethodDecl->isStatic())
13164 diag::err_operator_overload_static) << FnDecl->
getDeclName();
13166 bool ClassOrEnumParam =
false;
13168 QualType ParamType = Param->getType().getNonReferenceType();
13171 ClassOrEnumParam =
true;
13176 if (!ClassOrEnumParam)
13178 diag::err_operator_overload_needs_class_or_enum)
13188 if (Op != OO_Call) {
13190 if (Param->hasDefaultArg())
13191 return Diag(Param->getLocation(),
13192 diag::err_operator_overload_default_arg)
13193 << FnDecl->
getDeclName() << Param->getDefaultArgRange();
13198 {
false,
false,
false }
13199 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 13200 , { Unary, Binary, MemberOnly } 13201 #include "clang/Basic/OperatorKinds.def" 13204 bool CanBeUnaryOperator = OperatorUses[Op][0];
13205 bool CanBeBinaryOperator = OperatorUses[Op][1];
13206 bool MustBeMemberOperator = OperatorUses[Op][2];
13213 + (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
13214 if (Op != OO_Call &&
13215 ((NumParams == 1 && !CanBeUnaryOperator) ||
13216 (NumParams == 2 && !CanBeBinaryOperator) ||
13217 (NumParams < 1) || (NumParams > 2))) {
13220 if (CanBeUnaryOperator && CanBeBinaryOperator) {
13222 }
else if (CanBeUnaryOperator) {
13225 assert(CanBeBinaryOperator &&
13226 "All non-call overloaded operators are unary or binary!");
13230 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
13235 if (Op != OO_Call &&
13237 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
13242 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
13244 diag::err_operator_overload_must_be_member)
13258 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
13265 diag::err_operator_overload_post_incdec_must_be_int)
13266 << LastParam->
getType() << (Op == OO_MinusMinus);
13278 if (TemplateParams->
size() == 1) {
13287 }
else if (TemplateParams->
size() == 2) {
13296 PmArgs->isTemplateParameterPack()) {
13303 diag::ext_string_literal_operator_template);
13310 diag::err_literal_operator_template)
13319 if (isa<CXXMethodDecl>(FnDecl)) {
13320 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
13329 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
13346 diag::err_literal_operator_template_with_params);
13375 diag::err_literal_operator_param)
13392 diag::err_literal_operator_invalid_param)
13402 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
13409 Diag((*Param)->getSourceRange().getBegin(),
13410 diag::err_literal_operator_param)
13411 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13418 Diag((*Param)->getSourceRange().getBegin(),
13419 diag::err_literal_operator_param)
13420 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13433 Diag((*Param)->getSourceRange().getBegin(),
13434 diag::err_literal_operator_param)
13435 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13443 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
13445 Diag((*Param)->getSourceRange().getBegin(),
13446 diag::err_literal_operator_param)
13448 << (*Param)->getSourceRange();
13452 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
13461 if (Param->hasDefaultArg()) {
13462 Diag(Param->getDefaultArgRange().getBegin(),
13463 diag::err_literal_operator_default_argument)
13464 << Param->getDefaultArgRange();
13469 StringRef LiteralName
13471 if (LiteralName[0] !=
'_' &&
13472 !getSourceManager().isInSystemHeader(FnDecl->
getLocation())) {
13494 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
13503 else if (Lang ==
"C++")
13506 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
13517 PushDeclContext(S, D);
13533 return LinkageSpec;
13542 ProcessDeclAttributeList(S, ED, AttrList);
13544 CurContext->addDecl(ED);
13556 bool Invalid =
false;
13570 Diag(Loc, diag::err_catch_rvalue_ref);
13575 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
13581 unsigned DK = diag::err_catch_incomplete;
13585 DK = diag::err_catch_incomplete_ptr;
13590 DK = diag::err_catch_incomplete_ref;
13592 if (!Invalid && (Mode == 0 || !BaseType->
isVoidType()) &&
13593 !BaseType->
isDependentType() && RequireCompleteType(Loc, BaseType, DK))
13597 RequireNonAbstractType(Loc, ExDeclType,
13598 diag::err_abstract_type_in_decl,
13599 AbstractVariableType))
13604 if (!Invalid && getLangOpts().ObjC1) {
13610 Diag(Loc, diag::err_objc_object_catch);
13614 if (getLangOpts().ObjCRuntime.isFragile())
13615 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
13624 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(ExDecl))
13631 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
13649 Expr *opaqueValue =
13660 Expr *init = MaybeCreateExprWithCleanups(construct);
13665 FinalizeVarWithDestructor(ExDecl,
recordType);
13684 UPPC_ExceptionType)) {
13692 LookupOrdinaryName,
13693 ForVisibleRedeclaration)) {
13698 if (isDeclInScope(PrevDecl, CurContext, S)) {
13701 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
13703 }
else if (PrevDecl->isTemplateParameter())
13714 VarDecl *ExDecl = BuildExceptionDeclaration(S, TInfo,
13723 PushOnScopeChains(ExDecl, S);
13725 CurContext->addDecl(ExDecl);
13727 ProcessDeclAttributes(S, ExDecl, D);
13733 Expr *AssertMessageExpr,
13736 AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) :
nullptr;
13738 if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
13741 return BuildStaticAssertDeclaration(StaticAssertLoc, AssertExpr,
13742 AssertMessage, RParenLoc,
false);
13750 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
13755 ExprResult Converted = PerformContextuallyConvertToBool(AssertExpr);
13760 if (!Failed && VerifyIntegerConstantExpression(Converted.
get(), &Cond,
13761 diag::err_static_assert_expression_is_not_constant,
13765 if (!Failed && !Cond) {
13767 llvm::raw_svector_ostream Msg(MsgBuffer);
13769 AssertMessage->
printPretty(Msg,
nullptr, getPrintingPolicy());
13771 Expr *InnerCond =
nullptr;
13772 std::string InnerCondDescription;
13773 std::tie(InnerCond, InnerCondDescription) =
13774 findFailedBooleanCondition(Converted.
get(),
13777 Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed)
13778 << InnerCondDescription << !AssertMessage
13781 Diag(StaticAssertLoc, diag::err_static_assert_failed)
13788 ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
13794 AssertExpr = FullAssertExpr.
get();
13797 AssertExpr, AssertMessage, RParenLoc,
13800 CurContext->addDecl(Decl);
13810 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
13820 if (!CodeSynthesisContexts.empty()) {
13835 getLangOpts().CPlusPlus11 ?
13836 diag::warn_cxx98_compat_unelaborated_friend_type :
13837 diag::ext_unelaborated_friend_type)
13845 diag::warn_cxx98_compat_nonclass_type_friend :
13846 diag::ext_nonclass_type_friend)
13853 diag::warn_cxx98_compat_enum_friend :
13854 diag::ext_enum_friend)
13865 if (getLangOpts().
CPlusPlus11 && LocStart != FriendLoc)
13866 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
13887 bool IsMemberSpecialization =
false;
13888 bool Invalid =
false;
13891 MatchTemplateParametersToScopeSpecifier(
13892 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
13893 IsMemberSpecialization, Invalid)) {
13894 if (TemplateParams->size() > 0) {
13899 return CheckClassTemplate(S, TagSpec, TUK_Friend, TagLoc, SS, Name,
13900 NameLoc, Attr, TemplateParams,
AS_public,
13902 FriendLoc, TempParamLists.size() - 1,
13903 TempParamLists.data()).
get();
13906 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
13908 IsMemberSpecialization =
true;
13912 if (Invalid)
return nullptr;
13914 bool isAllExplicitSpecializations =
true;
13915 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
13916 if (TempParamLists[I]->size()) {
13917 isAllExplicitSpecializations =
false;
13927 if (isAllExplicitSpecializations) {
13929 bool Owned =
false;
13930 bool IsDependent =
false;
13931 return ActOnTag(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc,
13945 QualType T = CheckTypenameType(Keyword, TagLoc, QualifierLoc,
13951 if (isa<DependentNameType>(T)) {
13965 TSI, FriendLoc, TempParamLists);
13967 CurContext->addDecl(Friend);
13971 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
13978 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
13989 TSI, FriendLoc, TempParamLists);
13992 CurContext->addDecl(Friend);
14026 if (TheDeclarator.isInvalidType())
14029 if (DiagnoseUnexpandedParameterPack(Loc, TSI, UPPC_FriendDeclaration))
14047 Diag(Loc, diag::err_tagless_friend_type_template)
14064 if (!TempParams.empty())
14076 CurContext->addDecl(D);
14102 Diag(Loc, diag::err_unexpected_friend);
14130 if (DiagnoseUnexpandedParameterPack(Loc, TInfo, UPPC_FriendDeclaration) ||
14131 DiagnoseUnexpandedParameterPack(NameInfo, UPPC_FriendDeclaration) ||
14132 DiagnoseUnexpandedParameterPack(SS, UPPC_FriendDeclaration))
14138 Scope *DCScope = S;
14140 ForExternalRedeclaration);
14148 (FunctionContainingLocalClass =
14149 cast<CXXRecordDecl>(CurContext)->isLocalClass())) {
14164 Previous.
clear(LookupLocalFriendName);
14165 LookupName(Previous, S,
false);
14167 if (!Previous.
empty()) {
14175 DC = FunctionContainingLocalClass;
14177 adjustContextForLocalExternDecl(DC);
14197 bool isTemplateId =
14218 LookupQualifiedName(Previous, LookupDC);
14220 if (!Previous.
empty()) {
14225 if (isTemplateId) {
14226 if (isa<TranslationUnitDecl>(LookupDC))
break;
14233 DCScope = getScopeForDeclContext(S, DC);
14239 DC = computeDeclContext(SS);
14240 if (!DC)
return nullptr;
14242 if (RequireCompleteDeclContext(SS, DC))
return nullptr;
14244 LookupQualifiedName(Previous, DC);
14258 if (Previous.
empty()) {
14260 Diag(Loc, diag::err_qualified_friend_not_found)
14267 if (DC->
Equals(CurContext))
14269 getLangOpts().CPlusPlus11 ?
14270 diag::warn_cxx98_compat_friend_is_member :
14271 diag::err_friend_is_member);
14303 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
14330 if (DiagArg >= 0) {
14331 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
14342 DCScope = &FakeDCScope;
14345 bool AddToScope =
true;
14346 NamedDecl *ND = ActOnFunctionDeclarator(DCScope, D, DC, TInfo, Previous,
14347 TemplateParams, AddToScope);
14348 if (!ND)
return nullptr;
14362 if (!CurContext->isDependentContext()) {
14365 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
14366 PushOnScopeChains(ND, EnclosingScope,
false);
14373 CurContext->addDecl(FrD);
14378 if (DC->isRecord()) CheckFriendAccess(ND);
14382 FD = FTD->getTemplatedDecl();
14384 FD = cast<FunctionDecl>(ND);
14395 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
14397 diag::note_previous_declaration);
14399 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
14404 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
14406 << cast<CXXRecordDecl>(CurContext);
14415 AdjustDeclIfTemplate(Dcl);
14417 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
14419 Diag(DelLoc, diag::err_deleted_non_function);
14430 Prev->getPreviousDecl()) &&
14431 !Prev->isDefined()) {
14432 Diag(DelLoc, diag::err_deleted_decl_not_first);
14433 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
14434 Prev->isImplicit() ? diag::note_previous_implicit_declaration
14435 : diag::note_previous_declaration);
14454 bool IssuedDiagnostic =
false;
14457 if (!IssuedDiagnostic) {
14459 IssuedDiagnostic =
true;
14461 Diag(O->getLocation(), diag::note_overridden_virtual_function);
14467 ShouldDeleteSpecialMember(MD, getSpecialMember(MD),
nullptr,
14474 Diag(DelLoc, diag::err_deleted_main);
14493 if (Member == CXXInvalid) {
14495 Diag(DefaultLoc, diag::err_default_special_members);
14521 CheckExplicitlyDefaultedSpecialMember(MD);
14526 Diag(DefaultLoc, diag::err_default_special_members);
14534 if (isa<ReturnStmt>(SubStmt))
14535 Self.
Diag(SubStmt->getLocStart(),
14536 diag::err_return_in_constructor_handler);
14537 if (!isa<Expr>(SubStmt))
14543 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
14555 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
14559 !NewFT->getExtParameterInfo(I).isNoEscape()) {
14561 diag::warn_overriding_method_missing_noescape);
14563 diag::note_overridden_marked_noescape);
14568 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
14569 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
14570 if ((NewCSA || OldCSA) &&
14571 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
14580 if (NewCC == OldCC)
14591 diag::err_conflicting_overriding_cc_attributes)
14617 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
14625 if (NewClassTy.
isNull()) {
14627 diag::err_different_return_type_for_overriding_virtual_function)
14643 if (!RT->isBeingDefined() &&
14644 RequireCompleteType(New->
getLocation(), NewClassTy,
14645 diag::err_covariant_return_incomplete,
14651 if (!IsDerivedFrom(New->
getLocation(), NewClassTy, OldClassTy)) {
14661 if (CheckDerivedToBaseConversion(
14662 NewClassTy, OldClassTy,
14663 diag::err_covariant_return_inaccessible_base,
14664 diag::err_covariant_return_ambiguous_derived_to_base_conv,
14680 diag::err_covariant_return_type_different_qualifications)
14692 diag::err_covariant_return_type_class_type_more_qualified)
14727 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
14728 CheckPureMethod(M, ZeroLoc);
14736 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
14737 return Var->hasGlobalStorage();
14765 PushExpressionEvaluationContext(
14766 ExpressionEvaluationContext::PotentiallyEvaluated, D);
14776 PopExpressionEvaluationContext();
14779 ExitDeclaratorContext(S);
14791 "Parser allowed 'typedef' as storage class of condition decl.");
14793 Decl *Dcl = ActOnDeclarator(S, D);
14797 if (isa<FunctionDecl>(Dcl)) {
14798 Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
14807 if (!ExternalSource)
14811 ExternalSource->ReadUsedVTables(VTables);
14813 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
14814 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
14815 = VTablesUsed.find(VTables[I].Record);
14817 if (Pos != VTablesUsed.end()) {
14818 if (!Pos->second && VTables[I].DefinitionRequired)
14819 Pos->second =
true;
14823 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
14824 NewUses.push_back(
VTableUse(VTables[I].Record, VTables[I].Location));
14827 VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end());
14831 bool DefinitionRequired) {
14835 CurContext->isDependentContext() || isUnevaluatedContext())
14839 LoadExternalVTableUses();
14841 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
14842 Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
14847 if (DefinitionRequired && !Pos.first->second) {
14848 Pos.first->second =
true;
14866 CheckDestructor(DD);
14878 MarkVirtualMembersReferenced(Loc, Class);
14880 VTableUses.push_back(std::make_pair(Class, Loc));
14884 LoadExternalVTableUses();
14885 if (VTableUses.empty())
14892 bool DefinedAnything =
false;
14893 for (
unsigned I = 0; I != VTableUses.size(); ++I) {
14902 bool DefineVTable =
true;
14908 if (KeyFunction && !KeyFunction->
hasBody()) {
14910 DefineVTable =
false;
14915 "Instantiations don't have key functions");
14917 }
else if (!KeyFunction) {
14922 bool IsExplicitInstantiationDeclaration =
14924 for (
auto R : Class->
redecls()) {
14928 IsExplicitInstantiationDeclaration =
true;
14930 IsExplicitInstantiationDeclaration =
false;
14935 if (IsExplicitInstantiationDeclaration)
14936 DefineVTable =
false;
14942 if (!DefineVTable) {
14943 MarkVirtualMemberExceptionSpecsNeeded(Loc, Class);
14950 DefinedAnything =
true;
14951 MarkVirtualMembersReferenced(Loc, Class);
14953 if (VTablesUsed[Canonical])
14954 Consumer.HandleVTable(Class);
14962 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
14966 ? diag::warn_weak_template_vtable
14967 : diag::warn_weak_vtable)
14972 VTableUses.clear();
14974 return DefinedAnything;
14979 for (
const auto *I : RD->
methods())
14980 if (I->isVirtual() && !I->isPure())
14989 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
14990 E = FinalOverriders.end();
14993 OE = I->second.end();
14995 assert(OI->second.size() > 0 &&
"no final overrider");
15000 if (!Overrider->isPure())
15001 MarkFunctionReferenced(Loc, Overrider);
15009 for (
const auto &I : RD->
bases()) {
15011 cast<CXXRecordDecl>(I.getType()->getAs<
RecordType>()->getDecl());
15014 MarkVirtualMembersReferenced(Loc, Base);
15025 CollectIvarsToConstructOrDestruct(OID, ivars);
15029 for (
unsigned i = 0; i < ivars.size(); i++) {
15041 InitSeq.Perform(*
this, InitEntity, InitKind,
None);
15042 MemberInit = MaybeCreateExprWithCleanups(MemberInit);
15053 AllToInit.push_back(Member);
15058 ->getAs<RecordType>()) {
15059 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
15061 MarkFunctionReferenced(Field->
getLocation(), Destructor);
15062 CheckDestructorAccess(Field->
getLocation(), Destructor,
15063 PDiag(diag::err_access_dtor_ivar)
15069 AllToInit.data(), AllToInit.size());
15075 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Valid,
15076 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Invalid,
15077 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Current,
15088 (void)Target->
hasBody(FNTarget);
15090 cast_or_null<CXXConstructorDecl>(FNTarget));
15097 if (!Current.insert(Canonical).second)
15103 Valid.insert(Current.begin(), Current.end());
15106 }
else if (TCanonical == Canonical || Invalid.count(TCanonical) ||
15107 Current.count(TCanonical)) {
15109 if (!Invalid.count(TCanonical)) {
15111 diag::warn_delegating_ctor_cycle)
15115 if (TCanonical != Canonical)
15122 assert(FNTarget &&
"Ctor cycle through bodiless function");
15125 cast<CXXConstructorDecl>(FNTarget));
15130 Invalid.insert(Current.begin(), Current.end());
15139 llvm::SmallPtrSet<CXXConstructorDecl*, 4> Valid, Invalid, Current;
15141 for (DelegatingCtorDeclsType::iterator
15142 I = DelegatingCtorDecls.begin(ExternalSource),
15143 E = DelegatingCtorDecls.end();
15147 for (
auto CI = Invalid.begin(), CE = Invalid.end(); CI != CE; ++CI)
15148 (*CI)->setInvalidDecl();
15157 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
15185 FindCXXThisExpr Finder(*
this);
15193 if (checkThisInStaticMemberFunctionExceptionSpec(Method))
15196 return checkThisInStaticMemberFunctionAttributes(Method);
15210 FindCXXThisExpr Finder(*
this);
15231 if (!Finder.TraverseType(E))
15241 FindCXXThisExpr Finder(*
this);
15244 for (
const auto *A : Method->
attrs()) {
15246 Expr *Arg =
nullptr;
15248 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
15250 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
15252 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
15253 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
15254 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
15255 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
15256 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
15257 Arg = ETLF->getSuccessValue();
15258 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
15259 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
15260 Arg = STLF->getSuccessValue();
15261 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
15262 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
15263 Arg = LR->getArg();
15264 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
15265 Args = llvm::makeArrayRef(LE->args_begin(), LE->args_size());
15266 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
15267 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
15268 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
15269 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
15270 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
15271 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
15272 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
15273 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
15275 if (Arg && !Finder.TraverseStmt(Arg))
15278 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
15279 if (!Finder.TraverseStmt(Args[I]))
15293 Exceptions.clear();
15296 Exceptions.reserve(DynamicExceptions.size());
15297 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
15299 QualType ET = GetTypeFromParser(DynamicExceptions[ei]);
15304 if (!Unexpanded.empty()) {
15306 DynamicExceptionRanges[ei].getBegin(), UPPC_ExceptionType,
15314 if (!CheckSpecifiedExceptionType(ET, DynamicExceptionRanges[ei]))
15315 Exceptions.push_back(ET);
15325 "Parser should have made sure that the expression is boolean");
15326 if (IsTopLevel && DiagnoseUnexpandedParameterPack(NoexceptExpr)) {
15341 Expr *NoexceptExpr) {
15347 MethodD = FunTmpl->getTemplatedDecl();
15356 checkExceptionSpecification(
true, EST, DynamicExceptions,
15357 DynamicExceptionRanges, NoexceptExpr, Exceptions,
15364 checkThisInStaticMemberFunctionExceptionSpec(Method);
15369 CheckOverridingFunctionExceptionSpec(Method, O);
15383 Diag(DeclStart, diag::err_anonymous_property);
15391 CheckExtraCXXDefaultArguments(D);
15394 UPPC_DataMemberType)) {
15405 << getLangOpts().CPlusPlus17;
15408 diag::err_invalid_thread)
15414 ForVisibleRedeclaration);
15415 LookupName(Previous, S);
15436 PrevDecl =
nullptr;
15439 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
15440 PrevDecl =
nullptr;
15446 ProcessDeclAttributes(TUScope, NewPD, D);
15459 PushOnScopeChains(NewPD, S);
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.
static bool checkMemberDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const CXXRecordDecl *RD)
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()
void setSourceOrder(int Pos)
Set the source order of this initializer.
Defines the clang::ASTContext interface.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
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)
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
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.
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.
const Stmt * getElse() const
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...
void setOrigin(CXXRecordDecl *Rec)
CXXMethodDecl * getMethod() const
no exception specification
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.
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...
static unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built...
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.
SourceLocation getLocStart() const LLVM_READONLY
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
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...
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)
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
static unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
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.
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...
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.
StmtResult ActOnExprStmt(ExprResult Arg)
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.
static unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
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.
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
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true)
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)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
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.
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.
void EvaluateImplicitExceptionSpec(SourceLocation Loc, CXXMethodDecl *MD)
Evaluate the implicit exception specification for a defaulted special member function.
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...
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. ...
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.
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 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".
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.
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...
SourceLocation getLocEnd() const LLVM_READONLY
QualType getConversionType() const
Returns the type that this conversion function is converting to.
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.
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.
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.
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.
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.
void ActOnFinishCXXNonNestedClass(Decl *D)
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.
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.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
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.
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.
SourceLocation getFinalLoc() 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...
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 hasDefinition() const
static StringRef getResultString(ComparisonCategoryResult Kind)
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
Represents a parameter to a function.
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
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.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
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.
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.
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
void setUninstantiatedDefaultArg(Expr *arg)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
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
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
static CXXConstructExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr *> Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
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.
SourceLocation getLocStart() const LLVM_READONLY
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
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.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
bool isAbstractType(SourceLocation Loc, QualType T)
static bool isIncrementDecrementOp(Opcode Op)
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned The qualifier bitmask values are the same as...
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)
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.
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)
ParmVarDecl * getParam(unsigned i) const
unsigned getTypeQualifiers() 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...
SourceLocation getLocStart() const LLVM_READONLY
static bool CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S, SmallVectorImpl< SourceLocation > &ReturnStmts, SourceLocation &Cxx1yLoc)
Check the provided statement is allowed in a constexpr function definition.
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()
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.
unsigned getTypeQuals() const
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
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 bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, DeclStmt *DS, SourceLocation &Cxx1yLoc)
Check the given declaration statement is legal within a constexpr function body.
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.
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.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
TagKind getTagKind() const
Microsoft throw(...) extension.
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 isSpecialMemberAccessibleForDeletion(CXXMethodDecl *decl, AccessSpecifier access, QualType objectType)
Is the given special member function accessible for the purposes of deciding whether to define a spec...
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
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...
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true)
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.
bool CheckConstexprFunctionDecl(const FunctionDecl *FD)
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.
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()
SourceLocation getLocStart() const LLVM_READONLY
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.
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.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, const ASTContext *Context=nullptr) const
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...
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
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
param_type_iterator param_type_begin() const
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.
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
ExprResult ActOnCXXThis(SourceLocation loc)
bool isAnyMemberInitializer() const
Represents a C++ nested-name-specifier or a global scope specifier.
enum clang::DeclaratorChunk::@196 Kind
static unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built...
void setNumCtorInitializers(unsigned numCtorInitializers)
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
FieldDecl * getAnyMember() const
SourceLocation getLocStart() const LLVM_READONLY
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
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.
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.
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.
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)
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
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.
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.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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...
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.
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
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.
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.
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)
bool isFinalSpecified() const
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
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.
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 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.
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...
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 isDynamicClass() const
void ClearConstexprSpec()
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
void 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.
static unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
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.
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)
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
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
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...
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
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...
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.
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 ...
Expr - 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.
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 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.
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...
const Stmt * getThen() const
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)
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
getNameAsString - Retrieve the human-readable string for this name.
unsigned getNumInits() const
static unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
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...
const Expr * getCallee() const
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 InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
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 ...
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()
IdentifierInfo * SetterId
CXXRecordDecl * getDefinition() const
bool isConstexprSpecified() const
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.
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.
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
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.
SourceLocation getLocStart() const LLVM_READONLY
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
void DiscardCleanupsInEvaluationContext()
The argument of this type cannot be passed directly in registers.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
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...
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
void setInheritConstructors(bool Inherit=true)
Set that this base class's constructors should be inherited.
SourceLocation getLocEnd() const LLVM_READONLY
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.
void CheckCompletedCXXClass(CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl, CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
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.
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.
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
Retrieves 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 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.
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)
Represents a C++ deduction guide declaration.
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.
SourceLocation getLocEnd() const LLVM_READONLY
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.
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...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
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.
ExprResult ActOnFinishFullExpr(Expr *Expr)
bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body)
Check the body for the given constexpr function declaration only contains the permitted types of stat...
#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
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.
SourceLocation getLocStart() const LLVM_READONLY
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
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)
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)
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
static unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
We are declaring an implicit special member function.
CXXSpecialMember SpecialMember
The special member being declared or defined.
static CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
Represents a call to an inherited base class constructor from an inheriting constructor.
static const CXXRecordDecl * 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.
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.
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...
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
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
CastKind getCastKind() const
static void CheckConstexprCtorInitializer(Sema &SemaRef, const FunctionDecl *Dcl, FieldDecl *Field, llvm::SmallSet< Decl *, 16 > &Inits, bool &Diagnosed)
Check that the given field is initialized within a constexpr constructor.
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
static unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built...
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 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)
SourceLocation getLocStart() const LLVM_READONLY
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)
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.
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)
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
bool isUsualDeallocationFunction() const
Determine whether this is a usual deallocation function (C++ [basic.stc.dynamic.deallocation]p2), which is an overloaded delete or delete[] operator with a particular signature.
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.
Expr * getNoexceptExpr() const
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]).
static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
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.
static CXXDefaultInitExpr * Create(const ASTContext &C, SourceLocation Loc, FieldDecl *Field)
Field is the non-static data member whose default initializer is used by this expression.
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
void CheckExplicitlyDefaultedMemberExceptionSpec(CXXMethodDecl *MD, const FunctionProtoType *T)
Check whether the exception specification provided for an explicitly-defaulted special member matches...
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()
bool hasUninstantiatedDefaultArg() const
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList *> Params, FriendUnion Friend, SourceLocation FriendLoc)
SourceLocation getLocEnd() const LLVM_READONLY
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.
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang)
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
void setExplicitlyDefaulted(bool ED=true)
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)
static Sema::ImplicitExceptionSpecification computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD)
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...
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
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)
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)
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
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.
SourceLocation getLocStart() const LLVM_READONLY
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
bool isExplicit() const
Whether this function is explicit.
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.
void setImplicitlyInline()
Flag that this function is implicitly inline.
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
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)
SourceLocation getLocStart() const LLVM_READONLY
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)
bool hasTrivialDestructorForCall() const
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.
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
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.
DeclarationName - 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
Returns the parent of this method declaration, which is the class in which this method is defined...
const PropertyData & getPropertyData() const
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 mapping from each virtual member function to its set of final overriders.
SourceLocation getLocStart() const LLVM_READONLY
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 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.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
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...
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
static unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
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...
unsigned getNumParams() const
void setNameLoc(SourceLocation Loc)
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...
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
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 ...
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.
bool hasNonTrivialObjCLifetime() const
IndirectFieldDecl * getIndirectMember() const
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
bool isFunctionType() const
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.
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)
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)
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
The template argument is a type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
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.
void addDecl(Decl *D)
Add the declaration D into this context.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
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.
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.
ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
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...
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
static bool CheckConstexprParameterTypes(Sema &SemaRef, const FunctionDecl *FD)
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 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.
void CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD)
void setConstexpr(bool IC)
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...
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
static unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
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...
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
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.
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.
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 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...
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.
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)
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< 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...
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)
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.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void setType(QualType newType)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
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.
SourceLocation ColonLoc
Location of ':'.
SourceRange getSourceRange() const LLVM_READONLY
const LangOptions & getLangOpts() const
void WillReplaceSpecifier(bool ForceReplacement)
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
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).
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.
void clear()
Clears out any current state.
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)
IdentifierInfo * GetterId
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
IgnoreParens - Ignore parentheses.
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".
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 unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
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)
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.
param_type_iterator param_type_end() const
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.
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.