40 #include "llvm/ADT/STLExtras.h" 41 #include "llvm/ADT/SmallString.h" 42 #include "llvm/ADT/StringExtras.h" 46 using namespace clang;
58 class CheckDefaultArgumentVisitor
59 :
public StmtVisitor<CheckDefaultArgumentVisitor, bool> {
64 CheckDefaultArgumentVisitor(
Expr *defarg,
Sema *s)
65 : DefaultArg(defarg), S(s) {}
75 bool CheckDefaultArgumentVisitor::VisitExpr(
Expr *
Node) {
76 bool IsInvalid =
false;
78 IsInvalid |= Visit(SubStmt);
85 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
DeclRefExpr *DRE) {
87 if (
ParmVarDecl *Param = dyn_cast<ParmVarDecl>(Decl)) {
97 diag::err_param_default_argument_references_param)
98 << Param->getDeclName() << DefaultArg->getSourceRange();
99 }
else if (
VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) {
103 if (VDecl->isLocalVarDecl())
105 diag::err_param_default_argument_references_local)
106 << VDecl->getDeclName() << DefaultArg->getSourceRange();
113 bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
CXXThisExpr *ThisE) {
118 diag::err_param_default_argument_references_this)
122 bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
PseudoObjectExpr *POE) {
130 E = OVE->getSourceExpr();
131 assert(E &&
"pseudo-object binding without source expression?");
139 bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
LambdaExpr *Lambda) {
146 return S->
Diag(Lambda->
getBeginLoc(), diag::err_lambda_capture_default_arg);
159 Proto = Self->ResolveExceptionSpec(CallLoc, Proto);
176 llvm_unreachable(
"should not see unresolved exception specs here");
205 "should not generate implicit declarations for dependent cases");
209 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
211 "Shouldn't collect exceptions when throw-all is guaranteed.");
215 if (ExceptionsSeen.insert(Self->Context.getCanonicalType(E)).second)
216 Exceptions.push_back(E);
244 if (Self->canThrow(E))
252 diag::err_typecheck_decl_incomplete_type)) {
273 CheckCompletedExpr(Arg, EqualLoc);
274 Arg = MaybeCreateExprWithCleanups(Arg);
281 UnparsedDefaultArgInstantiationsMap::iterator InstPos
282 = UnparsedDefaultArgInstantiations.find(Param);
283 if (InstPos != UnparsedDefaultArgInstantiations.end()) {
284 for (
unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
285 InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
288 UnparsedDefaultArgInstantiations.erase(InstPos);
300 if (!param || !DefaultArg)
304 UnparsedDefaultArgLocs.erase(Param);
308 Diag(EqualLoc, diag::err_param_default_argument)
315 if (DiagnoseUnexpandedParameterPack(DefaultArg, UPPC_DefaultArgument)) {
324 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
330 CheckDefaultArgumentVisitor DefaultArgChecker(DefaultArg,
this);
331 if (DefaultArgChecker.Visit(DefaultArg)) {
336 SetParamDefaultArgument(Param, DefaultArg, EqualLoc);
351 UnparsedDefaultArgLocs[Param] = ArgLoc;
363 UnparsedDefaultArgLocs.erase(Param);
387 if (MightBeFunction) {
391 MightBeFunction =
false;
394 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
398 std::unique_ptr<CachedTokens> Toks =
401 if (Toks->size() > 1)
403 Toks->back().getLocation());
405 SR = UnparsedDefaultArgLocs[Param];
415 MightBeFunction =
false;
421 for (
unsigned NumParams = FD->
getNumParams(); NumParams > 0; --NumParams) {
437 bool Invalid =
false;
448 for (; PrevForDefaultArgs;
458 if (S && !isDeclInScope(PrevForDefaultArgs, ScopeDC, S) &&
496 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
499 p < NumParams; ++
p) {
503 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
506 if (OldParamHasDfl && NewParamHasDfl) {
507 unsigned DiagDefaultParamID =
508 diag::err_param_default_argument_redefinition;
513 if (getLangOpts().MicrosoftExt) {
523 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
541 for (
auto Older = PrevForDefaultArgs;
543 Older = Older->getPreviousDecl();
544 OldParam = Older->getParamDecl(
p);
549 }
else if (OldParamHasDfl) {
567 }
else if (NewParamHasDfl) {
571 diag::err_param_default_argument_template_redecl)
574 diag::note_template_prev_declaration)
605 if (Record->getDescribedClassTemplate())
607 else if (isa<ClassTemplatePartialSpecializationDecl>(Record))
614 diag::err_param_default_argument_member_template_redecl)
624 if (isa<CXXConstructorDecl>(New) &&
627 OldSM = getSpecialMember(cast<CXXMethodDecl>(Old));
628 if (NewSM != OldSM) {
631 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
657 Diag(Def->getLocation(), diag::note_previous_definition);
665 if (isa<CXXDeductionGuideDecl>(New) &&
677 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
695 Diag(Decomp.getLSquareLoc(), diag::err_decomp_decl_context)
696 << Decomp.getSourceRange();
700 if (!TemplateParamLists.empty()) {
703 Diag(TemplateParamLists.front()->getTemplateLoc(),
704 diag::err_decomp_decl_template);
708 Diag(Decomp.getLSquareLoc(),
709 !getLangOpts().CPlusPlus17
710 ? diag::ext_decomp_decl
712 ? diag::ext_decomp_decl_cond
713 : diag::warn_cxx14_compat_decomp_decl)
714 << Decomp.getSourceRange();
731 if (
auto SCS = DS.getStorageClassSpec()) {
734 CPlusPlus20SpecifierLocs.push_back(DS.getStorageClassSpecLoc());
737 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
740 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
742 CPlusPlus20SpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
744 if (DS.hasConstexprSpecifier()) {
745 BadSpecifiers.push_back(
747 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
749 if (DS.isInlineSpecified()) {
750 BadSpecifiers.push_back(
"inline");
751 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
753 if (!BadSpecifiers.empty()) {
754 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
755 Err << (int)BadSpecifiers.size()
756 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
759 for (
auto Loc : BadSpecifierLocs)
761 }
else if (!CPlusPlus20Specifiers.empty()) {
762 auto &&Warn =
Diag(CPlusPlus20SpecifierLocs.front(),
763 getLangOpts().CPlusPlus2a
764 ? diag::warn_cxx17_compat_decomp_decl_spec
765 : diag::ext_decomp_decl_spec);
766 Warn << (int)CPlusPlus20Specifiers.size()
767 << llvm::join(CPlusPlus20Specifiers.begin(),
768 CPlusPlus20Specifiers.end(),
" ");
769 for (
auto Loc : CPlusPlus20SpecifierLocs)
781 UPPC_DeclarationType))
791 Diag(Decomp.getLSquareLoc(),
795 ? diag::err_decomp_decl_parens
796 : diag::err_decomp_decl_type)
814 ForVisibleRedeclaration);
815 LookupName(Previous, S,
828 FilterLookupForScope(Previous, DC, S, ConsiderLinkage,
830 if (!Previous.
empty()) {
832 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
833 Diag(Old->getLocation(), diag::note_previous_definition);
837 PushOnScopeChains(BD, S,
true);
838 Bindings.push_back(BD);
839 ParsingInitForAutoVars.insert(BD);
845 Decomp.getLSquareLoc());
847 ForVisibleRedeclaration);
850 bool AddToScope =
true;
852 ActOnVariableDeclarator(S, D, DC, TInfo, Previous,
856 CurContext->addHiddenDecl(New);
859 if (isInOpenMPDeclareTargetContext())
860 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
869 if ((int64_t)Bindings.size() != NumElems) {
870 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
871 << DecompType << (
unsigned)Bindings.size() << NumElems.toString(10)
872 << (NumElems < Bindings.size());
877 for (
auto *B : Bindings) {
882 E = GetInit(Loc, E.
get(), I++);
885 B->setBinding(ElemType, E.
get());
894 const llvm::APSInt &NumElems,
897 S, Bindings, Src, DecompType, NumElems, ElemType,
918 S, Bindings, Src, DecompType, llvm::APSInt::get(VT->
getNumElements()),
928 S, Bindings, Src, DecompType, llvm::APSInt::get(2),
939 llvm::raw_svector_ostream OS(SS);
944 Arg.getArgument().print(PrintingPolicy, OS);
954 auto DiagnoseMissing = [&] {
964 return DiagnoseMissing();
974 return DiagnoseMissing();
980 Result.suppressDiagnostics();
982 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
994 Loc, TraitTy, DiagID,
1000 assert(RD &&
"specialization of class template is not a class?");
1022 llvm::APSInt &Size) {
1037 return IsTupleLike::NotTupleLike;
1046 : R(R), Args(Args) {}
1048 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1051 } Diagnoser(R, Args);
1062 return IsTupleLike::TupleLike;
1077 S, R, Loc,
"tuple_element", Args,
1078 diag::err_decomp_decl_std_tuple_element_not_specialized))
1084 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1095 struct BindingDiagnosticTrap {
1101 : S(S), Trap(S.
Diags), BD(BD) {}
1102 ~BindingDiagnosticTrap() {
1112 const llvm::APSInt &TupleSize) {
1113 if ((int64_t)Bindings.size() != TupleSize) {
1114 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1115 << DecompType << (
unsigned)Bindings.size() << TupleSize.toString(10)
1116 << (TupleSize < Bindings.size());
1120 if (Bindings.empty())
1129 bool UseMemberGet =
false;
1133 if (MemberGet.isAmbiguous())
1139 dyn_cast<FunctionTemplateDecl>(D->getUnderlyingDecl())) {
1141 if (TPL->
size() != 0 &&
1142 isa<NonTypeTemplateParmDecl>(TPL->
getParam(0))) {
1144 UseMemberGet =
true;
1152 for (
auto *B : Bindings) {
1153 BindingDiagnosticTrap Trap(S, B);
1175 MemberGet, &Args,
nullptr);
1209 B->getDeclName().getAsIdentifierInfo(), RefType,
1213 RefVD->setImplicit();
1215 RefVD->setInlineSpecified();
1216 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1221 E = Seq.
Perform(S, Entity, Kind, Init);
1227 RefVD->setInit(E.
get());
1228 if (!E.
get()->isValueDependent())
1229 RefVD->checkInitIsICE();
1237 B->setBinding(T, E.
get());
1261 ClassWithFields = RD;
1265 Paths.
setOrigin(const_cast<CXXRecordDecl*>(RD));
1273 for (
auto &
P : Paths) {
1277 BestPath->back().Base->getType())) {
1279 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1280 <<
false << RD << BestPath->back().Base->getType()
1281 <<
P.back().Base->getType();
1283 }
else if (
P.Access < BestPath->
Access) {
1289 QualType BaseType = BestPath->back().Base->getType();
1291 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1298 *BestPath, diag::err_decomp_decl_inaccessible_base);
1309 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1310 << (ClassWithFields == RD) << RD << ClassWithFields
1311 << Paths.
front().back().Base->getType();
1322 diag::err_incomplete_type))
1334 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1335 unsigned NumFields =
1336 std::count_if(RD->field_begin(), RD->field_end(),
1337 [](
FieldDecl *FD) {
return !FD->isUnnamedBitfield(); });
1338 assert(Bindings.size() != NumFields);
1339 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1340 << DecompType << (
unsigned)Bindings.size() << NumFields
1341 << (NumFields < Bindings.size());
1349 for (
auto *FD : RD->fields()) {
1350 if (FD->isUnnamedBitfield())
1353 if (FD->isAnonymousStructOrUnion()) {
1356 S.
Diag(FD->getLocation(), diag::note_declared_at);
1361 if (I >= Bindings.size())
1362 return DiagnoseBadNumberOfBindings();
1363 auto *B = Bindings[I++];
1371 Loc, const_cast<CXXRecordDecl *>(OrigRD),
1373 BasePair.
getAccess(), FD->getAccess())));
1396 if (FD->isMutable())
1401 if (I != Bindings.size())
1402 return DiagnoseBadNumberOfBindings();
1444 llvm::APSInt TupleSize(32);
1450 case IsTupleLike::TupleLike:
1455 case IsTupleLike::NotTupleLike:
1464 << DD << !RD << DecompType;
1483 if (!getLangOpts().CXXExceptions)
1487 "Should only be called if types are otherwise the same.");
1498 NewType =
P->getPointeeType();
1511 if (CheckEquivalentExceptionSpec(
1526 for (p = 0; p < NumParams; ++
p) {
1538 unsigned LastMissingDefaultArg = 0;
1539 for (; p < NumParams; ++
p) {
1546 diag::err_param_default_argument_missing_name)
1550 diag::err_param_default_argument_missing);
1552 LastMissingDefaultArg =
p;
1556 if (LastMissingDefaultArg > 0) {
1561 for (p = 0; p <= LastMissingDefaultArg; ++
p) {
1575 unsigned ArgIndex = 0;
1579 i != e; ++
i, ++ArgIndex) {
1582 if (!(*i)->isDependentType() &&
1584 ParamLoc, *
i, diag::err_constexpr_non_literal_param, ArgIndex + 1,
1602 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1625 << isa<CXXConstructorDecl>(NewFD)
1627 for (
const auto &I : RD->
vbases())
1628 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
1629 << I.getSourceRange();
1634 if (!isa<CXXConstructorDecl>(NewFD)) {
1641 if (getLangOpts().CPlusPlus2a) {
1642 Diag(Method->
getLocation(), diag::warn_cxx17_compat_constexpr_virtual);
1650 while (!WrittenVirtual->isVirtualAsWritten())
1652 if (WrittenVirtual != Method)
1653 Diag(WrittenVirtual->getLocation(),
1654 diag::note_overridden_virtual_function);
1663 diag::err_constexpr_non_literal_return,
1685 for (
const auto *DclIt : DS->
decls()) {
1686 switch (DclIt->getKind()) {
1687 case Decl::StaticAssert:
1689 case Decl::UsingShadow:
1690 case Decl::UsingDirective:
1691 case Decl::UnresolvedUsingTypename:
1692 case Decl::UnresolvedUsingValue:
1699 case Decl::TypeAlias: {
1702 const auto *TN = cast<TypedefNameDecl>(DclIt);
1703 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1705 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1708 << isa<CXXConstructorDecl>(Dcl);
1715 case Decl::CXXRecord:
1717 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition())
1720 ? diag::warn_cxx11_compat_constexpr_type_definition
1721 : diag::ext_constexpr_type_definition)
1722 << isa<CXXConstructorDecl>(Dcl);
1725 case Decl::EnumConstant:
1726 case Decl::IndirectField:
1733 case Decl::Decomposition: {
1737 const auto *VD = cast<VarDecl>(DclIt);
1738 if (VD->isThisDeclarationADefinition()) {
1739 if (VD->isStaticLocal()) {
1740 SemaRef.
Diag(VD->getLocation(),
1741 diag::err_constexpr_local_var_static)
1742 << isa<CXXConstructorDecl>(Dcl)
1746 if (!VD->getType()->isDependentType() &&
1748 VD->getLocation(), VD->getType(),
1749 diag::err_constexpr_local_var_non_literal_type,
1750 isa<CXXConstructorDecl>(Dcl)))
1752 if (!VD->getType()->isDependentType() &&
1753 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1754 SemaRef.
Diag(VD->getLocation(),
1755 diag::err_constexpr_local_var_no_init)
1756 << isa<CXXConstructorDecl>(Dcl);
1760 SemaRef.
Diag(VD->getLocation(),
1762 ? diag::warn_cxx11_compat_constexpr_local_var
1763 : diag::ext_constexpr_local_var)
1764 << isa<CXXConstructorDecl>(Dcl);
1768 case Decl::NamespaceAlias:
1777 SemaRef.
Diag(DS->
getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
1778 << isa<CXXConstructorDecl>(Dcl) << Dcl->
isConsteval();
1797 llvm::SmallSet<Decl*, 16> &
Inits,
1814 if (!Inits.count(Field)) {
1816 SemaRef.
Diag(Dcl->
getLocation(), diag::err_constexpr_ctor_missing_init);
1819 SemaRef.
Diag(Field->
getLocation(), diag::note_constexpr_ctor_missing_init);
1822 for (
auto *I : RD->
fields())
1825 if (!RD->
isUnion() || Inits.count(I))
1838 case Stmt::NullStmtClass:
1842 case Stmt::DeclStmtClass:
1852 case Stmt::ReturnStmtClass:
1854 if (isa<CXXConstructorDecl>(Dcl)) {
1864 case Stmt::CompoundStmtClass: {
1870 for (
auto *BodyIt : CompStmt->
body()) {
1872 Cxx1yLoc, Cxx2aLoc))
1878 case Stmt::AttributedStmtClass:
1883 case Stmt::IfStmtClass: {
1888 IfStmt *If = cast<IfStmt>(S);
1890 Cxx1yLoc, Cxx2aLoc))
1894 Cxx1yLoc, Cxx2aLoc))
1899 case Stmt::WhileStmtClass:
1900 case Stmt::DoStmtClass:
1901 case Stmt::ForStmtClass:
1902 case Stmt::CXXForRangeStmtClass:
1903 case Stmt::ContinueStmtClass:
1913 Cxx1yLoc, Cxx2aLoc))
1917 case Stmt::SwitchStmtClass:
1918 case Stmt::CaseStmtClass:
1919 case Stmt::DefaultStmtClass:
1920 case Stmt::BreakStmtClass:
1928 Cxx1yLoc, Cxx2aLoc))
1932 case Stmt::CXXTryStmtClass:
1938 Cxx1yLoc, Cxx2aLoc))
1943 case Stmt::CXXCatchStmtClass:
1947 cast<CXXCatchStmt>(S)->getHandlerBlock(),
1948 ReturnStmts, Cxx1yLoc, Cxx2aLoc))
1963 << isa<CXXConstructorDecl>(Dcl) << Dcl->
isConsteval();
1974 if (isa<CXXTryStmt>(Body)) {
1988 !getLangOpts().CPlusPlus2a
1989 ? diag::ext_constexpr_function_try_block_cxx2a
1990 : diag::warn_cxx17_compat_constexpr_function_try_block)
1991 << isa<CXXConstructorDecl>(Dcl);
2003 Cxx1yLoc, Cxx2aLoc))
2009 getLangOpts().CPlusPlus2a
2010 ? diag::warn_cxx17_compat_constexpr_body_invalid_stmt
2011 : diag::ext_constexpr_body_invalid_stmt_cxx2a)
2012 << isa<CXXConstructorDecl>(Dcl);
2015 getLangOpts().CPlusPlus14
2016 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
2017 : diag::ext_constexpr_body_invalid_stmt)
2018 << isa<CXXConstructorDecl>(Dcl);
2021 = dyn_cast<CXXConstructorDecl>(Dcl)) {
2030 if (Constructor->getNumCtorInitializers() == 0 &&
2035 }
else if (!Constructor->isDependentContext() &&
2036 !Constructor->isDelegatingConstructor()) {
2037 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
2041 bool AnyAnonStructUnionMembers =
false;
2042 unsigned Fields = 0;
2044 E = RD->
field_end(); I != E; ++I, ++Fields) {
2045 if (I->isAnonymousStructOrUnion()) {
2046 AnyAnonStructUnionMembers =
true;
2054 if (AnyAnonStructUnionMembers ||
2055 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
2059 llvm::SmallSet<Decl*, 16>
Inits;
2060 for (
const auto *I: Constructor->inits()) {
2064 Inits.insert(
ID->chain_begin(),
ID->chain_end());
2067 bool Diagnosed =
false;
2068 for (
auto *I : RD->
fields())
2075 if (ReturnStmts.empty()) {
2080 bool OK = getLangOpts().CPlusPlus14 &&
2084 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2085 : diag::err_constexpr_body_no_return)
2089 }
else if (ReturnStmts.size() > 1) {
2090 Diag(ReturnStmts.back(),
2091 getLangOpts().CPlusPlus14
2092 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2093 : diag::ext_constexpr_body_multiple_return);
2094 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2095 Diag(ReturnStmts[I], diag::note_constexpr_body_previous_return);
2111 Diag(Dcl->
getLocation(), diag::ext_constexpr_function_never_constant_expr)
2112 << isa<CXXConstructorDecl>(Dcl);
2113 for (
size_t I = 0, N = Diags.size(); I != N; ++I)
2114 Diag(Diags[I].first, Diags[I].second);
2131 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2138 return dyn_cast_or_null<CXXRecordDecl>(DC);
2141 return dyn_cast_or_null<CXXRecordDecl>(CurContext);
2158 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2160 if (!getLangOpts().SpellChecking)
2166 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2168 CurDecl = dyn_cast_or_null<CXXRecordDecl>(CurContext);
2170 if (CurDecl && CurDecl->getIdentifier() && II != CurDecl->getIdentifier() &&
2171 3 * II->
getName().edit_distance(CurDecl->getIdentifier()->getName())
2173 II = CurDecl->getIdentifier();
2188 for (
const auto &I : Current->
bases()) {
2200 Queue.push_back(Base);
2206 Current = Queue.pop_back_val();
2234 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2247 ((BaseDecl = BaseDecl->getDefinition()) &&
2249 Diag(BaseLoc, diag::err_circular_inheritance)
2253 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
2262 Access, TInfo, EllipsisLoc);
2267 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2274 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2281 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2283 propagateDLLAttrToBaseClassTemplate(Class, ClassAttr, BaseTemplate,
2292 if (RequireCompleteType(BaseLoc, BaseType,
2293 diag::err_incomplete_base_class, SpecifierRange)) {
2300 assert(BaseDecl &&
"Record type has no declaration");
2302 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2304 assert(CXXBaseDecl &&
"Base type is not a C++ type");
2309 const auto *BaseCSA = CXXBaseDecl->
getAttr<CodeSegAttr>();
2310 const auto *DerivedCSA = Class->
getAttr<CodeSegAttr>();
2311 if ((DerivedCSA || BaseCSA) &&
2312 (!BaseCSA || !DerivedCSA || BaseCSA->getName() != DerivedCSA->getName())) {
2314 Diag(CXXBaseDecl->
getLocation(), diag::note_base_class_specified_here)
2326 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2334 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
2335 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2337 << FA->isSpelledAsSealed();
2349 Access, TInfo, EllipsisLoc);
2366 AdjustDeclIfTemplate(classdecl);
2380 ? (unsigned)diag::warn_unknown_attribute_ignored
2381 : (
unsigned)diag::err_base_specifier_attribute)
2386 GetTypeFromParser(basetype, &TInfo);
2389 DiagnoseUnexpandedParameterPack(SpecifierRange.
getBegin(), TInfo,
2394 Virtual, Access, TInfo,
2415 auto Decl = Rec->getAsCXXRecordDecl();
2418 for (
const auto &BaseSpec : Decl->bases()) {
2420 .getUnqualifiedType();
2421 if (Set.insert(Base).second)
2439 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2443 IndirectBaseSet IndirectBaseTypes;
2446 unsigned NumGoodBases = 0;
2447 bool Invalid =
false;
2448 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2458 Diag(Bases[idx]->getBeginLoc(), diag::err_duplicate_base_class)
2459 << KnownBase->
getType() << Bases[idx]->getSourceRange();
2468 KnownBase = Bases[idx];
2469 Bases[NumGoodBases++] = Bases[idx];
2472 if (Bases.size() > 1)
2476 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
2488 Class->
addAttr(WeakAttr::CreateImplicit(Context));
2494 Class->
setBases(Bases.data(), NumGoodBases);
2497 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2499 QualType BaseType = Bases[idx]->getType();
2509 if (IndirectBaseTypes.count(CanonicalBase)) {
2513 = Class->
isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
2518 Diag(Bases[idx]->getBeginLoc(), diag::warn_inaccessible_base_class)
2519 << BaseType << getAmbiguousPathsDisplayString(Paths)
2520 << Bases[idx]->getSourceRange();
2522 assert(Bases[idx]->isVirtual());
2538 if (!ClassDecl || Bases.empty())
2541 AdjustDeclIfTemplate(ClassDecl);
2542 AttachBaseSpecifiers(cast<CXXRecordDecl>(ClassDecl), Bases);
2566 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2587 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2599 for (
unsigned I = Path.size(); I != 0; --I) {
2600 if (Path[I - 1].
Base->isVirtual()) {
2607 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
2608 BasePathArray.push_back(const_cast<CXXBaseSpecifier*>(Path[I].Base));
2614 assert(BasePathArray.empty() &&
"Base path array must be empty!");
2632 unsigned InaccessibleBaseID,
2633 unsigned AmbigiousBaseConvID,
2637 bool IgnoreAccess) {
2644 bool DerivationOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2645 if (!DerivationOkay)
2650 Path = &Paths.
front();
2655 if (!Path && getLangOpts().MSVCCompat) {
2657 if (PossiblePath.size() == 1) {
2658 Path = &PossiblePath;
2659 if (AmbigiousBaseConvID)
2660 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
2661 << Base << Derived << Range;
2668 if (!IgnoreAccess) {
2671 CheckBaseClassAccess(Loc, Base, Derived, *Path, InaccessibleBaseID)) {
2687 if (AmbigiousBaseConvID) {
2696 bool StillOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2697 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
2704 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
2706 Diag(Loc, AmbigiousBaseConvID)
2707 << Derived << Base << PathDisplayStr << Range << Name;
2716 bool IgnoreAccess) {
2717 return CheckDerivedToBaseConversion(
2718 Derived, Base, diag::err_upcast_to_inaccessible_base,
2719 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
2720 BasePath, IgnoreAccess);
2737 std::string PathDisplayStr;
2738 std::set<unsigned> DisplayedPaths;
2740 Path != Paths.
end(); ++Path) {
2741 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
2744 PathDisplayStr +=
"\n ";
2746 for (CXXBasePath::const_iterator Element = Path->begin();
2747 Element != Path->end(); ++Element)
2748 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
2752 return PathDisplayStr;
2763 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
2766 CurContext->addHiddenDecl(ASDecl);
2767 return ProcessAccessDeclAttributeList(ASDecl, Attrs);
2791 FindHiddenVirtualMethods(MD, OverloadedMethods);
2793 if (!OverloadedMethods.empty()) {
2794 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2795 Diag(OA->getLocation(),
2796 diag::override_keyword_hides_virtual_member_function)
2797 <<
"override" << (OverloadedMethods.size() > 1);
2798 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2799 Diag(FA->getLocation(),
2800 diag::override_keyword_hides_virtual_member_function)
2801 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2802 << (OverloadedMethods.size() > 1);
2804 NoteHiddenVirtualMethods(MD, OverloadedMethods);
2813 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2814 Diag(OA->getLocation(),
2815 diag::override_keyword_only_allowed_on_virtual_member_functions)
2819 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2820 Diag(FA->getLocation(),
2821 diag::override_keyword_only_allowed_on_virtual_member_functions)
2822 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2834 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
2835 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
2848 if (getSourceManager().isMacroArgExpansion(Loc))
2849 SpellingLoc = getSourceManager().getImmediateExpansionRange(Loc).getBegin();
2850 SpellingLoc = getSourceManager().getSpellingLoc(SpellingLoc);
2851 if (SpellingLoc.
isValid() && getSourceManager().isInSystemHeader(SpellingLoc))
2855 unsigned DiagID = isa<CXXDestructorDecl>(MD)
2856 ? diag::warn_destructor_marked_not_override_overriding
2857 : diag::warn_function_marked_not_override_overriding;
2869 FinalAttr *FA = Old->
getAttr<FinalAttr>();
2875 << FA->isSpelledAsSealed();
2884 return !RD->isCompleteDefinition() ||
2885 !RD->hasTrivialDefaultConstructor() ||
2886 !RD->hasTrivialDestructor();
2892 llvm::find_if(list, [](
const ParsedAttr &AL) {
2895 if (Itr != list.
end())
2905 if (Diags.isIgnored(diag::warn_shadow_field, Loc))
2909 std::map<CXXRecordDecl*, NamedDecl*> Bases;
2914 if (Bases.find(
Base) != Bases.end())
2916 for (
const auto Field :
Base->lookup(FieldName)) {
2917 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
2919 assert(Field->getAccess() !=
AS_none);
2920 assert(Bases.find(
Base) == Bases.end());
2921 Bases[
Base] = Field;
2933 for (
const auto &
P : Paths) {
2934 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
2935 auto It = Bases.find(
Base);
2937 if (It == Bases.end())
2939 auto BaseField = It->second;
2940 assert(BaseField->getAccess() !=
AS_private);
2943 Diag(Loc, diag::warn_shadow_field)
2944 << FieldName << RD <<
Base << DeclIsField;
2945 Diag(BaseField->getLocation(), diag::note_shadow_field);
2970 Expr *BitWidth =
static_cast<Expr*
>(BW);
2972 assert(isa<CXXRecordDecl>(CurContext));
2979 if (cast<CXXRecordDecl>(CurContext)->isInterface()) {
2983 unsigned InvalidDecl;
2984 bool ShowDeclName =
true;
2997 ShowDeclName =
false;
3002 ShowDeclName =
false;
3017 Diag(Loc, diag::err_invalid_member_in_interface)
3018 << (InvalidDecl-1) << Name;
3020 Diag(Loc, diag::err_invalid_member_in_interface)
3021 << (InvalidDecl-1) <<
"";
3047 diag::err_storageclass_invalid_for_member);
3067 const char *PrevSpec;
3072 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3076 const char *PrevSpec;
3082 "This is the only DeclSpec that should fail to be applied");
3086 isInstField =
false;
3097 Diag(Loc, diag::err_bad_variable_name)
3106 if (TemplateParameterLists.size()) {
3108 if (TemplateParams->
size()) {
3117 diag::err_template_member_noparams)
3132 if (
DeclContext *DC = computeDeclContext(SS,
false))
3143 if (MSPropertyAttr) {
3144 Member = HandleMSProperty(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3145 BitWidth, InitStyle, AS, *MSPropertyAttr);
3148 isInstField =
false;
3150 Member = HandleField(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3151 BitWidth, InitStyle, AS);
3156 CheckShadowInheritedFields(Loc, Name, cast<CXXRecordDecl>(CurContext));
3158 Member = HandleDeclarator(S, D, TemplateParameterLists);
3166 }
else if (isa<VarDecl>(Member) || isa<VarTemplateDecl>(Member)) {
3169 Diag(Loc, diag::err_static_not_bitfield)
3171 }
else if (isa<TypedefDecl>(Member)) {
3173 Diag(Loc, diag::err_typedef_not_bitfield)
3178 Diag(Loc, diag::err_not_integral_type_bitfield)
3179 << Name << cast<ValueDecl>(Member)->getType()
3189 NonTemplateMember = FunTmpl->getTemplatedDecl();
3190 else if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(Member))
3191 NonTemplateMember = VarTmpl->getTemplatedDecl();
3197 if (NonTemplateMember != Member)
3203 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3204 auto *TD = DG->getDeducedTemplate();
3207 if (AS != TD->getAccess() &&
3208 TD->getDeclContext()->getRedeclContext()->Equals(
3209 DG->getDeclContext()->getRedeclContext())) {
3210 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
3211 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
3214 for (
const auto *D : cast<CXXRecordDecl>(CurContext)->decls()) {
3215 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(D))
3216 LastAccessSpec = AccessSpec;
3218 assert(LastAccessSpec &&
"differing access with no access specifier");
3219 Diag(LastAccessSpec->
getBeginLoc(), diag::note_deduction_guide_access)
3233 if (
CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(Member))
3237 CheckOverrideControl(Member);
3239 assert((Name || isInstField) &&
"No identifier for non-field ?");
3242 FieldDecl *FD = cast<FieldDecl>(Member);
3243 FieldCollector->Add(FD);
3245 if (!Diags.isIgnored(diag::warn_unused_private_field, FD->
getLocation())) {
3253 UnusedPrivateFields.insert(FD);
3261 class UninitializedFieldVisitor
3266 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3269 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3284 UninitializedFieldVisitor(
Sema &S,
3285 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3286 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3287 : Inherited(S.
Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3288 Constructor(
nullptr), InitList(
false), InitListFieldDecl(
nullptr) {}
3291 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3292 bool CheckReferenceOnly) {
3294 bool ReferenceField =
false;
3299 Fields.push_back(FD);
3301 ReferenceField =
true;
3307 if (CheckReferenceOnly && !ReferenceField)
3313 for (
auto I = Fields.rbegin() + 1, E = Fields.rend(); I != E; ++I) {
3314 UsedFieldIndex.push_back((*I)->getFieldIndex());
3317 for (
auto UsedIter = UsedFieldIndex.begin(),
3318 UsedEnd = UsedFieldIndex.end(),
3319 OrigIter = InitFieldIndex.begin(),
3320 OrigEnd = InitFieldIndex.end();
3321 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3322 if (*UsedIter < *OrigIter)
3324 if (*UsedIter > *OrigIter)
3331 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3346 if (isa<VarDecl>(SubME->getMemberDecl()))
3349 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3350 if (!FD->isAnonymousStructOrUnion())
3354 AllPODFields =
false;
3356 Base = SubME->getBase();
3362 if (AddressOf && AllPODFields)
3368 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3369 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
3372 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3382 if (!Decls.count(FoundVD))
3387 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3389 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3394 if (CheckReferenceOnly && !IsReference)
3398 unsigned diag = IsReference
3399 ? diag::warn_reference_field_is_uninit
3400 : diag::warn_field_is_uninit;
3404 diag::note_uninit_in_this_constructor)
3409 void HandleValue(
Expr *E,
bool AddressOf) {
3412 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3413 HandleMemberExpr(ME,
false ,
3419 Visit(CO->getCond());
3420 HandleValue(CO->getTrueExpr(), AddressOf);
3421 HandleValue(CO->getFalseExpr(), AddressOf);
3426 dyn_cast<BinaryConditionalOperator>(E)) {
3427 Visit(BCO->getCond());
3428 HandleValue(BCO->getFalseExpr(), AddressOf);
3433 HandleValue(OVE->getSourceExpr(), AddressOf);
3438 switch (BO->getOpcode()) {
3443 HandleValue(BO->getLHS(), AddressOf);
3444 Visit(BO->getRHS());
3447 Visit(BO->getLHS());
3448 HandleValue(BO->getRHS(), AddressOf);
3457 InitFieldIndex.push_back(0);
3458 for (
auto Child : ILE->
children()) {
3459 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3460 CheckInitListExpr(SubList);
3464 ++InitFieldIndex.back();
3466 InitFieldIndex.pop_back();
3475 DeclsToRemove.clear();
3477 Constructor = FieldConstructor;
3482 InitListFieldDecl = Field;
3483 InitFieldIndex.clear();
3484 CheckInitListExpr(ILE);
3498 HandleMemberExpr(ME,
true ,
false );
3507 Inherited::VisitImplicitCastExpr(E);
3513 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3517 if (ICE->getCastKind() == CK_NoOp)
3518 ArgExpr = ICE->getSubExpr();
3519 HandleValue(ArgExpr,
false );
3522 Inherited::VisitCXXConstructExpr(E);
3527 if (isa<MemberExpr>(Callee)) {
3528 HandleValue(Callee,
false );
3534 Inherited::VisitCXXMemberCallExpr(E);
3540 HandleValue(E->
getArg(0),
false);
3544 Inherited::VisitCallExpr(E);
3550 if (isa<UnresolvedLookupExpr>(Callee))
3551 return Inherited::VisitCXXOperatorCallExpr(E);
3555 HandleValue(Arg->IgnoreParenImpCasts(),
false );
3564 if (!FD->getType()->isReferenceType())
3565 DeclsToRemove.push_back(FD);
3568 HandleValue(E->
getLHS(),
false );
3573 Inherited::VisitBinaryOperator(E);
3583 HandleValue(ME->
getBase(),
true );
3588 Inherited::VisitUnaryOperator(E);
3598 static void DiagnoseUninitializedFields(
3615 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
3618 for (
auto *I : RD->
decls()) {
3619 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
3620 UninitializedFields.insert(FD);
3621 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
3622 UninitializedFields.insert(IFD->getAnonField());
3626 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
3627 for (
auto I : RD->
bases())
3628 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
3630 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3633 UninitializedFieldVisitor UninitializedChecker(SemaRef,
3634 UninitializedFields,
3635 UninitializedBaseClasses);
3637 for (
const auto *FieldInit : Constructor->
inits()) {
3638 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3641 Expr *InitExpr = FieldInit->getInit();
3646 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
3647 InitExpr =
Default->getExpr();
3651 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
3652 FieldInit->getAnyMember(),
3653 FieldInit->getBaseClass());
3655 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
3656 FieldInit->getAnyMember(),
3657 FieldInit->getBaseClass());
3669 PushFunctionScope();
3679 PopFunctionScopeInfo(
nullptr, D);
3683 "must set init style when field is created");
3692 if (DiagnoseUnexpandedParameterPack(InitExpr, UPPC_Initializer)) {
3709 Init = Seq.Perform(*
this, Entity, Kind, InitExpr);
3719 Init = ActOnFinishFullExpr(Init.
get(), InitLoc,
false);
3725 InitExpr = Init.
get();
3739 DirectBaseSpec =
nullptr;
3740 for (
const auto &
Base : ClassDecl->
bases()) {
3744 DirectBaseSpec = &
Base;
3752 VirtualBaseSpec =
nullptr;
3753 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
3762 Path != Paths.
end(); ++Path) {
3763 if (Path->back().Base->isVirtual()) {
3764 VirtualBaseSpec = Path->back().Base;
3771 return DirectBaseSpec || VirtualBaseSpec;
3785 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
3786 DS, IdLoc, InitList,
3804 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
3805 DS, IdLoc, List, EllipsisLoc);
3814 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
3815 : ClassDecl(ClassDecl) {}
3817 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
3819 if (
FieldDecl *Member = dyn_cast<FieldDecl>(ND))
3821 return isa<TypeDecl>(ND);
3826 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
3827 return llvm::make_unique<MemInitializerValidatorCCC>(*this);
3846 if ((Member = dyn_cast<FieldDecl>(Result.
front())) ||
3863 ExprResult Res = CorrectDelayedTyposInExpr(Init);
3871 AdjustDeclIfTemplate(ConstructorD);
3897 if (
ValueDecl *Member = tryLookupCtorInitMemberDecl(
3898 ClassDecl, SS, TemplateTypeTy, MemberOrBase)) {
3900 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
3904 return BuildMemberInitializer(Member, Init, IdLoc);
3910 if (TemplateTypeTy) {
3911 BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo);
3920 LookupResult R(*
this, MemberOrBase, IdLoc, LookupOrdinaryName);
3921 LookupParsedName(R, S, &SS);
3930 if (SS.
isSet() && isDependentScopeSpecifier(SS)) {
3931 bool NotUnknownSpecialization =
false;
3933 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
3934 NotUnknownSpecialization = !Record->hasAnyDependentBases();
3936 if (!NotUnknownSpecialization) {
3941 *MemberOrBase, IdLoc);
3961 MemInitializerValidatorCCC CCC(ClassDecl);
3964 CCC, CTK_ErrorRecovery, ClassDecl))) {
3970 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3971 << MemberOrBase <<
true);
3972 return BuildMemberInitializer(Member, Init, IdLoc);
3978 DirectBaseSpec, VirtualBaseSpec)) {
3983 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3984 << MemberOrBase <<
false,
3997 if (!TyD && BaseType.
isNull()) {
3998 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
4006 MarkAnyDeclReferenced(TyD->
getLocation(), TyD,
false);
4022 return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, EllipsisLoc);
4030 assert((DirectMember || IndirectMember) &&
4031 "Member must be a FieldDecl or IndirectFieldDecl");
4033 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4040 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4041 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4042 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
4043 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
4054 DiscardCleanupsInEvaluationContext();
4056 bool InitList =
false;
4057 if (isa<InitListExpr>(Init)) {
4074 ExprResult MemberInit = InitSeq.Perform(*
this, MemberEntity, Kind, Args,
4082 MemberInit = ActOnFinishFullExpr(MemberInit.
get(), InitRange.
getBegin(),
4087 Init = MemberInit.
get();
4105 if (!LangOpts.CPlusPlus11)
4106 return Diag(NameLoc, diag::err_delegating_ctor)
4108 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4110 bool InitList =
true;
4112 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4114 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4125 InitRange.getEnd());
4127 ExprResult DelegationInit = InitSeq.Perform(*
this, DelegationEntity, Kind,
4132 assert(cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor() &&
4133 "Delegating constructor with no target?");
4138 DelegationInit = ActOnFinishFullExpr(
4139 DelegationInit.get(), InitRange.getBegin(),
false);
4140 if (DelegationInit.isInvalid())
4150 if (CurContext->isDependentContext())
4151 DelegationInit = Init;
4154 DelegationInit.getAs<
Expr>(),
4155 InitRange.getEnd());
4166 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4181 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4188 if (DiagnoseUnexpandedParameterPack(BaseLoc, BaseTInfo, UPPC_Initializer))
4191 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4201 return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
4210 if (!DirectBaseSpec && !VirtualBaseSpec) {
4219 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4226 DiscardCleanupsInEvaluationContext();
4231 InitRange.
getEnd(), EllipsisLoc);
4238 if (DirectBaseSpec && VirtualBaseSpec)
4239 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4244 BaseSpec = VirtualBaseSpec;
4247 bool InitList =
true;
4249 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4251 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4261 ExprResult BaseInit = InitSeq.Perform(*
this, BaseEntity, Kind, Args,
nullptr);
4268 BaseInit = ActOnFinishFullExpr(BaseInit.
get(), InitRange.
getBegin(),
4280 if (CurContext->isDependentContext())
4287 InitRange.
getEnd(), EllipsisLoc);
4292 if (T.isNull()) T = E->
getType();
4297 TargetType, ExprLoc);
4317 bool IsInheritedVirtualBase,
4321 IsInheritedVirtualBase);
4325 switch (ImplicitInitKind) {
4331 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
None);
4337 bool Moving = ImplicitInitKind ==
IIK_Move;
4359 BasePath.push_back(BaseSpec);
4361 CK_UncheckedDerivedToBase,
4369 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4392 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
4407 bool Moving = ImplicitInitKind ==
IIK_Move;
4415 Expr *MemberExprBase =
4430 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
4432 MemberLookup.resolveKind();
4466 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
4481 "Unhandled implicit init kind!");
4497 InitSeq.
Perform(SemaRef, InitEntity, InitKind,
None);
4520 diag::err_uninitialized_member_in_ctor)
4530 diag::err_uninitialized_member_in_ctor)
4551 CXXMemberInit =
nullptr;
4556 struct BaseAndFieldInfo {
4559 bool AnyErrorsInInits;
4561 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
4563 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
4566 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
4578 bool isImplicitCopyOrMove()
const {
4589 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
4593 AllToInit.push_back(Init);
4602 bool isInactiveUnionMember(
FieldDecl *Field) {
4612 if (isImplicitCopyOrMove())
4630 bool isWithinInactiveUnionMember(
FieldDecl *Field,
4633 return isInactiveUnionMember(Field);
4635 for (
auto *
C : Indirect->
chain()) {
4637 if (Field && isInactiveUnionMember(Field))
4652 if (!ArrayT->getSize())
4655 T = ArrayT->getElementType();
4670 return Info.addFieldInitializer(Init);
4684 if (Info.isWithinInactiveUnionMember(Field, Indirect))
4705 return Info.addFieldInitializer(Init);
4715 if (Info.AnyErrorsInInits)
4726 return Info.addFieldInitializer(Init);
4744 DelegatingCtorDecls.push_back(Constructor);
4746 DiagnoseUninitializedFields(*
this, Constructor);
4756 if (!Initializers.empty()) {
4760 memcpy(baseOrMemberInitializers, Initializers.data(),
4772 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
4780 bool HadError =
false;
4782 for (
unsigned i = 0;
i < Initializers.size();
i++) {
4791 for (
auto *
C : F->chain()) {
4794 Info.ActiveUnionMember.insert(std::make_pair(
4798 if (FD->getParent()->isUnion())
4799 Info.ActiveUnionMember.insert(std::make_pair(
4800 FD->getParent()->getCanonicalDecl(), FD->getCanonicalDecl()));
4806 llvm::SmallPtrSet<CXXBaseSpecifier *, 16> DirectVBases;
4807 for (
auto &I : ClassDecl->
bases()) {
4809 DirectVBases.insert(&I);
4813 for (
auto &VBase : ClassDecl->
vbases()) {
4815 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
4823 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
4824 << VBase.getType() << ClassDecl;
4825 DiagnoseAbstractType(ClassDecl);
4828 Info.AllToInit.push_back(
Value);
4829 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
4834 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
4837 &VBase, IsInheritedVirtualBase,
4843 Info.AllToInit.push_back(CXXBaseInit);
4850 if (
Base.isVirtual())
4854 = Info.AllBaseFields.lookup(
Base.getType()->getAs<
RecordType>())) {
4855 Info.AllToInit.push_back(
Value);
4856 }
else if (!AnyErrors) {
4865 Info.AllToInit.push_back(CXXBaseInit);
4870 for (
auto *Mem : ClassDecl->
decls()) {
4871 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
4876 if (F->isUnnamedBitfield())
4882 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
4891 if (Info.isImplicitCopyOrMove())
4894 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
4895 if (F->getType()->isIncompleteArrayType()) {
4897 "Incomplete array type is not valid");
4909 unsigned NumInitializers = Info.AllToInit.size();
4910 if (NumInitializers > 0) {
4914 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
4920 MarkBaseAndMemberDestructorsReferenced(Constructor->
getLocation(),
4931 for (
auto *Field : RD->
fields())
4959 bool ShouldCheckOrder =
false;
4960 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4962 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
4964 ShouldCheckOrder =
true;
4968 if (!ShouldCheckOrder)
4979 for (
const auto &VBase : ClassDecl->
vbases())
4983 for (
const auto &
Base : ClassDecl->
bases()) {
4984 if (
Base.isVirtual())
4990 for (
auto *Field : ClassDecl->
fields()) {
4991 if (Field->isUnnamedBitfield())
4997 unsigned NumIdealInits = IdealInitKeys.size();
4998 unsigned IdealIndex = 0;
5001 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5007 for (; IdealIndex != NumIdealInits; ++IdealIndex)
5008 if (InitKey == IdealInitKeys[IdealIndex])
5014 if (IdealIndex == NumIdealInits && PrevInit) {
5017 diag::warn_initializer_out_of_order);
5030 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
5031 if (InitKey == IdealInitKeys[IdealIndex])
5034 assert(IdealIndex < NumIdealInits &&
5035 "initializer not found in initializer list");
5043 bool CheckRedundantInit(
Sema &S,
5053 diag::err_multiple_mem_initialization)
5054 << Field->getDeclName()
5058 assert(BaseClass &&
"neither field nor base");
5060 diag::err_multiple_base_initialization)
5070 typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5071 typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5073 bool CheckRedundantUnionInit(
Sema &S,
5075 RedundantUnionMap &Unions) {
5082 UnionEntry &En = Unions[
Parent];
5083 if (En.first && En.first != Child) {
5085 diag::err_multiple_mem_union_initialization)
5088 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5089 << 0 << En.second->getSourceRange();
5113 if (!ConstructorDecl)
5116 AdjustDeclIfTemplate(ConstructorDecl);
5122 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5129 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5132 RedundantUnionMap MemberUnions;
5134 bool HadError =
false;
5135 for (
unsigned i = 0;
i < MemInits.size();
i++) {
5143 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
5144 CheckRedundantUnionInit(*
this, Init, MemberUnions))
5148 if (CheckRedundantInit(*
this, Init, Members[Key]))
5153 if (MemInits.size() != 1) {
5155 diag::err_delegating_initializer_alone)
5159 SetDelegatingInitializer(Constructor, MemInits[
i]);
5170 SetCtorInitializers(Constructor, AnyErrors, MemInits);
5172 DiagnoseUninitializedFields(*
this, Constructor);
5189 for (
auto *Field : ClassDecl->
fields()) {
5190 if (Field->isInvalidDecl())
5213 assert(Dtor &&
"No dtor found for FieldClassDecl!");
5214 CheckDestructorAccess(Field->getLocation(), Dtor,
5215 PDiag(diag::err_access_dtor_field)
5216 << Field->getDeclName()
5219 MarkFunctionReferenced(Location, Dtor);
5220 DiagnoseUseOfDecl(Dtor, Location);
5225 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5227 llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
5230 for (
const auto &
Base : ClassDecl->
bases()) {
5235 if (
Base.isVirtual()) {
5236 if (!VisitVirtualBases)
5238 DirectVirtualBases.insert(RT);
5249 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5252 CheckDestructorAccess(
Base.getBeginLoc(), Dtor,
5253 PDiag(diag::err_access_dtor_base)
5254 <<
Base.getType() <<
Base.getSourceRange(),
5257 MarkFunctionReferenced(Location, Dtor);
5258 DiagnoseUseOfDecl(Dtor, Location);
5261 if (!VisitVirtualBases)
5265 for (
const auto &VBase : ClassDecl->
vbases()) {
5270 if (DirectVirtualBases.count(RT))
5281 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5282 if (CheckDestructorAccess(
5284 PDiag(diag::err_access_dtor_vbase)
5288 CheckDerivedToBaseConversion(
5290 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5294 MarkFunctionReferenced(Location, Dtor);
5295 DiagnoseUseOfDecl(Dtor, Location);
5304 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5305 SetCtorInitializers(Constructor,
false);
5306 DiagnoseUninitializedFields(*
this, Constructor);
5333 if (!isAbstractType(Loc, T))
5345 if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
5351 if (Diags.isLastDiagnosticIgnored())
5359 llvm::SmallPtrSet<const CXXMethodDecl *, 8> SeenPureMethods;
5361 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5362 MEnd = FinalOverriders.end();
5366 SOEnd = M->second.end();
5367 SO != SOEnd; ++SO) {
5374 if (SO->second.size() != 1)
5377 if (!SO->second.front().Method->isPure())
5380 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5383 Diag(SO->second.front().Method->getLocation(),
5384 diag::note_pure_virtual_function)
5385 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5389 if (!PureVirtualClassDiagSet)
5391 PureVirtualClassDiagSet->insert(RD);
5395 struct AbstractUsageInfo {
5402 : S(S), Record(Record),
5407 void DiagnoseAbstractType() {
5408 if (Invalid)
return;
5416 struct CheckAbstractUsage {
5417 AbstractUsageInfo &Info;
5420 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
5421 : Info(Info), Ctx(Ctx) {}
5425 #define ABSTRACT_TYPELOC(CLASS, PARENT) 5426 #define TYPELOC(CLASS, PARENT) \ 5427 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break; 5428 #include "clang/AST/TypeLocNodes.def" 5434 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
5449 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
5459 #define CheckPolymorphic(Type) \ 5460 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \ 5461 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \ 5476 return Visit(Next, Sel);
5486 T = Info.S.Context.getBaseElementType(T);
5489 if (CT != Info.AbstractType)
return;
5493 Info.S.Diag(Ctx->
getLocation(), diag::err_array_of_abstract_type)
5496 Info.S.Diag(Ctx->
getLocation(), diag::err_abstract_type_in_decl)
5499 Info.DiagnoseAbstractType();
5505 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
5528 for (
auto *D : RD->
decls()) {
5529 if (D->isImplicit())
continue;
5532 if (isa<CXXMethodDecl>(D)) {
5534 }
else if (isa<FunctionTemplateDecl>(D)) {
5535 FunctionDecl *FD = cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
5539 }
else if (isa<FieldDecl>(D)) {
5543 }
else if (isa<VarDecl>(D)) {
5544 VarDecl *VD = cast<VarDecl>(D);
5549 }
else if (isa<CXXRecordDecl>(D)) {
5551 }
else if (isa<ClassTemplateDecl>(D)) {
5553 cast<ClassTemplateDecl>(D)->getTemplatedDecl());
5563 assert(ClassAttr->
getKind() == attr::DLLExport);
5575 for (Decl *Member : Class->
decls()) {
5578 auto *VD = dyn_cast<
VarDecl>(Member);
5579 if (VD && Member->getAttr<DLLExportAttr>() &&
5588 if (Member->getAttr<DLLExportAttr>()) {
5589 if (MD->isUserProvided()) {
5600 }
else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
5601 MD->isCopyAssignmentOperator() ||
5602 MD->isMoveAssignmentOperator()) {
5631 for (Decl *Member : Class->
decls()) {
5634 if (!CD || !CD->isDefaultConstructor())
5636 auto *
Attr = CD->getAttr<DLLExportAttr>();
5649 if (LastExportedDefaultCtor) {
5651 diag::err_attribute_dll_ambiguous_default_ctor)
5653 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
5654 << CD->getDeclName();
5657 LastExportedDefaultCtor = CD;
5663 for (
auto *Method : Class->
methods()) {
5664 if (Method->isUserProvided())
5666 if (
Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method,
true))
5677 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
5678 if (
Attr *TemplateAttr =
5679 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
5680 auto *A = cast<InheritableAttr>(TemplateAttr->clone(getASTContext()));
5681 A->setInherited(
true);
5692 << Class << ClassAttr;
5699 for (Decl *Member : Class->
decls()) {
5700 if (!isa<VarDecl>(Member) && !isa<CXXMethodDecl>(Member))
5703 if (!MemberAttr || MemberAttr->
isInherited() || Member->isInvalidDecl())
5707 diag::err_attribute_dll_member_of_dll_class)
5708 << MemberAttr << ClassAttr;
5710 Member->setInvalidDecl();
5719 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
5724 const bool PropagatedImport =
5726 cast<DLLImportAttr>(ClassAttr)->wasPropagatedToBaseTemplate();
5740 ForceDeclarationOfImplicitMembers(Class);
5745 for (Decl *Member : Class->
decls()) {
5755 if (MD->isDeleted())
5758 if (MD->isInlined()) {
5771 if ((MD->isMoveAssignmentOperator() ||
5772 (Ctor && Ctor->isMoveConstructor())) &&
5779 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->isTrivial())
5786 if (VD && PropagatedImport)
5789 if (!cast<NamedDecl>(Member)->isExternallyVisible())
5797 if (!getLangOpts().DllExportInlines && MD && MD->isInlined() &&
5800 if (ClassExported) {
5801 NewAttr = ::new (getASTContext())
5802 DLLExportStaticLocalAttr(ClassAttr->
getRange(),
5806 NewAttr = ::new (getASTContext())
5807 DLLImportStaticLocalAttr(ClassAttr->
getRange(),
5812 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5816 Member->addAttr(NewAttr);
5826 "friend re-decl should not already have a DLLAttr");
5827 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5829 FD->addAttr(NewAttr);
5836 DelayedDllExportClasses.push_back(Class);
5857 auto *NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5858 NewAttr->setInherited(
true);
5859 BaseTemplateSpec->
addAttr(NewAttr);
5863 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
5864 ImportAttr->setPropagatedToBaseTemplate();
5870 checkClassLevelDLLAttribute(BaseTemplateSpec);
5885 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
5890 diag::note_template_class_explicit_specialization_was_here)
5891 << BaseTemplateSpec;
5894 diag::note_template_class_instantiation_was_here)
5895 << BaseTemplateSpec;
5904 cast<CXXConstructorDecl>(MD));
5922 llvm_unreachable(
"Invalid special member.");
5940 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
5941 bool DtorIsTrivialForCall =
false;
5952 CopyCtorIsTrivial =
true;
5954 CopyCtorIsTrivialForCall =
true;
5958 if (CD->isCopyConstructor() && !CD->isDeleted()) {
5959 if (CD->isTrivial())
5960 CopyCtorIsTrivial =
true;
5961 if (CD->isTrivialForCall())
5962 CopyCtorIsTrivialForCall =
true;
5970 DtorIsTrivialForCall =
true;
5972 if (!DD->isDeleted() && DD->isTrivialForCall())
5973 DtorIsTrivialForCall =
true;
5977 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
5991 uint64_t TypeSize = isAArch64 ? 128 : 64;
5993 if (CopyCtorIsTrivial &&
6003 bool HasNonDeletedCopyOrMove =
false;
6009 HasNonDeletedCopyOrMove =
true;
6016 HasNonDeletedCopyOrMove =
true;
6024 if (MD->isDeleted())
6028 if (CD && CD->isCopyOrMoveConstructor())
6029 HasNonDeletedCopyOrMove =
true;
6030 else if (!isa<CXXDestructorDecl>(MD))
6033 if (!MD->isTrivialForCall())
6037 return HasNonDeletedCopyOrMove;
6048 AbstractUsageInfo Info(*
this, Record);
6058 bool Complained =
false;
6059 for (
const auto *F : Record->
fields()) {
6060 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
6063 if (F->getType()->isReferenceType() ||
6064 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
6071 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
6072 << F->getType()->isReferenceType()
6073 << F->getDeclName();
6091 if (((isa<FieldDecl>(D) || isa<UnresolvedUsingValueDecl>(D)) &&
6093 isa<IndirectFieldDecl>(D)) {
6094 Diag((*I)->getLocation(), diag::err_member_name_of_class)
6105 !Record->
hasAttr<FinalAttr>())
6107 diag::warn_non_virtual_dtor) << Context.
getRecordType(Record);
6111 if (FinalAttr *FA = Record->
getAttr<FinalAttr>()) {
6113 << FA->isSpelledAsSealed();
6114 DiagnoseAbstractType(Record);
6119 if (Record->
hasAttr<TrivialABIAttr>())
6120 checkIllFormedTrivialABIStruct(*Record);
6124 bool HasTrivialABI = Record->
hasAttr<TrivialABIAttr>();
6131 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted())
6132 CheckExplicitlyDefaultedSpecialMember(M);
6137 if (!M->isImplicit() && !M->isUserProvided()) {
6138 if (CSM != CXXInvalid) {
6139 M->setTrivial(SpecialMemberIsTrivial(M, CSM));
6142 M->setTrivialForCall(
6144 SpecialMemberIsTrivial(M, CSM, TAH_ConsiderTrivialABI));
6151 if ((CSM == CXXCopyConstructor || CSM == CXXMoveConstructor ||
6152 CSM == CXXDestructor) && M->isUserProvided()) {
6153 M->setTrivialForCall(HasTrivialABI);
6157 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
6158 M->hasAttr<DLLExportAttr>()) {
6161 (CSM == CXXDefaultConstructor || CSM == CXXCopyConstructor ||
6162 CSM == CXXDestructor))
6163 M->dropAttr<DLLExportAttr>();
6165 if (M->hasAttr<DLLExportAttr>()) {
6167 DelayedDllExportMemberFunctions.push_back(M);
6172 bool HasMethodWithOverrideControl =
false,
6173 HasOverridingMethodWithoutOverrideControl =
false;
6181 CompleteMemberFunction(Dtor);
6183 for (
auto *M : Record->
methods()) {
6187 DiagnoseHiddenVirtualMethods(M);
6188 if (M->hasAttr<OverrideAttr>())
6189 HasMethodWithOverrideControl =
true;
6190 else if (M->size_overridden_methods() > 0)
6191 HasOverridingMethodWithoutOverrideControl =
true;
6193 if (!isa<CXXDestructorDecl>(M))
6194 CompleteMemberFunction(M);
6198 if (HasMethodWithOverrideControl &&
6199 HasOverridingMethodWithoutOverrideControl) {
6202 for (
auto *M : Record->
methods())
6203 DiagnoseAbsenceOfOverrideControl(M);
6220 checkClassLevelDLLAttribute(Record);
6221 checkClassLevelCodeSegAttribute(Record);
6223 bool ClangABICompat4 =
6245 if (getLangOpts().ForceEmitVTables) {
6263 unsigned FieldQuals,
bool ConstRHS) {
6264 unsigned LHSQuals = 0;
6266 LHSQuals = FieldQuals;
6268 unsigned RHSQuals = FieldQuals;
6278 LHSQuals & Qualifiers::Const,
6279 LHSQuals & Qualifiers::Volatile);
6289 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
6295 : S(S), UseLoc(UseLoc) {
6296 bool DiagnosedMultipleConstructedBases =
false;
6298 UsingDecl *ConstructedBaseUsing =
nullptr;
6302 for (
auto *D : Shadow->
redecls()) {
6303 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
6304 auto *DNominatedBase = DShadow->getNominatedBaseClass();
6305 auto *DConstructedBase = DShadow->getConstructedBaseClass();
6307 InheritedFromBases.insert(
6308 std::make_pair(DNominatedBase->getCanonicalDecl(),
6309 DShadow->getNominatedBaseClassShadowDecl()));
6310 if (DShadow->constructsVirtualBase())
6311 InheritedFromBases.insert(
6312 std::make_pair(DConstructedBase->getCanonicalDecl(),
6313 DShadow->getConstructedBaseClassShadowDecl()));
6315 assert(DNominatedBase == DConstructedBase);
6320 if (!ConstructedBase) {
6321 ConstructedBase = DConstructedBase;
6322 ConstructedBaseUsing = D->getUsingDecl();
6323 }
else if (ConstructedBase != DConstructedBase &&
6325 if (!DiagnosedMultipleConstructedBases) {
6326 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
6329 diag::note_ambiguous_inherited_constructor_using)
6331 DiagnosedMultipleConstructedBases =
true;
6333 S.
Diag(D->getUsingDecl()->getLocation(),
6334 diag::note_ambiguous_inherited_constructor_using)
6335 << DConstructedBase;
6339 if (DiagnosedMultipleConstructedBases)
6346 std::pair<CXXConstructorDecl *, bool>
6349 if (It == InheritedFromBases.end())
6350 return std::make_pair(
nullptr,
false);
6354 return std::make_pair(
6356 It->second->constructsVirtualBase());
6359 return std::make_pair(Ctor,
false);
6373 if (InheritedCtor) {
6376 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
6378 return BaseCtor->isConstexpr();
6442 if (Ctor && ClassDecl->
isUnion())
6461 for (
const auto &B : ClassDecl->
bases()) {
6463 if (!BaseType)
continue;
6467 InheritedCtor, Inherited))
6478 for (
const auto *F : ClassDecl->
fields()) {
6479 if (F->isInvalidDecl())
6485 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
6488 ConstArg && !F->isMutable()))
6510 auto *CD = cast<CXXConstructorDecl>(MD);
6511 assert(CD->getInheritedConstructor() &&
6512 "only special members have implicit exception specs");
6514 S, Loc, CD->getInheritedConstructor().getShadowDecl());
6541 auto ESI = IES.getExceptionSpec();
6544 UpdateExceptionSpec(MD, ESI);
6560 "not an explicitly-defaulted special member");
6566 bool HadError =
false;
6578 bool DeleteOnTypeMismatch = getLangOpts().CPlusPlus2a &&
First;
6579 bool ShouldDeleteForTypeMismatch =
false;
6580 unsigned ExpectedParams = 1;
6581 if (CSM == CXXDefaultConstructor || CSM == CXXDestructor)
6591 if (DeleteOnTypeMismatch)
6592 ShouldDeleteForTypeMismatch =
true;
6602 bool CanHaveConstParam =
false;
6603 if (CSM == CXXCopyConstructor)
6605 else if (CSM == CXXCopyAssignment)
6609 if (CSM == CXXCopyAssignment || CSM == CXXMoveAssignment) {
6617 if (!Context.
hasSameType(ReturnType, ExpectedReturnType)) {
6618 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
6619 << (CSM == CXXMoveAssignment) << ExpectedReturnType;
6625 if (DeleteOnTypeMismatch)
6626 ShouldDeleteForTypeMismatch =
true;
6629 << (CSM == CXXMoveAssignment) << getLangOpts().CPlusPlus14;
6637 bool HasConstParam =
false;
6644 if (DeleteOnTypeMismatch)
6645 ShouldDeleteForTypeMismatch =
true;
6648 diag::err_defaulted_special_member_volatile_param) << CSM;
6653 if (HasConstParam && !CanHaveConstParam) {
6654 if (DeleteOnTypeMismatch)
6655 ShouldDeleteForTypeMismatch =
true;
6656 else if (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment) {
6658 diag::err_defaulted_special_member_copy_const_param)
6659 << (CSM == CXXCopyAssignment);
6664 diag::err_defaulted_special_member_move_const_param)
6665 << (CSM == CXXMoveAssignment);
6669 }
else if (ExpectedParams) {
6672 assert(CSM == CXXCopyAssignment &&
"unexpected non-ref argument");
6688 if ((getLangOpts().
CPlusPlus14 ? !isa<CXXDestructorDecl>(MD)
6689 : isa<CXXConstructorDecl>(MD)) &&
6693 ? diag::err_incorrect_defaulted_consteval
6694 : diag::err_incorrect_defaulted_constexpr)
6716 llvm::makeArrayRef(&ArgType,
6722 if (ShouldDeleteForTypeMismatch || ShouldDeleteSpecialMember(MD, CSM)) {
6725 if (!inTemplateInstantiation() && !HadError) {
6727 if (ShouldDeleteForTypeMismatch) {
6730 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
6733 if (ShouldDeleteForTypeMismatch && !HadError) {
6735 diag::warn_cxx17_compat_defaulted_method_type_mismatch) << CSM;
6741 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
6742 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
6743 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
6753 decltype(DelayedOverridingExceptionSpecChecks) Overriding;
6754 decltype(DelayedEquivalentExceptionSpecChecks)
Equivalent;
6756 std::swap(Overriding, DelayedOverridingExceptionSpecChecks);
6757 std::swap(
Equivalent, DelayedEquivalentExceptionSpecChecks);
6761 for (
auto &Check : Overriding)
6762 CheckOverridingFunctionExceptionSpec(Check.first, Check.second);
6767 CheckEquivalentExceptionSpec(Check.second, Check.first);
6773 template<
typename Derived>
6774 struct SpecialMemberVisitor {
6781 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
6785 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
6790 IsConstructor =
true;
6794 IsAssignment =
true;
6799 llvm_unreachable(
"invalid special member kind");
6805 ConstArg = RT->getPointeeType().isConstQualified();
6809 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
6812 bool isMove()
const {
6818 unsigned Quals,
bool IsMutable) {
6820 ConstArg && !IsMutable);
6830 cast<CXXConstructorDecl>(MD)->getInheritedConstructor().getConstructor();
6837 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
6844 return B->getBaseTypeLoc();
6846 return Subobj.get<
FieldDecl*>()->getLocation();
6851 VisitNonVirtualBases,
6856 VisitPotentiallyConstructedBases,
6862 bool visit(BasesToVisit Bases) {
6865 if (Bases == VisitPotentiallyConstructedBases)
6866 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
6868 for (
auto &B : RD->
bases())
6869 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
6870 getDerived().visitBase(&B))
6873 if (Bases == VisitAllBases)
6874 for (
auto &B : RD->
vbases())
6875 if (getDerived().visitBase(&B))
6878 for (
auto *F : RD->
fields())
6879 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
6880 getDerived().visitField(F))
6889 struct SpecialMemberDeletionInfo
6890 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
6895 bool AllFieldsAreConst;
6900 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
6901 Loc(MD->
getLocation()), AllFieldsAreConst(
true) {}
6912 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
6915 bool shouldDeleteForField(
FieldDecl *FD);
6916 bool shouldDeleteForAllConstMembers();
6918 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
6920 bool shouldDeleteForSubobjectCall(Subobject Subobj,
6922 bool IsDtorCallInCtor);
6930 bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
6950 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
6952 bool IsDtorCallInCtor) {
6959 DiagKind = !Decl ? 0 : 1;
6962 else if (!isAccessible(Subobj, Decl))
6980 diag::note_deleted_special_member_class_subobject)
6981 << getEffectiveCSM() << MD->
getParent() <<
true 6982 << Field << DiagKind << IsDtorCallInCtor <<
false;
6986 diag::note_deleted_special_member_class_subobject)
6987 << getEffectiveCSM() << MD->
getParent() <<
false 6988 << Base->
getType() << DiagKind << IsDtorCallInCtor
7002 bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
7005 bool IsMutable = Field && Field->
isMutable();
7023 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
7030 if (IsConstructor) {
7033 false,
false,
false,
false,
false);
7034 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
7041 bool SpecialMemberDeletionInfo::shouldDeleteForVariantObjCPtrMember(
7055 auto *ParentClass = cast<CXXRecordDecl>(FD->
getParent());
7057 diag::note_deleted_special_member_class_subobject)
7058 << getEffectiveCSM() << ParentClass <<
true 7059 << FD << 4 <<
false <<
true;
7076 if (
auto *BaseCtor = SMOR.
getMethod()) {
7081 if (BaseCtor->isDeleted() && Diagnose) {
7083 diag::note_deleted_special_member_class_subobject)
7084 << getEffectiveCSM() << MD->
getParent() <<
false 7085 << Base->
getType() << 1 <<
false 7089 return BaseCtor->isDeleted();
7091 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
7096 bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
7100 if (inUnion() && shouldDeleteForVariantObjCPtrMember(FD, FieldType))
7108 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
7109 << !!ICI << MD->
getParent() << FD << FieldType << 0;
7120 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
7126 AllFieldsAreConst =
false;
7132 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
7136 }
else if (IsAssignment) {
7141 << isMove() << MD->
getParent() << FD << FieldType << 0;
7156 if (!inUnion() && FieldRecord->
isUnion() &&
7158 bool AllVariantFieldsAreConst =
true;
7161 for (
auto *UI : FieldRecord->
fields()) {
7164 if (shouldDeleteForVariantObjCPtrMember(&*UI, UnionFieldType))
7168 AllVariantFieldsAreConst =
false;
7171 if (UnionFieldRecord &&
7172 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
7182 diag::note_deleted_default_ctor_all_const)
7192 if (shouldDeleteForClassSubobject(FieldRecord, FD,
7203 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
7207 bool AnyFields =
false;
7209 if ((AnyFields = !F->isUnnamedBitfield()))
7215 diag::note_deleted_default_ctor_all_const)
7241 (CSM == CXXDefaultConstructor || CSM == CXXCopyAssignment)) {
7250 if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
7259 (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
7265 bool DeletesOnlyMatchingCopy =
7266 getLangOpts().MSVCCompat &&
7270 (!DeletesOnlyMatchingCopy || CSM == CXXCopyConstructor)) {
7271 if (!Diagnose)
return true;
7274 for (
auto *I : RD->
ctors()) {
7275 if (I->isMoveConstructor()) {
7276 UserDeclaredMove = I;
7280 assert(UserDeclaredMove);
7282 (!DeletesOnlyMatchingCopy || CSM == CXXCopyAssignment)) {
7283 if (!Diagnose)
return true;
7286 for (
auto *I : RD->
methods()) {
7287 if (I->isMoveAssignmentOperator()) {
7288 UserDeclaredMove = I;
7292 assert(UserDeclaredMove);
7295 if (UserDeclaredMove) {
7297 diag::note_deleted_copy_user_declared_move)
7298 << (CSM == CXXCopyAssignment) << RD
7310 if (CSM == CXXDestructor && MD->
isVirtual()) {
7315 OperatorDelete,
false)) {
7322 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
7330 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
7331 : SMI.VisitPotentiallyConstructedBases))
7334 if (SMI.shouldDeleteForAllConstMembers())
7337 if (getLangOpts().CUDA) {
7344 assert(ICI || CSM == getSpecialMember(MD));
7347 RealCSM = getSpecialMember(MD);
7349 return inferCUDATargetForImplicitSpecialMember(RD, RealCSM, MD,
7350 SMI.ConstArg, Diagnose);
7373 *Selected =
nullptr;
7377 llvm_unreachable(
"not a special member");
7395 for (
auto *CI : RD->
ctors()) {
7396 if (!CI->isDefaultConstructor())
7403 *Selected = DefCtor;
7436 }
else if (!Selected) {
7444 goto NeedOverloadResolution;
7454 }
else if (!Selected) {
7459 goto NeedOverloadResolution;
7463 NeedOverloadResolution:
7491 llvm_unreachable(
"unknown special method kind");
7495 for (
auto *CI : RD->
ctors())
7496 if (!CI->isImplicit())
7500 typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
7503 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
7533 ConstRHS, TAH, Diagnose ? &Selected :
nullptr))
7541 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
7544 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
7545 }
else if (!Selected)
7546 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
7551 << Kind << SubType.getUnqualifiedType() << CSM;
7553 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
7554 << Kind << SubType.getUnqualifiedType() << CSM;
7559 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
7560 << Kind << SubType.getUnqualifiedType() << CSM;
7578 for (
const auto *FI : RD->
fields()) {
7579 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
7585 if (FI->isAnonymousStructOrUnion()) {
7587 CSM, ConstArg, TAH, Diagnose))
7598 S.
Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI;
7608 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
7613 bool ConstRHS = ConstArg && !FI->isMutable();
7627 bool ConstArg = (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment);
7638 assert(!MD->
isUserProvided() && CSM != CXXInvalid &&
"not special enough");
7642 bool ConstArg =
false;
7648 case CXXDefaultConstructor:
7653 case CXXCopyConstructor:
7654 case CXXCopyAssignment: {
7670 case CXXMoveConstructor:
7671 case CXXMoveAssignment: {
7687 llvm_unreachable(
"not a special member");
7693 diag::note_nontrivial_default_arg)
7712 for (
const auto &BI : RD->bases())
7735 if (CSM == CXXDestructor && MD->
isVirtual()) {
7748 if (RD->getNumVBases()) {
7758 for (
const auto *MI : RD->methods()) {
7759 if (MI->isVirtual()) {
7761 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
7766 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
7774 struct FindHiddenVirtualMethod {
7777 llvm::SmallPtrSet<const CXXMethodDecl *, 8> OverridenAndUsingBaseMethods;
7782 static bool CheckMostOverridenMethods(
7784 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
7788 if (CheckMostOverridenMethods(O, Methods))
7804 bool foundSameNameMethod =
false;
7811 foundSameNameMethod =
true;
7828 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
7829 overloadedMethods.push_back(MD);
7833 if (foundSameNameMethod)
7834 OverloadedMethods.append(overloadedMethods.begin(),
7835 overloadedMethods.end());
7836 return foundSameNameMethod;
7843 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
7861 FindHiddenVirtualMethod FHVM;
7872 ND = shad->getTargetDecl();
7878 OverloadedMethods = FHVM.OverloadedMethods;
7883 for (
unsigned i = 0, e = OverloadedMethods.size();
i != e; ++
i) {
7886 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
7887 HandleFunctionTypeMismatch(PD, MD->
getType(), overloadedMD->
getType());
7898 if (Diags.isIgnored(diag::warn_overloaded_virtual, MD->
getLocation()))
7902 FindHiddenVirtualMethods(MD, OverloadedMethods);
7903 if (!OverloadedMethods.empty()) {
7905 << MD << (OverloadedMethods.size() > 1);
7907 NoteHiddenVirtualMethods(MD, OverloadedMethods);
7912 auto PrintDiagAndRemoveAttr = [&]() {
7916 diag::ext_cannot_use_trivial_abi) << &RD;
7922 PrintDiagAndRemoveAttr();
7926 for (
const auto &B : RD.
bases()) {
7929 if ((!B.getType()->isDependentType() &&
7930 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) ||
7932 PrintDiagAndRemoveAttr();
7937 for (
const auto *FD : RD.
fields()) {
7942 PrintDiagAndRemoveAttr();
7947 if (!RT->isDependentType() &&
7949 PrintDiagAndRemoveAttr();
7961 AdjustDeclIfTemplate(TagDecl);
7964 if (AL.getKind() != ParsedAttr::AT_Visibility)
7967 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored)
7971 ActOnFields(S, RLoc, TagDecl, llvm::makeArrayRef(
7973 reinterpret_cast<Decl**>(FieldCollector->getCurFields()),
7974 FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList);
7976 CheckCompletedCXXClass(cast<CXXRecordDecl>(TagDecl));
7986 ++getASTContext().NumImplicitDefaultConstructors;
7989 DeclareImplicitDefaultConstructor(ClassDecl);
7993 ++getASTContext().NumImplicitCopyConstructors;
8000 DeclareImplicitCopyConstructor(ClassDecl);
8011 DeclareImplicitCopyConstructor(ClassDecl);
8015 ++getASTContext().NumImplicitMoveConstructors;
8019 DeclareImplicitMoveConstructor(ClassDecl);
8023 ++getASTContext().NumImplicitCopyAssignmentOperators;
8032 DeclareImplicitCopyAssignment(ClassDecl);
8036 ++getASTContext().NumImplicitMoveAssignmentOperators;
8042 DeclareImplicitMoveAssignment(ClassDecl);
8046 ++getASTContext().NumImplicitDestructors;
8054 DeclareImplicitDestructor(ClassDecl);
8067 D = TD->getTemplatedDecl();
8069 if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
8070 ParameterLists.push_back(PSD->getTemplateParameters());
8073 for (
unsigned i = 0;
i < DD->getNumTemplateParameterLists(); ++
i)
8074 ParameterLists.push_back(DD->getTemplateParameterList(
i));
8078 ParameterLists.push_back(FTD->getTemplateParameters());
8082 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
8083 for (
unsigned i = 0;
i < TD->getNumTemplateParameterLists(); ++
i)
8084 ParameterLists.push_back(TD->getTemplateParameterList(
i));
8088 ParameterLists.push_back(CTD->getTemplateParameters());
8094 if (Params->size() > 0)
8099 if (Param->getDeclName()) {
8101 IdResolver.AddDecl(Param);
8110 if (!RecordD)
return;
8111 AdjustDeclIfTemplate(RecordD);
8113 PushDeclContext(S, Record);
8117 if (!RecordD)
return;
8130 IdResolver.AddDecl(Param);
8162 IdResolver.AddDecl(Param);
8175 AdjustDeclIfTemplate(MethodD);
8184 CheckConstructor(Constructor);
8188 CheckCXXDefaultArguments(Method);
8196 bool DiagOccured =
false;
8198 [DiagID, &S, &DiagOccured](
DeclSpec::TQ, StringRef QualName,
8244 diagnoseIgnoredQualifiers(
8302 const char *ConstRef
8305 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
8331 FindDeallocationFunctionForDestructor(Loc, RD)) {
8332 Expr *ThisArg =
nullptr;
8337 if (OperatorDelete->isDestroyingOperatorDelete()) {
8338 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
8345 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
8346 assert(!This.
isInvalid() &&
"couldn't form 'this' expr in dtor?");
8347 This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
8348 if (This.isInvalid()) {
8351 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
8354 ThisArg = This.get();
8358 DiagnoseUseOfDecl(OperatorDelete, Loc);
8359 MarkFunctionReferenced(Loc, OperatorDelete);
8383 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
8386 if (TST->isTypeAlias())
8388 << DeclaratorType << 1;
8421 diagnoseIgnoredQualifiers(diag::err_destructor_return_type, TypeQuals,
8556 bool NeedsTypedef =
false;
8560 bool PastFunctionChunk =
false;
8562 switch (Chunk.Kind) {
8564 if (!PastFunctionChunk) {
8565 if (Chunk.Fun.HasTrailingReturnType) {
8567 GetTypeFromParser(Chunk.Fun.getTrailingReturnType(), &TRT);
8570 PastFunctionChunk =
true;
8575 NeedsTypedef =
true;
8597 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
8598 DB << Before <<
After;
8600 if (!NeedsTypedef) {
8604 if (After.isInvalid() && ConvTSI) {
8649 if (DS.hasExplicitSpecifier() && !getLangOpts().CPlusPlus2a)
8650 Diag(DS.getExplicitSpecLoc(),
8651 getLangOpts().CPlusPlus11
8652 ? diag::warn_cxx98_compat_explicit_conversion_functions
8653 : diag::ext_explicit_conversion_functions)
8662 assert(Conversion &&
"Expected to receive a conversion function declaration");
8680 ConvType = ConvTypeRef->getPointeeType();
8684 else if (ConvType->isRecordType()) {
8686 if (ConvType == ClassType)
8689 else if (IsDerivedFrom(Conversion->
getLocation(), ClassType, ConvType))
8691 << ClassType << ConvType;
8692 }
else if (ConvType->isVoidType()) {
8694 << ClassType << ConvType;
8699 return ConversionTemplate;
8707 struct BadSpecifierDiagnoser {
8710 ~BadSpecifierDiagnoser() {
8714 template<
typename T>
void check(
SourceLocation SpecLoc, T Spec) {
8718 return check(SpecLoc,
8724 if (!Specifiers.empty()) Specifiers +=
" ";
8730 std::string Specifiers;
8742 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
8747 if (!CurContext->getRedeclContext()->Equals(
8750 << GuidedTemplateDecl;
8751 Diag(GuidedTemplateDecl->
getLocation(), diag::note_template_decl_here);
8756 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
8757 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
8758 DS.isNoreturnSpecified() || DS.hasConstexprSpecifier()) {
8759 BadSpecifierDiagnoser Diagnoser(
8761 diag::err_deduction_guide_invalid_specifier);
8763 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
8768 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
8769 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
8770 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
8771 DS.ClearConstexprSpec();
8773 Diagnoser.check(DS.getConstSpecLoc(),
"const");
8774 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
8775 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
8776 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
8777 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
8778 DS.ClearTypeQualifiers();
8780 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
8781 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
8782 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
8783 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
8784 DS.ClearTypeSpecType();
8791 bool FoundFunction =
false;
8797 diag::err_deduction_guide_with_complex_decl)
8801 if (!Chunk.Fun.hasTrailingReturnType()) {
8803 diag::err_deduction_guide_no_trailing_return_type);
8809 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
8811 QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
8812 assert(TSI &&
"deduction guide has valid type but invalid return type?");
8813 bool AcceptableReturnType =
false;
8814 bool MightInstantiateToSpecialization =
false;
8817 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
8818 bool TemplateMatches =
8821 AcceptableReturnType =
true;
8826 MightInstantiateToSpecialization = !(TD && isa<ClassTemplateDecl>(TD) &&
8830 MightInstantiateToSpecialization =
true;
8833 if (!AcceptableReturnType) {
8835 diag::err_deduction_guide_bad_trailing_return_type)
8836 << GuidedTemplate << TSI->
getType()
8837 << MightInstantiateToSpecialization
8843 FoundFunction =
true;
8860 assert(*IsInline != PrevNS->
isInline());
8868 if (*IsInline && II && II->
getName().startswith(
"__atomic") &&
8873 NS->setInline(*IsInline);
8876 for (
auto *I : PrevNS->
decls())
8877 if (
auto *ND = dyn_cast<NamedDecl>(I))
8885 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
8888 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
8903 bool IsInline = InlineLoc.
isValid();
8904 bool IsInvalid =
false;
8906 bool AddToKnown =
false;
8922 LookupResult R(*
this, II, IdentLoc, LookupOrdinaryName,
8923 ForExternalRedeclaration);
8924 LookupQualifiedName(R, CurContext->getRedeclContext());
8927 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
8931 if (IsInline != PrevNS->
isInline())
8934 }
else if (PrevDecl) {
8936 Diag(Loc, diag::err_redefinition_different_kind)
8938 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
8941 }
else if (II->
isStr(
"std") &&
8942 CurContext->getRedeclContext()->isTranslationUnit()) {
8945 PrevNS = getStdNamespace();
8947 AddToKnown = !IsInline;
8950 AddToKnown = !IsInline;
8964 if (PrevNS && IsInline != PrevNS->
isInline())
8970 StartLoc, Loc, II, PrevNS);
8974 ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
8975 AddPragmaAttributes(DeclRegionScope, Namespc);
8978 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
8979 PushNamespaceVisibilityAttr(
Attr, Loc);
8982 StdNamespace = Namespc;
8984 KnownNamespaces[Namespc] =
false;
8987 PushOnScopeChains(Namespc, DeclRegionScope);
8992 TU->setAnonymousNamespace(Namespc);
8994 cast<NamespaceDecl>(
Parent)->setAnonymousNamespace(Namespc);
8997 CurContext->addDecl(Namespc);
9028 ActOnDocumentableDecl(Namespc);
9035 PushDeclContext(NamespcScope, Namespc);
9043 return AD->getNamespace();
9044 return dyn_cast_or_null<NamespaceDecl>(D);
9050 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
9051 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
9054 if (Namespc->
hasAttr<VisibilityAttr>())
9055 PopPragmaVisibility(
true, RBrace);
9057 if (DeferredExportedNamespaces.erase(Namespc))
9062 return cast_or_null<CXXRecordDecl>(
9071 return cast_or_null<NamespaceDecl>(
9076 if (!StdExperimentalNamespaceCache) {
9077 if (
auto Std = getStdNamespace()) {
9080 if (!LookupQualifiedName(
Result,
Std) ||
9081 !(StdExperimentalNamespaceCache =
9083 Result.suppressDiagnostics();
9086 return StdExperimentalNamespaceCache;
9098 struct InvalidSTLDiagnoser {
9104 const VarDecl *VD =
nullptr) {
9106 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
9107 << TyForDiags << ((int)Sel);
9108 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
9109 assert(!Name.empty());
9113 if (Sel == USS_InvalidMember) {
9114 S.
Diag(VD->getLocation(), diag::note_var_declared_here)
9115 << VD << VD->getSourceRange();
9125 "Looking for comparison category type outside of C++.");
9130 if (Info && FullyCheckedComparisonCategories[static_cast<unsigned>(Kind)])
9135 std::string NameForDiags =
"std::";
9137 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
9142 assert(Info->
Kind == Kind);
9158 if (RequireCompleteType(Loc, TyForDiags, diag::err_incomplete_type))
9161 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags};
9164 return UnsupportedSTLError(USS_NonTrivial);
9172 return UnsupportedSTLError();
9181 !FIt->getType()->isIntegralOrEnumerationType()) {
9182 return UnsupportedSTLError();
9192 return UnsupportedSTLError(USS_MissingMember, MemName);
9195 assert(VD &&
"should not be null!");
9202 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
9208 return UnsupportedSTLError();
9210 MarkVariableReferenced(Loc, VD);
9215 FullyCheckedComparisonCategories[
static_cast<unsigned>(
Kind)] =
true;
9222 if (!StdNamespace) {
9228 &PP.getIdentifierTable().get(
"std"),
9233 return getStdNamespace();
9238 "Looking for std::initializer_list outside of C++.");
9253 if (!Specialization)
9260 Template = dyn_cast_or_null<ClassTemplateDecl>(
9261 TST->getTemplateName().getAsTemplateDecl());
9262 Arguments = TST->getArgs();
9267 if (!StdInitializerList) {
9271 &PP.getIdentifierTable().get(
"initializer_list") ||
9272 !getStdNamespace()->InEnclosingNamespaceSetOf(
9280 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
9284 StdInitializerList = Template;
9299 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
9306 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
9311 Result.suppressDiagnostics();
9314 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
9322 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
9323 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
9331 if (!StdInitializerList) {
9333 if (!StdInitializerList)
9342 CheckTemplateIdType(
TemplateName(StdInitializerList), Loc, Args));
9359 return isStdInitializerList(ArgType,
nullptr);
9366 case Decl::TranslationUnit:
9368 case Decl::LinkageSpec:
9380 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
9382 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
9386 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
9387 return llvm::make_unique<NamespaceValidatorCCC>(*this);
9398 NamespaceValidatorCCC CCC{};
9403 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
9404 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
9405 Ident->
getName().equals(CorrectedStr);
9407 S.
PDiag(diag::err_using_directive_member_suggest)
9408 << Ident << DC << DroppedSpecifier << SS.getRange(),
9409 S.
PDiag(diag::note_namespace_defined_here));
9412 S.
PDiag(diag::err_using_directive_suggest) << Ident,
9413 S.
PDiag(diag::note_namespace_defined_here));
9415 R.
addDecl(Corrected.getFoundDecl());
9426 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9427 assert(NamespcName &&
"Invalid NamespcName.");
9428 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
9441 LookupResult R(*
this, NamespcName, IdentLoc, LookupNamespaceName);
9442 LookupParsedName(R, S, &SS);
9451 NamespcName->
isStr(
"std")) {
9452 Diag(IdentLoc, diag::ext_using_undefined_std);
9453 R.
addDecl(getOrCreateStdNamespace());
9463 assert(NS &&
"expected namespace decl");
9466 DiagnoseUseOfDecl(Named, IdentLoc);
9481 while (CommonAncestor && !CommonAncestor->
Encloses(CurContext))
9482 CommonAncestor = CommonAncestor->
getParent();
9486 IdentLoc, Named, CommonAncestor);
9489 !SourceMgr.isInMainFile(SourceMgr.getExpansionLoc(IdentLoc))) {
9490 Diag(IdentLoc, diag::warn_using_directive_in_header);
9493 PushUsingDirective(S, UDir);
9495 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
9499 ProcessDeclAttributeList(S, UDir, AttrList);
9542 getLangOpts().CPlusPlus11
9543 ? diag::warn_cxx98_compat_using_decl_constructor
9544 : diag::err_using_decl_constructor)
9561 llvm_unreachable(
"cannot parse qualified deduction guide name");
9572 ? diag::err_access_decl
9573 : diag::warn_access_decl_deprecated)
9578 if (DiagnoseUnexpandedParameterPack(SS, UPPC_UsingDeclaration) ||
9579 DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC_UsingDeclaration))
9584 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
9591 BuildUsingDeclaration(S, AS, UsingLoc, TypenameLoc.
isValid(), TypenameLoc,
9592 SS, TargetNameInfo, EllipsisLoc, AttrList,
9595 PushOnScopeChains(UD, S,
false);
9610 return Context.
hasSameType(TD1->getUnderlyingType(),
9611 TD2->getUnderlyingType());
9641 if (!getLangOpts().
CPlusPlus11 && CurContext->isRecord()) {
9645 if (isa<EnumDecl>(OrigDC)) OrigDC = OrigDC->
getParent();
9650 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(OrigRec)) {
9651 if (OrigDC == CurContext) {
9653 diag::err_using_decl_nested_name_specifier_is_current_class)
9661 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9663 << cast<CXXRecordDecl>(CurContext)
9671 if (Previous.
empty())
return false;
9674 if (isa<UsingShadowDecl>(Target))
9675 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
9682 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
9683 bool FoundEquivalentDecl =
false;
9690 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D))
9693 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
9698 !isa<IndirectFieldDecl>(Target) &&
9699 !isa<UnresolvedUsingValueDecl>(
Target) &&
9700 DiagnoseClassNameShadow(
9708 PrevShadow = Shadow;
9709 FoundEquivalentDecl =
true;
9710 }
else if (isEquivalentInternalLinkageDeclaration(D, Target)) {
9713 FoundEquivalentDecl =
true;
9717 (isa<TagDecl>(D) ? Tag : NonTag) = D;
9720 if (FoundEquivalentDecl)
9725 switch (CheckOverload(
nullptr, FD, Previous, OldDecl,
9730 case Ovl_NonFunction:
9739 if (CurContext->isRecord())
9755 if (isa<TagDecl>(Target)) {
9757 if (!Tag)
return false;
9761 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
9767 if (!NonTag)
return false;
9780 for (
auto &B : Derived->
bases())
9781 if (B.getType()->getAsCXXRecordDecl() == Base)
9782 return B.isVirtual();
9783 llvm_unreachable(
"not a direct base class");
9793 if (isa<UsingShadowDecl>(Target)) {
9794 Target = cast<UsingShadowDecl>(
Target)->getTargetDecl();
9795 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
9799 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
9800 NonTemplateTarget = TargetTD->getTemplatedDecl();
9803 if (NonTemplateTarget && isa<CXXConstructorDecl>(NonTemplateTarget)) {
9804 bool IsVirtualBase =
9808 Context, CurContext, UD->
getLocation(), UD, Orig, IsVirtualBase);
9822 PushOnScopeChains(Shadow, S);
9824 CurContext->addDecl(Shadow);
9860 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
9868 IdResolver.RemoveDecl(Shadow);
9881 bool &AnyDependentBases) {
9884 for (
auto &Base : Derived->
bases()) {
9886 if (CanonicalDesiredBase == BaseType)
9888 if (BaseType->isDependentType())
9889 AnyDependentBases =
true;
9897 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
9899 : HasTypenameKeyword(HasTypenameKeyword),
9900 IsInstantiation(IsInstantiation), OldNNS(NNS),
9901 RequireMemberOf(RequireMemberOf) {}
9903 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
9907 if (!ND || isa<NamespaceDecl>(ND))
9917 if (RequireMemberOf) {
9919 if (FoundRecord && FoundRecord->isInjectedClassName()) {
9940 bool AnyDependentBases =
false;
9943 AnyDependentBases) &&
9955 if (FoundRecord && FoundRecord->isInjectedClassName())
9959 if (isa<TypeDecl>(ND))
9960 return HasTypenameKeyword || !IsInstantiation;
9962 return !HasTypenameKeyword;
9965 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
9966 return llvm::make_unique<UsingValidatorCCC>(*this);
9970 bool HasTypenameKeyword;
9971 bool IsInstantiation;
9987 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9989 assert(IdentLoc.isValid() &&
"Invalid TargetName location.");
9998 if (
auto *RD = dyn_cast<CXXRecordDecl>(CurContext))
10004 ForVisibleRedeclaration);
10007 LookupName(Previous, S);
10013 if (!isDeclInScope(D, CurContext, S))
10025 assert(IsInstantiation &&
"no scope in non-instantiation");
10026 if (CurContext->isRecord())
10027 LookupQualifiedName(Previous, CurContext);
10046 if (CheckUsingDeclRedeclaration(UsingLoc, HasTypenameKeyword,
10047 SS, IdentLoc, Previous))
10051 if (CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo,
10055 DeclContext *LookupContext = computeDeclContext(SS);
10058 if (!LookupContext || EllipsisLoc.
isValid()) {
10059 if (HasTypenameKeyword) {
10062 UsingLoc, TypenameLoc,
10064 IdentLoc, NameInfo.
getName(),
10068 QualifierLoc, NameInfo, EllipsisLoc);
10071 CurContext->addDecl(D);
10075 auto Build = [&](
bool Invalid) {
10078 UsingName, HasTypenameKeyword);
10080 CurContext->addDecl(UD);
10084 auto BuildInvalid = [&]{
return Build(
true); };
10085 auto BuildValid = [&]{
return Build(
false); };
10087 if (RequireCompleteDeclContext(SS, LookupContext))
10088 return BuildInvalid();
10097 if (!IsInstantiation)
10102 if (CurContext->isRecord()) {
10107 LookupQualifiedName(R, LookupContext);
10120 if (getLangOpts().
CPlusPlus14 && II && II->isStr(
"gets") &&
10121 CurContext->isStdNamespace() &&
10122 isa<TranslationUnitDecl>(LookupContext) &&
10123 getSourceManager().isInSystemHeader(UsingLoc))
10125 UsingValidatorCCC CCC(HasTypenameKeyword, IsInstantiation, SS.
getScopeRep(),
10129 CTK_ErrorRecovery)) {
10132 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
10133 << NameInfo.
getName() << LookupContext << 0
10138 NamedDecl *ND = Corrected.getCorrectionDecl();
10140 return BuildInvalid();
10146 RD = cast<CXXRecordDecl>(RD->
getParent());
10149 if (Corrected.WillReplaceSpecifier()) {
10151 Builder.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
10158 auto *CurClass = cast<CXXRecordDecl>(CurContext);
10161 UsingName.setNamedTypeInfo(
nullptr);
10162 for (
auto *Ctor : LookupConstructors(RD))
10168 UsingName.setName(ND->getDeclName());
10172 Diag(IdentLoc, diag::err_no_member)
10173 << NameInfo.
getName() << LookupContext << SS.getRange();
10174 return BuildInvalid();
10179 return BuildInvalid();
10181 if (HasTypenameKeyword) {
10184 Diag(IdentLoc, diag::err_using_typename_non_type);
10186 Diag((*I)->getUnderlyingDecl()->getLocation(),
10187 diag::note_using_decl_target);
10188 return BuildInvalid();
10195 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
10197 return BuildInvalid();
10204 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
10206 return BuildInvalid();
10212 if (cast<EnumDecl>(ED->getDeclContext())->isScoped()) {
10213 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
10215 return BuildInvalid();
10222 if (UsingName.getName().getNameKind() ==
10227 if (CheckInheritingConstructorUsingDecl(UD))
10233 if (!CheckUsingShadowDecl(UD, *I, Previous, PrevDecl))
10234 BuildUsingShadowDecl(S, UD, *I, PrevDecl);
10242 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
10243 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
10244 isa<UsingPackDecl>(InstantiatedFrom));
10248 UPD->setAccess(InstantiatedFrom->
getAccess());
10249 CurContext->addDecl(UPD);
10255 assert(!UD->
hasTypename() &&
"expecting a constructor name");
10258 assert(SourceType &&
10259 "Using decl naming constructor doesn't have type in scope spec.");
10260 CXXRecordDecl *TargetClass = cast<CXXRecordDecl>(CurContext);
10263 bool AnyDependentBases =
false;
10265 AnyDependentBases);
10266 if (!Base && !AnyDependentBases) {
10268 diag::err_using_decl_constructor_not_in_direct_base)
10270 <<
QualType(SourceType, 0) << TargetClass;
10285 bool HasTypenameKeyword,
10298 if (!CurContext->getRedeclContext()->isRecord()) {
10304 if (Qual->
isDependent() && !HasTypenameKeyword) {
10305 for (
auto *D : Prev) {
10306 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
10307 bool OldCouldBeEnumerator =
10308 isa<UnresolvedUsingValueDecl>(D) || isa<EnumConstantDecl>(D);
10310 OldCouldBeEnumerator ? diag::err_redefinition
10311 : diag::err_redefinition_different_kind)
10312 << Prev.getLookupName();
10313 Diag(D->getLocation(), diag::note_previous_definition);
10326 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
10327 DTypename = UD->hasTypename();
10328 DQual = UD->getQualifier();
10330 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
10332 DQual = UD->getQualifier();
10334 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
10336 DQual = UD->getQualifier();
10341 if (HasTypenameKeyword != DTypename)
continue;
10350 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
10367 DeclContext *NamedContext = computeDeclContext(SS);
10369 if (!CurContext->isRecord()) {
10377 if ((HasTypename && !NamedContext) ||
10379 auto *RD = NamedContext
10382 if (RD && RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), RD))
10385 Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member)
10397 LookupQualifiedName(R, RD);
10402 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
10410 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
10420 if (getLangOpts().CPlusPlus11) {
10426 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
10441 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
10442 << (getLangOpts().CPlusPlus11 ? 4 : 3)
10455 if (!NamedContext) {
10469 diag::err_using_decl_nested_name_specifier_is_not_class)
10475 RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), NamedContext))
10478 if (getLangOpts().CPlusPlus11) {
10484 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(
10485 cast<CXXRecordDecl>(NamedContext))) {
10486 if (CurContext == NamedContext) {
10488 diag::err_using_decl_nested_name_specifier_is_current_class)
10493 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
10495 diag::err_using_decl_nested_name_specifier_is_not_base_class)
10497 << cast<CXXRecordDecl>(CurContext)
10519 llvm::SmallPtrSet<const CXXRecordDecl *, 4> Bases;
10521 Bases.insert(Base);
10526 if (!cast<CXXRecordDecl>(CurContext)->forallBases(Collect))
10532 return !Bases.count(Base);
10537 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
10538 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
10542 diag::err_using_decl_nested_name_specifier_is_not_base_class)
10544 << cast<CXXRecordDecl>(CurContext)
10559 "got alias-declaration outside of declaration scope");
10564 bool Invalid =
false;
10567 GetTypeFromParser(Type.
get(), &TInfo);
10569 if (DiagnoseClassNameShadow(CurContext, NameInfo))
10572 if (DiagnoseUnexpandedParameterPack(Name.
StartLocation, TInfo,
10573 UPPC_DeclarationType)) {
10580 TemplateParamLists.size()
10581 ? forRedeclarationInCurContext()
10582 : ForVisibleRedeclaration);
10587 Previous.getFoundDecl()->isTemplateParameter()) {
10593 "name in alias declaration must be an identifier");
10603 ProcessDeclAttributeList(S, NewTD, AttrList);
10604 AddPragmaAttributes(S, NewTD);
10606 CheckTypedefForVariablyModifiedType(S, NewTD);
10609 bool Redeclaration =
false;
10612 if (TemplateParamLists.size()) {
10616 if (TemplateParamLists.size() != 1) {
10617 Diag(UsingLoc, diag::err_alias_template_extra_headers)
10618 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
10619 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
10624 if (CheckTemplateDeclScope(S, TemplateParams))
10628 FilterLookupForScope(
Previous, CurContext, S,
false,
10631 Redeclaration =
true;
10634 if (!OldDecl && !Invalid) {
10635 Diag(UsingLoc, diag::err_redefinition_different_kind)
10646 if (TemplateParameterListsAreEqual(TemplateParams,
10649 TPL_TemplateMatch))
10650 OldTemplateParams =
10672 if (CheckTemplateParameterList(TemplateParams, OldTemplateParams,
10673 TPC_TypeAliasTemplate))
10686 else if (OldDecl) {
10688 CheckRedeclarationModuleOwnership(NewDecl, OldDecl);
10693 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
10694 setTagNameForLinkagePurposes(TD, NewTD);
10695 handleTagNumbering(TD, S);
10697 ActOnTypedefNameDecl(S, CurContext, NewTD,
Previous, Redeclaration);
10701 PushOnScopeChains(NewND, S);
10702 ActOnDocumentableDecl(NewND);
10713 LookupResult R(*
this, Ident, IdentLoc, LookupNamespaceName);
10714 LookupParsedName(R, S, &SS);
10721 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
10729 LookupResult PrevR(*
this, Alias, AliasLoc, LookupOrdinaryName,
10730 ForVisibleRedeclaration);
10731 LookupName(PrevR, S);
10735 DiagnoseTemplateParameterShadow(AliasLoc, PrevR.
getFoundDecl());
10740 FilterLookupForScope(PrevR, CurContext, S,
false,
10752 }
else if (isVisible(PrevDecl)) {
10753 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
10755 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
10756 << AD->getNamespace();
10759 }
else if (isVisible(PrevDecl)) {
10761 ? diag::err_redefinition
10762 : diag::err_redefinition_different_kind;
10763 Diag(AliasLoc, DiagID) << Alias;
10770 DiagnoseUseOfDecl(ND, IdentLoc);
10779 PushOnScopeChains(AliasDecl, S);
10784 struct SpecialMemberExceptionSpecInfo
10785 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
10793 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
10798 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
10801 void visitSubobjectCall(Subobject Subobj,
10811 auto *BaseClass = cast<CXXRecordDecl>(RT->getDecl());
10813 if (
auto *BaseCtor = SMOR.getMethod()) {
10814 visitSubobjectCall(Base, BaseCtor);
10818 visitClassSubobject(BaseClass, Base, 0);
10822 bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
10833 ExceptSpec.CalledExpr(E);
10835 ->getAs<RecordType>()) {
10836 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
10842 void SpecialMemberExceptionSpecInfo::visitClassSubobject(
CXXRecordDecl *Class,
10846 bool IsMutable = Field && Field->
isMutable();
10847 visitSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable));
10850 void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
10855 ExceptSpec.CalledDecl(getSubobjectLoc(Subobj), MD);
10860 struct ComputingExceptionSpec {
10871 ~ComputingExceptionSpec() {
10882 if (Converted.
isUsable() && !Converted.
get()->isValueDependent()) {
10883 ExplicitSpec.
setKind(Result.getBoolValue()
10895 tryResolveExplicitSpecifier(ES);
10903 ComputingExceptionSpec CES(S, MD, Loc);
10910 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
10912 return Info.ExceptSpec;
10919 diag::err_exception_spec_incomplete_type))
10920 return Info.ExceptSpec;
10937 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
10938 : Info.VisitAllBases);
10940 return Info.ExceptSpec;
10945 struct DeclaringSpecialMember {
10949 bool WasAlreadyBeingDeclared;
10952 : S(S), D(RD, CSM), SavedContext(S, RD) {
10954 if (WasAlreadyBeingDeclared)
10975 ~DeclaringSpecialMember() {
10976 if (!WasAlreadyBeingDeclared) {
10983 bool isAlreadyBeingDeclared()
const {
10984 return WasAlreadyBeingDeclared;
10994 ForExternalRedeclaration);
11001 CheckFunctionDeclaration(S, FD, R,
false);
11004 void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
11010 if (getLangOpts().OpenCLCPlusPlus) {
11029 "Should not build implicit default constructor!");
11031 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDefaultConstructor);
11032 if (DSM.isAlreadyBeingDeclared())
11036 CXXDefaultConstructor,
11047 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
11054 if (getLangOpts().CUDA) {
11055 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDefaultConstructor,
11061 setupImplicitSpecialMemberType(DefaultCon, Context.
VoidTy,
None);
11068 ++getASTContext().NumImplicitDefaultConstructorsDeclared;
11070 Scope *S = getScopeForContext(ClassDecl);
11071 CheckImplicitSpecialMemberDeclaration(S, DefaultCon);
11073 if (ShouldDeleteSpecialMember(DefaultCon, CXXDefaultConstructor))
11074 SetDeclDeleted(DefaultCon, ClassLoc);
11077 PushOnScopeChains(DefaultCon, S,
false);
11078 ClassDecl->
addDecl(DefaultCon);
11088 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
11093 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
11099 ResolveExceptionSpec(CurrentLocation,
11101 MarkVTableUsed(CurrentLocation, ClassDecl);
11106 if (SetCtorInitializers(Constructor,
false)) {
11118 L->CompletedImplicitDefinition(Constructor);
11121 DiagnoseUninitializedFields(*
this, Constructor);
11126 CheckDelayedMemberExceptionSpecs();
11147 ->getInheritedConstructor()
11150 return cast<CXXConstructorDecl>(Ctor);
11165 false, BaseCtor, &ICI);
11168 Context, Derived, UsingLoc, NameInfo, TInfo->
getType(), TInfo,
11180 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
11186 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
11190 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
11197 ParamDecls.push_back(PD);
11202 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
11205 Derived->
addDecl(DerivedCtor);
11207 if (ShouldDeleteSpecialMember(DerivedCtor, CXXDefaultConstructor, &ICI))
11208 SetDeclDeleted(DerivedCtor, UsingLoc);
11210 return DerivedCtor;
11216 ShouldDeleteSpecialMember(Ctor, CXXDefaultConstructor, &ICI,
11235 ResolveExceptionSpec(CurrentLocation,
11237 MarkVTableUsed(CurrentLocation, ClassDecl);
11259 for (
bool VBase : {
false,
true}) {
11261 if (B.isVirtual() != VBase)
11264 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
11269 if (!BaseCtor.first)
11272 MarkFunctionReferenced(CurrentLocation, BaseCtor.first);
11274 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
11278 Context, TInfo, VBase, InitLoc, Init.
get(), InitLoc,
11286 if (SetCtorInitializers(Constructor,
false, Inits)) {
11295 L->CompletedImplicitDefinition(Constructor);
11298 DiagnoseUninitializedFields(*
this, Constructor);
11308 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDestructor);
11309 if (DSM.isAlreadyBeingDeclared())
11326 if (getLangOpts().CUDA) {
11327 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDestructor,
11333 setupImplicitSpecialMemberType(Destructor, Context.
VoidTy,
None);
11342 ++getASTContext().NumImplicitDestructorsDeclared;
11344 Scope *S = getScopeForContext(ClassDecl);
11345 CheckImplicitSpecialMemberDeclaration(S, Destructor);
11351 ShouldDeleteSpecialMember(Destructor, CXXDestructor))
11352 SetDeclDeleted(Destructor, ClassLoc);
11356 PushOnScopeChains(Destructor, S,
false);
11357 ClassDecl->
addDecl(Destructor);
11367 "DefineImplicitDestructor - call it for implicit default dtor");
11372 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
11378 ResolveExceptionSpec(CurrentLocation,
11380 MarkVTableUsed(CurrentLocation, ClassDecl);
11385 MarkBaseAndMemberDestructorsReferenced(Destructor->
getLocation(),
11388 if (CheckDestructor(Destructor)) {
11400 L->CompletedImplicitDefinition(Destructor);
11408 if (
CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(CurContext)) {
11409 if (Record->isInvalidDecl()) {
11410 DelayedOverridingExceptionSpecChecks.clear();
11411 DelayedEquivalentExceptionSpecChecks.clear();
11419 referenceDLLExportedClassMethods();
11421 if (!DelayedDllExportMemberFunctions.empty()) {
11423 std::swap(DelayedDllExportMemberFunctions, WorkList);
11430 if (M->getParent()->getTemplateSpecializationKind() !=
11432 ActOnFinishInlineFunctionDef(M);
11438 if (!DelayedDllExportClasses.empty()) {
11442 std::swap(DelayedDllExportClasses, WorkList);
11450 "adjusting dtor exception specs was introduced in c++11");
11460 getAs<FunctionProtoType>();
11483 class ExprBuilder {
11484 ExprBuilder(
const ExprBuilder&) =
delete;
11485 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
11488 static Expr *assertNotNull(
Expr *E) {
11489 assert(E &&
"Expression construction must not fail.");
11495 virtual ~ExprBuilder() {}
11500 class RefBuilder:
public ExprBuilder {
11510 : Var(Var), VarType(VarType) {}
11513 class ThisBuilder:
public ExprBuilder {
11520 class CastBuilder:
public ExprBuilder {
11521 const ExprBuilder &Builder;
11529 CK_UncheckedDerivedToBase,
Kind,
11535 : Builder(Builder), Type(Type),
Kind(Kind), Path(Path) {}
11538 class DerefBuilder:
public ExprBuilder {
11539 const ExprBuilder &Builder;
11543 return assertNotNull(
11547 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11550 class MemberBuilder:
public ExprBuilder {
11551 const ExprBuilder &Builder;
11560 Builder.build(S, Loc), Type, Loc, IsArrow, SS,
SourceLocation(),
11561 nullptr, MemberLookup,
nullptr,
nullptr).
get());
11564 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
11566 : Builder(Builder), Type(Type), IsArrow(IsArrow),
11567 MemberLookup(MemberLookup) {}
11570 class MoveCastBuilder:
public ExprBuilder {
11571 const ExprBuilder &Builder;
11575 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
11578 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11581 class LvalueConvBuilder:
public ExprBuilder {
11582 const ExprBuilder &Builder;
11586 return assertNotNull(
11590 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11593 class SubscriptBuilder:
public ExprBuilder {
11594 const ExprBuilder &Base;
11595 const ExprBuilder &Index;
11600 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
11603 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
11604 : Base(Base), Index(Index) {}
11615 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
11624 Expr *From = FromB.build(S, Loc);
11628 Expr *To = ToB.build(S, Loc);
11634 bool NeedsCollectableMemCpy =
11638 StringRef MemCpyName = NeedsCollectableMemCpy ?
11639 "__builtin_objc_memmove_collectable" :
11640 "__builtin_memcpy";
11653 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
11655 Expr *CallArgs[] = {
11659 Loc, CallArgs, Loc);
11661 assert(!Call.
isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
11694 const ExprBuilder &To,
const ExprBuilder &From,
11695 bool CopyingBaseSubobject,
bool Copying,
11696 unsigned Depth = 0) {
11712 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
11727 if (Method->isCopyAssignmentOperator() ||
11728 (!Copying && Method->isMoveAssignmentOperator()))
11747 if (CopyingBaseSubobject) {
11778 Expr *FromInst = From.build(S, Loc);
11781 Loc, FromInst, Loc);
11801 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
11821 llvm::raw_svector_ostream OS(Str);
11822 OS <<
"__i" <<
Depth;
11826 IterationVarName, SizeType,
11835 RefBuilder IterationVarRef(IterationVar, SizeType);
11836 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
11842 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
11843 MoveCastBuilder FromIndexMove(FromIndexCopy);
11844 const ExprBuilder *FromIndex;
11846 FromIndex = &FromIndexCopy;
11848 FromIndex = &FromIndexMove;
11850 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
11855 ToIndex, *FromIndex, CopyingBaseSubobject,
11856 Copying,
Depth + 1);
11858 if (Copy.isInvalid() || !Copy.get())
11874 UnaryOperator(IterationVarRef.build(S, Loc), UO_PreInc, SizeType,
11879 Loc, Loc, InitStmt,
11886 const ExprBuilder &To,
const ExprBuilder &From,
11887 bool CopyingBaseSubobject,
bool Copying) {
11894 CopyingBaseSubobject,
11899 if (!Result.isInvalid() && !Result.get())
11912 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyAssignment);
11913 if (DSM.isAlreadyBeingDeclared())
11936 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
11944 if (getLangOpts().CUDA) {
11945 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyAssignment,
11951 setupImplicitSpecialMemberType(CopyAssignment, RetType, ArgType);
11955 ClassLoc, ClassLoc,
11963 ? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
11967 ++getASTContext().NumImplicitCopyAssignmentOperatorsDeclared;
11969 Scope *S = getScopeForContext(ClassDecl);
11970 CheckImplicitSpecialMemberDeclaration(S, CopyAssignment);
11972 if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment))
11973 SetDeclDeleted(CopyAssignment, ClassLoc);
11976 PushOnScopeChains(CopyAssignment, S,
false);
11977 ClassDecl->
addDecl(CopyAssignment);
11979 return CopyAssignment;
11993 if (RD->hasUserDeclaredDestructor()) {
11994 UserDeclaredOperation = RD->getDestructor();
11995 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
11996 RD->hasUserDeclaredCopyConstructor() &&
11999 for (
auto *I : RD->ctors()) {
12000 if (I->isCopyConstructor()) {
12001 UserDeclaredOperation = I;
12005 assert(UserDeclaredOperation);
12006 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
12007 RD->hasUserDeclaredCopyAssignment() &&
12010 for (
auto *I : RD->methods()) {
12011 if (I->isCopyAssignmentOperator()) {
12012 UserDeclaredOperation = I;
12016 assert(UserDeclaredOperation);
12019 if (UserDeclaredOperation) {
12021 diag::warn_deprecated_copy_operation)
12022 << RD << !isa<CXXConstructorDecl>(CopyOp)
12023 << isa<CXXDestructorDecl>(UserDeclaredOperation);
12034 "DefineImplicitCopyAssignment called for wrong function");
12048 ResolveExceptionSpec(CurrentLocation,
12088 RefBuilder OtherRef(Other, OtherRefType);
12094 bool Invalid =
false;
12095 for (
auto &Base : ClassDecl->
bases()) {
12105 BasePath.push_back(&Base);
12109 CastBuilder From(OtherRef, Context.
getQualifiedType(BaseType, OtherQuals),
12113 DerefBuilder DerefThis(This);
12114 CastBuilder To(DerefThis,
12130 Statements.push_back(Copy.
getAs<
Expr>());
12134 for (
auto *Field : ClassDecl->
fields()) {
12137 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
12140 if (Field->isInvalidDecl()) {
12146 if (Field->getType()->isReferenceType()) {
12147 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12148 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
12149 Diag(Field->getLocation(), diag::note_declared_at);
12157 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12158 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
12159 Diag(Field->getLocation(), diag::note_declared_at);
12165 if (Field->isZeroLengthBitField(Context))
12168 QualType FieldType = Field->getType().getNonReferenceType();
12171 "Incomplete array type is not valid");
12177 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
12180 MemberLookup.resolveKind();
12182 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
12184 MemberBuilder To(This, getCurrentThisType(),
true, MemberLookup);
12197 Statements.push_back(Copy.
getAs<
Stmt>());
12202 ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
12205 if (Return.isInvalid())
12208 Statements.push_back(Return.getAs<
Stmt>());
12219 Body = ActOnCompoundStmt(Loc, Loc, Statements,
12221 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
12224 CopyAssignOperator->
markUsed(Context);
12227 L->CompletedImplicitDefinition(CopyAssignOperator);
12234 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveAssignment);
12235 if (DSM.isAlreadyBeingDeclared())
12257 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
12265 if (getLangOpts().CUDA) {
12266 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveAssignment,
12279 ClassLoc, ClassLoc,
12287 ? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
12291 ++getASTContext().NumImplicitMoveAssignmentOperatorsDeclared;
12293 Scope *S = getScopeForContext(ClassDecl);
12294 CheckImplicitSpecialMemberDeclaration(S, MoveAssignment);
12296 if (ShouldDeleteSpecialMember(MoveAssignment, CXXMoveAssignment)) {
12298 SetDeclDeleted(MoveAssignment, ClassLoc);
12302 PushOnScopeChains(MoveAssignment, S,
false);
12303 ClassDecl->
addDecl(MoveAssignment);
12305 return MoveAssignment;
12324 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
12327 for (
auto &BI : Class->
bases()) {
12328 Worklist.push_back(&BI);
12329 while (!Worklist.empty()) {
12362 if (Existing && Existing != &BI) {
12363 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
12366 << (Base->getCanonicalDecl() ==
12369 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
12370 << (Base->getCanonicalDecl() ==
12371 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
12375 Existing =
nullptr;
12385 for (
auto &BI : Base->
bases())
12386 Worklist.push_back(&BI);
12399 "DefineImplicitMoveAssignment called for wrong function");
12425 ResolveExceptionSpec(CurrentLocation,
12437 getAs<RValueReferenceType>()->getPointeeType();
12445 RefBuilder OtherRef(Other, OtherRefType);
12447 MoveCastBuilder MoveOther(OtherRef);
12453 bool Invalid =
false;
12454 for (
auto &Base : ClassDecl->
bases()) {
12472 BasePath.push_back(&Base);
12476 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
12479 DerefBuilder DerefThis(This);
12482 CastBuilder To(DerefThis,
12498 Statements.push_back(Move.
getAs<
Expr>());
12502 for (
auto *Field : ClassDecl->
fields()) {
12505 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
12508 if (Field->isInvalidDecl()) {
12514 if (Field->getType()->isReferenceType()) {
12515 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12516 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
12517 Diag(Field->getLocation(), diag::note_declared_at);
12525 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12526 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
12527 Diag(Field->getLocation(), diag::note_declared_at);
12533 if (Field->isZeroLengthBitField(Context))
12536 QualType FieldType = Field->getType().getNonReferenceType();
12539 "Incomplete array type is not valid");
12544 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
12547 MemberLookup.resolveKind();
12548 MemberBuilder From(MoveOther, OtherRefType,
12549 false, MemberLookup);
12550 MemberBuilder To(This, getCurrentThisType(),
12551 true, MemberLookup);
12553 assert(!From.build(*
this, Loc)->isLValue() &&
12554 "Member reference with rvalue base must be rvalue except for reference " 12555 "members, which aren't allowed for move assignment.");
12562 if (Move.isInvalid()) {
12568 Statements.push_back(Move.getAs<
Stmt>());
12574 CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
12577 if (Return.isInvalid())
12580 Statements.push_back(Return.getAs<
Stmt>());
12591 Body = ActOnCompoundStmt(Loc, Loc, Statements,
12593 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
12596 MoveAssignOperator->
markUsed(Context);
12599 L->CompletedImplicitDefinition(MoveAssignOperator);
12610 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyConstructor);
12611 if (DSM.isAlreadyBeingDeclared())
12626 CXXCopyConstructor,
12638 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12646 if (getLangOpts().CUDA) {
12647 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyConstructor,
12653 setupImplicitSpecialMemberType(CopyConstructor, Context.
VoidTy, ArgType);
12657 ClassLoc, ClassLoc,
12665 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
12669 ClassDecl->
hasAttr<TrivialABIAttr>() ||
12671 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor,
12672 TAH_ConsiderTrivialABI)
12676 ++getASTContext().NumImplicitCopyConstructorsDeclared;
12678 Scope *S = getScopeForContext(ClassDecl);
12679 CheckImplicitSpecialMemberDeclaration(S, CopyConstructor);
12681 if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) {
12683 SetDeclDeleted(CopyConstructor, ClassLoc);
12687 PushOnScopeChains(CopyConstructor, S,
false);
12688 ClassDecl->
addDecl(CopyConstructor);
12690 return CopyConstructor;
12699 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
12704 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
12710 ResolveExceptionSpec(CurrentLocation,
12712 MarkVTableUsed(CurrentLocation, ClassDecl);
12724 if (SetCtorInitializers(CopyConstructor,
false)) {
12732 ActOnCompoundStmt(Loc, Loc,
None,
false).getAs<Stmt>());
12733 CopyConstructor->
markUsed(Context);
12737 L->CompletedImplicitDefinition(CopyConstructor);
12745 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveConstructor);
12746 if (DSM.isAlreadyBeingDeclared())
12757 CXXMoveConstructor,
12770 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12778 if (getLangOpts().CUDA) {
12779 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveConstructor,
12785 setupImplicitSpecialMemberType(MoveConstructor, Context.
VoidTy, ArgType);
12789 ClassLoc, ClassLoc,
12797 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
12801 ClassDecl->
hasAttr<TrivialABIAttr>() ||
12803 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor,
12804 TAH_ConsiderTrivialABI)
12808 ++getASTContext().NumImplicitMoveConstructorsDeclared;
12810 Scope *S = getScopeForContext(ClassDecl);
12811 CheckImplicitSpecialMemberDeclaration(S, MoveConstructor);
12813 if (ShouldDeleteSpecialMember(MoveConstructor, CXXMoveConstructor)) {
12815 SetDeclDeleted(MoveConstructor, ClassLoc);
12819 PushOnScopeChains(MoveConstructor, S,
false);
12820 ClassDecl->
addDecl(MoveConstructor);
12822 return MoveConstructor;
12831 "DefineImplicitMoveConstructor - call it for implicit move ctor");
12836 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
12842 ResolveExceptionSpec(CurrentLocation,
12844 MarkVTableUsed(CurrentLocation, ClassDecl);
12849 if (SetCtorInitializers(MoveConstructor,
false)) {
12856 MoveConstructor->
setBody(ActOnCompoundStmt(
12857 Loc, Loc,
None,
false).getAs<Stmt>());
12858 MoveConstructor->
markUsed(Context);
12862 L->CompletedImplicitDefinition(MoveConstructor);
12877 FunctionDecl *CallOp = Lambda->getLambdaCallOperator();
12878 FunctionDecl *Invoker = Lambda->getLambdaStaticInvoker();
12881 CallOp = InstantiateFunctionDeclaration(
12886 Invoker = InstantiateFunctionDeclaration(
12900 MarkFunctionReferenced(CurrentLocation, CallOp);
12911 Expr *FunctionRef = BuildDeclRefExpr(Invoker, Invoker->
getType(),
12913 assert(FunctionRef &&
"Can't refer to __invoke function?");
12914 Stmt *Return = BuildReturnStmt(Conv->
getLocation(), FunctionRef).
get();
12921 L->CompletedImplicitDefinition(Conv);
12922 L->CompletedImplicitDefinition(Invoker);
12937 Expr *This = ActOnCXXThis(CurrentLocation).get();
12938 Expr *DerefThis =CreateBuiltinUnaryOp(CurrentLocation, UO_Deref, This).get();
12940 ExprResult BuildBlock = BuildBlockForLambdaConversion(CurrentLocation,
12948 if (!BuildBlock.
isInvalid() && !getLangOpts().ObjCAutoRefCount)
12950 CK_CopyAndAutoreleaseBlockObject,
12954 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12963 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12969 Stmt *ReturnS = Return.
get();
12976 L->CompletedImplicitDefinition(Conv);
12983 switch (Args.size()) {
12988 if (!Args[1]->isDefaultArgument())
12993 return !Args[0]->isDefaultArgument();
13004 bool HadMultipleCandidates,
13005 bool IsListInitialization,
13006 bool IsStdInitListInitialization,
13007 bool RequiresZeroInit,
13008 unsigned ConstructKind,
13010 bool Elidable =
false;
13024 Expr *SubExpr = ExprArgs[0];
13029 return BuildCXXConstructExpr(ConstructLoc, DeclInitType,
13030 FoundDecl, Constructor,
13031 Elidable, ExprArgs, HadMultipleCandidates,
13032 IsListInitialization,
13033 IsStdInitListInitialization, RequiresZeroInit,
13034 ConstructKind, ParenRange);
13043 bool HadMultipleCandidates,
13044 bool IsListInitialization,
13045 bool IsStdInitListInitialization,
13046 bool RequiresZeroInit,
13047 unsigned ConstructKind,
13049 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
13050 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
13051 if (DiagnoseUseOfDecl(Constructor, ConstructLoc))
13055 return BuildCXXConstructExpr(
13056 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
13057 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
13058 RequiresZeroInit, ConstructKind, ParenRange);
13068 bool HadMultipleCandidates,
13069 bool IsListInitialization,
13070 bool IsStdInitListInitialization,
13071 bool RequiresZeroInit,
13072 unsigned ConstructKind,
13077 "given constructor for wrong type");
13078 MarkFunctionReferenced(ConstructLoc, Constructor);
13079 if (getLangOpts().CUDA && !CheckCUDACall(ConstructLoc, Constructor))
13083 Context, DeclInitType, ConstructLoc, Constructor, Elidable,
13084 ExprArgs, HadMultipleCandidates, IsListInitialization,
13085 IsStdInitListInitialization, RequiresZeroInit,
13086 static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
13115 assert((getLangOpts().Modules || (!Lookup.
empty() && Lookup.
size() <= 2)) &&
13116 "more than two lookup results for field name");
13119 assert(isa<CXXRecordDecl>(Lookup[0]) &&
13120 "cannot have other non-field member with same name");
13121 for (
auto L : Lookup)
13122 if (isa<FieldDecl>(L)) {
13123 Pattern = cast<FieldDecl>(L);
13126 assert(Pattern &&
"We must have set the Pattern!");
13129 if (!Pattern->hasInClassInitializer() ||
13130 InstantiateInClassInitializer(Loc, Field, Pattern,
13131 getTemplateInstantiationArgs(Field))) {
13154 Diag(Loc, diag::err_in_class_initializer_not_yet_parsed)
13155 << OutermostClass << Field;
13156 Diag(Field->getEndLoc(), diag::note_in_class_initializer_not_yet_parsed);
13158 if (!isSFINAEContext())
13159 Field->setInvalidDecl();
13180 MarkFunctionReferenced(VD->
getLocation(), Destructor);
13181 CheckDestructorAccess(VD->
getLocation(), Destructor,
13182 PDiag(diag::err_access_dtor_var)
13184 DiagnoseUseOfDecl(Destructor, VD->
getLocation());
13209 bool AllowExplicit,
13210 bool IsListInitialization) {
13212 unsigned NumArgs = ArgsPtr.size();
13213 Expr **Args = ArgsPtr.data();
13217 assert(Proto &&
"Constructor without a prototype?");
13221 if (NumArgs < NumParams)
13222 ConvertedArgs.reserve(NumParams);
13224 ConvertedArgs.reserve(NumArgs);
13227 Proto->
isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
13229 bool Invalid = GatherArgumentsForCall(Loc, Constructor,
13231 llvm::makeArrayRef(Args, NumArgs),
13233 CallType, AllowExplicit,
13234 IsListInitialization);
13235 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
13237 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
13239 CheckConstructorCall(Constructor,
13240 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
13250 if (isa<NamespaceDecl>(DC)) {
13252 diag::err_operator_new_delete_declared_in_namespace)
13256 if (isa<TranslationUnitDecl>(DC) &&
13259 diag::err_operator_new_delete_declared_static)
13277 unsigned DependentParamTypeDiag,
13278 unsigned InvalidParamTypeDiag) {
13285 diag::err_operator_new_delete_dependent_result_type)
13298 diag::err_operator_new_delete_invalid_result_type)
13304 diag::err_operator_new_delete_template_too_few_parameters)
13310 diag::err_operator_new_delete_too_few_parameters)
13317 << FnDecl->
getDeclName() << ExpectedFirstParamType;
13328 ExpectedFirstParamType)
13330 << FnDecl->
getDeclName() << ExpectedFirstParamType;
13352 diag::err_operator_new_dependent_param_type,
13353 diag::err_operator_new_param_type))
13360 diag::err_operator_new_default_arg)
13390 SemaRef, FnDecl, SemaRef.
Context.
VoidTy, ExpectedFirstParamType,
13391 diag::err_operator_delete_dependent_param_type,
13392 diag::err_operator_delete_param_type))
13401 diag::err_destroying_operator_delete_not_usual);
13413 "Expected an overloaded operator declaration");
13423 if (Op == OO_Delete || Op == OO_Array_Delete)
13426 if (Op == OO_New || Op == OO_Array_New)
13434 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
13435 if (MethodDecl->isStatic())
13437 diag::err_operator_overload_static) << FnDecl->
getDeclName();
13439 bool ClassOrEnumParam =
false;
13441 QualType ParamType = Param->getType().getNonReferenceType();
13444 ClassOrEnumParam =
true;
13449 if (!ClassOrEnumParam)
13451 diag::err_operator_overload_needs_class_or_enum)
13461 if (Op != OO_Call) {
13463 if (Param->hasDefaultArg())
13464 return Diag(Param->getLocation(),
13465 diag::err_operator_overload_default_arg)
13466 << FnDecl->
getDeclName() << Param->getDefaultArgRange();
13471 {
false,
false,
false }
13472 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 13473 , { Unary, Binary, MemberOnly } 13474 #include "clang/Basic/OperatorKinds.def" 13477 bool CanBeUnaryOperator = OperatorUses[Op][0];
13478 bool CanBeBinaryOperator = OperatorUses[Op][1];
13479 bool MustBeMemberOperator = OperatorUses[Op][2];
13486 + (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
13487 if (Op != OO_Call &&
13488 ((NumParams == 1 && !CanBeUnaryOperator) ||
13489 (NumParams == 2 && !CanBeBinaryOperator) ||
13490 (NumParams < 1) || (NumParams > 2))) {
13493 if (CanBeUnaryOperator && CanBeBinaryOperator) {
13495 }
else if (CanBeUnaryOperator) {
13498 assert(CanBeBinaryOperator &&
13499 "All non-call overloaded operators are unary or binary!");
13503 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
13508 if (Op != OO_Call &&
13510 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
13515 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
13517 diag::err_operator_overload_must_be_member)
13531 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
13538 diag::err_operator_overload_post_incdec_must_be_int)
13539 << LastParam->
getType() << (Op == OO_MinusMinus);
13551 if (TemplateParams->
size() == 1) {
13560 }
else if (TemplateParams->
size() == 2) {
13569 PmArgs->isTemplateParameterPack()) {
13576 diag::ext_string_literal_operator_template);
13583 diag::err_literal_operator_template)
13592 if (isa<CXXMethodDecl>(FnDecl)) {
13593 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
13602 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
13619 diag::err_literal_operator_template_with_params);
13648 diag::err_literal_operator_param)
13665 diag::err_literal_operator_invalid_param)
13675 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
13682 Diag((*Param)->getSourceRange().getBegin(),
13683 diag::err_literal_operator_param)
13684 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13691 Diag((*Param)->getSourceRange().getBegin(),
13692 diag::err_literal_operator_param)
13693 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13706 Diag((*Param)->getSourceRange().getBegin(),
13707 diag::err_literal_operator_param)
13708 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13716 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
13718 Diag((*Param)->getSourceRange().getBegin(),
13719 diag::err_literal_operator_param)
13721 << (*Param)->getSourceRange();
13725 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
13734 if (Param->hasDefaultArg()) {
13735 Diag(Param->getDefaultArgRange().getBegin(),
13736 diag::err_literal_operator_default_argument)
13737 << Param->getDefaultArgRange();
13742 StringRef LiteralName
13744 if (LiteralName[0] !=
'_' &&
13745 !getSourceManager().isInSystemHeader(FnDecl->
getLocation())) {
13767 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
13776 else if (Lang ==
"C++")
13779 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
13790 PushDeclContext(S, D);
13806 return LinkageSpec;
13815 ProcessDeclAttributeList(S, ED, AttrList);
13817 CurContext->addDecl(ED);
13829 bool Invalid =
false;
13843 Diag(Loc, diag::err_catch_rvalue_ref);
13848 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
13854 unsigned DK = diag::err_catch_incomplete;
13858 DK = diag::err_catch_incomplete_ptr;
13863 DK = diag::err_catch_incomplete_ref;
13865 if (!Invalid && (Mode == 0 || !BaseType->
isVoidType()) &&
13866 !BaseType->
isDependentType() && RequireCompleteType(Loc, BaseType, DK))
13870 RequireNonAbstractType(Loc, ExDeclType,
13871 diag::err_abstract_type_in_decl,
13872 AbstractVariableType))
13877 if (!Invalid && getLangOpts().ObjC) {
13883 Diag(Loc, diag::err_objc_object_catch);
13887 if (getLangOpts().ObjCRuntime.isFragile())
13888 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
13897 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(ExDecl))
13904 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
13922 Expr *opaqueValue =
13933 Expr *init = MaybeCreateExprWithCleanups(construct);
13938 FinalizeVarWithDestructor(ExDecl,
recordType);
13957 UPPC_ExceptionType)) {
13965 LookupOrdinaryName,
13966 ForVisibleRedeclaration)) {
13971 if (isDeclInScope(PrevDecl, CurContext, S)) {
13974 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
13976 }
else if (PrevDecl->isTemplateParameter())
13987 VarDecl *ExDecl = BuildExceptionDeclaration(
13994 PushOnScopeChains(ExDecl, S);
13996 CurContext->addDecl(ExDecl);
13998 ProcessDeclAttributes(S, ExDecl, D);
14004 Expr *AssertMessageExpr,
14007 AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) :
nullptr;
14009 if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
14012 return BuildStaticAssertDeclaration(StaticAssertLoc, AssertExpr,
14013 AssertMessage, RParenLoc,
false);
14021 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
14026 ExprResult Converted = PerformContextuallyConvertToBool(AssertExpr);
14031 if (!Failed && VerifyIntegerConstantExpression(Converted.
get(), &Cond,
14032 diag::err_static_assert_expression_is_not_constant,
14036 if (!Failed && !Cond) {
14038 llvm::raw_svector_ostream Msg(MsgBuffer);
14040 AssertMessage->
printPretty(Msg,
nullptr, getPrintingPolicy());
14042 Expr *InnerCond =
nullptr;
14043 std::string InnerCondDescription;
14044 std::tie(InnerCond, InnerCondDescription) =
14045 findFailedBooleanCondition(Converted.
get());
14046 if (InnerCond && !isa<CXXBoolLiteralExpr>(InnerCond)
14047 && !isa<IntegerLiteral>(InnerCond)) {
14048 Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed)
14049 << InnerCondDescription << !AssertMessage
14052 Diag(StaticAssertLoc, diag::err_static_assert_failed)
14059 ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
14065 AssertExpr = FullAssertExpr.
get();
14068 AssertExpr, AssertMessage, RParenLoc,
14071 CurContext->addDecl(Decl);
14081 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
14091 if (!CodeSynthesisContexts.empty()) {
14106 getLangOpts().CPlusPlus11 ?
14107 diag::warn_cxx98_compat_unelaborated_friend_type :
14108 diag::ext_unelaborated_friend_type)
14116 diag::warn_cxx98_compat_nonclass_type_friend :
14117 diag::ext_nonclass_type_friend)
14124 diag::warn_cxx98_compat_enum_friend :
14125 diag::ext_enum_friend)
14136 if (getLangOpts().
CPlusPlus11 && LocStart != FriendLoc)
14137 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
14158 bool IsMemberSpecialization =
false;
14159 bool Invalid =
false;
14162 MatchTemplateParametersToScopeSpecifier(
14163 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
14164 IsMemberSpecialization, Invalid)) {
14165 if (TemplateParams->size() > 0) {
14170 return CheckClassTemplate(S, TagSpec, TUK_Friend, TagLoc, SS, Name,
14171 NameLoc, Attr, TemplateParams,
AS_public,
14173 FriendLoc, TempParamLists.size() - 1,
14174 TempParamLists.data()).
get();
14177 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
14179 IsMemberSpecialization =
true;
14183 if (Invalid)
return nullptr;
14185 bool isAllExplicitSpecializations =
true;
14186 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
14187 if (TempParamLists[I]->size()) {
14188 isAllExplicitSpecializations =
false;
14198 if (isAllExplicitSpecializations) {
14200 bool Owned =
false;
14201 bool IsDependent =
false;
14202 return ActOnTag(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc,
14216 QualType T = CheckTypenameType(Keyword, TagLoc, QualifierLoc,
14222 if (isa<DependentNameType>(T)) {
14236 TSI, FriendLoc, TempParamLists);
14238 CurContext->addDecl(Friend);
14242 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
14249 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
14260 TSI, FriendLoc, TempParamLists);
14263 CurContext->addDecl(Friend);
14323 if (DiagnoseUnexpandedParameterPack(Loc, TSI, UPPC_FriendDeclaration))
14341 Diag(Loc, diag::err_tagless_friend_type_template)
14358 if (!TempParams.empty())
14370 CurContext->addDecl(D);
14396 Diag(Loc, diag::err_unexpected_friend);
14423 if (DiagnoseUnexpandedParameterPack(Loc, TInfo, UPPC_FriendDeclaration) ||
14424 DiagnoseUnexpandedParameterPack(NameInfo, UPPC_FriendDeclaration) ||
14425 DiagnoseUnexpandedParameterPack(SS, UPPC_FriendDeclaration))
14431 Scope *DCScope = S;
14433 ForExternalRedeclaration);
14441 (FunctionContainingLocalClass =
14442 cast<CXXRecordDecl>(CurContext)->isLocalClass())) {
14457 Previous.
clear(LookupLocalFriendName);
14458 LookupName(Previous, S,
false);
14460 if (!Previous.
empty()) {
14468 DC = FunctionContainingLocalClass;
14470 adjustContextForLocalExternDecl(DC);
14490 bool isTemplateId =
14511 LookupQualifiedName(Previous, LookupDC);
14513 if (!Previous.
empty()) {
14518 if (isTemplateId) {
14519 if (isa<TranslationUnitDecl>(LookupDC))
break;
14526 DCScope = getScopeForDeclContext(S, DC);
14532 DC = computeDeclContext(SS);
14533 if (!DC)
return nullptr;
14535 if (RequireCompleteDeclContext(SS, DC))
return nullptr;
14537 LookupQualifiedName(Previous, DC);
14541 if (DC->
Equals(CurContext))
14543 getLangOpts().CPlusPlus11 ?
14544 diag::warn_cxx98_compat_friend_is_member :
14545 diag::err_friend_is_member);
14581 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
14608 if (DiagArg >= 0) {
14609 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
14620 DCScope = &FakeDCScope;
14623 bool AddToScope =
true;
14624 NamedDecl *ND = ActOnFunctionDeclarator(DCScope, D, DC, TInfo, Previous,
14625 TemplateParams, AddToScope);
14626 if (!ND)
return nullptr;
14640 if (!CurContext->isDependentContext()) {
14643 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
14644 PushOnScopeChains(ND, EnclosingScope,
false);
14651 CurContext->addDecl(FrD);
14656 if (DC->isRecord()) CheckFriendAccess(ND);
14660 FD = FTD->getTemplatedDecl();
14662 FD = cast<FunctionDecl>(ND);
14673 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
14675 diag::note_previous_declaration);
14677 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
14682 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
14684 << cast<CXXRecordDecl>(CurContext);
14693 AdjustDeclIfTemplate(Dcl);
14695 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
14697 Diag(DelLoc, diag::err_deleted_non_function);
14708 Prev->getPreviousDecl()) &&
14709 !Prev->isDefined()) {
14710 Diag(DelLoc, diag::err_deleted_decl_not_first);
14711 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
14712 Prev->isImplicit() ? diag::note_previous_implicit_declaration
14713 : diag::note_previous_declaration);
14732 bool IssuedDiagnostic =
false;
14735 if (!IssuedDiagnostic) {
14737 IssuedDiagnostic =
true;
14739 Diag(O->getLocation(), diag::note_overridden_virtual_function);
14745 ShouldDeleteSpecialMember(MD, getSpecialMember(MD),
nullptr,
14752 Diag(DelLoc, diag::err_deleted_main);
14771 if (Member == CXXInvalid) {
14773 Diag(DefaultLoc, diag::err_default_special_members);
14799 CheckExplicitlyDefaultedSpecialMember(MD);
14804 Diag(DefaultLoc, diag::err_default_special_members);
14812 if (isa<ReturnStmt>(SubStmt))
14813 Self.
Diag(SubStmt->getBeginLoc(),
14814 diag::err_return_in_constructor_handler);
14815 if (!isa<Expr>(SubStmt))
14821 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
14833 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
14837 !NewFT->getExtParameterInfo(I).isNoEscape()) {
14839 diag::warn_overriding_method_missing_noescape);
14841 diag::note_overridden_marked_noescape);
14846 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
14847 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
14848 if ((NewCSA || OldCSA) &&
14849 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
14858 if (NewCC == OldCC)
14869 diag::err_conflicting_overriding_cc_attributes)
14895 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
14903 if (NewClassTy.
isNull()) {
14905 diag::err_different_return_type_for_overriding_virtual_function)
14921 if (!RT->isBeingDefined() &&
14922 RequireCompleteType(New->
getLocation(), NewClassTy,
14923 diag::err_covariant_return_incomplete,
14929 if (!IsDerivedFrom(New->
getLocation(), NewClassTy, OldClassTy)) {
14939 if (CheckDerivedToBaseConversion(
14940 NewClassTy, OldClassTy,
14941 diag::err_covariant_return_inaccessible_base,
14942 diag::err_covariant_return_ambiguous_derived_to_base_conv,
14958 diag::err_covariant_return_type_different_qualifications)
14970 diag::err_covariant_return_type_class_type_more_qualified)
15005 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
15006 CheckPureMethod(M, ZeroLoc);
15014 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
15015 return Var->hasGlobalStorage();
15043 PushExpressionEvaluationContext(
15044 ExpressionEvaluationContext::PotentiallyEvaluated, D);
15054 PopExpressionEvaluationContext();
15057 ExitDeclaratorContext(S);
15069 "Parser allowed 'typedef' as storage class of condition decl.");
15071 Decl *Dcl = ActOnDeclarator(S, D);
15075 if (isa<FunctionDecl>(Dcl)) {
15076 Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
15085 if (!ExternalSource)
15089 ExternalSource->ReadUsedVTables(VTables);
15091 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
15092 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
15093 = VTablesUsed.find(VTables[I].Record);
15095 if (Pos != VTablesUsed.end()) {
15096 if (!Pos->second && VTables[I].DefinitionRequired)
15097 Pos->second =
true;
15101 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
15102 NewUses.push_back(
VTableUse(VTables[I].Record, VTables[I].Location));
15105 VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end());
15109 bool DefinitionRequired) {
15113 CurContext->isDependentContext() || isUnevaluatedContext())
15117 if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
15118 !isInOpenMPDeclareTargetContext() &&
15119 !isInOpenMPTargetExecutionDirective()) {
15120 if (!DefinitionRequired)
15121 MarkVirtualMembersReferenced(Loc, Class);
15126 LoadExternalVTableUses();
15128 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
15129 Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
15134 if (DefinitionRequired && !Pos.first->second) {
15135 Pos.first->second =
true;
15153 CheckDestructor(DD);
15165 MarkVirtualMembersReferenced(Loc, Class);
15167 VTableUses.push_back(std::make_pair(Class, Loc));
15171 LoadExternalVTableUses();
15172 if (VTableUses.empty())
15179 bool DefinedAnything =
false;
15180 for (
unsigned I = 0; I != VTableUses.size(); ++I) {
15189 bool DefineVTable =
true;
15195 if (KeyFunction && !KeyFunction->
hasBody()) {
15197 DefineVTable =
false;
15202 "Instantiations don't have key functions");
15204 }
else if (!KeyFunction) {
15209 bool IsExplicitInstantiationDeclaration =
15211 for (
auto R : Class->
redecls()) {
15215 IsExplicitInstantiationDeclaration =
true;
15217 IsExplicitInstantiationDeclaration =
false;
15222 if (IsExplicitInstantiationDeclaration)
15223 DefineVTable =
false;
15229 if (!DefineVTable) {
15230 MarkVirtualMemberExceptionSpecsNeeded(Loc, Class);
15237 DefinedAnything =
true;
15238 MarkVirtualMembersReferenced(Loc, Class);
15240 if (VTablesUsed[Canonical])
15241 Consumer.HandleVTable(Class);
15249 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
15253 ? diag::warn_weak_template_vtable
15254 : diag::warn_weak_vtable)
15259 VTableUses.clear();
15261 return DefinedAnything;
15266 for (
const auto *I : RD->
methods())
15267 if (I->isVirtual() && !I->isPure())
15273 bool ConstexprOnly) {
15277 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
15278 E = FinalOverriders.end();
15281 OE = I->second.end();
15283 assert(OI->second.size() > 0 &&
"no final overrider");
15288 if (!Overrider->isPure() && (!ConstexprOnly || Overrider->isConstexpr()))
15289 MarkFunctionReferenced(Loc, Overrider);
15297 for (
const auto &I : RD->
bases()) {
15299 cast<CXXRecordDecl>(I.getType()->getAs<
RecordType>()->getDecl());
15302 MarkVirtualMembersReferenced(Loc, Base);
15313 CollectIvarsToConstructOrDestruct(OID, ivars);
15317 for (
unsigned i = 0;
i < ivars.size();
i++) {
15329 InitSeq.Perform(*
this, InitEntity, InitKind,
None);
15330 MemberInit = MaybeCreateExprWithCleanups(MemberInit);
15341 AllToInit.push_back(Member);
15346 ->getAs<RecordType>()) {
15347 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
15349 MarkFunctionReferenced(Field->
getLocation(), Destructor);
15350 CheckDestructorAccess(Field->
getLocation(), Destructor,
15351 PDiag(diag::err_access_dtor_ivar)
15357 AllToInit.data(), AllToInit.size());
15363 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Valid,
15364 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Invalid,
15365 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Current,
15376 (void)Target->
hasBody(FNTarget);
15378 cast_or_null<CXXConstructorDecl>(FNTarget));
15385 if (!Current.insert(Canonical).second)
15391 Valid.insert(Current.begin(), Current.end());
15394 }
else if (TCanonical == Canonical || Invalid.count(TCanonical) ||
15395 Current.count(TCanonical)) {
15397 if (!Invalid.count(TCanonical)) {
15399 diag::warn_delegating_ctor_cycle)
15403 if (TCanonical != Canonical)
15410 assert(FNTarget &&
"Ctor cycle through bodiless function");
15413 cast<CXXConstructorDecl>(FNTarget));
15418 Invalid.insert(Current.begin(), Current.end());
15427 llvm::SmallPtrSet<CXXConstructorDecl*, 4> Valid, Invalid, Current;
15429 for (DelegatingCtorDeclsType::iterator
15430 I = DelegatingCtorDecls.begin(ExternalSource),
15431 E = DelegatingCtorDecls.end();
15435 for (
auto CI = Invalid.begin(), CE = Invalid.end(); CI != CE; ++CI)
15436 (*CI)->setInvalidDecl();
15445 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
15473 FindCXXThisExpr Finder(*
this);
15481 if (checkThisInStaticMemberFunctionExceptionSpec(Method))
15484 return checkThisInStaticMemberFunctionAttributes(Method);
15498 FindCXXThisExpr Finder(*
this);
15520 if (!Finder.TraverseType(E))
15530 FindCXXThisExpr Finder(*
this);
15533 for (
const auto *A : Method->
attrs()) {
15535 Expr *Arg =
nullptr;
15537 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
15539 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
15541 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
15542 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
15543 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
15544 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
15545 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
15546 Arg = ETLF->getSuccessValue();
15547 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
15548 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
15549 Arg = STLF->getSuccessValue();
15550 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
15551 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
15552 Arg = LR->getArg();
15553 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
15554 Args = llvm::makeArrayRef(LE->args_begin(), LE->args_size());
15555 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
15556 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
15557 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
15558 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
15559 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
15560 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
15561 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
15562 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
15564 if (Arg && !Finder.TraverseStmt(Arg))
15567 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
15568 if (!Finder.TraverseStmt(Args[I]))
15582 Exceptions.clear();
15585 Exceptions.reserve(DynamicExceptions.size());
15586 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
15588 QualType ET = GetTypeFromParser(DynamicExceptions[ei]);
15593 if (!Unexpanded.empty()) {
15595 DynamicExceptionRanges[ei].getBegin(), UPPC_ExceptionType,
15603 if (!CheckSpecifiedExceptionType(ET, DynamicExceptionRanges[ei]))
15604 Exceptions.push_back(ET);
15614 "Parser should have made sure that the expression is boolean");
15615 if (IsTopLevel && DiagnoseUnexpandedParameterPack(NoexceptExpr)) {
15630 Expr *NoexceptExpr) {
15636 MethodD = FunTmpl->getTemplatedDecl();
15645 checkExceptionSpecification(
true, EST, DynamicExceptions,
15646 DynamicExceptionRanges, NoexceptExpr, Exceptions,
15653 checkThisInStaticMemberFunctionExceptionSpec(Method);
15658 CheckOverridingFunctionExceptionSpec(Method, O);
15672 Diag(DeclStart, diag::err_anonymous_property);
15680 CheckExtraCXXDefaultArguments(D);
15683 UPPC_DataMemberType)) {
15694 << getLangOpts().CPlusPlus17;
15697 diag::err_invalid_thread)
15703 ForVisibleRedeclaration);
15704 LookupName(Previous, S);
15725 PrevDecl =
nullptr;
15728 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
15729 PrevDecl =
nullptr;
15736 ProcessDeclAttributes(TUScope, NewPD, D);
15749 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.
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.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
void ActOnFinishDelayedMemberInitializers(Decl *Record)
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCallToStdMove() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
SourceLocation getBeginLoc() const
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
Represents a function declaration or definition.
static StmtResult buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying, unsigned Depth=0)
Builds a statement that copies/moves the given entity from From to To.
Name lookup found a set of overloaded functions that met the criteria.
NamespaceDecl * getStdNamespace() const
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Expr * getInit() const
Get the initializer.
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void setOrigin(CXXRecordDecl *Rec)
CXXMethodDecl * getMethod() const
no exception specification
static bool checkMemberDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const CXXRecordDecl *OrigRD)
const TypeClass * getTypePtr() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
bool SetTypeQual(TQ T, SourceLocation Loc)
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
static bool findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, Sema::TrivialABIHandling TAH, CXXMethodDecl **Selected)
Perform lookup for a special member of the specified kind, and determine whether it is trivial...
static DeclAccessPair findDecomposableBaseClass(Sema &S, SourceLocation Loc, const CXXRecordDecl *RD, CXXCastPath &BasePath)
Find the base class to decompose in a built-in decomposition of a class type.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
const Expr * getInit(unsigned Init) const
The subobject is a base class.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
static UsingPackDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> UsingDecls)
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.
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class...
static CharSourceRange getTokenRange(SourceRange R)
void addConst()
Add the const type qualifier to this QualType.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
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 isVariadic() const
Whether this function prototype is variadic.
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
SourceLocation getBeginLoc() const LLVM_READONLY
static bool FindBaseInitializer(Sema &SemaRef, CXXRecordDecl *ClassDecl, QualType BaseType, const CXXBaseSpecifier *&DirectBaseSpec, const CXXBaseSpecifier *&VirtualBaseSpec)
Find the direct and/or virtual base specifiers that correspond to the given base type, for use in base initialization within a constructor.
void setArgPassingRestrictions(ArgPassingKind Kind)
ComparisonCategoryType Kind
The Kind of the comparison category type.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
ThreadStorageClassSpecifier getTSCSpec() const
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)
bool isOverrideSpecified() const
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
NamedDecl * getDecl() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static bool isVirtualDirectBase(CXXRecordDecl *Derived, CXXRecordDecl *Base)
Determine whether a direct base class is a virtual base class.
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...
SourceLocation getBeginLoc() const LLVM_READONLY
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
One instance of this struct is used for each type in a declarator that is parsed. ...
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 getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getEndLoc() const LLVM_READONLY
NamedDecl * getParam(unsigned Idx)
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
QualType withConst() const
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
const TargetInfo & getTargetInfo() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
const NestedNameSpecifier * Specifier
RefQualifierKind RefQualifier
A container of type source information.
Store information needed for an explicit specifier.
Floating point control options.
constexpr XRayInstrMask Function
static std::string printTemplateArgs(const PrintingPolicy &PrintingPolicy, TemplateArgumentListInfo &Args)
An overloaded operator name, e.g., operator+.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
TSCS getThreadStorageClassSpec() const
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
QualType getConversionType() const
Returns the type that this conversion function is converting to.
static void checkMethodTypeQualifiers(Sema &S, Declarator &D, unsigned DiagID)
static InitializedEntity InitializeMemberFromDefaultMemberInitializer(FieldDecl *Member)
Create the initialization entity for a default member initializer.
Abstract base class used for diagnosing integer constant expression violations.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
unsigned getIdentifierNamespace() const
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
IdentifierInfo * getPropertyDataGetter() const
bool implicitCopyAssignmentHasConstParam() const
Determine whether an implicit copy assignment operator for this type would have a parameter with a co...
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class...
size_t param_size() const
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
SourceLocation getEndLoc() const
Get the end source location.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
SourceLocation getOverrideLoc() const
QualType getElementType() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
void CheckCXXDefaultArguments(FunctionDecl *FD)
CheckCXXDefaultArguments - Verify that the default arguments for a function declaration are well-form...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
RAII object to handle the state changes required to synthesize a function body.
IdentifierInfo * getPropertyDataSetter() const
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> Expansions)
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
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.
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr *> Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
RAII object that enters a new expression evaluation context.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
Represents a variable declaration or definition.
ActionResult< Stmt * > StmtResult
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Information about one declarator, including the parsed type information and the identifier.
QualType getReturnType() const
DiagnosticsEngine & Diags
Wrapper for source info for member pointers.
unsigned getNumParams() const
bool isEnumeralType() const
void finishedDefaultedOrDeletedMember(CXXMethodDecl *MD)
Indicates that the declaration of a defaulted or deleted special member function is now complete...
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
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.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
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...
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext)
Field is the non-static data member whose default initializer is used by this expression.
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool hasMethodTypeQualifiers() const
Determine whether this method has qualifiers.
bool hasDefinition() const
static StringRef getResultString(ComparisonCategoryResult Kind)
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
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.
enum clang::DeclaratorChunk::@217 Kind
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.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation)
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
bool isRecordingPaths() const
Whether we are recording paths.
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T)
Determine whether the given type is an incomplete or zero-lenfgth array type.
void CheckDelayedMemberExceptionSpecs()
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
SourceLocation getFriendSpecLoc() const
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
bool isRedeclaration() const
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer *> MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
Represents a struct/union/class.
bool hasTrivialCopyConstructorForCall() const
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
static QualType getTupleLikeElementType(Sema &S, SourceLocation Loc, unsigned I, QualType T)
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Description of a constructor that was inherited from a base class.
static bool IsEquivalentForUsingDecl(ASTContext &Context, NamedDecl *D1, NamedDecl *D2)
Determine whether a using declaration considers the given declarations as "equivalent", e.g., if they are redeclarations of the same entity or are both typedefs of the same type.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
unsigned getDepth() const
Retrieve the depth of the template parameter.
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
static bool IsUsingDirectiveInToplevelContext(DeclContext *CurContext)
Determine whether a using statement is in a context where it will be apply in all contexts...
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
void setRecordingPaths(bool RP)
Specify whether we should be recording paths or not.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
void setUninstantiatedDefaultArg(Expr *arg)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
bool isInline() const
Returns true if this is an inline namespace declaration.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ArrayRef< QualType > getParamTypes() const
The results of name lookup within a DeclContext.
SourceLocation getTypeSpecTypeLoc() const
TypeSourceInfo * getTypeSourceInfo() const
ConstexprSpecKind getConstexprKind() const
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
field_range fields() const
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, ParsedAttributes &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info, FieldDecl *Field, IndirectFieldDecl *Indirect=nullptr)
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause...
Represents a member of a struct/union/class.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
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)
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.
ParmVarDecl * getParam(unsigned i) const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const
Make an APSInt of the appropriate width and signedness for the given Value and integer Type...
LookupResultKind getResultKind() const
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
Represents an access specifier followed by colon ':'.
void ClearStorageClassSpecs()
SourceLocation getBeginLoc() const LLVM_READONLY
void addShadowDecl(UsingShadowDecl *S)
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
SourceLocation getTemplateLoc() const
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
A user-defined literal name, e.g., operator "" _i.
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 ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr *> Exprs, SourceLocation RParenLoc)
Create a paren list.
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.
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization. ...
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace...
static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class)
Represents the results of name lookup.
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
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
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
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...
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()
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier *> Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
LangAS getAddressSpace() const
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt *> Stmts, SourceLocation LB, SourceLocation RB)
void CheckDelegatingCtorCycles()
QualType getExceptionObjectType(QualType T) const
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
bool isRValueReferenceType() const
static void checkMoveAssignmentForRepeatedMove(Sema &S, CXXRecordDecl *Class, SourceLocation CurrentLocation)
Check if we're implicitly defining a move assignment operator for a class with virtual bases...
void setExceptionVariable(bool EV)
The argument of this type cannot be passed directly in registers.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
ActionResult< ParsedType > TypeResult
DeclContextLookupResult slice(size_t N) const
bool isLambda() const
Determine whether this class describes a lambda function object.
Scope - A scope is a transient data structure that is used while parsing the program.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
field_iterator field_begin() const
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.
void setNumCtorInitializers(unsigned numCtorInitializers)
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
FieldDecl * getAnyMember() const
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
TemplateArgumentLoc getArgLoc(unsigned i) const
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
SourceLocation getConstSpecLoc() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
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.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor())
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)
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.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
unsigned getNumArgs() const
A binding in a decomposition declaration.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
void setKind(ExplicitSpecKind Kind)
init_iterator init_begin()
Retrieve an iterator to the first initializer.
IdentifierInfo * getIdentifier() const
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3).
unsigned getLength() const
Efficiently return the length of this identifier info.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location...
static TemplateArgumentLoc getTrivialIntegralTemplateArgument(Sema &S, SourceLocation Loc, QualType T, uint64_t I)
ArgPassingKind getArgPassingRestrictions() const
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
param_iterator param_begin()
Represents the this expression in C++.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, UsingDecl *UD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
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...
SourceLocation getUnalignedSpecLoc() const
Represents a prototype with parameter type info, e.g.
virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool hasConstexprSpecifier() const
bool isDynamicClass() const
void ClearConstexprSpec()
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
SourceLocation getBeginLoc() const LLVM_READONLY
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
A RAII object to enter scope of a compound statement.
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Represents a ValueDecl that came out of a declarator.
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)
ExplicitSpecifier getExplicitSpecifier()
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
ExplicitSpecifier ActOnExplicitBoolSpecifier(Expr *E)
ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression found in an explicit(bool)...
DeclarationNameTable DeclarationNames
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
bool hasTrivialMoveConstructorForCall() const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl *> &OverloadedMethods)
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
A conversion function name, e.g., operator int.
SourceRange getRange() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
bool isInlineSpecified() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
bool isLiteral() const
Determine whether this class is a literal type.
void setInClassInitializer(Expr *Init)
Set the C++11 in-class initializer for this member.
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared...
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
TST getTypeSpecType() const
SourceLocation getBeginLoc() const LLVM_READONLY
static void diagnoseDeprecatedCopyOperation(Sema &S, CXXMethodDecl *CopyOp)
Diagnose an implicit copy operation for a class which is odr-used, but which is deprecated because th...
bool hasKeyFunctions() const
Does this ABI use key functions? If so, class data such as the vtable is emitted with strong linkage ...
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
static Sema::SpecialMemberOverloadResult lookupCallFromSpecialMember(Sema &S, CXXRecordDecl *Class, Sema::CXXSpecialMember CSM, unsigned FieldQuals, bool ConstRHS)
Look up the special member function that would be called by a special member function for a subobject...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
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...
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
void setTrivialForCall(bool IT)
static bool checkComplexDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const ComplexType *CT)
SourceLocation getBeginLoc() const
Get the begin source location.
static bool checkArrayLikeDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType)
Allows QualTypes to be sorted and hence used in maps and sets.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
QualType getElementType() const
bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method)
Whether this' shows up in the exception specification of a static member function.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
StringRef getKindName() const
QualType getPointeeType() const
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
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.
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
void setRBraceLoc(SourceLocation L)
static bool checkVectorDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const VectorType *VT)
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
OpaquePtr< T > get() const
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
SourceLocation getLocation() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
void freeParams()
Reset the parameter list to having zero parameters.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
std::string getAsString() const
Retrieve the human-readable string for this name.
unsigned getNumInits() const
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
SourceLocation getVolatileSpecLoc() const
SourceLocation getThreadStorageClassSpecLoc() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
void setRBraceLoc(SourceLocation L)
Defines the clang::Preprocessor interface.
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
field_iterator field_end() const
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
overridden_method_range overridden_methods() const
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
bool isFileContext() const
SourceLocation getBeginLoc() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
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.
const Expr * getExpr() const
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.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
void DiscardCleanupsInEvaluationContext()
The argument of this type cannot be passed directly in registers.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
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.
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...
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
InClassInitStyle
In-class initialization styles for non-static data members.
This declaration has an owning module, and is visible when that module is imported.
Declaration of an alias template.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for record diagnostic message.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
static bool checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, bool ConstArg, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the members of a class type allow a special member to be trivial.
A boolean condition, from 'if', 'while', 'for', or 'do'.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
static bool specialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, CXXConstructorDecl *InheritedCtor=nullptr, Sema::InheritedConstructorInfo *Inherited=nullptr)
Is the special member function which would be selected to perform the specified operation on the spec...
QualType getRecordType(const RecordDecl *Decl) const
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method)
Integrate another called method into the collected data.
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
void setHasTrivialSpecialMemberForCall()
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool 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)
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
static void PopulateKeysForFields(FieldDecl *Field, SmallVectorImpl< const void *> &IdealInits)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class.copy]p25)
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
The triviality of a method affected by "trivial_abi".
static bool CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S, SmallVectorImpl< SourceLocation > &ReturnStmts, SourceLocation &Cxx1yLoc, SourceLocation &Cxx2aLoc)
Check the provided statement is allowed in a constexpr function definition.
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...
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
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
Whether this function prototype has a trailing return type.
RecordDecl * getDecl() const
bool hasVariantMembers() const
Determine whether this class has any variant members.
noexcept(expression), evals to 'false'
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
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)
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
We are declaring an implicit special member function.
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.
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.
We are computing the exception specification for a defaulted special member function.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
bool hasSameTemplateName(TemplateName X, TemplateName Y)
Determine whether the given template names refer to the same template.
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
unsigned getNumHandlers() const
decl_iterator decls_begin() const
Expr * getSubExpr() const
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void setTrivialForCallFlags(CXXMethodDecl *MD)
Attr * clone(ASTContext &C) const
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.
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)
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)
unsigned getSpellingListIndex() const
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
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.
Qualifiers getMethodQuals() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
static CXXBaseSpecifier * findDirectBaseWithType(CXXRecordDecl *Derived, QualType DesiredBase, bool &AnyDependentBases)
Find the base specifier for a base class with the given type.
void actOnDelayedExceptionSpecification(Decl *Method, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member function (or member function template).
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
AccessSpecifier getAccess() const
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
bool isObjCObjectPointerType() const
A class for iterating through a result set and possibly filtering out results.
Direct list-initialization.
Represents a C++11 virt-specifier-seq.
static ConstructorUsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target, bool IsVirtual)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
bool isFunctionProtoType() const
static bool checkSimpleDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType, llvm::function_ref< ExprResult(SourceLocation, Expr *, unsigned)> GetInit)
void setIsParsingBaseSpecifiers()
bool hasUninstantiatedDefaultArg() const
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList *> Params, FriendUnion Friend, SourceLocation FriendLoc)
CXXRecordDecl * getOrigin() const
Retrieve the type from which this base-paths search began.
static bool BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, CXXBaseSpecifier *BaseSpec, bool IsInheritedVirtualBase, CXXCtorInitializer *&CXXBaseInit)
No entity found met the criteria.
static bool CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl)
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
SourceLocation getRAngleLoc() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
SourceLocation getInlineSpecLoc() const
void setExplicitlyDefaulted(bool ED=true)
State that this function is explicitly defaulted per C++0x.
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)
A POD class for pairing a NamedDecl* with an access specifier.
CXXConstructorDecl * getConstructor() const
StringRef getName() const
Return the actual identifier string.
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
SourceRange getRange() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
static void checkForMultipleExportedDefaultConstructors(Sema &S, CXXRecordDecl *Class)
Decl * ActOnExceptionDeclarator(Scope *S, Declarator &D)
ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch handler.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Base class for declarations which introduce a typedef-name.
const ComparisonCategoryInfo * lookupInfo(ComparisonCategoryType Kind) const
Return the cached comparison category information for the specified 'Kind'.
ast_type_traits::DynTypedNode Node
TLS with a dynamic initializer.
Represents a template argument.
TagTypeKind
The kind of a tag type.
static bool isInvalid(LocType Loc, bool *Invalid)
const ObjCInterfaceDecl * getClassInterface() const
bool hasNonTrivialCopyConstructorForCall() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Dataflow Directional Tag Classes.
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
static void DelegatingCycleHelper(CXXConstructorDecl *Ctor, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Valid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Invalid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Current, Sema &S)
bool isValid() const
Return true if this is a valid SourceLocation object.
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, const ParsedAttr &MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
const TemplateArgument & getArgument() const
not evaluated yet, for special member function
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static const TST TST_auto
method_iterator begin_overridden_methods() const
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
static void AddMostOverridenMethods(const CXXMethodDecl *MD, llvm::SmallPtrSetImpl< const CXXMethodDecl *> &Methods)
Add the most overriden methods from MD to Methods.
QualType getType() const
Get the type for which this source info wrapper provides information.
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
static bool InitializationHasSideEffects(const FieldDecl &FD)
bool hasTrivialDestructorForCall() const
Qualifiers getMethodQualifiers() 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.
The name of a declaration.
StmtClass getStmtClass() const
ArrayRef< QualType > exceptions() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
A mapping from each virtual member function to its set of final overriders.
unsigned getNumTemplateParameterLists() const
CXXRecordDecl * Record
The declaration for the comparison category type from the standard library.
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i...
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack...
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
semantics_iterator semantics_begin()
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
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...
SourceLocation getBeginLoc() const LLVM_READONLY
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...
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
void PushUsingDirective(UsingDirectiveDecl *UDir)
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
std::pair< CXXConstructorDecl *, bool > findConstructorForBase(CXXRecordDecl *Base, CXXConstructorDecl *Ctor) const
Find the constructor to use for inherited construction of a base class, and whether that base class c...
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
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 ...
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static void extendRight(SourceRange &R, SourceRange After)
QualType getCanonicalTypeInternal() const
SourceLocation getVirtualSpecLoc() const
Represents a C++ base or member initializer.
LanguageIDs
Represents the language in a linkage specification.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
This template specialization was declared or defined by an explicit specialization (C++ [temp...
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
void setConstexprKind(ConstexprSpecKind CSK)
bool hasNonTrivialObjCLifetime() const
IndirectFieldDecl * getIndirectMember() const
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
const llvm::APInt & getSize() const
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
bool isFunctionType() const
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)
The template argument is a type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Holds information about the various types of exception specification.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
void addDecl(Decl *D)
Add the declaration D into this context.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
void setInherited(bool I)
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Represents a base class of a C++ class.
bool hasTypename() const
Return true if the using declaration has 'typename'.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
This is a scope that can contain a declaration.
bool isObjCObjectType() const
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static const void * GetKeyForMember(ASTContext &Context, CXXCtorInitializer *Member)
A use of a default initializer in a constructor or in aggregate initialization.
EnumDecl * getStdAlignValT() const
bool isSet() const
Deprecated.
bool isLValueReferenceType() const
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
void setInvalidType(bool Val=true)
Reading or writing from this object requires a barrier call.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
QualType getParamType(unsigned i) const
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
TranslationUnitDecl * getTranslationUnitDecl() const
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
void Deallocate(void *Ptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static bool functionDeclHasDefaultArgument(const FunctionDecl *FD)
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
CallingConv getCallConv() const
ThreadStorageClassSpecifier
Thread storage-class-specifier.
void setImplicitMoveAssignmentIsDeleted()
Set that we attempted to declare an implicit move assignment operator, but overload resolution failed...
Describes the sequence of initializations required to initialize a given object or reference with a s...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
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 DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter, but we can't parse it yet because we're inside a class definition.
static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, llvm::APSInt &Size)
void popCodeSynthesisContext()
void setParam(unsigned i, ParmVarDecl *VD)
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
static bool hasOneRealArgument(MultiExprArg Args)
Determine whether the given list arguments contains exactly one "real" (non-default) argument...
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void setUnsupportedFriend(bool Unsupported)
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
Declaration of a class template.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool isVirtualSpecified() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
bool lambdaIsDefaultConstructibleAndAssignable() const
Determine whether this lambda should have an implicit default constructor and copy and move assignmen...
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
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.
Microsoft __declspec(nothrow) extension.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
SourceLocation getConstexprSpecLoc() const
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD)
Diagnose methods which overload virtual methods in a base class without overriding any...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool implicitCopyConstructorHasConstParam() const
Determine whether an implicit copy constructor for this type would have a parameter with a const-qual...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
void addAddressSpace(LangAS space)
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
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.
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
A trivial tuple used to represent a source range.
void setLexicalDeclContext(DeclContext *DC)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
bool isTranslationUnit() const
Expr * getRepAsExpr() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
bool tryResolveExplicitSpecifier(ExplicitSpecifier &ExplicitSpec)
tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
Represents a C++ namespace alias.
Decl * ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
No keyword precedes the qualified type name.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Represents C++ using-directive.
void DiagnoseAbstractType(const CXXRecordDecl *RD)
static Expr * CastForMoving(Sema &SemaRef, Expr *E, QualType T=QualType())
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
Describes an entity that is being initialized.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
attr::Kind getKind() const
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr *> Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
The global specifier '::'. There is no stored value.
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
The object is actually the complete object.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void setType(QualType newType)
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
Wrapper for source info for pointers.
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
SourceRange getSourceRange() const LLVM_READONLY
const LangOptions & getLangOpts() const
void WillReplaceSpecifier(bool ForceReplacement)
Wrapper for source info for block pointers.
void setDeletedAsWritten(bool D=true)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions, such as the default constructor, copy constructor, or destructor, to the given C++ class (C++ [special]p1).
An implicit 'self' parameter.
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
ExceptionSpecInfo ExceptionSpec
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
A deduction-guide name (a template-name)
Declaration of a template function.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
Represents an implicitly-generated value initialization of an object of a given type.
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
void setElaboratedKeywordLoc(SourceLocation Loc)
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
static bool checkLiteralOperatorTemplateParameterList(Sema &SemaRef, FunctionTemplateDecl *TpDecl)
static const ParsedAttr * getMSPropertyAttr(const ParsedAttributesView &list)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool isExternallyVisible() const
QualType getType() const
Return the type wrapped by this type source info.
A single template declaration.
bool isBeingDefined() const
Return true if this decl is currently being defined.
ConstructorUsingShadowDecl * getShadowDecl() const
noexcept(expression), evals to 'true'
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
decl_iterator decls_end() const
The triviality of a method unaffected by "trivial_abi".
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
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.
bool isNoDestroy(const ASTContext &) const
Do we need to emit an exit-time destructor for this variable?
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.