40 #include "llvm/ADT/STLExtras.h" 41 #include "llvm/ADT/SmallString.h" 42 #include "llvm/ADT/StringExtras.h" 46 using namespace clang;
58 class CheckDefaultArgumentVisitor
59 :
public StmtVisitor<CheckDefaultArgumentVisitor, bool> {
64 CheckDefaultArgumentVisitor(
Expr *defarg,
Sema *s)
65 : DefaultArg(defarg), S(s) {}
75 bool CheckDefaultArgumentVisitor::VisitExpr(
Expr *
Node) {
76 bool IsInvalid =
false;
78 IsInvalid |= Visit(SubStmt);
85 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
DeclRefExpr *DRE) {
87 if (
ParmVarDecl *Param = dyn_cast<ParmVarDecl>(Decl)) {
97 diag::err_param_default_argument_references_param)
98 << Param->getDeclName() << DefaultArg->getSourceRange();
99 }
else if (
VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) {
103 if (VDecl->isLocalVarDecl())
105 diag::err_param_default_argument_references_local)
106 << VDecl->getDeclName() << DefaultArg->getSourceRange();
113 bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
CXXThisExpr *ThisE) {
118 diag::err_param_default_argument_references_this)
122 bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
PseudoObjectExpr *POE) {
130 E = OVE->getSourceExpr();
131 assert(E &&
"pseudo-object binding without source expression?");
139 bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
LambdaExpr *Lambda) {
147 diag::err_lambda_capture_default_arg);
160 Proto = Self->ResolveExceptionSpec(CallLoc, Proto);
197 "Must have noexcept result for EST_ComputedNoexcept.");
199 "Should not generate implicit declarations for dependent cases, " 200 "and don't know how to handle them anyway.");
212 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
214 "Shouldn't collect exceptions when throw-all is guaranteed.");
218 if (ExceptionsSeen.insert(Self->Context.getCanonicalType(E)).second)
219 Exceptions.push_back(E);
247 if (Self->canThrow(E))
255 diag::err_typecheck_decl_incomplete_type)) {
276 CheckCompletedExpr(Arg, EqualLoc);
277 Arg = MaybeCreateExprWithCleanups(Arg);
284 UnparsedDefaultArgInstantiationsMap::iterator InstPos
285 = UnparsedDefaultArgInstantiations.find(Param);
286 if (InstPos != UnparsedDefaultArgInstantiations.end()) {
287 for (
unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
288 InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
291 UnparsedDefaultArgInstantiations.erase(InstPos);
303 if (!param || !DefaultArg)
307 UnparsedDefaultArgLocs.erase(Param);
311 Diag(EqualLoc, diag::err_param_default_argument)
318 if (DiagnoseUnexpandedParameterPack(DefaultArg, UPPC_DefaultArgument)) {
327 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
333 CheckDefaultArgumentVisitor DefaultArgChecker(DefaultArg,
this);
334 if (DefaultArgChecker.Visit(DefaultArg)) {
339 SetParamDefaultArgument(Param, DefaultArg, EqualLoc);
354 UnparsedDefaultArgLocs[Param] = ArgLoc;
366 UnparsedDefaultArgLocs.erase(Param);
390 if (MightBeFunction) {
394 MightBeFunction =
false;
397 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
401 std::unique_ptr<CachedTokens> Toks =
404 if (Toks->size() > 1)
406 Toks->back().getLocation());
408 SR = UnparsedDefaultArgLocs[Param];
418 MightBeFunction =
false;
424 for (
unsigned NumParams = FD->
getNumParams(); NumParams > 0; --NumParams) {
440 bool Invalid =
false;
451 for (; PrevForDefaultArgs;
461 if (S && !isDeclInScope(PrevForDefaultArgs, ScopeDC, S) &&
499 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
502 p < NumParams; ++p) {
506 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
509 if (OldParamHasDfl && NewParamHasDfl) {
510 unsigned DiagDefaultParamID =
511 diag::err_param_default_argument_redefinition;
516 if (getLangOpts().MicrosoftExt) {
526 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
544 for (
auto Older = PrevForDefaultArgs;
546 Older = Older->getPreviousDecl();
547 OldParam = Older->getParamDecl(p);
552 }
else if (OldParamHasDfl) {
570 }
else if (NewParamHasDfl) {
574 diag::err_param_default_argument_template_redecl)
577 diag::note_template_prev_declaration)
608 if (Record->getDescribedClassTemplate())
610 else if (isa<ClassTemplatePartialSpecializationDecl>(Record))
617 diag::err_param_default_argument_member_template_redecl)
627 if (isa<CXXConstructorDecl>(New) &&
630 OldSM = getSpecialMember(cast<CXXMethodDecl>(Old));
631 if (NewSM != OldSM) {
634 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
660 Diag(Def->getLocation(), diag::note_previous_definition);
668 if (NewGuide && NewGuide->isExplicitSpecified() !=
669 cast<CXXDeductionGuideDecl>(Old)->isExplicitSpecified()) {
671 << NewGuide->isExplicitSpecified();
681 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
699 Diag(Decomp.getLSquareLoc(), diag::err_decomp_decl_context)
700 << Decomp.getSourceRange();
704 if (!TemplateParamLists.empty()) {
707 Diag(TemplateParamLists.front()->getTemplateLoc(),
708 diag::err_decomp_decl_template);
712 Diag(Decomp.getLSquareLoc(),
713 !getLangOpts().CPlusPlus17
714 ? diag::ext_decomp_decl
716 ? diag::ext_decomp_decl_cond
717 : diag::warn_cxx14_compat_decomp_decl)
718 << Decomp.getSourceRange();
730 if (
auto SCS = DS.getStorageClassSpec()) {
732 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
734 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
736 BadSpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
738 if (DS.isConstexprSpecified()) {
739 BadSpecifiers.push_back(
"constexpr");
740 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
742 if (DS.isInlineSpecified()) {
743 BadSpecifiers.push_back(
"inline");
744 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
746 if (!BadSpecifiers.empty()) {
747 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
748 Err << (int)BadSpecifiers.size()
749 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
752 for (
auto Loc : BadSpecifierLocs)
764 UPPC_DeclarationType))
774 Diag(Decomp.getLSquareLoc(),
778 ? diag::err_decomp_decl_parens
779 : diag::err_decomp_decl_type)
797 ForVisibleRedeclaration);
798 LookupName(Previous, S,
811 FilterLookupForScope(Previous, DC, S, ConsiderLinkage,
813 if (!Previous.
empty()) {
815 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
816 Diag(Old->getLocation(), diag::note_previous_definition);
820 PushOnScopeChains(BD, S,
true);
821 Bindings.push_back(BD);
822 ParsingInitForAutoVars.insert(BD);
828 Decomp.getLSquareLoc());
830 ForVisibleRedeclaration);
833 bool AddToScope =
true;
835 ActOnVariableDeclarator(S, D, DC, TInfo, Previous,
839 CurContext->addHiddenDecl(New);
842 if (isInOpenMPDeclareTargetContext())
843 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
852 if ((int64_t)Bindings.size() != NumElems) {
853 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
854 << DecompType << (
unsigned)Bindings.size() << NumElems.toString(10)
855 << (NumElems < Bindings.size());
860 for (
auto *B : Bindings) {
865 E = GetInit(Loc, E.
get(), I++);
868 B->setBinding(ElemType, E.
get());
877 const llvm::APSInt &NumElems,
880 S, Bindings, Src, DecompType, NumElems, ElemType,
901 S, Bindings, Src, DecompType, llvm::APSInt::get(VT->
getNumElements()),
911 S, Bindings, Src, DecompType, llvm::APSInt::get(2),
922 llvm::raw_svector_ostream OS(SS);
927 Arg.getArgument().print(PrintingPolicy, OS);
937 auto DiagnoseMissing = [&] {
947 return DiagnoseMissing();
957 return DiagnoseMissing();
963 Result.suppressDiagnostics();
965 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
977 Loc, TraitTy, DiagID,
983 assert(RD &&
"specialization of class template is not a class?");
1005 llvm::APSInt &Size) {
1018 return IsTupleLike::NotTupleLike;
1027 : R(R), Args(Args) {}
1029 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1032 } Diagnoser(R, Args);
1048 return IsTupleLike::TupleLike;
1063 S, R, Loc,
"tuple_element", Args,
1064 diag::err_decomp_decl_std_tuple_element_not_specialized))
1070 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1081 struct BindingDiagnosticTrap {
1087 : S(S), Trap(S.
Diags), BD(BD) {}
1088 ~BindingDiagnosticTrap() {
1098 const llvm::APSInt &TupleSize) {
1099 if ((int64_t)Bindings.size() != TupleSize) {
1100 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1101 << DecompType << (
unsigned)Bindings.size() << TupleSize.toString(10)
1102 << (TupleSize < Bindings.size());
1106 if (Bindings.empty())
1115 bool UseMemberGet =
false;
1119 if (MemberGet.isAmbiguous())
1121 UseMemberGet = !MemberGet.empty();
1126 for (
auto *B : Bindings) {
1127 BindingDiagnosticTrap Trap(S, B);
1149 MemberGet, &Args,
nullptr);
1183 B->getDeclName().getAsIdentifierInfo(), RefType,
1187 RefVD->setImplicit();
1189 RefVD->setInlineSpecified();
1190 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1195 E = Seq.
Perform(S, Entity, Kind, Init);
1201 RefVD->setInit(E.
get());
1202 RefVD->checkInitIsICE();
1210 B->setBinding(T, E.
get());
1234 ClassWithFields = RD;
1238 Paths.
setOrigin(const_cast<CXXRecordDecl*>(RD));
1246 for (
auto &
P : Paths) {
1250 BestPath->back().Base->getType())) {
1252 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1253 <<
false << RD << BestPath->back().Base->getType()
1254 <<
P.back().Base->getType();
1256 }
else if (
P.Access < BestPath->
Access) {
1262 QualType BaseType = BestPath->back().Base->getType();
1264 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1271 S.
Diag(Loc, diag::err_decomp_decl_non_public_base)
1273 for (
auto &BS : *BestPath) {
1274 if (BS.Base->getAccessSpecifier() !=
AS_public) {
1275 S.
Diag(BS.Base->getLocStart(), diag::note_access_constrained_by_path)
1277 << (BS.Base->getAccessSpecifierAsWritten() ==
AS_none);
1292 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1293 << (ClassWithFields == RD) << RD << ClassWithFields
1294 << Paths.
front().back().Base->getType();
1298 return ClassWithFields;
1311 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1312 unsigned NumFields =
1314 [](
FieldDecl *FD) {
return !FD->isUnnamedBitfield(); });
1315 assert(Bindings.size() != NumFields);
1316 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1317 << DecompType << (
unsigned)Bindings.size() << NumFields
1318 << (NumFields < Bindings.size());
1325 for (
auto *FD : RD->
fields()) {
1326 if (FD->isUnnamedBitfield())
1329 if (FD->isAnonymousStructOrUnion()) {
1332 S.
Diag(FD->getLocation(), diag::note_declared_at);
1337 if (I >= Bindings.size())
1338 return DiagnoseBadNumberOfBindings();
1339 auto *B = Bindings[I++];
1343 S.
Diag(Loc, diag::err_decomp_decl_non_public_member) << FD << DecompType;
1346 bool Implicit =
true;
1347 for (
const auto *D : RD->
decls()) {
1350 if (isa<AccessSpecDecl>(D)) {
1356 S.
Diag(FD->getLocation(), diag::note_access_natural)
1382 if (FD->isMutable())
1387 if (I != Bindings.size())
1388 return DiagnoseBadNumberOfBindings();
1430 llvm::APSInt TupleSize(32);
1436 case IsTupleLike::TupleLike:
1441 case IsTupleLike::NotTupleLike:
1450 << DD << !RD << DecompType;
1469 if (!getLangOpts().CXXExceptions)
1473 "Should only be called if types are otherwise the same.");
1484 NewType =
P->getPointeeType();
1497 if (CheckEquivalentExceptionSpec(
1512 for (p = 0; p < NumParams; ++p) {
1524 unsigned LastMissingDefaultArg = 0;
1525 for (; p < NumParams; ++p) {
1532 diag::err_param_default_argument_missing_name)
1536 diag::err_param_default_argument_missing);
1538 LastMissingDefaultArg = p;
1542 if (LastMissingDefaultArg > 0) {
1547 for (p = 0; p <= LastMissingDefaultArg; ++p) {
1561 unsigned ArgIndex = 0;
1565 i != e; ++i, ++ArgIndex) {
1568 if (!(*i)->isDependentType() &&
1570 diag::err_constexpr_non_literal_param,
1572 isa<CXXConstructorDecl>(FD)))
1588 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1608 << isa<CXXConstructorDecl>(NewFD)
1610 for (
const auto &I : RD->
vbases())
1611 Diag(I.getLocStart(),
1612 diag::note_constexpr_virtual_base_here) << I.getSourceRange();
1617 if (!isa<CXXConstructorDecl>(NewFD)) {
1630 while (!WrittenVirtual->isVirtualAsWritten())
1632 if (WrittenVirtual != Method)
1633 Diag(WrittenVirtual->getLocation(),
1634 diag::note_overridden_virtual_function);
1642 diag::err_constexpr_non_literal_return))
1663 for (
const auto *DclIt : DS->
decls()) {
1664 switch (DclIt->getKind()) {
1665 case Decl::StaticAssert:
1667 case Decl::UsingShadow:
1668 case Decl::UsingDirective:
1669 case Decl::UnresolvedUsingTypename:
1670 case Decl::UnresolvedUsingValue:
1677 case Decl::TypeAlias: {
1680 const auto *TN = cast<TypedefNameDecl>(DclIt);
1681 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1683 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1686 << isa<CXXConstructorDecl>(Dcl);
1693 case Decl::CXXRecord:
1695 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition())
1698 ? diag::warn_cxx11_compat_constexpr_type_definition
1699 : diag::ext_constexpr_type_definition)
1700 << isa<CXXConstructorDecl>(Dcl);
1703 case Decl::EnumConstant:
1704 case Decl::IndirectField:
1711 case Decl::Decomposition: {
1715 const auto *VD = cast<VarDecl>(DclIt);
1716 if (VD->isThisDeclarationADefinition()) {
1717 if (VD->isStaticLocal()) {
1718 SemaRef.
Diag(VD->getLocation(),
1719 diag::err_constexpr_local_var_static)
1720 << isa<CXXConstructorDecl>(Dcl)
1724 if (!VD->getType()->isDependentType() &&
1726 VD->getLocation(), VD->getType(),
1727 diag::err_constexpr_local_var_non_literal_type,
1728 isa<CXXConstructorDecl>(Dcl)))
1730 if (!VD->getType()->isDependentType() &&
1731 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1732 SemaRef.
Diag(VD->getLocation(),
1733 diag::err_constexpr_local_var_no_init)
1734 << isa<CXXConstructorDecl>(Dcl);
1738 SemaRef.
Diag(VD->getLocation(),
1740 ? diag::warn_cxx11_compat_constexpr_local_var
1741 : diag::ext_constexpr_local_var)
1742 << isa<CXXConstructorDecl>(Dcl);
1746 case Decl::NamespaceAlias:
1747 case Decl::Function:
1755 SemaRef.
Diag(DS->
getLocStart(), diag::err_constexpr_body_invalid_stmt)
1756 << isa<CXXConstructorDecl>(Dcl);
1775 llvm::SmallSet<Decl*, 16> &
Inits,
1792 if (!Inits.count(Field)) {
1794 SemaRef.
Diag(Dcl->
getLocation(), diag::err_constexpr_ctor_missing_init);
1797 SemaRef.
Diag(Field->
getLocation(), diag::note_constexpr_ctor_missing_init);
1800 for (
auto *I : RD->
fields())
1803 if (!RD->
isUnion() || Inits.count(I))
1816 case Stmt::NullStmtClass:
1820 case Stmt::DeclStmtClass:
1830 case Stmt::ReturnStmtClass:
1832 if (isa<CXXConstructorDecl>(Dcl)) {
1842 case Stmt::CompoundStmtClass: {
1848 for (
auto *BodyIt : CompStmt->
body()) {
1856 case Stmt::AttributedStmtClass:
1861 case Stmt::IfStmtClass: {
1866 IfStmt *If = cast<IfStmt>(S);
1877 case Stmt::WhileStmtClass:
1878 case Stmt::DoStmtClass:
1879 case Stmt::ForStmtClass:
1880 case Stmt::CXXForRangeStmtClass:
1881 case Stmt::ContinueStmtClass:
1895 case Stmt::SwitchStmtClass:
1896 case Stmt::CaseStmtClass:
1897 case Stmt::DefaultStmtClass:
1898 case Stmt::BreakStmtClass:
1921 << isa<CXXConstructorDecl>(Dcl);
1930 if (isa<CXXTryStmt>(Body)) {
1941 << isa<CXXConstructorDecl>(Dcl);
1951 for (
auto *BodyIt : CompBody->
body()) {
1956 if (Cxx1yLoc.isValid())
1958 getLangOpts().CPlusPlus14
1959 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
1960 : diag::ext_constexpr_body_invalid_stmt)
1961 << isa<CXXConstructorDecl>(Dcl);
1964 = dyn_cast<CXXConstructorDecl>(Dcl)) {
1973 if (Constructor->getNumCtorInitializers() == 0 &&
1978 }
else if (!Constructor->isDependentContext() &&
1979 !Constructor->isDelegatingConstructor()) {
1980 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
1984 bool AnyAnonStructUnionMembers =
false;
1985 unsigned Fields = 0;
1987 E = RD->
field_end(); I != E; ++I, ++Fields) {
1988 if (I->isAnonymousStructOrUnion()) {
1989 AnyAnonStructUnionMembers =
true;
1997 if (AnyAnonStructUnionMembers ||
1998 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
2002 llvm::SmallSet<Decl*, 16>
Inits;
2003 for (
const auto *I: Constructor->inits()) {
2007 Inits.insert(
ID->chain_begin(),
ID->chain_end());
2010 bool Diagnosed =
false;
2011 for (
auto *I : RD->
fields())
2018 if (ReturnStmts.empty()) {
2023 bool OK = getLangOpts().CPlusPlus14 &&
2027 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2028 : diag::err_constexpr_body_no_return);
2031 }
else if (ReturnStmts.size() > 1) {
2032 Diag(ReturnStmts.back(),
2033 getLangOpts().CPlusPlus14
2034 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2035 : diag::ext_constexpr_body_multiple_return);
2036 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2037 Diag(ReturnStmts[I], diag::note_constexpr_body_previous_return);
2053 Diag(Dcl->
getLocation(), diag::ext_constexpr_function_never_constant_expr)
2054 << isa<CXXConstructorDecl>(Dcl);
2055 for (
size_t I = 0, N = Diags.size(); I != N; ++I)
2056 Diag(Diags[I].first, Diags[I].second);
2070 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2075 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2077 CurDecl = dyn_cast_or_null<CXXRecordDecl>(CurContext);
2079 if (CurDecl && CurDecl->getIdentifier())
2080 return &II == CurDecl->getIdentifier();
2088 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2090 if (!getLangOpts().SpellChecking)
2096 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2098 CurDecl = dyn_cast_or_null<CXXRecordDecl>(CurContext);
2100 if (CurDecl && CurDecl->getIdentifier() && II != CurDecl->getIdentifier() &&
2101 3 * II->
getName().edit_distance(CurDecl->getIdentifier()->getName())
2103 II = CurDecl->getIdentifier();
2118 for (
const auto &I : Current->
bases()) {
2130 Queue.push_back(Base);
2136 Current = Queue.pop_back_val();
2164 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2177 ((BaseDecl = BaseDecl->getDefinition()) &&
2179 Diag(BaseLoc, diag::err_circular_inheritance)
2183 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
2192 Access, TInfo, EllipsisLoc);
2197 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2204 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2211 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2213 propagateDLLAttrToBaseClassTemplate(Class, ClassAttr, BaseTemplate,
2222 if (RequireCompleteType(BaseLoc, BaseType,
2223 diag::err_incomplete_base_class, SpecifierRange)) {
2230 assert(BaseDecl &&
"Record type has no declaration");
2232 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2234 assert(CXXBaseDecl &&
"Base type is not a C++ type");
2243 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2251 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
2252 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2254 << FA->isSpelledAsSealed();
2266 Access, TInfo, EllipsisLoc);
2283 AdjustDeclIfTemplate(classdecl);
2293 if (!Attributes.
empty()) {
2296 if (
Attr->isInvalid() ||
2301 ? diag::warn_unknown_attribute_ignored
2302 : diag::err_base_specifier_attribute)
2308 GetTypeFromParser(basetype, &TInfo);
2311 DiagnoseUnexpandedParameterPack(SpecifierRange.
getBegin(), TInfo,
2316 Virtual, Access, TInfo,
2337 auto Decl = Rec->getAsCXXRecordDecl();
2340 for (
const auto &BaseSpec : Decl->bases()) {
2342 .getUnqualifiedType();
2343 if (Set.insert(Base).second)
2361 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2365 IndirectBaseSet IndirectBaseTypes;
2368 unsigned NumGoodBases = 0;
2369 bool Invalid =
false;
2370 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2380 Diag(Bases[idx]->getLocStart(),
2381 diag::err_duplicate_base_class)
2383 << Bases[idx]->getSourceRange();
2392 KnownBase = Bases[idx];
2393 Bases[NumGoodBases++] = Bases[idx];
2396 if (Bases.size() > 1)
2400 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
2412 Class->
addAttr(WeakAttr::CreateImplicit(Context));
2418 Class->
setBases(Bases.data(), NumGoodBases);
2420 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2422 QualType BaseType = Bases[idx]->getType();
2426 if (IndirectBaseTypes.count(CanonicalBase)) {
2430 = Class->
isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
2435 Diag(Bases[idx]->getLocStart (), diag::warn_inaccessible_base_class)
2436 << BaseType << getAmbiguousPathsDisplayString(Paths)
2437 << Bases[idx]->getSourceRange();
2439 assert(Bases[idx]->isVirtual());
2455 if (!ClassDecl || Bases.empty())
2458 AdjustDeclIfTemplate(ClassDecl);
2459 AttachBaseSpecifiers(cast<CXXRecordDecl>(ClassDecl), Bases);
2483 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2504 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2516 for (
unsigned I = Path.size(); I != 0; --I) {
2517 if (Path[I - 1].
Base->isVirtual()) {
2524 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
2525 BasePathArray.push_back(const_cast<CXXBaseSpecifier*>(Path[I].Base));
2531 assert(BasePathArray.empty() &&
"Base path array must be empty!");
2549 unsigned InaccessibleBaseID,
2550 unsigned AmbigiousBaseConvID,
2554 bool IgnoreAccess) {
2561 bool DerivationOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2562 if (!DerivationOkay)
2567 Path = &Paths.
front();
2572 if (!Path && getLangOpts().MSVCCompat) {
2574 if (PossiblePath.size() == 1) {
2575 Path = &PossiblePath;
2576 if (AmbigiousBaseConvID)
2577 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
2578 << Base << Derived << Range;
2585 if (!IgnoreAccess) {
2588 CheckBaseClassAccess(Loc, Base, Derived, *Path, InaccessibleBaseID)) {
2604 if (AmbigiousBaseConvID) {
2613 bool StillOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2614 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
2621 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
2623 Diag(Loc, AmbigiousBaseConvID)
2624 << Derived << Base << PathDisplayStr << Range << Name;
2633 bool IgnoreAccess) {
2634 return CheckDerivedToBaseConversion(
2635 Derived, Base, diag::err_upcast_to_inaccessible_base,
2636 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
2637 BasePath, IgnoreAccess);
2654 std::string PathDisplayStr;
2655 std::set<unsigned> DisplayedPaths;
2657 Path != Paths.
end(); ++Path) {
2658 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
2661 PathDisplayStr +=
"\n ";
2663 for (CXXBasePath::const_iterator Element = Path->begin();
2664 Element != Path->end(); ++Element)
2665 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
2669 return PathDisplayStr;
2681 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
2684 CurContext->addHiddenDecl(ASDecl);
2685 return ProcessAccessDeclAttributeList(ASDecl, Attrs);
2709 FindHiddenVirtualMethods(MD, OverloadedMethods);
2711 if (!OverloadedMethods.empty()) {
2712 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2713 Diag(OA->getLocation(),
2714 diag::override_keyword_hides_virtual_member_function)
2715 <<
"override" << (OverloadedMethods.size() > 1);
2716 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2717 Diag(FA->getLocation(),
2718 diag::override_keyword_hides_virtual_member_function)
2719 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2720 << (OverloadedMethods.size() > 1);
2722 NoteHiddenVirtualMethods(MD, OverloadedMethods);
2731 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2732 Diag(OA->getLocation(),
2733 diag::override_keyword_only_allowed_on_virtual_member_functions)
2737 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2738 Diag(FA->getLocation(),
2739 diag::override_keyword_only_allowed_on_virtual_member_functions)
2740 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2752 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
2753 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
2766 if (getSourceManager().isMacroArgExpansion(Loc))
2767 SpellingLoc = getSourceManager().getImmediateExpansionRange(Loc).first;
2768 SpellingLoc = getSourceManager().getSpellingLoc(SpellingLoc);
2769 if (SpellingLoc.
isValid() && getSourceManager().isInSystemHeader(SpellingLoc))
2773 unsigned DiagID = isa<CXXDestructorDecl>(MD)
2774 ? diag::warn_destructor_marked_not_override_overriding
2775 : diag::warn_function_marked_not_override_overriding;
2787 FinalAttr *FA = Old->
getAttr<FinalAttr>();
2793 << FA->isSpelledAsSealed();
2802 return !RD->isCompleteDefinition() ||
2803 !RD->hasTrivialDefaultConstructor() ||
2804 !RD->hasTrivialDestructor();
2810 if (it->isDeclspecPropertyAttribute())
2819 if (Diags.isIgnored(diag::warn_shadow_field, Loc))
2823 std::map<CXXRecordDecl*, NamedDecl*> Bases;
2828 if (Bases.find(
Base) != Bases.end())
2830 for (
const auto Field :
Base->lookup(FieldName)) {
2831 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
2833 assert(Field->getAccess() !=
AS_none);
2834 assert(Bases.find(
Base) == Bases.end());
2835 Bases[
Base] = Field;
2847 for (
const auto &
P : Paths) {
2848 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
2849 auto It = Bases.find(
Base);
2851 if (It == Bases.end())
2853 auto BaseField = It->second;
2854 assert(BaseField->getAccess() !=
AS_private);
2857 Diag(Loc, diag::warn_shadow_field)
2859 Diag(BaseField->getLocation(), diag::note_shadow_field);
2884 Expr *BitWidth =
static_cast<Expr*
>(BW);
2886 assert(isa<CXXRecordDecl>(CurContext));
2893 if (cast<CXXRecordDecl>(CurContext)->isInterface()) {
2897 unsigned InvalidDecl;
2898 bool ShowDeclName =
true;
2911 ShowDeclName =
false;
2916 ShowDeclName =
false;
2931 Diag(Loc, diag::err_invalid_member_in_interface)
2932 << (InvalidDecl-1) << Name;
2934 Diag(Loc, diag::err_invalid_member_in_interface)
2935 << (InvalidDecl-1) <<
"";
2961 diag::err_storageclass_invalid_for_member);
2981 const char *PrevSpec;
2986 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
2990 const char *PrevSpec;
2996 "This is the only DeclSpec that should fail to be applied");
3000 isInstField =
false;
3011 Diag(Loc, diag::err_bad_variable_name)
3020 if (TemplateParameterLists.size()) {
3022 if (TemplateParams->
size()) {
3031 diag::err_template_member_noparams)
3046 if (
DeclContext *DC = computeDeclContext(SS,
false))
3055 if (MSPropertyAttr) {
3056 Member = HandleMSProperty(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3057 BitWidth, InitStyle, AS, MSPropertyAttr);
3060 isInstField =
false;
3062 Member = HandleField(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3063 BitWidth, InitStyle, AS);
3068 CheckShadowInheritedFields(Loc, Name, cast<CXXRecordDecl>(CurContext));
3070 Member = HandleDeclarator(S, D, TemplateParameterLists);
3078 }
else if (isa<VarDecl>(Member) || isa<VarTemplateDecl>(Member)) {
3081 Diag(Loc, diag::err_static_not_bitfield)
3083 }
else if (isa<TypedefDecl>(Member)) {
3085 Diag(Loc, diag::err_typedef_not_bitfield)
3090 Diag(Loc, diag::err_not_integral_type_bitfield)
3091 << Name << cast<ValueDecl>(Member)->getType()
3104 FunTmpl->getTemplatedDecl()->setAccess(AS);
3105 else if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(Member))
3106 VarTmpl->getTemplatedDecl()->setAccess(AS);
3117 if (
CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(Member))
3121 CheckOverrideControl(Member);
3123 assert((Name || isInstField) &&
"No identifier for non-field ?");
3126 FieldDecl *FD = cast<FieldDecl>(Member);
3127 FieldCollector->Add(FD);
3129 if (!Diags.isIgnored(diag::warn_unused_private_field, FD->
getLocation())) {
3137 UnusedPrivateFields.insert(FD);
3145 class UninitializedFieldVisitor
3150 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3153 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3168 UninitializedFieldVisitor(
Sema &S,
3169 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3170 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3171 : Inherited(S.
Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3172 Constructor(
nullptr), InitList(
false), InitListFieldDecl(
nullptr) {}
3175 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3176 bool CheckReferenceOnly) {
3178 bool ReferenceField =
false;
3183 Fields.push_back(FD);
3185 ReferenceField =
true;
3191 if (CheckReferenceOnly && !ReferenceField)
3197 for (
auto I = Fields.rbegin() + 1, E = Fields.rend(); I != E; ++I) {
3198 UsedFieldIndex.push_back((*I)->getFieldIndex());
3201 for (
auto UsedIter = UsedFieldIndex.begin(),
3202 UsedEnd = UsedFieldIndex.end(),
3203 OrigIter = InitFieldIndex.begin(),
3204 OrigEnd = InitFieldIndex.end();
3205 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3206 if (*UsedIter < *OrigIter)
3208 if (*UsedIter > *OrigIter)
3215 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3230 if (isa<VarDecl>(SubME->getMemberDecl()))
3233 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3234 if (!FD->isAnonymousStructOrUnion())
3238 AllPODFields =
false;
3240 Base = SubME->getBase();
3246 if (AddressOf && AllPODFields)
3252 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3253 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
3256 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3266 if (!Decls.count(FoundVD))
3271 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3273 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3278 if (CheckReferenceOnly && !IsReference)
3282 unsigned diag = IsReference
3283 ? diag::warn_reference_field_is_uninit
3284 : diag::warn_field_is_uninit;
3288 diag::note_uninit_in_this_constructor)
3293 void HandleValue(
Expr *E,
bool AddressOf) {
3296 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3297 HandleMemberExpr(ME,
false ,
3303 Visit(CO->getCond());
3304 HandleValue(CO->getTrueExpr(), AddressOf);
3305 HandleValue(CO->getFalseExpr(), AddressOf);
3310 dyn_cast<BinaryConditionalOperator>(E)) {
3311 Visit(BCO->getCond());
3312 HandleValue(BCO->getFalseExpr(), AddressOf);
3317 HandleValue(OVE->getSourceExpr(), AddressOf);
3322 switch (BO->getOpcode()) {
3327 HandleValue(BO->getLHS(), AddressOf);
3328 Visit(BO->getRHS());
3331 Visit(BO->getLHS());
3332 HandleValue(BO->getRHS(), AddressOf);
3341 InitFieldIndex.push_back(0);
3342 for (
auto Child : ILE->
children()) {
3343 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3344 CheckInitListExpr(SubList);
3348 ++InitFieldIndex.back();
3350 InitFieldIndex.pop_back();
3359 DeclsToRemove.clear();
3361 Constructor = FieldConstructor;
3366 InitListFieldDecl = Field;
3367 InitFieldIndex.clear();
3368 CheckInitListExpr(ILE);
3382 HandleMemberExpr(ME,
true ,
false );
3391 Inherited::VisitImplicitCastExpr(E);
3397 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3401 if (ICE->getCastKind() == CK_NoOp)
3402 ArgExpr = ICE->getSubExpr();
3403 HandleValue(ArgExpr,
false );
3406 Inherited::VisitCXXConstructExpr(E);
3411 if (isa<MemberExpr>(Callee)) {
3412 HandleValue(Callee,
false );
3418 Inherited::VisitCXXMemberCallExpr(E);
3424 HandleValue(E->
getArg(0),
false);
3428 Inherited::VisitCallExpr(E);
3434 if (isa<UnresolvedLookupExpr>(Callee))
3435 return Inherited::VisitCXXOperatorCallExpr(E);
3439 HandleValue(Arg->IgnoreParenImpCasts(),
false );
3448 if (!FD->getType()->isReferenceType())
3449 DeclsToRemove.push_back(FD);
3452 HandleValue(E->
getLHS(),
false );
3457 Inherited::VisitBinaryOperator(E);
3467 HandleValue(ME->
getBase(),
true );
3472 Inherited::VisitUnaryOperator(E);
3482 static void DiagnoseUninitializedFields(
3499 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
3502 for (
auto *I : RD->
decls()) {
3503 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
3504 UninitializedFields.insert(FD);
3505 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
3506 UninitializedFields.insert(IFD->getAnonField());
3510 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
3511 for (
auto I : RD->
bases())
3512 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
3514 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3517 UninitializedFieldVisitor UninitializedChecker(SemaRef,
3518 UninitializedFields,
3519 UninitializedBaseClasses);
3521 for (
const auto *FieldInit : Constructor->
inits()) {
3522 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3525 Expr *InitExpr = FieldInit->getInit();
3530 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
3531 InitExpr =
Default->getExpr();
3535 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
3536 FieldInit->getAnyMember(),
3537 FieldInit->getBaseClass());
3539 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
3540 FieldInit->getAnyMember(),
3541 FieldInit->getBaseClass());
3553 PushFunctionScope();
3563 PopFunctionScopeInfo(
nullptr, D);
3567 "must set init style when field is created");
3576 if (DiagnoseUnexpandedParameterPack(InitExpr, UPPC_Initializer)) {
3589 Init = Seq.Perform(*
this, Entity, Kind, InitExpr);
3599 Init = ActOnFinishFullExpr(Init.
get(), InitLoc);
3605 InitExpr = Init.
get();
3619 DirectBaseSpec =
nullptr;
3620 for (
const auto &
Base : ClassDecl->
bases()) {
3624 DirectBaseSpec = &
Base;
3632 VirtualBaseSpec =
nullptr;
3633 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
3642 Path != Paths.
end(); ++Path) {
3643 if (Path->back().Base->isVirtual()) {
3644 VirtualBaseSpec = Path->back().Base;
3651 return DirectBaseSpec || VirtualBaseSpec;
3665 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
3666 DS, IdLoc, InitList,
3685 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
3686 DS, IdLoc, List, EllipsisLoc);
3695 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
3696 : ClassDecl(ClassDecl) {}
3698 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
3700 if (
FieldDecl *Member = dyn_cast<FieldDecl>(ND))
3702 return isa<TypeDecl>(ND);
3724 ExprResult Res = CorrectDelayedTyposInExpr(Init);
3732 AdjustDeclIfTemplate(ConstructorD);
3759 if (!Result.
empty()) {
3761 if ((Member = dyn_cast<FieldDecl>(Result.
front())) ||
3764 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
3768 return BuildMemberInitializer(Member, Init, IdLoc);
3776 if (TemplateTypeTy) {
3777 BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo);
3784 LookupResult R(*
this, MemberOrBase, IdLoc, LookupOrdinaryName);
3785 LookupParsedName(R, S, &SS);
3794 if (SS.
isSet() && isDependentScopeSpecifier(SS)) {
3795 bool NotUnknownSpecialization =
false;
3797 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
3798 NotUnknownSpecialization = !Record->hasAnyDependentBases();
3800 if (!NotUnknownSpecialization) {
3805 *MemberOrBase, IdLoc);
3826 (Corr = CorrectTypo(
3828 llvm::make_unique<MemInitializerValidatorCCC>(ClassDecl),
3829 CTK_ErrorRecovery, ClassDecl))) {
3835 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3836 << MemberOrBase <<
true);
3837 return BuildMemberInitializer(Member, Init, IdLoc);
3843 DirectBaseSpec, VirtualBaseSpec)) {
3848 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3849 << MemberOrBase <<
false,
3855 diag::note_base_class_specified_here)
3864 if (!TyD && BaseType.
isNull()) {
3865 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
3873 MarkAnyDeclReferenced(TyD->
getLocation(), TyD,
false);
3889 return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, EllipsisLoc);
3910 if (Op->getOpcode() != UO_AddrOf)
3913 Init = Op->getSubExpr();
3927 IsPointer ? diag::warn_init_ptr_member_to_parameter_addr
3928 : diag::warn_bind_ref_member_to_parameter)
3935 S.
Diag(Member->
getLocation(), diag::note_ref_or_ptr_member_declared_here)
3936 << (
unsigned)IsPointer;
3944 assert((DirectMember || IndirectMember) &&
3945 "Member must be a FieldDecl or IndirectFieldDecl");
3947 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
3954 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
3955 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
3956 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
3957 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
3968 DiscardCleanupsInEvaluationContext();
3970 bool InitList =
false;
3971 if (isa<InitListExpr>(Init)) {
3987 ExprResult MemberInit = InitSeq.Perform(*
this, MemberEntity, Kind, Args,
3997 MemberInit = ActOnFinishFullExpr(MemberInit.get(), InitRange.
getBegin());
3998 if (MemberInit.isInvalid())
4001 Init = MemberInit.get();
4019 if (!LangOpts.CPlusPlus11)
4020 return Diag(NameLoc, diag::err_delegating_ctor)
4022 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4024 bool InitList =
true;
4026 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4028 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4038 InitRange.getEnd());
4040 ExprResult DelegationInit = InitSeq.Perform(*
this, DelegationEntity, Kind,
4045 assert(cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor() &&
4046 "Delegating constructor with no target?");
4051 DelegationInit = ActOnFinishFullExpr(DelegationInit.get(),
4052 InitRange.getBegin());
4053 if (DelegationInit.isInvalid())
4063 if (CurContext->isDependentContext())
4064 DelegationInit = Init;
4067 DelegationInit.getAs<
Expr>(),
4068 InitRange.getEnd());
4079 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4094 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4101 if (DiagnoseUnexpandedParameterPack(BaseLoc, BaseTInfo, UPPC_Initializer))
4104 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4114 return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
4123 if (!DirectBaseSpec && !VirtualBaseSpec) {
4132 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4139 DiscardCleanupsInEvaluationContext();
4144 InitRange.
getEnd(), EllipsisLoc);
4151 if (DirectBaseSpec && VirtualBaseSpec)
4152 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4157 BaseSpec = VirtualBaseSpec;
4160 bool InitList =
true;
4162 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4164 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4174 ExprResult BaseInit = InitSeq.Perform(*
this, BaseEntity, Kind, Args,
nullptr);
4181 BaseInit = ActOnFinishFullExpr(BaseInit.
get(), InitRange.
getBegin());
4192 if (CurContext->isDependentContext())
4199 InitRange.
getEnd(), EllipsisLoc);
4209 TargetType, ExprLoc);
4229 bool IsInheritedVirtualBase,
4233 IsInheritedVirtualBase);
4237 switch (ImplicitInitKind) {
4243 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
None);
4249 bool Moving = ImplicitInitKind ==
IIK_Move;
4271 BasePath.push_back(BaseSpec);
4273 CK_UncheckedDerivedToBase,
4281 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4304 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
4319 bool Moving = ImplicitInitKind ==
IIK_Move;
4327 Expr *MemberExprBase =
4342 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
4344 MemberLookup.resolveKind();
4378 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
4393 "Unhandled implicit init kind!");
4409 InitSeq.
Perform(SemaRef, InitEntity, InitKind,
None);
4432 diag::err_uninitialized_member_in_ctor)
4442 diag::err_uninitialized_member_in_ctor)
4463 CXXMemberInit =
nullptr;
4468 struct BaseAndFieldInfo {
4471 bool AnyErrorsInInits;
4473 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
4475 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
4478 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
4490 bool isImplicitCopyOrMove()
const {
4501 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
4505 AllToInit.push_back(Init);
4514 bool isInactiveUnionMember(
FieldDecl *Field) {
4524 if (isImplicitCopyOrMove())
4542 bool isWithinInactiveUnionMember(
FieldDecl *Field,
4545 return isInactiveUnionMember(Field);
4547 for (
auto *
C : Indirect->
chain()) {
4549 if (Field && isInactiveUnionMember(Field))
4564 if (!ArrayT->getSize())
4567 T = ArrayT->getElementType();
4582 return Info.addFieldInitializer(Init);
4596 if (Info.isWithinInactiveUnionMember(Field, Indirect))
4613 return Info.addFieldInitializer(Init);
4623 if (Info.AnyErrorsInInits)
4634 return Info.addFieldInitializer(Init);
4652 DelegatingCtorDecls.push_back(Constructor);
4654 DiagnoseUninitializedFields(*
this, Constructor);
4664 if (!Initializers.empty()) {
4668 memcpy(baseOrMemberInitializers, Initializers.data(),
4680 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
4688 bool HadError =
false;
4690 for (
unsigned i = 0; i < Initializers.size(); i++) {
4699 for (
auto *
C : F->chain()) {
4702 Info.ActiveUnionMember.insert(std::make_pair(
4706 if (FD->getParent()->isUnion())
4707 Info.ActiveUnionMember.insert(std::make_pair(
4708 FD->getParent()->getCanonicalDecl(), FD->getCanonicalDecl()));
4714 llvm::SmallPtrSet<CXXBaseSpecifier *, 16> DirectVBases;
4715 for (
auto &I : ClassDecl->
bases()) {
4717 DirectVBases.insert(&I);
4721 for (
auto &VBase : ClassDecl->
vbases()) {
4723 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
4731 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
4732 << VBase.getType() << ClassDecl;
4733 DiagnoseAbstractType(ClassDecl);
4736 Info.AllToInit.push_back(
Value);
4737 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
4742 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
4745 &VBase, IsInheritedVirtualBase,
4751 Info.AllToInit.push_back(CXXBaseInit);
4758 if (
Base.isVirtual())
4762 = Info.AllBaseFields.lookup(
Base.getType()->getAs<
RecordType>())) {
4763 Info.AllToInit.push_back(
Value);
4764 }
else if (!AnyErrors) {
4773 Info.AllToInit.push_back(CXXBaseInit);
4778 for (
auto *Mem : ClassDecl->
decls()) {
4779 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
4784 if (F->isUnnamedBitfield())
4790 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
4799 if (Info.isImplicitCopyOrMove())
4802 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
4803 if (F->getType()->isIncompleteArrayType()) {
4805 "Incomplete array type is not valid");
4817 unsigned NumInitializers = Info.AllToInit.size();
4818 if (NumInitializers > 0) {
4822 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
4828 MarkBaseAndMemberDestructorsReferenced(Constructor->
getLocation(),
4839 for (
auto *Field : RD->
fields())
4867 bool ShouldCheckOrder =
false;
4868 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4870 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
4872 ShouldCheckOrder =
true;
4876 if (!ShouldCheckOrder)
4887 for (
const auto &VBase : ClassDecl->
vbases())
4891 for (
const auto &
Base : ClassDecl->
bases()) {
4892 if (
Base.isVirtual())
4898 for (
auto *Field : ClassDecl->
fields()) {
4899 if (Field->isUnnamedBitfield())
4905 unsigned NumIdealInits = IdealInitKeys.size();
4906 unsigned IdealIndex = 0;
4909 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4915 for (; IdealIndex != NumIdealInits; ++IdealIndex)
4916 if (InitKey == IdealInitKeys[IdealIndex])
4922 if (IdealIndex == NumIdealInits && PrevInit) {
4925 diag::warn_initializer_out_of_order);
4938 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
4939 if (InitKey == IdealInitKeys[IdealIndex])
4942 assert(IdealIndex < NumIdealInits &&
4943 "initializer not found in initializer list");
4951 bool CheckRedundantInit(
Sema &S,
4961 diag::err_multiple_mem_initialization)
4962 << Field->getDeclName()
4966 assert(BaseClass &&
"neither field nor base");
4968 diag::err_multiple_base_initialization)
4978 typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
4979 typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
4981 bool CheckRedundantUnionInit(
Sema &S,
4983 RedundantUnionMap &Unions) {
4990 UnionEntry &En = Unions[
Parent];
4991 if (En.first && En.first != Child) {
4993 diag::err_multiple_mem_union_initialization)
4996 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
4997 << 0 << En.second->getSourceRange();
5021 if (!ConstructorDecl)
5024 AdjustDeclIfTemplate(ConstructorDecl);
5030 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5037 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5040 RedundantUnionMap MemberUnions;
5042 bool HadError =
false;
5043 for (
unsigned i = 0; i < MemInits.size(); i++) {
5051 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
5052 CheckRedundantUnionInit(*
this, Init, MemberUnions))
5056 if (CheckRedundantInit(*
this, Init, Members[Key]))
5061 if (MemInits.size() != 1) {
5063 diag::err_delegating_initializer_alone)
5064 << Init->
getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5067 SetDelegatingInitializer(Constructor, MemInits[i]);
5078 SetCtorInitializers(Constructor, AnyErrors, MemInits);
5080 DiagnoseUninitializedFields(*
this, Constructor);
5097 for (
auto *Field : ClassDecl->
fields()) {
5098 if (Field->isInvalidDecl())
5121 assert(Dtor &&
"No dtor found for FieldClassDecl!");
5122 CheckDestructorAccess(Field->getLocation(), Dtor,
5123 PDiag(diag::err_access_dtor_field)
5124 << Field->getDeclName()
5127 MarkFunctionReferenced(Location, Dtor);
5128 DiagnoseUseOfDecl(Dtor, Location);
5133 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5135 llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
5138 for (
const auto &
Base : ClassDecl->
bases()) {
5143 if (
Base.isVirtual()) {
5144 if (!VisitVirtualBases)
5146 DirectVirtualBases.insert(RT);
5157 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5160 CheckDestructorAccess(
Base.getLocStart(), Dtor,
5161 PDiag(diag::err_access_dtor_base)
5163 <<
Base.getSourceRange(),
5166 MarkFunctionReferenced(Location, Dtor);
5167 DiagnoseUseOfDecl(Dtor, Location);
5170 if (!VisitVirtualBases)
5174 for (
const auto &VBase : ClassDecl->
vbases()) {
5179 if (DirectVirtualBases.count(RT))
5190 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5191 if (CheckDestructorAccess(
5193 PDiag(diag::err_access_dtor_vbase)
5197 CheckDerivedToBaseConversion(
5199 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5203 MarkFunctionReferenced(Location, Dtor);
5204 DiagnoseUseOfDecl(Dtor, Location);
5213 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5214 SetCtorInitializers(Constructor,
false);
5215 DiagnoseUninitializedFields(*
this, Constructor);
5242 if (!isAbstractType(Loc, T))
5254 if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
5260 if (Diags.isLastDiagnosticIgnored())
5268 llvm::SmallPtrSet<const CXXMethodDecl *, 8> SeenPureMethods;
5270 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5271 MEnd = FinalOverriders.end();
5275 SOEnd = M->second.end();
5276 SO != SOEnd; ++SO) {
5283 if (SO->second.size() != 1)
5286 if (!SO->second.front().Method->isPure())
5289 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5292 Diag(SO->second.front().Method->getLocation(),
5293 diag::note_pure_virtual_function)
5294 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5298 if (!PureVirtualClassDiagSet)
5300 PureVirtualClassDiagSet->insert(RD);
5304 struct AbstractUsageInfo {
5311 : S(S), Record(Record),
5316 void DiagnoseAbstractType() {
5317 if (Invalid)
return;
5325 struct CheckAbstractUsage {
5326 AbstractUsageInfo &Info;
5329 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
5330 : Info(Info), Ctx(Ctx) {}
5334 #define ABSTRACT_TYPELOC(CLASS, PARENT) 5335 #define TYPELOC(CLASS, PARENT) \ 5336 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break; 5337 #include "clang/AST/TypeLocNodes.def" 5343 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
5358 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
5368 #define CheckPolymorphic(Type) \ 5369 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \ 5370 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \ 5385 return Visit(Next, Sel);
5395 T = Info.S.Context.getBaseElementType(T);
5398 if (CT != Info.AbstractType)
return;
5402 Info.S.Diag(Ctx->
getLocation(), diag::err_array_of_abstract_type)
5405 Info.S.Diag(Ctx->
getLocation(), diag::err_abstract_type_in_decl)
5408 Info.DiagnoseAbstractType();
5414 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
5437 for (
auto *D : RD->
decls()) {
5438 if (D->isImplicit())
continue;
5441 if (isa<CXXMethodDecl>(D)) {
5443 }
else if (isa<FunctionTemplateDecl>(D)) {
5444 FunctionDecl *FD = cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
5448 }
else if (isa<FieldDecl>(D)) {
5452 }
else if (isa<VarDecl>(D)) {
5453 VarDecl *VD = cast<VarDecl>(D);
5458 }
else if (isa<CXXRecordDecl>(D)) {
5460 }
else if (isa<ClassTemplateDecl>(D)) {
5462 cast<ClassTemplateDecl>(D)->getTemplatedDecl());
5472 assert(ClassAttr->
getKind() == attr::DLLExport);
5481 for (Decl *Member : Class->
decls()) {
5486 if (Member->getAttr<DLLExportAttr>()) {
5487 if (MD->isUserProvided()) {
5498 }
else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
5499 MD->isCopyAssignmentOperator() ||
5500 MD->isMoveAssignmentOperator()) {
5529 for (Decl *Member : Class->
decls()) {
5532 if (!CD || !CD->isDefaultConstructor())
5534 auto *
Attr = CD->getAttr<DLLExportAttr>();
5547 if (LastExportedDefaultCtor) {
5549 diag::err_attribute_dll_ambiguous_default_ctor)
5551 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
5552 << CD->getDeclName();
5555 LastExportedDefaultCtor = CD;
5565 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
5566 if (
Attr *TemplateAttr =
5567 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
5568 auto *A = cast<InheritableAttr>(TemplateAttr->clone(getASTContext()));
5569 A->setInherited(
true);
5580 << Class << ClassAttr;
5587 for (Decl *Member : Class->
decls()) {
5588 if (!isa<VarDecl>(Member) && !isa<CXXMethodDecl>(Member))
5591 if (!MemberAttr || MemberAttr->
isInherited() || Member->isInvalidDecl())
5595 diag::err_attribute_dll_member_of_dll_class)
5596 << MemberAttr << ClassAttr;
5598 Member->setInvalidDecl();
5607 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
5619 ForceDeclarationOfImplicitMembers(Class);
5624 for (Decl *Member : Class->
decls()) {
5634 if (MD->isDeleted())
5637 if (MD->isInlined()) {
5647 if ((MD->isMoveAssignmentOperator() ||
5648 (Ctor && Ctor->isMoveConstructor())) &&
5655 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->isTrivial())
5660 if (!cast<NamedDecl>(Member)->isExternallyVisible())
5665 cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5666 NewAttr->setInherited(
true);
5672 DelayedDllExportClasses.push_back(Class);
5693 auto *NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5694 NewAttr->setInherited(
true);
5695 BaseTemplateSpec->
addAttr(NewAttr);
5701 checkClassLevelDLLAttribute(BaseTemplateSpec);
5716 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
5721 diag::note_template_class_explicit_specialization_was_here)
5722 << BaseTemplateSpec;
5725 diag::note_template_class_instantiation_was_here)
5726 << BaseTemplateSpec;
5735 cast<CXXConstructorDecl>(MD));
5753 llvm_unreachable(
"Invalid special member.");
5767 bool HasNonDeletedCopyOrMove =
false;
5773 HasNonDeletedCopyOrMove =
true;
5780 HasNonDeletedCopyOrMove =
true;
5788 if (MD->isDeleted())
5792 if (CD && CD->isCopyOrMoveConstructor())
5793 HasNonDeletedCopyOrMove =
true;
5794 else if (!isa<CXXDestructorDecl>(MD))
5797 if (!MD->isTrivial())
5801 return HasNonDeletedCopyOrMove;
5812 AbstractUsageInfo Info(*
this, Record);
5822 bool Complained =
false;
5823 for (
const auto *F : Record->
fields()) {
5824 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
5827 if (F->getType()->isReferenceType() ||
5828 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
5835 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
5836 << F->getType()->isReferenceType()
5837 << F->getDeclName();
5856 isa<IndirectFieldDecl>(D)) {
5868 !Record->
hasAttr<FinalAttr>())
5870 diag::warn_non_virtual_dtor) << Context.
getRecordType(Record);
5874 if (FinalAttr *FA = Record->
getAttr<FinalAttr>()) {
5876 << FA->isSpelledAsSealed();
5877 DiagnoseAbstractType(Record);
5881 bool HasMethodWithOverrideControl =
false,
5882 HasOverridingMethodWithoutOverrideControl =
false;
5884 for (
auto *M : Record->
methods()) {
5888 DiagnoseHiddenVirtualMethods(M);
5889 if (M->hasAttr<OverrideAttr>())
5890 HasMethodWithOverrideControl =
true;
5891 else if (M->size_overridden_methods() > 0)
5892 HasOverridingMethodWithoutOverrideControl =
true;
5894 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted())
5895 CheckExplicitlyDefaultedSpecialMember(M);
5900 if (!M->isImplicit() && !M->isUserProvided()) {
5901 if (CSM != CXXInvalid) {
5902 M->setTrivial(SpecialMemberIsTrivial(M, CSM));
5909 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
5910 M->hasAttr<DLLExportAttr>()) {
5913 (CSM == CXXDefaultConstructor || CSM == CXXCopyConstructor ||
5914 CSM == CXXDestructor))
5915 M->dropAttr<DLLExportAttr>();
5917 if (M->hasAttr<DLLExportAttr>()) {
5919 ActOnFinishInlineFunctionDef(M);
5925 if (HasMethodWithOverrideControl &&
5926 HasOverridingMethodWithoutOverrideControl) {
5929 for (
auto *M : Record->
methods())
5930 DiagnoseAbsenceOfOverrideControl(M);
5947 checkClassLevelDLLAttribute(Record);
5963 unsigned FieldQuals,
bool ConstRHS) {
5964 unsigned LHSQuals = 0;
5966 LHSQuals = FieldQuals;
5968 unsigned RHSQuals = FieldQuals;
5978 LHSQuals & Qualifiers::Const,
5979 LHSQuals & Qualifiers::Volatile);
5989 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
5995 : S(S), UseLoc(UseLoc) {
5996 bool DiagnosedMultipleConstructedBases =
false;
5998 UsingDecl *ConstructedBaseUsing =
nullptr;
6002 for (
auto *D : Shadow->
redecls()) {
6003 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
6004 auto *DNominatedBase = DShadow->getNominatedBaseClass();
6005 auto *DConstructedBase = DShadow->getConstructedBaseClass();
6007 InheritedFromBases.insert(
6008 std::make_pair(DNominatedBase->getCanonicalDecl(),
6009 DShadow->getNominatedBaseClassShadowDecl()));
6010 if (DShadow->constructsVirtualBase())
6011 InheritedFromBases.insert(
6012 std::make_pair(DConstructedBase->getCanonicalDecl(),
6013 DShadow->getConstructedBaseClassShadowDecl()));
6015 assert(DNominatedBase == DConstructedBase);
6020 if (!ConstructedBase) {
6021 ConstructedBase = DConstructedBase;
6022 ConstructedBaseUsing = D->getUsingDecl();
6023 }
else if (ConstructedBase != DConstructedBase &&
6025 if (!DiagnosedMultipleConstructedBases) {
6026 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
6029 diag::note_ambiguous_inherited_constructor_using)
6031 DiagnosedMultipleConstructedBases =
true;
6033 S.
Diag(D->getUsingDecl()->getLocation(),
6034 diag::note_ambiguous_inherited_constructor_using)
6035 << DConstructedBase;
6039 if (DiagnosedMultipleConstructedBases)
6046 std::pair<CXXConstructorDecl *, bool>
6049 if (It == InheritedFromBases.end())
6050 return std::make_pair(
nullptr,
false);
6054 return std::make_pair(
6056 It->second->constructsVirtualBase());
6059 return std::make_pair(Ctor,
false);
6073 if (InheritedCtor) {
6076 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
6078 return BaseCtor->isConstexpr();
6142 if (Ctor && ClassDecl->
isUnion())
6161 for (
const auto &B : ClassDecl->
bases()) {
6163 if (!BaseType)
continue;
6167 InheritedCtor, Inherited))
6178 for (
const auto *F : ClassDecl->
fields()) {
6179 if (F->isInvalidDecl())
6185 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
6188 ConstArg && !F->isMutable()))
6210 auto *CD = cast<CXXConstructorDecl>(MD);
6211 assert(CD->getInheritedConstructor() &&
6212 "only special members have implicit exception specs");
6214 S, Loc, CD->getInheritedConstructor().getShadowDecl());
6241 auto ESI = IES.getExceptionSpec();
6244 UpdateExceptionSpec(MD, ESI);
6260 "not an explicitly-defaulted special member");
6266 bool HadError =
false;
6275 unsigned ExpectedParams = 1;
6276 if (CSM == CXXDefaultConstructor || CSM == CXXDestructor)
6293 bool CanHaveConstParam =
false;
6294 if (CSM == CXXCopyConstructor)
6296 else if (CSM == CXXCopyAssignment)
6300 if (CSM == CXXCopyAssignment || CSM == CXXMoveAssignment) {
6305 if (!Context.
hasSameType(ReturnType, ExpectedReturnType)) {
6306 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
6307 << (CSM == CXXMoveAssignment) << ExpectedReturnType;
6314 << (CSM == CXXMoveAssignment) << getLangOpts().CPlusPlus14;
6321 bool HasConstParam =
false;
6329 diag::err_defaulted_special_member_volatile_param) << CSM;
6333 if (HasConstParam && !CanHaveConstParam) {
6334 if (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment) {
6336 diag::err_defaulted_special_member_copy_const_param)
6337 << (CSM == CXXCopyAssignment);
6341 diag::err_defaulted_special_member_move_const_param)
6342 << (CSM == CXXMoveAssignment);
6346 }
else if (ExpectedParams) {
6349 assert(CSM == CXXCopyAssignment &&
"unexpected non-ref argument");
6363 if ((getLangOpts().
CPlusPlus14 ? !isa<CXXDestructorDecl>(MD)
6364 : isa<CXXConstructorDecl>(MD)) &&
6367 Diag(MD->
getLocStart(), diag::err_incorrect_defaulted_constexpr) << CSM;
6384 DelayedDefaultedMemberExceptionSpecs.push_back(std::make_pair(MD, Type));
6386 CheckExplicitlyDefaultedMemberExceptionSpec(MD, Type);
6401 llvm::makeArrayRef(&ArgType,
6406 if (ShouldDeleteSpecialMember(MD, CSM)) {
6413 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
6414 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
6445 CheckEquivalentExceptionSpec(
6446 PDiag(diag::err_incorrect_defaulted_exception_spec)
6447 << getSpecialMember(MD), PDiag(),
6453 decltype(DelayedExceptionSpecChecks) Checks;
6454 decltype(DelayedDefaultedMemberExceptionSpecs) Specs;
6456 std::swap(Checks, DelayedExceptionSpecChecks);
6457 std::swap(Specs, DelayedDefaultedMemberExceptionSpecs);
6461 for (
auto &Check : Checks)
6462 CheckOverridingFunctionExceptionSpec(Check.first, Check.second);
6466 for (
auto &Spec : Specs)
6467 CheckExplicitlyDefaultedMemberExceptionSpec(Spec.first, Spec.second);
6473 template<
typename Derived>
6474 struct SpecialMemberVisitor {
6481 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
6485 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
6490 IsConstructor =
true;
6494 IsAssignment =
true;
6499 llvm_unreachable(
"invalid special member kind");
6505 ConstArg = RT->getPointeeType().isConstQualified();
6509 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
6512 bool isMove()
const {
6518 unsigned Quals,
bool IsMutable) {
6520 ConstArg && !IsMutable);
6530 cast<CXXConstructorDecl>(MD)->getInheritedConstructor().getConstructor();
6537 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
6544 return B->getBaseTypeLoc();
6546 return Subobj.get<
FieldDecl*>()->getLocation();
6551 VisitNonVirtualBases,
6556 VisitPotentiallyConstructedBases,
6562 bool visit(BasesToVisit Bases) {
6565 if (Bases == VisitPotentiallyConstructedBases)
6566 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
6568 for (
auto &B : RD->
bases())
6569 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
6570 getDerived().visitBase(&B))
6573 if (Bases == VisitAllBases)
6574 for (
auto &B : RD->
vbases())
6575 if (getDerived().visitBase(&B))
6578 for (
auto *F : RD->
fields())
6579 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
6580 getDerived().visitField(F))
6589 struct SpecialMemberDeletionInfo
6590 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
6595 bool AllFieldsAreConst;
6600 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
6601 Loc(MD->
getLocation()), AllFieldsAreConst(
true) {}
6610 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
6613 bool shouldDeleteForField(
FieldDecl *FD);
6614 bool shouldDeleteForAllConstMembers();
6616 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
6618 bool shouldDeleteForSubobjectCall(Subobject Subobj,
6620 bool IsDtorCallInCtor);
6628 bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
6648 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
6650 bool IsDtorCallInCtor) {
6657 DiagKind = !Decl ? 0 : 1;
6660 else if (!isAccessible(Subobj, Decl))
6678 diag::note_deleted_special_member_class_subobject)
6679 << getEffectiveCSM() << MD->
getParent() <<
true 6680 << Field << DiagKind << IsDtorCallInCtor;
6684 diag::note_deleted_special_member_class_subobject)
6685 << getEffectiveCSM() << MD->
getParent() <<
false 6686 << Base->
getType() << DiagKind << IsDtorCallInCtor;
6699 bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
6702 bool IsMutable = Field && Field->
isMutable();
6720 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
6727 if (IsConstructor) {
6730 false,
false,
false,
false,
false);
6731 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
6749 if (
auto *BaseCtor = SMOR.
getMethod()) {
6754 if (BaseCtor->isDeleted() && Diagnose) {
6756 diag::note_deleted_special_member_class_subobject)
6757 << getEffectiveCSM() << MD->
getParent() <<
false 6758 << Base->
getType() << 1 <<
false;
6761 return BaseCtor->isDeleted();
6763 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
6768 bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
6777 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
6778 << !!ICI << MD->
getParent() << FD << FieldType << 0;
6789 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
6795 AllFieldsAreConst =
false;
6801 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
6805 }
else if (IsAssignment) {
6810 << isMove() << MD->
getParent() << FD << FieldType << 0;
6825 if (!inUnion() && FieldRecord->
isUnion() &&
6827 bool AllVariantFieldsAreConst =
true;
6830 for (
auto *UI : FieldRecord->
fields()) {
6834 AllVariantFieldsAreConst =
false;
6837 if (UnionFieldRecord &&
6838 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
6848 diag::note_deleted_default_ctor_all_const)
6858 if (shouldDeleteForClassSubobject(FieldRecord, FD,
6869 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
6873 bool AnyFields =
false;
6875 if ((AnyFields = !F->isUnnamedBitfield()))
6881 diag::note_deleted_default_ctor_all_const)
6906 (CSM == CXXDefaultConstructor || CSM == CXXCopyAssignment)) {
6915 if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
6924 (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
6930 bool DeletesOnlyMatchingCopy =
6931 getLangOpts().MSVCCompat &&
6935 (!DeletesOnlyMatchingCopy || CSM == CXXCopyConstructor)) {
6936 if (!Diagnose)
return true;
6939 for (
auto *I : RD->
ctors()) {
6940 if (I->isMoveConstructor()) {
6941 UserDeclaredMove = I;
6945 assert(UserDeclaredMove);
6947 (!DeletesOnlyMatchingCopy || CSM == CXXCopyAssignment)) {
6948 if (!Diagnose)
return true;
6951 for (
auto *I : RD->
methods()) {
6952 if (I->isMoveAssignmentOperator()) {
6953 UserDeclaredMove = I;
6957 assert(UserDeclaredMove);
6960 if (UserDeclaredMove) {
6962 diag::note_deleted_copy_user_declared_move)
6963 << (CSM == CXXCopyAssignment) << RD
6975 if (CSM == CXXDestructor && MD->
isVirtual()) {
6980 OperatorDelete,
false)) {
6987 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
6995 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
6996 : SMI.VisitPotentiallyConstructedBases))
6999 if (SMI.shouldDeleteForAllConstMembers())
7002 if (getLangOpts().CUDA) {
7005 return inferCUDATargetForImplicitSpecialMember(RD, CSM, MD, SMI.ConstArg,
7024 *Selected =
nullptr;
7028 llvm_unreachable(
"not a special member");
7046 for (
auto *CI : RD->
ctors()) {
7047 if (!CI->isDefaultConstructor())
7054 *Selected = DefCtor;
7083 }
else if (!Selected) {
7091 goto NeedOverloadResolution;
7101 }
else if (!Selected) {
7106 goto NeedOverloadResolution;
7110 NeedOverloadResolution:
7134 llvm_unreachable(
"unknown special method kind");
7138 for (
auto *CI : RD->
ctors())
7139 if (!CI->isImplicit())
7143 typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
7146 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
7176 ConstRHS, Diagnose ? &Selected :
nullptr))
7184 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
7187 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
7188 }
else if (!Selected)
7189 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
7194 << Kind << SubType.getUnqualifiedType() << CSM;
7196 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
7197 << Kind << SubType.getUnqualifiedType() << CSM;
7202 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
7203 << Kind << SubType.getUnqualifiedType() << CSM;
7217 bool ConstArg,
bool Diagnose) {
7218 for (
const auto *FI : RD->
fields()) {
7219 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
7225 if (FI->isAnonymousStructOrUnion()) {
7227 CSM, ConstArg, Diagnose))
7238 S.
Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI;
7248 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
7253 bool ConstRHS = ConstArg && !FI->isMutable();
7267 bool ConstArg = (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment);
7277 assert(!MD->
isUserProvided() && CSM != CXXInvalid &&
"not special enough");
7281 bool ConstArg =
false;
7287 case CXXDefaultConstructor:
7292 case CXXCopyConstructor:
7293 case CXXCopyAssignment: {
7309 case CXXMoveConstructor:
7310 case CXXMoveAssignment: {
7326 llvm_unreachable(
"not a special member");
7332 diag::note_nontrivial_default_arg)
7351 for (
const auto &BI : RD->bases())
7374 if (CSM == CXXDestructor && MD->
isVirtual()) {
7387 if (RD->getNumVBases()) {
7397 for (
const auto *MI : RD->methods()) {
7398 if (MI->isVirtual()) {
7400 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
7405 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
7413 struct FindHiddenVirtualMethod {
7416 llvm::SmallPtrSet<const CXXMethodDecl *, 8> OverridenAndUsingBaseMethods;
7421 static bool CheckMostOverridenMethods(
7423 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
7427 if (CheckMostOverridenMethods(O, Methods))
7443 bool foundSameNameMethod =
false;
7450 foundSameNameMethod =
true;
7467 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
7468 overloadedMethods.push_back(MD);
7472 if (foundSameNameMethod)
7473 OverloadedMethods.append(overloadedMethods.begin(),
7474 overloadedMethods.end());
7475 return foundSameNameMethod;
7482 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
7500 FindHiddenVirtualMethod FHVM;
7511 ND = shad->getTargetDecl();
7517 OverloadedMethods = FHVM.OverloadedMethods;
7522 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
7525 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
7526 HandleFunctionTypeMismatch(PD, MD->
getType(), overloadedMD->
getType());
7537 if (Diags.isIgnored(diag::warn_overloaded_virtual, MD->
getLocation()))
7541 FindHiddenVirtualMethods(MD, OverloadedMethods);
7542 if (!OverloadedMethods.empty()) {
7544 << MD << (OverloadedMethods.size() > 1);
7546 NoteHiddenVirtualMethods(MD, OverloadedMethods);
7558 AdjustDeclIfTemplate(TagDecl);
7561 if (l->getKind() != AttributeList::AT_Visibility)
7564 Diag(l->getLoc(), diag::warn_attribute_after_definition_ignored) <<
7568 ActOnFields(S, RLoc, TagDecl, llvm::makeArrayRef(
7570 reinterpret_cast<Decl**>(FieldCollector->getCurFields()),
7571 FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList);
7573 CheckCompletedCXXClass(dyn_cast_or_null<CXXRecordDecl>(TagDecl));
7586 DeclareImplicitDefaultConstructor(ClassDecl);
7597 DeclareImplicitCopyConstructor(ClassDecl);
7608 DeclareImplicitCopyConstructor(ClassDecl);
7616 DeclareImplicitMoveConstructor(ClassDecl);
7629 DeclareImplicitCopyAssignment(ClassDecl);
7639 DeclareImplicitMoveAssignment(ClassDecl);
7651 DeclareImplicitDestructor(ClassDecl);
7664 D = TD->getTemplatedDecl();
7666 if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
7667 ParameterLists.push_back(PSD->getTemplateParameters());
7670 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
7671 ParameterLists.push_back(DD->getTemplateParameterList(i));
7675 ParameterLists.push_back(FTD->getTemplateParameters());
7679 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
7680 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
7681 ParameterLists.push_back(TD->getTemplateParameterList(i));
7685 ParameterLists.push_back(CTD->getTemplateParameters());
7691 if (Params->size() > 0)
7696 if (Param->getDeclName()) {
7698 IdResolver.AddDecl(Param);
7707 if (!RecordD)
return;
7708 AdjustDeclIfTemplate(RecordD);
7710 PushDeclContext(S, Record);
7714 if (!RecordD)
return;
7727 IdResolver.AddDecl(Param);
7759 IdResolver.AddDecl(Param);
7772 AdjustDeclIfTemplate(MethodD);
7781 CheckConstructor(Constructor);
7785 CheckCXXDefaultArguments(Method);
7820 diagnoseIgnoredQualifiers(
7889 const char *ConstRef
7892 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
7918 FindDeallocationFunctionForDestructor(Loc, RD)) {
7919 Expr *ThisArg =
nullptr;
7924 if (OperatorDelete->isDestroyingOperatorDelete()) {
7925 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
7932 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
7933 assert(!This.
isInvalid() &&
"couldn't form 'this' expr in dtor?");
7934 This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
7935 if (This.isInvalid()) {
7938 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
7941 ThisArg = This.get();
7945 MarkFunctionReferenced(Loc, OperatorDelete);
7969 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
7972 if (TST->isTypeAlias())
7974 << DeclaratorType << 1;
8007 diagnoseIgnoredQualifiers(diag::err_destructor_return_type, TypeQuals,
8143 bool NeedsTypedef =
false;
8147 bool PastFunctionChunk =
false;
8149 switch (Chunk.Kind) {
8151 if (!PastFunctionChunk) {
8152 if (Chunk.Fun.HasTrailingReturnType) {
8154 GetTypeFromParser(Chunk.Fun.getTrailingReturnType(), &TRT);
8157 PastFunctionChunk =
true;
8162 NeedsTypedef =
true;
8184 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
8185 DB << Before <<
After;
8187 if (!NeedsTypedef) {
8191 if (After.isInvalid() && ConvTSI) {
8238 getLangOpts().CPlusPlus11 ?
8239 diag::warn_cxx98_compat_explicit_conversion_functions :
8240 diag::ext_explicit_conversion_functions)
8249 assert(Conversion &&
"Expected to receive a conversion function declaration");
8267 ConvType = ConvTypeRef->getPointeeType();
8271 else if (ConvType->isRecordType()) {
8273 if (ConvType == ClassType)
8276 else if (IsDerivedFrom(Conversion->
getLocation(), ClassType, ConvType))
8278 << ClassType << ConvType;
8279 }
else if (ConvType->isVoidType()) {
8281 << ClassType << ConvType;
8286 return ConversionTemplate;
8294 struct BadSpecifierDiagnoser {
8297 ~BadSpecifierDiagnoser() {
8305 return check(SpecLoc,
8311 if (!Specifiers.empty()) Specifiers +=
" ";
8317 std::string Specifiers;
8329 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
8334 if (!CurContext->getRedeclContext()->Equals(
8337 << GuidedTemplateDecl;
8338 Diag(GuidedTemplateDecl->
getLocation(), diag::note_template_decl_here);
8343 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
8344 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
8345 DS.isNoreturnSpecified() || DS.isConstexprSpecified()) {
8346 BadSpecifierDiagnoser Diagnoser(
8348 diag::err_deduction_guide_invalid_specifier);
8350 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
8355 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
8356 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
8357 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
8358 DS.ClearConstexprSpec();
8360 Diagnoser.check(DS.getConstSpecLoc(),
"const");
8361 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
8362 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
8363 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
8364 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
8365 DS.ClearTypeQualifiers();
8367 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
8368 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
8369 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
8370 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
8371 DS.ClearTypeSpecType();
8378 bool FoundFunction =
false;
8384 diag::err_deduction_guide_with_complex_decl)
8388 if (!Chunk.Fun.hasTrailingReturnType()) {
8390 diag::err_deduction_guide_no_trailing_return_type);
8396 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
8398 QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
8399 assert(TSI &&
"deduction guide has valid type but invalid return type?");
8400 bool AcceptableReturnType =
false;
8401 bool MightInstantiateToSpecialization =
false;
8404 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
8405 bool TemplateMatches =
8408 AcceptableReturnType =
true;
8413 MightInstantiateToSpecialization = !(TD && isa<ClassTemplateDecl>(TD) &&
8417 MightInstantiateToSpecialization =
true;
8420 if (!AcceptableReturnType) {
8422 diag::err_deduction_guide_bad_trailing_return_type)
8423 << GuidedTemplate << TSI->
getType() << MightInstantiateToSpecialization
8429 FoundFunction =
true;
8446 assert(*IsInline != PrevNS->
isInline());
8454 if (*IsInline && II && II->
getName().startswith(
"__atomic") &&
8459 NS->setInline(*IsInline);
8462 for (
auto *I : PrevNS->
decls())
8463 if (
auto *ND = dyn_cast<NamedDecl>(I))
8471 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
8474 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
8493 bool IsInline = InlineLoc.
isValid();
8494 bool IsInvalid =
false;
8496 bool AddToKnown =
false;
8512 LookupResult R(*
this, II, IdentLoc, LookupOrdinaryName,
8513 ForExternalRedeclaration);
8514 LookupQualifiedName(R, CurContext->getRedeclContext());
8517 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
8521 if (IsInline != PrevNS->
isInline())
8524 }
else if (PrevDecl) {
8526 Diag(Loc, diag::err_redefinition_different_kind)
8528 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
8531 }
else if (II->
isStr(
"std") &&
8532 CurContext->getRedeclContext()->isTranslationUnit()) {
8535 PrevNS = getStdNamespace();
8537 AddToKnown = !IsInline;
8540 AddToKnown = !IsInline;
8554 if (PrevNS && IsInline != PrevNS->
isInline())
8560 StartLoc, Loc, II, PrevNS);
8564 ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
8565 AddPragmaAttributes(DeclRegionScope, Namespc);
8568 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
8569 PushNamespaceVisibilityAttr(
Attr, Loc);
8572 StdNamespace = Namespc;
8574 KnownNamespaces[Namespc] =
false;
8577 PushOnScopeChains(Namespc, DeclRegionScope);
8582 TU->setAnonymousNamespace(Namespc);
8584 cast<NamespaceDecl>(
Parent)->setAnonymousNamespace(Namespc);
8587 CurContext->addDecl(Namespc);
8618 ActOnDocumentableDecl(Namespc);
8625 PushDeclContext(NamespcScope, Namespc);
8633 return AD->getNamespace();
8634 return dyn_cast_or_null<NamespaceDecl>(D);
8640 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
8641 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
8644 if (Namespc->
hasAttr<VisibilityAttr>())
8645 PopPragmaVisibility(
true, RBrace);
8649 return cast_or_null<CXXRecordDecl>(
8658 return cast_or_null<NamespaceDecl>(
8663 if (!StdExperimentalNamespaceCache) {
8664 if (
auto Std = getStdNamespace()) {
8667 if (!LookupQualifiedName(
Result, Std) ||
8668 !(StdExperimentalNamespaceCache =
8670 Result.suppressDiagnostics();
8673 return StdExperimentalNamespaceCache;
8679 if (!StdNamespace) {
8685 &PP.getIdentifierTable().get(
"std"),
8690 return getStdNamespace();
8695 "Looking for std::initializer_list outside of C++.");
8710 if (!Specialization)
8717 Template = dyn_cast_or_null<ClassTemplateDecl>(
8718 TST->getTemplateName().getAsTemplateDecl());
8719 Arguments = TST->getArgs();
8724 if (!StdInitializerList) {
8728 &PP.getIdentifierTable().get(
"initializer_list") ||
8729 !getStdNamespace()->InEnclosingNamespaceSetOf(
8737 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
8741 StdInitializerList = Template;
8756 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
8763 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
8768 Result.suppressDiagnostics();
8771 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
8779 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
8780 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
8788 if (!StdInitializerList) {
8790 if (!StdInitializerList)
8799 CheckTemplateIdType(
TemplateName(StdInitializerList), Loc, Args));
8816 return isStdInitializerList(ArgType,
nullptr);
8823 case Decl::TranslationUnit:
8825 case Decl::LinkageSpec:
8837 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
8839 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
8853 llvm::make_unique<NamespaceValidatorCCC>(),
8856 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
8857 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
8858 Ident->
getName().equals(CorrectedStr);
8860 S.
PDiag(diag::err_using_directive_member_suggest)
8861 << Ident << DC << DroppedSpecifier << SS.getRange(),
8862 S.
PDiag(diag::note_namespace_defined_here));
8865 S.
PDiag(diag::err_using_directive_suggest) << Ident,
8866 S.
PDiag(diag::note_namespace_defined_here));
8868 R.
addDecl(Corrected.getFoundDecl());
8881 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
8882 assert(NamespcName &&
"Invalid NamespcName.");
8883 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
8896 LookupResult R(*
this, NamespcName, IdentLoc, LookupNamespaceName);
8897 LookupParsedName(R, S, &SS);
8906 NamespcName->
isStr(
"std")) {
8907 Diag(IdentLoc, diag::ext_using_undefined_std);
8908 R.
addDecl(getOrCreateStdNamespace());
8918 assert(NS &&
"expected namespace decl");
8921 DiagnoseUseOfDecl(Named, IdentLoc);
8935 DeclContext *CommonAncestor = cast<DeclContext>(NS);
8936 while (CommonAncestor && !CommonAncestor->
Encloses(CurContext))
8937 CommonAncestor = CommonAncestor->
getParent();
8941 IdentLoc, Named, CommonAncestor);
8944 !SourceMgr.isInMainFile(SourceMgr.getExpansionLoc(IdentLoc))) {
8945 Diag(IdentLoc, diag::warn_using_directive_in_header);
8948 PushUsingDirective(S, UDir);
8950 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
8954 ProcessDeclAttributeList(S, UDir, AttrList);
9000 getLangOpts().CPlusPlus11 ?
9001 diag::warn_cxx98_compat_using_decl_constructor :
9002 diag::err_using_decl_constructor)
9020 llvm_unreachable(
"cannot parse qualified deduction guide name");
9031 getLangOpts().CPlusPlus11 ? diag::err_access_decl
9032 : diag::warn_access_decl_deprecated)
9037 if (DiagnoseUnexpandedParameterPack(SS, UPPC_UsingDeclaration) ||
9038 DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC_UsingDeclaration))
9043 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
9050 BuildUsingDeclaration(S, AS, UsingLoc, TypenameLoc.
isValid(), TypenameLoc,
9051 SS, TargetNameInfo, EllipsisLoc, AttrList,
9054 PushOnScopeChains(UD, S,
false);
9069 return Context.
hasSameType(TD1->getUnderlyingType(),
9070 TD2->getUnderlyingType());
9100 if (!getLangOpts().
CPlusPlus11 && CurContext->isRecord()) {
9104 if (isa<EnumDecl>(OrigDC)) OrigDC = OrigDC->
getParent();
9109 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(OrigRec)) {
9110 if (OrigDC == CurContext) {
9112 diag::err_using_decl_nested_name_specifier_is_current_class)
9120 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9122 << cast<CXXRecordDecl>(CurContext)
9130 if (Previous.
empty())
return false;
9133 if (isa<UsingShadowDecl>(Target))
9134 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
9141 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
9142 bool FoundEquivalentDecl =
false;
9149 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D))
9154 PrevShadow = Shadow;
9155 FoundEquivalentDecl =
true;
9156 }
else if (isEquivalentInternalLinkageDeclaration(D, Target)) {
9159 FoundEquivalentDecl =
true;
9163 (isa<TagDecl>(D) ? Tag : NonTag) = D;
9166 if (FoundEquivalentDecl)
9171 switch (CheckOverload(
nullptr, FD, Previous, OldDecl,
9176 case Ovl_NonFunction:
9185 if (CurContext->isRecord())
9201 if (isa<TagDecl>(Target)) {
9203 if (!Tag)
return false;
9207 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
9213 if (!NonTag)
return false;
9226 for (
auto &B : Derived->
bases())
9227 if (B.getType()->getAsCXXRecordDecl() == Base)
9228 return B.isVirtual();
9229 llvm_unreachable(
"not a direct base class");
9239 if (isa<UsingShadowDecl>(Target)) {
9240 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
9241 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
9245 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
9246 NonTemplateTarget = TargetTD->getTemplatedDecl();
9249 if (isa<CXXConstructorDecl>(NonTemplateTarget)) {
9250 bool IsVirtualBase =
9254 Context, CurContext, UD->
getLocation(), UD, Orig, IsVirtualBase);
9268 PushOnScopeChains(Shadow, S);
9270 CurContext->addDecl(Shadow);
9306 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
9314 IdResolver.RemoveDecl(Shadow);
9327 bool &AnyDependentBases) {
9330 for (
auto &Base : Derived->
bases()) {
9332 if (CanonicalDesiredBase == BaseType)
9334 if (BaseType->isDependentType())
9335 AnyDependentBases =
true;
9343 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
9345 : HasTypenameKeyword(HasTypenameKeyword),
9346 IsInstantiation(IsInstantiation), OldNNS(NNS),
9347 RequireMemberOf(RequireMemberOf) {}
9349 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
9353 if (!ND || isa<NamespaceDecl>(ND))
9363 if (RequireMemberOf) {
9365 if (FoundRecord && FoundRecord->isInjectedClassName()) {
9386 bool AnyDependentBases =
false;
9389 AnyDependentBases) &&
9401 if (FoundRecord && FoundRecord->isInjectedClassName())
9405 if (isa<TypeDecl>(ND))
9406 return HasTypenameKeyword || !IsInstantiation;
9408 return !HasTypenameKeyword;
9412 bool HasTypenameKeyword;
9413 bool IsInstantiation;
9426 bool HasTypenameKeyword,
9432 bool IsInstantiation) {
9433 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9435 assert(IdentLoc.isValid() &&
"Invalid TargetName location.");
9444 if (
auto *RD = dyn_cast<CXXRecordDecl>(CurContext))
9450 ForVisibleRedeclaration);
9453 LookupName(Previous, S);
9459 if (!isDeclInScope(D, CurContext, S))
9471 assert(IsInstantiation &&
"no scope in non-instantiation");
9472 if (CurContext->isRecord())
9473 LookupQualifiedName(Previous, CurContext);
9492 if (CheckUsingDeclRedeclaration(UsingLoc, HasTypenameKeyword,
9493 SS, IdentLoc, Previous))
9497 if (CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo,
9501 DeclContext *LookupContext = computeDeclContext(SS);
9504 if (!LookupContext || EllipsisLoc.
isValid()) {
9505 if (HasTypenameKeyword) {
9508 UsingLoc, TypenameLoc,
9514 QualifierLoc, NameInfo, EllipsisLoc);
9517 CurContext->addDecl(D);
9521 auto Build = [&](
bool Invalid) {
9524 UsingName, HasTypenameKeyword);
9526 CurContext->addDecl(UD);
9530 auto BuildInvalid = [&]{
return Build(
true); };
9531 auto BuildValid = [&]{
return Build(
false); };
9533 if (RequireCompleteDeclContext(SS, LookupContext))
9534 return BuildInvalid();
9543 if (!IsInstantiation)
9548 if (CurContext->isRecord()) {
9553 LookupQualifiedName(R, LookupContext);
9566 if (getLangOpts().
CPlusPlus14 && II && II->isStr(
"gets") &&
9567 CurContext->isStdNamespace() &&
9568 isa<TranslationUnitDecl>(LookupContext) &&
9569 getSourceManager().isInSystemHeader(UsingLoc))
9573 llvm::make_unique<UsingValidatorCCC>(
9574 HasTypenameKeyword, IsInstantiation, SS.getScopeRep(),
9576 CTK_ErrorRecovery)) {
9579 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
9580 << NameInfo.
getName() << LookupContext << 0
9585 NamedDecl *ND = Corrected.getCorrectionDecl();
9587 return BuildInvalid();
9593 RD = cast<CXXRecordDecl>(RD->
getParent());
9596 if (Corrected.WillReplaceSpecifier()) {
9598 Builder.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
9605 auto *CurClass = cast<CXXRecordDecl>(CurContext);
9608 UsingName.setNamedTypeInfo(
nullptr);
9609 for (
auto *Ctor : LookupConstructors(RD))
9615 UsingName.setName(ND->getDeclName());
9619 Diag(IdentLoc, diag::err_no_member)
9620 << NameInfo.
getName() << LookupContext << SS.getRange();
9621 return BuildInvalid();
9626 return BuildInvalid();
9628 if (HasTypenameKeyword) {
9631 Diag(IdentLoc, diag::err_using_typename_non_type);
9633 Diag((*I)->getUnderlyingDecl()->getLocation(),
9634 diag::note_using_decl_target);
9635 return BuildInvalid();
9642 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
9644 return BuildInvalid();
9651 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
9653 return BuildInvalid();
9659 if (cast<EnumDecl>(ED->getDeclContext())->isScoped()) {
9660 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
9662 return BuildInvalid();
9669 if (UsingName.getName().getNameKind() ==
9674 if (CheckInheritingConstructorUsingDecl(UD))
9680 if (!CheckUsingShadowDecl(UD, *I, Previous, PrevDecl))
9681 BuildUsingShadowDecl(S, UD, *I, PrevDecl);
9689 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
9690 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
9691 isa<UsingPackDecl>(InstantiatedFrom));
9695 UPD->setAccess(InstantiatedFrom->
getAccess());
9696 CurContext->addDecl(UPD);
9702 assert(!UD->
hasTypename() &&
"expecting a constructor name");
9705 assert(SourceType &&
9706 "Using decl naming constructor doesn't have type in scope spec.");
9707 CXXRecordDecl *TargetClass = cast<CXXRecordDecl>(CurContext);
9710 bool AnyDependentBases =
false;
9713 if (!Base && !AnyDependentBases) {
9715 diag::err_using_decl_constructor_not_in_direct_base)
9717 <<
QualType(SourceType, 0) << TargetClass;
9732 bool HasTypenameKeyword,
9745 if (!CurContext->getRedeclContext()->isRecord()) {
9752 for (
auto *D : Prev) {
9753 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
9754 bool OldCouldBeEnumerator =
9755 isa<UnresolvedUsingValueDecl>(D) || isa<EnumConstantDecl>(D);
9757 OldCouldBeEnumerator ? diag::err_redefinition
9758 : diag::err_redefinition_different_kind)
9759 << Prev.getLookupName();
9760 Diag(D->getLocation(), diag::note_previous_definition);
9773 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
9774 DTypename = UD->hasTypename();
9775 DQual = UD->getQualifier();
9777 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
9779 DQual = UD->getQualifier();
9781 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
9783 DQual = UD->getQualifier();
9788 if (HasTypenameKeyword != DTypename)
continue;
9797 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
9814 DeclContext *NamedContext = computeDeclContext(SS);
9816 if (!CurContext->isRecord()) {
9824 if ((HasTypename && !NamedContext) ||
9826 auto *RD = NamedContext
9829 if (RD && RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), RD))
9832 Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member)
9844 LookupQualifiedName(R, RD);
9857 getLocForEndOfToken(NameInfo.
getLocEnd());
9858 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
9868 if (getLangOpts().CPlusPlus11) {
9874 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
9889 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
9890 << (getLangOpts().CPlusPlus11 ? 4 : 3)
9903 if (!NamedContext) {
9917 diag::err_using_decl_nested_name_specifier_is_not_class)
9923 RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), NamedContext))
9926 if (getLangOpts().CPlusPlus11) {
9932 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(
9933 cast<CXXRecordDecl>(NamedContext))) {
9934 if (CurContext == NamedContext) {
9936 diag::err_using_decl_nested_name_specifier_is_current_class)
9941 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
9943 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9945 << cast<CXXRecordDecl>(CurContext)
9967 llvm::SmallPtrSet<const CXXRecordDecl *, 4> Bases;
9974 if (!cast<CXXRecordDecl>(CurContext)->forallBases(Collect))
9980 return !Bases.count(Base);
9985 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
9986 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
9990 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9992 << cast<CXXRecordDecl>(CurContext)
10005 Decl *DeclFromDeclSpec) {
10010 "got alias-declaration outside of declaration scope");
10015 bool Invalid =
false;
10018 GetTypeFromParser(Type.
get(), &TInfo);
10020 if (DiagnoseClassNameShadow(CurContext, NameInfo))
10023 if (DiagnoseUnexpandedParameterPack(Name.
StartLocation, TInfo,
10024 UPPC_DeclarationType)) {
10031 TemplateParamLists.size()
10032 ? forRedeclarationInCurContext()
10033 : ForVisibleRedeclaration);
10038 Previous.getFoundDecl()->isTemplateParameter()) {
10044 "name in alias declaration must be an identifier");
10054 ProcessDeclAttributeList(S, NewTD, AttrList);
10055 AddPragmaAttributes(S, NewTD);
10057 CheckTypedefForVariablyModifiedType(S, NewTD);
10060 bool Redeclaration =
false;
10063 if (TemplateParamLists.size()) {
10067 if (TemplateParamLists.size() != 1) {
10068 Diag(UsingLoc, diag::err_alias_template_extra_headers)
10069 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
10070 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
10075 if (CheckTemplateDeclScope(S, TemplateParams))
10079 FilterLookupForScope(
Previous, CurContext, S,
false,
10082 Redeclaration =
true;
10085 if (!OldDecl && !Invalid) {
10086 Diag(UsingLoc, diag::err_redefinition_different_kind)
10097 if (TemplateParameterListsAreEqual(TemplateParams,
10100 TPL_TemplateMatch))
10122 if (CheckTemplateParameterList(TemplateParams, OldTemplateParams,
10123 TPC_TypeAliasTemplate))
10136 else if (OldDecl) {
10138 CheckRedeclarationModuleOwnership(NewDecl, OldDecl);
10143 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
10144 setTagNameForLinkagePurposes(TD, NewTD);
10145 handleTagNumbering(TD, S);
10147 ActOnTypedefNameDecl(S, CurContext, NewTD,
Previous, Redeclaration);
10151 PushOnScopeChains(NewND, S);
10152 ActOnDocumentableDecl(NewND);
10163 LookupResult R(*
this, Ident, IdentLoc, LookupNamespaceName);
10164 LookupParsedName(R, S, &SS);
10171 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
10179 LookupResult PrevR(*
this, Alias, AliasLoc, LookupOrdinaryName,
10180 ForVisibleRedeclaration);
10181 LookupName(PrevR, S);
10185 DiagnoseTemplateParameterShadow(AliasLoc, PrevR.
getFoundDecl());
10190 FilterLookupForScope(PrevR, CurContext, S,
false,
10202 }
else if (isVisible(PrevDecl)) {
10203 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
10205 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
10206 << AD->getNamespace();
10209 }
else if (isVisible(PrevDecl)) {
10211 ? diag::err_redefinition
10212 : diag::err_redefinition_different_kind;
10213 Diag(AliasLoc, DiagID) << Alias;
10220 DiagnoseUseOfDecl(ND, IdentLoc);
10229 PushOnScopeChains(AliasDecl, S);
10234 struct SpecialMemberExceptionSpecInfo
10235 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
10243 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
10248 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
10251 void visitSubobjectCall(Subobject Subobj,
10261 auto *BaseClass = cast<CXXRecordDecl>(RT->getDecl());
10263 if (
auto *BaseCtor = SMOR.getMethod()) {
10264 visitSubobjectCall(Base, BaseCtor);
10268 visitClassSubobject(BaseClass, Base, 0);
10272 bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
10283 ExceptSpec.CalledExpr(E);
10285 ->getAs<RecordType>()) {
10286 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
10292 void SpecialMemberExceptionSpecInfo::visitClassSubobject(
CXXRecordDecl *Class,
10296 bool IsMutable = Field && Field->
isMutable();
10297 visitSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable));
10300 void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
10305 ExceptSpec.CalledDecl(getSubobjectLoc(Subobj), MD);
10317 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, Loc);
10319 return Info.ExceptSpec;
10336 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
10337 : Info.VisitAllBases);
10339 return Info.ExceptSpec;
10344 struct DeclaringSpecialMember {
10348 bool WasAlreadyBeingDeclared;
10351 : S(S), D(RD, CSM), SavedContext(S, RD) {
10353 if (WasAlreadyBeingDeclared)
10374 ~DeclaringSpecialMember() {
10375 if (!WasAlreadyBeingDeclared) {
10382 bool isAlreadyBeingDeclared()
const {
10383 return WasAlreadyBeingDeclared;
10393 ForExternalRedeclaration);
10400 CheckFunctionDeclaration(S, FD, R,
false);
10412 "Should not build implicit default constructor!");
10414 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDefaultConstructor);
10415 if (DSM.isAlreadyBeingDeclared())
10419 CXXDefaultConstructor,
10430 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
10431 nullptr,
false,
true,
10436 if (getLangOpts().CUDA) {
10437 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDefaultConstructor,
10454 Scope *S = getScopeForContext(ClassDecl);
10455 CheckImplicitSpecialMemberDeclaration(S, DefaultCon);
10457 if (ShouldDeleteSpecialMember(DefaultCon, CXXDefaultConstructor))
10458 SetDeclDeleted(DefaultCon, ClassLoc);
10461 PushOnScopeChains(DefaultCon, S,
false);
10462 ClassDecl->
addDecl(DefaultCon);
10472 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
10477 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
10483 ResolveExceptionSpec(CurrentLocation,
10485 MarkVTableUsed(CurrentLocation, ClassDecl);
10490 if (SetCtorInitializers(Constructor,
false)) {
10502 L->CompletedImplicitDefinition(Constructor);
10505 DiagnoseUninitializedFields(*
this, Constructor);
10510 CheckDelayedMemberExceptionSpecs();
10531 ->getInheritedConstructor()
10534 return cast<CXXConstructorDecl>(Ctor);
10549 false, BaseCtor, &ICI);
10552 Context, Derived, UsingLoc, NameInfo, TInfo->
getType(), TInfo,
10563 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
10569 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
10573 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
10580 ParamDecls.push_back(PD);
10585 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
10588 Derived->
addDecl(DerivedCtor);
10590 if (ShouldDeleteSpecialMember(DerivedCtor, CXXDefaultConstructor, &ICI))
10591 SetDeclDeleted(DerivedCtor, UsingLoc);
10593 return DerivedCtor;
10599 ShouldDeleteSpecialMember(Ctor, CXXDefaultConstructor, &ICI,
10618 ResolveExceptionSpec(CurrentLocation,
10620 MarkVTableUsed(CurrentLocation, ClassDecl);
10642 for (
bool VBase : {
false,
true}) {
10644 if (B.isVirtual() != VBase)
10647 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
10652 if (!BaseCtor.first)
10655 MarkFunctionReferenced(CurrentLocation, BaseCtor.first);
10657 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
10661 Context, TInfo, VBase, InitLoc, Init.
get(), InitLoc,
10669 if (SetCtorInitializers(Constructor,
false, Inits)) {
10678 L->CompletedImplicitDefinition(Constructor);
10681 DiagnoseUninitializedFields(*
this, Constructor);
10691 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDestructor);
10692 if (DSM.isAlreadyBeingDeclared())
10709 if (getLangOpts().CUDA) {
10710 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDestructor,
10727 Scope *S = getScopeForContext(ClassDecl);
10728 CheckImplicitSpecialMemberDeclaration(S, Destructor);
10734 ShouldDeleteSpecialMember(Destructor, CXXDestructor))
10735 SetDeclDeleted(Destructor, ClassLoc);
10739 PushOnScopeChains(Destructor, S,
false);
10740 ClassDecl->
addDecl(Destructor);
10750 "DefineImplicitDestructor - call it for implicit default dtor");
10755 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
10761 ResolveExceptionSpec(CurrentLocation,
10763 MarkVTableUsed(CurrentLocation, ClassDecl);
10768 MarkBaseAndMemberDestructorsReferenced(Destructor->
getLocation(),
10771 if (CheckDestructor(Destructor)) {
10783 L->CompletedImplicitDefinition(Destructor);
10791 if (
CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(CurContext)) {
10792 if (Record->isInvalidDecl()) {
10793 DelayedDefaultedMemberExceptionSpecs.clear();
10794 DelayedExceptionSpecChecks.clear();
10802 referenceDLLExportedClassMethods();
10806 if (!DelayedDllExportClasses.empty()) {
10810 std::swap(DelayedDllExportClasses, WorkList);
10819 "adjusting dtor exception specs was introduced in c++11");
10826 getAs<FunctionProtoType>();
10849 class ExprBuilder {
10850 ExprBuilder(
const ExprBuilder&) =
delete;
10851 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
10854 static Expr *assertNotNull(
Expr *E) {
10855 assert(E &&
"Expression construction must not fail.");
10861 virtual ~ExprBuilder() {}
10866 class RefBuilder:
public ExprBuilder {
10876 : Var(Var), VarType(VarType) {}
10879 class ThisBuilder:
public ExprBuilder {
10886 class CastBuilder:
public ExprBuilder {
10887 const ExprBuilder &Builder;
10895 CK_UncheckedDerivedToBase,
Kind,
10901 : Builder(Builder), Type(Type),
Kind(Kind), Path(Path) {}
10904 class DerefBuilder:
public ExprBuilder {
10905 const ExprBuilder &Builder;
10909 return assertNotNull(
10913 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
10916 class MemberBuilder:
public ExprBuilder {
10917 const ExprBuilder &Builder;
10926 Builder.build(S, Loc), Type, Loc, IsArrow, SS,
SourceLocation(),
10927 nullptr, MemberLookup,
nullptr,
nullptr).
get());
10930 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
10932 : Builder(Builder), Type(Type), IsArrow(IsArrow),
10933 MemberLookup(MemberLookup) {}
10936 class MoveCastBuilder:
public ExprBuilder {
10937 const ExprBuilder &Builder;
10941 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
10944 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
10947 class LvalueConvBuilder:
public ExprBuilder {
10948 const ExprBuilder &Builder;
10952 return assertNotNull(
10956 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
10959 class SubscriptBuilder:
public ExprBuilder {
10960 const ExprBuilder &Base;
10961 const ExprBuilder &Index;
10966 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
10969 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
10970 : Base(Base), Index(Index) {}
10981 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
10990 Expr *From = FromB.build(S, Loc);
10994 Expr *To = ToB.build(S, Loc);
11000 bool NeedsCollectableMemCpy =
11004 StringRef MemCpyName = NeedsCollectableMemCpy ?
11005 "__builtin_objc_memmove_collectable" :
11006 "__builtin_memcpy";
11019 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
11021 Expr *CallArgs[] = {
11025 Loc, CallArgs, Loc);
11027 assert(!Call.
isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
11060 const ExprBuilder &To,
const ExprBuilder &From,
11061 bool CopyingBaseSubobject,
bool Copying,
11062 unsigned Depth = 0) {
11078 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
11093 if (Method->isCopyAssignmentOperator() ||
11094 (!Copying && Method->isMoveAssignmentOperator()))
11113 if (CopyingBaseSubobject) {
11144 Expr *FromInst = From.build(S, Loc);
11147 Loc, FromInst, Loc);
11167 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
11187 llvm::raw_svector_ostream OS(Str);
11188 OS <<
"__i" <<
Depth;
11192 IterationVarName, SizeType,
11201 RefBuilder IterationVarRef(IterationVar, SizeType);
11202 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
11208 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
11209 MoveCastBuilder FromIndexMove(FromIndexCopy);
11210 const ExprBuilder *FromIndex;
11212 FromIndex = &FromIndexCopy;
11214 FromIndex = &FromIndexMove;
11216 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
11221 ToIndex, *FromIndex, CopyingBaseSubobject,
11222 Copying,
Depth + 1);
11224 if (Copy.isInvalid() || !Copy.get())
11243 Loc, Loc, InitStmt,
11250 const ExprBuilder &To,
const ExprBuilder &From,
11251 bool CopyingBaseSubobject,
bool Copying) {
11258 CopyingBaseSubobject,
11263 if (!Result.isInvalid() && !Result.get())
11276 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyAssignment);
11277 if (DSM.isAlreadyBeingDeclared())
11304 if (getLangOpts().CUDA) {
11305 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyAssignment,
11318 ClassLoc, ClassLoc,
11326 ? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
11332 Scope *S = getScopeForContext(ClassDecl);
11333 CheckImplicitSpecialMemberDeclaration(S, CopyAssignment);
11335 if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment))
11336 SetDeclDeleted(CopyAssignment, ClassLoc);
11339 PushOnScopeChains(CopyAssignment, S,
false);
11340 ClassDecl->
addDecl(CopyAssignment);
11342 return CopyAssignment;
11356 if (RD->hasUserDeclaredDestructor()) {
11357 UserDeclaredOperation = RD->getDestructor();
11358 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
11359 RD->hasUserDeclaredCopyConstructor() &&
11362 for (
auto *I : RD->ctors()) {
11363 if (I->isCopyConstructor()) {
11364 UserDeclaredOperation = I;
11368 assert(UserDeclaredOperation);
11369 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
11370 RD->hasUserDeclaredCopyAssignment() &&
11373 for (
auto *I : RD->methods()) {
11374 if (I->isCopyAssignmentOperator()) {
11375 UserDeclaredOperation = I;
11379 assert(UserDeclaredOperation);
11382 if (UserDeclaredOperation) {
11384 diag::warn_deprecated_copy_operation)
11385 << RD << !isa<CXXConstructorDecl>(CopyOp)
11386 << isa<CXXDestructorDecl>(UserDeclaredOperation);
11397 "DefineImplicitCopyAssignment called for wrong function");
11411 ResolveExceptionSpec(CurrentLocation,
11451 RefBuilder OtherRef(Other, OtherRefType);
11457 bool Invalid =
false;
11458 for (
auto &Base : ClassDecl->
bases()) {
11468 BasePath.push_back(&Base);
11472 CastBuilder From(OtherRef, Context.
getQualifiedType(BaseType, OtherQuals),
11476 DerefBuilder DerefThis(This);
11477 CastBuilder To(DerefThis,
11493 Statements.push_back(Copy.
getAs<
Expr>());
11497 for (
auto *Field : ClassDecl->
fields()) {
11500 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
11503 if (Field->isInvalidDecl()) {
11509 if (Field->getType()->isReferenceType()) {
11510 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
11511 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
11512 Diag(Field->getLocation(), diag::note_declared_at);
11520 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
11521 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
11522 Diag(Field->getLocation(), diag::note_declared_at);
11528 if (Field->isBitField() && Field->getBitWidthValue(Context) == 0)
11531 QualType FieldType = Field->getType().getNonReferenceType();
11534 "Incomplete array type is not valid");
11540 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
11543 MemberLookup.resolveKind();
11545 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
11547 MemberBuilder To(This, getCurrentThisType(),
true, MemberLookup);
11560 Statements.push_back(Copy.
getAs<
Stmt>());
11565 ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
11568 if (Return.isInvalid())
11571 Statements.push_back(Return.getAs<
Stmt>());
11582 Body = ActOnCompoundStmt(Loc, Loc, Statements,
11584 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
11587 CopyAssignOperator->
markUsed(Context);
11590 L->CompletedImplicitDefinition(CopyAssignOperator);
11597 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveAssignment);
11598 if (DSM.isAlreadyBeingDeclared())
11625 if (getLangOpts().CUDA) {
11626 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveAssignment,
11639 ClassLoc, ClassLoc,
11647 ? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
11653 Scope *S = getScopeForContext(ClassDecl);
11654 CheckImplicitSpecialMemberDeclaration(S, MoveAssignment);
11656 if (ShouldDeleteSpecialMember(MoveAssignment, CXXMoveAssignment)) {
11658 SetDeclDeleted(MoveAssignment, ClassLoc);
11662 PushOnScopeChains(MoveAssignment, S,
false);
11663 ClassDecl->
addDecl(MoveAssignment);
11665 return MoveAssignment;
11684 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
11687 for (
auto &BI : Class->
bases()) {
11688 Worklist.push_back(&BI);
11689 while (!Worklist.empty()) {
11722 if (Existing && Existing != &BI) {
11723 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
11726 << (Base->getCanonicalDecl() ==
11729 S.
Diag(BI.getLocStart(), diag::note_vbase_moved_here)
11730 << (Base->getCanonicalDecl() ==
11731 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
11735 Existing =
nullptr;
11745 for (
auto &BI : Base->
bases())
11746 Worklist.push_back(&BI);
11759 "DefineImplicitMoveAssignment called for wrong function");
11785 ResolveExceptionSpec(CurrentLocation,
11797 getAs<RValueReferenceType>()->getPointeeType();
11799 "Bad argument type of defaulted move assignment");
11807 RefBuilder OtherRef(Other, OtherRefType);
11809 MoveCastBuilder MoveOther(OtherRef);
11815 bool Invalid =
false;
11816 for (
auto &Base : ClassDecl->
bases()) {
11834 BasePath.push_back(&Base);
11838 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
11841 DerefBuilder DerefThis(This);
11844 CastBuilder To(DerefThis,
11860 Statements.push_back(Move.
getAs<
Expr>());
11864 for (
auto *Field : ClassDecl->
fields()) {
11867 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
11870 if (Field->isInvalidDecl()) {
11876 if (Field->getType()->isReferenceType()) {
11877 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
11878 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
11879 Diag(Field->getLocation(), diag::note_declared_at);
11887 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
11888 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
11889 Diag(Field->getLocation(), diag::note_declared_at);
11895 if (Field->isBitField() && Field->getBitWidthValue(Context) == 0)
11898 QualType FieldType = Field->getType().getNonReferenceType();
11901 "Incomplete array type is not valid");
11906 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
11909 MemberLookup.resolveKind();
11910 MemberBuilder From(MoveOther, OtherRefType,
11911 false, MemberLookup);
11912 MemberBuilder To(This, getCurrentThisType(),
11913 true, MemberLookup);
11915 assert(!From.build(*
this, Loc)->isLValue() &&
11916 "Member reference with rvalue base must be rvalue except for reference " 11917 "members, which aren't allowed for move assignment.");
11924 if (Move.isInvalid()) {
11930 Statements.push_back(Move.getAs<
Stmt>());
11936 CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
11939 if (Return.isInvalid())
11942 Statements.push_back(Return.getAs<
Stmt>());
11953 Body = ActOnCompoundStmt(Loc, Loc, Statements,
11955 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
11958 MoveAssignOperator->
markUsed(Context);
11961 L->CompletedImplicitDefinition(MoveAssignOperator);
11972 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyConstructor);
11973 if (DSM.isAlreadyBeingDeclared())
11984 CXXCopyConstructor,
11996 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12002 if (getLangOpts().CUDA) {
12003 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyConstructor,
12017 ClassLoc, ClassLoc,
12025 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
12031 Scope *S = getScopeForContext(ClassDecl);
12032 CheckImplicitSpecialMemberDeclaration(S, CopyConstructor);
12034 if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) {
12036 SetDeclDeleted(CopyConstructor, ClassLoc);
12040 PushOnScopeChains(CopyConstructor, S,
false);
12041 ClassDecl->
addDecl(CopyConstructor);
12043 return CopyConstructor;
12052 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
12057 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
12063 ResolveExceptionSpec(CurrentLocation,
12065 MarkVTableUsed(CurrentLocation, ClassDecl);
12077 if (SetCtorInitializers(CopyConstructor,
false)) {
12085 ActOnCompoundStmt(Loc, Loc,
None,
false).getAs<Stmt>());
12086 CopyConstructor->
markUsed(Context);
12090 L->CompletedImplicitDefinition(CopyConstructor);
12098 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveConstructor);
12099 if (DSM.isAlreadyBeingDeclared())
12106 CXXMoveConstructor,
12119 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12125 if (getLangOpts().CUDA) {
12126 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveConstructor,
12140 ClassLoc, ClassLoc,
12148 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
12154 Scope *S = getScopeForContext(ClassDecl);
12155 CheckImplicitSpecialMemberDeclaration(S, MoveConstructor);
12157 if (ShouldDeleteSpecialMember(MoveConstructor, CXXMoveConstructor)) {
12159 SetDeclDeleted(MoveConstructor, ClassLoc);
12163 PushOnScopeChains(MoveConstructor, S,
false);
12164 ClassDecl->
addDecl(MoveConstructor);
12166 return MoveConstructor;
12175 "DefineImplicitMoveConstructor - call it for implicit move ctor");
12180 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
12186 ResolveExceptionSpec(CurrentLocation,
12188 MarkVTableUsed(CurrentLocation, ClassDecl);
12193 if (SetCtorInitializers(MoveConstructor,
false)) {
12200 MoveConstructor->
setBody(ActOnCompoundStmt(
12201 Loc, Loc,
None,
false).getAs<Stmt>());
12202 MoveConstructor->
markUsed(Context);
12206 L->CompletedImplicitDefinition(MoveConstructor);
12221 FunctionDecl *CallOp = Lambda->getLambdaCallOperator();
12222 FunctionDecl *Invoker = Lambda->getLambdaStaticInvoker();
12225 CallOp = InstantiateFunctionDeclaration(
12230 Invoker = InstantiateFunctionDeclaration(
12244 MarkFunctionReferenced(CurrentLocation, CallOp);
12255 Expr *FunctionRef = BuildDeclRefExpr(Invoker, Invoker->
getType(),
12257 assert(FunctionRef &&
"Can't refer to __invoke function?");
12258 Stmt *Return = BuildReturnStmt(Conv->
getLocation(), FunctionRef).
get();
12265 L->CompletedImplicitDefinition(Conv);
12266 L->CompletedImplicitDefinition(Invoker);
12281 Expr *This = ActOnCXXThis(CurrentLocation).get();
12282 Expr *DerefThis =CreateBuiltinUnaryOp(CurrentLocation, UO_Deref, This).get();
12284 ExprResult BuildBlock = BuildBlockForLambdaConversion(CurrentLocation,
12292 if (!BuildBlock.
isInvalid() && !getLangOpts().ObjCAutoRefCount)
12294 CK_CopyAndAutoreleaseBlockObject,
12298 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12307 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12313 Stmt *ReturnS = Return.
get();
12320 L->CompletedImplicitDefinition(Conv);
12327 switch (Args.size()) {
12332 if (!Args[1]->isDefaultArgument())
12337 return !Args[0]->isDefaultArgument();
12348 bool HadMultipleCandidates,
12349 bool IsListInitialization,
12350 bool IsStdInitListInitialization,
12351 bool RequiresZeroInit,
12352 unsigned ConstructKind,
12354 bool Elidable =
false;
12368 Expr *SubExpr = ExprArgs[0];
12373 return BuildCXXConstructExpr(ConstructLoc, DeclInitType,
12374 FoundDecl, Constructor,
12375 Elidable, ExprArgs, HadMultipleCandidates,
12376 IsListInitialization,
12377 IsStdInitListInitialization, RequiresZeroInit,
12378 ConstructKind, ParenRange);
12387 bool HadMultipleCandidates,
12388 bool IsListInitialization,
12389 bool IsStdInitListInitialization,
12390 bool RequiresZeroInit,
12391 unsigned ConstructKind,
12393 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
12394 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
12395 if (DiagnoseUseOfDecl(Constructor, ConstructLoc))
12399 return BuildCXXConstructExpr(
12400 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
12401 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
12402 RequiresZeroInit, ConstructKind, ParenRange);
12412 bool HadMultipleCandidates,
12413 bool IsListInitialization,
12414 bool IsStdInitListInitialization,
12415 bool RequiresZeroInit,
12416 unsigned ConstructKind,
12421 "given constructor for wrong type");
12422 MarkFunctionReferenced(ConstructLoc, Constructor);
12423 if (getLangOpts().CUDA && !CheckCUDACall(ConstructLoc, Constructor))
12427 Context, DeclInitType, ConstructLoc, Constructor, Elidable,
12428 ExprArgs, HadMultipleCandidates, IsListInitialization,
12429 IsStdInitListInitialization, RequiresZeroInit,
12430 static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
12459 assert((getLangOpts().Modules || (!Lookup.
empty() && Lookup.
size() <= 2)) &&
12460 "more than two lookup results for field name");
12463 assert(isa<CXXRecordDecl>(Lookup[0]) &&
12464 "cannot have other non-field member with same name");
12465 for (
auto L : Lookup)
12466 if (isa<FieldDecl>(L)) {
12467 Pattern = cast<FieldDecl>(L);
12470 assert(Pattern &&
"We must have set the Pattern!");
12473 if (!Pattern->hasInClassInitializer() ||
12474 InstantiateInClassInitializer(Loc, Field, Pattern,
12475 getTemplateInstantiationArgs(Field))) {
12498 Diag(Loc, diag::err_in_class_initializer_not_yet_parsed)
12499 << OutermostClass << Field;
12500 Diag(Field->getLocEnd(), diag::note_in_class_initializer_not_yet_parsed);
12502 if (!isSFINAEContext())
12503 Field->setInvalidDecl();
12516 MarkFunctionReferenced(VD->
getLocation(), Destructor);
12517 CheckDestructorAccess(VD->
getLocation(), Destructor,
12518 PDiag(diag::err_access_dtor_var)
12521 DiagnoseUseOfDecl(Destructor, VD->
getLocation());
12545 bool AllowExplicit,
12546 bool IsListInitialization) {
12548 unsigned NumArgs = ArgsPtr.size();
12549 Expr **Args = ArgsPtr.data();
12553 assert(Proto &&
"Constructor without a prototype?");
12557 if (NumArgs < NumParams)
12558 ConvertedArgs.reserve(NumParams);
12560 ConvertedArgs.reserve(NumArgs);
12563 Proto->
isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
12565 bool Invalid = GatherArgumentsForCall(Loc, Constructor,
12567 llvm::makeArrayRef(Args, NumArgs),
12569 CallType, AllowExplicit,
12570 IsListInitialization);
12571 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
12573 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
12575 CheckConstructorCall(Constructor,
12576 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
12586 if (isa<NamespaceDecl>(DC)) {
12588 diag::err_operator_new_delete_declared_in_namespace)
12592 if (isa<TranslationUnitDecl>(DC) &&
12595 diag::err_operator_new_delete_declared_static)
12606 unsigned DependentParamTypeDiag,
12607 unsigned InvalidParamTypeDiag) {
12614 diag::err_operator_new_delete_dependent_result_type)
12620 diag::err_operator_new_delete_invalid_result_type)
12626 diag::err_operator_new_delete_template_too_few_parameters)
12632 diag::err_operator_new_delete_too_few_parameters)
12639 << FnDecl->
getDeclName() << ExpectedFirstParamType;
12643 ExpectedFirstParamType)
12645 << FnDecl->
getDeclName() << ExpectedFirstParamType;
12667 diag::err_operator_new_dependent_param_type,
12668 diag::err_operator_new_param_type))
12675 diag::err_operator_new_default_arg)
12705 SemaRef, FnDecl, SemaRef.
Context.
VoidTy, ExpectedFirstParamType,
12706 diag::err_operator_delete_dependent_param_type,
12707 diag::err_operator_delete_param_type))
12715 diag::err_destroying_operator_delete_not_usual);
12727 "Expected an overloaded operator declaration");
12737 if (Op == OO_Delete || Op == OO_Array_Delete)
12740 if (Op == OO_New || Op == OO_Array_New)
12748 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
12749 if (MethodDecl->isStatic())
12751 diag::err_operator_overload_static) << FnDecl->
getDeclName();
12753 bool ClassOrEnumParam =
false;
12755 QualType ParamType = Param->getType().getNonReferenceType();
12758 ClassOrEnumParam =
true;
12763 if (!ClassOrEnumParam)
12765 diag::err_operator_overload_needs_class_or_enum)
12775 if (Op != OO_Call) {
12777 if (Param->hasDefaultArg())
12778 return Diag(Param->getLocation(),
12779 diag::err_operator_overload_default_arg)
12780 << FnDecl->
getDeclName() << Param->getDefaultArgRange();
12785 {
false,
false,
false }
12786 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 12787 , { Unary, Binary, MemberOnly } 12788 #include "clang/Basic/OperatorKinds.def" 12791 bool CanBeUnaryOperator = OperatorUses[Op][0];
12792 bool CanBeBinaryOperator = OperatorUses[Op][1];
12793 bool MustBeMemberOperator = OperatorUses[Op][2];
12800 + (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
12801 if (Op != OO_Call &&
12802 ((NumParams == 1 && !CanBeUnaryOperator) ||
12803 (NumParams == 2 && !CanBeBinaryOperator) ||
12804 (NumParams < 1) || (NumParams > 2))) {
12807 if (CanBeUnaryOperator && CanBeBinaryOperator) {
12809 }
else if (CanBeUnaryOperator) {
12812 assert(CanBeBinaryOperator &&
12813 "All non-call overloaded operators are unary or binary!");
12817 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
12822 if (Op != OO_Call &&
12824 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
12829 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
12831 diag::err_operator_overload_must_be_member)
12845 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
12852 diag::err_operator_overload_post_incdec_must_be_int)
12853 << LastParam->
getType() << (Op == OO_MinusMinus);
12865 if (TemplateParams->
size() == 1) {
12874 }
else if (TemplateParams->
size() == 2) {
12883 PmArgs->isTemplateParameterPack()) {
12890 diag::ext_string_literal_operator_template);
12897 diag::err_literal_operator_template)
12906 if (isa<CXXMethodDecl>(FnDecl)) {
12907 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
12916 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
12933 diag::err_literal_operator_template_with_params);
12961 diag::err_literal_operator_param)
12978 diag::err_literal_operator_invalid_param)
12988 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
12995 Diag((*Param)->getSourceRange().getBegin(),
12996 diag::err_literal_operator_param)
12997 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13004 Diag((*Param)->getSourceRange().getBegin(),
13005 diag::err_literal_operator_param)
13006 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13017 Diag((*Param)->getSourceRange().getBegin(),
13018 diag::err_literal_operator_param)
13019 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13027 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
13029 Diag((*Param)->getSourceRange().getBegin(),
13030 diag::err_literal_operator_param)
13032 << (*Param)->getSourceRange();
13036 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
13045 if (Param->hasDefaultArg()) {
13046 Diag(Param->getDefaultArgRange().getBegin(),
13047 diag::err_literal_operator_default_argument)
13048 << Param->getDefaultArgRange();
13053 StringRef LiteralName
13055 if (LiteralName[0] !=
'_' &&
13056 !getSourceManager().isInSystemHeader(FnDecl->
getLocation())) {
13078 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
13087 else if (Lang ==
"C++")
13090 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
13101 PushDeclContext(S, D);
13117 return LinkageSpec;
13127 ProcessDeclAttributeList(S, ED, AttrList);
13129 CurContext->addDecl(ED);
13141 bool Invalid =
false;
13155 Diag(Loc, diag::err_catch_rvalue_ref);
13160 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
13166 unsigned DK = diag::err_catch_incomplete;
13170 DK = diag::err_catch_incomplete_ptr;
13175 DK = diag::err_catch_incomplete_ref;
13177 if (!Invalid && (Mode == 0 || !BaseType->
isVoidType()) &&
13178 !BaseType->
isDependentType() && RequireCompleteType(Loc, BaseType, DK))
13182 RequireNonAbstractType(Loc, ExDeclType,
13183 diag::err_abstract_type_in_decl,
13184 AbstractVariableType))
13189 if (!Invalid && getLangOpts().ObjC1) {
13195 Diag(Loc, diag::err_objc_object_catch);
13199 if (getLangOpts().ObjCRuntime.isFragile())
13200 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
13209 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(ExDecl))
13216 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
13234 Expr *opaqueValue =
13245 Expr *init = MaybeCreateExprWithCleanups(construct);
13250 FinalizeVarWithDestructor(ExDecl,
recordType);
13269 UPPC_ExceptionType)) {
13277 LookupOrdinaryName,
13278 ForVisibleRedeclaration)) {
13283 if (isDeclInScope(PrevDecl, CurContext, S)) {
13286 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
13288 }
else if (PrevDecl->isTemplateParameter())
13299 VarDecl *ExDecl = BuildExceptionDeclaration(S, TInfo,
13308 PushOnScopeChains(ExDecl, S);
13310 CurContext->addDecl(ExDecl);
13312 ProcessDeclAttributes(S, ExDecl, D);
13318 Expr *AssertMessageExpr,
13321 AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) :
nullptr;
13323 if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
13326 return BuildStaticAssertDeclaration(StaticAssertLoc, AssertExpr,
13327 AssertMessage, RParenLoc,
false);
13335 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
13340 ExprResult Converted = PerformContextuallyConvertToBool(AssertExpr);
13345 if (!Failed && VerifyIntegerConstantExpression(Converted.
get(), &Cond,
13346 diag::err_static_assert_expression_is_not_constant,
13350 if (!Failed && !Cond) {
13352 llvm::raw_svector_ostream Msg(MsgBuffer);
13354 AssertMessage->
printPretty(Msg,
nullptr, getPrintingPolicy());
13356 Expr *InnerCond =
nullptr;
13357 std::string InnerCondDescription;
13358 std::tie(InnerCond, InnerCondDescription) =
13359 findFailedBooleanCondition(Converted.
get(),
13362 Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed)
13363 << InnerCondDescription << !AssertMessage
13366 Diag(StaticAssertLoc, diag::err_static_assert_failed)
13373 ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
13379 AssertExpr = FullAssertExpr.
get();
13382 AssertExpr, AssertMessage, RParenLoc,
13385 CurContext->addDecl(Decl);
13395 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
13405 if (!CodeSynthesisContexts.empty()) {
13420 getLangOpts().CPlusPlus11 ?
13421 diag::warn_cxx98_compat_unelaborated_friend_type :
13422 diag::ext_unelaborated_friend_type)
13430 diag::warn_cxx98_compat_nonclass_type_friend :
13431 diag::ext_nonclass_type_friend)
13438 diag::warn_cxx98_compat_enum_friend :
13439 diag::ext_enum_friend)
13450 if (getLangOpts().
CPlusPlus11 && LocStart != FriendLoc)
13451 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) <<
T;
13473 bool IsMemberSpecialization =
false;
13474 bool Invalid =
false;
13477 MatchTemplateParametersToScopeSpecifier(
13478 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
13479 IsMemberSpecialization, Invalid)) {
13480 if (TemplateParams->size() > 0) {
13485 return CheckClassTemplate(S, TagSpec, TUK_Friend, TagLoc, SS, Name,
13486 NameLoc, Attr, TemplateParams,
AS_public,
13488 FriendLoc, TempParamLists.size() - 1,
13489 TempParamLists.data()).
get();
13492 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
13494 IsMemberSpecialization =
true;
13498 if (Invalid)
return nullptr;
13500 bool isAllExplicitSpecializations =
true;
13501 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
13502 if (TempParamLists[I]->size()) {
13503 isAllExplicitSpecializations =
false;
13513 if (isAllExplicitSpecializations) {
13515 bool Owned =
false;
13516 bool IsDependent =
false;
13517 return ActOnTag(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc,
13531 QualType T = CheckTypenameType(Keyword, TagLoc, QualifierLoc,
13537 if (isa<DependentNameType>(T)) {
13551 TSI, FriendLoc, TempParamLists);
13553 CurContext->addDecl(Friend);
13557 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
13564 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
13575 TSI, FriendLoc, TempParamLists);
13578 CurContext->addDecl(Friend);
13613 if (TheDeclarator.isInvalidType())
13616 if (DiagnoseUnexpandedParameterPack(Loc, TSI, UPPC_FriendDeclaration))
13634 Diag(Loc, diag::err_tagless_friend_type_template)
13651 if (!TempParams.empty())
13663 CurContext->addDecl(D);
13689 Diag(Loc, diag::err_unexpected_friend);
13717 if (DiagnoseUnexpandedParameterPack(Loc, TInfo, UPPC_FriendDeclaration) ||
13718 DiagnoseUnexpandedParameterPack(NameInfo, UPPC_FriendDeclaration) ||
13719 DiagnoseUnexpandedParameterPack(SS, UPPC_FriendDeclaration))
13725 Scope *DCScope = S;
13727 ForExternalRedeclaration);
13735 (FunctionContainingLocalClass =
13736 cast<CXXRecordDecl>(CurContext)->isLocalClass())) {
13751 Previous.
clear(LookupLocalFriendName);
13752 LookupName(Previous, S,
false);
13754 if (!Previous.
empty()) {
13762 DC = FunctionContainingLocalClass;
13764 adjustContextForLocalExternDecl(DC);
13784 bool isTemplateId =
13805 LookupQualifiedName(Previous, LookupDC);
13807 if (!Previous.
empty()) {
13812 if (isTemplateId) {
13813 if (isa<TranslationUnitDecl>(LookupDC))
break;
13820 DCScope = getScopeForDeclContext(S, DC);
13826 DC = computeDeclContext(SS);
13827 if (!DC)
return nullptr;
13829 if (RequireCompleteDeclContext(SS, DC))
return nullptr;
13831 LookupQualifiedName(Previous, DC);
13845 if (Previous.
empty()) {
13847 Diag(Loc, diag::err_qualified_friend_not_found)
13854 if (DC->
Equals(CurContext))
13856 getLangOpts().CPlusPlus11 ?
13857 diag::warn_cxx98_compat_friend_is_member :
13858 diag::err_friend_is_member);
13890 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
13917 if (DiagArg >= 0) {
13918 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
13929 DCScope = &FakeDCScope;
13932 bool AddToScope =
true;
13933 NamedDecl *ND = ActOnFunctionDeclarator(DCScope, D, DC, TInfo, Previous,
13934 TemplateParams, AddToScope);
13935 if (!ND)
return nullptr;
13949 if (!CurContext->isDependentContext()) {
13952 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
13953 PushOnScopeChains(ND, EnclosingScope,
false);
13960 CurContext->addDecl(FrD);
13965 if (DC->isRecord()) CheckFriendAccess(ND);
13969 FD = FTD->getTemplatedDecl();
13971 FD = cast<FunctionDecl>(ND);
13982 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
13984 diag::note_previous_declaration);
13986 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
13991 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
13993 << cast<CXXRecordDecl>(CurContext);
14002 AdjustDeclIfTemplate(Dcl);
14004 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
14006 Diag(DelLoc, diag::err_deleted_non_function);
14017 Prev->getPreviousDecl()) &&
14018 !Prev->isDefined()) {
14019 Diag(DelLoc, diag::err_deleted_decl_not_first);
14020 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
14021 Prev->isImplicit() ? diag::note_previous_implicit_declaration
14022 : diag::note_previous_declaration);
14041 bool IssuedDiagnostic =
false;
14044 if (!IssuedDiagnostic) {
14046 IssuedDiagnostic =
true;
14048 Diag(O->getLocation(), diag::note_overridden_virtual_function);
14054 ShouldDeleteSpecialMember(MD, getSpecialMember(MD),
nullptr,
14061 Diag(DelLoc, diag::err_deleted_main);
14080 if (Member == CXXInvalid) {
14082 Diag(DefaultLoc, diag::err_default_special_members);
14108 CheckExplicitlyDefaultedSpecialMember(MD);
14113 Diag(DefaultLoc, diag::err_default_special_members);
14121 if (isa<ReturnStmt>(SubStmt))
14122 Self.
Diag(SubStmt->getLocStart(),
14123 diag::err_return_in_constructor_handler);
14124 if (!isa<Expr>(SubStmt))
14130 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
14142 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
14146 !NewFT->getExtParameterInfo(I).isNoEscape()) {
14148 diag::warn_overriding_method_missing_noescape);
14150 diag::note_overridden_marked_noescape);
14157 if (NewCC == OldCC)
14168 diag::err_conflicting_overriding_cc_attributes)
14194 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
14202 if (NewClassTy.
isNull()) {
14204 diag::err_different_return_type_for_overriding_virtual_function)
14220 if (!RT->isBeingDefined() &&
14221 RequireCompleteType(New->
getLocation(), NewClassTy,
14222 diag::err_covariant_return_incomplete,
14228 if (!IsDerivedFrom(New->
getLocation(), NewClassTy, OldClassTy)) {
14238 if (CheckDerivedToBaseConversion(
14239 NewClassTy, OldClassTy,
14240 diag::err_covariant_return_inaccessible_base,
14241 diag::err_covariant_return_ambiguous_derived_to_base_conv,
14257 diag::err_covariant_return_type_different_qualifications)
14269 diag::err_covariant_return_type_class_type_more_qualified)
14304 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
14305 CheckPureMethod(M, ZeroLoc);
14313 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
14314 return Var->hasGlobalStorage();
14342 PushExpressionEvaluationContext(
14343 ExpressionEvaluationContext::PotentiallyEvaluated, D);
14353 PopExpressionEvaluationContext();
14356 ExitDeclaratorContext(S);
14368 "Parser allowed 'typedef' as storage class of condition decl.");
14370 Decl *Dcl = ActOnDeclarator(S, D);
14374 if (isa<FunctionDecl>(Dcl)) {
14375 Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
14384 if (!ExternalSource)
14388 ExternalSource->ReadUsedVTables(VTables);
14390 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
14391 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
14392 = VTablesUsed.find(VTables[I].Record);
14394 if (Pos != VTablesUsed.end()) {
14395 if (!Pos->second && VTables[I].DefinitionRequired)
14396 Pos->second =
true;
14400 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
14401 NewUses.push_back(
VTableUse(VTables[I].Record, VTables[I].Location));
14404 VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end());
14408 bool DefinitionRequired) {
14412 CurContext->isDependentContext() || isUnevaluatedContext())
14416 LoadExternalVTableUses();
14418 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
14419 Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
14424 if (DefinitionRequired && !Pos.first->second) {
14425 Pos.first->second =
true;
14443 CheckDestructor(DD);
14455 MarkVirtualMembersReferenced(Loc, Class);
14457 VTableUses.push_back(std::make_pair(Class, Loc));
14461 LoadExternalVTableUses();
14462 if (VTableUses.empty())
14469 bool DefinedAnything =
false;
14470 for (
unsigned I = 0; I != VTableUses.size(); ++I) {
14479 bool DefineVTable =
true;
14485 if (KeyFunction && !KeyFunction->
hasBody()) {
14487 DefineVTable =
false;
14492 "Instantiations don't have key functions");
14494 }
else if (!KeyFunction) {
14499 bool IsExplicitInstantiationDeclaration =
14501 for (
auto R : Class->
redecls()) {
14505 IsExplicitInstantiationDeclaration =
true;
14507 IsExplicitInstantiationDeclaration =
false;
14512 if (IsExplicitInstantiationDeclaration)
14513 DefineVTable =
false;
14519 if (!DefineVTable) {
14520 MarkVirtualMemberExceptionSpecsNeeded(Loc, Class);
14527 DefinedAnything =
true;
14528 MarkVirtualMembersReferenced(Loc, Class);
14530 if (VTablesUsed[Canonical])
14531 Consumer.HandleVTable(Class);
14539 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
14543 ? diag::warn_weak_template_vtable
14544 : diag::warn_weak_vtable)
14549 VTableUses.clear();
14551 return DefinedAnything;
14556 for (
const auto *I : RD->
methods())
14557 if (I->isVirtual() && !I->isPure())
14566 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
14567 E = FinalOverriders.end();
14570 OE = I->second.end();
14572 assert(OI->second.size() > 0 &&
"no final overrider");
14577 if (!Overrider->isPure())
14578 MarkFunctionReferenced(Loc, Overrider);
14586 for (
const auto &I : RD->
bases()) {
14588 cast<CXXRecordDecl>(I.getType()->getAs<
RecordType>()->getDecl());
14591 MarkVirtualMembersReferenced(Loc, Base);
14602 CollectIvarsToConstructOrDestruct(OID, ivars);
14606 for (
unsigned i = 0; i < ivars.size(); i++) {
14618 InitSeq.Perform(*
this, InitEntity, InitKind,
None);
14619 MemberInit = MaybeCreateExprWithCleanups(MemberInit);
14630 AllToInit.push_back(Member);
14635 ->getAs<RecordType>()) {
14636 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
14638 MarkFunctionReferenced(Field->
getLocation(), Destructor);
14639 CheckDestructorAccess(Field->
getLocation(), Destructor,
14640 PDiag(diag::err_access_dtor_ivar)
14646 AllToInit.data(), AllToInit.size());
14652 llvm::SmallSet<CXXConstructorDecl*, 4> &Valid,
14653 llvm::SmallSet<CXXConstructorDecl*, 4> &Invalid,
14654 llvm::SmallSet<CXXConstructorDecl*, 4> &Current,
14665 (void)Target->
hasBody(FNTarget);
14667 cast_or_null<CXXConstructorDecl>(FNTarget));
14674 if (!Current.insert(Canonical).second)
14680 Valid.insert(Current.begin(), Current.end());
14683 }
else if (TCanonical == Canonical || Invalid.count(TCanonical) ||
14684 Current.count(TCanonical)) {
14686 if (!Invalid.count(TCanonical)) {
14688 diag::warn_delegating_ctor_cycle)
14692 if (TCanonical != Canonical)
14699 assert(FNTarget &&
"Ctor cycle through bodiless function");
14702 cast<CXXConstructorDecl>(FNTarget));
14707 Invalid.insert(Current.begin(), Current.end());
14716 llvm::SmallSet<CXXConstructorDecl*, 4> Valid, Invalid, Current;
14718 for (DelegatingCtorDeclsType::iterator
14719 I = DelegatingCtorDecls.begin(ExternalSource),
14720 E = DelegatingCtorDecls.end();
14724 for (llvm::SmallSet<CXXConstructorDecl *, 4>::iterator CI = Invalid.begin(),
14725 CE = Invalid.end();
14727 (*CI)->setInvalidDecl();
14736 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
14764 FindCXXThisExpr Finder(*
this);
14772 if (checkThisInStaticMemberFunctionExceptionSpec(Method))
14775 return checkThisInStaticMemberFunctionAttributes(Method);
14789 FindCXXThisExpr Finder(*
this);
14808 if (!Finder.TraverseType(E))
14818 FindCXXThisExpr Finder(*
this);
14821 for (
const auto *A : Method->
attrs()) {
14823 Expr *Arg =
nullptr;
14825 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
14827 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
14829 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
14830 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
14831 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
14832 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
14833 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
14834 Arg = ETLF->getSuccessValue();
14835 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
14836 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
14837 Arg = STLF->getSuccessValue();
14838 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
14839 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
14840 Arg = LR->getArg();
14841 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
14842 Args = llvm::makeArrayRef(LE->args_begin(), LE->args_size());
14843 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
14844 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
14845 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
14846 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
14847 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
14848 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
14849 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
14850 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
14852 if (Arg && !Finder.TraverseStmt(Arg))
14855 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
14856 if (!Finder.TraverseStmt(Args[I]))
14870 Exceptions.clear();
14873 Exceptions.reserve(DynamicExceptions.size());
14874 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
14876 QualType ET = GetTypeFromParser(DynamicExceptions[ei]);
14881 if (!Unexpanded.empty()) {
14883 DynamicExceptionRanges[ei].getBegin(), UPPC_ExceptionType,
14891 if (!CheckSpecifiedExceptionType(ET, DynamicExceptionRanges[ei]))
14892 Exceptions.push_back(ET);
14900 if (NoexceptExpr) {
14904 "Parser should have made sure that the expression is boolean");
14905 if (IsTopLevel && NoexceptExpr &&
14906 DiagnoseUnexpandedParameterPack(NoexceptExpr)) {
14913 NoexceptExpr,
nullptr, diag::err_noexcept_needs_constant_expression,
14919 NoexceptExpr = Result.
get();
14932 Expr *NoexceptExpr) {
14938 MethodD = FunTmpl->getTemplatedDecl();
14947 checkExceptionSpecification(
true, EST, DynamicExceptions,
14948 DynamicExceptionRanges, NoexceptExpr, Exceptions,
14955 checkThisInStaticMemberFunctionExceptionSpec(Method);
14960 CheckOverridingFunctionExceptionSpec(Method, O);
14974 Diag(DeclStart, diag::err_anonymous_property);
14982 CheckExtraCXXDefaultArguments(D);
14985 UPPC_DataMemberType)) {
14996 << getLangOpts().CPlusPlus17;
14999 diag::err_invalid_thread)
15005 ForVisibleRedeclaration);
15006 LookupName(Previous, S);
15027 PrevDecl =
nullptr;
15030 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
15031 PrevDecl =
nullptr;
15037 ProcessDeclAttributes(TUScope, NewPD, D);
15050 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.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
static bool checkMemberDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const CXXRecordDecl *RD)
A call to an overloaded operator written using operator syntax.
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl)
NamespaceDecl * lookupStdExperimentalNamespace()
void setSourceOrder(int Pos)
Set the source order of this initializer.
Defines the clang::ASTContext interface.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
bool isCallToStdMove() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
An instance of this class is created to represent a function declaration or definition.
static StmtResult buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying, unsigned Depth=0)
Builds a statement that copies/moves the given entity from From to To.
static void CheckForDanglingReferenceOrPointer(Sema &S, ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
Checks a member initializer expression for cases where reference (or pointer) members are bound to by...
Name lookup found a set of overloaded functions that met the criteria.
NamespaceDecl * getStdNamespace() const
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Expr * getInit() const
Get the initializer.
const Stmt * getElse() const
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void setOrigin(CXXRecordDecl *Rec)
CXXMethodDecl * getMethod() const
no exception specification
const TypeClass * getTypePtr() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool isOverloadedOperator() const
isOverloadedOperator - Whether this function declaration represents an C++ overloaded operator...
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static bool checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, bool ConstArg, bool Diagnose)
Check whether the members of a class type allow a special member to be trivial.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
AttributeList * getNext() const
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.
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.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
const Expr * getInit(unsigned Init) const
The subobject is a base class.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
static UsingPackDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> UsingDecls)
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
static unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
Decl * Entity
The entity that is being synthesized.
Expr *const * semantics_iterator
static ClassTemplateDecl * LookupStdInitializerList(Sema &S, SourceLocation Loc)
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
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.
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
bool isRealFloatingType() const
Floating point categories.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
StmtResult ActOnExprStmt(ExprResult Arg)
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class...
static CharSourceRange getTokenRange(SourceRange R)
void addConst()
Add the const type qualifier to this QualType.
ActionResult< Expr * > ExprResult
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.
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.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
static bool FindBaseInitializer(Sema &SemaRef, CXXRecordDecl *ClassDecl, QualType BaseType, const CXXBaseSpecifier *&DirectBaseSpec, const CXXBaseSpecifier *&VirtualBaseSpec)
Find the direct and/or virtual base specifiers that correspond to the given base type, for use in base initialization within a constructor.
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)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
bool isOverrideSpecified() const
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static bool isVirtualDirectBase(CXXRecordDecl *Derived, CXXRecordDecl *Base)
Determine whether a direct base class is a virtual base class.
void EvaluateImplicitExceptionSpec(SourceLocation Loc, CXXMethodDecl *MD)
Evaluate the implicit exception specification for a defaulted special member function.
A constructor named via a template-id.
bool isExplicitSpecialization() const
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this field is ...
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.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
One instance of this struct is used for each type in a declarator that is parsed. ...
Declaration of a variable template.
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
NamespaceDecl - 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...
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
NamedDecl * getParam(unsigned Idx)
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
QualType withConst() const
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
const TargetInfo & getTargetInfo() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
const NestedNameSpecifier * Specifier
RefQualifierKind RefQualifier
A container of type source information.
Floating point control options.
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 is defined at all, including a deleted definition.
TSCS getThreadStorageClassSpec() const
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
SourceLocation getLocEnd() const LLVM_READONLY
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Abstract base class used for diagnosing integer constant expression violations.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
unsigned getIdentifierNamespace() const
Represents a C++ constructor within a class.
bool implicitCopyAssignmentHasConstParam() const
Determine whether an implicit copy assignment operator for this type would have a parameter with a co...
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class...
size_t param_size() const
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
SourceLocation getOverrideLoc() const
QualType getElementType() const
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
void CheckCXXDefaultArguments(FunctionDecl *FD)
CheckCXXDefaultArguments - Verify that the default arguments for a function declaration are well-form...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
RAII object to handle the state changes required to synthesize a function body.
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> Expansions)
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
void ActOnFinishCXXNonNestedClass(Decl *D)
This file provides some common utility functions for processing Lambda related AST Constructs...
std::list< CXXBasePath >::iterator paths_iterator
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
RAII object that enters a new expression evaluation context.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
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
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
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.
RAII class that determines when any errors have occurred between the time the instance was created an...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
SourceLocation getFinalLoc() const
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.
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
ParmVarDecl - Represents a parameter to a function.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
Defines the clang::Expr interface and subclasses for C++ expressions.
Parse and apply any fixits to the source.
AttributeList * getList() const
void removeDecl(Decl *D)
Removes a declaration from this context.
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
isAnonymousStructOrUnion - Determines whether this field is a representative for an anonymous struct ...
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
getIdentifier - 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.
RecordDecl - Represents a struct/union/class.
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, AttributeList *AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
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
getDeclName - 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.
static bool IsUsingDirectiveInToplevelContext(DeclContext *CurContext)
Determine whether a using statement is in a context where it will be apply in all contexts...
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
void setRecordingPaths(bool RP)
Specify whether we should be recording paths or not.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
void setUninstantiatedDefaultArg(Expr *arg)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
A C++ nested-name-specifier augmented with source location information.
bool isInline() const
Returns true if this is an inline namespace declaration.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ArrayRef< QualType > getParamTypes() const
The results of name lookup within a DeclContext.
SourceLocation getTypeSpecTypeLoc() const
TypeSourceInfo * getTypeSourceInfo() const
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
static CXXConstructExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr *> Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
SourceLocation getLocStart() const LLVM_READONLY
field_range fields() const
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, ParsedAttributes &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info, FieldDecl *Field, IndirectFieldDecl *Indirect=nullptr)
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
const PropertyData & getPropertyData() const
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
NoexceptResult
Result type of getNoexceptSpec().
bool isAbstractType(SourceLocation Loc, QualType T)
static bool isIncrementDecrementOp(Opcode Op)
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned The qualifier bitmask values are the same as...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
bool isFunctionDefinition() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getExprLoc() const LLVM_READONLY
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
bool isReferenceType() const
CXXRecordDecl * getStdBadAlloc() const
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class.copy]p25)
void setElaboratedKeywordLoc(SourceLocation Loc)
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
The iterator over UnresolvedSets.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
static void extendLeft(SourceRange &R, SourceRange Before)
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
ParmVarDecl * getParam(unsigned i) const
unsigned getTypeQualifiers() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const
Make an APSInt of the appropriate width and signedness for the given Value and integer Type...
SourceLocation getLocStart() const LLVM_READONLY
static bool CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S, SmallVectorImpl< SourceLocation > &ReturnStmts, SourceLocation &Cxx1yLoc)
Check the provided statement is allowed in a constexpr function definition.
LookupResultKind getResultKind() const
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
Represents an access specifier followed by colon ':'.
void ClearStorageClassSpecs()
void addShadowDecl(UsingShadowDecl *S)
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
SourceLocation getTemplateLoc() const
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
A user-defined literal name, e.g., operator "" _i.
unsigned getTypeQuals() const
SpecialMemberOverloadResult - The overloading result for a special member function.
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
void setImplicitCopyConstructorIsDeleted()
Set that we attempted to declare an implicit copy constructor, but overload resolution failed so we d...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
ArrayRef< ParmVarDecl * > parameters() const
DeclClass * getAsSingle() const
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl *> &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
bool isFinalSpelledSealed() const
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, DeclStmt *DS, SourceLocation &Cxx1yLoc)
Check the given declaration statement is legal within a constexpr function body.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
Describes an C or C++ initializer list.
Represents a C++ using-declaration.
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.
bool isBitField() const
Determines whether this field is a bitfield.
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...
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.
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.
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
SourceLocation getEndLoc() const
getEndLoc - Retrieve the location of the last token.
static bool BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, FieldDecl *Field, IndirectFieldDecl *Indirect, CXXCtorInitializer *&CXXMemberInit)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
const clang::PrintingPolicy & getPrintingPolicy() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
static void NoteIndirectBases(ASTContext &Context, IndirectBaseSet &Set, const QualType &Type)
Recursively add the bases of Type. Don't add Type itself.
semantics_iterator semantics_end()
SourceLocation getLocStart() const LLVM_READONLY
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier *> Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
TypeDecl - Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt *> Stmts, SourceLocation LB, SourceLocation RB)
void CheckDelegatingCtorCycles()
QualType getExceptionObjectType(QualType T) const
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
static void ReferenceDllExportedMethods(Sema &S, CXXRecordDecl *Class)
enum clang::DeclaratorChunk::@198 Kind
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)
DeclContextLookupResult slice(size_t N) const
bool isLambda() const
Determine whether this class describes a lambda function object.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, const ASTContext *Context=nullptr) const
Scope - A scope is a transient data structure that is used while parsing the program.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
field_iterator field_begin() const
param_type_iterator param_type_begin() const
unsigned getBitWidthValue(const ASTContext &Ctx) const
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
bool hasUnparsedDefaultArg() const
hasUnparsedDefaultArg - Determines whether this parameter has a default argument that has not yet bee...
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
SourceLocation getLocStart() const LLVM_READONLY
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getConstSpecLoc() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
static bool findCircularInheritance(const CXXRecordDecl *Class, const CXXRecordDecl *Current)
Determine whether the given class is a base class of the given class, including looking at dependent ...
static void DelegatingCycleHelper(CXXConstructorDecl *Ctor, llvm::SmallSet< CXXConstructorDecl *, 4 > &Valid, llvm::SmallSet< CXXConstructorDecl *, 4 > &Invalid, llvm::SmallSet< CXXConstructorDecl *, 4 > &Current, Sema &S)
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
An ordinary object is located at an address in memory.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification, including the language and (if present) the '{'.
Represents an ObjC class declaration.
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
Represents a linkage specification.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
SourceRange getSourceRange() const LLVM_READONLY
bool isAbstract() const
Determine whether this class has a pure virtual function.
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
unsigned getNumArgs() const
A binding in a decomposition declaration.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
init_iterator init_begin()
Retrieve an iterator to the first initializer.
IdentifierInfo * getIdentifier() const
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)
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
param_iterator param_begin()
Represents the this expression in C++.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, UsingDecl *UD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
static bool isValidUDSuffix(const LangOptions &LangOpts, StringRef Suffix)
Determine whether a suffix is a valid ud-suffix.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
ExtInfo withCallingConv(CallingConv cc) const
static StmtResult buildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying)
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
void removeInClassInitializer()
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...
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.
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.
Sema - This implements semantic analysis and AST building for C.
Decl * ActOnEmptyDeclaration(Scope *S, AttributeList *AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
StringRef getString() const
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool isDynamicClass() const
void ClearConstexprSpec()
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
static unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
A RAII object to enter scope of a compound statement.
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Represents a ValueDecl that came out of a declarator.
SourceRange getLocalSourceRange() const
Get the local source range.
static Sema::ImplicitExceptionSpecification ComputeDefaultedSpecialMemberExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD, Sema::CXXSpecialMember CSM, Sema::InheritedConstructorInfo *ICI)
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclarationNameTable DeclarationNames
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
bool 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)
setInClassInitializer - Set the C++11 in-class initializer for this member.
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared...
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
TST getTypeSpecType() const
static void diagnoseDeprecatedCopyOperation(Sema &S, CXXMethodDecl *CopyOp)
Diagnose an implicit copy operation for a class which is odr-used, but which is deprecated because th...
bool hasKeyFunctions() const
Does this ABI use key functions? If so, class data such as the vtable is emitted with strong linkage ...
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
static Sema::SpecialMemberOverloadResult lookupCallFromSpecialMember(Sema &S, CXXRecordDecl *Class, Sema::CXXSpecialMember CSM, unsigned FieldQuals, bool ConstRHS)
Look up the special member function that would be called by a special member function for a subobject...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMember > SpecialMemberDecl
bool isMsStruct(const ASTContext &C) const
Get whether or not this is an ms_struct which can be turned on with an attribute, pragma...
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...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
StringRef getKindName() const
QualType getPointeeType() const
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isVariadic() const
Whether this function is variadic.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
llvm::StringRef getAsString(SyncScope S)
bool isExplicitSpecified() const
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.
const FunctionProtoType * T
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
Declaration of a template type parameter.
unsigned getIndex() const
DeclContext * getEntity() const
bool defaultedMoveConstructorIsDeleted() const
true if a defaulted move constructor for this class would be deleted.
DeclarationNameInfo getNameInfo() const
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
const Stmt * getThen() const
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
void setRBraceLoc(SourceLocation L)
static bool checkVectorDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const VectorType *VT)
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
OpaquePtr< T > get() const
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
SourceLocation getLocation() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
void freeParams()
Reset the parameter list to having zero parameters.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
unsigned getNumInits() const
static unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
SourceLocation getVolatileSpecLoc() const
SourceLocation getThreadStorageClassSpecLoc() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
const Expr * getCallee() const
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
void setRBraceLoc(SourceLocation L)
Defines the clang::Preprocessor interface.
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
field_iterator field_end() const
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
overridden_method_range overridden_methods() const
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
bool isFileContext() const
SourceLocation getBeginLoc() const
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, AttributeList *Attrs=nullptr)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
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...
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 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.
There is no noexcept specifier.
SourceLocation getLocStart() const LLVM_READONLY
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
void DiscardCleanupsInEvaluationContext()
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
void setInheritConstructors(bool Inherit=true)
Set that this base class's constructors should be inherited.
SourceLocation getLocEnd() const LLVM_READONLY
bool isFunctionOrMethod() const
static bool isPotentialConstantExpr(const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExpr - Return true if this function's definition might be usable in a constant exp...
StorageClass
Storage classes.
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void CheckCompletedCXXClass(CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl, CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
InClassInitStyle
In-class initialization styles for non-static data members.
Declaration of an alias template.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for record diagnostic message.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool isFriendSpecified() const
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
void addContextNote(SourceLocation UseLoc)
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class...
void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an initializer for the declaration ...
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
Represents a C++ deduction guide declaration.
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
SourceLocation getLocEnd() const LLVM_READONLY
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
static void PopulateKeysForFields(FieldDecl *Field, SmallVectorImpl< const void *> &IdealInits)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class.copy]p25)
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
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)
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
static bool computeCanPassInRegisters(Sema &S, CXXRecordDecl *D)
Determine whether a type is permitted to be passed or returned in registers, per C++ [class...
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, AttributeList *AttrList)
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
ExprResult ActOnFinishFullExpr(Expr *Expr)
bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body)
Check the body for the given constexpr function declaration only contains the permitted types of stat...
#define CheckPolymorphic(Type)
CanQualType getCanonicalTypeUnqualified() const
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasGroupingParens() const
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool hasTrailingReturn() const
RecordDecl * getDecl() const
bool hasVariantMembers() const
Determine whether this class has any variant members.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
IdentifierInfo * SetterId
unsigned size_overridden_methods() const
static void SearchForReturnInStmt(Sema &Self, Stmt *S)
Wrapper for source info for arrays.
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter...
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
Decl::Kind getDeclKind() const
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
static bool CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef, const FunctionDecl *FnDecl)
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
static unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
We are declaring an implicit special member function.
CXXSpecialMember SpecialMember
The special member being declared or defined.
static CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
Represents a call to an inherited base class constructor from an inheriting constructor.
static const CXXRecordDecl * findDecomposableBaseClass(Sema &S, SourceLocation Loc, const CXXRecordDecl *RD, CXXCastPath &BasePath)
Find the base class to decompose in a built-in decomposition of a class type.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ExceptionSpecificationType Type
The kind of exception specification this is.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
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
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)
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, AttributeList *AttrList, bool IsInstantiation)
Builds a using declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
llvm::SmallPtrSet< QualType, 4 > IndirectBaseSet
Use small set to collect indirect bases.
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
Encodes a location in the source.
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
bool hasSameTemplateName(TemplateName X, TemplateName Y)
Determine whether the given template names refer to the same template.
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
unsigned getNumHandlers() const
decl_iterator decls_begin() const
Expr * getSubExpr() const
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
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.
TagDecl - Represents the declaration of a struct/union/class/enum.
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
void referenceDLLExportedClassMethods()
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)
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)
IdentifierTable & getIdentifierTable()
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error...
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
Represents a dependent using declaration which was not marked with typename.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
const DecompositionDeclarator & getDecompositionDeclarator() const
void removeShadowDecl(UsingShadowDecl *S)
void setCtorInitializers(CXXCtorInitializer **Initializers)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Represents a static or instance method of a struct/union/class.
void setDefaulted(bool D=true)
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
ExprResult DefaultLvalueConversion(Expr *E)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
void setEntity(DeclContext *E)
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckForFunctionMarkedFinal - Checks whether a virtual member function overrides a virtual member fun...
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
const ParmVarDecl * getParamDecl(unsigned i) const
bool isUsualDeallocationFunction() const
Determine whether this is a usual deallocation function (C++ [basic.stc.dynamic.deallocation]p2), which is an overloaded delete or delete[] operator with a particular signature.
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
void setImplicitMoveConstructorIsDeleted()
Set that we attempted to declare an implicit move constructor, but overload resolution failed so we d...
SourceLocation getLocation() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Name lookup found an unresolvable value declaration and cannot yet complete.
Expr * getNoexceptExpr() const
static CXXBaseSpecifier * findDirectBaseWithType(CXXRecordDecl *Derived, QualType DesiredBase, bool &AnyDependentBases)
Find the base specifier for a base class with the given type.
void actOnDelayedExceptionSpecification(Decl *Method, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member function (or member function template).
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
Decl * ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
bool isObjCObjectPointerType() const
A class for iterating through a result set and possibly filtering out results.
Direct list-initialization.
Represents a C++11 virt-specifier-seq.
static CXXDefaultInitExpr * Create(const ASTContext &C, SourceLocation Loc, FieldDecl *Field)
Field is the non-static data member whose default initializer is used by this expression.
static ConstructorUsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target, bool IsVirtual)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
bool isFunctionProtoType() const
void CheckExplicitlyDefaultedMemberExceptionSpec(CXXMethodDecl *MD, const FunctionProtoType *T)
Check whether the exception specification provided for an explicitly-defaulted special member matches...
static bool checkSimpleDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType, llvm::function_ref< ExprResult(SourceLocation, Expr *, unsigned)> GetInit)
void setIsParsingBaseSpecifiers()
bool hasUninstantiatedDefaultArg() const
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList *> Params, FriendUnion Friend, SourceLocation FriendLoc)
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.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, AttributeList *AttrList)
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang)
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
SourceLocation getRAngleLoc() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
SourceLocation getInlineSpecLoc() const
IdentifierInfo * GetterId
SourceLocation getLocStart() const LLVM_READONLY
void setExplicitlyDefaulted(bool ED=true)
void setHasInheritedDefaultArg(bool I=true)
bool hasFlexibleArrayMember() const
bool defaultedCopyConstructorIsDeleted() const
true if a defaulted copy constructor for this class would be deleted.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
MutableArrayRef< Expr * > MultiExprArg
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 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.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, AttributeList *AttrList)
TypeLoc getElementLoc() const
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
SourceLocation getLastLocation() const
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
CXXConstructorDecl * getConstructor() const
StringRef getName() const
Return the actual identifier string.
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
static AttributeList * getMSPropertyAttr(AttributeList *list)
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.
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
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Dataflow Directional Tag Classes.
SourceLocation getLocStart() const LLVM_READONLY
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
bool isExplicit() const
Whether this function is explicit.
bool isValid() const
Return true if this is a valid SourceLocation object.
void setImplicitlyInline()
Flag that this function is implicitly inline.
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
const TemplateArgument & getArgument() const
not evaluated yet, for special member function
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static const TST TST_auto
method_iterator begin_overridden_methods() const
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
static void AddMostOverridenMethods(const CXXMethodDecl *MD, llvm::SmallPtrSetImpl< const CXXMethodDecl *> &Methods)
Add the most overriden methods from MD to Methods.
QualType getType() const
Get the type for which this source info wrapper provides information.
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
SourceLocation getLocStart() const LLVM_READONLY
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
static bool InitializationHasSideEffects(const FieldDecl &FD)
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
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)
void setWillHaveBody(bool V=true)
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
DeclarationName - The name of a declaration.
StmtClass getStmtClass() const
ArrayRef< QualType > exceptions() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
A mapping from each virtual member function to its set of final overriders.
SourceLocation getLocStart() const LLVM_READONLY
unsigned getNumTemplateParameterLists() const
EnumDecl - Represents an enum.
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i...
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
semantics_iterator semantics_begin()
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
static unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
void PushUsingDirective(UsingDirectiveDecl *UDir)
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
std::pair< CXXConstructorDecl *, bool > findConstructorForBase(CXXRecordDecl *Base, CXXConstructorDecl *Ctor) const
Find the constructor to use for inherited construction of a base class, and whether that base class c...
unsigned getNumParams() const
void setNameLoc(SourceLocation Loc)
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
const FunctionDecl * getOperatorDelete() const
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
static FunctionProtoType::ExtProtoInfo getImplicitMethodEPI(Sema &S, CXXMethodDecl *MD)
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
Name lookup found a single declaration that met the criteria.
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class...
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool isIncompleteArrayType() const
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, AttributeList *AttrList, UsingDirectiveDecl *&UsingDecl)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
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()
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 ...
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
isStaticLocal - 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.
The noexcept specifier evaluates to false.
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.
ActionResult< Stmt * > StmtResult
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.
ActionResult< ParsedType > TypeResult
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
void addDecl(Decl *D)
Add the declaration D into this context.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Represents a base class of a C++ class.
bool hasTypename() const
Return true if the using declaration has 'typename'.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
This is a scope that can contain a declaration.
bool isObjCObjectType() const
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static const void * GetKeyForMember(ASTContext &Context, CXXCtorInitializer *Member)
A use of a default initializer in a constructor or in aggregate initialization.
EnumDecl * getStdAlignValT() const
bool isSet() const
Deprecated.
bool isLValueReferenceType() const
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
void setInvalidType(bool Val=true)
Expr * NoexceptExpr
Noexcept expression, if this is EST_ComputedNoexcept.
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
QualType getParamType(unsigned i) const
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
TranslationUnitDecl * getTranslationUnitDecl() const
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
void Deallocate(void *Ptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static bool functionDeclHasDefaultArgument(const FunctionDecl *FD)
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
CallingConv getCallConv() const
ThreadStorageClassSpecifier
Thread storage-class-specifier.
void setImplicitMoveAssignmentIsDeleted()
Set that we attempted to declare an implicit move assignment operator, but overload resolution failed...
Describes the sequence of initializations required to initialize a given object or reference with a s...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Captures information about "declaration specifiers".
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
isMutable - 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.
The parameter type of a method or function.
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.
static bool hasOneRealArgument(MultiExprArg Args)
Determine whether the given list arguments contains exactly one "real" (non-default) argument...
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
static unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void setUnsupportedFriend(bool Unsupported)
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
Declaration of a class template.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool isVirtualSpecified() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
SourceManager & getSourceManager() const
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
A template-id, e.g., f<int>.
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant, according to C++ [class.virtual]p5.
static bool checkTrivialSubobjectCall(Sema &S, SourceLocation SubobjLoc, QualType SubType, bool ConstRHS, Sema::CXXSpecialMember CSM, TrivialSubobjectKind Kind, bool Diagnose)
Check whether the special member selected for a given type would be trivial.
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 - that is, if it is a non-delete...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
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.
TranslationUnitDecl - The top declaration context.
SourceLocation getExplicitSpecLoc() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
SourceLocation getConstexprSpecLoc() const
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD)
Diagnose methods which overload virtual methods in a base class without overriding any...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool implicitCopyConstructorHasConstParam() const
Determine whether an implicit copy constructor for this type would have a parameter with a const-qual...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
static bool findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, CXXMethodDecl **Selected)
Perform lookup for a special member of the specified kind, and determine whether it is trivial...
void setCanPassInRegisters(bool CanPass)
Set that we can pass this RecordDecl in registers.
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
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
bool hasDirectFields() const
Determine whether this class has direct non-static data members.
An instance of this class represents the declaration of a property member.
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
NoexceptResult getNoexceptSpec(const ASTContext &Ctx) const
Get the meaning of the noexcept spec on this function, if any.
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.
NamedDecl - This represents a decl with 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.
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.
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.
The noexcept specifier is dependent.
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.
SourceLocation getLocStart() const LLVM_READONLY
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())
Wrapper for source info for pointers.
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
SourceRange getSourceRange() const LLVM_READONLY
const LangOptions & getLangOpts() const
void WillReplaceSpecifier(bool ForceReplacement)
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
Wrapper for source info for block pointers.
void setDeletedAsWritten(bool D=true)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions, such as the default constructor, copy constructor, or destructor, to the given C++ class (C++ [special]p1).
An implicit 'self' parameter.
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
ExceptionSpecInfo ExceptionSpec
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
A deduction-guide name (a template-name)
Declaration of a template function.
void clear()
Clears out any current state.
Represents an implicitly-generated value initialization of an object of a given type.
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, AttributeList *MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
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)
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
isBeingDefined - Return true if this decl is currently being defined.
ConstructorUsingShadowDecl * getShadowDecl() const
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
AttributeList - Represents a syntactic attribute.
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
decl_iterator decls_end() const
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
static unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
param_type_iterator param_type_end() const
unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template)
static void DiagnoseNamespaceInlineMismatch(Sema &S, SourceLocation KeywordLoc, SourceLocation Loc, IdentifierInfo *II, bool *IsInline, NamespaceDecl *PrevNS)
Diagnose a mismatch in 'inline' qualifiers when a namespace is reopened.
method_range methods() const
The subobject is a non-static data member.
QualType getType() const
Retrieves the type of the base class.
bool defaultedDestructorIsDeleted() const
true if a defaulted destructor for this class would be deleted.