41 #include "llvm/ADT/STLExtras.h" 42 #include "llvm/ADT/SmallString.h" 43 #include "llvm/ADT/StringExtras.h" 47 using namespace clang;
59 class CheckDefaultArgumentVisitor
60 :
public StmtVisitor<CheckDefaultArgumentVisitor, bool> {
65 CheckDefaultArgumentVisitor(
Expr *defarg,
Sema *s)
66 : DefaultArg(defarg), S(s) {}
76 bool CheckDefaultArgumentVisitor::VisitExpr(
Expr *
Node) {
77 bool IsInvalid =
false;
79 IsInvalid |= Visit(SubStmt);
86 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
DeclRefExpr *DRE) {
88 if (
ParmVarDecl *Param = dyn_cast<ParmVarDecl>(Decl)) {
98 diag::err_param_default_argument_references_param)
99 << Param->getDeclName() << DefaultArg->getSourceRange();
100 }
else if (
VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) {
104 if (VDecl->isLocalVarDecl())
106 diag::err_param_default_argument_references_local)
107 << VDecl->getDeclName() << DefaultArg->getSourceRange();
114 bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
CXXThisExpr *ThisE) {
119 diag::err_param_default_argument_references_this)
123 bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
PseudoObjectExpr *POE) {
131 E = OVE->getSourceExpr();
132 assert(E &&
"pseudo-object binding without source expression?");
140 bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
LambdaExpr *Lambda) {
147 return S->
Diag(Lambda->
getBeginLoc(), diag::err_lambda_capture_default_arg);
160 Proto = Self->ResolveExceptionSpec(CallLoc, Proto);
177 llvm_unreachable(
"should not see unresolved exception specs here");
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 (NewGuide && NewGuide->isExplicitSpecified() !=
666 cast<CXXDeductionGuideDecl>(Old)->isExplicitSpecified()) {
668 << NewGuide->isExplicitSpecified();
678 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
696 Diag(Decomp.getLSquareLoc(), diag::err_decomp_decl_context)
697 << Decomp.getSourceRange();
701 if (!TemplateParamLists.empty()) {
704 Diag(TemplateParamLists.front()->getTemplateLoc(),
705 diag::err_decomp_decl_template);
709 Diag(Decomp.getLSquareLoc(),
710 !getLangOpts().CPlusPlus17
711 ? diag::ext_decomp_decl
713 ? diag::ext_decomp_decl_cond
714 : diag::warn_cxx14_compat_decomp_decl)
715 << Decomp.getSourceRange();
727 if (
auto SCS = DS.getStorageClassSpec()) {
729 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
731 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
733 BadSpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
735 if (DS.isConstexprSpecified()) {
736 BadSpecifiers.push_back(
"constexpr");
737 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
739 if (DS.isInlineSpecified()) {
740 BadSpecifiers.push_back(
"inline");
741 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
743 if (!BadSpecifiers.empty()) {
744 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
745 Err << (int)BadSpecifiers.size()
746 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
749 for (
auto Loc : BadSpecifierLocs)
761 UPPC_DeclarationType))
771 Diag(Decomp.getLSquareLoc(),
775 ? diag::err_decomp_decl_parens
776 : diag::err_decomp_decl_type)
794 ForVisibleRedeclaration);
795 LookupName(Previous, S,
808 FilterLookupForScope(Previous, DC, S, ConsiderLinkage,
810 if (!Previous.
empty()) {
812 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
813 Diag(Old->getLocation(), diag::note_previous_definition);
817 PushOnScopeChains(BD, S,
true);
818 Bindings.push_back(BD);
819 ParsingInitForAutoVars.insert(BD);
825 Decomp.getLSquareLoc());
827 ForVisibleRedeclaration);
830 bool AddToScope =
true;
832 ActOnVariableDeclarator(S, D, DC, TInfo, Previous,
836 CurContext->addHiddenDecl(New);
839 if (isInOpenMPDeclareTargetContext())
840 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
849 if ((int64_t)Bindings.size() != NumElems) {
850 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
851 << DecompType << (
unsigned)Bindings.size() << NumElems.toString(10)
852 << (NumElems < Bindings.size());
857 for (
auto *B : Bindings) {
862 E = GetInit(Loc, E.
get(), I++);
865 B->setBinding(ElemType, E.
get());
874 const llvm::APSInt &NumElems,
877 S, Bindings, Src, DecompType, NumElems, ElemType,
898 S, Bindings, Src, DecompType, llvm::APSInt::get(VT->
getNumElements()),
908 S, Bindings, Src, DecompType, llvm::APSInt::get(2),
919 llvm::raw_svector_ostream OS(SS);
924 Arg.getArgument().print(PrintingPolicy, OS);
934 auto DiagnoseMissing = [&] {
944 return DiagnoseMissing();
954 return DiagnoseMissing();
960 Result.suppressDiagnostics();
962 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
974 Loc, TraitTy, DiagID,
980 assert(RD &&
"specialization of class template is not a class?");
1002 llvm::APSInt &Size) {
1015 return IsTupleLike::NotTupleLike;
1024 : R(R), Args(Args) {}
1026 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1029 } Diagnoser(R, Args);
1045 return IsTupleLike::TupleLike;
1060 S, R, Loc,
"tuple_element", Args,
1061 diag::err_decomp_decl_std_tuple_element_not_specialized))
1067 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1078 struct BindingDiagnosticTrap {
1084 : S(S), Trap(S.
Diags), BD(BD) {}
1085 ~BindingDiagnosticTrap() {
1095 const llvm::APSInt &TupleSize) {
1096 if ((int64_t)Bindings.size() != TupleSize) {
1097 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1098 << DecompType << (
unsigned)Bindings.size() << TupleSize.toString(10)
1099 << (TupleSize < Bindings.size());
1103 if (Bindings.empty())
1112 bool UseMemberGet =
false;
1116 if (MemberGet.isAmbiguous())
1122 dyn_cast<FunctionTemplateDecl>(D->getUnderlyingDecl())) {
1124 if (TPL->
size() != 0 &&
1125 isa<NonTypeTemplateParmDecl>(TPL->
getParam(0))) {
1127 UseMemberGet =
true;
1136 for (
auto *B : Bindings) {
1137 BindingDiagnosticTrap Trap(S, B);
1159 MemberGet, &Args,
nullptr);
1193 B->getDeclName().getAsIdentifierInfo(), RefType,
1197 RefVD->setImplicit();
1199 RefVD->setInlineSpecified();
1200 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1205 E = Seq.
Perform(S, Entity, Kind, Init);
1211 RefVD->setInit(E.
get());
1212 RefVD->checkInitIsICE();
1220 B->setBinding(T, E.
get());
1244 ClassWithFields = RD;
1248 Paths.
setOrigin(const_cast<CXXRecordDecl*>(RD));
1256 for (
auto &
P : Paths) {
1260 BestPath->back().Base->getType())) {
1262 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1263 <<
false << RD << BestPath->back().Base->getType()
1264 <<
P.back().Base->getType();
1266 }
else if (
P.Access < BestPath->
Access) {
1272 QualType BaseType = BestPath->back().Base->getType();
1274 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1281 *BestPath, diag::err_decomp_decl_inaccessible_base);
1292 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1293 << (ClassWithFields == RD) << RD << ClassWithFields
1294 << Paths.
front().back().Base->getType();
1313 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1314 unsigned NumFields =
1315 std::count_if(RD->field_begin(), RD->field_end(),
1316 [](
FieldDecl *FD) {
return !FD->isUnnamedBitfield(); });
1317 assert(Bindings.size() != NumFields);
1318 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1319 << DecompType << (
unsigned)Bindings.size() << NumFields
1320 << (NumFields < Bindings.size());
1328 for (
auto *FD : RD->fields()) {
1329 if (FD->isUnnamedBitfield())
1332 if (FD->isAnonymousStructOrUnion()) {
1335 S.
Diag(FD->getLocation(), diag::note_declared_at);
1340 if (I >= Bindings.size())
1341 return DiagnoseBadNumberOfBindings();
1342 auto *B = Bindings[I++];
1350 Loc, const_cast<CXXRecordDecl *>(OrigRD),
1352 BasePair.
getAccess(), FD->getAccess())));
1375 if (FD->isMutable())
1380 if (I != Bindings.size())
1381 return DiagnoseBadNumberOfBindings();
1423 llvm::APSInt TupleSize(32);
1429 case IsTupleLike::TupleLike:
1434 case IsTupleLike::NotTupleLike:
1443 << DD << !RD << DecompType;
1462 if (!getLangOpts().CXXExceptions)
1466 "Should only be called if types are otherwise the same.");
1477 NewType =
P->getPointeeType();
1490 if (CheckEquivalentExceptionSpec(
1505 for (p = 0; p < NumParams; ++p) {
1517 unsigned LastMissingDefaultArg = 0;
1518 for (; p < NumParams; ++p) {
1525 diag::err_param_default_argument_missing_name)
1529 diag::err_param_default_argument_missing);
1531 LastMissingDefaultArg = p;
1535 if (LastMissingDefaultArg > 0) {
1540 for (p = 0; p <= LastMissingDefaultArg; ++p) {
1554 unsigned ArgIndex = 0;
1558 i != e; ++i, ++ArgIndex) {
1561 if (!(*i)->isDependentType() &&
1563 diag::err_constexpr_non_literal_param,
1565 isa<CXXConstructorDecl>(FD)))
1581 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1601 << isa<CXXConstructorDecl>(NewFD)
1603 for (
const auto &I : RD->
vbases())
1604 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
1605 << I.getSourceRange();
1610 if (!isa<CXXConstructorDecl>(NewFD)) {
1623 while (!WrittenVirtual->isVirtualAsWritten())
1625 if (WrittenVirtual != Method)
1626 Diag(WrittenVirtual->getLocation(),
1627 diag::note_overridden_virtual_function);
1635 diag::err_constexpr_non_literal_return))
1656 for (
const auto *DclIt : DS->
decls()) {
1657 switch (DclIt->getKind()) {
1658 case Decl::StaticAssert:
1660 case Decl::UsingShadow:
1661 case Decl::UsingDirective:
1662 case Decl::UnresolvedUsingTypename:
1663 case Decl::UnresolvedUsingValue:
1670 case Decl::TypeAlias: {
1673 const auto *TN = cast<TypedefNameDecl>(DclIt);
1674 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1676 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1679 << isa<CXXConstructorDecl>(Dcl);
1686 case Decl::CXXRecord:
1688 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition())
1691 ? diag::warn_cxx11_compat_constexpr_type_definition
1692 : diag::ext_constexpr_type_definition)
1693 << isa<CXXConstructorDecl>(Dcl);
1696 case Decl::EnumConstant:
1697 case Decl::IndirectField:
1704 case Decl::Decomposition: {
1708 const auto *VD = cast<VarDecl>(DclIt);
1709 if (VD->isThisDeclarationADefinition()) {
1710 if (VD->isStaticLocal()) {
1711 SemaRef.
Diag(VD->getLocation(),
1712 diag::err_constexpr_local_var_static)
1713 << isa<CXXConstructorDecl>(Dcl)
1717 if (!VD->getType()->isDependentType() &&
1719 VD->getLocation(), VD->getType(),
1720 diag::err_constexpr_local_var_non_literal_type,
1721 isa<CXXConstructorDecl>(Dcl)))
1723 if (!VD->getType()->isDependentType() &&
1724 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1725 SemaRef.
Diag(VD->getLocation(),
1726 diag::err_constexpr_local_var_no_init)
1727 << isa<CXXConstructorDecl>(Dcl);
1731 SemaRef.
Diag(VD->getLocation(),
1733 ? diag::warn_cxx11_compat_constexpr_local_var
1734 : diag::ext_constexpr_local_var)
1735 << isa<CXXConstructorDecl>(Dcl);
1739 case Decl::NamespaceAlias:
1748 SemaRef.
Diag(DS->
getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
1749 << isa<CXXConstructorDecl>(Dcl);
1768 llvm::SmallSet<Decl*, 16> &
Inits,
1785 if (!Inits.count(Field)) {
1787 SemaRef.
Diag(Dcl->
getLocation(), diag::err_constexpr_ctor_missing_init);
1790 SemaRef.
Diag(Field->
getLocation(), diag::note_constexpr_ctor_missing_init);
1793 for (
auto *I : RD->
fields())
1796 if (!RD->
isUnion() || Inits.count(I))
1809 case Stmt::NullStmtClass:
1813 case Stmt::DeclStmtClass:
1823 case Stmt::ReturnStmtClass:
1825 if (isa<CXXConstructorDecl>(Dcl)) {
1835 case Stmt::CompoundStmtClass: {
1841 for (
auto *BodyIt : CompStmt->
body()) {
1843 Cxx1yLoc, Cxx2aLoc))
1849 case Stmt::AttributedStmtClass:
1854 case Stmt::IfStmtClass: {
1859 IfStmt *If = cast<IfStmt>(S);
1861 Cxx1yLoc, Cxx2aLoc))
1865 Cxx1yLoc, Cxx2aLoc))
1870 case Stmt::WhileStmtClass:
1871 case Stmt::DoStmtClass:
1872 case Stmt::ForStmtClass:
1873 case Stmt::CXXForRangeStmtClass:
1874 case Stmt::ContinueStmtClass:
1884 Cxx1yLoc, Cxx2aLoc))
1888 case Stmt::SwitchStmtClass:
1889 case Stmt::CaseStmtClass:
1890 case Stmt::DefaultStmtClass:
1891 case Stmt::BreakStmtClass:
1899 Cxx1yLoc, Cxx2aLoc))
1903 case Stmt::CXXTryStmtClass:
1909 Cxx1yLoc, Cxx2aLoc))
1914 case Stmt::CXXCatchStmtClass:
1918 cast<CXXCatchStmt>(S)->getHandlerBlock(),
1919 ReturnStmts, Cxx1yLoc, Cxx2aLoc))
1934 << isa<CXXConstructorDecl>(Dcl);
1945 if (isa<CXXTryStmt>(Body)) {
1959 !getLangOpts().CPlusPlus2a
1960 ? diag::ext_constexpr_function_try_block_cxx2a
1961 : diag::warn_cxx17_compat_constexpr_function_try_block)
1962 << isa<CXXConstructorDecl>(Dcl);
1974 Cxx1yLoc, Cxx2aLoc))
1980 getLangOpts().CPlusPlus2a
1981 ? diag::warn_cxx17_compat_constexpr_body_invalid_stmt
1982 : diag::ext_constexpr_body_invalid_stmt_cxx2a)
1983 << isa<CXXConstructorDecl>(Dcl);
1986 getLangOpts().CPlusPlus14
1987 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
1988 : diag::ext_constexpr_body_invalid_stmt)
1989 << isa<CXXConstructorDecl>(Dcl);
1992 = dyn_cast<CXXConstructorDecl>(Dcl)) {
2001 if (Constructor->getNumCtorInitializers() == 0 &&
2006 }
else if (!Constructor->isDependentContext() &&
2007 !Constructor->isDelegatingConstructor()) {
2008 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
2012 bool AnyAnonStructUnionMembers =
false;
2013 unsigned Fields = 0;
2015 E = RD->
field_end(); I != E; ++I, ++Fields) {
2016 if (I->isAnonymousStructOrUnion()) {
2017 AnyAnonStructUnionMembers =
true;
2025 if (AnyAnonStructUnionMembers ||
2026 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
2030 llvm::SmallSet<Decl*, 16>
Inits;
2031 for (
const auto *I: Constructor->inits()) {
2035 Inits.insert(
ID->chain_begin(),
ID->chain_end());
2038 bool Diagnosed =
false;
2039 for (
auto *I : RD->
fields())
2046 if (ReturnStmts.empty()) {
2051 bool OK = getLangOpts().CPlusPlus14 &&
2055 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2056 : diag::err_constexpr_body_no_return);
2059 }
else if (ReturnStmts.size() > 1) {
2060 Diag(ReturnStmts.back(),
2061 getLangOpts().CPlusPlus14
2062 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2063 : diag::ext_constexpr_body_multiple_return);
2064 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2065 Diag(ReturnStmts[I], diag::note_constexpr_body_previous_return);
2081 Diag(Dcl->
getLocation(), diag::ext_constexpr_function_never_constant_expr)
2082 << isa<CXXConstructorDecl>(Dcl);
2083 for (
size_t I = 0, N = Diags.size(); I != N; ++I)
2084 Diag(Diags[I].first, Diags[I].second);
2101 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2108 return dyn_cast_or_null<CXXRecordDecl>(DC);
2111 return dyn_cast_or_null<CXXRecordDecl>(CurContext);
2128 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2130 if (!getLangOpts().SpellChecking)
2136 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2138 CurDecl = dyn_cast_or_null<CXXRecordDecl>(CurContext);
2140 if (CurDecl && CurDecl->getIdentifier() && II != CurDecl->getIdentifier() &&
2141 3 * II->
getName().edit_distance(CurDecl->getIdentifier()->getName())
2143 II = CurDecl->getIdentifier();
2158 for (
const auto &I : Current->
bases()) {
2170 Queue.push_back(Base);
2176 Current = Queue.pop_back_val();
2204 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2217 ((BaseDecl = BaseDecl->getDefinition()) &&
2219 Diag(BaseLoc, diag::err_circular_inheritance)
2223 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
2232 Access, TInfo, EllipsisLoc);
2237 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2244 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2251 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2253 propagateDLLAttrToBaseClassTemplate(Class, ClassAttr, BaseTemplate,
2262 if (RequireCompleteType(BaseLoc, BaseType,
2263 diag::err_incomplete_base_class, SpecifierRange)) {
2270 assert(BaseDecl &&
"Record type has no declaration");
2272 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2274 assert(CXXBaseDecl &&
"Base type is not a C++ type");
2279 const auto *BaseCSA = CXXBaseDecl->
getAttr<CodeSegAttr>();
2280 const auto *DerivedCSA = Class->
getAttr<CodeSegAttr>();
2281 if ((DerivedCSA || BaseCSA) &&
2282 (!BaseCSA || !DerivedCSA || BaseCSA->getName() != DerivedCSA->getName())) {
2284 Diag(CXXBaseDecl->
getLocation(), diag::note_base_class_specified_here)
2296 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2304 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
2305 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2307 << FA->isSpelledAsSealed();
2319 Access, TInfo, EllipsisLoc);
2336 AdjustDeclIfTemplate(classdecl);
2350 ? (unsigned)diag::warn_unknown_attribute_ignored
2351 : (
unsigned)diag::err_base_specifier_attribute)
2356 GetTypeFromParser(basetype, &TInfo);
2359 DiagnoseUnexpandedParameterPack(SpecifierRange.
getBegin(), TInfo,
2364 Virtual, Access, TInfo,
2385 auto Decl = Rec->getAsCXXRecordDecl();
2388 for (
const auto &BaseSpec : Decl->bases()) {
2390 .getUnqualifiedType();
2391 if (Set.insert(Base).second)
2409 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2413 IndirectBaseSet IndirectBaseTypes;
2416 unsigned NumGoodBases = 0;
2417 bool Invalid =
false;
2418 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2428 Diag(Bases[idx]->getBeginLoc(), diag::err_duplicate_base_class)
2429 << KnownBase->
getType() << Bases[idx]->getSourceRange();
2438 KnownBase = Bases[idx];
2439 Bases[NumGoodBases++] = Bases[idx];
2442 if (Bases.size() > 1)
2446 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
2458 Class->
addAttr(WeakAttr::CreateImplicit(Context));
2464 Class->
setBases(Bases.data(), NumGoodBases);
2467 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2469 QualType BaseType = Bases[idx]->getType();
2479 if (IndirectBaseTypes.count(CanonicalBase)) {
2483 = Class->
isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
2488 Diag(Bases[idx]->getBeginLoc(), diag::warn_inaccessible_base_class)
2489 << BaseType << getAmbiguousPathsDisplayString(Paths)
2490 << Bases[idx]->getSourceRange();
2492 assert(Bases[idx]->isVirtual());
2508 if (!ClassDecl || Bases.empty())
2511 AdjustDeclIfTemplate(ClassDecl);
2512 AttachBaseSpecifiers(cast<CXXRecordDecl>(ClassDecl), Bases);
2536 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2557 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2569 for (
unsigned I = Path.size(); I != 0; --I) {
2570 if (Path[I - 1].
Base->isVirtual()) {
2577 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
2578 BasePathArray.push_back(const_cast<CXXBaseSpecifier*>(Path[I].Base));
2584 assert(BasePathArray.empty() &&
"Base path array must be empty!");
2602 unsigned InaccessibleBaseID,
2603 unsigned AmbigiousBaseConvID,
2607 bool IgnoreAccess) {
2614 bool DerivationOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2615 if (!DerivationOkay)
2620 Path = &Paths.
front();
2625 if (!Path && getLangOpts().MSVCCompat) {
2627 if (PossiblePath.size() == 1) {
2628 Path = &PossiblePath;
2629 if (AmbigiousBaseConvID)
2630 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
2631 << Base << Derived << Range;
2638 if (!IgnoreAccess) {
2641 CheckBaseClassAccess(Loc, Base, Derived, *Path, InaccessibleBaseID)) {
2657 if (AmbigiousBaseConvID) {
2666 bool StillOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2667 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
2674 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
2676 Diag(Loc, AmbigiousBaseConvID)
2677 << Derived << Base << PathDisplayStr << Range << Name;
2686 bool IgnoreAccess) {
2687 return CheckDerivedToBaseConversion(
2688 Derived, Base, diag::err_upcast_to_inaccessible_base,
2689 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
2690 BasePath, IgnoreAccess);
2707 std::string PathDisplayStr;
2708 std::set<unsigned> DisplayedPaths;
2710 Path != Paths.
end(); ++Path) {
2711 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
2714 PathDisplayStr +=
"\n ";
2716 for (CXXBasePath::const_iterator Element = Path->begin();
2717 Element != Path->end(); ++Element)
2718 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
2722 return PathDisplayStr;
2733 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
2736 CurContext->addHiddenDecl(ASDecl);
2737 return ProcessAccessDeclAttributeList(ASDecl, Attrs);
2761 FindHiddenVirtualMethods(MD, OverloadedMethods);
2763 if (!OverloadedMethods.empty()) {
2764 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2765 Diag(OA->getLocation(),
2766 diag::override_keyword_hides_virtual_member_function)
2767 <<
"override" << (OverloadedMethods.size() > 1);
2768 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2769 Diag(FA->getLocation(),
2770 diag::override_keyword_hides_virtual_member_function)
2771 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2772 << (OverloadedMethods.size() > 1);
2774 NoteHiddenVirtualMethods(MD, OverloadedMethods);
2783 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2784 Diag(OA->getLocation(),
2785 diag::override_keyword_only_allowed_on_virtual_member_functions)
2789 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2790 Diag(FA->getLocation(),
2791 diag::override_keyword_only_allowed_on_virtual_member_functions)
2792 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2804 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
2805 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
2818 if (getSourceManager().isMacroArgExpansion(Loc))
2819 SpellingLoc = getSourceManager().getImmediateExpansionRange(Loc).getBegin();
2820 SpellingLoc = getSourceManager().getSpellingLoc(SpellingLoc);
2821 if (SpellingLoc.
isValid() && getSourceManager().isInSystemHeader(SpellingLoc))
2825 unsigned DiagID = isa<CXXDestructorDecl>(MD)
2826 ? diag::warn_destructor_marked_not_override_overriding
2827 : diag::warn_function_marked_not_override_overriding;
2839 FinalAttr *FA = Old->
getAttr<FinalAttr>();
2845 << FA->isSpelledAsSealed();
2854 return !RD->isCompleteDefinition() ||
2855 !RD->hasTrivialDefaultConstructor() ||
2856 !RD->hasTrivialDestructor();
2862 llvm::find_if(list, [](
const ParsedAttr &AL) {
2865 if (Itr != list.
end())
2875 if (Diags.isIgnored(diag::warn_shadow_field, Loc))
2879 std::map<CXXRecordDecl*, NamedDecl*> Bases;
2884 if (Bases.find(
Base) != Bases.end())
2886 for (
const auto Field :
Base->lookup(FieldName)) {
2887 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
2889 assert(Field->getAccess() !=
AS_none);
2890 assert(Bases.find(
Base) == Bases.end());
2891 Bases[
Base] = Field;
2903 for (
const auto &
P : Paths) {
2904 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
2905 auto It = Bases.find(
Base);
2907 if (It == Bases.end())
2909 auto BaseField = It->second;
2910 assert(BaseField->getAccess() !=
AS_private);
2913 Diag(Loc, diag::warn_shadow_field)
2914 << FieldName << RD <<
Base << DeclIsField;
2915 Diag(BaseField->getLocation(), diag::note_shadow_field);
2940 Expr *BitWidth =
static_cast<Expr*
>(BW);
2942 assert(isa<CXXRecordDecl>(CurContext));
2949 if (cast<CXXRecordDecl>(CurContext)->isInterface()) {
2953 unsigned InvalidDecl;
2954 bool ShowDeclName =
true;
2967 ShowDeclName =
false;
2972 ShowDeclName =
false;
2987 Diag(Loc, diag::err_invalid_member_in_interface)
2988 << (InvalidDecl-1) << Name;
2990 Diag(Loc, diag::err_invalid_member_in_interface)
2991 << (InvalidDecl-1) <<
"";
3017 diag::err_storageclass_invalid_for_member);
3037 const char *PrevSpec;
3042 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3046 const char *PrevSpec;
3052 "This is the only DeclSpec that should fail to be applied");
3056 isInstField =
false;
3067 Diag(Loc, diag::err_bad_variable_name)
3076 if (TemplateParameterLists.size()) {
3078 if (TemplateParams->
size()) {
3087 diag::err_template_member_noparams)
3102 if (
DeclContext *DC = computeDeclContext(SS,
false))
3113 if (MSPropertyAttr) {
3114 Member = HandleMSProperty(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3115 BitWidth, InitStyle, AS, *MSPropertyAttr);
3118 isInstField =
false;
3120 Member = HandleField(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3121 BitWidth, InitStyle, AS);
3126 CheckShadowInheritedFields(Loc, Name, cast<CXXRecordDecl>(CurContext));
3128 Member = HandleDeclarator(S, D, TemplateParameterLists);
3136 }
else if (isa<VarDecl>(Member) || isa<VarTemplateDecl>(Member)) {
3139 Diag(Loc, diag::err_static_not_bitfield)
3141 }
else if (isa<TypedefDecl>(Member)) {
3143 Diag(Loc, diag::err_typedef_not_bitfield)
3148 Diag(Loc, diag::err_not_integral_type_bitfield)
3149 << Name << cast<ValueDecl>(Member)->getType()
3159 NonTemplateMember = FunTmpl->getTemplatedDecl();
3160 else if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(Member))
3161 NonTemplateMember = VarTmpl->getTemplatedDecl();
3167 if (NonTemplateMember != Member)
3173 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3174 auto *TD = DG->getDeducedTemplate();
3175 if (AS != TD->getAccess()) {
3176 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
3177 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
3180 for (
const auto *D : cast<CXXRecordDecl>(CurContext)->decls()) {
3181 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(D))
3182 LastAccessSpec = AccessSpec;
3184 assert(LastAccessSpec &&
"differing access with no access specifier");
3185 Diag(LastAccessSpec->
getBeginLoc(), diag::note_deduction_guide_access)
3199 if (
CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(Member))
3203 CheckOverrideControl(Member);
3205 assert((Name || isInstField) &&
"No identifier for non-field ?");
3208 FieldDecl *FD = cast<FieldDecl>(Member);
3209 FieldCollector->Add(FD);
3211 if (!Diags.isIgnored(diag::warn_unused_private_field, FD->
getLocation())) {
3219 UnusedPrivateFields.insert(FD);
3227 class UninitializedFieldVisitor
3232 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3235 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3250 UninitializedFieldVisitor(
Sema &S,
3251 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3252 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3253 : Inherited(S.
Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3254 Constructor(
nullptr), InitList(
false), InitListFieldDecl(
nullptr) {}
3257 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3258 bool CheckReferenceOnly) {
3260 bool ReferenceField =
false;
3265 Fields.push_back(FD);
3267 ReferenceField =
true;
3273 if (CheckReferenceOnly && !ReferenceField)
3279 for (
auto I = Fields.rbegin() + 1, E = Fields.rend(); I != E; ++I) {
3280 UsedFieldIndex.push_back((*I)->getFieldIndex());
3283 for (
auto UsedIter = UsedFieldIndex.begin(),
3284 UsedEnd = UsedFieldIndex.end(),
3285 OrigIter = InitFieldIndex.begin(),
3286 OrigEnd = InitFieldIndex.end();
3287 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3288 if (*UsedIter < *OrigIter)
3290 if (*UsedIter > *OrigIter)
3297 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3312 if (isa<VarDecl>(SubME->getMemberDecl()))
3315 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3316 if (!FD->isAnonymousStructOrUnion())
3320 AllPODFields =
false;
3322 Base = SubME->getBase();
3328 if (AddressOf && AllPODFields)
3334 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3335 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
3338 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3348 if (!Decls.count(FoundVD))
3353 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3355 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3360 if (CheckReferenceOnly && !IsReference)
3364 unsigned diag = IsReference
3365 ? diag::warn_reference_field_is_uninit
3366 : diag::warn_field_is_uninit;
3370 diag::note_uninit_in_this_constructor)
3375 void HandleValue(
Expr *E,
bool AddressOf) {
3378 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3379 HandleMemberExpr(ME,
false ,
3385 Visit(CO->getCond());
3386 HandleValue(CO->getTrueExpr(), AddressOf);
3387 HandleValue(CO->getFalseExpr(), AddressOf);
3392 dyn_cast<BinaryConditionalOperator>(E)) {
3393 Visit(BCO->getCond());
3394 HandleValue(BCO->getFalseExpr(), AddressOf);
3399 HandleValue(OVE->getSourceExpr(), AddressOf);
3404 switch (BO->getOpcode()) {
3409 HandleValue(BO->getLHS(), AddressOf);
3410 Visit(BO->getRHS());
3413 Visit(BO->getLHS());
3414 HandleValue(BO->getRHS(), AddressOf);
3423 InitFieldIndex.push_back(0);
3424 for (
auto Child : ILE->
children()) {
3425 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3426 CheckInitListExpr(SubList);
3430 ++InitFieldIndex.back();
3432 InitFieldIndex.pop_back();
3441 DeclsToRemove.clear();
3443 Constructor = FieldConstructor;
3448 InitListFieldDecl = Field;
3449 InitFieldIndex.clear();
3450 CheckInitListExpr(ILE);
3464 HandleMemberExpr(ME,
true ,
false );
3473 Inherited::VisitImplicitCastExpr(E);
3479 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3483 if (ICE->getCastKind() == CK_NoOp)
3484 ArgExpr = ICE->getSubExpr();
3485 HandleValue(ArgExpr,
false );
3488 Inherited::VisitCXXConstructExpr(E);
3493 if (isa<MemberExpr>(Callee)) {
3494 HandleValue(Callee,
false );
3500 Inherited::VisitCXXMemberCallExpr(E);
3506 HandleValue(E->
getArg(0),
false);
3510 Inherited::VisitCallExpr(E);
3516 if (isa<UnresolvedLookupExpr>(Callee))
3517 return Inherited::VisitCXXOperatorCallExpr(E);
3521 HandleValue(Arg->IgnoreParenImpCasts(),
false );
3530 if (!FD->getType()->isReferenceType())
3531 DeclsToRemove.push_back(FD);
3534 HandleValue(E->
getLHS(),
false );
3539 Inherited::VisitBinaryOperator(E);
3549 HandleValue(ME->
getBase(),
true );
3554 Inherited::VisitUnaryOperator(E);
3564 static void DiagnoseUninitializedFields(
3581 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
3584 for (
auto *I : RD->
decls()) {
3585 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
3586 UninitializedFields.insert(FD);
3587 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
3588 UninitializedFields.insert(IFD->getAnonField());
3592 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
3593 for (
auto I : RD->
bases())
3594 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
3596 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3599 UninitializedFieldVisitor UninitializedChecker(SemaRef,
3600 UninitializedFields,
3601 UninitializedBaseClasses);
3603 for (
const auto *FieldInit : Constructor->
inits()) {
3604 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3607 Expr *InitExpr = FieldInit->getInit();
3612 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
3613 InitExpr =
Default->getExpr();
3617 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
3618 FieldInit->getAnyMember(),
3619 FieldInit->getBaseClass());
3621 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
3622 FieldInit->getAnyMember(),
3623 FieldInit->getBaseClass());
3635 PushFunctionScope();
3645 PopFunctionScopeInfo(
nullptr, D);
3649 "must set init style when field is created");
3658 if (DiagnoseUnexpandedParameterPack(InitExpr, UPPC_Initializer)) {
3675 Init = Seq.Perform(*
this, Entity, Kind, InitExpr);
3685 Init = ActOnFinishFullExpr(Init.
get(), InitLoc,
false);
3691 InitExpr = Init.
get();
3705 DirectBaseSpec =
nullptr;
3706 for (
const auto &
Base : ClassDecl->
bases()) {
3710 DirectBaseSpec = &
Base;
3718 VirtualBaseSpec =
nullptr;
3719 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
3728 Path != Paths.
end(); ++Path) {
3729 if (Path->back().Base->isVirtual()) {
3730 VirtualBaseSpec = Path->back().Base;
3737 return DirectBaseSpec || VirtualBaseSpec;
3751 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
3752 DS, IdLoc, InitList,
3770 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
3771 DS, IdLoc, List, EllipsisLoc);
3780 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
3781 : ClassDecl(ClassDecl) {}
3783 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
3785 if (
FieldDecl *Member = dyn_cast<FieldDecl>(ND))
3787 return isa<TypeDecl>(ND);
3808 if ((Member = dyn_cast<FieldDecl>(Result.
front())) ||
3825 ExprResult Res = CorrectDelayedTyposInExpr(Init);
3833 AdjustDeclIfTemplate(ConstructorD);
3859 if (
ValueDecl *Member = tryLookupCtorInitMemberDecl(
3860 ClassDecl, SS, TemplateTypeTy, MemberOrBase)) {
3862 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
3866 return BuildMemberInitializer(Member, Init, IdLoc);
3872 if (TemplateTypeTy) {
3873 BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo);
3880 LookupResult R(*
this, MemberOrBase, IdLoc, LookupOrdinaryName);
3881 LookupParsedName(R, S, &SS);
3890 if (SS.
isSet() && isDependentScopeSpecifier(SS)) {
3891 bool NotUnknownSpecialization =
false;
3893 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
3894 NotUnknownSpecialization = !Record->hasAnyDependentBases();
3896 if (!NotUnknownSpecialization) {
3901 *MemberOrBase, IdLoc);
3922 (Corr = CorrectTypo(
3924 llvm::make_unique<MemInitializerValidatorCCC>(ClassDecl),
3925 CTK_ErrorRecovery, ClassDecl))) {
3931 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3932 << MemberOrBase <<
true);
3933 return BuildMemberInitializer(Member, Init, IdLoc);
3939 DirectBaseSpec, VirtualBaseSpec)) {
3944 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3945 << MemberOrBase <<
false,
3958 if (!TyD && BaseType.
isNull()) {
3959 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
3967 MarkAnyDeclReferenced(TyD->
getLocation(), TyD,
false);
3983 return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, EllipsisLoc);
3991 assert((DirectMember || IndirectMember) &&
3992 "Member must be a FieldDecl or IndirectFieldDecl");
3994 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4001 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4002 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4003 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
4004 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
4015 DiscardCleanupsInEvaluationContext();
4017 bool InitList =
false;
4018 if (isa<InitListExpr>(Init)) {
4035 ExprResult MemberInit = InitSeq.Perform(*
this, MemberEntity, Kind, Args,
4043 MemberInit = ActOnFinishFullExpr(MemberInit.
get(), InitRange.
getBegin(),
4048 Init = MemberInit.
get();
4066 if (!LangOpts.CPlusPlus11)
4067 return Diag(NameLoc, diag::err_delegating_ctor)
4069 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4071 bool InitList =
true;
4073 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4075 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4086 InitRange.getEnd());
4088 ExprResult DelegationInit = InitSeq.Perform(*
this, DelegationEntity, Kind,
4093 assert(cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor() &&
4094 "Delegating constructor with no target?");
4099 DelegationInit = ActOnFinishFullExpr(
4100 DelegationInit.get(), InitRange.getBegin(),
false);
4101 if (DelegationInit.isInvalid())
4111 if (CurContext->isDependentContext())
4112 DelegationInit = Init;
4115 DelegationInit.getAs<
Expr>(),
4116 InitRange.getEnd());
4127 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4142 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4149 if (DiagnoseUnexpandedParameterPack(BaseLoc, BaseTInfo, UPPC_Initializer))
4152 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4162 return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
4171 if (!DirectBaseSpec && !VirtualBaseSpec) {
4180 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4187 DiscardCleanupsInEvaluationContext();
4192 InitRange.
getEnd(), EllipsisLoc);
4199 if (DirectBaseSpec && VirtualBaseSpec)
4200 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4205 BaseSpec = VirtualBaseSpec;
4208 bool InitList =
true;
4210 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4212 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4222 ExprResult BaseInit = InitSeq.Perform(*
this, BaseEntity, Kind, Args,
nullptr);
4229 BaseInit = ActOnFinishFullExpr(BaseInit.
get(), InitRange.
getBegin(),
4241 if (CurContext->isDependentContext())
4248 InitRange.
getEnd(), EllipsisLoc);
4253 if (T.isNull()) T = E->
getType();
4258 TargetType, ExprLoc);
4278 bool IsInheritedVirtualBase,
4282 IsInheritedVirtualBase);
4286 switch (ImplicitInitKind) {
4292 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
None);
4298 bool Moving = ImplicitInitKind ==
IIK_Move;
4320 BasePath.push_back(BaseSpec);
4322 CK_UncheckedDerivedToBase,
4330 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4353 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
4368 bool Moving = ImplicitInitKind ==
IIK_Move;
4376 Expr *MemberExprBase =
4391 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
4393 MemberLookup.resolveKind();
4427 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
4442 "Unhandled implicit init kind!");
4458 InitSeq.
Perform(SemaRef, InitEntity, InitKind,
None);
4481 diag::err_uninitialized_member_in_ctor)
4491 diag::err_uninitialized_member_in_ctor)
4512 CXXMemberInit =
nullptr;
4517 struct BaseAndFieldInfo {
4520 bool AnyErrorsInInits;
4522 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
4524 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
4527 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
4539 bool isImplicitCopyOrMove()
const {
4550 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
4554 AllToInit.push_back(Init);
4563 bool isInactiveUnionMember(
FieldDecl *Field) {
4573 if (isImplicitCopyOrMove())
4591 bool isWithinInactiveUnionMember(
FieldDecl *Field,
4594 return isInactiveUnionMember(Field);
4596 for (
auto *
C : Indirect->
chain()) {
4598 if (Field && isInactiveUnionMember(Field))
4613 if (!ArrayT->getSize())
4616 T = ArrayT->getElementType();
4631 return Info.addFieldInitializer(Init);
4645 if (Info.isWithinInactiveUnionMember(Field, Indirect))
4666 return Info.addFieldInitializer(Init);
4676 if (Info.AnyErrorsInInits)
4687 return Info.addFieldInitializer(Init);
4705 DelegatingCtorDecls.push_back(Constructor);
4707 DiagnoseUninitializedFields(*
this, Constructor);
4717 if (!Initializers.empty()) {
4721 memcpy(baseOrMemberInitializers, Initializers.data(),
4733 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
4741 bool HadError =
false;
4743 for (
unsigned i = 0; i < Initializers.size(); i++) {
4752 for (
auto *
C : F->chain()) {
4755 Info.ActiveUnionMember.insert(std::make_pair(
4759 if (FD->getParent()->isUnion())
4760 Info.ActiveUnionMember.insert(std::make_pair(
4761 FD->getParent()->getCanonicalDecl(), FD->getCanonicalDecl()));
4767 llvm::SmallPtrSet<CXXBaseSpecifier *, 16> DirectVBases;
4768 for (
auto &I : ClassDecl->
bases()) {
4770 DirectVBases.insert(&I);
4774 for (
auto &VBase : ClassDecl->
vbases()) {
4776 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
4784 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
4785 << VBase.getType() << ClassDecl;
4786 DiagnoseAbstractType(ClassDecl);
4789 Info.AllToInit.push_back(
Value);
4790 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
4795 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
4798 &VBase, IsInheritedVirtualBase,
4804 Info.AllToInit.push_back(CXXBaseInit);
4811 if (
Base.isVirtual())
4815 = Info.AllBaseFields.lookup(
Base.getType()->getAs<
RecordType>())) {
4816 Info.AllToInit.push_back(
Value);
4817 }
else if (!AnyErrors) {
4826 Info.AllToInit.push_back(CXXBaseInit);
4831 for (
auto *Mem : ClassDecl->
decls()) {
4832 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
4837 if (F->isUnnamedBitfield())
4843 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
4852 if (Info.isImplicitCopyOrMove())
4855 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
4856 if (F->getType()->isIncompleteArrayType()) {
4858 "Incomplete array type is not valid");
4870 unsigned NumInitializers = Info.AllToInit.size();
4871 if (NumInitializers > 0) {
4875 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
4881 MarkBaseAndMemberDestructorsReferenced(Constructor->
getLocation(),
4892 for (
auto *Field : RD->
fields())
4920 bool ShouldCheckOrder =
false;
4921 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4923 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
4925 ShouldCheckOrder =
true;
4929 if (!ShouldCheckOrder)
4940 for (
const auto &VBase : ClassDecl->
vbases())
4944 for (
const auto &
Base : ClassDecl->
bases()) {
4945 if (
Base.isVirtual())
4951 for (
auto *Field : ClassDecl->
fields()) {
4952 if (Field->isUnnamedBitfield())
4958 unsigned NumIdealInits = IdealInitKeys.size();
4959 unsigned IdealIndex = 0;
4962 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4968 for (; IdealIndex != NumIdealInits; ++IdealIndex)
4969 if (InitKey == IdealInitKeys[IdealIndex])
4975 if (IdealIndex == NumIdealInits && PrevInit) {
4978 diag::warn_initializer_out_of_order);
4991 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
4992 if (InitKey == IdealInitKeys[IdealIndex])
4995 assert(IdealIndex < NumIdealInits &&
4996 "initializer not found in initializer list");
5004 bool CheckRedundantInit(
Sema &S,
5014 diag::err_multiple_mem_initialization)
5015 << Field->getDeclName()
5019 assert(BaseClass &&
"neither field nor base");
5021 diag::err_multiple_base_initialization)
5031 typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5032 typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5034 bool CheckRedundantUnionInit(
Sema &S,
5036 RedundantUnionMap &Unions) {
5043 UnionEntry &En = Unions[
Parent];
5044 if (En.first && En.first != Child) {
5046 diag::err_multiple_mem_union_initialization)
5049 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5050 << 0 << En.second->getSourceRange();
5074 if (!ConstructorDecl)
5077 AdjustDeclIfTemplate(ConstructorDecl);
5083 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5090 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5093 RedundantUnionMap MemberUnions;
5095 bool HadError =
false;
5096 for (
unsigned i = 0; i < MemInits.size(); i++) {
5104 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
5105 CheckRedundantUnionInit(*
this, Init, MemberUnions))
5109 if (CheckRedundantInit(*
this, Init, Members[Key]))
5114 if (MemInits.size() != 1) {
5116 diag::err_delegating_initializer_alone)
5117 << Init->
getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5120 SetDelegatingInitializer(Constructor, MemInits[i]);
5131 SetCtorInitializers(Constructor, AnyErrors, MemInits);
5133 DiagnoseUninitializedFields(*
this, Constructor);
5150 for (
auto *Field : ClassDecl->
fields()) {
5151 if (Field->isInvalidDecl())
5174 assert(Dtor &&
"No dtor found for FieldClassDecl!");
5175 CheckDestructorAccess(Field->getLocation(), Dtor,
5176 PDiag(diag::err_access_dtor_field)
5177 << Field->getDeclName()
5180 MarkFunctionReferenced(Location, Dtor);
5181 DiagnoseUseOfDecl(Dtor, Location);
5186 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5188 llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
5191 for (
const auto &
Base : ClassDecl->
bases()) {
5196 if (
Base.isVirtual()) {
5197 if (!VisitVirtualBases)
5199 DirectVirtualBases.insert(RT);
5210 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5213 CheckDestructorAccess(
Base.getBeginLoc(), Dtor,
5214 PDiag(diag::err_access_dtor_base)
5215 <<
Base.getType() <<
Base.getSourceRange(),
5218 MarkFunctionReferenced(Location, Dtor);
5219 DiagnoseUseOfDecl(Dtor, Location);
5222 if (!VisitVirtualBases)
5226 for (
const auto &VBase : ClassDecl->
vbases()) {
5231 if (DirectVirtualBases.count(RT))
5242 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5243 if (CheckDestructorAccess(
5245 PDiag(diag::err_access_dtor_vbase)
5249 CheckDerivedToBaseConversion(
5251 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5255 MarkFunctionReferenced(Location, Dtor);
5256 DiagnoseUseOfDecl(Dtor, Location);
5265 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5266 SetCtorInitializers(Constructor,
false);
5267 DiagnoseUninitializedFields(*
this, Constructor);
5294 if (!isAbstractType(Loc, T))
5306 if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
5312 if (Diags.isLastDiagnosticIgnored())
5320 llvm::SmallPtrSet<const CXXMethodDecl *, 8> SeenPureMethods;
5322 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5323 MEnd = FinalOverriders.end();
5327 SOEnd = M->second.end();
5328 SO != SOEnd; ++SO) {
5335 if (SO->second.size() != 1)
5338 if (!SO->second.front().Method->isPure())
5341 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5344 Diag(SO->second.front().Method->getLocation(),
5345 diag::note_pure_virtual_function)
5346 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5350 if (!PureVirtualClassDiagSet)
5352 PureVirtualClassDiagSet->insert(RD);
5356 struct AbstractUsageInfo {
5363 : S(S), Record(Record),
5368 void DiagnoseAbstractType() {
5369 if (Invalid)
return;
5377 struct CheckAbstractUsage {
5378 AbstractUsageInfo &Info;
5381 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
5382 : Info(Info), Ctx(Ctx) {}
5386 #define ABSTRACT_TYPELOC(CLASS, PARENT) 5387 #define TYPELOC(CLASS, PARENT) \ 5388 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break; 5389 #include "clang/AST/TypeLocNodes.def" 5395 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
5410 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
5420 #define CheckPolymorphic(Type) \ 5421 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \ 5422 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \ 5437 return Visit(Next, Sel);
5447 T = Info.S.Context.getBaseElementType(T);
5450 if (CT != Info.AbstractType)
return;
5454 Info.S.Diag(Ctx->
getLocation(), diag::err_array_of_abstract_type)
5457 Info.S.Diag(Ctx->
getLocation(), diag::err_abstract_type_in_decl)
5460 Info.DiagnoseAbstractType();
5466 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
5489 for (
auto *D : RD->
decls()) {
5490 if (D->isImplicit())
continue;
5493 if (isa<CXXMethodDecl>(D)) {
5495 }
else if (isa<FunctionTemplateDecl>(D)) {
5496 FunctionDecl *FD = cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
5500 }
else if (isa<FieldDecl>(D)) {
5504 }
else if (isa<VarDecl>(D)) {
5505 VarDecl *VD = cast<VarDecl>(D);
5510 }
else if (isa<CXXRecordDecl>(D)) {
5512 }
else if (isa<ClassTemplateDecl>(D)) {
5514 cast<ClassTemplateDecl>(D)->getTemplatedDecl());
5524 assert(ClassAttr->
getKind() == attr::DLLExport);
5536 for (Decl *Member : Class->
decls()) {
5539 auto *VD = dyn_cast<
VarDecl>(Member);
5540 if (VD && Member->getAttr<DLLExportAttr>() &&
5549 if (Member->getAttr<DLLExportAttr>()) {
5550 if (MD->isUserProvided()) {
5561 }
else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
5562 MD->isCopyAssignmentOperator() ||
5563 MD->isMoveAssignmentOperator()) {
5592 for (Decl *Member : Class->
decls()) {
5595 if (!CD || !CD->isDefaultConstructor())
5597 auto *
Attr = CD->getAttr<DLLExportAttr>();
5610 if (LastExportedDefaultCtor) {
5612 diag::err_attribute_dll_ambiguous_default_ctor)
5614 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
5615 << CD->getDeclName();
5618 LastExportedDefaultCtor = CD;
5624 for (
auto *Method : Class->
methods()) {
5625 if (Method->isUserProvided())
5627 if (
Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method,
true))
5638 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
5639 if (
Attr *TemplateAttr =
5640 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
5641 auto *A = cast<InheritableAttr>(TemplateAttr->clone(getASTContext()));
5642 A->setInherited(
true);
5653 << Class << ClassAttr;
5660 for (Decl *Member : Class->
decls()) {
5661 if (!isa<VarDecl>(Member) && !isa<CXXMethodDecl>(Member))
5664 if (!MemberAttr || MemberAttr->
isInherited() || Member->isInvalidDecl())
5668 diag::err_attribute_dll_member_of_dll_class)
5669 << MemberAttr << ClassAttr;
5671 Member->setInvalidDecl();
5680 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
5685 const bool PropagatedImport =
5687 cast<DLLImportAttr>(ClassAttr)->wasPropagatedToBaseTemplate();
5699 ForceDeclarationOfImplicitMembers(Class);
5704 for (Decl *Member : Class->
decls()) {
5714 if (MD->isDeleted())
5717 if (MD->isInlined()) {
5727 if ((MD->isMoveAssignmentOperator() ||
5728 (Ctor && Ctor->isMoveConstructor())) &&
5735 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->isTrivial())
5742 if (VD && PropagatedImport)
5745 if (!cast<NamedDecl>(Member)->isExternallyVisible())
5753 if (!getLangOpts().DllExportInlines && MD && MD->isInlined() &&
5756 if (ClassExported) {
5757 NewAttr = ::new (getASTContext())
5758 DLLExportStaticLocalAttr(ClassAttr->
getRange(),
5762 NewAttr = ::new (getASTContext())
5763 DLLImportStaticLocalAttr(ClassAttr->
getRange(),
5768 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5772 Member->addAttr(NewAttr);
5782 "friend re-decl should not already have a DLLAttr");
5783 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5785 FD->addAttr(NewAttr);
5792 DelayedDllExportClasses.push_back(Class);
5813 auto *NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5814 NewAttr->setInherited(
true);
5815 BaseTemplateSpec->
addAttr(NewAttr);
5819 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
5820 ImportAttr->setPropagatedToBaseTemplate();
5826 checkClassLevelDLLAttribute(BaseTemplateSpec);
5841 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
5846 diag::note_template_class_explicit_specialization_was_here)
5847 << BaseTemplateSpec;
5850 diag::note_template_class_instantiation_was_here)
5851 << BaseTemplateSpec;
5860 cast<CXXConstructorDecl>(MD));
5878 llvm_unreachable(
"Invalid special member.");
5889 if (D->
hasAttr<TrivialABIAttr>())
5899 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
5900 bool DtorIsTrivialForCall =
false;
5911 CopyCtorIsTrivial =
true;
5913 CopyCtorIsTrivialForCall =
true;
5917 if (CD->isCopyConstructor() && !CD->isDeleted()) {
5918 if (CD->isTrivial())
5919 CopyCtorIsTrivial =
true;
5920 if (CD->isTrivialForCall())
5921 CopyCtorIsTrivialForCall =
true;
5929 DtorIsTrivialForCall =
true;
5931 if (!DD->isDeleted() && DD->isTrivialForCall())
5932 DtorIsTrivialForCall =
true;
5936 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
5949 if (CopyCtorIsTrivial &&
5959 bool HasNonDeletedCopyOrMove =
false;
5965 HasNonDeletedCopyOrMove =
true;
5972 HasNonDeletedCopyOrMove =
true;
5980 if (MD->isDeleted())
5984 if (CD && CD->isCopyOrMoveConstructor())
5985 HasNonDeletedCopyOrMove =
true;
5986 else if (!isa<CXXDestructorDecl>(MD))
5989 if (!MD->isTrivialForCall())
5993 return HasNonDeletedCopyOrMove;
6004 AbstractUsageInfo Info(*
this, Record);
6014 bool Complained =
false;
6015 for (
const auto *F : Record->
fields()) {
6016 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
6019 if (F->getType()->isReferenceType() ||
6020 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
6027 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
6028 << F->getType()->isReferenceType()
6029 << F->getDeclName();
6047 if (((isa<FieldDecl>(D) || isa<UnresolvedUsingValueDecl>(D)) &&
6049 isa<IndirectFieldDecl>(D)) {
6050 Diag((*I)->getLocation(), diag::err_member_name_of_class)
6061 !Record->
hasAttr<FinalAttr>())
6063 diag::warn_non_virtual_dtor) << Context.
getRecordType(Record);
6067 if (FinalAttr *FA = Record->
getAttr<FinalAttr>()) {
6069 << FA->isSpelledAsSealed();
6070 DiagnoseAbstractType(Record);
6075 if (Record->
hasAttr<TrivialABIAttr>())
6076 checkIllFormedTrivialABIStruct(*Record);
6080 bool HasTrivialABI = Record->
hasAttr<TrivialABIAttr>();
6085 bool HasMethodWithOverrideControl =
false,
6086 HasOverridingMethodWithoutOverrideControl =
false;
6088 for (
auto *M : Record->
methods()) {
6092 DiagnoseHiddenVirtualMethods(M);
6093 if (M->hasAttr<OverrideAttr>())
6094 HasMethodWithOverrideControl =
true;
6095 else if (M->size_overridden_methods() > 0)
6096 HasOverridingMethodWithoutOverrideControl =
true;
6098 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted())
6099 CheckExplicitlyDefaultedSpecialMember(M);
6104 if (!M->isImplicit() && !M->isUserProvided()) {
6105 if (CSM != CXXInvalid) {
6106 M->setTrivial(SpecialMemberIsTrivial(M, CSM));
6109 M->setTrivialForCall(
6111 SpecialMemberIsTrivial(M, CSM, TAH_ConsiderTrivialABI));
6118 if ((CSM == CXXCopyConstructor || CSM == CXXMoveConstructor ||
6119 CSM == CXXDestructor) && M->isUserProvided()) {
6120 M->setTrivialForCall(HasTrivialABI);
6124 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
6125 M->hasAttr<DLLExportAttr>()) {
6128 (CSM == CXXDefaultConstructor || CSM == CXXCopyConstructor ||
6129 CSM == CXXDestructor))
6130 M->dropAttr<DLLExportAttr>();
6132 if (M->hasAttr<DLLExportAttr>()) {
6134 ActOnFinishInlineFunctionDef(M);
6140 if (HasMethodWithOverrideControl &&
6141 HasOverridingMethodWithoutOverrideControl) {
6144 for (
auto *M : Record->
methods())
6145 DiagnoseAbsenceOfOverrideControl(M);
6162 checkClassLevelDLLAttribute(Record);
6163 checkClassLevelCodeSegAttribute(Record);
6165 bool ClangABICompat4 =
6187 if (getLangOpts().ForceEmitVTables) {
6205 unsigned FieldQuals,
bool ConstRHS) {
6206 unsigned LHSQuals = 0;
6208 LHSQuals = FieldQuals;
6210 unsigned RHSQuals = FieldQuals;
6220 LHSQuals & Qualifiers::Const,
6221 LHSQuals & Qualifiers::Volatile);
6231 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
6237 : S(S), UseLoc(UseLoc) {
6238 bool DiagnosedMultipleConstructedBases =
false;
6240 UsingDecl *ConstructedBaseUsing =
nullptr;
6244 for (
auto *D : Shadow->
redecls()) {
6245 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
6246 auto *DNominatedBase = DShadow->getNominatedBaseClass();
6247 auto *DConstructedBase = DShadow->getConstructedBaseClass();
6249 InheritedFromBases.insert(
6250 std::make_pair(DNominatedBase->getCanonicalDecl(),
6251 DShadow->getNominatedBaseClassShadowDecl()));
6252 if (DShadow->constructsVirtualBase())
6253 InheritedFromBases.insert(
6254 std::make_pair(DConstructedBase->getCanonicalDecl(),
6255 DShadow->getConstructedBaseClassShadowDecl()));
6257 assert(DNominatedBase == DConstructedBase);
6262 if (!ConstructedBase) {
6263 ConstructedBase = DConstructedBase;
6264 ConstructedBaseUsing = D->getUsingDecl();
6265 }
else if (ConstructedBase != DConstructedBase &&
6267 if (!DiagnosedMultipleConstructedBases) {
6268 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
6271 diag::note_ambiguous_inherited_constructor_using)
6273 DiagnosedMultipleConstructedBases =
true;
6275 S.
Diag(D->getUsingDecl()->getLocation(),
6276 diag::note_ambiguous_inherited_constructor_using)
6277 << DConstructedBase;
6281 if (DiagnosedMultipleConstructedBases)
6288 std::pair<CXXConstructorDecl *, bool>
6291 if (It == InheritedFromBases.end())
6292 return std::make_pair(
nullptr,
false);
6296 return std::make_pair(
6298 It->second->constructsVirtualBase());
6301 return std::make_pair(Ctor,
false);
6315 if (InheritedCtor) {
6318 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
6320 return BaseCtor->isConstexpr();
6384 if (Ctor && ClassDecl->
isUnion())
6403 for (
const auto &B : ClassDecl->
bases()) {
6405 if (!BaseType)
continue;
6409 InheritedCtor, Inherited))
6420 for (
const auto *F : ClassDecl->
fields()) {
6421 if (F->isInvalidDecl())
6427 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
6430 ConstArg && !F->isMutable()))
6452 auto *CD = cast<CXXConstructorDecl>(MD);
6453 assert(CD->getInheritedConstructor() &&
6454 "only special members have implicit exception specs");
6456 S, Loc, CD->getInheritedConstructor().getShadowDecl());
6483 auto ESI = IES.getExceptionSpec();
6486 UpdateExceptionSpec(MD, ESI);
6502 "not an explicitly-defaulted special member");
6508 bool HadError =
false;
6520 bool DeleteOnTypeMismatch = getLangOpts().CPlusPlus2a &&
First;
6521 bool ShouldDeleteForTypeMismatch =
false;
6522 unsigned ExpectedParams = 1;
6523 if (CSM == CXXDefaultConstructor || CSM == CXXDestructor)
6533 if (DeleteOnTypeMismatch)
6534 ShouldDeleteForTypeMismatch =
true;
6544 bool CanHaveConstParam =
false;
6545 if (CSM == CXXCopyConstructor)
6547 else if (CSM == CXXCopyAssignment)
6551 if (CSM == CXXCopyAssignment || CSM == CXXMoveAssignment) {
6559 if (!Context.
hasSameType(ReturnType, ExpectedReturnType)) {
6560 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
6561 << (CSM == CXXMoveAssignment) << ExpectedReturnType;
6567 if (DeleteOnTypeMismatch)
6568 ShouldDeleteForTypeMismatch =
true;
6571 << (CSM == CXXMoveAssignment) << getLangOpts().CPlusPlus14;
6579 bool HasConstParam =
false;
6586 if (DeleteOnTypeMismatch)
6587 ShouldDeleteForTypeMismatch =
true;
6590 diag::err_defaulted_special_member_volatile_param) << CSM;
6595 if (HasConstParam && !CanHaveConstParam) {
6596 if (DeleteOnTypeMismatch)
6597 ShouldDeleteForTypeMismatch =
true;
6598 else if (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment) {
6600 diag::err_defaulted_special_member_copy_const_param)
6601 << (CSM == CXXCopyAssignment);
6606 diag::err_defaulted_special_member_move_const_param)
6607 << (CSM == CXXMoveAssignment);
6611 }
else if (ExpectedParams) {
6614 assert(CSM == CXXCopyAssignment &&
"unexpected non-ref argument");
6628 if ((getLangOpts().
CPlusPlus14 ? !isa<CXXDestructorDecl>(MD)
6629 : isa<CXXConstructorDecl>(MD)) &&
6632 Diag(MD->
getBeginLoc(), diag::err_incorrect_defaulted_constexpr) << CSM;
6649 DelayedDefaultedMemberExceptionSpecs.push_back(std::make_pair(MD, Type));
6651 CheckExplicitlyDefaultedMemberExceptionSpec(MD, Type);
6666 llvm::makeArrayRef(&ArgType,
6671 if (ShouldDeleteForTypeMismatch || ShouldDeleteSpecialMember(MD, CSM)) {
6674 if (!inTemplateInstantiation() && !HadError) {
6676 if (ShouldDeleteForTypeMismatch) {
6679 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
6682 if (ShouldDeleteForTypeMismatch && !HadError) {
6684 diag::warn_cxx17_compat_defaulted_method_type_mismatch) << CSM;
6690 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
6691 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
6692 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
6723 CheckEquivalentExceptionSpec(
6724 PDiag(diag::err_incorrect_defaulted_exception_spec)
6725 << getSpecialMember(MD), PDiag(),
6731 decltype(DelayedOverridingExceptionSpecChecks) Overriding;
6732 decltype(DelayedEquivalentExceptionSpecChecks)
Equivalent;
6733 decltype(DelayedDefaultedMemberExceptionSpecs) Defaulted;
6735 std::swap(Overriding, DelayedOverridingExceptionSpecChecks);
6736 std::swap(
Equivalent, DelayedEquivalentExceptionSpecChecks);
6737 std::swap(Defaulted, DelayedDefaultedMemberExceptionSpecs);
6741 for (
auto &Check : Overriding)
6742 CheckOverridingFunctionExceptionSpec(Check.first, Check.second);
6747 CheckEquivalentExceptionSpec(Check.second, Check.first);
6751 for (
auto &Spec : Defaulted)
6752 CheckExplicitlyDefaultedMemberExceptionSpec(Spec.first, Spec.second);
6758 template<
typename Derived>
6759 struct SpecialMemberVisitor {
6766 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
6770 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
6775 IsConstructor =
true;
6779 IsAssignment =
true;
6784 llvm_unreachable(
"invalid special member kind");
6790 ConstArg = RT->getPointeeType().isConstQualified();
6794 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
6797 bool isMove()
const {
6803 unsigned Quals,
bool IsMutable) {
6805 ConstArg && !IsMutable);
6815 cast<CXXConstructorDecl>(MD)->getInheritedConstructor().getConstructor();
6822 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
6829 return B->getBaseTypeLoc();
6831 return Subobj.get<
FieldDecl*>()->getLocation();
6836 VisitNonVirtualBases,
6841 VisitPotentiallyConstructedBases,
6847 bool visit(BasesToVisit Bases) {
6850 if (Bases == VisitPotentiallyConstructedBases)
6851 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
6853 for (
auto &B : RD->
bases())
6854 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
6855 getDerived().visitBase(&B))
6858 if (Bases == VisitAllBases)
6859 for (
auto &B : RD->
vbases())
6860 if (getDerived().visitBase(&B))
6863 for (
auto *F : RD->
fields())
6864 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
6865 getDerived().visitField(F))
6874 struct SpecialMemberDeletionInfo
6875 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
6880 bool AllFieldsAreConst;
6885 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
6886 Loc(MD->
getLocation()), AllFieldsAreConst(
true) {}
6895 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
6898 bool shouldDeleteForField(
FieldDecl *FD);
6899 bool shouldDeleteForAllConstMembers();
6901 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
6903 bool shouldDeleteForSubobjectCall(Subobject Subobj,
6905 bool IsDtorCallInCtor);
6913 bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
6933 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
6935 bool IsDtorCallInCtor) {
6942 DiagKind = !Decl ? 0 : 1;
6945 else if (!isAccessible(Subobj, Decl))
6963 diag::note_deleted_special_member_class_subobject)
6964 << getEffectiveCSM() << MD->
getParent() <<
true 6965 << Field << DiagKind << IsDtorCallInCtor;
6969 diag::note_deleted_special_member_class_subobject)
6970 << getEffectiveCSM() << MD->
getParent() <<
false 6971 << Base->
getType() << DiagKind << IsDtorCallInCtor;
6984 bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
6987 bool IsMutable = Field && Field->
isMutable();
7005 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
7012 if (IsConstructor) {
7015 false,
false,
false,
false,
false);
7016 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
7034 if (
auto *BaseCtor = SMOR.
getMethod()) {
7039 if (BaseCtor->isDeleted() && Diagnose) {
7041 diag::note_deleted_special_member_class_subobject)
7042 << getEffectiveCSM() << MD->
getParent() <<
false 7043 << Base->
getType() << 1 <<
false;
7046 return BaseCtor->isDeleted();
7048 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
7053 bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
7062 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
7063 << !!ICI << MD->
getParent() << FD << FieldType << 0;
7074 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
7080 AllFieldsAreConst =
false;
7086 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
7090 }
else if (IsAssignment) {
7095 << isMove() << MD->
getParent() << FD << FieldType << 0;
7110 if (!inUnion() && FieldRecord->
isUnion() &&
7112 bool AllVariantFieldsAreConst =
true;
7115 for (
auto *UI : FieldRecord->
fields()) {
7119 AllVariantFieldsAreConst =
false;
7122 if (UnionFieldRecord &&
7123 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
7133 diag::note_deleted_default_ctor_all_const)
7143 if (shouldDeleteForClassSubobject(FieldRecord, FD,
7154 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
7158 bool AnyFields =
false;
7160 if ((AnyFields = !F->isUnnamedBitfield()))
7166 diag::note_deleted_default_ctor_all_const)
7192 (CSM == CXXDefaultConstructor || CSM == CXXCopyAssignment)) {
7201 if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
7210 (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
7216 bool DeletesOnlyMatchingCopy =
7217 getLangOpts().MSVCCompat &&
7221 (!DeletesOnlyMatchingCopy || CSM == CXXCopyConstructor)) {
7222 if (!Diagnose)
return true;
7225 for (
auto *I : RD->
ctors()) {
7226 if (I->isMoveConstructor()) {
7227 UserDeclaredMove = I;
7231 assert(UserDeclaredMove);
7233 (!DeletesOnlyMatchingCopy || CSM == CXXCopyAssignment)) {
7234 if (!Diagnose)
return true;
7237 for (
auto *I : RD->
methods()) {
7238 if (I->isMoveAssignmentOperator()) {
7239 UserDeclaredMove = I;
7243 assert(UserDeclaredMove);
7246 if (UserDeclaredMove) {
7248 diag::note_deleted_copy_user_declared_move)
7249 << (CSM == CXXCopyAssignment) << RD
7261 if (CSM == CXXDestructor && MD->
isVirtual()) {
7266 OperatorDelete,
false)) {
7273 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
7281 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
7282 : SMI.VisitPotentiallyConstructedBases))
7285 if (SMI.shouldDeleteForAllConstMembers())
7288 if (getLangOpts().CUDA) {
7295 assert(ICI || CSM == getSpecialMember(MD));
7298 RealCSM = getSpecialMember(MD);
7300 return inferCUDATargetForImplicitSpecialMember(RD, RealCSM, MD,
7301 SMI.ConstArg, Diagnose);
7324 *Selected =
nullptr;
7328 llvm_unreachable(
"not a special member");
7346 for (
auto *CI : RD->
ctors()) {
7347 if (!CI->isDefaultConstructor())
7354 *Selected = DefCtor;
7387 }
else if (!Selected) {
7395 goto NeedOverloadResolution;
7405 }
else if (!Selected) {
7410 goto NeedOverloadResolution;
7414 NeedOverloadResolution:
7442 llvm_unreachable(
"unknown special method kind");
7446 for (
auto *CI : RD->
ctors())
7447 if (!CI->isImplicit())
7451 typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
7454 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
7484 ConstRHS, TAH, Diagnose ? &Selected :
nullptr))
7492 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
7495 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
7496 }
else if (!Selected)
7497 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
7502 << Kind << SubType.getUnqualifiedType() << CSM;
7504 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
7505 << Kind << SubType.getUnqualifiedType() << CSM;
7510 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
7511 << Kind << SubType.getUnqualifiedType() << CSM;
7529 for (
const auto *FI : RD->
fields()) {
7530 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
7536 if (FI->isAnonymousStructOrUnion()) {
7538 CSM, ConstArg, TAH, Diagnose))
7549 S.
Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI;
7559 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
7564 bool ConstRHS = ConstArg && !FI->isMutable();
7578 bool ConstArg = (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment);
7589 assert(!MD->
isUserProvided() && CSM != CXXInvalid &&
"not special enough");
7593 bool ConstArg =
false;
7599 case CXXDefaultConstructor:
7604 case CXXCopyConstructor:
7605 case CXXCopyAssignment: {
7621 case CXXMoveConstructor:
7622 case CXXMoveAssignment: {
7638 llvm_unreachable(
"not a special member");
7644 diag::note_nontrivial_default_arg)
7663 for (
const auto &BI : RD->bases())
7686 if (CSM == CXXDestructor && MD->
isVirtual()) {
7699 if (RD->getNumVBases()) {
7709 for (
const auto *MI : RD->methods()) {
7710 if (MI->isVirtual()) {
7712 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
7717 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
7725 struct FindHiddenVirtualMethod {
7728 llvm::SmallPtrSet<const CXXMethodDecl *, 8> OverridenAndUsingBaseMethods;
7733 static bool CheckMostOverridenMethods(
7735 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
7739 if (CheckMostOverridenMethods(O, Methods))
7755 bool foundSameNameMethod =
false;
7762 foundSameNameMethod =
true;
7779 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
7780 overloadedMethods.push_back(MD);
7784 if (foundSameNameMethod)
7785 OverloadedMethods.append(overloadedMethods.begin(),
7786 overloadedMethods.end());
7787 return foundSameNameMethod;
7794 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
7812 FindHiddenVirtualMethod FHVM;
7823 ND = shad->getTargetDecl();
7829 OverloadedMethods = FHVM.OverloadedMethods;
7834 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
7837 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
7838 HandleFunctionTypeMismatch(PD, MD->
getType(), overloadedMD->
getType());
7849 if (Diags.isIgnored(diag::warn_overloaded_virtual, MD->
getLocation()))
7853 FindHiddenVirtualMethods(MD, OverloadedMethods);
7854 if (!OverloadedMethods.empty()) {
7856 << MD << (OverloadedMethods.size() > 1);
7858 NoteHiddenVirtualMethods(MD, OverloadedMethods);
7863 auto PrintDiagAndRemoveAttr = [&]() {
7867 diag::ext_cannot_use_trivial_abi) << &RD;
7873 PrintDiagAndRemoveAttr();
7877 for (
const auto &B : RD.
bases()) {
7880 if ((!B.getType()->isDependentType() &&
7881 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) ||
7883 PrintDiagAndRemoveAttr();
7888 for (
const auto *FD : RD.
fields()) {
7893 PrintDiagAndRemoveAttr();
7898 if (!RT->isDependentType() &&
7900 PrintDiagAndRemoveAttr();
7912 AdjustDeclIfTemplate(TagDecl);
7915 if (AL.getKind() != ParsedAttr::AT_Visibility)
7918 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored)
7922 ActOnFields(S, RLoc, TagDecl, llvm::makeArrayRef(
7924 reinterpret_cast<Decl**>(FieldCollector->getCurFields()),
7925 FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList);
7927 CheckCompletedCXXClass(cast<CXXRecordDecl>(TagDecl));
7940 DeclareImplicitDefaultConstructor(ClassDecl);
7951 DeclareImplicitCopyConstructor(ClassDecl);
7962 DeclareImplicitCopyConstructor(ClassDecl);
7970 DeclareImplicitMoveConstructor(ClassDecl);
7983 DeclareImplicitCopyAssignment(ClassDecl);
7993 DeclareImplicitMoveAssignment(ClassDecl);
8005 DeclareImplicitDestructor(ClassDecl);
8018 D = TD->getTemplatedDecl();
8020 if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
8021 ParameterLists.push_back(PSD->getTemplateParameters());
8024 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
8025 ParameterLists.push_back(DD->getTemplateParameterList(i));
8029 ParameterLists.push_back(FTD->getTemplateParameters());
8033 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
8034 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
8035 ParameterLists.push_back(TD->getTemplateParameterList(i));
8039 ParameterLists.push_back(CTD->getTemplateParameters());
8045 if (Params->size() > 0)
8050 if (Param->getDeclName()) {
8052 IdResolver.AddDecl(Param);
8061 if (!RecordD)
return;
8062 AdjustDeclIfTemplate(RecordD);
8064 PushDeclContext(S, Record);
8068 if (!RecordD)
return;
8081 IdResolver.AddDecl(Param);
8113 IdResolver.AddDecl(Param);
8126 AdjustDeclIfTemplate(MethodD);
8135 CheckConstructor(Constructor);
8139 CheckCXXDefaultArguments(Method);
8174 diagnoseIgnoredQualifiers(
8186 Diag(SL, diag::err_invalid_qualified_constructor)
8239 const char *ConstRef
8242 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
8268 FindDeallocationFunctionForDestructor(Loc, RD)) {
8269 Expr *ThisArg =
nullptr;
8274 if (OperatorDelete->isDestroyingOperatorDelete()) {
8275 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
8282 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
8283 assert(!This.
isInvalid() &&
"couldn't form 'this' expr in dtor?");
8284 This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
8285 if (This.isInvalid()) {
8288 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
8291 ThisArg = This.get();
8295 DiagnoseUseOfDecl(OperatorDelete, Loc);
8296 MarkFunctionReferenced(Loc, OperatorDelete);
8320 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
8323 if (TST->isTypeAlias())
8325 << DeclaratorType << 1;
8358 diagnoseIgnoredQualifiers(diag::err_destructor_return_type, TypeQuals,
8372 Diag(SL, diag::err_invalid_qualified_destructor)
8500 bool NeedsTypedef =
false;
8504 bool PastFunctionChunk =
false;
8506 switch (Chunk.Kind) {
8508 if (!PastFunctionChunk) {
8509 if (Chunk.Fun.HasTrailingReturnType) {
8511 GetTypeFromParser(Chunk.Fun.getTrailingReturnType(), &TRT);
8514 PastFunctionChunk =
true;
8519 NeedsTypedef =
true;
8541 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
8542 DB << Before <<
After;
8544 if (!NeedsTypedef) {
8548 if (After.isInvalid() && ConvTSI) {
8593 if (DS.isExplicitSpecified())
8594 Diag(DS.getExplicitSpecLoc(),
8595 getLangOpts().CPlusPlus11
8596 ? diag::warn_cxx98_compat_explicit_conversion_functions
8597 : diag::ext_explicit_conversion_functions)
8606 assert(Conversion &&
"Expected to receive a conversion function declaration");
8624 ConvType = ConvTypeRef->getPointeeType();
8628 else if (ConvType->isRecordType()) {
8630 if (ConvType == ClassType)
8633 else if (IsDerivedFrom(Conversion->
getLocation(), ClassType, ConvType))
8635 << ClassType << ConvType;
8636 }
else if (ConvType->isVoidType()) {
8638 << ClassType << ConvType;
8643 return ConversionTemplate;
8651 struct BadSpecifierDiagnoser {
8654 ~BadSpecifierDiagnoser() {
8658 template<
typename T>
void check(
SourceLocation SpecLoc, T Spec) {
8662 return check(SpecLoc,
8668 if (!Specifiers.empty()) Specifiers +=
" ";
8674 std::string Specifiers;
8686 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
8691 if (!CurContext->getRedeclContext()->Equals(
8694 << GuidedTemplateDecl;
8695 Diag(GuidedTemplateDecl->
getLocation(), diag::note_template_decl_here);
8700 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
8701 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
8702 DS.isNoreturnSpecified() || DS.isConstexprSpecified()) {
8703 BadSpecifierDiagnoser Diagnoser(
8705 diag::err_deduction_guide_invalid_specifier);
8707 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
8712 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
8713 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
8714 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
8715 DS.ClearConstexprSpec();
8717 Diagnoser.check(DS.getConstSpecLoc(),
"const");
8718 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
8719 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
8720 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
8721 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
8722 DS.ClearTypeQualifiers();
8724 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
8725 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
8726 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
8727 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
8728 DS.ClearTypeSpecType();
8735 bool FoundFunction =
false;
8741 diag::err_deduction_guide_with_complex_decl)
8745 if (!Chunk.Fun.hasTrailingReturnType()) {
8747 diag::err_deduction_guide_no_trailing_return_type);
8753 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
8755 QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
8756 assert(TSI &&
"deduction guide has valid type but invalid return type?");
8757 bool AcceptableReturnType =
false;
8758 bool MightInstantiateToSpecialization =
false;
8761 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
8762 bool TemplateMatches =
8765 AcceptableReturnType =
true;
8770 MightInstantiateToSpecialization = !(TD && isa<ClassTemplateDecl>(TD) &&
8774 MightInstantiateToSpecialization =
true;
8777 if (!AcceptableReturnType) {
8779 diag::err_deduction_guide_bad_trailing_return_type)
8780 << GuidedTemplate << TSI->
getType()
8781 << MightInstantiateToSpecialization
8787 FoundFunction =
true;
8804 assert(*IsInline != PrevNS->
isInline());
8812 if (*IsInline && II && II->
getName().startswith(
"__atomic") &&
8817 NS->setInline(*IsInline);
8820 for (
auto *I : PrevNS->
decls())
8821 if (
auto *ND = dyn_cast<NamedDecl>(I))
8829 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
8832 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
8847 bool IsInline = InlineLoc.
isValid();
8848 bool IsInvalid =
false;
8850 bool AddToKnown =
false;
8866 LookupResult R(*
this, II, IdentLoc, LookupOrdinaryName,
8867 ForExternalRedeclaration);
8868 LookupQualifiedName(R, CurContext->getRedeclContext());
8871 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
8875 if (IsInline != PrevNS->
isInline())
8878 }
else if (PrevDecl) {
8880 Diag(Loc, diag::err_redefinition_different_kind)
8882 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
8885 }
else if (II->
isStr(
"std") &&
8886 CurContext->getRedeclContext()->isTranslationUnit()) {
8889 PrevNS = getStdNamespace();
8891 AddToKnown = !IsInline;
8894 AddToKnown = !IsInline;
8908 if (PrevNS && IsInline != PrevNS->
isInline())
8914 StartLoc, Loc, II, PrevNS);
8918 ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
8919 AddPragmaAttributes(DeclRegionScope, Namespc);
8922 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
8923 PushNamespaceVisibilityAttr(
Attr, Loc);
8926 StdNamespace = Namespc;
8928 KnownNamespaces[Namespc] =
false;
8931 PushOnScopeChains(Namespc, DeclRegionScope);
8936 TU->setAnonymousNamespace(Namespc);
8938 cast<NamespaceDecl>(
Parent)->setAnonymousNamespace(Namespc);
8941 CurContext->addDecl(Namespc);
8972 ActOnDocumentableDecl(Namespc);
8979 PushDeclContext(NamespcScope, Namespc);
8987 return AD->getNamespace();
8988 return dyn_cast_or_null<NamespaceDecl>(D);
8994 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
8995 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
8998 if (Namespc->
hasAttr<VisibilityAttr>())
8999 PopPragmaVisibility(
true, RBrace);
9003 return cast_or_null<CXXRecordDecl>(
9012 return cast_or_null<NamespaceDecl>(
9017 if (!StdExperimentalNamespaceCache) {
9018 if (
auto Std = getStdNamespace()) {
9021 if (!LookupQualifiedName(
Result,
Std) ||
9022 !(StdExperimentalNamespaceCache =
9024 Result.suppressDiagnostics();
9027 return StdExperimentalNamespaceCache;
9039 struct InvalidSTLDiagnoser {
9045 const VarDecl *VD =
nullptr) {
9047 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
9048 << TyForDiags << ((int)Sel);
9049 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
9050 assert(!Name.empty());
9054 if (Sel == USS_InvalidMember) {
9055 S.
Diag(VD->getLocation(), diag::note_var_declared_here)
9056 << VD << VD->getSourceRange();
9066 "Looking for comparison category type outside of C++.");
9071 if (Info && FullyCheckedComparisonCategories[static_cast<unsigned>(Kind)])
9076 std::string NameForDiags =
"std::";
9078 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
9083 assert(Info->
Kind == Kind);
9099 if (RequireCompleteType(Loc, TyForDiags, diag::err_incomplete_type))
9102 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags};
9105 return UnsupportedSTLError(USS_NonTrivial);
9113 return UnsupportedSTLError();
9122 !FIt->getType()->isIntegralOrEnumerationType()) {
9123 return UnsupportedSTLError();
9133 return UnsupportedSTLError(USS_MissingMember, MemName);
9136 assert(VD &&
"should not be null!");
9143 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
9149 return UnsupportedSTLError();
9151 MarkVariableReferenced(Loc, VD);
9156 FullyCheckedComparisonCategories[
static_cast<unsigned>(
Kind)] =
true;
9163 if (!StdNamespace) {
9169 &PP.getIdentifierTable().get(
"std"),
9174 return getStdNamespace();
9179 "Looking for std::initializer_list outside of C++.");
9194 if (!Specialization)
9201 Template = dyn_cast_or_null<ClassTemplateDecl>(
9202 TST->getTemplateName().getAsTemplateDecl());
9203 Arguments = TST->getArgs();
9208 if (!StdInitializerList) {
9212 &PP.getIdentifierTable().get(
"initializer_list") ||
9213 !getStdNamespace()->InEnclosingNamespaceSetOf(
9221 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
9225 StdInitializerList = Template;
9240 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
9247 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
9252 Result.suppressDiagnostics();
9255 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
9263 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
9264 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
9272 if (!StdInitializerList) {
9274 if (!StdInitializerList)
9283 CheckTemplateIdType(
TemplateName(StdInitializerList), Loc, Args));
9300 return isStdInitializerList(ArgType,
nullptr);
9307 case Decl::TranslationUnit:
9309 case Decl::LinkageSpec:
9321 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
9323 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
9337 llvm::make_unique<NamespaceValidatorCCC>(),
9340 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
9341 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
9342 Ident->
getName().equals(CorrectedStr);
9344 S.
PDiag(diag::err_using_directive_member_suggest)
9345 << Ident << DC << DroppedSpecifier << SS.getRange(),
9346 S.
PDiag(diag::note_namespace_defined_here));
9349 S.
PDiag(diag::err_using_directive_suggest) << Ident,
9350 S.
PDiag(diag::note_namespace_defined_here));
9352 R.
addDecl(Corrected.getFoundDecl());
9363 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9364 assert(NamespcName &&
"Invalid NamespcName.");
9365 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
9378 LookupResult R(*
this, NamespcName, IdentLoc, LookupNamespaceName);
9379 LookupParsedName(R, S, &SS);
9388 NamespcName->
isStr(
"std")) {
9389 Diag(IdentLoc, diag::ext_using_undefined_std);
9390 R.
addDecl(getOrCreateStdNamespace());
9400 assert(NS &&
"expected namespace decl");
9403 DiagnoseUseOfDecl(Named, IdentLoc);
9418 while (CommonAncestor && !CommonAncestor->
Encloses(CurContext))
9419 CommonAncestor = CommonAncestor->
getParent();
9423 IdentLoc, Named, CommonAncestor);
9426 !SourceMgr.isInMainFile(SourceMgr.getExpansionLoc(IdentLoc))) {
9427 Diag(IdentLoc, diag::warn_using_directive_in_header);
9430 PushUsingDirective(S, UDir);
9432 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
9436 ProcessDeclAttributeList(S, UDir, AttrList);
9479 getLangOpts().CPlusPlus11
9480 ? diag::warn_cxx98_compat_using_decl_constructor
9481 : diag::err_using_decl_constructor)
9498 llvm_unreachable(
"cannot parse qualified deduction guide name");
9509 ? diag::err_access_decl
9510 : diag::warn_access_decl_deprecated)
9515 if (DiagnoseUnexpandedParameterPack(SS, UPPC_UsingDeclaration) ||
9516 DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC_UsingDeclaration))
9521 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
9528 BuildUsingDeclaration(S, AS, UsingLoc, TypenameLoc.
isValid(), TypenameLoc,
9529 SS, TargetNameInfo, EllipsisLoc, AttrList,
9532 PushOnScopeChains(UD, S,
false);
9547 return Context.
hasSameType(TD1->getUnderlyingType(),
9548 TD2->getUnderlyingType());
9578 if (!getLangOpts().
CPlusPlus11 && CurContext->isRecord()) {
9582 if (isa<EnumDecl>(OrigDC)) OrigDC = OrigDC->
getParent();
9587 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(OrigRec)) {
9588 if (OrigDC == CurContext) {
9590 diag::err_using_decl_nested_name_specifier_is_current_class)
9598 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9600 << cast<CXXRecordDecl>(CurContext)
9608 if (Previous.
empty())
return false;
9611 if (isa<UsingShadowDecl>(Target))
9612 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
9619 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
9620 bool FoundEquivalentDecl =
false;
9627 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D))
9630 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
9635 !isa<IndirectFieldDecl>(Target) &&
9636 !isa<UnresolvedUsingValueDecl>(
Target) &&
9637 DiagnoseClassNameShadow(
9645 PrevShadow = Shadow;
9646 FoundEquivalentDecl =
true;
9647 }
else if (isEquivalentInternalLinkageDeclaration(D, Target)) {
9650 FoundEquivalentDecl =
true;
9654 (isa<TagDecl>(D) ? Tag : NonTag) = D;
9657 if (FoundEquivalentDecl)
9662 switch (CheckOverload(
nullptr, FD, Previous, OldDecl,
9667 case Ovl_NonFunction:
9676 if (CurContext->isRecord())
9692 if (isa<TagDecl>(Target)) {
9694 if (!Tag)
return false;
9698 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
9704 if (!NonTag)
return false;
9717 for (
auto &B : Derived->
bases())
9718 if (B.getType()->getAsCXXRecordDecl() == Base)
9719 return B.isVirtual();
9720 llvm_unreachable(
"not a direct base class");
9730 if (isa<UsingShadowDecl>(Target)) {
9731 Target = cast<UsingShadowDecl>(
Target)->getTargetDecl();
9732 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
9736 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
9737 NonTemplateTarget = TargetTD->getTemplatedDecl();
9740 if (isa<CXXConstructorDecl>(NonTemplateTarget)) {
9741 bool IsVirtualBase =
9745 Context, CurContext, UD->
getLocation(), UD, Orig, IsVirtualBase);
9759 PushOnScopeChains(Shadow, S);
9761 CurContext->addDecl(Shadow);
9797 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
9805 IdResolver.RemoveDecl(Shadow);
9818 bool &AnyDependentBases) {
9821 for (
auto &Base : Derived->
bases()) {
9823 if (CanonicalDesiredBase == BaseType)
9825 if (BaseType->isDependentType())
9826 AnyDependentBases =
true;
9834 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
9836 : HasTypenameKeyword(HasTypenameKeyword),
9837 IsInstantiation(IsInstantiation), OldNNS(NNS),
9838 RequireMemberOf(RequireMemberOf) {}
9840 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
9844 if (!ND || isa<NamespaceDecl>(ND))
9854 if (RequireMemberOf) {
9856 if (FoundRecord && FoundRecord->isInjectedClassName()) {
9877 bool AnyDependentBases =
false;
9880 AnyDependentBases) &&
9892 if (FoundRecord && FoundRecord->isInjectedClassName())
9896 if (isa<TypeDecl>(ND))
9897 return HasTypenameKeyword || !IsInstantiation;
9899 return !HasTypenameKeyword;
9903 bool HasTypenameKeyword;
9904 bool IsInstantiation;
9920 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9922 assert(IdentLoc.isValid() &&
"Invalid TargetName location.");
9931 if (
auto *RD = dyn_cast<CXXRecordDecl>(CurContext))
9937 ForVisibleRedeclaration);
9940 LookupName(Previous, S);
9946 if (!isDeclInScope(D, CurContext, S))
9958 assert(IsInstantiation &&
"no scope in non-instantiation");
9959 if (CurContext->isRecord())
9960 LookupQualifiedName(Previous, CurContext);
9979 if (CheckUsingDeclRedeclaration(UsingLoc, HasTypenameKeyword,
9980 SS, IdentLoc, Previous))
9984 if (CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo,
9988 DeclContext *LookupContext = computeDeclContext(SS);
9991 if (!LookupContext || EllipsisLoc.
isValid()) {
9992 if (HasTypenameKeyword) {
9995 UsingLoc, TypenameLoc,
10001 QualifierLoc, NameInfo, EllipsisLoc);
10004 CurContext->addDecl(D);
10008 auto Build = [&](
bool Invalid) {
10011 UsingName, HasTypenameKeyword);
10013 CurContext->addDecl(UD);
10017 auto BuildInvalid = [&]{
return Build(
true); };
10018 auto BuildValid = [&]{
return Build(
false); };
10020 if (RequireCompleteDeclContext(SS, LookupContext))
10021 return BuildInvalid();
10030 if (!IsInstantiation)
10035 if (CurContext->isRecord()) {
10040 LookupQualifiedName(R, LookupContext);
10053 if (getLangOpts().
CPlusPlus14 && II && II->isStr(
"gets") &&
10054 CurContext->isStdNamespace() &&
10055 isa<TranslationUnitDecl>(LookupContext) &&
10056 getSourceManager().isInSystemHeader(UsingLoc))
10060 llvm::make_unique<UsingValidatorCCC>(
10061 HasTypenameKeyword, IsInstantiation, SS.getScopeRep(),
10063 CTK_ErrorRecovery)) {
10066 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
10067 << NameInfo.
getName() << LookupContext << 0
10072 NamedDecl *ND = Corrected.getCorrectionDecl();
10074 return BuildInvalid();
10080 RD = cast<CXXRecordDecl>(RD->
getParent());
10083 if (Corrected.WillReplaceSpecifier()) {
10085 Builder.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
10092 auto *CurClass = cast<CXXRecordDecl>(CurContext);
10095 UsingName.setNamedTypeInfo(
nullptr);
10096 for (
auto *Ctor : LookupConstructors(RD))
10102 UsingName.setName(ND->getDeclName());
10106 Diag(IdentLoc, diag::err_no_member)
10107 << NameInfo.
getName() << LookupContext << SS.getRange();
10108 return BuildInvalid();
10113 return BuildInvalid();
10115 if (HasTypenameKeyword) {
10118 Diag(IdentLoc, diag::err_using_typename_non_type);
10120 Diag((*I)->getUnderlyingDecl()->getLocation(),
10121 diag::note_using_decl_target);
10122 return BuildInvalid();
10129 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
10131 return BuildInvalid();
10138 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
10140 return BuildInvalid();
10146 if (cast<EnumDecl>(ED->getDeclContext())->isScoped()) {
10147 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
10149 return BuildInvalid();
10156 if (UsingName.getName().getNameKind() ==
10161 if (CheckInheritingConstructorUsingDecl(UD))
10167 if (!CheckUsingShadowDecl(UD, *I, Previous, PrevDecl))
10168 BuildUsingShadowDecl(S, UD, *I, PrevDecl);
10176 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
10177 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
10178 isa<UsingPackDecl>(InstantiatedFrom));
10182 UPD->setAccess(InstantiatedFrom->
getAccess());
10183 CurContext->addDecl(UPD);
10189 assert(!UD->
hasTypename() &&
"expecting a constructor name");
10192 assert(SourceType &&
10193 "Using decl naming constructor doesn't have type in scope spec.");
10194 CXXRecordDecl *TargetClass = cast<CXXRecordDecl>(CurContext);
10197 bool AnyDependentBases =
false;
10199 AnyDependentBases);
10200 if (!Base && !AnyDependentBases) {
10202 diag::err_using_decl_constructor_not_in_direct_base)
10204 <<
QualType(SourceType, 0) << TargetClass;
10219 bool HasTypenameKeyword,
10232 if (!CurContext->getRedeclContext()->isRecord()) {
10238 if (Qual->
isDependent() && !HasTypenameKeyword) {
10239 for (
auto *D : Prev) {
10240 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
10241 bool OldCouldBeEnumerator =
10242 isa<UnresolvedUsingValueDecl>(D) || isa<EnumConstantDecl>(D);
10244 OldCouldBeEnumerator ? diag::err_redefinition
10245 : diag::err_redefinition_different_kind)
10246 << Prev.getLookupName();
10247 Diag(D->getLocation(), diag::note_previous_definition);
10260 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
10261 DTypename = UD->hasTypename();
10262 DQual = UD->getQualifier();
10264 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
10266 DQual = UD->getQualifier();
10268 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
10270 DQual = UD->getQualifier();
10275 if (HasTypenameKeyword != DTypename)
continue;
10284 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
10301 DeclContext *NamedContext = computeDeclContext(SS);
10303 if (!CurContext->isRecord()) {
10311 if ((HasTypename && !NamedContext) ||
10313 auto *RD = NamedContext
10316 if (RD && RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), RD))
10319 Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member)
10331 LookupQualifiedName(R, RD);
10336 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
10344 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
10354 if (getLangOpts().CPlusPlus11) {
10360 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
10375 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
10376 << (getLangOpts().CPlusPlus11 ? 4 : 3)
10389 if (!NamedContext) {
10403 diag::err_using_decl_nested_name_specifier_is_not_class)
10409 RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), NamedContext))
10412 if (getLangOpts().CPlusPlus11) {
10418 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(
10419 cast<CXXRecordDecl>(NamedContext))) {
10420 if (CurContext == NamedContext) {
10422 diag::err_using_decl_nested_name_specifier_is_current_class)
10427 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
10429 diag::err_using_decl_nested_name_specifier_is_not_base_class)
10431 << cast<CXXRecordDecl>(CurContext)
10453 llvm::SmallPtrSet<const CXXRecordDecl *, 4> Bases;
10455 Bases.insert(Base);
10460 if (!cast<CXXRecordDecl>(CurContext)->forallBases(Collect))
10466 return !Bases.count(Base);
10471 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
10472 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
10476 diag::err_using_decl_nested_name_specifier_is_not_base_class)
10478 << cast<CXXRecordDecl>(CurContext)
10493 "got alias-declaration outside of declaration scope");
10498 bool Invalid =
false;
10501 GetTypeFromParser(Type.
get(), &TInfo);
10503 if (DiagnoseClassNameShadow(CurContext, NameInfo))
10506 if (DiagnoseUnexpandedParameterPack(Name.
StartLocation, TInfo,
10507 UPPC_DeclarationType)) {
10514 TemplateParamLists.size()
10515 ? forRedeclarationInCurContext()
10516 : ForVisibleRedeclaration);
10521 Previous.getFoundDecl()->isTemplateParameter()) {
10527 "name in alias declaration must be an identifier");
10537 ProcessDeclAttributeList(S, NewTD, AttrList);
10538 AddPragmaAttributes(S, NewTD);
10540 CheckTypedefForVariablyModifiedType(S, NewTD);
10543 bool Redeclaration =
false;
10546 if (TemplateParamLists.size()) {
10550 if (TemplateParamLists.size() != 1) {
10551 Diag(UsingLoc, diag::err_alias_template_extra_headers)
10552 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
10553 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
10558 if (CheckTemplateDeclScope(S, TemplateParams))
10562 FilterLookupForScope(
Previous, CurContext, S,
false,
10565 Redeclaration =
true;
10568 if (!OldDecl && !Invalid) {
10569 Diag(UsingLoc, diag::err_redefinition_different_kind)
10580 if (TemplateParameterListsAreEqual(TemplateParams,
10583 TPL_TemplateMatch))
10584 OldTemplateParams =
10606 if (CheckTemplateParameterList(TemplateParams, OldTemplateParams,
10607 TPC_TypeAliasTemplate))
10620 else if (OldDecl) {
10622 CheckRedeclarationModuleOwnership(NewDecl, OldDecl);
10627 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
10628 setTagNameForLinkagePurposes(TD, NewTD);
10629 handleTagNumbering(TD, S);
10631 ActOnTypedefNameDecl(S, CurContext, NewTD,
Previous, Redeclaration);
10635 PushOnScopeChains(NewND, S);
10636 ActOnDocumentableDecl(NewND);
10647 LookupResult R(*
this, Ident, IdentLoc, LookupNamespaceName);
10648 LookupParsedName(R, S, &SS);
10655 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
10663 LookupResult PrevR(*
this, Alias, AliasLoc, LookupOrdinaryName,
10664 ForVisibleRedeclaration);
10665 LookupName(PrevR, S);
10669 DiagnoseTemplateParameterShadow(AliasLoc, PrevR.
getFoundDecl());
10674 FilterLookupForScope(PrevR, CurContext, S,
false,
10686 }
else if (isVisible(PrevDecl)) {
10687 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
10689 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
10690 << AD->getNamespace();
10693 }
else if (isVisible(PrevDecl)) {
10695 ? diag::err_redefinition
10696 : diag::err_redefinition_different_kind;
10697 Diag(AliasLoc, DiagID) << Alias;
10704 DiagnoseUseOfDecl(ND, IdentLoc);
10713 PushOnScopeChains(AliasDecl, S);
10718 struct SpecialMemberExceptionSpecInfo
10719 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
10727 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
10732 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
10735 void visitSubobjectCall(Subobject Subobj,
10745 auto *BaseClass = cast<CXXRecordDecl>(RT->getDecl());
10747 if (
auto *BaseCtor = SMOR.getMethod()) {
10748 visitSubobjectCall(Base, BaseCtor);
10752 visitClassSubobject(BaseClass, Base, 0);
10756 bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
10767 ExceptSpec.CalledExpr(E);
10769 ->getAs<RecordType>()) {
10770 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
10776 void SpecialMemberExceptionSpecInfo::visitClassSubobject(
CXXRecordDecl *Class,
10780 bool IsMutable = Field && Field->
isMutable();
10781 visitSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable));
10784 void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
10789 ExceptSpec.CalledDecl(getSubobjectLoc(Subobj), MD);
10794 struct ComputingExceptionSpec {
10805 ~ComputingExceptionSpec() {
10815 ComputingExceptionSpec CES(S, MD, Loc);
10822 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
10824 return Info.ExceptSpec;
10831 diag::err_exception_spec_incomplete_type))
10832 return Info.ExceptSpec;
10849 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
10850 : Info.VisitAllBases);
10852 return Info.ExceptSpec;
10857 struct DeclaringSpecialMember {
10861 bool WasAlreadyBeingDeclared;
10864 : S(S), D(RD, CSM), SavedContext(S, RD) {
10866 if (WasAlreadyBeingDeclared)
10887 ~DeclaringSpecialMember() {
10888 if (!WasAlreadyBeingDeclared) {
10895 bool isAlreadyBeingDeclared()
const {
10896 return WasAlreadyBeingDeclared;
10906 ForExternalRedeclaration);
10913 CheckFunctionDeclaration(S, FD, R,
false);
10916 void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
10922 if (getLangOpts().OpenCLCPlusPlus) {
10941 "Should not build implicit default constructor!");
10943 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDefaultConstructor);
10944 if (DSM.isAlreadyBeingDeclared())
10948 CXXDefaultConstructor,
10959 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
10960 nullptr,
false,
true,
10965 if (getLangOpts().CUDA) {
10966 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDefaultConstructor,
10972 setupImplicitSpecialMemberType(DefaultCon, Context.
VoidTy,
None);
10981 Scope *S = getScopeForContext(ClassDecl);
10982 CheckImplicitSpecialMemberDeclaration(S, DefaultCon);
10984 if (ShouldDeleteSpecialMember(DefaultCon, CXXDefaultConstructor))
10985 SetDeclDeleted(DefaultCon, ClassLoc);
10988 PushOnScopeChains(DefaultCon, S,
false);
10989 ClassDecl->
addDecl(DefaultCon);
10999 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
11004 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
11010 ResolveExceptionSpec(CurrentLocation,
11012 MarkVTableUsed(CurrentLocation, ClassDecl);
11017 if (SetCtorInitializers(Constructor,
false)) {
11029 L->CompletedImplicitDefinition(Constructor);
11032 DiagnoseUninitializedFields(*
this, Constructor);
11037 CheckDelayedMemberExceptionSpecs();
11058 ->getInheritedConstructor()
11061 return cast<CXXConstructorDecl>(Ctor);
11076 false, BaseCtor, &ICI);
11079 Context, Derived, UsingLoc, NameInfo, TInfo->
getType(), TInfo,
11090 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
11096 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
11100 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
11107 ParamDecls.push_back(PD);
11112 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
11115 Derived->
addDecl(DerivedCtor);
11117 if (ShouldDeleteSpecialMember(DerivedCtor, CXXDefaultConstructor, &ICI))
11118 SetDeclDeleted(DerivedCtor, UsingLoc);
11120 return DerivedCtor;
11126 ShouldDeleteSpecialMember(Ctor, CXXDefaultConstructor, &ICI,
11145 ResolveExceptionSpec(CurrentLocation,
11147 MarkVTableUsed(CurrentLocation, ClassDecl);
11169 for (
bool VBase : {
false,
true}) {
11171 if (B.isVirtual() != VBase)
11174 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
11179 if (!BaseCtor.first)
11182 MarkFunctionReferenced(CurrentLocation, BaseCtor.first);
11184 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
11188 Context, TInfo, VBase, InitLoc, Init.
get(), InitLoc,
11196 if (SetCtorInitializers(Constructor,
false, Inits)) {
11205 L->CompletedImplicitDefinition(Constructor);
11208 DiagnoseUninitializedFields(*
this, Constructor);
11218 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDestructor);
11219 if (DSM.isAlreadyBeingDeclared())
11236 if (getLangOpts().CUDA) {
11237 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDestructor,
11243 setupImplicitSpecialMemberType(Destructor, Context.
VoidTy,
None);
11254 Scope *S = getScopeForContext(ClassDecl);
11255 CheckImplicitSpecialMemberDeclaration(S, Destructor);
11261 ShouldDeleteSpecialMember(Destructor, CXXDestructor))
11262 SetDeclDeleted(Destructor, ClassLoc);
11266 PushOnScopeChains(Destructor, S,
false);
11267 ClassDecl->
addDecl(Destructor);
11277 "DefineImplicitDestructor - call it for implicit default dtor");
11282 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
11288 ResolveExceptionSpec(CurrentLocation,
11290 MarkVTableUsed(CurrentLocation, ClassDecl);
11295 MarkBaseAndMemberDestructorsReferenced(Destructor->
getLocation(),
11298 if (CheckDestructor(Destructor)) {
11310 L->CompletedImplicitDefinition(Destructor);
11318 if (
CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(CurContext)) {
11319 if (Record->isInvalidDecl()) {
11320 DelayedOverridingExceptionSpecChecks.clear();
11321 DelayedEquivalentExceptionSpecChecks.clear();
11322 DelayedDefaultedMemberExceptionSpecs.clear();
11330 referenceDLLExportedClassMethods();
11334 if (!DelayedDllExportClasses.empty()) {
11338 std::swap(DelayedDllExportClasses, WorkList);
11346 "adjusting dtor exception specs was introduced in c++11");
11356 getAs<FunctionProtoType>();
11379 class ExprBuilder {
11380 ExprBuilder(
const ExprBuilder&) =
delete;
11381 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
11384 static Expr *assertNotNull(
Expr *E) {
11385 assert(E &&
"Expression construction must not fail.");
11391 virtual ~ExprBuilder() {}
11396 class RefBuilder:
public ExprBuilder {
11406 : Var(Var), VarType(VarType) {}
11409 class ThisBuilder:
public ExprBuilder {
11416 class CastBuilder:
public ExprBuilder {
11417 const ExprBuilder &Builder;
11425 CK_UncheckedDerivedToBase,
Kind,
11431 : Builder(Builder), Type(Type),
Kind(Kind), Path(Path) {}
11434 class DerefBuilder:
public ExprBuilder {
11435 const ExprBuilder &Builder;
11439 return assertNotNull(
11443 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11446 class MemberBuilder:
public ExprBuilder {
11447 const ExprBuilder &Builder;
11456 Builder.build(S, Loc), Type, Loc, IsArrow, SS,
SourceLocation(),
11457 nullptr, MemberLookup,
nullptr,
nullptr).
get());
11460 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
11462 : Builder(Builder), Type(Type), IsArrow(IsArrow),
11463 MemberLookup(MemberLookup) {}
11466 class MoveCastBuilder:
public ExprBuilder {
11467 const ExprBuilder &Builder;
11471 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
11474 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11477 class LvalueConvBuilder:
public ExprBuilder {
11478 const ExprBuilder &Builder;
11482 return assertNotNull(
11486 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11489 class SubscriptBuilder:
public ExprBuilder {
11490 const ExprBuilder &Base;
11491 const ExprBuilder &Index;
11496 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
11499 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
11500 : Base(Base), Index(Index) {}
11511 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
11520 Expr *From = FromB.build(S, Loc);
11524 Expr *To = ToB.build(S, Loc);
11530 bool NeedsCollectableMemCpy =
11534 StringRef MemCpyName = NeedsCollectableMemCpy ?
11535 "__builtin_objc_memmove_collectable" :
11536 "__builtin_memcpy";
11549 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
11551 Expr *CallArgs[] = {
11555 Loc, CallArgs, Loc);
11557 assert(!Call.
isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
11590 const ExprBuilder &To,
const ExprBuilder &From,
11591 bool CopyingBaseSubobject,
bool Copying,
11592 unsigned Depth = 0) {
11608 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
11623 if (Method->isCopyAssignmentOperator() ||
11624 (!Copying && Method->isMoveAssignmentOperator()))
11643 if (CopyingBaseSubobject) {
11674 Expr *FromInst = From.build(S, Loc);
11677 Loc, FromInst, Loc);
11697 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
11717 llvm::raw_svector_ostream OS(Str);
11718 OS <<
"__i" <<
Depth;
11722 IterationVarName, SizeType,
11731 RefBuilder IterationVarRef(IterationVar, SizeType);
11732 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
11738 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
11739 MoveCastBuilder FromIndexMove(FromIndexCopy);
11740 const ExprBuilder *FromIndex;
11742 FromIndex = &FromIndexCopy;
11744 FromIndex = &FromIndexMove;
11746 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
11751 ToIndex, *FromIndex, CopyingBaseSubobject,
11752 Copying,
Depth + 1);
11754 if (Copy.isInvalid() || !Copy.get())
11770 UnaryOperator(IterationVarRef.build(S, Loc), UO_PreInc, SizeType,
11775 Loc, Loc, InitStmt,
11782 const ExprBuilder &To,
const ExprBuilder &From,
11783 bool CopyingBaseSubobject,
bool Copying) {
11790 CopyingBaseSubobject,
11795 if (!Result.isInvalid() && !Result.get())
11808 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyAssignment);
11809 if (DSM.isAlreadyBeingDeclared())
11840 if (getLangOpts().CUDA) {
11841 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyAssignment,
11847 setupImplicitSpecialMemberType(CopyAssignment, RetType, ArgType);
11851 ClassLoc, ClassLoc,
11859 ? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
11865 Scope *S = getScopeForContext(ClassDecl);
11866 CheckImplicitSpecialMemberDeclaration(S, CopyAssignment);
11868 if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment))
11869 SetDeclDeleted(CopyAssignment, ClassLoc);
11872 PushOnScopeChains(CopyAssignment, S,
false);
11873 ClassDecl->
addDecl(CopyAssignment);
11875 return CopyAssignment;
11889 if (RD->hasUserDeclaredDestructor()) {
11890 UserDeclaredOperation = RD->getDestructor();
11891 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
11892 RD->hasUserDeclaredCopyConstructor() &&
11895 for (
auto *I : RD->ctors()) {
11896 if (I->isCopyConstructor()) {
11897 UserDeclaredOperation = I;
11901 assert(UserDeclaredOperation);
11902 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
11903 RD->hasUserDeclaredCopyAssignment() &&
11906 for (
auto *I : RD->methods()) {
11907 if (I->isCopyAssignmentOperator()) {
11908 UserDeclaredOperation = I;
11912 assert(UserDeclaredOperation);
11915 if (UserDeclaredOperation) {
11917 diag::warn_deprecated_copy_operation)
11918 << RD << !isa<CXXConstructorDecl>(CopyOp)
11919 << isa<CXXDestructorDecl>(UserDeclaredOperation);
11930 "DefineImplicitCopyAssignment called for wrong function");
11944 ResolveExceptionSpec(CurrentLocation,
11984 RefBuilder OtherRef(Other, OtherRefType);
11990 bool Invalid =
false;
11991 for (
auto &Base : ClassDecl->
bases()) {
12001 BasePath.push_back(&Base);
12005 CastBuilder From(OtherRef, Context.
getQualifiedType(BaseType, OtherQuals),
12009 DerefBuilder DerefThis(This);
12010 CastBuilder To(DerefThis,
12026 Statements.push_back(Copy.
getAs<
Expr>());
12030 for (
auto *Field : ClassDecl->
fields()) {
12033 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
12036 if (Field->isInvalidDecl()) {
12042 if (Field->getType()->isReferenceType()) {
12043 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12044 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
12045 Diag(Field->getLocation(), diag::note_declared_at);
12053 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12054 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
12055 Diag(Field->getLocation(), diag::note_declared_at);
12061 if (Field->isZeroLengthBitField(Context))
12064 QualType FieldType = Field->getType().getNonReferenceType();
12067 "Incomplete array type is not valid");
12073 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
12076 MemberLookup.resolveKind();
12078 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
12080 MemberBuilder To(This, getCurrentThisType(),
true, MemberLookup);
12093 Statements.push_back(Copy.
getAs<
Stmt>());
12098 ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
12101 if (Return.isInvalid())
12104 Statements.push_back(Return.getAs<
Stmt>());
12115 Body = ActOnCompoundStmt(Loc, Loc, Statements,
12117 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
12120 CopyAssignOperator->
markUsed(Context);
12123 L->CompletedImplicitDefinition(CopyAssignOperator);
12130 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveAssignment);
12131 if (DSM.isAlreadyBeingDeclared())
12158 if (getLangOpts().CUDA) {
12159 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveAssignment,
12172 ClassLoc, ClassLoc,
12180 ? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
12186 Scope *S = getScopeForContext(ClassDecl);
12187 CheckImplicitSpecialMemberDeclaration(S, MoveAssignment);
12189 if (ShouldDeleteSpecialMember(MoveAssignment, CXXMoveAssignment)) {
12191 SetDeclDeleted(MoveAssignment, ClassLoc);
12195 PushOnScopeChains(MoveAssignment, S,
false);
12196 ClassDecl->
addDecl(MoveAssignment);
12198 return MoveAssignment;
12217 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
12220 for (
auto &BI : Class->
bases()) {
12221 Worklist.push_back(&BI);
12222 while (!Worklist.empty()) {
12255 if (Existing && Existing != &BI) {
12256 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
12259 << (Base->getCanonicalDecl() ==
12262 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
12263 << (Base->getCanonicalDecl() ==
12264 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
12268 Existing =
nullptr;
12278 for (
auto &BI : Base->
bases())
12279 Worklist.push_back(&BI);
12292 "DefineImplicitMoveAssignment called for wrong function");
12318 ResolveExceptionSpec(CurrentLocation,
12330 getAs<RValueReferenceType>()->getPointeeType();
12338 RefBuilder OtherRef(Other, OtherRefType);
12340 MoveCastBuilder MoveOther(OtherRef);
12346 bool Invalid =
false;
12347 for (
auto &Base : ClassDecl->
bases()) {
12365 BasePath.push_back(&Base);
12369 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
12372 DerefBuilder DerefThis(This);
12375 CastBuilder To(DerefThis,
12391 Statements.push_back(Move.
getAs<
Expr>());
12395 for (
auto *Field : ClassDecl->
fields()) {
12398 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
12401 if (Field->isInvalidDecl()) {
12407 if (Field->getType()->isReferenceType()) {
12408 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12409 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
12410 Diag(Field->getLocation(), diag::note_declared_at);
12418 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12419 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
12420 Diag(Field->getLocation(), diag::note_declared_at);
12426 if (Field->isZeroLengthBitField(Context))
12429 QualType FieldType = Field->getType().getNonReferenceType();
12432 "Incomplete array type is not valid");
12437 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
12440 MemberLookup.resolveKind();
12441 MemberBuilder From(MoveOther, OtherRefType,
12442 false, MemberLookup);
12443 MemberBuilder To(This, getCurrentThisType(),
12444 true, MemberLookup);
12446 assert(!From.build(*
this, Loc)->isLValue() &&
12447 "Member reference with rvalue base must be rvalue except for reference " 12448 "members, which aren't allowed for move assignment.");
12455 if (Move.isInvalid()) {
12461 Statements.push_back(Move.getAs<
Stmt>());
12467 CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
12470 if (Return.isInvalid())
12473 Statements.push_back(Return.getAs<
Stmt>());
12484 Body = ActOnCompoundStmt(Loc, Loc, Statements,
12486 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
12489 MoveAssignOperator->
markUsed(Context);
12492 L->CompletedImplicitDefinition(MoveAssignOperator);
12503 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyConstructor);
12504 if (DSM.isAlreadyBeingDeclared())
12519 CXXCopyConstructor,
12531 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12537 if (getLangOpts().CUDA) {
12538 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyConstructor,
12544 setupImplicitSpecialMemberType(CopyConstructor, Context.
VoidTy, ArgType);
12548 ClassLoc, ClassLoc,
12556 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
12560 ClassDecl->
hasAttr<TrivialABIAttr>() ||
12562 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor,
12563 TAH_ConsiderTrivialABI)
12569 Scope *S = getScopeForContext(ClassDecl);
12570 CheckImplicitSpecialMemberDeclaration(S, CopyConstructor);
12572 if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) {
12574 SetDeclDeleted(CopyConstructor, ClassLoc);
12578 PushOnScopeChains(CopyConstructor, S,
false);
12579 ClassDecl->
addDecl(CopyConstructor);
12581 return CopyConstructor;
12590 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
12595 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
12601 ResolveExceptionSpec(CurrentLocation,
12603 MarkVTableUsed(CurrentLocation, ClassDecl);
12615 if (SetCtorInitializers(CopyConstructor,
false)) {
12623 ActOnCompoundStmt(Loc, Loc,
None,
false).getAs<Stmt>());
12624 CopyConstructor->
markUsed(Context);
12628 L->CompletedImplicitDefinition(CopyConstructor);
12636 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveConstructor);
12637 if (DSM.isAlreadyBeingDeclared())
12648 CXXMoveConstructor,
12661 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12667 if (getLangOpts().CUDA) {
12668 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveConstructor,
12674 setupImplicitSpecialMemberType(MoveConstructor, Context.
VoidTy, ArgType);
12678 ClassLoc, ClassLoc,
12686 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
12690 ClassDecl->
hasAttr<TrivialABIAttr>() ||
12692 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor,
12693 TAH_ConsiderTrivialABI)
12699 Scope *S = getScopeForContext(ClassDecl);
12700 CheckImplicitSpecialMemberDeclaration(S, MoveConstructor);
12702 if (ShouldDeleteSpecialMember(MoveConstructor, CXXMoveConstructor)) {
12704 SetDeclDeleted(MoveConstructor, ClassLoc);
12708 PushOnScopeChains(MoveConstructor, S,
false);
12709 ClassDecl->
addDecl(MoveConstructor);
12711 return MoveConstructor;
12720 "DefineImplicitMoveConstructor - call it for implicit move ctor");
12725 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
12731 ResolveExceptionSpec(CurrentLocation,
12733 MarkVTableUsed(CurrentLocation, ClassDecl);
12738 if (SetCtorInitializers(MoveConstructor,
false)) {
12745 MoveConstructor->
setBody(ActOnCompoundStmt(
12746 Loc, Loc,
None,
false).getAs<Stmt>());
12747 MoveConstructor->
markUsed(Context);
12751 L->CompletedImplicitDefinition(MoveConstructor);
12766 FunctionDecl *CallOp = Lambda->getLambdaCallOperator();
12767 FunctionDecl *Invoker = Lambda->getLambdaStaticInvoker();
12770 CallOp = InstantiateFunctionDeclaration(
12775 Invoker = InstantiateFunctionDeclaration(
12789 MarkFunctionReferenced(CurrentLocation, CallOp);
12800 Expr *FunctionRef = BuildDeclRefExpr(Invoker, Invoker->
getType(),
12802 assert(FunctionRef &&
"Can't refer to __invoke function?");
12803 Stmt *Return = BuildReturnStmt(Conv->
getLocation(), FunctionRef).
get();
12810 L->CompletedImplicitDefinition(Conv);
12811 L->CompletedImplicitDefinition(Invoker);
12826 Expr *This = ActOnCXXThis(CurrentLocation).get();
12827 Expr *DerefThis =CreateBuiltinUnaryOp(CurrentLocation, UO_Deref, This).get();
12829 ExprResult BuildBlock = BuildBlockForLambdaConversion(CurrentLocation,
12837 if (!BuildBlock.
isInvalid() && !getLangOpts().ObjCAutoRefCount)
12839 CK_CopyAndAutoreleaseBlockObject,
12843 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12852 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12858 Stmt *ReturnS = Return.
get();
12865 L->CompletedImplicitDefinition(Conv);
12872 switch (Args.size()) {
12877 if (!Args[1]->isDefaultArgument())
12882 return !Args[0]->isDefaultArgument();
12893 bool HadMultipleCandidates,
12894 bool IsListInitialization,
12895 bool IsStdInitListInitialization,
12896 bool RequiresZeroInit,
12897 unsigned ConstructKind,
12899 bool Elidable =
false;
12913 Expr *SubExpr = ExprArgs[0];
12918 return BuildCXXConstructExpr(ConstructLoc, DeclInitType,
12919 FoundDecl, Constructor,
12920 Elidable, ExprArgs, HadMultipleCandidates,
12921 IsListInitialization,
12922 IsStdInitListInitialization, RequiresZeroInit,
12923 ConstructKind, ParenRange);
12932 bool HadMultipleCandidates,
12933 bool IsListInitialization,
12934 bool IsStdInitListInitialization,
12935 bool RequiresZeroInit,
12936 unsigned ConstructKind,
12938 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
12939 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
12940 if (DiagnoseUseOfDecl(Constructor, ConstructLoc))
12944 return BuildCXXConstructExpr(
12945 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
12946 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
12947 RequiresZeroInit, ConstructKind, ParenRange);
12957 bool HadMultipleCandidates,
12958 bool IsListInitialization,
12959 bool IsStdInitListInitialization,
12960 bool RequiresZeroInit,
12961 unsigned ConstructKind,
12966 "given constructor for wrong type");
12967 MarkFunctionReferenced(ConstructLoc, Constructor);
12968 if (getLangOpts().CUDA && !CheckCUDACall(ConstructLoc, Constructor))
12972 Context, DeclInitType, ConstructLoc, Constructor, Elidable,
12973 ExprArgs, HadMultipleCandidates, IsListInitialization,
12974 IsStdInitListInitialization, RequiresZeroInit,
12975 static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
13004 assert((getLangOpts().Modules || (!Lookup.
empty() && Lookup.
size() <= 2)) &&
13005 "more than two lookup results for field name");
13008 assert(isa<CXXRecordDecl>(Lookup[0]) &&
13009 "cannot have other non-field member with same name");
13010 for (
auto L : Lookup)
13011 if (isa<FieldDecl>(L)) {
13012 Pattern = cast<FieldDecl>(L);
13015 assert(Pattern &&
"We must have set the Pattern!");
13018 if (!Pattern->hasInClassInitializer() ||
13019 InstantiateInClassInitializer(Loc, Field, Pattern,
13020 getTemplateInstantiationArgs(Field))) {
13043 Diag(Loc, diag::err_in_class_initializer_not_yet_parsed)
13044 << OutermostClass << Field;
13045 Diag(Field->getEndLoc(), diag::note_in_class_initializer_not_yet_parsed);
13047 if (!isSFINAEContext())
13048 Field->setInvalidDecl();
13064 MarkFunctionReferenced(VD->
getLocation(), Destructor);
13065 CheckDestructorAccess(VD->
getLocation(), Destructor,
13066 PDiag(diag::err_access_dtor_var)
13069 DiagnoseUseOfDecl(Destructor, VD->
getLocation());
13093 bool AllowExplicit,
13094 bool IsListInitialization) {
13096 unsigned NumArgs = ArgsPtr.size();
13097 Expr **Args = ArgsPtr.data();
13101 assert(Proto &&
"Constructor without a prototype?");
13105 if (NumArgs < NumParams)
13106 ConvertedArgs.reserve(NumParams);
13108 ConvertedArgs.reserve(NumArgs);
13111 Proto->
isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
13113 bool Invalid = GatherArgumentsForCall(Loc, Constructor,
13115 llvm::makeArrayRef(Args, NumArgs),
13117 CallType, AllowExplicit,
13118 IsListInitialization);
13119 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
13121 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
13123 CheckConstructorCall(Constructor,
13124 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
13134 if (isa<NamespaceDecl>(DC)) {
13136 diag::err_operator_new_delete_declared_in_namespace)
13140 if (isa<TranslationUnitDecl>(DC) &&
13143 diag::err_operator_new_delete_declared_static)
13161 unsigned DependentParamTypeDiag,
13162 unsigned InvalidParamTypeDiag) {
13169 diag::err_operator_new_delete_dependent_result_type)
13182 diag::err_operator_new_delete_invalid_result_type)
13188 diag::err_operator_new_delete_template_too_few_parameters)
13194 diag::err_operator_new_delete_too_few_parameters)
13201 << FnDecl->
getDeclName() << ExpectedFirstParamType;
13212 ExpectedFirstParamType)
13214 << FnDecl->
getDeclName() << ExpectedFirstParamType;
13236 diag::err_operator_new_dependent_param_type,
13237 diag::err_operator_new_param_type))
13244 diag::err_operator_new_default_arg)
13274 SemaRef, FnDecl, SemaRef.
Context.
VoidTy, ExpectedFirstParamType,
13275 diag::err_operator_delete_dependent_param_type,
13276 diag::err_operator_delete_param_type))
13285 diag::err_destroying_operator_delete_not_usual);
13297 "Expected an overloaded operator declaration");
13307 if (Op == OO_Delete || Op == OO_Array_Delete)
13310 if (Op == OO_New || Op == OO_Array_New)
13318 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
13319 if (MethodDecl->isStatic())
13321 diag::err_operator_overload_static) << FnDecl->
getDeclName();
13323 bool ClassOrEnumParam =
false;
13325 QualType ParamType = Param->getType().getNonReferenceType();
13328 ClassOrEnumParam =
true;
13333 if (!ClassOrEnumParam)
13335 diag::err_operator_overload_needs_class_or_enum)
13345 if (Op != OO_Call) {
13347 if (Param->hasDefaultArg())
13348 return Diag(Param->getLocation(),
13349 diag::err_operator_overload_default_arg)
13350 << FnDecl->
getDeclName() << Param->getDefaultArgRange();
13355 {
false,
false,
false }
13356 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 13357 , { Unary, Binary, MemberOnly } 13358 #include "clang/Basic/OperatorKinds.def" 13361 bool CanBeUnaryOperator = OperatorUses[Op][0];
13362 bool CanBeBinaryOperator = OperatorUses[Op][1];
13363 bool MustBeMemberOperator = OperatorUses[Op][2];
13370 + (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
13371 if (Op != OO_Call &&
13372 ((NumParams == 1 && !CanBeUnaryOperator) ||
13373 (NumParams == 2 && !CanBeBinaryOperator) ||
13374 (NumParams < 1) || (NumParams > 2))) {
13377 if (CanBeUnaryOperator && CanBeBinaryOperator) {
13379 }
else if (CanBeUnaryOperator) {
13382 assert(CanBeBinaryOperator &&
13383 "All non-call overloaded operators are unary or binary!");
13387 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
13392 if (Op != OO_Call &&
13394 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
13399 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
13401 diag::err_operator_overload_must_be_member)
13415 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
13422 diag::err_operator_overload_post_incdec_must_be_int)
13423 << LastParam->
getType() << (Op == OO_MinusMinus);
13435 if (TemplateParams->
size() == 1) {
13444 }
else if (TemplateParams->
size() == 2) {
13453 PmArgs->isTemplateParameterPack()) {
13460 diag::ext_string_literal_operator_template);
13467 diag::err_literal_operator_template)
13476 if (isa<CXXMethodDecl>(FnDecl)) {
13477 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
13486 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
13503 diag::err_literal_operator_template_with_params);
13532 diag::err_literal_operator_param)
13549 diag::err_literal_operator_invalid_param)
13559 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
13566 Diag((*Param)->getSourceRange().getBegin(),
13567 diag::err_literal_operator_param)
13568 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13575 Diag((*Param)->getSourceRange().getBegin(),
13576 diag::err_literal_operator_param)
13577 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13590 Diag((*Param)->getSourceRange().getBegin(),
13591 diag::err_literal_operator_param)
13592 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13600 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
13602 Diag((*Param)->getSourceRange().getBegin(),
13603 diag::err_literal_operator_param)
13605 << (*Param)->getSourceRange();
13609 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
13618 if (Param->hasDefaultArg()) {
13619 Diag(Param->getDefaultArgRange().getBegin(),
13620 diag::err_literal_operator_default_argument)
13621 << Param->getDefaultArgRange();
13626 StringRef LiteralName
13628 if (LiteralName[0] !=
'_' &&
13629 !getSourceManager().isInSystemHeader(FnDecl->
getLocation())) {
13651 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
13660 else if (Lang ==
"C++")
13663 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
13674 PushDeclContext(S, D);
13690 return LinkageSpec;
13699 ProcessDeclAttributeList(S, ED, AttrList);
13701 CurContext->addDecl(ED);
13713 bool Invalid =
false;
13727 Diag(Loc, diag::err_catch_rvalue_ref);
13732 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
13738 unsigned DK = diag::err_catch_incomplete;
13742 DK = diag::err_catch_incomplete_ptr;
13747 DK = diag::err_catch_incomplete_ref;
13749 if (!Invalid && (Mode == 0 || !BaseType->
isVoidType()) &&
13750 !BaseType->
isDependentType() && RequireCompleteType(Loc, BaseType, DK))
13754 RequireNonAbstractType(Loc, ExDeclType,
13755 diag::err_abstract_type_in_decl,
13756 AbstractVariableType))
13761 if (!Invalid && getLangOpts().ObjC) {
13767 Diag(Loc, diag::err_objc_object_catch);
13771 if (getLangOpts().ObjCRuntime.isFragile())
13772 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
13781 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(ExDecl))
13788 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
13806 Expr *opaqueValue =
13817 Expr *init = MaybeCreateExprWithCleanups(construct);
13822 FinalizeVarWithDestructor(ExDecl,
recordType);
13841 UPPC_ExceptionType)) {
13849 LookupOrdinaryName,
13850 ForVisibleRedeclaration)) {
13855 if (isDeclInScope(PrevDecl, CurContext, S)) {
13858 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
13860 }
else if (PrevDecl->isTemplateParameter())
13871 VarDecl *ExDecl = BuildExceptionDeclaration(
13878 PushOnScopeChains(ExDecl, S);
13880 CurContext->addDecl(ExDecl);
13882 ProcessDeclAttributes(S, ExDecl, D);
13888 Expr *AssertMessageExpr,
13891 AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) :
nullptr;
13893 if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
13896 return BuildStaticAssertDeclaration(StaticAssertLoc, AssertExpr,
13897 AssertMessage, RParenLoc,
false);
13905 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
13910 ExprResult Converted = PerformContextuallyConvertToBool(AssertExpr);
13917 if (!Failed && VerifyIntegerConstantExpression(Converted.
get(), &Cond,
13918 diag::err_static_assert_expression_is_not_constant,
13922 if (!Failed && !Cond) {
13924 llvm::raw_svector_ostream Msg(MsgBuffer);
13926 AssertMessage->
printPretty(Msg,
nullptr, getPrintingPolicy());
13928 Expr *InnerCond =
nullptr;
13929 std::string InnerCondDescription;
13930 std::tie(InnerCond, InnerCondDescription) =
13931 findFailedBooleanCondition(Converted.
get());
13932 if (InnerCond && !isa<CXXBoolLiteralExpr>(InnerCond)
13933 && !isa<IntegerLiteral>(InnerCond)) {
13934 Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed)
13935 << InnerCondDescription << !AssertMessage
13938 Diag(StaticAssertLoc, diag::err_static_assert_failed)
13945 ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
13951 AssertExpr = FullAssertExpr.
get();
13954 AssertExpr, AssertMessage, RParenLoc,
13957 CurContext->addDecl(Decl);
13967 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
13977 if (!CodeSynthesisContexts.empty()) {
13992 getLangOpts().CPlusPlus11 ?
13993 diag::warn_cxx98_compat_unelaborated_friend_type :
13994 diag::ext_unelaborated_friend_type)
14002 diag::warn_cxx98_compat_nonclass_type_friend :
14003 diag::ext_nonclass_type_friend)
14010 diag::warn_cxx98_compat_enum_friend :
14011 diag::ext_enum_friend)
14022 if (getLangOpts().
CPlusPlus11 && LocStart != FriendLoc)
14023 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
14044 bool IsMemberSpecialization =
false;
14045 bool Invalid =
false;
14048 MatchTemplateParametersToScopeSpecifier(
14049 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
14050 IsMemberSpecialization, Invalid)) {
14051 if (TemplateParams->size() > 0) {
14056 return CheckClassTemplate(S, TagSpec, TUK_Friend, TagLoc, SS, Name,
14057 NameLoc, Attr, TemplateParams,
AS_public,
14059 FriendLoc, TempParamLists.size() - 1,
14060 TempParamLists.data()).
get();
14063 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
14065 IsMemberSpecialization =
true;
14069 if (Invalid)
return nullptr;
14071 bool isAllExplicitSpecializations =
true;
14072 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
14073 if (TempParamLists[I]->size()) {
14074 isAllExplicitSpecializations =
false;
14084 if (isAllExplicitSpecializations) {
14086 bool Owned =
false;
14087 bool IsDependent =
false;
14088 return ActOnTag(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc,
14102 QualType T = CheckTypenameType(Keyword, TagLoc, QualifierLoc,
14108 if (isa<DependentNameType>(T)) {
14122 TSI, FriendLoc, TempParamLists);
14124 CurContext->addDecl(Friend);
14128 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
14135 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
14146 TSI, FriendLoc, TempParamLists);
14149 CurContext->addDecl(Friend);
14209 if (DiagnoseUnexpandedParameterPack(Loc, TSI, UPPC_FriendDeclaration))
14227 Diag(Loc, diag::err_tagless_friend_type_template)
14244 if (!TempParams.empty())
14256 CurContext->addDecl(D);
14282 Diag(Loc, diag::err_unexpected_friend);
14309 if (DiagnoseUnexpandedParameterPack(Loc, TInfo, UPPC_FriendDeclaration) ||
14310 DiagnoseUnexpandedParameterPack(NameInfo, UPPC_FriendDeclaration) ||
14311 DiagnoseUnexpandedParameterPack(SS, UPPC_FriendDeclaration))
14317 Scope *DCScope = S;
14319 ForExternalRedeclaration);
14327 (FunctionContainingLocalClass =
14328 cast<CXXRecordDecl>(CurContext)->isLocalClass())) {
14343 Previous.
clear(LookupLocalFriendName);
14344 LookupName(Previous, S,
false);
14346 if (!Previous.
empty()) {
14354 DC = FunctionContainingLocalClass;
14356 adjustContextForLocalExternDecl(DC);
14376 bool isTemplateId =
14397 LookupQualifiedName(Previous, LookupDC);
14399 if (!Previous.
empty()) {
14404 if (isTemplateId) {
14405 if (isa<TranslationUnitDecl>(LookupDC))
break;
14412 DCScope = getScopeForDeclContext(S, DC);
14418 DC = computeDeclContext(SS);
14419 if (!DC)
return nullptr;
14421 if (RequireCompleteDeclContext(SS, DC))
return nullptr;
14423 LookupQualifiedName(Previous, DC);
14427 if (DC->
Equals(CurContext))
14429 getLangOpts().CPlusPlus11 ?
14430 diag::warn_cxx98_compat_friend_is_member :
14431 diag::err_friend_is_member);
14467 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
14494 if (DiagArg >= 0) {
14495 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
14506 DCScope = &FakeDCScope;
14509 bool AddToScope =
true;
14510 NamedDecl *ND = ActOnFunctionDeclarator(DCScope, D, DC, TInfo, Previous,
14511 TemplateParams, AddToScope);
14512 if (!ND)
return nullptr;
14526 if (!CurContext->isDependentContext()) {
14529 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
14530 PushOnScopeChains(ND, EnclosingScope,
false);
14537 CurContext->addDecl(FrD);
14542 if (DC->isRecord()) CheckFriendAccess(ND);
14546 FD = FTD->getTemplatedDecl();
14548 FD = cast<FunctionDecl>(ND);
14559 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
14561 diag::note_previous_declaration);
14563 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
14568 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
14570 << cast<CXXRecordDecl>(CurContext);
14579 AdjustDeclIfTemplate(Dcl);
14581 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
14583 Diag(DelLoc, diag::err_deleted_non_function);
14594 Prev->getPreviousDecl()) &&
14595 !Prev->isDefined()) {
14596 Diag(DelLoc, diag::err_deleted_decl_not_first);
14597 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
14598 Prev->isImplicit() ? diag::note_previous_implicit_declaration
14599 : diag::note_previous_declaration);
14618 bool IssuedDiagnostic =
false;
14621 if (!IssuedDiagnostic) {
14623 IssuedDiagnostic =
true;
14625 Diag(O->getLocation(), diag::note_overridden_virtual_function);
14631 ShouldDeleteSpecialMember(MD, getSpecialMember(MD),
nullptr,
14638 Diag(DelLoc, diag::err_deleted_main);
14657 if (Member == CXXInvalid) {
14659 Diag(DefaultLoc, diag::err_default_special_members);
14685 CheckExplicitlyDefaultedSpecialMember(MD);
14690 Diag(DefaultLoc, diag::err_default_special_members);
14698 if (isa<ReturnStmt>(SubStmt))
14699 Self.
Diag(SubStmt->getBeginLoc(),
14700 diag::err_return_in_constructor_handler);
14701 if (!isa<Expr>(SubStmt))
14707 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
14719 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
14723 !NewFT->getExtParameterInfo(I).isNoEscape()) {
14725 diag::warn_overriding_method_missing_noescape);
14727 diag::note_overridden_marked_noescape);
14732 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
14733 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
14734 if ((NewCSA || OldCSA) &&
14735 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
14744 if (NewCC == OldCC)
14755 diag::err_conflicting_overriding_cc_attributes)
14781 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
14789 if (NewClassTy.
isNull()) {
14791 diag::err_different_return_type_for_overriding_virtual_function)
14807 if (!RT->isBeingDefined() &&
14808 RequireCompleteType(New->
getLocation(), NewClassTy,
14809 diag::err_covariant_return_incomplete,
14815 if (!IsDerivedFrom(New->
getLocation(), NewClassTy, OldClassTy)) {
14825 if (CheckDerivedToBaseConversion(
14826 NewClassTy, OldClassTy,
14827 diag::err_covariant_return_inaccessible_base,
14828 diag::err_covariant_return_ambiguous_derived_to_base_conv,
14844 diag::err_covariant_return_type_different_qualifications)
14856 diag::err_covariant_return_type_class_type_more_qualified)
14891 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
14892 CheckPureMethod(M, ZeroLoc);
14900 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
14901 return Var->hasGlobalStorage();
14929 PushExpressionEvaluationContext(
14930 ExpressionEvaluationContext::PotentiallyEvaluated, D);
14940 PopExpressionEvaluationContext();
14943 ExitDeclaratorContext(S);
14955 "Parser allowed 'typedef' as storage class of condition decl.");
14957 Decl *Dcl = ActOnDeclarator(S, D);
14961 if (isa<FunctionDecl>(Dcl)) {
14962 Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
14971 if (!ExternalSource)
14975 ExternalSource->ReadUsedVTables(VTables);
14977 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
14978 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
14979 = VTablesUsed.find(VTables[I].Record);
14981 if (Pos != VTablesUsed.end()) {
14982 if (!Pos->second && VTables[I].DefinitionRequired)
14983 Pos->second =
true;
14987 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
14988 NewUses.push_back(
VTableUse(VTables[I].Record, VTables[I].Location));
14991 VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end());
14995 bool DefinitionRequired) {
14999 CurContext->isDependentContext() || isUnevaluatedContext())
15003 if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
15004 !isInOpenMPDeclareTargetContext() &&
15005 !isInOpenMPTargetExecutionDirective()) {
15006 if (!DefinitionRequired)
15007 MarkVirtualMembersReferenced(Loc, Class);
15012 LoadExternalVTableUses();
15014 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
15015 Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
15020 if (DefinitionRequired && !Pos.first->second) {
15021 Pos.first->second =
true;
15039 CheckDestructor(DD);
15051 MarkVirtualMembersReferenced(Loc, Class);
15053 VTableUses.push_back(std::make_pair(Class, Loc));
15057 LoadExternalVTableUses();
15058 if (VTableUses.empty())
15065 bool DefinedAnything =
false;
15066 for (
unsigned I = 0; I != VTableUses.size(); ++I) {
15075 bool DefineVTable =
true;
15081 if (KeyFunction && !KeyFunction->
hasBody()) {
15083 DefineVTable =
false;
15088 "Instantiations don't have key functions");
15090 }
else if (!KeyFunction) {
15095 bool IsExplicitInstantiationDeclaration =
15097 for (
auto R : Class->
redecls()) {
15101 IsExplicitInstantiationDeclaration =
true;
15103 IsExplicitInstantiationDeclaration =
false;
15108 if (IsExplicitInstantiationDeclaration)
15109 DefineVTable =
false;
15115 if (!DefineVTable) {
15116 MarkVirtualMemberExceptionSpecsNeeded(Loc, Class);
15123 DefinedAnything =
true;
15124 MarkVirtualMembersReferenced(Loc, Class);
15126 if (VTablesUsed[Canonical])
15127 Consumer.HandleVTable(Class);
15135 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
15139 ? diag::warn_weak_template_vtable
15140 : diag::warn_weak_vtable)
15145 VTableUses.clear();
15147 return DefinedAnything;
15152 for (
const auto *I : RD->
methods())
15153 if (I->isVirtual() && !I->isPure())
15162 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
15163 E = FinalOverriders.end();
15166 OE = I->second.end();
15168 assert(OI->second.size() > 0 &&
"no final overrider");
15173 if (!Overrider->isPure())
15174 MarkFunctionReferenced(Loc, Overrider);
15182 for (
const auto &I : RD->
bases()) {
15184 cast<CXXRecordDecl>(I.getType()->getAs<
RecordType>()->getDecl());
15187 MarkVirtualMembersReferenced(Loc, Base);
15198 CollectIvarsToConstructOrDestruct(OID, ivars);
15202 for (
unsigned i = 0; i < ivars.size(); i++) {
15214 InitSeq.Perform(*
this, InitEntity, InitKind,
None);
15215 MemberInit = MaybeCreateExprWithCleanups(MemberInit);
15226 AllToInit.push_back(Member);
15231 ->getAs<RecordType>()) {
15232 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
15234 MarkFunctionReferenced(Field->
getLocation(), Destructor);
15235 CheckDestructorAccess(Field->
getLocation(), Destructor,
15236 PDiag(diag::err_access_dtor_ivar)
15242 AllToInit.data(), AllToInit.size());
15248 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Valid,
15249 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Invalid,
15250 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Current,
15261 (void)Target->
hasBody(FNTarget);
15263 cast_or_null<CXXConstructorDecl>(FNTarget));
15270 if (!Current.insert(Canonical).second)
15276 Valid.insert(Current.begin(), Current.end());
15279 }
else if (TCanonical == Canonical || Invalid.count(TCanonical) ||
15280 Current.count(TCanonical)) {
15282 if (!Invalid.count(TCanonical)) {
15284 diag::warn_delegating_ctor_cycle)
15288 if (TCanonical != Canonical)
15295 assert(FNTarget &&
"Ctor cycle through bodiless function");
15298 cast<CXXConstructorDecl>(FNTarget));
15303 Invalid.insert(Current.begin(), Current.end());
15312 llvm::SmallPtrSet<CXXConstructorDecl*, 4> Valid, Invalid, Current;
15314 for (DelegatingCtorDeclsType::iterator
15315 I = DelegatingCtorDecls.begin(ExternalSource),
15316 E = DelegatingCtorDecls.end();
15320 for (
auto CI = Invalid.begin(), CE = Invalid.end(); CI != CE; ++CI)
15321 (*CI)->setInvalidDecl();
15330 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
15358 FindCXXThisExpr Finder(*
this);
15366 if (checkThisInStaticMemberFunctionExceptionSpec(Method))
15369 return checkThisInStaticMemberFunctionAttributes(Method);
15383 FindCXXThisExpr Finder(*
this);
15404 if (!Finder.TraverseType(E))
15414 FindCXXThisExpr Finder(*
this);
15417 for (
const auto *A : Method->
attrs()) {
15419 Expr *Arg =
nullptr;
15421 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
15423 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
15425 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
15426 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
15427 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
15428 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
15429 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
15430 Arg = ETLF->getSuccessValue();
15431 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
15432 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
15433 Arg = STLF->getSuccessValue();
15434 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
15435 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
15436 Arg = LR->getArg();
15437 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
15438 Args = llvm::makeArrayRef(LE->args_begin(), LE->args_size());
15439 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
15440 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
15441 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
15442 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
15443 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
15444 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
15445 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
15446 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
15448 if (Arg && !Finder.TraverseStmt(Arg))
15451 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
15452 if (!Finder.TraverseStmt(Args[I]))
15466 Exceptions.clear();
15469 Exceptions.reserve(DynamicExceptions.size());
15470 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
15472 QualType ET = GetTypeFromParser(DynamicExceptions[ei]);
15477 if (!Unexpanded.empty()) {
15479 DynamicExceptionRanges[ei].getBegin(), UPPC_ExceptionType,
15487 if (!CheckSpecifiedExceptionType(ET, DynamicExceptionRanges[ei]))
15488 Exceptions.push_back(ET);
15498 "Parser should have made sure that the expression is boolean");
15499 if (IsTopLevel && DiagnoseUnexpandedParameterPack(NoexceptExpr)) {
15514 Expr *NoexceptExpr) {
15520 MethodD = FunTmpl->getTemplatedDecl();
15529 checkExceptionSpecification(
true, EST, DynamicExceptions,
15530 DynamicExceptionRanges, NoexceptExpr, Exceptions,
15537 checkThisInStaticMemberFunctionExceptionSpec(Method);
15542 CheckOverridingFunctionExceptionSpec(Method, O);
15556 Diag(DeclStart, diag::err_anonymous_property);
15564 CheckExtraCXXDefaultArguments(D);
15567 UPPC_DataMemberType)) {
15578 << getLangOpts().CPlusPlus17;
15581 diag::err_invalid_thread)
15587 ForVisibleRedeclaration);
15588 LookupName(Previous, S);
15609 PrevDecl =
nullptr;
15612 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
15613 PrevDecl =
nullptr;
15620 ProcessDeclAttributes(TUScope, NewPD, D);
15633 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)
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field)
Field is the non-static data member whose default initializer is used by this expression.
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...
static unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built...
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
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)
static unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
Decl * Entity
The entity that is being synthesized.
Expr *const * semantics_iterator
static ClassTemplateDecl * LookupStdInitializerList(Sema &S, SourceLocation Loc)
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
CXXRecordDecl * getCurrentClass(Scope *S, const CXXScopeSpec *SS)
Get the class that is directly named by the current context.
Filter makeFilter()
Create a filter for this result set.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
CXXCatchStmt * getHandler(unsigned i)
IfStmt - This represents an if/then/else.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD)
Check a completed declaration of an implicit special member.
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
An instance of this object exists for each enum constant that is defined.
bool isRealFloatingType() const
Floating point categories.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class...
static CharSourceRange getTokenRange(SourceRange R)
void addConst()
Add the const type qualifier to this QualType.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
static unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
bool isRecordType() const
static TemplateArgumentLoc getTrivialTypeTemplateArgument(Sema &S, SourceLocation Loc, QualType T)
bool isEmpty() const
No scope specifier.
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
void erase()
Erase the last element returned from this iterator.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation)
Builds a using declaration.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
bool 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)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
bool isOverrideSpecified() const
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
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.
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 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...
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.
noexcept(expression), value-dependent
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
The collection of all-type qualifiers we support.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
bool isRecordingPaths() const
Whether we are recording paths.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T)
Determine whether the given type is an incomplete or zero-lenfgth array type.
void CheckDelayedMemberExceptionSpecs()
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
SourceLocation getFriendSpecLoc() const
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
bool isRedeclaration() const
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer *> MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
Represents a struct/union/class.
bool hasTrivialCopyConstructorForCall() const
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
static QualType getTupleLikeElementType(Sema &S, SourceLocation Loc, unsigned I, QualType T)
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Description of a constructor that was inherited from a base class.
static bool IsEquivalentForUsingDecl(ASTContext &Context, NamedDecl *D1, NamedDecl *D2)
Determine whether a using declaration considers the given declarations as "equivalent", e.g., if they are redeclarations of the same entity or are both typedefs of the same type.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
unsigned getDepth() const
Retrieve the depth of the template parameter.
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
static bool IsUsingDirectiveInToplevelContext(DeclContext *CurContext)
Determine whether a using statement is in a context where it will be apply in all contexts...
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
void setRecordingPaths(bool RP)
Specify whether we should be recording paths or not.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
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 ...
static unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
A C++ nested-name-specifier augmented with source location information.
bool isInline() const
Returns true if this is an inline namespace declaration.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ArrayRef< QualType > getParamTypes() const
The results of name lookup within a DeclContext.
SourceLocation getTypeSpecTypeLoc() const
TypeSourceInfo * getTypeSourceInfo() const
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
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.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
ParmVarDecl * getParam(unsigned i) const
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.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization. ...
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace...
static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class)
Represents the results of name lookup.
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
TagKind getTagKind() const
Microsoft throw(...) extension.
A convenient class for passing around template argument information.
void setParamDestroyedInCallee(bool V)
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
bool isSpecialMemberAccessibleForDeletion(CXXMethodDecl *decl, AccessSpecifier access, QualType objectType)
Is the given special member function accessible for the purposes of deciding whether to define a spec...
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow)
Determines whether to create a using shadow decl for a particular decl, given the set of decls existi...
bool needsOverloadResolutionForCopyAssignment() const
Determine whether we need to eagerly declare a defaulted copy assignment operator for this class...
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true)
bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS)
Determine whether the identifier II is a typo for the name of the class type currently being defined...
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool CheckConstexprFunctionDecl(const FunctionDecl *FD)
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
ArrayRef< NamedDecl * > chain() const
An x-value expression is a reference to an object with independent storage but which can be "moved"...
A friend of a previously-undeclared entity.
bool hasNonTrivialDestructorForCall() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
static bool BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, FieldDecl *Field, IndirectFieldDecl *Indirect, CXXCtorInitializer *&CXXMemberInit)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
const clang::PrintingPolicy & getPrintingPolicy() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
static void NoteIndirectBases(ASTContext &Context, IndirectBaseSet &Set, const QualType &Type)
Recursively add the bases of Type. Don't add Type itself.
semantics_iterator semantics_end()
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.
static unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built...
void setNumCtorInitializers(unsigned numCtorInitializers)
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
FieldDecl * getAnyMember() const
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.
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...
Qualifiers getTypeQuals() const
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
init_iterator init_begin()
Retrieve an iterator to the first initializer.
IdentifierInfo * getIdentifier() const
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3).
unsigned getLength() const
Efficiently return the length of this identifier info.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location...
static TemplateArgumentLoc getTrivialIntegralTemplateArgument(Sema &S, SourceLocation Loc, QualType T, uint64_t I)
ArgPassingKind getArgPassingRestrictions() const
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
param_iterator param_begin()
Represents the this expression in C++.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, UsingDecl *UD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
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
enum clang::DeclaratorChunk::@215 Kind
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 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.
static unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
A RAII object to enter scope of a compound statement.
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Represents a ValueDecl that came out of a declarator.
SourceRange getLocalSourceRange() const
Get the local source range.
static StringRef getCategoryString(ComparisonCategoryType Kind)
static Sema::ImplicitExceptionSpecification ComputeDefaultedSpecialMemberExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD, Sema::CXXSpecialMember CSM, Sema::InheritedConstructorInfo *ICI)
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
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.
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
static unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
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
bool isConstexprSpecified() const
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member, and after instantiating an in-class initializer in a class template.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
CXXTryStmt - A C++ try block, including all handlers.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
static void DefineImplicitSpecialMember(Sema &S, CXXMethodDecl *MD, SourceLocation DefaultLoc)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
Represents a C++ template name within the type system.
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
SourceLocation getStorageClassSpecLoc() const
Defines the clang::TypeLoc interface and its subclasses.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
void DiscardCleanupsInEvaluationContext()
The argument of this type cannot be passed directly in registers.
IdentifierInfo * getAsIdentifierInfo() const
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...
Qualifiers getTypeQualifiers() const
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
InClassInitStyle
In-class initialization styles for non-static data members.
Declaration of an alias template.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for record diagnostic message.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
static bool checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, bool ConstArg, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the members of a class type allow a special member to be trivial.
A boolean condition, from 'if', 'while', 'for', or 'do'.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
static bool specialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, CXXConstructorDecl *InheritedCtor=nullptr, Sema::InheritedConstructorInfo *Inherited=nullptr)
Is the special member function which would be selected to perform the specified operation on the spec...
QualType getRecordType(const RecordDecl *Decl) const
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method)
Integrate another called method into the collected data.
CXXMethodDecl * getMethodDecl() const
Retrieves the declaration of the called method.
void setHasTrivialSpecialMemberForCall()
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool isFriendSpecified() const
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
void addContextNote(SourceLocation UseLoc)
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class...
void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an initializer for the declaration ...
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
Represents a C++ deduction guide declaration.
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
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...
static unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
We are declaring an implicit special member function.
CXXSpecialMember SpecialMember
The special member being declared or defined.
static CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
Represents a call to an inherited base class constructor from an inheriting constructor.
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...
unsigned getNumHandlers() const
decl_iterator decls_begin() const
Expr * getSubExpr() const
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void setTrivialForCallFlags(CXXMethodDecl *MD)
Attr * clone(ASTContext &C) const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
CastKind getCastKind() const
static void CheckConstexprCtorInitializer(Sema &SemaRef, const FunctionDecl *Dcl, FieldDecl *Field, llvm::SmallSet< Decl *, 16 > &Inits, bool &Diagnosed)
Check that the given field is initialized within a constexpr constructor.
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
static unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built...
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
DeclarationName getName() const
getName - Returns the embedded declaration name.
static ConstantExpr * Create(const ASTContext &Context, Expr *E)
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.
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]).
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
void CheckExplicitlyDefaultedMemberExceptionSpec(CXXMethodDecl *MD, const FunctionProtoType *T)
Check whether the exception specification provided for an explicitly-defaulted special member matches...
static bool checkSimpleDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType, llvm::function_ref< ExprResult(SourceLocation, Expr *, unsigned)> GetInit)
void setIsParsingBaseSpecifiers()
bool hasUninstantiatedDefaultArg() const
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList *> Params, FriendUnion Friend, SourceLocation FriendLoc)
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)
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
Base class for declarations which introduce a typedef-name.
const ComparisonCategoryInfo * lookupInfo(ComparisonCategoryType Kind) const
Return the cached comparison category information for the specified 'Kind'.
ast_type_traits::DynTypedNode Node
TLS with a dynamic initializer.
Represents a template argument.
TagTypeKind
The kind of a tag type.
static bool isInvalid(LocType Loc, bool *Invalid)
const ObjCInterfaceDecl * getClassInterface() const
bool hasNonTrivialCopyConstructorForCall() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Dataflow Directional Tag Classes.
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
bool isExplicit() const
Whether this function is explicit.
static void DelegatingCycleHelper(CXXConstructorDecl *Ctor, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Valid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Invalid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Current, Sema &S)
bool isValid() const
Return true if this is a valid SourceLocation object.
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
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
Returns 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 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...
static unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
void PushUsingDirective(UsingDirectiveDecl *UDir)
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
std::pair< CXXConstructorDecl *, bool > findConstructorForBase(CXXRecordDecl *Base, CXXConstructorDecl *Ctor) const
Find the constructor to use for inherited construction of a base class, and whether that base class c...
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 ...
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static void extendRight(SourceRange &R, SourceRange After)
QualType getCanonicalTypeInternal() const
SourceLocation getVirtualSpecLoc() const
Represents a C++ base or member initializer.
LanguageIDs
Represents the language in a linkage specification.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
This template specialization was declared or defined by an explicit specialization (C++ [temp...
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
bool hasNonTrivialObjCLifetime() const
IndirectFieldDecl * getIndirectMember() const
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
const llvm::APInt & getSize() const
bool isFunctionType() const
TrivialSubobjectKind
The kind of subobject we are checking for triviality.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
static const void * GetKeyForBase(ASTContext &Context, QualType BaseType)
TypeSourceInfo * getTypeSourceInfo() const
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static UsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target)
TypeLocClass getTypeLocClass() const
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr)
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
The template argument is a type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
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.
ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
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 setConstexpr(bool IC)
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter, but we can't parse it yet because we're inside a class definition.
static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, llvm::APSInt &Size)
void popCodeSynthesisContext()
void setParam(unsigned i, ParmVarDecl *VD)
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
static bool hasOneRealArgument(MultiExprArg Args)
Determine whether the given list arguments contains exactly one "real" (non-default) argument...
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.
static unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void setUnsupportedFriend(bool Unsupported)
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
Declaration of a class template.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool isVirtualSpecified() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
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.
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)
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
bool isTranslationUnit() const
Expr * getRepAsExpr() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
Represents a C++ namespace alias.
Decl * ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
No keyword precedes the qualified type name.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Represents C++ using-directive.
void DiagnoseAbstractType(const CXXRecordDecl *RD)
static Expr * CastForMoving(Sema &SemaRef, Expr *E, QualType T=QualType())
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
Describes an entity that is being initialized.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
attr::Kind getKind() const
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr *> Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
The global specifier '::'. There is no stored value.
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
The object is actually the complete object.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void setType(QualType newType)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
Wrapper for source info for pointers.
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
SourceRange getSourceRange() const LLVM_READONLY
const LangOptions & getLangOpts() const
void WillReplaceSpecifier(bool ForceReplacement)
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
Wrapper for source info for block pointers.
void setDeletedAsWritten(bool D=true)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions, such as the default constructor, copy constructor, or destructor, to the given C++ class (C++ [special]p1).
An implicit 'self' parameter.
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
ExceptionSpecInfo ExceptionSpec
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
A deduction-guide name (a template-name)
Declaration of a template function.
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
IgnoreParens - Ignore parentheses.
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
decl_iterator decls_end() const
The triviality of a method unaffected by "trivial_abi".
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
static unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
param_type_iterator param_type_end() const
unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template)
static void DiagnoseNamespaceInlineMismatch(Sema &S, SourceLocation KeywordLoc, SourceLocation Loc, IdentifierInfo *II, bool *IsInline, NamespaceDecl *PrevNS)
Diagnose a mismatch in 'inline' qualifiers when a namespace is reopened.
method_range methods() const
The subobject is a non-static data member.
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.