40 #include "llvm/ADT/STLExtras.h"
41 #include "llvm/ADT/SmallString.h"
42 #include "llvm/ADT/StringExtras.h"
46 using namespace clang;
58 class CheckDefaultArgumentVisitor
59 :
public StmtVisitor<CheckDefaultArgumentVisitor, bool> {
64 CheckDefaultArgumentVisitor(
Expr *defarg,
Sema *s)
65 : DefaultArg(defarg),
S(s) {}
75 bool CheckDefaultArgumentVisitor::VisitExpr(
Expr *
Node) {
76 bool IsInvalid =
false;
78 IsInvalid |= Visit(SubStmt);
85 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
DeclRefExpr *DRE) {
87 if (
ParmVarDecl *Param = dyn_cast<ParmVarDecl>(Decl)) {
97 diag::err_param_default_argument_references_param)
98 << Param->getDeclName() << DefaultArg->getSourceRange();
99 }
else if (
VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) {
103 if (VDecl->isLocalVarDecl())
105 diag::err_param_default_argument_references_local)
106 << VDecl->getDeclName() << DefaultArg->getSourceRange();
113 bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
CXXThisExpr *ThisE) {
118 diag::err_param_default_argument_references_this)
122 bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
PseudoObjectExpr *POE) {
130 E = OVE->getSourceExpr();
131 assert(E &&
"pseudo-object binding without source expression?");
139 bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
LambdaExpr *Lambda) {
147 diag::err_lambda_capture_default_arg);
194 "Must have noexcept result for EST_ComputedNoexcept.");
196 "Should not generate implicit declarations for dependent cases, "
197 "and don't know how to handle them anyway.");
209 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
211 "Shouldn't collect exceptions when throw-all is guaranteed.");
216 Exceptions.push_back(E);
244 if (Self->canThrow(E))
252 diag::err_typecheck_decl_incomplete_type)) {
273 CheckCompletedExpr(Arg, EqualLoc);
281 UnparsedDefaultArgInstantiationsMap::iterator InstPos
284 for (
unsigned I = 0, N = InstPos->second.size();
I != N; ++
I)
285 InstPos->second[
I]->setUninstantiatedDefaultArg(Arg);
300 if (!param || !DefaultArg)
308 Diag(EqualLoc, diag::err_param_default_argument)
324 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
330 CheckDefaultArgumentVisitor DefaultArgChecker(DefaultArg,
this);
331 if (DefaultArgChecker.Visit(DefaultArg)) {
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());
415 MightBeFunction =
false;
421 for (
unsigned NumParams = FD->
getNumParams(); NumParams > 0; --NumParams) {
437 bool Invalid =
false;
448 for (; PrevForDefaultArgs;
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;
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) &&
628 if (NewSM != OldSM) {
631 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
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);
695 Diag(Decomp.getLSquareLoc(), diag::err_decomp_decl_context)
696 << Decomp.getSourceRange();
700 if (!TemplateParamLists.empty()) {
703 Diag(TemplateParamLists.front()->getTemplateLoc(),
704 diag::err_decomp_decl_template);
709 ? diag::warn_cxx14_compat_decomp_decl
710 : diag::ext_decomp_decl)
711 << Decomp.getSourceRange();
723 if (
auto SCS = DS.getStorageClassSpec()) {
725 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
727 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
729 BadSpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
731 if (DS.isConstexprSpecified()) {
732 BadSpecifiers.push_back(
"constexpr");
733 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
735 if (DS.isInlineSpecified()) {
736 BadSpecifiers.push_back(
"inline");
737 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
739 if (!BadSpecifiers.empty()) {
740 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
741 Err << (int)BadSpecifiers.size()
742 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
745 for (
auto Loc : BadSpecifierLocs)
767 Diag(Decomp.getLSquareLoc(),
771 ? diag::err_decomp_decl_parens
772 : diag::err_decomp_decl_type)
806 if (!Previous.
empty()) {
808 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
809 Diag(Old->getLocation(), diag::note_previous_definition);
814 Bindings.push_back(BD);
821 Decomp.getLSquareLoc());
825 bool AddToScope =
true;
841 if ((int64_t)Bindings.size() != NumElems) {
842 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
843 << DecompType << (
unsigned)Bindings.size() << NumElems.toString(10)
844 << (NumElems < Bindings.size());
849 for (
auto *B : Bindings) {
854 E = GetInit(Loc, E.
get(), I++);
857 B->setBinding(ElemType, E.
get());
866 const llvm::APSInt &NumElems,
869 S, Bindings, Src, DecompType, NumElems, ElemType,
890 S, Bindings, Src, DecompType, llvm::APSInt::get(VT->
getNumElements()),
900 S, Bindings, Src, DecompType, llvm::APSInt::get(2),
911 llvm::raw_svector_ostream OS(SS);
916 Arg.getArgument().print(PrintingPolicy, OS);
926 auto DiagnoseMissing = [&] {
936 return DiagnoseMissing();
946 return DiagnoseMissing();
952 Result.suppressDiagnostics();
954 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
966 Loc, TraitTy, DiagID,
972 assert(RD &&
"specialization of class template is not a class?");
994 llvm::APSInt &Size) {
1007 return IsTupleLike::NotTupleLike;
1016 : R(R), Args(Args) {}
1018 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1021 } Diagnoser(R, Args);
1037 return IsTupleLike::TupleLike;
1052 S, R, Loc,
"tuple_element", Args,
1053 diag::err_decomp_decl_std_tuple_element_not_specialized))
1059 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1070 struct BindingDiagnosticTrap {
1076 : S(S), Trap(S.
Diags), BD(BD) {}
1077 ~BindingDiagnosticTrap() {
1078 if (Trap.hasErrorOccurred())
1079 S.
Diag(BD->getLocation(), diag::note_in_binding_decl_init) << BD;
1087 const llvm::APSInt &TupleSize) {
1088 if ((int64_t)Bindings.size() != TupleSize) {
1089 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1090 << DecompType << (
unsigned)Bindings.size() << TupleSize.toString(10)
1091 << (TupleSize < Bindings.size());
1095 if (Bindings.empty())
1104 bool UseMemberGet =
false;
1108 if (MemberGet.isAmbiguous())
1110 UseMemberGet = !MemberGet.empty();
1115 for (
auto *B : Bindings) {
1116 BindingDiagnosticTrap Trap(S, B);
1138 MemberGet, &Args,
nullptr);
1172 B->getDeclName().getAsIdentifierInfo(), RefType,
1176 RefVD->setImplicit();
1178 RefVD->setInlineSpecified();
1179 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1184 E = Seq.
Perform(S, Entity, Kind, Init);
1190 RefVD->setInit(E.
get());
1191 RefVD->checkInitIsICE();
1199 B->setBinding(T, E.
get());
1223 ClassWithFields = RD;
1227 Paths.
setOrigin(const_cast<CXXRecordDecl*>(RD));
1235 for (
auto &
P : Paths) {
1239 BestPath->back().Base->getType())) {
1241 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1242 <<
false << RD << BestPath->back().Base->getType()
1243 <<
P.back().Base->getType();
1245 }
else if (
P.Access < BestPath->
Access) {
1251 QualType BaseType = BestPath->back().Base->getType();
1253 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1260 S.
Diag(Loc, diag::err_decomp_decl_non_public_base)
1262 for (
auto &BS : *BestPath) {
1263 if (BS.Base->getAccessSpecifier() !=
AS_public) {
1264 S.
Diag(BS.Base->getLocStart(), diag::note_access_constrained_by_path)
1266 << (BS.Base->getAccessSpecifierAsWritten() ==
AS_none);
1281 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1282 << (ClassWithFields == RD) << RD << ClassWithFields
1283 << Paths.
front().back().Base->getType();
1287 return ClassWithFields;
1300 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1301 unsigned NumFields =
1303 [](
FieldDecl *FD) {
return !FD->isUnnamedBitfield(); });
1304 assert(Bindings.size() != NumFields);
1305 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1306 << DecompType << (
unsigned)Bindings.size() << NumFields
1307 << (NumFields < Bindings.size());
1314 for (
auto *FD : RD->
fields()) {
1315 if (FD->isUnnamedBitfield())
1318 if (FD->isAnonymousStructOrUnion()) {
1321 S.
Diag(FD->getLocation(), diag::note_declared_at);
1326 if (I >= Bindings.size())
1327 return DiagnoseBadNumberOfBindings();
1328 auto *B = Bindings[I++];
1332 S.
Diag(Loc, diag::err_decomp_decl_non_public_member) << FD << DecompType;
1335 bool Implicit =
true;
1336 for (
const auto *D : RD->
decls()) {
1339 if (isa<AccessSpecDecl>(D)) {
1345 S.
Diag(FD->getLocation(), diag::note_access_natural)
1371 if (FD->isMutable())
1376 if (I != Bindings.size())
1377 return DiagnoseBadNumberOfBindings();
1419 llvm::APSInt TupleSize(32);
1425 case IsTupleLike::TupleLike:
1430 case IsTupleLike::NotTupleLike:
1439 << DD << !RD << DecompType;
1462 "Should only be called if types are otherwise the same.");
1473 NewType =
P->getPointeeType();
1501 for (p = 0; p < NumParams; ++p) {
1513 unsigned LastMissingDefaultArg = 0;
1514 for (; p < NumParams; ++p) {
1521 diag::err_param_default_argument_missing_name)
1525 diag::err_param_default_argument_missing);
1527 LastMissingDefaultArg = p;
1531 if (LastMissingDefaultArg > 0) {
1536 for (p = 0; p <= LastMissingDefaultArg; ++p) {
1550 unsigned ArgIndex = 0;
1554 i != e; ++i, ++ArgIndex) {
1557 if (!(*i)->isDependentType() &&
1559 diag::err_constexpr_non_literal_param,
1561 isa<CXXConstructorDecl>(FD)))
1577 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1597 << isa<CXXConstructorDecl>(NewFD)
1599 for (
const auto &
I : RD->
vbases())
1600 Diag(
I.getLocStart(),
1601 diag::note_constexpr_virtual_base_here) <<
I.getSourceRange();
1606 if (!isa<CXXConstructorDecl>(NewFD)) {
1619 while (!WrittenVirtual->isVirtualAsWritten())
1621 if (WrittenVirtual != Method)
1622 Diag(WrittenVirtual->getLocation(),
1623 diag::note_overridden_virtual_function);
1631 diag::err_constexpr_non_literal_return))
1652 for (
const auto *DclIt : DS->
decls()) {
1653 switch (DclIt->getKind()) {
1654 case Decl::StaticAssert:
1656 case Decl::UsingShadow:
1657 case Decl::UsingDirective:
1658 case Decl::UnresolvedUsingTypename:
1659 case Decl::UnresolvedUsingValue:
1666 case Decl::TypeAlias: {
1669 const auto *TN = cast<TypedefNameDecl>(DclIt);
1670 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1672 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1675 << isa<CXXConstructorDecl>(Dcl);
1682 case Decl::CXXRecord:
1684 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition())
1687 ? diag::warn_cxx11_compat_constexpr_type_definition
1688 : diag::ext_constexpr_type_definition)
1689 << isa<CXXConstructorDecl>(Dcl);
1692 case Decl::EnumConstant:
1693 case Decl::IndirectField:
1700 case Decl::Decomposition: {
1704 const auto *VD = cast<VarDecl>(DclIt);
1705 if (VD->isThisDeclarationADefinition()) {
1706 if (VD->isStaticLocal()) {
1707 SemaRef.
Diag(VD->getLocation(),
1708 diag::err_constexpr_local_var_static)
1709 << isa<CXXConstructorDecl>(Dcl)
1713 if (!VD->getType()->isDependentType() &&
1715 VD->getLocation(), VD->getType(),
1716 diag::err_constexpr_local_var_non_literal_type,
1717 isa<CXXConstructorDecl>(Dcl)))
1719 if (!VD->getType()->isDependentType() &&
1720 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1721 SemaRef.
Diag(VD->getLocation(),
1722 diag::err_constexpr_local_var_no_init)
1723 << isa<CXXConstructorDecl>(Dcl);
1727 SemaRef.
Diag(VD->getLocation(),
1729 ? diag::warn_cxx11_compat_constexpr_local_var
1730 : diag::ext_constexpr_local_var)
1731 << isa<CXXConstructorDecl>(Dcl);
1735 case Decl::NamespaceAlias:
1736 case Decl::Function:
1744 SemaRef.
Diag(DS->
getLocStart(), diag::err_constexpr_body_invalid_stmt)
1745 << isa<CXXConstructorDecl>(Dcl);
1764 llvm::SmallSet<Decl*, 16> &
Inits,
1781 if (!Inits.count(Field)) {
1783 SemaRef.
Diag(Dcl->
getLocation(), diag::err_constexpr_ctor_missing_init);
1786 SemaRef.
Diag(Field->
getLocation(), diag::note_constexpr_ctor_missing_init);
1792 if (!RD->
isUnion() || Inits.count(
I))
1805 case Stmt::NullStmtClass:
1809 case Stmt::DeclStmtClass:
1819 case Stmt::ReturnStmtClass:
1821 if (isa<CXXConstructorDecl>(Dcl)) {
1831 case Stmt::CompoundStmtClass: {
1837 for (
auto *BodyIt : CompStmt->
body()) {
1845 case Stmt::AttributedStmtClass:
1850 case Stmt::IfStmtClass: {
1866 case Stmt::WhileStmtClass:
1867 case Stmt::DoStmtClass:
1868 case Stmt::ForStmtClass:
1869 case Stmt::CXXForRangeStmtClass:
1870 case Stmt::ContinueStmtClass:
1884 case Stmt::SwitchStmtClass:
1885 case Stmt::CaseStmtClass:
1886 case Stmt::DefaultStmtClass:
1887 case Stmt::BreakStmtClass:
1910 << isa<CXXConstructorDecl>(Dcl);
1919 if (isa<CXXTryStmt>(Body)) {
1930 << isa<CXXConstructorDecl>(Dcl);
1940 for (
auto *BodyIt : CompBody->
body()) {
1945 if (Cxx1yLoc.isValid())
1948 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
1949 : diag::ext_constexpr_body_invalid_stmt)
1950 << isa<CXXConstructorDecl>(Dcl);
1953 = dyn_cast<CXXConstructorDecl>(Dcl)) {
1962 if (Constructor->getNumCtorInitializers() == 0 &&
1967 }
else if (!Constructor->isDependentContext() &&
1968 !Constructor->isDelegatingConstructor()) {
1969 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
1973 bool AnyAnonStructUnionMembers =
false;
1974 unsigned Fields = 0;
1977 if (
I->isAnonymousStructOrUnion()) {
1978 AnyAnonStructUnionMembers =
true;
1986 if (AnyAnonStructUnionMembers ||
1987 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
1991 llvm::SmallSet<Decl*, 16>
Inits;
1992 for (
const auto *
I: Constructor->inits()) {
1996 Inits.insert(
ID->chain_begin(),
ID->chain_end());
1999 bool Diagnosed =
false;
2007 if (ReturnStmts.empty()) {
2016 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2017 : diag::err_constexpr_body_no_return);
2020 }
else if (ReturnStmts.size() > 1) {
2021 Diag(ReturnStmts.back(),
2023 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2024 : diag::ext_constexpr_body_multiple_return);
2025 for (
unsigned I = 0;
I < ReturnStmts.size() - 1; ++
I)
2026 Diag(ReturnStmts[
I], diag::note_constexpr_body_previous_return);
2042 Diag(Dcl->
getLocation(), diag::ext_constexpr_function_never_constant_expr)
2043 << isa<CXXConstructorDecl>(Dcl);
2044 for (
size_t I = 0, N = Diags.size();
I != N; ++
I)
2045 Diag(Diags[
I].first, Diags[
I].second);
2064 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2066 CurDecl = dyn_cast_or_null<CXXRecordDecl>(
CurContext);
2085 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2087 CurDecl = dyn_cast_or_null<CXXRecordDecl>(
CurContext);
2107 for (
const auto &
I : Current->
bases()) {
2119 Queue.push_back(Base);
2125 Current = Queue.pop_back_val();
2153 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2166 ((BaseDecl = BaseDecl->getDefinition()) &&
2168 Diag(BaseLoc, diag::err_circular_inheritance)
2172 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
2181 Access, TInfo, EllipsisLoc);
2186 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2193 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2200 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2212 diag::err_incomplete_base_class, SpecifierRange)) {
2219 assert(BaseDecl &&
"Record type has no declaration");
2221 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2223 assert(CXXBaseDecl &&
"Base type is not a C++ type");
2232 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2240 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
2241 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2243 << FA->isSpelledAsSealed();
2255 Access, TInfo, EllipsisLoc);
2282 if (!Attributes.
empty()) {
2285 if (
Attr->isInvalid() ||
2290 ? diag::warn_unknown_attribute_ignored
2291 : diag::err_base_specifier_attribute)
2305 Virtual, Access, TInfo,
2326 auto Decl = Rec->getAsCXXRecordDecl();
2329 for (
const auto &BaseSpec : Decl->bases()) {
2331 .getUnqualifiedType();
2332 if (Set.insert(Base).second)
2350 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2357 unsigned NumGoodBases = 0;
2358 bool Invalid =
false;
2359 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2369 Diag(Bases[idx]->getLocStart(),
2370 diag::err_duplicate_base_class)
2372 << Bases[idx]->getSourceRange();
2381 KnownBase = Bases[idx];
2382 Bases[NumGoodBases++] = Bases[idx];
2385 if (Bases.size() > 1)
2389 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
2407 Class->
setBases(Bases.data(), NumGoodBases);
2409 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2411 QualType BaseType = Bases[idx]->getType();
2415 if (IndirectBaseTypes.count(CanonicalBase)) {
2419 = Class->
isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
2424 Diag(Bases[idx]->getLocStart (), diag::warn_inaccessible_base_class)
2426 << Bases[idx]->getSourceRange();
2428 assert(Bases[idx]->isVirtual());
2444 if (!ClassDecl || Bases.empty())
2501 assert(BasePathArray.empty() &&
"Base path array must be empty!");
2510 for (
unsigned I = Path.size();
I != 0; --
I) {
2511 if (Path[
I - 1].
Base->isVirtual()) {
2518 for (
unsigned I = Start, E = Path.size();
I !=
E; ++
I)
2519 BasePathArray.push_back(const_cast<CXXBaseSpecifier*>(Path[
I].Base));
2536 unsigned InaccessibleBaseID,
2537 unsigned AmbigiousBaseConvID,
2541 bool IgnoreAccess) {
2548 bool DerivationOkay =
IsDerivedFrom(Loc, Derived, Base, Paths);
2549 assert(DerivationOkay &&
2550 "Can only be used with a derived-to-base conversion");
2551 (void)DerivationOkay;
2554 if (!IgnoreAccess) {
2557 InaccessibleBaseID)) {
2573 if (AmbigiousBaseConvID) {
2583 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
2592 Diag(Loc, AmbigiousBaseConvID)
2593 << Derived << Base << PathDisplayStr << Range <<
Name;
2602 bool IgnoreAccess) {
2604 Derived, Base, diag::err_upcast_to_inaccessible_base,
2605 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
2606 BasePath, IgnoreAccess);
2623 std::string PathDisplayStr;
2624 std::set<unsigned> DisplayedPaths;
2626 Path != Paths.
end(); ++Path) {
2627 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
2630 PathDisplayStr +=
"\n ";
2632 for (CXXBasePath::const_iterator Element = Path->begin();
2633 Element != Path->end(); ++Element)
2634 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
2638 return PathDisplayStr;
2650 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
2680 if (!OverloadedMethods.empty()) {
2681 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2682 Diag(OA->getLocation(),
2683 diag::override_keyword_hides_virtual_member_function)
2684 <<
"override" << (OverloadedMethods.size() > 1);
2685 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2686 Diag(FA->getLocation(),
2687 diag::override_keyword_hides_virtual_member_function)
2688 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2689 << (OverloadedMethods.size() > 1);
2700 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
2701 Diag(OA->getLocation(),
2702 diag::override_keyword_only_allowed_on_virtual_member_functions)
2706 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
2707 Diag(FA->getLocation(),
2708 diag::override_keyword_only_allowed_on_virtual_member_functions)
2709 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
2720 bool HasOverriddenMethods =
2722 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
2723 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
2743 unsigned DiagID = isa<CXXDestructorDecl>(MD)
2744 ? diag::warn_destructor_marked_not_override_overriding
2745 : diag::warn_function_marked_not_override_overriding;
2757 FinalAttr *FA = Old->
getAttr<FinalAttr>();
2763 << FA->isSpelledAsSealed();
2772 return !RD->isCompleteDefinition() ||
2773 !RD->hasTrivialDefaultConstructor() ||
2774 !RD->hasTrivialDestructor();
2780 if (it->isDeclspecPropertyAttribute())
2793 std::map<CXXRecordDecl*, NamedDecl*> Bases;
2798 if (Bases.find(
Base) != Bases.end())
2800 for (
const auto Field :
Base->lookup(FieldName)) {
2801 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
2804 assert(Bases.find(
Base) == Bases.end());
2817 for (
const auto &
P : Paths) {
2818 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
2819 auto It = Bases.find(
Base);
2821 if (It == Bases.end())
2823 auto BaseField = It->second;
2824 assert(BaseField->getAccess() !=
AS_private);
2827 Diag(Loc, diag::warn_shadow_field)
2829 Diag(BaseField->getLocation(), diag::note_shadow_field);
2854 Expr *BitWidth =
static_cast<Expr*
>(BW);
2861 if (cast<CXXRecordDecl>(
CurContext)->isInterface()) {
2865 unsigned InvalidDecl;
2866 bool ShowDeclName =
true;
2876 ShowDeclName =
false;
2881 ShowDeclName =
false;
2896 Diag(Loc, diag::err_invalid_member_in_interface)
2897 << (InvalidDecl-1) << Name;
2899 Diag(Loc, diag::err_invalid_member_in_interface)
2900 << (InvalidDecl-1) <<
"";
2926 diag::err_storageclass_invalid_for_member);
2946 const char *PrevSpec;
2951 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
2955 const char *PrevSpec;
2961 "This is the only DeclSpec that should fail to be applied");
2965 isInstField =
false;
2976 Diag(Loc, diag::err_bad_variable_name)
2985 if (TemplateParameterLists.size()) {
2987 if (TemplateParams->
size()) {
2996 diag::err_template_member_noparams)
3022 if (MSPropertyAttr) {
3024 BitWidth, InitStyle, AS, MSPropertyAttr);
3027 isInstField =
false;
3030 BitWidth, InitStyle, AS);
3035 CheckShadowInheritedFields(Loc, Name, cast<CXXRecordDecl>(
CurContext));
3045 }
else if (isa<VarDecl>(Member) || isa<VarTemplateDecl>(Member)) {
3048 Diag(Loc, diag::err_static_not_bitfield)
3050 }
else if (isa<TypedefDecl>(Member)) {
3052 Diag(Loc, diag::err_typedef_not_bitfield)
3057 Diag(Loc, diag::err_not_integral_type_bitfield)
3058 << Name << cast<ValueDecl>(Member)->getType()
3071 FunTmpl->getTemplatedDecl()->setAccess(AS);
3072 else if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(Member))
3073 VarTmpl->getTemplatedDecl()->setAccess(AS);
3084 if (
CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(Member))
3090 assert((Name || isInstField) &&
"No identifier for non-field ?");
3093 FieldDecl *FD = cast<FieldDecl>(Member);
3112 class UninitializedFieldVisitor
3117 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3120 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3135 UninitializedFieldVisitor(
Sema &S,
3136 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3137 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3138 : Inherited(S.
Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3139 Constructor(nullptr), InitList(
false), InitListFieldDecl(nullptr) {}
3142 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3143 bool CheckReferenceOnly) {
3145 bool ReferenceField =
false;
3150 Fields.push_back(FD);
3152 ReferenceField =
true;
3158 if (CheckReferenceOnly && !ReferenceField)
3164 for (
auto I = Fields.rbegin() + 1, E = Fields.rend();
I !=
E; ++
I) {
3165 UsedFieldIndex.push_back((*I)->getFieldIndex());
3168 for (
auto UsedIter = UsedFieldIndex.begin(),
3169 UsedEnd = UsedFieldIndex.end(),
3170 OrigIter = InitFieldIndex.begin(),
3171 OrigEnd = InitFieldIndex.end();
3172 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3173 if (*UsedIter < *OrigIter)
3175 if (*UsedIter > *OrigIter)
3182 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3197 if (isa<VarDecl>(SubME->getMemberDecl()))
3200 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3205 AllPODFields =
false;
3207 Base = SubME->getBase();
3213 if (AddressOf && AllPODFields)
3219 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3220 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
3223 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3233 if (!Decls.count(FoundVD))
3238 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3240 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3245 if (CheckReferenceOnly && !IsReference)
3249 unsigned diag = IsReference
3250 ? diag::warn_reference_field_is_uninit
3251 : diag::warn_field_is_uninit;
3255 diag::note_uninit_in_this_constructor)
3260 void HandleValue(
Expr *E,
bool AddressOf) {
3263 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3264 HandleMemberExpr(ME,
false ,
3270 Visit(CO->getCond());
3271 HandleValue(CO->getTrueExpr(), AddressOf);
3272 HandleValue(CO->getFalseExpr(), AddressOf);
3277 dyn_cast<BinaryConditionalOperator>(E)) {
3278 Visit(BCO->getCond());
3279 HandleValue(BCO->getFalseExpr(), AddressOf);
3284 HandleValue(OVE->getSourceExpr(), AddressOf);
3289 switch (BO->getOpcode()) {
3294 HandleValue(BO->getLHS(), AddressOf);
3295 Visit(BO->getRHS());
3298 Visit(BO->getLHS());
3299 HandleValue(BO->getRHS(), AddressOf);
3308 InitFieldIndex.push_back(0);
3309 for (
auto Child : ILE->
children()) {
3310 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3311 CheckInitListExpr(SubList);
3315 ++InitFieldIndex.back();
3317 InitFieldIndex.pop_back();
3326 DeclsToRemove.clear();
3333 InitListFieldDecl = Field;
3334 InitFieldIndex.clear();
3335 CheckInitListExpr(ILE);
3349 HandleMemberExpr(ME,
true ,
false );
3358 Inherited::VisitImplicitCastExpr(E);
3364 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3368 if (ICE->getCastKind() == CK_NoOp)
3369 ArgExpr = ICE->getSubExpr();
3370 HandleValue(ArgExpr,
false );
3373 Inherited::VisitCXXConstructExpr(E);
3378 if (isa<MemberExpr>(Callee)) {
3379 HandleValue(Callee,
false );
3385 Inherited::VisitCXXMemberCallExpr(E);
3394 HandleValue(E->
getArg(0),
false );
3400 Inherited::VisitCallExpr(E);
3406 if (isa<UnresolvedLookupExpr>(Callee))
3407 return Inherited::VisitCXXOperatorCallExpr(E);
3411 HandleValue(Arg->IgnoreParenImpCasts(),
false );
3421 DeclsToRemove.push_back(FD);
3424 HandleValue(E->
getLHS(),
false );
3429 Inherited::VisitBinaryOperator(E);
3439 HandleValue(ME->
getBase(),
true );
3444 Inherited::VisitUnaryOperator(E);
3454 static void DiagnoseUninitializedFields(
3471 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
3474 for (
auto *
I : RD->
decls()) {
3475 if (
auto *FD = dyn_cast<FieldDecl>(
I)) {
3476 UninitializedFields.insert(FD);
3477 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(
I)) {
3478 UninitializedFields.insert(IFD->getAnonField());
3482 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
3483 for (
auto I : RD->
bases())
3484 UninitializedBaseClasses.insert(
I.getType().getCanonicalType());
3486 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3489 UninitializedFieldVisitor UninitializedChecker(SemaRef,
3490 UninitializedFields,
3491 UninitializedBaseClasses);
3493 for (
const auto *FieldInit : Constructor->
inits()) {
3494 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3497 Expr *InitExpr = FieldInit->getInit();
3502 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
3503 InitExpr =
Default->getExpr();
3507 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
3508 FieldInit->getAnyMember(),
3509 FieldInit->getBaseClass());
3511 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
3512 FieldInit->getAnyMember(),
3513 FieldInit->getBaseClass());
3539 "must set init style when field is created");
3561 Init = Seq.Perform(*
this, Entity, Kind, InitExpr);
3577 InitExpr = Init.
get();
3591 DirectBaseSpec =
nullptr;
3592 for (
const auto &Base : ClassDecl->
bases()) {
3596 DirectBaseSpec = &Base;
3604 VirtualBaseSpec =
nullptr;
3605 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
3614 Path != Paths.
end(); ++Path) {
3615 if (Path->back().Base->isVirtual()) {
3616 VirtualBaseSpec = Path->back().Base;
3623 return DirectBaseSpec || VirtualBaseSpec;
3638 DS, IdLoc, InitList,
3658 DS, IdLoc, List, EllipsisLoc);
3667 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
3668 : ClassDecl(ClassDecl) {}
3670 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
3672 if (
FieldDecl *Member = dyn_cast<FieldDecl>(ND))
3674 return isa<TypeDecl>(ND);
3731 if (!Result.
empty()) {
3733 if ((Member = dyn_cast<FieldDecl>(Result.
front())) ||
3736 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
3748 if (TemplateTypeTy) {
3767 bool NotUnknownSpecialization =
false;
3769 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
3770 NotUnknownSpecialization = !Record->hasAnyDependentBases();
3772 if (!NotUnknownSpecialization) {
3777 *MemberOrBase, IdLoc);
3800 llvm::make_unique<MemInitializerValidatorCCC>(ClassDecl),
3807 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3808 << MemberOrBase <<
true);
3815 DirectBaseSpec, VirtualBaseSpec)) {
3820 PDiag(diag::err_mem_init_not_member_or_class_suggest)
3821 << MemberOrBase <<
false,
3827 diag::note_base_class_specified_here)
3836 if (!TyD && BaseType.
isNull()) {
3837 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
3882 if (Op->getOpcode() != UO_AddrOf)
3885 Init = Op->getSubExpr();
3899 IsPointer ? diag::warn_init_ptr_member_to_parameter_addr
3900 : diag::warn_bind_ref_member_to_parameter)
3907 S.
Diag(Member->
getLocation(), diag::note_ref_or_ptr_member_declared_here)
3908 << (
unsigned)IsPointer;
3916 assert((DirectMember || IndirectMember) &&
3917 "Member must be a FieldDecl or IndirectFieldDecl");
3926 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
3927 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
3928 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
3929 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
3942 bool InitList =
false;
3943 if (isa<InitListExpr>(Init)) {
3959 ExprResult MemberInit = InitSeq.Perform(*
this, MemberEntity, Kind, Args,
3970 if (MemberInit.isInvalid())
3973 Init = MemberInit.get();
3992 return Diag(NameLoc, diag::err_delegating_ctor)
3994 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
3996 bool InitList =
true;
3998 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4000 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4012 ExprResult DelegationInit = InitSeq.Perform(*
this, DelegationEntity, Kind,
4017 assert(cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor() &&
4018 "Delegating constructor with no target?");
4025 if (DelegationInit.isInvalid())
4036 DelegationInit = Init;
4039 DelegationInit.getAs<
Expr>(),
4051 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4066 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4095 if (!DirectBaseSpec && !VirtualBaseSpec) {
4104 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4116 InitRange.
getEnd(), EllipsisLoc);
4123 if (DirectBaseSpec && VirtualBaseSpec)
4124 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4129 BaseSpec = VirtualBaseSpec;
4132 bool InitList =
true;
4134 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4136 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4146 ExprResult BaseInit = InitSeq.Perform(*
this, BaseEntity, Kind, Args,
nullptr);
4171 InitRange.
getEnd(), EllipsisLoc);
4181 TargetType, ExprLoc);
4201 bool IsInheritedVirtualBase,
4205 IsInheritedVirtualBase);
4209 switch (ImplicitInitKind) {
4215 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
None);
4221 bool Moving = ImplicitInitKind ==
IIK_Move;
4243 BasePath.push_back(BaseSpec);
4245 CK_UncheckedDerivedToBase,
4253 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4276 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
4291 bool Moving = ImplicitInitKind ==
IIK_Move;
4299 Expr *MemberExprBase =
4314 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
4316 MemberLookup.resolveKind();
4350 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
4365 "Unhandled implicit init kind!");
4381 InitSeq.
Perform(SemaRef, InitEntity, InitKind,
None);
4404 diag::err_uninitialized_member_in_ctor)
4414 diag::err_uninitialized_member_in_ctor)
4435 CXXMemberInit =
nullptr;
4440 struct BaseAndFieldInfo {
4443 bool AnyErrorsInInits;
4445 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
4447 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
4450 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
4462 bool isImplicitCopyOrMove()
const {
4473 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
4477 AllToInit.push_back(Init);
4486 bool isInactiveUnionMember(
FieldDecl *Field) {
4496 if (isImplicitCopyOrMove())
4514 bool isWithinInactiveUnionMember(
FieldDecl *Field,
4517 return isInactiveUnionMember(Field);
4519 for (
auto *C : Indirect->
chain()) {
4521 if (Field && isInactiveUnionMember(Field))
4536 if (!ArrayT->getSize())
4539 T = ArrayT->getElementType();
4554 return Info.addFieldInitializer(Init);
4568 if (Info.isWithinInactiveUnionMember(Field, Indirect))
4585 return Info.addFieldInitializer(Init);
4595 if (Info.AnyErrorsInInits)
4606 return Info.addFieldInitializer(Init);
4626 DiagnoseUninitializedFields(*
this, Constructor);
4636 if (!Initializers.empty()) {
4640 memcpy(baseOrMemberInitializers, Initializers.data(),
4652 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
4660 bool HadError =
false;
4662 for (
unsigned i = 0; i < Initializers.size(); i++) {
4671 for (
auto *C : F->chain()) {
4674 Info.ActiveUnionMember.insert(std::make_pair(
4679 Info.ActiveUnionMember.insert(std::make_pair(
4686 llvm::SmallPtrSet<CXXBaseSpecifier *, 16> DirectVBases;
4687 for (
auto &
I : ClassDecl->
bases()) {
4689 DirectVBases.insert(&
I);
4693 for (
auto &VBase : ClassDecl->
vbases()) {
4695 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
4703 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
4704 << VBase.getType() << ClassDecl;
4708 Info.AllToInit.push_back(
Value);
4709 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
4714 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
4717 &VBase, IsInheritedVirtualBase,
4723 Info.AllToInit.push_back(CXXBaseInit);
4728 for (
auto &Base : ClassDecl->
bases()) {
4730 if (Base.isVirtual())
4735 Info.AllToInit.push_back(
Value);
4736 }
else if (!AnyErrors) {
4745 Info.AllToInit.push_back(CXXBaseInit);
4750 for (
auto *Mem : ClassDecl->
decls()) {
4751 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
4756 if (F->isUnnamedBitfield())
4762 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
4771 if (Info.isImplicitCopyOrMove())
4774 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
4775 if (F->getType()->isIncompleteArrayType()) {
4777 "Incomplete array type is not valid");
4789 unsigned NumInitializers = Info.AllToInit.size();
4790 if (NumInitializers > 0) {
4794 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
4811 for (
auto *Field : RD->
fields())
4839 bool ShouldCheckOrder =
false;
4840 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4842 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
4844 ShouldCheckOrder =
true;
4848 if (!ShouldCheckOrder)
4859 for (
const auto &VBase : ClassDecl->
vbases())
4863 for (
const auto &Base : ClassDecl->
bases()) {
4864 if (Base.isVirtual())
4870 for (
auto *Field : ClassDecl->
fields()) {
4877 unsigned NumIdealInits = IdealInitKeys.size();
4878 unsigned IdealIndex = 0;
4881 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4887 for (; IdealIndex != NumIdealInits; ++IdealIndex)
4888 if (InitKey == IdealInitKeys[IdealIndex])
4894 if (IdealIndex == NumIdealInits && PrevInit) {
4897 diag::warn_initializer_out_of_order);
4910 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
4911 if (InitKey == IdealInitKeys[IdealIndex])
4914 assert(IdealIndex < NumIdealInits &&
4915 "initializer not found in initializer list");
4923 bool CheckRedundantInit(
Sema &S,
4933 diag::err_multiple_mem_initialization)
4938 assert(BaseClass &&
"neither field nor base");
4940 diag::err_multiple_base_initialization)
4950 typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
4951 typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
4953 bool CheckRedundantUnionInit(
Sema &S,
4955 RedundantUnionMap &Unions) {
4962 UnionEntry &En = Unions[Parent];
4963 if (En.first && En.first != Child) {
4965 diag::err_multiple_mem_union_initialization)
4968 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
4969 << 0 << En.second->getSourceRange();
4993 if (!ConstructorDecl)
5002 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5009 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5012 RedundantUnionMap MemberUnions;
5014 bool HadError =
false;
5015 for (
unsigned i = 0; i < MemInits.size(); i++) {
5023 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
5024 CheckRedundantUnionInit(*
this, Init, MemberUnions))
5028 if (CheckRedundantInit(*
this, Init, Members[Key]))
5033 if (MemInits.size() != 1) {
5035 diag::err_delegating_initializer_alone)
5036 << Init->
getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5052 DiagnoseUninitializedFields(*
this, Constructor);
5069 for (
auto *Field : ClassDecl->
fields()) {
5093 assert(Dtor &&
"No dtor found for FieldClassDecl!");
5095 PDiag(diag::err_access_dtor_field)
5105 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5107 llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
5110 for (
const auto &Base : ClassDecl->
bases()) {
5115 if (Base.isVirtual()) {
5116 if (!VisitVirtualBases)
5118 DirectVirtualBases.insert(RT);
5129 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5133 PDiag(diag::err_access_dtor_base)
5142 if (!VisitVirtualBases)
5146 for (
const auto &VBase : ClassDecl->
vbases()) {
5151 if (DirectVirtualBases.count(RT))
5162 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5165 PDiag(diag::err_access_dtor_vbase)
5171 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5185 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5187 DiagnoseUninitializedFields(*
this, Constructor);
5240 llvm::SmallPtrSet<const CXXMethodDecl *, 8> SeenPureMethods;
5242 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5243 MEnd = FinalOverriders.end();
5247 SOEnd = M->second.end();
5248 SO != SOEnd; ++SO) {
5255 if (SO->second.size() != 1)
5258 if (!SO->second.front().Method->isPure())
5261 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5264 Diag(SO->second.front().Method->getLocation(),
5265 diag::note_pure_virtual_function)
5266 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5276 struct AbstractUsageInfo {
5283 : S(S), Record(Record),
5284 AbstractType(S.
Context.getCanonicalType(
5285 S.
Context.getTypeDeclType(Record))),
5289 if (Invalid)
return;
5297 struct CheckAbstractUsage {
5298 AbstractUsageInfo &Info;
5301 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
5302 : Info(Info), Ctx(Ctx) {}
5306 #define ABSTRACT_TYPELOC(CLASS, PARENT)
5307 #define TYPELOC(CLASS, PARENT) \
5308 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break;
5309 #include "clang/AST/TypeLocNodes.def"
5340 #define CheckPolymorphic(Type) \
5341 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \
5342 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \
5357 return Visit(
Next, Sel);
5367 T = Info.S.Context.getBaseElementType(T);
5370 if (CT != Info.AbstractType)
return;
5374 Info.S.Diag(Ctx->getLocation(), diag::err_array_of_abstract_type)
5375 << T << TL.getSourceRange();
5377 Info.S.Diag(Ctx->getLocation(), diag::err_abstract_type_in_decl)
5378 << Sel << T << TL.getSourceRange();
5380 Info.DiagnoseAbstractType();
5386 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
5409 for (
auto *D : RD->
decls()) {
5410 if (D->isImplicit())
continue;
5413 if (isa<CXXMethodDecl>(D)) {
5415 }
else if (isa<FunctionTemplateDecl>(D)) {
5416 FunctionDecl *FD = cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
5420 }
else if (isa<FieldDecl>(D)) {
5424 }
else if (isa<VarDecl>(D)) {
5425 VarDecl *VD = cast<VarDecl>(D);
5430 }
else if (isa<CXXRecordDecl>(D)) {
5432 }
else if (isa<ClassTemplateDecl>(D)) {
5434 cast<ClassTemplateDecl>(D)->getTemplatedDecl());
5444 assert(ClassAttr->
getKind() == attr::DLLExport);
5453 for (Decl *Member : Class->
decls()) {
5458 if (Member->getAttr<DLLExportAttr>()) {
5459 if (MD->isUserProvided()) {
5470 }
else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
5471 MD->isCopyAssignmentOperator() ||
5472 MD->isMoveAssignmentOperator()) {
5501 for (Decl *Member : Class->
decls()) {
5504 if (!CD || !CD->isDefaultConstructor())
5506 auto *
Attr = CD->getAttr<DLLExportAttr>();
5519 if (LastExportedDefaultCtor) {
5521 diag::err_attribute_dll_ambiguous_default_ctor)
5523 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
5524 << CD->getDeclName();
5527 LastExportedDefaultCtor = CD;
5537 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
5538 if (
Attr *TemplateAttr =
5539 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
5540 auto *A = cast<InheritableAttr>(TemplateAttr->clone(
getASTContext()));
5541 A->setInherited(
true);
5552 << Class << ClassAttr;
5559 for (Decl *Member : Class->
decls()) {
5560 if (!isa<VarDecl>(Member) && !isa<CXXMethodDecl>(Member))
5563 if (!MemberAttr || MemberAttr->
isInherited() || Member->isInvalidDecl())
5567 diag::err_attribute_dll_member_of_dll_class)
5568 << MemberAttr << ClassAttr;
5570 Member->setInvalidDecl();
5579 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
5596 for (Decl *Member : Class->
decls()) {
5606 if (MD->isDeleted())
5609 if (MD->isInlined()) {
5619 if ((MD->isMoveAssignmentOperator() ||
5627 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->isTrivial())
5632 if (!cast<NamedDecl>(Member)->isExternallyVisible())
5638 NewAttr->setInherited(
true);
5666 NewAttr->setInherited(
true);
5667 BaseTemplateSpec->
addAttr(NewAttr);
5688 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
5693 diag::note_template_class_explicit_specialization_was_here)
5694 << BaseTemplateSpec;
5697 diag::note_template_class_instantiation_was_here)
5698 << BaseTemplateSpec;
5707 cast<CXXConstructorDecl>(MD));
5725 llvm_unreachable(
"Invalid special member.");
5739 bool HasNonDeletedCopyOrMove =
false;
5745 HasNonDeletedCopyOrMove =
true;
5752 HasNonDeletedCopyOrMove =
true;
5760 if (MD->isDeleted())
5764 if (CD && CD->isCopyOrMoveConstructor())
5765 HasNonDeletedCopyOrMove =
true;
5766 else if (!isa<CXXDestructorDecl>(MD))
5769 if (!MD->isTrivial())
5773 return HasNonDeletedCopyOrMove;
5784 AbstractUsageInfo Info(*
this, Record);
5794 bool Complained =
false;
5795 for (
const auto *F : Record->
fields()) {
5796 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
5799 if (F->getType()->isReferenceType() ||
5800 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
5807 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
5808 << F->getType()->isReferenceType()
5809 << F->getDeclName();
5828 isa<IndirectFieldDecl>(D)) {
5840 !Record->
hasAttr<FinalAttr>())
5846 if (FinalAttr *FA = Record->
getAttr<FinalAttr>()) {
5848 << FA->isSpelledAsSealed();
5853 bool HasMethodWithOverrideControl =
false,
5854 HasOverridingMethodWithoutOverrideControl =
false;
5856 for (
auto *M : Record->
methods()) {
5861 if (M->hasAttr<OverrideAttr>())
5862 HasMethodWithOverrideControl =
true;
5863 else if (M->size_overridden_methods() > 0)
5864 HasOverridingMethodWithoutOverrideControl =
true;
5866 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted())
5872 if (!M->isImplicit() && !M->isUserProvided()) {
5881 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
5882 M->hasAttr<DLLExportAttr>()) {
5887 M->dropAttr<DLLExportAttr>();
5889 if (M->hasAttr<DLLExportAttr>()) {
5897 if (HasMethodWithOverrideControl &&
5898 HasOverridingMethodWithoutOverrideControl) {
5901 for (
auto *M : Record->
methods())
5935 unsigned FieldQuals,
bool ConstRHS) {
5936 unsigned LHSQuals = 0;
5938 LHSQuals = FieldQuals;
5940 unsigned RHSQuals = FieldQuals;
5950 LHSQuals & Qualifiers::Const,
5951 LHSQuals & Qualifiers::Volatile);
5961 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
5967 : S(S), UseLoc(UseLoc) {
5968 bool DiagnosedMultipleConstructedBases =
false;
5970 UsingDecl *ConstructedBaseUsing =
nullptr;
5974 for (
auto *D : Shadow->
redecls()) {
5975 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
5976 auto *DNominatedBase = DShadow->getNominatedBaseClass();
5977 auto *DConstructedBase = DShadow->getConstructedBaseClass();
5979 InheritedFromBases.insert(
5980 std::make_pair(DNominatedBase->getCanonicalDecl(),
5981 DShadow->getNominatedBaseClassShadowDecl()));
5982 if (DShadow->constructsVirtualBase())
5983 InheritedFromBases.insert(
5984 std::make_pair(DConstructedBase->getCanonicalDecl(),
5985 DShadow->getConstructedBaseClassShadowDecl()));
5987 assert(DNominatedBase == DConstructedBase);
5992 if (!ConstructedBase) {
5993 ConstructedBase = DConstructedBase;
5994 ConstructedBaseUsing = D->getUsingDecl();
5995 }
else if (ConstructedBase != DConstructedBase &&
5997 if (!DiagnosedMultipleConstructedBases) {
5998 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
6001 diag::note_ambiguous_inherited_constructor_using)
6003 DiagnosedMultipleConstructedBases =
true;
6005 S.
Diag(D->getUsingDecl()->getLocation(),
6006 diag::note_ambiguous_inherited_constructor_using)
6007 << DConstructedBase;
6011 if (DiagnosedMultipleConstructedBases)
6018 std::pair<CXXConstructorDecl *, bool>
6021 if (It == InheritedFromBases.end())
6022 return std::make_pair(
nullptr,
false);
6026 return std::make_pair(
6028 It->second->constructsVirtualBase());
6031 return std::make_pair(Ctor,
false);
6045 if (InheritedCtor) {
6048 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
6050 return BaseCtor->isConstexpr();
6114 if (Ctor && ClassDecl->
isUnion())
6133 for (
const auto &B : ClassDecl->
bases()) {
6135 if (!BaseType)
continue;
6139 InheritedCtor, Inherited))
6150 for (
const auto *F : ClassDecl->
fields()) {
6151 if (F->isInvalidDecl())
6157 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
6160 ConstArg && !F->isMutable()))
6182 auto *CD = cast<CXXConstructorDecl>(MD);
6183 assert(CD->getInheritedConstructor() &&
6184 "only special members have implicit exception specs");
6186 S, Loc, CD->getInheritedConstructor().getShadowDecl());
6213 auto ESI = IES.getExceptionSpec();
6232 "not an explicitly-defaulted special member");
6238 bool HadError =
false;
6247 unsigned ExpectedParams = 1;
6265 bool CanHaveConstParam =
false;
6278 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
6293 bool HasConstParam =
false;
6301 diag::err_defaulted_special_member_volatile_param) << CSM;
6305 if (HasConstParam && !CanHaveConstParam) {
6308 diag::err_defaulted_special_member_copy_const_param)
6313 diag::err_defaulted_special_member_move_const_param)
6318 }
else if (ExpectedParams) {
6336 : isa<CXXConstructorDecl>(MD)) &&
6339 Diag(MD->
getLocStart(), diag::err_incorrect_defaulted_constexpr) << CSM;
6373 llvm::makeArrayRef(&ArgType,
6385 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
6418 PDiag(diag::err_incorrect_defaulted_exception_spec)
6433 for (
auto &Check : Checks)
6438 for (
auto &Spec : Specs)
6445 template<
typename Derived>
6446 struct SpecialMemberVisitor {
6453 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
6457 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
6462 IsConstructor =
true;
6466 IsAssignment =
true;
6471 llvm_unreachable(
"invalid special member kind");
6477 ConstArg = RT->getPointeeType().isConstQualified();
6481 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
6484 bool isMove()
const {
6490 unsigned Quals,
bool IsMutable) {
6492 ConstArg && !IsMutable);
6502 cast<CXXConstructorDecl>(MD)->getInheritedConstructor().getConstructor();
6509 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
6516 return B->getBaseTypeLoc();
6518 return Subobj.get<
FieldDecl*>()->getLocation();
6523 VisitNonVirtualBases,
6528 VisitPotentiallyConstructedBases,
6534 bool visit(BasesToVisit Bases) {
6537 if (Bases == VisitPotentiallyConstructedBases)
6538 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
6540 for (
auto &B : RD->
bases())
6541 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
6542 getDerived().visitBase(&B))
6545 if (Bases == VisitAllBases)
6546 for (
auto &B : RD->
vbases())
6547 if (getDerived().visitBase(&B))
6550 for (
auto *F : RD->
fields())
6551 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
6552 getDerived().visitField(F))
6561 struct SpecialMemberDeletionInfo
6562 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
6567 bool AllFieldsAreConst;
6572 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
6573 Loc(MD->getLocation()), AllFieldsAreConst(
true) {}
6581 bool visitBase(
CXXBaseSpecifier *Base) {
return shouldDeleteForBase(Base); }
6582 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
6585 bool shouldDeleteForField(
FieldDecl *FD);
6586 bool shouldDeleteForAllConstMembers();
6588 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
6590 bool shouldDeleteForSubobjectCall(Subobject Subobj,
6592 bool IsDtorCallInCtor);
6600 bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
6620 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
6622 bool IsDtorCallInCtor) {
6629 DiagKind = !Decl ? 0 : 1;
6632 else if (!isAccessible(Subobj, Decl))
6650 diag::note_deleted_special_member_class_subobject)
6651 << getEffectiveCSM() << MD->
getParent() <<
true
6652 << Field << DiagKind << IsDtorCallInCtor;
6656 diag::note_deleted_special_member_class_subobject)
6657 << getEffectiveCSM() << MD->
getParent() <<
false
6658 << Base->
getType() << DiagKind << IsDtorCallInCtor;
6671 bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
6674 bool IsMutable = Field && Field->
isMutable();
6692 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
6699 if (IsConstructor) {
6702 false,
false,
false,
false,
false);
6703 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
6712 bool SpecialMemberDeletionInfo::shouldDeleteForBase(
CXXBaseSpecifier *Base) {
6721 if (
auto *BaseCtor = SMOR.
getMethod()) {
6726 if (BaseCtor->isDeleted() && Diagnose) {
6728 diag::note_deleted_special_member_class_subobject)
6729 << getEffectiveCSM() << MD->
getParent() <<
false
6730 << Base->
getType() << 1 <<
false;
6733 return BaseCtor->isDeleted();
6735 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
6740 bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
6749 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
6750 << !!ICI << MD->
getParent() << FD << FieldType << 0;
6761 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
6767 AllFieldsAreConst =
false;
6773 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
6777 }
else if (IsAssignment) {
6782 << isMove() << MD->
getParent() << FD << FieldType << 0;
6797 if (!inUnion() && FieldRecord->
isUnion() &&
6799 bool AllVariantFieldsAreConst =
true;
6802 for (
auto *UI : FieldRecord->
fields()) {
6806 AllVariantFieldsAreConst =
false;
6809 if (UnionFieldRecord &&
6810 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
6820 diag::note_deleted_default_ctor_all_const)
6830 if (shouldDeleteForClassSubobject(FieldRecord, FD,
6841 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
6845 bool AnyFields =
false;
6847 if ((AnyFields = !F->isUnnamedBitfield()))
6853 diag::note_deleted_default_ctor_all_const)
6902 bool DeletesOnlyMatchingCopy =
6908 if (!Diagnose)
return true;
6911 for (
auto *
I : RD->
ctors()) {
6912 if (
I->isMoveConstructor()) {
6913 UserDeclaredMove =
I;
6917 assert(UserDeclaredMove);
6920 if (!Diagnose)
return true;
6924 if (
I->isMoveAssignmentOperator()) {
6925 UserDeclaredMove =
I;
6929 assert(UserDeclaredMove);
6932 if (UserDeclaredMove) {
6934 diag::note_deleted_copy_user_declared_move)
6952 OperatorDelete,
false)) {
6959 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
6967 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
6968 : SMI.VisitPotentiallyConstructedBases))
6971 if (SMI.shouldDeleteForAllConstMembers())
6996 *Selected =
nullptr;
7000 llvm_unreachable(
"not a special member");
7018 for (
auto *CI : RD->
ctors()) {
7019 if (!CI->isDefaultConstructor())
7026 *Selected = DefCtor;
7055 }
else if (!Selected) {
7063 goto NeedOverloadResolution;
7073 }
else if (!Selected) {
7078 goto NeedOverloadResolution;
7082 NeedOverloadResolution:
7106 llvm_unreachable(
"unknown special method kind");
7110 for (
auto *CI : RD->
ctors())
7111 if (!CI->isImplicit())
7115 typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
7118 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
7148 ConstRHS, Diagnose ? &Selected :
nullptr))
7156 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
7159 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
7160 }
else if (!Selected)
7161 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
7166 << Kind << SubType.getUnqualifiedType() << CSM;
7168 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
7169 << Kind << SubType.getUnqualifiedType() << CSM;
7174 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
7175 << Kind << SubType.getUnqualifiedType() << CSM;
7189 bool ConstArg,
bool Diagnose) {
7190 for (
const auto *FI : RD->
fields()) {
7191 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
7197 if (FI->isAnonymousStructOrUnion()) {
7199 CSM, ConstArg, Diagnose))
7210 S.
Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI;
7220 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
7225 bool ConstRHS = ConstArg && !FI->isMutable();
7253 bool ConstArg =
false;
7298 llvm_unreachable(
"not a special member");
7304 diag::note_nontrivial_default_arg)
7323 for (
const auto &BI : RD->bases())
7359 if (RD->getNumVBases()) {
7369 for (
const auto *MI : RD->methods()) {
7370 if (MI->isVirtual()) {
7372 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
7377 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
7385 struct FindHiddenVirtualMethod {
7388 llvm::SmallPtrSet<const CXXMethodDecl *, 8> OverridenAndUsingBaseMethods;
7393 static bool CheckMostOverridenMethods(
7395 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
7401 if (CheckMostOverridenMethods(*
I, Methods))
7417 bool foundSameNameMethod =
false;
7424 foundSameNameMethod =
true;
7441 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
7442 overloadedMethods.push_back(MD);
7446 if (foundSameNameMethod)
7447 OverloadedMethods.append(overloadedMethods.begin(),
7448 overloadedMethods.end());
7449 return foundSameNameMethod;
7456 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
7475 FindHiddenVirtualMethod FHVM;
7486 ND = shad->getTargetDecl();
7492 OverloadedMethods = FHVM.OverloadedMethods;
7497 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
7500 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
7517 if (!OverloadedMethods.empty()) {
7519 << MD << (OverloadedMethods.size() > 1);
7536 if (l->getKind() != AttributeList::AT_Visibility)
7539 Diag(l->getLoc(), diag::warn_attribute_after_definition_ignored) <<
7639 D = TD->getTemplatedDecl();
7641 if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
7642 ParameterLists.push_back(PSD->getTemplateParameters());
7645 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
7646 ParameterLists.push_back(DD->getTemplateParameterList(i));
7650 ParameterLists.push_back(FTD->getTemplateParameters());
7654 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
7655 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
7656 ParameterLists.push_back(TD->getTemplateParameterList(i));
7660 ParameterLists.push_back(CTD->getTemplateParameters());
7666 if (Params->size() > 0)
7671 if (Param->getDeclName()) {
7682 if (!RecordD)
return;
7689 if (!RecordD)
return;
7864 const char *ConstRef
7867 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
7918 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
7921 if (TST->isTypeAlias())
7923 << DeclaratorType << 1;
8092 bool NeedsTypedef =
false;
8096 bool PastFunctionChunk =
false;
8098 switch (Chunk.Kind) {
8100 if (!PastFunctionChunk) {
8101 if (Chunk.Fun.HasTrailingReturnType) {
8106 PastFunctionChunk =
true;
8111 NeedsTypedef =
true;
8133 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
8134 DB << Before <<
After;
8136 if (!NeedsTypedef) {
8140 if (After.isInvalid() && ConvTSI) {
8188 diag::warn_cxx98_compat_explicit_conversion_functions :
8189 diag::ext_explicit_conversion_functions)
8198 assert(Conversion &&
"Expected to receive a conversion function declaration");
8216 ConvType = ConvTypeRef->getPointeeType();
8220 else if (ConvType->isRecordType()) {
8222 if (ConvType == ClassType)
8227 << ClassType << ConvType;
8228 }
else if (ConvType->isVoidType()) {
8230 << ClassType << ConvType;
8235 return ConversionTemplate;
8243 struct BadSpecifierDiagnoser {
8246 ~BadSpecifierDiagnoser() {
8250 template<
typename T>
void check(
SourceLocation SpecLoc, T Spec) {
8254 return check(SpecLoc,
8260 if (!Specifiers.empty()) Specifiers +=
" ";
8266 std::string Specifiers;
8278 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
8286 << GuidedTemplateDecl;
8287 Diag(GuidedTemplateDecl->
getLocation(), diag::note_template_decl_here);
8292 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
8293 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
8294 DS.isNoreturnSpecified() || DS.isConstexprSpecified() ||
8295 DS.isConceptSpecified()) {
8296 BadSpecifierDiagnoser Diagnoser(
8298 diag::err_deduction_guide_invalid_specifier);
8300 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
8305 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
8306 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
8307 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
8308 Diagnoser.check(DS.getConceptSpecLoc(),
"concept");
8309 DS.ClearConstexprSpec();
8310 DS.ClearConceptSpec();
8312 Diagnoser.check(DS.getConstSpecLoc(),
"const");
8313 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
8314 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
8315 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
8316 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
8317 DS.ClearTypeQualifiers();
8319 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
8320 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
8321 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
8322 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
8323 DS.ClearTypeSpecType();
8330 bool FoundFunction =
false;
8336 diag::err_deduction_guide_with_complex_decl)
8340 if (!Chunk.Fun.hasTrailingReturnType()) {
8342 diag::err_deduction_guide_no_trailing_return_type);
8348 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
8351 assert(TSI &&
"deduction guide has valid type but invalid return type?");
8352 bool AcceptableReturnType =
false;
8353 bool MightInstantiateToSpecialization =
false;
8356 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
8357 bool TemplateMatches =
8360 AcceptableReturnType =
true;
8365 MightInstantiateToSpecialization = !(TD && isa<ClassTemplateDecl>(TD) &&
8369 MightInstantiateToSpecialization =
true;
8372 if (!AcceptableReturnType) {
8374 diag::err_deduction_guide_bad_trailing_return_type)
8375 << GuidedTemplate << TSI->
getType() << MightInstantiateToSpecialization
8381 FoundFunction =
true;
8398 assert(*IsInline != PrevNS->
isInline());
8406 if (*IsInline && II && II->
getName().startswith(
"__atomic") &&
8411 NS->setInline(*IsInline);
8414 for (
auto *
I : PrevNS->
decls())
8415 if (
auto *ND = dyn_cast<NamedDecl>(
I))
8423 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
8426 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
8445 bool IsInline = InlineLoc.
isValid();
8446 bool IsInvalid =
false;
8448 bool AddToKnown =
false;
8468 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
8472 if (IsInline != PrevNS->
isInline())
8475 }
else if (PrevDecl) {
8477 Diag(Loc, diag::err_redefinition_different_kind)
8479 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
8482 }
else if (II->
isStr(
"std") &&
8488 AddToKnown = !IsInline;
8491 AddToKnown = !IsInline;
8505 if (PrevNS && IsInline != PrevNS->
isInline())
8511 StartLoc, Loc, II, PrevNS);
8519 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
8525 KnownNamespaces[Namespc] =
false;
8533 TU->setAnonymousNamespace(Namespc);
8535 cast<NamespaceDecl>(Parent)->setAnonymousNamespace(Namespc);
8584 return AD->getNamespace();
8585 return dyn_cast_or_null<NamespaceDecl>(D);
8591 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
8592 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
8595 if (Namespc->
hasAttr<VisibilityAttr>())
8600 return cast_or_null<CXXRecordDecl>(
8609 return cast_or_null<NamespaceDecl>(
8621 Result.suppressDiagnostics();
8646 "Looking for std::initializer_list outside of C++.");
8661 if (!Specialization)
8668 Template = dyn_cast_or_null<ClassTemplateDecl>(
8669 TST->getTemplateName().getAsTemplateDecl());
8670 Arguments = TST->getArgs();
8688 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
8707 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
8714 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
8719 Result.suppressDiagnostics();
8722 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
8730 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
8731 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
8774 case Decl::TranslationUnit:
8776 case Decl::LinkageSpec:
8788 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
8790 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
8804 llvm::make_unique<NamespaceValidatorCCC>(),
8807 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
8808 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
8809 Ident->
getName().equals(CorrectedStr);
8811 S.
PDiag(diag::err_using_directive_member_suggest)
8812 << Ident << DC << DroppedSpecifier << SS.getRange(),
8813 S.
PDiag(diag::note_namespace_defined_here));
8816 S.
PDiag(diag::err_using_directive_suggest) << Ident,
8817 S.
PDiag(diag::note_namespace_defined_here));
8819 R.
addDecl(Corrected.getFoundDecl());
8832 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
8833 assert(NamespcName &&
"Invalid NamespcName.");
8834 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
8857 NamespcName->
isStr(
"std")) {
8858 Diag(IdentLoc, diag::ext_using_undefined_std);
8869 assert(NS &&
"expected namespace decl");
8886 DeclContext *CommonAncestor = cast<DeclContext>(NS);
8888 CommonAncestor = CommonAncestor->
getParent();
8892 IdentLoc, Named, CommonAncestor);
8896 Diag(IdentLoc, diag::warn_using_directive_in_header);
8901 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
8952 diag::warn_cxx98_compat_using_decl_constructor :
8953 diag::err_using_decl_constructor)
8971 llvm_unreachable(
"cannot parse qualified deduction guide name");
8983 : diag::warn_access_decl_deprecated)
8994 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
9002 SS, TargetNameInfo, EllipsisLoc, AttrList,
9020 return Context.
hasSameType(TD1->getUnderlyingType(),
9021 TD2->getUnderlyingType());
9055 if (isa<EnumDecl>(OrigDC)) OrigDC = OrigDC->
getParent();
9060 if (cast<CXXRecordDecl>(
CurContext)->isProvablyNotDerivedFrom(OrigRec)) {
9063 diag::err_using_decl_nested_name_specifier_is_current_class)
9071 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9081 if (Previous.
empty())
return false;
9084 if (isa<UsingShadowDecl>(Target))
9085 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
9092 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
9093 bool FoundEquivalentDecl =
false;
9100 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D))
9105 PrevShadow = Shadow;
9106 FoundEquivalentDecl =
true;
9110 FoundEquivalentDecl =
true;
9114 (isa<TagDecl>(D) ? Tag : NonTag) = D;
9117 if (FoundEquivalentDecl)
9152 if (isa<TagDecl>(Target)) {
9154 if (!Tag)
return false;
9158 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
9164 if (!NonTag)
return false;
9177 for (
auto &B : Derived->
bases())
9178 if (B.getType()->getAsCXXRecordDecl() == Base)
9179 return B.isVirtual();
9180 llvm_unreachable(
"not a direct base class");
9190 if (isa<UsingShadowDecl>(Target)) {
9191 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
9192 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
9196 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
9197 NonTemplateTarget = TargetTD->getTemplatedDecl();
9200 if (isa<CXXConstructorDecl>(NonTemplateTarget)) {
9201 bool IsVirtualBase =
9257 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
9278 bool &AnyDependentBases) {
9281 for (
auto &Base : Derived->
bases()) {
9283 if (CanonicalDesiredBase == BaseType)
9285 if (BaseType->isDependentType())
9286 AnyDependentBases =
true;
9294 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
9296 : HasTypenameKeyword(HasTypenameKeyword),
9297 IsInstantiation(IsInstantiation), OldNNS(NNS),
9298 RequireMemberOf(RequireMemberOf) {}
9300 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
9304 if (!ND || isa<NamespaceDecl>(ND))
9314 if (RequireMemberOf) {
9316 if (FoundRecord && FoundRecord->isInjectedClassName()) {
9337 bool AnyDependentBases =
false;
9340 AnyDependentBases) &&
9352 if (FoundRecord && FoundRecord->isInjectedClassName())
9356 if (isa<TypeDecl>(ND))
9357 return HasTypenameKeyword || !IsInstantiation;
9359 return !HasTypenameKeyword;
9363 bool HasTypenameKeyword;
9364 bool IsInstantiation;
9377 bool HasTypenameKeyword,
9383 bool IsInstantiation) {
9384 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
9386 assert(IdentLoc.isValid() &&
"Invalid TargetName location.");
9395 if (
auto *RD = dyn_cast<CXXRecordDecl>(
CurContext))
9422 assert(IsInstantiation &&
"no scope in non-instantiation");
9444 SS, IdentLoc, Previous))
9455 if (!LookupContext || EllipsisLoc.
isValid()) {
9456 if (HasTypenameKeyword) {
9459 UsingLoc, TypenameLoc,
9465 QualifierLoc, NameInfo, EllipsisLoc);
9472 auto Build = [&](
bool Invalid) {
9475 UsingName, HasTypenameKeyword);
9481 auto BuildInvalid = [&]{
return Build(
true); };
9482 auto BuildValid = [&]{
return Build(
false); };
9485 return BuildInvalid();
9494 if (!IsInstantiation)
9519 isa<TranslationUnitDecl>(LookupContext) &&
9524 llvm::make_unique<UsingValidatorCCC>(
9525 HasTypenameKeyword, IsInstantiation, SS.getScopeRep(),
9531 << NameInfo.
getName() << LookupContext << 0
9536 NamedDecl *ND = Corrected.getCorrectionDecl();
9538 return BuildInvalid();
9544 RD = cast<CXXRecordDecl>(RD->
getParent());
9547 if (Corrected.WillReplaceSpecifier()) {
9556 auto *CurClass = cast<CXXRecordDecl>(
CurContext);
9559 UsingName.setNamedTypeInfo(
nullptr);
9566 UsingName.setName(ND->getDeclName());
9570 Diag(IdentLoc, diag::err_no_member)
9571 << NameInfo.
getName() << LookupContext << SS.getRange();
9572 return BuildInvalid();
9577 return BuildInvalid();
9579 if (HasTypenameKeyword) {
9582 Diag(IdentLoc, diag::err_using_typename_non_type);
9584 Diag((*I)->getUnderlyingDecl()->getLocation(),
9585 diag::note_using_decl_target);
9586 return BuildInvalid();
9593 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
9595 return BuildInvalid();
9602 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
9604 return BuildInvalid();
9610 if (cast<EnumDecl>(ED->getDeclContext())->isScoped()) {
9611 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
9613 return BuildInvalid();
9620 if (UsingName.getName().getNameKind() ==
9640 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
9641 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
9642 isa<UsingPackDecl>(InstantiatedFrom));
9646 UPD->setAccess(InstantiatedFrom->
getAccess());
9653 assert(!UD->
hasTypename() &&
"expecting a constructor name");
9656 assert(SourceType &&
9657 "Using decl naming constructor doesn't have type in scope spec.");
9661 bool AnyDependentBases =
false;
9664 if (!Base && !AnyDependentBases) {
9666 diag::err_using_decl_constructor_not_in_direct_base)
9668 <<
QualType(SourceType, 0) << TargetClass;
9683 bool HasTypenameKeyword,
9703 for (
auto *D : Prev) {
9704 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
9705 bool OldCouldBeEnumerator =
9706 isa<UnresolvedUsingValueDecl>(D) || isa<EnumConstantDecl>(D);
9708 OldCouldBeEnumerator ? diag::err_redefinition
9709 : diag::err_redefinition_different_kind)
9710 << Prev.getLookupName();
9724 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
9725 DTypename = UD->hasTypename();
9726 DQual = UD->getQualifier();
9728 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
9730 DQual = UD->getQualifier();
9732 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
9734 DQual = UD->getQualifier();
9739 if (HasTypenameKeyword != DTypename)
continue;
9748 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
9775 if ((HasTypename && !NamedContext) ||
9777 auto *RD = NamedContext
9783 Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member)
9809 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
9825 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
9840 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
9854 if (!NamedContext) {
9868 diag::err_using_decl_nested_name_specifier_is_not_class)
9883 if (cast<CXXRecordDecl>(
CurContext)->isProvablyNotDerivedFrom(
9884 cast<CXXRecordDecl>(NamedContext))) {
9887 diag::err_using_decl_nested_name_specifier_is_current_class)
9892 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
9894 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9918 llvm::SmallPtrSet<const CXXRecordDecl *, 4> Bases;
9925 if (!cast<CXXRecordDecl>(
CurContext)->forallBases(Collect))
9931 return !Bases.count(Base);
9936 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
9937 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
9941 diag::err_using_decl_nested_name_specifier_is_not_base_class)
9956 Decl *DeclFromDeclSpec) {
9961 "got alias-declaration outside of declaration scope");
9966 bool Invalid =
false;
9992 "name in alias declaration must be an identifier");
10008 bool Redeclaration =
false;
10011 if (TemplateParamLists.size()) {
10015 if (TemplateParamLists.size() != 1) {
10016 Diag(UsingLoc, diag::err_alias_template_extra_headers)
10017 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
10018 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
10029 if (!Previous.
empty()) {
10030 Redeclaration =
true;
10033 if (!OldDecl && !Invalid) {
10034 Diag(UsingLoc, diag::err_redefinition_different_kind)
10089 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
10117 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
10149 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
10151 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
10152 << AD->getNamespace();
10157 ? diag::err_redefinition
10158 : diag::err_redefinition_different_kind;
10159 Diag(AliasLoc, DiagID) << Alias;
10180 struct SpecialMemberExceptionSpecInfo
10181 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
10189 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
10194 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
10197 void visitSubobjectCall(Subobject Subobj,
10207 auto *BaseClass = cast<CXXRecordDecl>(RT->getDecl());
10209 if (
auto *BaseCtor = SMOR.getMethod()) {
10210 visitSubobjectCall(Base, BaseCtor);
10214 visitClassSubobject(BaseClass, Base, 0);
10218 bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
10229 ExceptSpec.CalledExpr(E);
10231 ->getAs<RecordType>()) {
10232 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
10238 void SpecialMemberExceptionSpecInfo::visitClassSubobject(
CXXRecordDecl *Class,
10242 bool IsMutable = Field && Field->
isMutable();
10243 visitSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable));
10246 void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
10251 ExceptSpec.CalledDecl(getSubobjectLoc(Subobj), MD);
10263 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, Loc);
10265 return Info.ExceptSpec;
10282 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
10283 : Info.VisitAllBases);
10285 return Info.ExceptSpec;
10290 struct DeclaringSpecialMember {
10294 bool WasAlreadyBeingDeclared;
10297 : S(S), D(RD, CSM), SavedContext(S, RD) {
10299 if (WasAlreadyBeingDeclared)
10320 ~DeclaringSpecialMember() {
10321 if (!WasAlreadyBeingDeclared) {
10328 bool isAlreadyBeingDeclared()
const {
10329 return WasAlreadyBeingDeclared;
10358 "Should not build implicit default constructor!");
10361 if (DSM.isAlreadyBeingDeclared())
10377 nullptr,
false,
true,
10408 ClassDecl->
addDecl(DefaultCon);
10418 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
10423 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
10448 L->CompletedImplicitDefinition(Constructor);
10451 DiagnoseUninitializedFields(*
this, Constructor);
10477 ->getInheritedConstructor()
10480 return cast<CXXConstructorDecl>(Ctor);
10495 false, BaseCtor, &ICI);
10509 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
10519 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
10526 ParamDecls.push_back(PD);
10531 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
10534 Derived->
addDecl(DerivedCtor);
10539 return DerivedCtor;
10588 for (
bool VBase : {
false,
true}) {
10590 if (B.isVirtual() != VBase)
10593 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
10598 if (!BaseCtor.first)
10603 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
10607 Context, TInfo, VBase, InitLoc, Init.
get(), InitLoc,
10624 L->CompletedImplicitDefinition(Constructor);
10627 DiagnoseUninitializedFields(*
this, Constructor);
10637 DeclaringSpecialMember DSM(*
this, ClassDecl,
CXXDestructor);
10638 if (DSM.isAlreadyBeingDeclared())
10686 ClassDecl->
addDecl(Destructor);
10696 "DefineImplicitDestructor - call it for implicit default dtor");
10701 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
10729 L->CompletedImplicitDefinition(Destructor);
10765 "adjusting dtor exception specs was introduced in c++11");
10772 getAs<FunctionProtoType>();
10795 class ExprBuilder {
10796 ExprBuilder(
const ExprBuilder&) =
delete;
10797 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
10800 static Expr *assertNotNull(
Expr *E) {
10801 assert(E &&
"Expression construction must not fail.");
10807 virtual ~ExprBuilder() {}
10812 class RefBuilder:
public ExprBuilder {
10822 : Var(Var), VarType(VarType) {}
10825 class ThisBuilder:
public ExprBuilder {
10832 class CastBuilder:
public ExprBuilder {
10841 CK_UncheckedDerivedToBase,
Kind,
10847 : Builder(Builder), Type(Type), Kind(Kind), Path(Path) {}
10850 class DerefBuilder:
public ExprBuilder {
10855 return assertNotNull(
10859 DerefBuilder(
const ExprBuilder &
Builder) : Builder(Builder) {}
10862 class MemberBuilder:
public ExprBuilder {
10873 nullptr, MemberLookup,
nullptr,
nullptr).
get());
10878 : Builder(Builder), Type(Type), IsArrow(IsArrow),
10879 MemberLookup(MemberLookup) {}
10882 class MoveCastBuilder:
public ExprBuilder {
10890 MoveCastBuilder(
const ExprBuilder &
Builder) : Builder(Builder) {}
10893 class LvalueConvBuilder:
public ExprBuilder {
10898 return assertNotNull(
10902 LvalueConvBuilder(
const ExprBuilder &
Builder) : Builder(Builder) {}
10905 class SubscriptBuilder:
public ExprBuilder {
10906 const ExprBuilder &Base;
10907 const ExprBuilder &Index;
10912 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
10915 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
10916 : Base(Base), Index(Index) {}
10927 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
10936 Expr *From = FromB.build(S, Loc);
10940 Expr *To = ToB.build(S, Loc);
10946 bool NeedsCollectableMemCpy =
10950 StringRef MemCpyName = NeedsCollectableMemCpy ?
10951 "__builtin_objc_memmove_collectable" :
10952 "__builtin_memcpy";
10965 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
10967 Expr *CallArgs[] = {
10971 Loc, CallArgs, Loc);
10973 assert(!Call.
isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
11006 const ExprBuilder &To,
const ExprBuilder &From,
11007 bool CopyingBaseSubobject,
bool Copying,
11008 unsigned Depth = 0) {
11024 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
11039 if (Method->isCopyAssignmentOperator() ||
11040 (!Copying && Method->isMoveAssignmentOperator()))
11059 if (CopyingBaseSubobject) {
11090 Expr *FromInst = From.build(S, Loc);
11093 Loc, FromInst, Loc);
11113 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
11133 llvm::raw_svector_ostream OS(Str);
11134 OS <<
"__i" <<
Depth;
11138 IterationVarName, SizeType,
11147 RefBuilder IterationVarRef(IterationVar, SizeType);
11148 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
11154 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
11155 MoveCastBuilder FromIndexMove(FromIndexCopy);
11156 const ExprBuilder *FromIndex;
11158 FromIndex = &FromIndexCopy;
11160 FromIndex = &FromIndexMove;
11162 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
11167 ToIndex, *FromIndex, CopyingBaseSubobject,
11168 Copying,
Depth + 1);
11170 if (Copy.isInvalid() || !Copy.get())
11189 Loc, Loc, InitStmt,
11196 const ExprBuilder &To,
const ExprBuilder &From,
11197 bool CopyingBaseSubobject,
bool Copying) {
11204 CopyingBaseSubobject,
11209 if (!Result.isInvalid() && !Result.get())
11223 if (DSM.isAlreadyBeingDeclared())
11264 ClassLoc, ClassLoc,
11286 ClassDecl->
addDecl(CopyAssignment);
11288 return CopyAssignment;
11302 if (RD->hasUserDeclaredDestructor()) {
11303 UserDeclaredOperation = RD->getDestructor();
11304 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
11305 RD->hasUserDeclaredCopyConstructor() &&
11308 for (
auto *
I : RD->ctors()) {
11309 if (
I->isCopyConstructor()) {
11310 UserDeclaredOperation =
I;
11314 assert(UserDeclaredOperation);
11315 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
11316 RD->hasUserDeclaredCopyAssignment() &&
11319 for (
auto *
I : RD->methods()) {
11320 if (
I->isCopyAssignmentOperator()) {
11321 UserDeclaredOperation =
I;
11325 assert(UserDeclaredOperation);
11328 if (UserDeclaredOperation) {
11330 diag::warn_deprecated_copy_operation)
11331 << RD << !isa<CXXConstructorDecl>(CopyOp)
11332 << isa<CXXDestructorDecl>(UserDeclaredOperation);
11343 "DefineImplicitCopyAssignment called for wrong function");
11397 RefBuilder OtherRef(Other, OtherRefType);
11403 bool Invalid =
false;
11404 for (
auto &Base : ClassDecl->
bases()) {
11414 BasePath.push_back(&Base);
11422 DerefBuilder DerefThis(This);
11423 CastBuilder To(DerefThis,
11439 Statements.push_back(Copy.
getAs<
Expr>());
11443 for (
auto *Field : ClassDecl->
fields()) {
11456 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
11466 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
11480 "Incomplete array type is not valid");
11489 MemberLookup.resolveKind();
11491 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
11506 Statements.push_back(Copy.
getAs<
Stmt>());
11514 if (Return.isInvalid())
11517 Statements.push_back(Return.getAs<
Stmt>());
11530 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
11536 L->CompletedImplicitDefinition(CopyAssignOperator);
11544 if (DSM.isAlreadyBeingDeclared())
11585 ClassLoc, ClassLoc,
11609 ClassDecl->
addDecl(MoveAssignment);
11611 return MoveAssignment;
11630 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
11633 for (
auto &BI : Class->
bases()) {
11634 Worklist.push_back(&BI);
11635 while (!Worklist.empty()) {
11668 if (Existing && Existing != &BI) {
11669 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
11672 << (Base->getCanonicalDecl() ==
11675 S.
Diag(BI.getLocStart(), diag::note_vbase_moved_here)
11676 << (Base->getCanonicalDecl() ==
11677 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
11681 Existing =
nullptr;
11691 for (
auto &BI : Base->
bases())
11692 Worklist.push_back(&BI);
11705 "DefineImplicitMoveAssignment called for wrong function");
11743 getAs<RValueReferenceType>()->getPointeeType();
11745 "Bad argument type of defaulted move assignment");
11753 RefBuilder OtherRef(Other, OtherRefType);
11755 MoveCastBuilder MoveOther(OtherRef);
11761 bool Invalid =
false;
11762 for (
auto &Base : ClassDecl->
bases()) {
11780 BasePath.push_back(&Base);
11784 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
11787 DerefBuilder DerefThis(This);
11790 CastBuilder To(DerefThis,
11806 Statements.push_back(Move.
getAs<
Expr>());
11810 for (
auto *Field : ClassDecl->
fields()) {
11823 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
11833 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
11847 "Incomplete array type is not valid");
11855 MemberLookup.resolveKind();
11856 MemberBuilder From(MoveOther, OtherRefType,
11857 false, MemberLookup);
11859 true, MemberLookup);
11861 assert(!From.build(*
this, Loc)->isLValue() &&
11862 "Member reference with rvalue base must be rvalue except for reference "
11863 "members, which aren't allowed for move assignment.");
11870 if (Move.isInvalid()) {
11876 Statements.push_back(Move.getAs<
Stmt>());
11885 if (Return.isInvalid())
11888 Statements.push_back(Return.getAs<
Stmt>());
11901 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
11907 L->CompletedImplicitDefinition(MoveAssignOperator);
11919 if (DSM.isAlreadyBeingDeclared())
11963 ClassLoc, ClassLoc,
11987 ClassDecl->
addDecl(CopyConstructor);
11989 return CopyConstructor;
11998 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
12003 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
12036 L->CompletedImplicitDefinition(CopyConstructor);
12045 if (DSM.isAlreadyBeingDeclared())
12086 ClassLoc, ClassLoc,
12110 ClassDecl->
addDecl(MoveConstructor);
12112 return MoveConstructor;
12121 "DefineImplicitMoveConstructor - call it for implicit move ctor");
12126 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
12147 Loc, Loc,
None,
false).getAs<Stmt>());
12152 L->CompletedImplicitDefinition(MoveConstructor);
12179 void *InsertPos =
nullptr;
12180 FunctionDecl *CallOpSpec = CallOpTemplate->findSpecialization(
12181 DeducedTemplateArgs->
asArray(),
12183 assert(CallOpSpec &&
12184 "Conversion operator must have a corresponding call operator");
12185 CallOp = cast<CXXMethodDecl>(CallOpSpec);
12199 assert(DeducedTemplateArgs &&
12200 "Must have deduced template arguments from Conversion Operator");
12203 void *InsertPos =
nullptr;
12205 DeducedTemplateArgs->
asArray(),
12207 assert(InvokeSpec &&
12208 "Must have a corresponding static invoker specialization");
12209 Invoker = cast<CXXMethodDecl>(InvokeSpec);
12214 assert(FunctionRef &&
"Can't refer to __invoke function?");
12230 L->CompletedImplicitDefinition(Conv);
12231 L->CompletedImplicitDefinition(Invoker);
12259 CK_CopyAndAutoreleaseBlockObject,
12263 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12272 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
12278 Stmt *ReturnS = Return.
get();
12286 L->CompletedImplicitDefinition(Conv);
12293 switch (Args.size()) {
12298 if (!Args[1]->isDefaultArgument())
12303 return !Args[0]->isDefaultArgument();
12314 bool HadMultipleCandidates,
12315 bool IsListInitialization,
12316 bool IsStdInitListInitialization,
12317 bool RequiresZeroInit,
12318 unsigned ConstructKind,
12320 bool Elidable =
false;
12334 Expr *SubExpr = ExprArgs[0];
12340 FoundDecl, Constructor,
12341 Elidable, ExprArgs, HadMultipleCandidates,
12342 IsListInitialization,
12343 IsStdInitListInitialization, RequiresZeroInit,
12344 ConstructKind, ParenRange);
12353 bool HadMultipleCandidates,
12354 bool IsListInitialization,
12355 bool IsStdInitListInitialization,
12356 bool RequiresZeroInit,
12357 unsigned ConstructKind,
12359 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
12366 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
12367 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
12368 RequiresZeroInit, ConstructKind, ParenRange);
12378 bool HadMultipleCandidates,
12379 bool IsListInitialization,
12380 bool IsStdInitListInitialization,
12381 bool RequiresZeroInit,
12382 unsigned ConstructKind,
12387 "given constructor for wrong type");
12393 Context, DeclInitType, ConstructLoc, Constructor, Elidable,
12394 ExprArgs, HadMultipleCandidates, IsListInitialization,
12395 IsStdInitListInitialization, RequiresZeroInit,
12396 static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
12426 "more than two lookup results for field name");
12429 assert(isa<CXXRecordDecl>(Lookup[0]) &&
12430 "cannot have other non-field member with same name");
12431 for (
auto L : Lookup)
12432 if (isa<FieldDecl>(L)) {
12433 Pattern = cast<FieldDecl>(L);
12436 assert(Pattern &&
"We must have set the Pattern!");
12463 Diag(Loc, diag::err_in_class_initializer_not_yet_parsed)
12464 << OutermostClass << Field;
12465 Diag(Field->getLocEnd(), diag::note_in_class_initializer_not_yet_parsed);
12468 Field->setInvalidDecl();
12483 PDiag(diag::err_access_dtor_var)
12510 bool AllowExplicit,
12511 bool IsListInitialization) {
12513 unsigned NumArgs = ArgsPtr.size();
12514 Expr **Args = ArgsPtr.data();
12518 assert(Proto &&
"Constructor without a prototype?");
12522 if (NumArgs < NumParams)
12523 ConvertedArgs.reserve(NumParams);
12525 ConvertedArgs.reserve(NumArgs);
12532 llvm::makeArrayRef(Args, NumArgs),
12534 CallType, AllowExplicit,
12535 IsListInitialization);
12536 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
12540 CheckConstructorCall(Constructor,
12541 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
12551 if (isa<NamespaceDecl>(DC)) {
12553 diag::err_operator_new_delete_declared_in_namespace)
12557 if (isa<TranslationUnitDecl>(DC) &&
12560 diag::err_operator_new_delete_declared_static)
12571 unsigned DependentParamTypeDiag,
12572 unsigned InvalidParamTypeDiag) {
12579 diag::err_operator_new_delete_dependent_result_type)
12585 diag::err_operator_new_delete_invalid_result_type)
12591 diag::err_operator_new_delete_template_too_few_parameters)
12597 diag::err_operator_new_delete_too_few_parameters)
12604 << FnDecl->
getDeclName() << ExpectedFirstParamType;
12608 ExpectedFirstParamType)
12610 << FnDecl->
getDeclName() << ExpectedFirstParamType;
12632 diag::err_operator_new_dependent_param_type,
12633 diag::err_operator_new_param_type))
12640 diag::err_operator_new_default_arg)
12660 diag::err_operator_delete_dependent_param_type,
12661 diag::err_operator_delete_param_type))
12672 "Expected an overloaded operator declaration");
12682 if (Op == OO_Delete || Op == OO_Array_Delete)
12685 if (Op == OO_New || Op == OO_Array_New)
12693 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
12694 if (MethodDecl->isStatic())
12696 diag::err_operator_overload_static) << FnDecl->
getDeclName();
12698 bool ClassOrEnumParam =
false;
12700 QualType ParamType = Param->getType().getNonReferenceType();
12703 ClassOrEnumParam =
true;
12708 if (!ClassOrEnumParam)
12710 diag::err_operator_overload_needs_class_or_enum)
12720 if (Op != OO_Call) {
12722 if (Param->hasDefaultArg())
12723 return Diag(Param->getLocation(),
12724 diag::err_operator_overload_default_arg)
12725 << FnDecl->
getDeclName() << Param->getDefaultArgRange();
12730 {
false,
false,
false }
12731 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
12732 , { Unary, Binary, MemberOnly }
12733 #include "clang/Basic/OperatorKinds.def"
12736 bool CanBeUnaryOperator = OperatorUses[Op][0];
12737 bool CanBeBinaryOperator = OperatorUses[Op][1];
12738 bool MustBeMemberOperator = OperatorUses[Op][2];
12745 + (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
12746 if (Op != OO_Call &&
12747 ((NumParams == 1 && !CanBeUnaryOperator) ||
12748 (NumParams == 2 && !CanBeBinaryOperator) ||
12749 (NumParams < 1) || (NumParams > 2))) {
12752 if (CanBeUnaryOperator && CanBeBinaryOperator) {
12754 }
else if (CanBeUnaryOperator) {
12757 assert(CanBeBinaryOperator &&
12758 "All non-call overloaded operators are unary or binary!");
12762 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
12767 if (Op != OO_Call &&
12769 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
12774 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
12776 diag::err_operator_overload_must_be_member)
12790 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
12797 diag::err_operator_overload_post_incdec_must_be_int)
12798 << LastParam->
getType() << (Op == OO_MinusMinus);
12810 if (TemplateParams->
size() == 1) {
12819 }
else if (TemplateParams->
size() == 2) {
12828 PmArgs->isTemplateParameterPack()) {
12835 diag::ext_string_literal_operator_template);
12842 diag::err_literal_operator_template)
12851 if (isa<CXXMethodDecl>(FnDecl)) {
12852 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
12861 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
12878 diag::err_literal_operator_template_with_params);
12906 diag::err_literal_operator_param)
12923 diag::err_literal_operator_invalid_param)
12933 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
12940 Diag((*Param)->getSourceRange().getBegin(),
12941 diag::err_literal_operator_param)
12942 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
12949 Diag((*Param)->getSourceRange().getBegin(),
12950 diag::err_literal_operator_param)
12951 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
12962 Diag((*Param)->getSourceRange().getBegin(),
12963 diag::err_literal_operator_param)
12964 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
12972 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
12974 Diag((*Param)->getSourceRange().getBegin(),
12975 diag::err_literal_operator_param)
12977 << (*Param)->getSourceRange();
12981 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
12990 if (Param->hasDefaultArg()) {
12991 Diag(Param->getDefaultArgRange().getBegin(),
12992 diag::err_literal_operator_default_argument)
12993 << Param->getDefaultArgRange();
12998 StringRef LiteralName
13000 if (LiteralName[0] !=
'_') {
13022 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
13031 else if (Lang ==
"C++")
13034 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
13061 return LinkageSpec;
13085 bool Invalid =
false;
13099 Diag(Loc, diag::err_catch_rvalue_ref);
13104 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
13110 unsigned DK = diag::err_catch_incomplete;
13114 DK = diag::err_catch_incomplete_ptr;
13119 DK = diag::err_catch_incomplete_ref;
13121 if (!Invalid && (Mode == 0 || !BaseType->
isVoidType()) &&
13127 diag::err_abstract_type_in_decl,
13139 Diag(Loc, diag::err_objc_object_catch);
13144 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
13178 Expr *opaqueValue =
13230 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
13232 }
else if (PrevDecl->isTemplateParameter())
13262 Expr *AssertMessageExpr,
13265 AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) :
nullptr;
13271 AssertMessage, RParenLoc,
false);
13279 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
13290 diag::err_static_assert_expression_is_not_constant,
13294 if (!Failed && !Cond) {
13296 llvm::raw_svector_ostream Msg(MsgBuffer);
13299 Diag(StaticAssertLoc, diag::err_static_assert_failed)
13311 AssertExpr = FullAssertExpr.
get();
13314 AssertExpr, AssertMessage, RParenLoc,
13327 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
13353 diag::warn_cxx98_compat_unelaborated_friend_type :
13354 diag::ext_unelaborated_friend_type)
13362 diag::warn_cxx98_compat_nonclass_type_friend :
13363 diag::ext_nonclass_type_friend)
13370 diag::warn_cxx98_compat_enum_friend :
13371 diag::ext_enum_friend)
13383 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
13405 bool IsMemberSpecialization =
false;
13406 bool Invalid =
false;
13410 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
13411 IsMemberSpecialization, Invalid)) {
13412 if (TemplateParams->size() > 0) {
13418 NameLoc, Attr, TemplateParams,
AS_public,
13420 FriendLoc, TempParamLists.size() - 1,
13421 TempParamLists.data()).
get();
13424 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
13426 IsMemberSpecialization =
true;
13430 if (Invalid)
return nullptr;
13432 bool isAllExplicitSpecializations =
true;
13433 for (
unsigned I = TempParamLists.size();
I-- > 0; ) {
13434 if (TempParamLists[
I]->size()) {
13435 isAllExplicitSpecializations =
false;
13445 if (isAllExplicitSpecializations) {
13447 bool Owned =
false;
13448 bool IsDependent =
false;
13469 if (isa<DependentNameType>(T)) {
13483 TSI, FriendLoc, TempParamLists);
13489 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
13496 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
13507 TSI, FriendLoc, TempParamLists);
13545 if (TheDeclarator.isInvalidType())
13566 Diag(Loc, diag::err_tagless_friend_type_template)
13583 if (!TempParams.empty())
13621 Diag(Loc, diag::err_unexpected_friend);
13667 (FunctionContainingLocalClass =
13668 cast<CXXRecordDecl>(
CurContext)->isLocalClass())) {
13686 if (!Previous.
empty()) {
13694 DC = FunctionContainingLocalClass;
13738 if (!Previous.
empty()) {
13743 if (isTemplateId) {
13744 if (isa<TranslationUnitDecl>(LookupDC))
break;
13758 if (!DC)
return nullptr;
13776 if (Previous.
empty()) {
13778 Diag(Loc, diag::err_qualified_friend_not_found)
13788 diag::warn_cxx98_compat_friend_is_member :
13789 diag::err_friend_is_member);
13821 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
13848 if (DiagArg >= 0) {
13849 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
13860 DCScope = &FakeDCScope;
13863 bool AddToScope =
true;
13865 TemplateParams, AddToScope);
13866 if (!ND)
return nullptr;
13900 FD = FTD->getTemplatedDecl();
13902 FD = cast<FunctionDecl>(ND);
13913 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
13915 diag::note_previous_declaration);
13917 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
13922 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
13935 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
13937 Diag(DelLoc, diag::err_deleted_non_function);
13948 Prev->getPreviousDecl()) &&
13949 !Prev->isDefined()) {
13950 Diag(DelLoc, diag::err_deleted_decl_not_first);
13951 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
13952 Prev->isImplicit() ? diag::note_previous_implicit_declaration
13953 : diag::note_previous_declaration);
13972 bool IssuedDiagnostic =
false;
13977 if (!IssuedDiagnostic) {
13979 IssuedDiagnostic =
true;
13981 Diag((*I)->getLocation(), diag::note_overridden_virtual_function);
13994 Diag(DelLoc, diag::err_deleted_main);
14015 Diag(DefaultLoc, diag::err_default_special_members);
14046 Diag(DefaultLoc, diag::err_default_special_members);
14054 if (isa<ReturnStmt>(SubStmt))
14055 Self.
Diag(SubStmt->getLocStart(),
14056 diag::err_return_in_constructor_handler);
14057 if (!isa<Expr>(SubStmt))
14077 if (NewCC == OldCC)
14088 diag::err_conflicting_overriding_cc_attributes)
14114 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
14122 if (NewClassTy.
isNull()) {
14124 diag::err_different_return_type_for_overriding_virtual_function)
14140 if (!RT->isBeingDefined() &&
14142 diag::err_covariant_return_incomplete,
14159 NewClassTy, OldClassTy,
14160 diag::err_covariant_return_inaccessible_base,
14161 diag::err_covariant_return_ambiguous_derived_to_base_conv,
14177 diag::err_covariant_return_type_different_qualifications)
14189 diag::err_covariant_return_type_class_type_more_qualified)
14224 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
14232 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
14233 return Var->isStaticDataMember();
14288 "Parser allowed 'typedef' as storage class of condition decl.");
14294 if (isa<FunctionDecl>(Dcl)) {
14295 Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
14304 if (!ExternalSource)
14310 for (
unsigned I = 0, N = VTables.size();
I != N; ++
I) {
14311 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
14315 if (!Pos->second && VTables[
I].DefinitionRequired)
14316 Pos->second =
true;
14320 VTablesUsed[VTables[
I].Record] = VTables[
I].DefinitionRequired;
14321 NewUses.push_back(
VTableUse(VTables[
I].Record, VTables[
I].Location));
14328 bool DefinitionRequired) {
14338 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
14339 Pos =
VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
14344 if (DefinitionRequired && !Pos.first->second) {
14345 Pos.first->second =
true;
14377 VTableUses.push_back(std::make_pair(Class, Loc));
14389 bool DefinedAnything =
false;
14399 bool DefineVTable =
true;
14405 if (KeyFunction && !KeyFunction->
hasBody()) {
14407 DefineVTable =
false;
14412 "Instantiations don't have key functions");
14414 }
else if (!KeyFunction) {
14419 bool IsExplicitInstantiationDeclaration =
14421 for (
auto R : Class->
redecls()) {
14425 IsExplicitInstantiationDeclaration =
true;
14427 IsExplicitInstantiationDeclaration =
false;
14432 if (IsExplicitInstantiationDeclaration)
14433 DefineVTable =
false;
14439 if (!DefineVTable) {
14447 DefinedAnything =
true;
14459 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
14463 ? diag::warn_weak_template_vtable
14464 : diag::warn_weak_vtable)
14471 return DefinedAnything;
14476 for (
const auto *
I : RD->
methods())
14477 if (
I->isVirtual() && !
I->isPure())
14486 for (CXXFinalOverriderMap::const_iterator
I = FinalOverriders.begin(),
14487 E = FinalOverriders.end();
14490 OE =
I->second.end();
14492 assert(OI->second.size() > 0 &&
"no final overrider");
14497 if (!Overrider->isPure())
14506 for (
const auto &
I : RD->
bases()) {
14508 cast<CXXRecordDecl>(
I.getType()->getAs<
RecordType>()->getDecl());
14526 for (
unsigned i = 0; i < ivars.size(); i++) {
14538 InitSeq.Perform(*
this, InitEntity, InitKind,
None);
14550 AllToInit.push_back(Member);
14555 ->getAs<RecordType>()) {
14556 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
14560 PDiag(diag::err_access_dtor_ivar)
14566 AllToInit.data(), AllToInit.size());
14572 llvm::SmallSet<CXXConstructorDecl*, 4> &Valid,
14573 llvm::SmallSet<CXXConstructorDecl*, 4> &Invalid,
14574 llvm::SmallSet<CXXConstructorDecl*, 4> &
Current,
14585 (void)Target->
hasBody(FNTarget);
14587 cast_or_null<CXXConstructorDecl>(FNTarget));
14594 if (!Current.insert(Canonical).second)
14600 Valid.insert(Current.begin(), Current.end());
14603 }
else if (TCanonical == Canonical || Invalid.count(TCanonical) ||
14604 Current.count(TCanonical)) {
14606 if (!Invalid.count(TCanonical)) {
14608 diag::warn_delegating_ctor_cycle)
14612 if (TCanonical != Canonical)
14619 assert(FNTarget &&
"Ctor cycle through bodiless function");
14622 cast<CXXConstructorDecl>(FNTarget));
14627 Invalid.insert(Current.begin(), Current.end());
14636 llvm::SmallSet<CXXConstructorDecl*, 4> Valid, Invalid,
Current;
14638 for (DelegatingCtorDeclsType::iterator
14644 for (llvm::SmallSet<CXXConstructorDecl *, 4>::iterator CI = Invalid.begin(),
14645 CE = Invalid.end();
14647 (*CI)->setInvalidDecl();
14656 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
14684 FindCXXThisExpr
Finder(*
this);
14709 FindCXXThisExpr
Finder(*
this);
14728 if (!Finder.TraverseType(E))
14738 FindCXXThisExpr
Finder(*
this);
14741 for (
const auto *A : Method->
attrs()) {
14743 Expr *Arg =
nullptr;
14745 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
14747 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
14749 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
14750 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
14751 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
14752 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
14753 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
14754 Arg = ETLF->getSuccessValue();
14755 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
14756 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
14757 Arg = STLF->getSuccessValue();
14758 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
14759 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
14760 Arg = LR->getArg();
14761 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
14762 Args = llvm::makeArrayRef(LE->args_begin(), LE->args_size());
14763 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
14764 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
14765 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
14766 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
14767 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
14768 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
14769 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
14770 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
14772 if (Arg && !Finder.TraverseStmt(Arg))
14775 for (
unsigned I = 0, N = Args.size();
I != N; ++
I) {
14776 if (!Finder.TraverseStmt(Args[
I]))
14790 Exceptions.clear();
14793 Exceptions.reserve(DynamicExceptions.size());
14794 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
14801 if (!Unexpanded.empty()) {
14812 Exceptions.push_back(ET);
14820 if (NoexceptExpr) {
14824 "Parser should have made sure that the expression is boolean");
14825 if (IsTopLevel && NoexceptExpr &&
14833 diag::err_noexcept_needs_constant_expression,
14846 Expr *NoexceptExpr) {
14852 MethodD = FunTmpl->getTemplatedDecl();
14862 DynamicExceptionRanges, NoexceptExpr, Exceptions,
14890 Diag(DeclStart, diag::err_anonymous_property);
14915 diag::err_invalid_thread)
14942 PrevDecl =
nullptr;
14946 PrevDecl =
nullptr;
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
Abstract class used to diagnose incomplete types.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
unsigned getNumElements() const
unsigned getFlags() const
getFlags - Return the flags for this scope.
A call to an overloaded operator written using operator syntax.
SourceLocation getThreadStorageClassSpecLoc() const
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl)
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
NamespaceDecl * lookupStdExperimentalNamespace()
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0) const
void setSourceOrder(int Pos)
Set the source order of this initializer.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
Defines the clang::ASTContext interface.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
unsigned getNumInits() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
SourceLocation getEnd() const
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
StmtClass getStmtClass() const
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
CastKind getCastKind() const
IdKind getKind() const
Determine what kind of name we have.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
static StmtResult buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying, unsigned Depth=0)
Builds a statement that copies/moves the given entity from From to To.
static void CheckForDanglingReferenceOrPointer(Sema &S, ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
Checks a member initializer expression for cases where reference (or pointer) members are bound to by...
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclarationName Name, FunctionDecl *&Operator, bool Diagnose=true)
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Name lookup found a set of overloaded functions that met the criteria.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
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.
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
unsigned getDepth() const
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void setOrigin(CXXRecordDecl *Rec)
no exception specification
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
SourceLocation getRestrictSpecLoc() const
A (possibly-)qualified type.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
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).
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
SourceLocation getConstSpecLoc() const
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules, and thus an ambiguity error can be downgraded to an extension warning.
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
SourceLocation getExplicitSpecLoc() const
ExtInfo withCallingConv(CallingConv cc) const
QualType getConversionType() const
Returns the type that this conversion function is converting to.
static bool checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, bool ConstArg, bool Diagnose)
Check whether the members of a class type allow a special member to be trivial.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
bool isBitField() const
Determines whether this field is a bitfield.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
QualType getType() const
Retrieves the type of the base class.
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...
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
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.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
std::unique_ptr< RecordDeclSetTy > PureVirtualClassDiagSet
PureVirtualClassDiagSet - a set of class declarations which we have emitted a list of pure virtual fu...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
method_range methods() const
The subobject is a base class.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee)
Check whether we're allowed to call Callee from the current context.
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.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
static unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
DeclClass * getAsSingle() const
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
Decl * Entity
The entity that is being synthesized.
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
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.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Filter makeFilter()
Create a filter for this result set.
SourceLocation getEndLoc() const
getEndLoc - Retrieve the location of the last token.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
We are matching the template parameter lists of two templates that might be redeclarations.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
CXXCatchStmt * getHandler(unsigned i)
TypeLoc getNamedTypeLoc() const
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
IfStmt - This represents an if/then/else.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD)
Check a completed declaration of an implicit special member.
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
StmtResult ActOnExprStmt(ExprResult Arg)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class...
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
static CharSourceRange getTokenRange(SourceRange R)
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
void addConst()
Add the const type qualifier to this QualType.
ActionResult< Expr * > ExprResult
static unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class...
void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class)
Force the declaration of any implicitly-declared members of this class.
A conversion function name, e.g., operator int.
static TemplateArgumentLoc getTrivialTypeTemplateArgument(Sema &S, SourceLocation Loc, QualType T)
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.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
bool isRecordType() const
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
QualType getUnderlyingType() const
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed...
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
static bool FindBaseInitializer(Sema &SemaRef, CXXRecordDecl *ClassDecl, QualType BaseType, const CXXBaseSpecifier *&DirectBaseSpec, const CXXBaseSpecifier *&VirtualBaseSpec)
Find the direct and/or virtual base specifiers that correspond to the given base type, for use in base initialization within a constructor.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true)
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function...
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void setPure(bool P=true)
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
bool hasFlexibleArrayMember() const
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
bool isEnumeralType() const
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
SCS getStorageClassSpec() const
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
static bool isVirtualDirectBase(CXXRecordDecl *Derived, CXXRecordDecl *Base)
Determine whether a direct base class is a virtual base class.
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier * > Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
void EvaluateImplicitExceptionSpec(SourceLocation Loc, CXXMethodDecl *MD)
Evaluate the implicit exception specification for a defaulted special member function.
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
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.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
bool isInStdNamespace() const
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
bool isStdNamespace() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
const DecompositionDeclarator & getDecompositionDeclarator() const
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
unsigned getLength() const
Efficiently return the length of this identifier info.
MapType::iterator iterator
QualType getRecordType(const RecordDecl *Decl) const
One instance of this struct is used for each type in a declarator that is parsed. ...
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
Declaration of a variable template.
const Expr * getInit() const
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
NamespaceDecl - Represent a C++ namespace.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location...
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
NamedDecl * getParam(unsigned Idx)
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
SourceLocation getInlineSpecLoc() 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.
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
unsigned getIndex() const
const Stmt * getElse() const
Floating point control options.
static std::string printTemplateArgs(const PrintingPolicy &PrintingPolicy, TemplateArgumentListInfo &Args)
bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMember CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
SourceLocation getLocEnd() const LLVM_READONLY
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList * > FriendTypeTPLists=None)
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...
Represents a C++ constructor within a class.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
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)
Expr * getInClassInitializer() const
getInClassInitializer - Get the C++11 in-class initializer for this member, or null if one has not be...
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
InClassInitStyle getInClassInitStyle() const
getInClassInitStyle - Get the kind of (C++11) in-class initializer which this field has...
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
const llvm::APInt & getSize() const
static bool checkSimpleDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType, llvm::function_ref< ExprResult(SourceLocation, Expr *, unsigned)> GetInit)
void CheckCXXDefaultArguments(FunctionDecl *FD)
CheckCXXDefaultArguments - Verify that the default arguments for a function declaration are well-form...
RAII object to handle the state changes required to synthesize a function body.
Look up a namespace name within a C++ using directive or namespace alias definition, ignoring non-namespace names (C++ [basic.lookup.udir]p1).
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.
static CXXConstructExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
void ActOnFinishCXXNonNestedClass(Decl *D)
static void DiagnoseBaseOrMemInitializerOrder(Sema &SemaRef, const CXXConstructorDecl *Constructor, ArrayRef< CXXCtorInitializer * > Inits)
This file provides some common utility functions for processing Lambda related AST Constructs...
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class, then each of the following shall have a name different from T:
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
RAII object that enters a new expression evaluation context.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
std::pair< CXXRecordDecl *, CXXSpecialMember > SpecialMemberDecl
Expr * getInit() const
Get the initializer.
Information about one declarator, including the parsed type information and the identifier.
DiagnosticsEngine & Diags
Wrapper for source info for member pointers.
bool isInlineSpecified() const
const Expr * getCallee() const
void finishedDefaultedOrDeletedMember(CXXMethodDecl *MD)
Indicates that the declaration of a defaulted or deleted special member function is now complete...
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool IsForUsingDecl)
Determine whether the given New declaration is an overload of the declarations in Old...
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Extra information about a function prototype.
AccessSpecifier getAccess() const
void clear()
Clear the base-paths results.
CallingConv getCallConv() const
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
TypeSpecifierType
Specifies the kind of type.
field_iterator field_begin() const
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
MapType::const_iterator const_iterator
The "__interface" keyword.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
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.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
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)
static InitializationKind CreateDirectList(SourceLocation InitLoc)
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...
decl_iterator decls_end() const
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class.copy]p25)
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
ParmVarDecl - Represents a parameter to a function.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
Defines the clang::Expr interface and subclasses for C++ expressions.
Parse and apply any fixits to the source.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
void removeDecl(Decl *D)
Removes a declaration from this context.
bool isEmpty() const
No scope specifier.
iterator begin(Source *source, bool LocalOnly=false)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
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...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
The collection of all-type qualifiers we support.
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.
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
HandleField - Analyze a field of a C struct or a C++ data member.
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class...
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()
Base wrapper for a particular "section" of type source info.
unsigned getNumParams() const
AccessResult CheckFriendAccess(NamedDecl *D)
Checks access to the target of a friend declaration.
RecordDecl - Represents a struct/union/class.
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, AttributeList *AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
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 isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
Description of a constructor that was inherited from a base class.
bool hasUninstantiatedDefaultArg() const
bool isExternC() const
Determines whether this function is a function with external, C linkage.
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 ...
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
DeclarationName getName() const
getName - Returns the embedded declaration name.
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.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
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)
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
void setRecordingPaths(bool RP)
Specify whether we should be recording paths or not.
method_iterator end_overridden_methods() const
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
AttributeList * getList() const
void setUninstantiatedDefaultArg(Expr *arg)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
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.
The results of name lookup within a DeclContext.
unsigned getNumArgs() const
ArrayRef< QualType > getParamTypes() const
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, ArrayRef< CXXCtorInitializer * > Initializers=None)
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool isIdentifier() const
Predicate functions for querying what type of name this is.
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.
static void AddMostOverridenMethods(const CXXMethodDecl *MD, llvm::SmallPtrSetImpl< const CXXMethodDecl * > &Methods)
Add the most overriden methods from MD to Methods.
SourceLocation getLocStart() const LLVM_READONLY
bool isRecordingPaths() const
Whether we are recording paths.
bool isReferenceType() 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 getReturnType() const
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
The current expression is potentially evaluated at run time, which means that code may be generated t...
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class...
NoexceptResult
Result type of getNoexceptSpec().
bool isAbstractType(SourceLocation Loc, QualType T)
static bool isIncrementDecrementOp(Opcode Op)
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned The qualifier bitmask values are the same as...
void Deallocate(void *Ptr) const
ParmVarDecl * getParam(unsigned i) const
unsigned getIdentifierNamespace() 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.
This is not an overload because the signature exactly matches an existing declaration.
CXXRecordDecl * getDefinition() const
bool isTranslationUnit() const
void setElaboratedKeywordLoc(SourceLocation Loc)
TagKind getTagKind() const
The iterator over UnresolvedSets.
SourceRange getLocalSourceRange() const
Get the local source range.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static void extendLeft(SourceRange &R, SourceRange Before)
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)
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...
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
SourceLocation getTypeSpecTypeLoc() const
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > Expansions)
SourceLocation getLocStart() const LLVM_READONLY
static bool CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S, SmallVectorImpl< SourceLocation > &ReturnStmts, SourceLocation &Cxx1yLoc)
Check the provided statement is allowed in a constexpr function definition.
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
Represents an access specifier followed by colon ':'.
void ClearStorageClassSpecs()
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared...
void addShadowDecl(UsingShadowDecl *S)
TypeSourceInfo * getTypeSourceInfo() const
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
void PopExpressionEvaluationContext()
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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...
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
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...
EnumDecl * getStdAlignValT() const
The type of an exception.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
SourceLocation getBeginLoc() const
Get the begin source location.
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.
bool implicitCopyConstructorHasConstParam() const
Determine whether an implicit copy constructor for this type would have a parameter with a const-qual...
Represents a C++ unqualified-id that has been parsed.
An rvalue reference type, per C++11 [dcl.ref].
bool isCompleteType(SourceLocation Loc, QualType T)
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace...
Represents the results of name lookup.
const TargetInfo & getTargetInfo() const
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
bool hasGroupingParens() const
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
const LangOptions & getLangOpts() const
Decl * ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
bool isLastDiagnosticIgnored() const
Determine whether the previous diagnostic was ignored.
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isInline() const
Returns true if this is an inline namespace declaration.
IndirectFieldDecl * getIndirectMember() const
Microsoft throw(...) extension.
A convenient class for passing around template argument information.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
static bool isStaticDataMember(const Decl *D)
Determine whether the given declaration is a static data member.
virtual void HandleVTable(CXXRecordDecl *RD)
Callback involved at the end of a translation unit to notify the consumer that a vtable for the given...
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...
The base type of a class type.
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
QualType getReturnType() const
Look up all declarations in a scope with the given name, including resolved using declarations...
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...
unsigned getMinRequiredArguments() const
getMinRequiredArguments - Returns the minimum number of arguments needed to call this function...
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...
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec...
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isDefaulted() const
Whether this function is defaulted per C++0x.
bool CheckConstexprFunctionDecl(const FunctionDecl *FD)
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
field_range fields() const
A friend of a previously-undeclared entity.
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
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.
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
static void NoteIndirectBases(ASTContext &Context, IndirectBaseSet &Set, const QualType &Type)
Recursively add the bases of Type. Don't add Type itself.
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
semantics_iterator semantics_end()
SourceLocation getLocStart() const LLVM_READONLY
TypeDecl - Represents a declaration of a type.
Expr * getNoexceptExpr() const
A builtin binary operation expression such as "x + y" or "x <= y".
An implicit 'self' parameter.
static bool checkMemberDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const CXXRecordDecl *RD)
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
RecordDecl * getDecl() const
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
void CheckDelegatingCtorCycles()
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
static void ReferenceDllExportedMethods(Sema &S, CXXRecordDecl *Class)
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)
bool isOverloadedOperator() const
isOverloadedOperator - Whether this function declaration represents an C++ overloaded operator...
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
bool isVariadic() const
Whether this function is variadic.
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...
The type of a data member.
bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
ExprResult ActOnCXXThis(SourceLocation loc)
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
Represents a C++ nested-name-specifier or a global scope specifier.
enum clang::DeclaratorChunk::@196 Kind
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)...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
SourceLocation getLocation() const
SourceLocation getLocStart() const LLVM_READONLY
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool isStaticLocal() const
isStaticLocal - Returns true if a variable with function scope is a static local variable.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
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'.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
static bool findCircularInheritance(const CXXRecordDecl *Class, const CXXRecordDecl *Current)
Determine whether the given class is a base class of the given class, including looking at dependent ...
static void DelegatingCycleHelper(CXXConstructorDecl *Ctor, llvm::SmallSet< CXXConstructorDecl *, 4 > &Valid, llvm::SmallSet< CXXConstructorDecl *, 4 > &Invalid, llvm::SmallSet< CXXConstructorDecl *, 4 > &Current, Sema &S)
ArrayRef< BindingDecl * > bindings() const
An ordinary object is located at an address in memory.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
A class that does preordor or postorder depth-first traversal on the entire Clang AST and visits each...
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.
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
Represents a linkage specification.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
decl_iterator decls_begin() const
SourceRange getSourceRange() const LLVM_READONLY
detail::InMemoryDirectory::const_iterator I
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
NamespaceDecl * StdExperimentalNamespaceCache
The C++ "std::experimental" namespace, where the experimental parts of the standard library resides...
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
unsigned getNumParams() const
A binding in a decomposition declaration.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
QualType getCanonicalTypeInternal() const
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
init_iterator init_begin()
Retrieve an iterator to the first initializer.
bool defaultedCopyConstructorIsDeleted() const
true if a defaulted copy constructor for this class would be deleted.
const LangOptions & LangOpts
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...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
static TemplateArgumentLoc getTrivialIntegralTemplateArgument(Sema &S, SourceLocation Loc, QualType T, uint64_t I)
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, bool IncludeCXX11Attributes=true)
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc)
PopPragmaVisibility - Pop the top element of the visibility stack; used for '#pragma GCC visibility' ...
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
SourceRange getRange() const
bool isDefined(const FunctionDecl *&Definition) const
isDefined - Returns true if the function is defined at all, including a deleted definition.
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.
bool isAbstract() const
Determine whether this class has a pure virtual function.
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
static bool isValidUDSuffix(const LangOptions &LangOpts, StringRef Suffix)
Determine whether a suffix is a valid ud-suffix.
field_iterator field_end() const
Class that aids in the construction of nested-name-specifiers along with source-location information ...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
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.
CXXConstructorDecl * getConstructor() const
void removeInClassInitializer()
removeInClassInitializer - Remove the C++11 in-class initializer from this member.
CXXMethodDecl * getMethod() const
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
CXXSpecialMember
Kinds of C++ special members.
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, Expr *Init, SourceLocation EllipsisLoc)
Handle a C++ member initializer.
CXXConstructorDecl * findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor, ConstructorUsingShadowDecl *DerivedShadow)
Given a derived-class using shadow declaration for a constructor and the correspnding base class cons...
void setBases(CXXBaseSpecifier const *const *Bases, unsigned NumBases)
Sets the base classes of this struct or class.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
ConditionalOperator - The ?: ternary operator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Sema - This implements semantic analysis and AST building for C.
Decl * ActOnEmptyDeclaration(Scope *S, AttributeList *AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
CanQualType getCanonicalTypeUnqualified() const
TST getTypeSpecType() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
void ClearConstexprSpec()
CXXMethodDecl * getMethodDecl() const
Retrieves the declaration of the called method.
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
static unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
A RAII object to enter scope of a compound statement.
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...
bool inferObjCARCLifetime(ValueDecl *decl)
Represents a ValueDecl that came out of a declarator.
static bool checkComplexDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const ComplexType *CT)
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
param_type_iterator param_type_begin() const
static Sema::ImplicitExceptionSpecification ComputeDefaultedSpecialMemberExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD, Sema::CXXSpecialMember CSM, Sema::InheritedConstructorInfo *ICI)
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp)
SourceLocation getFriendSpecLoc() const
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 isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
const CXXMethodDecl *const * method_iterator
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
void setInClassInitializer(Expr *Init)
setInClassInitializer - Set the C++11 in-class initializer for this member.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
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)
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
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 isRealFloatingType() const
Floating point categories.
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...
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Allows QualTypes to be sorted and hence used in maps and sets.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
bool isDeleted() const
Whether this function has been deleted.
bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method)
Whether this' shows up in the exception specification of a static member function.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const Type * getTypeForDecl() const
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
unsigned getTypeQualifiers() const
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D, const TemplateArgumentList *Innermost=nullptr, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
StringRef getName() const
Return the actual identifier string.
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.
SourceLocation getAtomicSpecLoc() const
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
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...
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
Declaration of a template type parameter.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
bool isFunctionDefinition() 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...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
ArrayRef< NamedDecl * > chain() const
void setRBraceLoc(SourceLocation L)
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
Represents a C++ destructor within a class.
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
void freeParams()
Reset the parameter list to having zero parameters.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
TranslationUnitDecl * getTranslationUnitDecl() const
static unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
llvm::SmallSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
bool isLiteral() const
Determine whether this class is a literal type.
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.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
ArgKind getKind() const
Return the kind of stored template argument.
const ParmVarDecl * getParamDecl(unsigned i) const
ExtProtoInfo getExtProtoInfo() const
SourceLocation getVolatileSpecLoc() const
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, AttributeList *Attrs=nullptr)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
DeclContext * getDeclContext()
void PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, const BlockExpr *blkExpr=nullptr)
bool hasDirectFields() const
Determine whether this class has direct non-static data members.
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
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.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
CXXTryStmt - A C++ try block, including all handlers.
static void DefineImplicitSpecialMember(Sema &S, CXXMethodDecl *MD, SourceLocation DefaultLoc)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
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 isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool hasUserDeclaredMoveConstructor() const
Determine whether this class has had a move constructor declared by the user.
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name...
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
There is no noexcept specifier.
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getLastLocation() const
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void DiscardCleanupsInEvaluationContext()
static bool checkVectorDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const VectorType *VT)
bool isConstexprSpecified() const
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 hasKeyFunctions() const
Does this ABI use key functions? If so, class data such as the vtable is emitted with strong linkage ...
ASTMutationListener * getASTMutationListener() const
bool isExplicit() const
Whether this function is explicit.
void setInheritConstructors(bool Inherit=true)
Set that this base class's constructors should be inherited.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
QualType getType() const
Get the type for which this source info wrapper provides information.
SourceLocation getLocEnd() const LLVM_READONLY
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
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.
Expr * getSubExpr() const
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void CheckCompletedCXXClass(CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
void AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl, CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
bool hasTrailingReturn() const
bool isFunctionOrMethod() const
clang::ObjCRuntime ObjCRuntime
InClassInitStyle
In-class initialization styles for non-static data members.
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
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.
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
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...
bool isExternallyVisible() 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.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
DeclContextLookupResult slice(size_t N) const
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
Represents a GCC generic vector type.
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
DiagnosticsEngine & getDiagnostics() const
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
CXXRecordDecl * getStdBadAlloc() const
unsigned getNumBases() const
Retrieves the number of base classes of this class.
void addContextNote(SourceLocation UseLoc)
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an initializer for the declaration ...
Represents a C++ deduction guide declaration.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
QualType getElementType() const
Represents a C++ conversion function within a class.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
SourceLocation getLocEnd() const LLVM_READONLY
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
SourceLocation getStorageClassSpecLoc() const
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
TypeSourceInfo * getTypeSourceInfo() const
bool isVirtualSpecified() const
bool needsOverloadResolutionForCopyAssignment() const
Determine whether we need to eagerly declare a defaulted copy assignment operator for this class...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static bool RefersToRValueRef(Expr *MemRef)
const clang::PrintingPolicy & getPrintingPolicy() const
static bool computeCanPassInRegisters(Sema &S, CXXRecordDecl *D)
Determine whether a type is permitted to be passed or returned in registers, per C++ [class...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
This is a legitimate overload: the existing declarations are functions or function templates with dif...
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, AttributeList *AttrList)
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
ExprResult ActOnFinishFullExpr(Expr *Expr)
const TypeClass * getTypePtr() const
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)
DeclarationNameInfo getNameInfo() const
OpaquePtr< T > get() const
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
IdentifierInfo * SetterId
static void SearchForReturnInStmt(Sema &Self, Stmt *S)
Wrapper for source info for arrays.
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D)
Check declaration inside target region.
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 doesThisDeclarationHaveABody() const
doesThisDeclarationHaveABody - Returns whether this specific declaration of the function has a body -...
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
TemplateArgumentLoc getArgLoc(unsigned i) const
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
DeclContext * getEntity() const
static bool CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef, const FunctionDecl *FnDecl)
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ASTMatchFinder *const Finder
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
We are declaring an implicit special member function.
CXXSpecialMember SpecialMember
The special member being declared or defined.
static CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
Represents a call to an inherited base class constructor from an inheriting constructor.
static const CXXRecordDecl * findDecomposableBaseClass(Sema &S, SourceLocation Loc, const CXXRecordDecl *RD, CXXCastPath &BasePath)
Find the base class to decompose in a built-in decomposition of a class type.
ExceptionSpecificationType Type
The kind of exception specification this is.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
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.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, AttributeList *AttrList, bool IsInstantiation)
Builds a using declaration.
llvm::SmallPtrSet< QualType, 4 > IndirectBaseSet
Use small set to collect indirect bases.
This is not an overload because the lookup results contain a non-function.
Encodes a location in the source.
void setOperatorDelete(FunctionDecl *OD)
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Determines whether this field is a representative for an anonymous struct ...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
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...
QualType getElementType() const
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
unsigned getBitWidthValue(const ASTContext &Ctx) const
method_iterator begin_overridden_methods() const
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
FieldDecl * getAnyMember() const
An overloaded operator name, e.g., operator+.
Expr * getRepAsExpr() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
A deduction-guide name (a template-name)
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 isValid() const
Return true if this is a valid SourceLocation object.
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.
void ExitDeclaratorContext(Scope *S)
TagDecl - Represents the declaration of a struct/union/class/enum.
void referenceDLLExportedClassMethods()
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc)
Build the type that describes a C++ typename specifier, e.g., "typename T::type". ...
Represents a call to a member function that may be written either with member call syntax (e...
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
ASTContext & getASTContext() const LLVM_READONLY
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP target region.
unsigned size_overridden_methods() const
InheritedConstructorInfo(Sema &S, SourceLocation UseLoc, ConstructorUsingShadowDecl *Shadow)
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.
ASTContext & getASTContext() const
static bool CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, CanQualType ExpectedResultType, CanQualType ExpectedFirstParamType, unsigned DependentParamTypeDiag, unsigned InvalidParamTypeDiag)
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
void setReferenced(bool R=true)
IdentifierTable & getIdentifierTable()
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error...
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
Represents a dependent using declaration which was not marked with typename.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
QualType withConst() const
void removeShadowDecl(UsingShadowDecl *S)
void setCtorInitializers(CXXCtorInitializer **Initializers)
ClassTemplateDecl * StdInitializerList
The C++ "std::initializer_list" template, which is defined in <initializer_list>. ...
Represents a static or instance method of a struct/union/class.
unsigned getDepth() const
Retrieve the depth of the template parameter.
void setDefaulted(bool D=true)
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
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...
ArrayRef< ParmVarDecl * > parameters() const
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
bool isInvalid() const
An error occurred during parsing of the scope specifier.
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...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Name lookup found an unresolvable value declaration and cannot yet complete.
const ObjCInterfaceDecl * getClassInterface() const
SourceLocation getConstexprSpecLoc() const
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
void push_back(const T &LocalValue)
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).
Decl * ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
Describes the kind of initialization being performed, along with location information for tokens rela...
static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
A class for iterating through a result set and possibly filtering out results.
Direct list-initialization.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
Represents a C++11 virt-specifier-seq.
static bool checkArrayLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType)
SourceLocation getVirtualSpecLoc() const
static CXXDefaultInitExpr * Create(const ASTContext &C, SourceLocation Loc, FieldDecl *Field)
Field is the non-static data member whose default initializer is used by this expression.
ThreadStorageClassSpecifier getTSCSpec() const
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 ...
TypeLocClass getTypeLocClass() const
bool isFinalSpelledSealed() const
void CheckExplicitlyDefaultedMemberExceptionSpec(CXXMethodDecl *MD, const FunctionProtoType *T)
Check whether the exception specification provided for an explicitly-defaulted special member matches...
void setIsParsingBaseSpecifiers()
SourceLocation getBegin() 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 T * castAs() const
Member-template castAs<specific type>.
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer.
TypeLoc getReturnLoc() const
SourceLocation getBeginLoc() const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
static bool BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, CXXBaseSpecifier *BaseSpec, bool IsInheritedVirtualBase, CXXCtorInitializer *&CXXBaseInit)
No entity found met the criteria.
NoexceptResult getNoexceptSpec(const ASTContext &Ctx) const
Get the meaning of the noexcept spec on this function, if any.
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.
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 isFileContext() const
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, AttributeList *AttrList)
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang)
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer * > MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
Attr * clone(ASTContext &C) const
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, AttributeList *AttrList)
ConstructorUsingShadowDecl * getShadowDecl() const
IdentifierInfo * GetterId
SourceLocation getLocStart() const LLVM_READONLY
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
void setExplicitlyDefaulted(bool ED=true)
void setHasInheritedDefaultArg(bool I=true)
MutableArrayRef< Expr * > MultiExprArg
static Sema::ImplicitExceptionSpecification computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD)
QualType getType() const
Return the type wrapped by this type source info.
void addArgument(const TemplateArgumentLoc &Loc)
bool isDynamicClass() const
static bool checkArrayDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const ConstantArrayType *CAT)
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool isFunctionProtoType() const
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
QualType getPointeeType() const
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, AttributeList *AttrList)
A constructor named via a template-id.
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) 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)
The expression in a static assertion.
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
static bool checkTupleLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, VarDecl *Src, QualType DecompType, const llvm::APSInt &TupleSize)
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
static AttributeList * getMSPropertyAttr(AttributeList *list)
static void checkForMultipleExportedDefaultConstructors(Sema &S, CXXRecordDecl *Class)
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Decl * ActOnExceptionDeclarator(Scope *S, Declarator &D)
ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch handler.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Base class for declarations which introduce a typedef-name.
attr::Kind getKind() const
ast_type_traits::DynTypedNode Node
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
TLS with a dynamic initializer.
Represents a template argument.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
QualType getAsType() const
Retrieve the type for a type template argument.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument. ...
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
TagTypeKind
The kind of a tag type.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
static bool isInvalid(LocType Loc, bool *Invalid)
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
TSCS getThreadStorageClassSpec() 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)
SourceLocation getLocStart() const LLVM_READONLY
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
void setImplicitlyInline()
Flag that this function is implicitly inline.
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
bool hasTypename() const
Return true if the using declaration has 'typename'.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
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...
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
The base class of all kinds of template declarations (e.g., class, function, etc.).
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
bool hasUnparsedDefaultArg() const
hasUnparsedDefaultArg - Determines whether this parameter has a default argument that has not yet bee...
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static const TST TST_auto
bool isFriendSpecified() const
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
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.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
SourceLocation getLocStart() const LLVM_READONLY
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
static bool InitializationHasSideEffects(const FieldDecl &FD)
bool hasVariantMembers() const
Determine whether this class has any variant members.
bool isInvalidDecl() const
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
SourceLocation getFinalLoc() const
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings=None)
TypeLoc IgnoreParens() const
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
CanQualType UnsignedLongLongTy
bool defaultedMoveConstructorIsDeleted() const
true if a defaulted move constructor for this class would be deleted.
bool isFinalSpecified() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
A decomposition declaration.
static void PopulateKeysForFields(FieldDecl *Field, SmallVectorImpl< const void * > &IdealInits)
std::pair< SourceLocation, SourceLocation > getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
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.
QualType getExceptionObjectType(QualType T) const
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
Represents a dependent using declaration which was marked with typename.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
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...
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
void setWillHaveBody(bool V=true)
DeclarationName - The name of a declaration.
unsigned getNumHandlers() const
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
param_type_iterator param_type_end() const
A mapping from each virtual member function to its set of final overriders.
StringRef getString() const
SourceLocation getLocStart() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
size_t param_size() const
EnumDecl - Represents an enum.
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
detail::InMemoryDirectory::const_iterator E
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i...
static UsingPackDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > UsingDecls)
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
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...
IdentifierResolver IdResolver
semantics_iterator semantics_begin()
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
SourceLocation getLocation() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isLValueReferenceType() const
bool isMsStruct(const ASTContext &C) const
isMsStrust - Get whether or not this is an ms_struct which can be turned on with an attribute...
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
ArrayRef< Binding > bindings() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization. ...
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
bool isLambda() const
Determine whether this class describes a lambda function object.
DeclClass * getCorrectionDeclAs() const
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).
static unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
void PushUsingDirective(UsingDirectiveDecl *UDir)
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
bool isRValueReferenceType() const
const Stmt * getThen() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
void setNameLoc(SourceLocation Loc)
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
static FunctionProtoType::ExtProtoInfo getImplicitMethodEPI(Sema &S, CXXMethodDecl *MD)
bool hasInheritedDefaultArg() const
Name lookup found a single declaration that met the criteria.
bool empty() const
Return true if no decls were found.
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...
bool isObjCObjectType() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, AttributeList *AttrList, UsingDirectiveDecl *&UsingDecl)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class.copy]p25)
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)
void setUnparsedDefaultArg()
setUnparsedDefaultArg - Specify that this parameter has an unparsed default argument.
Expr * getUninstantiatedDefaultArg()
SourceManager & getSourceManager() const
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
const T * getAs() const
Member-template getAs<specific type>'.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
static void extendRight(SourceRange &R, SourceRange After)
unsigned getTypeQuals() const
Decl::Kind getDeclKind() const
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const AttributeList *AttrList)
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, bool IsDecltype=false)
Represents a C++ base or member initializer.
LanguageIDs
Represents the language in a linkage specification.
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.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
bool isRedeclaration() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false)
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S'...
CXXRecordDecl * getOrigin() const
Retrieve the type from which this base-paths search began.
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope...
TrivialSubobjectKind
The kind of subobject we are checking for triviality.
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.
bool isFunctionType() const
static const void * GetKeyForBase(ASTContext &Context, QualType BaseType)
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
QualType BuildDecltypeType(Expr *E, SourceLocation Loc, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
The noexcept specifier evaluates to false.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
ActionResult< Stmt * > StmtResult
static UsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr)
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
The template argument is a type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
ActionResult< ParsedType > TypeResult
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void addDecl(Decl *D)
Add the declaration D into this context.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
bool isInlineSpecified() const
A template-id, e.g., f<int>.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Represents a base class of a C++ class.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
bool isAnyMemberInitializer() const
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.
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
QualType getPointeeType() const
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
This is a scope that can contain a declaration.
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
IdentifierInfo * getIdentifier() const
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
static const void * GetKeyForMember(ASTContext &Context, CXXCtorInitializer *Member)
A use of a default initializer in a constructor or in aggregate initialization.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
A template argument list.
bool hasNonTrivialObjCLifetime() const
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
void setInvalidType(bool Val=true)
Expr * NoexceptExpr
Noexcept expression, if this is EST_ComputedNoexcept.
void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr, SourceLocation Loc)
PushNamespaceVisibilityAttr - Note that we've entered a namespace with a visibility attribute...
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.
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD)
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 MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static bool functionDeclHasDefaultArgument(const FunctionDecl *FD)
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
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...
Captures information about "declaration specifiers".
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
bool isExplicitSpecified() const
static bool CheckConstexprParameterTypes(Sema &SemaRef, const FunctionDecl *FD)
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
SourceLocation getIdentifierLoc() const
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization)
Perform semantic checking of a new function declaration.
void setDefaultArg(Expr *defarg)
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 NULL if there isn't one...
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
static bool isCompoundAssignmentOp(Opcode Opc)
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
A user-defined literal name, e.g., operator "" _i.
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
bool isObjCObjectPointerType() const
bool implicitCopyAssignmentHasConstParam() const
Determine whether an implicit copy assignment operator for this type would have a parameter with a co...
Look up a friend of a local class.
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this 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)
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter, but we can't parse it yet because we're inside a class definition.
The parameter type of a method or function.
static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, llvm::APSInt &Size)
void popCodeSynthesisContext()
void setParam(unsigned i, ParmVarDecl *VD)
bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range)
CheckSpecifiedExceptionType - Check if the given type is valid in an exception specification.
CallingConv getDefaultCallingConvention(bool isVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult{return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
TypeLoc getElementLoc() const
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.
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.
SourceLocation getOverrideLoc() const
void setUnsupportedFriend(bool Unsupported)
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
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...
Declaration of a class template.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
const PropertyData & getPropertyData() const
bool isOverrideSpecified() const
LookupResultKind getResultKind() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant, according to C++ [class.virtual]p5.
static bool checkTrivialSubobjectCall(Sema &S, SourceLocation SubobjLoc, QualType SubType, bool ConstRHS, Sema::CXXSpecialMember CSM, TrivialSubobjectKind Kind, bool Diagnose)
Check whether the special member selected for a given type would be trivial.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
unsigned getIndex() const
Retrieve the index of the template parameter.
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 needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
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.
const FunctionDecl * getOperatorDelete() const
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl * > &Ivars)
CollectIvarsToConstructOrDestruct - Collect those ivars which require initialization.
bool defaultedDestructorIsDeleted() const
true if a defaulted destructor for this class would be deleted.
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.
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.
static void CheckAbstractClassUsage(AbstractUsageInfo &Info, CXXMethodDecl *MD)
Check for invalid uses of an abstract type in a method declaration.
bool isIncompleteArrayType() const
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
TranslationUnitDecl - The top declaration context.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
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...
bool isSet() const
Deprecated.
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
SourceLocation getRAngleLoc() const
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 isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
QualType getElementType() const
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
bool hasQualifiers() const
Determine whether this type has any qualifiers.
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
SourceManager & SourceMgr
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
static bool findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, CXXMethodDecl **Selected)
Perform lookup for a special member of the specified kind, and determine whether it is trivial...
void setCanPassInRegisters(bool CanPass)
Set that we can pass this RecordDecl in registers.
const Expr * getInit(unsigned Init) const
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness, issuing any diagnostics required.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
An instance of this class represents the declaration of a property member.
AttributeList * getNext() const
An l-value expression is a reference to an object with independent storage.
StringRef getKindName() const
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
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 ...
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
void setLexicalDeclContext(DeclContext *DC)
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
NamedDecl - This represents a decl with a name.
bool isInvalidType() const
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
bool isModulePrivateSpecified() const
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared...
void setAccess(AccessSpecifier AS)
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
Represents a C++ namespace alias.
No keyword precedes the qualified type name.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
bool isConstQualified() const
Determine whether this type is const-qualified.
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Represents C++ using-directive.
SmallVector< std::pair< const CXXMethodDecl *, const CXXMethodDecl * >, 2 > DelayedExceptionSpecChecks
All the overriding functions seen during a class definition that had their exception spec checks dela...
void DiagnoseAbstractType(const CXXRecordDecl *RD)
static Expr * CastForMoving(Sema &SemaRef, Expr *E, QualType T=QualType())
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
Describes an entity that is being initialized.
virtual void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables)
Read the set of used vtables known to the external Sema source.
The global specifier '::'. There is no stored value.
The noexcept specifier is dependent.
The type of an arbitrary declaration.
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
NamespaceDecl * getStdNamespace() const
The object is actually the complete object.
SourceLocation getLocStart() const LLVM_READONLY
void setType(QualType newType)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
const TemplateArgument & getArgument() const
Wrapper for source info for pointers.
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
bool isExplicitSpecialization() const
SourceRange getSourceRange() const LLVM_READONLY
void WillReplaceSpecifier(bool ForceReplacement)
Wrapper for source info for block pointers.
void setDeletedAsWritten(bool D=true)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions, such as the default constructor, copy constructor, or destructor, to the given C++ class (C++ [special]p1).
bool hasInheritedAssignment() const
Determine whether this class has a using-declaration that names a base class assignment operator...
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
SmallVector< std::pair< CXXMethodDecl *, const FunctionProtoType * >, 2 > DelayedDefaultedMemberExceptionSpecs
All the members seen during a class definition which were both explicitly defaulted and had explicitl...
ArrayRef< QualType > exceptions() const
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
ExceptionSpecInfo ExceptionSpec
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
enum clang::UnqualifiedId::IdKind Kind
Declaration of a template function.
void clear()
Clears out any current state.
std::list< CXXBasePath >::iterator paths_iterator
Represents an implicitly-generated value initialization of an object of a given type.
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, AttributeList *MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
void PushFunctionScope()
Enter a new function scope.
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
void setElaboratedKeywordLoc(SourceLocation Loc)
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
static bool checkLiteralOperatorTemplateParameterList(Sema &SemaRef, FunctionTemplateDecl *TpDecl)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
bool hasUserDeclaredConstructor() const
Determine whether this class has any user-declared constructors.
A single template declaration.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this field is ...
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Decl * ActOnDeclarator(Scope *S, Declarator &D)
AttributeList - Represents a syntactic attribute.
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope...
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
bool hasInClassInitializer() const
hasInClassInitializer - Determine whether this member has a C++11 in-class initializer.
bool isPointerType() const
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.
unsigned getNumTemplateParameterLists() const
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
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.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
The subobject is a non-static data member.
SourceLocation getTemplateLoc() const