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) {
122 bool Invalid =
false;
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);
196 "Must have noexcept result for EST_ComputedNoexcept.");
198 "Should not generate implicit declarations for dependent cases, "
199 "and don't know how to handle them anyway.");
210 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
212 "Shouldn't collect exceptions when throw-all is guaranteed.");
217 Exceptions.push_back(E);
245 if (Self->canThrow(E))
253 diag::err_typecheck_decl_incomplete_type)) {
274 CheckCompletedExpr(Arg, EqualLoc);
282 UnparsedDefaultArgInstantiationsMap::iterator InstPos
285 for (
unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
286 InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
301 if (!param || !DefaultArg)
309 Diag(EqualLoc, diag::err_param_default_argument)
310 << DefaultArg->getSourceRange();
325 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
326 << DefaultArg->getSourceRange();
331 CheckDefaultArgumentVisitor DefaultArgChecker(DefaultArg,
this);
332 if (DefaultArgChecker.Visit(DefaultArg)) {
388 if (MightBeFunction) {
392 MightBeFunction =
false;
395 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
401 if (Toks->size() > 1)
403 Toks->back().getLocation());
417 MightBeFunction =
false;
423 for (
unsigned NumParams = FD->
getNumParams(); NumParams > 0; --NumParams) {
439 bool Invalid =
false;
450 for (; PrevForDefaultArgs;
498 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
501 p < NumParams; ++
p) {
505 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
508 if (OldParamHasDfl && NewParamHasDfl) {
509 unsigned DiagDefaultParamID =
510 diag::err_param_default_argument_redefinition;
525 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
543 for (
auto Older = PrevForDefaultArgs;
545 Older = Older->getPreviousDecl();
546 OldParam = Older->getParamDecl(
p);
551 }
else if (OldParamHasDfl) {
563 }
else if (NewParamHasDfl) {
567 diag::err_param_default_argument_template_redecl)
570 diag::note_template_prev_declaration)
601 if (Record->getDescribedClassTemplate())
603 else if (isa<ClassTemplatePartialSpecializationDecl>(Record))
610 diag::err_param_default_argument_member_template_redecl)
620 if (isa<CXXConstructorDecl>(New) &&
624 if (NewSM != OldSM) {
627 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
658 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
680 "Should only be called if types are otherwise the same.");
691 NewType =
P->getPointeeType();
719 for (p = 0; p < NumParams; ++
p) {
731 unsigned LastMissingDefaultArg = 0;
732 for (; p < NumParams; ++
p) {
739 diag::err_param_default_argument_missing_name)
743 diag::err_param_default_argument_missing);
745 LastMissingDefaultArg =
p;
749 if (LastMissingDefaultArg > 0) {
754 for (p = 0; p <= LastMissingDefaultArg; ++
p) {
768 unsigned ArgIndex = 0;
772 i != e; ++i, ++ArgIndex) {
775 if (!(*i)->isDependentType() &&
777 diag::err_constexpr_non_literal_param,
779 isa<CXXConstructorDecl>(FD)))
795 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
815 << isa<CXXConstructorDecl>(NewFD)
817 for (
const auto &I : RD->
vbases())
818 Diag(I.getLocStart(),
819 diag::note_constexpr_virtual_base_here) << I.getSourceRange();
824 if (!isa<CXXConstructorDecl>(NewFD)) {
837 while (!WrittenVirtual->isVirtualAsWritten())
839 if (WrittenVirtual != Method)
840 Diag(WrittenVirtual->getLocation(),
841 diag::note_overridden_virtual_function);
849 diag::err_constexpr_non_literal_return))
870 for (
const auto *DclIt : DS->
decls()) {
871 switch (DclIt->getKind()) {
872 case Decl::StaticAssert:
874 case Decl::UsingShadow:
875 case Decl::UsingDirective:
876 case Decl::UnresolvedUsingTypename:
877 case Decl::UnresolvedUsingValue:
884 case Decl::TypeAlias: {
887 const auto *TN = cast<TypedefNameDecl>(DclIt);
888 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
890 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
893 << isa<CXXConstructorDecl>(Dcl);
900 case Decl::CXXRecord:
902 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition())
905 ? diag::warn_cxx11_compat_constexpr_type_definition
906 : diag::ext_constexpr_type_definition)
907 << isa<CXXConstructorDecl>(Dcl);
910 case Decl::EnumConstant:
911 case Decl::IndirectField:
921 const auto *VD = cast<VarDecl>(DclIt);
922 if (VD->isThisDeclarationADefinition()) {
923 if (VD->isStaticLocal()) {
924 SemaRef.
Diag(VD->getLocation(),
925 diag::err_constexpr_local_var_static)
926 << isa<CXXConstructorDecl>(Dcl)
930 if (!VD->getType()->isDependentType() &&
932 VD->getLocation(), VD->getType(),
933 diag::err_constexpr_local_var_non_literal_type,
934 isa<CXXConstructorDecl>(Dcl)))
936 if (!VD->getType()->isDependentType() &&
937 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
938 SemaRef.
Diag(VD->getLocation(),
939 diag::err_constexpr_local_var_no_init)
940 << isa<CXXConstructorDecl>(Dcl);
944 SemaRef.
Diag(VD->getLocation(),
946 ? diag::warn_cxx11_compat_constexpr_local_var
947 : diag::ext_constexpr_local_var)
948 << isa<CXXConstructorDecl>(Dcl);
952 case Decl::NamespaceAlias:
962 << isa<CXXConstructorDecl>(Dcl);
981 llvm::SmallSet<Decl*, 16> &
Inits,
998 if (!Inits.count(Field)) {
1000 SemaRef.
Diag(Dcl->
getLocation(), diag::err_constexpr_ctor_missing_init);
1003 SemaRef.
Diag(Field->
getLocation(), diag::note_constexpr_ctor_missing_init);
1006 for (
auto *I : RD->
fields())
1009 if (!RD->
isUnion() || Inits.count(I))
1021 switch (S->getStmtClass()) {
1022 case Stmt::NullStmtClass:
1026 case Stmt::DeclStmtClass:
1036 case Stmt::ReturnStmtClass:
1038 if (isa<CXXConstructorDecl>(Dcl)) {
1041 Cxx1yLoc = S->getLocStart();
1045 ReturnStmts.push_back(S->getLocStart());
1048 case Stmt::CompoundStmtClass: {
1051 Cxx1yLoc = S->getLocStart();
1054 for (
auto *BodyIt : CompStmt->
body()) {
1062 case Stmt::AttributedStmtClass:
1064 Cxx1yLoc = S->getLocStart();
1067 case Stmt::IfStmtClass: {
1070 Cxx1yLoc = S->getLocStart();
1083 case Stmt::WhileStmtClass:
1084 case Stmt::DoStmtClass:
1085 case Stmt::ForStmtClass:
1086 case Stmt::CXXForRangeStmtClass:
1087 case Stmt::ContinueStmtClass:
1093 Cxx1yLoc = S->getLocStart();
1094 for (
Stmt *SubStmt : S->children())
1101 case Stmt::SwitchStmtClass:
1102 case Stmt::CaseStmtClass:
1103 case Stmt::DefaultStmtClass:
1104 case Stmt::BreakStmtClass:
1108 Cxx1yLoc = S->getLocStart();
1109 for (
Stmt *SubStmt : S->children())
1122 Cxx1yLoc = S->getLocStart();
1126 SemaRef.
Diag(S->getLocStart(), diag::err_constexpr_body_invalid_stmt)
1127 << isa<CXXConstructorDecl>(Dcl);
1136 if (isa<CXXTryStmt>(Body)) {
1146 Diag(Body->getLocStart(), diag::err_constexpr_function_try_block)
1147 << isa<CXXConstructorDecl>(Dcl);
1157 for (
auto *BodyIt : CompBody->
body()) {
1162 if (Cxx1yLoc.isValid())
1165 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
1166 : diag::ext_constexpr_body_invalid_stmt)
1167 << isa<CXXConstructorDecl>(Dcl);
1170 = dyn_cast<CXXConstructorDecl>(Dcl)) {
1179 if (Constructor->getNumCtorInitializers() == 0 &&
1184 }
else if (!Constructor->isDependentContext() &&
1185 !Constructor->isDelegatingConstructor()) {
1186 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
1190 bool AnyAnonStructUnionMembers =
false;
1191 unsigned Fields = 0;
1193 E = RD->
field_end(); I != E; ++I, ++Fields) {
1194 if (I->isAnonymousStructOrUnion()) {
1195 AnyAnonStructUnionMembers =
true;
1203 if (AnyAnonStructUnionMembers ||
1204 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
1208 llvm::SmallSet<Decl*, 16>
Inits;
1209 for (
const auto *I: Constructor->inits()) {
1213 Inits.insert(
ID->chain_begin(),
ID->chain_end());
1216 bool Diagnosed =
false;
1217 for (
auto *I : RD->
fields())
1224 if (ReturnStmts.empty()) {
1233 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
1234 : diag::err_constexpr_body_no_return);
1237 if (ReturnStmts.size() > 1) {
1238 Diag(ReturnStmts.back(),
1240 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
1241 : diag::ext_constexpr_body_multiple_return);
1242 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
1243 Diag(ReturnStmts[I], diag::note_constexpr_body_previous_return);
1259 Diag(Dcl->
getLocation(), diag::ext_constexpr_function_never_constant_expr)
1260 << isa<CXXConstructorDecl>(Dcl);
1261 for (
size_t I = 0, N = Diags.size(); I != N; ++I)
1262 Diag(Diags[I].first, Diags[I].second);
1281 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
1283 CurDecl = dyn_cast_or_null<CXXRecordDecl>(
CurContext);
1302 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
1304 CurDecl = dyn_cast_or_null<CXXRecordDecl>(
CurContext);
1324 for (
const auto &I : Current->
bases()) {
1336 Queue.push_back(Base);
1342 Current = Queue.pop_back_val();
1370 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1383 ((BaseDecl = BaseDecl->getDefinition()) &&
1385 Diag(BaseLoc, diag::err_circular_inheritance)
1389 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
1398 Access, TInfo, EllipsisLoc);
1403 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
1410 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
1417 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
1429 diag::err_incomplete_base_class, SpecifierRange)) {
1436 assert(BaseDecl &&
"Record type has no declaration");
1438 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
1440 assert(CXXBaseDecl &&
"Base type is not a C++ type");
1449 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
1457 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
1458 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
1460 << FA->isSpelledAsSealed();
1472 Access, TInfo, EllipsisLoc);
1499 if (!Attributes.
empty()) {
1502 if (
Attr->isInvalid() ||
1507 ? diag::warn_unknown_attribute_ignored
1508 : diag::err_base_specifier_attribute)
1522 Virtual, Access, TInfo,
1543 auto Decl = Rec->getAsCXXRecordDecl();
1546 for (
const auto &BaseSpec : Decl->bases()) {
1548 .getUnqualifiedType();
1549 if (Set.insert(Base).second)
1559 unsigned NumBases) {
1567 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
1574 unsigned NumGoodBases = 0;
1575 bool Invalid =
false;
1576 for (
unsigned idx = 0; idx < NumBases; ++idx) {
1586 Diag(Bases[idx]->getLocStart(),
1587 diag::err_duplicate_base_class)
1598 KnownBase = Bases[idx];
1599 Bases[NumGoodBases++] = Bases[idx];
1606 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
1624 Class->
setBases(Bases, NumGoodBases);
1626 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
1632 if (IndirectBaseTypes.count(CanonicalBase)) {
1636 = Class->
isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
1641 Diag(Bases[idx]->getLocStart (), diag::warn_inaccessible_base_class)
1645 assert(Bases[idx]->isVirtual());
1660 unsigned NumBases) {
1661 if (!ClassDecl || !Bases || !NumBases)
1710 assert(BasePathArray.empty() &&
"Base path array must be empty!");
1719 for (
unsigned I = Path.size(); I != 0; --I) {
1720 if (Path[I - 1].
Base->isVirtual()) {
1727 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
1728 BasePathArray.push_back(const_cast<CXXBaseSpecifier*>(Path[I].Base));
1741 unsigned InaccessibleBaseID,
1742 unsigned AmbigiousBaseConvID,
1753 assert(DerivationOkay &&
1754 "Can only be used with a derived-to-base conversion");
1755 (void)DerivationOkay;
1758 if (InaccessibleBaseID) {
1761 InaccessibleBaseID)) {
1777 if (AmbigiousBaseConvID) {
1787 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
1796 Diag(Loc, AmbigiousBaseConvID)
1797 << Derived << Base << PathDisplayStr << Range << Name;
1806 bool IgnoreAccess) {
1809 : diag::err_upcast_to_inaccessible_base,
1810 diag::err_ambiguous_derived_to_base_conv,
1829 std::string PathDisplayStr;
1830 std::set<unsigned> DisplayedPaths;
1832 Path != Paths.
end(); ++Path) {
1833 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
1836 PathDisplayStr +=
"\n ";
1838 for (CXXBasePath::const_iterator Element = Path->begin();
1839 Element != Path->end(); ++Element)
1840 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
1844 return PathDisplayStr;
1856 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
1886 if (!OverloadedMethods.empty()) {
1887 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
1888 Diag(OA->getLocation(),
1889 diag::override_keyword_hides_virtual_member_function)
1890 <<
"override" << (OverloadedMethods.size() > 1);
1891 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
1892 Diag(FA->getLocation(),
1893 diag::override_keyword_hides_virtual_member_function)
1894 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
1895 << (OverloadedMethods.size() > 1);
1906 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
1907 Diag(OA->getLocation(),
1908 diag::override_keyword_only_allowed_on_virtual_member_functions)
1912 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
1913 Diag(FA->getLocation(),
1914 diag::override_keyword_only_allowed_on_virtual_member_functions)
1915 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
1926 bool HasOverriddenMethods =
1928 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
1929 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
1938 isa<CXXDestructorDecl>(MD))
1950 Diag(MD->
getLocation(), diag::warn_function_marked_not_override_overriding)
1962 FinalAttr *FA = Old->
getAttr<FinalAttr>();
1968 << FA->isSpelledAsSealed();
1977 return !RD->isCompleteDefinition() ||
1978 !RD->hasTrivialDefaultConstructor() ||
1979 !RD->hasTrivialDestructor();
1985 if (it->isDeclspecPropertyAttribute())
2009 Expr *BitWidth =
static_cast<Expr*
>(BW);
2016 if (cast<CXXRecordDecl>(
CurContext)->isInterface()) {
2020 unsigned InvalidDecl;
2021 bool ShowDeclName =
true;
2031 ShowDeclName =
false;
2036 ShowDeclName =
false;
2051 Diag(Loc, diag::err_invalid_member_in_interface)
2052 << (InvalidDecl-1) << Name;
2054 Diag(Loc, diag::err_invalid_member_in_interface)
2055 << (InvalidDecl-1) <<
"";
2081 diag::err_storageclass_invalid_for_member);
2101 const char *PrevSpec;
2106 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
2110 const char *PrevSpec;
2116 "This is the only DeclSpec that should fail to be applied");
2120 isInstField =
false;
2131 Diag(Loc, diag::err_bad_variable_name)
2140 if (TemplateParameterLists.size()) {
2142 if (TemplateParams->
size()) {
2151 diag::err_template_member_noparams)
2177 if (MSPropertyAttr) {
2179 BitWidth, InitStyle, AS, MSPropertyAttr);
2182 isInstField =
false;
2185 BitWidth, InitStyle, AS);
2186 assert(Member &&
"HandleField never returns null");
2197 }
else if (isa<VarDecl>(Member) || isa<VarTemplateDecl>(Member)) {
2200 Diag(Loc, diag::err_static_not_bitfield)
2201 << Name << BitWidth->getSourceRange();
2202 }
else if (isa<TypedefDecl>(Member)) {
2204 Diag(Loc, diag::err_typedef_not_bitfield)
2205 << Name << BitWidth->getSourceRange();
2209 Diag(Loc, diag::err_not_integral_type_bitfield)
2210 << Name << cast<ValueDecl>(Member)->getType()
2211 << BitWidth->getSourceRange();
2223 FunTmpl->getTemplatedDecl()->setAccess(AS);
2224 else if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(Member))
2225 VarTmpl->getTemplatedDecl()->setAccess(AS);
2236 if (
CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(Member))
2242 assert((Name || isInstField) &&
"No identifier for non-field ?");
2245 FieldDecl *FD = cast<FieldDecl>(Member);
2264 class UninitializedFieldVisitor
2269 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
2272 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
2287 UninitializedFieldVisitor(
Sema &
S,
2288 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
2289 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
2290 : Inherited(S.
Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
2291 Constructor(nullptr), InitList(
false), InitListFieldDecl(nullptr) {}
2294 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
2295 bool CheckReferenceOnly) {
2297 bool ReferenceField =
false;
2302 Fields.push_back(FD);
2304 ReferenceField =
true;
2310 if (CheckReferenceOnly && !ReferenceField)
2316 for (
auto I = Fields.rbegin() + 1, E = Fields.rend(); I != E; ++I) {
2317 UsedFieldIndex.push_back((*I)->getFieldIndex());
2320 for (
auto UsedIter = UsedFieldIndex.begin(),
2321 UsedEnd = UsedFieldIndex.end(),
2322 OrigIter = InitFieldIndex.begin(),
2323 OrigEnd = InitFieldIndex.end();
2324 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
2325 if (*UsedIter < *OrigIter)
2327 if (*UsedIter > *OrigIter)
2334 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
2349 if (isa<VarDecl>(SubME->getMemberDecl()))
2352 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
2357 AllPODFields =
false;
2359 Base = SubME->getBase();
2365 if (AddressOf && AllPODFields)
2371 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
2372 BaseCast = cast<ImplicitCastExpr>(BaseCast->getSubExpr());
2385 if (!Decls.count(FoundVD))
2390 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
2392 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
2397 if (CheckReferenceOnly && !IsReference)
2401 unsigned diag = IsReference
2402 ? diag::warn_reference_field_is_uninit
2403 : diag::warn_field_is_uninit;
2406 S.
Diag(Constructor->getLocation(),
2407 diag::note_uninit_in_this_constructor)
2408 << (Constructor->isDefaultConstructor() && Constructor->isImplicit());
2412 void HandleValue(
Expr *E,
bool AddressOf) {
2415 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
2416 HandleMemberExpr(ME,
false ,
2422 Visit(CO->getCond());
2423 HandleValue(CO->getTrueExpr(),
AddressOf);
2424 HandleValue(CO->getFalseExpr(),
AddressOf);
2429 dyn_cast<BinaryConditionalOperator>(E)) {
2430 Visit(BCO->getCond());
2431 HandleValue(BCO->getFalseExpr(),
AddressOf);
2436 HandleValue(OVE->getSourceExpr(),
AddressOf);
2441 switch (BO->getOpcode()) {
2447 Visit(BO->getRHS());
2450 Visit(BO->getLHS());
2460 InitFieldIndex.push_back(0);
2461 for (
auto Child : ILE->
children()) {
2462 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
2463 CheckInitListExpr(SubList);
2467 ++InitFieldIndex.back();
2469 InitFieldIndex.pop_back();
2478 DeclsToRemove.clear();
2480 Constructor = FieldConstructor;
2485 InitListFieldDecl = Field;
2486 InitFieldIndex.clear();
2487 CheckInitListExpr(ILE);
2501 HandleMemberExpr(ME,
true ,
false );
2510 Inherited::VisitImplicitCastExpr(E);
2516 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
2520 if (ICE->getCastKind() ==
CK_NoOp)
2521 ArgExpr = ICE->getSubExpr();
2522 HandleValue(ArgExpr,
false );
2525 Inherited::VisitCXXConstructExpr(E);
2530 if (isa<MemberExpr>(Callee)) {
2531 HandleValue(Callee,
false );
2537 Inherited::VisitCXXMemberCallExpr(E);
2546 HandleValue(E->
getArg(0),
false );
2552 Inherited::VisitCallExpr(E);
2558 if (isa<UnresolvedLookupExpr>(Callee))
2559 return Inherited::VisitCXXOperatorCallExpr(E);
2563 HandleValue(Arg->IgnoreParenImpCasts(),
false );
2573 DeclsToRemove.push_back(FD);
2576 HandleValue(E->
getLHS(),
false );
2581 Inherited::VisitBinaryOperator(E);
2591 HandleValue(ME->
getBase(),
true );
2596 Inherited::VisitUnaryOperator(E);
2606 static void DiagnoseUninitializedFields(
2623 llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
2626 for (
auto *I : RD->
decls()) {
2627 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
2628 UninitializedFields.insert(FD);
2629 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
2630 UninitializedFields.insert(IFD->getAnonField());
2634 llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
2635 for (
auto I : RD->
bases())
2636 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
2638 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
2641 UninitializedFieldVisitor UninitializedChecker(SemaRef,
2642 UninitializedFields,
2643 UninitializedBaseClasses);
2645 for (
const auto *FieldInit : Constructor->
inits()) {
2646 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
2649 Expr *InitExpr = FieldInit->getInit();
2654 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
2655 InitExpr = Default->getExpr();
2659 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
2660 FieldInit->getAnyMember(),
2661 FieldInit->getBaseClass());
2663 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
2664 FieldInit->getAnyMember(),
2665 FieldInit->getBaseClass());
2691 "must set init style when field is created");
2713 Init = Seq.Perform(*
this, Entity, Kind, InitExpr);
2729 InitExpr = Init.
get();
2743 DirectBaseSpec =
nullptr;
2744 for (
const auto &Base : ClassDecl->
bases()) {
2748 DirectBaseSpec = &Base;
2756 VirtualBaseSpec =
nullptr;
2757 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
2765 Path != Paths.
end(); ++Path) {
2766 if (Path->back().Base->isVirtual()) {
2767 VirtualBaseSpec = Path->back().Base;
2774 return DirectBaseSpec || VirtualBaseSpec;
2789 DS, IdLoc, InitList,
2809 DS, IdLoc, List, EllipsisLoc);
2818 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
2819 : ClassDecl(ClassDecl) {}
2821 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2823 if (
FieldDecl *Member = dyn_cast<FieldDecl>(ND))
2825 return isa<TypeDecl>(ND);
2882 if (!Result.
empty()) {
2884 if ((Member = dyn_cast<FieldDecl>(Result.
front())) ||
2887 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
2889 <<
SourceRange(IdLoc, Init->getSourceRange().getEnd());
2899 if (TemplateTypeTy) {
2915 bool NotUnknownSpecialization =
false;
2917 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
2918 NotUnknownSpecialization = !Record->hasAnyDependentBases();
2920 if (!NotUnknownSpecialization) {
2925 *MemberOrBase, IdLoc);
2939 llvm::make_unique<MemInitializerValidatorCCC>(ClassDecl),
2946 PDiag(diag::err_mem_init_not_member_or_class_suggest)
2947 << MemberOrBase <<
true);
2954 DirectBaseSpec, VirtualBaseSpec)) {
2959 PDiag(diag::err_mem_init_not_member_or_class_suggest)
2960 << MemberOrBase <<
false,
2966 diag::note_base_class_specified_here)
2975 if (!TyD && BaseType.
isNull()) {
2976 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
2977 << MemberOrBase <<
SourceRange(IdLoc,Init->getSourceRange().getEnd());
3019 Init = Op->getSubExpr();
3033 IsPointer ? diag::warn_init_ptr_member_to_parameter_addr
3034 : diag::warn_bind_ref_member_to_parameter)
3035 << Member << Parameter << Init->getSourceRange();
3041 S.
Diag(Member->
getLocation(), diag::note_ref_or_ptr_member_declared_here)
3042 << (
unsigned)IsPointer;
3050 assert((DirectMember || IndirectMember) &&
3051 "Member must be a FieldDecl or IndirectFieldDecl");
3060 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
3061 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
3062 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
3063 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
3076 bool InitList =
false;
3077 if (isa<InitListExpr>(Init)) {
3093 ExprResult MemberInit = InitSeq.Perform(*
this, MemberEntity, Kind, Args,
3104 if (MemberInit.isInvalid())
3107 Init = MemberInit.get();
3126 return Diag(NameLoc, diag::err_delegating_ctor)
3128 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
3130 bool InitList =
true;
3132 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
3134 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
3146 ExprResult DelegationInit = InitSeq.Perform(*
this, DelegationEntity, Kind,
3151 assert(cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor() &&
3152 "Delegating constructor with no target?");
3159 if (DelegationInit.isInvalid())
3170 DelegationInit = Init;
3173 DelegationInit.getAs<
Expr>(),
3185 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
3200 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
3229 if (!DirectBaseSpec && !VirtualBaseSpec) {
3238 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
3250 InitRange.
getEnd(), EllipsisLoc);
3257 if (DirectBaseSpec && VirtualBaseSpec)
3258 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
3263 BaseSpec = VirtualBaseSpec;
3266 bool InitList =
true;
3268 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
3270 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
3280 ExprResult BaseInit = InitSeq.Perform(*
this, BaseEntity, Kind, Args,
nullptr);
3305 InitRange.
getEnd(), EllipsisLoc);
3315 TargetType, ExprLoc);
3319 E->getSourceRange()).
get();
3335 bool IsInheritedVirtualBase,
3339 IsInheritedVirtualBase);
3343 switch (ImplicitInitKind) {
3354 for (
unsigned I = 0, E = Constructor->
getNumParams(); I != E; ++I) {
3367 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, Args);
3376 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
None);
3382 bool Moving = ImplicitInitKind ==
IIK_Move;
3404 BasePath.push_back(BaseSpec);
3414 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
3437 ValueDecl *Referenced = cast<MemberExpr>(MemRef)->getMemberDecl();
3452 bool Moving = ImplicitInitKind ==
IIK_Move;
3460 Expr *MemberExprBase =
3475 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
3477 MemberLookup.resolveKind();
3504 bool InitializingArray =
false;
3507 InitializingArray =
true;
3512 llvm::raw_svector_ostream OS(Str);
3513 OS <<
"__i" << IndexVariables.size();
3518 IterationVarName, SizeType,
3521 IndexVariables.push_back(IterationVar);
3527 "Reference to invented variable cannot fail!");
3529 assert(!IterationVarRef.isInvalid() &&
3530 "Conversion of invented variable cannot fail!");
3534 IterationVarRef.get(),
3536 if (CtorArg.isInvalid())
3539 BaseType = Array->getElementType();
3543 if (Moving && InitializingArray)
3550 Entities.reserve(1 + IndexVariables.size());
3555 for (
unsigned I = 0, N = IndexVariables.size(); I != N; ++I)
3569 = InitSeq.Perform(SemaRef, Entities.back(), InitKind,
3572 if (MemberInit.isInvalid())
3576 assert(IndexVariables.size() == 0 &&
3577 "Indirect field improperly initialized");
3581 MemberInit.getAs<
Expr>(),
3585 Loc, MemberInit.getAs<
Expr>(),
3587 IndexVariables.data(),
3588 IndexVariables.size());
3593 "Unhandled implicit init kind!");
3607 InitSeq.
Perform(SemaRef, InitEntity, InitKind,
None);
3630 diag::err_uninitialized_member_in_ctor)
3640 diag::err_uninitialized_member_in_ctor)
3664 CXXMemberInit =
nullptr;
3669 struct BaseAndFieldInfo {
3672 bool AnyErrorsInInits;
3674 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
3676 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
3679 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
3691 bool isImplicitCopyOrMove()
const {
3702 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
3706 AllToInit.push_back(Init);
3715 bool isInactiveUnionMember(
FieldDecl *Field) {
3725 if (isImplicitCopyOrMove())
3743 bool isWithinInactiveUnionMember(
FieldDecl *Field,
3746 return isInactiveUnionMember(Field);
3748 for (
auto *
C : Indirect->
chain()) {
3750 if (Field && isInactiveUnionMember(Field))
3765 if (!ArrayT->getSize())
3768 T = ArrayT->getElementType();
3783 return Info.addFieldInitializer(Init);
3797 if (Info.isWithinInactiveUnionMember(Field, Indirect))
3814 return Info.addFieldInitializer(Init);
3824 if (Info.AnyErrorsInInits)
3835 return Info.addFieldInitializer(Init);
3855 DiagnoseUninitializedFields(*
this, Constructor);
3865 if (!Initializers.empty()) {
3869 memcpy(baseOrMemberInitializers, Initializers.data(),
3881 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
3889 bool HadError =
false;
3891 for (
unsigned i = 0; i < Initializers.size(); i++) {
3900 for (
auto *
C : F->chain()) {
3903 Info.ActiveUnionMember.insert(std::make_pair(
3908 Info.ActiveUnionMember.insert(std::make_pair(
3915 llvm::SmallPtrSet<CXXBaseSpecifier *, 16> DirectVBases;
3916 for (
auto &I : ClassDecl->
bases()) {
3918 DirectVBases.insert(&I);
3922 for (
auto &VBase : ClassDecl->
vbases()) {
3924 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
3932 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
3933 << VBase.getType() << ClassDecl;
3937 Info.AllToInit.push_back(
Value);
3938 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
3943 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
3946 &VBase, IsInheritedVirtualBase,
3952 Info.AllToInit.push_back(CXXBaseInit);
3957 for (
auto &Base : ClassDecl->
bases()) {
3959 if (Base.isVirtual())
3964 Info.AllToInit.push_back(
Value);
3965 }
else if (!AnyErrors) {
3974 Info.AllToInit.push_back(CXXBaseInit);
3979 for (
auto *Mem : ClassDecl->
decls()) {
3980 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
3985 if (F->isUnnamedBitfield())
3991 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
4000 if (Info.isImplicitCopyOrMove())
4003 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
4004 if (F->getType()->isIncompleteArrayType()) {
4006 "Incomplete array type is not valid");
4018 unsigned NumInitializers = Info.AllToInit.size();
4019 if (NumInitializers > 0) {
4023 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
4040 for (
auto *Field : RD->
fields())
4068 bool ShouldCheckOrder =
false;
4069 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4071 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
4073 ShouldCheckOrder =
true;
4077 if (!ShouldCheckOrder)
4088 for (
const auto &VBase : ClassDecl->
vbases())
4092 for (
const auto &Base : ClassDecl->
bases()) {
4093 if (Base.isVirtual())
4099 for (
auto *Field : ClassDecl->
fields()) {
4106 unsigned NumIdealInits = IdealInitKeys.size();
4107 unsigned IdealIndex = 0;
4110 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
4116 for (; IdealIndex != NumIdealInits; ++IdealIndex)
4117 if (InitKey == IdealInitKeys[IdealIndex])
4123 if (IdealIndex == NumIdealInits && PrevInit) {
4126 diag::warn_initializer_out_of_order);
4139 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
4140 if (InitKey == IdealInitKeys[IdealIndex])
4143 assert(IdealIndex != NumIdealInits &&
4144 "initializer not found in initializer list");
4152 bool CheckRedundantInit(
Sema &S,
4162 diag::err_multiple_mem_initialization)
4167 assert(BaseClass &&
"neither field nor base");
4169 diag::err_multiple_base_initialization)
4179 typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
4180 typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
4182 bool CheckRedundantUnionInit(
Sema &S,
4184 RedundantUnionMap &Unions) {
4191 UnionEntry &En = Unions[Parent];
4192 if (En.first && En.first != Child) {
4194 diag::err_multiple_mem_union_initialization)
4197 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
4198 << 0 << En.second->getSourceRange();
4222 if (!ConstructorDecl)
4231 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
4238 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
4241 RedundantUnionMap MemberUnions;
4243 bool HadError =
false;
4244 for (
unsigned i = 0; i < MemInits.size(); i++) {
4252 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
4253 CheckRedundantUnionInit(*
this, Init, MemberUnions))
4257 if (CheckRedundantInit(*
this, Init, Members[Key]))
4262 if (MemInits.size() != 1) {
4264 diag::err_delegating_initializer_alone)
4265 << Init->
getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
4281 DiagnoseUninitializedFields(*
this, Constructor);
4298 for (
auto *Field : ClassDecl->
fields()) {
4322 assert(Dtor &&
"No dtor found for FieldClassDecl!");
4324 PDiag(diag::err_access_dtor_field)
4332 llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
4335 for (
const auto &Base : ClassDecl->
bases()) {
4340 if (Base.isVirtual())
4341 DirectVirtualBases.insert(RT);
4351 assert(Dtor &&
"No dtor found for BaseClassDecl!");
4355 PDiag(diag::err_access_dtor_base)
4357 << Base.getSourceRange(),
4365 for (
const auto &VBase : ClassDecl->
vbases()) {
4370 if (DirectVirtualBases.count(RT))
4381 assert(Dtor &&
"No dtor found for BaseClassDecl!");
4384 PDiag(diag::err_access_dtor_vbase)
4390 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
4404 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
4406 DiagnoseUninitializedFields(*
this, Constructor);
4418 :
TypeDiagnoser(DiagID == 0), DiagID(DiagID), SelID(SelID) { }
4421 if (Suppressed)
return;
4423 S.
Diag(Loc, DiagID) << T;
4425 S.
Diag(Loc, DiagID) << SelID << T;
4427 } Diagnoser(DiagID, SelID);
4459 if (!Def || Def->isBeingDefined())
4488 llvm::SmallPtrSet<const CXXMethodDecl *, 8> SeenPureMethods;
4490 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
4491 MEnd = FinalOverriders.end();
4495 SOEnd = M->second.end();
4496 SO != SOEnd; ++SO) {
4503 if (SO->second.size() != 1)
4506 if (!SO->second.front().Method->isPure())
4509 if (!SeenPureMethods.insert(SO->second.front().Method).second)
4512 Diag(SO->second.front().Method->getLocation(),
4513 diag::note_pure_virtual_function)
4514 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
4524 struct AbstractUsageInfo {
4531 : S(S), Record(Record),
4532 AbstractType(S.
Context.getCanonicalType(
4533 S.
Context.getTypeDeclType(Record))),
4537 if (Invalid)
return;
4545 struct CheckAbstractUsage {
4546 AbstractUsageInfo &Info;
4549 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
4550 : Info(Info), Ctx(Ctx) {}
4554 #define ABSTRACT_TYPELOC(CLASS, PARENT)
4555 #define TYPELOC(CLASS, PARENT) \
4556 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break;
4557 #include "clang/AST/TypeLocNodes.def"
4563 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
4578 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
4588 #define CheckPolymorphic(Type) \
4589 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \
4590 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \
4605 return Visit(
Next, Sel);
4615 T = Info.S.Context.getBaseElementType(T);
4618 if (CT != Info.AbstractType)
return;
4622 Info.S.Diag(Ctx->getLocation(), diag::err_array_of_abstract_type)
4623 << T << TL.getSourceRange();
4625 Info.S.Diag(Ctx->getLocation(), diag::err_abstract_type_in_decl)
4626 << Sel << T << TL.getSourceRange();
4628 Info.DiagnoseAbstractType();
4634 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
4657 for (
auto *D : RD->
decls()) {
4658 if (D->isImplicit())
continue;
4661 if (isa<CXXMethodDecl>(D)) {
4663 }
else if (isa<FunctionTemplateDecl>(D)) {
4664 FunctionDecl *FD = cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
4668 }
else if (isa<FieldDecl>(D)) {
4672 }
else if (isa<VarDecl>(D)) {
4673 VarDecl *VD = cast<VarDecl>(D);
4678 }
else if (isa<CXXRecordDecl>(D)) {
4680 }
else if (isa<ClassTemplateDecl>(D)) {
4682 cast<ClassTemplateDecl>(D)->getTemplatedDecl());
4693 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
4694 if (
Attr *TemplateAttr =
4695 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
4696 auto *A = cast<InheritableAttr>(TemplateAttr->clone(
getASTContext()));
4697 A->setInherited(
true);
4708 << Class << ClassAttr;
4715 for (Decl *Member : Class->
decls()) {
4716 if (!isa<VarDecl>(Member) && !isa<CXXMethodDecl>(Member))
4719 if (!MemberAttr || MemberAttr->
isInherited() || Member->isInvalidDecl())
4723 diag::err_attribute_dll_member_of_dll_class)
4724 << MemberAttr << ClassAttr;
4726 Member->setInvalidDecl();
4735 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
4736 const bool ClassImported = !ClassExported;
4753 for (Decl *Member : Class->
decls()) {
4763 if (MD->isDeleted())
4766 if (MD->isInlined()) {
4773 if (ClassImported && MD->isMoveAssignmentOperator() &&
4779 if (!cast<NamedDecl>(Member)->isExternallyVisible())
4785 NewAttr->setInherited(
true);
4789 if (MD && ClassExported) {
4795 if (MD->isUserProvided()) {
4806 }
else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
4807 MD->isCopyAssignmentOperator() ||
4808 MD->isMoveAssignmentOperator()) {
4848 NewAttr->setInherited(
true);
4849 BaseTemplateSpec->
addAttr(NewAttr);
4870 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
4875 diag::note_template_class_explicit_specialization_was_here)
4876 << BaseTemplateSpec;
4879 diag::note_template_class_instantiation_was_here)
4880 << BaseTemplateSpec;
4892 AbstractUsageInfo Info(*
this, Record);
4902 bool Complained =
false;
4903 for (
const auto *F : Record->
fields()) {
4904 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
4907 if (F->getType()->isReferenceType() ||
4908 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
4915 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
4916 << F->getType()->isReferenceType()
4917 << F->getDeclName();
4936 isa<IndirectFieldDecl>(D)) {
4948 !Record->
hasAttr<FinalAttr>())
4954 if (FinalAttr *FA = Record->
getAttr<FinalAttr>()) {
4956 << FA->isSpelledAsSealed();
4961 bool HasMethodWithOverrideControl =
false,
4962 HasOverridingMethodWithoutOverrideControl =
false;
4964 for (
auto *M : Record->
methods()) {
4969 if (M->hasAttr<OverrideAttr>())
4970 HasMethodWithOverrideControl =
true;
4971 else if (M->size_overridden_methods() > 0)
4972 HasOverridingMethodWithoutOverrideControl =
true;
4974 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted())
4979 if (!M->isImplicit() && !M->isUserProvided()) {
4991 if (HasMethodWithOverrideControl &&
4992 HasOverridingMethodWithoutOverrideControl) {
4995 for (
auto *M : Record->
methods())
5036 unsigned FieldQuals,
bool ConstRHS) {
5037 unsigned LHSQuals = 0;
5039 LHSQuals = FieldQuals;
5041 unsigned RHSQuals = FieldQuals;
5051 LHSQuals & Qualifiers::Const,
5052 LHSQuals & Qualifiers::Volatile);
5059 unsigned Quals,
bool ConstRHS) {
5115 if (Ctor && ClassDecl->
isUnion())
5131 for (
const auto &B : ClassDecl->
bases()) {
5133 if (!BaseType)
continue;
5147 for (
const auto *F : ClassDecl->
fields()) {
5148 if (F->isInvalidDecl())
5152 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
5155 ConstArg && !F->isMutable()))
5182 assert(cast<CXXConstructorDecl>(MD)->getInheritedConstructor() &&
5183 "only special members have implicit exception specs");
5227 "not an explicitly-defaulted special member");
5233 bool HadError =
false;
5242 unsigned ExpectedParams = 1;
5260 bool CanHaveConstParam =
false;
5273 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
5288 bool HasConstParam =
false;
5296 diag::err_defaulted_special_member_volatile_param) << CSM;
5300 if (HasConstParam && !CanHaveConstParam) {
5303 diag::err_defaulted_special_member_copy_const_param)
5308 diag::err_defaulted_special_member_move_const_param)
5313 }
else if (ExpectedParams) {
5331 : isa<CXXConstructorDecl>(MD)) &&
5334 Diag(MD->
getLocStart(), diag::err_incorrect_defaulted_constexpr) << CSM;
5368 llvm::makeArrayRef(&ArgType,
5380 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
5407 .getExceptionSpec();
5413 PDiag(diag::err_incorrect_defaulted_exception_spec)
5428 for (
auto &Check : Checks)
5433 for (
auto &Spec : Specs)
5438 struct SpecialMemberDeletionInfo {
5445 bool IsConstructor, IsAssignment, IsMove, ConstArg;
5448 bool AllFieldsAreConst;
5452 : S(S), MD(MD), CSM(CSM), Diagnose(Diagnose),
5454 ConstArg(
false), Loc(MD->getLocation()),
5455 AllFieldsAreConst(
true) {
5459 IsConstructor =
true;
5462 IsConstructor =
true;
5466 IsAssignment =
true;
5469 IsAssignment =
true;
5475 llvm_unreachable(
"invalid special member kind");
5481 ConstArg = RT->getPointeeType().isConstQualified();
5489 unsigned Quals,
bool IsMutable) {
5491 ConstArg && !IsMutable);
5494 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
5497 bool shouldDeleteForField(
FieldDecl *FD);
5498 bool shouldDeleteForAllConstMembers();
5500 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
5502 bool shouldDeleteForSubobjectCall(Subobject Subobj,
5504 bool IsDtorCallInCtor);
5512 bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
5532 bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
5534 bool IsDtorCallInCtor) {
5541 DiagKind = !Decl ? 0 : 1;
5544 else if (!isAccessible(Subobj, Decl))
5562 diag::note_deleted_special_member_class_subobject)
5564 << Field << DiagKind << IsDtorCallInCtor;
5568 diag::note_deleted_special_member_class_subobject)
5570 << Base->
getType() << DiagKind << IsDtorCallInCtor;
5583 bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
5586 bool IsMutable = Field && Field->
isMutable();
5604 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
5611 if (IsConstructor) {
5614 false,
false,
false,
false,
false);
5615 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
5624 bool SpecialMemberDeletionInfo::shouldDeleteForBase(
CXXBaseSpecifier *Base) {
5626 return shouldDeleteForClassSubobject(BaseClass, Base, 0);
5631 bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
5640 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
5641 << MD->
getParent() << FD << FieldType << 0;
5652 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
5658 AllFieldsAreConst =
false;
5664 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
5668 }
else if (IsAssignment) {
5673 << IsMove << MD->
getParent() << FD << FieldType << 0;
5688 if (!inUnion() && FieldRecord->
isUnion() &&
5690 bool AllVariantFieldsAreConst =
true;
5693 for (
auto *UI : FieldRecord->
fields()) {
5697 AllVariantFieldsAreConst =
false;
5700 if (UnionFieldRecord &&
5701 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
5711 diag::note_deleted_default_ctor_all_const)
5721 if (shouldDeleteForClassSubobject(FieldRecord, FD,
5732 bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
5739 diag::note_deleted_default_ctor_all_const)
5788 if (!Diagnose)
return true;
5791 for (
auto *I : RD->
ctors()) {
5792 if (I->isMoveConstructor()) {
5793 UserDeclaredMove = I;
5797 assert(UserDeclaredMove);
5800 if (!Diagnose)
return true;
5803 for (
auto *I : RD->
methods()) {
5804 if (I->isMoveAssignmentOperator()) {
5805 UserDeclaredMove = I;
5809 assert(UserDeclaredMove);
5812 if (UserDeclaredMove) {
5814 diag::note_deleted_copy_user_declared_move)
5832 OperatorDelete,
false)) {
5839 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, Diagnose);
5841 for (
auto &BI : RD->
bases())
5842 if (!BI.isVirtual() &&
5843 SMI.shouldDeleteForBase(&BI))
5848 if (!RD->
isAbstract() || !SMI.IsConstructor) {
5849 for (
auto &BI : RD->
vbases())
5850 if (SMI.shouldDeleteForBase(&BI))
5854 for (
auto *FI : RD->
fields())
5855 if (!FI->isInvalidDecl() && !FI->isUnnamedBitfield() &&
5856 SMI.shouldDeleteForField(FI))
5859 if (SMI.shouldDeleteForAllConstMembers())
5884 *Selected =
nullptr;
5888 llvm_unreachable(
"not a special member");
5906 for (
auto *CI : RD->
ctors()) {
5907 if (!CI->isDefaultConstructor())
5914 *Selected = DefCtor;
5943 }
else if (!Selected) {
5951 goto NeedOverloadResolution;
5961 }
else if (!Selected) {
5966 goto NeedOverloadResolution;
5970 NeedOverloadResolution:
5994 llvm_unreachable(
"unknown special method kind");
5998 for (
auto *CI : RD->
ctors())
5999 if (!CI->isImplicit())
6003 typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
6006 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
6036 ConstRHS, Diagnose ? &Selected :
nullptr))
6044 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
6047 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
6048 }
else if (!Selected)
6049 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
6054 << Kind << SubType.getUnqualifiedType() << CSM;
6056 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
6057 << Kind << SubType.getUnqualifiedType() << CSM;
6062 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
6063 << Kind << SubType.getUnqualifiedType() << CSM;
6077 bool ConstArg,
bool Diagnose) {
6078 for (
const auto *FI : RD->
fields()) {
6079 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
6085 if (FI->isAnonymousStructOrUnion()) {
6087 CSM, ConstArg, Diagnose))
6098 S.
Diag(FI->getLocation(), diag::note_nontrivial_in_class_init) << FI;
6109 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
6114 bool ConstRHS = ConstArg && !FI->isMutable();
6142 bool ConstArg =
false;
6187 llvm_unreachable(
"not a special member");
6193 diag::note_nontrivial_default_arg)
6212 for (
const auto &BI : RD->bases())
6248 if (RD->getNumVBases()) {
6258 for (
const auto *MI : RD->methods()) {
6259 if (MI->isVirtual()) {
6261 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
6266 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
6275 struct FindHiddenVirtualMethodData {
6278 llvm::SmallPtrSet<const CXXMethodDecl *, 8> OverridenAndUsingBaseMethods;
6285 const llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
6304 FindHiddenVirtualMethodData &Data
6305 = *
static_cast<FindHiddenVirtualMethodData*
>(UserData);
6310 bool foundSameNameMethod =
false;
6318 foundSameNameMethod =
true;
6331 if (!Data.S->IsOverload(Data.Method, MD,
false))
6335 overloadedMethods.push_back(MD);
6339 if (foundSameNameMethod)
6340 Data.OverloadedMethods.append(overloadedMethods.begin(),
6341 overloadedMethods.end());
6342 return foundSameNameMethod;
6347 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
6366 FindHiddenVirtualMethodData Data;
6377 ND = shad->getTargetDecl();
6383 OverloadedMethods = Data.OverloadedMethods;
6388 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
6391 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
6408 if (!OverloadedMethods.empty()) {
6410 << MD << (OverloadedMethods.size() > 1);
6427 if (l->getKind() != AttributeList::AT_Visibility)
6430 Diag(l->getLoc(), diag::warn_attribute_after_definition_ignored) <<
6440 dyn_cast_or_null<CXXRecordDecl>(TagDecl));
6512 D = TD->getTemplatedDecl();
6514 if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
6515 ParameterLists.push_back(PSD->getTemplateParameters());
6518 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
6519 ParameterLists.push_back(DD->getTemplateParameterList(i));
6523 ParameterLists.push_back(FTD->getTemplateParameters());
6527 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
6528 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
6529 ParameterLists.push_back(TD->getTemplateParameterList(i));
6533 ParameterLists.push_back(CTD->getTemplateParameters());
6539 if (Params->size() > 0)
6544 if (Param->getDeclName()) {
6555 if (!RecordD)
return;
6562 if (!RecordD)
return;
6737 const char *ConstRef
6740 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
6772 if (!OperatorDelete)
6799 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
6802 if (TST->isTypeAlias())
6804 << DeclaratorType << 1;
6973 bool NeedsTypedef =
false;
6977 bool PastFunctionChunk =
false;
6979 switch (Chunk.Kind) {
6981 if (!PastFunctionChunk) {
6982 if (Chunk.Fun.HasTrailingReturnType) {
6987 PastFunctionChunk =
true;
6992 NeedsTypedef =
true;
7013 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
7014 DB << Before <<
After;
7016 if (!NeedsTypedef) {
7020 if (After.isInvalid() && ConvTSI) {
7068 diag::warn_cxx98_compat_explicit_conversion_functions :
7069 diag::ext_explicit_conversion_functions)
7078 assert(Conversion &&
"Expected to receive a conversion function declaration");
7096 ConvType = ConvTypeRef->getPointeeType();
7100 else if (ConvType->isRecordType()) {
7102 if (ConvType == ClassType)
7107 << ClassType << ConvType;
7108 }
else if (ConvType->isVoidType()) {
7110 << ClassType << ConvType;
7115 return ConversionTemplate;
7130 assert(*IsInline != PrevNS->
isInline());
7138 if (*IsInline && II && II->
getName().startswith(
"__atomic") &&
7143 NS->setInline(*IsInline);
7146 for (
auto *I : PrevNS->
decls())
7147 if (
auto *ND = dyn_cast<NamedDecl>(I))
7155 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
7158 S.
Diag(Loc, diag::err_inline_namespace_mismatch) << *IsInline;
7176 bool IsInline = InlineLoc.
isValid();
7177 bool IsInvalid =
false;
7179 bool AddToKnown =
false;
7202 if ((*I)->getIdentifierNamespace() & IDNS) {
7208 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
7212 if (IsInline != PrevNS->
isInline())
7215 }
else if (PrevDecl) {
7217 Diag(Loc, diag::err_redefinition_different_kind)
7222 }
else if (II->
isStr(
"std") &&
7228 AddToKnown = !IsInline;
7231 AddToKnown = !IsInline;
7245 if (PrevNS && IsInline != PrevNS->
isInline())
7251 StartLoc, Loc, II, PrevNS);
7258 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
7264 KnownNamespaces[Namespc] =
false;
7272 TU->setAnonymousNamespace(Namespc);
7274 cast<NamespaceDecl>(Parent)->setAnonymousNamespace(Namespc);
7324 return AD->getNamespace();
7325 return dyn_cast_or_null<NamespaceDecl>(D);
7331 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
7332 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
7335 if (Namespc->
hasAttr<VisibilityAttr>())
7340 return cast_or_null<CXXRecordDecl>(
7345 return cast_or_null<NamespaceDecl>(
7368 "Looking for std::initializer_list outside of C++.");
7383 if (!Specialization)
7390 Template = dyn_cast_or_null<ClassTemplateDecl>(
7391 TST->getTemplateName().getAsTemplateDecl());
7392 Arguments = TST->getArgs();
7410 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
7429 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
7436 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
7441 Result.suppressDiagnostics();
7444 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
7452 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
7453 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
7496 case Decl::TranslationUnit:
7498 case Decl::LinkageSpec:
7510 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
7512 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
7526 llvm::make_unique<NamespaceValidatorCCC>(),
7529 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
7530 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
7531 Ident->
getName().equals(CorrectedStr);
7533 S.
PDiag(diag::err_using_directive_member_suggest)
7534 << Ident << DC << DroppedSpecifier << SS.getRange(),
7535 S.
PDiag(diag::note_namespace_defined_here));
7538 S.
PDiag(diag::err_using_directive_suggest) << Ident,
7539 S.
PDiag(diag::note_namespace_defined_here));
7541 R.
addDecl(Corrected.getCorrectionDecl());
7554 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
7555 assert(NamespcName &&
"Invalid NamespcName.");
7556 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
7579 NamespcName->
isStr(
"std")) {
7580 Diag(IdentLoc, diag::ext_using_undefined_std);
7590 assert((isa<NamespaceDecl>(Named) || isa<NamespaceAliasDecl>(Named))
7591 &&
"expected namespace decl");
7609 DeclContext *CommonAncestor = cast<DeclContext>(NS);
7611 CommonAncestor = CommonAncestor->
getParent();
7615 IdentLoc, Named, CommonAncestor);
7619 Diag(IdentLoc, diag::warn_using_directive_in_header);
7624 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
7649 bool HasUsingKeyword,
7654 bool HasTypenameKeyword,
7671 diag::warn_cxx98_compat_using_decl_constructor :
7672 diag::err_using_decl_constructor)
7696 if (!HasUsingKeyword) {
7699 : diag::warn_access_decl_deprecated)
7708 TargetNameInfo, AttrList,
7710 HasTypenameKeyword, TypenameLoc);
7727 return Context.
hasSameType(TD1->getUnderlyingType(),
7728 TD2->getUnderlyingType());
7762 if (isa<EnumDecl>(OrigDC)) OrigDC = OrigDC->
getParent();
7767 if (cast<CXXRecordDecl>(
CurContext)->isProvablyNotDerivedFrom(OrigRec)) {
7770 diag::err_using_decl_nested_name_specifier_is_current_class)
7777 diag::err_using_decl_nested_name_specifier_is_not_base_class)
7786 if (Previous.
empty())
return false;
7789 if (isa<UsingShadowDecl>(Target))
7790 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
7797 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
7798 bool FoundEquivalentDecl =
false;
7804 PrevShadow = Shadow;
7805 FoundEquivalentDecl =
true;
7808 (isa<TagDecl>(D) ? Tag : NonTag) = D;
7811 if (FoundEquivalentDecl)
7845 if (isa<TagDecl>(Target)) {
7847 if (!Tag)
return false;
7851 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
7856 if (!NonTag)
return false;
7872 if (isa<UsingShadowDecl>(Target)) {
7873 Target = cast<UsingShadowDecl>(Target)->getTargetDecl();
7874 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
7927 cast<CXXRecordDecl>(Shadow->
getDeclContext())->removeConversion(Shadow);
7948 bool &AnyDependentBases) {
7951 for (
auto &Base : Derived->
bases()) {
7953 if (CanonicalDesiredBase == BaseType)
7955 if (BaseType->isDependentType())
7956 AnyDependentBases =
true;
7964 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
7966 : HasTypenameKeyword(HasTypenameKeyword),
7967 IsInstantiation(IsInstantiation), OldNNS(NNS),
7968 RequireMemberOf(RequireMemberOf) {}
7970 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
7974 if (!ND || isa<NamespaceDecl>(ND))
7981 if (RequireMemberOf) {
7983 if (FoundRecord && FoundRecord->isInjectedClassName()) {
8004 bool AnyDependentBases =
false;
8007 AnyDependentBases) &&
8019 if (isa<TypeDecl>(ND))
8020 return HasTypenameKeyword || !IsInstantiation;
8022 return !HasTypenameKeyword;
8026 bool HasTypenameKeyword;
8027 bool IsInstantiation;
8043 bool IsInstantiation,
8044 bool HasTypenameKeyword,
8046 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
8048 assert(IdentLoc.isValid() &&
"Invalid TargetName location.");
8053 Diag(IdentLoc, diag::err_using_requires_qualname);
8080 assert(IsInstantiation &&
"no scope in non-instantiation");
8087 SS, IdentLoc, Previous))
8097 if (!LookupContext) {
8098 if (HasTypenameKeyword) {
8101 UsingLoc, TypenameLoc,
8103 IdentLoc, NameInfo.
getName());
8106 QualifierLoc, NameInfo);
8113 auto Build = [&](
bool Invalid) {
8116 HasTypenameKeyword);
8122 auto BuildInvalid = [&]{
return Build(
true); };
8123 auto BuildValid = [&]{
return Build(
false); };
8126 return BuildInvalid();
8135 if (!IsInstantiation)
8155 llvm::make_unique<UsingValidatorCCC>(
8156 HasTypenameKeyword, IsInstantiation, SS.getScopeRep(),
8160 NamedDecl *ND = Corrected.getCorrectionDecl();
8165 << NameInfo.
getName() << LookupContext << 0
8170 if (RD && RD->isInjectedClassName()) {
8172 if (Corrected.WillReplaceSpecifier()) {
8189 Diag(IdentLoc, diag::err_no_member)
8190 << NameInfo.
getName() << LookupContext << SS.getRange();
8191 return BuildInvalid();
8196 return BuildInvalid();
8198 if (HasTypenameKeyword) {
8201 Diag(IdentLoc, diag::err_using_typename_non_type);
8203 Diag((*I)->getUnderlyingDecl()->getLocation(),
8204 diag::note_using_decl_target);
8205 return BuildInvalid();
8212 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
8214 return BuildInvalid();
8221 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
8223 return BuildInvalid();
8250 assert(!UD->
hasTypename() &&
"expecting a constructor name");
8253 assert(SourceType &&
8254 "Using decl naming constructor doesn't have type in scope spec.");
8258 bool AnyDependentBases =
false;
8261 if (!Base && !AnyDependentBases) {
8263 diag::err_using_decl_constructor_not_in_direct_base)
8265 <<
QualType(SourceType, 0) << TargetClass;
8280 bool HasTypenameKeyword,
8301 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
8302 DTypename = UD->hasTypename();
8303 DQual = UD->getQualifier();
8305 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
8307 DQual = UD->getQualifier();
8309 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
8311 DQual = UD->getQualifier();
8316 if (HasTypenameKeyword != DTypename)
continue;
8325 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
8350 if (!NamedContext || NamedContext->
isRecord()) {
8351 auto *RD = dyn_cast_or_null<CXXRecordDecl>(NamedContext);
8355 Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member)
8381 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
8397 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
8411 if (!NamedContext) {
8425 diag::err_using_decl_nested_name_specifier_is_not_class)
8440 if (cast<CXXRecordDecl>(
CurContext)->isProvablyNotDerivedFrom(
8441 cast<CXXRecordDecl>(NamedContext))) {
8444 diag::err_using_decl_nested_name_specifier_is_current_class)
8450 diag::err_using_decl_nested_name_specifier_is_not_base_class)
8474 llvm::SmallPtrSet<const CXXRecordDecl*, 4> Bases;
8476 static bool collect(
const CXXRecordDecl *Base,
void *OpaqueData) {
8477 UserData *Data =
reinterpret_cast<UserData*
>(OpaqueData);
8478 Data->Bases.insert(Base);
8488 static bool doesNotContain(
const CXXRecordDecl *Base,
void *OpaqueData) {
8489 UserData *Data =
reinterpret_cast<UserData*
>(OpaqueData);
8490 return !Data->Bases.count(Base);
8494 return Bases.count(Class) || !Class->
forallBases(doesNotContain,
this);
8501 if (Data.hasDependentBases(cast<CXXRecordDecl>(
CurContext)))
8506 if (Data.mightShareBases(cast<CXXRecordDecl>(NamedContext)))
8510 diag::err_using_decl_nested_name_specifier_is_not_base_class)
8525 Decl *DeclFromDeclSpec) {
8530 "got alias-declaration outside of declaration scope");
8535 bool Invalid =
false;
8561 "name in alias declaration must be an identifier");
8576 bool Redeclaration =
false;
8579 if (TemplateParamLists.size()) {
8583 if (TemplateParamLists.size() != 1) {
8584 Diag(UsingLoc, diag::err_alias_template_extra_headers)
8585 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
8586 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
8593 if (!Previous.
empty()) {
8594 Redeclaration =
true;
8597 if (!OldDecl && !Invalid) {
8598 Diag(UsingLoc, diag::err_redefinition_different_kind)
8653 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
8683 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
8702 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
8704 Diag(PrevDecl->getLocation(), diag::note_previous_namespace_alias)
8705 << AD->getNamespace();
8709 unsigned DiagID = isa<NamespaceDecl>(PrevDecl)
8710 ? diag::err_redefinition
8711 : diag::err_redefinition_different_kind;
8712 Diag(AliasLoc, DiagID) << Alias;
8713 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
8745 for (
const auto &B : ClassDecl->
bases()) {
8750 CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
8755 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
8760 for (
const auto &B : ClassDecl->
vbases()) {
8762 CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
8767 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
8772 for (
const auto *F : ClassDecl->
fields()) {
8773 if (F->hasInClassInitializer()) {
8774 if (
Expr *E = F->getInClassInitializer())
8778 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
8786 ExceptSpec.
CalledDecl(F->getLocation(), Constructor);
8812 for (
const auto &B : ClassDecl->
bases()) {
8817 CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
8818 if (BaseClassDecl == InheritedDecl)
8822 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
8827 for (
const auto &B : ClassDecl->
vbases()) {
8829 CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
8830 if (BaseClassDecl == InheritedDecl)
8834 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
8839 for (
const auto *F : ClassDecl->
fields()) {
8840 if (F->hasInClassInitializer()) {
8841 if (
Expr *E = F->getInClassInitializer())
8845 CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
8848 ExceptSpec.
CalledDecl(F->getLocation(), Constructor);
8857 struct DeclaringSpecialMember {
8860 bool WasAlreadyBeingDeclared;
8863 : S(S), D(RD, CSM) {
8865 if (WasAlreadyBeingDeclared)
8873 ~DeclaringSpecialMember() {
8874 if (!WasAlreadyBeingDeclared)
8879 bool isAlreadyBeingDeclared()
const {
8880 return WasAlreadyBeingDeclared;
8894 "Should not build implicit default constructor!");
8897 if (DSM.isAlreadyBeingDeclared())
8913 nullptr,
false,
true,
8941 ClassDecl->
addDecl(DefaultCon);
8951 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
8954 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
8960 Diag(CurrentLocation, diag::note_member_synthesized_at)
8980 L->CompletedImplicitDefinition(Constructor);
8983 DiagnoseUninitializedFields(*
this, Constructor);
8993 class InheritingConstructorInfo {
8996 : SemaRef(SemaRef), Derived(Derived) {
9002 visitAll(Derived, &InheritingConstructorInfo::noteDeclaredInDerived);
9006 visitAll(RD, &InheritingConstructorInfo::inherit);
9011 struct InheritingConstructor {
9012 InheritingConstructor()
9013 : DeclaredInDerived(
false), BaseCtor(nullptr), DerivedCtor(nullptr) {}
9017 bool DeclaredInDerived;
9029 struct InheritingConstructorsForType {
9030 InheritingConstructor NonTemplate;
9037 for (
unsigned I = 0, N = Templates.size(); I != N; ++I)
9040 return Templates[I].second;
9041 Templates.push_back(std::make_pair(ParamList, InheritingConstructor()));
9042 return Templates.back().second;
9053 .getEntry(SemaRef, Ctor);
9060 for (
const auto *Ctor : RD->
ctors())
9061 (this->*Callback)(Ctor);
9062 for (CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl>
9073 getEntry(Ctor, Ctor->
getType()).DeclaredInDerived =
true;
9087 SemaRef.
Diag(UsingLoc, diag::warn_using_decl_constructor_ellipsis);
9089 diag::note_using_decl_constructor_ellipsis);
9102 unsigned MinParams = minParamsToInherit(Ctor);
9104 if (Params >= MinParams) {
9106 declareCtor(UsingLoc, Ctor,
9109 while (Params > MinParams &&
9123 return Decls.
empty() ? Derived->getLocation() : Decls[0]->getLocation();
9153 InheritingConstructor &Entry = getEntry(BaseCtor, DerivedType);
9159 if (Entry.DeclaredInDerived)
9165 if (Entry.DerivedCtor) {
9166 if (BaseCtor->
getParent() != Entry.BaseCtor->getParent()) {
9168 if (Entry.DerivedCtor->isInvalidDecl())
9170 Entry.DerivedCtor->setInvalidDecl();
9172 SemaRef.
Diag(UsingLoc, diag::err_using_decl_constructor_conflict);
9174 diag::note_using_decl_constructor_conflict_current_ctor);
9175 SemaRef.
Diag(Entry.BaseCtor->getLocation(),
9176 diag::note_using_decl_constructor_conflict_previous_ctor);
9177 SemaRef.
Diag(Entry.DerivedCtor->getLocation(),
9178 diag::note_using_decl_constructor_conflict_previous_using);
9197 TemplateParams = FTD->getTemplateParameters();
9213 Context, Derived, UsingLoc, NameInfo, DerivedType,
9221 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
9223 FPT->getParamTypes(), EPI));
9227 for (
unsigned I = 0, N = FPT->getNumParams(); I != N; ++I) {
9231 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
9232 FPT->getParamType(I), TInfo,
SC_None,
nullptr);
9235 ParamDecls.push_back(PD);
9240 DerivedCtor->setAccess(BaseCtor->
getAccess());
9241 DerivedCtor->setParams(ParamDecls);
9242 DerivedCtor->setInheritedConstructor(BaseCtor);
9247 if (TemplateParams) {
9250 TemplateParams, DerivedCtor);
9252 DerivedCtor->setDescribedFunctionTemplate(DerivedTemplate);
9253 Derived->addDecl(DerivedTemplate);
9255 Derived->addDecl(DerivedCtor);
9258 Entry.BaseCtor = BaseCtor;
9259 Entry.DerivedCtor = DerivedCtor;
9264 typedef llvm::DenseMap<const Type *, InheritingConstructorsForType> MapType;
9277 for (
const auto &BaseIt : ClassDecl->
bases())
9278 if (BaseIt.getInheritConstructors())
9279 InheritedBases.push_back(BaseIt.getType()->getAsCXXRecordDecl());
9282 if (InheritedBases.empty())
9286 InheritingConstructorInfo ICI(*
this, ClassDecl);
9287 for (
unsigned I = 0, N = InheritedBases.size(); I != N; ++I)
9288 ICI.inheritAll(InheritedBases[I]);
9302 Diag(CurrentLocation, diag::note_inhctor_synthesized_at)
9315 L->CompletedImplicitDefinition(Constructor);
9332 for (
const auto &B : ClassDecl->
bases()) {
9342 for (
const auto &B : ClassDecl->
vbases()) {
9349 for (
const auto *F : ClassDecl->
fields()) {
9366 DeclaringSpecialMember DSM(*
this, ClassDecl,
CXXDestructor);
9367 if (DSM.isAlreadyBeingDeclared())
9410 ClassDecl->
addDecl(Destructor);
9420 "DefineImplicitDestructor - call it for implicit default dtor");
9422 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
9434 Diag(CurrentLocation, diag::note_member_synthesized_at)
9454 L->CompletedImplicitDefinition(Destructor);
9476 for (Decl *Member : Class->
decls()) {
9480 if (
auto *NestedRD = dyn_cast<CXXRecordDecl>(Member))
9483 }
else if (!CD->isDefaultConstructor() || !CD->hasAttr<DLLExportAttr>()) {
9487 for (
unsigned I = 0, E = CD->getNumParams(); I != E; ++I) {
9493 CD->getParamDecl(I)).
get();
9513 "adjusting dtor exception specs was introduced in c++11");
9520 getAs<FunctionProtoType>();
9544 ExprBuilder(
const ExprBuilder&) =
delete;
9545 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
9548 static Expr *assertNotNull(
Expr *E) {
9549 assert(E &&
"Expression construction must not fail.");
9555 virtual ~ExprBuilder() {}
9560 class RefBuilder:
public ExprBuilder {
9570 : Var(Var), VarType(VarType) {}
9573 class ThisBuilder:
public ExprBuilder {
9580 class CastBuilder:
public ExprBuilder {
9595 : Builder(Builder), Type(Type), Kind(Kind), Path(Path) {}
9598 class DerefBuilder:
public ExprBuilder {
9603 return assertNotNull(
9607 DerefBuilder(
const ExprBuilder &
Builder) : Builder(Builder) {}
9610 class MemberBuilder:
public ExprBuilder {
9621 nullptr, MemberLookup,
nullptr).
get());
9626 : Builder(Builder), Type(Type), IsArrow(IsArrow),
9627 MemberLookup(MemberLookup) {}
9630 class MoveCastBuilder:
public ExprBuilder {
9638 MoveCastBuilder(
const ExprBuilder &
Builder) : Builder(Builder) {}
9641 class LvalueConvBuilder:
public ExprBuilder {
9646 return assertNotNull(
9650 LvalueConvBuilder(
const ExprBuilder &
Builder) : Builder(Builder) {}
9653 class SubscriptBuilder:
public ExprBuilder {
9654 const ExprBuilder &Base;
9655 const ExprBuilder &Index;
9660 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
9663 SubscriptBuilder(
const ExprBuilder &Base,
const ExprBuilder &Index)
9664 : Base(Base), Index(Index) {}
9675 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
9684 Expr *From = FromB.build(S, Loc);
9688 Expr *To = ToB.build(S, Loc);
9694 bool NeedsCollectableMemCpy =
9698 StringRef MemCpyName = NeedsCollectableMemCpy ?
9699 "__builtin_objc_memmove_collectable" :
9713 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
9715 Expr *CallArgs[] = {
9719 Loc, CallArgs, Loc);
9721 assert(!Call.
isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
9754 const ExprBuilder &To,
const ExprBuilder &From,
9755 bool CopyingBaseSubobject,
bool Copying,
9756 unsigned Depth = 0) {
9772 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
9787 if (Method->isCopyAssignmentOperator() ||
9788 (!Copying && Method->isMoveAssignmentOperator()))
9807 if (CopyingBaseSubobject) {
9838 Expr *FromInst = From.build(S, Loc);
9841 Loc, FromInst, Loc);
9861 Loc,
BO_Assign, To.build(S, Loc), From.build(S, Loc));
9881 llvm::raw_svector_ostream OS(Str);
9882 OS <<
"__i" <<
Depth;
9886 IterationVarName, SizeType,
9895 RefBuilder IterationVarRef(IterationVar, SizeType);
9896 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
9902 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
9903 MoveCastBuilder FromIndexMove(FromIndexCopy);
9904 const ExprBuilder *FromIndex;
9906 FromIndex = &FromIndexCopy;
9908 FromIndex = &FromIndexMove;
9910 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
9915 ToIndex, *FromIndex, CopyingBaseSubobject,
9916 Copying,
Depth + 1);
9944 const ExprBuilder &To,
const ExprBuilder &From,
9945 bool CopyingBaseSubobject,
bool Copying) {
9952 CopyingBaseSubobject,
9972 assert(T->
getNumParams() == 1 &&
"not a copy assignment op");
9986 for (
const auto &Base : ClassDecl->
bases()) {
9987 if (Base.isVirtual())
9991 = cast<CXXRecordDecl>(Base.getType()->getAs<
RecordType>()->getDecl());
9993 ArgQuals,
false, 0))
9997 for (
const auto &Base : ClassDecl->
vbases()) {
9999 = cast<CXXRecordDecl>(Base.getType()->getAs<
RecordType>()->getDecl());
10001 ArgQuals,
false, 0))
10005 for (
const auto *Field : ClassDecl->
fields()) {
10027 if (DSM.isAlreadyBeingDeclared())
10068 ClassLoc, ClassLoc,
10089 ClassDecl->
addDecl(CopyAssignment);
10091 return CopyAssignment;
10106 if (RD->hasUserDeclaredDestructor()) {
10107 UserDeclaredOperation = RD->getDestructor();
10108 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
10109 RD->hasUserDeclaredCopyConstructor() &&
10112 for (
auto *I : RD->ctors()) {
10113 if (I->isCopyConstructor()) {
10114 UserDeclaredOperation = I;
10118 assert(UserDeclaredOperation);
10119 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
10120 RD->hasUserDeclaredCopyAssignment() &&
10123 for (
auto *I : RD->methods()) {
10124 if (I->isCopyAssignmentOperator()) {
10125 UserDeclaredOperation = I;
10129 assert(UserDeclaredOperation);
10132 if (UserDeclaredOperation) {
10134 diag::warn_deprecated_copy_operation)
10135 << RD << !isa<CXXConstructorDecl>(CopyOp)
10136 << isa<CXXDestructorDecl>(UserDeclaredOperation);
10137 S.
Diag(UseLoc, diag::note_member_synthesized_at)
10151 "DefineImplicitCopyAssignment called for wrong function");
10167 CopyAssignOperator->
markUsed(Context);
10199 RefBuilder OtherRef(Other, OtherRefType);
10205 bool Invalid =
false;
10206 for (
auto &Base : ClassDecl->
bases()) {
10209 QualType BaseType = Base.getType().getUnqualifiedType();
10216 BasePath.push_back(&Base);
10220 CastBuilder From(OtherRef, Context.
getQualifiedType(BaseType, OtherQuals),
10224 DerefBuilder DerefThis(This);
10225 CastBuilder To(DerefThis,
10236 Diag(CurrentLocation, diag::note_member_synthesized_at)
10243 Statements.push_back(Copy.
getAs<
Expr>());
10247 for (
auto *Field : ClassDecl->
fields()) {
10260 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
10263 Diag(CurrentLocation, diag::note_member_synthesized_at)
10272 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
10275 Diag(CurrentLocation, diag::note_member_synthesized_at)
10288 "Incomplete array type is not valid");
10297 MemberLookup.resolveKind();
10299 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
10309 Diag(CurrentLocation, diag::note_member_synthesized_at)
10316 Statements.push_back(Copy.
getAs<
Stmt>());
10324 if (Return.isInvalid())
10327 Statements.push_back(Return.getAs<
Stmt>());
10330 Diag(CurrentLocation, diag::note_member_synthesized_at)
10352 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
10357 L->CompletedImplicitDefinition(CopyAssignOperator);
10381 for (
const auto &Base : ClassDecl->
bases()) {
10382 if (Base.isVirtual())
10386 = cast<CXXRecordDecl>(Base.getType()->getAs<
RecordType>()->getDecl());
10392 for (
const auto &Base : ClassDecl->
vbases()) {
10394 = cast<CXXRecordDecl>(Base.getType()->getAs<
RecordType>()->getDecl());
10400 for (
const auto *Field : ClassDecl->
fields()) {
10418 if (DSM.isAlreadyBeingDeclared())
10459 ClassLoc, ClassLoc,
10482 ClassDecl->
addDecl(MoveAssignment);
10484 return MoveAssignment;
10503 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
10506 for (
auto &BI : Class->
bases()) {
10507 Worklist.push_back(&BI);
10508 while (!Worklist.empty()) {
10541 if (Existing && Existing != &BI) {
10542 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
10545 << (Base->getCanonicalDecl() ==
10548 S.
Diag(BI.getLocStart(), diag::note_vbase_moved_here)
10549 << (Base->getCanonicalDecl() ==
10550 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
10554 Existing =
nullptr;
10564 for (
auto &BI : Base->
bases())
10565 Worklist.push_back(&BI);
10578 "DefineImplicitMoveAssignment called for wrong function");
10587 MoveAssignOperator->
markUsed(Context);
10610 getAs<RValueReferenceType>()->getPointeeType();
10612 "Bad argument type of defaulted move assignment");
10620 RefBuilder OtherRef(Other, OtherRefType);
10622 MoveCastBuilder MoveOther(OtherRef);
10628 bool Invalid =
false;
10629 for (
auto &Base : ClassDecl->
bases()) {
10640 QualType BaseType = Base.getType().getUnqualifiedType();
10647 BasePath.push_back(&Base);
10651 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
10654 DerefBuilder DerefThis(This);
10657 CastBuilder To(DerefThis,
10668 Diag(CurrentLocation, diag::note_member_synthesized_at)
10675 Statements.push_back(Move.
getAs<
Expr>());
10679 for (
auto *Field : ClassDecl->
fields()) {
10692 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
10695 Diag(CurrentLocation, diag::note_member_synthesized_at)
10704 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
10707 Diag(CurrentLocation, diag::note_member_synthesized_at)
10720 "Incomplete array type is not valid");
10728 MemberLookup.resolveKind();
10729 MemberBuilder From(MoveOther, OtherRefType,
10730 false, MemberLookup);
10732 true, MemberLookup);
10734 assert(!From.build(*
this, Loc)->isLValue() &&
10735 "Member reference with rvalue base must be rvalue except for reference "
10736 "members, which aren't allowed for move assignment.");
10743 if (Move.isInvalid()) {
10744 Diag(CurrentLocation, diag::note_member_synthesized_at)
10751 Statements.push_back(Move.getAs<
Stmt>());
10760 if (Return.isInvalid())
10763 Statements.push_back(Return.getAs<
Stmt>());
10766 Diag(CurrentLocation, diag::note_member_synthesized_at)
10788 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
10793 L->CompletedImplicitDefinition(MoveAssignOperator);
10812 for (
const auto &Base : ClassDecl->
bases()) {
10814 if (Base.isVirtual())
10818 = cast<CXXRecordDecl>(Base.getType()->getAs<
RecordType>()->getDecl());
10823 for (
const auto &Base : ClassDecl->
vbases()) {
10825 = cast<CXXRecordDecl>(Base.getType()->getAs<
RecordType>()->getDecl());
10830 for (
const auto *Field : ClassDecl->
fields()) {
10851 if (DSM.isAlreadyBeingDeclared())
10874 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
10895 ClassLoc, ClassLoc,
10914 ClassDecl->
addDecl(CopyConstructor);
10916 return CopyConstructor;
10925 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
10928 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
10942 Diag(CurrentLocation, diag::note_member_synthesized_at)
10959 CopyConstructor->
markUsed(Context);
10963 L->CompletedImplicitDefinition(CopyConstructor);
10979 for (
const auto &B : ClassDecl->
bases()) {
10984 CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
10990 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
10995 for (
const auto &B : ClassDecl->
vbases()) {
10997 CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
11003 ExceptSpec.
CalledDecl(B.getLocStart(), Constructor);
11008 for (
const auto *F : ClassDecl->
fields()) {
11019 ExceptSpec.
CalledDecl(F->getLocation(), Constructor);
11031 if (DSM.isAlreadyBeingDeclared())
11051 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
11072 ClassLoc, ClassLoc,
11093 ClassDecl->
addDecl(MoveConstructor);
11095 return MoveConstructor;
11104 "DefineImplicitMoveConstructor - call it for implicit move ctor");
11107 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
11114 Diag(CurrentLocation, diag::note_member_synthesized_at)
11123 Loc, Loc,
None,
false).getAs<Stmt>());
11131 MoveConstructor->
markUsed(Context);
11135 L->CompletedImplicitDefinition(MoveConstructor);
11160 void *InsertPos =
nullptr;
11161 FunctionDecl *CallOpSpec = CallOpTemplate->findSpecialization(
11162 DeducedTemplateArgs->
asArray(),
11164 assert(CallOpSpec &&
11165 "Conversion operator must have a corresponding call operator");
11166 CallOp = cast<CXXMethodDecl>(CallOpSpec);
11182 assert(DeducedTemplateArgs &&
11183 "Must have deduced template arguments from Conversion Operator");
11186 void *InsertPos =
nullptr;
11188 DeducedTemplateArgs->
asArray(),
11190 assert(InvokeSpec &&
11191 "Must have a corresponding static invoker specialization");
11192 Invoker = cast<CXXMethodDecl>(InvokeSpec);
11197 assert(FunctionRef &&
"Can't refer to __invoke function?");
11213 L->CompletedImplicitDefinition(Conv);
11214 L->CompletedImplicitDefinition(Invoker);
11249 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
11258 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
11264 Stmt *ReturnS = Return.
get();
11271 L->CompletedImplicitDefinition(Conv);
11278 switch (Args.size()) {
11283 if (!Args[1]->isDefaultArgument())
11288 return !Args[0]->isDefaultArgument();
11298 bool HadMultipleCandidates,
11299 bool IsListInitialization,
11300 bool IsStdInitListInitialization,
11301 bool RequiresZeroInit,
11302 unsigned ConstructKind,
11304 bool Elidable =
false;
11318 Expr *SubExpr = ExprArgs[0];
11323 Elidable, ExprArgs, HadMultipleCandidates,
11324 IsListInitialization,
11325 IsStdInitListInitialization, RequiresZeroInit,
11326 ConstructKind, ParenRange);
11335 bool HadMultipleCandidates,
11336 bool IsListInitialization,
11337 bool IsStdInitListInitialization,
11338 bool RequiresZeroInit,
11339 unsigned ConstructKind,
11343 Context, DeclInitType, ConstructLoc, Constructor, Elidable, ExprArgs,
11344 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
11346 static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind),
11365 assert(Lookup.
size() == 1);
11366 FieldDecl *Pattern = cast<FieldDecl>(Lookup[0]);
11388 if (OutermostClass == ParentRD) {
11389 Diag(Field->
getLocEnd(), diag::err_in_class_initializer_not_yet_parsed)
11390 << ParentRD << Field;
11393 diag::err_in_class_initializer_not_yet_parsed_outer_class)
11394 << ParentRD << OutermostClass << Field;
11411 PDiag(diag::err_access_dtor_var)
11438 bool AllowExplicit,
11439 bool IsListInitialization) {
11441 unsigned NumArgs = ArgsPtr.size();
11442 Expr **Args = ArgsPtr.data();
11446 assert(Proto &&
"Constructor without a prototype?");
11450 if (NumArgs < NumParams)
11451 ConvertedArgs.reserve(NumParams);
11453 ConvertedArgs.reserve(NumArgs);
11460 llvm::makeArrayRef(Args, NumArgs),
11462 CallType, AllowExplicit,
11463 IsListInitialization);
11464 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
11468 CheckConstructorCall(Constructor,
11469 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
11479 if (isa<NamespaceDecl>(DC)) {
11481 diag::err_operator_new_delete_declared_in_namespace)
11485 if (isa<TranslationUnitDecl>(DC) &&
11488 diag::err_operator_new_delete_declared_static)
11499 unsigned DependentParamTypeDiag,
11500 unsigned InvalidParamTypeDiag) {
11507 diag::err_operator_new_delete_dependent_result_type)
11513 diag::err_operator_new_delete_invalid_result_type)
11519 diag::err_operator_new_delete_template_too_few_parameters)
11525 diag::err_operator_new_delete_too_few_parameters)
11532 << FnDecl->
getDeclName() << ExpectedFirstParamType;
11536 ExpectedFirstParamType)
11538 << FnDecl->
getDeclName() << ExpectedFirstParamType;
11560 diag::err_operator_new_dependent_param_type,
11561 diag::err_operator_new_param_type))
11568 diag::err_operator_new_default_arg)
11588 diag::err_operator_delete_dependent_param_type,
11589 diag::err_operator_delete_param_type))
11600 "Expected an overloaded operator declaration");
11610 if (Op == OO_Delete || Op == OO_Array_Delete)
11613 if (Op == OO_New || Op == OO_Array_New)
11621 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
11622 if (MethodDecl->isStatic())
11624 diag::err_operator_overload_static) << FnDecl->
getDeclName();
11626 bool ClassOrEnumParam =
false;
11627 for (
auto Param : FnDecl->
params()) {
11628 QualType ParamType = Param->getType().getNonReferenceType();
11631 ClassOrEnumParam =
true;
11636 if (!ClassOrEnumParam)
11638 diag::err_operator_overload_needs_class_or_enum)
11648 if (Op != OO_Call) {
11649 for (
auto Param : FnDecl->
params()) {
11650 if (Param->hasDefaultArg())
11651 return Diag(Param->getLocation(),
11652 diag::err_operator_overload_default_arg)
11653 << FnDecl->
getDeclName() << Param->getDefaultArgRange();
11658 {
false,
false,
false }
11659 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
11660 , { Unary, Binary, MemberOnly }
11661 #include "clang/Basic/OperatorKinds.def"
11664 bool CanBeUnaryOperator = OperatorUses[Op][0];
11665 bool CanBeBinaryOperator = OperatorUses[Op][1];
11666 bool MustBeMemberOperator = OperatorUses[Op][2];
11673 + (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
11674 if (Op != OO_Call &&
11675 ((NumParams == 1 && !CanBeUnaryOperator) ||
11676 (NumParams == 2 && !CanBeBinaryOperator) ||
11677 (NumParams < 1) || (NumParams > 2))) {
11679 unsigned ErrorKind;
11680 if (CanBeUnaryOperator && CanBeBinaryOperator) {
11682 }
else if (CanBeUnaryOperator) {
11685 assert(CanBeBinaryOperator &&
11686 "All non-call overloaded operators are unary or binary!");
11690 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
11691 << FnDecl->
getDeclName() << NumParams << ErrorKind;
11695 if (Op != OO_Call &&
11697 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
11702 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
11704 diag::err_operator_overload_must_be_member)
11718 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
11725 diag::err_operator_overload_post_incdec_must_be_int)
11726 << LastParam->
getType() << (Op == OO_MinusMinus);
11736 if (isa<CXXMethodDecl>(FnDecl)) {
11737 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
11747 bool Valid =
false;
11762 if (Params->
size() == 1) {
11770 }
else if (Params->
size() == 2) {
11778 if (PmType && PmArgs &&
11780 PmArgs->isTemplateParameterPack()) {
11788 diag::ext_string_literal_operator_template);
11797 QualType T = (*Param)->getType().getUnqualifiedType();
11809 goto FinishedParams;
11815 goto FinishedParams;
11818 goto FinishedParams;
11828 goto FinishedParams;
11837 goto FinishedParams;
11840 T = (*Param)->getType().getUnqualifiedType();
11856 for (
auto Param : FnDecl->
params()) {
11857 if (Param->hasDefaultArg()) {
11858 Diag(Param->getDefaultArgRange().getBegin(),
11859 diag::err_literal_operator_default_argument)
11860 << Param->getDefaultArgRange();
11865 StringRef LiteralName
11867 if (LiteralName[0] !=
'_') {
11889 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
11890 << LangStr->getSourceRange();
11898 else if (Lang ==
"C++")
11901 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
11902 << LangStr->getSourceRange();
11928 return LinkageSpec;
11952 bool Invalid =
false;
11966 Diag(Loc, diag::err_catch_rvalue_ref);
11972 unsigned DK = diag::err_catch_incomplete;
11976 DK = diag::err_catch_incomplete_ptr;
11981 DK = diag::err_catch_incomplete_ref;
11983 if (!Invalid && (Mode == 0 || !BaseType->
isVoidType()) &&
11989 diag::err_abstract_type_in_decl,
12001 Diag(Loc, diag::err_objc_object_catch);
12006 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
12011 ExDeclType, TInfo, SC_None);
12039 Expr *opaqueValue =
12091 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
12093 }
else if (PrevDecl->isTemplateParameter())
12123 Expr *AssertMessageExpr,
12126 AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) :
nullptr;
12132 AssertMessage, RParenLoc,
false);
12140 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
12151 diag::err_static_assert_expression_is_not_constant,
12155 if (!Failed && !Cond) {
12157 llvm::raw_svector_ostream Msg(MsgBuffer);
12160 Diag(StaticAssertLoc, diag::err_static_assert_failed)
12161 << !AssertMessage << Msg.str() << AssertExpr->getSourceRange();
12167 AssertExpr, AssertMessage, RParenLoc,
12180 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
12206 diag::warn_cxx98_compat_unelaborated_friend_type :
12207 diag::ext_unelaborated_friend_type)
12215 diag::warn_cxx98_compat_nonclass_type_friend :
12216 diag::ext_nonclass_type_friend)
12223 diag::warn_cxx98_compat_enum_friend :
12224 diag::ext_enum_friend)
12236 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
12258 bool isExplicitSpecialization =
false;
12259 bool Invalid =
false;
12263 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
12264 isExplicitSpecialization, Invalid)) {
12265 if (TemplateParams->
size() > 0) {
12271 NameLoc, Attr, TemplateParams,
AS_public,
12273 FriendLoc, TempParamLists.size() - 1,
12274 TempParamLists.data()).
get();
12279 isExplicitSpecialization =
true;
12283 if (Invalid)
return nullptr;
12285 bool isAllExplicitSpecializations =
true;
12286 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
12287 if (TempParamLists[I]->size()) {
12288 isAllExplicitSpecializations =
false;
12298 if (isAllExplicitSpecializations) {
12300 bool Owned =
false;
12301 bool IsDependent =
false;
12321 if (isa<DependentNameType>(T)) {
12335 TSI, FriendLoc, TempParamLists);
12341 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
12348 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
12359 TSI, FriendLoc, TempParamLists);
12397 if (TheDeclarator.isInvalidType())
12418 Diag(Loc, diag::err_tagless_friend_type_template)
12435 if (
unsigned NumTempParamLists = TempParams.size())
12474 Diag(Loc, diag::err_unexpected_friend);
12520 (FunctionContainingLocalClass =
12521 cast<CXXRecordDecl>(
CurContext)->isLocalClass())) {
12539 if (!Previous.
empty()) {
12547 DC = FunctionContainingLocalClass;
12591 if (!Previous.
empty()) {
12596 if (isTemplateId) {
12597 if (isa<TranslationUnitDecl>(LookupDC))
break;
12611 if (!DC)
return nullptr;
12629 if (Previous.
empty()) {
12631 Diag(Loc, diag::err_qualified_friend_not_found)
12641 diag::warn_cxx98_compat_friend_is_member :
12642 diag::err_friend_is_member);
12674 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
12682 Diag(Loc, diag::err_introducing_special_friend) <<
12695 DCScope = &FakeDCScope;
12698 bool AddToScope =
true;
12700 TemplateParams, AddToScope);
12701 if (!ND)
return nullptr;
12735 FD = FTD->getTemplatedDecl();
12737 FD = cast<FunctionDecl>(ND);
12745 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
12746 Diag(OldFD->getLocation(), diag::note_previous_declaration);
12748 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
12753 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
12766 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
12768 Diag(DelLoc, diag::err_deleted_non_function);
12776 Prev->getPreviousDecl()) &&
12777 !Prev->isDefined()) {
12778 Diag(DelLoc, diag::err_deleted_decl_not_first);
12779 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
12780 Prev->isImplicit() ? diag::note_previous_implicit_declaration
12781 : diag::note_previous_declaration);
12799 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Fn)) {
12800 bool IssuedDiagnostic =
false;
12805 if (!IssuedDiagnostic) {
12807 IssuedDiagnostic =
true;
12809 Diag((*I)->getLocation(), diag::note_overridden_virtual_function);
12817 Diag(DelLoc, diag::err_deleted_main);
12835 Diag(DefaultLoc, diag::err_default_special_members);
12864 cast<CXXConstructorDecl>(MD));
12882 llvm_unreachable(
"Invalid special member.");
12885 Diag(DefaultLoc, diag::err_default_special_members);
12890 for (
Stmt *SubStmt : S->children()) {
12893 if (isa<ReturnStmt>(SubStmt))
12894 Self.
Diag(SubStmt->getLocStart(),
12895 diag::err_return_in_constructor_handler);
12896 if (!isa<Expr>(SubStmt))
12902 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
12916 if (NewCC == OldCC)
12927 diag::err_conflicting_overriding_cc_attributes)
12953 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
12961 if (NewClassTy.
isNull()) {
12963 diag::err_different_return_type_for_overriding_virtual_function)
12977 if (!RT->isBeingDefined() &&
12979 diag::err_covariant_return_incomplete,
12997 NewClassTy, OldClassTy,
12998 diag::err_covariant_return_inaccessible_base,
12999 diag::err_covariant_return_ambiguous_derived_to_base_conv,
13015 diag::err_covariant_return_type_different_qualifications)
13027 diag::err_covariant_return_type_class_type_more_qualified)
13062 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
13070 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
13071 return Var->isStaticDataMember();
13125 "Parser allowed 'typedef' as storage class of condition decl.");
13131 if (isa<FunctionDecl>(Dcl)) {
13132 Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
13141 if (!ExternalSource)
13147 for (
unsigned I = 0, N = VTables.size(); I != N; ++I) {
13148 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
13152 if (!Pos->second && VTables[I].DefinitionRequired)
13153 Pos->second =
true;
13157 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
13158 NewUses.push_back(
VTableUse(VTables[I].Record, VTables[I].Location));
13165 bool DefinitionRequired) {
13175 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
13176 Pos =
VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
13181 if (DefinitionRequired && !Pos.first->second) {
13182 Pos.first->second =
true;
13209 VTableUses.push_back(std::make_pair(Class, Loc));
13221 bool DefinedAnything =
false;
13222 for (
unsigned I = 0; I !=
VTableUses.size(); ++I) {
13229 bool DefineVTable =
true;
13235 if (KeyFunction && !KeyFunction->
hasBody()) {
13237 DefineVTable =
false;
13242 "Instantiations don't have key functions");
13244 }
else if (!KeyFunction) {
13249 bool IsExplicitInstantiationDeclaration
13252 for (
auto R : Class->
redecls()) {
13256 IsExplicitInstantiationDeclaration =
true;
13258 IsExplicitInstantiationDeclaration =
false;
13263 if (IsExplicitInstantiationDeclaration)
13264 DefineVTable =
false;
13270 if (!DefineVTable) {
13278 DefinedAnything =
true;
13288 if (!KeyFunction ||
13289 (KeyFunction->
hasBody(KeyFunctionDef) &&
13293 ? diag::warn_weak_template_vtable : diag::warn_weak_vtable)
13299 return DefinedAnything;
13304 for (
const auto *I : RD->
methods())
13305 if (I->isVirtual() && !I->isPure())
13314 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
13315 E = FinalOverriders.end();
13318 OE = I->second.end();
13320 assert(OI->second.size() > 0 &&
"no final overrider");
13325 if (!Overrider->isPure())
13334 for (
const auto &I : RD->
bases()) {
13336 cast<CXXRecordDecl>(I.getType()->getAs<
RecordType>()->getDecl());
13354 for (
unsigned i = 0; i < ivars.size(); i++) {
13366 InitSeq.Perform(*
this, InitEntity, InitKind,
None);
13378 AllToInit.push_back(Member);
13383 ->getAs<RecordType>()) {
13384 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
13388 PDiag(diag::err_access_dtor_ivar)
13394 AllToInit.data(), AllToInit.size());
13400 llvm::SmallSet<CXXConstructorDecl*, 4> &Valid,
13401 llvm::SmallSet<CXXConstructorDecl*, 4> &Invalid,
13402 llvm::SmallSet<CXXConstructorDecl*, 4> &
Current,
13413 (void)Target->
hasBody(FNTarget);
13415 cast_or_null<CXXConstructorDecl>(FNTarget));
13422 if (!Current.insert(Canonical).second)
13428 Valid.insert(Current.begin(), Current.end());
13431 }
else if (TCanonical == Canonical || Invalid.count(TCanonical) ||
13432 Current.count(TCanonical)) {
13434 if (!Invalid.count(TCanonical)) {
13436 diag::warn_delegating_ctor_cycle)
13440 if (TCanonical != Canonical)
13447 assert(FNTarget &&
"Ctor cycle through bodiless function");
13450 cast<CXXConstructorDecl>(FNTarget));
13455 Invalid.insert(Current.begin(), Current.end());
13464 llvm::SmallSet<CXXConstructorDecl*, 4> Valid, Invalid,
Current;
13466 for (DelegatingCtorDeclsType::iterator
13472 for (llvm::SmallSet<CXXConstructorDecl *, 4>::iterator CI = Invalid.begin(),
13473 CE = Invalid.end();
13475 (*CI)->setInvalidDecl();
13484 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
13512 FindCXXThisExpr
Finder(*
this);
13537 FindCXXThisExpr
Finder(*
this);
13555 if (!Finder.TraverseType(E))
13565 FindCXXThisExpr
Finder(*
this);
13568 for (
const auto *A : Method->
attrs()) {
13570 Expr *Arg =
nullptr;
13572 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
13574 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
13576 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
13577 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
13578 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
13579 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
13580 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
13581 Arg = ETLF->getSuccessValue();
13582 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
13583 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
13584 Arg = STLF->getSuccessValue();
13585 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
13586 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
13587 Arg = LR->getArg();
13588 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
13589 Args = llvm::makeArrayRef(LE->args_begin(), LE->args_size());
13590 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
13591 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
13592 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
13593 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
13594 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
13595 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
13596 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
13597 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
13599 if (Arg && !Finder.TraverseStmt(Arg))
13602 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
13603 if (!Finder.TraverseStmt(Args[I]))
13617 Exceptions.clear();
13620 Exceptions.reserve(DynamicExceptions.size());
13621 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
13628 if (!Unexpanded.empty()) {
13639 Exceptions.push_back(ET);
13647 if (NoexceptExpr) {
13651 "Parser should have made sure that the expression is boolean");
13652 if (IsTopLevel && NoexceptExpr &&
13660 diag::err_noexcept_needs_constant_expression,
13673 Expr *NoexceptExpr) {
13679 MethodD = FunTmpl->getTemplatedDecl();
13689 DynamicExceptionRanges, NoexceptExpr, Exceptions,
13717 Diag(DeclStart, diag::err_anonymous_property);
13739 diag::err_invalid_thread)
13766 PrevDecl =
nullptr;
13770 PrevDecl =
nullptr;
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
Abstract class used to diagnose incomplete types.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
unsigned getFlags() const
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...
CastKind getCastKind() const
IdKind getKind() const
Determine what kind of name we have.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
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)
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()
bool isTransparentContext() const
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
bool isTemplateParameter() const
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference. Otherwise, it's an rvalue reference...
unsigned getDepth() const
StringRef getName() const
ExprResult PerformContextuallyConvertToBool(Expr *From)
void CheckConstructor(CXXConstructorDecl *Constructor)
static bool specialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS)
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.
EvaluatedExprVisitor - This class visits 'Expr *'s.
SourceLocation getRestrictSpecLoc() const
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
Simple class containing the result of Sema::CorrectTypo.
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
isSpecificBuiltinType - Test for a particular builtin type.
SourceLocation getConstSpecLoc() const
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
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)
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)
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
IdentifierInfo * getIdentifier() const
method_range methods() const
The subobject is a base class.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
static CXXConstructExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, CXXConstructorDecl *D, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
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
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
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
Expr *const * semantics_iterator
static ClassTemplateDecl * LookupStdInitializerList(Sema &S, SourceLocation Loc)
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
Filter makeFilter()
Create a filter for this result set.
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. If PrevDecl is NULL, set this as the first and only declaration...
CXXCatchStmt * getHandler(unsigned i)
FullExprArg MakeFullExpr(Expr *Arg)
TypeLoc getNamedTypeLoc() const
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
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>.
IdentifierInfo * getCXXLiteralIdentifier() const
CachedTokens * DefaultArgTokens
StmtResult ActOnExprStmt(ExprResult Arg)
const Scope * getParent() const
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
static CharSourceRange getTokenRange(SourceRange R)
void ActOnDocumentableDecl(Decl *D)
void addConst()
addConst - add the specified type qualifier to this QualType.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
The current expression is potentially evaluated at run time, which means that code may be generated t...
void ActOnFinishCXXMemberDefaultArgs(Decl *D)
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)
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)
chain_range chain() const
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
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)
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function...
void setModulePrivate(bool MP=true)
Specify whether this declaration was marked as being private to the module in which it was defined...
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...
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)
bool isEnumeralType() const
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
SCS getStorageClassSpec() const
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
bool hasDefinition() const
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)
IdentifierInfo * getAsIdentifierInfo() const
bool isInStdNamespace() const
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)
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.
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)
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)
SourceLocation getLocEnd() const LLVM_READONLY
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList * > FriendTypeTPLists=None)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
bool hasUserDeclaredCopyAssignment() const
Determine whether this class has a user-declared copy assignment operator.
Represents a C++ constructor within a class.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
Expr * getInClassInitializer() const
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
InClassInitStyle getInClassInitStyle() const
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
const llvm::APInt & getSize() const
void CheckCXXDefaultArguments(FunctionDecl *FD)
RAII object to handle the state changes required to synthesize a function body.
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
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)
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
RAII object that enters a new expression evaluation context.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
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.
void setUninstantiatedDefaultArg(Expr *arg)
const Expr * getCallee() const
void finishedDefaultedOrDeletedMember(CXXMethodDecl *MD)
Indicates that the declaration of a defaulted or deleted special member function is now complete...
static void extendLeft(SourceRange &R, const SourceRange &Before)
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.
ExtProtoInfo - Extra information about a function prototype.
AccessSpecifier getAccess() const
void clear()
Clear the base-paths results.
CallingConv getCallConv() const
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
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.
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.
bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD)
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)
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)
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM, bool Diagnose=false)
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. Returns null if this cl...
void removeDecl(Decl *D)
Removes a declaration from this context.
bool isEmpty() const
No scope specifier.
iterator begin(Source *source, bool LocalOnly=false)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
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)
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)
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.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool OdrUse)
Perform marking for a reference to an arbitrary declaration. It marks the declaration referenced...
unsigned getNumParams() const
AccessResult CheckFriendAccess(NamedDecl *D)
Checks access to the target of a friend declaration.
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, AttributeList *AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition). The function body might be in any of the (re-)d...
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
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...
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)
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, bool HasUsingKeyword, SourceLocation UsingLoc, CXXScopeSpec &SS, UnqualifiedId &Name, AttributeList *AttrList, bool HasTypenameKeyword, SourceLocation TypenameLoc)
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
AttributeList * getList() const
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. This is either a single result (with no stable stora...
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)
const CXXScopeSpec & getCXXScopeSpec() const
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...
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)
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...
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...
void ActOnBaseSpecifiers(Decl *ClassDecl, CXXBaseSpecifier **Bases, unsigned NumBases)
NoexceptResult
Result type of getNoexceptSpec().
static bool isIncrementDecrementOp(Opcode Op)
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, FullExprArg Second, Decl *SecondVar, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
void Deallocate(void *Ptr) const
ParmVarDecl * getParam(unsigned i) const
unsigned getIdentifierNamespace() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getExprLoc() const LLVM_READONLY
const CXXRecordDecl * getPointeeCXXRecordDecl() const
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
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
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 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)
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++0x [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
bool forallBases(ForallBasesCallback *BaseMatches, void *UserData, bool AllowShortCircuit=true) const
Determines if the given callback holds for all the direct or indirect base classes of this type...
SourceLocation getLocStart() const LLVM_READONLY
static bool CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S, SmallVectorImpl< SourceLocation > &ReturnStmts, SourceLocation &Cxx1yLoc)
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)
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param IfCond Not a nullptr if if clause was nullptr *otherwise *param PrivateVars List of references to private variables for the task *directive *param PrivateCopies List of private copies for each private variable in *p PrivateVars *param FirstprivateVars List of references to private variables for the *task directive *param FirstprivateCopies List of private copies for each private variable *in p FirstprivateVars *param FirstprivateInits List of references to auto generated variables *used for initialization of a single array element Used if firstprivate *variable is of array type *param Dependences List of dependences for the task construct
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 {'. In the former case, Name will be non-null...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
void PopExpressionEvaluationContext()
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, unsigned NParams, TemplateParameterList **Params, FriendUnion Friend, SourceLocation FriendLoc)
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void CheckExtraCXXDefaultArguments(Declarator &D)
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
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
SourceLocation getBeginLoc() const
Get the begin source location.
static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, DeclStmt *DS, SourceLocation &Cxx1yLoc)
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.
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
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. This can be used by clients that want to deter...
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.
ImplicitExceptionSpecification ComputeInheritingCtorExceptionSpec(CXXConstructorDecl *CD)
Determine what sort of exception specification an inheriting constructor of a class will have...
IndirectFieldDecl * getIndirectMember() const
Microsoft throw(...) extension.
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)
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
bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow)
unsigned getMinRequiredArguments() const
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)
const CXXRecordDecl * getParent() const
bool CheckConstexprFunctionDecl(const FunctionDecl *FD)
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
field_range fields() const
A friend of a previously-undeclared entity.
void RemoveDecl(NamedDecl *D)
static bool BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, FieldDecl *Field, IndirectFieldDecl *Indirect, CXXCtorInitializer *&CXXMemberInit)
const ArrayType * getAsArrayType(QualType T) const
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)
static bool isValidUDSuffix(const LangOptions &LangOpts, StringRef 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
Expr * getNoexceptExpr() const
A builtin binary operation expression such as "x + y" or "x <= y".
An implicit 'self' parameter.
bool isValueDependent() const
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)
ImplicitExceptionSpecification ComputeDefaultedDtorExceptionSpec(CXXMethodDecl *MD)
Determine what sort of exception specification a defaulted destructor of a class will have...
static void checkMoveAssignmentForRepeatedMove(Sema &S, CXXRecordDecl *Class, SourceLocation CurrentLocation)
void setExceptionVariable(bool EV)
bool isOverloadedOperator() const
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
bool isVariadic() const
Whether this function is variadic.
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.
static bool FindHiddenVirtualMethod(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, void *UserData)
Member lookup function that determines whether a given C++ method overloads virtual methods in a base...
bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
const Type * getBaseClass() const
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)
DeclContext * getLexicalDeclContext()
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
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.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
A class that does preorder depth-first traversal on the entire Clang AST and visits each node...
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
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.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
const SourceRange & getSourceRange() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access. Does not test the acceptance criteria...
decl_iterator decls_begin() const
FunctionDecl * SourceDecl
unsigned getNumParams() const
QualType getCanonicalTypeInternal() const
init_iterator init_begin()
Retrieve an iterator to the first initializer.
const LangOptions & LangOpts
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
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)
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)
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
bool isDefined(const FunctionDecl *&Definition) const
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)
void removeInClassInitializer()
CXXMethodDecl * getMethod() const
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
bool isTemplateParameterPack() const
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.
void setBases(CXXBaseSpecifier const *const *Bases, unsigned NumBases)
Sets the base classes of this struct or class.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
DeclSpec & getMutableDeclSpec()
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.
CanQualType getCanonicalTypeUnqualified() const
TST getTypeSpecType() const
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
QualType getParamType(unsigned i) const
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 ClearConstexprSpec()
SourceLocation getLocStart() const LLVM_READONLY
CXXMethodDecl * getMethodDecl() const
Retrieves the declaration of the called method.
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
Qualifiers::ObjCLifetime getObjCLifetime() const
getObjCLifetime - Returns lifetime attribute of this type.
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
Causes a block literal to by copied to the heap and then autoreleased.
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. Contains type source information through TypeSo...
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
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e. function call operator ...
static bool defaultedSpecialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember CSM, bool ConstArg)
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
ID
Defines the set of possible language-specific address spaces.
StorageClass getStorageClass() const
Returns the storage class as written in the source. For the computed linkage of symbol, see getLinkage.
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
void setInClassInitializer(Expr *Init)
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static 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.
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
unsigned param_size() const
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...
StringRef getName() const
Return the actual identifier string.
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
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)
Helper class that collects exception specifications for implicitly-declared special member functions...
MatchFinder::MatchCallback * Callback
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)
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...
void setRBraceLoc(SourceLocation L)
Inits[]
Gets the list of initial values for linear variables.
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.
void setInvalidDecl(bool Invalid=true)
TranslationUnitDecl * getTranslationUnitDecl() const
static unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup. Asserts that one was found.
llvm::SmallSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
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)
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
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage. This will either be a local variabl...
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, AttributeList *Attrs=nullptr)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
DeclContext * getDeclContext()
void PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, const BlockExpr *blkExpr=nullptr)
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)
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. Such actions are deferred until the class is complete.
bool hasDefaultArg() const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
Represents a C++ template name within the type system.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool hasUserDeclaredMoveConstructor() const
Determine whether this class has had a move constructor declared by the user.
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
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
void setDefaultArg(Expr *defarg)
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
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)
StorageClass
Storage classes.
Expr * getUninstantiatedDefaultArg()
Expr * getSubExpr() const
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
const SourceRange & getRange() const
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
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.
bool IsDerivedFrom(QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
Declaration of an alias template.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for record diagnostic message. WARNING: Indexes apply to par...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
bool isExternallyVisible() const
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.
DeclarationName getDeclName() const
DiagnosticsEngine & getDiagnostics() const
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
CXXRecordDecl * getStdBadAlloc() const
bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases, unsigned NumBases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
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)
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.
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. Return null if the results were absent...
SourceLocation getLocEnd() const LLVM_READONLY
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
SourceLocation getStorageClassSpecLoc() const
RecordDecl * getDefinition() const
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)
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)
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.
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 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)
#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)
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.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
bool doesThisDeclarationHaveABody() const
TemplateArgumentLoc getArgLoc(unsigned i) const
There is no lifetime qualification on this type.
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope. After calling this, the caller must call ActOnFinishCXXInC...
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. This may omit quali...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ASTMatchFinder *const Finder
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl. It will iterate at least once ...
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)
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc)
ExceptionSpecificationType Type
The kind of exception specification this is.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
llvm::SmallPtrSet< QualType, 4 > IndirectBaseSet
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
void setOperatorDelete(FunctionDecl *OD)
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
bool isAnonymousStructOrUnion() const
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
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
const Type * getTypePtr() const
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
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
bool CheckSpecifiedExceptionType(QualType &T, const SourceRange &Range)
static bool CheckMostOverridenMethods(const CXXMethodDecl *MD, const llvm::SmallPtrSetImpl< const CXXMethodDecl * > &Methods)
Check whether any most overriden method from MD in Methods.
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)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr)
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.
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". ...
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
ASTContext & getASTContext() const LLVM_READONLY
unsigned size_overridden_methods() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
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.
void setReferenced(bool R=true)
IdentifierTable & getIdentifierTable()
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
Represents a dependent using declaration which was not marked with typename.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
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.
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)
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
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
Source range that this declaration covers.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Name lookup found an unresolvable value declaration and cannot yet complete. This only happens in C++...
const ObjCInterfaceDecl * getClassInterface() const
SourceLocation getConstexprSpecLoc() const
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). The exception-specification was parsed after the method itself was declared.
Decl * ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, MultiTemplateParamsArg TempParamLists)
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
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)
TypeLocClass getTypeLocClass() const
bool isFinalSpelledSealed() const
void CheckExplicitlyDefaultedMemberExceptionSpec(CXXMethodDecl *MD, const FunctionProtoType *T)
void setIsParsingBaseSpecifiers()
SourceLocation getBegin() const
bool isTypeDependent() const
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
const SourceRange & getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
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.
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)
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.
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)
IdentifierInfo * GetterId
SourceLocation getLocStart() const LLVM_READONLY
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
void setExplicitlyDefaulted(bool ED=true)
void setHasInheritedDefaultArg(bool I=true)
MutableArrayRef< Expr * > MultiExprArg
static Sema::ImplicitExceptionSpecification computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD)
QualType getType() const
Return the type wrapped by this type source info.
void addArgument(const TemplateArgumentLoc &Loc)
bool isDynamicClass() const
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
SourceLocation getExprLoc() const LLVM_READONLY
bool isFunctionProtoType() const
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)
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)
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
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.
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
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 EnterDeclaratorContext(Scope *S, DeclContext *DC)
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
bool hasUnparsedDefaultArg() const
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
bool lookupInBases(BaseMatchesCallback *BaseMatches, void *UserData, CXXBasePaths &Paths) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
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)
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
SourceLocation getLocStart() const LLVM_READONLY
static bool InitializationHasSideEffects(const FieldDecl &FD)
static __inline__ uint32_t volatile uint32_t * p
bool hasVariantMembers() const
Determine whether this class has any variant members.
bool isInvalidDecl() const
ImplicitExceptionSpecification ComputeDefaultedCopyAssignmentExceptionSpec(CXXMethodDecl *MD)
Determine what sort of exception specification a defautled copy assignment operator of a class will h...
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
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.
This is a scope that corresponds to the template parameters of a C++ template. Template parameter sco...
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.
static NamespaceDecl * getNamespaceDecl(NamedDecl *D)
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).
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)
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
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i...
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
IdentifierResolver IdResolver
semantics_iterator semantics_begin()
unsigned getNumArgs() const
bool isSingleResult() const
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
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...
static Sema::SpecialMemberOverloadResult * lookupCallFromSpecialMember(Sema &S, CXXRecordDecl *Class, Sema::CXXSpecialMember CSM, unsigned FieldQuals, bool ConstRHS)
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 hasUserDeclaredCopyConstructor() const
Determine whether this class has a user-declared copy constructor.
bool isLambda() const
Determine whether this class describes a lambda function object.
DeclClass * getCorrectionDeclAs() const
static unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
enum clang::DeclaratorChunk::@184 Kind
Expr * IgnoreParenImpCasts() LLVM_READONLY
param_iterator param_end()
void PushUsingDirective(UsingDirectiveDecl *UDir)
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
bool isRValueReferenceType() const
const Stmt * getThen() const
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase)
Create the initialization entity for a base class subobject.
QualType getNonReferenceType() 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. getFoundDecl() will return this declara...
bool empty() const
Return true if no decls were found.
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
bool isObjCObjectType() const
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...
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)
static void extendRight(SourceRange &R, const SourceRange &After)
bool isTriviallyCopyableType(ASTContext &Context) const
static bool CheckOperatorNewDeclaration(Sema &SemaRef, const FunctionDecl *FnDecl)
void setUnparsedDefaultArg()
static void diagnoseDeprecatedCopyOperation(Sema &S, CXXMethodDecl *CopyOp, SourceLocation UseLoc)
SourceManager & getSourceManager() const
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
unsigned getTypeQuals() const
QualType getCanonicalType() 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.
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)
CXXRecordDecl * getOrigin() const
Retrieve the type from which this base-paths search began.
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
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
Retrieves the canonical declaration of this template.
QualType BuildDecltypeType(Expr *E, SourceLocation Loc, bool AsUnevaluated=true)
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.
DeclContext * getRedeclContext()
CXXConstructorDecl * getConstructor() const
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...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
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 bool isInvalid(SourceLocation Loc, bool *Invalid)
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...
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...
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
Represents a base class of a C++ class.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
bool isAnyMemberInitializer() const
void setNamedTypeInfo(TypeSourceInfo *TInfo)
const CXXConstructorDecl * getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
QualType getPointeeType() const
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
This is a scope that can contain a declaration. Some scopes just contain loop constructs but don't co...
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
IdentifierInfo * getIdentifier() const
bool isDefaultConstructor() const
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)
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc)
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
bool isPODType(ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
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 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)
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)
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation())
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...
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
void CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD)
void setConstexpr(bool IC)
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
virtual bool isOutOfLine() const
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)
The parameter type of a method or function.
void setParam(unsigned i, ParmVarDecl *VD)
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)
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...
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)
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.
Defines the clang::TargetInfo interface.
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...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const FunctionDecl * getOperatorDelete() const
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl * > &Ivars)
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
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. [C99 6.5.1p2].
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
SourceLocation getRAngleLoc() const
void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD)
Diagnose methods which overload virtual methods in a base class without overriding any...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
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)
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool OdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
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.
virtual bool HandleTopLevelDecl(DeclGroupRef D)
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)
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)
void suppressDiagnostics()
const DeclaratorChunk & getTypeObject(unsigned i) const
AttributeList * getNext() const
An l-value expression is a reference to an object with independent storage.
StringRef getKindName() const
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr * > &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted...
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
Retrieves the "canonical" declaration of the given declaration.
bool isInvalidType() const
void DeclareInheritingConstructors(CXXRecordDecl *ClassDecl)
Declare all inheriting constructors for the given class.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
bool isModulePrivateSpecified() const
void setAccess(AccessSpecifier AS)
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
Represents a C++ namespace alias.
No keyword precedes the qualified type name.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
bool isConstQualified() const
Determine whether this type is const-qualified.
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Represents C++ using-directive.
SmallVector< std::pair< const CXXMethodDecl *, const CXXMethodDecl * >, 2 > DelayedExceptionSpecChecks
All the overriding functions seen during a class definition that had their exception spec checks dela...
void DiagnoseAbstractType(const CXXRecordDecl *RD)
static Expr * CastForMoving(Sema &SemaRef, Expr *E, QualType T=QualType())
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
bool isPolymorphic() const
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)
const TemplateArgument & getArgument() const
Wrapper for source info for pointers.
SourceLocation ColonLoc
Location of ':'.
bool isExplicitSpecialization() const
void WillReplaceSpecifier(bool ForceReplacement)
Wrapper for source info for block pointers.
void setDeletedAsWritten(bool D=true)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
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
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)
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
void PushFunctionScope()
Enter a new function scope.
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D)
void setElaboratedKeywordLoc(SourceLocation Loc)
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
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)
bool hasUserDeclaredConstructor() const
Determine whether this class has any user-declared constructors.
const RecordDecl * getParent() const
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
const DeclSpec & getDeclSpec() const
Decl * ActOnDeclarator(Scope *S, Declarator &D)
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
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)
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, AttributeList *AttrList)
bool hasInClassInitializer() const
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
The subobject is a non-static data member.
SourceLocation getTemplateLoc() const