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);
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());
4051 Init = MemberInit.
get();
4069 if (!LangOpts.CPlusPlus11)
4070 return Diag(NameLoc, diag::err_delegating_ctor)
4072 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4074 bool InitList =
true;
4076 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4078 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4089 InitRange.getEnd());
4091 ExprResult DelegationInit = InitSeq.Perform(*
this, DelegationEntity, Kind,
4096 assert(cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor() &&
4097 "Delegating constructor with no target?");
4102 DelegationInit = ActOnFinishFullExpr(DelegationInit.get(),
4103 InitRange.getBegin());
4104 if (DelegationInit.isInvalid())
4114 if (CurContext->isDependentContext())
4115 DelegationInit = Init;
4118 DelegationInit.getAs<
Expr>(),
4119 InitRange.getEnd());
4130 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4145 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4152 if (DiagnoseUnexpandedParameterPack(BaseLoc, BaseTInfo, UPPC_Initializer))
4155 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4165 return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
4174 if (!DirectBaseSpec && !VirtualBaseSpec) {
4183 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4190 DiscardCleanupsInEvaluationContext();
4195 InitRange.
getEnd(), EllipsisLoc);
4202 if (DirectBaseSpec && VirtualBaseSpec)
4203 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4208 BaseSpec = VirtualBaseSpec;
4211 bool InitList =
true;
4213 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4215 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4225 ExprResult BaseInit = InitSeq.Perform(*
this, BaseEntity, Kind, Args,
nullptr);
4232 BaseInit = ActOnFinishFullExpr(BaseInit.
get(), InitRange.
getBegin());
4243 if (CurContext->isDependentContext())
4250 InitRange.
getEnd(), EllipsisLoc);
4255 if (T.isNull()) T = E->
getType();
4260 TargetType, ExprLoc);
4280 bool IsInheritedVirtualBase,
4284 IsInheritedVirtualBase);
4288 switch (ImplicitInitKind) {
4294 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
None);
4300 bool Moving = ImplicitInitKind ==
IIK_Move;
4322 BasePath.push_back(BaseSpec);
4324 CK_UncheckedDerivedToBase,
4332 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4355 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
4370 bool Moving = ImplicitInitKind ==
IIK_Move;
4378 Expr *MemberExprBase =
4393 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
4395 MemberLookup.resolveKind();
4429 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
4444 "Unhandled implicit init kind!");
4460 InitSeq.
Perform(SemaRef, InitEntity, InitKind,
None);
4483 diag::err_uninitialized_member_in_ctor)
4493 diag::err_uninitialized_member_in_ctor)
4514 CXXMemberInit =
nullptr;
4519 struct BaseAndFieldInfo {
4522 bool AnyErrorsInInits;
4524 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
4526 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
4529 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
4541 bool isImplicitCopyOrMove()
const {
4552 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
4556 AllToInit.push_back(Init);
4565 bool isInactiveUnionMember(
FieldDecl *Field) {
4575 if (isImplicitCopyOrMove())
4593 bool isWithinInactiveUnionMember(
FieldDecl *Field,
4596 return isInactiveUnionMember(Field);
4598 for (
auto *
C : Indirect->
chain()) {
4600 if (Field && isInactiveUnionMember(Field))
4615 if (!ArrayT->getSize())
4618 T = ArrayT->getElementType();
4633 return Info.addFieldInitializer(Init);
4647 if (Info.isWithinInactiveUnionMember(Field, Indirect))
4668 return Info.addFieldInitializer(Init);
4678 if (Info.AnyErrorsInInits)
4689 return Info.addFieldInitializer(Init);
4707 DelegatingCtorDecls.push_back(Constructor);
4709 DiagnoseUninitializedFields(*
this, Constructor);
4719 if (!Initializers.empty()) {
4723 memcpy(baseOrMemberInitializers, Initializers.data(),
4735 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
4743 bool HadError =
false;
4745 for (
unsigned i = 0; i < Initializers.size(); i++) {
4754 for (
auto *
C : F->chain()) {
4757 Info.ActiveUnionMember.insert(std::make_pair(
4761 if (FD->getParent()->isUnion())
4762 Info.ActiveUnionMember.insert(std::make_pair(
4763 FD->getParent()->getCanonicalDecl(), FD->getCanonicalDecl()));
4769 llvm::SmallPtrSet<CXXBaseSpecifier *, 16> DirectVBases;
4770 for (
auto &I : ClassDecl->
bases()) {
4772 DirectVBases.insert(&I);
4776 for (
auto &VBase : ClassDecl->
vbases()) {
4778 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
4786 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
4787 << VBase.getType() << ClassDecl;
4788 DiagnoseAbstractType(ClassDecl);
4791 Info.AllToInit.push_back(
Value);
4792 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
4797 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
4800 &VBase, IsInheritedVirtualBase,
4806 Info.AllToInit.push_back(CXXBaseInit);
4813 if (
Base.isVirtual())
4817 = Info.AllBaseFields.lookup(
Base.getType()->getAs<
RecordType>())) {
4818 Info.AllToInit.push_back(
Value);
4819 }
else if (!AnyErrors) {
4828 Info.AllToInit.push_back(CXXBaseInit);
4833 for (
auto *Mem : ClassDecl->
decls()) {
4834 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
4839 if (F->isUnnamedBitfield())
4845 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
4854 if (Info.isImplicitCopyOrMove())
4857 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
4858 if (F->getType()->isIncompleteArrayType()) {
4860 "Incomplete array type is not valid");
4872 unsigned NumInitializers = Info.AllToInit.size();
4873 if (NumInitializers > 0) {
4877 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
4883 MarkBaseAndMemberDestructorsReferenced(Constructor->
getLocation(),
4894 for (
auto *Field : RD->
fields())
4922 bool ShouldCheckOrder =
false;
4923 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4925 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
4927 ShouldCheckOrder =
true;
4931 if (!ShouldCheckOrder)
4942 for (
const auto &VBase : ClassDecl->
vbases())
4946 for (
const auto &
Base : ClassDecl->
bases()) {
4947 if (
Base.isVirtual())
4953 for (
auto *Field : ClassDecl->
fields()) {
4954 if (Field->isUnnamedBitfield())
4960 unsigned NumIdealInits = IdealInitKeys.size();
4961 unsigned IdealIndex = 0;
4964 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4970 for (; IdealIndex != NumIdealInits; ++IdealIndex)
4971 if (InitKey == IdealInitKeys[IdealIndex])
4977 if (IdealIndex == NumIdealInits && PrevInit) {
4980 diag::warn_initializer_out_of_order);
4993 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
4994 if (InitKey == IdealInitKeys[IdealIndex])
4997 assert(IdealIndex < NumIdealInits &&
4998 "initializer not found in initializer list");
5006 bool CheckRedundantInit(
Sema &S,
5016 diag::err_multiple_mem_initialization)
5017 << Field->getDeclName()
5021 assert(BaseClass &&
"neither field nor base");
5023 diag::err_multiple_base_initialization)
5033 typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5034 typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5036 bool CheckRedundantUnionInit(
Sema &S,
5038 RedundantUnionMap &Unions) {
5045 UnionEntry &En = Unions[
Parent];
5046 if (En.first && En.first != Child) {
5048 diag::err_multiple_mem_union_initialization)
5051 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5052 << 0 << En.second->getSourceRange();
5076 if (!ConstructorDecl)
5079 AdjustDeclIfTemplate(ConstructorDecl);
5085 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5092 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5095 RedundantUnionMap MemberUnions;
5097 bool HadError =
false;
5098 for (
unsigned i = 0; i < MemInits.size(); i++) {
5106 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
5107 CheckRedundantUnionInit(*
this, Init, MemberUnions))
5111 if (CheckRedundantInit(*
this, Init, Members[Key]))
5116 if (MemInits.size() != 1) {
5118 diag::err_delegating_initializer_alone)
5119 << Init->
getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5122 SetDelegatingInitializer(Constructor, MemInits[i]);
5133 SetCtorInitializers(Constructor, AnyErrors, MemInits);
5135 DiagnoseUninitializedFields(*
this, Constructor);
5152 for (
auto *Field : ClassDecl->
fields()) {
5153 if (Field->isInvalidDecl())
5176 assert(Dtor &&
"No dtor found for FieldClassDecl!");
5177 CheckDestructorAccess(Field->getLocation(), Dtor,
5178 PDiag(diag::err_access_dtor_field)
5179 << Field->getDeclName()
5182 MarkFunctionReferenced(Location, Dtor);
5183 DiagnoseUseOfDecl(Dtor, Location);
5188 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5190 llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
5193 for (
const auto &
Base : ClassDecl->
bases()) {
5198 if (
Base.isVirtual()) {
5199 if (!VisitVirtualBases)
5201 DirectVirtualBases.insert(RT);
5212 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5215 CheckDestructorAccess(
Base.getBeginLoc(), Dtor,
5216 PDiag(diag::err_access_dtor_base)
5217 <<
Base.getType() <<
Base.getSourceRange(),
5220 MarkFunctionReferenced(Location, Dtor);
5221 DiagnoseUseOfDecl(Dtor, Location);
5224 if (!VisitVirtualBases)
5228 for (
const auto &VBase : ClassDecl->
vbases()) {
5233 if (DirectVirtualBases.count(RT))
5244 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5245 if (CheckDestructorAccess(
5247 PDiag(diag::err_access_dtor_vbase)
5251 CheckDerivedToBaseConversion(
5253 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5257 MarkFunctionReferenced(Location, Dtor);
5258 DiagnoseUseOfDecl(Dtor, Location);
5267 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5268 SetCtorInitializers(Constructor,
false);
5269 DiagnoseUninitializedFields(*
this, Constructor);
5296 if (!isAbstractType(Loc, T))
5308 if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
5314 if (Diags.isLastDiagnosticIgnored())
5322 llvm::SmallPtrSet<const CXXMethodDecl *, 8> SeenPureMethods;
5324 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5325 MEnd = FinalOverriders.end();
5329 SOEnd = M->second.end();
5330 SO != SOEnd; ++SO) {
5337 if (SO->second.size() != 1)
5340 if (!SO->second.front().Method->isPure())
5343 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5346 Diag(SO->second.front().Method->getLocation(),
5347 diag::note_pure_virtual_function)
5348 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5352 if (!PureVirtualClassDiagSet)
5354 PureVirtualClassDiagSet->insert(RD);
5358 struct AbstractUsageInfo {
5365 : S(S), Record(Record),
5370 void DiagnoseAbstractType() {
5371 if (Invalid)
return;
5379 struct CheckAbstractUsage {
5380 AbstractUsageInfo &Info;
5383 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
5384 : Info(Info), Ctx(Ctx) {}
5388 #define ABSTRACT_TYPELOC(CLASS, PARENT) 5389 #define TYPELOC(CLASS, PARENT) \ 5390 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break; 5391 #include "clang/AST/TypeLocNodes.def" 5397 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
5412 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
5422 #define CheckPolymorphic(Type) \ 5423 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \ 5424 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \ 5439 return Visit(Next, Sel);
5449 T = Info.S.Context.getBaseElementType(T);
5452 if (CT != Info.AbstractType)
return;
5456 Info.S.Diag(Ctx->
getLocation(), diag::err_array_of_abstract_type)
5459 Info.S.Diag(Ctx->
getLocation(), diag::err_abstract_type_in_decl)
5462 Info.DiagnoseAbstractType();
5468 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
5491 for (
auto *D : RD->
decls()) {
5492 if (D->isImplicit())
continue;
5495 if (isa<CXXMethodDecl>(D)) {
5497 }
else if (isa<FunctionTemplateDecl>(D)) {
5498 FunctionDecl *FD = cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
5502 }
else if (isa<FieldDecl>(D)) {
5506 }
else if (isa<VarDecl>(D)) {
5507 VarDecl *VD = cast<VarDecl>(D);
5512 }
else if (isa<CXXRecordDecl>(D)) {
5514 }
else if (isa<ClassTemplateDecl>(D)) {
5516 cast<ClassTemplateDecl>(D)->getTemplatedDecl());
5526 assert(ClassAttr->
getKind() == attr::DLLExport);
5538 for (Decl *Member : Class->
decls()) {
5541 auto *VD = dyn_cast<
VarDecl>(Member);
5542 if (VD && Member->getAttr<DLLExportAttr>() &&
5551 if (Member->getAttr<DLLExportAttr>()) {
5552 if (MD->isUserProvided()) {
5563 }
else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
5564 MD->isCopyAssignmentOperator() ||
5565 MD->isMoveAssignmentOperator()) {
5594 for (Decl *Member : Class->
decls()) {
5597 if (!CD || !CD->isDefaultConstructor())
5599 auto *
Attr = CD->getAttr<DLLExportAttr>();
5612 if (LastExportedDefaultCtor) {
5614 diag::err_attribute_dll_ambiguous_default_ctor)
5616 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
5617 << CD->getDeclName();
5620 LastExportedDefaultCtor = CD;
5626 for (
auto *Method : Class->
methods()) {
5627 if (Method->isUserProvided())
5629 if (
Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method,
true))
5640 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
5641 if (
Attr *TemplateAttr =
5642 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
5643 auto *A = cast<InheritableAttr>(TemplateAttr->clone(getASTContext()));
5644 A->setInherited(
true);
5655 << Class << ClassAttr;
5662 for (Decl *Member : Class->
decls()) {
5663 if (!isa<VarDecl>(Member) && !isa<CXXMethodDecl>(Member))
5666 if (!MemberAttr || MemberAttr->
isInherited() || Member->isInvalidDecl())
5670 diag::err_attribute_dll_member_of_dll_class)
5671 << MemberAttr << ClassAttr;
5673 Member->setInvalidDecl();
5682 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
5687 const bool PropagatedImport =
5689 cast<DLLImportAttr>(ClassAttr)->wasPropagatedToBaseTemplate();
5701 ForceDeclarationOfImplicitMembers(Class);
5706 for (Decl *Member : Class->
decls()) {
5716 if (MD->isDeleted())
5719 if (MD->isInlined()) {
5729 if ((MD->isMoveAssignmentOperator() ||
5730 (Ctor && Ctor->isMoveConstructor())) &&
5737 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->isTrivial())
5744 if (VD && PropagatedImport)
5747 if (!cast<NamedDecl>(Member)->isExternallyVisible())
5755 if (!getLangOpts().DllExportInlines && MD && MD->isInlined() &&
5758 if (ClassExported) {
5759 NewAttr = ::new (getASTContext())
5760 DLLExportStaticLocalAttr(ClassAttr->
getRange(),
5764 NewAttr = ::new (getASTContext())
5765 DLLImportStaticLocalAttr(ClassAttr->
getRange(),
5770 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5774 Member->addAttr(NewAttr);
5784 "friend re-decl should not already have a DLLAttr");
5785 NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5787 FD->addAttr(NewAttr);
5794 DelayedDllExportClasses.push_back(Class);
5815 auto *NewAttr = cast<InheritableAttr>(ClassAttr->
clone(getASTContext()));
5816 NewAttr->setInherited(
true);
5817 BaseTemplateSpec->
addAttr(NewAttr);
5821 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
5822 ImportAttr->setPropagatedToBaseTemplate();
5828 checkClassLevelDLLAttribute(BaseTemplateSpec);
5843 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
5848 diag::note_template_class_explicit_specialization_was_here)
5849 << BaseTemplateSpec;
5852 diag::note_template_class_instantiation_was_here)
5853 << BaseTemplateSpec;
5862 cast<CXXConstructorDecl>(MD));
5880 llvm_unreachable(
"Invalid special member.");
5898 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
5899 bool DtorIsTrivialForCall =
false;
5910 CopyCtorIsTrivial =
true;
5912 CopyCtorIsTrivialForCall =
true;
5916 if (CD->isCopyConstructor() && !CD->isDeleted()) {
5917 if (CD->isTrivial())
5918 CopyCtorIsTrivial =
true;
5919 if (CD->isTrivialForCall())
5920 CopyCtorIsTrivialForCall =
true;
5928 DtorIsTrivialForCall =
true;
5930 if (!DD->isDeleted() && DD->isTrivialForCall())
5931 DtorIsTrivialForCall =
true;
5935 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
5948 if (CopyCtorIsTrivial &&
5958 bool HasNonDeletedCopyOrMove =
false;
5964 HasNonDeletedCopyOrMove =
true;
5971 HasNonDeletedCopyOrMove =
true;
5979 if (MD->isDeleted())
5983 if (CD && CD->isCopyOrMoveConstructor())
5984 HasNonDeletedCopyOrMove =
true;
5985 else if (!isa<CXXDestructorDecl>(MD))
5988 if (!MD->isTrivialForCall())
5992 return HasNonDeletedCopyOrMove;
6003 AbstractUsageInfo Info(*
this, Record);
6013 bool Complained =
false;
6014 for (
const auto *F : Record->
fields()) {
6015 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
6018 if (F->getType()->isReferenceType() ||
6019 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
6026 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
6027 << F->getType()->isReferenceType()
6028 << F->getDeclName();
6046 if (((isa<FieldDecl>(D) || isa<UnresolvedUsingValueDecl>(D)) &&
6048 isa<IndirectFieldDecl>(D)) {
6049 Diag((*I)->getLocation(), diag::err_member_name_of_class)
6060 !Record->
hasAttr<FinalAttr>())
6062 diag::warn_non_virtual_dtor) << Context.
getRecordType(Record);
6066 if (FinalAttr *FA = Record->
getAttr<FinalAttr>()) {
6068 << FA->isSpelledAsSealed();
6069 DiagnoseAbstractType(Record);
6074 if (Record->
hasAttr<TrivialABIAttr>())
6075 checkIllFormedTrivialABIStruct(*Record);
6079 bool HasTrivialABI = Record->
hasAttr<TrivialABIAttr>();
6084 bool HasMethodWithOverrideControl =
false,
6085 HasOverridingMethodWithoutOverrideControl =
false;
6087 for (
auto *M : Record->
methods()) {
6091 DiagnoseHiddenVirtualMethods(M);
6092 if (M->hasAttr<OverrideAttr>())
6093 HasMethodWithOverrideControl =
true;
6094 else if (M->size_overridden_methods() > 0)
6095 HasOverridingMethodWithoutOverrideControl =
true;
6097 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted())
6098 CheckExplicitlyDefaultedSpecialMember(M);
6103 if (!M->isImplicit() && !M->isUserProvided()) {
6104 if (CSM != CXXInvalid) {
6105 M->setTrivial(SpecialMemberIsTrivial(M, CSM));
6108 M->setTrivialForCall(
6110 SpecialMemberIsTrivial(M, CSM, TAH_ConsiderTrivialABI));
6117 if ((CSM == CXXCopyConstructor || CSM == CXXMoveConstructor ||
6118 CSM == CXXDestructor) && M->isUserProvided()) {
6119 M->setTrivialForCall(HasTrivialABI);
6123 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
6124 M->hasAttr<DLLExportAttr>()) {
6127 (CSM == CXXDefaultConstructor || CSM == CXXCopyConstructor ||
6128 CSM == CXXDestructor))
6129 M->dropAttr<DLLExportAttr>();
6131 if (M->hasAttr<DLLExportAttr>()) {
6133 ActOnFinishInlineFunctionDef(M);
6139 if (HasMethodWithOverrideControl &&
6140 HasOverridingMethodWithoutOverrideControl) {
6143 for (
auto *M : Record->
methods())
6144 DiagnoseAbsenceOfOverrideControl(M);
6161 checkClassLevelDLLAttribute(Record);
6162 checkClassLevelCodeSegAttribute(Record);
6164 bool ClangABICompat4 =
6186 if (getLangOpts().ForceEmitVTables) {
6204 unsigned FieldQuals,
bool ConstRHS) {
6205 unsigned LHSQuals = 0;
6207 LHSQuals = FieldQuals;
6209 unsigned RHSQuals = FieldQuals;
6219 LHSQuals & Qualifiers::Const,
6220 LHSQuals & Qualifiers::Volatile);
6230 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
6236 : S(S), UseLoc(UseLoc) {
6237 bool DiagnosedMultipleConstructedBases =
false;
6239 UsingDecl *ConstructedBaseUsing =
nullptr;
6243 for (
auto *D : Shadow->
redecls()) {
6244 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
6245 auto *DNominatedBase = DShadow->getNominatedBaseClass();
6246 auto *DConstructedBase = DShadow->getConstructedBaseClass();
6248 InheritedFromBases.insert(
6249 std::make_pair(DNominatedBase->getCanonicalDecl(),
6250 DShadow->getNominatedBaseClassShadowDecl()));
6251 if (DShadow->constructsVirtualBase())
6252 InheritedFromBases.insert(
6253 std::make_pair(DConstructedBase->getCanonicalDecl(),
6254 DShadow->getConstructedBaseClassShadowDecl()));
6256 assert(DNominatedBase == DConstructedBase);
6261 if (!ConstructedBase) {
6262 ConstructedBase = DConstructedBase;
6263 ConstructedBaseUsing = D->getUsingDecl();
6264 }
else if (ConstructedBase != DConstructedBase &&
6266 if (!DiagnosedMultipleConstructedBases) {
6267 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
6270 diag::note_ambiguous_inherited_constructor_using)
6272 DiagnosedMultipleConstructedBases =
true;
6274 S.
Diag(D->getUsingDecl()->getLocation(),
6275 diag::note_ambiguous_inherited_constructor_using)
6276 << DConstructedBase;
6280 if (DiagnosedMultipleConstructedBases)
6287 std::pair<CXXConstructorDecl *, bool>
6290 if (It == InheritedFromBases.end())
6291 return std::make_pair(
nullptr,
false);
6295 return std::make_pair(
6297 It->second->constructsVirtualBase());
6300 return std::make_pair(Ctor,
false);
6314 if (InheritedCtor) {
6317 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
6319 return BaseCtor->isConstexpr();
6383 if (Ctor && ClassDecl->
isUnion())
6402 for (
const auto &B : ClassDecl->
bases()) {
6404 if (!BaseType)
continue;
6408 InheritedCtor, Inherited))
6419 for (
const auto *F : ClassDecl->
fields()) {
6420 if (F->isInvalidDecl())
6426 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
6429 ConstArg && !F->isMutable()))
6451 auto *CD = cast<CXXConstructorDecl>(MD);
6452 assert(CD->getInheritedConstructor() &&
6453 "only special members have implicit exception specs");
6455 S, Loc, CD->getInheritedConstructor().getShadowDecl());
6482 auto ESI = IES.getExceptionSpec();
6485 UpdateExceptionSpec(MD, ESI);
6501 "not an explicitly-defaulted special member");
6507 bool HadError =
false;
6519 bool DeleteOnTypeMismatch = getLangOpts().CPlusPlus2a &&
First;
6520 bool ShouldDeleteForTypeMismatch =
false;
6521 unsigned ExpectedParams = 1;
6522 if (CSM == CXXDefaultConstructor || CSM == CXXDestructor)
6532 if (DeleteOnTypeMismatch)
6533 ShouldDeleteForTypeMismatch =
true;
6543 bool CanHaveConstParam =
false;
6544 if (CSM == CXXCopyConstructor)
6546 else if (CSM == CXXCopyAssignment)
6550 if (CSM == CXXCopyAssignment || CSM == CXXMoveAssignment) {
6558 if (!Context.
hasSameType(ReturnType, ExpectedReturnType)) {
6559 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
6560 << (CSM == CXXMoveAssignment) << ExpectedReturnType;
6566 if (DeleteOnTypeMismatch)
6567 ShouldDeleteForTypeMismatch =
true;
6570 << (CSM == CXXMoveAssignment) << getLangOpts().CPlusPlus14;
6578 bool HasConstParam =
false;
6585 if (DeleteOnTypeMismatch)
6586 ShouldDeleteForTypeMismatch =
true;
6589 diag::err_defaulted_special_member_volatile_param) << CSM;
6594 if (HasConstParam && !CanHaveConstParam) {
6595 if (DeleteOnTypeMismatch)
6596 ShouldDeleteForTypeMismatch =
true;
6597 else if (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment) {
6599 diag::err_defaulted_special_member_copy_const_param)
6600 << (CSM == CXXCopyAssignment);
6605 diag::err_defaulted_special_member_move_const_param)
6606 << (CSM == CXXMoveAssignment);
6610 }
else if (ExpectedParams) {
6613 assert(CSM == CXXCopyAssignment &&
"unexpected non-ref argument");
6627 if ((getLangOpts().
CPlusPlus14 ? !isa<CXXDestructorDecl>(MD)
6628 : isa<CXXConstructorDecl>(MD)) &&
6631 Diag(MD->
getBeginLoc(), diag::err_incorrect_defaulted_constexpr) << CSM;
6648 DelayedDefaultedMemberExceptionSpecs.push_back(std::make_pair(MD, Type));
6650 CheckExplicitlyDefaultedMemberExceptionSpec(MD, Type);
6665 llvm::makeArrayRef(&ArgType,
6670 if (ShouldDeleteForTypeMismatch || ShouldDeleteSpecialMember(MD, CSM)) {
6673 if (!inTemplateInstantiation() && !HadError) {
6675 if (ShouldDeleteForTypeMismatch) {
6678 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
6681 if (ShouldDeleteForTypeMismatch && !HadError) {
6683 diag::warn_cxx17_compat_defaulted_method_type_mismatch) << CSM;
6689 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
6690 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
6691 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
6722 CheckEquivalentExceptionSpec(
6723 PDiag(diag::err_incorrect_defaulted_exception_spec)
6724 << getSpecialMember(MD), PDiag(),
6730 decltype(DelayedOverridingExceptionSpecChecks) Overriding;
6731 decltype(DelayedEquivalentExceptionSpecChecks)
Equivalent;
6732 decltype(DelayedDefaultedMemberExceptionSpecs) Defaulted;
6734 std::swap(Overriding, DelayedOverridingExceptionSpecChecks);
6735 std::swap(
Equivalent, DelayedEquivalentExceptionSpecChecks);
6736 std::swap(Defaulted, DelayedDefaultedMemberExceptionSpecs);
6740 for (
auto &Check : Overriding)
6741 CheckOverridingFunctionExceptionSpec(Check.first, Check.second);
6746 CheckEquivalentExceptionSpec(Check.second, Check.first);
6750 for (
auto &Spec : Defaulted)
6751 CheckExplicitlyDefaultedMemberExceptionSpec(Spec.first, Spec.second);
6757 template<
typename Derived>
6758 struct SpecialMemberVisitor {
6765 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
6769 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
6774 IsConstructor =
true;
6778 IsAssignment =
true;
6783 llvm_unreachable(
"invalid special member kind");
6789 ConstArg = RT->getPointeeType().isConstQualified();
6793 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
6796 bool isMove()
const {
6802 unsigned Quals,
bool IsMutable) {
6804 ConstArg && !IsMutable);
6814 cast<CXXConstructorDecl>(MD)->getInheritedConstructor().getConstructor();
6821 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
6828 return B->getBaseTypeLoc();
6830 return Subobj.get<
FieldDecl*>()->getLocation();
6835 VisitNonVirtualBases,
6840 VisitPotentiallyConstructedBases,
6846 bool visit(BasesToVisit Bases) {
6849 if (Bases == VisitPotentiallyConstructedBases)
6850 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
6852 for (
auto &B : RD->
bases())
6853 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
6854 getDerived().visitBase(&B))
6857 if (Bases == VisitAllBases)
6858 for (
auto &B : RD->
vbases())
6859 if (getDerived().visitBase(&B))
6862 for (
auto *F : RD->
fields())
6863 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
6864 getDerived().visitField(F))
6873 struct SpecialMemberDeletionInfo
6874 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
6879 bool AllFieldsAreConst;
6884 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
6885 Loc(MD->
getLocation()), AllFieldsAreConst(
true) {}
6894 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
6897 bool shouldDeleteForField(
FieldDecl *FD);
6898 bool shouldDeleteForAllConstMembers();
6900 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
6902 bool shouldDeleteForSubobjectCall(Subobject Subobj,
6904 bool IsDtorCallInCtor);
6912 bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
6932 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
6934 bool IsDtorCallInCtor) {
6941 DiagKind = !Decl ? 0 : 1;
6944 else if (!isAccessible(Subobj, Decl))
6962 diag::note_deleted_special_member_class_subobject)
6963 << getEffectiveCSM() << MD->
getParent() <<
true 6964 << Field << DiagKind << IsDtorCallInCtor;
6968 diag::note_deleted_special_member_class_subobject)
6969 << getEffectiveCSM() << MD->
getParent() <<
false 6970 << Base->
getType() << DiagKind << IsDtorCallInCtor;
6983 bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
6986 bool IsMutable = Field && Field->
isMutable();
7004 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
7011 if (IsConstructor) {
7014 false,
false,
false,
false,
false);
7015 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
7033 if (
auto *BaseCtor = SMOR.
getMethod()) {
7038 if (BaseCtor->isDeleted() && Diagnose) {
7040 diag::note_deleted_special_member_class_subobject)
7041 << getEffectiveCSM() << MD->
getParent() <<
false 7042 << Base->
getType() << 1 <<
false;
7045 return BaseCtor->isDeleted();
7047 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
7052 bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
7061 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
7062 << !!ICI << MD->
getParent() << FD << FieldType << 0;
7073 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
7079 AllFieldsAreConst =
false;
7085 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
7089 }
else if (IsAssignment) {
7094 << isMove() << MD->
getParent() << FD << FieldType << 0;
7109 if (!inUnion() && FieldRecord->
isUnion() &&
7111 bool AllVariantFieldsAreConst =
true;
7114 for (
auto *UI : FieldRecord->
fields()) {
7118 AllVariantFieldsAreConst =
false;
7121 if (UnionFieldRecord &&
7122 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
7132 diag::note_deleted_default_ctor_all_const)
7142 if (shouldDeleteForClassSubobject(FieldRecord, FD,
7153 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
7157 bool AnyFields =
false;
7159 if ((AnyFields = !F->isUnnamedBitfield()))
7165 diag::note_deleted_default_ctor_all_const)
7191 (CSM == CXXDefaultConstructor || CSM == CXXCopyAssignment)) {
7200 if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
7209 (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
7215 bool DeletesOnlyMatchingCopy =
7216 getLangOpts().MSVCCompat &&
7220 (!DeletesOnlyMatchingCopy || CSM == CXXCopyConstructor)) {
7221 if (!Diagnose)
return true;
7224 for (
auto *I : RD->
ctors()) {
7225 if (I->isMoveConstructor()) {
7226 UserDeclaredMove = I;
7230 assert(UserDeclaredMove);
7232 (!DeletesOnlyMatchingCopy || CSM == CXXCopyAssignment)) {
7233 if (!Diagnose)
return true;
7236 for (
auto *I : RD->
methods()) {
7237 if (I->isMoveAssignmentOperator()) {
7238 UserDeclaredMove = I;
7242 assert(UserDeclaredMove);
7245 if (UserDeclaredMove) {
7247 diag::note_deleted_copy_user_declared_move)
7248 << (CSM == CXXCopyAssignment) << RD
7260 if (CSM == CXXDestructor && MD->
isVirtual()) {
7265 OperatorDelete,
false)) {
7272 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
7280 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
7281 : SMI.VisitPotentiallyConstructedBases))
7284 if (SMI.shouldDeleteForAllConstMembers())
7287 if (getLangOpts().CUDA) {
7294 assert(ICI || CSM == getSpecialMember(MD));
7297 RealCSM = getSpecialMember(MD);
7299 return inferCUDATargetForImplicitSpecialMember(RD, RealCSM, MD,
7300 SMI.ConstArg, Diagnose);
7323 *Selected =
nullptr;
7327 llvm_unreachable(
"not a special member");
7345 for (
auto *CI : RD->
ctors()) {
7346 if (!CI->isDefaultConstructor())
7353 *Selected = DefCtor;
7386 }
else if (!Selected) {
7394 goto NeedOverloadResolution;
7404 }
else if (!Selected) {
7409 goto NeedOverloadResolution;
7413 NeedOverloadResolution:
7441 llvm_unreachable(
"unknown special method kind");
7445 for (
auto *CI : RD->
ctors())
7446 if (!CI->isImplicit())
7450 typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
7453 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
7483 ConstRHS, TAH, Diagnose ? &Selected :
nullptr))
7491 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
7494 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
7495 }
else if (!Selected)
7496 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
7501 << Kind << SubType.getUnqualifiedType() << CSM;
7503 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
7504 << Kind << SubType.getUnqualifiedType() << CSM;
7509 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
7510 << Kind << SubType.getUnqualifiedType() << CSM;
7528 for (
const auto *FI : RD->
fields()) {
7529 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
7535 if (FI->isAnonymousStructOrUnion()) {
7537 CSM, ConstArg, TAH, Diagnose))
7548 S.
Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI;
7558 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
7563 bool ConstRHS = ConstArg && !FI->isMutable();
7577 bool ConstArg = (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment);
7588 assert(!MD->
isUserProvided() && CSM != CXXInvalid &&
"not special enough");
7592 bool ConstArg =
false;
7598 case CXXDefaultConstructor:
7603 case CXXCopyConstructor:
7604 case CXXCopyAssignment: {
7620 case CXXMoveConstructor:
7621 case CXXMoveAssignment: {
7637 llvm_unreachable(
"not a special member");
7643 diag::note_nontrivial_default_arg)
7662 for (
const auto &BI : RD->bases())
7685 if (CSM == CXXDestructor && MD->
isVirtual()) {
7698 if (RD->getNumVBases()) {
7708 for (
const auto *MI : RD->methods()) {
7709 if (MI->isVirtual()) {
7711 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
7716 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
7724 struct FindHiddenVirtualMethod {
7727 llvm::SmallPtrSet<const CXXMethodDecl *, 8> OverridenAndUsingBaseMethods;
7732 static bool CheckMostOverridenMethods(
7734 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
7738 if (CheckMostOverridenMethods(O, Methods))
7754 bool foundSameNameMethod =
false;
7761 foundSameNameMethod =
true;
7778 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
7779 overloadedMethods.push_back(MD);
7783 if (foundSameNameMethod)
7784 OverloadedMethods.append(overloadedMethods.begin(),
7785 overloadedMethods.end());
7786 return foundSameNameMethod;
7793 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
7811 FindHiddenVirtualMethod FHVM;
7822 ND = shad->getTargetDecl();
7828 OverloadedMethods = FHVM.OverloadedMethods;
7833 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
7836 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
7837 HandleFunctionTypeMismatch(PD, MD->
getType(), overloadedMD->
getType());
7848 if (Diags.isIgnored(diag::warn_overloaded_virtual, MD->
getLocation()))
7852 FindHiddenVirtualMethods(MD, OverloadedMethods);
7853 if (!OverloadedMethods.empty()) {
7855 << MD << (OverloadedMethods.size() > 1);
7857 NoteHiddenVirtualMethods(MD, OverloadedMethods);
7862 auto PrintDiagAndRemoveAttr = [&]() {
7866 diag::ext_cannot_use_trivial_abi) << &RD;
7872 PrintDiagAndRemoveAttr();
7876 for (
const auto &B : RD.
bases()) {
7879 if ((!B.getType()->isDependentType() &&
7880 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) ||
7882 PrintDiagAndRemoveAttr();
7887 for (
const auto *FD : RD.
fields()) {
7892 PrintDiagAndRemoveAttr();
7897 if (!RT->isDependentType() &&
7899 PrintDiagAndRemoveAttr();
7911 AdjustDeclIfTemplate(TagDecl);
7914 if (AL.getKind() != ParsedAttr::AT_Visibility)
7917 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored)
7921 ActOnFields(S, RLoc, TagDecl, llvm::makeArrayRef(
7923 reinterpret_cast<Decl**>(FieldCollector->getCurFields()),
7924 FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList);
7926 CheckCompletedCXXClass(cast<CXXRecordDecl>(TagDecl));
7939 DeclareImplicitDefaultConstructor(ClassDecl);
7950 DeclareImplicitCopyConstructor(ClassDecl);
7961 DeclareImplicitCopyConstructor(ClassDecl);
7969 DeclareImplicitMoveConstructor(ClassDecl);
7982 DeclareImplicitCopyAssignment(ClassDecl);
7992 DeclareImplicitMoveAssignment(ClassDecl);
8004 DeclareImplicitDestructor(ClassDecl);
8017 D = TD->getTemplatedDecl();
8019 if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
8020 ParameterLists.push_back(PSD->getTemplateParameters());
8023 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
8024 ParameterLists.push_back(DD->getTemplateParameterList(i));
8028 ParameterLists.push_back(FTD->getTemplateParameters());
8032 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
8033 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
8034 ParameterLists.push_back(TD->getTemplateParameterList(i));
8038 ParameterLists.push_back(CTD->getTemplateParameters());
8044 if (Params->size() > 0)
8049 if (Param->getDeclName()) {
8051 IdResolver.AddDecl(Param);
8060 if (!RecordD)
return;
8061 AdjustDeclIfTemplate(RecordD);
8063 PushDeclContext(S, Record);
8067 if (!RecordD)
return;
8080 IdResolver.AddDecl(Param);
8112 IdResolver.AddDecl(Param);
8125 AdjustDeclIfTemplate(MethodD);
8134 CheckConstructor(Constructor);
8138 CheckCXXDefaultArguments(Method);
8173 diagnoseIgnoredQualifiers(
8185 Diag(SL, diag::err_invalid_qualified_constructor)
8238 const char *ConstRef
8241 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
8267 FindDeallocationFunctionForDestructor(Loc, RD)) {
8268 Expr *ThisArg =
nullptr;
8273 if (OperatorDelete->isDestroyingOperatorDelete()) {
8274 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
8281 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
8282 assert(!This.
isInvalid() &&
"couldn't form 'this' expr in dtor?");
8283 This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
8284 if (This.isInvalid()) {
8287 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
8290 ThisArg = This.get();
8294 DiagnoseUseOfDecl(OperatorDelete, Loc);
8295 MarkFunctionReferenced(Loc, OperatorDelete);
8319 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
8322 if (TST->isTypeAlias())
8324 << DeclaratorType << 1;
8357 diagnoseIgnoredQualifiers(diag::err_destructor_return_type, TypeQuals,
8371 Diag(SL, diag::err_invalid_qualified_destructor)
8499 bool NeedsTypedef =
false;
8503 bool PastFunctionChunk =
false;
8505 switch (Chunk.Kind) {
8507 if (!PastFunctionChunk) {
8508 if (Chunk.Fun.HasTrailingReturnType) {
8510 GetTypeFromParser(Chunk.Fun.getTrailingReturnType(), &TRT);
8513 PastFunctionChunk =
true;
8518 NeedsTypedef =
true;
8540 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
8541 DB << Before <<
After;
8543 if (!NeedsTypedef) {
8547 if (After.isInvalid() && ConvTSI) {
8592 if (DS.isExplicitSpecified())
8593 Diag(DS.getExplicitSpecLoc(),
8594 getLangOpts().CPlusPlus11
8595 ? diag::warn_cxx98_compat_explicit_conversion_functions
8596 : diag::ext_explicit_conversion_functions)
8605 assert(Conversion &&
"Expected to receive a conversion function declaration");
8623 ConvType = ConvTypeRef->getPointeeType();
8627 else if (ConvType->isRecordType()) {
8629 if (ConvType == ClassType)
8632 else if (IsDerivedFrom(Conversion->
getLocation(), ClassType, ConvType))
8634 << ClassType << ConvType;
8635 }
else if (ConvType->isVoidType()) {
8637 << ClassType << ConvType;
8642 return ConversionTemplate;
8650 struct BadSpecifierDiagnoser {
8653 ~BadSpecifierDiagnoser() {
8657 template<
typename T>
void check(
SourceLocation SpecLoc, T Spec) {
8661 return check(SpecLoc,
8667 if (!Specifiers.empty()) Specifiers +=
" ";
8673 std::string Specifiers;
8685 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
8690 if (!CurContext->getRedeclContext()->Equals(
8693 << GuidedTemplateDecl;
8694 Diag(GuidedTemplateDecl->
getLocation(), diag::note_template_decl_here);
8699 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
8700 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
8701 DS.isNoreturnSpecified() || DS.isConstexprSpecified()) {
8702 BadSpecifierDiagnoser Diagnoser(
8704 diag::err_deduction_guide_invalid_specifier);
8706 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
8711 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
8712 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
8713 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
8714 DS.ClearConstexprSpec();
8716 Diagnoser.check(DS.getConstSpecLoc(),
"const");
8717 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
8718 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
8719 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
8720 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
8721 DS.ClearTypeQualifiers();
8723 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
8724 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
8725 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
8726 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
8727 DS.ClearTypeSpecType();
8734 bool FoundFunction =
false;
8740 diag::err_deduction_guide_with_complex_decl)
8744 if (!Chunk.Fun.hasTrailingReturnType()) {
8746 diag::err_deduction_guide_no_trailing_return_type);
8752 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
8754 QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
8755 assert(TSI &&
"deduction guide has valid type but invalid return type?");
8756 bool AcceptableReturnType =
false;
8757 bool MightInstantiateToSpecialization =
false;
8760 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
8761 bool TemplateMatches =
8764 AcceptableReturnType =
true;
8769 MightInstantiateToSpecialization = !(TD && isa<ClassTemplateDecl>(TD) &&
8773 MightInstantiateToSpecialization =
true;
8776 if (!AcceptableReturnType) {
8778 diag::err_deduction_guide_bad_trailing_return_type)
8779 << GuidedTemplate << TSI->
getType()
8780 << MightInstantiateToSpecialization
8786 FoundFunction =
true;
8803 assert(*IsInline != PrevNS->
isInline());
8811 if (*IsInline && II && II->
getName().startswith(
"__atomic") &&
8816 NS->setInline(*IsInline);
8819 for (
auto *I : PrevNS->
decls())
8820 if (
auto *ND = dyn_cast<NamedDecl>(I))
8828 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
8831 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
8846 bool IsInline = InlineLoc.
isValid();
8847 bool IsInvalid =
false;
8849 bool AddToKnown =
false;
8865 LookupResult R(*
this, II, IdentLoc, LookupOrdinaryName,
8866 ForExternalRedeclaration);
8867 LookupQualifiedName(R, CurContext->getRedeclContext());
8870 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
8874 if (IsInline != PrevNS->
isInline())
8877 }
else if (PrevDecl) {
8879 Diag(Loc, diag::err_redefinition_different_kind)
8881 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
8884 }
else if (II->
isStr(
"std") &&
8885 CurContext->getRedeclContext()->isTranslationUnit()) {
8888 PrevNS = getStdNamespace();
8890 AddToKnown = !IsInline;
8893 AddToKnown = !IsInline;
8907 if (PrevNS && IsInline != PrevNS->
isInline())
8913 StartLoc, Loc, II, PrevNS);
8917 ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
8918 AddPragmaAttributes(DeclRegionScope, Namespc);
8921 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
8922 PushNamespaceVisibilityAttr(
Attr, Loc);
8925 StdNamespace = Namespc;
8927 KnownNamespaces[Namespc] =
false;
8930 PushOnScopeChains(Namespc, DeclRegionScope);
8935 TU->setAnonymousNamespace(Namespc);
8937 cast<NamespaceDecl>(
Parent)->setAnonymousNamespace(Namespc);
8940 CurContext->addDecl(Namespc);
8971 ActOnDocumentableDecl(Namespc);
8978 PushDeclContext(NamespcScope, Namespc);
8986 return AD->getNamespace();
8987 return dyn_cast_or_null<NamespaceDecl>(D);
8993 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
8994 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
8997 if (Namespc->
hasAttr<VisibilityAttr>())
8998 PopPragmaVisibility(
true, RBrace);
9002 return cast_or_null<CXXRecordDecl>(
9011 return cast_or_null<NamespaceDecl>(
9016 if (!StdExperimentalNamespaceCache) {
9017 if (
auto Std = getStdNamespace()) {
9020 if (!LookupQualifiedName(
Result,
Std) ||
9021 !(StdExperimentalNamespaceCache =
9023 Result.suppressDiagnostics();
9026 return StdExperimentalNamespaceCache;
9038 struct InvalidSTLDiagnoser {
9044 const VarDecl *VD =
nullptr) {
9046 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
9047 << TyForDiags << ((int)Sel);
9048 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
9049 assert(!Name.empty());
9053 if (Sel == USS_InvalidMember) {
9054 S.
Diag(VD->getLocation(), diag::note_var_declared_here)
9055 << VD << VD->getSourceRange();
9065 "Looking for comparison category type outside of C++.");
9070 if (Info && FullyCheckedComparisonCategories[static_cast<unsigned>(Kind)])
9075 std::string NameForDiags =
"std::";
9077 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
9082 assert(Info->
Kind == Kind);
9098 if (RequireCompleteType(Loc, TyForDiags, diag::err_incomplete_type))
9101 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags};
9104 return UnsupportedSTLError(USS_NonTrivial);
9112 return UnsupportedSTLError();
9121 !FIt->getType()->isIntegralOrEnumerationType()) {
9122 return UnsupportedSTLError();
9132 return UnsupportedSTLError(USS_MissingMember, MemName);
9135 assert(VD &&
"should not be null!");
9142 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
9148 return UnsupportedSTLError();
9150 MarkVariableReferenced(Loc, VD);
9155 FullyCheckedComparisonCategories[
static_cast<unsigned>(
Kind)] =
true;
9162 if (!StdNamespace) {
9168 &PP.getIdentifierTable().get(
"std"),
9173 return getStdNamespace();
9178 "Looking for std::initializer_list outside of C++.");
9193 if (!Specialization)
9200 Template = dyn_cast_or_null<ClassTemplateDecl>(
9201 TST->getTemplateName().getAsTemplateDecl());
9202 Arguments = TST->getArgs();
9207 if (!StdInitializerList) {
9211 &PP.getIdentifierTable().get(
"initializer_list") ||
9212 !getStdNamespace()->InEnclosingNamespaceSetOf(
9220 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
9224 StdInitializerList = Template;
9239 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
9246 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
9251 Result.suppressDiagnostics();
9254 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
9262 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
9263 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
9271 if (!StdInitializerList) {
9273 if (!StdInitializerList)
9282 CheckTemplateIdType(
TemplateName(StdInitializerList), Loc, Args));
9299 return isStdInitializerList(ArgType,
nullptr);
9306 case Decl::TranslationUnit:
9308 case Decl::LinkageSpec:
9320 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
9322 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
9336 llvm::make_unique<NamespaceValidatorCCC>(),
9339 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
9340 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
9341 Ident->
getName().equals(CorrectedStr);
9343 S.
PDiag(diag::err_using_directive_member_suggest)
9344 << Ident << DC << DroppedSpecifier << SS.getRange(),
9345 S.
PDiag(diag::note_namespace_defined_here));
9348 S.
PDiag(diag::err_using_directive_suggest) << Ident,
9349 S.
PDiag(diag::note_namespace_defined_here));
9351 R.
addDecl(Corrected.getFoundDecl());
9362 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9363 assert(NamespcName &&
"Invalid NamespcName.");
9364 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
9377 LookupResult R(*
this, NamespcName, IdentLoc, LookupNamespaceName);
9378 LookupParsedName(R, S, &SS);
9387 NamespcName->
isStr(
"std")) {
9388 Diag(IdentLoc, diag::ext_using_undefined_std);
9389 R.
addDecl(getOrCreateStdNamespace());
9399 assert(NS &&
"expected namespace decl");
9402 DiagnoseUseOfDecl(Named, IdentLoc);
9417 while (CommonAncestor && !CommonAncestor->
Encloses(CurContext))
9418 CommonAncestor = CommonAncestor->
getParent();
9422 IdentLoc, Named, CommonAncestor);
9425 !SourceMgr.isInMainFile(SourceMgr.getExpansionLoc(IdentLoc))) {
9426 Diag(IdentLoc, diag::warn_using_directive_in_header);
9429 PushUsingDirective(S, UDir);
9431 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
9435 ProcessDeclAttributeList(S, UDir, AttrList);
9478 getLangOpts().CPlusPlus11
9479 ? diag::warn_cxx98_compat_using_decl_constructor
9480 : diag::err_using_decl_constructor)
9497 llvm_unreachable(
"cannot parse qualified deduction guide name");
9508 ? diag::err_access_decl
9509 : diag::warn_access_decl_deprecated)
9514 if (DiagnoseUnexpandedParameterPack(SS, UPPC_UsingDeclaration) ||
9515 DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC_UsingDeclaration))
9520 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
9527 BuildUsingDeclaration(S, AS, UsingLoc, TypenameLoc.
isValid(), TypenameLoc,
9528 SS, TargetNameInfo, EllipsisLoc, AttrList,
9531 PushOnScopeChains(UD, S,
false);
9546 return Context.
hasSameType(TD1->getUnderlyingType(),
9547 TD2->getUnderlyingType());
9577 if (!getLangOpts().
CPlusPlus11 && CurContext->isRecord()) {
9581 if (isa<EnumDecl>(OrigDC)) OrigDC = OrigDC->
getParent();
9586 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(OrigRec)) {
9587 if (OrigDC == CurContext) {
9589 diag::err_using_decl_nested_name_specifier_is_current_class)
9597 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9599 << cast<CXXRecordDecl>(CurContext)
9607 if (Previous.
empty())
return false;
9610 if (isa<UsingShadowDecl>(Target))
9611 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
9618 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
9619 bool FoundEquivalentDecl =
false;
9626 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D))
9629 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
9634 !isa<IndirectFieldDecl>(Target) &&
9635 !isa<UnresolvedUsingValueDecl>(
Target) &&
9636 DiagnoseClassNameShadow(
9644 PrevShadow = Shadow;
9645 FoundEquivalentDecl =
true;
9646 }
else if (isEquivalentInternalLinkageDeclaration(D, Target)) {
9649 FoundEquivalentDecl =
true;
9653 (isa<TagDecl>(D) ? Tag : NonTag) = D;
9656 if (FoundEquivalentDecl)
9661 switch (CheckOverload(
nullptr, FD, Previous, OldDecl,
9666 case Ovl_NonFunction:
9675 if (CurContext->isRecord())
9691 if (isa<TagDecl>(Target)) {
9693 if (!Tag)
return false;
9697 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
9703 if (!NonTag)
return false;
9716 for (
auto &B : Derived->
bases())
9717 if (B.getType()->getAsCXXRecordDecl() == Base)
9718 return B.isVirtual();
9719 llvm_unreachable(
"not a direct base class");
9729 if (isa<UsingShadowDecl>(Target)) {
9730 Target = cast<UsingShadowDecl>(
Target)->getTargetDecl();
9731 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
9735 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
9736 NonTemplateTarget = TargetTD->getTemplatedDecl();
9739 if (isa<CXXConstructorDecl>(NonTemplateTarget)) {
9740 bool IsVirtualBase =
9744 Context, CurContext, UD->
getLocation(), UD, Orig, IsVirtualBase);
9758 PushOnScopeChains(Shadow, S);
9760 CurContext->addDecl(Shadow);
9796 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
9804 IdResolver.RemoveDecl(Shadow);
9817 bool &AnyDependentBases) {
9820 for (
auto &Base : Derived->
bases()) {
9822 if (CanonicalDesiredBase == BaseType)
9824 if (BaseType->isDependentType())
9825 AnyDependentBases =
true;
9833 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
9835 : HasTypenameKeyword(HasTypenameKeyword),
9836 IsInstantiation(IsInstantiation), OldNNS(NNS),
9837 RequireMemberOf(RequireMemberOf) {}
9839 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
9843 if (!ND || isa<NamespaceDecl>(ND))
9853 if (RequireMemberOf) {
9855 if (FoundRecord && FoundRecord->isInjectedClassName()) {
9876 bool AnyDependentBases =
false;
9879 AnyDependentBases) &&
9891 if (FoundRecord && FoundRecord->isInjectedClassName())
9895 if (isa<TypeDecl>(ND))
9896 return HasTypenameKeyword || !IsInstantiation;
9898 return !HasTypenameKeyword;
9902 bool HasTypenameKeyword;
9903 bool IsInstantiation;
9919 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9921 assert(IdentLoc.isValid() &&
"Invalid TargetName location.");
9930 if (
auto *RD = dyn_cast<CXXRecordDecl>(CurContext))
9936 ForVisibleRedeclaration);
9939 LookupName(Previous, S);
9945 if (!isDeclInScope(D, CurContext, S))
9957 assert(IsInstantiation &&
"no scope in non-instantiation");
9958 if (CurContext->isRecord())
9959 LookupQualifiedName(Previous, CurContext);
9978 if (CheckUsingDeclRedeclaration(UsingLoc, HasTypenameKeyword,
9979 SS, IdentLoc, Previous))
9983 if (CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo,
9987 DeclContext *LookupContext = computeDeclContext(SS);
9990 if (!LookupContext || EllipsisLoc.
isValid()) {
9991 if (HasTypenameKeyword) {
9994 UsingLoc, TypenameLoc,
10000 QualifierLoc, NameInfo, EllipsisLoc);
10003 CurContext->addDecl(D);
10007 auto Build = [&](
bool Invalid) {
10010 UsingName, HasTypenameKeyword);
10012 CurContext->addDecl(UD);
10016 auto BuildInvalid = [&]{
return Build(
true); };
10017 auto BuildValid = [&]{
return Build(
false); };
10019 if (RequireCompleteDeclContext(SS, LookupContext))
10020 return BuildInvalid();
10029 if (!IsInstantiation)
10034 if (CurContext->isRecord()) {
10039 LookupQualifiedName(R, LookupContext);
10052 if (getLangOpts().
CPlusPlus14 && II && II->isStr(
"gets") &&
10053 CurContext->isStdNamespace() &&
10054 isa<TranslationUnitDecl>(LookupContext) &&
10055 getSourceManager().isInSystemHeader(UsingLoc))
10059 llvm::make_unique<UsingValidatorCCC>(
10060 HasTypenameKeyword, IsInstantiation, SS.getScopeRep(),
10062 CTK_ErrorRecovery)) {
10065 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
10066 << NameInfo.
getName() << LookupContext << 0
10071 NamedDecl *ND = Corrected.getCorrectionDecl();
10073 return BuildInvalid();
10079 RD = cast<CXXRecordDecl>(RD->
getParent());
10082 if (Corrected.WillReplaceSpecifier()) {
10084 Builder.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
10091 auto *CurClass = cast<CXXRecordDecl>(CurContext);
10094 UsingName.setNamedTypeInfo(
nullptr);
10095 for (
auto *Ctor : LookupConstructors(RD))
10101 UsingName.setName(ND->getDeclName());
10105 Diag(IdentLoc, diag::err_no_member)
10106 << NameInfo.
getName() << LookupContext << SS.getRange();
10107 return BuildInvalid();
10112 return BuildInvalid();
10114 if (HasTypenameKeyword) {
10117 Diag(IdentLoc, diag::err_using_typename_non_type);
10119 Diag((*I)->getUnderlyingDecl()->getLocation(),
10120 diag::note_using_decl_target);
10121 return BuildInvalid();
10128 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
10130 return BuildInvalid();
10137 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
10139 return BuildInvalid();
10145 if (cast<EnumDecl>(ED->getDeclContext())->isScoped()) {
10146 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
10148 return BuildInvalid();
10155 if (UsingName.getName().getNameKind() ==
10160 if (CheckInheritingConstructorUsingDecl(UD))
10166 if (!CheckUsingShadowDecl(UD, *I, Previous, PrevDecl))
10167 BuildUsingShadowDecl(S, UD, *I, PrevDecl);
10175 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
10176 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
10177 isa<UsingPackDecl>(InstantiatedFrom));
10181 UPD->setAccess(InstantiatedFrom->
getAccess());
10182 CurContext->addDecl(UPD);
10188 assert(!UD->
hasTypename() &&
"expecting a constructor name");
10191 assert(SourceType &&
10192 "Using decl naming constructor doesn't have type in scope spec.");
10193 CXXRecordDecl *TargetClass = cast<CXXRecordDecl>(CurContext);
10196 bool AnyDependentBases =
false;
10198 AnyDependentBases);
10199 if (!Base && !AnyDependentBases) {
10201 diag::err_using_decl_constructor_not_in_direct_base)
10203 <<
QualType(SourceType, 0) << TargetClass;
10218 bool HasTypenameKeyword,
10231 if (!CurContext->getRedeclContext()->isRecord()) {
10237 if (Qual->
isDependent() && !HasTypenameKeyword) {
10238 for (
auto *D : Prev) {
10239 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
10240 bool OldCouldBeEnumerator =
10241 isa<UnresolvedUsingValueDecl>(D) || isa<EnumConstantDecl>(D);
10243 OldCouldBeEnumerator ? diag::err_redefinition
10244 : diag::err_redefinition_different_kind)
10245 << Prev.getLookupName();
10246 Diag(D->getLocation(), diag::note_previous_definition);
10259 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
10260 DTypename = UD->hasTypename();
10261 DQual = UD->getQualifier();
10263 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
10265 DQual = UD->getQualifier();
10267 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
10269 DQual = UD->getQualifier();
10274 if (HasTypenameKeyword != DTypename)
continue;
10283 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
10300 DeclContext *NamedContext = computeDeclContext(SS);
10302 if (!CurContext->isRecord()) {
10310 if ((HasTypename && !NamedContext) ||
10312 auto *RD = NamedContext
10315 if (RD && RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), RD))
10318 Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member)
10330 LookupQualifiedName(R, RD);
10335 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
10343 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
10353 if (getLangOpts().CPlusPlus11) {
10359 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
10374 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
10375 << (getLangOpts().CPlusPlus11 ? 4 : 3)
10388 if (!NamedContext) {
10402 diag::err_using_decl_nested_name_specifier_is_not_class)
10408 RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), NamedContext))
10411 if (getLangOpts().CPlusPlus11) {
10417 if (cast<CXXRecordDecl>(CurContext)->isProvablyNotDerivedFrom(
10418 cast<CXXRecordDecl>(NamedContext))) {
10419 if (CurContext == NamedContext) {
10421 diag::err_using_decl_nested_name_specifier_is_current_class)
10426 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
10428 diag::err_using_decl_nested_name_specifier_is_not_base_class)
10430 << cast<CXXRecordDecl>(CurContext)
10452 llvm::SmallPtrSet<const CXXRecordDecl *, 4> Bases;
10454 Bases.insert(Base);
10459 if (!cast<CXXRecordDecl>(CurContext)->forallBases(Collect))
10465 return !Bases.count(Base);
10470 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
10471 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
10475 diag::err_using_decl_nested_name_specifier_is_not_base_class)
10477 << cast<CXXRecordDecl>(CurContext)
10492 "got alias-declaration outside of declaration scope");
10497 bool Invalid =
false;
10500 GetTypeFromParser(Type.
get(), &TInfo);
10502 if (DiagnoseClassNameShadow(CurContext, NameInfo))
10505 if (DiagnoseUnexpandedParameterPack(Name.
StartLocation, TInfo,
10506 UPPC_DeclarationType)) {
10513 TemplateParamLists.size()
10514 ? forRedeclarationInCurContext()
10515 : ForVisibleRedeclaration);
10520 Previous.getFoundDecl()->isTemplateParameter()) {
10526 "name in alias declaration must be an identifier");
10536 ProcessDeclAttributeList(S, NewTD, AttrList);
10537 AddPragmaAttributes(S, NewTD);
10539 CheckTypedefForVariablyModifiedType(S, NewTD);
10542 bool Redeclaration =
false;
10545 if (TemplateParamLists.size()) {
10549 if (TemplateParamLists.size() != 1) {
10550 Diag(UsingLoc, diag::err_alias_template_extra_headers)
10551 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
10552 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
10557 if (CheckTemplateDeclScope(S, TemplateParams))
10561 FilterLookupForScope(
Previous, CurContext, S,
false,
10564 Redeclaration =
true;
10567 if (!OldDecl && !Invalid) {
10568 Diag(UsingLoc, diag::err_redefinition_different_kind)
10579 if (TemplateParameterListsAreEqual(TemplateParams,
10582 TPL_TemplateMatch))
10583 OldTemplateParams =
10605 if (CheckTemplateParameterList(TemplateParams, OldTemplateParams,
10606 TPC_TypeAliasTemplate))
10619 else if (OldDecl) {
10621 CheckRedeclarationModuleOwnership(NewDecl, OldDecl);
10626 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
10627 setTagNameForLinkagePurposes(TD, NewTD);
10628 handleTagNumbering(TD, S);
10630 ActOnTypedefNameDecl(S, CurContext, NewTD,
Previous, Redeclaration);
10634 PushOnScopeChains(NewND, S);
10635 ActOnDocumentableDecl(NewND);
10646 LookupResult R(*
this, Ident, IdentLoc, LookupNamespaceName);
10647 LookupParsedName(R, S, &SS);
10654 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
10662 LookupResult PrevR(*
this, Alias, AliasLoc, LookupOrdinaryName,
10663 ForVisibleRedeclaration);
10664 LookupName(PrevR, S);
10668 DiagnoseTemplateParameterShadow(AliasLoc, PrevR.
getFoundDecl());
10673 FilterLookupForScope(PrevR, CurContext, S,
false,
10685 }
else if (isVisible(PrevDecl)) {
10686 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
10688 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
10689 << AD->getNamespace();
10692 }
else if (isVisible(PrevDecl)) {
10694 ? diag::err_redefinition
10695 : diag::err_redefinition_different_kind;
10696 Diag(AliasLoc, DiagID) << Alias;
10703 DiagnoseUseOfDecl(ND, IdentLoc);
10712 PushOnScopeChains(AliasDecl, S);
10717 struct SpecialMemberExceptionSpecInfo
10718 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
10726 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
10731 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
10734 void visitSubobjectCall(Subobject Subobj,
10744 auto *BaseClass = cast<CXXRecordDecl>(RT->getDecl());
10746 if (
auto *BaseCtor = SMOR.getMethod()) {
10747 visitSubobjectCall(Base, BaseCtor);
10751 visitClassSubobject(BaseClass, Base, 0);
10755 bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
10766 ExceptSpec.CalledExpr(E);
10768 ->getAs<RecordType>()) {
10769 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
10775 void SpecialMemberExceptionSpecInfo::visitClassSubobject(
CXXRecordDecl *Class,
10779 bool IsMutable = Field && Field->
isMutable();
10780 visitSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable));
10783 void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
10788 ExceptSpec.CalledDecl(getSubobjectLoc(Subobj), MD);
10793 struct ComputingExceptionSpec {
10804 ~ComputingExceptionSpec() {
10814 ComputingExceptionSpec CES(S, MD, Loc);
10821 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
10823 return Info.ExceptSpec;
10830 diag::err_exception_spec_incomplete_type))
10831 return Info.ExceptSpec;
10848 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
10849 : Info.VisitAllBases);
10851 return Info.ExceptSpec;
10856 struct DeclaringSpecialMember {
10860 bool WasAlreadyBeingDeclared;
10863 : S(S), D(RD, CSM), SavedContext(S, RD) {
10865 if (WasAlreadyBeingDeclared)
10886 ~DeclaringSpecialMember() {
10887 if (!WasAlreadyBeingDeclared) {
10894 bool isAlreadyBeingDeclared()
const {
10895 return WasAlreadyBeingDeclared;
10905 ForExternalRedeclaration);
10912 CheckFunctionDeclaration(S, FD, R,
false);
10915 void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
10921 if (getLangOpts().OpenCLCPlusPlus) {
10940 "Should not build implicit default constructor!");
10942 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDefaultConstructor);
10943 if (DSM.isAlreadyBeingDeclared())
10947 CXXDefaultConstructor,
10958 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
10959 nullptr,
false,
true,
10964 if (getLangOpts().CUDA) {
10965 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDefaultConstructor,
10971 setupImplicitSpecialMemberType(DefaultCon, Context.
VoidTy,
None);
10980 Scope *S = getScopeForContext(ClassDecl);
10981 CheckImplicitSpecialMemberDeclaration(S, DefaultCon);
10983 if (ShouldDeleteSpecialMember(DefaultCon, CXXDefaultConstructor))
10984 SetDeclDeleted(DefaultCon, ClassLoc);
10987 PushOnScopeChains(DefaultCon, S,
false);
10988 ClassDecl->
addDecl(DefaultCon);
10998 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
11003 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
11009 ResolveExceptionSpec(CurrentLocation,
11011 MarkVTableUsed(CurrentLocation, ClassDecl);
11016 if (SetCtorInitializers(Constructor,
false)) {
11028 L->CompletedImplicitDefinition(Constructor);
11031 DiagnoseUninitializedFields(*
this, Constructor);
11036 CheckDelayedMemberExceptionSpecs();
11057 ->getInheritedConstructor()
11060 return cast<CXXConstructorDecl>(Ctor);
11075 false, BaseCtor, &ICI);
11078 Context, Derived, UsingLoc, NameInfo, TInfo->
getType(), TInfo,
11089 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
11095 for (
unsigned I = 0, N = FPT->
getNumParams(); I != N; ++I) {
11099 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
11106 ParamDecls.push_back(PD);
11111 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
11114 Derived->
addDecl(DerivedCtor);
11116 if (ShouldDeleteSpecialMember(DerivedCtor, CXXDefaultConstructor, &ICI))
11117 SetDeclDeleted(DerivedCtor, UsingLoc);
11119 return DerivedCtor;
11125 ShouldDeleteSpecialMember(Ctor, CXXDefaultConstructor, &ICI,
11144 ResolveExceptionSpec(CurrentLocation,
11146 MarkVTableUsed(CurrentLocation, ClassDecl);
11168 for (
bool VBase : {
false,
true}) {
11170 if (B.isVirtual() != VBase)
11173 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
11178 if (!BaseCtor.first)
11181 MarkFunctionReferenced(CurrentLocation, BaseCtor.first);
11183 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
11187 Context, TInfo, VBase, InitLoc, Init.
get(), InitLoc,
11195 if (SetCtorInitializers(Constructor,
false, Inits)) {
11204 L->CompletedImplicitDefinition(Constructor);
11207 DiagnoseUninitializedFields(*
this, Constructor);
11217 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDestructor);
11218 if (DSM.isAlreadyBeingDeclared())
11235 if (getLangOpts().CUDA) {
11236 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDestructor,
11242 setupImplicitSpecialMemberType(Destructor, Context.
VoidTy,
None);
11253 Scope *S = getScopeForContext(ClassDecl);
11254 CheckImplicitSpecialMemberDeclaration(S, Destructor);
11260 ShouldDeleteSpecialMember(Destructor, CXXDestructor))
11261 SetDeclDeleted(Destructor, ClassLoc);
11265 PushOnScopeChains(Destructor, S,
false);
11266 ClassDecl->
addDecl(Destructor);
11276 "DefineImplicitDestructor - call it for implicit default dtor");
11281 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
11287 ResolveExceptionSpec(CurrentLocation,
11289 MarkVTableUsed(CurrentLocation, ClassDecl);
11294 MarkBaseAndMemberDestructorsReferenced(Destructor->
getLocation(),
11297 if (CheckDestructor(Destructor)) {
11309 L->CompletedImplicitDefinition(Destructor);
11317 if (
CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(CurContext)) {
11318 if (Record->isInvalidDecl()) {
11319 DelayedOverridingExceptionSpecChecks.clear();
11320 DelayedEquivalentExceptionSpecChecks.clear();
11321 DelayedDefaultedMemberExceptionSpecs.clear();
11329 referenceDLLExportedClassMethods();
11333 if (!DelayedDllExportClasses.empty()) {
11337 std::swap(DelayedDllExportClasses, WorkList);
11345 "adjusting dtor exception specs was introduced in c++11");
11355 getAs<FunctionProtoType>();
11378 class ExprBuilder {
11379 ExprBuilder(
const ExprBuilder&) =
delete;
11380 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
11383 static Expr *assertNotNull(
Expr *E) {
11384 assert(E &&
"Expression construction must not fail.");
11390 virtual ~ExprBuilder() {}
11395 class RefBuilder:
public ExprBuilder {
11405 : Var(Var), VarType(VarType) {}
11408 class ThisBuilder:
public ExprBuilder {
11415 class CastBuilder:
public ExprBuilder {
11416 const ExprBuilder &Builder;
11424 CK_UncheckedDerivedToBase,
Kind,
11430 : Builder(Builder), Type(Type),
Kind(Kind), Path(Path) {}
11433 class DerefBuilder:
public ExprBuilder {
11434 const ExprBuilder &Builder;
11438 return assertNotNull(
11442 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11445 class MemberBuilder:
public ExprBuilder {
11446 const ExprBuilder &Builder;
11455 Builder.build(S, Loc), Type, Loc, IsArrow, SS,
SourceLocation(),
11456 nullptr, MemberLookup,
nullptr,
nullptr).
get());
11459 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
11461 : Builder(Builder), Type(Type), IsArrow(IsArrow),
11462 MemberLookup(MemberLookup) {}
11465 class MoveCastBuilder:
public ExprBuilder {
11466 const ExprBuilder &Builder;
11470 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
11473 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11476 class LvalueConvBuilder:
public ExprBuilder {
11477 const ExprBuilder &Builder;
11481 return assertNotNull(
11485 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
11488 class SubscriptBuilder:
public ExprBuilder {
11489 const ExprBuilder &Base;
11490 const ExprBuilder &Index;
11495 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
11498 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
11499 : Base(Base), Index(Index) {}
11510 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
11519 Expr *From = FromB.build(S, Loc);
11523 Expr *To = ToB.build(S, Loc);
11529 bool NeedsCollectableMemCpy =
11533 StringRef MemCpyName = NeedsCollectableMemCpy ?
11534 "__builtin_objc_memmove_collectable" :
11535 "__builtin_memcpy";
11548 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
11550 Expr *CallArgs[] = {
11554 Loc, CallArgs, Loc);
11556 assert(!Call.
isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
11589 const ExprBuilder &To,
const ExprBuilder &From,
11590 bool CopyingBaseSubobject,
bool Copying,
11591 unsigned Depth = 0) {
11607 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
11622 if (Method->isCopyAssignmentOperator() ||
11623 (!Copying && Method->isMoveAssignmentOperator()))
11642 if (CopyingBaseSubobject) {
11673 Expr *FromInst = From.build(S, Loc);
11676 Loc, FromInst, Loc);
11696 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
11716 llvm::raw_svector_ostream OS(Str);
11717 OS <<
"__i" <<
Depth;
11721 IterationVarName, SizeType,
11730 RefBuilder IterationVarRef(IterationVar, SizeType);
11731 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
11737 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
11738 MoveCastBuilder FromIndexMove(FromIndexCopy);
11739 const ExprBuilder *FromIndex;
11741 FromIndex = &FromIndexCopy;
11743 FromIndex = &FromIndexMove;
11745 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
11750 ToIndex, *FromIndex, CopyingBaseSubobject,
11751 Copying,
Depth + 1);
11753 if (Copy.isInvalid() || !Copy.get())
11769 UnaryOperator(IterationVarRef.build(S, Loc), UO_PreInc, SizeType,
11774 Loc, Loc, InitStmt,
11781 const ExprBuilder &To,
const ExprBuilder &From,
11782 bool CopyingBaseSubobject,
bool Copying) {
11789 CopyingBaseSubobject,
11794 if (!Result.isInvalid() && !Result.get())
11807 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyAssignment);
11808 if (DSM.isAlreadyBeingDeclared())
11839 if (getLangOpts().CUDA) {
11840 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyAssignment,
11846 setupImplicitSpecialMemberType(CopyAssignment, RetType, ArgType);
11850 ClassLoc, ClassLoc,
11858 ? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
11864 Scope *S = getScopeForContext(ClassDecl);
11865 CheckImplicitSpecialMemberDeclaration(S, CopyAssignment);
11867 if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment))
11868 SetDeclDeleted(CopyAssignment, ClassLoc);
11871 PushOnScopeChains(CopyAssignment, S,
false);
11872 ClassDecl->
addDecl(CopyAssignment);
11874 return CopyAssignment;
11888 if (RD->hasUserDeclaredDestructor()) {
11889 UserDeclaredOperation = RD->getDestructor();
11890 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
11891 RD->hasUserDeclaredCopyConstructor() &&
11894 for (
auto *I : RD->ctors()) {
11895 if (I->isCopyConstructor()) {
11896 UserDeclaredOperation = I;
11900 assert(UserDeclaredOperation);
11901 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
11902 RD->hasUserDeclaredCopyAssignment() &&
11905 for (
auto *I : RD->methods()) {
11906 if (I->isCopyAssignmentOperator()) {
11907 UserDeclaredOperation = I;
11911 assert(UserDeclaredOperation);
11914 if (UserDeclaredOperation) {
11916 diag::warn_deprecated_copy_operation)
11917 << RD << !isa<CXXConstructorDecl>(CopyOp)
11918 << isa<CXXDestructorDecl>(UserDeclaredOperation);
11929 "DefineImplicitCopyAssignment called for wrong function");
11943 ResolveExceptionSpec(CurrentLocation,
11983 RefBuilder OtherRef(Other, OtherRefType);
11989 bool Invalid =
false;
11990 for (
auto &Base : ClassDecl->
bases()) {
12000 BasePath.push_back(&Base);
12004 CastBuilder From(OtherRef, Context.
getQualifiedType(BaseType, OtherQuals),
12008 DerefBuilder DerefThis(This);
12009 CastBuilder To(DerefThis,
12025 Statements.push_back(Copy.
getAs<
Expr>());
12029 for (
auto *Field : ClassDecl->
fields()) {
12032 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
12035 if (Field->isInvalidDecl()) {
12041 if (Field->getType()->isReferenceType()) {
12042 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12043 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
12044 Diag(Field->getLocation(), diag::note_declared_at);
12052 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12053 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
12054 Diag(Field->getLocation(), diag::note_declared_at);
12060 if (Field->isZeroLengthBitField(Context))
12063 QualType FieldType = Field->getType().getNonReferenceType();
12066 "Incomplete array type is not valid");
12072 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
12075 MemberLookup.resolveKind();
12077 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
12079 MemberBuilder To(This, getCurrentThisType(),
true, MemberLookup);
12092 Statements.push_back(Copy.
getAs<
Stmt>());
12097 ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
12100 if (Return.isInvalid())
12103 Statements.push_back(Return.getAs<
Stmt>());
12114 Body = ActOnCompoundStmt(Loc, Loc, Statements,
12116 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
12119 CopyAssignOperator->
markUsed(Context);
12122 L->CompletedImplicitDefinition(CopyAssignOperator);
12129 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveAssignment);
12130 if (DSM.isAlreadyBeingDeclared())
12157 if (getLangOpts().CUDA) {
12158 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveAssignment,
12171 ClassLoc, ClassLoc,
12179 ? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
12185 Scope *S = getScopeForContext(ClassDecl);
12186 CheckImplicitSpecialMemberDeclaration(S, MoveAssignment);
12188 if (ShouldDeleteSpecialMember(MoveAssignment, CXXMoveAssignment)) {
12190 SetDeclDeleted(MoveAssignment, ClassLoc);
12194 PushOnScopeChains(MoveAssignment, S,
false);
12195 ClassDecl->
addDecl(MoveAssignment);
12197 return MoveAssignment;
12216 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
12219 for (
auto &BI : Class->
bases()) {
12220 Worklist.push_back(&BI);
12221 while (!Worklist.empty()) {
12254 if (Existing && Existing != &BI) {
12255 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
12258 << (Base->getCanonicalDecl() ==
12261 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
12262 << (Base->getCanonicalDecl() ==
12263 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
12267 Existing =
nullptr;
12277 for (
auto &BI : Base->
bases())
12278 Worklist.push_back(&BI);
12291 "DefineImplicitMoveAssignment called for wrong function");
12317 ResolveExceptionSpec(CurrentLocation,
12329 getAs<RValueReferenceType>()->getPointeeType();
12337 RefBuilder OtherRef(Other, OtherRefType);
12339 MoveCastBuilder MoveOther(OtherRef);
12345 bool Invalid =
false;
12346 for (
auto &Base : ClassDecl->
bases()) {
12364 BasePath.push_back(&Base);
12368 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
12371 DerefBuilder DerefThis(This);
12374 CastBuilder To(DerefThis,
12390 Statements.push_back(Move.
getAs<
Expr>());
12394 for (
auto *Field : ClassDecl->
fields()) {
12397 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
12400 if (Field->isInvalidDecl()) {
12406 if (Field->getType()->isReferenceType()) {
12407 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12408 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
12409 Diag(Field->getLocation(), diag::note_declared_at);
12417 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
12418 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
12419 Diag(Field->getLocation(), diag::note_declared_at);
12425 if (Field->isZeroLengthBitField(Context))
12428 QualType FieldType = Field->getType().getNonReferenceType();
12431 "Incomplete array type is not valid");
12436 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
12439 MemberLookup.resolveKind();
12440 MemberBuilder From(MoveOther, OtherRefType,
12441 false, MemberLookup);
12442 MemberBuilder To(This, getCurrentThisType(),
12443 true, MemberLookup);
12445 assert(!From.build(*
this, Loc)->isLValue() &&
12446 "Member reference with rvalue base must be rvalue except for reference " 12447 "members, which aren't allowed for move assignment.");
12454 if (Move.isInvalid()) {
12460 Statements.push_back(Move.getAs<
Stmt>());
12466 CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
12469 if (Return.isInvalid())
12472 Statements.push_back(Return.getAs<
Stmt>());
12483 Body = ActOnCompoundStmt(Loc, Loc, Statements,
12485 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
12488 MoveAssignOperator->
markUsed(Context);
12491 L->CompletedImplicitDefinition(MoveAssignOperator);
12502 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyConstructor);
12503 if (DSM.isAlreadyBeingDeclared())
12518 CXXCopyConstructor,
12530 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12536 if (getLangOpts().CUDA) {
12537 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyConstructor,
12543 setupImplicitSpecialMemberType(CopyConstructor, Context.
VoidTy, ArgType);
12547 ClassLoc, ClassLoc,
12555 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
12559 ClassDecl->
hasAttr<TrivialABIAttr>() ||
12561 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor,
12562 TAH_ConsiderTrivialABI)
12568 Scope *S = getScopeForContext(ClassDecl);
12569 CheckImplicitSpecialMemberDeclaration(S, CopyConstructor);
12571 if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) {
12573 SetDeclDeleted(CopyConstructor, ClassLoc);
12577 PushOnScopeChains(CopyConstructor, S,
false);
12578 ClassDecl->
addDecl(CopyConstructor);
12580 return CopyConstructor;
12589 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
12594 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
12600 ResolveExceptionSpec(CurrentLocation,
12602 MarkVTableUsed(CurrentLocation, ClassDecl);
12614 if (SetCtorInitializers(CopyConstructor,
false)) {
12622 ActOnCompoundStmt(Loc, Loc,
None,
false).getAs<Stmt>());
12623 CopyConstructor->
markUsed(Context);
12627 L->CompletedImplicitDefinition(CopyConstructor);
12635 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveConstructor);
12636 if (DSM.isAlreadyBeingDeclared())
12647 CXXMoveConstructor,
12660 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
12666 if (getLangOpts().CUDA) {
12667 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveConstructor,
12673 setupImplicitSpecialMemberType(MoveConstructor, Context.
VoidTy, ArgType);
12677 ClassLoc, ClassLoc,
12685 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
12689 ClassDecl->
hasAttr<TrivialABIAttr>() ||
12691 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor,
12692 TAH_ConsiderTrivialABI)
12698 Scope *S = getScopeForContext(ClassDecl);
12699 CheckImplicitSpecialMemberDeclaration(S, MoveConstructor);
12701 if (ShouldDeleteSpecialMember(MoveConstructor, CXXMoveConstructor)) {
12703 SetDeclDeleted(MoveConstructor, ClassLoc);
12707 PushOnScopeChains(MoveConstructor, S,
false);
12708 ClassDecl->
addDecl(MoveConstructor);
12710 return MoveConstructor;
12719 "DefineImplicitMoveConstructor - call it for implicit move ctor");
12724 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
12730 ResolveExceptionSpec(CurrentLocation,
12732 MarkVTableUsed(CurrentLocation, ClassDecl);
12737 if (SetCtorInitializers(MoveConstructor,
false)) {
12744 MoveConstructor->
setBody(ActOnCompoundStmt(
12745 Loc, Loc,
None,
false).getAs<Stmt>());
12746 MoveConstructor->
markUsed(Context);
12750 L->CompletedImplicitDefinition(MoveConstructor);
12765 FunctionDecl *CallOp = Lambda->getLambdaCallOperator();
12766 FunctionDecl *Invoker = Lambda->getLambdaStaticInvoker();
12769 CallOp = InstantiateFunctionDeclaration(
12774 Invoker = InstantiateFunctionDeclaration(
12788 MarkFunctionReferenced(CurrentLocation, CallOp);
12799 Expr *FunctionRef = BuildDeclRefExpr(Invoker, Invoker->
getType(),
12801 assert(FunctionRef &&
"Can't refer to __invoke function?");
12802 Stmt *Return = BuildReturnStmt(Conv->
getLocation(), FunctionRef).
get();
12809 L->CompletedImplicitDefinition(Conv);
12810 L->CompletedImplicitDefinition(Invoker);
12825 Expr *This = ActOnCXXThis(CurrentLocation).get();
12826 Expr *DerefThis =CreateBuiltinUnaryOp(CurrentLocation, UO_Deref, This).get();
12828 ExprResult BuildBlock = BuildBlockForLambdaConversion(CurrentLocation,
12836 if (!BuildBlock.
isInvalid() && !getLangOpts().ObjCAutoRefCount)
12838 CK_CopyAndAutoreleaseBlockObject,
12842 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12851 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12857 Stmt *ReturnS = Return.
get();
12864 L->CompletedImplicitDefinition(Conv);
12871 switch (Args.size()) {
12876 if (!Args[1]->isDefaultArgument())
12881 return !Args[0]->isDefaultArgument();
12892 bool HadMultipleCandidates,
12893 bool IsListInitialization,
12894 bool IsStdInitListInitialization,
12895 bool RequiresZeroInit,
12896 unsigned ConstructKind,
12898 bool Elidable =
false;
12912 Expr *SubExpr = ExprArgs[0];
12917 return BuildCXXConstructExpr(ConstructLoc, DeclInitType,
12918 FoundDecl, Constructor,
12919 Elidable, ExprArgs, HadMultipleCandidates,
12920 IsListInitialization,
12921 IsStdInitListInitialization, RequiresZeroInit,
12922 ConstructKind, ParenRange);
12931 bool HadMultipleCandidates,
12932 bool IsListInitialization,
12933 bool IsStdInitListInitialization,
12934 bool RequiresZeroInit,
12935 unsigned ConstructKind,
12937 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
12938 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
12939 if (DiagnoseUseOfDecl(Constructor, ConstructLoc))
12943 return BuildCXXConstructExpr(
12944 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
12945 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
12946 RequiresZeroInit, ConstructKind, ParenRange);
12956 bool HadMultipleCandidates,
12957 bool IsListInitialization,
12958 bool IsStdInitListInitialization,
12959 bool RequiresZeroInit,
12960 unsigned ConstructKind,
12965 "given constructor for wrong type");
12966 MarkFunctionReferenced(ConstructLoc, Constructor);
12967 if (getLangOpts().CUDA && !CheckCUDACall(ConstructLoc, Constructor))
12971 Context, DeclInitType, ConstructLoc, Constructor, Elidable,
12972 ExprArgs, HadMultipleCandidates, IsListInitialization,
12973 IsStdInitListInitialization, RequiresZeroInit,
12974 static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
13003 assert((getLangOpts().Modules || (!Lookup.
empty() && Lookup.
size() <= 2)) &&
13004 "more than two lookup results for field name");
13007 assert(isa<CXXRecordDecl>(Lookup[0]) &&
13008 "cannot have other non-field member with same name");
13009 for (
auto L : Lookup)
13010 if (isa<FieldDecl>(L)) {
13011 Pattern = cast<FieldDecl>(L);
13014 assert(Pattern &&
"We must have set the Pattern!");
13017 if (!Pattern->hasInClassInitializer() ||
13018 InstantiateInClassInitializer(Loc, Field, Pattern,
13019 getTemplateInstantiationArgs(Field))) {
13042 Diag(Loc, diag::err_in_class_initializer_not_yet_parsed)
13043 << OutermostClass << Field;
13044 Diag(Field->getEndLoc(), diag::note_in_class_initializer_not_yet_parsed);
13046 if (!isSFINAEContext())
13047 Field->setInvalidDecl();
13063 MarkFunctionReferenced(VD->
getLocation(), Destructor);
13064 CheckDestructorAccess(VD->
getLocation(), Destructor,
13065 PDiag(diag::err_access_dtor_var)
13068 DiagnoseUseOfDecl(Destructor, VD->
getLocation());
13092 bool AllowExplicit,
13093 bool IsListInitialization) {
13095 unsigned NumArgs = ArgsPtr.size();
13096 Expr **Args = ArgsPtr.data();
13100 assert(Proto &&
"Constructor without a prototype?");
13104 if (NumArgs < NumParams)
13105 ConvertedArgs.reserve(NumParams);
13107 ConvertedArgs.reserve(NumArgs);
13110 Proto->
isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
13112 bool Invalid = GatherArgumentsForCall(Loc, Constructor,
13114 llvm::makeArrayRef(Args, NumArgs),
13116 CallType, AllowExplicit,
13117 IsListInitialization);
13118 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
13120 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
13122 CheckConstructorCall(Constructor,
13123 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
13133 if (isa<NamespaceDecl>(DC)) {
13135 diag::err_operator_new_delete_declared_in_namespace)
13139 if (isa<TranslationUnitDecl>(DC) &&
13142 diag::err_operator_new_delete_declared_static)
13160 unsigned DependentParamTypeDiag,
13161 unsigned InvalidParamTypeDiag) {
13168 diag::err_operator_new_delete_dependent_result_type)
13181 diag::err_operator_new_delete_invalid_result_type)
13187 diag::err_operator_new_delete_template_too_few_parameters)
13193 diag::err_operator_new_delete_too_few_parameters)
13200 << FnDecl->
getDeclName() << ExpectedFirstParamType;
13211 ExpectedFirstParamType)
13213 << FnDecl->
getDeclName() << ExpectedFirstParamType;
13235 diag::err_operator_new_dependent_param_type,
13236 diag::err_operator_new_param_type))
13243 diag::err_operator_new_default_arg)
13273 SemaRef, FnDecl, SemaRef.
Context.
VoidTy, ExpectedFirstParamType,
13274 diag::err_operator_delete_dependent_param_type,
13275 diag::err_operator_delete_param_type))
13284 diag::err_destroying_operator_delete_not_usual);
13296 "Expected an overloaded operator declaration");
13306 if (Op == OO_Delete || Op == OO_Array_Delete)
13309 if (Op == OO_New || Op == OO_Array_New)
13317 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
13318 if (MethodDecl->isStatic())
13320 diag::err_operator_overload_static) << FnDecl->
getDeclName();
13322 bool ClassOrEnumParam =
false;
13324 QualType ParamType = Param->getType().getNonReferenceType();
13327 ClassOrEnumParam =
true;
13332 if (!ClassOrEnumParam)
13334 diag::err_operator_overload_needs_class_or_enum)
13344 if (Op != OO_Call) {
13346 if (Param->hasDefaultArg())
13347 return Diag(Param->getLocation(),
13348 diag::err_operator_overload_default_arg)
13349 << FnDecl->
getDeclName() << Param->getDefaultArgRange();
13354 {
false,
false,
false }
13355 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 13356 , { Unary, Binary, MemberOnly } 13357 #include "clang/Basic/OperatorKinds.def" 13360 bool CanBeUnaryOperator = OperatorUses[Op][0];
13361 bool CanBeBinaryOperator = OperatorUses[Op][1];
13362 bool MustBeMemberOperator = OperatorUses[Op][2];
13369 + (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
13370 if (Op != OO_Call &&
13371 ((NumParams == 1 && !CanBeUnaryOperator) ||
13372 (NumParams == 2 && !CanBeBinaryOperator) ||
13373 (NumParams < 1) || (NumParams > 2))) {
13376 if (CanBeUnaryOperator && CanBeBinaryOperator) {
13378 }
else if (CanBeUnaryOperator) {
13381 assert(CanBeBinaryOperator &&
13382 "All non-call overloaded operators are unary or binary!");
13386 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
13391 if (Op != OO_Call &&
13393 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
13398 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
13400 diag::err_operator_overload_must_be_member)
13414 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
13421 diag::err_operator_overload_post_incdec_must_be_int)
13422 << LastParam->
getType() << (Op == OO_MinusMinus);
13434 if (TemplateParams->
size() == 1) {
13443 }
else if (TemplateParams->
size() == 2) {
13452 PmArgs->isTemplateParameterPack()) {
13459 diag::ext_string_literal_operator_template);
13466 diag::err_literal_operator_template)
13475 if (isa<CXXMethodDecl>(FnDecl)) {
13476 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
13485 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
13502 diag::err_literal_operator_template_with_params);
13531 diag::err_literal_operator_param)
13548 diag::err_literal_operator_invalid_param)
13558 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
13565 Diag((*Param)->getSourceRange().getBegin(),
13566 diag::err_literal_operator_param)
13567 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13574 Diag((*Param)->getSourceRange().getBegin(),
13575 diag::err_literal_operator_param)
13576 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13589 Diag((*Param)->getSourceRange().getBegin(),
13590 diag::err_literal_operator_param)
13591 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
13599 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
13601 Diag((*Param)->getSourceRange().getBegin(),
13602 diag::err_literal_operator_param)
13604 << (*Param)->getSourceRange();
13608 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
13617 if (Param->hasDefaultArg()) {
13618 Diag(Param->getDefaultArgRange().getBegin(),
13619 diag::err_literal_operator_default_argument)
13620 << Param->getDefaultArgRange();
13625 StringRef LiteralName
13627 if (LiteralName[0] !=
'_' &&
13628 !getSourceManager().isInSystemHeader(FnDecl->
getLocation())) {
13650 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
13659 else if (Lang ==
"C++")
13662 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
13673 PushDeclContext(S, D);
13689 return LinkageSpec;
13698 ProcessDeclAttributeList(S, ED, AttrList);
13700 CurContext->addDecl(ED);
13712 bool Invalid =
false;
13726 Diag(Loc, diag::err_catch_rvalue_ref);
13731 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
13737 unsigned DK = diag::err_catch_incomplete;
13741 DK = diag::err_catch_incomplete_ptr;
13746 DK = diag::err_catch_incomplete_ref;
13748 if (!Invalid && (Mode == 0 || !BaseType->
isVoidType()) &&
13749 !BaseType->
isDependentType() && RequireCompleteType(Loc, BaseType, DK))
13753 RequireNonAbstractType(Loc, ExDeclType,
13754 diag::err_abstract_type_in_decl,
13755 AbstractVariableType))
13760 if (!Invalid && getLangOpts().ObjC) {
13766 Diag(Loc, diag::err_objc_object_catch);
13770 if (getLangOpts().ObjCRuntime.isFragile())
13771 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
13780 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(ExDecl))
13787 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
13805 Expr *opaqueValue =
13816 Expr *init = MaybeCreateExprWithCleanups(construct);
13821 FinalizeVarWithDestructor(ExDecl,
recordType);
13840 UPPC_ExceptionType)) {
13848 LookupOrdinaryName,
13849 ForVisibleRedeclaration)) {
13854 if (isDeclInScope(PrevDecl, CurContext, S)) {
13857 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
13859 }
else if (PrevDecl->isTemplateParameter())
13870 VarDecl *ExDecl = BuildExceptionDeclaration(
13877 PushOnScopeChains(ExDecl, S);
13879 CurContext->addDecl(ExDecl);
13881 ProcessDeclAttributes(S, ExDecl, D);
13887 Expr *AssertMessageExpr,
13890 AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) :
nullptr;
13892 if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
13895 return BuildStaticAssertDeclaration(StaticAssertLoc, AssertExpr,
13896 AssertMessage, RParenLoc,
false);
13904 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
13909 ExprResult Converted = PerformContextuallyConvertToBool(AssertExpr);
13916 if (!Failed && VerifyIntegerConstantExpression(Converted.
get(), &Cond,
13917 diag::err_static_assert_expression_is_not_constant,
13921 if (!Failed && !Cond) {
13923 llvm::raw_svector_ostream Msg(MsgBuffer);
13925 AssertMessage->
printPretty(Msg,
nullptr, getPrintingPolicy());
13927 Expr *InnerCond =
nullptr;
13928 std::string InnerCondDescription;
13929 std::tie(InnerCond, InnerCondDescription) =
13930 findFailedBooleanCondition(Converted.
get());
13931 if (InnerCond && !isa<CXXBoolLiteralExpr>(InnerCond)
13932 && !isa<IntegerLiteral>(InnerCond)) {
13933 Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed)
13934 << InnerCondDescription << !AssertMessage
13937 Diag(StaticAssertLoc, diag::err_static_assert_failed)
13944 ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
13950 AssertExpr = FullAssertExpr.
get();
13953 AssertExpr, AssertMessage, RParenLoc,
13956 CurContext->addDecl(Decl);
13966 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
13976 if (!CodeSynthesisContexts.empty()) {
13991 getLangOpts().CPlusPlus11 ?
13992 diag::warn_cxx98_compat_unelaborated_friend_type :
13993 diag::ext_unelaborated_friend_type)
14001 diag::warn_cxx98_compat_nonclass_type_friend :
14002 diag::ext_nonclass_type_friend)
14009 diag::warn_cxx98_compat_enum_friend :
14010 diag::ext_enum_friend)
14021 if (getLangOpts().
CPlusPlus11 && LocStart != FriendLoc)
14022 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
14043 bool IsMemberSpecialization =
false;
14044 bool Invalid =
false;
14047 MatchTemplateParametersToScopeSpecifier(
14048 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
14049 IsMemberSpecialization, Invalid)) {
14050 if (TemplateParams->size() > 0) {
14055 return CheckClassTemplate(S, TagSpec, TUK_Friend, TagLoc, SS, Name,
14056 NameLoc, Attr, TemplateParams,
AS_public,
14058 FriendLoc, TempParamLists.size() - 1,
14059 TempParamLists.data()).
get();
14062 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
14064 IsMemberSpecialization =
true;
14068 if (Invalid)
return nullptr;
14070 bool isAllExplicitSpecializations =
true;
14071 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
14072 if (TempParamLists[I]->size()) {
14073 isAllExplicitSpecializations =
false;
14083 if (isAllExplicitSpecializations) {
14085 bool Owned =
false;
14086 bool IsDependent =
false;
14087 return ActOnTag(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc,
14101 QualType T = CheckTypenameType(Keyword, TagLoc, QualifierLoc,
14107 if (isa<DependentNameType>(T)) {
14121 TSI, FriendLoc, TempParamLists);
14123 CurContext->addDecl(Friend);
14127 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
14134 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
14145 TSI, FriendLoc, TempParamLists);
14148 CurContext->addDecl(Friend);
14208 if (DiagnoseUnexpandedParameterPack(Loc, TSI, UPPC_FriendDeclaration))
14226 Diag(Loc, diag::err_tagless_friend_type_template)
14243 if (!TempParams.empty())
14255 CurContext->addDecl(D);
14281 Diag(Loc, diag::err_unexpected_friend);
14308 if (DiagnoseUnexpandedParameterPack(Loc, TInfo, UPPC_FriendDeclaration) ||
14309 DiagnoseUnexpandedParameterPack(NameInfo, UPPC_FriendDeclaration) ||
14310 DiagnoseUnexpandedParameterPack(SS, UPPC_FriendDeclaration))
14316 Scope *DCScope = S;
14318 ForExternalRedeclaration);
14326 (FunctionContainingLocalClass =
14327 cast<CXXRecordDecl>(CurContext)->isLocalClass())) {
14342 Previous.
clear(LookupLocalFriendName);
14343 LookupName(Previous, S,
false);
14345 if (!Previous.
empty()) {
14353 DC = FunctionContainingLocalClass;
14355 adjustContextForLocalExternDecl(DC);
14375 bool isTemplateId =
14396 LookupQualifiedName(Previous, LookupDC);
14398 if (!Previous.
empty()) {
14403 if (isTemplateId) {
14404 if (isa<TranslationUnitDecl>(LookupDC))
break;
14411 DCScope = getScopeForDeclContext(S, DC);
14417 DC = computeDeclContext(SS);
14418 if (!DC)
return nullptr;
14420 if (RequireCompleteDeclContext(SS, DC))
return nullptr;
14422 LookupQualifiedName(Previous, DC);
14426 if (DC->
Equals(CurContext))
14428 getLangOpts().CPlusPlus11 ?
14429 diag::warn_cxx98_compat_friend_is_member :
14430 diag::err_friend_is_member);
14466 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
14493 if (DiagArg >= 0) {
14494 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
14505 DCScope = &FakeDCScope;
14508 bool AddToScope =
true;
14509 NamedDecl *ND = ActOnFunctionDeclarator(DCScope, D, DC, TInfo, Previous,
14510 TemplateParams, AddToScope);
14511 if (!ND)
return nullptr;
14525 if (!CurContext->isDependentContext()) {
14528 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
14529 PushOnScopeChains(ND, EnclosingScope,
false);
14536 CurContext->addDecl(FrD);
14541 if (DC->isRecord()) CheckFriendAccess(ND);
14545 FD = FTD->getTemplatedDecl();
14547 FD = cast<FunctionDecl>(ND);
14558 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
14560 diag::note_previous_declaration);
14562 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
14567 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
14569 << cast<CXXRecordDecl>(CurContext);
14578 AdjustDeclIfTemplate(Dcl);
14580 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
14582 Diag(DelLoc, diag::err_deleted_non_function);
14593 Prev->getPreviousDecl()) &&
14594 !Prev->isDefined()) {
14595 Diag(DelLoc, diag::err_deleted_decl_not_first);
14596 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
14597 Prev->isImplicit() ? diag::note_previous_implicit_declaration
14598 : diag::note_previous_declaration);
14617 bool IssuedDiagnostic =
false;
14620 if (!IssuedDiagnostic) {
14622 IssuedDiagnostic =
true;
14624 Diag(O->getLocation(), diag::note_overridden_virtual_function);
14630 ShouldDeleteSpecialMember(MD, getSpecialMember(MD),
nullptr,
14637 Diag(DelLoc, diag::err_deleted_main);
14656 if (Member == CXXInvalid) {
14658 Diag(DefaultLoc, diag::err_default_special_members);
14684 CheckExplicitlyDefaultedSpecialMember(MD);
14689 Diag(DefaultLoc, diag::err_default_special_members);
14697 if (isa<ReturnStmt>(SubStmt))
14698 Self.
Diag(SubStmt->getBeginLoc(),
14699 diag::err_return_in_constructor_handler);
14700 if (!isa<Expr>(SubStmt))
14706 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
14718 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
14722 !NewFT->getExtParameterInfo(I).isNoEscape()) {
14724 diag::warn_overriding_method_missing_noescape);
14726 diag::note_overridden_marked_noescape);
14731 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
14732 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
14733 if ((NewCSA || OldCSA) &&
14734 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
14743 if (NewCC == OldCC)
14754 diag::err_conflicting_overriding_cc_attributes)
14780 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
14788 if (NewClassTy.
isNull()) {
14790 diag::err_different_return_type_for_overriding_virtual_function)
14806 if (!RT->isBeingDefined() &&
14807 RequireCompleteType(New->
getLocation(), NewClassTy,
14808 diag::err_covariant_return_incomplete,
14814 if (!IsDerivedFrom(New->
getLocation(), NewClassTy, OldClassTy)) {
14824 if (CheckDerivedToBaseConversion(
14825 NewClassTy, OldClassTy,
14826 diag::err_covariant_return_inaccessible_base,
14827 diag::err_covariant_return_ambiguous_derived_to_base_conv,
14843 diag::err_covariant_return_type_different_qualifications)
14855 diag::err_covariant_return_type_class_type_more_qualified)
14890 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
14891 CheckPureMethod(M, ZeroLoc);
14899 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
14900 return Var->hasGlobalStorage();
14928 PushExpressionEvaluationContext(
14929 ExpressionEvaluationContext::PotentiallyEvaluated, D);
14939 PopExpressionEvaluationContext();
14942 ExitDeclaratorContext(S);
14954 "Parser allowed 'typedef' as storage class of condition decl.");
14956 Decl *Dcl = ActOnDeclarator(S, D);
14960 if (isa<FunctionDecl>(Dcl)) {
14961 Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
14970 if (!ExternalSource)
14974 ExternalSource->ReadUsedVTables(VTables);
14976 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
14977 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
14978 = VTablesUsed.find(VTables[I].Record);
14980 if (Pos != VTablesUsed.end()) {
14981 if (!Pos->second && VTables[I].DefinitionRequired)
14982 Pos->second =
true;
14986 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
14987 NewUses.push_back(
VTableUse(VTables[I].Record, VTables[I].Location));
14990 VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end());
14994 bool DefinitionRequired) {
14998 CurContext->isDependentContext() || isUnevaluatedContext())
15002 if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
15003 !isInOpenMPDeclareTargetContext() &&
15004 !isInOpenMPTargetExecutionDirective()) {
15005 if (!DefinitionRequired)
15006 MarkVirtualMembersReferenced(Loc, Class);
15011 LoadExternalVTableUses();
15013 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
15014 Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
15019 if (DefinitionRequired && !Pos.first->second) {
15020 Pos.first->second =
true;
15038 CheckDestructor(DD);
15050 MarkVirtualMembersReferenced(Loc, Class);
15052 VTableUses.push_back(std::make_pair(Class, Loc));
15056 LoadExternalVTableUses();
15057 if (VTableUses.empty())
15064 bool DefinedAnything =
false;
15065 for (
unsigned I = 0; I != VTableUses.size(); ++I) {
15074 bool DefineVTable =
true;
15080 if (KeyFunction && !KeyFunction->
hasBody()) {
15082 DefineVTable =
false;
15087 "Instantiations don't have key functions");
15089 }
else if (!KeyFunction) {
15094 bool IsExplicitInstantiationDeclaration =
15096 for (
auto R : Class->
redecls()) {
15100 IsExplicitInstantiationDeclaration =
true;
15102 IsExplicitInstantiationDeclaration =
false;
15107 if (IsExplicitInstantiationDeclaration)
15108 DefineVTable =
false;
15114 if (!DefineVTable) {
15115 MarkVirtualMemberExceptionSpecsNeeded(Loc, Class);
15122 DefinedAnything =
true;
15123 MarkVirtualMembersReferenced(Loc, Class);
15125 if (VTablesUsed[Canonical])
15126 Consumer.HandleVTable(Class);
15134 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
15138 ? diag::warn_weak_template_vtable
15139 : diag::warn_weak_vtable)
15144 VTableUses.clear();
15146 return DefinedAnything;
15151 for (
const auto *I : RD->
methods())
15152 if (I->isVirtual() && !I->isPure())
15161 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
15162 E = FinalOverriders.end();
15165 OE = I->second.end();
15167 assert(OI->second.size() > 0 &&
"no final overrider");
15172 if (!Overrider->isPure())
15173 MarkFunctionReferenced(Loc, Overrider);
15181 for (
const auto &I : RD->
bases()) {
15183 cast<CXXRecordDecl>(I.getType()->getAs<
RecordType>()->getDecl());
15186 MarkVirtualMembersReferenced(Loc, Base);
15197 CollectIvarsToConstructOrDestruct(OID, ivars);
15201 for (
unsigned i = 0; i < ivars.size(); i++) {
15213 InitSeq.Perform(*
this, InitEntity, InitKind,
None);
15214 MemberInit = MaybeCreateExprWithCleanups(MemberInit);
15225 AllToInit.push_back(Member);
15230 ->getAs<RecordType>()) {
15231 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
15233 MarkFunctionReferenced(Field->
getLocation(), Destructor);
15234 CheckDestructorAccess(Field->
getLocation(), Destructor,
15235 PDiag(diag::err_access_dtor_ivar)
15241 AllToInit.data(), AllToInit.size());
15247 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Valid,
15248 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Invalid,
15249 llvm::SmallPtrSet<CXXConstructorDecl*, 4> &Current,
15260 (void)Target->
hasBody(FNTarget);
15262 cast_or_null<CXXConstructorDecl>(FNTarget));
15269 if (!Current.insert(Canonical).second)
15275 Valid.insert(Current.begin(), Current.end());
15278 }
else if (TCanonical == Canonical || Invalid.count(TCanonical) ||
15279 Current.count(TCanonical)) {
15281 if (!Invalid.count(TCanonical)) {
15283 diag::warn_delegating_ctor_cycle)
15287 if (TCanonical != Canonical)
15294 assert(FNTarget &&
"Ctor cycle through bodiless function");
15297 cast<CXXConstructorDecl>(FNTarget));
15302 Invalid.insert(Current.begin(), Current.end());
15311 llvm::SmallPtrSet<CXXConstructorDecl*, 4> Valid, Invalid, Current;
15313 for (DelegatingCtorDeclsType::iterator
15314 I = DelegatingCtorDecls.begin(ExternalSource),
15315 E = DelegatingCtorDecls.end();
15319 for (
auto CI = Invalid.begin(), CE = Invalid.end(); CI != CE; ++CI)
15320 (*CI)->setInvalidDecl();
15329 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
15357 FindCXXThisExpr Finder(*
this);
15365 if (checkThisInStaticMemberFunctionExceptionSpec(Method))
15368 return checkThisInStaticMemberFunctionAttributes(Method);
15382 FindCXXThisExpr Finder(*
this);
15403 if (!Finder.TraverseType(E))
15413 FindCXXThisExpr Finder(*
this);
15416 for (
const auto *A : Method->
attrs()) {
15418 Expr *Arg =
nullptr;
15420 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
15422 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
15424 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
15425 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
15426 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
15427 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
15428 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
15429 Arg = ETLF->getSuccessValue();
15430 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
15431 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
15432 Arg = STLF->getSuccessValue();
15433 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
15434 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
15435 Arg = LR->getArg();
15436 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
15437 Args = llvm::makeArrayRef(LE->args_begin(), LE->args_size());
15438 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
15439 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
15440 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
15441 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
15442 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
15443 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
15444 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
15445 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
15447 if (Arg && !Finder.TraverseStmt(Arg))
15450 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
15451 if (!Finder.TraverseStmt(Args[I]))
15465 Exceptions.clear();
15468 Exceptions.reserve(DynamicExceptions.size());
15469 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
15471 QualType ET = GetTypeFromParser(DynamicExceptions[ei]);
15476 if (!Unexpanded.empty()) {
15478 DynamicExceptionRanges[ei].getBegin(), UPPC_ExceptionType,
15486 if (!CheckSpecifiedExceptionType(ET, DynamicExceptionRanges[ei]))
15487 Exceptions.push_back(ET);
15497 "Parser should have made sure that the expression is boolean");
15498 if (IsTopLevel && DiagnoseUnexpandedParameterPack(NoexceptExpr)) {
15513 Expr *NoexceptExpr) {
15519 MethodD = FunTmpl->getTemplatedDecl();
15528 checkExceptionSpecification(
true, EST, DynamicExceptions,
15529 DynamicExceptionRanges, NoexceptExpr, Exceptions,
15536 checkThisInStaticMemberFunctionExceptionSpec(Method);
15541 CheckOverridingFunctionExceptionSpec(Method, O);
15555 Diag(DeclStart, diag::err_anonymous_property);
15563 CheckExtraCXXDefaultArguments(D);
15566 UPPC_DataMemberType)) {
15577 << getLangOpts().CPlusPlus17;
15580 diag::err_invalid_thread)
15586 ForVisibleRedeclaration);
15587 LookupName(Previous, S);
15608 PrevDecl =
nullptr;
15611 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
15612 PrevDecl =
nullptr;
15619 ProcessDeclAttributes(TUScope, NewPD, D);
15632 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.
StmtResult ActOnExprStmt(ExprResult Arg)
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class...
static CharSourceRange getTokenRange(SourceRange R)
void addConst()
Add the const type qualifier to this QualType.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
static unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
bool isRecordType() const
static TemplateArgumentLoc getTrivialTypeTemplateArgument(Sema &S, SourceLocation Loc, QualType T)
bool isEmpty() const
No scope specifier.
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
void erase()
Erase the last element returned from this iterator.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation)
Builds a using declaration.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
bool 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.
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.
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.
ExprResult ActOnFinishFullExpr(Expr *Expr)
bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body)
Check the body for the given constexpr function declaration only contains the permitted types of stat...
#define CheckPolymorphic(Type)
CanQualType getCanonicalTypeUnqualified() const
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasGroupingParens() const
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool hasTrailingReturn() const
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.