40 #include "llvm/ADT/STLExtras.h"
41 #include "llvm/ADT/SmallString.h"
45 using namespace clang;
57 class CheckDefaultArgumentVisitor
58 :
public StmtVisitor<CheckDefaultArgumentVisitor, bool> {
63 CheckDefaultArgumentVisitor(
Expr *defarg,
Sema *s)
64 : DefaultArg(defarg),
S(s) {}
74 bool CheckDefaultArgumentVisitor::VisitExpr(
Expr *
Node) {
75 bool IsInvalid =
false;
76 for (
Stmt *SubStmt : Node->children())
77 IsInvalid |= Visit(SubStmt);
84 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
DeclRefExpr *DRE) {
86 if (
ParmVarDecl *Param = dyn_cast<ParmVarDecl>(Decl)) {
96 diag::err_param_default_argument_references_param)
97 << Param->getDeclName() << DefaultArg->getSourceRange();
98 }
else if (
VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) {
102 if (VDecl->isLocalVarDecl())
104 diag::err_param_default_argument_references_local)
105 << VDecl->getDeclName() << DefaultArg->getSourceRange();
112 bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
CXXThisExpr *ThisE) {
117 diag::err_param_default_argument_references_this)
118 << ThisE->getSourceRange();
121 bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
PseudoObjectExpr *POE) {
129 E = OVE->getSourceExpr();
130 assert(E &&
"pseudo-object binding without source expression?");
138 bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
LambdaExpr *Lambda) {
146 diag::err_lambda_capture_default_arg);
193 "Must have noexcept result for EST_ComputedNoexcept.");
195 "Should not generate implicit declarations for dependent cases, "
196 "and don't know how to handle them anyway.");
208 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
210 "Shouldn't collect exceptions when throw-all is guaranteed.");
215 Exceptions.push_back(E);
243 if (Self->canThrow(E))
251 diag::err_typecheck_decl_incomplete_type)) {
252 Param->setInvalidDecl();
272 CheckCompletedExpr(Arg, EqualLoc);
283 for (
unsigned I = 0, N = InstPos->second.size();
I != N; ++
I)
284 InstPos->second[
I]->setUninstantiatedDefaultArg(Arg);
299 if (!param || !DefaultArg)
307 Diag(EqualLoc, diag::err_param_default_argument)
308 << DefaultArg->getSourceRange();
309 Param->setInvalidDecl();
315 Param->setInvalidDecl();
323 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
324 << DefaultArg->getSourceRange();
329 CheckDefaultArgumentVisitor DefaultArgChecker(DefaultArg,
this);
330 if (DefaultArgChecker.Visit(DefaultArg)) {
331 Param->setInvalidDecl();
361 Param->setInvalidDecl();
386 if (MightBeFunction) {
390 MightBeFunction =
false;
393 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
399 if (Toks->size() > 1)
401 Toks->back().getLocation());
404 Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
409 Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
415 MightBeFunction =
false;
421 for (
unsigned NumParams = FD->
getNumParams(); NumParams > 0; --NumParams) {
437 bool Invalid =
false;
443 ? New->getLexicalDeclContext()
444 : New->getDeclContext();
448 for (; PrevForDefaultArgs;
451 PrevForDefaultArgs = New->isLocalExternDecl()
466 if (PrevForDefaultArgs->isLocalExternDecl() != New->isLocalExternDecl()) {
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;
536 Diag(NewParam->getLocation(), DiagDefaultParamID)
541 for (
auto Older = PrevForDefaultArgs;
543 Older = Older->getPreviousDecl();
544 OldParam = Older->getParamDecl(p);
547 Diag(OldParam->getLocation(), diag::note_previous_definition)
549 }
else if (OldParamHasDfl) {
561 }
else if (NewParamHasDfl) {
564 Diag(NewParam->getLocation(),
565 diag::err_param_default_argument_template_redecl)
567 Diag(PrevForDefaultArgs->getLocation(),
568 diag::note_template_prev_declaration)
582 Diag(NewParam->getLocation(), diag::err_template_spec_default_arg)
598 = dyn_cast<CXXRecordDecl>(New->getDeclContext())) {
599 if (Record->getDescribedClassTemplate())
601 else if (isa<ClassTemplatePartialSpecializationDecl>(Record))
607 Diag(NewParam->getLocation(),
608 diag::err_param_default_argument_member_template_redecl)
618 if (isa<CXXConstructorDecl>(New) &&
622 if (NewSM != OldSM) {
625 Diag(NewParam->getLocation(), diag::err_default_arg_makes_ctor_special)
627 Diag(Old->getLocation(), diag::note_previous_declaration);
636 Diag(New->getLocation(), diag::err_constexpr_redecl_mismatch)
638 Diag(Old->getLocation(), diag::note_previous_declaration);
645 Diag(New->getLocation(), diag::err_inline_decl_follows_def) << New;
646 Diag(Def->getLocation(), diag::note_previous_definition);
654 if (Old->getFriendObjectKind() == Decl::FOK_Undeclared &&
656 Diag(New->getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
657 Diag(Old->getLocation(), diag::note_previous_declaration);
678 "Should only be called if types are otherwise the same.");
689 NewType =
P->getPointeeType();
705 New->setInvalidDecl();
717 for (p = 0; p < NumParams; ++p) {
729 unsigned LastMissingDefaultArg = 0;
730 for (; p < NumParams; ++p) {
733 if (Param->isInvalidDecl())
736 Diag(Param->getLocation(),
737 diag::err_param_default_argument_missing_name)
740 Diag(Param->getLocation(),
741 diag::err_param_default_argument_missing);
743 LastMissingDefaultArg = p;
747 if (LastMissingDefaultArg > 0) {
752 for (p = 0; p <= LastMissingDefaultArg; ++p) {
766 unsigned ArgIndex = 0;
770 i != e; ++i, ++ArgIndex) {
773 if (!(*i)->isDependentType() &&
775 diag::err_constexpr_non_literal_param,
777 isa<CXXConstructorDecl>(FD)))
793 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
812 Diag(NewFD->getLocation(), diag::err_constexpr_virtual_base)
813 << isa<CXXConstructorDecl>(NewFD)
815 for (
const auto &
I : RD->
vbases())
816 Diag(
I.getLocStart(),
817 diag::note_constexpr_virtual_base_here) <<
I.getSourceRange();
822 if (!isa<CXXConstructorDecl>(NewFD)) {
830 Diag(Method->getLocation(), diag::err_constexpr_virtual);
835 while (!WrittenVirtual->isVirtualAsWritten())
837 if (WrittenVirtual != Method)
838 Diag(WrittenVirtual->getLocation(),
839 diag::note_overridden_virtual_function);
847 diag::err_constexpr_non_literal_return))
868 for (
const auto *DclIt : DS->
decls()) {
869 switch (DclIt->getKind()) {
870 case Decl::StaticAssert:
872 case Decl::UsingShadow:
873 case Decl::UsingDirective:
874 case Decl::UnresolvedUsingTypename:
875 case Decl::UnresolvedUsingValue:
885 const auto *TN = cast<TypedefNameDecl>(DclIt);
886 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
888 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
891 << isa<CXXConstructorDecl>(Dcl);
898 case Decl::CXXRecord:
900 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition())
903 ? diag::warn_cxx11_compat_constexpr_type_definition
904 : diag::ext_constexpr_type_definition)
905 << isa<CXXConstructorDecl>(Dcl);
908 case Decl::EnumConstant:
909 case Decl::IndirectField:
919 const auto *VD = cast<VarDecl>(DclIt);
920 if (VD->isThisDeclarationADefinition()) {
921 if (VD->isStaticLocal()) {
922 SemaRef.
Diag(VD->getLocation(),
923 diag::err_constexpr_local_var_static)
924 << isa<CXXConstructorDecl>(Dcl)
928 if (!VD->getType()->isDependentType() &&
930 VD->getLocation(), VD->getType(),
931 diag::err_constexpr_local_var_non_literal_type,
932 isa<CXXConstructorDecl>(Dcl)))
934 if (!VD->getType()->isDependentType() &&
935 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
936 SemaRef.
Diag(VD->getLocation(),
937 diag::err_constexpr_local_var_no_init)
938 << isa<CXXConstructorDecl>(Dcl);
942 SemaRef.
Diag(VD->getLocation(),
944 ? diag::warn_cxx11_compat_constexpr_local_var
945 : diag::ext_constexpr_local_var)
946 << isa<CXXConstructorDecl>(Dcl);
950 case Decl::NamespaceAlias:
960 << isa<CXXConstructorDecl>(Dcl);
979 llvm::SmallSet<Decl*, 16> &
Inits,
981 if (Field->isInvalidDecl())
996 if (!Inits.count(Field)) {
998 SemaRef.
Diag(Dcl->getLocation(), diag::err_constexpr_ctor_missing_init);
1001 SemaRef.
Diag(Field->getLocation(), diag::note_constexpr_ctor_missing_init);
1007 if (!RD->
isUnion() || Inits.count(
I))
1019 switch (S->getStmtClass()) {
1020 case Stmt::NullStmtClass:
1024 case Stmt::DeclStmtClass:
1034 case Stmt::ReturnStmtClass:
1036 if (isa<CXXConstructorDecl>(Dcl)) {
1039 Cxx1yLoc = S->getLocStart();
1043 ReturnStmts.push_back(S->getLocStart());
1046 case Stmt::CompoundStmtClass: {
1049 Cxx1yLoc = S->getLocStart();
1052 for (
auto *BodyIt : CompStmt->
body()) {
1060 case Stmt::AttributedStmtClass:
1062 Cxx1yLoc = S->getLocStart();
1065 case Stmt::IfStmtClass: {
1068 Cxx1yLoc = S->getLocStart();
1081 case Stmt::WhileStmtClass:
1082 case Stmt::DoStmtClass:
1083 case Stmt::ForStmtClass:
1084 case Stmt::CXXForRangeStmtClass:
1085 case Stmt::ContinueStmtClass:
1091 Cxx1yLoc = S->getLocStart();
1092 for (
Stmt *SubStmt : S->children())
1099 case Stmt::SwitchStmtClass:
1100 case Stmt::CaseStmtClass:
1101 case Stmt::DefaultStmtClass:
1102 case Stmt::BreakStmtClass:
1106 Cxx1yLoc = S->getLocStart();
1107 for (
Stmt *SubStmt : S->children())
1120 Cxx1yLoc = S->getLocStart();
1124 SemaRef.
Diag(S->getLocStart(), diag::err_constexpr_body_invalid_stmt)
1125 << isa<CXXConstructorDecl>(Dcl);
1134 if (isa<CXXTryStmt>(Body)) {
1144 Diag(Body->getLocStart(), diag::err_constexpr_function_try_block)
1145 << isa<CXXConstructorDecl>(Dcl);
1155 for (
auto *BodyIt : CompBody->
body()) {
1160 if (Cxx1yLoc.isValid())
1163 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
1164 : diag::ext_constexpr_body_invalid_stmt)
1165 << isa<CXXConstructorDecl>(Dcl);
1168 = dyn_cast<CXXConstructorDecl>(Dcl)) {
1177 if (Constructor->getNumCtorInitializers() == 0 &&
1179 Diag(Dcl->getLocation(), diag::err_constexpr_union_ctor_no_init);
1182 }
else if (!Constructor->isDependentContext() &&
1183 !Constructor->isDelegatingConstructor()) {
1184 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
1188 bool AnyAnonStructUnionMembers =
false;
1189 unsigned Fields = 0;
1192 if (
I->isAnonymousStructOrUnion()) {
1193 AnyAnonStructUnionMembers =
true;
1201 if (AnyAnonStructUnionMembers ||
1202 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
1206 llvm::SmallSet<Decl*, 16>
Inits;
1207 for (
const auto *
I: Constructor->inits()) {
1211 Inits.insert(
ID->chain_begin(),
ID->chain_end());
1214 bool Diagnosed =
false;
1222 if (ReturnStmts.empty()) {
1230 Diag(Dcl->getLocation(),
1231 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
1232 : diag::err_constexpr_body_no_return);
1235 }
else if (ReturnStmts.size() > 1) {
1236 Diag(ReturnStmts.back(),
1238 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
1239 : diag::ext_constexpr_body_multiple_return);
1240 for (
unsigned I = 0;
I < ReturnStmts.size() - 1; ++
I)
1241 Diag(ReturnStmts[
I], diag::note_constexpr_body_previous_return);
1257 Diag(Dcl->getLocation(), diag::ext_constexpr_function_never_constant_expr)
1258 << isa<CXXConstructorDecl>(Dcl);
1259 for (
size_t I = 0, N = Diags.size();
I != N; ++
I)
1260 Diag(Diags[
I].first, Diags[
I].second);
1279 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
1281 CurDecl = dyn_cast_or_null<CXXRecordDecl>(
CurContext);
1300 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
1302 CurDecl = dyn_cast_or_null<CXXRecordDecl>(
CurContext);
1322 for (
const auto &
I : Current->
bases()) {
1334 Queue.push_back(Base);
1340 Current = Queue.pop_back_val();
1361 Diag(Class->getLocation(), diag::err_base_clause_on_union)
1368 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1381 ((BaseDecl = BaseDecl->getDefinition()) &&
1383 Diag(BaseLoc, diag::err_circular_inheritance)
1387 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
1396 Access, TInfo, EllipsisLoc);
1401 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
1408 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
1415 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
1427 diag::err_incomplete_base_class, SpecifierRange)) {
1428 Class->setInvalidDecl();
1434 assert(BaseDecl &&
"Record type has no declaration");
1436 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
1438 assert(CXXBaseDecl &&
"Base type is not a C++ type");
1447 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
1455 if (FinalAttr *FA = CXXBaseDecl->getAttr<FinalAttr>()) {
1456 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
1458 << FA->isSpelledAsSealed();
1459 Diag(CXXBaseDecl->getLocation(), diag::note_entity_declared_at)
1464 if (BaseDecl->isInvalidDecl())
1465 Class->setInvalidDecl();
1470 Access, TInfo, EllipsisLoc);
1497 if (!Attributes.
empty()) {
1500 if (
Attr->isInvalid() ||
1505 ? diag::warn_unknown_attribute_ignored
1506 : diag::err_base_specifier_attribute)
1520 Virtual, Access, TInfo,
1524 Class->setInvalidDecl();
1541 auto Decl = Rec->getAsCXXRecordDecl();
1544 for (
const auto &BaseSpec : Decl->bases()) {
1546 .getUnqualifiedType();
1547 if (Set.insert(Base).second)
1565 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
1572 unsigned NumGoodBases = 0;
1573 bool Invalid =
false;
1574 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
1584 Diag(Bases[idx]->getLocStart(),
1585 diag::err_duplicate_base_class)
1587 << Bases[idx]->getSourceRange();
1596 KnownBase = Bases[idx];
1597 Bases[NumGoodBases++] = Bases[idx];
1600 if (Bases.size() > 1)
1604 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
1615 if (RD->hasAttr<WeakAttr>())
1616 Class->addAttr(WeakAttr::CreateImplicit(
Context));
1622 Class->
setBases(Bases.data(), NumGoodBases);
1624 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
1626 QualType BaseType = Bases[idx]->getType();
1630 if (IndirectBaseTypes.count(CanonicalBase)) {
1634 = Class->
isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
1639 Diag(Bases[idx]->getLocStart (), diag::warn_inaccessible_base_class)
1641 << Bases[idx]->getSourceRange();
1643 assert(Bases[idx]->isVirtual());
1659 if (!ClassDecl || Bases.empty())
1682 if (BaseRD->isInvalidDecl() || DerivedRD->isInvalidDecl())
1716 assert(BasePathArray.empty() &&
"Base path array must be empty!");
1725 for (
unsigned I = Path.size();
I != 0; --
I) {
1726 if (Path[
I - 1].
Base->isVirtual()) {
1733 for (
unsigned I = Start, E = Path.size();
I !=
E; ++
I)
1734 BasePathArray.push_back(const_cast<CXXBaseSpecifier*>(Path[
I].Base));
1751 unsigned InaccessibleBaseID,
1752 unsigned AmbigiousBaseConvID,
1756 bool IgnoreAccess) {
1763 bool DerivationOkay =
IsDerivedFrom(Loc, Derived, Base, Paths);
1764 assert(DerivationOkay &&
1765 "Can only be used with a derived-to-base conversion");
1766 (void)DerivationOkay;
1769 if (!IgnoreAccess) {
1772 InaccessibleBaseID)) {
1788 if (AmbigiousBaseConvID) {
1798 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
1807 Diag(Loc, AmbigiousBaseConvID)
1808 << Derived << Base << PathDisplayStr << Range <<
Name;
1817 bool IgnoreAccess) {
1819 Derived, Base, diag::err_upcast_to_inaccessible_base,
1820 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
1821 BasePath, IgnoreAccess);
1838 std::string PathDisplayStr;
1839 std::set<unsigned> DisplayedPaths;
1841 Path != Paths.
end(); ++Path) {
1842 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
1845 PathDisplayStr +=
"\n ";
1847 for (CXXBasePath::const_iterator Element = Path->begin();
1848 Element != Path->end(); ++Element)
1849 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
1853 return PathDisplayStr;
1865 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
1874 if (D->isInvalidDecl())
1878 if (!D->hasAttr<OverrideAttr>() && !D->hasAttr<FinalAttr>())
1895 if (!OverloadedMethods.empty()) {
1896 if (OverrideAttr *OA = D->getAttr<OverrideAttr>()) {
1897 Diag(OA->getLocation(),
1898 diag::override_keyword_hides_virtual_member_function)
1899 <<
"override" << (OverloadedMethods.size() > 1);
1900 }
else if (FinalAttr *FA = D->getAttr<FinalAttr>()) {
1901 Diag(FA->getLocation(),
1902 diag::override_keyword_hides_virtual_member_function)
1903 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
1904 << (OverloadedMethods.size() > 1);
1907 MD->setInvalidDecl();
1915 if (OverrideAttr *OA = D->getAttr<OverrideAttr>()) {
1916 Diag(OA->getLocation(),
1917 diag::override_keyword_only_allowed_on_virtual_member_functions)
1919 D->dropAttr<OverrideAttr>();
1921 if (FinalAttr *FA = D->getAttr<FinalAttr>()) {
1922 Diag(FA->getLocation(),
1923 diag::override_keyword_only_allowed_on_virtual_member_functions)
1924 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
1926 D->dropAttr<FinalAttr>();
1935 bool HasOverriddenMethods =
1937 if (MD->hasAttr<OverrideAttr>() && !HasOverriddenMethods)
1938 Diag(MD->getLocation(), diag::err_function_marked_override_not_overriding)
1943 if (D->isInvalidDecl() || D->hasAttr<OverrideAttr>())
1946 if (!MD || MD->isImplicit() || MD->hasAttr<FinalAttr>() ||
1947 isa<CXXDestructorDecl>(MD))
1959 Diag(MD->getLocation(), diag::warn_function_marked_not_override_overriding)
1962 Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
1971 FinalAttr *FA = Old->getAttr<FinalAttr>();
1975 Diag(New->getLocation(), diag::err_final_function_overridden)
1977 << FA->isSpelledAsSealed();
1978 Diag(Old->getLocation(), diag::note_overridden_virtual_function);
1986 return !RD->isCompleteDefinition() ||
1987 !RD->hasTrivialDefaultConstructor() ||
1988 !RD->hasTrivialDestructor();
1994 if (it->isDeclspecPropertyAttribute())
2018 Expr *BitWidth =
static_cast<Expr*
>(BW);
2025 if (cast<CXXRecordDecl>(
CurContext)->isInterface()) {
2029 unsigned InvalidDecl;
2030 bool ShowDeclName =
true;
2040 ShowDeclName =
false;
2045 ShowDeclName =
false;
2060 Diag(Loc, diag::err_invalid_member_in_interface)
2061 << (InvalidDecl-1) << Name;
2063 Diag(Loc, diag::err_invalid_member_in_interface)
2064 << (InvalidDecl-1) <<
"";
2090 diag::err_storageclass_invalid_for_member);
2110 const char *PrevSpec;
2115 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
2119 const char *PrevSpec;
2125 "This is the only DeclSpec that should fail to be applied");
2129 isInstField =
false;
2140 Diag(Loc, diag::err_bad_variable_name)
2149 if (TemplateParameterLists.size()) {
2151 if (TemplateParams->
size()) {
2160 diag::err_template_member_noparams)
2186 if (MSPropertyAttr) {
2188 BitWidth, InitStyle, AS, MSPropertyAttr);
2191 isInstField =
false;
2194 BitWidth, InitStyle, AS);
2195 assert(Member &&
"HandleField never returns null");
2204 if (Member->isInvalidDecl()) {
2206 }
else if (isa<VarDecl>(Member) || isa<VarTemplateDecl>(Member)) {
2209 Diag(Loc, diag::err_static_not_bitfield)
2210 << Name << BitWidth->getSourceRange();
2211 }
else if (isa<TypedefDecl>(Member)) {
2213 Diag(Loc, diag::err_typedef_not_bitfield)
2214 << Name << BitWidth->getSourceRange();
2218 Diag(Loc, diag::err_not_integral_type_bitfield)
2219 << Name << cast<ValueDecl>(Member)->getType()
2220 << BitWidth->getSourceRange();
2224 Member->setInvalidDecl();
2227 Member->setAccess(AS);
2232 FunTmpl->getTemplatedDecl()->setAccess(AS);
2233 else if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(Member))
2234 VarTmpl->getTemplatedDecl()->setAccess(AS);
2245 if (
CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(Member))
2251 assert((Name || isInstField) &&
"No identifier for non-field ?");
2254 FieldDecl *FD = cast<FieldDecl>(Member);
2257 if (!
Diags.
isIgnored(diag::warn_unused_private_field, FD->getLocation())) {
2262 !FD->hasAttr<UnusedAttr>() &&
2273 class UninitializedFieldVisitor
2278 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
2281 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
2296 UninitializedFieldVisitor(
Sema &
S,
2297 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
2298 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
2299 : Inherited(S.
Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
2300 Constructor(nullptr), InitList(
false), InitListFieldDecl(nullptr) {}
2303 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
2304 bool CheckReferenceOnly) {
2306 bool ReferenceField =
false;
2311 Fields.push_back(FD);
2313 ReferenceField =
true;
2319 if (CheckReferenceOnly && !ReferenceField)
2325 for (
auto I = Fields.rbegin() + 1, E = Fields.rend();
I !=
E; ++
I) {
2326 UsedFieldIndex.push_back((*I)->getFieldIndex());
2329 for (
auto UsedIter = UsedFieldIndex.begin(),
2330 UsedEnd = UsedFieldIndex.end(),
2331 OrigIter = InitFieldIndex.begin(),
2332 OrigEnd = InitFieldIndex.end();
2333 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
2334 if (*UsedIter < *OrigIter)
2336 if (*UsedIter > *OrigIter)
2343 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
2358 if (isa<VarDecl>(SubME->getMemberDecl()))
2361 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
2366 AllPODFields =
false;
2368 Base = SubME->getBase();
2374 if (AddressOf && AllPODFields)
2380 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
2381 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
2384 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
2394 if (!Decls.count(FoundVD))
2399 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
2401 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
2406 if (CheckReferenceOnly && !IsReference)
2410 unsigned diag = IsReference
2411 ? diag::warn_reference_field_is_uninit
2412 : diag::warn_field_is_uninit;
2416 diag::note_uninit_in_this_constructor)
2421 void HandleValue(
Expr *E,
bool AddressOf) {
2424 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
2425 HandleMemberExpr(ME,
false ,
2431 Visit(CO->getCond());
2432 HandleValue(CO->getTrueExpr(), AddressOf);
2433 HandleValue(CO->getFalseExpr(), AddressOf);
2438 dyn_cast<BinaryConditionalOperator>(E)) {
2439 Visit(BCO->getCond());
2440 HandleValue(BCO->getFalseExpr(), AddressOf);
2445 HandleValue(OVE->getSourceExpr(), AddressOf);
2450 switch (BO->getOpcode()) {
2455 HandleValue(BO->getLHS(), AddressOf);
2456 Visit(BO->getRHS());
2459 Visit(BO->getLHS());
2460 HandleValue(BO->getRHS(), AddressOf);
2469 InitFieldIndex.push_back(0);
2470 for (
auto Child : ILE->
children()) {
2471 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
2472 CheckInitListExpr(SubList);
2476 ++InitFieldIndex.back();
2478 InitFieldIndex.pop_back();
2487 DeclsToRemove.clear();
2494 InitListFieldDecl = Field;
2495 InitFieldIndex.clear();
2496 CheckInitListExpr(ILE);
2510 HandleMemberExpr(ME,
true ,
false );
2519 Inherited::VisitImplicitCastExpr(E);
2525 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
2529 if (ICE->getCastKind() == CK_NoOp)
2530 ArgExpr = ICE->getSubExpr();
2531 HandleValue(ArgExpr,
false );
2534 Inherited::VisitCXXConstructExpr(E);
2539 if (isa<MemberExpr>(Callee)) {
2540 HandleValue(Callee,
false );
2546 Inherited::VisitCXXMemberCallExpr(E);
2555 HandleValue(E->
getArg(0),
false );
2561 Inherited::VisitCallExpr(E);
2567 if (isa<UnresolvedLookupExpr>(Callee))
2568 return Inherited::VisitCXXOperatorCallExpr(E);
2572 HandleValue(Arg->IgnoreParenImpCasts(),
false );
2582 DeclsToRemove.push_back(FD);
2585 HandleValue(E->
getLHS(),
false );
2590 Inherited::VisitBinaryOperator(E);
2600 HandleValue(ME->
getBase(),
true );
2605 Inherited::VisitUnaryOperator(E);
2615 static void DiagnoseUninitializedFields(
2619 Constructor->getLocation())) {
2623 if (Constructor->isInvalidDecl())
2632 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
2635 for (
auto *
I : RD->
decls()) {
2636 if (
auto *FD = dyn_cast<FieldDecl>(
I)) {
2637 UninitializedFields.insert(FD);
2638 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(
I)) {
2639 UninitializedFields.insert(IFD->getAnonField());
2643 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
2644 for (
auto I : RD->
bases())
2645 UninitializedBaseClasses.insert(
I.getType().getCanonicalType());
2647 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
2650 UninitializedFieldVisitor UninitializedChecker(SemaRef,
2651 UninitializedFields,
2652 UninitializedBaseClasses);
2654 for (
const auto *FieldInit : Constructor->
inits()) {
2655 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
2658 Expr *InitExpr = FieldInit->getInit();
2663 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
2664 InitExpr = Default->getExpr();
2668 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
2669 FieldInit->getAnyMember(),
2670 FieldInit->getBaseClass());
2672 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
2673 FieldInit->getAnyMember(),
2674 FieldInit->getBaseClass());
2700 "must set init style when field is created");
2703 D->setInvalidDecl();
2710 FD->setInvalidDecl();
2722 Init = Seq.Perform(*
this, Entity, Kind, InitExpr);
2724 FD->setInvalidDecl();
2734 FD->setInvalidDecl();
2738 InitExpr = Init.
get();
2752 DirectBaseSpec =
nullptr;
2753 for (
const auto &Base : ClassDecl->
bases()) {
2757 DirectBaseSpec = &Base;
2765 VirtualBaseSpec =
nullptr;
2766 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
2775 Path != Paths.
end(); ++Path) {
2776 if (Path->back().Base->isVirtual()) {
2777 VirtualBaseSpec = Path->back().Base;
2784 return DirectBaseSpec || VirtualBaseSpec;
2799 DS, IdLoc, InitList,
2819 DS, IdLoc, List, EllipsisLoc);
2828 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
2829 : ClassDecl(ClassDecl) {}
2831 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2833 if (
FieldDecl *Member = dyn_cast<FieldDecl>(ND))
2835 return isa<TypeDecl>(ND);
2892 if (!Result.
empty()) {
2894 if ((Member = dyn_cast<FieldDecl>(Result.
front())) ||
2897 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
2899 <<
SourceRange(IdLoc, Init->getSourceRange().getEnd());
2909 if (TemplateTypeTy) {
2925 bool NotUnknownSpecialization =
false;
2927 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
2928 NotUnknownSpecialization = !Record->hasAnyDependentBases();
2930 if (!NotUnknownSpecialization) {
2935 *MemberOrBase, IdLoc);
2949 llvm::make_unique<MemInitializerValidatorCCC>(ClassDecl),
2956 PDiag(diag::err_mem_init_not_member_or_class_suggest)
2957 << MemberOrBase <<
true);
2964 DirectBaseSpec, VirtualBaseSpec)) {
2969 PDiag(diag::err_mem_init_not_member_or_class_suggest)
2970 << MemberOrBase <<
false,
2976 diag::note_base_class_specified_here)
2985 if (!TyD && BaseType.
isNull()) {
2986 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
2987 << MemberOrBase <<
SourceRange(IdLoc,Init->getSourceRange().getEnd());
3031 if (Op->getOpcode() != UO_AddrOf)
3034 Init = Op->getSubExpr();
3048 IsPointer ? diag::warn_init_ptr_member_to_parameter_addr
3049 : diag::warn_bind_ref_member_to_parameter)
3050 << Member << Parameter << Init->getSourceRange();
3056 S.
Diag(Member->getLocation(), diag::note_ref_or_ptr_member_declared_here)
3057 << (
unsigned)IsPointer;
3065 assert((DirectMember || IndirectMember) &&
3066 "Member must be a FieldDecl or IndirectFieldDecl");
3071 if (Member->isInvalidDecl())
3075 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
3076 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
3077 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
3078 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
3091 bool InitList =
false;
3092 if (isa<InitListExpr>(Init)) {
3108 ExprResult MemberInit = InitSeq.Perform(*
this, MemberEntity, Kind, Args,
3119 if (MemberInit.isInvalid())
3122 Init = MemberInit.get();
3141 return Diag(NameLoc, diag::err_delegating_ctor)
3143 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
3145 bool InitList =
true;
3147 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
3149 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
3161 ExprResult DelegationInit = InitSeq.Perform(*
this, DelegationEntity, Kind,
3166 assert(cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor() &&
3167 "Delegating constructor with no target?");
3174 if (DelegationInit.isInvalid())
3185 DelegationInit = Init;
3188 DelegationInit.getAs<
Expr>(),
3200 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
3215 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
3244 if (!DirectBaseSpec && !VirtualBaseSpec) {
3253 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
3265 InitRange.
getEnd(), EllipsisLoc);
3272 if (DirectBaseSpec && VirtualBaseSpec)
3273 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
3278 BaseSpec = VirtualBaseSpec;
3281 bool InitList =
true;
3283 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
3285 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
3295 ExprResult BaseInit = InitSeq.Perform(*
this, BaseEntity, Kind, Args,
nullptr);
3320 InitRange.
getEnd(), EllipsisLoc);
3330 TargetType, ExprLoc);
3334 E->getSourceRange()).
get();
3350 bool IsInheritedVirtualBase,
3354 IsInheritedVirtualBase);
3358 switch (ImplicitInitKind) {
3364 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
None);
3370 bool Moving = ImplicitInitKind ==
IIK_Move;
3377 Constructor->getLocation(), ParamType,
3392 BasePath.push_back(BaseSpec);
3394 CK_UncheckedDerivedToBase,
3402 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
3425 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
3434 if (Field->isInvalidDecl())
3440 bool Moving = ImplicitInitKind ==
IIK_Move;
3448 Expr *MemberExprBase =
3463 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
3465 MemberLookup.resolveKind();
3493 bool InitializingArray =
false;
3496 InitializingArray =
true;
3501 llvm::raw_svector_ostream OS(Str);
3502 OS <<
"__i" << IndexVariables.size();
3507 IterationVarName, SizeType,
3510 IndexVariables.push_back(IterationVar);
3516 "Reference to invented variable cannot fail!");
3518 assert(!IterationVarRef.isInvalid() &&
3519 "Conversion of invented variable cannot fail!");
3523 IterationVarRef.get(),
3525 if (CtorArg.isInvalid())
3528 BaseType = Array->getElementType();
3532 if (Moving && InitializingArray)
3539 Entities.reserve(1 + IndexVariables.size());
3544 for (
unsigned I = 0, N = IndexVariables.size();
I != N; ++
I)
3558 = InitSeq.Perform(SemaRef, Entities.back(), InitKind,
3561 if (MemberInit.isInvalid())
3565 assert(IndexVariables.size() == 0 &&
3566 "Indirect field improperly initialized");
3570 MemberInit.getAs<
Expr>(),
3574 Loc, MemberInit.getAs<
Expr>(),
3576 IndexVariables.data(),
3577 IndexVariables.size());
3582 "Unhandled implicit init kind!");
3596 InitSeq.
Perform(SemaRef, InitEntity, InitKind,
None);
3618 SemaRef.
Diag(Constructor->getLocation(),
3619 diag::err_uninitialized_member_in_ctor)
3620 << (
int)Constructor->isImplicit()
3623 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
3628 SemaRef.
Diag(Constructor->getLocation(),
3629 diag::err_uninitialized_member_in_ctor)
3630 << (
int)Constructor->isImplicit()
3633 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
3653 CXXMemberInit =
nullptr;
3658 struct BaseAndFieldInfo {
3661 bool AnyErrorsInInits;
3663 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
3665 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
3668 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
3669 bool Generated = Ctor->isImplicit() || Ctor->
isDefaulted();
3680 bool isImplicitCopyOrMove()
const {
3691 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
3695 AllToInit.push_back(Init);
3704 bool isInactiveUnionMember(
FieldDecl *Field) {
3714 if (isImplicitCopyOrMove())
3732 bool isWithinInactiveUnionMember(
FieldDecl *Field,
3735 return isInactiveUnionMember(Field);
3737 for (
auto *C : Indirect->
chain()) {
3739 if (Field && isInactiveUnionMember(Field))
3754 if (!ArrayT->getSize())
3757 T = ArrayT->getElementType();
3766 if (Field->isInvalidDecl())
3772 return Info.addFieldInitializer(Init);
3786 if (Info.isWithinInactiveUnionMember(Field, Indirect))
3803 return Info.addFieldInitializer(Init);
3813 if (Info.AnyErrorsInInits)
3824 return Info.addFieldInitializer(Init);
3844 DiagnoseUninitializedFields(*
this, Constructor);
3854 if (!Initializers.empty()) {
3858 memcpy(baseOrMemberInitializers, Initializers.data(),
3865 Constructor->setInvalidDecl();
3870 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
3878 bool HadError =
false;
3880 for (
unsigned i = 0; i < Initializers.size(); i++) {
3889 for (
auto *C : F->chain()) {
3892 Info.ActiveUnionMember.insert(std::make_pair(
3897 Info.ActiveUnionMember.insert(std::make_pair(
3904 llvm::SmallPtrSet<CXXBaseSpecifier *, 16> DirectVBases;
3905 for (
auto &
I : ClassDecl->
bases()) {
3907 DirectVBases.insert(&
I);
3911 for (
auto &VBase : ClassDecl->
vbases()) {
3913 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
3921 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
3922 << VBase.getType() << ClassDecl;
3926 Info.AllToInit.push_back(
Value);
3927 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
3932 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
3935 &VBase, IsInheritedVirtualBase,
3941 Info.AllToInit.push_back(CXXBaseInit);
3946 for (
auto &Base : ClassDecl->
bases()) {
3948 if (Base.isVirtual())
3953 Info.AllToInit.push_back(
Value);
3954 }
else if (!AnyErrors) {
3963 Info.AllToInit.push_back(CXXBaseInit);
3968 for (
auto *Mem : ClassDecl->
decls()) {
3969 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
3974 if (F->isUnnamedBitfield())
3980 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
3989 if (Info.isImplicitCopyOrMove())
3992 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
3993 if (F->getType()->isIncompleteArrayType()) {
3995 "Incomplete array type is not valid");
4007 unsigned NumInitializers = Info.AllToInit.size();
4008 if (NumInitializers > 0) {
4012 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
4029 for (
auto *Field : RD->
fields())
4057 bool ShouldCheckOrder =
false;
4058 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4060 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
4062 ShouldCheckOrder =
true;
4066 if (!ShouldCheckOrder)
4077 for (
const auto &VBase : ClassDecl->
vbases())
4081 for (
const auto &Base : ClassDecl->
bases()) {
4082 if (Base.isVirtual())
4088 for (
auto *Field : ClassDecl->
fields()) {
4095 unsigned NumIdealInits = IdealInitKeys.size();
4096 unsigned IdealIndex = 0;
4099 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4105 for (; IdealIndex != NumIdealInits; ++IdealIndex)
4106 if (InitKey == IdealInitKeys[IdealIndex])
4112 if (IdealIndex == NumIdealInits && PrevInit) {
4115 diag::warn_initializer_out_of_order);
4128 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
4129 if (InitKey == IdealInitKeys[IdealIndex])
4132 assert(IdealIndex < NumIdealInits &&
4133 "initializer not found in initializer list");
4141 bool CheckRedundantInit(
Sema &S,
4151 diag::err_multiple_mem_initialization)
4156 assert(BaseClass &&
"neither field nor base");
4158 diag::err_multiple_base_initialization)
4168 typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
4169 typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
4171 bool CheckRedundantUnionInit(
Sema &S,
4173 RedundantUnionMap &Unions) {
4180 UnionEntry &En = Unions[Parent];
4181 if (En.first && En.first != Child) {
4183 diag::err_multiple_mem_union_initialization)
4186 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
4187 << 0 << En.second->getSourceRange();
4199 Parent = cast<RecordDecl>(Parent->getDeclContext());
4211 if (!ConstructorDecl)
4220 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
4227 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
4230 RedundantUnionMap MemberUnions;
4232 bool HadError =
false;
4233 for (
unsigned i = 0; i < MemInits.size(); i++) {
4241 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
4242 CheckRedundantUnionInit(*
this, Init, MemberUnions))
4246 if (CheckRedundantInit(*
this, Init, Members[Key]))
4251 if (MemInits.size() != 1) {
4253 diag::err_delegating_initializer_alone)
4254 << Init->
getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
4270 DiagnoseUninitializedFields(*
this, Constructor);
4287 for (
auto *Field : ClassDecl->
fields()) {
4288 if (Field->isInvalidDecl())
4302 if (FieldClassDecl->isInvalidDecl())
4311 assert(Dtor &&
"No dtor found for FieldClassDecl!");
4313 PDiag(diag::err_access_dtor_field)
4321 llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
4324 for (
const auto &Base : ClassDecl->
bases()) {
4329 if (Base.isVirtual())
4330 DirectVirtualBases.insert(RT);
4334 if (BaseClassDecl->isInvalidDecl())
4340 assert(Dtor &&
"No dtor found for BaseClassDecl!");
4344 PDiag(diag::err_access_dtor_base)
4346 << Base.getSourceRange(),
4354 for (
const auto &VBase : ClassDecl->
vbases()) {
4359 if (DirectVirtualBases.count(RT))
4364 if (BaseClassDecl->isInvalidDecl())
4370 assert(Dtor &&
"No dtor found for BaseClassDecl!");
4372 ClassDecl->getLocation(), Dtor,
4373 PDiag(diag::err_access_dtor_vbase)
4379 diag::err_access_dtor_vbase, 0, ClassDecl->getLocation(),
4393 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
4395 DiagnoseUninitializedFields(*
this, Constructor);
4448 llvm::SmallPtrSet<const CXXMethodDecl *, 8> SeenPureMethods;
4451 MEnd = FinalOverriders.end();
4455 SOEnd = M->second.end();
4456 SO != SOEnd; ++SO) {
4463 if (SO->second.size() != 1)
4466 if (!SO->second.front().Method->isPure())
4469 if (!SeenPureMethods.insert(SO->second.front().Method).second)
4472 Diag(SO->second.front().Method->getLocation(),
4473 diag::note_pure_virtual_function)
4474 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
4484 struct AbstractUsageInfo {
4491 : S(S), Record(Record),
4492 AbstractType(S.
Context.getCanonicalType(
4493 S.
Context.getTypeDeclType(Record))),
4497 if (Invalid)
return;
4505 struct CheckAbstractUsage {
4506 AbstractUsageInfo &Info;
4509 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
4510 : Info(Info), Ctx(Ctx) {}
4514 #define ABSTRACT_TYPELOC(CLASS, PARENT)
4515 #define TYPELOC(CLASS, PARENT) \
4516 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break;
4517 #include "clang/AST/TypeLocNodes.def"
4548 #define CheckPolymorphic(Type) \
4549 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \
4550 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \
4565 return Visit(
Next, Sel);
4575 T = Info.S.Context.getBaseElementType(T);
4578 if (CT != Info.AbstractType)
return;
4582 Info.S.Diag(Ctx->getLocation(), diag::err_array_of_abstract_type)
4583 << T << TL.getSourceRange();
4585 Info.S.Diag(Ctx->getLocation(), diag::err_abstract_type_in_decl)
4586 << Sel << T << TL.getSourceRange();
4588 Info.DiagnoseAbstractType();
4594 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
4617 for (
auto *D : RD->
decls()) {
4618 if (D->isImplicit())
continue;
4621 if (isa<CXXMethodDecl>(D)) {
4623 }
else if (isa<FunctionTemplateDecl>(D)) {
4624 FunctionDecl *FD = cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
4628 }
else if (isa<FieldDecl>(D)) {
4632 }
else if (isa<VarDecl>(D)) {
4633 VarDecl *VD = cast<VarDecl>(D);
4638 }
else if (isa<CXXRecordDecl>(D)) {
4640 }
else if (isa<ClassTemplateDecl>(D)) {
4642 cast<ClassTemplateDecl>(D)->getTemplatedDecl());
4652 assert(ClassAttr->
getKind() == attr::DLLExport);
4661 for (Decl *Member : Class->
decls()) {
4666 if (Member->getAttr<DLLExportAttr>()) {
4667 if (MD->isUserProvided()) {
4678 }
else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
4679 MD->isCopyAssignmentOperator() ||
4680 MD->isMoveAssignmentOperator()) {
4707 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
4708 if (
Attr *TemplateAttr =
4709 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
4710 auto *A = cast<InheritableAttr>(TemplateAttr->clone(
getASTContext()));
4711 A->setInherited(
true);
4721 Diag(Class->getLocation(), diag::err_attribute_dll_not_extern)
4722 << Class << ClassAttr;
4729 for (Decl *Member : Class->
decls()) {
4730 if (!isa<VarDecl>(Member) && !isa<CXXMethodDecl>(Member))
4733 if (!MemberAttr || MemberAttr->
isInherited() || Member->isInvalidDecl())
4737 diag::err_attribute_dll_member_of_dll_class)
4738 << MemberAttr << ClassAttr;
4740 Member->setInvalidDecl();
4749 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
4756 Class->dropAttr<DLLExportAttr>();
4766 for (Decl *Member : Class->
decls()) {
4776 if (MD->isDeleted())
4779 if (MD->isInlined()) {
4788 if ((MD->isMoveAssignmentOperator() ||
4796 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->isTrivial())
4801 if (!cast<NamedDecl>(Member)->isExternallyVisible())
4807 NewAttr->setInherited(
true);
4808 Member->addAttr(NewAttr);
4835 NewAttr->setInherited(
true);
4836 BaseTemplateSpec->addAttr(NewAttr);
4857 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
4861 Diag(BaseTemplateSpec->getLocation(),
4862 diag::note_template_class_explicit_specialization_was_here)
4863 << BaseTemplateSpec;
4866 diag::note_template_class_instantiation_was_here)
4867 << BaseTemplateSpec;
4876 cast<CXXConstructorDecl>(MD));
4894 llvm_unreachable(
"Invalid special member.");
4905 if (Record->
isAbstract() && !Record->isInvalidDecl()) {
4906 AbstractUsageInfo Info(*
this, Record);
4916 bool Complained =
false;
4917 for (
const auto *F : Record->
fields()) {
4918 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
4921 if (F->getType()->isReferenceType() ||
4922 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
4924 Diag(Record->getLocation(), diag::warn_no_constructor_for_refconst)
4929 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
4930 << F->getType()->isReferenceType()
4931 << F->getDeclName();
4950 isa<IndirectFieldDecl>(D)) {
4951 Diag(D->getLocation(), diag::err_member_name_of_class)
4962 !Record->hasAttr<FinalAttr>())
4963 Diag(dtor ? dtor->getLocation() : Record->getLocation(),
4968 if (FinalAttr *FA = Record->getAttr<FinalAttr>()) {
4969 Diag(Record->getLocation(), diag::warn_abstract_final_class)
4970 << FA->isSpelledAsSealed();
4975 bool HasMethodWithOverrideControl =
false,
4976 HasOverridingMethodWithoutOverrideControl =
false;
4978 for (
auto *M : Record->
methods()) {
4983 if (M->hasAttr<OverrideAttr>())
4984 HasMethodWithOverrideControl =
true;
4985 else if (M->size_overridden_methods() > 0)
4986 HasOverridingMethodWithoutOverrideControl =
true;
4988 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted())
4994 if (!M->isImplicit() && !M->isUserProvided()) {
5003 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
5004 M->hasAttr<DLLExportAttr>()) {
5009 M->dropAttr<DLLExportAttr>();
5011 if (M->hasAttr<DLLExportAttr>()) {
5019 if (HasMethodWithOverrideControl &&
5020 HasOverridingMethodWithoutOverrideControl) {
5023 for (
auto *M : Record->
methods())
5038 Diag(Record->getLocation(), diag::warn_cxx_ms_struct);
5055 unsigned FieldQuals,
bool ConstRHS) {
5056 unsigned LHSQuals = 0;
5058 LHSQuals = FieldQuals;
5060 unsigned RHSQuals = FieldQuals;
5070 LHSQuals & Qualifiers::Const,
5071 LHSQuals & Qualifiers::Volatile);
5081 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
5087 : S(S), UseLoc(UseLoc) {
5088 bool DiagnosedMultipleConstructedBases =
false;
5090 UsingDecl *ConstructedBaseUsing =
nullptr;
5094 for (
auto *D : Shadow->
redecls()) {
5095 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
5096 auto *DNominatedBase = DShadow->getNominatedBaseClass();
5097 auto *DConstructedBase = DShadow->getConstructedBaseClass();
5099 InheritedFromBases.insert(
5100 std::make_pair(DNominatedBase->getCanonicalDecl(),
5101 DShadow->getNominatedBaseClassShadowDecl()));
5102 if (DShadow->constructsVirtualBase())
5103 InheritedFromBases.insert(
5104 std::make_pair(DConstructedBase->getCanonicalDecl(),
5105 DShadow->getConstructedBaseClassShadowDecl()));
5107 assert(DNominatedBase == DConstructedBase);
5112 if (!ConstructedBase) {
5113 ConstructedBase = DConstructedBase;
5114 ConstructedBaseUsing = D->getUsingDecl();
5115 }
else if (ConstructedBase != DConstructedBase &&
5116 !Shadow->isInvalidDecl()) {
5117 if (!DiagnosedMultipleConstructedBases) {
5118 S.
Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
5120 S.
Diag(ConstructedBaseUsing->getLocation(),
5121 diag::note_ambiguous_inherited_constructor_using)
5123 DiagnosedMultipleConstructedBases =
true;
5125 S.
Diag(D->getUsingDecl()->getLocation(),
5126 diag::note_ambiguous_inherited_constructor_using)
5127 << DConstructedBase;
5131 if (DiagnosedMultipleConstructedBases)
5132 Shadow->setInvalidDecl();
5138 std::pair<CXXConstructorDecl *, bool>
5141 if (It == InheritedFromBases.end())
5142 return std::make_pair(
nullptr,
false);
5146 return std::make_pair(
5148 It->second->constructsVirtualBase());
5151 return std::make_pair(Ctor,
false);
5165 if (InheritedCtor) {
5168 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
5170 return BaseCtor->isConstexpr();
5234 if (Ctor && ClassDecl->
isUnion())
5253 for (
const auto &B : ClassDecl->
bases()) {
5255 if (!BaseType)
continue;
5259 InheritedCtor, Inherited))
5270 for (
const auto *F : ClassDecl->
fields()) {
5271 if (F->isInvalidDecl())
5277 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
5280 ConstArg && !F->isMutable()))
5309 assert(cast<CXXConstructorDecl>(MD)->getInheritedConstructor() &&
5310 "only special members have implicit exception specs");
5312 cast<CXXConstructorDecl>(MD));
5355 "not an explicitly-defaulted special member");
5361 bool HadError =
false;
5370 unsigned ExpectedParams = 1;
5377 Diag(MD->getLocation(), diag::err_defaulted_special_member_params)
5381 Diag(MD->getLocation(), diag::err_defaulted_special_member_variadic)
5388 bool CanHaveConstParam =
false;
5401 Diag(MD->getLocation(), diag::err_defaulted_special_member_return_type)
5408 Diag(MD->getLocation(), diag::err_defaulted_special_member_quals)
5416 bool HasConstParam =
false;
5423 Diag(MD->getLocation(),
5424 diag::err_defaulted_special_member_volatile_param) << CSM;
5428 if (HasConstParam && !CanHaveConstParam) {
5430 Diag(MD->getLocation(),
5431 diag::err_defaulted_special_member_copy_const_param)
5435 Diag(MD->getLocation(),
5436 diag::err_defaulted_special_member_move_const_param)
5441 }
else if (ExpectedParams) {
5445 Diag(MD->getLocation(), diag::err_defaulted_copy_assign_not_ref);
5459 : isa<CXXConstructorDecl>(MD)) &&
5462 Diag(MD->
getLocStart(), diag::err_incorrect_defaulted_constexpr) << CSM;
5496 llvm::makeArrayRef(&ArgType,
5508 Diag(MD->getLocation(), diag::err_out_of_line_default_deletes) << CSM;
5515 MD->setInvalidDecl();
5535 .getExceptionSpec();
5541 PDiag(diag::err_incorrect_defaulted_exception_spec)
5544 SpecifiedType, MD->getLocation());
5556 for (
auto &Check : Checks)
5561 for (
auto &Spec : Specs)
5566 struct SpecialMemberDeletionInfo {
5574 bool IsConstructor, IsAssignment, IsMove, ConstArg;
5577 bool AllFieldsAreConst;
5582 : S(S), MD(MD), CSM(CSM), ICI(ICI), Diagnose(Diagnose),
5584 ConstArg(
false), Loc(MD->getLocation()), AllFieldsAreConst(
true) {
5588 IsConstructor =
true;
5591 IsConstructor =
true;
5595 IsAssignment =
true;
5598 IsAssignment =
true;
5604 llvm_unreachable(
"invalid special member kind");
5610 ConstArg = RT->getPointeeType().isConstQualified();
5622 unsigned Quals,
bool IsMutable) {
5624 ConstArg && !IsMutable);
5627 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
5630 bool shouldDeleteForField(
FieldDecl *FD);
5631 bool shouldDeleteForAllConstMembers();
5633 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
5635 bool shouldDeleteForSubobjectCall(Subobject Subobj,
5637 bool IsDtorCallInCtor);
5645 bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
5665 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
5667 bool IsDtorCallInCtor) {
5674 DiagKind = !Decl ? 0 : 1;
5677 else if (!isAccessible(Subobj, Decl))
5694 S.
Diag(Field->getLocation(),
5695 diag::note_deleted_special_member_class_subobject)
5696 << getEffectiveCSM() << MD->
getParent() <<
true
5697 << Field << DiagKind << IsDtorCallInCtor;
5701 diag::note_deleted_special_member_class_subobject)
5702 << getEffectiveCSM() << MD->
getParent() <<
false
5703 << Base->
getType() << DiagKind << IsDtorCallInCtor;
5716 bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
5719 bool IsMutable = Field && Field->
isMutable();
5737 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
5744 if (IsConstructor) {
5747 false,
false,
false,
false,
false);
5748 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
5757 bool SpecialMemberDeletionInfo::shouldDeleteForBase(
CXXBaseSpecifier *Base) {
5769 ->getInheritedConstructor()
5773 if (BaseCtor->isDeleted() && Diagnose) {
5775 diag::note_deleted_special_member_class_subobject)
5776 << getEffectiveCSM() << MD->
getParent() <<
false
5777 << Base->
getType() << 1 <<
false;
5780 return BaseCtor->isDeleted();
5783 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
5788 bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
5797 S.
Diag(FD->getLocation(), diag::note_deleted_default_ctor_uninit_field)
5798 << !!ICI << MD->
getParent() << FD << FieldType << 0;
5809 S.
Diag(FD->getLocation(), diag::note_deleted_default_ctor_uninit_field)
5815 AllFieldsAreConst =
false;
5821 S.
Diag(FD->getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
5825 }
else if (IsAssignment) {
5829 S.
Diag(FD->getLocation(), diag::note_deleted_assign_field)
5830 << IsMove << MD->
getParent() << FD << FieldType << 0;
5837 S.
Diag(FD->getLocation(), diag::note_deleted_assign_field)
5845 if (!inUnion() && FieldRecord->
isUnion() &&
5847 bool AllVariantFieldsAreConst =
true;
5850 for (
auto *UI : FieldRecord->
fields()) {
5854 AllVariantFieldsAreConst =
false;
5857 if (UnionFieldRecord &&
5858 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
5867 S.
Diag(FieldRecord->getLocation(),
5868 diag::note_deleted_default_ctor_all_const)
5878 if (shouldDeleteForClassSubobject(FieldRecord, FD,
5889 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
5896 diag::note_deleted_default_ctor_all_const)
5909 if (MD->isInvalidDecl())
5913 if (!
LangOpts.CPlusPlus11 || RD->isInvalidDecl())
5923 Diag(RD->getLocation(), diag::note_lambda_decl);
5938 if (MD->isImplicit() &&
5946 if (!Diagnose)
return true;
5949 for (
auto *
I : RD->
ctors()) {
5950 if (
I->isMoveConstructor()) {
5951 UserDeclaredMove =
I;
5955 assert(UserDeclaredMove);
5958 if (!Diagnose)
return true;
5962 if (
I->isMoveAssignmentOperator()) {
5963 UserDeclaredMove =
I;
5967 assert(UserDeclaredMove);
5970 if (UserDeclaredMove) {
5971 Diag(UserDeclaredMove->getLocation(),
5972 diag::note_deleted_copy_user_declared_move)
5990 OperatorDelete,
false)) {
5992 Diag(RD->getLocation(), diag::note_deleted_dtor_no_operator_delete);
5997 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
5999 for (
auto &BI : RD->
bases())
6000 if (!BI.isVirtual() &&
6001 SMI.shouldDeleteForBase(&BI))
6006 if (!RD->
isAbstract() || !SMI.IsConstructor) {
6007 for (
auto &BI : RD->
vbases())
6008 if (SMI.shouldDeleteForBase(&BI))
6012 for (
auto *FI : RD->
fields())
6013 if (!FI->isInvalidDecl() && !FI->isUnnamedBitfield() &&
6014 SMI.shouldDeleteForField(FI))
6017 if (SMI.shouldDeleteForAllConstMembers())
6042 *Selected =
nullptr;
6046 llvm_unreachable(
"not a special member");
6064 for (
auto *CI : RD->
ctors()) {
6065 if (!CI->isDefaultConstructor())
6072 *Selected = DefCtor;
6101 }
else if (!Selected) {
6109 goto NeedOverloadResolution;
6119 }
else if (!Selected) {
6124 goto NeedOverloadResolution;
6128 NeedOverloadResolution:
6152 llvm_unreachable(
"unknown special method kind");
6156 for (
auto *CI : RD->
ctors())
6157 if (!CI->isImplicit())
6161 typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
6164 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
6194 ConstRHS, Diagnose ? &Selected :
nullptr))
6202 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
6205 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
6206 }
else if (!Selected)
6207 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
6211 S.
Diag(Selected->getLocation(), diag::note_nontrivial_user_provided)
6212 << Kind << SubType.getUnqualifiedType() << CSM;
6214 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
6215 << Kind << SubType.getUnqualifiedType() << CSM;
6216 S.
Diag(Selected->getLocation(), diag::note_declared_at);
6220 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
6221 << Kind << SubType.getUnqualifiedType() << CSM;
6235 bool ConstArg,
bool Diagnose) {
6236 for (
const auto *FI : RD->
fields()) {
6237 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
6243 if (FI->isAnonymousStructOrUnion()) {
6245 CSM, ConstArg, Diagnose))
6256 S.
Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI;
6267 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
6272 bool ConstRHS = ConstArg && !FI->isMutable();
6300 bool ConstArg =
false;
6319 Diag(Param0->getLocation(), diag::note_nontrivial_param_type)
6336 Diag(Param0->getLocation(), diag::note_nontrivial_param_type)
6345 llvm_unreachable(
"not a special member");
6351 diag::note_nontrivial_default_arg)
6357 Diag(MD->getLocation(), diag::note_nontrivial_variadic);
6370 for (
const auto &BI : RD->bases())
6395 Diag(MD->getLocation(), diag::note_nontrivial_virtual_dtor) << RD;
6406 if (RD->getNumVBases()) {
6416 for (
const auto *MI : RD->methods()) {
6417 if (MI->isVirtual()) {
6419 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
6424 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
6432 struct FindHiddenVirtualMethod {
6435 llvm::SmallPtrSet<const CXXMethodDecl *, 8> OverridenAndUsingBaseMethods;
6440 static bool CheckMostOverridenMethods(
6442 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
6448 if (CheckMostOverridenMethods(*
I, Methods))
6464 bool foundSameNameMethod =
false;
6471 foundSameNameMethod =
true;
6488 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
6489 overloadedMethods.push_back(MD);
6493 if (foundSameNameMethod)
6494 OverloadedMethods.append(overloadedMethods.begin(),
6495 overloadedMethods.end());
6496 return foundSameNameMethod;
6503 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
6522 FindHiddenVirtualMethod FHVM;
6533 ND = shad->getTargetDecl();
6539 OverloadedMethods = FHVM.OverloadedMethods;
6544 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
6547 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
6549 Diag(overloadedMD->getLocation(), PD);
6556 if (MD->isInvalidDecl())
6559 if (
Diags.
isIgnored(diag::warn_overloaded_virtual, MD->getLocation()))
6564 if (!OverloadedMethods.empty()) {
6565 Diag(MD->getLocation(), diag::warn_overloaded_virtual)
6566 << MD << (OverloadedMethods.size() > 1);
6583 if (l->getKind() != AttributeList::AT_Visibility)
6586 Diag(l->getLoc(), diag::warn_attribute_after_definition_ignored) <<
6596 dyn_cast_or_null<CXXRecordDecl>(TagDecl));
6676 D = TD->getTemplatedDecl();
6678 if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
6679 ParameterLists.push_back(PSD->getTemplateParameters());
6682 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
6683 ParameterLists.push_back(DD->getTemplateParameterList(i));
6687 ParameterLists.push_back(FTD->getTemplateParameters());
6691 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
6692 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
6693 ParameterLists.push_back(TD->getTemplateParameterList(i));
6697 ParameterLists.push_back(CTD->getTemplateParameters());
6703 if (Params->size() > 0)
6708 if (Param->getDeclName()) {
6719 if (!RecordD)
return;
6726 if (!RecordD)
return;
6796 if (!Method->isInvalidDecl())
6884 return Constructor->setInvalidDecl();
6891 if (!Constructor->isInvalidDecl() &&
6901 const char *ConstRef
6904 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
6909 Constructor->setInvalidDecl();
6923 if (!Destructor->isImplicit())
6924 Loc = Destructor->getLocation();
6926 Loc = RD->getLocation();
6936 if (!OperatorDelete)
6963 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
6966 if (TST->isTypeAlias())
6968 << DeclaratorType << 1;
7137 bool NeedsTypedef =
false;
7141 bool PastFunctionChunk =
false;
7143 switch (Chunk.Kind) {
7145 if (!PastFunctionChunk) {
7146 if (Chunk.Fun.HasTrailingReturnType) {
7151 PastFunctionChunk =
true;
7156 NeedsTypedef =
true;
7178 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
7179 DB << Before <<
After;
7181 if (!NeedsTypedef) {
7185 if (After.isInvalid() && ConvTSI) {
7233 diag::warn_cxx98_compat_explicit_conversion_functions :
7234 diag::ext_explicit_conversion_functions)
7243 assert(Conversion &&
"Expected to receive a conversion function declaration");
7245 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Conversion->getDeclContext());
7261 ConvType = ConvTypeRef->getPointeeType();
7265 else if (ConvType->isRecordType()) {
7267 if (ConvType == ClassType)
7268 Diag(Conversion->getLocation(), diag::warn_conv_to_self_not_used)
7270 else if (
IsDerivedFrom(Conversion->getLocation(), ClassType, ConvType))
7271 Diag(Conversion->getLocation(), diag::warn_conv_to_base_not_used)
7272 << ClassType << ConvType;
7273 }
else if (ConvType->isVoidType()) {
7274 Diag(Conversion->getLocation(), diag::warn_conv_to_void_not_used)
7275 << ClassType << ConvType;
7280 return ConversionTemplate;
7295 assert(*IsInline != PrevNS->
isInline());
7303 if (*IsInline && II && II->
getName().startswith(
"__atomic") &&
7307 NS = NS->getPreviousDecl())
7308 NS->setInline(*IsInline);
7311 for (
auto *
I : PrevNS->
decls())
7312 if (
auto *ND = dyn_cast<NamedDecl>(
I))
7320 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
7323 S.
Diag(Loc, diag::err_inline_namespace_mismatch) << *IsInline;
7325 S.
Diag(PrevNS->getLocation(), diag::note_previous_definition);
7342 bool IsInline = InlineLoc.
isValid();
7343 bool IsInvalid =
false;
7345 bool AddToKnown =
false;
7365 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
7369 if (IsInline != PrevNS->
isInline())
7372 }
else if (PrevDecl) {
7374 Diag(Loc, diag::err_redefinition_different_kind)
7376 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
7379 }
else if (II->
isStr(
"std") &&
7385 AddToKnown = !IsInline;
7388 AddToKnown = !IsInline;
7402 if (PrevNS && IsInline != PrevNS->
isInline())
7408 StartLoc, Loc, II, PrevNS);
7410 Namespc->setInvalidDecl();
7415 if (
const VisibilityAttr *
Attr = Namespc->getAttr<VisibilityAttr>())
7421 KnownNamespaces[Namespc] =
false;
7429 TU->setAnonymousNamespace(Namespc);
7431 cast<NamespaceDecl>(Parent)->setAnonymousNamespace(Namespc);
7480 return AD->getNamespace();
7481 return dyn_cast_or_null<NamespaceDecl>(D);
7487 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
7488 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
7491 if (Namespc->hasAttr<VisibilityAttr>())
7496 return cast_or_null<CXXRecordDecl>(
7501 return cast_or_null<NamespaceDecl>(
7524 "Looking for std::initializer_list outside of C++.");
7539 if (!Specialization)
7546 Template = dyn_cast_or_null<ClassTemplateDecl>(
7547 TST->getTemplateName().getAsTemplateDecl());
7548 Arguments = TST->getArgs();
7559 TemplateClass->getDeclContext()))
7566 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
7585 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
7592 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
7597 Result.suppressDiagnostics();
7600 S.
Diag(Found->getLocation(), diag::err_malformed_std_initializer_list);
7608 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
7609 S.
Diag(Template->getLocation(), diag::err_malformed_std_initializer_list);
7652 case Decl::TranslationUnit:
7654 case Decl::LinkageSpec:
7666 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
7668 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
7682 llvm::make_unique<NamespaceValidatorCCC>(),
7685 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
7686 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
7687 Ident->
getName().equals(CorrectedStr);
7689 S.
PDiag(diag::err_using_directive_member_suggest)
7690 << Ident << DC << DroppedSpecifier << SS.getRange(),
7691 S.
PDiag(diag::note_namespace_defined_here));
7694 S.
PDiag(diag::err_using_directive_suggest) << Ident,
7695 S.
PDiag(diag::note_namespace_defined_here));
7697 R.
addDecl(Corrected.getFoundDecl());
7710 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
7711 assert(NamespcName &&
"Invalid NamespcName.");
7712 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
7735 NamespcName->
isStr(
"std")) {
7736 Diag(IdentLoc, diag::ext_using_undefined_std);
7747 assert(NS &&
"expected namespace decl");
7764 DeclContext *CommonAncestor = cast<DeclContext>(NS);
7766 CommonAncestor = CommonAncestor->
getParent();
7770 IdentLoc, Named, CommonAncestor);
7774 Diag(IdentLoc, diag::warn_using_directive_in_header);
7779 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
7804 bool HasUsingKeyword,
7809 bool HasTypenameKeyword,
7826 diag::warn_cxx98_compat_using_decl_constructor :
7827 diag::err_using_decl_constructor)
7851 if (!HasUsingKeyword) {
7854 : diag::warn_access_decl_deprecated)
7863 TargetNameInfo, AttrList,
7865 HasTypenameKeyword, TypenameLoc);
7877 if (D1->getCanonicalDecl() == D2->getCanonicalDecl())
7882 return Context.
hasSameType(TD1->getUnderlyingType(),
7883 TD2->getUnderlyingType());
7917 if (isa<EnumDecl>(OrigDC)) OrigDC = OrigDC->
getParent();
7920 OrigRec = cast<CXXRecordDecl>(OrigRec->getDeclContext());
7922 if (cast<CXXRecordDecl>(
CurContext)->isProvablyNotDerivedFrom(OrigRec)) {
7924 Diag(Using->getLocation(),
7925 diag::err_using_decl_nested_name_specifier_is_current_class)
7927 Diag(Orig->getLocation(), diag::note_using_decl_target);
7932 diag::err_using_decl_nested_name_specifier_is_not_base_class)
7936 Diag(Orig->getLocation(), diag::note_using_decl_target);
7941 if (Previous.
empty())
return false;
7944 if (isa<UsingShadowDecl>(Target))
7945 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
7952 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
7953 bool FoundEquivalentDecl =
false;
7960 if (isa<UsingDecl>(D))
7965 PrevShadow = Shadow;
7966 FoundEquivalentDecl =
true;
7970 FoundEquivalentDecl =
true;
7974 (isa<TagDecl>(D) ? Tag : NonTag) = D;
7977 if (FoundEquivalentDecl)
7988 Diag(Using->getLocation(), diag::err_using_decl_conflict);
8000 Diag(Using->getLocation(), diag::err_using_decl_conflict);
8004 Diag(Target->getLocation(), diag::note_using_decl_target);
8005 Diag(OldDecl->getLocation(), diag::note_using_decl_conflict);
8011 if (isa<TagDecl>(Target)) {
8013 if (!Tag)
return false;
8015 Diag(Using->getLocation(), diag::err_using_decl_conflict);
8016 Diag(Target->getLocation(), diag::note_using_decl_target);
8017 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
8022 if (!NonTag)
return false;
8024 Diag(Using->getLocation(), diag::err_using_decl_conflict);
8025 Diag(Target->getLocation(), diag::note_using_decl_target);
8026 Diag(NonTag->getLocation(), diag::note_using_decl_conflict);
8034 for (
auto &B : Derived->
bases())
8035 if (B.getType()->getAsCXXRecordDecl() == Base)
8036 return B.isVirtual();
8037 llvm_unreachable(
"not a direct base class");
8047 if (isa<UsingShadowDecl>(Target)) {
8048 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
8049 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
8053 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
8054 NonTemplateTarget = TargetTD->getTemplatedDecl();
8057 if (isa<CXXConstructorDecl>(NonTemplateTarget)) {
8058 bool IsVirtualBase =
8069 Shadow->setAccess(UD->getAccess());
8070 if (Orig->isInvalidDecl() || UD->isInvalidDecl())
8071 Shadow->setInvalidDecl();
8114 cast<CXXRecordDecl>(Shadow->getDeclContext())->removeConversion(Shadow);
8117 Shadow->getDeclContext()->removeDecl(Shadow);
8135 bool &AnyDependentBases) {
8138 for (
auto &Base : Derived->
bases()) {
8140 if (CanonicalDesiredBase == BaseType)
8142 if (BaseType->isDependentType())
8143 AnyDependentBases =
true;
8151 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
8153 : HasTypenameKeyword(HasTypenameKeyword),
8154 IsInstantiation(IsInstantiation), OldNNS(NNS),
8155 RequireMemberOf(RequireMemberOf) {}
8157 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
8161 if (!ND || isa<NamespaceDecl>(ND))
8171 if (RequireMemberOf) {
8173 if (FoundRecord && FoundRecord->isInjectedClassName()) {
8194 bool AnyDependentBases =
false;
8197 AnyDependentBases) &&
8209 if (FoundRecord && FoundRecord->isInjectedClassName())
8213 if (isa<TypeDecl>(ND))
8214 return HasTypenameKeyword || !IsInstantiation;
8216 return !HasTypenameKeyword;
8220 bool HasTypenameKeyword;
8221 bool IsInstantiation;
8237 bool IsInstantiation,
8238 bool HasTypenameKeyword,
8240 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
8242 assert(IdentLoc.isValid() &&
"Invalid TargetName location.");
8247 Diag(IdentLoc, diag::err_using_requires_qualname);
8256 if (
auto *RD = dyn_cast<CXXRecordDecl>(
CurContext))
8278 !(D->getIdentifierNamespace() & Decl::IDNS_Ordinary))
8283 assert(IsInstantiation &&
"no scope in non-instantiation");
8290 SS, IdentLoc, Previous))
8300 if (!LookupContext) {
8301 if (HasTypenameKeyword) {
8304 UsingLoc, TypenameLoc,
8306 IdentLoc, NameInfo.
getName());
8309 QualifierLoc, NameInfo);
8316 auto Build = [&](
bool Invalid) {
8319 UsingName, HasTypenameKeyword);
8322 UD->setInvalidDecl(Invalid);
8325 auto BuildInvalid = [&]{
return Build(
true); };
8326 auto BuildValid = [&]{
return Build(
false); };
8329 return BuildInvalid();
8338 if (!IsInstantiation)
8358 llvm::make_unique<UsingValidatorCCC>(
8359 HasTypenameKeyword, IsInstantiation, SS.getScopeRep(),
8363 NamedDecl *ND = Corrected.getCorrectionDecl();
8368 << NameInfo.
getName() << LookupContext << 0
8373 if (RD && RD->isInjectedClassName()) {
8375 RD = cast<CXXRecordDecl>(RD->getParent());
8378 if (Corrected.WillReplaceSpecifier()) {
8387 auto *CurClass = cast<CXXRecordDecl>(
CurContext);
8401 Diag(IdentLoc, diag::err_no_member)
8402 << NameInfo.
getName() << LookupContext << SS.getRange();
8403 return BuildInvalid();
8408 return BuildInvalid();
8410 if (HasTypenameKeyword) {
8413 Diag(IdentLoc, diag::err_using_typename_non_type);
8415 Diag((*I)->getUnderlyingDecl()->getLocation(),
8416 diag::note_using_decl_target);
8417 return BuildInvalid();
8424 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
8426 return BuildInvalid();
8433 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
8435 return BuildInvalid();
8441 if (cast<EnumDecl>(ED->getDeclContext())->isScoped()) {
8442 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
8444 return BuildInvalid();
8471 assert(!UD->
hasTypename() &&
"expecting a constructor name");
8474 assert(SourceType &&
8475 "Using decl naming constructor doesn't have type in scope spec.");
8479 bool AnyDependentBases =
false;
8482 if (!Base && !AnyDependentBases) {
8484 diag::err_using_decl_constructor_not_in_direct_base)
8486 <<
QualType(SourceType, 0) << TargetClass;
8487 UD->setInvalidDecl();
8501 bool HasTypenameKeyword,
8522 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
8523 DTypename = UD->hasTypename();
8524 DQual = UD->getQualifier();
8526 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
8528 DQual = UD->getQualifier();
8530 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
8532 DQual = UD->getQualifier();
8537 if (HasTypenameKeyword != DTypename)
continue;
8546 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
8547 Diag(D->getLocation(), diag::note_using_decl) << 1;
8572 auto *RD = NamedContext
8578 Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member)
8604 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
8620 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
8634 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
8648 if (!NamedContext) {
8662 diag::err_using_decl_nested_name_specifier_is_not_class)
8677 if (cast<CXXRecordDecl>(
CurContext)->isProvablyNotDerivedFrom(
8678 cast<CXXRecordDecl>(NamedContext))) {
8681 diag::err_using_decl_nested_name_specifier_is_current_class)
8687 diag::err_using_decl_nested_name_specifier_is_not_base_class)
8710 llvm::SmallPtrSet<const CXXRecordDecl *, 4> Bases;
8717 if (!cast<CXXRecordDecl>(
CurContext)->forallBases(Collect))
8723 return !Bases.count(Base);
8728 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
8729 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
8733 diag::err_using_decl_nested_name_specifier_is_not_base_class)
8748 Decl *DeclFromDeclSpec) {
8753 "got alias-declaration outside of declaration scope");
8758 bool Invalid =
false;
8784 "name in alias declaration must be an identifier");
8789 NewTD->setAccess(AS);
8792 NewTD->setInvalidDecl();
8797 Invalid |= NewTD->isInvalidDecl();
8799 bool Redeclaration =
false;
8802 if (TemplateParamLists.size()) {
8806 if (TemplateParamLists.size() != 1) {
8807 Diag(UsingLoc, diag::err_alias_template_extra_headers)
8808 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
8809 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
8820 if (!Previous.
empty()) {
8821 Redeclaration =
true;
8824 if (!OldDecl && !Invalid) {
8825 Diag(UsingLoc, diag::err_redefinition_different_kind)
8829 if (OldD->getLocation().isValid())
8830 Diag(OldD->getLocation(), diag::note_previous_definition);
8835 if (!Invalid && OldDecl && !OldDecl->isInvalidDecl()) {
8850 Diag(NewTD->getLocation(), diag::err_redefinition_different_typedef)
8852 if (OldTD->getLocation().isValid())
8853 Diag(OldTD->getLocation(), diag::note_previous_definition);
8871 NewDecl->setAccess(AS);
8874 NewDecl->setInvalidDecl();
8880 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
8908 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
8940 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
8942 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
8943 << AD->getNamespace();
8948 ? diag::err_redefinition
8949 : diag::err_redefinition_different_kind;
8950 Diag(AliasLoc, DiagID) << Alias;
8951 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
8979 if (ClassDecl->isInvalidDecl())
8983 for (
const auto &B : ClassDecl->
bases()) {
8988 CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
8993 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
8998 for (
const auto &B : ClassDecl->
vbases()) {
9000 CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
9005 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
9010 for (
const auto *F : ClassDecl->
fields()) {
9011 if (F->hasInClassInitializer()) {
9012 if (
Expr *E = F->getInClassInitializer())
9016 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
9024 ExceptSpec.
CalledDecl(F->getLocation(), Constructor);
9039 if (ClassDecl->isInvalidDecl())
9046 for (
bool VBase : {
false,
true}) {
9048 VBase ? ClassDecl->
vbases() : ClassDecl->
bases()) {
9050 if (B.isVirtual() != VBase)
9053 CXXRecordDecl *BaseClass = B.getType()->getAsCXXRecordDecl();
9063 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
9068 for (
const auto *F : ClassDecl->
fields()) {
9069 if (F->hasInClassInitializer()) {
9070 if (
Expr *E = F->getInClassInitializer())
9074 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
9077 ExceptSpec.
CalledDecl(F->getLocation(), Constructor);
9086 struct DeclaringSpecialMember {
9090 bool WasAlreadyBeingDeclared;
9093 : S(S), D(RD, CSM), SavedContext(S, RD) {
9095 if (WasAlreadyBeingDeclared)
9103 ~DeclaringSpecialMember() {
9104 if (!WasAlreadyBeingDeclared)
9109 bool isAlreadyBeingDeclared()
const {
9110 return WasAlreadyBeingDeclared;
9139 "Should not build implicit default constructor!");
9142 if (DSM.isAlreadyBeingDeclared())
9158 nullptr,
false,
true,
9189 ClassDecl->
addDecl(DefaultCon);
9199 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
9202 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
9208 Diag(CurrentLocation, diag::note_member_synthesized_at)
9210 Constructor->setInvalidDecl();
9220 ? Constructor->getLocEnd()
9221 : Constructor->getLocation();
9224 Constructor->markUsed(
Context);
9228 L->CompletedImplicitDefinition(Constructor);
9231 DiagnoseUninitializedFields(*
this, Constructor);
9257 ->getInheritedConstructor()
9260 return cast<CXXConstructorDecl>(Ctor);
9275 false, BaseCtor, &ICI);
9282 if (Shadow->isInvalidDecl())
9283 DerivedCtor->setInvalidDecl();
9289 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
9299 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
9306 ParamDecls.push_back(PD);
9311 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
9312 DerivedCtor->setAccess(BaseCtor->getAccess());
9314 Derived->
addDecl(DerivedCtor);
9335 if (Constructor->isInvalidDecl())
9360 for (
bool VBase : {
false,
true}) {
9362 if (B.isVirtual() != VBase)
9365 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
9370 if (!BaseCtor.first)
9375 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
9379 Context, TInfo, VBase, InitLoc, Init.
get(), InitLoc,
9389 Diag(CurrentLocation, diag::note_inhctor_synthesized_at) << RD;
9390 Constructor->setInvalidDecl();
9401 Constructor->markUsed(
Context);
9405 L->CompletedImplicitDefinition(Constructor);
9408 DiagnoseUninitializedFields(*
this, Constructor);
9419 if (ClassDecl->isInvalidDecl())
9423 for (
const auto &B : ClassDecl->
bases()) {
9433 for (
const auto &B : ClassDecl->
vbases()) {
9440 for (
const auto *F : ClassDecl->
fields()) {
9457 DeclaringSpecialMember DSM(*
this, ClassDecl,
CXXDestructor);
9458 if (DSM.isAlreadyBeingDeclared())
9502 ClassDecl->
addDecl(Destructor);
9512 "DefineImplicitDestructor - call it for implicit default dtor");
9514 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
9516 if (Destructor->isInvalidDecl())
9526 Diag(CurrentLocation, diag::note_member_synthesized_at)
9529 Destructor->setInvalidDecl();
9539 ? Destructor->getLocEnd()
9540 : Destructor->getLocation();
9542 Destructor->markUsed(
Context);
9546 L->CompletedImplicitDefinition(Destructor);
9555 if (Record->isInvalidDecl()) {
9572 for (Decl *Member : Class->
decls()) {
9576 if (
auto *NestedRD = dyn_cast<CXXRecordDecl>(Member))
9579 }
else if (!CD->isDefaultConstructor() || !CD->hasAttr<DLLExportAttr>()) {
9588 unsigned NumParams = CD->getNumParams();
9589 if (ExpectedCallingConv == ActualCallingConv && NumParams == 0)
9592 if (LastExportedDefaultCtor) {
9593 S.
Diag(LastExportedDefaultCtor->getLocation(),
9594 diag::err_attribute_dll_ambiguous_default_ctor) << Class;
9595 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
9596 << CD->getDeclName();
9599 LastExportedDefaultCtor = CD;
9601 for (
unsigned I = 0;
I != NumParams; ++
I) {
9607 CD->getParamDecl(
I)).
get();
9640 "adjusting dtor exception specs was introduced in c++11");
9647 getAs<FunctionProtoType>();
9671 ExprBuilder(
const ExprBuilder&) =
delete;
9672 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
9675 static Expr *assertNotNull(
Expr *E) {
9676 assert(E &&
"Expression construction must not fail.");
9682 virtual ~ExprBuilder() {}
9687 class RefBuilder:
public ExprBuilder {
9697 : Var(Var), VarType(VarType) {}
9700 class ThisBuilder:
public ExprBuilder {
9707 class CastBuilder:
public ExprBuilder {
9716 CK_UncheckedDerivedToBase,
Kind,
9722 : Builder(Builder), Type(Type), Kind(Kind), Path(Path) {}
9725 class DerefBuilder:
public ExprBuilder {
9730 return assertNotNull(
9734 DerefBuilder(
const ExprBuilder &
Builder) : Builder(Builder) {}
9737 class MemberBuilder:
public ExprBuilder {
9748 nullptr, MemberLookup,
nullptr,
nullptr).
get());
9753 : Builder(Builder), Type(Type), IsArrow(IsArrow),
9754 MemberLookup(MemberLookup) {}
9757 class MoveCastBuilder:
public ExprBuilder {
9765 MoveCastBuilder(
const ExprBuilder &
Builder) : Builder(Builder) {}
9768 class LvalueConvBuilder:
public ExprBuilder {
9773 return assertNotNull(
9777 LvalueConvBuilder(
const ExprBuilder &
Builder) : Builder(Builder) {}
9780 class SubscriptBuilder:
public ExprBuilder {
9781 const ExprBuilder &Base;
9782 const ExprBuilder &Index;
9787 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
9790 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
9791 : Base(Base), Index(Index) {}
9802 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
9811 Expr *From = FromB.build(S, Loc);
9815 Expr *To = ToB.build(S, Loc);
9821 bool NeedsCollectableMemCpy =
9825 StringRef MemCpyName = NeedsCollectableMemCpy ?
9826 "__builtin_objc_memmove_collectable" :
9840 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
9842 Expr *CallArgs[] = {
9846 Loc, CallArgs, Loc);
9848 assert(!Call.
isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
9881 const ExprBuilder &To,
const ExprBuilder &From,
9882 bool CopyingBaseSubobject,
bool Copying,
9883 unsigned Depth = 0) {
9899 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
9914 if (Method->isCopyAssignmentOperator() ||
9915 (!Copying && Method->isMoveAssignmentOperator()))
9934 if (CopyingBaseSubobject) {
9965 Expr *FromInst = From.build(S, Loc);
9968 Loc, FromInst, Loc);
9988 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
10008 llvm::raw_svector_ostream OS(Str);
10009 OS <<
"__i" <<
Depth;
10013 IterationVarName, SizeType,
10022 RefBuilder IterationVarRef(IterationVar, SizeType);
10023 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
10029 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
10030 MoveCastBuilder FromIndexMove(FromIndexCopy);
10031 const ExprBuilder *FromIndex;
10033 FromIndex = &FromIndexCopy;
10035 FromIndex = &FromIndexMove;
10037 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
10042 ToIndex, *FromIndex, CopyingBaseSubobject,
10043 Copying,
Depth + 1);
10045 if (Copy.isInvalid() || !Copy.get())
10064 Loc, Loc, InitStmt,
10071 const ExprBuilder &To,
const ExprBuilder &From,
10072 bool CopyingBaseSubobject,
bool Copying) {
10079 CopyingBaseSubobject,
10084 if (!Result.isInvalid() && !Result.get())
10095 if (ClassDecl->isInvalidDecl())
10099 assert(T->
getNumParams() == 1 &&
"not a copy assignment op");
10100 unsigned ArgQuals =
10113 for (
const auto &Base : ClassDecl->
bases()) {
10120 ArgQuals,
false, 0))
10124 for (
const auto &Base : ClassDecl->
vbases()) {
10128 ArgQuals,
false, 0))
10132 for (
const auto *Field : ClassDecl->
fields()) {
10139 ExceptSpec.
CalledDecl(Field->getLocation(), CopyAssign);
10154 if (DSM.isAlreadyBeingDeclared())
10179 CopyAssignment->setImplicit();
10195 ClassLoc, ClassLoc,
10217 ClassDecl->
addDecl(CopyAssignment);
10219 return CopyAssignment;
10227 assert(CopyOp->isImplicit());
10234 if (RD->hasUserDeclaredDestructor()) {
10235 UserDeclaredOperation = RD->getDestructor();
10236 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
10237 RD->hasUserDeclaredCopyConstructor() &&
10240 for (
auto *
I : RD->ctors()) {
10241 if (
I->isCopyConstructor()) {
10242 UserDeclaredOperation =
I;
10246 assert(UserDeclaredOperation);
10247 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
10248 RD->hasUserDeclaredCopyAssignment() &&
10251 for (
auto *
I : RD->methods()) {
10252 if (
I->isCopyAssignmentOperator()) {
10253 UserDeclaredOperation =
I;
10257 assert(UserDeclaredOperation);
10260 if (UserDeclaredOperation) {
10261 S.
Diag(UserDeclaredOperation->getLocation(),
10262 diag::warn_deprecated_copy_operation)
10263 << RD << !isa<CXXConstructorDecl>(CopyOp)
10264 << isa<CXXDestructorDecl>(UserDeclaredOperation);
10265 S.
Diag(UseLoc, diag::note_member_synthesized_at)
10279 "DefineImplicitCopyAssignment called for wrong function");
10283 if (ClassDecl->isInvalidDecl() || CopyAssignOperator->isInvalidDecl()) {
10284 CopyAssignOperator->setInvalidDecl();
10295 CopyAssignOperator->markUsed(
Context);
10323 ? CopyAssignOperator->getLocEnd()
10324 : CopyAssignOperator->getLocation();
10327 RefBuilder OtherRef(Other, OtherRefType);
10333 bool Invalid =
false;
10334 for (
auto &Base : ClassDecl->
bases()) {
10344 BasePath.push_back(&Base);
10352 DerefBuilder DerefThis(This);
10353 CastBuilder To(DerefThis,
10364 Diag(CurrentLocation, diag::note_member_synthesized_at)
10366 CopyAssignOperator->setInvalidDecl();
10371 Statements.push_back(Copy.
getAs<
Expr>());
10375 for (
auto *Field : ClassDecl->
fields()) {
10381 if (Field->isInvalidDecl()) {
10388 Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign)
10390 Diag(Field->getLocation(), diag::note_declared_at);
10391 Diag(CurrentLocation, diag::note_member_synthesized_at)
10400 Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign)
10402 Diag(Field->getLocation(), diag::note_declared_at);
10403 Diag(CurrentLocation, diag::note_member_synthesized_at)
10416 "Incomplete array type is not valid");
10425 MemberLookup.resolveKind();
10427 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
10437 Diag(CurrentLocation, diag::note_member_synthesized_at)
10439 CopyAssignOperator->setInvalidDecl();
10444 Statements.push_back(Copy.
getAs<
Stmt>());
10452 if (Return.isInvalid())
10455 Statements.push_back(Return.getAs<
Stmt>());
10458 Diag(CurrentLocation, diag::note_member_synthesized_at)
10471 CopyAssignOperator->setInvalidDecl();
10480 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
10485 L->CompletedImplicitDefinition(CopyAssignOperator);
10494 if (ClassDecl->isInvalidDecl())
10509 for (
const auto &Base : ClassDecl->
bases()) {
10520 for (
const auto &Base : ClassDecl->
vbases()) {
10528 for (
const auto *Field : ClassDecl->
fields()) {
10535 ExceptSpec.
CalledDecl(Field->getLocation(), MoveAssign);
10546 if (DSM.isAlreadyBeingDeclared())
10571 MoveAssignment->setImplicit();
10587 ClassLoc, ClassLoc,
10611 ClassDecl->
addDecl(MoveAssignment);
10613 return MoveAssignment;
10632 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
10635 for (
auto &BI : Class->
bases()) {
10636 Worklist.push_back(&BI);
10637 while (!Worklist.empty()) {
10670 if (Existing && Existing != &BI) {
10671 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
10674 << (Base->getCanonicalDecl() ==
10677 S.
Diag(BI.getLocStart(), diag::note_vbase_moved_here)
10678 << (Base->getCanonicalDecl() ==
10679 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
10683 Existing =
nullptr;
10693 for (
auto &BI : Base->
bases())
10694 Worklist.push_back(&BI);
10707 "DefineImplicitMoveAssignment called for wrong function");
10711 if (ClassDecl->isInvalidDecl() || MoveAssignOperator->isInvalidDecl()) {
10712 MoveAssignOperator->setInvalidDecl();
10716 MoveAssignOperator->markUsed(
Context);
10739 getAs<RValueReferenceType>()->getPointeeType();
10741 "Bad argument type of defaulted move assignment");
10745 ? MoveAssignOperator->getLocEnd()
10746 : MoveAssignOperator->getLocation();
10749 RefBuilder OtherRef(Other, OtherRefType);
10751 MoveCastBuilder MoveOther(OtherRef);
10757 bool Invalid =
false;
10758 for (
auto &Base : ClassDecl->
bases()) {
10776 BasePath.push_back(&Base);
10780 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
10783 DerefBuilder DerefThis(This);
10786 CastBuilder To(DerefThis,
10797 Diag(CurrentLocation, diag::note_member_synthesized_at)
10799 MoveAssignOperator->setInvalidDecl();
10804 Statements.push_back(Move.
getAs<
Expr>());
10808 for (
auto *Field : ClassDecl->
fields()) {
10814 if (Field->isInvalidDecl()) {
10821 Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign)
10823 Diag(Field->getLocation(), diag::note_declared_at);
10824 Diag(CurrentLocation, diag::note_member_synthesized_at)
10833 Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign)
10835 Diag(Field->getLocation(), diag::note_declared_at);
10836 Diag(CurrentLocation, diag::note_member_synthesized_at)
10849 "Incomplete array type is not valid");
10857 MemberLookup.resolveKind();
10858 MemberBuilder From(MoveOther, OtherRefType,
10859 false, MemberLookup);
10861 true, MemberLookup);
10863 assert(!From.build(*
this, Loc)->isLValue() &&
10864 "Member reference with rvalue base must be rvalue except for reference "
10865 "members, which aren't allowed for move assignment.");
10872 if (Move.isInvalid()) {
10873 Diag(CurrentLocation, diag::note_member_synthesized_at)
10875 MoveAssignOperator->setInvalidDecl();
10880 Statements.push_back(Move.getAs<
Stmt>());
10889 if (Return.isInvalid())
10892 Statements.push_back(Return.getAs<
Stmt>());
10895 Diag(CurrentLocation, diag::note_member_synthesized_at)
10908 MoveAssignOperator->setInvalidDecl();
10917 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
10922 L->CompletedImplicitDefinition(MoveAssignOperator);
10931 if (ClassDecl->isInvalidDecl())
10941 for (
const auto &Base : ClassDecl->
bases()) {
10952 for (
const auto &Base : ClassDecl->
vbases()) {
10959 for (
const auto *Field : ClassDecl->
fields()) {
10965 ExceptSpec.
CalledDecl(Field->getLocation(), CopyConstructor);
10980 if (DSM.isAlreadyBeingDeclared())
11024 ClassLoc, ClassLoc,
11046 ClassDecl->
addDecl(CopyConstructor);
11048 return CopyConstructor;
11057 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
11060 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
11074 Diag(CurrentLocation, diag::note_member_synthesized_at)
11076 CopyConstructor->setInvalidDecl();
11079 ? CopyConstructor->getLocEnd()
11080 : CopyConstructor->getLocation();
11091 CopyConstructor->markUsed(
Context);
11095 L->CompletedImplicitDefinition(CopyConstructor);
11107 if (ClassDecl->isInvalidDecl())
11111 for (
const auto &B : ClassDecl->
bases()) {
11116 CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
11122 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
11127 for (
const auto &B : ClassDecl->
vbases()) {
11129 CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
11135 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
11140 for (
const auto *F : ClassDecl->
fields()) {
11151 ExceptSpec.
CalledDecl(F->getLocation(), Constructor);
11163 if (DSM.isAlreadyBeingDeclared())
11204 ClassLoc, ClassLoc,
11228 ClassDecl->
addDecl(MoveConstructor);
11230 return MoveConstructor;
11239 "DefineImplicitMoveConstructor - call it for implicit move ctor");
11242 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
11249 Diag(CurrentLocation, diag::note_member_synthesized_at)
11251 MoveConstructor->setInvalidDecl();
11254 ? MoveConstructor->getLocEnd()
11255 : MoveConstructor->getLocation();
11258 Loc, Loc,
None,
false).getAs<Stmt>());
11266 MoveConstructor->markUsed(
Context);
11270 L->CompletedImplicitDefinition(MoveConstructor);
11295 void *InsertPos =
nullptr;
11296 FunctionDecl *CallOpSpec = CallOpTemplate->findSpecialization(
11297 DeducedTemplateArgs->
asArray(),
11299 assert(CallOpSpec &&
11300 "Conversion operator must have a corresponding call operator");
11301 CallOp = cast<CXXMethodDecl>(CallOpSpec);
11317 assert(DeducedTemplateArgs &&
11318 "Must have deduced template arguments from Conversion Operator");
11321 void *InsertPos =
nullptr;
11323 DeducedTemplateArgs->
asArray(),
11325 assert(InvokeSpec &&
11326 "Must have a corresponding static invoker specialization");
11327 Invoker = cast<CXXMethodDecl>(InvokeSpec);
11332 assert(FunctionRef &&
"Can't refer to __invoke function?");
11335 Conv->getLocation(),
11336 Conv->getLocation()));
11339 Conv->setReferenced();
11344 Invoker->setReferenced();
11348 L->CompletedImplicitDefinition(Conv);
11349 L->CompletedImplicitDefinition(Invoker);
11371 Conv->getLocation(),
11380 CK_CopyAndAutoreleaseBlockObject,
11384 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
11385 Conv->setInvalidDecl();
11393 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
11394 Conv->setInvalidDecl();
11399 Stmt *ReturnS = Return.
get();
11401 Conv->getLocation(),
11402 Conv->getLocation()));
11406 L->CompletedImplicitDefinition(Conv);
11413 switch (Args.size()) {
11418 if (!Args[1]->isDefaultArgument())
11423 return !Args[0]->isDefaultArgument();
11434 bool HadMultipleCandidates,
11435 bool IsListInitialization,
11436 bool IsStdInitListInitialization,
11437 bool RequiresZeroInit,
11438 unsigned ConstructKind,
11440 bool Elidable =
false;
11454 Expr *SubExpr = ExprArgs[0];
11456 Context, cast<CXXRecordDecl>(FoundDecl->getDeclContext()));
11460 FoundDecl, Constructor,
11461 Elidable, ExprArgs, HadMultipleCandidates,
11462 IsListInitialization,
11463 IsStdInitListInitialization, RequiresZeroInit,
11464 ConstructKind, ParenRange);
11473 bool HadMultipleCandidates,
11474 bool IsListInitialization,
11475 bool IsStdInitListInitialization,
11476 bool RequiresZeroInit,
11477 unsigned ConstructKind,
11479 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
11486 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
11487 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
11488 RequiresZeroInit, ConstructKind, ParenRange);
11498 bool HadMultipleCandidates,
11499 bool IsListInitialization,
11500 bool IsStdInitListInitialization,
11501 bool RequiresZeroInit,
11502 unsigned ConstructKind,
11507 "given constructor for wrong type");
11511 Context, DeclInitType, ConstructLoc, Constructor, Elidable,
11512 ExprArgs, HadMultipleCandidates, IsListInitialization,
11513 IsStdInitListInitialization, RequiresZeroInit,
11514 static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
11537 assert(!Lookup.
empty() && Lookup.
size() <= 2 &&
11538 "more than two lookup results for field name");
11541 assert(isa<CXXRecordDecl>(Lookup[0]) &&
11542 "cannot have other non-field member with same name");
11543 Pattern = cast<FieldDecl>(Lookup[1]);
11567 if (OutermostClass == ParentRD) {
11568 Diag(Field->getLocEnd(), diag::err_in_class_initializer_not_yet_parsed)
11569 << ParentRD << Field;
11571 Diag(Field->getLocEnd(),
11572 diag::err_in_class_initializer_not_yet_parsed_outer_class)
11573 << ParentRD << OutermostClass << Field;
11580 if (VD->isInvalidDecl())
return;
11583 if (ClassDecl->isInvalidDecl())
return;
11590 PDiag(diag::err_access_dtor_var)
11600 Diag(VD->getLocation(), diag::warn_exit_time_destructor);
11604 Diag(VD->getLocation(), diag::warn_global_destructor);
11617 bool AllowExplicit,
11618 bool IsListInitialization) {
11620 unsigned NumArgs = ArgsPtr.size();
11621 Expr **Args = ArgsPtr.data();
11625 assert(Proto &&
"Constructor without a prototype?");
11629 if (NumArgs < NumParams)
11630 ConvertedArgs.reserve(NumParams);
11632 ConvertedArgs.reserve(NumArgs);
11639 llvm::makeArrayRef(Args, NumArgs),
11641 CallType, AllowExplicit,
11642 IsListInitialization);
11643 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
11647 CheckConstructorCall(Constructor,
11648 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
11658 if (isa<NamespaceDecl>(DC)) {
11659 return SemaRef.
Diag(FnDecl->getLocation(),
11660 diag::err_operator_new_delete_declared_in_namespace)
11664 if (isa<TranslationUnitDecl>(DC) &&
11666 return SemaRef.
Diag(FnDecl->getLocation(),
11667 diag::err_operator_new_delete_declared_static)
11678 unsigned DependentParamTypeDiag,
11679 unsigned InvalidParamTypeDiag) {
11685 return SemaRef.
Diag(FnDecl->getLocation(),
11686 diag::err_operator_new_delete_dependent_result_type)
11691 return SemaRef.
Diag(FnDecl->getLocation(),
11692 diag::err_operator_new_delete_invalid_result_type)
11697 return SemaRef.
Diag(FnDecl->getLocation(),
11698 diag::err_operator_new_delete_template_too_few_parameters)
11703 return SemaRef.
Diag(FnDecl->getLocation(),
11704 diag::err_operator_new_delete_too_few_parameters)
11710 return SemaRef.
Diag(FnDecl->getLocation(), DependentParamTypeDiag)
11711 << FnDecl->
getDeclName() << ExpectedFirstParamType;
11715 ExpectedFirstParamType)
11716 return SemaRef.
Diag(FnDecl->getLocation(), InvalidParamTypeDiag)
11717 << FnDecl->
getDeclName() << ExpectedFirstParamType;
11739 diag::err_operator_new_dependent_param_type,
11740 diag::err_operator_new_param_type))
11746 return SemaRef.
Diag(FnDecl->getLocation(),
11747 diag::err_operator_new_default_arg)
11767 diag::err_operator_delete_dependent_param_type,
11768 diag::err_operator_delete_param_type))
11779 "Expected an overloaded operator declaration");
11789 if (Op == OO_Delete || Op == OO_Array_Delete)
11792 if (Op == OO_New || Op == OO_Array_New)
11800 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
11801 if (MethodDecl->isStatic())
11802 return Diag(FnDecl->getLocation(),
11803 diag::err_operator_overload_static) << FnDecl->
getDeclName();
11805 bool ClassOrEnumParam =
false;
11807 QualType ParamType = Param->getType().getNonReferenceType();
11810 ClassOrEnumParam =
true;
11815 if (!ClassOrEnumParam)
11816 return Diag(FnDecl->getLocation(),
11817 diag::err_operator_overload_needs_class_or_enum)
11827 if (Op != OO_Call) {
11829 if (Param->hasDefaultArg())
11830 return Diag(Param->getLocation(),
11831 diag::err_operator_overload_default_arg)
11832 << FnDecl->
getDeclName() << Param->getDefaultArgRange();
11837 {
false,
false,
false }
11838 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
11839 , { Unary, Binary, MemberOnly }
11840 #include "clang/Basic/OperatorKinds.def"
11843 bool CanBeUnaryOperator = OperatorUses[Op][0];
11844 bool CanBeBinaryOperator = OperatorUses[Op][1];
11845 bool MustBeMemberOperator = OperatorUses[Op][2];
11852 + (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
11853 if (Op != OO_Call &&
11854 ((NumParams == 1 && !CanBeUnaryOperator) ||
11855 (NumParams == 2 && !CanBeBinaryOperator) ||
11856 (NumParams < 1) || (NumParams > 2))) {
11859 if (CanBeUnaryOperator && CanBeBinaryOperator) {
11861 }
else if (CanBeUnaryOperator) {
11864 assert(CanBeBinaryOperator &&
11865 "All non-call overloaded operators are unary or binary!");
11869 return Diag(FnDecl->getLocation(), diag::err_operator_overload_must_be)
11874 if (Op != OO_Call &&
11876 return Diag(FnDecl->getLocation(), diag::err_operator_overload_variadic)
11881 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
11882 return Diag(FnDecl->getLocation(),
11883 diag::err_operator_overload_must_be_member)
11897 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
11903 return Diag(LastParam->getLocation(),
11904 diag::err_operator_overload_post_incdec_must_be_int)
11905 << LastParam->
getType() << (Op == OO_MinusMinus);
11917 if (TemplateParams->
size() == 1) {
11922 if (PmDecl && PmDecl->isTemplateParameterPack() &&
11926 }
else if (TemplateParams->
size() == 2) {
11934 if (PmType && PmArgs && !PmType->isTemplateParameterPack() &&
11935 PmArgs->isTemplateParameterPack()) {
11941 SemaRef.
Diag(TpDecl->getLocation(),
11942 diag::ext_string_literal_operator_template);
11949 diag::err_literal_operator_template)
11958 if (isa<CXXMethodDecl>(FnDecl)) {
11959 Diag(FnDecl->getLocation(), diag::err_literal_operator_outside_namespace)
11965 Diag(FnDecl->getLocation(), diag::err_literal_operator_extern_c);
11981 Diag(FnDecl->getLocation(),
11982 diag::err_literal_operator_template_with_params);
12010 diag::err_literal_operator_param)
12027 diag::err_literal_operator_invalid_param)
12037 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
12044 Diag((*Param)->getSourceRange().getBegin(),
12045 diag::err_literal_operator_param)
12046 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
12053 Diag((*Param)->getSourceRange().getBegin(),
12054 diag::err_literal_operator_param)
12055 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
12066 Diag((*Param)->getSourceRange().getBegin(),
12067 diag::err_literal_operator_param)
12068 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
12076 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
12078 Diag((*Param)->getSourceRange().getBegin(),
12079 diag::err_literal_operator_param)
12081 << (*Param)->getSourceRange();
12085 Diag(FnDecl->getLocation(), diag::err_literal_operator_bad_param_count);
12094 if (Param->hasDefaultArg()) {
12095 Diag(Param->getDefaultArgRange().getBegin(),
12096 diag::err_literal_operator_default_argument)
12097 << Param->getDefaultArgRange();
12102 StringRef LiteralName
12104 if (LiteralName[0] !=
'_') {
12108 Diag(FnDecl->getLocation(), diag::warn_user_literal_reserved)
12126 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
12127 << LangStr->getSourceRange();
12135 else if (Lang ==
"C++")
12138 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
12139 << LangStr->getSourceRange();
12165 return LinkageSpec;
12189 bool Invalid =
false;
12203 Diag(Loc, diag::err_catch_rvalue_ref);
12208 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
12214 unsigned DK = diag::err_catch_incomplete;
12218 DK = diag::err_catch_incomplete_ptr;
12223 DK = diag::err_catch_incomplete_ref;
12225 if (!Invalid && (Mode == 0 || !BaseType->
isVoidType()) &&
12231 diag::err_abstract_type_in_decl,
12243 Diag(Loc, diag::err_objc_object_catch);
12248 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
12281 Expr *opaqueValue =
12303 ExDecl->setInvalidDecl();
12333 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
12335 }
else if (PrevDecl->isTemplateParameter())
12351 ExDecl->setInvalidDecl();
12365 Expr *AssertMessageExpr,
12368 AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) :
nullptr;
12374 AssertMessage, RParenLoc,
false);
12382 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
12393 diag::err_static_assert_expression_is_not_constant,
12397 if (!Failed && !Cond) {
12399 llvm::raw_svector_ostream Msg(MsgBuffer);
12402 Diag(StaticAssertLoc, diag::err_static_assert_failed)
12403 << !AssertMessage << Msg.str() << AssertExpr->getSourceRange();
12409 AssertExpr, AssertMessage, RParenLoc,
12422 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
12448 diag::warn_cxx98_compat_unelaborated_friend_type :
12449 diag::ext_unelaborated_friend_type)
12457 diag::warn_cxx98_compat_nonclass_type_friend :
12458 diag::ext_nonclass_type_friend)
12465 diag::warn_cxx98_compat_enum_friend :
12466 diag::ext_enum_friend)
12478 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
12500 bool isExplicitSpecialization =
false;
12501 bool Invalid =
false;
12505 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
12506 isExplicitSpecialization, Invalid)) {
12507 if (TemplateParams->size() > 0) {
12513 NameLoc, Attr, TemplateParams,
AS_public,
12515 FriendLoc, TempParamLists.size() - 1,
12516 TempParamLists.data()).
get();
12519 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
12521 isExplicitSpecialization =
true;
12525 if (Invalid)
return nullptr;
12527 bool isAllExplicitSpecializations =
true;
12528 for (
unsigned I = TempParamLists.size();
I-- > 0; ) {
12529 if (TempParamLists[
I]->size()) {
12530 isAllExplicitSpecializations =
false;
12540 if (isAllExplicitSpecializations) {
12542 bool Owned =
false;
12543 bool IsDependent =
false;
12563 if (isa<DependentNameType>(T)) {
12577 TSI, FriendLoc, TempParamLists);
12583 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
12590 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
12601 TSI, FriendLoc, TempParamLists);
12639 if (TheDeclarator.isInvalidType())
12660 Diag(Loc, diag::err_tagless_friend_type_template)
12677 if (!TempParams.empty())
12715 Diag(Loc, diag::err_unexpected_friend);
12761 (FunctionContainingLocalClass =
12762 cast<CXXRecordDecl>(
CurContext)->isLocalClass())) {
12780 if (!Previous.
empty()) {
12788 DC = FunctionContainingLocalClass;
12832 if (!Previous.
empty()) {
12837 if (isTemplateId) {
12838 if (isa<TranslationUnitDecl>(LookupDC))
break;
12852 if (!DC)
return nullptr;
12865 D->getDeclContext()->getRedeclContext()))
12870 if (Previous.
empty()) {
12872 Diag(Loc, diag::err_qualified_friend_not_found)
12882 diag::warn_cxx98_compat_friend_is_member :
12883 diag::err_friend_is_member);
12915 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
12939 if (DiagArg >= 0) {
12940 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
12951 DCScope = &FakeDCScope;
12954 bool AddToScope =
true;
12956 TemplateParams, AddToScope);
12957 if (!ND)
return nullptr;
12959 assert(ND->getLexicalDeclContext() ==
CurContext);
12963 DC = ND->getDeclContext();
12972 DC = DC->getRedeclContext();
12973 DC->makeDeclVisibleInContext(ND);
12984 if (ND->isInvalidDecl()) {
12985 FrD->setInvalidDecl();
12991 FD = FTD->getTemplatedDecl();
12993 FD = cast<FunctionDecl>(ND);
13001 Diag(FD->getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
13002 Diag(OldFD->getLocation(), diag::note_previous_declaration);
13004 Diag(FD->getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
13009 Diag(FD->getLocation(), diag::warn_template_qualified_friend_unsupported)
13022 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
13024 Diag(DelLoc, diag::err_deleted_non_function);
13032 Prev->getPreviousDecl()) &&
13033 !Prev->isDefined()) {
13034 Diag(DelLoc, diag::err_deleted_decl_not_first);
13035 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
13036 Prev->isImplicit() ? diag::note_previous_implicit_declaration
13037 : diag::note_previous_declaration);
13046 Diag(Fn->getLocation(), diag::err_attribute_dll_deleted) << DLLAttr;
13047 Fn->setInvalidDecl();
13055 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Fn)) {
13056 bool IssuedDiagnostic =
false;
13061 if (!IssuedDiagnostic) {
13063 IssuedDiagnostic =
true;
13065 Diag((*I)->getLocation(), diag::note_overridden_virtual_function);
13073 Diag(DelLoc, diag::err_deleted_main);
13090 if (!MD->isInvalidDecl())
13091 Diag(DefaultLoc, diag::err_default_special_members);
13114 if (!MD->isInvalidDecl())
13117 Diag(DefaultLoc, diag::err_default_special_members);
13122 for (
Stmt *SubStmt : S->children()) {
13125 if (isa<ReturnStmt>(SubStmt))
13126 Self.
Diag(SubStmt->getLocStart(),
13127 diag::err_return_in_constructor_handler);
13128 if (!isa<Expr>(SubStmt))
13148 if (NewCC == OldCC)
13158 Diag(New->getLocation(),
13159 diag::err_conflicting_overriding_cc_attributes)
13161 Diag(Old->getLocation(), diag::note_overridden_virtual_function);
13185 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
13193 if (NewClassTy.
isNull()) {
13194 Diag(New->getLocation(),
13195 diag::err_different_return_type_for_overriding_virtual_function)
13198 Diag(Old->getLocation(), diag::note_overridden_virtual_function)
13211 if (!RT->isBeingDefined() &&
13213 diag::err_covariant_return_incomplete,
13219 if (!
IsDerivedFrom(New->getLocation(), NewClassTy, OldClassTy)) {
13220 Diag(New->getLocation(), diag::err_covariant_return_not_derived)
13223 Diag(Old->getLocation(), diag::note_overridden_virtual_function)
13230 NewClassTy, OldClassTy,
13231 diag::err_covariant_return_inaccessible_base,
13232 diag::err_covariant_return_ambiguous_derived_to_base_conv,
13239 Diag(Old->getLocation(), diag::note_overridden_virtual_function)
13247 Diag(New->getLocation(),
13248 diag::err_covariant_return_type_different_qualifications)
13251 Diag(Old->getLocation(), diag::note_overridden_virtual_function)
13259 Diag(New->getLocation(),
13260 diag::err_covariant_return_type_class_type_more_qualified)
13263 Diag(Old->getLocation(), diag::note_overridden_virtual_function)
13286 if (!Method->isInvalidDecl())
13287 Diag(Method->getLocation(), diag::err_non_virtual_pure)
13293 if (D->getFriendObjectKind())
13294 Diag(D->getLocation(), diag::err_pure_friend);
13295 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
13298 Diag(D->getLocation(), diag::err_illegal_initializer);
13303 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
13304 return Var->isStaticDataMember();
13318 if (!D || D->isInvalidDecl())
13325 if (D->isOutOfLine())
13339 if (!D || D->isInvalidDecl())
13345 if (D->isOutOfLine())
13358 "Parser allowed 'typedef' as storage class of condition decl.");
13364 if (isa<FunctionDecl>(Dcl)) {
13365 Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
13374 if (!ExternalSource)
13380 for (
unsigned I = 0, N = VTables.size();
I != N; ++
I) {
13385 if (!Pos->second && VTables[
I].DefinitionRequired)
13386 Pos->second =
true;
13390 VTablesUsed[VTables[
I].Record] = VTables[
I].DefinitionRequired;
13391 NewUses.push_back(
VTableUse(VTables[
I].Record, VTables[
I].Location));
13398 bool DefinitionRequired) {
13409 Pos =
VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
13414 if (DefinitionRequired && !Pos.first->second) {
13415 Pos.first->second =
true;
13447 VTableUses.push_back(std::make_pair(Class, Loc));
13459 bool DefinedAnything =
false;
13467 bool DefineVTable =
true;
13473 if (KeyFunction && !KeyFunction->
hasBody()) {
13475 DefineVTable =
false;
13480 "Instantiations don't have key functions");
13482 }
else if (!KeyFunction) {
13487 bool IsExplicitInstantiationDeclaration
13490 for (
auto R : Class->
redecls()) {
13494 IsExplicitInstantiationDeclaration =
true;
13496 IsExplicitInstantiationDeclaration =
false;
13501 if (IsExplicitInstantiationDeclaration)
13502 DefineVTable =
false;
13508 if (!DefineVTable) {
13516 DefinedAnything =
true;
13526 if (!KeyFunction ||
13527 (KeyFunction->
hasBody(KeyFunctionDef) &&
13531 ? diag::warn_weak_template_vtable : diag::warn_weak_vtable)
13537 return DefinedAnything;
13542 for (
const auto *
I : RD->
methods())
13543 if (
I->isVirtual() && !
I->isPure())
13552 for (CXXFinalOverriderMap::const_iterator
I = FinalOverriders.begin(),
13553 E = FinalOverriders.end();
13556 OE =
I->second.end();
13558 assert(OI->second.size() > 0 &&
"no final overrider");
13563 if (!Overrider->isPure())
13572 for (
const auto &
I : RD->
bases()) {
13574 cast<CXXRecordDecl>(
I.getType()->getAs<
RecordType>()->getDecl());
13592 for (
unsigned i = 0; i < ivars.size(); i++) {
13594 if (Field->isInvalidDecl())
13604 InitSeq.Perform(*
this, InitEntity, InitKind,
None);
13616 AllToInit.push_back(Member);
13621 ->getAs<RecordType>()) {
13622 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
13626 PDiag(diag::err_access_dtor_ivar)
13632 AllToInit.data(), AllToInit.size());
13638 llvm::SmallSet<CXXConstructorDecl*, 4> &Valid,
13639 llvm::SmallSet<CXXConstructorDecl*, 4> &Invalid,
13640 llvm::SmallSet<CXXConstructorDecl*, 4> &
Current,
13642 if (Ctor->isInvalidDecl())
13651 (void)Target->
hasBody(FNTarget);
13653 cast_or_null<CXXConstructorDecl>(FNTarget));
13660 if (!Current.insert(Canonical).second)
13665 Target->isInvalidDecl() || Valid.count(TCanonical)) {
13666 Valid.insert(Current.begin(), Current.end());
13669 }
else if (TCanonical == Canonical || Invalid.count(TCanonical) ||
13670 Current.count(TCanonical)) {
13672 if (!Invalid.count(TCanonical)) {
13674 diag::warn_delegating_ctor_cycle)
13678 if (TCanonical != Canonical)
13679 S.
Diag(Target->getLocation(), diag::note_it_delegates_to);
13685 assert(FNTarget &&
"Ctor cycle through bodiless function");
13688 cast<CXXConstructorDecl>(FNTarget));
13689 S.
Diag(C->getLocation(), diag::note_which_delegates_to);
13693 Invalid.insert(Current.begin(), Current.end());
13702 llvm::SmallSet<CXXConstructorDecl*, 4> Valid, Invalid,
Current;
13711 CE = Invalid.end();
13713 (*CI)->setInvalidDecl();
13722 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
13750 FindCXXThisExpr
Finder(*
this);
13775 FindCXXThisExpr
Finder(*
this);
13793 if (!Finder.TraverseType(E))
13803 FindCXXThisExpr
Finder(*
this);
13806 for (
const auto *A : Method->attrs()) {
13808 Expr *Arg =
nullptr;
13810 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
13812 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
13814 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
13815 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
13816 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
13817 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
13818 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
13819 Arg = ETLF->getSuccessValue();
13820 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
13821 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
13822 Arg = STLF->getSuccessValue();
13823 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
13824 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
13825 Arg = LR->getArg();
13826 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
13827 Args = llvm::makeArrayRef(LE->args_begin(), LE->args_size());
13828 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
13829 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
13830 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
13831 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
13832 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
13833 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
13834 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
13835 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
13837 if (Arg && !Finder.TraverseStmt(Arg))
13840 for (
unsigned I = 0, N = Args.size();
I != N; ++
I) {
13841 if (!Finder.TraverseStmt(Args[
I]))
13855 Exceptions.clear();
13858 Exceptions.reserve(DynamicExceptions.size());
13859 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
13866 if (!Unexpanded.empty()) {
13877 Exceptions.push_back(ET);
13885 if (NoexceptExpr) {
13889 "Parser should have made sure that the expression is boolean");
13890 if (IsTopLevel && NoexceptExpr &&
13898 diag::err_noexcept_needs_constant_expression,
13911 Expr *NoexceptExpr) {
13917 MethodD = FunTmpl->getTemplatedDecl();
13927 DynamicExceptionRanges, NoexceptExpr, Exceptions,
13955 Diag(DeclStart, diag::err_anonymous_property);
13980 diag::err_invalid_thread)
14003 if (PrevDecl && PrevDecl->isTemplateParameter()) {
14007 PrevDecl =
nullptr;
14011 PrevDecl =
nullptr;
14018 NewPD->setAccess(AS);
14020 if (NewPD->isInvalidDecl())
14021 Record->setInvalidDecl();
14024 NewPD->setModulePrivate();
14026 if (NewPD->isInvalidDecl() && PrevDecl) {
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 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.
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...
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)
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...
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
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...
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.
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
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 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. ...
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)
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.
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.
CXXMethodDecl * LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the moving assignment operator for the given class.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
CXXCatchStmt * getHandler(unsigned i)
TypeLoc getNamedTypeLoc() const
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...
CachedTokens * DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
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...
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.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
The current expression is potentially evaluated at run time, which means that code may be generated t...
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.
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsExplicitSpecialization)
Perform semantic checking of a new function declaration.
void erase()
Erase the last element returned from this iterator.
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
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.
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.
void addDefaultArgExprForConstructor(const CXXConstructorDecl *CD, unsigned ParmIdx, Expr *DAE)
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
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.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
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.
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 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.
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
void MarkDeclRefReferenced(DeclRefExpr *E)
Perform reference-marking and odr-use handling for a DeclRefExpr.
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)
SourceLocation getInlineSpecLoc() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
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
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 ...
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)
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 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
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...
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
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.
CXXMethodDecl * LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the copying assignment operator for the given class.
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.
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)
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Extra information about a function prototype.
void clear()
Clear the base-paths results.
CallingConv getCallConv() const
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
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.
SpecialMemberOverloadResult * LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
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)
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 isObjCRetainableType() const
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.
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...
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
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...
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, bool HasUsingKeyword, SourceLocation UsingLoc, CXXScopeSpec &SS, UnqualifiedId &Name, AttributeList *AttrList, bool HasTypenameKeyword, SourceLocation TypenameLoc)
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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...
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...
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
ImplicitExceptionSpecification ComputeInheritingCtorExceptionSpec(SourceLocation Loc, CXXConstructorDecl *CD)
Determine what sort of exception specification an inheriting constructor of a class will have...
ParmVarDecl * getParam(unsigned i) const
CXXMethodDecl * getCanonicalDecl() override
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
static CXXCtorInitializer * Create(ASTContext &Context, FieldDecl *Member, SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R, VarDecl **Indices, unsigned NumIndices)
Creates a new member initializer that optionally contains array indices used to describe an elementwi...
bool isTranslationUnit() const
void setElaboratedKeywordLoc(SourceLocation Loc)
TagKind getTagKind() const
The iterator over UnresolvedSets.
SourceRange getLocalSourceRange() const
Get the local source range.
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
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
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, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
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...
SpecialMemberOverloadResult - The overloading result for a special member function.
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
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 DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
const LangOptions & getLangOpts() const
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 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...
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
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)
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.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, AttributeList *AttrList, bool IsInstantiation, bool HasTypenameKeyword, SourceLocation TypenameLoc)
Builds a using declaration.
static bool isValidUDSuffix(const LangOptions &LangOpts, StringRef Suffix)
Determine whether a suffix is a valid ud-suffix.
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.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
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...
ImplicitExceptionSpecification ComputeDefaultedDtorExceptionSpec(CXXMethodDecl *MD)
Determine what sort of exception specification a defaulted destructor of a class will have...
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
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.
static unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built...
void setNumCtorInitializers(unsigned numCtorInitializers)
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo)
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)
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
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
unsigned getNumParams() const
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.
const LangOptions & LangOpts
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.
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' ...
This object can be modified without requiring retains or releases.
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.
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...
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
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.
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a member subobject.
param_type_iterator param_type_begin() const
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp)
ImplicitExceptionSpecification ComputeDefaultedCopyCtorExceptionSpec(CXXMethodDecl *MD)
Determine what sort of exception specification a defaulted default constructor of a class will have...
SourceLocation getFriendSpecLoc() const
DeclarationNameTable DeclarationNames
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
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.
bool isRealFloatingType() const
Floating point categories.
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...
ImplicitExceptionSpecification ComputeDefaultedMoveCtorExceptionSpec(CXXMethodDecl *MD)
Determine what sort of exception specification a defaulted move constructor of a class will have...
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...
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.
static void getDefaultArgExprsForConstructors(Sema &S, CXXRecordDecl *Class)
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.
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.
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.
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
bool isInitListConstructor(const CXXConstructorDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
SourceLocation getVolatileSpecLoc() const
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, AttributeList *Attrs=nullptr)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
void PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, const BlockExpr *blkExpr=nullptr)
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
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.
enum clang::DeclaratorChunk::@185 Kind
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()
bool isConstexprSpecified() const
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...
ASTMutationListener * getASTMutationListener() const
bool isExplicit() const
Determine whether this constructor was marked "explicit" or not.
void setInheritConstructors(bool Inherit=true)
Set that this base class's constructors should be inherited.
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.
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
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal 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
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
unsigned getNumBases() const
Retrieves the number of base classes of this class.
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 ...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
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.
llvm::FoldingSet< SpecialMemberOverloadResult > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
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...
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static bool RefersToRValueRef(Expr *MemRef)
const clang::PrintingPolicy & getPrintingPolicy() const
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
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.
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
There is no lifetime qualification on this type.
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
DeclContext * getEntity() const
static bool CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef, const FunctionDecl *FnDecl)
void setSourceOrder(int pos)
Set the source order of this initializer.
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.
static CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
Represents a call to an inherited base class constructor from an inheriting constructor.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, 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...
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
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
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.
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
const TemplateArgument * iterator
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.
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.
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. ...
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
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
static InitializedEntity InitializeElement(ASTContext &Context, unsigned Index, const InitializedEntity &Parent)
Create the initialization entity for an array element.
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.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ExprResult DefaultLvalueConversion(Expr *E)
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 implicitly move constructor, but overload resolution failed so we...
SourceRange getSourceRange() const override LLVM_READONLY
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)
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.
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.
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.
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.
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)
unsigned TypeAlias
Whether this template specialization type is a substituted type alias.
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
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.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
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)
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
static AttributeList * getMSPropertyAttr(AttributeList *list)
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)
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.
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.
ImplicitExceptionSpecification ComputeDefaultedCopyAssignmentExceptionSpec(CXXMethodDecl *MD)
Determine what sort of exception specification a defautled copy assignment operator of a class will h...
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
TypeLoc IgnoreParens() const
CanQualType UnsignedLongLongTy
bool isFinalSpecified() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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
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 hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
DeclarationName - The name of a declaration.
ImplicitExceptionSpecification ComputeDefaultedDefaultCtorExceptionSpec(SourceLocation Loc, CXXMethodDecl *MD)
Determine what sort of exception specification a defaulted copy constructor of a class will have...
unsigned getNumHandlers() const
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName)
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
size_t param_size() const
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
detail::InMemoryDirectory::const_iterator E
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i...
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool 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 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...
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...
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 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)
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...
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()
static void diagnoseDeprecatedCopyOperation(Sema &S, CXXMethodDecl *CopyOp, SourceLocation UseLoc)
Diagnose an implicit copy operation for a class which is odr-used, but which is deprecated because th...
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.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
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...
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsExplicitSpecialization, bool &Invalid)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
ClassTemplateDecl * getCanonicalDecl() override
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.
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...
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
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
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
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.
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.
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...
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.
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)
FunctionDecl * FindUsualDeallocationFunction(SourceLocation StartLoc, bool CanProvideSize, DeclarationName Name)
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.
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)
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.
unsigned getIndex() const
Retrieve the index of the template parameter.
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]).
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...
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
const FunctionDecl * getOperatorDelete() const
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl * > &Ivars)
CollectIvarsToConstructOrDestruct - Collect those ivars which require initialization.
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.
ImplicitExceptionSpecification ComputeDefaultedMoveAssignmentExceptionSpec(CXXMethodDecl *MD)
Determine what sort of exception specification a defaulted move assignment operator of a class will h...
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.
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.
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
QualType getElementType() const
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Expr * getDefaultArgExprForConstructor(const CXXConstructorDecl *CD, unsigned ParmIdx)
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...
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.
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.
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
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...
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.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
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.
NamespaceDecl * getStdNamespace() const
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
The object is actually the complete object.
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...
TemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon, QualType Aliased)
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.
Represents the canonical version of C arrays with a specified constant size.
base_class_range vbases()
ExceptionSpecInfo ExceptionSpec
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
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.
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 method 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