41 #include "llvm/ADT/STLExtras.h" 42 #include "llvm/ADT/SmallString.h" 43 #include "llvm/ADT/StringExtras.h" 47 using namespace clang;
59 class CheckDefaultArgumentVisitor
60 :
public StmtVisitor<CheckDefaultArgumentVisitor, bool> {
65 CheckDefaultArgumentVisitor(
Expr *defarg,
Sema *s)
66 : DefaultArg(defarg), S(s) {}
76 bool CheckDefaultArgumentVisitor::VisitExpr(
Expr *
Node) {
77 bool IsInvalid =
false;
79 IsInvalid |= Visit(SubStmt);
86 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
DeclRefExpr *DRE) {
88 if (
ParmVarDecl *Param = dyn_cast<ParmVarDecl>(Decl)) {
98 diag::err_param_default_argument_references_param)
99 << Param->getDeclName() << DefaultArg->getSourceRange();
100 }
else if (
VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) {
104 if (VDecl->isLocalVarDecl())
106 diag::err_param_default_argument_references_local)
107 << VDecl->getDeclName() << DefaultArg->getSourceRange();
114 bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
CXXThisExpr *ThisE) {
119 diag::err_param_default_argument_references_this)
123 bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
PseudoObjectExpr *POE) {
131 E = OVE->getSourceExpr();
132 assert(E &&
"pseudo-object binding without source expression?");
140 bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
LambdaExpr *Lambda) {
147 return S->
Diag(Lambda->
getBeginLoc(), diag::err_lambda_capture_default_arg);
160 Proto = Self->ResolveExceptionSpec(CallLoc, Proto);
177 llvm_unreachable(
"should not see unresolved exception specs here");
205 "should not generate implicit declarations for dependent cases");
209 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
211 "Shouldn't collect exceptions when throw-all is guaranteed.");
215 if (ExceptionsSeen.insert(Self->Context.getCanonicalType(E)).second)
216 Exceptions.push_back(E);
244 if (Self->canThrow(E))
252 diag::err_typecheck_decl_incomplete_type)) {
273 CheckCompletedExpr(Arg, EqualLoc);
274 Arg = MaybeCreateExprWithCleanups(Arg);
281 UnparsedDefaultArgInstantiationsMap::iterator InstPos
282 = UnparsedDefaultArgInstantiations.find(Param);
283 if (InstPos != UnparsedDefaultArgInstantiations.end()) {
284 for (
unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
285 InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
288 UnparsedDefaultArgInstantiations.erase(InstPos);
300 if (!param || !DefaultArg)
304 UnparsedDefaultArgLocs.erase(Param);
308 Diag(EqualLoc, diag::err_param_default_argument)
315 if (DiagnoseUnexpandedParameterPack(DefaultArg, UPPC_DefaultArgument)) {
324 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
330 CheckDefaultArgumentVisitor DefaultArgChecker(DefaultArg,
this);
331 if (DefaultArgChecker.Visit(DefaultArg)) {
336 SetParamDefaultArgument(Param, DefaultArg, EqualLoc);
351 UnparsedDefaultArgLocs[Param] = ArgLoc;
363 UnparsedDefaultArgLocs.erase(Param);
387 if (MightBeFunction) {
391 MightBeFunction =
false;
394 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
398 std::unique_ptr<CachedTokens> Toks =
401 if (Toks->size() > 1)
403 Toks->back().getLocation());
405 SR = UnparsedDefaultArgLocs[Param];
415 MightBeFunction =
false;
421 for (
unsigned NumParams = FD->
getNumParams(); NumParams > 0; --NumParams) {
437 bool Invalid =
false;
448 for (; PrevForDefaultArgs;
458 if (S && !isDeclInScope(PrevForDefaultArgs, ScopeDC, S) &&
496 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
499 p < NumParams; ++p) {
503 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
506 if (OldParamHasDfl && NewParamHasDfl) {
507 unsigned DiagDefaultParamID =
508 diag::err_param_default_argument_redefinition;
513 if (getLangOpts().MicrosoftExt) {
523 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
541 for (
auto Older = PrevForDefaultArgs;
543 Older = Older->getPreviousDecl();
544 OldParam = Older->getParamDecl(p);
549 }
else if (OldParamHasDfl) {
567 }
else if (NewParamHasDfl) {
571 diag::err_param_default_argument_template_redecl)
574 diag::note_template_prev_declaration)
605 if (Record->getDescribedClassTemplate())
607 else if (isa<ClassTemplatePartialSpecializationDecl>(Record))
614 diag::err_param_default_argument_member_template_redecl)
624 if (isa<CXXConstructorDecl>(New) &&
627 OldSM = getSpecialMember(cast<CXXMethodDecl>(Old));
628 if (NewSM != OldSM) {
631 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
657 Diag(Def->getLocation(), diag::note_previous_definition);
665 if (NewGuide && NewGuide->isExplicitSpecified() !=
666 cast<CXXDeductionGuideDecl>(Old)->isExplicitSpecified()) {
668 << NewGuide->isExplicitSpecified();
678 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
696 Diag(Decomp.getLSquareLoc(), diag::err_decomp_decl_context)
697 << Decomp.getSourceRange();
701 if (!TemplateParamLists.empty()) {
704 Diag(TemplateParamLists.front()->getTemplateLoc(),
705 diag::err_decomp_decl_template);
709 Diag(Decomp.getLSquareLoc(),
710 !getLangOpts().CPlusPlus17
711 ? diag::ext_decomp_decl
713 ? diag::ext_decomp_decl_cond
714 : diag::warn_cxx14_compat_decomp_decl)
715 << Decomp.getSourceRange();
727 if (
auto SCS = DS.getStorageClassSpec()) {
729 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
731 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
733 BadSpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
735 if (DS.isConstexprSpecified()) {
736 BadSpecifiers.push_back(
"constexpr");
737 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
739 if (DS.isInlineSpecified()) {
740 BadSpecifiers.push_back(
"inline");
741 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
743 if (!BadSpecifiers.empty()) {
744 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
745 Err << (int)BadSpecifiers.size()
746 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
749 for (
auto Loc : BadSpecifierLocs)
761 UPPC_DeclarationType))
771 Diag(Decomp.getLSquareLoc(),
775 ? diag::err_decomp_decl_parens
776 : diag::err_decomp_decl_type)
794 ForVisibleRedeclaration);
795 LookupName(Previous, S,
808 FilterLookupForScope(Previous, DC, S, ConsiderLinkage,
810 if (!Previous.
empty()) {
812 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
813 Diag(Old->getLocation(), diag::note_previous_definition);
817 PushOnScopeChains(BD, S,
true);
818 Bindings.push_back(BD);
819 ParsingInitForAutoVars.insert(BD);
825 Decomp.getLSquareLoc());
827 ForVisibleRedeclaration);
830 bool AddToScope =
true;
832 ActOnVariableDeclarator(S, D, DC, TInfo, Previous,
836 CurContext->addHiddenDecl(New);
839 if (isInOpenMPDeclareTargetContext())
840 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
849 if ((int64_t)Bindings.size() != NumElems) {
850 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
851 << DecompType << (
unsigned)Bindings.size() << NumElems.toString(10)
852 << (NumElems < Bindings.size());
857 for (
auto *B : Bindings) {
862 E = GetInit(Loc, E.
get(), I++);
865 B->setBinding(ElemType, E.
get());
874 const llvm::APSInt &NumElems,
877 S, Bindings, Src, DecompType, NumElems, ElemType,
898 S, Bindings, Src, DecompType, llvm::APSInt::get(VT->
getNumElements()),
908 S, Bindings, Src, DecompType, llvm::APSInt::get(2),
919 llvm::raw_svector_ostream OS(SS);
924 Arg.getArgument().print(PrintingPolicy, OS);
934 auto DiagnoseMissing = [&] {
944 return DiagnoseMissing();
954 return DiagnoseMissing();
960 Result.suppressDiagnostics();
962 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
974 Loc, TraitTy, DiagID,
980 assert(RD &&
"specialization of class template is not a class?");
1002 llvm::APSInt &Size) {
1015 return IsTupleLike::NotTupleLike;
1024 : R(R), Args(Args) {}
1026 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1029 } Diagnoser(R, Args);
1045 return IsTupleLike::TupleLike;
1060 S, R, Loc,
"tuple_element", Args,
1061 diag::err_decomp_decl_std_tuple_element_not_specialized))
1067 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1078 struct BindingDiagnosticTrap {
1084 : S(S), Trap(S.
Diags), BD(BD) {}
1085 ~BindingDiagnosticTrap() {
1095 const llvm::APSInt &TupleSize) {
1096 if ((int64_t)Bindings.size() != TupleSize) {
1097 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1098 << DecompType << (
unsigned)Bindings.size() << TupleSize.toString(10)
1099 << (TupleSize < Bindings.size());
1103 if (Bindings.empty())
1112 bool UseMemberGet =
false;
1116 if (MemberGet.isAmbiguous())
1122 dyn_cast<FunctionTemplateDecl>(D->getUnderlyingDecl())) {
1124 if (TPL->
size() != 0 &&
1125 isa<NonTypeTemplateParmDecl>(TPL->
getParam(0))) {
1127 UseMemberGet =
true;
1136 for (
auto *B : Bindings) {
1137 BindingDiagnosticTrap Trap(S, B);
1159 MemberGet, &Args,
nullptr);
1193 B->getDeclName().getAsIdentifierInfo(), RefType,
1197 RefVD->setImplicit();
1199 RefVD->setInlineSpecified();
1200 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1205 E = Seq.
Perform(S, Entity, Kind, Init);
1211 RefVD->setInit(E.
get());
1212 RefVD->checkInitIsICE();
1220 B->setBinding(T, E.
get());
1244 ClassWithFields = RD;
1248 Paths.
setOrigin(const_cast<CXXRecordDecl*>(RD));
1256 for (
auto &
P : Paths) {
1260 BestPath->back().Base->getType())) {
1262 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1263 <<
false << RD << BestPath->back().Base->getType()
1264 <<
P.back().Base->getType();
1266 }
else if (
P.Access < BestPath->
Access) {
1272 QualType BaseType = BestPath->back().Base->getType();
1274 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1281 *BestPath, diag::err_decomp_decl_inaccessible_base);
1292 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1293 << (ClassWithFields == RD) << RD << ClassWithFields
1294 << Paths.
front().back().Base->getType();
1305 diag::err_incomplete_type))
1317 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1318 unsigned NumFields =
1319 std::count_if(RD->field_begin(), RD->field_end(),
1320 [](
FieldDecl *FD) {
return !FD->isUnnamedBitfield(); });
1321 assert(Bindings.size() != NumFields);
1322 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1323 << DecompType << (
unsigned)Bindings.size() << NumFields
1324 << (NumFields < Bindings.size());
1332 for (
auto *FD : RD->fields()) {
1333 if (FD->isUnnamedBitfield())
1336 if (FD->isAnonymousStructOrUnion()) {
1339 S.
Diag(FD->getLocation(), diag::note_declared_at);
1344 if (I >= Bindings.size())
1345 return DiagnoseBadNumberOfBindings();
1346 auto *B = Bindings[I++];
1354 Loc, const_cast<CXXRecordDecl *>(OrigRD),
1356 BasePair.
getAccess(), FD->getAccess())));
1379 if (FD->isMutable())
1384 if (I != Bindings.size())
1385 return DiagnoseBadNumberOfBindings();
1427 llvm::APSInt TupleSize(32);
1433 case IsTupleLike::TupleLike:
1438 case IsTupleLike::NotTupleLike:
1447 << DD << !RD << DecompType;
1466 if (!getLangOpts().CXXExceptions)
1470 "Should only be called if types are otherwise the same.");
1481 NewType =
P->getPointeeType();
1494 if (CheckEquivalentExceptionSpec(
1509 for (p = 0; p < NumParams; ++p) {
1521 unsigned LastMissingDefaultArg = 0;
1522 for (; p < NumParams; ++p) {
1529 diag::err_param_default_argument_missing_name)
1533 diag::err_param_default_argument_missing);
1535 LastMissingDefaultArg = p;
1539 if (LastMissingDefaultArg > 0) {
1544 for (p = 0; p <= LastMissingDefaultArg; ++p) {
1558 unsigned ArgIndex = 0;
1562 i != e; ++i, ++ArgIndex) {
1565 if (!(*i)->isDependentType() &&
1567 diag::err_constexpr_non_literal_param,
1569 isa<CXXConstructorDecl>(FD)))
1585 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1605 << isa<CXXConstructorDecl>(NewFD)
1607 for (
const auto &I : RD->
vbases())
1608 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
1609 << I.getSourceRange();
1614 if (!isa<CXXConstructorDecl>(NewFD)) {
1627 while (!WrittenVirtual->isVirtualAsWritten())
1629 if (WrittenVirtual != Method)
1630 Diag(WrittenVirtual->getLocation(),
1631 diag::note_overridden_virtual_function);
1639 diag::err_constexpr_non_literal_return))
1660 for (
const auto *DclIt : DS->
decls()) {
1661 switch (DclIt->getKind()) {
1662 case Decl::StaticAssert:
1664 case Decl::UsingShadow:
1665 case Decl::UsingDirective:
1666 case Decl::UnresolvedUsingTypename:
1667 case Decl::UnresolvedUsingValue:
1674 case Decl::TypeAlias: {
1677 const auto *TN = cast<TypedefNameDecl>(DclIt);
1678 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1680 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1683 << isa<CXXConstructorDecl>(Dcl);
1690 case Decl::CXXRecord:
1692 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition())
1695 ? diag::warn_cxx11_compat_constexpr_type_definition
1696 : diag::ext_constexpr_type_definition)
1697 << isa<CXXConstructorDecl>(Dcl);
1700 case Decl::EnumConstant:
1701 case Decl::IndirectField:
1708 case Decl::Decomposition: {
1712 const auto *VD = cast<VarDecl>(DclIt);
1713 if (VD->isThisDeclarationADefinition()) {
1714 if (VD->isStaticLocal()) {
1715 SemaRef.
Diag(VD->getLocation(),
1716 diag::err_constexpr_local_var_static)
1717 << isa<CXXConstructorDecl>(Dcl)
1721 if (!VD->getType()->isDependentType() &&
1723 VD->getLocation(), VD->getType(),
1724 diag::err_constexpr_local_var_non_literal_type,
1725 isa<CXXConstructorDecl>(Dcl)))
1727 if (!VD->getType()->isDependentType() &&
1728 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1729 SemaRef.
Diag(VD->getLocation(),
1730 diag::err_constexpr_local_var_no_init)
1731 << isa<CXXConstructorDecl>(Dcl);
1735 SemaRef.
Diag(VD->getLocation(),
1737 ? diag::warn_cxx11_compat_constexpr_local_var
1738 : diag::ext_constexpr_local_var)
1739 << isa<CXXConstructorDecl>(Dcl);
1743 case Decl::NamespaceAlias:
1752 SemaRef.
Diag(DS->
getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
1753 << isa<CXXConstructorDecl>(Dcl);
1772 llvm::SmallSet<Decl*, 16> &
Inits,
1789 if (!Inits.count(Field)) {
1791 SemaRef.
Diag(Dcl->
getLocation(), diag::err_constexpr_ctor_missing_init);
1794 SemaRef.
Diag(Field->
getLocation(), diag::note_constexpr_ctor_missing_init);
1797 for (
auto *I : RD->
fields())
1800 if (!RD->
isUnion() || Inits.count(I))
1813 case Stmt::NullStmtClass:
1817 case Stmt::DeclStmtClass:
1827 case Stmt::ReturnStmtClass:
1829 if (isa<CXXConstructorDecl>(Dcl)) {
1839 case Stmt::CompoundStmtClass: {
1845 for (
auto *BodyIt : CompStmt->
body()) {
1847 Cxx1yLoc, Cxx2aLoc))
1853 case Stmt::AttributedStmtClass:
1858 case Stmt::IfStmtClass: {
1863 IfStmt *If = cast<IfStmt>(S);
1865 Cxx1yLoc, Cxx2aLoc))
1869 Cxx1yLoc, Cxx2aLoc))
1874 case Stmt::WhileStmtClass:
1875 case Stmt::DoStmtClass:
1876 case Stmt::ForStmtClass:
1877 case Stmt::CXXForRangeStmtClass:
1878 case Stmt::ContinueStmtClass:
1888 Cxx1yLoc, Cxx2aLoc))
1892 case Stmt::SwitchStmtClass:
1893 case Stmt::CaseStmtClass:
1894 case Stmt::DefaultStmtClass:
1895 case Stmt::BreakStmtClass:
1903 Cxx1yLoc, Cxx2aLoc))
1907 case Stmt::CXXTryStmtClass:
1913 Cxx1yLoc, Cxx2aLoc))
1918 case Stmt::CXXCatchStmtClass:
1922 cast<CXXCatchStmt>(S)->getHandlerBlock(),
1923 ReturnStmts, Cxx1yLoc, Cxx2aLoc))
1938 << isa<CXXConstructorDecl>(Dcl);
1949 if (isa<CXXTryStmt>(Body)) {
1963 !getLangOpts().CPlusPlus2a
1964 ? diag::ext_constexpr_function_try_block_cxx2a
1965 : diag::warn_cxx17_compat_constexpr_function_try_block)
1966 << isa<CXXConstructorDecl>(Dcl);
1978 Cxx1yLoc, Cxx2aLoc))
1984 getLangOpts().CPlusPlus2a
1985 ? diag::warn_cxx17_compat_constexpr_body_invalid_stmt
1986 : diag::ext_constexpr_body_invalid_stmt_cxx2a)
1987 << isa<CXXConstructorDecl>(Dcl);
1990 getLangOpts().CPlusPlus14
1991 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
1992 : diag::ext_constexpr_body_invalid_stmt)
1993 << isa<CXXConstructorDecl>(Dcl);
1996 = dyn_cast<CXXConstructorDecl>(Dcl)) {
2005 if (Constructor->getNumCtorInitializers() == 0 &&
2010 }
else if (!Constructor->isDependentContext() &&
2011 !Constructor->isDelegatingConstructor()) {
2012 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
2016 bool AnyAnonStructUnionMembers =
false;
2017 unsigned Fields = 0;
2019 E = RD->
field_end(); I != E; ++I, ++Fields) {
2020 if (I->isAnonymousStructOrUnion()) {
2021 AnyAnonStructUnionMembers =
true;
2029 if (AnyAnonStructUnionMembers ||
2030 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
2034 llvm::SmallSet<Decl*, 16>
Inits;
2035 for (
const auto *I: Constructor->inits()) {
2039 Inits.insert(
ID->chain_begin(),
ID->chain_end());
2042 bool Diagnosed =
false;
2043 for (
auto *I : RD->
fields())
2050 if (ReturnStmts.empty()) {
2055 bool OK = getLangOpts().CPlusPlus14 &&
2059 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2060 : diag::err_constexpr_body_no_return);
2063 }
else if (ReturnStmts.size() > 1) {
2064 Diag(ReturnStmts.back(),
2065 getLangOpts().CPlusPlus14
2066 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2067 : diag::ext_constexpr_body_multiple_return);
2068 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2069 Diag(ReturnStmts[I], diag::note_constexpr_body_previous_return);
2085 Diag(Dcl->
getLocation(), diag::ext_constexpr_function_never_constant_expr)
2086 << isa<CXXConstructorDecl>(Dcl);
2087 for (
size_t I = 0, N = Diags.size(); I != N; ++I)
2088 Diag(Diags[I].first, Diags[I].second);
2105 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2112 return dyn_cast_or_null<CXXRecordDecl>(DC);
2115 return dyn_cast_or_null<CXXRecordDecl>(CurContext);
2132 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2134 if (!getLangOpts().SpellChecking)
2140 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2142 CurDecl = dyn_cast_or_null<CXXRecordDecl>(CurContext);
2144 if (CurDecl && CurDecl->getIdentifier() && II != CurDecl->getIdentifier() &&
2145 3 * II->
getName().edit_distance(CurDecl->getIdentifier()->getName())
2147 II = CurDecl->getIdentifier();
2162 for (
const auto &I : Current->
bases()) {
2174 Queue.push_back(Base);
2180 Current = Queue.pop_back_val();
2208 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2221 ((BaseDecl = BaseDecl->getDefinition()) &&
2223 Diag(BaseLoc, diag::err_circular_inheritance)
2227 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
2236 Access, TInfo, EllipsisLoc);
2241 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2248 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2255 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2257 propagateDLLAttrToBaseClassTemplate(Class, ClassAttr, BaseTemplate,
2266 if (RequireCompleteType(BaseLoc, BaseType,
2267 diag::err_incomplete_base_class, SpecifierRange)) {
2274 assert(BaseDecl &&
"Record type has no declaration");
2276 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2278 assert(CXXBaseDecl &&
"Base type is not a C++ type");
2283 const auto *BaseCSA = CXXBaseDecl->
getAttr<CodeSegAttr>();
2284 const auto *DerivedCSA = Class->
getAttr<CodeSegAttr>();
2285 if ((DerivedCSA || BaseCSA) &&
2286 (!BaseCSA || !DerivedCSA || BaseCSA->getName() != DerivedCSA->getName())) {
2288 Diag(CXXBaseDecl->
getLocation(), diag::note_base_class_specified_here)
2300 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2308 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
2309 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2311 << FA->isSpelledAsSealed();
2323 Access, TInfo, EllipsisLoc);
2340 AdjustDeclIfTemplate(classdecl);
2354 ? (unsigned)diag::warn_unknown_attribute_ignored
2355 : (
unsigned)diag::err_base_specifier_attribute)
2360 GetTypeFromParser(basetype, &TInfo);
2363 DiagnoseUnexpandedParameterPack(SpecifierRange.
getBegin(), TInfo,
2368 Virtual, Access, TInfo,
2389 auto Decl = Rec->getAsCXXRecordDecl();
2392 for (
const auto &BaseSpec : Decl->bases()) {
2394 .getUnqualifiedType();
2395 if (Set.insert(Base).second)
2413 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2417 IndirectBaseSet IndirectBaseTypes;
2420 unsigned NumGoodBases = 0;
2421 bool Invalid =
false;
2422 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2432 Diag(Bases[idx]->getBeginLoc(), diag::err_duplicate_base_class)
2433 << KnownBase->
getType() << Bases[idx]->getSourceRange();
2442 KnownBase = Bases[idx];
2443 Bases[NumGoodBases++] = Bases[idx];
2446 if (Bases.size() > 1)
2450 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
2462 Class->
addAttr(WeakAttr::CreateImplicit(Context));
2468 Class->
setBases(Bases.data(), NumGoodBases);
2471 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2473 QualType BaseType = Bases[idx]->getType();
2483 if (IndirectBaseTypes.count(CanonicalBase)) {
2487 = Class->
isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
2492 Diag(Bases[idx]->getBeginLoc(), diag::warn_inaccessible_base_class)
2493 << BaseType << getAmbiguousPathsDisplayString(Paths)
2494 << Bases[idx]->getSourceRange();
2496 assert(Bases[idx]->isVirtual());
2512 if (!ClassDecl || Bases.empty())
2515 AdjustDeclIfTemplate(ClassDecl);
2516 AttachBaseSpecifiers(cast<CXXRecordDecl>(ClassDecl), Bases);
2540 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2561 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2573 for (
unsigned I = Path.size(); I != 0; --I) {
2574 if (Path[I - 1].
Base->isVirtual()) {
2581 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
2582 BasePathArray.push_back(const_cast<CXXBaseSpecifier*>(Path[I].Base));
2588 assert(BasePathArray.empty() &&
"Base path array must be empty!");
2606 unsigned InaccessibleBaseID,
2607 unsigned AmbigiousBaseConvID,
2611 bool IgnoreAccess) {
2618 bool DerivationOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2619 if (!DerivationOkay)
2624 Path = &Paths.
front();
2629 if (!Path && getLangOpts().MSVCCompat) {
2631 if (PossiblePath.size() == 1) {
2632 Path = &PossiblePath;
2633 if (AmbigiousBaseConvID)
2634 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
2635 << Base << Derived << Range;
2642 if (!IgnoreAccess) {
2645 CheckBaseClassAccess(Loc, Base, Derived, *Path, InaccessibleBaseID)) {
2661 if (AmbigiousBaseConvID) {
2670 bool StillOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
2671 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
2678 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
2680 Diag(Loc, AmbigiousBaseConvID)
2681 << Derived << Base << PathDisplayStr << Range << Name;
2690 bool IgnoreAccess) {
2691 return CheckDerivedToBaseConversion(
2692 Derived, Base, diag::err_upcast_to_inaccessible_base,
2693 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
2694 BasePath, IgnoreAccess);
2711 std::string PathDisplayStr;
2712 std::set<unsigned> DisplayedPaths;
2714 Path != Paths.
end(); ++Path) {
2715 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
2718 PathDisplayStr +=
"\n ";
2720 for (CXXBasePath::const_iterator Element = Path->begin();
2721 Element != Path->end(); ++Element)
2722 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
2726 return PathDisplayStr;
2737 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
2740 CurContext->addHiddenDecl(ASDecl);
2741 return ProcessAccessDeclAttributeList(ASDecl, Attrs);
2765 FindHiddenVirtualMethods(MD, OverloadedMethods);
2767 if (!OverloadedMethods.empty()) {
2768 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2769 Diag(OA->getLocation(),
2770 diag::override_keyword_hides_virtual_member_function)
2771 <<
"override" << (OverloadedMethods.size() > 1);
2772 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2773 Diag(FA->getLocation(),
2774 diag::override_keyword_hides_virtual_member_function)
2775 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2776 << (OverloadedMethods.size() > 1);
2778 NoteHiddenVirtualMethods(MD, OverloadedMethods);
2787 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2788 Diag(OA->getLocation(),
2789 diag::override_keyword_only_allowed_on_virtual_member_functions)
2793 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2794 Diag(FA->getLocation(),
2795 diag::override_keyword_only_allowed_on_virtual_member_functions)
2796 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2808 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
2809 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
2822 if (getSourceManager().isMacroArgExpansion(Loc))
2823 SpellingLoc = getSourceManager().getImmediateExpansionRange(Loc).getBegin();
2824 SpellingLoc = getSourceManager().getSpellingLoc(SpellingLoc);
2825 if (SpellingLoc.
isValid() && getSourceManager().isInSystemHeader(SpellingLoc))
2829 unsigned DiagID = isa<CXXDestructorDecl>(MD)
2830 ? diag::warn_destructor_marked_not_override_overriding
2831 : diag::warn_function_marked_not_override_overriding;
2843 FinalAttr *FA = Old->
getAttr<FinalAttr>();
2849 << FA->isSpelledAsSealed();
2858 return !RD->isCompleteDefinition() ||
2859 !RD->hasTrivialDefaultConstructor() ||
2860 !RD->hasTrivialDestructor();
2866 llvm::find_if(list, [](
const ParsedAttr &AL) {
2869 if (Itr != list.
end())
2879 if (Diags.isIgnored(diag::warn_shadow_field, Loc))
2883 std::map<CXXRecordDecl*, NamedDecl*> Bases;
2888 if (Bases.find(
Base) != Bases.end())
2890 for (
const auto Field :
Base->lookup(FieldName)) {
2891 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
2893 assert(Field->getAccess() !=
AS_none);
2894 assert(Bases.find(
Base) == Bases.end());
2895 Bases[
Base] = Field;
2907 for (
const auto &
P : Paths) {
2908 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
2909 auto It = Bases.find(
Base);
2911 if (It == Bases.end())
2913 auto BaseField = It->second;
2914 assert(BaseField->getAccess() !=
AS_private);
2917 Diag(Loc, diag::warn_shadow_field)
2918 << FieldName << RD <<
Base << DeclIsField;
2919 Diag(BaseField->getLocation(), diag::note_shadow_field);
2944 Expr *BitWidth =
static_cast<Expr*
>(BW);
2946 assert(isa<CXXRecordDecl>(CurContext));
2953 if (cast<CXXRecordDecl>(CurContext)->isInterface()) {
2957 unsigned InvalidDecl;
2958 bool ShowDeclName =
true;
2971 ShowDeclName =
false;
2976 ShowDeclName =
false;
2991 Diag(Loc, diag::err_invalid_member_in_interface)
2992 << (InvalidDecl-1) << Name;
2994 Diag(Loc, diag::err_invalid_member_in_interface)
2995 << (InvalidDecl-1) <<
"";
3021 diag::err_storageclass_invalid_for_member);
3041 const char *PrevSpec;
3046 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3050 const char *PrevSpec;
3056 "This is the only DeclSpec that should fail to be applied");
3060 isInstField =
false;
3071 Diag(Loc, diag::err_bad_variable_name)
3080 if (TemplateParameterLists.size()) {
3082 if (TemplateParams->
size()) {
3091 diag::err_template_member_noparams)
3106 if (
DeclContext *DC = computeDeclContext(SS,
false))
3117 if (MSPropertyAttr) {
3118 Member = HandleMSProperty(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3119 BitWidth, InitStyle, AS, *MSPropertyAttr);
3122 isInstField =
false;
3124 Member = HandleField(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3125 BitWidth, InitStyle, AS);
3130 CheckShadowInheritedFields(Loc, Name, cast<CXXRecordDecl>(CurContext));
3132 Member = HandleDeclarator(S, D, TemplateParameterLists);
3140 }
else if (isa<VarDecl>(Member) || isa<VarTemplateDecl>(Member)) {
3143 Diag(Loc, diag::err_static_not_bitfield)
3145 }
else if (isa<TypedefDecl>(Member)) {
3147 Diag(Loc, diag::err_typedef_not_bitfield)
3152 Diag(Loc, diag::err_not_integral_type_bitfield)
3153 << Name << cast<ValueDecl>(Member)->getType()
3163 NonTemplateMember = FunTmpl->getTemplatedDecl();
3164 else if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(Member))
3165 NonTemplateMember = VarTmpl->getTemplatedDecl();
3171 if (NonTemplateMember != Member)
3177 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3178 auto *TD = DG->getDeducedTemplate();
3179 if (AS != TD->getAccess()) {
3180 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
3181 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
3184 for (
const auto *D : cast<CXXRecordDecl>(CurContext)->decls()) {
3185 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(D))
3186 LastAccessSpec = AccessSpec;
3188 assert(LastAccessSpec &&
"differing access with no access specifier");
3189 Diag(LastAccessSpec->
getBeginLoc(), diag::note_deduction_guide_access)
3203 if (
CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(Member))
3207 CheckOverrideControl(Member);
3209 assert((Name || isInstField) &&
"No identifier for non-field ?");
3212 FieldDecl *FD = cast<FieldDecl>(Member);
3213 FieldCollector->Add(FD);
3215 if (!Diags.isIgnored(diag::warn_unused_private_field, FD->
getLocation())) {
3223 UnusedPrivateFields.insert(FD);
3231 class UninitializedFieldVisitor
3236 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3239 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3254 UninitializedFieldVisitor(
Sema &S,
3255 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3256 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3257 : Inherited(S.
Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3258 Constructor(
nullptr), InitList(
false), InitListFieldDecl(
nullptr) {}
3261 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3262 bool CheckReferenceOnly) {
3264 bool ReferenceField =
false;
3269 Fields.push_back(FD);
3271 ReferenceField =
true;
3277 if (CheckReferenceOnly && !ReferenceField)
3283 for (
auto I = Fields.rbegin() + 1, E = Fields.rend(); I != E; ++I) {
3284 UsedFieldIndex.push_back((*I)->getFieldIndex());
3287 for (
auto UsedIter = UsedFieldIndex.begin(),
3288 UsedEnd = UsedFieldIndex.end(),
3289 OrigIter = InitFieldIndex.begin(),
3290 OrigEnd = InitFieldIndex.end();
3291 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3292 if (*UsedIter < *OrigIter)
3294 if (*UsedIter > *OrigIter)
3301 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3316 if (isa<VarDecl>(SubME->getMemberDecl()))
3319 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3320 if (!FD->isAnonymousStructOrUnion())
3324 AllPODFields =
false;
3326 Base = SubME->getBase();
3332 if (AddressOf && AllPODFields)
3338 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3339 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
3342 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3352 if (!Decls.count(FoundVD))
3357 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3359 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3364 if (CheckReferenceOnly && !IsReference)
3368 unsigned diag = IsReference
3369 ? diag::warn_reference_field_is_uninit
3370 : diag::warn_field_is_uninit;
3374 diag::note_uninit_in_this_constructor)
3379 void HandleValue(
Expr *E,
bool AddressOf) {
3382 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3383 HandleMemberExpr(ME,
false ,
3389 Visit(CO->getCond());
3390 HandleValue(CO->getTrueExpr(), AddressOf);
3391 HandleValue(CO->getFalseExpr(), AddressOf);
3396 dyn_cast<BinaryConditionalOperator>(E)) {
3397 Visit(BCO->getCond());
3398 HandleValue(BCO->getFalseExpr(), AddressOf);
3403 HandleValue(OVE->getSourceExpr(), AddressOf);
3408 switch (BO->getOpcode()) {
3413 HandleValue(BO->getLHS(), AddressOf);
3414 Visit(BO->getRHS());
3417 Visit(BO->getLHS());
3418 HandleValue(BO->getRHS(), AddressOf);
3427 InitFieldIndex.push_back(0);
3428 for (
auto Child : ILE->
children()) {
3429 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3430 CheckInitListExpr(SubList);
3434 ++InitFieldIndex.back();
3436 InitFieldIndex.pop_back();
3445 DeclsToRemove.clear();
3447 Constructor = FieldConstructor;
3452 InitListFieldDecl = Field;
3453 InitFieldIndex.clear();
3454 CheckInitListExpr(ILE);
3468 HandleMemberExpr(ME,
true ,
false );
3477 Inherited::VisitImplicitCastExpr(E);
3483 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3487 if (ICE->getCastKind() == CK_NoOp)
3488 ArgExpr = ICE->getSubExpr();
3489 HandleValue(ArgExpr,
false );
3492 Inherited::VisitCXXConstructExpr(E);
3497 if (isa<MemberExpr>(Callee)) {
3498 HandleValue(Callee,
false );
3504 Inherited::VisitCXXMemberCallExpr(E);
3510 HandleValue(E->
getArg(0),
false);
3514 Inherited::VisitCallExpr(E);
3520 if (isa<UnresolvedLookupExpr>(Callee))
3521 return Inherited::VisitCXXOperatorCallExpr(E);
3525 HandleValue(Arg->IgnoreParenImpCasts(),
false );
3534 if (!FD->getType()->isReferenceType())
3535 DeclsToRemove.push_back(FD);
3538 HandleValue(E->
getLHS(),
false );
3543 Inherited::VisitBinaryOperator(E);
3553 HandleValue(ME->
getBase(),
true );
3558 Inherited::VisitUnaryOperator(E);
3568 static void DiagnoseUninitializedFields(
3585 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
3588 for (
auto *I : RD->
decls()) {
3589 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
3590 UninitializedFields.insert(FD);
3591 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
3592 UninitializedFields.insert(IFD->getAnonField());
3596 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
3597 for (
auto I : RD->
bases())
3598 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
3600 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3603 UninitializedFieldVisitor UninitializedChecker(SemaRef,
3604 UninitializedFields,
3605 UninitializedBaseClasses);
3607 for (
const auto *FieldInit : Constructor->
inits()) {
3608 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3611 Expr *InitExpr = FieldInit->getInit();
3616 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
3617 InitExpr =
Default->getExpr();
3621 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
3622 FieldInit->getAnyMember(),
3623 FieldInit->getBaseClass());
3625 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
3626 FieldInit->getAnyMember(),
3627 FieldInit->getBaseClass());
3639 PushFunctionScope();
3649 PopFunctionScopeInfo(
nullptr, D);
3653 "must set init style when field is created");
3662 if (DiagnoseUnexpandedParameterPack(InitExpr, UPPC_Initializer)) {
3679 Init = Seq.Perform(*
this, Entity, Kind, InitExpr);
3689 Init = ActOnFinishFullExpr(Init.
get(), InitLoc,
false);
3695 InitExpr = Init.
get();
3709 DirectBaseSpec =
nullptr;
3710 for (
const auto &
Base : ClassDecl->
bases()) {
3714 DirectBaseSpec = &
Base;
3722 VirtualBaseSpec =
nullptr;
3723 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
3732 Path != Paths.
end(); ++Path) {
3733 if (Path->back().Base->isVirtual()) {
3734 VirtualBaseSpec = Path->back().Base;
3741 return DirectBaseSpec || VirtualBaseSpec;
3755 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
3756 DS, IdLoc, InitList,
3774 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
3775 DS, IdLoc, List, EllipsisLoc);
3784 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
3785 : ClassDecl(ClassDecl) {}
3787 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
3789 if (
FieldDecl *Member = dyn_cast<FieldDecl>(ND))
3791 return isa<TypeDecl>(ND);
3812 if ((Member = dyn_cast<FieldDecl>(Result.
front())) ||
3829 ExprResult Res = CorrectDelayedTyposInExpr(Init);
3837 AdjustDeclIfTemplate(ConstructorD);
3863 if (
ValueDecl *Member = tryLookupCtorInitMemberDecl(
3864 ClassDecl, SS, TemplateTypeTy, MemberOrBase)) {
3866 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
3870 return BuildMemberInitializer(Member, Init, IdLoc);
3876 if (TemplateTypeTy) {
3877 BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo);
3884 LookupResult R(*
this, MemberOrBase, IdLoc, LookupOrdinaryName);
3885 LookupParsedName(R, S, &SS);
3894 if (SS.
isSet() && isDependentScopeSpecifier(SS)) {
3895 bool NotUnknownSpecialization =
false;
3897 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
3898 NotUnknownSpecialization = !Record->hasAnyDependentBases();
3900 if (!NotUnknownSpecialization) {
3905 *MemberOrBase, IdLoc);
3926 (Corr = CorrectTypo(
3928 llvm::make_unique<MemInitializerValidatorCCC>(ClassDecl),
3929 CTK_ErrorRecovery, ClassDecl))) {
3935 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3936 << MemberOrBase <<
true);
3937 return BuildMemberInitializer(Member, Init, IdLoc);
3943 DirectBaseSpec, VirtualBaseSpec)) {
3948 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3949 << MemberOrBase <<
false,
3962 if (!TyD && BaseType.
isNull()) {
3963 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
3971 MarkAnyDeclReferenced(TyD->
getLocation(), TyD,
false);
3987 return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, EllipsisLoc);
3995 assert((DirectMember || IndirectMember) &&
3996 "Member must be a FieldDecl or IndirectFieldDecl");
3998 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4005 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4006 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4007 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
4008 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
4019 DiscardCleanupsInEvaluationContext();
4021 bool InitList =
false;
4022 if (isa<InitListExpr>(Init)) {
4039 ExprResult MemberInit = InitSeq.Perform(*
this, MemberEntity, Kind, Args,
4047 MemberInit = ActOnFinishFullExpr(MemberInit.
get(), InitRange.
getBegin(),
4052 Init = MemberInit.
get();
4070 if (!LangOpts.CPlusPlus11)
4071 return Diag(NameLoc, diag::err_delegating_ctor)
4073 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4075 bool InitList =
true;
4077 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4079 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4090 InitRange.getEnd());
4092 ExprResult DelegationInit = InitSeq.Perform(*
this, DelegationEntity, Kind,
4097 assert(cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor() &&
4098 "Delegating constructor with no target?");
4103 DelegationInit = ActOnFinishFullExpr(
4104 DelegationInit.get(), InitRange.getBegin(),
false);
4105 if (DelegationInit.isInvalid())
4115 if (CurContext->isDependentContext())
4116 DelegationInit = Init;
4119 DelegationInit.getAs<
Expr>(),
4120 InitRange.getEnd());
4131 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4146 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4153 if (DiagnoseUnexpandedParameterPack(BaseLoc, BaseTInfo, UPPC_Initializer))
4156 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4166 return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
4175 if (!DirectBaseSpec && !VirtualBaseSpec) {
4184 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4191 DiscardCleanupsInEvaluationContext();
4196 InitRange.
getEnd(), EllipsisLoc);
4203 if (DirectBaseSpec && VirtualBaseSpec)
4204 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4209 BaseSpec = VirtualBaseSpec;
4212 bool InitList =
true;
4214 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4216 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4226 ExprResult BaseInit = InitSeq.Perform(*
this, BaseEntity, Kind, Args,
nullptr);
4233 BaseInit = ActOnFinishFullExpr(BaseInit.
get(), InitRange.
getBegin(),
4245 if (CurContext->isDependentContext())
4252 InitRange.
getEnd(), EllipsisLoc);
4257 if (T.isNull()) T = E->
getType();
4262 TargetType, ExprLoc);
4282 bool IsInheritedVirtualBase,
4286 IsInheritedVirtualBase);
4290 switch (ImplicitInitKind) {
4296 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
None);
4302 bool Moving = ImplicitInitKind ==
IIK_Move;
4324 BasePath.push_back(BaseSpec);
4326 CK_UncheckedDerivedToBase,
4334 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4357 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
4372 bool Moving = ImplicitInitKind ==
IIK_Move;
4380 Expr *MemberExprBase =
4395 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
4397 MemberLookup.resolveKind();
4431 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
4446 "Unhandled implicit init kind!");
4462 InitSeq.
Perform(SemaRef, InitEntity, InitKind,
None);
4485 diag::err_uninitialized_member_in_ctor)
4495 diag::err_uninitialized_member_in_ctor)
4516 CXXMemberInit =
nullptr;
4521 struct BaseAndFieldInfo {
4524 bool AnyErrorsInInits;
4526 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
4528 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
4531 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
4543 bool isImplicitCopyOrMove()
const {
4554 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
4558 AllToInit.push_back(Init);
4567 bool isInactiveUnionMember(
FieldDecl *Field) {
4577 if (isImplicitCopyOrMove())
4595 bool isWithinInactiveUnionMember(
FieldDecl *Field,
4598 return isInactiveUnionMember(Field);
4600 for (
auto *
C : Indirect->
chain()) {
4602 if (Field && isInactiveUnionMember(Field))
4617 if (!ArrayT->getSize())
4620 T = ArrayT->getElementType();
4635 return Info.addFieldInitializer(Init);
4649 if (Info.isWithinInactiveUnionMember(Field, Indirect))
4670 return Info.addFieldInitializer(Init);
4680 if (Info.AnyErrorsInInits)
4691 return Info.addFieldInitializer(Init);
4709 DelegatingCtorDecls.push_back(Constructor);
4711 DiagnoseUninitializedFields(*
this, Constructor);
4721 if (!Initializers.empty()) {
4725 memcpy(baseOrMemberInitializers, Initializers.data(),
4737 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
4745 bool HadError =
false;
4747 for (
unsigned i = 0; i < Initializers.size(); i++) {
4756 for (
auto *
C : F->chain()) {
4759 Info.ActiveUnionMember.insert(std::make_pair(
4763 if (FD->getParent()->isUnion())
4764 Info.ActiveUnionMember.insert(std::make_pair(
4765 FD->getParent()->getCanonicalDecl(), FD->getCanonicalDecl()));
4771 llvm::SmallPtrSet<CXXBaseSpecifier *, 16> DirectVBases;
4772 for (
auto &I : ClassDecl->
bases()) {
4774 DirectVBases.insert(&I);
4778 for (
auto &VBase : ClassDecl->
vbases()) {
4780 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
4788 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
4789 << VBase.getType() << ClassDecl;
4790 DiagnoseAbstractType(ClassDecl);
4793 Info.AllToInit.push_back(
Value);
4794 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
4799 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
4802 &VBase, IsInheritedVirtualBase,
4808 Info.AllToInit.push_back(CXXBaseInit);
4815 if (
Base.isVirtual())
4819 = Info.AllBaseFields.lookup(
Base.getType()->getAs<
RecordType>())) {
4820 Info.AllToInit.push_back(
Value);
4821 }
else if (!AnyErrors) {
4830 Info.AllToInit.push_back(CXXBaseInit);
4835 for (
auto *Mem : ClassDecl->
decls()) {
4836 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
4841 if (F->isUnnamedBitfield())
4847 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
4856 if (Info.isImplicitCopyOrMove())
4859 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
4860 if (F->getType()->isIncompleteArrayType()) {
4862 "Incomplete array type is not valid");
4874 unsigned NumInitializers = Info.AllToInit.size();
4875 if (NumInitializers > 0) {
4879 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
4885 MarkBaseAndMemberDestructorsReferenced(Constructor->
getLocation(),
4896 for (
auto *Field : RD->
fields())
4924 bool ShouldCheckOrder =
false;
4925 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4927 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
4929 ShouldCheckOrder =
true;
4933 if (!ShouldCheckOrder)
4944 for (
const auto &VBase : ClassDecl->
vbases())
4948 for (
const auto &
Base : ClassDecl->
bases()) {
4949 if (
Base.isVirtual())
4955 for (
auto *Field : ClassDecl->
fields()) {
4956 if (Field->isUnnamedBitfield())
4962 unsigned NumIdealInits = IdealInitKeys.size();
4963 unsigned IdealIndex = 0;
4966 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4972 for (; IdealIndex != NumIdealInits; ++IdealIndex)
4973 if (InitKey == IdealInitKeys[IdealIndex])
4979 if (IdealIndex == NumIdealInits && PrevInit) {
4982 diag::warn_initializer_out_of_order);
4995 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
4996 if (InitKey == IdealInitKeys[IdealIndex])
4999 assert(IdealIndex < NumIdealInits &&
5000 "initializer not found in initializer list");
5008 bool CheckRedundantInit(
Sema &S,
5018 diag::err_multiple_mem_initialization)
5019 << Field->getDeclName()
5023 assert(BaseClass &&
"neither field nor base");
5025 diag::err_multiple_base_initialization)
5035 typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5036 typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5038 bool CheckRedundantUnionInit(
Sema &S,
5040 RedundantUnionMap &Unions) {
5047 UnionEntry &En = Unions[
Parent];
5048 if (En.first && En.first != Child) {
5050 diag::err_multiple_mem_union_initialization)
5053 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5054 << 0 << En.second->getSourceRange();
5078 if (!ConstructorDecl)
5081 AdjustDeclIfTemplate(ConstructorDecl);
5087 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5094 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5097 RedundantUnionMap MemberUnions;
5099 bool HadError =
false;
5100 for (
unsigned i = 0; i < MemInits.size(); i++) {
5108 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
5109 CheckRedundantUnionInit(*
this, Init, MemberUnions))
5113 if (CheckRedundantInit(*
this, Init, Members[Key]))
5118 if (MemInits.size() != 1) {
5120 diag::err_delegating_initializer_alone)
5121 << Init->
getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5124 SetDelegatingInitializer(Constructor, MemInits[i]);
5135 SetCtorInitializers(Constructor, AnyErrors, MemInits);
5137 DiagnoseUninitializedFields(*
this, Constructor);
5154 for (
auto *Field : ClassDecl->
fields()) {
5155 if (Field->isInvalidDecl())
5178 assert(Dtor &&
"No dtor found for FieldClassDecl!");
5179 CheckDestructorAccess(Field->getLocation(), Dtor,
5180 PDiag(diag::err_access_dtor_field)
5181 << Field->getDeclName()
5184 MarkFunctionReferenced(Location, Dtor);
5185 DiagnoseUseOfDecl(Dtor, Location);
5190 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5192 llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
5195 for (
const auto &
Base : ClassDecl->
bases()) {
5200 if (
Base.isVirtual()) {
5201 if (!VisitVirtualBases)
5203 DirectVirtualBases.insert(RT);
5214 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5217 CheckDestructorAccess(
Base.getBeginLoc(), Dtor,
5218 PDiag(diag::err_access_dtor_base)
5219 <<
Base.getType() <<
Base.getSourceRange(),
5222 MarkFunctionReferenced(Location, Dtor);
5223 DiagnoseUseOfDecl(Dtor, Location);
5226 if (!VisitVirtualBases)
5230 for (
const auto &VBase : ClassDecl->
vbases()) {
5235 if (DirectVirtualBases.count(RT))
5246 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5247 if (CheckDestructorAccess(
5249 PDiag(diag::err_access_dtor_vbase)
5253 CheckDerivedToBaseConversion(
5255 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5259 MarkFunctionReferenced(Location, Dtor);
5260 DiagnoseUseOfDecl(Dtor, Location);
5269 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5270 SetCtorInitializers(Constructor,
false);
5271 DiagnoseUninitializedFields(*
this, Constructor);
5298 if (!isAbstractType(Loc, T))
5310 if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
5316 if (Diags.isLastDiagnosticIgnored())
5324 llvm::SmallPtrSet<const CXXMethodDecl *, 8> SeenPureMethods;
5326 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5327 MEnd = FinalOverriders.end();
5331 SOEnd = M->second.end();
5332 SO != SOEnd; ++SO) {
5339 if (SO->second.size() != 1)
5342 if (!SO->second.front().Method->isPure())
5345 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5348 Diag(SO->second.front().Method->getLocation(),
5349 diag::note_pure_virtual_function)
5350 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5354 if (!PureVirtualClassDiagSet)
5356 PureVirtualClassDiagSet->insert(RD);
5360 struct AbstractUsageInfo {
5367 : S(S), Record(Record),
5372 void DiagnoseAbstractType() {
5373 if (Invalid)
return;
5381 struct CheckAbstractUsage {
5382 AbstractUsageInfo &Info;
5385 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
5386 : Info(Info), Ctx(Ctx) {}
5390 #define ABSTRACT_TYPELOC(CLASS, PARENT) 5391 #define TYPELOC(CLASS, PARENT) \ 5392 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break; 5393 #include "clang/AST/TypeLocNodes.def" 5399 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
5414 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
5424 #define CheckPolymorphic(Type) \ 5425 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \ 5426 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \ 5441 return Visit(Next, Sel);
5451 T = Info.S.Context.getBaseElementType(T);
5454 if (CT != Info.AbstractType)
return;
5458 Info.S.Diag(Ctx->
getLocation(), diag::err_array_of_abstract_type)
5461 Info.S.Diag(Ctx->
getLocation(), diag::err_abstract_type_in_decl)
5464 Info.DiagnoseAbstractType();
5470 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
5493 for (
auto *D : RD->
decls()) {
5494 if (D->isImplicit())
continue;
5497 if (isa<CXXMethodDecl>(D)) {
5499 }
else if (isa<FunctionTemplateDecl>(D)) {
5500 FunctionDecl *FD = cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
5504 }
else if (isa<FieldDecl>(D)) {
5508 }
else if (isa<VarDecl>(D)) {
5509 VarDecl *VD = cast<VarDecl>(D);
5514 }
else if (isa<CXXRecordDecl>(D)) {
5516 }
else if (isa<ClassTemplateDecl>(D)) {
5518 cast<ClassTemplateDecl>(D)->getTemplatedDecl());
5528 assert(ClassAttr->
getKind() == attr::DLLExport);
5540 for (Decl *Member : Class->
decls()) {
5543 auto *VD = dyn_cast<
VarDecl>(Member);
5544 if (VD && Member->getAttr<DLLExportAttr>() &&
5553 if (Member->getAttr<DLLExportAttr>()) {
5554 if (MD->isUserProvided()) {
5565 }
else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
5566 MD->isCopyAssignmentOperator() ||
5567 MD->isMoveAssignmentOperator()) {
5596 for (Decl *Member : Class->
decls()) {
5599 if (!CD || !CD->isDefaultConstructor())
5601 auto *
Attr = CD->getAttr<DLLExportAttr>();
5614 if (LastExportedDefaultCtor) {
5616 diag::err_attribute_dll_ambiguous_default_ctor)
5618 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
5619 << CD->getDeclName();
5622 LastExportedDefaultCtor = CD;
5628 for (
auto *Method : Class->
methods()) {
5629 if (Method->isUserProvided())
5631 if (
Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method,
true))
5642 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
5643 if (
Attr *TemplateAttr =
5644 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
5645 auto *A = cast<InheritableAttr>(TemplateAttr->clone(getASTContext()));
5646 A->setInherited(
true);
5657 << Class << ClassAttr;
5664 for (Decl *Member : Class->
decls()) {
5665 if (!isa<VarDecl>(Member) && !isa<CXXMethodDecl>(Member))
5668 if (!MemberAttr || MemberAttr->
isInherited() || Member->isInvalidDecl())
5672 diag::err_attribute_dll_member_of_dll_class)
5673 << MemberAttr << ClassAttr;
5675 Member->setInvalidDecl();
5684 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
5689 const bool PropagatedImport =
5691 cast<DLLImportAttr>(ClassAttr)->wasPropagatedToBaseTemplate();
5703 ForceDeclarationOfImplicitMembers(Class);
5708 for (Decl *Member : Class->
decls()) {
5718 if (MD->isDeleted())
5721 if (MD->isInlined()) {
5731 if ((MD->isMoveAssignmentOperator() ||
5732 (Ctor && Ctor->isMoveConstructor())) &&
5739 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->isTrivial())
5746 if (VD && PropagatedImport)
5749 if (!cast<NamedDecl>(Member)->isExternallyVisible())
5757 if (!getLangOpts().DllExportInlines && MD && MD->isInlined() &&
5760 if (ClassExported) {
5761 NewAttr = ::new (getASTContext())
5762 DLLExportStaticLocalAttr(ClassAttr->
getRange(),
5766 NewAttr = ::new (getASTContext())
5767 DLLImportStaticLocalAttr(ClassAttr->
getRange(),
5772 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5776 Member->addAttr(NewAttr);
5786 "friend re-decl should not already have a DLLAttr");
5787 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5789 FD->addAttr(NewAttr);
5796 DelayedDllExportClasses.push_back(Class);
5817 auto *NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5818 NewAttr->setInherited(
true);
5819 BaseTemplateSpec->
addAttr(NewAttr);
5823 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
5824 ImportAttr->setPropagatedToBaseTemplate();
5830 checkClassLevelDLLAttribute(BaseTemplateSpec);
5845 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
5850 diag::note_template_class_explicit_specialization_was_here)
5851 << BaseTemplateSpec;
5854 diag::note_template_class_instantiation_was_here)
5855 << BaseTemplateSpec;
5864 cast<CXXConstructorDecl>(MD));
5882 llvm_unreachable(
"Invalid special member.");
5900 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
5901 bool DtorIsTrivialForCall =
false;
5912 CopyCtorIsTrivial =
true;
5914 CopyCtorIsTrivialForCall =
true;
5918 if (CD->isCopyConstructor() && !CD->isDeleted()) {
5919 if (CD->isTrivial())
5920 CopyCtorIsTrivial =
true;
5921 if (CD->isTrivialForCall())
5922 CopyCtorIsTrivialForCall =
true;
5930 DtorIsTrivialForCall =
true;
5932 if (!DD->isDeleted() && DD->isTrivialForCall())
5933 DtorIsTrivialForCall =
true;
5937 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
5950 if (CopyCtorIsTrivial &&
5960 bool HasNonDeletedCopyOrMove =
false;
5966 HasNonDeletedCopyOrMove =
true;
5973 HasNonDeletedCopyOrMove =
true;
5981 if (MD->isDeleted())
5985 if (CD && CD->isCopyOrMoveConstructor())
5986 HasNonDeletedCopyOrMove =
true;
5987 else if (!isa<CXXDestructorDecl>(MD))
5990 if (!MD->isTrivialForCall())
5994 return HasNonDeletedCopyOrMove;
6005 AbstractUsageInfo Info(*
this, Record);
6015 bool Complained =
false;
6016 for (
const auto *F : Record->
fields()) {
6017 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
6020 if (F->getType()->isReferenceType() ||
6021 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
6028 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
6029 << F->getType()->isReferenceType()
6030 << F->getDeclName();
6048 if (((isa<FieldDecl>(D) || isa<UnresolvedUsingValueDecl>(D)) &&
6050 isa<IndirectFieldDecl>(D)) {
6051 Diag((*I)->getLocation(), diag::err_member_name_of_class)
6062 !Record->
hasAttr<FinalAttr>())
6064 diag::warn_non_virtual_dtor) << Context.
getRecordType(Record);
6068 if (FinalAttr *FA = Record->
getAttr<FinalAttr>()) {
6070 << FA->isSpelledAsSealed();
6071 DiagnoseAbstractType(Record);
6076 if (Record->
hasAttr<TrivialABIAttr>())
6077 checkIllFormedTrivialABIStruct(*Record);
6081 bool HasTrivialABI = Record->
hasAttr<TrivialABIAttr>();
6086 bool HasMethodWithOverrideControl =
false,
6087 HasOverridingMethodWithoutOverrideControl =
false;
6089 for (
auto *M : Record->
methods()) {
6093 DiagnoseHiddenVirtualMethods(M);
6094 if (M->hasAttr<OverrideAttr>())
6095 HasMethodWithOverrideControl =
true;
6096 else if (M->size_overridden_methods() > 0)
6097 HasOverridingMethodWithoutOverrideControl =
true;
6099 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted())
6100 CheckExplicitlyDefaultedSpecialMember(M);
6105 if (!M->isImplicit() && !M->isUserProvided()) {
6106 if (CSM != CXXInvalid) {
6107 M->setTrivial(SpecialMemberIsTrivial(M, CSM));
6110 M->setTrivialForCall(
6112 SpecialMemberIsTrivial(M, CSM, TAH_ConsiderTrivialABI));
6119 if ((CSM == CXXCopyConstructor || CSM == CXXMoveConstructor ||
6120 CSM == CXXDestructor) && M->isUserProvided()) {
6121 M->setTrivialForCall(HasTrivialABI);
6125 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
6126 M->hasAttr<DLLExportAttr>()) {
6129 (CSM == CXXDefaultConstructor || CSM == CXXCopyConstructor ||
6130 CSM == CXXDestructor))
6131 M->dropAttr<DLLExportAttr>();
6133 if (M->hasAttr<DLLExportAttr>()) {
6135 ActOnFinishInlineFunctionDef(M);
6141 if (HasMethodWithOverrideControl &&
6142 HasOverridingMethodWithoutOverrideControl) {
6145 for (
auto *M : Record->
methods())
6146 DiagnoseAbsenceOfOverrideControl(M);
6163 checkClassLevelDLLAttribute(Record);
6164 checkClassLevelCodeSegAttribute(Record);
6166 bool ClangABICompat4 =
6188 if (getLangOpts().ForceEmitVTables) {
6206 unsigned FieldQuals,
bool ConstRHS) {
6207 unsigned LHSQuals = 0;
6209 LHSQuals = FieldQuals;
6211 unsigned RHSQuals = FieldQuals;
6221 LHSQuals & Qualifiers::Const,
6222 LHSQuals & Qualifiers::Volatile);
6232 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
6238 : S(S), UseLoc(UseLoc) {
6239 bool DiagnosedMultipleConstructedBases =
false;
6241 UsingDecl *ConstructedBaseUsing =
nullptr;
6245 for (
auto *D : Shadow->
redecls()) {
6246 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
6247 auto *DNominatedBase = DShadow->getNominatedBaseClass();
6248 auto *DConstructedBase = DShadow->getConstructedBaseClass();
6250 InheritedFromBases.insert(
6251 std::make_pair(DNominatedBase->getCanonicalDecl(),
6252 DShadow->getNominatedBaseClassShadowDecl()));
6253 if (DShadow->constructsVirtualBase())
6254 InheritedFromBases.insert(
6255 std::make_pair(DConstructedBase->getCanonicalDecl(),
6256 DShadow->getConstructedBaseClassShadowDecl()));
6258 assert(DNominatedBase == DConstructedBase);
6263 if (!ConstructedBase) {
6264 ConstructedBase = DConstructedBase;
6265 ConstructedBaseUsing = D->getUsingDecl();
6266 }
else if (ConstructedBase != DConstructedBase &&
6268 if (!DiagnosedMultipleConstructedBases) {
6269 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
6272 diag::note_ambiguous_inherited_constructor_using)
6274 DiagnosedMultipleConstructedBases =
true;
6276 S.
Diag(D->getUsingDecl()->getLocation(),
6277 diag::note_ambiguous_inherited_constructor_using)
6278 << DConstructedBase;
6282 if (DiagnosedMultipleConstructedBases)
6289 std::pair<CXXConstructorDecl *, bool>
6292 if (It == InheritedFromBases.end())
6293 return std::make_pair(
nullptr,
false);
6297 return std::make_pair(
6299 It->second->constructsVirtualBase());
6302 return std::make_pair(Ctor,
false);
6316 if (InheritedCtor) {
6319 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
6321 return BaseCtor->isConstexpr();
6385 if (Ctor && ClassDecl->
isUnion())
6404 for (
const auto &B : ClassDecl->
bases()) {
6406 if (!BaseType)
continue;
6410 InheritedCtor, Inherited))
6421 for (
const auto *F : ClassDecl->
fields()) {
6422 if (F->isInvalidDecl())
6428 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
6431 ConstArg && !F->isMutable()))
6453 auto *CD = cast<CXXConstructorDecl>(MD);
6454 assert(CD->getInheritedConstructor() &&
6455 "only special members have implicit exception specs");
6457 S, Loc, CD->getInheritedConstructor().getShadowDecl());
6484 auto ESI = IES.getExceptionSpec();
6487 UpdateExceptionSpec(MD, ESI);
6503 "not an explicitly-defaulted special member");
6509 bool HadError =
false;
6521 bool DeleteOnTypeMismatch = getLangOpts().CPlusPlus2a &&
First;
6522 bool ShouldDeleteForTypeMismatch =
false;
6523 unsigned ExpectedParams = 1;
6524 if (CSM == CXXDefaultConstructor || CSM == CXXDestructor)
6534 if (DeleteOnTypeMismatch)
6535 ShouldDeleteForTypeMismatch =
true;
6545 bool CanHaveConstParam =
false;
6546 if (CSM == CXXCopyConstructor)
6548 else if (CSM == CXXCopyAssignment)
6552 if (CSM == CXXCopyAssignment || CSM == CXXMoveAssignment) {
6560 if (!Context.
hasSameType(ReturnType, ExpectedReturnType)) {
6561 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
6562 << (CSM == CXXMoveAssignment) << ExpectedReturnType;
6568 if (DeleteOnTypeMismatch)
6569 ShouldDeleteForTypeMismatch =
true;
6572 << (CSM == CXXMoveAssignment) << getLangOpts().CPlusPlus14;
6580 bool HasConstParam =
false;
6587 if (DeleteOnTypeMismatch)
6588 ShouldDeleteForTypeMismatch =
true;
6591 diag::err_defaulted_special_member_volatile_param) << CSM;
6596 if (HasConstParam && !CanHaveConstParam) {
6597 if (DeleteOnTypeMismatch)
6598 ShouldDeleteForTypeMismatch =
true;
6599 else if (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment) {
6601 diag::err_defaulted_special_member_copy_const_param)
6602 << (CSM == CXXCopyAssignment);
6607 diag::err_defaulted_special_member_move_const_param)
6608 << (CSM == CXXMoveAssignment);
6612 }
else if (ExpectedParams) {
6615 assert(CSM == CXXCopyAssignment &&
"unexpected non-ref argument");
6629 if ((getLangOpts().
CPlusPlus14 ? !isa<CXXDestructorDecl>(MD)
6630 : isa<CXXConstructorDecl>(MD)) &&
6633 Diag(MD->
getBeginLoc(), diag::err_incorrect_defaulted_constexpr) << CSM;
6650 DelayedDefaultedMemberExceptionSpecs.push_back(std::make_pair(MD, Type));
6652 CheckExplicitlyDefaultedMemberExceptionSpec(MD, Type);
6667 llvm::makeArrayRef(&ArgType,
6672 if (ShouldDeleteForTypeMismatch || ShouldDeleteSpecialMember(MD, CSM)) {
6675 if (!inTemplateInstantiation() && !HadError) {
6677 if (ShouldDeleteForTypeMismatch) {
6680 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
6683 if (ShouldDeleteForTypeMismatch && !HadError) {
6685 diag::warn_cxx17_compat_defaulted_method_type_mismatch) << CSM;
6691 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
6692 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
6693 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
6724 CheckEquivalentExceptionSpec(
6725 PDiag(diag::err_incorrect_defaulted_exception_spec)
6726 << getSpecialMember(MD), PDiag(),
6732 decltype(DelayedOverridingExceptionSpecChecks) Overriding;
6733 decltype(DelayedEquivalentExceptionSpecChecks)
Equivalent;
6734 decltype(DelayedDefaultedMemberExceptionSpecs) Defaulted;
6736 std::swap(Overriding, DelayedOverridingExceptionSpecChecks);
6737 std::swap(
Equivalent, DelayedEquivalentExceptionSpecChecks);
6738 std::swap(Defaulted, DelayedDefaultedMemberExceptionSpecs);
6742 for (
auto &Check : Overriding)
6743 CheckOverridingFunctionExceptionSpec(Check.first, Check.second);
6748 CheckEquivalentExceptionSpec(Check.second, Check.first);
6752 for (
auto &Spec : Defaulted)
6753 CheckExplicitlyDefaultedMemberExceptionSpec(Spec.first, Spec.second);
6759 template<
typename Derived>
6760 struct SpecialMemberVisitor {
6767 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
6771 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
6776 IsConstructor =
true;
6780 IsAssignment =
true;
6785 llvm_unreachable(
"invalid special member kind");
6791 ConstArg = RT->getPointeeType().isConstQualified();
6795 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
6798 bool isMove()
const {
6804 unsigned Quals,
bool IsMutable) {
6806 ConstArg && !IsMutable);
6816 cast<CXXConstructorDecl>(MD)->getInheritedConstructor().getConstructor();
6823 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
6830 return B->getBaseTypeLoc();
6832 return Subobj.get<
FieldDecl*>()->getLocation();
6837 VisitNonVirtualBases,
6842 VisitPotentiallyConstructedBases,
6848 bool visit(BasesToVisit Bases) {
6851 if (Bases == VisitPotentiallyConstructedBases)
6852 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
6854 for (
auto &B : RD->
bases())
6855 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
6856 getDerived().visitBase(&B))
6859 if (Bases == VisitAllBases)
6860 for (
auto &B : RD->
vbases())
6861 if (getDerived().visitBase(&B))
6864 for (
auto *F : RD->
fields())
6865 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
6866 getDerived().visitField(F))
6875 struct SpecialMemberDeletionInfo
6876 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
6881 bool AllFieldsAreConst;
6886 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
6887 Loc(MD->
getLocation()), AllFieldsAreConst(
true) {}
6896 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
6899 bool shouldDeleteForField(
FieldDecl *FD);
6900 bool shouldDeleteForAllConstMembers();
6902 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
6904 bool shouldDeleteForSubobjectCall(Subobject Subobj,
6906 bool IsDtorCallInCtor);
6914 bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
6934 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
6936 bool IsDtorCallInCtor) {
6943 DiagKind = !Decl ? 0 : 1;
6946 else if (!isAccessible(Subobj, Decl))
6964 diag::note_deleted_special_member_class_subobject)
6965 << getEffectiveCSM() << MD->
getParent() <<
true 6966 << Field << DiagKind << IsDtorCallInCtor;
6970 diag::note_deleted_special_member_class_subobject)
6971 << getEffectiveCSM() << MD->
getParent() <<
false 6972 << Base->
getType() << DiagKind << IsDtorCallInCtor;
6985 bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
6988 bool IsMutable = Field && Field->
isMutable();
7006 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
7013 if (IsConstructor) {
7016 false,
false,
false,
false,
false);
7017 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
7035 if (
auto *BaseCtor = SMOR.
getMethod()) {
7040 if (BaseCtor->isDeleted() && Diagnose) {
7042 diag::note_deleted_special_member_class_subobject)
7043 << getEffectiveCSM() << MD->
getParent() <<
false 7044 << Base->
getType() << 1 <<
false;
7047 return BaseCtor->isDeleted();
7049 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
7054 bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
7063 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
7064 << !!ICI << MD->
getParent() << FD << FieldType << 0;
7075 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
7081 AllFieldsAreConst =
false;
7087 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
7091 }
else if (IsAssignment) {
7096 << isMove() << MD->
getParent() << FD << FieldType << 0;
7111 if (!inUnion() && FieldRecord->
isUnion() &&
7113 bool AllVariantFieldsAreConst =
true;
7116 for (
auto *UI : FieldRecord->
fields()) {
7120 AllVariantFieldsAreConst =
false;
7123 if (UnionFieldRecord &&
7124 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
7134 diag::note_deleted_default_ctor_all_const)
7144 if (shouldDeleteForClassSubobject(FieldRecord, FD,
7155 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
7159 bool AnyFields =
false;
7161 if ((AnyFields = !F->isUnnamedBitfield()))
7167 diag::note_deleted_default_ctor_all_const)
7193 (CSM == CXXDefaultConstructor || CSM == CXXCopyAssignment)) {
7202 if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
7211 (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
7217 bool DeletesOnlyMatchingCopy =
7218 getLangOpts().MSVCCompat &&
7222 (!DeletesOnlyMatchingCopy || CSM == CXXCopyConstructor)) {
7223 if (!Diagnose)
return true;
7226 for (
auto *I : RD->
ctors()) {
7227 if (I->isMoveConstructor()) {
7228 UserDeclaredMove = I;
7232 assert(UserDeclaredMove);
7234 (!DeletesOnlyMatchingCopy || CSM == CXXCopyAssignment)) {
7235 if (!Diagnose)
return true;
7238 for (
auto *I : RD->
methods()) {
7239 if (I->isMoveAssignmentOperator()) {
7240 UserDeclaredMove = I;
7244 assert(UserDeclaredMove);
7247 if (UserDeclaredMove) {
7249 diag::note_deleted_copy_user_declared_move)
7250 << (CSM == CXXCopyAssignment) << RD
7262 if (CSM == CXXDestructor && MD->
isVirtual()) {
7267 OperatorDelete,
false)) {
7274 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
7282 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
7283 : SMI.VisitPotentiallyConstructedBases))
7286 if (SMI.shouldDeleteForAllConstMembers())
7289 if (getLangOpts().CUDA) {
7296 assert(ICI || CSM == getSpecialMember(MD));
7299 RealCSM = getSpecialMember(MD);
7301 return inferCUDATargetForImplicitSpecialMember(RD, RealCSM, MD,
7302 SMI.ConstArg, Diagnose);
7325 *Selected =
nullptr;
7329 llvm_unreachable(
"not a special member");
7347 for (
auto *CI : RD->
ctors()) {
7348 if (!CI->isDefaultConstructor())
7355 *Selected = DefCtor;
7388 }
else if (!Selected) {
7396 goto NeedOverloadResolution;
7406 }
else if (!Selected) {
7411 goto NeedOverloadResolution;
7415 NeedOverloadResolution:
7443 llvm_unreachable(
"unknown special method kind");
7447 for (
auto *CI : RD->
ctors())
7448 if (!CI->isImplicit())
7452 typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
7455 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
7485 ConstRHS, TAH, Diagnose ? &Selected :
nullptr))
7493 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
7496 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
7497 }
else if (!Selected)
7498 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
7503 << Kind << SubType.getUnqualifiedType() << CSM;
7505 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
7506 << Kind << SubType.getUnqualifiedType() << CSM;
7511 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
7512 << Kind << SubType.getUnqualifiedType() << CSM;
7530 for (
const auto *FI : RD->
fields()) {
7531 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
7537 if (FI->isAnonymousStructOrUnion()) {
7539 CSM, ConstArg, TAH, Diagnose))
7550 S.
Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI;
7560 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
7565 bool ConstRHS = ConstArg && !FI->isMutable();
7579 bool ConstArg = (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment);
7590 assert(!MD->
isUserProvided() && CSM != CXXInvalid &&
"not special enough");
7594 bool ConstArg =
false;
7600 case CXXDefaultConstructor:
7605 case CXXCopyConstructor:
7606 case CXXCopyAssignment: {
7622 case CXXMoveConstructor:
7623 case CXXMoveAssignment: {
7639 llvm_unreachable(
"not a special member");
7645 diag::note_nontrivial_default_arg)
7664 for (
const auto &BI : RD->bases())
7687 if (CSM == CXXDestructor && MD->
isVirtual()) {
7700 if (RD->getNumVBases()) {
7710 for (
const auto *MI : RD->methods()) {
7711 if (MI->isVirtual()) {
7713 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
7718 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
7726 struct FindHiddenVirtualMethod {
7729 llvm::SmallPtrSet<const CXXMethodDecl *, 8> OverridenAndUsingBaseMethods;
7734 static bool CheckMostOverridenMethods(
7736 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
7740 if (CheckMostOverridenMethods(O, Methods))
7756 bool foundSameNameMethod =
false;
7763 foundSameNameMethod =
true;
7780 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
7781 overloadedMethods.push_back(MD);
7785 if (foundSameNameMethod)
7786 OverloadedMethods.append(overloadedMethods.begin(),
7787 overloadedMethods.end());
7788 return foundSameNameMethod;
7795 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
7813 FindHiddenVirtualMethod FHVM;
7824 ND = shad->getTargetDecl();
7830 OverloadedMethods = FHVM.OverloadedMethods;
7835 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
7838 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
7839 HandleFunctionTypeMismatch(PD, MD->
getType(), overloadedMD->
getType());
7850 if (Diags.isIgnored(diag::warn_overloaded_virtual, MD->
getLocation()))
7854 FindHiddenVirtualMethods(MD, OverloadedMethods);
7855 if (!OverloadedMethods.empty()) {
7857 << MD << (OverloadedMethods.size() > 1);
7859 NoteHiddenVirtualMethods(MD, OverloadedMethods);
7864 auto PrintDiagAndRemoveAttr = [&]() {
7868 diag::ext_cannot_use_trivial_abi) << &RD;
7874 PrintDiagAndRemoveAttr();
7878 for (
const auto &B : RD.
bases()) {
7881 if ((!B.getType()->isDependentType() &&
7882 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) ||
7884 PrintDiagAndRemoveAttr();
7889 for (
const auto *FD : RD.
fields()) {
7894 PrintDiagAndRemoveAttr();
7899 if (!RT->isDependentType() &&
7901 PrintDiagAndRemoveAttr();
7913 AdjustDeclIfTemplate(TagDecl);
7916 if (AL.getKind() != ParsedAttr::AT_Visibility)
7919 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored)
7923 ActOnFields(S, RLoc, TagDecl, llvm::makeArrayRef(
7925 reinterpret_cast<Decl**>(FieldCollector->getCurFields()),
7926 FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList);
7928 CheckCompletedCXXClass(cast<CXXRecordDecl>(TagDecl));
7941 DeclareImplicitDefaultConstructor(ClassDecl);
7952 DeclareImplicitCopyConstructor(ClassDecl);
7963 DeclareImplicitCopyConstructor(ClassDecl);
7971 DeclareImplicitMoveConstructor(ClassDecl);
7984 DeclareImplicitCopyAssignment(ClassDecl);
7994 DeclareImplicitMoveAssignment(ClassDecl);
8006 DeclareImplicitDestructor(ClassDecl);
8019 D = TD->getTemplatedDecl();
8021 if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
8022 ParameterLists.push_back(PSD->getTemplateParameters());
8025 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
8026 ParameterLists.push_back(DD->getTemplateParameterList(i));
8030 ParameterLists.push_back(FTD->getTemplateParameters());
8034 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
8035 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
8036 ParameterLists.push_back(TD->getTemplateParameterList(i));
8040 ParameterLists.push_back(CTD->getTemplateParameters());
8046 if (Params->size() > 0)
8051 if (Param->getDeclName()) {
8053 IdResolver.AddDecl(Param);
8062 if (!RecordD)
return;
8063 AdjustDeclIfTemplate(RecordD);
8065 PushDeclContext(S, Record);
8069 if (!RecordD)
return;
8082 IdResolver.AddDecl(Param);
8114 IdResolver.AddDecl(Param);
8127 AdjustDeclIfTemplate(MethodD);
8136 CheckConstructor(Constructor);
8140 CheckCXXDefaultArguments(Method);
8175 diagnoseIgnoredQualifiers(
8187 Diag(SL, diag::err_invalid_qualified_constructor)
8240 const char *ConstRef
8243 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
8269 FindDeallocationFunctionForDestructor(Loc, RD)) {
8270 Expr *ThisArg =
nullptr;
8275 if (OperatorDelete->isDestroyingOperatorDelete()) {
8276 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
8283 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
8284 assert(!This.
isInvalid() &&
"couldn't form 'this' expr in dtor?");
8285 This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
8286 if (This.isInvalid()) {
8289 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
8292 ThisArg = This.get();
8296 DiagnoseUseOfDecl(OperatorDelete, Loc);
8297 MarkFunctionReferenced(Loc, OperatorDelete);
8321 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
8324 if (TST->isTypeAlias())
8326 << DeclaratorType << 1;
8359 diagnoseIgnoredQualifiers(diag::err_destructor_return_type, TypeQuals,
8373 Diag(SL, diag::err_invalid_qualified_destructor)
8501 bool NeedsTypedef =
false;
8505 bool PastFunctionChunk =
false;
8507 switch (Chunk.Kind) {
8509 if (!PastFunctionChunk) {
8510 if (Chunk.Fun.HasTrailingReturnType) {
8512 GetTypeFromParser(Chunk.Fun.getTrailingReturnType(), &TRT);
8515 PastFunctionChunk =
true;
8520 NeedsTypedef =
true;
8542 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
8543 DB << Before <<
After;
8545 if (!NeedsTypedef) {
8549 if (After.isInvalid() && ConvTSI) {
8594 if (DS.isExplicitSpecified())
8595 Diag(DS.getExplicitSpecLoc(),
8596 getLangOpts().CPlusPlus11
8597 ? diag::warn_cxx98_compat_explicit_conversion_functions
8598 : diag::ext_explicit_conversion_functions)
8607 assert(Conversion &&
"Expected to receive a conversion function declaration");
8625 ConvType = ConvTypeRef->getPointeeType();
8629 else if (ConvType->isRecordType()) {
8631 if (ConvType == ClassType)
8634 else if (IsDerivedFrom(Conversion->
getLocation(), ClassType, ConvType))
8636 << ClassType << ConvType;
8637 }
else if (ConvType->isVoidType()) {
8639 << ClassType << ConvType;
8644 return ConversionTemplate;
8652 struct BadSpecifierDiagnoser {
8655 ~BadSpecifierDiagnoser() {
8659 template<
typename T>
void check(
SourceLocation SpecLoc, T Spec) {
8663 return check(SpecLoc,
8669 if (!Specifiers.empty()) Specifiers +=
" ";
8675 std::string Specifiers;
8687 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
8692 if (!CurContext->getRedeclContext()->Equals(
8695 << GuidedTemplateDecl;
8696 Diag(GuidedTemplateDecl->
getLocation(), diag::note_template_decl_here);
8701 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
8702 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
8703 DS.isNoreturnSpecified() || DS.isConstexprSpecified()) {
8704 BadSpecifierDiagnoser Diagnoser(
8706 diag::err_deduction_guide_invalid_specifier);
8708 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
8713 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
8714 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
8715 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
8716 DS.ClearConstexprSpec();
8718 Diagnoser.check(DS.getConstSpecLoc(),
"const");
8719 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
8720 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
8721 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
8722 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
8723 DS.ClearTypeQualifiers();
8725 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
8726 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
8727 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
8728 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
8729 DS.ClearTypeSpecType();
8736 bool FoundFunction =
false;
8742 diag::err_deduction_guide_with_complex_decl)
8746 if (!Chunk.Fun.hasTrailingReturnType()) {
8748 diag::err_deduction_guide_no_trailing_return_type);
8754 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
8756 QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
8757 assert(TSI &&
"deduction guide has valid type but invalid return type?");
8758 bool AcceptableReturnType =
false;
8759 bool MightInstantiateToSpecialization =
false;
8762 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
8763 bool TemplateMatches =
8766 AcceptableReturnType =
true;
8771 MightInstantiateToSpecialization = !(TD && isa<ClassTemplateDecl>(TD) &&
8775 MightInstantiateToSpecialization =
true;
8778 if (!AcceptableReturnType) {
8780 diag::err_deduction_guide_bad_trailing_return_type)
8781 << GuidedTemplate << TSI->
getType()
8782 << MightInstantiateToSpecialization
8788 FoundFunction =
true;
8805 assert(*IsInline != PrevNS->
isInline());
8813 if (*IsInline && II && II->
getName().startswith(
"__atomic") &&
8818 NS->setInline(*IsInline);
8821 for (
auto *I : PrevNS->
decls())
8822 if (
auto *ND = dyn_cast<NamedDecl>(I))
8830 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
8833 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
8848 bool IsInline = InlineLoc.
isValid();
8849 bool IsInvalid =
false;
8851 bool AddToKnown =
false;
8867 LookupResult R(*
this, II, IdentLoc, LookupOrdinaryName,
8868 ForExternalRedeclaration);
8869 LookupQualifiedName(R, CurContext->getRedeclContext());
8872 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
8876 if (IsInline != PrevNS->
isInline())
8879 }
else if (PrevDecl) {
8881 Diag(Loc, diag::err_redefinition_different_kind)
8883 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
8886 }
else if (II->
isStr(
"std") &&
8887 CurContext->getRedeclContext()->isTranslationUnit()) {
8890 PrevNS = getStdNamespace();
8892 AddToKnown = !IsInline;
8895 AddToKnown = !IsInline;
8909 if (PrevNS && IsInline != PrevNS->
isInline())
8915 StartLoc, Loc, II, PrevNS);
8919 ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
8920 AddPragmaAttributes(DeclRegionScope, Namespc);
8923 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
8924 PushNamespaceVisibilityAttr(
Attr, Loc);
8927 StdNamespace = Namespc;
8929 KnownNamespaces[Namespc] =
false;
8932 PushOnScopeChains(Namespc, DeclRegionScope);
8937 TU->setAnonymousNamespace(Namespc);
8939 cast<NamespaceDecl>(
Parent)->setAnonymousNamespace(Namespc);
8942 CurContext->addDecl(Namespc);
8973 ActOnDocumentableDecl(Namespc);
8980 PushDeclContext(NamespcScope, Namespc);
8988 return AD->getNamespace();
8989 return dyn_cast_or_null<NamespaceDecl>(D);
8995 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
8996 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
8999 if (Namespc->
hasAttr<VisibilityAttr>())
9000 PopPragmaVisibility(
true, RBrace);
9004 return cast_or_null<CXXRecordDecl>(
9013 return cast_or_null<NamespaceDecl>(
9018 if (!StdExperimentalNamespaceCache) {
9019 if (
auto Std = getStdNamespace()) {
9022 if (!LookupQualifiedName(
Result,
Std) ||
9023 !(StdExperimentalNamespaceCache =
9025 Result.suppressDiagnostics();
9028 return StdExperimentalNamespaceCache;
9040 struct InvalidSTLDiagnoser {
9046 const VarDecl *VD =
nullptr) {
9048 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
9049 << TyForDiags << ((int)Sel);
9050 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
9051 assert(!Name.empty());
9055 if (Sel == USS_InvalidMember) {
9056 S.
Diag(VD->getLocation(), diag::note_var_declared_here)
9057 << VD << VD->getSourceRange();
9067 "Looking for comparison category type outside of C++.");
9072 if (Info && FullyCheckedComparisonCategories[static_cast<unsigned>(Kind)])
9077 std::string NameForDiags =
"std::";
9079 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
9084 assert(Info->
Kind == Kind);
9100 if (RequireCompleteType(Loc, TyForDiags, diag::err_incomplete_type))
9103 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags};
9106 return UnsupportedSTLError(USS_NonTrivial);
9114 return UnsupportedSTLError();
9123 !FIt->getType()->isIntegralOrEnumerationType()) {
9124 return UnsupportedSTLError();
9134 return UnsupportedSTLError(USS_MissingMember, MemName);
9137 assert(VD &&
"should not be null!");
9144 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
9150 return UnsupportedSTLError();
9152 MarkVariableReferenced(Loc, VD);
9157 FullyCheckedComparisonCategories[
static_cast<unsigned>(
Kind)] =
true;
9164 if (!StdNamespace) {
9170 &PP.getIdentifierTable().get(
"std"),
9175 return getStdNamespace();
9180 "Looking for std::initializer_list outside of C++.");
9195 if (!Specialization)
9202 Template = dyn_cast_or_null<ClassTemplateDecl>(
9203 TST->getTemplateName().getAsTemplateDecl());
9204 Arguments = TST->getArgs();
9209 if (!StdInitializerList) {
9213 &PP.getIdentifierTable().get(
"initializer_list") ||
9214 !getStdNamespace()->InEnclosingNamespaceSetOf(
9222 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
9226 StdInitializerList = Template;
9241 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
9248 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
9253 Result.suppressDiagnostics();
9256 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
9264 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
9265 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
9273 if (!StdInitializerList) {
9275 if (!StdInitializerList)
9284 CheckTemplateIdType(
TemplateName(StdInitializerList), Loc, Args));
9301 return isStdInitializerList(ArgType,
nullptr);
9308 case Decl::TranslationUnit:
9310 case Decl::LinkageSpec:
9322 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
9324 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
9338 llvm::make_unique<NamespaceValidatorCCC>(),
9341 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
9342 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
9343 Ident->
getName().equals(CorrectedStr);
9345 S.
PDiag(diag::err_using_directive_member_suggest)
9346 << Ident << DC << DroppedSpecifier << SS.getRange(),
9347 S.
PDiag(diag::note_namespace_defined_here));
9350 S.
PDiag(diag::err_using_directive_suggest) << Ident,
9351 S.
PDiag(diag::note_namespace_defined_here));
9353 R.
addDecl(Corrected.getFoundDecl());
9364 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9365 assert(NamespcName &&
"Invalid NamespcName.");
9366 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
9379 LookupResult R(*
this, NamespcName, IdentLoc, LookupNamespaceName);
9380 LookupParsedName(R, S, &SS);
9389 NamespcName->
isStr(
"std")) {
9390 Diag(IdentLoc, diag::ext_using_undefined_std);
9391 R.
addDecl(getOrCreateStdNamespace());
9401 assert(NS &&
"expected namespace decl");
9404 DiagnoseUseOfDecl(Named, IdentLoc);
9419 while (CommonAncestor && !CommonAncestor->
Encloses(CurContext))
9420 CommonAncestor = CommonAncestor->
getParent();
9424 IdentLoc, Named, CommonAncestor);
9427 !SourceMgr.isInMainFile(SourceMgr.getExpansionLoc(IdentLoc))) {
9428 Diag(IdentLoc, diag::warn_using_directive_in_header);
9431 PushUsingDirective(S, UDir);
9433 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
9437 ProcessDeclAttributeList(S, UDir, AttrList);
9480 getLangOpts().CPlusPlus11
9481 ? diag::warn_cxx98_compat_using_decl_constructor
9482 : diag::err_using_decl_constructor)
9499 llvm_unreachable(
"cannot parse qualified deduction guide name");
9510 ? diag::err_access_decl
9511 : diag::warn_access_decl_deprecated)
9516 if (DiagnoseUnexpandedParameterPack(SS, UPPC_UsingDeclaration) ||
9517 DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC_UsingDeclaration))
9522 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
9529 BuildUsingDeclaration(S, AS, UsingLoc, TypenameLoc.
isValid(), TypenameLoc,
9530 SS, TargetNameInfo, EllipsisLoc, AttrList,
9533 PushOnScopeChains(UD, S,
false);
9548 return Context.
hasSameType(TD1->getUnderlyingType(),
9549 TD2->getUnderlyingType());
9579 if (!getLangOpts().
CPlusPlus11 && CurContext->isRecord()) {
9583 if (isa<EnumDecl>(OrigDC)) OrigDC = OrigDC->
getParent();
9588 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(OrigRec)) {
9589 if (OrigDC == CurContext) {
9591 diag::err_using_decl_nested_name_specifier_is_current_class)
9599 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9601 << cast<CXXRecordDecl>(CurContext)
9609 if (Previous.
empty())
return false;
9612 if (isa<UsingShadowDecl>(Target))
9613 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
9620 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
9621 bool FoundEquivalentDecl =
false;
9628 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D))
9631 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
9636 !isa<IndirectFieldDecl>(Target) &&
9637 !isa<UnresolvedUsingValueDecl>(
Target) &&
9638 DiagnoseClassNameShadow(
9646 PrevShadow = Shadow;
9647 FoundEquivalentDecl =
true;
9648 }
else if (isEquivalentInternalLinkageDeclaration(D, Target)) {
9651 FoundEquivalentDecl =
true;
9655 (isa<TagDecl>(D) ? Tag : NonTag) = D;
9658 if (FoundEquivalentDecl)
9663 switch (CheckOverload(
nullptr, FD, Previous, OldDecl,
9668 case Ovl_NonFunction:
9677 if (CurContext->isRecord())
9693 if (isa<TagDecl>(Target)) {
9695 if (!Tag)
return false;
9699 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
9705 if (!NonTag)
return false;
9718 for (
auto &B : Derived->
bases())
9719 if (B.getType()->getAsCXXRecordDecl() == Base)
9720 return B.isVirtual();
9721 llvm_unreachable(
"not a direct base class");
9731 if (isa<UsingShadowDecl>(Target)) {
9732 Target = cast<UsingShadowDecl>(
Target)->getTargetDecl();
9733 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
9737 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
9738 NonTemplateTarget = TargetTD->getTemplatedDecl();
9741 if (isa<CXXConstructorDecl>(NonTemplateTarget)) {
9742 bool IsVirtualBase =
9746 Context, CurContext, UD->
getLocation(), UD, Orig, IsVirtualBase);
9760 PushOnScopeChains(Shadow, S);
9762 CurContext->addDecl(Shadow);
9798 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
9806 IdResolver.RemoveDecl(Shadow);
9819 bool &AnyDependentBases) {
9822 for (
auto &Base : Derived->
bases()) {
9824 if (CanonicalDesiredBase == BaseType)
9826 if (BaseType->isDependentType())
9827 AnyDependentBases =
true;
9835 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
9837 : HasTypenameKeyword(HasTypenameKeyword),
9838 IsInstantiation(IsInstantiation), OldNNS(NNS),
9839 RequireMemberOf(RequireMemberOf) {}
9841 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
9845 if (!ND || isa<NamespaceDecl>(ND))
9855 if (RequireMemberOf) {
9857 if (FoundRecord && FoundRecord->isInjectedClassName()) {
9878 bool AnyDependentBases =
false;
9881 AnyDependentBases) &&
9893 if (FoundRecord && FoundRecord->isInjectedClassName())
9897 if (isa<TypeDecl>(ND))
9898 return HasTypenameKeyword || !IsInstantiation;
9900 return !HasTypenameKeyword;
9904 bool HasTypenameKeyword;
9905 bool IsInstantiation;
9921 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9923 assert(IdentLoc.isValid() &&
"Invalid TargetName location.");
9932 if (
auto *RD = dyn_cast<CXXRecordDecl>(CurContext))
9938 ForVisibleRedeclaration);
9941 LookupName(Previous, S);
9947 if (!isDeclInScope(D, CurContext, S))
9959 assert(IsInstantiation &&
"no scope in non-instantiation");
9960 if (CurContext->isRecord())
9961 LookupQualifiedName(Previous, CurContext);
9980 if (CheckUsingDeclRedeclaration(UsingLoc, HasTypenameKeyword,
9981 SS, IdentLoc, Previous))
9985 if (CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo,
9989 DeclContext *LookupContext = computeDeclContext(SS);
9992 if (!LookupContext || EllipsisLoc.
isValid()) {
9993 if (HasTypenameKeyword) {
9996 UsingLoc, TypenameLoc,
10002 QualifierLoc, NameInfo, EllipsisLoc);
10005 CurContext->addDecl(D);
10009 auto Build = [&](
bool Invalid) {
10012 UsingName, HasTypenameKeyword);
10014 CurContext->addDecl(UD);
10018 auto BuildInvalid = [&]{
return Build(
true); };
10019 auto BuildValid = [&]{
return Build(
false); };
10021 if (RequireCompleteDeclContext(SS, LookupContext))
10022 return BuildInvalid();
10031 if (!IsInstantiation)
10036 if (CurContext->isRecord()) {
10041 LookupQualifiedName(R, LookupContext);
10054 if (getLangOpts().
CPlusPlus14 && II && II->isStr(
"gets") &&
10055 CurContext->isStdNamespace() &&
10056 isa<TranslationUnitDecl>(LookupContext) &&
10057 getSourceManager().isInSystemHeader(UsingLoc))
10061 llvm::make_unique<UsingValidatorCCC>(
10062 HasTypenameKeyword, IsInstantiation, SS.getScopeRep(),
10064 CTK_ErrorRecovery)) {
10067 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
10068 << NameInfo.
getName() << LookupContext << 0
10073 NamedDecl *ND = Corrected.getCorrectionDecl();
10075 return BuildInvalid();
10081 RD = cast<CXXRecordDecl>(RD->
getParent());
10084 if (Corrected.WillReplaceSpecifier()) {
10086 Builder.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
10093 auto *CurClass = cast<CXXRecordDecl>(CurContext);
10096 UsingName.setNamedTypeInfo(
nullptr);
10097 for (
auto *Ctor : LookupConstructors(RD))
10103 UsingName.setName(ND->getDeclName());
10107 Diag(IdentLoc, diag::err_no_member)
10108 << NameInfo.
getName() << LookupContext << SS.getRange();
10109 return BuildInvalid();
10114 return BuildInvalid();
10116 if (HasTypenameKeyword) {
10119 Diag(IdentLoc, diag::err_using_typename_non_type);
10121 Diag((*I)->getUnderlyingDecl()->getLocation(),
10122 diag::note_using_decl_target);
10123 return BuildInvalid();
10130 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
10132 return BuildInvalid();
10139 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
10141 return BuildInvalid();
10147 if (cast<EnumDecl>(ED->getDeclContext())->isScoped()) {
10148 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
10150 return BuildInvalid();
10157 if (UsingName.getName().getNameKind() ==
10162 if (CheckInheritingConstructorUsingDecl(UD))
10168 if (!CheckUsingShadowDecl(UD, *I, Previous, PrevDecl))
10169 BuildUsingShadowDecl(S, UD, *I, PrevDecl);
10177 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
10178 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
10179 isa<UsingPackDecl>(InstantiatedFrom));
10183 UPD->setAccess(InstantiatedFrom->
getAccess());
10184 CurContext->addDecl(UPD);
10190 assert(!UD->
hasTypename() &&
"expecting a constructor name");
10193 assert(SourceType &&
10194 "Using decl naming constructor doesn't have type in scope spec.");
10195 CXXRecordDecl *TargetClass = cast<CXXRecordDecl>(CurContext);
10198 bool AnyDependentBases =
false;
10200 AnyDependentBases);
10201 if (!Base && !AnyDependentBases) {
10203 diag::err_using_decl_constructor_not_in_direct_base)
10205 <<
QualType(SourceType, 0) << TargetClass;
10220 bool HasTypenameKeyword,
10233 if (!CurContext->getRedeclContext()->isRecord()) {
10239 if (Qual->
isDependent() && !HasTypenameKeyword) {
10240 for (
auto *D : Prev) {
10241 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
10242 bool OldCouldBeEnumerator =
10243 isa<UnresolvedUsingValueDecl>(D) || isa<EnumConstantDecl>(D);
10245 OldCouldBeEnumerator ? diag::err_redefinition
10246 : diag::err_redefinition_different_kind)
10247 << Prev.getLookupName();
10248 Diag(D->getLocation(), diag::note_previous_definition);
10261 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
10262 DTypename = UD->hasTypename();
10263 DQual = UD->getQualifier();
10265 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
10267 DQual = UD->getQualifier();
10269 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
10271 DQual = UD->getQualifier();
10276 if (HasTypenameKeyword != DTypename)
continue;
10285 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
10302 DeclContext *NamedContext = computeDeclContext(SS);
10304 if (!CurContext->isRecord()) {
10312 if ((HasTypename && !NamedContext) ||
10314 auto *RD = NamedContext
10317 if (RD && RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), RD))
10320 Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member)
10332 LookupQualifiedName(R, RD);
10337 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
10345 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
10355 if (getLangOpts().CPlusPlus11) {
10361 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
10376 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
10377 << (getLangOpts().CPlusPlus11 ? 4 : 3)
10390 if (!NamedContext) {
10404 diag::err_using_decl_nested_name_specifier_is_not_class)
10410 RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), NamedContext))
10413 if (getLangOpts().CPlusPlus11) {
10419 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(
10420 cast<CXXRecordDecl>(NamedContext))) {
10421 if (CurContext == NamedContext) {
10423 diag::err_using_decl_nested_name_specifier_is_current_class)
10428 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
10430 diag::err_using_decl_nested_name_specifier_is_not_base_class)
10432 << cast<CXXRecordDecl>(CurContext)
10454 llvm::SmallPtrSet<const CXXRecordDecl *, 4> Bases;
10456 Bases.insert(Base);
10461 if (!cast<CXXRecordDecl>(CurContext)->forallBases(Collect))
10467 return !Bases.count(Base);
10472 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
10473 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
10477 diag::err_using_decl_nested_name_specifier_is_not_base_class)
10479 << cast<CXXRecordDecl>(CurContext)
10494 "got alias-declaration outside of declaration scope");
10499 bool Invalid =
false;
10502 GetTypeFromParser(Type.
get(), &TInfo);
10504 if (DiagnoseClassNameShadow(CurContext, NameInfo))
10507 if (DiagnoseUnexpandedParameterPack(Name.
StartLocation, TInfo,
10508 UPPC_DeclarationType)) {
10515 TemplateParamLists.size()
10516 ? forRedeclarationInCurContext()
10517 : ForVisibleRedeclaration);
10522 Previous.getFoundDecl()->isTemplateParameter()) {
10528 "name in alias declaration must be an identifier");
10538 ProcessDeclAttributeList(S, NewTD, AttrList);
10539 AddPragmaAttributes(S, NewTD);
10541 CheckTypedefForVariablyModifiedType(S, NewTD);
10544 bool Redeclaration =
false;
10547 if (TemplateParamLists.size()) {
10551 if (TemplateParamLists.size() != 1) {
10552 Diag(UsingLoc, diag::err_alias_template_extra_headers)
10553 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
10554 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
10559 if (CheckTemplateDeclScope(S, TemplateParams))
10563 FilterLookupForScope(
Previous, CurContext, S,
false,
10566 Redeclaration =
true;
10569 if (!OldDecl && !Invalid) {
10570 Diag(UsingLoc, diag::err_redefinition_different_kind)
10581 if (TemplateParameterListsAreEqual(TemplateParams,
10584 TPL_TemplateMatch))
10585 OldTemplateParams =
10607 if (CheckTemplateParameterList(TemplateParams, OldTemplateParams,
10608 TPC_TypeAliasTemplate))
10621 else if (OldDecl) {
10623 CheckRedeclarationModuleOwnership(NewDecl, OldDecl);
10628 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
10629 setTagNameForLinkagePurposes(TD, NewTD);
10630 handleTagNumbering(TD, S);
10632 ActOnTypedefNameDecl(S, CurContext, NewTD,
Previous, Redeclaration);
10636 PushOnScopeChains(NewND, S);
10637 ActOnDocumentableDecl(NewND);
10648 LookupResult R(*
this, Ident, IdentLoc, LookupNamespaceName);
10649 LookupParsedName(R, S, &SS);
10656 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
10664 LookupResult PrevR(*
this, Alias, AliasLoc, LookupOrdinaryName,
10665 ForVisibleRedeclaration);
10666 LookupName(PrevR, S);
10670 DiagnoseTemplateParameterShadow(AliasLoc, PrevR.
getFoundDecl());
10675 FilterLookupForScope(PrevR, CurContext, S,
false,
10687 }
else if (isVisible(PrevDecl)) {
10688 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
10690 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
10691 << AD->getNamespace();
10694 }
else if (isVisible(PrevDecl)) {
10696 ? diag::err_redefinition
10697 : diag::err_redefinition_different_kind;
10698 Diag(AliasLoc, DiagID) << Alias;
10705 DiagnoseUseOfDecl(ND, IdentLoc);
10714 PushOnScopeChains(AliasDecl, S);
10719 struct SpecialMemberExceptionSpecInfo
10720 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
10728 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
10733 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
10736 void visitSubobjectCall(Subobject Subobj,
10746 auto *BaseClass = cast<CXXRecordDecl>(RT->getDecl());
10748 if (
auto *BaseCtor = SMOR.getMethod()) {
10749 visitSubobjectCall(Base, BaseCtor);
10753 visitClassSubobject(BaseClass, Base, 0);
10757 bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
10768 ExceptSpec.CalledExpr(E);
10770 ->getAs<RecordType>()) {
10771 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
10777 void SpecialMemberExceptionSpecInfo::visitClassSubobject(
CXXRecordDecl *Class,
10781 bool IsMutable = Field && Field->
isMutable();
10782 visitSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable));
10785 void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
10790 ExceptSpec.CalledDecl(getSubobjectLoc(Subobj), MD);
10795 struct ComputingExceptionSpec {
10806 ~ComputingExceptionSpec() {
10816 ComputingExceptionSpec CES(S, MD, Loc);
10823 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
10825 return Info.ExceptSpec;
10832 diag::err_exception_spec_incomplete_type))
10833 return Info.ExceptSpec;
10850 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
10851 : Info.VisitAllBases);
10853 return Info.ExceptSpec;
10858 struct DeclaringSpecialMember {
10862 bool WasAlreadyBeingDeclared;
10865 : S(S), D(RD, CSM), SavedContext(S, RD) {
10867 if (WasAlreadyBeingDeclared)
10888 ~DeclaringSpecialMember() {
10889 if (!WasAlreadyBeingDeclared) {
10896 bool isAlreadyBeingDeclared()
const {
10897 return WasAlreadyBeingDeclared;
10907 ForExternalRedeclaration);
10914 CheckFunctionDeclaration(S, FD, R,
false);
10917 void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
10923 if (getLangOpts().OpenCLCPlusPlus) {
10942 "Should not build implicit default constructor!");
10944 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDefaultConstructor);
10945 if (DSM.isAlreadyBeingDeclared())
10949 CXXDefaultConstructor,
10960 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
10961 nullptr,
false,
true,
10966 if (getLangOpts().CUDA) {
10967 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDefaultConstructor,
10973 setupImplicitSpecialMemberType(DefaultCon, Context.
VoidTy,
None);
10982 Scope *S = getScopeForContext(ClassDecl);
10983 CheckImplicitSpecialMemberDeclaration(S, DefaultCon);
10985 if (ShouldDeleteSpecialMember(DefaultCon, CXXDefaultConstructor))
10986 SetDeclDeleted(DefaultCon, ClassLoc);
10989 PushOnScopeChains(DefaultCon, S,
false);
10990 ClassDecl->
addDecl(DefaultCon);
11000 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
11005 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
11011 ResolveExceptionSpec(CurrentLocation,
11013 MarkVTableUsed(CurrentLocation, ClassDecl);
11018 if (SetCtorInitializers(Constructor,
false)) {
11030 L->CompletedImplicitDefinition(Constructor);
11033 DiagnoseUninitializedFields(*
this, Constructor);
11038 CheckDelayedMemberExceptionSpecs();
11059 ->getInheritedConstructor()
11062 return cast<CXXConstructorDecl>(Ctor);
11077 false, BaseCtor, &ICI);
11080 Context, Derived, UsingLoc, NameInfo, TInfo->
getType(), TInfo,
11091 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
11097 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
11101 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
11108 ParamDecls.push_back(PD);
11113 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
11116 Derived->
addDecl(DerivedCtor);
11118 if (ShouldDeleteSpecialMember(DerivedCtor, CXXDefaultConstructor, &ICI))
11119 SetDeclDeleted(DerivedCtor, UsingLoc);
11121 return DerivedCtor;
11127 ShouldDeleteSpecialMember(Ctor, CXXDefaultConstructor, &ICI,
11146 ResolveExceptionSpec(CurrentLocation,
11148 MarkVTableUsed(CurrentLocation, ClassDecl);
11170 for (
bool VBase : {
false,
true}) {
11172 if (B.isVirtual() != VBase)
11175 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
11180 if (!BaseCtor.first)
11183 MarkFunctionReferenced(CurrentLocation, BaseCtor.first);
11185 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
11189 Context, TInfo, VBase, InitLoc, Init.
get(), InitLoc,
11197 if (SetCtorInitializers(Constructor,
false, Inits)) {
11206 L->CompletedImplicitDefinition(Constructor);
11209 DiagnoseUninitializedFields(*
this, Constructor);
11219 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDestructor);
11220 if (DSM.isAlreadyBeingDeclared())
11237 if (getLangOpts().CUDA) {
11238 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDestructor,
11244 setupImplicitSpecialMemberType(Destructor, Context.
VoidTy,
None);
11255 Scope *S = getScopeForContext(ClassDecl);
11256 CheckImplicitSpecialMemberDeclaration(S, Destructor);
11262 ShouldDeleteSpecialMember(Destructor, CXXDestructor))
11263 SetDeclDeleted(Destructor, ClassLoc);
11267 PushOnScopeChains(Destructor, S,
false);
11268 ClassDecl->
addDecl(Destructor);
11278 "DefineImplicitDestructor - call it for implicit default dtor");
11283 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
11289 ResolveExceptionSpec(CurrentLocation,
11291 MarkVTableUsed(CurrentLocation, ClassDecl);
11296 MarkBaseAndMemberDestructorsReferenced(Destructor->
getLocation(),
11299 if (CheckDestructor(Destructor)) {
11311 L->CompletedImplicitDefinition(Destructor);
11319 if (
CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(CurContext)) {
11320 if (Record->isInvalidDecl()) {
11321 DelayedOverridingExceptionSpecChecks.clear();
11322 DelayedEquivalentExceptionSpecChecks.clear();
11323 DelayedDefaultedMemberExceptionSpecs.clear();
11331 referenceDLLExportedClassMethods();
11335 if (!DelayedDllExportClasses.empty()) {
11339 std::swap(DelayedDllExportClasses, WorkList);
11347 "adjusting dtor exception specs was introduced in c++11");
11357 getAs<FunctionProtoType>();
11380 class ExprBuilder {
11381 ExprBuilder(
const ExprBuilder&) =
delete;
11382 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
11385 static Expr *assertNotNull(
Expr *E) {
11386 assert(E &&
"Expression construction must not fail.");
11392 virtual ~ExprBuilder() {}
11397 class RefBuilder:
public ExprBuilder {
11407 : Var(Var), VarType(VarType) {}
11410 class ThisBuilder:
public ExprBuilder {
11417 class CastBuilder:
public ExprBuilder {
11418 const ExprBuilder &Builder;
11426 CK_UncheckedDerivedToBase,
Kind,
11432 : Builder(Builder), Type(Type),
Kind(Kind), Path(Path) {}
11435 class DerefBuilder:
public ExprBuilder {
11436 const ExprBuilder &Builder;
11440 return assertNotNull(
11444 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11447 class MemberBuilder:
public ExprBuilder {
11448 const ExprBuilder &Builder;
11457 Builder.build(S, Loc), Type, Loc, IsArrow, SS,
SourceLocation(),
11458 nullptr, MemberLookup,
nullptr,
nullptr).
get());
11461 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
11463 : Builder(Builder), Type(Type), IsArrow(IsArrow),
11464 MemberLookup(MemberLookup) {}
11467 class MoveCastBuilder:
public ExprBuilder {
11468 const ExprBuilder &Builder;
11472 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
11475 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11478 class LvalueConvBuilder:
public ExprBuilder {
11479 const ExprBuilder &Builder;
11483 return assertNotNull(
11487 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11490 class SubscriptBuilder:
public ExprBuilder {
11491 const ExprBuilder &Base;
11492 const ExprBuilder &Index;
11497 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
11500 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
11501 : Base(Base), Index(Index) {}
11512 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
11521 Expr *From = FromB.build(S, Loc);
11525 Expr *To = ToB.build(S, Loc);
11531 bool NeedsCollectableMemCpy =
11535 StringRef MemCpyName = NeedsCollectableMemCpy ?
11536 "__builtin_objc_memmove_collectable" :
11537 "__builtin_memcpy";
11550 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
11552 Expr *CallArgs[] = {
11556 Loc, CallArgs, Loc);
11558 assert(!Call.
isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
11591 const ExprBuilder &To,
const ExprBuilder &From,
11592 bool CopyingBaseSubobject,
bool Copying,
11593 unsigned Depth = 0) {
11609 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
11624 if (Method->isCopyAssignmentOperator() ||
11625 (!Copying && Method->isMoveAssignmentOperator()))
11644 if (CopyingBaseSubobject) {
11675 Expr *FromInst = From.build(S, Loc);
11678 Loc, FromInst, Loc);
11698 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
11718 llvm::raw_svector_ostream OS(Str);
11719 OS <<
"__i" <<
Depth;
11723 IterationVarName, SizeType,
11732 RefBuilder IterationVarRef(IterationVar, SizeType);
11733 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
11739 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
11740 MoveCastBuilder FromIndexMove(FromIndexCopy);
11741 const ExprBuilder *FromIndex;
11743 FromIndex = &FromIndexCopy;
11745 FromIndex = &FromIndexMove;
11747 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
11752 ToIndex, *FromIndex, CopyingBaseSubobject,
11753 Copying,
Depth + 1);
11755 if (Copy.isInvalid() || !Copy.get())
11771 UnaryOperator(IterationVarRef.build(S, Loc), UO_PreInc, SizeType,
11776 Loc, Loc, InitStmt,
11783 const ExprBuilder &To,
const ExprBuilder &From,
11784 bool CopyingBaseSubobject,
bool Copying) {
11791 CopyingBaseSubobject,
11796 if (!Result.isInvalid() && !Result.get())
11809 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyAssignment);
11810 if (DSM.isAlreadyBeingDeclared())
11841 if (getLangOpts().CUDA) {
11842 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyAssignment,
11848 setupImplicitSpecialMemberType(CopyAssignment, RetType, ArgType);
11852 ClassLoc, ClassLoc,
11860 ? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
11866 Scope *S = getScopeForContext(ClassDecl);
11867 CheckImplicitSpecialMemberDeclaration(S, CopyAssignment);
11869 if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment))
11870 SetDeclDeleted(CopyAssignment, ClassLoc);
11873 PushOnScopeChains(CopyAssignment, S,
false);
11874 ClassDecl->
addDecl(CopyAssignment);
11876 return CopyAssignment;
11890 if (RD->hasUserDeclaredDestructor()) {
11891 UserDeclaredOperation = RD->getDestructor();
11892 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
11893 RD->hasUserDeclaredCopyConstructor() &&
11896 for (
auto *I : RD->ctors()) {
11897 if (I->isCopyConstructor()) {
11898 UserDeclaredOperation = I;
11902 assert(UserDeclaredOperation);
11903 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
11904 RD->hasUserDeclaredCopyAssignment() &&
11907 for (
auto *I : RD->methods()) {
11908 if (I->isCopyAssignmentOperator()) {
11909 UserDeclaredOperation = I;
11913 assert(UserDeclaredOperation);
11916 if (UserDeclaredOperation) {
11918 diag::warn_deprecated_copy_operation)
11919 << RD << !isa<CXXConstructorDecl>(CopyOp)
11920 << isa<CXXDestructorDecl>(UserDeclaredOperation);
11931 "DefineImplicitCopyAssignment called for wrong function");
11945 ResolveExceptionSpec(CurrentLocation,
11985 RefBuilder OtherRef(Other, OtherRefType);
11991 bool Invalid =
false;
11992 for (
auto &Base : ClassDecl->
bases()) {
12002 BasePath.push_back(&Base);
12006 CastBuilder From(OtherRef, Context.
getQualifiedType(BaseType, OtherQuals),
12010 DerefBuilder DerefThis(This);
12011 CastBuilder To(DerefThis,
12027 Statements.push_back(Copy.
getAs<
Expr>());
12031 for (
auto *Field : ClassDecl->
fields()) {
12034 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
12037 if (Field->isInvalidDecl()) {
12043 if (Field->getType()->isReferenceType()) {
12044 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12045 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
12046 Diag(Field->getLocation(), diag::note_declared_at);
12054 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12055 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
12056 Diag(Field->getLocation(), diag::note_declared_at);
12062 if (Field->isZeroLengthBitField(Context))
12065 QualType FieldType = Field->getType().getNonReferenceType();
12068 "Incomplete array type is not valid");
12074 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
12077 MemberLookup.resolveKind();
12079 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
12081 MemberBuilder To(This, getCurrentThisType(),
true, MemberLookup);
12094 Statements.push_back(Copy.
getAs<
Stmt>());
12099 ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
12102 if (Return.isInvalid())
12105 Statements.push_back(Return.getAs<
Stmt>());
12116 Body = ActOnCompoundStmt(Loc, Loc, Statements,
12118 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
12121 CopyAssignOperator->
markUsed(Context);
12124 L->CompletedImplicitDefinition(CopyAssignOperator);
12131 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveAssignment);
12132 if (DSM.isAlreadyBeingDeclared())
12159 if (getLangOpts().CUDA) {
12160 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveAssignment,
12173 ClassLoc, ClassLoc,
12181 ? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
12187 Scope *S = getScopeForContext(ClassDecl);
12188 CheckImplicitSpecialMemberDeclaration(S, MoveAssignment);
12190 if (ShouldDeleteSpecialMember(MoveAssignment, CXXMoveAssignment)) {
12192 SetDeclDeleted(MoveAssignment, ClassLoc);
12196 PushOnScopeChains(MoveAssignment, S,
false);
12197 ClassDecl->
addDecl(MoveAssignment);
12199 return MoveAssignment;
12218 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
12221 for (
auto &BI : Class->
bases()) {
12222 Worklist.push_back(&BI);
12223 while (!Worklist.empty()) {
12256 if (Existing && Existing != &BI) {
12257 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
12260 << (Base->getCanonicalDecl() ==
12263 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
12264 << (Base->getCanonicalDecl() ==
12265 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
12269 Existing =
nullptr;
12279 for (
auto &BI : Base->
bases())
12280 Worklist.push_back(&BI);
12293 "DefineImplicitMoveAssignment called for wrong function");
12319 ResolveExceptionSpec(CurrentLocation,
12331 getAs<RValueReferenceType>()->getPointeeType();
12339 RefBuilder OtherRef(Other, OtherRefType);
12341 MoveCastBuilder MoveOther(OtherRef);
12347 bool Invalid =
false;
12348 for (
auto &Base : ClassDecl->
bases()) {
12366 BasePath.push_back(&Base);
12370 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
12373 DerefBuilder DerefThis(This);
12376 CastBuilder To(DerefThis,
12392 Statements.push_back(Move.
getAs<
Expr>());
12396 for (
auto *Field : ClassDecl->
fields()) {
12399 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
12402 if (Field->isInvalidDecl()) {
12408 if (Field->getType()->isReferenceType()) {
12409 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12410 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
12411 Diag(Field->getLocation(), diag::note_declared_at);
12419 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12420 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
12421 Diag(Field->getLocation(), diag::note_declared_at);
12427 if (Field->isZeroLengthBitField(Context))
12430 QualType FieldType = Field->getType().getNonReferenceType();
12433 "Incomplete array type is not valid");
12438 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
12441 MemberLookup.resolveKind();
12442 MemberBuilder From(MoveOther, OtherRefType,
12443 false, MemberLookup);
12444 MemberBuilder To(This, getCurrentThisType(),
12445 true, MemberLookup);
12447 assert(!From.build(*
this, Loc)->isLValue() &&
12448 "Member reference with rvalue base must be rvalue except for reference " 12449 "members, which aren't allowed for move assignment.");
12456 if (Move.isInvalid()) {
12462 Statements.push_back(Move.getAs<
Stmt>());
12468 CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
12471 if (Return.isInvalid())
12474 Statements.push_back(Return.getAs<
Stmt>());
12485 Body = ActOnCompoundStmt(Loc, Loc, Statements,
12487 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
12490 MoveAssignOperator->
markUsed(Context);
12493 L->CompletedImplicitDefinition(MoveAssignOperator);
12504 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyConstructor);
12505 if (DSM.isAlreadyBeingDeclared())
12520 CXXCopyConstructor,
12532 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12538 if (getLangOpts().CUDA) {
12539 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyConstructor,
12545 setupImplicitSpecialMemberType(CopyConstructor, Context.
VoidTy, ArgType);
12549 ClassLoc, ClassLoc,
12557 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
12561 ClassDecl->
hasAttr<TrivialABIAttr>() ||
12563 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor,
12564 TAH_ConsiderTrivialABI)
12570 Scope *S = getScopeForContext(ClassDecl);
12571 CheckImplicitSpecialMemberDeclaration(S, CopyConstructor);
12573 if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) {
12575 SetDeclDeleted(CopyConstructor, ClassLoc);
12579 PushOnScopeChains(CopyConstructor, S,
false);
12580 ClassDecl->
addDecl(CopyConstructor);
12582 return CopyConstructor;
12591 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
12596 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
12602 ResolveExceptionSpec(CurrentLocation,
12604 MarkVTableUsed(CurrentLocation, ClassDecl);
12616 if (SetCtorInitializers(CopyConstructor,
false)) {
12624 ActOnCompoundStmt(Loc, Loc,
None,
false).getAs<Stmt>());
12625 CopyConstructor->
markUsed(Context);
12629 L->CompletedImplicitDefinition(CopyConstructor);
12637 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveConstructor);
12638 if (DSM.isAlreadyBeingDeclared())
12649 CXXMoveConstructor,
12662 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12668 if (getLangOpts().CUDA) {
12669 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveConstructor,
12675 setupImplicitSpecialMemberType(MoveConstructor, Context.
VoidTy, ArgType);
12679 ClassLoc, ClassLoc,
12687 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
12691 ClassDecl->
hasAttr<TrivialABIAttr>() ||
12693 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor,
12694 TAH_ConsiderTrivialABI)
12700 Scope *S = getScopeForContext(ClassDecl);
12701 CheckImplicitSpecialMemberDeclaration(S, MoveConstructor);
12703 if (ShouldDeleteSpecialMember(MoveConstructor, CXXMoveConstructor)) {
12705 SetDeclDeleted(MoveConstructor, ClassLoc);
12709 PushOnScopeChains(MoveConstructor, S,
false);
12710 ClassDecl->
addDecl(MoveConstructor);
12712 return MoveConstructor;
12721 "DefineImplicitMoveConstructor - call it for implicit move ctor");
12726 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
12732 ResolveExceptionSpec(CurrentLocation,
12734 MarkVTableUsed(CurrentLocation, ClassDecl);
12739 if (SetCtorInitializers(MoveConstructor,
false)) {
12746 MoveConstructor->
setBody(ActOnCompoundStmt(
12747 Loc, Loc,
None,
false).getAs<Stmt>());
12748 MoveConstructor->
markUsed(Context);
12752 L->CompletedImplicitDefinition(MoveConstructor);
12767 FunctionDecl *CallOp = Lambda->getLambdaCallOperator();
12768 FunctionDecl *Invoker = Lambda->getLambdaStaticInvoker();
12771 CallOp = InstantiateFunctionDeclaration(
12776 Invoker = InstantiateFunctionDeclaration(
12790 MarkFunctionReferenced(CurrentLocation, CallOp);
12801 Expr *FunctionRef = BuildDeclRefExpr(Invoker, Invoker->
getType(),
12803 assert(FunctionRef &&
"Can't refer to __invoke function?");
12804 Stmt *Return = BuildReturnStmt(Conv->
getLocation(), FunctionRef).
get();
12811 L->CompletedImplicitDefinition(Conv);
12812 L->CompletedImplicitDefinition(Invoker);
12827 Expr *This = ActOnCXXThis(CurrentLocation).get();
12828 Expr *DerefThis =CreateBuiltinUnaryOp(CurrentLocation, UO_Deref, This).get();
12830 ExprResult BuildBlock = BuildBlockForLambdaConversion(CurrentLocation,
12838 if (!BuildBlock.
isInvalid() && !getLangOpts().ObjCAutoRefCount)
12840 CK_CopyAndAutoreleaseBlockObject,
12844 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12853 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12859 Stmt *ReturnS = Return.
get();
12866 L->CompletedImplicitDefinition(Conv);
12873 switch (Args.size()) {
12878 if (!Args[1]->isDefaultArgument())
12883 return !Args[0]->isDefaultArgument();
12894 bool HadMultipleCandidates,
12895 bool IsListInitialization,
12896 bool IsStdInitListInitialization,
12897 bool RequiresZeroInit,
12898 unsigned ConstructKind,
12900 bool Elidable =
false;
12914 Expr *SubExpr = ExprArgs[0];
12919 return BuildCXXConstructExpr(ConstructLoc, DeclInitType,
12920 FoundDecl, Constructor,
12921 Elidable, ExprArgs, HadMultipleCandidates,
12922 IsListInitialization,
12923 IsStdInitListInitialization, RequiresZeroInit,
12924 ConstructKind, ParenRange);
12933 bool HadMultipleCandidates,
12934 bool IsListInitialization,
12935 bool IsStdInitListInitialization,
12936 bool RequiresZeroInit,
12937 unsigned ConstructKind,
12939 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
12940 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
12941 if (DiagnoseUseOfDecl(Constructor, ConstructLoc))
12945 return BuildCXXConstructExpr(
12946 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
12947 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
12948 RequiresZeroInit, ConstructKind, ParenRange);
12958 bool HadMultipleCandidates,
12959 bool IsListInitialization,
12960 bool IsStdInitListInitialization,
12961 bool RequiresZeroInit,
12962 unsigned ConstructKind,
12967 "given constructor for wrong type");
12968 MarkFunctionReferenced(ConstructLoc, Constructor);
12969 if (getLangOpts().CUDA && !CheckCUDACall(ConstructLoc, Constructor))
12973 Context, DeclInitType, ConstructLoc, Constructor, Elidable,
12974 ExprArgs, HadMultipleCandidates, IsListInitialization,
12975 IsStdInitListInitialization, RequiresZeroInit,
12976 static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
13005 assert((getLangOpts().Modules || (!Lookup.
empty() && Lookup.
size() <= 2)) &&
13006 "more than two lookup results for field name");
13009 assert(isa<CXXRecordDecl>(Lookup[0]) &&
13010 "cannot have other non-field member with same name");
13011 for (
auto L : Lookup)
13012 if (isa<FieldDecl>(L)) {
13013 Pattern = cast<FieldDecl>(L);
13016 assert(Pattern &&
"We must have set the Pattern!");
13019 if (!Pattern->hasInClassInitializer() ||
13020 InstantiateInClassInitializer(Loc, Field, Pattern,
13021 getTemplateInstantiationArgs(Field))) {
13044 Diag(Loc, diag::err_in_class_initializer_not_yet_parsed)
13045 << OutermostClass << Field;
13046 Diag(Field->getEndLoc(), diag::note_in_class_initializer_not_yet_parsed);
13048 if (!isSFINAEContext())
13049 Field->setInvalidDecl();
13065 MarkFunctionReferenced(VD->
getLocation(), Destructor);
13066 CheckDestructorAccess(VD->
getLocation(), Destructor,
13067 PDiag(diag::err_access_dtor_var)
13070 DiagnoseUseOfDecl(Destructor, VD->
getLocation());
13094 bool AllowExplicit,
13095 bool IsListInitialization) {
13097 unsigned NumArgs = ArgsPtr.size();
13098 Expr **Args = ArgsPtr.data();
13102 assert(Proto &&
"Constructor without a prototype?");
13106 if (NumArgs < NumParams)
13107 ConvertedArgs.reserve(NumParams);
13109 ConvertedArgs.reserve(NumArgs);
13112 Proto->
isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
13114 bool Invalid = GatherArgumentsForCall(Loc, Constructor,
13116 llvm::makeArrayRef(Args, NumArgs),
13118 CallType, AllowExplicit,
13119 IsListInitialization);
13120 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
13122 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
13124 CheckConstructorCall(Constructor,
13125 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
13135 if (isa<NamespaceDecl>(DC)) {
13137 diag::err_operator_new_delete_declared_in_namespace)
13141 if (isa<TranslationUnitDecl>(DC) &&
13144 diag::err_operator_new_delete_declared_static)
13162 unsigned DependentParamTypeDiag,
13163 unsigned InvalidParamTypeDiag) {
13170 diag::err_operator_new_delete_dependent_result_type)
13183 diag::err_operator_new_delete_invalid_result_type)
13189 diag::err_operator_new_delete_template_too_few_parameters)
13195 diag::err_operator_new_delete_too_few_parameters)
13202 << FnDecl->
getDeclName() << ExpectedFirstParamType;
13213 ExpectedFirstParamType)
13215 << FnDecl->
getDeclName() << ExpectedFirstParamType;
13237 diag::err_operator_new_dependent_param_type,
13238 diag::err_operator_new_param_type))
13245 diag::err_operator_new_default_arg)
13275 SemaRef, FnDecl, SemaRef.
Context.
VoidTy, ExpectedFirstParamType,
13276 diag::err_operator_delete_dependent_param_type,
13277 diag::err_operator_delete_param_type))
13286 diag::err_destroying_operator_delete_not_usual);
13298 "Expected an overloaded operator declaration");
13308 if (Op == OO_Delete || Op == OO_Array_Delete)
13311 if (Op == OO_New || Op == OO_Array_New)
13319 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
13320 if (MethodDecl->isStatic())
13322 diag::err_operator_overload_static) << FnDecl->
getDeclName();
13324 bool ClassOrEnumParam =
false;
13326 QualType ParamType = Param->getType().getNonReferenceType();
13329 ClassOrEnumParam =
true;
13334 if (!ClassOrEnumParam)
13336 diag::err_operator_overload_needs_class_or_enum)
13346 if (Op != OO_Call) {
13348 if (Param->hasDefaultArg())
13349 return Diag(Param->getLocation(),
13350 diag::err_operator_overload_default_arg)
13351 << FnDecl->
getDeclName() << Param->getDefaultArgRange();
13356 {
false,
false,
false }
13357 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 13358 , { Unary, Binary, MemberOnly } 13359 #include "clang/Basic/OperatorKinds.def" 13362 bool CanBeUnaryOperator = OperatorUses[Op][0];
13363 bool CanBeBinaryOperator = OperatorUses[Op][1];
13364 bool MustBeMemberOperator = OperatorUses[Op][2];
13371 + (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
13372 if (Op != OO_Call &&
13373 ((NumParams == 1 && !CanBeUnaryOperator) ||
13374 (NumParams == 2 && !CanBeBinaryOperator) ||
13375 (NumParams < 1) || (NumParams > 2))) {
13378 if (CanBeUnaryOperator && CanBeBinaryOperator) {
13380 }
else if (CanBeUnaryOperator) {
13383 assert(CanBeBinaryOperator &&
13384 "All non-call overloaded operators are unary or binary!");
13388 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
13393 if (Op != OO_Call &&
13395 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
13400 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
13402 diag::err_operator_overload_must_be_member)
13416 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
13423 diag::err_operator_overload_post_incdec_must_be_int)
13424 << LastParam->
getType() << (Op == OO_MinusMinus);
13436 if (TemplateParams->
size() == 1) {
13445 }
else if (TemplateParams->
size() == 2) {
13454 PmArgs->isTemplateParameterPack()) {
13461 diag::ext_string_literal_operator_template);
13468 diag::err_literal_operator_template)
13477 if (isa<CXXMethodDecl>(FnDecl)) {
13478 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
13487 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
13504 diag::err_literal_operator_template_with_params);
13533 diag::err_literal_operator_param)
13550 diag::err_literal_operator_invalid_param)
13560 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
13567 Diag((*Param)->getSourceRange().getBegin(),
13568 diag::err_literal_operator_param)
13569 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13576 Diag((*Param)->getSourceRange().getBegin(),
13577 diag::err_literal_operator_param)
13578 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13591 Diag((*Param)->getSourceRange().getBegin(),
13592 diag::err_literal_operator_param)
13593 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13601 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
13603 Diag((*Param)->getSourceRange().getBegin(),
13604 diag::err_literal_operator_param)
13606 << (*Param)->getSourceRange();
13610 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
13619 if (Param->hasDefaultArg()) {
13620 Diag(Param->getDefaultArgRange().getBegin(),
13621 diag::err_literal_operator_default_argument)
13622 << Param->getDefaultArgRange();
13627 StringRef LiteralName
13629 if (LiteralName[0] !=
'_' &&
13630 !getSourceManager().isInSystemHeader(FnDecl->
getLocation())) {
13652 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
13661 else if (Lang ==
"C++")
13664 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
13675 PushDeclContext(S, D);
13691 return LinkageSpec;
13700 ProcessDeclAttributeList(S, ED, AttrList);
13702 CurContext->addDecl(ED);
13714 bool Invalid =
false;
13728 Diag(Loc, diag::err_catch_rvalue_ref);
13733 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
13739 unsigned DK = diag::err_catch_incomplete;
13743 DK = diag::err_catch_incomplete_ptr;
13748 DK = diag::err_catch_incomplete_ref;
13750 if (!Invalid && (Mode == 0 || !BaseType->
isVoidType()) &&
13751 !BaseType->
isDependentType() && RequireCompleteType(Loc, BaseType, DK))
13755 RequireNonAbstractType(Loc, ExDeclType,
13756 diag::err_abstract_type_in_decl,
13757 AbstractVariableType))
13762 if (!Invalid && getLangOpts().ObjC) {
13768 Diag(Loc, diag::err_objc_object_catch);
13772 if (getLangOpts().ObjCRuntime.isFragile())
13773 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
13782 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(ExDecl))
13789 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
13807 Expr *opaqueValue =
13818 Expr *init = MaybeCreateExprWithCleanups(construct);
13823 FinalizeVarWithDestructor(ExDecl,
recordType);
13842 UPPC_ExceptionType)) {
13850 LookupOrdinaryName,
13851 ForVisibleRedeclaration)) {
13856 if (isDeclInScope(PrevDecl, CurContext, S)) {
13859 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
13861 }
else if (PrevDecl->isTemplateParameter())
13872 VarDecl *ExDecl = BuildExceptionDeclaration(
13879 PushOnScopeChains(ExDecl, S);
13881 CurContext->addDecl(ExDecl);
13883 ProcessDeclAttributes(S, ExDecl, D);
13889 Expr *AssertMessageExpr,
13892 AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) :
nullptr;
13894 if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
13897 return BuildStaticAssertDeclaration(StaticAssertLoc, AssertExpr,
13898 AssertMessage, RParenLoc,
false);
13906 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
13911 ExprResult Converted = PerformContextuallyConvertToBool(AssertExpr);
13918 if (!Failed && VerifyIntegerConstantExpression(Converted.
get(), &Cond,
13919 diag::err_static_assert_expression_is_not_constant,
13923 if (!Failed && !Cond) {
13925 llvm::raw_svector_ostream Msg(MsgBuffer);
13927 AssertMessage->
printPretty(Msg,
nullptr, getPrintingPolicy());
13929 Expr *InnerCond =
nullptr;
13930 std::string InnerCondDescription;
13931 std::tie(InnerCond, InnerCondDescription) =
13932 findFailedBooleanCondition(Converted.
get());
13933 if (InnerCond && !isa<CXXBoolLiteralExpr>(InnerCond)
13934 && !isa<IntegerLiteral>(InnerCond)) {
13935 Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed)
13936 << InnerCondDescription << !AssertMessage
13939 Diag(StaticAssertLoc, diag::err_static_assert_failed)
13946 ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
13952 AssertExpr = FullAssertExpr.
get();
13955 AssertExpr, AssertMessage, RParenLoc,
13958 CurContext->addDecl(Decl);
13968 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
13978 if (!CodeSynthesisContexts.empty()) {
13993 getLangOpts().CPlusPlus11 ?
13994 diag::warn_cxx98_compat_unelaborated_friend_type :
13995 diag::ext_unelaborated_friend_type)
14003 diag::warn_cxx98_compat_nonclass_type_friend :
14004 diag::ext_nonclass_type_friend)
14011 diag::warn_cxx98_compat_enum_friend :
14012 diag::ext_enum_friend)
14023 if (getLangOpts().
CPlusPlus11 && LocStart != FriendLoc)
14024 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
14045 bool IsMemberSpecialization =
false;
14046 bool Invalid =
false;
14049 MatchTemplateParametersToScopeSpecifier(
14050 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
14051 IsMemberSpecialization, Invalid)) {
14052 if (TemplateParams->size() > 0) {
14057 return CheckClassTemplate(S, TagSpec, TUK_Friend, TagLoc, SS, Name,
14058 NameLoc, Attr, TemplateParams,
AS_public,
14060 FriendLoc, TempParamLists.size() - 1,
14061 TempParamLists.data()).
get();
14064 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
14066 IsMemberSpecialization =
true;
14070 if (Invalid)
return nullptr;
14072 bool isAllExplicitSpecializations =
true;
14073 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
14074 if (TempParamLists[I]->size()) {
14075 isAllExplicitSpecializations =
false;
14085 if (isAllExplicitSpecializations) {
14087 bool Owned =
false;
14088 bool IsDependent =
false;
14089 return ActOnTag(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc,
14103 QualType T = CheckTypenameType(Keyword, TagLoc, QualifierLoc,
14109 if (isa<DependentNameType>(T)) {
14123 TSI, FriendLoc, TempParamLists);
14125 CurContext->addDecl(Friend);
14129 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
14136 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
14147 TSI, FriendLoc, TempParamLists);
14150 CurContext->addDecl(Friend);
14210 if (DiagnoseUnexpandedParameterPack(Loc, TSI, UPPC_FriendDeclaration))
14228 Diag(Loc, diag::err_tagless_friend_type_template)
14245 if (!TempParams.empty())
14257 CurContext->addDecl(D);
14283 Diag(Loc, diag::err_unexpected_friend);
14310 if (DiagnoseUnexpandedParameterPack(Loc, TInfo, UPPC_FriendDeclaration) ||
14311 DiagnoseUnexpandedParameterPack(NameInfo, UPPC_FriendDeclaration) ||
14312 DiagnoseUnexpandedParameterPack(SS, UPPC_FriendDeclaration))
14318 Scope *DCScope = S;
14320 ForExternalRedeclaration);
14328 (FunctionContainingLocalClass =
14329 cast<CXXRecordDecl>(CurContext)->isLocalClass())) {
14344 Previous.
clear(LookupLocalFriendName);
14345 LookupName(Previous, S,
false);
14347 if (!Previous.
empty()) {
14355 DC = FunctionContainingLocalClass;
14357 adjustContextForLocalExternDecl(DC);
14377 bool isTemplateId =
14398 LookupQualifiedName(Previous, LookupDC);
14400 if (!Previous.
empty()) {
14405 if (isTemplateId) {
14406 if (isa<TranslationUnitDecl>(LookupDC))
break;
14413 DCScope = getScopeForDeclContext(S, DC);
14419 DC = computeDeclContext(SS);
14420 if (!DC)
return nullptr;
14422 if (RequireCompleteDeclContext(SS, DC))
return nullptr;
14424 LookupQualifiedName(Previous, DC);
14428 if (DC->
Equals(CurContext))
14430 getLangOpts().CPlusPlus11 ?
14431 diag::warn_cxx98_compat_friend_is_member :
14432 diag::err_friend_is_member);
14468 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
14495 if (DiagArg >= 0) {
14496 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
14507 DCScope = &FakeDCScope;
14510 bool AddToScope =
true;
14511 NamedDecl *ND = ActOnFunctionDeclarator(DCScope, D, DC, TInfo, Previous,
14512 TemplateParams, AddToScope);
14513 if (!ND)
return nullptr;
14527 if (!CurContext->isDependentContext()) {
14530 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
14531 PushOnScopeChains(ND, EnclosingScope,
false);
14538 CurContext->addDecl(FrD);
14543 if (DC->isRecord()) CheckFriendAccess(ND);
14547 FD = FTD->getTemplatedDecl();
14549 FD = cast<FunctionDecl>(ND);
14560 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
14562 diag::note_previous_declaration);
14564 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
14569 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
14571 << cast<CXXRecordDecl>(CurContext);
14580 AdjustDeclIfTemplate(Dcl);
14582 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
14584 Diag(DelLoc, diag::err_deleted_non_function);
14595 Prev->getPreviousDecl()) &&
14596 !Prev->isDefined()) {
14597 Diag(DelLoc, diag::err_deleted_decl_not_first);
14598 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
14599 Prev->isImplicit() ? diag::note_previous_implicit_declaration
14600 : diag::note_previous_declaration);
14619 bool IssuedDiagnostic =
false;
14622 if (!IssuedDiagnostic) {
14624 IssuedDiagnostic =
true;
14626 Diag(O->getLocation(), diag::note_overridden_virtual_function);
14632 ShouldDeleteSpecialMember(MD, getSpecialMember(MD),
nullptr,
14639 Diag(DelLoc, diag::err_deleted_main);
14658 if (Member == CXXInvalid) {
14660 Diag(DefaultLoc, diag::err_default_special_members);
14686 CheckExplicitlyDefaultedSpecialMember(MD);
14691 Diag(DefaultLoc, diag::err_default_special_members);
14699 if (isa<ReturnStmt>(SubStmt))
14700 Self.
Diag(SubStmt->getBeginLoc(),
14701 diag::err_return_in_constructor_handler);
14702 if (!isa<Expr>(SubStmt))
14708 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
14720 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
14724 !NewFT->getExtParameterInfo(I).isNoEscape()) {
14726 diag::warn_overriding_method_missing_noescape);
14728 diag::note_overridden_marked_noescape);
14733 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
14734 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
14735 if ((NewCSA || OldCSA) &&
14736 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
14745 if (NewCC == OldCC)
14756 diag::err_conflicting_overriding_cc_attributes)
14782 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
14790 if (NewClassTy.
isNull()) {
14792 diag::err_different_return_type_for_overriding_virtual_function)
14808 if (!RT->isBeingDefined() &&
14809 RequireCompleteType(New->
getLocation(), NewClassTy,
14810 diag::err_covariant_return_incomplete,
14816 if (!IsDerivedFrom(New->
getLocation(), NewClassTy, OldClassTy)) {
14826 if (CheckDerivedToBaseConversion(
14827 NewClassTy, OldClassTy,
14828 diag::err_covariant_return_inaccessible_base,
14829 diag::err_covariant_return_ambiguous_derived_to_base_conv,
14845 diag::err_covariant_return_type_different_qualifications)
14857 diag::err_covariant_return_type_class_type_more_qualified)
14892 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
14893 CheckPureMethod(M, ZeroLoc);
14901 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
14902 return Var->hasGlobalStorage();
14930 PushExpressionEvaluationContext(
14931 ExpressionEvaluationContext::PotentiallyEvaluated, D);
14941 PopExpressionEvaluationContext();
14944 ExitDeclaratorContext(S);
14956 "Parser allowed 'typedef' as storage class of condition decl.");
14958 Decl *Dcl = ActOnDeclarator(S, D);
14962 if (isa<FunctionDecl>(Dcl)) {
14963 Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
14972 if (!ExternalSource)
14976 ExternalSource->ReadUsedVTables(VTables);
14978 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
14979 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
14980 = VTablesUsed.find(VTables[I].Record);
14982 if (Pos != VTablesUsed.end()) {
14983 if (!Pos->second && VTables[I].DefinitionRequired)
14984 Pos->second =
true;
14988 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
14989 NewUses.push_back(
VTableUse(VTables[I].Record, VTables[I].Location));
14992 VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end());
14996 bool DefinitionRequired) {
15000 CurContext->isDependentContext() || isUnevaluatedContext())
15004 if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
15005 !isInOpenMPDeclareTargetContext() &&
15006 !isInOpenMPTargetExecutionDirective()) {
15007 if (!DefinitionRequired)
15008 MarkVirtualMembersReferenced(Loc, Class);
15013 LoadExternalVTableUses();
15015 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
15016 Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
15021 if (DefinitionRequired && !Pos.first->second) {
15022 Pos.first->second =
true;
15040 CheckDestructor(DD);
15052 MarkVirtualMembersReferenced(Loc, Class);
15054 VTableUses.push_back(std::make_pair(Class, Loc));
15058 LoadExternalVTableUses();
15059 if (VTableUses.empty())
15066 bool DefinedAnything =
false;
15067 for (
unsigned I = 0; I != VTableUses.size(); ++I) {
15076 bool DefineVTable =
true;
15082 if (KeyFunction && !KeyFunction->
hasBody()) {
15084 DefineVTable =
false;
15089 "Instantiations don't have key functions");
15091 }
else if (!KeyFunction) {
15096 bool IsExplicitInstantiationDeclaration =
15098 for (
auto R : Class->
redecls()) {
15102 IsExplicitInstantiationDeclaration =
true;
15104 IsExplicitInstantiationDeclaration =
false;
15109 if (IsExplicitInstantiationDeclaration)
15110 DefineVTable =
false;
15116 if (!DefineVTable) {
15117 MarkVirtualMemberExceptionSpecsNeeded(Loc, Class);
15124 DefinedAnything =
true;
15125 MarkVirtualMembersReferenced(Loc, Class);
15127 if (VTablesUsed[Canonical])
15128 Consumer.HandleVTable(Class);
15136 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
15140 ? diag::warn_weak_template_vtable
15141 : diag::warn_weak_vtable)
15146 VTableUses.clear();
15148 return DefinedAnything;
15153 for (
const auto *I : RD->
methods())
15154 if (I->isVirtual() && !I->isPure())
15163 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
15164 E = FinalOverriders.end();
15167 OE = I->second.end();
15169 assert(OI->second.size() > 0 &&
"no final overrider");
15174 if (!Overrider->isPure())
15175 MarkFunctionReferenced(Loc, Overrider);
15183 for (
const auto &I : RD->
bases()) {
15185 cast<CXXRecordDecl>(I.getType()->getAs<
RecordType>()->getDecl());
15188 MarkVirtualMembersReferenced(Loc, Base);
15199 CollectIvarsToConstructOrDestruct(OID, ivars);
15203 for (
unsigned i = 0; i < ivars.size(); i++) {
15215 InitSeq.Perform(*
this, InitEntity, InitKind,
None);
15216 MemberInit = MaybeCreateExprWithCleanups(MemberInit);
15227 AllToInit.push_back(Member);
15232 ->getAs<RecordType>()) {
15233 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
15235 MarkFunctionReferenced(Field->
getLocation(), Destructor);
15236 CheckDestructorAccess(Field->
getLocation(), Destructor,
15237 PDiag(diag::err_access_dtor_ivar)
15243 AllToInit.data(), AllToInit.size());
15249 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Valid,
15250 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Invalid,
15251 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Current,
15262 (void)Target->
hasBody(FNTarget);
15264 cast_or_null<CXXConstructorDecl>(FNTarget));
15271 if (!Current.insert(Canonical).second)
15277 Valid.insert(Current.begin(), Current.end());
15280 }
else if (TCanonical == Canonical || Invalid.count(TCanonical) ||
15281 Current.count(TCanonical)) {
15283 if (!Invalid.count(TCanonical)) {
15285 diag::warn_delegating_ctor_cycle)
15289 if (TCanonical != Canonical)
15296 assert(FNTarget &&
"Ctor cycle through bodiless function");
15299 cast<CXXConstructorDecl>(FNTarget));
15304 Invalid.insert(Current.begin(), Current.end());
15313 llvm::SmallPtrSet<CXXConstructorDecl*, 4> Valid, Invalid, Current;
15315 for (DelegatingCtorDeclsType::iterator
15316 I = DelegatingCtorDecls.begin(ExternalSource),
15317 E = DelegatingCtorDecls.end();
15321 for (
auto CI = Invalid.begin(), CE = Invalid.end(); CI != CE; ++CI)
15322 (*CI)->setInvalidDecl();
15331 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
15359 FindCXXThisExpr Finder(*
this);
15367 if (checkThisInStaticMemberFunctionExceptionSpec(Method))
15370 return checkThisInStaticMemberFunctionAttributes(Method);
15384 FindCXXThisExpr Finder(*
this);
15405 if (!Finder.TraverseType(E))
15415 FindCXXThisExpr Finder(*
this);
15418 for (
const auto *A : Method->
attrs()) {
15420 Expr *Arg =
nullptr;
15422 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
15424 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
15426 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
15427 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
15428 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
15429 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
15430 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
15431 Arg = ETLF->getSuccessValue();
15432 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
15433 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
15434 Arg = STLF->getSuccessValue();
15435 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
15436 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
15437 Arg = LR->getArg();
15438 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
15439 Args = llvm::makeArrayRef(LE->args_begin(), LE->args_size());
15440 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
15441 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
15442 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
15443 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
15444 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
15445 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
15446 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
15447 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
15449 if (Arg && !Finder.TraverseStmt(Arg))
15452 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
15453 if (!Finder.TraverseStmt(Args[I]))
15467 Exceptions.clear();
15470 Exceptions.reserve(DynamicExceptions.size());
15471 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
15473 QualType ET = GetTypeFromParser(DynamicExceptions[ei]);
15478 if (!Unexpanded.empty()) {
15480 DynamicExceptionRanges[ei].getBegin(), UPPC_ExceptionType,
15488 if (!CheckSpecifiedExceptionType(ET, DynamicExceptionRanges[ei]))
15489 Exceptions.push_back(ET);
15499 "Parser should have made sure that the expression is boolean");
15500 if (IsTopLevel && DiagnoseUnexpandedParameterPack(NoexceptExpr)) {
15515 Expr *NoexceptExpr) {
15521 MethodD = FunTmpl->getTemplatedDecl();
15530 checkExceptionSpecification(
true, EST, DynamicExceptions,
15531 DynamicExceptionRanges, NoexceptExpr, Exceptions,
15538 checkThisInStaticMemberFunctionExceptionSpec(Method);
15543 CheckOverridingFunctionExceptionSpec(Method, O);
15557 Diag(DeclStart, diag::err_anonymous_property);
15565 CheckExtraCXXDefaultArguments(D);
15568 UPPC_DataMemberType)) {
15579 << getLangOpts().CPlusPlus17;
15582 diag::err_invalid_thread)
15588 ForVisibleRedeclaration);
15589 LookupName(Previous, S);
15610 PrevDecl =
nullptr;
15613 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
15614 PrevDecl =
nullptr;
15621 ProcessDeclAttributes(TUScope, NewPD, D);
15634 PushOnScopeChains(NewPD, S);
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
Abstract class used to diagnose incomplete types.
A call to an overloaded operator written using operator syntax.
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl)
NamespaceDecl * lookupStdExperimentalNamespace()
void setSourceOrder(int Pos)
Set the source order of this initializer.
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
void ActOnFinishDelayedMemberInitializers(Decl *Record)
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field)
Field is the non-static data member whose default initializer is used by this expression.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCallToStdMove() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
SourceLocation getBeginLoc() const
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
Represents a function declaration or definition.
static StmtResult buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying, unsigned Depth=0)
Builds a statement that copies/moves the given entity from From to To.
Name lookup found a set of overloaded functions that met the criteria.
NamespaceDecl * getStdNamespace() const
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Expr * getInit() const
Get the initializer.
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void setOrigin(CXXRecordDecl *Rec)
CXXMethodDecl * getMethod() const
no exception specification
static bool checkMemberDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const CXXRecordDecl *OrigRD)
const TypeClass * getTypePtr() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
static unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built...
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
bool SetTypeQual(TQ T, SourceLocation Loc)
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
static bool findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, Sema::TrivialABIHandling TAH, CXXMethodDecl **Selected)
Perform lookup for a special member of the specified kind, and determine whether it is trivial...
static DeclAccessPair findDecomposableBaseClass(Sema &S, SourceLocation Loc, const CXXRecordDecl *RD, CXXCastPath &BasePath)
Find the base class to decompose in a built-in decomposition of a class type.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
const Expr * getInit(unsigned Init) const
The subobject is a base class.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
static UsingPackDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> UsingDecls)
static unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
Decl * Entity
The entity that is being synthesized.
Expr *const * semantics_iterator
static ClassTemplateDecl * LookupStdInitializerList(Sema &S, SourceLocation Loc)
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
CXXRecordDecl * getCurrentClass(Scope *S, const CXXScopeSpec *SS)
Get the class that is directly named by the current context.
Filter makeFilter()
Create a filter for this result set.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
CXXCatchStmt * getHandler(unsigned i)
IfStmt - This represents an if/then/else.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD)
Check a completed declaration of an implicit special member.
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
An instance of this object exists for each enum constant that is defined.
bool isRealFloatingType() const
Floating point categories.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class...
static CharSourceRange getTokenRange(SourceRange R)
void addConst()
Add the const type qualifier to this QualType.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
static unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
bool isRecordType() const
static TemplateArgumentLoc getTrivialTypeTemplateArgument(Sema &S, SourceLocation Loc, QualType T)
bool isEmpty() const
No scope specifier.
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
void erase()
Erase the last element returned from this iterator.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation)
Builds a using declaration.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
bool isVariadic() const
Whether this function prototype is variadic.
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
SourceLocation getBeginLoc() const LLVM_READONLY
static bool FindBaseInitializer(Sema &SemaRef, CXXRecordDecl *ClassDecl, QualType BaseType, const CXXBaseSpecifier *&DirectBaseSpec, const CXXBaseSpecifier *&VirtualBaseSpec)
Find the direct and/or virtual base specifiers that correspond to the given base type, for use in base initialization within a constructor.
void setArgPassingRestrictions(ArgPassingKind Kind)
ComparisonCategoryType Kind
The Kind of the comparison category type.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
ThreadStorageClassSpecifier getTSCSpec() const
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true)
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void setPure(bool P=true)
static QualType RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
bool isOverrideSpecified() const
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
NamedDecl * getDecl() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static bool isVirtualDirectBase(CXXRecordDecl *Derived, CXXRecordDecl *Base)
Determine whether a direct base class is a virtual base class.
void EvaluateImplicitExceptionSpec(SourceLocation Loc, CXXMethodDecl *MD)
Evaluate the implicit exception specification for a defaulted special member function.
A constructor named via a template-id.
bool isExplicitSpecialization() const
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
static bool lookupStdTypeTraitMember(Sema &S, LookupResult &TraitMemberLookup, SourceLocation Loc, StringRef Trait, TemplateArgumentListInfo &Args, unsigned DiagID)
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
The base class of the type hierarchy.
static bool checkTrivialSubobjectCall(Sema &S, SourceLocation SubobjLoc, QualType SubType, bool ConstRHS, Sema::CXXSpecialMember CSM, TrivialSubobjectKind Kind, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the special member selected for a given type would be trivial.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
SourceLocation getBeginLoc() const LLVM_READONLY
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
One instance of this struct is used for each type in a declarator that is parsed. ...
Declaration of a variable template.
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
Represent a C++ namespace.
static bool isNonlocalVariable(const Decl *D)
Determine whether the given declaration is a global variable or static data member.
Represents a call to a C++ constructor.
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location...
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getEndLoc() const LLVM_READONLY
NamedDecl * getParam(unsigned Idx)
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
QualType withConst() const
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
const TargetInfo & getTargetInfo() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
const NestedNameSpecifier * Specifier
RefQualifierKind RefQualifier
A container of type source information.
Floating point control options.
constexpr XRayInstrMask Function
static std::string printTemplateArgs(const PrintingPolicy &PrintingPolicy, TemplateArgumentListInfo &Args)
An overloaded operator name, e.g., operator+.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
TSCS getThreadStorageClassSpec() const
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
QualType getConversionType() const
Returns the type that this conversion function is converting to.
static InitializedEntity InitializeMemberFromDefaultMemberInitializer(FieldDecl *Member)
Create the initialization entity for a default member initializer.
Abstract base class used for diagnosing integer constant expression violations.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
unsigned getIdentifierNamespace() const
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
IdentifierInfo * getPropertyDataGetter() const
bool implicitCopyAssignmentHasConstParam() const
Determine whether an implicit copy assignment operator for this type would have a parameter with a co...
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class...
size_t param_size() const
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
SourceLocation getEndLoc() const
Get the end source location.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
SourceLocation getOverrideLoc() const
QualType getElementType() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
void CheckCXXDefaultArguments(FunctionDecl *FD)
CheckCXXDefaultArguments - Verify that the default arguments for a function declaration are well-form...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
RAII object to handle the state changes required to synthesize a function body.
IdentifierInfo * getPropertyDataSetter() const
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> Expansions)
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
void ActOnFinishCXXNonNestedClass(Decl *D)
This file provides some common utility functions for processing Lambda related AST Constructs...
std::list< CXXBasePath >::iterator paths_iterator
static std::vector< ComparisonCategoryResult > getPossibleResultsForType(ComparisonCategoryType Type)
Return the list of results which are valid for the specified comparison category type.
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr *> Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
RAII object that enters a new expression evaluation context.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
Represents a variable declaration or definition.
ActionResult< Stmt * > StmtResult
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Information about one declarator, including the parsed type information and the identifier.
QualType getReturnType() const
DiagnosticsEngine & Diags
Wrapper for source info for member pointers.
unsigned getNumParams() const
bool isEnumeralType() const
void finishedDefaultedOrDeletedMember(CXXMethodDecl *MD)
Indicates that the declaration of a defaulted or deleted special member function is now complete...
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Extra information about a function prototype.
bool hasInheritedDefaultArg() const
void clear()
Clear the base-paths results.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
TypeSpecifierType
Specifies the kind of type.
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared...
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
The "__interface" keyword.
void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD)
Check that the C++ class annoated with "trivial_abi" satisfies all the conditions that are needed for...
RAII class that determines when any errors have occurred between the time the instance was created an...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
SourceLocation getFinalLoc() const
bool isZeroLengthBitField(const ASTContext &Ctx) const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
DeclClass * getCorrectionDeclAs() const
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
TypeLoc getNamedTypeLoc() const
bool isInvalidDecl() const
Like System, but searched after the system directories.
static StmtResult buildMemcpyForAssignmentOp(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &ToB, const ExprBuilder &FromB)
When generating a defaulted copy or move assignment operator, if a field should be copied with __buil...
Stores a list of template parameters for a TemplateDecl and its derived classes.
void setBegin(SourceLocation b)
static StringRef getTagTypeKindName(TagTypeKind Kind)
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
bool isInterfaceLike() const
Describes how types, statements, expressions, and declarations should be printed. ...
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool hasMethodTypeQualifiers() const
Determine whether this method has qualifiers.
bool hasDefinition() const
static StringRef getResultString(ComparisonCategoryResult Kind)
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
Represents a parameter to a function.
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
Defines the clang::Expr interface and subclasses for C++ expressions.
Parse and apply any fixits to the source.
void removeDecl(Decl *D)
Removes a declaration from this context.
noexcept(expression), value-dependent
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
The collection of all-type qualifiers we support.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
bool isRecordingPaths() const
Whether we are recording paths.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T)
Determine whether the given type is an incomplete or zero-lenfgth array type.
void CheckDelayedMemberExceptionSpecs()
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
SourceLocation getFriendSpecLoc() const
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
bool isRedeclaration() const
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer *> MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
Represents a struct/union/class.
bool hasTrivialCopyConstructorForCall() const
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
static QualType getTupleLikeElementType(Sema &S, SourceLocation Loc, unsigned I, QualType T)
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Description of a constructor that was inherited from a base class.
static bool IsEquivalentForUsingDecl(ASTContext &Context, NamedDecl *D1, NamedDecl *D2)
Determine whether a using declaration considers the given declarations as "equivalent", e.g., if they are redeclarations of the same entity or are both typedefs of the same type.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
unsigned getDepth() const
Retrieve the depth of the template parameter.
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
static bool IsUsingDirectiveInToplevelContext(DeclContext *CurContext)
Determine whether a using statement is in a context where it will be apply in all contexts...
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
void setRecordingPaths(bool RP)
Specify whether we should be recording paths or not.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
void setUninstantiatedDefaultArg(Expr *arg)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
A C++ nested-name-specifier augmented with source location information.
bool isInline() const
Returns true if this is an inline namespace declaration.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ArrayRef< QualType > getParamTypes() const
The results of name lookup within a DeclContext.
SourceLocation getTypeSpecTypeLoc() const
TypeSourceInfo * getTypeSourceInfo() const
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
field_range fields() const
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, ParsedAttributes &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info, FieldDecl *Field, IndirectFieldDecl *Indirect=nullptr)
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause...
Represents a member of a struct/union/class.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
bool isAbstractType(SourceLocation Loc, QualType T)
static bool isIncrementDecrementOp(Opcode Op)
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
bool isFunctionDefinition() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getExprLoc() const LLVM_READONLY
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
bool isReferenceType() const
CXXRecordDecl * getStdBadAlloc() const
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class.copy]p25)
void setElaboratedKeywordLoc(SourceLocation Loc)
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
The iterator over UnresolvedSets.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
static void extendLeft(SourceRange &R, SourceRange Before)
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
ParmVarDecl * getParam(unsigned i) const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const
Make an APSInt of the appropriate width and signedness for the given Value and integer Type...
LookupResultKind getResultKind() const
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
Represents an access specifier followed by colon ':'.
void ClearStorageClassSpecs()
SourceLocation getBeginLoc() const LLVM_READONLY
void addShadowDecl(UsingShadowDecl *S)
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
SourceLocation getTemplateLoc() const
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
A user-defined literal name, e.g., operator "" _i.
SpecialMemberOverloadResult - The overloading result for a special member function.
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
void setImplicitCopyConstructorIsDeleted()
Set that we attempted to declare an implicit copy constructor, but overload resolution failed so we d...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
ArrayRef< ParmVarDecl * > parameters() const
DeclClass * getAsSingle() const
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl *> &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
bool isFinalSpelledSealed() const
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr *> Exprs, SourceLocation RParenLoc)
Create a paren list.
static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, DeclStmt *DS, SourceLocation &Cxx1yLoc)
Check the given declaration statement is legal within a constexpr function body.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
Describes an C or C++ initializer list.
Represents a C++ using-declaration.
The argument of this type can be passed directly in registers.
ArrayRef< BindingDecl * > bindings() const
Represents a C++ unqualified-id that has been parsed.
An rvalue reference type, per C++11 [dcl.ref].
bool isCompleteType(SourceLocation Loc, QualType T)
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization. ...
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace...
static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class)
Represents the results of name lookup.
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
TagKind getTagKind() const
Microsoft throw(...) extension.
A convenient class for passing around template argument information.
void setParamDestroyedInCallee(bool V)
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
bool isSpecialMemberAccessibleForDeletion(CXXMethodDecl *decl, AccessSpecifier access, QualType objectType)
Is the given special member function accessible for the purposes of deciding whether to define a spec...
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow)
Determines whether to create a using shadow decl for a particular decl, given the set of decls existi...
bool needsOverloadResolutionForCopyAssignment() const
Determine whether we need to eagerly declare a defaulted copy assignment operator for this class...
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true)
bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS)
Determine whether the identifier II is a typo for the name of the class type currently being defined...
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool CheckConstexprFunctionDecl(const FunctionDecl *FD)
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
ArrayRef< NamedDecl * > chain() const
An x-value expression is a reference to an object with independent storage but which can be "moved"...
A friend of a previously-undeclared entity.
bool hasNonTrivialDestructorForCall() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
static bool BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, FieldDecl *Field, IndirectFieldDecl *Indirect, CXXCtorInitializer *&CXXMemberInit)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
const clang::PrintingPolicy & getPrintingPolicy() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
static void NoteIndirectBases(ASTContext &Context, IndirectBaseSet &Set, const QualType &Type)
Recursively add the bases of Type. Don't add Type itself.
semantics_iterator semantics_end()
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier *> Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
LangAS getAddressSpace() const
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt *> Stmts, SourceLocation LB, SourceLocation RB)
void CheckDelegatingCtorCycles()
QualType getExceptionObjectType(QualType T) const
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
bool isRValueReferenceType() const
static void checkMoveAssignmentForRepeatedMove(Sema &S, CXXRecordDecl *Class, SourceLocation CurrentLocation)
Check if we're implicitly defining a move assignment operator for a class with virtual bases...
void setExceptionVariable(bool EV)
The argument of this type cannot be passed directly in registers.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
ActionResult< ParsedType > TypeResult
DeclContextLookupResult slice(size_t N) const
bool isLambda() const
Determine whether this class describes a lambda function object.
Scope - A scope is a transient data structure that is used while parsing the program.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
field_iterator field_begin() const
param_type_iterator param_type_begin() const
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
ExprResult ActOnCXXThis(SourceLocation loc)
bool isAnyMemberInitializer() const
Represents a C++ nested-name-specifier or a global scope specifier.
static unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built...
void setNumCtorInitializers(unsigned numCtorInitializers)
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
FieldDecl * getAnyMember() const
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
TemplateArgumentLoc getArgLoc(unsigned i) const
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
SourceLocation getConstSpecLoc() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
static bool findCircularInheritance(const CXXRecordDecl *Class, const CXXRecordDecl *Current)
Determine whether the given class is a base class of the given class, including looking at dependent ...
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
An ordinary object is located at an address in memory.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification, including the language and (if present) the '{'.
Represents an ObjC class declaration.
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
Represents a linkage specification.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
SourceRange getSourceRange() const LLVM_READONLY
bool isAbstract() const
Determine whether this class has a pure virtual function.
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
unsigned getNumArgs() const
A binding in a decomposition declaration.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
Qualifiers getTypeQuals() const
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
init_iterator init_begin()
Retrieve an iterator to the first initializer.
IdentifierInfo * getIdentifier() const
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3).
unsigned getLength() const
Efficiently return the length of this identifier info.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location...
static TemplateArgumentLoc getTrivialIntegralTemplateArgument(Sema &S, SourceLocation Loc, QualType T, uint64_t I)
ArgPassingKind getArgPassingRestrictions() const
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
param_iterator param_begin()
Represents the this expression in C++.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, UsingDecl *UD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
static bool isValidUDSuffix(const LangOptions &LangOpts, StringRef Suffix)
Determine whether a suffix is a valid ud-suffix.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
ExtInfo withCallingConv(CallingConv cc) const
static StmtResult buildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying)
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
void removeInClassInitializer()
Remove the C++11 in-class initializer from this member.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
static bool canPassInRegisters(Sema &S, CXXRecordDecl *D, TargetInfo::CallingConvKind CCK)
Determine whether a type is permitted to be passed or returned in registers, per C++ [class...
DiagnosticsEngine & getDiagnostics() const
static bool checkArrayDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const ConstantArrayType *CAT)
bool isFinalSpecified() const
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
CXXSpecialMember
Kinds of C++ special members.
unsigned getFlags() const
getFlags - Return the flags for this scope.
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, Expr *Init, SourceLocation EllipsisLoc)
Handle a C++ member initializer.
CXXConstructorDecl * findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor, ConstructorUsingShadowDecl *DerivedShadow)
Given a derived-class using shadow declaration for a constructor and the correspnding base class cons...
void setBases(CXXBaseSpecifier const *const *Bases, unsigned NumBases)
Sets the base classes of this struct or class.
bool isDeclspecPropertyAttribute() const
Is this the Microsoft __declspec(property) attribute?
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
ConditionalOperator - The ?: ternary operator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
Sema - This implements semantic analysis and AST building for C.
StringRef getString() const
enum clang::DeclaratorChunk::@215 Kind
Represents the declaration of a typedef-name via a C++11 alias-declaration.
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
SourceLocation getUnalignedSpecLoc() const
Represents a prototype with parameter type info, e.g.
virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool isDynamicClass() const
void ClearConstexprSpec()
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
SourceLocation getBeginLoc() const LLVM_READONLY
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
static unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
A RAII object to enter scope of a compound statement.
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Represents a ValueDecl that came out of a declarator.
SourceRange getLocalSourceRange() const
Get the local source range.
static StringRef getCategoryString(ComparisonCategoryType Kind)
static Sema::ImplicitExceptionSpecification ComputeDefaultedSpecialMemberExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD, Sema::CXXSpecialMember CSM, Sema::InheritedConstructorInfo *ICI)
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
DeclarationNameTable DeclarationNames
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
bool hasTrivialMoveConstructorForCall() const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl *> &OverloadedMethods)
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
A conversion function name, e.g., operator int.
SourceRange getRange() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
bool isInlineSpecified() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
bool isLiteral() const
Determine whether this class is a literal type.
void setInClassInitializer(Expr *Init)
Set the C++11 in-class initializer for this member.
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared...
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
TST getTypeSpecType() const
SourceLocation getBeginLoc() const LLVM_READONLY
static void diagnoseDeprecatedCopyOperation(Sema &S, CXXMethodDecl *CopyOp)
Diagnose an implicit copy operation for a class which is odr-used, but which is deprecated because th...
bool hasKeyFunctions() const
Does this ABI use key functions? If so, class data such as the vtable is emitted with strong linkage ...
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
static Sema::SpecialMemberOverloadResult lookupCallFromSpecialMember(Sema &S, CXXRecordDecl *Class, Sema::CXXSpecialMember CSM, unsigned FieldQuals, bool ConstRHS)
Look up the special member function that would be called by a special member function for a subobject...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMember > SpecialMemberDecl
bool isMsStruct(const ASTContext &C) const
Get whether or not this is an ms_struct which can be turned on with an attribute, pragma...
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
void setTrivialForCall(bool IT)
static bool checkComplexDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const ComplexType *CT)
SourceLocation getBeginLoc() const
Get the begin source location.
static bool checkArrayLikeDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType)
Allows QualTypes to be sorted and hence used in maps and sets.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
QualType getElementType() const
bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method)
Whether this' shows up in the exception specification of a static member function.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
StringRef getKindName() const
QualType getPointeeType() const
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isVariadic() const
Whether this function is variadic.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
llvm::StringRef getAsString(SyncScope S)
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
Helper class that collects exception specifications for implicitly-declared special member functions...
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
static void DiagnoseBaseOrMemInitializerOrder(Sema &SemaRef, const CXXConstructorDecl *Constructor, ArrayRef< CXXCtorInitializer *> Inits)
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
Declaration of a template type parameter.
unsigned getIndex() const
DeclContext * getEntity() const
bool defaultedMoveConstructorIsDeleted() const
true if a defaulted move constructor for this class would be deleted.
DeclarationNameInfo getNameInfo() const
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
void setRBraceLoc(SourceLocation L)
static bool checkVectorDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const VectorType *VT)
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
OpaquePtr< T > get() const
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
SourceLocation getLocation() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
void freeParams()
Reset the parameter list to having zero parameters.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
std::string getAsString() const
Retrieve the human-readable string for this name.
unsigned getNumInits() const
static unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
SourceLocation getVolatileSpecLoc() const
SourceLocation getThreadStorageClassSpecLoc() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
void setRBraceLoc(SourceLocation L)
Defines the clang::Preprocessor interface.
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
field_iterator field_end() const
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
overridden_method_range overridden_methods() const
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
bool isFileContext() const
SourceLocation getBeginLoc() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
bool isConstexprSpecified() const
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member, and after instantiating an in-class initializer in a class template.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
CXXTryStmt - A C++ try block, including all handlers.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
static void DefineImplicitSpecialMember(Sema &S, CXXMethodDecl *MD, SourceLocation DefaultLoc)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
Represents a C++ template name within the type system.
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
SourceLocation getStorageClassSpecLoc() const
Defines the clang::TypeLoc interface and its subclasses.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
void DiscardCleanupsInEvaluationContext()
The argument of this type cannot be passed directly in registers.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
void setInheritConstructors(bool Inherit=true)
Set that this base class's constructors should be inherited.
bool isFunctionOrMethod() const
static bool isPotentialConstantExpr(const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExpr - Return true if this function's definition might be usable in a constant exp...
StorageClass
Storage classes.
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void CheckCompletedCXXClass(CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
Qualifiers getTypeQualifiers() const
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
InClassInitStyle
In-class initialization styles for non-static data members.
Declaration of an alias template.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for record diagnostic message.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
static bool checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, bool ConstArg, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the members of a class type allow a special member to be trivial.
A boolean condition, from 'if', 'while', 'for', or 'do'.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
static bool specialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, CXXConstructorDecl *InheritedCtor=nullptr, Sema::InheritedConstructorInfo *Inherited=nullptr)
Is the special member function which would be selected to perform the specified operation on the spec...
QualType getRecordType(const RecordDecl *Decl) const
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method)
Integrate another called method into the collected data.
CXXMethodDecl * getMethodDecl() const
Retrieves the declaration of the called method.
void setHasTrivialSpecialMemberForCall()
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool isFriendSpecified() const
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
void addContextNote(SourceLocation UseLoc)
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class...
void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an initializer for the declaration ...
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
Represents a C++ deduction guide declaration.
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
static void PopulateKeysForFields(FieldDecl *Field, SmallVectorImpl< const void *> &IdealInits)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class.copy]p25)
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
The triviality of a method affected by "trivial_abi".
static bool CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S, SmallVectorImpl< SourceLocation > &ReturnStmts, SourceLocation &Cxx1yLoc, SourceLocation &Cxx2aLoc)
Check the provided statement is allowed in a constexpr function definition.
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
TypeLoc getReturnLoc() const
static bool RefersToRValueRef(Expr *MemRef)
bool hasValidIntValue() const
True iff we've successfully evaluated the variable as a constant expression and extracted its integer...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body)
Check the body for the given constexpr function declaration only contains the permitted types of stat...
#define CheckPolymorphic(Type)
CanQualType getCanonicalTypeUnqualified() const
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasGroupingParens() const
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
RecordDecl * getDecl() const
bool hasVariantMembers() const
Determine whether this class has any variant members.
noexcept(expression), evals to 'false'
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
unsigned size_overridden_methods() const
static void SearchForReturnInStmt(Sema &Self, Stmt *S)
Wrapper for source info for arrays.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter...
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
Decl::Kind getDeclKind() const
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
static bool CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef, const FunctionDecl *FnDecl)
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
static unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
We are declaring an implicit special member function.
CXXSpecialMember SpecialMember
The special member being declared or defined.
static CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
Represents a call to an inherited base class constructor from an inheriting constructor.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ExceptionSpecificationType Type
The kind of exception specification this is.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
TypeLoc IgnoreParens() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExtProtoInfo getExtProtoInfo() const
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SCS getStorageClassSpec() const
ASTContext & getASTContext() const
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList *> FriendTypeTPLists=None)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
llvm::SmallPtrSet< QualType, 4 > IndirectBaseSet
Use small set to collect indirect bases.
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
Encodes a location in the source.
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
We are computing the exception specification for a defaulted special member function.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
bool hasSameTemplateName(TemplateName X, TemplateName Y)
Determine whether the given template names refer to the same template.
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
unsigned getNumHandlers() const
decl_iterator decls_begin() const
Expr * getSubExpr() const
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void setTrivialForCallFlags(CXXMethodDecl *MD)
Attr * clone(ASTContext &C) const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
CastKind getCastKind() const
static void CheckConstexprCtorInitializer(Sema &SemaRef, const FunctionDecl *Dcl, FieldDecl *Field, llvm::SmallSet< Decl *, 16 > &Inits, bool &Diagnosed)
Check that the given field is initialized within a constexpr constructor.
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
static unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built...
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
DeclarationName getName() const
getName - Returns the embedded declaration name.
static ConstantExpr * Create(const ASTContext &Context, Expr *E)
Represents the declaration of a struct/union/class/enum.
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
void referenceDLLExportedClassMethods()
MutableArrayRef< Expr * > MultiExprArg
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
Represents a call to a member function that may be written either with member call syntax (e...
ASTContext & getASTContext() const LLVM_READONLY
bool isModulePrivateSpecified() const
InheritedConstructorInfo(Sema &S, SourceLocation UseLoc, ConstructorUsingShadowDecl *Shadow)
Attempt to be ABI-compatible with code generated by Clang 4.0.x (SVN r291814).
static bool CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, CanQualType ExpectedResultType, CanQualType ExpectedFirstParamType, unsigned DependentParamTypeDiag, unsigned InvalidParamTypeDiag)
QualType getElementType() const
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
void setReferenced(bool R=true)
unsigned getSpellingListIndex() const
IdentifierTable & getIdentifierTable()
ParsedAttr - Represents a syntactic attribute.
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error...
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
Represents a dependent using declaration which was not marked with typename.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
const DecompositionDeclarator & getDecompositionDeclarator() const
void removeShadowDecl(UsingShadowDecl *S)
void setCtorInitializers(CXXCtorInitializer **Initializers)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Represents a static or instance method of a struct/union/class.
void setDefaulted(bool D=true)
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
ExprResult DefaultLvalueConversion(Expr *E)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
void setEntity(DeclContext *E)
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckForFunctionMarkedFinal - Checks whether a virtual member function overrides a virtual member fun...
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
const ParmVarDecl * getParamDecl(unsigned i) const
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
void setImplicitMoveConstructorIsDeleted()
Set that we attempted to declare an implicit move constructor, but overload resolution failed so we d...
SourceLocation getLocation() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Name lookup found an unresolvable value declaration and cannot yet complete.
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
static CXXBaseSpecifier * findDirectBaseWithType(CXXRecordDecl *Derived, QualType DesiredBase, bool &AnyDependentBases)
Find the base specifier for a base class with the given type.
void actOnDelayedExceptionSpecification(Decl *Method, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member function (or member function template).
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
AccessSpecifier getAccess() const
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
bool isObjCObjectPointerType() const
A class for iterating through a result set and possibly filtering out results.
Direct list-initialization.
Represents a C++11 virt-specifier-seq.
static ConstructorUsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target, bool IsVirtual)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
bool isFunctionProtoType() const
void CheckExplicitlyDefaultedMemberExceptionSpec(CXXMethodDecl *MD, const FunctionProtoType *T)
Check whether the exception specification provided for an explicitly-defaulted special member matches...
static bool checkSimpleDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType, llvm::function_ref< ExprResult(SourceLocation, Expr *, unsigned)> GetInit)
void setIsParsingBaseSpecifiers()
bool hasUninstantiatedDefaultArg() const
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList *> Params, FriendUnion Friend, SourceLocation FriendLoc)
CXXRecordDecl * getOrigin() const
Retrieve the type from which this base-paths search began.
static bool BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, CXXBaseSpecifier *BaseSpec, bool IsInheritedVirtualBase, CXXCtorInitializer *&CXXBaseInit)
No entity found met the criteria.
static bool CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl)
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
SourceLocation getRAngleLoc() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
SourceLocation getInlineSpecLoc() const
void setExplicitlyDefaulted(bool ED=true)
State that this function is explicitly defaulted per C++0x.
void setHasInheritedDefaultArg(bool I=true)
bool hasFlexibleArrayMember() const
bool defaultedCopyConstructorIsDeleted() const
true if a defaulted copy constructor for this class would be deleted.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
static bool checkTupleLikeDecomposition(Sema &S, ArrayRef< BindingDecl *> Bindings, VarDecl *Src, QualType DecompType, const llvm::APSInt &TupleSize)
static Sema::ImplicitExceptionSpecification computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD)
bool isTrivialForCall() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addArgument(const TemplateArgumentLoc &Loc)
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
TypeLoc getElementLoc() const
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
SourceLocation getLastLocation() const
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
A POD class for pairing a NamedDecl* with an access specifier.
CXXConstructorDecl * getConstructor() const
StringRef getName() const
Return the actual identifier string.
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
SourceRange getRange() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
static void checkForMultipleExportedDefaultConstructors(Sema &S, CXXRecordDecl *Class)
Decl * ActOnExceptionDeclarator(Scope *S, Declarator &D)
ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch handler.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
Base class for declarations which introduce a typedef-name.
const ComparisonCategoryInfo * lookupInfo(ComparisonCategoryType Kind) const
Return the cached comparison category information for the specified 'Kind'.
ast_type_traits::DynTypedNode Node
TLS with a dynamic initializer.
Represents a template argument.
TagTypeKind
The kind of a tag type.
static bool isInvalid(LocType Loc, bool *Invalid)
const ObjCInterfaceDecl * getClassInterface() const
bool hasNonTrivialCopyConstructorForCall() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Dataflow Directional Tag Classes.
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
bool isExplicit() const
Whether this function is explicit.
static void DelegatingCycleHelper(CXXConstructorDecl *Ctor, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Valid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Invalid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Current, Sema &S)
bool isValid() const
Return true if this is a valid SourceLocation object.
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, const ParsedAttr &MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
const TemplateArgument & getArgument() const
not evaluated yet, for special member function
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static const TST TST_auto
method_iterator begin_overridden_methods() const
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
static void AddMostOverridenMethods(const CXXMethodDecl *MD, llvm::SmallPtrSetImpl< const CXXMethodDecl *> &Methods)
Add the most overriden methods from MD to Methods.
QualType getType() const
Get the type for which this source info wrapper provides information.
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
static bool InitializationHasSideEffects(const FieldDecl &FD)
bool hasTrivialDestructorForCall() const
Represents a field injected from an anonymous union/struct into the parent scope. ...
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
QualType getUnderlyingType() const
CanQualType UnsignedLongLongTy
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
AccessSpecifier getAccess() const
const Expr * getInit() const
A decomposition declaration.
MapType::iterator iterator
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
This template specialization was instantiated from a template due to an explicit instantiation declar...
static NamespaceDecl * getNamespaceDecl(NamedDecl *D)
getNamespaceDecl - Returns the namespace a decl represents.
bool hasUserDeclaredConstructor() const
Determine whether this class has any user-declared constructors.
unsigned getIndex() const
Retrieve the index of the template parameter.
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
Represents a dependent using declaration which was marked with typename.
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
bool areArgsDestroyedLeftToRightInCallee() const
Are arguments to a call destroyed left to right in the callee? This is a fundamental language change...
void setWillHaveBody(bool V=true)
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
The name of a declaration.
StmtClass getStmtClass() const
ArrayRef< QualType > exceptions() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
A mapping from each virtual member function to its set of final overriders.
unsigned getNumTemplateParameterLists() const
CXXRecordDecl * Record
The declaration for the comparison category type from the standard library.
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i...
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
semantics_iterator semantics_begin()
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
SourceLocation getBeginLoc() const LLVM_READONLY
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
static unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
void PushUsingDirective(UsingDirectiveDecl *UDir)
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
std::pair< CXXConstructorDecl *, bool > findConstructorForBase(CXXRecordDecl *Base, CXXConstructorDecl *Ctor) const
Find the constructor to use for inherited construction of a base class, and whether that base class c...
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
unsigned getNumParams() const
void setNameLoc(SourceLocation Loc)
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
const FunctionDecl * getOperatorDelete() const
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
static FunctionProtoType::ExtProtoInfo getImplicitMethodEPI(Sema &S, CXXMethodDecl *MD)
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
Name lookup found a single declaration that met the criteria.
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class...
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool isIncompleteArrayType() const
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
static bool CheckOperatorNewDeclaration(Sema &SemaRef, const FunctionDecl *FnDecl)
MapType::const_iterator const_iterator
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
Expr * getUninstantiatedDefaultArg()
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static void extendRight(SourceRange &R, SourceRange After)
QualType getCanonicalTypeInternal() const
SourceLocation getVirtualSpecLoc() const
Represents a C++ base or member initializer.
LanguageIDs
Represents the language in a linkage specification.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
This template specialization was declared or defined by an explicit specialization (C++ [temp...
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
bool hasNonTrivialObjCLifetime() const
IndirectFieldDecl * getIndirectMember() const
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
const llvm::APInt & getSize() const
bool isFunctionType() const
TrivialSubobjectKind
The kind of subobject we are checking for triviality.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
static const void * GetKeyForBase(ASTContext &Context, QualType BaseType)
TypeSourceInfo * getTypeSourceInfo() const
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static UsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target)
TypeLocClass getTypeLocClass() const
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr)
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
The template argument is a type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Holds information about the various types of exception specification.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
void addDecl(Decl *D)
Add the declaration D into this context.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
void setInherited(bool I)
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Represents a base class of a C++ class.
bool hasTypename() const
Return true if the using declaration has 'typename'.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
This is a scope that can contain a declaration.
bool isObjCObjectType() const
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static const void * GetKeyForMember(ASTContext &Context, CXXCtorInitializer *Member)
A use of a default initializer in a constructor or in aggregate initialization.
EnumDecl * getStdAlignValT() const
bool isSet() const
Deprecated.
bool isLValueReferenceType() const
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
void setInvalidType(bool Val=true)
Reading or writing from this object requires a barrier call.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
QualType getParamType(unsigned i) const
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
TranslationUnitDecl * getTranslationUnitDecl() const
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
void Deallocate(void *Ptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static bool functionDeclHasDefaultArgument(const FunctionDecl *FD)
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
CallingConv getCallConv() const
ThreadStorageClassSpecifier
Thread storage-class-specifier.
void setImplicitMoveAssignmentIsDeleted()
Set that we attempted to declare an implicit move assignment operator, but overload resolution failed...
Describes the sequence of initializations required to initialize a given object or reference with a s...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Captures information about "declaration specifiers".
ActionResult< Expr * > ExprResult
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
SourceLocation getRestrictSpecLoc() const
static bool CheckConstexprParameterTypes(Sema &SemaRef, const FunctionDecl *FD)
void setDefaultArg(Expr *defarg)
bool isMutable() const
Determines whether this field is mutable (C++ only).
void setEnd(SourceLocation e)
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
Represents a C++ struct/union/class.
static bool isCompoundAssignmentOp(Opcode Opc)
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
bool hasUserDeclaredMoveConstructor() const
Determine whether this class has had a move constructor declared by the user.
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr *> &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, ArrayRef< CXXCtorInitializer *> Initializers=None)
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier *> Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
CXXCatchStmt - This represents a C++ catch block.
void CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD)
void setConstexpr(bool IC)
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter, but we can't parse it yet because we're inside a class definition.
static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, llvm::APSInt &Size)
void popCodeSynthesisContext()
void setParam(unsigned i, ParmVarDecl *VD)
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
static bool hasOneRealArgument(MultiExprArg Args)
Determine whether the given list arguments contains exactly one "real" (non-default) argument...
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
static unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void setUnsupportedFriend(bool Unsupported)
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
Declaration of a class template.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool isVirtualSpecified() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
bool lambdaIsDefaultConstructibleAndAssignable() const
Determine whether this lambda should have an implicit default constructor and copy and move assignmen...
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
SourceManager & getSourceManager() const
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
A template-id, e.g., f<int>.
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant, according to C++ [class.virtual]p5.
bool hasInheritedAssignment() const
Determine whether this class has a using-declaration that names a base class assignment operator...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
AccessSpecifier Access
The access along this inheritance path.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool isInlineSpecified() const
static bool defaultedSpecialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember CSM, bool ConstArg, CXXConstructorDecl *InheritedCtor=nullptr, Sema::InheritedConstructorInfo *Inherited=nullptr)
Determine whether the specified special member function would be constexpr if it were implicitly defi...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
SourceLocation getAtomicSpecLoc() const
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated, or computed.
FriendDecl * CheckFriendTypeDecl(SourceLocation LocStart, SourceLocation FriendLoc, TypeSourceInfo *TSInfo)
Perform semantic analysis of the given friend type declaration.
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
static void CheckAbstractClassUsage(AbstractUsageInfo &Info, CXXMethodDecl *MD)
Check for invalid uses of an abstract type in a method declaration.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
unsigned getNumElements() const
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
The top declaration context.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
SourceLocation getConstexprSpecLoc() const
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD)
Diagnose methods which overload virtual methods in a base class without overriding any...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool implicitCopyConstructorHasConstParam() const
Determine whether an implicit copy constructor for this type would have a parameter with a const-qual...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
void addAddressSpace(LangAS space)
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
ArrayRef< Binding > bindings() const
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness, issuing any diagnostics required.
DeclaratorContext getContext() const
bool isStaticDataMember() const
Determines whether this is a static data member.
SourceLocation getInnerLocStart() const
Return SourceLocation representing start of source range ignoring outer template declarations.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
bool hasDirectFields() const
Determine whether this class has direct non-static data members.
An instance of this class represents the declaration of a property member.
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
A trivial tuple used to represent a source range.
void setLexicalDeclContext(DeclContext *DC)
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
bool isTranslationUnit() const
Expr * getRepAsExpr() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
Represents a C++ namespace alias.
Decl * ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
No keyword precedes the qualified type name.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Represents C++ using-directive.
void DiagnoseAbstractType(const CXXRecordDecl *RD)
static Expr * CastForMoving(Sema &SemaRef, Expr *E, QualType T=QualType())
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
Describes an entity that is being initialized.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
attr::Kind getKind() const
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr *> Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
The global specifier '::'. There is no stored value.
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
The object is actually the complete object.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void setType(QualType newType)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
Wrapper for source info for pointers.
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
SourceRange getSourceRange() const LLVM_READONLY
const LangOptions & getLangOpts() const
void WillReplaceSpecifier(bool ForceReplacement)
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
Wrapper for source info for block pointers.
void setDeletedAsWritten(bool D=true)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions, such as the default constructor, copy constructor, or destructor, to the given C++ class (C++ [special]p1).
An implicit 'self' parameter.
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
ExceptionSpecInfo ExceptionSpec
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
A deduction-guide name (a template-name)
Declaration of a template function.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
Represents an implicitly-generated value initialization of an object of a given type.
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
void setElaboratedKeywordLoc(SourceLocation Loc)
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
static bool checkLiteralOperatorTemplateParameterList(Sema &SemaRef, FunctionTemplateDecl *TpDecl)
static const ParsedAttr * getMSPropertyAttr(const ParsedAttributesView &list)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool isExternallyVisible() const
QualType getType() const
Return the type wrapped by this type source info.
A single template declaration.
bool isBeingDefined() const
Return true if this decl is currently being defined.
ConstructorUsingShadowDecl * getShadowDecl() const
noexcept(expression), evals to 'true'
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
decl_iterator decls_end() const
The triviality of a method unaffected by "trivial_abi".
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
static unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
param_type_iterator param_type_end() const
unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template)
static void DiagnoseNamespaceInlineMismatch(Sema &S, SourceLocation KeywordLoc, SourceLocation Loc, IdentifierInfo *II, bool *IsInline, NamespaceDecl *PrevNS)
Diagnose a mismatch in 'inline' qualifiers when a namespace is reopened.
method_range methods() const
The subobject is a non-static data member.
bool isNoDestroy(const ASTContext &) const
Do we need to emit an exit-time destructor for this variable?
QualType getType() const
Retrieves the type of the base class.
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>, including the values return by builtin <=> operators.
bool defaultedDestructorIsDeleted() const
true if a defaulted destructor for this class would be deleted.