45 #include "llvm/ADT/SmallString.h" 46 #include "llvm/ADT/Triple.h" 51 using namespace clang;
56 Decl *Group[2] = { OwnedType, Ptr };
67 TypeNameValidatorCCC(
bool AllowInvalid,
bool WantClass =
false,
68 bool AllowTemplates =
false,
69 bool AllowNonTemplates =
true)
70 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
71 AllowTemplates(AllowTemplates), AllowNonTemplates(AllowNonTemplates) {
72 WantExpressionKeywords =
false;
73 WantCXXNamedCasts =
false;
74 WantRemainingKeywords =
false;
79 if (!AllowInvalidDecl && ND->isInvalidDecl())
83 return AllowTemplates;
85 bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
89 if (AllowNonTemplates)
96 if (!RD || !RD->isInjectedClassName())
98 RD = cast<CXXRecordDecl>(RD->getDeclContext());
100 isa<ClassTemplateSpecializationDecl>(RD);
106 return !WantClassName && candidate.
isKeyword();
110 bool AllowInvalidDecl;
113 bool AllowNonTemplates;
125 case tok::kw___int64:
126 case tok::kw___int128:
128 case tok::kw_unsigned:
135 case tok::kw__Float16:
136 case tok::kw___float128:
137 case tok::kw_wchar_t:
139 case tok::kw___underlying_type:
140 case tok::kw___auto_type:
143 case tok::annot_typename:
144 case tok::kw_char16_t:
145 case tok::kw_char32_t:
147 case tok::annot_decltype:
148 case tok::kw_decltype:
149 return getLangOpts().CPlusPlus;
151 case tok::kw_char8_t:
152 return getLangOpts().Char8;
178 return UnqualifiedTypeNameLookupResult::NotFound;
181 UnqualifiedTypeNameLookupResult::NotFound;
184 if (
auto *BaseTT =
Base.getType()->getAs<
TagType>())
185 BaseRD = BaseTT->getAsCXXRecordDecl();
189 if (!TST || !TST->isDependentType())
191 auto *TD = TST->getTemplateName().getAsTemplateDecl();
194 if (
auto *BasePrimaryTemplate =
195 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
197 BaseRD = BasePrimaryTemplate;
198 else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
200 CTD->findPartialSpecialization(
Base.getType()))
208 if (!isa<TypeDecl>(ND))
209 return UnqualifiedTypeNameLookupResult::FoundNonType;
210 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
212 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
214 case UnqualifiedTypeNameLookupResult::FoundNonType:
215 return UnqualifiedTypeNameLookupResult::FoundNonType;
216 case UnqualifiedTypeNameLookupResult::FoundType:
217 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
219 case UnqualifiedTypeNameLookupResult::NotFound:
226 return FoundTypeDecl;
235 UnqualifiedTypeNameLookupResult::NotFound;
237 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
238 DC = DC->getParent()) {
245 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
251 S.
Diag(NameLoc, diag::ext_found_via_dependent_bases_lookup) << &II;
279 bool isClassName,
bool HasTrailingDot,
281 bool IsCtorOrDtorName,
282 bool WantNontrivialTypeSourceInfo,
283 bool IsClassTemplateDeductionContext,
286 bool AllowDeducedTemplate = IsClassTemplateDeductionContext &&
287 getLangOpts().CPlusPlus17 && !IsCtorOrDtorName &&
288 !isClassName && !HasTrailingDot;
295 LookupCtx = computeDeclContext(ObjectType);
297 LookupCtx = computeDeclContext(*SS,
false);
300 if (isDependentScopeSpecifier(*SS)) {
310 if (!isClassName && !IsCtorOrDtorName)
315 if (WantNontrivialTypeSourceInfo)
316 return ActOnTypenameType(S,
SourceLocation(), *SS, II, NameLoc).get();
328 RequireCompleteDeclContext(*SS, LookupCtx))
342 LookupQualifiedName(Result, LookupCtx);
344 if (ObjectTypePtr && Result.
empty()) {
351 LookupName(Result, S);
355 LookupName(Result, S);
359 if (Result.
empty() && getLangOpts().MSVCCompat && (!SS || SS->
isEmpty())) {
373 llvm::make_unique<TypeNameValidatorCCC>(
374 true, isClassName, AllowDeducedTemplate),
378 bool MemberOfUnknownSpecialization;
387 if (Correction && (NNS || NewII != &II) &&
392 isTemplateName(S, *NewSSPtr,
false, TemplateName,
nullptr,
false,
393 Template, MemberOfUnknownSpecialization))) {
395 isClassName, HasTrailingDot, ObjectTypePtr,
397 WantNontrivialTypeSourceInfo,
398 IsClassTemplateDeductionContext);
400 diagnoseTypo(Correction,
401 PDiag(diag::err_unknown_type_or_class_name_suggest)
404 SS->MakeTrivial(Context, NNS,
SourceRange(NameLoc));
405 *CorrectedII = NewII;
430 Res != ResEnd; ++Res) {
431 if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res) ||
462 assert(IIDecl &&
"Didn't find decl");
465 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
469 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
471 if (!isClassName && !IsCtorOrDtorName && LookupRD && FoundRD &&
472 FoundRD->isInjectedClassName() &&
474 Diag(NameLoc, diag::err_out_of_line_qualified_id_type_names_constructor)
477 DiagnoseUseOfDecl(IIDecl, NameLoc);
480 MarkAnyDeclReferenced(TD->getLocation(), TD,
false);
482 (void)DiagnoseUseOfDecl(IDecl, NameLoc);
485 }
else if (AllowDeducedTemplate) {
500 if (SS && SS->
isNotEmpty() && !IsCtorOrDtorName &&
501 !isa<ObjCInterfaceDecl>(IIDecl)) {
502 if (WantNontrivialTypeSourceInfo) {
507 T = getElaboratedType(
ETK_None, *SS, T);
513 T = getElaboratedType(
ETK_None, *SS, T);
526 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
528 else if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
530 RD->getTypeForDecl());
531 else if (isa<TranslationUnitDecl>(DC))
534 llvm_unreachable(
"something isn't in TU scope?");
545 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
546 if (MD->getParent()->hasAnyDependentBases())
554 bool IsTemplateTypeArg) {
555 assert(getLangOpts().MSVCCompat &&
"shouldn't be called in non-MSVC mode");
558 if (IsTemplateTypeArg && getCurScope()->isTemplateParamScope()) {
567 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
573 RD->getTypeForDecl());
577 Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
608 LookupName(R, S,
false);
612 switch (TD->getTagKind()) {
639 if (CurContext->isRecord()) {
659 bool IsTemplateName) {
664 SuggestedType =
nullptr;
670 llvm::make_unique<TypeNameValidatorCCC>(
671 false,
false, IsTemplateName, !IsTemplateName),
672 CTK_ErrorRecovery)) {
674 bool CanRecover = !IsTemplateName;
675 if (Corrected.isKeyword()) {
677 diagnoseTypo(Corrected,
678 PDiag(IsTemplateName ? diag::err_no_template_suggest
679 : diag::err_unknown_typename_suggest)
681 II = Corrected.getCorrectionAsIdentifierInfo();
684 if (!SS || !SS->
isSet()) {
685 diagnoseTypo(Corrected,
686 PDiag(IsTemplateName ? diag::err_no_template_suggest
687 : diag::err_unknown_typename_suggest)
689 }
else if (
DeclContext *DC = computeDeclContext(*SS,
false)) {
690 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
691 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
692 II->
getName().equals(CorrectedStr);
693 diagnoseTypo(Corrected,
695 ? diag::err_no_member_template_suggest
696 : diag::err_unknown_nested_typename_suggest)
697 << II << DC << DroppedSpecifier << SS->
getRange(),
700 llvm_unreachable(
"could not have corrected a typo here");
707 if (Corrected.getCorrectionSpecifier())
708 tmpSS.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
712 getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc, S,
713 tmpSS.
isSet() ? &tmpSS : SS,
false,
false,
nullptr,
720 if (getLangOpts().CPlusPlus && !IsTemplateName) {
726 bool MemberOfUnknownSpecialization;
727 if (isTemplateName(S, SS ? *SS : EmptySS,
false,
728 Name,
nullptr,
true, TemplateResult,
730 diagnoseMissingTemplateArguments(TemplateResult.
get(), IILoc);
739 Diag(IILoc, IsTemplateName ? diag::err_no_template
740 : diag::err_unknown_typename)
742 else if (
DeclContext *DC = computeDeclContext(*SS,
false))
743 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
744 : diag::err_typename_nested_not_found)
746 else if (isDependentScopeSpecifier(*SS)) {
747 unsigned DiagID = diag::err_typename_missing;
748 if (getLangOpts().MSVCCompat && isMicrosoftMissingTypename(SS, S))
749 DiagID = diag::ext_typename_missing;
756 *SS, *II, IILoc).
get();
759 "Invalid scope specifier has already been diagnosed");
767 NextToken.
is(tok::less);
770 if (isa<TypeDecl>(*I) || isa<ObjCInterfaceDecl>(*I))
773 if (CheckTemplate && isa<TemplateDecl>(*I))
787 StringRef FixItTagName;
788 switch (Tag->getTagKind()) {
790 FixItTagName =
"class ";
794 FixItTagName =
"enum ";
798 FixItTagName =
"struct ";
802 FixItTagName =
"__interface ";
806 FixItTagName =
"union ";
810 StringRef TagName = FixItTagName.drop_back();
811 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
812 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
817 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
847 bool IsAddressOfOperand,
848 std::unique_ptr<CorrectionCandidateCallback> CCC) {
852 if (NextToken.
is(tok::coloncolon)) {
854 BuildCXXNestedNameSpecifier(S, IdInfo,
false, SS,
nullptr,
false);
856 isCurrentClassName(*Name, S, &SS)) {
864 LookupResult Result(*
this, Name, NameLoc, LookupOrdinaryName);
865 LookupParsedName(Result, S, &SS, !CurMethod);
869 if (Result.
empty() && SS.
isEmpty() && getLangOpts().MSVCCompat) {
880 ExprResult E = LookupInObjCMethod(Result, S, Name,
true);
885 bool SecondTry =
false;
886 bool IsFilteredTemplateName =
false;
893 if (!SS.
isSet() && NextToken.
is(tok::l_paren)) {
896 if (getLangOpts().CPlusPlus)
897 return BuildDeclarationNameExpr(SS, Result,
true);
911 if (
NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *Name, S)) {
914 return BuildDeclarationNameExpr(SS, Result,
false);
921 if (!getLangOpts().
CPlusPlus && !SecondTry &&
928 if (!SecondTry && CCC) {
933 CTK_ErrorRecovery)) {
934 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
935 unsigned QualifiedDiag = diag::err_no_member_suggest;
937 NamedDecl *FirstDecl = Corrected.getFoundDecl();
938 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
939 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
940 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
941 UnqualifiedDiag = diag::err_no_template_suggest;
942 QualifiedDiag = diag::err_no_member_template_suggest;
943 }
else if (UnderlyingFirstDecl &&
944 (isa<TypeDecl>(UnderlyingFirstDecl) ||
945 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
946 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
947 UnqualifiedDiag = diag::err_unknown_typename_suggest;
948 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
952 diagnoseTypo(Corrected, PDiag(UnqualifiedDiag) << Name);
954 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
955 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
956 Name->
getName().equals(CorrectedStr);
957 diagnoseTypo(Corrected, PDiag(QualifiedDiag)
958 << Name << computeDeclContext(SS,
false)
959 << DroppedSpecifier << SS.getRange());
963 Name = Corrected.getCorrectionAsIdentifierInfo();
966 if (Corrected.isKeyword())
982 ExprResult E(LookupInObjCMethod(Result, S, Ivar->getIdentifier()));
1010 NameInfo, IsAddressOfOperand,
1020 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
1021 hasAnyAcceptableTemplateNames(Result)) {
1033 FilterAcceptableTemplateNames(Result);
1035 IsFilteredTemplateName =
true;
1044 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
1045 (IsFilteredTemplateName || hasAnyAcceptableTemplateNames(Result))) {
1052 if (!IsFilteredTemplateName)
1053 FilterAcceptableTemplateNames(Result);
1055 if (!Result.
empty()) {
1056 bool IsFunctionTemplate;
1059 if (Result.
end() - Result.
begin() > 1) {
1060 IsFunctionTemplate =
true;
1065 = cast<TemplateDecl>((*Result.
begin())->getUnderlyingDecl());
1066 IsFunctionTemplate = isa<FunctionTemplateDecl>(TD);
1067 IsVarTemplate = isa<VarTemplateDecl>(TD);
1077 if (IsFunctionTemplate) {
1083 return NameClassification::FunctionTemplate(Template);
1086 return IsVarTemplate ? NameClassification::VarTemplate(Template)
1087 : NameClassification::TypeTemplate(Template);
1093 DiagnoseUseOfDecl(
Type, NameLoc);
1094 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
1105 dyn_cast<ObjCCompatibleAliasDecl>(FirstDecl))
1106 Class = Alias->getClassInterface();
1110 DiagnoseUseOfDecl(Class, NameLoc);
1112 if (NextToken.
is(tok::period)) {
1124 if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl) &&
1125 !isa<VarTemplateDecl>(FirstDecl))
1126 return NameClassification::TypeTemplate(
1131 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1132 if ((NextToken.
is(tok::identifier) ||
1137 DiagnoseUseOfDecl(Type, NameLoc);
1145 return BuildPossibleImplicitMemberExpr(SS,
SourceLocation(), Result,
1148 bool ADL = UseArgumentDependentLookup(SS, Result, NextToken.
is(tok::l_paren));
1149 return BuildDeclarationNameExpr(SS, Result, ADL);
1156 return TemplateNameKindForDiagnostics::DependentTemplate;
1157 if (isa<ClassTemplateDecl>(TD))
1158 return TemplateNameKindForDiagnostics::ClassTemplate;
1159 if (isa<FunctionTemplateDecl>(TD))
1160 return TemplateNameKindForDiagnostics::FunctionTemplate;
1161 if (isa<VarTemplateDecl>(TD))
1162 return TemplateNameKindForDiagnostics::VarTemplate;
1163 if (isa<TypeAliasTemplateDecl>(TD))
1164 return TemplateNameKindForDiagnostics::AliasTemplate;
1165 if (isa<TemplateTemplateParmDecl>(TD))
1166 return TemplateNameKindForDiagnostics::TemplateTemplateParam;
1167 return TemplateNameKindForDiagnostics::DependentTemplate;
1192 if (!isa<CXXRecordDecl>(DC))
1210 assert(getContainingDC(DC) == CurContext &&
1211 "The next DeclContext should be lexically contained in the current one.");
1217 assert(CurContext &&
"DeclContext imbalance!");
1219 CurContext = getContainingDC(CurContext);
1220 assert(CurContext &&
"Popped translation unit!");
1230 assert(CurContext &&
"skipping definition of undefined tag");
1233 S->
setEntity(CurContext->getLookupParent());
1238 CurContext =
static_cast<decltype(CurContext)
>(Context);
1261 assert(!S->
getEntity() &&
"scope already has entity");
1265 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1266 assert(Ancestor->getEntity() == CurContext &&
"ancestor context mismatch");
1274 assert(S->
getEntity() == CurContext &&
"Context imbalance!");
1279 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1296 "The next DeclContext should be lexically contained in the current one.");
1300 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1305 IdResolver.AddDecl(Param);
1313 assert(CurContext &&
"DeclContext imbalance!");
1314 CurContext = CurContext->getLexicalParent();
1315 assert(CurContext &&
"Popped translation unit!");
1338 New->
hasAttr<OverloadableAttr>());
1353 CurContext->addDecl(D);
1364 if (isa<FunctionDecl>(D) &&
1365 cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
1370 IEnd = IdResolver.end();
1371 for (; I != IEnd; ++I) {
1374 IdResolver.RemoveDecl(*I);
1383 if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) {
1387 for (I = IdResolver.begin(D->
getDeclName()); I != IEnd; ++I) {
1389 if (IDC == CurContext) {
1392 }
else if (IDC->
Encloses(CurContext))
1396 IdResolver.InsertDeclAfter(I, D);
1398 IdResolver.AddDecl(D);
1403 if (IdResolver.tryAddTopLevelDecl(D, Name) && TUScope)
1404 TUScope->AddDecl(D);
1408 bool AllowInlineNamespace) {
1409 return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace);
1416 if (ScopeDC->getPrimaryContext() == TargetDC)
1430 bool ConsiderLinkage,
1431 bool AllowInlineNamespace) {
1436 if (isDeclInScope(D, Ctx, S, AllowInlineNamespace))
1458 makeMergedDefinitionVisible(New);
1470 if (NewIsModuleInterface || OldIsModuleInterface) {
1476 << NewIsModuleInterface
1478 << OldIsModuleInterface
1489 return isa<UsingShadowDecl>(D) ||
1490 isa<UnresolvedUsingTypenameDecl>(D) ||
1491 isa<UnresolvedUsingValueDecl>(D);
1518 return CD->isCopyConstructor();
1534 bool Sema::mightHaveNonExternalLinkage(
const DeclaratorDecl *D) {
1537 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1538 if (!RD->hasNameForLinkage())
1567 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1573 FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
1576 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1581 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1585 if (FD->doesThisDeclarationHaveABody() &&
1588 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1598 if (VD->isStaticDataMember() &&
1601 if (VD->isStaticDataMember() &&
1603 VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
1606 if (VD->isInline() && !
isMainFileLoc(*
this, VD->getLocation()))
1615 return mightHaveNonExternalLinkage(D);
1622 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1624 if (FD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1628 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1630 if (VD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1634 if (ShouldWarnIfUnusedFileScopedDecl(D))
1635 UnusedFileScopedDecls.push_back(D);
1642 bool Referenced =
false;
1643 if (
auto *DD = dyn_cast<DecompositionDecl>(D)) {
1647 for (
auto *BD : DD->bindings()) {
1648 if (BD->isReferenced()) {
1659 if (Referenced || D->
hasAttr<UnusedAttr>() ||
1660 D->
hasAttr<ObjCPreciseLifetimeAttr>())
1663 if (isa<LabelDecl>(D))
1669 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->
getDeclContext()))
1672 WithinFunction || (R->isLocalClass() && !R->isDependentType());
1673 if (!WithinFunction)
1676 if (isa<TypedefNameDecl>(D))
1680 if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D))
1684 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1687 const auto *Ty = VD->getType().getTypePtr();
1691 if (TT->getDecl()->hasAttr<UnusedAttr>())
1697 if (Ty->isIncompleteType() || Ty->isDependentType())
1702 Ty = Ty->getBaseElementTypeUnsafe();
1705 const TagDecl *Tag = TT->getDecl();
1706 if (Tag->
hasAttr<UnusedAttr>())
1709 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) {
1710 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
1713 if (
const Expr *Init = VD->getInit()) {
1715 dyn_cast<ExprWithCleanups>(Init))
1716 Init = Cleanups->getSubExpr();
1721 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
1722 (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
1737 if (isa<LabelDecl>(D)) {
1752 for (
auto *TmpD : D->
decls()) {
1753 if (
const auto *T = dyn_cast<TypedefNameDecl>(TmpD))
1754 DiagnoseUnusedDecl(T);
1755 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
1756 DiagnoseUnusedNestedTypedefs(R);
1766 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1769 UnusedLocalTypedefNameCandidates.insert(TD);
1777 if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
1778 DiagID = diag::warn_unused_exception_param;
1779 else if (isa<LabelDecl>(D))
1780 DiagID = diag::warn_unused_label;
1782 DiagID = diag::warn_unused_variable;
1792 bool Diagnose =
false;
1796 Diagnose = L->
getStmt() ==
nullptr;
1806 "Scope shouldn't contain decls!");
1808 for (
auto *TmpD : S->
decls()) {
1809 assert(TmpD &&
"This decl didn't get pushed??");
1811 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
1816 DiagnoseUnusedDecl(D);
1817 if (
const auto *RD = dyn_cast<RecordDecl>(D))
1818 DiagnoseUnusedNestedTypedefs(RD);
1824 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
1829 IdResolver.RemoveDecl(D);
1830 auto ShadowI = ShadowingDecls.find(D);
1831 if (ShadowI != ShadowingDecls.end()) {
1832 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
1834 << D << FD << FD->getParent();
1835 Diag(FD->getLocation(), diag::note_previous_declaration);
1837 ShadowingDecls.erase(ShadowI);
1857 bool DoTypoCorrection) {
1860 NamedDecl *IDecl = LookupSingleName(TUScope, Id, IdLoc, LookupOrdinaryName);
1862 if (!IDecl && DoTypoCorrection) {
1868 CTK_ErrorRecovery)) {
1869 diagnoseTypo(C, PDiag(diag::err_undef_interface_suggest) << Id);
1918 if (!II->
isStr(
"objc_msgSendSuper"))
1939 return "ucontext.h";
1941 llvm_unreachable(
"unhandled error kind");
1949 Scope *S,
bool ForRedeclaration,
1956 if (ForRedeclaration)
1957 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
1962 if (!ForRedeclaration &&
1965 Diag(Loc, diag::ext_implicit_lib_function_decl)
1968 !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc))
1969 Diag(Loc, diag::note_include_header_or_declare)
1983 Parent->
addDecl(CLinkageDecl);
1984 Parent = CLinkageDecl;
1989 Loc, Loc, II, R,
nullptr,
1999 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2002 nullptr, FT->getParamType(i),
nullptr,
2005 Params.push_back(parm);
2007 New->setParams(Params);
2010 AddKnownFunctionAttributes(New);
2011 RegisterLocallyScopedExternCDecl(New, S);
2019 PushOnScopeChains(New, TUScope);
2020 CurContext = SavedContext;
2036 if (Previous.
empty())
2049 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2056 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2070 OldType = OldTypedef->getUnderlyingType();
2077 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2078 Diag(New->
getLocation(), diag::err_redefinition_variably_modified_typedef)
2086 if (OldType != NewType &&
2090 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2092 << Kind << NewType << OldType;
2114 if (getLangOpts().ObjC) {
2120 if (!TypeID->
isStr(
"id"))
2136 if (!TypeID->
isStr(
"Class"))
2143 if (!TypeID->
isStr(
"SEL"))
2170 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2171 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2174 if (OldTag && NewTag &&
2175 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
2176 !hasVisibleDefinition(OldTag, &Hidden)) {
2180 if (OldTD->isModed())
2182 OldTD->getUnderlyingType());
2187 makeMergedDefinitionVisible(Hidden);
2191 if (isa<EnumDecl>(NewTag)) {
2192 Scope *EnumScope = getNonFieldDeclScope(S);
2193 for (
auto *D : NewTag->decls()) {
2194 auto *ED = cast<EnumConstantDecl>(D);
2197 IdResolver.RemoveDecl(ED);
2198 ED->getLexicalDeclContext()->removeDecl(ED);
2206 if (isIncompatibleTypedef(Old, New))
2213 mergeDeclAttributes(New, Old);
2216 if (getLangOpts().MicrosoftExt)
2224 if (!isa<CXXRecordDecl>(CurContext))
2248 if (!isa<TypedefNameDecl>(Old))
2258 if (getLangOpts().Modules || getLangOpts().
C11)
2265 if (getDiagnostics().getSuppressSystemWarnings() &&
2280 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2281 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2282 for (
const auto *i : D->
attrs())
2283 if (i->getKind() == A->
getKind()) {
2285 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2290 if (OA && isa<OwnershipAttr>(i))
2291 return OA->getOwnKind() == cast<OwnershipAttr>(i)->getOwnKind();
2299 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2300 return VD->isThisDeclarationADefinition();
2301 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2302 return TD->isCompleteDefinition() || TD->isBeingDefined();
2313 AlignedAttr *OldAlignasAttr =
nullptr;
2314 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2315 unsigned OldAlign = 0;
2323 if (I->isAlignmentDependent())
2329 unsigned Align = I->getAlignment(S.
Context);
2330 if (Align > OldAlign) {
2332 OldStrictestAlignAttr = I;
2337 AlignedAttr *NewAlignasAttr =
nullptr;
2338 unsigned NewAlign = 0;
2340 if (I->isAlignmentDependent())
2346 unsigned Align = I->getAlignment(S.
Context);
2347 if (Align > NewAlign)
2351 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2359 if (OldAlign == 0 || NewAlign == 0) {
2361 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2372 if (OldAlign != NewAlign) {
2373 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2376 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2391 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2395 bool AnyAdded =
false;
2398 if (OldAlign > NewAlign) {
2399 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2400 Clone->setInherited(
true);
2406 if (OldAlignasAttr && !NewAlignasAttr &&
2407 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2408 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2409 Clone->setInherited(
true);
2429 if (
const auto *AA = dyn_cast<AvailabilityAttr>(Attr))
2432 AA->getDeprecated(),
2433 AA->getObsoleted(), AA->getUnavailable(),
2434 AA->getMessage(), AA->getStrict(),
2435 AA->getReplacement(), AMK,
2436 AttrSpellingListIndex);
2437 else if (
const auto *VA = dyn_cast<VisibilityAttr>(Attr))
2439 AttrSpellingListIndex);
2440 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(Attr))
2442 AttrSpellingListIndex);
2443 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(Attr))
2445 AttrSpellingListIndex);
2446 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(Attr))
2448 AttrSpellingListIndex);
2449 else if (
const auto *FA = dyn_cast<FormatAttr>(Attr))
2451 FA->getFormatIdx(), FA->getFirstArg(),
2452 AttrSpellingListIndex);
2453 else if (
const auto *SA = dyn_cast<SectionAttr>(Attr))
2455 AttrSpellingListIndex);
2456 else if (
const auto *CSA = dyn_cast<CodeSegAttr>(Attr))
2458 AttrSpellingListIndex);
2459 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(Attr))
2461 AttrSpellingListIndex,
2462 IA->getSemanticSpelling());
2463 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(Attr))
2466 AttrSpellingListIndex);
2467 else if (S.
getLangOpts().CUDA && isa<FunctionDecl>(D) &&
2468 (isa<CUDAHostAttr>(Attr) || isa<CUDADeviceAttr>(Attr) ||
2469 isa<CUDAGlobalAttr>(Attr))) {
2473 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(Attr))
2475 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(Attr))
2477 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(Attr))
2479 else if (
const auto *CommonA = dyn_cast<CommonAttr>(Attr))
2481 else if (isa<AlignedAttr>(Attr))
2485 else if ((isa<DeprecatedAttr>(Attr) || isa<UnavailableAttr>(Attr)) &&
2489 else if (
const auto *UA = dyn_cast<UuidAttr>(Attr))
2490 NewAttr = S.
mergeUuidAttr(D, UA->getRange(), AttrSpellingListIndex,
2493 NewAttr = cast<InheritableAttr>(Attr->
clone(S.
Context));
2498 if (isa<MSInheritanceAttr>(NewAttr))
2507 if (
const TagDecl *TD = dyn_cast<TagDecl>(D))
2508 return TD->getDefinition();
2509 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2515 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
2521 for (
const auto *Attribute : D->
attrs())
2522 if (Attribute->getKind() ==
Kind)
2534 if (!Def || Def == New)
2538 for (
unsigned I = 0, E = NewAttributes.size(); I != E;) {
2539 const Attr *NewAttribute = NewAttributes[I];
2541 if (isa<AliasAttr>(NewAttribute) || isa<IFuncAttr>(NewAttribute)) {
2548 NewAttributes.erase(NewAttributes.begin() + I);
2553 VarDecl *VD = cast<VarDecl>(New);
2554 unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
2556 ? diag::err_alias_after_tentative
2557 : diag::err_redefinition;
2559 if (Diag == diag::err_redefinition)
2569 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
2582 if (isa<C11NoReturnAttr>(NewAttribute)) {
2586 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
2587 if (AA->isAlignas()) {
2598 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
2600 NewAttributes.erase(NewAttributes.begin() + I);
2607 diag::warn_attribute_precede_definition);
2609 NewAttributes.erase(NewAttributes.begin() + I);
2618 UsedAttr *NewAttr = OldAttr->clone(Context);
2619 NewAttr->setInherited(
true);
2629 if (AsmLabelAttr *NewA = New->
getAttr<AsmLabelAttr>()) {
2630 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
2631 if (OldA->getLabel() != NewA->getLabel()) {
2634 Diag(OldA->getLocation(), diag::note_previous_declaration);
2636 }
else if (Old->
isUsed()) {
2640 << isa<FunctionDecl>(Old) << New->
getAttr<AsmLabelAttr>()->getRange();
2645 if (
const auto *NewAbiTagAttr = New->
getAttr<AbiTagAttr>()) {
2646 if (
const auto *OldAbiTagAttr = Old->
getAttr<AbiTagAttr>()) {
2647 for (
const auto &NewTag : NewAbiTagAttr->tags()) {
2648 if (std::find(OldAbiTagAttr->tags_begin(), OldAbiTagAttr->tags_end(),
2649 NewTag) == OldAbiTagAttr->tags_end()) {
2650 Diag(NewAbiTagAttr->getLocation(),
2651 diag::err_new_abi_tag_on_redeclaration)
2653 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
2657 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
2663 if (New->
hasAttr<SectionAttr>() && !Old->
hasAttr<SectionAttr>()) {
2664 if (
auto *VD = dyn_cast<VarDecl>(New)) {
2666 Diag(New->
getLocation(), diag::warn_attribute_section_on_redeclaration);
2673 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
2674 if (NewCSA && !Old->
hasAttr<CodeSegAttr>() &&
2675 !NewCSA->isImplicit() && isa<CXXMethodDecl>(New)) {
2693 if (isa<DeprecatedAttr>(I) ||
2694 isa<UnavailableAttr>(I) ||
2695 isa<AvailabilityAttr>(I)) {
2700 case AMK_Redeclaration:
2702 case AMK_ProtocolImplementation:
2709 if (isa<UsedAttr>(I))
2731 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
2732 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
2733 S.
Diag(CDA->getLocation(),
2734 diag::err_carries_dependency_missing_on_first_decl) << 1;
2742 diag::note_carries_dependency_missing_first_decl) << 1;
2748 bool foundAny = newDecl->
hasAttrs();
2757 cast<InheritableParamAttr>(I->clone(S.
Context));
2772 if (*Oldnullability != *Newnullability) {
2773 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
2798 struct GNUCompatibleParamWarning {
2809 if (Ctor->isDefaultConstructor())
2812 if (Ctor->isCopyConstructor())
2815 if (Ctor->isMoveConstructor())
2817 }
else if (isa<CXXDestructorDecl>(MD)) {
2830 template <
typename T>
2831 static std::pair<diag::kind, SourceLocation>
2835 if (Old->isThisDeclarationADefinition())
2836 PrevDiag = diag::note_previous_definition;
2837 else if (Old->isImplicit()) {
2838 PrevDiag = diag::note_previous_implicit_declaration;
2840 OldLocation = New->getLocation();
2842 PrevDiag = diag::note_previous_declaration;
2843 return std::make_pair(PrevDiag, OldLocation);
2851 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
2852 !LangOpts.CPlusPlus &&
2864 template <
typename T>
2878 template<
typename T>
static bool isExternC(T *D) {
return D->isExternC(); }
2884 template<
typename ExpectedDecl>
2906 !Old->getDeclContext()->getRedeclContext()->Equals(
2907 New->getDeclContext()->getRedeclContext()) &&
2912 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
2925 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
2926 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
2929 return AttrA && AttrB && AttrA->getType() == AttrB->getType();
2932 return std::equal(A->param_begin(), A->param_end(), B->
param_begin(), AttrEq);
2955 if (NamedDC->Equals(SemaDC))
2958 assert((NamedDC->InEnclosingNamespaceSetOf(SemaDC) ||
2960 "unexpected context for redeclaration");
2971 if (
auto *FD = dyn_cast<FunctionDecl>(NewD))
2972 FixSemaDC(FD->getDescribedFunctionTemplate());
2973 else if (
auto *VD = dyn_cast<VarDecl>(NewD))
2974 FixSemaDC(VD->getDescribedVarTemplate());
2989 Scope *S,
bool MergeTypeWithOld) {
2996 Diag(Shadow->getTargetDecl()->getLocation(),
2997 diag::note_using_decl_target);
2998 Diag(Shadow->getUsingDecl()->getLocation(),
2999 diag::note_using_decl) << 0;
3004 if (checkUsingShadowRedecl<FunctionDecl>(*
this, Shadow, New))
3006 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
3020 if (!getASTContext().canBuiltinBeRedeclared(Old)) {
3029 std::tie(PrevDiag, OldLocation) =
3036 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
3041 if (getLangOpts().MicrosoftExt) {
3043 Diag(OldLocation, PrevDiag);
3046 Diag(OldLocation, PrevDiag);
3051 if (New->
hasAttr<InternalLinkageAttr>() &&
3052 !Old->
hasAttr<InternalLinkageAttr>()) {
3056 New->
dropAttr<InternalLinkageAttr>();
3059 if (CheckRedeclarationModuleOwnership(New, Old))
3062 if (!getLangOpts().CPlusPlus) {
3063 bool OldOvl = Old->
hasAttr<OverloadableAttr>();
3074 const Decl *DiagOld = Old;
3076 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *D) {
3077 const auto *A = D->
getAttr<OverloadableAttr>();
3078 return A && !A->isImplicit();
3082 DiagOld = OldIter == Old->
redecls_end() ? nullptr : *OldIter;
3086 Diag(DiagOld->getLocation(),
3087 diag::note_attribute_overloadable_prev_overload)
3091 New->
addAttr(OverloadableAttr::CreateImplicit(Context));
3112 const FunctionType *OldType = cast<FunctionType>(OldQType);
3113 const FunctionType *NewType = cast<FunctionType>(NewQType);
3116 bool RequiresAdjustment =
false;
3118 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC()) {
3123 bool NewCCExplicit = getCallingConvAttributedType(New->
getType());
3124 if (!NewCCExplicit) {
3128 RequiresAdjustment =
true;
3131 bool FirstCCExplicit = getCallingConvAttributedType(First->
getType());
3135 << (!FirstCCExplicit ?
"" :
3145 if (OldTypeInfo.getNoReturn() && !NewTypeInfo.
getNoReturn()) {
3147 RequiresAdjustment =
true;
3151 if (OldTypeInfo.getHasRegParm() != NewTypeInfo.
getHasRegParm() ||
3152 OldTypeInfo.getRegParm() != NewTypeInfo.
getRegParm()) {
3155 << NewType->getRegParmType()
3157 Diag(OldLocation, diag::note_previous_declaration);
3161 NewTypeInfo = NewTypeInfo.
withRegParm(OldTypeInfo.getRegParm());
3162 RequiresAdjustment =
true;
3169 <<
"'ns_returns_retained'";
3170 Diag(OldLocation, diag::note_previous_declaration);
3175 RequiresAdjustment =
true;
3178 if (OldTypeInfo.getNoCallerSavedRegs() !=
3181 AnyX86NoCallerSavedRegistersAttr *
Attr =
3182 New->
getAttr<AnyX86NoCallerSavedRegistersAttr>();
3183 Diag(New->
getLocation(), diag::err_function_attribute_mismatch) << Attr;
3184 Diag(OldLocation, diag::note_previous_declaration);
3189 RequiresAdjustment =
true;
3192 if (RequiresAdjustment) {
3197 NewType = cast<FunctionType>(NewQType);
3203 !New->
hasAttr<GNUInlineAttr>() &&
3204 !getLangOpts().GNUInline &&
3212 if (New->
hasAttr<GNUInlineAttr>() &&
3223 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3238 if (CheckEquivalentExceptionSpec(Old, New))
3250 if (!Context.
hasSameType(OldDeclaredReturnType, NewDeclaredReturnType) &&
3251 canFullyTypeCheckRedeclaration(New, Old, NewDeclaredReturnType,
3252 OldDeclaredReturnType)) {
3260 Diag(New->
getLocation(), diag::err_member_def_does_not_match_ret_type)
3265 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
3274 QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType();
3275 if (OldReturnType != NewReturnType) {
3285 SubstAutoType(NewQType,
3293 if (OldMethod && NewMethod) {
3300 bool IsClassScopeExplicitSpecialization =
3302 NewMethod->isFunctionTemplateSpecialization();
3303 bool isFriend = NewMethod->getFriendObjectKind();
3305 if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() &&
3306 !IsClassScopeExplicitSpecialization) {
3310 if (OldMethod->
isStatic() != NewMethod->isStatic()) {
3312 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3320 if (!inTemplateInstantiation()) {
3322 if (isa<CXXConstructorDecl>(OldMethod))
3323 NewDiag = diag::err_constructor_redeclared;
3324 else if (isa<CXXDestructorDecl>(NewMethod))
3325 NewDiag = diag::err_destructor_redeclared;
3326 else if (isa<CXXConversionDecl>(NewMethod))
3327 NewDiag = diag::err_conv_function_redeclared;
3329 NewDiag = diag::err_member_redeclared;
3333 Diag(New->
getLocation(), diag::err_member_redeclared_in_instantiation)
3336 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3346 NewMethod->setImplicit();
3348 Diag(NewMethod->getLocation(),
3349 diag::err_definition_of_implicitly_declared_member)
3350 << New << getSpecialMember(OldMethod);
3354 Diag(NewMethod->getLocation(),
3355 diag::err_definition_of_explicitly_defaulted_member)
3356 << getSpecialMember(OldMethod);
3365 const CXX11NoReturnAttr *NRA = New->
getAttr<CXX11NoReturnAttr>();
3366 if (NRA && !Old->
hasAttr<CXX11NoReturnAttr>()) {
3367 Diag(NRA->getLocation(), diag::err_noreturn_missing_on_first_decl);
3369 diag::note_noreturn_missing_first_decl);
3376 const CarriesDependencyAttr *CDA = New->
getAttr<CarriesDependencyAttr>();
3377 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
3378 Diag(CDA->getLocation(),
3379 diag::err_carries_dependency_missing_on_first_decl) << 0;
3381 diag::note_carries_dependency_missing_first_decl) << 0;
3390 QualType OldQTypeForComparison = OldQType;
3391 if (!OldTypeInfo.getNoReturn() && NewTypeInfo.
getNoReturn()) {
3395 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
3396 assert(OldQTypeForComparison.isCanonical());
3410 Diag(OldLocation, PrevDiag);
3412 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3413 Diag(OldLocation, PrevDiag);
3418 if (OldQTypeForComparison == NewQType)
3419 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3424 if (!canFullyTypeCheckRedeclaration(New, Old, NewQType, OldQType))
3437 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
3441 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
3445 OldProto->getExtProtoInfo());
3451 for (
const auto &ParamType : OldProto->param_types()) {
3458 Params.push_back(Param);
3461 New->setParams(Params);
3464 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3491 NewProto->getReturnType());
3492 bool LooseCompatible = !MergedReturn.
isNull();
3494 LooseCompatible && Idx !=
End; ++Idx) {
3498 NewProto->getParamType(Idx))) {
3499 ArgTypes.push_back(NewParm->
getType());
3503 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
3504 NewProto->getParamType(Idx) };
3505 Warnings.push_back(Warn);
3506 ArgTypes.push_back(NewParm->
getType());
3508 LooseCompatible =
false;
3511 if (LooseCompatible) {
3512 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
3513 Diag(Warnings[Warn].NewParm->getLocation(),
3514 diag::ext_param_promoted_not_compatible_with_prototype)
3515 << Warnings[Warn].PromotedType
3516 << Warnings[Warn].OldParm->getType();
3517 if (Warnings[Warn].OldParm->getLocation().isValid())
3518 Diag(Warnings[Warn].OldParm->getLocation(),
3519 diag::note_previous_declaration);
3522 if (MergeTypeWithOld)
3525 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3542 Diag(OldLocation, diag::note_previous_builtin_declaration)
3559 PrevDiag = diag::note_previous_builtin_declaration;
3563 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3577 Scope *S,
bool MergeTypeWithOld) {
3579 mergeDeclAttributes(New, Old);
3592 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
3600 return MergeCXXFunctionDecl(New, Old, S);
3606 if (!Merged.
isNull() && MergeTypeWithOld)
3617 ? AMK_ProtocolImplementation
3618 : isa<ObjCImplDecl>(newMethod->
getDeclContext()) ? AMK_Redeclaration
3621 mergeDeclAttributes(newMethod, oldMethod, MergeKind);
3628 ni != ne && oi != oe; ++ni, ++oi)
3631 CheckObjCMethodOverride(newMethod, oldMethod);
3638 ? diag::err_redefinition_different_type
3639 : diag::err_redeclaration_different_type)
3644 std::tie(PrevDiag, OldLocation)
3646 S.
Diag(OldLocation, PrevDiag);
3658 bool MergeTypeWithOld) {
3663 if (getLangOpts().CPlusPlus) {
3669 return MergeVarDeclExceptionSpecs(New, Old);
3740 if (MergeTypeWithOld)
3786 if (!shouldLinkPossiblyHiddenDecl(Previous, New))
3801 if (checkUsingShadowRedecl<VarTemplateDecl>(*
this, Shadow, NewTemplate))
3808 if (checkUsingShadowRedecl<VarDecl>(*
this, Shadow, New))
3824 true, TPL_TemplateMatch))
3838 mergeDeclAttributes(New, Old);
3841 if (New->
hasAttr<WeakImportAttr>() &&
3843 !Old->
hasAttr<WeakImportAttr>()) {
3850 if (New->
hasAttr<InternalLinkageAttr>() &&
3851 !Old->
hasAttr<InternalLinkageAttr>()) {
3855 New->
dropAttr<InternalLinkageAttr>();
3860 if (MostRecent != Old) {
3861 MergeVarDeclTypes(New, MostRecent,
3873 std::tie(PrevDiag, OldLocation) =
3880 if (getLangOpts().MicrosoftExt) {
3883 Diag(OldLocation, PrevDiag);
3887 Diag(OldLocation, PrevDiag);
3906 Diag(OldLocation, PrevDiag);
3914 Diag(OldLocation, PrevDiag);
3920 Diag(OldLocation, PrevDiag);
3924 if (CheckRedeclarationModuleOwnership(New, Old))
3936 Diag(OldLocation, PrevDiag);
3946 Diag(Def->getLocation(), diag::note_previous_definition);
3960 Diag(OldLocation, PrevDiag);
3963 Diag(OldLocation, PrevDiag);
3971 Diag(OldLocation, PrevDiag);
3982 diag::warn_deprecated_redundant_constexpr_static_def);
3984 if (checkVarDeclRedefinition(Def, New))
3990 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3991 Diag(OldLocation, PrevDiag);
4021 auto &HSI = PP.getHeaderSearchInfo();
4022 StringRef HdrFilename =
4025 auto noteFromModuleOrInclude = [&](
Module *Mod,
4031 if (IncLoc.isValid()) {
4033 Diag(IncLoc, diag::note_redefinition_modules_same_file)
4039 Diag(IncLoc, diag::note_redefinition_include_same_file)
4040 << HdrFilename.str();
4050 bool EmittedDiag =
false;
4051 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
4054 EmittedDiag = noteFromModuleOrInclude(Old->
getOwningModule(), OldIncLoc);
4055 EmittedDiag |= noteFromModuleOrInclude(getCurrentModule(), NewIncLoc);
4058 if (FOld && !HSI.isFileMultipleIncludeGuarded(FOld))
4073 if (!hasVisibleDefinition(Old) &&
4085 makeMergedDefinitionVisible(OldTD);
4086 makeMergedDefinitionVisible(Old);
4121 if (isa<CXXRecordDecl>(Tag->
getParent())) {
4135 Decl *ManglingContextDecl;
4139 Tag, MCtx->getManglingNumber(
4159 if (getLangOpts().CPlusPlus)
4174 tagLoc = getLocForEndOfToken(tagLoc);
4177 textToInsert +=
' ';
4179 Diag(tagLoc, diag::note_typedef_changes_linkage)
4201 llvm_unreachable(
"unexpected type specifier");
4211 bool IsExplicitInstantiation,
4213 Decl *TagD =
nullptr;
4228 if (isa<TagDecl>(TagD))
4229 Tag = cast<TagDecl>(TagD);
4231 Tag = CTD->getTemplatedDecl();
4235 handleTagNumbering(Tag, S);
4246 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
4252 << getLangOpts().CPlusPlus17;
4266 DiagnoseFunctionSpecifiers(DS);
4273 return ActOnFriendTypeDecl(S, DS, TemplateParams);
4277 bool IsExplicitSpecialization =
4278 !TemplateParams.empty() && TemplateParams.back()->size() == 0;
4280 !IsExplicitInstantiation && !IsExplicitSpecialization &&
4281 !isa<ClassTemplatePartialSpecializationDecl>(Tag)) {
4290 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
4296 bool DeclaresAnything =
true;
4299 if (
RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
4300 if (!Record->getDeclName() && Record->isCompleteDefinition() &&
4302 if (getLangOpts().CPlusPlus ||
4303 Record->getDeclContext()->isRecord()) {
4311 if (CurContext->isFunctionOrMethod())
4312 AnonRecord = Record;
4313 return BuildAnonymousStructOrUnion(S, DS, AS, Record,
4317 DeclaresAnything =
false;
4327 if (!getLangOpts().CPlusPlus && CurContext->isRecord() &&
4343 Record = RT->getDecl();
4345 Record = UT->getDecl();
4347 if (Record && getLangOpts().MicrosoftExt) {
4350 return BuildMicrosoftCAnonymousStruct(S, DS, Record);
4353 DeclaresAnything =
false;
4362 if (getLangOpts().CPlusPlus &&
4364 if (
EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Tag))
4365 if (Enum->enumerator_begin() == Enum->enumerator_end() &&
4366 !Enum->getIdentifier() && !Enum->isInvalidDecl())
4367 DeclaresAnything =
false;
4375 DeclaresAnything =
false;
4384 ActOnDocumentableDecl(TagD);
4394 if (!DeclaresAnything) {
4409 unsigned DiagID = diag::warn_standalone_specifier;
4411 DiagID = diag::ext_standalone_specifier;
4452 Diag(AL.getLoc(), diag::warn_declspec_attribute_ignored)
4476 assert(PrevDecl &&
"Expected a non-null Decl");
4481 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
4483 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
4508 bool Invalid =
false;
4511 for (
auto *D : AnonRecord->
decls()) {
4512 if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
4513 cast<NamedDecl>(D)->getDeclName()) {
4529 unsigned OldChainingSize = Chaining.size();
4531 Chaining.append(IF->chain_begin(), IF->chain_end());
4533 Chaining.push_back(VD);
4535 assert(Chaining.size() >= 2);
4538 for (
unsigned i = 0; i < Chaining.size(); i++)
4539 NamedChain[i] = Chaining[i];
4543 VD->
getType(), {NamedChain, Chaining.size()});
4555 Chaining.resize(OldChainingSize);
4570 "Parser allowed 'typedef' as storage class VarDecl.");
4571 switch (StorageClassSpec) {
4585 llvm_unreachable(
"unknown storage class specifier");
4591 for (
const auto *I : Record->
decls()) {
4592 const auto *FD = dyn_cast<
FieldDecl>(I);
4593 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
4594 FD = IFD->getAnonField();
4595 if (FD && FD->hasInClassInitializer())
4599 llvm_unreachable(
"couldn't find in-class initializer");
4607 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
4630 if (Record->
isUnion() && !getLangOpts().CPlusPlus && !getLangOpts().C11)
4632 else if (!Record->
isUnion() && getLangOpts().CPlusPlus)
4634 else if (!Record->
isUnion() && !getLangOpts().C11)
4639 bool Invalid =
false;
4640 if (getLangOpts().CPlusPlus) {
4641 const char *PrevSpec =
nullptr;
4652 !cast<NamespaceDecl>(OwnerScope)->isAnonymousNamespace()))) {
4658 PrevSpec, DiagID, Policy);
4664 isa<RecordDecl>(Owner)) {
4666 diag::err_anonymous_union_with_storage_spec)
4680 << Record->
isUnion() <<
"const" 4684 diag::ext_anonymous_struct_union_qualified)
4685 << Record->
isUnion() <<
"volatile" 4689 diag::ext_anonymous_struct_union_qualified)
4690 << Record->
isUnion() <<
"restrict" 4694 diag::ext_anonymous_struct_union_qualified)
4695 << Record->
isUnion() <<
"_Atomic" 4699 diag::ext_anonymous_struct_union_qualified)
4700 << Record->
isUnion() <<
"__unaligned" 4710 for (
auto *Mem : Record->
decls()) {
4711 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
4715 assert(FD->getAccess() !=
AS_none);
4717 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
4727 if (CheckNontrivialField(FD))
4729 }
else if (Mem->isImplicit()) {
4731 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
4736 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
4737 if (!MemRecord->isAnonymousStructOrUnion() &&
4738 MemRecord->getDeclName()) {
4740 if (getLangOpts().MicrosoftExt)
4741 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
4745 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
4753 Diag(MemRecord->getLocation(),
4754 diag::ext_anonymous_record_with_anonymous_type)
4757 }
else if (isa<AccessSpecDecl>(Mem)) {
4759 }
else if (isa<StaticAssertDecl>(Mem)) {
4764 unsigned DK = diag::err_anonymous_record_bad_member;
4765 if (isa<TypeDecl>(Mem))
4766 DK = diag::err_anonymous_record_with_type;
4767 else if (isa<FunctionDecl>(Mem))
4768 DK = diag::err_anonymous_record_with_function;
4769 else if (isa<VarDecl>(Mem))
4770 DK = diag::err_anonymous_record_with_static;
4773 if (getLangOpts().MicrosoftExt &&
4774 DK == diag::err_anonymous_record_with_type)
4775 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
4778 Diag(Mem->getLocation(), DK) << Record->
isUnion();
4787 if (cast<CXXRecordDecl>(Record)->hasInClassInitializer() &&
4790 cast<CXXRecordDecl>(Record));
4795 << getLangOpts().CPlusPlus;
4802 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
4806 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
4814 FieldCollector->Add(cast<FieldDecl>(Anon));
4834 ActOnUninitializedDecl(Anon);
4850 Chain.push_back(Anon);
4855 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
4856 if (getLangOpts().
CPlusPlus && NewVD->isStaticLocal()) {
4857 Decl *ManglingContextDecl;
4859 NewVD->getDeclContext(), ManglingContextDecl)) {
4861 NewVD, MCtx->getManglingNumber(
4889 assert(Record &&
"expected a record!");
4894 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
4896 auto *ParentDecl = cast<RecordDecl>(CurContext);
4902 nullptr, RecTy, TInfo,
4908 CurContext->addDecl(Anon);
4914 Chain.push_back(Anon);
4917 if (RequireCompleteType(Anon->
getLocation(), RecTy,
4918 diag::err_field_incomplete) ||
4922 ParentDecl->setInvalidDecl();
4931 return GetNameFromUnqualifiedId(D.
getName());
4960 if (!Template || !isa<ClassTemplateDecl>(Template)) {
4962 diag::err_deduction_guide_name_not_class_template)
4963 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
4965 Diag(Template->getLocation(), diag::note_template_decl_here);
5052 llvm_unreachable(
"Unknown name kind");
5080 for (
unsigned Idx = 0; Idx < Declaration->
param_size(); ++Idx) {
5094 (DeclTyName && DeclTyName == DefTyName))
5095 Params.push_back(Idx);
5136 if (!TSI)
return true;
5181 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer() &&
5185 if (getLangOpts().OpenCL)
5186 setCurrentOpenCLExtensionForDecl(Dcl);
5204 Record = dyn_cast<CXXRecordDecl>(Record->
getParent());
5206 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
5233 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
5247 Diag(Loc, LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
5248 : diag::err_member_extra_qualification)
5252 Diag(Loc, diag::warn_namespace_member_extra_qualification) << Name;
5260 if (!Cur->
Encloses(DC) && !IsTemplateId) {
5262 Diag(Loc, diag::err_member_qualification)
5264 else if (isa<TranslationUnitDecl>(DC))
5265 Diag(Loc, diag::err_invalid_declarator_global_scope)
5267 else if (isa<FunctionDecl>(Cur))
5268 Diag(Loc, diag::err_invalid_declarator_in_function)
5270 else if (isa<BlockDecl>(Cur))
5271 Diag(Loc, diag::err_invalid_declarator_in_block)
5274 Diag(Loc, diag::err_invalid_declarator_scope)
5275 << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.
getRange();
5282 Diag(Loc, diag::err_member_qualification)
5302 while (SpecLoc.getPrefix())
5304 if (dyn_cast_or_null<DecltypeType>(
5305 SpecLoc.getNestedNameSpecifier()->getAsType()))
5306 Diag(Loc, diag::err_decltype_in_declarator)
5307 << SpecLoc.getTypeLoc().getSourceRange();
5321 return ActOnDecompositionDeclarator(S, D, TemplateParamLists);
5327 }
else if (DiagnoseUnexpandedParameterPack(NameInfo, UPPC_DeclarationType))
5341 UPPC_DeclarationQualifier))
5346 if (!DC || isa<EnumDecl>(DC)) {
5352 diag::err_template_qualified_declarator_no_match)
5359 if (!IsDependentContext &&
5364 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
5366 diag::err_member_def_undefined_record)
5371 if (diagnoseQualifiedDeclaration(
5383 if (EnteringContext && IsDependentContext &&
5384 TemplateParamLists.size() != 0) {
5395 UPPC_DeclarationType))
5399 forRedeclarationInCurContext());
5403 bool IsLinkageLookup =
false;
5404 bool CreateBuiltins =
false;
5415 else if (CurContext->isFunctionOrMethod() &&
5418 IsLinkageLookup =
true;
5420 CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
5421 }
else if (CurContext->getRedeclContext()->isTranslationUnit() &&
5423 CreateBuiltins =
true;
5425 if (IsLinkageLookup) {
5426 Previous.
clear(LookupRedeclarationWithLinkage);
5430 LookupName(Previous, S, CreateBuiltins);
5432 LookupQualifiedName(Previous, DC);
5474 if (!R->
isFunctionType() && DiagnoseClassNameShadow(DC, NameInfo))
5490 CheckExtraCXXDefaultArguments(D);
5494 bool AddToScope =
true;
5496 if (TemplateParamLists.size()) {
5501 New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous);
5503 New = ActOnFunctionDeclarator(S, D, DC, TInfo, Previous,
5507 New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists,
5517 PushOnScopeChains(New, S);
5519 if (isInOpenMPDeclareTargetContext())
5520 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
5530 bool &SizeIsNegative,
5531 llvm::APSInt &Oversized) {
5536 SizeIsNegative =
false;
5545 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
5550 if (FixedType.
isNull())
return FixedType;
5552 return Qs.
apply(Context, FixedType);
5554 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
5555 QualType Inner = PTy->getInnerType();
5559 if (FixedType.
isNull())
return FixedType;
5561 return Qs.
apply(Context, FixedType);
5579 if (Res.isSigned() && Res.isNegative()) {
5580 SizeIsNegative =
true;
5585 unsigned ActiveSizeBits
5619 TypeLoc DstElemTL = DstATL.getElementLoc();
5632 bool &SizeIsNegative,
5633 llvm::APSInt &Oversized) {
5636 SizeIsNegative, Oversized);
5663 return Result.empty() ? nullptr : *Result.begin();
5673 diag::err_virtual_non_function);
5677 diag::err_explicit_non_function);
5681 diag::err_noreturn_non_function);
5701 << getLangOpts().CPlusPlus17;
5709 diag::err_deduction_guide_invalid_specifier)
5718 if (!NewTD)
return nullptr;
5721 ProcessDeclAttributes(S, NewTD, D);
5723 CheckTypedefForVariablyModifiedType(S, NewTD);
5726 NamedDecl *ND = ActOnTypedefNameDecl(S, DC, NewTD, Previous, Redeclaration);
5740 setFunctionHasBranchProtectedScope();
5743 bool SizeIsNegative;
5744 llvm::APSInt Oversized;
5757 else if (Oversized.getBoolValue())
5759 << Oversized.toString(10);
5776 NamedDecl *ShadowedDecl = getShadowedDeclaration(NewTD, Previous);
5780 FilterLookupForScope(Previous, DC, S,
false,
5783 if (!Previous.
empty()) {
5784 Redeclaration =
true;
5785 MergeTypedefNameDecl(S, NewTD, Previous);
5788 if (ShadowedDecl && !Redeclaration)
5789 CheckShadow(NewTD, ShadowedDecl, Previous);
5795 if (II->isStr(
"FILE"))
5797 else if (II->isStr(
"jmp_buf"))
5799 else if (II->isStr(
"sigjmp_buf"))
5801 else if (II->isStr(
"ucontext_t"))
5859 if (!OuterContext->
Equals(PrevOuterContext))
5868 if (!SS.
isSet())
return;
5877 unsigned kind = -1U;
5878 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5879 if (var->hasAttr<BlocksAttr>())
5881 else if (!var->hasLocalStorage())
5883 }
else if (isa<ObjCIvarDecl>(decl)) {
5885 }
else if (isa<FieldDecl>(decl)) {
5903 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5906 var->getTLSKind()) {
5907 Diag(var->getLocation(), diag::err_arc_thread_ownership)
5928 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
5936 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
5937 if (VD->hasInit()) {
5938 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
5939 assert(VD->isThisDeclarationADefinition() &&
5940 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
5942 VD->dropAttr<AliasAttr>();
5949 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
5952 diag::err_attribute_selectany_non_extern_data);
5960 auto *VD = dyn_cast<
VarDecl>(&ND);
5970 if (
auto *MD = dyn_cast<CXXMethodDecl>(&ND))
5971 if (MD->isVirtual()) {
5973 diag::err_invalid_attribute_on_virtual_function)
5979 if (
const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
5984 for (
TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
5990 if (
const auto *A = ATL.
getAttrAs<LifetimeBoundAttr>()) {
5992 if (!MD || MD->isStatic()) {
5993 S.
Diag(A->getLocation(), diag::err_lifetimebound_no_object_param)
5994 << !MD << A->getRange();
5995 }
else if (isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD)) {
5996 S.
Diag(A->getLocation(), diag::err_lifetimebound_ctor_dtor)
5997 << isa<CXXDestructorDecl>(MD) << A->getRange();
6006 bool IsSpecialization,
6007 bool IsDefinition) {
6011 bool IsTemplate =
false;
6012 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
6013 OldDecl = OldTD->getTemplatedDecl();
6015 if (!IsSpecialization)
6016 IsDefinition =
false;
6018 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
6019 NewDecl = NewTD->getTemplatedDecl();
6023 if (!OldDecl || !NewDecl)
6026 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
6027 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
6028 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
6029 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
6033 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
6034 (NewExportAttr && !NewExportAttr->isInherited());
6040 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
6042 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
6044 bool JustWarn =
false;
6046 auto *VD = dyn_cast<
VarDecl>(OldDecl);
6047 if (VD && !VD->getDescribedVarTemplate())
6058 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
6061 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
6062 : diag::err_attribute_dll_redeclaration;
6065 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
6078 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
6080 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
6083 IsStaticDataMember = VD->isStaticDataMember();
6084 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
6086 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
6087 IsInline = FD->isInlined();
6088 IsQualifiedFriend = FD->getQualifier() &&
6092 if (OldImportAttr && !HasNewAttr &&
6093 (!IsInline || (IsMicrosoft && IsTemplate)) && !IsStaticDataMember &&
6095 if (IsMicrosoft && IsDefinition) {
6097 diag::warn_redeclaration_without_import_attribute)
6100 NewDecl->
dropAttr<DLLImportAttr>();
6102 NewImportAttr->getRange(), S.
Context,
6103 NewImportAttr->getSpellingListIndex()));
6106 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
6107 << NewDecl << OldImportAttr;
6109 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
6110 OldDecl->
dropAttr<DLLImportAttr>();
6111 NewDecl->
dropAttr<DLLImportAttr>();
6113 }
else if (IsInline && OldImportAttr && !IsMicrosoft) {
6116 OldDecl->
dropAttr<DLLImportAttr>();
6117 NewDecl->
dropAttr<DLLImportAttr>();
6119 diag::warn_dllimport_dropped_from_inline_function)
6120 << NewDecl << OldImportAttr;
6127 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
6129 !NewImportAttr && !NewExportAttr) {
6130 if (
const DLLExportAttr *ParentExportAttr =
6131 MD->getParent()->getAttr<DLLExportAttr>()) {
6132 DLLExportAttr *NewAttr = ParentExportAttr->clone(S.
Context);
6133 NewAttr->setInherited(
true);
6173 template<
typename T>
6177 if (!D->isInExternCContext() || D->template hasAttr<OverloadableAttr>())
6181 if (S.
getLangOpts().CUDA && (D->template hasAttr<CUDADeviceAttr>() ||
6182 D->template hasAttr<CUDAHostAttr>()))
6185 return D->isExternC();
6196 llvm_unreachable(
"Unexpected context");
6202 isa<OMPDeclareReductionDecl>(DC))
6206 llvm_unreachable(
"Unexpected context");
6252 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
6253 return FD->isExternC();
6254 if (
const auto *VD = dyn_cast<VarDecl>(D))
6255 return VD->isExternC();
6257 llvm_unreachable(
"Unknown type of decl!");
6273 if (!Decomp.bindings().empty()) {
6274 II = Decomp.bindings()[0].Name;
6282 if (getLangOpts().OpenCL) {
6288 diag::err_opencl_type_can_only_be_used_as_function_parameter)
6301 diag::err_invalid_type_for_program_scope_var) << R;
6318 if (!getOpenCLOptions().
isEnabled(
"cl_khr_fp16")) {
6362 bool IsCXX = getLangOpts().OpenCLCPlusPlus;
6364 diag::err_opencl_unknown_type_specifier)
6365 << IsCXX << getLangOpts().getOpenCLVersionTuple().getAsString()
6383 bool IsLocalExternDecl = SC ==
SC_Extern &&
6384 adjustContextForLocalExternDecl(DC);
6395 !D.
getAsmLabel() && !getSourceManager().isInSystemMacro(
6401 getLangOpts().CPlusPlus17 ? diag::ext_register_storage_class
6402 : diag::warn_deprecated_register)
6418 bool IsMemberSpecialization =
false;
6419 bool IsVariableTemplateSpecialization =
false;
6421 bool IsVariableTemplate =
false;
6429 if (R->getContainedDeducedType())
6430 ParsingInitForAutoVars.insert(NewVD);
6435 bool Invalid =
false;
6437 if (DC->
isRecord() && !CurContext->isRecord()) {
6444 diag::err_static_out_of_line)
6456 diag::err_storage_class_for_static_member)
6460 llvm_unreachable(
"C storage class in c++!");
6464 if (SC ==
SC_Static && CurContext->isRecord()) {
6465 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
6466 if (RD->isLocalClass())
6468 diag::err_static_data_member_not_allowed_in_local_class)
6469 << Name << RD->getDeclName();
6475 getLangOpts().CPlusPlus11
6476 ? diag::warn_cxx98_compat_static_data_member_in_union
6477 : diag::ext_static_data_member_in_union) << Name;
6479 else if (!RD->getDeclName())
6481 diag::err_static_data_member_not_allowed_in_anon_struct)
6482 << Name << RD->isUnion();
6488 TemplateParams = MatchTemplateParametersToScopeSpecifier(
6495 false, IsMemberSpecialization, Invalid);
6497 if (TemplateParams) {
6498 if (!TemplateParams->
size() &&
6503 diag::err_template_variable_noparams)
6507 TemplateParams =
nullptr;
6512 IsVariableTemplateSpecialization =
true;
6513 IsPartialSpecialization = TemplateParams->
size() > 0;
6516 IsVariableTemplate =
true;
6519 if (CheckTemplateDeclScope(S, TemplateParams))
6524 getLangOpts().CPlusPlus14
6525 ? diag::warn_cxx11_compat_variable_template
6526 : diag::ext_variable_template);
6532 "should have a 'template<>' for this decl");
6535 if (IsVariableTemplateSpecialization) {
6537 TemplateParamLists.size() > 0
6538 ? TemplateParamLists[0]->getTemplateLoc()
6540 DeclResult Res = ActOnVarTemplateSpecialization(
6541 S, D, TInfo, TemplateKWLoc, TemplateParams, SC,
6542 IsPartialSpecialization);
6545 NewVD = cast<VarDecl>(Res.
get());
6556 if (IsVariableTemplate) {
6559 TemplateParams, NewVD);
6560 NewVD->setDescribedVarTemplate(NewTemplate);
6565 if (R->getContainedDeducedType())
6566 ParsingInitForAutoVars.insert(NewVD);
6578 unsigned VDTemplateParamLists = TemplateParams ? 1 : 0;
6579 if (TemplateParamLists.size() > VDTemplateParamLists)
6580 NewVD->setTemplateParameterListsInfo(
6581 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
6584 NewVD->setConstexpr(
true);
6588 if (NewVD->isStaticDataMember() && getLangOpts().CPlusPlus17)
6589 NewVD->setImplicitlyInline();
6594 if (!getLangOpts().CPlusPlus) {
6597 }
else if (CurContext->isFunctionOrMethod()) {
6600 diag::err_inline_declaration_block_scope) << Name
6604 getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_inline_variable
6605 : diag::ext_inline_variable);
6616 if (IsLocalExternDecl) {
6618 for (
auto *B : Bindings)
6619 B->setLocalExternDecl();
6624 bool EmitTLSUnsupportedError =
false;
6637 diag::err_thread_non_global)
6640 if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
6644 EmitTLSUnsupportedError =
true;
6651 diag::err_thread_unsupported);
6670 diag::warn_static_local_in_extern_inline);
6671 MaybeSuggestAddingStaticToDecl(CurFD);
6676 if (IsVariableTemplateSpecialization)
6678 << (IsPartialSpecialization ? 1 : 0)
6681 else if (IsMemberSpecialization)
6694 for (
auto *B : Bindings)
6695 B->setModulePrivate();
6700 ProcessDeclAttributes(S, NewVD, D);
6702 if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
6703 if (EmitTLSUnsupportedError &&
6705 (getLangOpts().OpenMPIsDevice &&
6706 NewVD->
hasAttr<OMPDeclareTargetDeclAttr>())))
6708 diag::err_thread_unsupported);
6712 (NewVD->
hasAttr<CUDASharedAttr>() ||
6713 NewVD->
hasAttr<CUDAConstantAttr>())) {
6721 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
6722 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
6727 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewVD))
6739 Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
6745 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6756 bool HasSizeMismatch;
6758 if (!TI.isValidGCCRegisterName(Label))
6759 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6760 else if (!TI.validateGlobalRegisterVariable(Label,
6763 Diag(E->getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
6764 else if (HasSizeMismatch)
6765 Diag(E->getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
6775 Context,
Label, 0));
6776 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
6777 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
6779 if (I != ExtnameUndeclaredIdentifiers.end()) {
6782 ExtnameUndeclaredIdentifiers.erase(I);
6791 ? getShadowedDeclaration(NewVD, Previous)
6799 IsMemberSpecialization ||
6800 IsVariableTemplateSpecialization);
6804 if (getLangOpts().CPlusPlus &&
6808 isDeclInScope(Previous.
getFoundDecl(), OriginalDC, S,
false));
6810 if (!getLangOpts().CPlusPlus) {
6815 CheckMemberSpecialization(NewVD, Previous))
6819 if (!Previous.
empty()) {
6838 if (!IsVariableTemplateSpecialization)
6850 if (CheckTemplateParameterList(
6856 ? TPC_ClassTemplateMember
6862 if (PrevVarTemplate &&
6870 CheckShadow(NewVD, ShadowedDecl, Previous);
6872 ProcessPragmaWeak(S, NewVD);
6878 RegisterLocallyScopedExternCDecl(NewVD, S);
6881 Decl *ManglingContextDecl;
6885 NewVD, MCtx->getManglingNumber(
6898 if (getLangOpts().CPlusPlus)
6916 ActOnDocumentableDecl(NewTemplate);
6921 CompleteMemberSpecialization(NewVD, Previous);
6939 if (isa<TypeAliasDecl>(ShadowedDecl))
6941 else if (isa<TypedefDecl>(ShadowedDecl))
6943 else if (isa<RecordDecl>(OldDC))
6982 return isa<VarDecl>(ShadowedDecl) || isa<FieldDecl>(ShadowedDecl)
6999 return isa<TypedefNameDecl>(ShadowedDecl) ? ShadowedDecl :
nullptr;
7015 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
7023 if (isa<CXXConstructorDecl>(NewDC))
7024 if (
const auto PVD = dyn_cast<ParmVarDecl>(D)) {
7027 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
7032 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
7033 if (shadowedVar->isExternC()) {
7036 for (
auto I : shadowedVar->redecls())
7037 if (I->isFileVarDecl()) {
7045 unsigned WarningDiag = diag::warn_decl_shadow;
7047 if (isa<VarDecl>(D) && isa<VarDecl>(ShadowedDecl) && NewDC &&
7048 isa<CXXMethodDecl>(NewDC)) {
7049 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
7051 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
7053 const auto *LSI = cast<LambdaScopeInfo>(getCurFunction());
7056 if (CaptureLoc.isInvalid())
7057 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
7061 cast<LambdaScopeInfo>(getCurFunction())
7062 ->ShadowingDecls.push_back(
7063 {cast<VarDecl>(D), cast<VarDecl>(ShadowedDecl)});
7068 if (cast<VarDecl>(ShadowedDecl)->hasLocalStorage()) {
7072 ParentDC && !ParentDC->
Equals(OldDC);
7076 if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) &&
7103 if (getSourceManager().isInSystemMacro(R.
getNameLoc()))
7108 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7117 const VarDecl *ShadowedDecl = Shadow.ShadowedDecl;
7122 ? diag::warn_decl_shadow_uncaptured_local
7123 : diag::warn_decl_shadow)
7124 << Shadow.VD->getDeclName()
7127 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7128 << Shadow.VD->getDeclName() << 0;
7135 if (Diags.isIgnored(diag::warn_decl_shadow, D->
getLocation()))
7141 if (
NamedDecl *ShadowedDecl = getShadowedDeclaration(D, R))
7142 CheckShadow(D, ShadowedDecl, R);
7149 if (!getLangOpts().
CPlusPlus || ShadowingDecls.empty())
7155 const NamedDecl *D = cast<NamedDecl>(DRE->getDecl()->getCanonicalDecl());
7156 auto I = ShadowingDecls.find(D);
7157 if (I == ShadowingDecls.end())
7159 const NamedDecl *ShadowedDecl = I->second;
7161 Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
7166 ShadowingDecls.erase(I);
7171 template<
typename T>
7174 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
7195 if (!isa<VarDecl>(ND))
7205 if (isa<VarDecl>(*I)) {
7215 if (isa<VarDecl>(*I)) {
7233 assert(Prev &&
"should have found a previous declaration to diagnose");
7235 Prev = FD->getFirstDecl();
7237 Prev = cast<VarDecl>(Prev)->getFirstDecl();
7239 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
7241 S.
Diag(Prev->getLocation(), diag::note_extern_c_global_conflict)
7254 template<
typename T>
7261 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
7273 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
7298 CheckAlignasUnderalignment(NewVD);
7320 if (getLangOpts().OpenCLVersion == 120 &&
7321 !getOpenCLOptions().
isEnabled(
"cl_clang_storage_class_specifiers") &&
7328 if (getLangOpts().OpenCL) {
7330 if (NewVD->
hasAttr<BlocksAttr>()) {
7339 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
7345 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
7363 (getLangOpts().OpenCLVersion == 200 ||
7364 getLangOpts().OpenCLCPlusPlus)))) {
7366 if (getLangOpts().OpenCLVersion == 200 || getLangOpts().OpenCLCPlusPlus)
7367 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7368 << Scope <<
"global or constant";
7370 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7371 << Scope <<
"constant";
7387 if (FD && !FD->
hasAttr<OpenCLKernelAttr>()) {
7399 if (FD && FD->
hasAttr<OpenCLKernelAttr>()) {
7400 if (!getCurScope()->isFunctionScope()) {
7421 && !NewVD->
hasAttr<BlocksAttr>()) {
7425 assert(!getLangOpts().ObjCAutoRefCount);
7431 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
7433 setFunctionHasBranchProtectedScope();
7437 bool SizeIsNegative;
7438 llvm::APSInt Oversized;
7443 FixedT = FixedTInfo->
getType();
7444 else if (FixedTInfo) {
7500 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
7508 diag::err_constexpr_var_non_literal)) {
7527 CheckVariableDeclarationType(NewVD);
7535 if (Previous.
empty() &&
7539 if (!Previous.
empty()) {
7540 MergeVarDecl(NewVD, Previous);
7547 struct FindOverriddenMethod {
7573 if (MD->isVirtual() && !S->
IsOverload(Method, MD,
false))
7598 if ((OEK == OEK_All) ||
7599 (OEK == OEK_NonDeleted && !O->isDeleted()) ||
7600 (OEK == OEK_Deleted && O->isDeleted()))
7601 S.
Diag(O->getLocation(), diag::note_overridden_virtual_function);
7610 FindOverriddenMethod FOM;
7613 bool hasDeletedOverridenMethods =
false;
7614 bool hasNonDeletedOverridenMethods =
false;
7615 bool AddedAny =
false;
7620 if (!CheckOverridingFunctionReturnType(MD, OldMD) &&
7621 !CheckOverridingFunctionAttributes(MD, OldMD) &&
7622 !CheckOverridingFunctionExceptionSpec(MD, OldMD) &&
7623 !CheckIfOverriddenFunctionIsMarkedFinal(MD, OldMD)) {
7624 hasDeletedOverridenMethods |= OldMD->isDeleted();
7625 hasNonDeletedOverridenMethods |= !OldMD->isDeleted();
7632 if (hasDeletedOverridenMethods && !MD->
isDeleted()) {
7633 ReportOverrides(*
this, diag::err_non_deleted_override, MD, OEK_Deleted);
7635 if (hasNonDeletedOverridenMethods && MD->
isDeleted()) {
7636 ReportOverrides(*
this, diag::err_deleted_override, MD, OEK_NonDeleted);
7645 struct ActOnFDArgs {
7661 : Context(Context), OriginalFD(TypoFD),
7664 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
7670 CDeclEnd = candidate.
end();
7671 CDecl != CDeclEnd; ++CDecl) {
7680 }
else if (!ExpectedParent) {
7698 TypoCorrectedFunctionDefinitions.insert(F);
7712 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *S) {
7718 bool IsDefinition = ExtraArgs.D.isFunctionDefinition();
7720 IsLocalFriend ? diag::err_no_matching_local_friend :
7722 diag::err_member_decl_does_not_match;
7733 assert(!Prev.isAmbiguous() &&
7734 "Cannot have an ambiguity in previous-declaration lookup");
7736 if (!Prev.empty()) {
7738 Func != FuncEnd; ++Func) {
7745 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
7746 NearMatches.push_back(std::make_pair(FD, ParamNum));
7751 Prev.getLookupNameInfo(), Prev.getLookupKind(), S,
7752 &ExtraArgs.D.getCXXScopeSpec(),
7753 llvm::make_unique<DifferentNameValidatorCCC>(
7758 ExtraArgs.D.getIdentifierLoc());
7762 CDeclEnd = Correction.
end();
7763 CDecl != CDeclEnd; ++CDecl) {
7770 bool wasRedeclaration = ExtraArgs.D.isRedeclaration();
7783 ExtraArgs.S, ExtraArgs.D,
7786 ExtraArgs.AddToScope);
7797 if ((*I)->getCanonicalDecl() == Canonical)
7804 SemaRef.
PDiag(IsLocalFriend
7805 ? diag::err_no_matching_local_friend_suggest
7806 : diag::err_member_decl_does_not_match_suggest)
7807 << Name << NewDC << IsDefinition);
7813 ExtraArgs.D.getIdentifierLoc());
7814 ExtraArgs.D.setRedeclaration(wasRedeclaration);
7820 << Name << NewDC << IsDefinition << NewFD->
getLocation();
7822 bool NewFDisConst =
false;
7824 NewFDisConst = NewMD->isConst();
7827 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
7828 NearMatch != NearMatchEnd; ++NearMatch) {
7831 bool FDisConst = MD && MD->
isConst();
7832 bool IsMember = MD || !IsLocalFriend;
7835 if (
unsigned Idx = NearMatch->second) {
7839 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
7840 : diag::note_local_decl_close_param_match)
7843 }
else if (FDisConst != NewFDisConst) {
7844 SemaRef.
Diag(FD->
getLocation(), diag::note_member_def_close_const_match)
7848 IsMember ? diag::note_member_def_close_match
7849 : diag::note_local_decl_close_match);
7856 default: llvm_unreachable(
"Unknown storage class!");
7861 diag::err_typecheck_sclass_func);
7878 diag::err_static_block_func);
7894 bool &IsVirtualOkay) {
7913 R, TInfo, SC, isInline, HasPrototype,
false);
7935 "Constructors can only be declared in a member context");
7940 TInfo, isExplicit, isInline,
7941 false, isConstexpr);
7950 NameInfo, R, TInfo, isInline,
7959 IsVirtualOkay =
true;
7977 diag::err_conv_function_not_member);
7982 IsVirtualOkay =
true;
7991 isExplicit, NameInfo, R, TInfo,
8022 R, TInfo, SC, isInline,
true ,
8040 StringRef SizeTypeNames[] = {
"size_t",
"intptr_t",
"uintptr_t",
"ptrdiff_t"};
8048 std::find(Names.begin(), Names.end(), DesugaredTy.
getAsString());
8049 if (Names.end() != Match)
8054 }
while (DesugaredTy != Ty);
8110 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
8157 S.
Diag(Loc, diag::note_entity_declared_at) << PT;
8180 HistoryStack.push_back(
nullptr);
8189 VisitStack.push_back(RecTy->
getDecl());
8190 assert(VisitStack.back() &&
"First decl null?");
8193 const Decl *Next = VisitStack.pop_back_val();
8195 assert(!HistoryStack.empty());
8197 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
8198 ValidTypes.insert(Hist->getType().getTypePtr());
8206 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(Next)) {
8207 HistoryStack.push_back(Field);
8209 QualType FieldTy = Field->getType();
8213 "Unexpected type.");
8218 RD = cast<RecordDecl>(Next);
8222 VisitStack.push_back(
nullptr);
8224 for (
const auto *FD : RD->
fields()) {
8235 VisitStack.push_back(FD);
8246 diag::err_record_with_pointers_kernel_param)
8253 S.
Diag(OrigRecDecl->getLocation(), diag::note_within_field_of_type)
8254 << OrigRecDecl->getDeclName();
8259 I = HistoryStack.begin() + 1,
8260 E = HistoryStack.end();
8267 S.
Diag(FD->getLocation(), diag::note_illegal_field_declared_here)
8273 }
while (!VisitStack.empty());
8290 (LangOpts.CPlusPlus &&
8314 diag::err_invalid_thread)
8321 bool isFriend =
false;
8323 bool isMemberSpecialization =
false;
8324 bool isFunctionTemplateSpecialization =
false;
8326 bool isDependentClassScopeExplicitSpecialization =
false;
8327 bool HasExplicitTemplateArgs =
false;
8330 bool isVirtualOkay =
false;
8333 bool IsLocalExternDecl = adjustContextForLocalExternDecl(DC);
8337 if (!NewFD)
return nullptr;
8339 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer())
8347 if (IsLocalExternDecl)
8368 if (
Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
8373 if (isVirtual &&
Parent->isUnion())
8378 isMemberSpecialization =
false;
8379 isFunctionTemplateSpecialization =
false;
8385 bool Invalid =
false;
8387 MatchTemplateParametersToScopeSpecifier(
8393 TemplateParamLists, isFriend, isMemberSpecialization,
8395 if (TemplateParams->size() > 0) {
8399 if (CheckTemplateDeclScope(S, TemplateParams))
8413 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
8419 Name, TemplateParams,
8425 if (TemplateParamLists.size() > 1) {
8427 TemplateParamLists.drop_back(1));
8431 isFunctionTemplateSpecialization =
true;
8433 if (TemplateParamLists.size() > 0)
8439 SourceRange RemoveRange = TemplateParams->getSourceRange();
8449 InsertLoc = getLocForEndOfToken(InsertLoc);
8453 << Name << RemoveRange
8461 if (TemplateParamLists.size() > 0)
8468 if (FunctionTemplate)
8478 if (!isVirtualOkay) {
8480 diag::err_virtual_non_function);
8481 }
else if (!CurContext->isRecord()) {
8484 diag::err_virtual_out_of_class)
8490 diag::err_virtual_member_function_template)
8502 if (getLangOpts().CPlusPlus14 &&
8504 (isFriend && CurContext->isDependentContext())) &&
8524 if (CurContext->isFunctionOrMethod()) {
8527 diag::err_inline_declaration_block_scope) << Name
8537 !isa<CXXDeductionGuideDecl>(NewFD)) {
8538 if (!CurContext->isRecord()) {
8541 diag::err_explicit_out_of_class)
8543 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
8544 !isa<CXXConversionDecl>(NewFD)) {
8548 diag::err_explicit_non_ctor_or_conv_function)
8561 if (isa<CXXDestructorDecl>(NewFD))
8567 if (isFunctionTemplateSpecialization) {
8570 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
8575 if (FunctionTemplate)
8581 if (FunctionTemplate) {
8606 if (isa<CXXMethodDecl>(NewFD) && DC == CurContext &&
8614 if (SC ==
SC_Static && isa<CXXMethodDecl>(NewFD) &&
8615 !CurContext->isRecord()) {
8624 diag::err_static_out_of_line)
8634 getLangOpts().CPlusPlus11 && FPT && !FPT->hasExceptionSpec())
8636 FPT->getReturnType(), FPT->getParamTypes(),
8643 isMemberSpecialization ||
8644 isFunctionTemplateSpecialization);
8652 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
8653 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
8655 if (I != ExtnameUndeclaredIdentifiers.end()) {
8658 ExtnameUndeclaredIdentifiers.erase(I);
8678 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
8682 Params.push_back(Param);
8697 auto *TD = dyn_cast<
TagDecl>(NonParmDecl);
8702 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
8703 TD = cast<EnumDecl>(ECD->getDeclContext());
8711 TD->setDeclContext(NewFD);
8719 if (TagDC != PrototypeTagContext)
8720 TD->setLexicalDeclContext(TagDC);
8734 for (
const auto &AI : FT->param_types()) {
8738 Params.push_back(Param);
8742 "Should not need args for typedef of non-prototype fn");
8746 NewFD->setParams(Params);
8763 !NewFD->
hasAttr<SectionAttr>()) {
8764 NewFD->
addAttr(PragmaClangTextSectionAttr::CreateImplicit(Context,
8765 PragmaClangTextSection.SectionName,
8766 PragmaClangTextSection.PragmaLocation));
8771 !NewFD->
hasAttr<SectionAttr>()) {
8773 SectionAttr::CreateImplicit(Context, SectionAttr::Declspec_allocate,
8774 CodeSegStack.CurrentValue->getString(),
8775 CodeSegStack.CurrentPragmaLocation));
8776 if (UnifySection(CodeSegStack.CurrentValue->getString(),
8785 if (!NewFD->
hasAttr<CodeSegAttr>()) {
8786 if (
Attr *SAttr = getImplicitCodeSegOrSectionAttrForFunction(NewFD,
8793 ProcessDeclAttributes(S, NewFD, D);
8795 if (getLangOpts().OpenCL) {
8801 diag::err_opencl_return_value_with_address_space);
8812 CheckMSVCRTEntryPoint(NewFD);
8816 isMemberSpecialization));
8817 else if (!Previous.
empty())
8822 "previous declaration set still overloaded");
8834 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
8851 diag::ext_operator_new_delete_declared_inline)
8862 translateTemplateArguments(TemplateArgsPtr,
8865 HasExplicitTemplateArgs =
true;
8868 HasExplicitTemplateArgs =
false;
8869 }
else if (FunctionTemplate) {
8874 HasExplicitTemplateArgs =
false;
8876 assert((isFunctionTemplateSpecialization ||
8878 "should have a 'template<>' for this decl");
8880 isFunctionTemplateSpecialization =
true;
8882 }
else if (isFriend && isFunctionTemplateSpecialization) {
8889 HasExplicitTemplateArgs =
true;
8900 if (getLangOpts().CUDA & !isFunctionTemplateSpecialization)
8901 maybeAddCUDAHostDeviceAttrs(NewFD, Previous);
8907 bool InstantiationDependent =
false;
8908 if (isFunctionTemplateSpecialization && isFriend &&
8912 InstantiationDependent))) {
8913 assert(HasExplicitTemplateArgs &&
8914 "friend function specialization without template args");
8915 if (CheckDependentFunctionTemplateSpecialization(NewFD, TemplateArgs,
8918 }
else if (isFunctionTemplateSpecialization) {
8919 if (CurContext->isDependentContext() && CurContext->isRecord()
8921 isDependentClassScopeExplicitSpecialization =
true;
8923 CheckFunctionTemplateSpecialization(
8924 NewFD, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr),
8936 diag::err_explicit_specialization_inconsistent_storage_class)
8943 diag::ext_explicit_specialization_storage_class)
8947 }
else if (isMemberSpecialization && isa<CXXMethodDecl>(NewFD)) {
8948 if (CheckMemberSpecialization(NewFD, Previous))
8953 if (!isDependentClassScopeExplicitSpecialization) {
8958 CheckMSVCRTEntryPoint(NewFD);
8962 isMemberSpecialization));
8963 else if (!Previous.
empty())
8970 "previous declaration set still overloaded");
8972 NamedDecl *PrincipalDecl = (FunctionTemplate
8973 ? cast<NamedDecl>(FunctionTemplate)
8982 if (FunctionTemplate) FunctionTemplate->
setAccess(Access);
8991 if (FunctionTemplate) {
8999 ? TPC_FriendFunctionTemplateDefinition
9000 : TPC_FriendFunctionTemplate)
9004 ? TPC_ClassTemplateMember
9005 : TPC_FunctionTemplate);
9011 struct ActOnFDArgs ExtraArgs = { S, D, TemplateParamLists,
9034 (!Previous.
empty() && (TemplateParamLists.size() ||
9035 CurContext->isDependentContext())))) {
9054 *
this, Previous, NewFD, ExtraArgs,
false,
nullptr)) {
9055 AddToScope = ExtraArgs.AddToScope;
9062 }
else if (isFriend && cast<CXXRecordDecl>(CurContext)->isLocalClass()) {
9064 *
this, Previous, NewFD, ExtraArgs,
true, S)) {
9065 AddToScope = ExtraArgs.AddToScope;
9070 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
9071 !isFriend && !isFunctionTemplateSpecialization &&
9072 !isMemberSpecialization) {
9085 ProcessPragmaWeak(S, NewFD);
9088 AddKnownFunctionAttributes(NewFD);
9090 if (NewFD->
hasAttr<OverloadableAttr>() &&
9093 diag::err_attribute_overloadable_no_prototype)
9101 EPI.ExtInfo = FT->getExtInfo();
9110 AddPushedVisibilityAttribute(NewFD);
9114 AddCFAuditedAttribute(NewFD);
9119 AddRangeBasedOptnone(NewFD);
9125 RegisterLocallyScopedExternCDecl(NewFD, S);
9133 isMemberSpecialization ||
9134 isFunctionTemplateSpecialization,
9138 if (getLangOpts().CUDA) {
9141 II->
isStr(getLangOpts().HIP ?
"hipConfigureCall" 9142 :
"cudaConfigureCall") &&
9153 if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->
isVariadic() &&
9154 (NewFD->
hasAttr<CUDADeviceAttr>() ||
9155 NewFD->
hasAttr<CUDAGlobalAttr>()) &&
9162 MarkUnusedFileScopedDecl(NewFD);
9165 if (FunctionTemplate) {
9168 return FunctionTemplate;
9172 CompleteMemberSpecialization(NewFD, Previous);
9175 if (NewFD->
hasAttr<OpenCLKernelAttr>()) {
9177 if ((getLangOpts().OpenCLVersion >= 120)
9192 llvm::SmallPtrSet<const Type *, 16> ValidTypes;
9201 if (getLangOpts().OpenCLVersion >= 200) {
9203 QualType ElemTy = PipeTy->getElementType();
9205 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type );
9215 if (isDependentClassScopeExplicitSpecialization) {
9219 cast<CXXMethodDecl>(NewFD),
9220 HasExplicitTemplateArgs, TemplateArgs);
9221 CurContext->addDecl(NewSpec);
9227 if (
const auto *attr = NewFD->
getAttr<AvailabilityAttr>()) {
9228 if (NewFD->
hasAttr<ConstructorAttr>()) {
9229 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer)
9231 NewFD->
dropAttr<AvailabilityAttr>();
9233 if (NewFD->
hasAttr<DestructorAttr>()) {
9234 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer)
9236 NewFD->
dropAttr<AvailabilityAttr>();
9258 if (
const auto *SAttr = Parent->
getAttr<CodeSegAttr>()) {
9269 while ((Parent = dyn_cast<CXXRecordDecl>(Parent->
getParent()))) {
9270 if (
const auto *SAttr = Parent->
getAttr<CodeSegAttr>()) {
9289 bool IsDefinition) {
9292 if (!FD->
hasAttr<SectionAttr>() && IsDefinition &&
9293 CodeSegStack.CurrentValue) {
9294 return SectionAttr::CreateImplicit(getASTContext(),
9295 SectionAttr::Declspec_allocate,
9296 CodeSegStack.CurrentValue->getString(),
9297 CodeSegStack.CurrentPragmaLocation);
9364 auto *PrevVD = dyn_cast<
ValueDecl>(PrevDecl);
9365 return !VD || !PrevVD ||
9366 canFullyTypeCheckRedeclaration(VD, PrevVD, VD->getType(),
9375 const auto *TA = FD->
getAttr<TargetAttr>();
9376 assert(TA &&
"MultiVersion Candidate requires a target attribute");
9377 TargetAttr::ParsedTargetAttr ParseInfo = TA->parse();
9379 enum ErrType { Feature = 0, Architecture = 1 };
9381 if (!ParseInfo.Architecture.empty() &&
9384 << Architecture << ParseInfo.Architecture;
9388 for (
const auto &Feat : ParseInfo.Features) {
9389 auto BareFeat = StringRef{Feat}.substr(1);
9390 if (Feat[0] ==
'-') {
9392 << Feature << (
"no-" + BareFeat).str();
9399 << Feature << BareFeat;
9409 switch (A->getKind()) {
9410 case attr::CPUDispatch:
9411 case attr::CPUSpecific:
9431 enum DoesntSupport {
9450 bool IsCPUSpecificCPUDispatchMVType =
9474 << IsCPUSpecificCPUDispatchMVType;
9480 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_no_other_attrs)
9481 << IsCPUSpecificCPUDispatchMVType;
9484 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_doesnt_support)
9485 << IsCPUSpecificCPUDispatchMVType << FuncTemplates;
9487 if (
const auto *NewCXXFD = dyn_cast<CXXMethodDecl>(NewFD)) {
9488 if (NewCXXFD->isVirtual())
9489 return S.
Diag(NewCXXFD->getLocation(),
9490 diag::err_multiversion_doesnt_support)
9491 << IsCPUSpecificCPUDispatchMVType << VirtFuncs;
9493 if (
const auto *NewCXXCtor = dyn_cast<CXXConstructorDecl>(NewFD))
9494 return S.
Diag(NewCXXCtor->getLocation(),
9495 diag::err_multiversion_doesnt_support)
9496 << IsCPUSpecificCPUDispatchMVType << Constructors;
9498 if (
const auto *NewCXXDtor = dyn_cast<CXXDestructorDecl>(NewFD))
9499 return S.
Diag(NewCXXDtor->getLocation(),
9500 diag::err_multiversion_doesnt_support)
9501 << IsCPUSpecificCPUDispatchMVType << Destructors;
9505 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_doesnt_support)
9506 << IsCPUSpecificCPUDispatchMVType << DeletedFuncs;
9509 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_doesnt_support)
9510 << IsCPUSpecificCPUDispatchMVType << DefaultedFuncs;
9514 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_doesnt_support)
9515 << IsCPUSpecificCPUDispatchMVType << ConstexprFuncs;
9518 const auto *NewType = cast<FunctionType>(NewQType);
9519 QualType NewReturnType = NewType->getReturnType();
9521 if (NewReturnType->isUndeducedType())
9522 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_doesnt_support)
9523 << IsCPUSpecificCPUDispatchMVType << DeducedReturn;
9526 if (OldFD && CausesMV && OldFD->
isUsed(
false))
9527 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
9532 const auto *OldType = cast<FunctionType>(OldQType);
9536 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC())
9540 QualType OldReturnType = OldType->getReturnType();
9542 if (OldReturnType != NewReturnType)
9578 const TargetAttr *TA,
9579 const CPUDispatchAttr *CPUDisp,
9580 const CPUSpecificAttr *CPUSpec) {
9582 "Function lacks multiversion attribute");
9614 bool &Redeclaration,
NamedDecl *&OldDecl,
bool &MergeTypeWithPrevious,
9616 const auto *OldTA = OldFD->
getAttr<TargetAttr>();
9617 TargetAttr::ParsedTargetAttr NewParsed = NewTA->parse();
9619 llvm::sort(NewParsed.Features);
9623 if (!NewTA->isDefaultVersion() &&
9624 (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr()))
9647 if (!OldFD->
isMultiVersion() && !OldTA && NewTA->isDefaultVersion()) {
9648 Redeclaration =
true;
9661 TargetAttr::ParsedTargetAttr OldParsed =
9662 OldTA->parse(std::less<std::string>());
9664 if (OldParsed == NewParsed) {
9671 for (
const auto *FD : OldFD->
redecls()) {
9672 const auto *CurTA = FD->getAttr<TargetAttr>();
9676 (!CurTA || CurTA->isInherited())) {
9677 S.
Diag(FD->getLocation(), diag::err_multiversion_required_in_redecl)
9687 Redeclaration =
false;
9688 MergeTypeWithPrevious =
false;
9699 const CPUDispatchAttr *NewCPUDisp,
const CPUSpecificAttr *NewCPUSpec,
9700 bool &Redeclaration,
NamedDecl *&OldDecl,
bool &MergeTypeWithPrevious,
9715 TargetAttr::ParsedTargetAttr NewParsed;
9717 NewParsed = NewTA->parse();
9718 llvm::sort(NewParsed.Features);
9721 bool UseMemberUsingDeclRules =
9730 if (S.
IsOverload(NewFD, CurFD, UseMemberUsingDeclRules))
9734 const auto *CurTA = CurFD->
getAttr<TargetAttr>();
9735 if (CurTA->getFeaturesStr() == NewTA->getFeaturesStr()) {
9737 Redeclaration =
true;
9742 TargetAttr::ParsedTargetAttr CurParsed =
9743 CurTA->parse(std::less<std::string>());
9744 if (CurParsed == NewParsed) {
9751 const auto *CurCPUSpec = CurFD->
getAttr<CPUSpecificAttr>();
9752 const auto *CurCPUDisp = CurFD->
getAttr<CPUDispatchAttr>();
9757 CurFD->
hasAttr<CPUDispatchAttr>()) {
9758 if (CurCPUDisp->cpus_size() == NewCPUDisp->cpus_size() &&
9760 CurCPUDisp->cpus_begin(), CurCPUDisp->cpus_end(),
9761 NewCPUDisp->cpus_begin(),
9763 return Cur->
getName() == New->getName();
9766 Redeclaration =
true;
9779 if (CurCPUSpec->cpus_size() == NewCPUSpec->cpus_size() &&
9781 CurCPUSpec->cpus_begin(), CurCPUSpec->cpus_end(),
9782 NewCPUSpec->cpus_begin(),
9784 return Cur->
getName() == New->getName();
9787 Redeclaration =
true;
9795 if (CurII == NewII) {
9829 Redeclaration =
true;
9835 Redeclaration =
false;
9836 MergeTypeWithPrevious =
false;
9850 bool &Redeclaration,
NamedDecl *&OldDecl,
9851 bool &MergeTypeWithPrevious,
9853 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
9854 const auto *NewCPUDisp = NewFD->
getAttr<CPUDispatchAttr>();
9855 const auto *NewCPUSpec = NewFD->
getAttr<CPUSpecificAttr>();
9858 if ((NewTA && NewCPUDisp) || (NewTA && NewCPUSpec) ||
9859 (NewCPUDisp && NewCPUSpec)) {
9873 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_not_allowed_on_main);
9897 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_required_in_redecl)
9906 Redeclaration, OldDecl,
9907 MergeTypeWithPrevious, Previous);
9913 S, OldFD, NewFD, MVType, NewTA, NewCPUDisp, NewCPUSpec, Redeclaration,
9914 OldDecl, MergeTypeWithPrevious, Previous);
9936 bool IsMemberSpecialization) {
9938 "Variably modified return types are not handled here");
9943 bool MergeTypeWithPrevious = !getLangOpts().CPlusPlus &&
9946 bool Redeclaration =
false;
9948 bool MayNeedOverloadableChecks =
false;
9952 if (!Previous.
empty()) {
9959 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
9960 Redeclaration =
true;
9961 OldDecl = Candidate;
9964 MayNeedOverloadableChecks =
true;
9965 switch (CheckOverload(S, NewFD, Previous, OldDecl,
9968 Redeclaration =
true;
9971 case Ovl_NonFunction:
9972 Redeclaration =
true;
9976 Redeclaration =
false;
9983 if (!Redeclaration &&
9985 if (!Previous.
empty()) {
9988 Redeclaration =
true;
9990 MergeTypeWithPrevious =
false;
9993 if (OldDecl->
hasAttr<OverloadableAttr>() ||
9994 NewFD->
hasAttr<OverloadableAttr>()) {
9995 if (IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
9996 MayNeedOverloadableChecks =
true;
9997 Redeclaration =
false;
10005 MergeTypeWithPrevious, Previous))
10006 return Redeclaration;
10018 if (!getLangOpts().CPlusPlus14 && MD && MD->
isConstexpr() &&
10019 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
10023 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
10024 if (!OldMD || !OldMD->
isStatic()) {
10034 if (!inTemplateInstantiation()) {
10038 AddConstLoc = getLocForEndOfToken(FTL.getRParenLoc());
10046 if (Redeclaration) {
10049 if (MergeFunctionDecl(NewFD, OldDecl, S, MergeTypeWithPrevious)) {
10051 return Redeclaration;
10058 dyn_cast<FunctionTemplateDecl>(OldDecl)) {
10059 auto *OldFD = OldTemplateDecl->getTemplatedDecl();
10062 assert(NewTemplateDecl &&
"Template/non-template mismatch");
10072 NewFD->
setAccess(OldTemplateDecl->getAccess());
10073 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
10078 if (IsMemberSpecialization &&
10081 assert(OldTemplateDecl->isMemberSpecialization());
10084 if (OldFD->isDeleted()) {
10086 assert(OldFD->getCanonicalDecl() == OldFD);
10088 OldFD->setDeletedAsWritten(
false);
10093 if (shouldLinkDependentDeclWithPrevious(NewFD, OldDecl)) {
10094 auto *OldFD = cast<FunctionDecl>(OldDecl);
10102 }
else if (!getLangOpts().CPlusPlus && MayNeedOverloadableChecks &&
10103 !NewFD->
getAttr<OverloadableAttr>()) {
10104 assert((Previous.
empty() ||
10105 llvm::any_of(Previous,
10107 return ND->
hasAttr<OverloadableAttr>();
10109 "Non-redecls shouldn't happen without overloadable present");
10111 auto OtherUnmarkedIter = llvm::find_if(Previous, [](
const NamedDecl *ND) {
10113 return FD && !FD->
hasAttr<OverloadableAttr>();
10116 if (OtherUnmarkedIter != Previous.
end()) {
10118 diag::err_attribute_overloadable_multiple_unmarked_overloads);
10119 Diag((*OtherUnmarkedIter)->getLocation(),
10120 diag::note_attribute_overloadable_prev_overload)
10123 NewFD->
addAttr(OverloadableAttr::CreateImplicit(Context));
10132 CheckConstructor(Constructor);
10134 dyn_cast<CXXDestructorDecl>(NewFD)) {
10147 return Redeclaration;
10151 = dyn_cast<CXXConversionDecl>(NewFD)) {
10152 ActOnConversionDeclarator(Conversion);
10153 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
10154 if (
auto *TD = Guide->getDescribedFunctionTemplate())
10155 CheckDeductionGuideTemplate(TD);
10160 Diag(Guide->getBeginLoc(), diag::err_deduction_guide_specialized)
10165 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
10166 if (!Method->isFunctionTemplateSpecialization() &&
10167 !Method->getDescribedFunctionTemplate() &&
10168 Method->isCanonicalDecl()) {
10169 if (AddOverriddenMethods(Method->getParent(), Method)) {
10177 if (Method->isStatic())
10178 checkThisInStaticMemberFunctionType(Method);
10183 CheckOverloadedOperatorDeclaration(NewFD)) {
10185 return Redeclaration;
10190 CheckLiteralOperatorDeclaration(NewFD)) {
10192 return Redeclaration;
10198 if (!CurContext->isRecord())
10199 CheckCXXDefaultArguments(NewFD);
10230 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
10243 auto HasNoexcept = [&](
QualType T) ->
bool {
10249 else if (T->isAnyPointerType())
10254 if (FPT->isNothrow())
10260 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
10261 for (
QualType T : FPT->param_types())
10262 AnyNoexcept |= HasNoexcept(T);
10265 diag::warn_cxx17_compat_exception_spec_in_signature)
10269 if (!Redeclaration && LangOpts.CUDA)
10270 checkCUDATargetOverload(NewFD, Previous);
10272 return Redeclaration;
10285 ? diag::err_static_main : diag::warn_static_main)
10292 SourceRange NoreturnRange(NoreturnLoc, getLocForEndOfToken(NoreturnLoc));
10293 Diag(NoreturnLoc, diag::ext_noreturn_main);
10294 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
10303 if (getLangOpts().
OpenCL) {
10305 << FD->
hasAttr<OpenCLKernelAttr>();
10311 assert(T->
isFunctionType() &&
"function decl is not of function type");
10315 if (FT->getCallConv() !=
CC_C) {
10321 if (getLangOpts().GNUMode && !getLangOpts().CPlusPlus) {
10332 if (RTRange.isValid())
10333 Diag(RTRange.getBegin(), diag::note_main_change_return_type)
10355 if (isa<FunctionNoProtoType>(FT))
return;
10361 bool HasExtraParameters = (nparams > 3);
10373 HasExtraParameters =
false;
10375 if (HasExtraParameters) {
10388 for (
unsigned i = 0; i < nparams; ++i) {
10391 bool mismatch =
true;
10395 else if (Expected[i] == CharPP) {
10408 mismatch = !qs.
empty();
10413 Diag(FD->
getLocation(), diag::err_main_arg_wrong) << i << Expected[i];
10431 assert(T->
isFunctionType() &&
"function decl is not of function type");
10436 if (FT->getReturnType()->isIntegralOrEnumerationType() ||
10437 FT->getReturnType()->isAnyPointerType() ||
10438 FT->getReturnType()->isNullPtrType())
10440 if (FD->
getName() !=
"DllMain")
10458 const Expr *Culprit;
10461 Diag(Culprit->
getExprLoc(), diag::err_init_element_not_constant)
10469 class SelfReferenceChecker
10475 bool isReferenceType;
10483 SelfReferenceChecker(
Sema &S,
Decl *OrigDecl) : Inherited(S.
Context),
10484 S(S), OrigDecl(OrigDecl) {
10486 isRecordType =
false;
10487 isReferenceType =
false;
10488 isInitList =
false;
10489 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
10490 isPODType = VD->getType().isPODType(S.
Context);
10491 isRecordType = VD->getType()->isRecordType();
10492 isReferenceType = VD->getType()->isReferenceType();
10499 void CheckExpr(
Expr *E) {
10508 InitFieldIndex.push_back(0);
10509 for (
auto Child : InitList->
children()) {
10510 CheckExpr(cast<Expr>(Child));
10511 ++InitFieldIndex.back();
10513 InitFieldIndex.pop_back();
10518 bool CheckInitListMemberExpr(
MemberExpr *E,
bool CheckReference) {
10521 bool ReferenceField =
false;
10524 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
10528 Fields.push_back(FD);
10530 ReferenceField =
true;
10536 if (!DRE || DRE->
getDecl() != OrigDecl)
10540 if (CheckReference && !ReferenceField)
10545 for (
const FieldDecl *I : llvm::reverse(Fields))
10546 UsedFieldIndex.push_back(I->getFieldIndex());
10551 for (
auto UsedIter = UsedFieldIndex.begin(),
10552 UsedEnd = UsedFieldIndex.end(),
10553 OrigIter = InitFieldIndex.begin(),
10554 OrigEnd = InitFieldIndex.end();
10555 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
10556 if (*UsedIter < *OrigIter)
10558 if (*UsedIter > *OrigIter)
10563 HandleDeclRefExpr(DRE);
10570 void HandleValue(
Expr *E) {
10572 if (
DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
10573 HandleDeclRefExpr(DRE);
10578 Visit(CO->getCond());
10579 HandleValue(CO->getTrueExpr());
10580 HandleValue(CO->getFalseExpr());
10585 dyn_cast<BinaryConditionalOperator>(E)) {
10586 Visit(BCO->getCond());
10587 HandleValue(BCO->getFalseExpr());
10592 HandleValue(OVE->getSourceExpr());
10597 if (BO->getOpcode() == BO_Comma) {
10598 Visit(BO->getLHS());
10599 HandleValue(BO->getRHS());
10604 if (isa<MemberExpr>(E)) {
10606 if (CheckInitListMemberExpr(cast<MemberExpr>(E),
10612 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
10614 if (!isa<FieldDecl>(ME->getMemberDecl()))
10618 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base))
10619 HandleDeclRefExpr(DRE);
10629 if (isReferenceType)
10630 HandleDeclRefExpr(E);
10639 Inherited::VisitImplicitCastExpr(E);
10644 if (CheckInitListMemberExpr(E,
true ))
10654 bool Warn = (MD && !MD->
isStatic());
10656 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
10657 if (!isa<FieldDecl>(ME->getMemberDecl()))
10662 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
10664 HandleDeclRefExpr(DRE);
10676 if (isa<UnresolvedLookupExpr>(Callee))
10677 return Inherited::VisitCXXOperatorCallExpr(E);
10681 HandleValue(Arg->IgnoreParenImpCasts());
10686 if (E->
getOpcode() == UO_AddrOf && isRecordType &&
10698 Inherited::VisitUnaryOperator(E);
10706 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
10707 if (ILE->getNumInits() == 1)
10708 ArgExpr = ILE->getInit(0);
10710 if (ICE->getCastKind() == CK_NoOp)
10711 ArgExpr = ICE->getSubExpr();
10712 HandleValue(ArgExpr);
10715 Inherited::VisitCXXConstructExpr(E);
10721 HandleValue(E->
getArg(0));
10725 Inherited::VisitCallExpr(E);
10730 HandleValue(E->
getLHS());
10735 Inherited::VisitBinaryOperator(E);
10748 if (OrigDecl != ReferenceDecl)
return;
10750 if (isReferenceType) {
10751 diag = diag::warn_uninit_self_reference_in_reference_init;
10752 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
10753 diag = diag::warn_static_self_reference_in_init;
10754 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
10757 diag = diag::warn_uninit_self_reference_in_init;
10771 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *E,
10775 if (isa<ParmVarDecl>(OrigDecl))
10782 if (!DirectInit && !cast<VarDecl>(OrigDecl)->getType()->
isRecordType())
10784 if (ICE->getCastKind() == CK_LValueToRValue)
10785 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
10786 if (DRE->getDecl() == OrigDecl)
10789 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
10796 struct VarDeclOrName {
10802 return VN.VDecl ? Diag << VN.VDecl : Diag << VN.Name;
10812 bool IsInitCapture = !VDecl;
10814 "init captures are expected to be deduced prior to initialization");
10816 VarDeclOrName VN{VDecl, Name};
10819 assert(Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
10823 assert(VDecl &&
"no init for init capture deduction?");
10827 if (!isa<DeducedTemplateSpecializationType>(Deduced) ||
10838 DeduceInits = Init;
10841 if (
auto *PL = dyn_cast_or_null<ParenListExpr>(Init))
10842 DeduceInits = PL->exprs();
10845 if (isa<DeducedTemplateSpecializationType>(Deduced)) {
10846 assert(VDecl &&
"non-auto type for init capture deduction?");
10852 return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind,
10857 if (
auto *IL = dyn_cast<InitListExpr>(Init))
10858 DeduceInits = IL->inits();
10862 if (DeduceInits.empty()) {
10866 ? diag::err_init_capture_no_expression
10867 : diag::err_auto_var_init_no_expression)
10868 << VN << Type << Range;
10872 if (DeduceInits.size() > 1) {
10873 Diag(DeduceInits[1]->getBeginLoc(),
10874 IsInitCapture ? diag::err_init_capture_multiple_expressions
10875 : diag::err_auto_var_init_multiple_expressions)
10876 << VN << Type << Range;
10880 Expr *DeduceInit = DeduceInits[0];
10881 if (DirectInit && isa<InitListExpr>(DeduceInit)) {
10883 ? diag::err_init_capture_paren_braces
10884 : diag::err_auto_var_init_paren_braces)
10885 << isa<InitListExpr>(Init) << VN << Type << Range;
10890 bool DefaultedAnyToId =
false;
10891 if (getLangOpts().DebuggerCastResultToId &&
10897 Init = Result.
get();
10898 DefaultedAnyToId =
true;
10904 if (VDecl && isa<DecompositionDecl>(VDecl) &&
10911 if (DeduceAutoType(TSI, DeduceInit, DeducedType) == DAR_Failed) {
10912 if (!IsInitCapture)
10913 DiagnoseAutoDeductionFailure(VDecl, DeduceInit);
10914 else if (isa<InitListExpr>(Init))
10916 diag::err_init_capture_deduction_failure_from_init_list)
10922 Diag(Range.
getBegin(), diag::err_init_capture_deduction_failure)
10935 if (!inTemplateInstantiation() && !DefaultedAnyToId && !IsInitCapture &&
10938 Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
10941 return DeducedType;
10949 if (DeducedType.
isNull()) {
10958 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(VDecl))
10966 MergeVarDeclTypes(VDecl, Old,
false);
10970 CheckVariableDeclarationType(VDecl);
10981 CorrectDelayedTyposInExpr(Init, dyn_cast_or_null<VarDecl>(RealDecl));
10985 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
10987 Diag(Method->getLocation(), diag::err_member_function_initialization)
10989 Method->setInvalidDecl();
10995 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
11006 ExprResult Res = CorrectDelayedTyposInExpr(Init, VDecl);
11013 if (DeduceVariableDeclarationType(VDecl, DirectInit, Init))
11019 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
11037 BaseDeclType = Array->getElementType();
11038 if (RequireCompleteType(VDecl->
getLocation(), BaseDeclType,
11039 diag::err_typecheck_decl_incomplete_type)) {
11046 diag::err_abstract_type_in_decl,
11047 AbstractVariableType))
11058 checkVarDeclRedefinition(Def, VDecl))
11061 if (getLangOpts().CPlusPlus) {
11075 Diag(Init->
getExprLoc(), diag::err_static_data_member_reinitialization)
11078 diag::note_previous_initializer)
11084 setFunctionHasBranchProtectedScope();
11086 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer)) {
11113 Init = Result.
get();
11129 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
11131 Args[Idx], VDecl, [
this, Entity, Kind](
Expr *E) {
11137 }
else if (Res.
get() != Args[Idx]) {
11138 Args[Idx] = Res.
get();
11161 CheckSelfReference(*
this, RealDecl, Init, DirectInit);
11174 if (VDecl->
hasAttr<BlocksAttr>())
11175 checkRetainCycles(VDecl, Init);
11187 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
11189 FSI->markSafeWeakUse(Init);
11210 Init = Result.
get();
11223 CheckForConstantInitializer(Init, DclT);
11232 CheckForConstantInitializer(Init, DclT);
11239 isa<InitListExpr>(Init)) {
11240 const Expr *Culprit;
11243 diag::ext_aggregate_init_not_constant)
11302 Diag(Loc, diag::ext_in_class_initializer_non_constant)
11307 Diag(Loc, diag::err_in_class_initializer_non_constant)
11316 if (getLangOpts().CPlusPlus11) {
11318 diag::ext_in_class_initializer_float_type_cxx11)
11321 diag::note_in_class_initializer_float_type_cxx11)
11324 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
11328 Diag(Init->
getExprLoc(), diag::err_in_class_initializer_non_constant)
11336 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
11355 ((!getLangOpts().CPlusPlus && !VDecl->
hasAttr<SelectAnyAttr>()) ||
11357 !(getLangOpts().CPlusPlus && VDecl->
isExternC()) &&
11363 CheckForConstantInitializer(Init, DclT);
11380 if (CXXDirectInit) {
11381 assert(DirectInit &&
"Call-style initializer must be direct init.");
11383 }
else if (DirectInit) {
11388 CheckCompleteVariableDeclaration(VDecl);
11403 if (
auto *DD = dyn_cast<DecompositionDecl>(D))
11404 for (
auto *BD : DD->bindings())
11408 if (ParsingInitForAutoVars.count(D)) {
11419 diag::err_typecheck_decl_incomplete_type)) {
11425 if (RequireNonAbstractType(VD->
getLocation(), Ty,
11426 diag::err_abstract_type_in_decl,
11427 AbstractVariableType)) {
11441 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
11445 if (isa<DecompositionDecl>(RealDecl)) {
11446 Diag(Var->getLocation(), diag::err_decomp_decl_requires_init) << Var;
11447 Var->setInvalidDecl();
11451 Expr *TmpInit =
nullptr;
11453 DeduceVariableDeclarationType(Var,
false, TmpInit))
11462 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
11463 !Var->isThisDeclarationADemotedDefinition()) {
11464 if (Var->isStaticDataMember()) {
11467 if (!getLangOpts().CPlusPlus17) {
11468 Diag(Var->getLocation(),
11469 diag::err_constexpr_static_mem_var_requires_init)
11470 << Var->getDeclName();
11471 Var->setInvalidDecl();
11475 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
11476 Var->setInvalidDecl();
11483 if (!Var->isInvalidDecl() &&
11485 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
11486 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
11487 Var->setInvalidDecl();
11491 switch (Var->isThisDeclarationADefinition()) {
11493 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
11509 !Var->hasLinkage() && !Var->isInvalidDecl() &&
11510 RequireCompleteType(Var->getLocation(), Type,
11511 diag::err_typecheck_decl_incomplete_type))
11512 Var->setInvalidDecl();
11516 RequireNonAbstractType(Var->getLocation(), Type,
11517 diag::err_abstract_type_in_decl,
11518 AbstractVariableType))
11519 Var->setInvalidDecl();
11522 Diag(Var->getLocation(), diag::warn_private_extern);
11523 Diag(Var->getLocation(), diag::note_private_extern);
11534 if (!Var->isInvalidDecl()) {
11537 if (RequireCompleteType(Var->getLocation(),
11538 ArrayT->getElementType(),
11539 diag::err_illegal_decl_array_incomplete_type))
11540 Var->setInvalidDecl();
11541 }
else if (Var->getStorageClass() ==
SC_Static) {
11551 if (Var->isFirstDecl())
11552 RequireCompleteType(Var->getLocation(), Type,
11553 diag::ext_typecheck_decl_incomplete_type);
11558 if (!Var->isInvalidDecl())
11559 TentativeDefinitions.push_back(Var);
11566 Diag(Var->getLocation(),
11567 diag::err_typecheck_incomplete_array_needs_initializer);
11568 Var->setInvalidDecl();
11575 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
11576 << Var->getDeclName()
11577 <<
SourceRange(Var->getLocation(), Var->getLocation());
11578 Var->setInvalidDecl();
11587 if (Var->isInvalidDecl())
11590 if (!Var->hasAttr<AliasAttr>()) {
11591 if (RequireCompleteType(Var->getLocation(),
11593 diag::err_typecheck_decl_incomplete_type)) {
11594 Var->setInvalidDecl();
11602 if (RequireNonAbstractType(Var->getLocation(), Type,
11603 diag::err_abstract_type_in_decl,
11604 AbstractVariableType)) {
11605 Var->setInvalidDecl();
11619 if (getLangOpts().
CPlusPlus && Var->hasLocalStorage()) {
11622 CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl());
11626 if (!CXXRecord->
isPOD())
11627 setFunctionHasBranchProtectedScope();
11650 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, None);
11652 Var->setInvalidDecl();
11653 else if (Init.
get()) {
11654 Var->setInit(MaybeCreateExprWithCleanups(Init.
get()));
11659 CheckCompleteVariableDeclaration(Var);
11717 const char *PrevSpec;
11720 getPrintingPolicy());
11729 Decl *Var = ActOnDeclarator(S, D);
11730 cast<VarDecl>(Var)->setCXXForRangeDecl(
true);
11731 FinalizeDeclaration(Var);
11732 return ActOnDeclStmt(FinalizeDeclaratorGroup(S, DS, Var), IdentLoc,
11733 AttrEnd.
isValid() ? AttrEnd : IdentLoc);
11739 if (getLangOpts().OpenCL) {
11753 if (getLangOpts().ObjC &&
11763 setFunctionHasBranchProtectedScope();
11770 setFunctionHasBranchProtectedScope();
11782 !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
11790 Diag(var->
getLocation(), diag::warn_missing_variable_declarations) << var;
11795 const Expr *CacheCulprit;
11796 auto checkConstInit = [&]()
mutable {
11797 if (!CacheHasConstInit)
11800 return *CacheHasConstInit;
11809 if (getLangOpts().CPlusPlus11)
11811 }
else if (getLangOpts().CPlusPlus && var->
hasInit()) {
11812 if (!checkConstInit()) {
11828 !inTemplateInstantiation()) {
11832 Stack = &ConstSegStack;
11834 Stack = &BSSSegStack;
11837 Stack = &DataSegStack;
11841 var->
addAttr(SectionAttr::CreateImplicit(
11842 Context, SectionAttr::Declspec_allocate,
11845 if (
const SectionAttr *SA = var->
getAttr<SectionAttr>())
11846 if (UnifySection(SA->getName(), SectionFlags, var))
11852 if (CurInitSeg && var->
getInit())
11853 var->
addAttr(InitSegAttr::CreateImplicit(Context, CurInitSeg->getString(),
11858 if (!getLangOpts().CPlusPlus) {
11866 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
11867 CheckCompleteDecompositionDeclaration(DD);
11872 if (var->
hasAttr<BlocksAttr>())
11873 getCurFunction()->addByrefBlockVar(var);
11886 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
11887 diag::note_invalid_subexpr_in_const_expr) {
11888 DiagLoc = Notes[0].first;
11891 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
11893 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
11894 Diag(Notes[I].first, Notes[I].second);
11906 var->
hasAttr<RequireConstantInitAttr>()) {
11908 bool DiagErr = getLangOpts().CPlusPlus11
11911 auto attr = var->
getAttr<RequireConstantInitAttr>();
11914 Diag(attr->getLocation(), diag::note_declared_required_constant_init_here)
11915 << attr->getRange();
11920 for (
auto &it : Notes)
11921 Diag(it.first, it.second);
11924 diag::note_invalid_subexpr_in_const_expr)
11930 !getDiagnostics().isIgnored(diag::warn_global_constructor,
11937 if (!checkConstInit())
11959 if (I->isAlignmentDependent())
11973 !FD->hasAttr<DLLExportStaticLocalAttr>() &&
11974 !FD->hasAttr<DLLImportStaticLocalAttr>()) {
11975 FD = dyn_cast_or_null<FunctionDecl>(FD->getParentFunctionOrMethod());
11983 auto *NewAttr = cast<InheritableAttr>(A->clone(getASTContext()));
11984 NewAttr->setInherited(
true);
11986 }
else if (
Attr *A = FD->getAttr<DLLExportStaticLocalAttr>()) {
11987 auto *NewAttr = ::new (getASTContext()) DLLExportAttr(A->getRange(),
11989 A->getSpellingListIndex());
11990 NewAttr->setInherited(
true);
11995 if (!FD->hasAttr<DLLExportAttr>())
11996 FD->addAttr(NewAttr);
11998 }
else if (
Attr *A = FD->getAttr<DLLImportStaticLocalAttr>()) {
11999 auto *NewAttr = ::new (getASTContext()) DLLImportAttr(A->getRange(),
12001 A->getSpellingListIndex());
12002 NewAttr->setInherited(
true);
12011 ParsingInitForAutoVars.erase(ThisDecl);
12013 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
12019 !inTemplateInstantiation() && !VD->
hasAttr<SectionAttr>()) {
12020 if (PragmaClangBSSSection.Valid)
12021 VD->
addAttr(PragmaClangBSSSectionAttr::CreateImplicit(Context,
12022 PragmaClangBSSSection.SectionName,
12023 PragmaClangBSSSection.PragmaLocation));
12024 if (PragmaClangDataSection.Valid)
12025 VD->
addAttr(PragmaClangDataSectionAttr::CreateImplicit(Context,
12026 PragmaClangDataSection.SectionName,
12027 PragmaClangDataSection.PragmaLocation));
12028 if (PragmaClangRodataSection.Valid)
12029 VD->
addAttr(PragmaClangRodataSectionAttr::CreateImplicit(Context,
12030 PragmaClangRodataSection.SectionName,
12031 PragmaClangRodataSection.PragmaLocation));
12034 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
12035 for (
auto *BD : DD->bindings()) {
12036 FinalizeDeclaration(BD);
12060 CheckStaticLocalForDllExport(VD);
12070 if (!getLangOpts().CUDA)
12072 if (VD->
hasAttr<CUDASharedAttr>())
12075 !(VD->
hasAttr<CUDADeviceAttr>() || VD->
hasAttr<CUDAConstantAttr>()))
12078 diag::err_device_static_local_var)
12079 << CurrentCUDATarget())
12090 if (getLangOpts().CUDA)
12091 checkAllowedCUDAInitializer(VD);
12097 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
12104 bool IsClassTemplateMember =
12105 isa<ClassTemplatePartialSpecializationDecl>(Context) ||
12109 IsClassTemplateMember
12110 ? diag::warn_attribute_dllimport_static_field_definition
12111 : diag::err_attribute_dllimport_static_field_definition);
12112 Diag(IA->getLocation(), diag::note_attribute);
12113 if (!IsClassTemplateMember)
12145 AddPushedVisibilityAttribute(VD);
12148 if (VD->
isFileVarDecl() && !isa<VarTemplatePartialSpecializationDecl>(VD))
12149 MarkUnusedFileScopedDecl(VD);
12153 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
12157 for (
const auto *I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
12159 if (!MagicValueExpr) {
12162 llvm::APSInt MagicValueInt;
12164 Diag(I->getRange().getBegin(),
12165 diag::err_type_tag_for_datatype_not_ice)
12169 if (MagicValueInt.getActiveBits() > 64) {
12170 Diag(I->getRange().getBegin(),
12171 diag::err_type_tag_for_datatype_too_large)
12175 uint64_t MagicValue = MagicValueInt.getZExtValue();
12176 RegisterTypeTagForDatatype(I->getArgumentKind(),
12178 I->getMatchingCType(),
12179 I->getLayoutCompatible(),
12180 I->getMustBeNull());
12185 auto *VD = dyn_cast<
VarDecl>(DD);
12198 bool DiagnosedMultipleDecomps =
false;
12200 bool DiagnosedNonDeducedAuto =
false;
12202 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
12203 if (
Decl *D = Group[i]) {
12206 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
12207 if (!FirstDeclaratorInGroup)
12208 FirstDeclaratorInGroup = DD;
12209 if (!FirstDecompDeclaratorInGroup)
12213 FirstNonDeducedAutoInGroup = DD;
12215 if (FirstDeclaratorInGroup != DD) {
12218 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
12220 diag::err_decomp_decl_not_alone)
12222 << DD->getSourceRange();
12223 DiagnosedMultipleDecomps =
true;
12229 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
12231 diag::err_auto_non_deduced_not_alone)
12232 << FirstNonDeducedAutoInGroup->
getType()
12235 << DD->getSourceRange();
12236 DiagnosedNonDeducedAuto =
true;
12241 Decls.push_back(D);
12247 handleTagNumbering(Tag, S);
12248 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
12249 getLangOpts().CPlusPlus)
12254 return BuildDeclaratorGroup(Decls);
12264 if (Group.size() > 1) {
12266 VarDecl *DeducedDecl =
nullptr;
12267 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
12278 auto *AT = dyn_cast<
AutoType>(DT);
12280 diag::err_auto_different_deductions)
12281 << (AT ? (
unsigned)AT->getKeyword() : 3)
12292 ActOnDocumentableDecls(Group);
12294 return DeclGroupPtrTy::make(
12299 ActOnDocumentableDecls(D);
12304 if (Group.empty() || !Group[0])
12307 if (Diags.isIgnored(diag::warn_doc_param_not_found,
12308 Group[0]->getLocation()) &&
12309 Diags.isIgnored(diag::warn_unknown_comment_command_name,
12310 Group[0]->getLocation()))
12313 if (Group.size() >= 2) {
12321 Decl *MaybeTagDecl = Group[0];
12322 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
12323 Group = Group.slice(1);
12329 if (!Comments.empty() &&
12330 !Comments.back()->isAttached()) {
12338 for (
unsigned i = 0, e = Group.size(); i != e; ++i)
12356 if (getLangOpts().CPlusPlus11) {
12358 getLangOpts().CPlusPlus17 ? diag::ext_register_storage_class
12359 : diag::warn_deprecated_register)
12362 }
else if (getLangOpts().CPlusPlus &&
12367 diag::err_invalid_storage_class_in_func_decl);
12376 << getLangOpts().CPlusPlus17;
12381 DiagnoseFunctionSpecifiers(DS);
12389 CheckExtraCXXDefaultArguments(D);
12405 << GetNameForDeclarator(D).getName();
12413 ForVisibleRedeclaration);
12415 if (R.isSingleResult()) {
12416 NamedDecl *PrevDecl = R.getFoundDecl();
12421 PrevDecl =
nullptr;
12452 IdResolver.AddDecl(New);
12454 ProcessDeclAttributes(S, New, D);
12462 if (New->
hasAttr<BlocksAttr>()) {
12486 if (inTemplateInstantiation())
12492 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
12500 if (LangOpts.NumLargeByValueCopy == 0)
12507 if (Size > LangOpts.NumLargeByValueCopy)
12519 if (Size > LangOpts.NumLargeByValueCopy)
12530 if (getLangOpts().ObjCAutoRefCount &&
12543 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
12554 TSInfo, SC,
nullptr);
12559 if (!CurContext->isRecord() &&
12560 RequireNonAbstractType(NameLoc, T, diag::err_abstract_type_in_decl,
12561 AbstractParamType))
12570 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
12583 !(getLangOpts().OpenCL &&
12585 Diag(NameLoc, diag::err_arg_with_address_space);
12599 for (
int i = FTI.
NumParams; i != 0; ) {
12603 llvm::raw_svector_ostream(Code)
12613 const char* PrevSpec;
12622 FTI.
Params[i].
Param = ActOnParamDeclarator(S, ParamD);
12632 assert(getCurFunctionDecl() ==
nullptr &&
"Function parsing confused");
12637 Decl *DP = HandleDeclarator(ParentScope, D, TemplateParameterLists);
12638 return ActOnStartOfFunctionDef(FnBodyScope, DP, SkipBody);
12642 Consumer.HandleInlineFunctionDefinition(D);
12656 if (isa<CXXMethodDecl>(FD))
12676 if (FD->
hasAttr<OpenCLKernelAttr>())
12683 bool MissingPrototype =
true;
12688 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
12691 MissingPrototype = !Prev->getType()->isFunctionProtoType();
12693 PossibleZeroParamPrototype = Prev;
12697 return MissingPrototype;
12721 for (
auto I : FD->
redecls()) {
12734 if (Original->isThisDeclarationADefinition()) {
12748 for (
auto I : FTD->redecls()) {
12749 auto D = cast<FunctionTemplateDecl>(I);
12751 assert(!D->isThisDeclarationADefinition() &&
12752 "More than one definition in redeclaration chain");
12755 D->getInstantiatedFromMemberTemplate()) {
12756 if (FT->isThisDeclarationADefinition()) {
12757 Definition = D->getTemplatedDecl();
12773 if (TypoCorrectedFunctionDefinitions.count(Definition))
12778 if (SkipBody && !hasVisibleDefinition(Definition) &&
12786 makeMergedDefinitionVisible(TD);
12787 makeMergedDefinitionVisible(const_cast<FunctionDecl*>(Definition));
12808 LSI->
Lambda = LambdaClass;
12826 for (
const auto &C : LambdaClass->
captures()) {
12827 if (C.capturesVariable()) {
12828 VarDecl *VD = C.getCapturedVar();
12832 const bool ByRef = C.getCaptureKind() ==
LCK_ByRef;
12834 true, C.getLocation(),
12835 C.isPackExpansion()
12837 CaptureType,
nullptr);
12839 }
else if (C.capturesThis()) {
12855 PushFunctionScope();
12856 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
12863 FD = FunTmpl->getTemplatedDecl();
12865 FD = cast<FunctionDecl>(D);
12870 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
12873 if (
const auto *
Attr = FD->
getAttr<AliasAttr>()) {
12878 if (
const auto *
Attr = FD->
getAttr<IFuncAttr>()) {
12887 CheckForFunctionRedefinition(FD,
nullptr, SkipBody);
12909 assert(inTemplateInstantiation() &&
12910 "There should be an active template instantiation on the stack " 12911 "when instantiating a generic lambda!");
12915 PushFunctionScope();
12932 RequireCompleteType(FD->
getLocation(), ResultType,
12933 diag::err_func_def_incomplete_result))
12937 PushDeclContext(FnBodyScope, FD);
12947 auto *NonParmDecl = dyn_cast<
NamedDecl>(NPD);
12950 assert(!isa<ParmVarDecl>(NonParmDecl) &&
12951 "parameters should not be in newly created FD yet");
12954 if (NonParmDecl->getDeclName())
12955 PushOnScopeChains(NonParmDecl, FnBodyScope,
false);
12959 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
12960 for (
auto *EI : ED->enumerators())
12961 PushOnScopeChains(EI, FnBodyScope,
false);
12968 Param->setOwningFunction(FD);
12971 if (Param->getIdentifier() && FnBodyScope) {
12972 CheckShadow(FnBodyScope, Param);
12974 PushOnScopeChains(Param, FnBodyScope);
12985 assert(!FD->
hasAttr<DLLExportAttr>());
12986 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
12992 ActOnDocumentableDecl(D);
12993 if (getCurLexicalContext()->isObjCContainer() &&
12994 getCurLexicalContext()->getDeclKind() != Decl::ObjCCategoryImpl &&
12995 getCurLexicalContext()->getDeclKind() != Decl::ObjCImplementation)
13016 for (
unsigned I = 0, E = Scope->
Returns.size(); I != E; ++I) {
13017 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
13018 if (!NRVOCandidate->isNRVOVariable())
13019 Returns[I]->setNRVOCandidate(
nullptr);
13037 Outer.Fun.hasTrailingReturnType()) {
13038 QualType Ty = GetTypeFromParser(Outer.Fun.getTrailingReturnType());
13055 if (FD->isConstexpr())
13060 if (FD->getReturnType()->getContainedDeducedType())
13063 return Consumer.shouldSkipFunctionBody(D);
13070 FD->setHasSkippedBody();
13072 MD->setHasSkippedBody();
13077 return ActOnFinishFunctionBody(D, BodyArg,
false);
13092 bool IsLambda =
false;
13096 bool IsInstantiation) {
13102 if (getLangOpts().CoroutinesTS && getCurFunction()->isCoroutine())
13103 CheckCompletedCoroutineBody(FD, Body);
13126 TypeLoc ResultType = getReturnTypeLoc(FD);
13134 auto *LSI = getCurLambda();
13135 if (LSI->HasImplicitReturnType) {
13136 deduceClosureReturnType(*LSI);
13142 LSI->ReturnType.isNull() ? Context.
VoidTy : LSI->ReturnType;
13166 DiagnoseSizeOfParametersAndReturnValue(FD->
parameters(),
13171 MarkVTableUsed(FD->
getLocation(), Constructor->getParent());
13173 MarkVTableUsed(FD->
getLocation(), Destructor->getParent());
13180 computeNRVO(Body, getCurFunction());
13188 const FunctionDecl *PossibleZeroParamPrototype =
nullptr;
13192 if (PossibleZeroParamPrototype) {
13197 TypeLoc TL = TI->getTypeLoc();
13200 diag::note_declaration_not_a_prototype)
13201 << PossibleZeroParamPrototype
13214 !LangOpts.CPlusPlus) {
13224 if (
const auto *CmpndBody = dyn_cast<CompoundStmt>(Body))
13225 if (!CmpndBody->body_empty())
13226 Diag(CmpndBody->body_front()->getBeginLoc(),
13227 diag::warn_dispatch_body_ignored);
13229 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13231 if (MD->isOutOfLine() && (MD = MD->getCanonicalDecl()) &&
13244 if (KeyFunction && KeyFunction->
isDefined(Definition))
13245 MarkVTableUsed(Definition->
getLocation(), MD->getParent(),
true);
13248 MarkVTableUsed(FD->
getLocation(), MD->getParent(),
true);
13253 assert((FD == getCurFunctionDecl() || getCurLambda()->CallOperator == FD) &&
13254 "Function parsing confused");
13255 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
13256 assert(MD == getCurMethodDecl() &&
"Method parsing confused");
13258 if (!MD->isInvalidDecl()) {
13259 if (!MD->hasSkippedBody())
13260 DiagnoseUnusedParameters(MD->parameters());
13261 DiagnoseSizeOfParametersAndReturnValue(MD->parameters(),
13262 MD->getReturnType(), MD);
13265 computeNRVO(Body, getCurFunction());
13267 if (getCurFunction()->ObjCShouldCallSuper) {
13268 Diag(MD->getEndLoc(), diag::warn_objc_missing_super_call)
13269 << MD->getSelector().getAsString();
13270 getCurFunction()->ObjCShouldCallSuper =
false;
13272 if (getCurFunction()->ObjCWarnForNoDesignatedInitChain) {
13274 bool isDesignated =
13276 assert(isDesignated && InitMethod);
13277 (void)isDesignated;
13280 auto IFace = MD->getClassInterface();
13283 auto SuperD = IFace->getSuperClass();
13286 return SuperD->getIdentifier() ==
13291 if (!MD->isUnavailable() && !superIsNSObject(MD)) {
13292 Diag(MD->getLocation(),
13293 diag::warn_objc_designated_init_missing_super_call);
13295 diag::note_objc_designated_init_marked_here);
13297 getCurFunction()->ObjCWarnForNoDesignatedInitChain =
false;
13299 if (getCurFunction()->ObjCWarnForNoInitDelegation) {
13301 if (!MD->isUnavailable())
13302 Diag(MD->getLocation(),
13303 diag::warn_objc_secondary_init_missing_init_call);
13304 getCurFunction()->ObjCWarnForNoInitDelegation =
false;
13309 PopFunctionScopeInfo(ActivePolicy, dcl);
13313 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
13314 DiagnoseUnguardedAvailabilityViolations(dcl);
13316 assert(!getCurFunction()->ObjCShouldCallSuper &&
13317 "This should only be set for ObjC methods, which should have been " 13318 "handled in the block above.");
13325 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
13326 DiagnoseReturnInConstructorExceptionHandler(cast<CXXTryStmt>(Body));
13329 if (getCurFunction()->NeedsScopeChecking() &&
13330 !PP.isCodeCompletionEnabled())
13331 DiagnoseInvalidJumps(Body);
13334 if (!Destructor->getParent()->isDependentType())
13335 CheckDestructor(Destructor);
13337 MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(),
13338 Destructor->getParent());
13344 if (getDiagnostics().hasErrorOccurred() ||
13345 getDiagnostics().getSuppressAllDiagnostics()) {
13346 DiscardCleanupsInEvaluationContext();
13348 if (!getDiagnostics().hasUncompilableErrorOccurred() &&
13349 !isa<FunctionTemplateDecl>(dcl)) {
13352 ActivePolicy = &WP;
13356 (!CheckConstexprFunctionDecl(FD) ||
13357 !CheckConstexprFunctionBody(FD, Body)))
13360 if (FD && FD->
hasAttr<NakedAttr>()) {
13364 bool RegisterVariables =
false;
13365 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
13366 for (
const auto *
Decl : DS->decls()) {
13367 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
13368 RegisterVariables =
13369 Var->hasAttr<AsmLabelAttr>() && !Var->hasInit();
13370 if (!RegisterVariables)
13375 if (RegisterVariables)
13377 if (!isa<AsmStmt>(S) && !isa<NullStmt>(S)) {
13378 Diag(S->getBeginLoc(), diag::err_non_asm_stmt_in_naked_function);
13379 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
13386 assert(ExprCleanupObjects.size() ==
13387 ExprEvalContexts.back().NumCleanupObjects &&
13388 "Leftover temporaries in function");
13389 assert(!Cleanup.exprNeedsCleanups() &&
"Unaccounted cleanups in function");
13390 assert(MaybeODRUseExprs.empty() &&
13391 "Leftover expressions for odr-use checking");
13394 if (!IsInstantiation)
13397 PopFunctionScopeInfo(ActivePolicy, dcl);
13401 if (getDiagnostics().hasErrorOccurred()) {
13402 DiscardCleanupsInEvaluationContext();
13414 D = TD->getTemplatedDecl();
13415 ProcessDeclAttributeList(S, D, Attrs);
13417 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D))
13418 if (Method->isStatic())
13419 checkThisInStaticMemberFunctionAttributes(Method);
13431 Scope *BlockScope = S;
13435 Scope *ContextScope = BlockScope;
13437 ContextScope = ContextScope->
getParent();
13444 NamedDecl *ExternCPrev = findLocallyScopedExternCDecl(&II);
13448 PushOnScopeChains(ExternCPrev, BlockScope,
false);
13453 if (!isa<FunctionDecl>(ExternCPrev) ||
13455 cast<FunctionDecl>(ExternCPrev)->getType(),
13457 Diag(Loc, diag::ext_use_out_of_scope_declaration)
13458 << ExternCPrev << !getLangOpts().C99;
13459 Diag(ExternCPrev->getLocation(), diag::note_previous_declaration);
13460 return ExternCPrev;
13466 if (II.
getName().startswith(
"__builtin_"))
13467 diag_id = diag::warn_builtin_unknown;
13469 else if (getLangOpts().OpenCL)
13470 diag_id = diag::err_opencl_implicit_function_decl;
13471 else if (getLangOpts().C99)
13472 diag_id = diag::ext_implicit_function_decl;
13474 diag_id = diag::warn_implicit_function_decl;
13475 Diag(Loc, diag_id) << &II;
13481 return ExternCPrev;
13488 (Corrected = CorrectTypo(
13491 diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion),
13503 assert(!Error &&
"Error setting up implicit decl!");
13528 FunctionDecl *FD = cast<FunctionDecl>(ActOnDeclarator(BlockScope, D));
13531 AddKnownFunctionAttributes(FD);
13553 unsigned FormatIdx;
13556 if (!FD->
hasAttr<FormatAttr>()) {
13557 const char *fmt =
"printf";
13559 if (FormatIdx < NumParams &&
13562 FD->
addAttr(FormatAttr::CreateImplicit(Context,
13565 HasVAListArg ? 0 : FormatIdx+2,
13571 if (!FD->
hasAttr<FormatAttr>())
13572 FD->
addAttr(FormatAttr::CreateImplicit(Context,
13575 HasVAListArg ? 0 : FormatIdx+2,
13582 if (!getLangOpts().MathErrno && !FD->
hasAttr<ConstAttr>() &&
13590 if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
13592 switch (BuiltinID) {
13593 case Builtin::BI__builtin_fma:
13594 case Builtin::BI__builtin_fmaf:
13595 case Builtin::BI__builtin_fmal:
13596 case Builtin::BIfma:
13597 case Builtin::BIfmaf:
13598 case Builtin::BIfmal:
13607 !FD->
hasAttr<ReturnsTwiceAttr>())
13608 FD->
addAttr(ReturnsTwiceAttr::CreateImplicit(Context,
13617 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
13621 if (getLangOpts().CUDAIsDevice !=
13632 if (getLangOpts().CXXExceptions && getLangOpts().ExternCNoUnwind &&
13635 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
13652 if (Name->
isStr(
"asprintf") || Name->
isStr(
"vasprintf")) {
13655 if (!FD->
hasAttr<FormatAttr>())
13656 FD->
addAttr(FormatAttr::CreateImplicit(Context,
13658 Name->
isStr(
"vasprintf") ? 0 : 3,
13662 if (Name->
isStr(
"__CFStringMakeConstantString")) {
13665 if (!FD->
hasAttr<FormatArgAttr>())
13673 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
13674 assert(!T.
isNull() &&
"GetTypeForDeclarator() returned null type");
13677 assert(D.
isInvalidType() &&
"no declarator info for valid type");
13693 if (CurContext->isFunctionOrMethod())
13715 setTagNameForLinkagePurposes(tagFromDeclSpec, NewTD);
13735 if (BT->isInteger())
13738 Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T;
13745 QualType EnumUnderlyingTy,
bool IsFixed,
13747 if (IsScoped != Prev->
isScoped()) {
13748 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
13754 if (IsFixed && Prev->
isFixed()) {
13760 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
13766 }
else if (IsFixed != Prev->
isFixed()) {
13767 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
13786 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
13801 if (isa<TypedefDecl>(PrevDecl))
13802 return NTK_Typedef;
13803 else if (isa<TypeAliasDecl>(PrevDecl))
13804 return NTK_TypeAlias;
13805 else if (isa<ClassTemplateDecl>(PrevDecl))
13806 return NTK_Template;
13807 else if (isa<TypeAliasTemplateDecl>(PrevDecl))
13808 return NTK_TypeAliasTemplate;
13809 else if (isa<TemplateTemplateParmDecl>(PrevDecl))
13810 return NTK_TemplateTemplateArgument;
13815 return getLangOpts().CPlusPlus ? NTK_NonClass : NTK_NonStruct;
13817 return NTK_NonUnion;
13819 return NTK_NonEnum;
13821 llvm_unreachable(
"invalid TTK");
13846 if (OldTag != NewTag &&
13861 return getDiagnostics().isIgnored(diag::warn_struct_class_tag_mismatch,
13864 if (IsIgnoredLoc(NewTagLoc))
13867 auto IsIgnored = [&](
const TagDecl *Tag) {
13868 return IsIgnoredLoc(Tag->getLocation());
13870 while (IsIgnored(Previous)) {
13878 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Previous))
13879 isTemplate = Record->getDescribedClassTemplate();
13881 if (inTemplateInstantiation()) {
13882 if (OldTag != NewTag) {
13885 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
13893 if (isDefinition) {
13901 bool previousMismatch =
false;
13903 if (I->getTagKind() != NewTag) {
13908 if (!previousMismatch) {
13909 previousMismatch =
true;
13910 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
13914 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
13927 if (PrevDef && IsIgnored(PrevDef))
13931 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
13938 Diag(NewTagLoc, diag::note_struct_class_suggestion)
13971 Namespaces.push_back(II);
13974 if (Lookup == Namespace)
13981 llvm::raw_svector_ostream OS(Insertion);
13984 std::reverse(Namespaces.begin(), Namespaces.end());
13985 for (
auto *II : Namespaces)
13986 OS << II->getName() <<
"::";
13999 if (OldDC->
Equals(NewDC))
14027 bool &OwnedDecl,
bool &IsDependent,
14029 bool ScopedEnumUsesClassTag,
TypeResult UnderlyingType,
14030 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
14034 assert((Name !=
nullptr || TUK == TUK_Definition) &&
14035 "Nameless record must be a definition!");
14036 assert(TemplateParameterLists.size() == 0 || TUK != TUK_Reference);
14040 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
14043 bool isMemberSpecialization =
false;
14044 bool Invalid =
false;
14049 if (TemplateParameterLists.size() > 0 ||
14050 (SS.
isNotEmpty() && TUK != TUK_Reference)) {
14052 MatchTemplateParametersToScopeSpecifier(
14053 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
14054 TUK == TUK_Friend, isMemberSpecialization, Invalid)) {
14056 Diag(KWLoc, diag::err_enum_template);
14060 if (TemplateParams->size() > 0) {
14069 S, TagSpec, TUK, KWLoc, SS, Name, NameLoc, Attrs, TemplateParams,
14070 AS, ModulePrivateLoc,
14072 TemplateParameterLists.data(), SkipBody);
14073 return Result.
get();
14076 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
14078 isMemberSpecialization =
true;
14086 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
14087 bool IsFixed = !UnderlyingType.
isUnset() || ScopedEnum;
14090 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum)) {
14094 }
else if (UnderlyingType.
get()) {
14098 GetTypeFromParser(UnderlyingType.
get(), &TI);
14099 EnumUnderlying = TI;
14101 if (CheckEnumUnderlyingType(TI))
14106 UPPC_FixedUnderlyingType))
14114 if (TUK == TUK_Definition || getLangOpts().MSVCCompat)
14121 bool isStdBadAlloc =
false;
14122 bool isStdAlignValT =
false;
14125 if (TUK == TUK_Friend || TUK == TUK_Reference)
14126 Redecl = NotForRedeclaration;
14131 auto createTagFromNewDecl = [&]() ->
TagDecl * {
14132 assert(!getLangOpts().
CPlusPlus &&
"not meant for C++ usage");
14141 ScopedEnum, ScopedEnumUsesClassTag, IsFixed);
14143 if (TUK != TUK_Definition && !Invalid)
14145 if (EnumUnderlying) {
14146 EnumDecl *ED = cast<EnumDecl>(New);
14158 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
14168 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip)) {
14169 AddAlignmentAttributesForRecord(RD);
14170 AddMsStructLayoutForRecord(RD);
14184 goto CreateNewDecl;
14189 if (TUK == TUK_Friend || TUK == TUK_Reference) {
14190 DC = computeDeclContext(SS,
false);
14192 IsDependent =
true;
14196 DC = computeDeclContext(SS,
true);
14204 if (RequireCompleteDeclContext(SS, DC))
14209 LookupQualifiedName(Previous, DC);
14214 if (Previous.
empty()) {
14222 (TUK == TUK_Reference || TUK == TUK_Friend)) {
14223 IsDependent =
true;
14228 Diag(NameLoc, diag::err_not_tag_in_scope)
14229 << Kind << Name << DC << SS.
getRange();
14232 goto CreateNewDecl;
14239 if (TUK != TUK_Reference && TUK != TUK_Friend &&
14248 LookupName(Previous, S);
14253 (TUK == TUK_Definition || TUK == TUK_Declaration)) {
14277 if (!Previous.
empty() && TUK == TUK_Friend) {
14280 bool FriendSawTagOutsideEnclosingNamespace =
false;
14286 if (getLangOpts().MSVCCompat)
14287 FriendSawTagOutsideEnclosingNamespace =
true;
14296 if (Previous.
isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
14298 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
14307 if (!getLangOpts().CPlusPlus && TUK != TUK_Reference) {
14312 while (isa<RecordDecl>(SearchDC) || isa<EnumDecl>(SearchDC))
14320 DiagnoseTemplateParameterShadow(NameLoc, Previous.
getFoundDecl());
14325 if (getLangOpts().
CPlusPlus && Name && DC && StdNamespace &&
14326 DC->
Equals(getStdNamespace())) {
14327 if (Name->
isStr(
"bad_alloc")) {
14329 isStdBadAlloc =
true;
14334 if (Previous.
empty() && StdBadAlloc)
14335 Previous.
addDecl(getStdBadAlloc());
14336 }
else if (Name->
isStr(
"align_val_t")) {
14337 isStdAlignValT =
true;
14338 if (Previous.
empty() && StdAlignValT)
14339 Previous.
addDecl(getStdAlignValT());
14347 if (Name && Previous.
empty() &&
14348 (TUK == TUK_Reference || TUK == TUK_Friend || IsTemplateParamOrArg)) {
14349 if (Invalid)
goto CreateNewDecl;
14352 if (TUK == TUK_Reference || IsTemplateParamOrArg) {
14386 assert(TUK == TUK_Friend);
14402 LookupQualifiedName(Previous, SearchDC);
14405 LookupName(Previous, S);
14413 if (!Previous.
empty()) {
14429 TagDecl *Tag = TT->getDecl();
14432 ->
Equals(TD->getDeclContext()->getRedeclContext())) {
14445 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
14446 auto *OldTag = dyn_cast<
TagDecl>(PrevDecl);
14447 if (SS.
isEmpty() && TUK != TUK_Reference && TUK != TUK_Friend &&
14448 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
14450 *
this, OldTag->getDeclContext(), SearchDC))) {
14451 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
14452 Diag(Shadow->getTargetDecl()->getLocation(),
14453 diag::note_using_decl_target);
14454 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl)
14458 goto CreateNewDecl;
14462 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
14466 if (TUK == TUK_Reference || TUK == TUK_Friend ||
14467 isDeclInScope(DirectPrevDecl, SearchDC, S,
14468 SS.
isNotEmpty() || isMemberSpecialization)) {
14471 if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind,
14472 TUK == TUK_Definition, KWLoc,
14474 bool SafeToContinue
14475 = (PrevTagDecl->getTagKind() !=
TTK_Enum &&
14477 if (SafeToContinue)
14478 Diag(KWLoc, diag::err_use_with_wrong_tag)
14481 PrevTagDecl->getKindName());
14483 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
14484 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
14486 if (SafeToContinue)
14487 Kind = PrevTagDecl->getTagKind();
14497 const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
14501 if (TUK == TUK_Reference || TUK == TUK_Friend) {
14503 Diag(ScopedEnumKWLoc, diag::err_enum_class_reference)
14506 return PrevTagDecl;
14511 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
14512 else if (
const Type *T = EnumUnderlying.dyn_cast<
const Type*>())
14513 EnumUnderlyingTy =
QualType(T, 0);
14518 if (CheckEnumRedeclaration(NameLoc.
isValid() ? NameLoc : KWLoc,
14519 ScopedEnum, EnumUnderlyingTy,
14520 IsFixed, PrevEnum))
14521 return TUK == TUK_Declaration ? PrevTagDecl :
nullptr;
14530 Diag(NameLoc, diag::ext_member_redeclared);
14531 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
14537 if (TUK == TUK_Reference || TUK == TUK_Friend) {
14538 if (!Attrs.
empty()) {
14541 }
else if (TUK == TUK_Reference &&
14542 (PrevTagDecl->getFriendObjectKind() ==
14555 return PrevTagDecl;
14560 return PrevTagDecl;
14565 if (TUK == TUK_Definition) {
14566 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
14570 bool IsExplicitSpecializationAfterInstantiation =
false;
14571 if (isMemberSpecialization) {
14573 IsExplicitSpecializationAfterInstantiation =
14574 RD->getTemplateSpecializationKind() !=
14576 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
14577 IsExplicitSpecializationAfterInstantiation =
14578 ED->getTemplateSpecializationKind() !=
14587 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
14598 SkipBody->
New = createTagFromNewDecl();
14604 makeMergedDefinitionVisible(Hidden);
14608 }
else if (!IsExplicitSpecializationAfterInstantiation) {
14612 Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name;
14614 Diag(NameLoc, diag::err_redefinition) << Name;
14615 notePreviousDefinition(Def,
14616 NameLoc.
isValid() ? NameLoc : KWLoc);
14628 if (TD->isBeingDefined()) {
14629 Diag(NameLoc, diag::err_nested_redefinition) << Name;
14630 Diag(PrevTagDecl->getLocation(),
14631 diag::note_previous_definition);
14645 if (TUK == TUK_Friend || TUK == TUK_Reference) {
14646 SearchDC = PrevTagDecl->getDeclContext();
14671 if ((TUK == TUK_Reference || TUK == TUK_Friend) &&
14673 NonTagKind NTK = getNonTagTypeDeclKind(PrevDecl, Kind);
14674 Diag(NameLoc, diag::err_tag_reference_non_tag) << PrevDecl << NTK
14680 }
else if (!isDeclInScope(DirectPrevDecl, SearchDC, S,
14681 SS.
isNotEmpty() || isMemberSpecialization)) {
14685 }
else if (TUK == TUK_Reference || TUK == TUK_Friend) {
14686 NonTagKind NTK = getNonTagTypeDeclKind(PrevDecl, Kind);
14687 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
14693 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
14695 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
14696 Diag(NameLoc, diag::err_tag_definition_of_typedef)
14697 << Name << Kind << TND->getUnderlyingType();
14705 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
14706 notePreviousDefinition(PrevDecl, NameLoc);
14737 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
14738 ScopedEnumUsesClassTag, IsFixed);
14740 if (isStdAlignValT && (!StdAlignValT || getStdAlignValT()->isImplicit()))
14741 StdAlignValT = cast<EnumDecl>(New);
14744 if (TUK != TUK_Definition && !Invalid) {
14746 if (IsFixed && (getLangOpts().
CPlusPlus11 || getLangOpts().ObjC) &&
14747 cast<EnumDecl>(New)->isFixed()) {
14751 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
14752 Diag(Loc, diag::ext_forward_ref_enum_def)
14756 unsigned DiagID = diag::ext_forward_ref_enum;
14757 if (getLangOpts().MSVCCompat)
14758 DiagID = diag::ext_ms_forward_ref_enum;
14759 else if (getLangOpts().CPlusPlus)
14760 DiagID = diag::err_forward_ref_enum;
14765 if (EnumUnderlying) {
14766 EnumDecl *ED = cast<EnumDecl>(New);
14772 assert(ED->
isComplete() &&
"enum with type should be complete");
14779 if (getLangOpts().CPlusPlus) {
14782 cast_or_null<CXXRecordDecl>(PrevDecl));
14784 if (isStdBadAlloc && (!StdBadAlloc || getStdBadAlloc()->isImplicit()))
14785 StdBadAlloc = cast<CXXRecordDecl>(New);
14788 cast_or_null<RecordDecl>(PrevDecl));
14793 if (getLangOpts().
CPlusPlus && (IsTypeSpecifier || IsTemplateParamOrArg) &&
14794 TUK == TUK_Definition) {
14800 if (!Invalid && getLangOpts().
CPlusPlus && TUK == TUK_Definition &&
14812 if ((TUK == TUK_Definition || TUK == TUK_Declaration) &&
14813 diagnoseQualifiedDeclaration(SS, DC, OrigName, Loc,
14814 isMemberSpecialization))
14818 if (TemplateParameterLists.size() > 0) {
14826 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
14836 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip)) {
14837 AddAlignmentAttributesForRecord(RD);
14838 AddMsStructLayoutForRecord(RD);
14842 if (ModulePrivateLoc.
isValid()) {
14843 if (isMemberSpecialization)
14856 if (isMemberSpecialization && CheckMemberSpecialization(New, Previous))
14863 getNonFieldDeclScope(S)->isFunctionPrototypeScope()) {
14867 if (TUK == TUK_Definition && !IsTypeSpecifier) {
14868 Diag(Loc, diag::err_type_defined_in_param_type)
14872 }
else if (!PrevDecl) {
14888 if (TUK == TUK_Friend)
14892 if (!Invalid && SearchDC->
isRecord())
14893 SetMemberAccessSpecifier(New, PrevDecl, AS);
14896 CheckRedeclarationModuleOwnership(New, PrevDecl);
14898 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip))
14901 ProcessDeclAttributeList(S, New, Attrs);
14902 AddPragmaAttributes(S, New);
14905 if (TUK == TUK_Friend) {
14914 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
14915 PushOnScopeChains(New, EnclosingScope,
false);
14917 S = getNonFieldDeclScope(S);
14918 PushOnScopeChains(New, S,
true);
14920 CurContext->addDecl(New);
14931 mergeDeclAttributes(New, PrevDecl);
14935 AddPushedVisibilityAttribute(New);
14938 CompleteMemberSpecialization(New, Previous);
14943 if (Invalid && getLangOpts().CPlusPlus) {
14945 if (
auto RD = dyn_cast<RecordDecl>(New))
14946 RD->completeDefinition();
14948 }
else if (SkipBody && SkipBody->
ShouldSkip) {
14956 AdjustDeclIfTemplate(TagD);
14957 TagDecl *Tag = cast<TagDecl>(TagD);
14960 PushDeclContext(S, Tag);
14962 ActOnDocumentableDecl(TagD);
14966 AddPushedVisibilityAttribute(Tag);
14971 if (!hasStructuralCompatLayout(Prev, SkipBody.
New))
14975 makeMergedDefinitionVisible(SkipBody.
Previous);
14980 assert(isa<ObjCContainerDecl>(IDecl) &&
14981 "ActOnObjCContainerStartDefinition - Not ObjCContainerDecl");
14983 assert(getContainingDC(OCD) == CurContext &&
14984 "The next DeclContext should be lexically contained in the current one.");
14991 bool IsFinalSpelledSealed,
14993 AdjustDeclIfTemplate(TagD);
14996 FieldCollector->StartClass();
15002 Record->
addAttr(new (Context)
15003 FinalAttr(FinalLoc, Context, IsFinalSpelledSealed));
15020 PushOnScopeChains(InjectedClassName, S);
15022 "Broken injected-class-name");
15027 AdjustDeclIfTemplate(TagD);
15028 TagDecl *Tag = cast<TagDecl>(TagD);
15033 assert(Tag->
isInvalidDecl() &&
"We should already have completed it");
15034 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
15035 RD->completeDefinition();
15038 if (isa<CXXRecordDecl>(Tag)) {
15039 FieldCollector->FinishClass();
15045 if (getCurLexicalContext()->isObjCContainer() &&
15051 Consumer.HandleTagDeclDefinition(Tag);
15060 assert(DC == CurContext &&
"Mismatch of container contexts");
15061 OriginalLexicalContext = DC;
15062 ActOnObjCContainerFinishDefinition();
15066 ActOnObjCContainerStartDefinition(cast<Decl>(DC));
15067 OriginalLexicalContext =
nullptr;
15071 AdjustDeclIfTemplate(TagD);
15072 TagDecl *Tag = cast<TagDecl>(TagD);
15077 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
15078 RD->completeDefinition();
15091 QualType FieldTy,
bool IsMsStruct,
15092 Expr *BitWidth,
bool *ZeroWidth) {
15101 if (RequireCompleteType(FieldLoc, FieldTy, diag::err_field_incomplete))
15104 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
15106 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
15108 }
else if (DiagnoseUnexpandedParameterPack(const_cast<Expr *>(BitWidth),
15109 UPPC_BitFieldWidth))
15117 llvm::APSInt
Value;
15118 ExprResult ICE = VerifyIntegerConstantExpression(BitWidth, &Value);
15121 BitWidth = ICE.
get();
15123 if (Value != 0 && ZeroWidth)
15124 *ZeroWidth =
false;
15127 if (Value == 0 && FieldName)
15128 return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
15130 if (Value.isSigned() && Value.isNegative()) {
15132 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
15133 << FieldName << Value.toString(10);
15134 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
15135 << Value.toString(10);
15139 uint64_t TypeStorageSize = Context.
getTypeSize(FieldTy);
15140 uint64_t TypeWidth = Context.
getIntWidth(FieldTy);
15141 bool BitfieldIsOverwide = Value.ugt(TypeWidth);
15145 bool CStdConstraintViolation =
15146 BitfieldIsOverwide && !getLangOpts().CPlusPlus;
15147 bool MSBitfieldViolation =
15148 Value.ugt(TypeStorageSize) &&
15150 if (CStdConstraintViolation || MSBitfieldViolation) {
15151 unsigned DiagWidth =
15152 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
15154 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
15155 << FieldName << (unsigned)Value.getZExtValue()
15156 << !CStdConstraintViolation << DiagWidth;
15158 return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width)
15159 << (unsigned)Value.getZExtValue() << !CStdConstraintViolation
15168 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
15169 << FieldName << (unsigned)Value.getZExtValue()
15170 << (unsigned)TypeWidth;
15172 Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_width)
15173 << (unsigned)Value.getZExtValue() << (unsigned)TypeWidth;
15184 FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD),
15185 DeclStart, D, static_cast<Expr*>(BitfieldWidth),
15211 CheckExtraCXXDefaultArguments(D);
15214 UPPC_DataMemberType)) {
15225 << getLangOpts().CPlusPlus17;
15228 diag::err_invalid_thread)
15234 ForVisibleRedeclaration);
15235 LookupName(Previous, S);
15257 PrevDecl =
nullptr;
15260 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
15261 PrevDecl =
nullptr;
15267 = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
15268 TSSL, AS, PrevDecl, &D);
15280 PushOnScopeChains(NewFD, S);
15300 bool Mutable,
Expr *BitWidth,
15306 bool InvalidDecl =
false;
15312 InvalidDecl =
true;
15318 if (RequireCompleteType(Loc, EltTy, diag::err_field_incomplete)) {
15321 InvalidDecl =
true;
15327 InvalidDecl =
true;
15335 Diag(Loc, diag::err_field_with_address_space);
15337 InvalidDecl =
true;
15340 if (LangOpts.OpenCL) {
15345 Diag(Loc, diag::err_opencl_type_struct_or_union_field) << T;
15347 InvalidDecl =
true;
15351 Diag(Loc, diag::err_opencl_bitfields);
15352 InvalidDecl =
true;
15357 if (!InvalidDecl && getLangOpts().
CPlusPlus && !II && BitWidth &&
15359 InvalidDecl =
true;
15360 Diag(Loc, diag::err_anon_bitfield_qualifiers);
15366 bool SizeIsNegative;
15367 llvm::APSInt Oversized;
15374 Diag(Loc, diag::warn_illegal_constant_array_size);
15375 TInfo = FixedTInfo;
15378 if (SizeIsNegative)
15379 Diag(Loc, diag::err_typecheck_negative_array_size);
15380 else if (Oversized.getBoolValue())
15381 Diag(Loc, diag::err_array_too_large)
15382 << Oversized.toString(10);
15384 Diag(Loc, diag::err_typecheck_field_variable_size);
15385 InvalidDecl =
true;
15390 if (!InvalidDecl && RequireNonAbstractType(Loc, T,
15391 diag::err_abstract_type_in_decl,
15392 AbstractFieldType))
15393 InvalidDecl =
true;
15395 bool ZeroWidth =
false;
15397 BitWidth =
nullptr;
15400 BitWidth = VerifyBitField(Loc, II, T, Record->
isMsStruct(Context), BitWidth,
15403 InvalidDecl =
true;
15404 BitWidth =
nullptr;
15410 if (!InvalidDecl && Mutable) {
15411 unsigned DiagID = 0;
15413 DiagID = getLangOpts().MSVCCompat ? diag::ext_mutable_reference
15414 : diag::err_mutable_reference;
15416 DiagID = diag::err_mutable_const;
15422 Diag(ErrLoc, DiagID);
15423 if (DiagID != diag::ext_mutable_reference) {
15425 InvalidDecl =
true;
15437 BitWidth, Mutable, InitStyle);
15441 if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
15442 Diag(Loc, diag::err_duplicate_member) << II;
15447 if (!InvalidDecl && getLangOpts().
CPlusPlus) {
15457 if (CheckNontrivialField(NewFD))
15467 diag::ext_union_member_of_reference_type :
15468 diag::err_union_member_of_reference_type)
15470 if (!getLangOpts().MicrosoftExt)
15480 ProcessDeclAttributes(getCurScope(), NewFD, *D);
15483 CheckAlignasUnderalignment(NewFD);
15488 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewFD))
15492 Diag(Loc, diag::warn_attribute_weak_on_field);
15500 assert(getLangOpts().
CPlusPlus &&
"valid check only for C++");
15520 member = CXXCopyConstructor;
15522 member = CXXDefaultConstructor;
15524 member = CXXCopyAssignment;
15526 member = CXXDestructor;
15528 if (member != CXXInvalid) {
15529 if (!getLangOpts().CPlusPlus11 &&
15537 if (getSourceManager().isInSystemHeader(Loc)) {
15538 if (!FD->
hasAttr<UnavailableAttr>())
15539 FD->
addAttr(UnavailableAttr::CreateImplicit(Context,
"",
15540 UnavailableAttr::IR_ARCFieldWithOwnership, Loc));
15546 diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member :
15547 diag::err_illegal_union_or_anon_struct_member)
15549 DiagnoseNontrivial(RDecl, member);
15550 return !getLangOpts().CPlusPlus11;
15562 switch (ivarVisibility) {
15563 default: llvm_unreachable(
"Unknown visitibility kind");
15579 Expr *BitWidth = (
Expr*)BitfieldWidth;
15591 BitWidth = VerifyBitField(Loc, II, T,
false, BitWidth).get();
15601 Diag(Loc, diag::err_ivar_reference_type);
15607 Diag(Loc, diag::err_typecheck_ivar_variable_size);
15621 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
15622 if (LangOpts.ObjCRuntime.isFragile()) {
15624 EnclosingContext = IMPDecl->getClassInterface();
15625 assert(EnclosingContext &&
"Implementation has no class interface!");
15628 EnclosingContext = EnclosingDecl;
15631 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
15632 if (LangOpts.ObjCRuntime.isFragile() || !CDecl->IsClassExtension()) {
15633 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
15637 EnclosingContext = EnclosingDecl;
15642 DeclStart, Loc, II, T,
15643 TInfo, ac, (
Expr *)BitfieldWidth);
15646 NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
15647 ForVisibleRedeclaration);
15648 if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S)
15649 && !isa<TagDecl>(PrevDecl)) {
15650 Diag(Loc, diag::err_duplicate_member) << II;
15657 ProcessDeclAttributes(S, NewID, D);
15663 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewID))
15673 IdResolver.AddDecl(NewID);
15676 if (LangOpts.ObjCRuntime.isNonFragile() &&
15677 !NewID->
isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
15678 Diag(Loc, diag::warn_ivars_in_interface);
15689 if (LangOpts.ObjCRuntime.isFragile() || AllIvarDecls.empty())
15692 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
15700 if (!CD->IsClassExtension())
15712 DeclLoc, DeclLoc,
nullptr,
15718 AllIvarDecls.push_back(Ivar);
15725 assert(EnclosingDecl &&
"missing record or interface decl");
15730 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
15734 case Decl::ObjCCategory:
15735 Context.
ResetObjCLayout(cast<ObjCCategoryDecl>(DC)->getClassInterface());
15737 case Decl::ObjCImplementation:
15739 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
15749 unsigned NumNamedMembers = 0;
15751 for (
const auto *I : Record->
decls()) {
15752 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
15753 if (IFD->getDeclName())
15761 bool ObjCFieldLifetimeErrReported =
false;
15771 RecFields.push_back(FD);
15791 bool IsLastField = (i + 1 == Fields.end());
15800 (Record || isa<ObjCContainerDecl>(EnclosingDecl))) {
15806 unsigned DiagID = 0;
15807 if (!Record->
isUnion() && !IsLastField) {
15810 Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
15814 }
else if (Record->
isUnion())
15815 DiagID = getLangOpts().MicrosoftExt
15816 ? diag::ext_flexible_array_union_ms
15817 : getLangOpts().CPlusPlus
15818 ? diag::ext_flexible_array_union_gnu
15819 : diag::err_flexible_array_union;
15820 else if (NumNamedMembers < 1)
15821 DiagID = getLangOpts().MicrosoftExt
15822 ? diag::ext_flexible_array_empty_aggregate_ms
15823 : getLangOpts().CPlusPlus
15824 ? diag::ext_flexible_array_empty_aggregate_gnu
15825 : diag::err_flexible_array_empty_aggregate;
15835 if (CXXRecord && CXXRecord->getNumVBases() != 0)
15838 if (!getLangOpts().
C99)
15849 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
15864 diag::err_field_incomplete)) {
15889 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
15891 diag::err_abstract_type_in_decl,
15892 AbstractIvarType)) {
15906 }
else if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
15907 Record && !ObjCFieldLifetimeErrReported && Record->
isUnion()) {
15916 if (getSourceManager().isInSystemHeader(loc)) {
15917 if (!FD->
hasAttr<UnavailableAttr>()) {
15918 FD->
addAttr(UnavailableAttr::CreateImplicit(Context,
"",
15919 UnavailableAttr::IR_ARCFieldWithOwnership, loc));
15925 ObjCFieldLifetimeErrReported =
true;
15927 }
else if (getLangOpts().ObjC &&
15944 if (Record && !getLangOpts().
CPlusPlus && !FD->
hasAttr<UnavailableAttr>()) {
15957 if (RT->getDecl()->getArgPassingRestrictions() ==
15973 bool Completed =
false;
15975 if (!CXXRecord->isInvalidDecl()) {
15978 I = CXXRecord->conversion_begin(),
15979 E = CXXRecord->conversion_end(); I != E; ++I)
15980 I.setAccess((*I)->getAccess());
15983 if (!CXXRecord->isDependentType()) {
15985 AddImplicitlyDeclaredMembersToClass(CXXRecord);
15987 if (!CXXRecord->isInvalidDecl()) {
15991 if (CXXRecord->getNumVBases()) {
15993 CXXRecord->getFinalOverriders(FinalOverriders);
15995 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
15996 MEnd = FinalOverriders.end();
15999 SOEnd = M->second.end();
16000 SO != SOEnd; ++SO) {
16001 assert(SO->second.size() > 0 &&
16002 "Virtual function without overriding functions?");
16003 if (SO->second.size() == 1)
16011 << (
const NamedDecl *)M->first << Record;
16012 Diag(M->first->getLocation(),
16013 diag::note_overridden_virtual_function);
16015 OM = SO->second.begin(),
16016 OMEnd = SO->second.end();
16018 Diag(OM->Method->getLocation(), diag::note_final_overrider)
16019 << (
const NamedDecl *)M->first << OM->Method->getParent();
16024 CXXRecord->completeDefinition(&FinalOverriders);
16035 ProcessDeclAttributeList(S, Record, Attrs);
16039 auto *Dtor = CXXRecord->getDestructor();
16040 if (Dtor && Dtor->isImplicit() &&
16041 ShouldDeleteSpecialMember(Dtor, CXXDestructor)) {
16042 CXXRecord->setImplicitDestructorIsDeleted();
16043 SetDeclDeleted(Dtor, CXXRecord->getLocation());
16048 CheckAlignasUnderalignment(Record);
16050 if (
const MSInheritanceAttr *IA = Record->
getAttr<MSInheritanceAttr>())
16051 checkMSInheritanceAttrOnDefinition(cast<CXXRecordDecl>(Record),
16052 IA->getRange(), IA->getBestCase(),
16053 IA->getSemanticSpelling());
16059 bool CheckForZeroSize;
16060 if (!getLangOpts().CPlusPlus) {
16061 CheckForZeroSize =
true;
16070 if (CheckForZeroSize) {
16071 bool ZeroSize =
true;
16072 bool IsEmpty =
true;
16073 unsigned NonBitFields = 0;
16076 (NonBitFields == 0 || ZeroSize) && I != E; ++I) {
16078 if (I->isUnnamedBitfield()) {
16079 if (!I->isZeroLengthBitField(Context))
16083 QualType FieldType = I->getType();
16095 diag::warn_zero_size_struct_union_in_extern_c :
16096 diag::warn_zero_size_struct_union_compat)
16097 << IsEmpty << Record->
isUnion() << (NonBitFields > 1);
16102 if (NonBitFields == 0 && !getLangOpts().CPlusPlus) {
16103 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union :
16104 diag::ext_no_named_members_in_struct_union)
16112 ID->setEndOfDefinitionLoc(RBrac);
16114 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
16116 ID->addDecl(ClsFields[i]);
16120 if (
ID->getSuperClass())
16121 DiagnoseDuplicateIvars(
ID,
ID->getSuperClass());
16123 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
16124 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
16125 for (
unsigned I = 0, N = RecFields.size(); I != N; ++I)
16128 ClsFields[I]->setLexicalDeclContext(IMPDecl);
16129 CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
16130 IMPDecl->setIvarLBraceLoc(LBrac);
16131 IMPDecl->setIvarRBraceLoc(RBrac);
16133 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
16141 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
16145 Diag(ClsFields[i]->getLocation(),
16146 diag::err_duplicate_ivar_declaration);
16147 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
16153 Diag(ClsFields[i]->getLocation(),
16154 diag::err_duplicate_ivar_declaration);
16155 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
16161 CDecl->addDecl(ClsFields[i]);
16163 CDecl->setIvarLBraceLoc(LBrac);
16164 CDecl->setIvarRBraceLoc(RBrac);
16172 llvm::APSInt &
Value,
16175 "Integral type required!");
16178 if (Value.isUnsigned() || Value.isNonNegative()) {
16181 return Value.getActiveBits() <= BitWidth;
16183 return Value.getMinSignedBits() <= BitWidth;
16193 const unsigned NumTypes = 4;
16194 QualType SignedIntegralTypes[NumTypes] = {
16197 QualType UnsignedIntegralTypes[NumTypes] = {
16204 : UnsignedIntegralTypes;
16205 for (
unsigned I = 0; I != NumTypes; ++I)
16218 llvm::APSInt EnumVal(IntWidth);
16221 if (Val && DiagnoseUnexpandedParameterPack(Val, UPPC_EnumeratorValue))
16225 Val = DefaultLvalueConversion(Val).get();
16231 if (getLangOpts().CPlusPlus11 && Enum->
isFixed() &&
16232 !getLangOpts().MSVCCompat) {
16243 Val = Converted.
get();
16245 !(Val = VerifyIntegerConstantExpression(Val,
16246 &EnumVal).get())) {
16257 if (getLangOpts().MSVCCompat) {
16258 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
16259 Val = ImpCastExprToType(Val, EltTy, CK_IntegralCast).get();
16261 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
16263 Val = ImpCastExprToType(Val, EltTy,
16265 CK_IntegralToBoolean : CK_IntegralCast)
16282 Diag(IdLoc, diag::ext_enum_value_not_int)
16284 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
16287 Val = ImpCastExprToType(Val, Context.
IntTy, CK_IntegralCast).get();
16296 if (Enum->isDependentType())
16298 else if (!LastEnumConst) {
16307 if (Enum->isFixed()) {
16308 EltTy = Enum->getIntegerType();
16311 EltTy = Context.
IntTy;
16315 EnumVal = LastEnumConst->getInitVal();
16317 EltTy = LastEnumConst->getType();
16320 if (EnumVal < LastEnumConst->getInitVal()) {
16332 if (T.
isNull() || Enum->isFixed()) {
16335 EnumVal = LastEnumConst->getInitVal();
16336 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
16338 if (Enum->isFixed())
16340 Diag(IdLoc, diag::err_enumerator_wrapped)
16341 << EnumVal.toString(10)
16344 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
16345 << EnumVal.toString(10);
16353 EnumVal = LastEnumConst->getInitVal();
16354 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
16355 EnumVal = EnumVal.zextOrTrunc(Context.
getIntWidth(EltTy));
16363 if (!getLangOpts().CPlusPlus && !T.
isNull())
16364 Diag(IdLoc, diag::warn_enum_value_overflow);
16365 }
else if (!getLangOpts().CPlusPlus &&
16368 Diag(IdLoc, diag::ext_enum_value_not_int)
16369 << EnumVal.toString(10) << 1;
16374 if (!EltTy->isDependentType()) {
16377 EnumVal = EnumVal.extOrTrunc(Context.
getIntWidth(EltTy));
16378 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
16387 if (!(getLangOpts().Modules || getLangOpts().ModulesLocalVisibility) ||
16394 NamedDecl *PrevDecl = LookupSingleName(S, II, IILoc, LookupOrdinaryName,
16395 forRedeclarationInCurContext());
16396 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
16400 EnumDecl *PrevED = cast<EnumDecl>(PrevECD->getDeclContext());
16402 if (!PrevED->
getDeclName() && !hasVisibleDefinition(PrevED, &Hidden)) {
16415 EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl);
16417 cast_or_null<EnumConstantDecl>(lastEnumConst);
16421 S = getNonFieldDeclScope(S);
16425 LookupResult R(*
this, Id, IdLoc, LookupOrdinaryName, ForVisibleRedeclaration);
16431 DiagnoseTemplateParameterShadow(IdLoc, PrevDecl);
16433 PrevDecl =
nullptr;
16446 CheckEnumConstant(TheEnumDecl, LastEnumConst, IdLoc, Id, Val);
16451 if (!TheEnumDecl->
isScoped() && isa<ValueDecl>(PrevDecl)) {
16453 CheckShadow(New, PrevDecl, R);
16458 assert((getLangOpts().
CPlusPlus || !isa<TagDecl>(PrevDecl)) &&
16459 "Received TagDecl when not in C++!");
16460 if (!isa<TagDecl>(PrevDecl) && isDeclInScope(PrevDecl, CurContext, S)) {
16461 if (isa<EnumConstantDecl>(PrevDecl))
16462 Diag(IdLoc, diag::err_redefinition_of_enumerator) <<
Id;
16464 Diag(IdLoc, diag::err_redefinition) <<
Id;
16465 notePreviousDefinition(PrevDecl, IdLoc);
16471 ProcessDeclAttributeList(S, New, Attrs);
16472 AddPragmaAttributes(S, New);
16476 PushOnScopeChains(New, S);
16478 ActOnDocumentableDecl(New);
16496 if (!BO->isAdditiveOp())
16504 InitExpr = BO->getLHS();
16541 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
16542 typedef std::unordered_map<int64_t, DeclOrVector> ValueToVectorMap;
16546 llvm::APSInt Val = D->getInitVal();
16547 return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
16550 DuplicatesVector DupVector;
16551 ValueToVectorMap EnumMap;
16555 for (
auto *Element : Elements) {
16569 EnumMap.insert({EnumConstantToKey(ECD), ECD});
16572 if (EnumMap.size() == 0)
16576 for (
auto *Element : Elements) {
16582 auto Iter = EnumMap.find(EnumConstantToKey(ECD));
16583 if (Iter == EnumMap.end())
16586 DeclOrVector& Entry = Iter->second;
16593 auto Vec = llvm::make_unique<ECDVector>();
16595 Vec->push_back(ECD);
16602 DupVector.emplace_back(std::move(Vec));
16606 ECDVector *Vec = Entry.get<ECDVector*>();
16608 if (*Vec->begin() == ECD)
16611 Vec->push_back(ECD);
16615 for (
const auto &Vec : DupVector) {
16616 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
16619 auto *FirstECD = Vec->front();
16620 S.
Diag(FirstECD->getLocation(), diag::warn_duplicate_enum_values)
16621 << FirstECD << FirstECD->getInitVal().toString(10)
16622 << FirstECD->getSourceRange();
16626 for (
auto *ECD : llvm::make_range(Vec->begin() + 1, Vec->end()))
16627 S.
Diag(ECD->getLocation(), diag::note_duplicate_element)
16628 << ECD << ECD->getInitVal().toString(10)
16629 << ECD->getSourceRange();
16634 bool AllowMask)
const {
16635 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
16638 auto R = FlagBitsCache.insert(std::make_pair(ED, llvm::APInt()));
16639 llvm::APInt &FlagBits = R.first->second;
16643 const auto &EVal = E->getInitVal();
16645 if (EVal.isPowerOf2())
16646 FlagBits = FlagBits.zextOrSelf(EVal.getBitWidth()) | EVal;
16658 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
16659 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
16665 EnumDecl *Enum = cast<EnumDecl>(EnumDeclX);
16668 ProcessDeclAttributeList(S, Enum, Attrs);
16671 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
16673 cast_or_null<EnumConstantDecl>(Elements[i]);
16674 if (!ECD)
continue;
16692 unsigned NumNegativeBits = 0;
16693 unsigned NumPositiveBits = 0;
16696 bool AllElementsInt =
true;
16698 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
16700 cast_or_null<EnumConstantDecl>(Elements[i]);
16701 if (!ECD)
continue;
16703 const llvm::APSInt &InitVal = ECD->
getInitVal();
16706 if (InitVal.isUnsigned() || InitVal.isNonNegative())
16707 NumPositiveBits =
std::max(NumPositiveBits,
16708 (
unsigned)InitVal.getActiveBits());
16710 NumNegativeBits =
std::max(NumNegativeBits,
16711 (
unsigned)InitVal.getMinSignedBits());
16714 if (AllElementsInt)
16720 unsigned BestWidth;
16733 bool Packed = Enum->
hasAttr<PackedAttr>();
16736 if (LangOpts.ShortEnums)
16746 BestPromotionType = BestType;
16750 else if (NumNegativeBits) {
16754 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
16756 BestWidth = CharWidth;
16757 }
else if (Packed && NumNegativeBits <= ShortWidth &&
16758 NumPositiveBits < ShortWidth) {
16760 BestWidth = ShortWidth;
16761 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
16762 BestType = Context.
IntTy;
16763 BestWidth = IntWidth;
16767 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
16768 BestType = Context.
LongTy;
16772 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
16777 BestPromotionType = (BestWidth <= IntWidth ? Context.
IntTy : BestType);
16782 if (Packed && NumPositiveBits <= CharWidth) {
16784 BestPromotionType = Context.
IntTy;
16785 BestWidth = CharWidth;
16786 }
else if (Packed && NumPositiveBits <= ShortWidth) {
16788 BestPromotionType = Context.
IntTy;
16789 BestWidth = ShortWidth;
16790 }
else if (NumPositiveBits <= IntWidth) {
16792 BestWidth = IntWidth;
16794 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
16796 }
else if (NumPositiveBits <=
16800 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
16804 assert(NumPositiveBits <= BestWidth &&
16805 "How could an initializer get larger than ULL?");
16808 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
16815 for (
auto *D : Elements) {
16816 auto *ECD = cast_or_null<EnumConstantDecl>(D);
16817 if (!ECD)
continue;
16826 llvm::APSInt InitVal = ECD->getInitVal();
16836 NewTy = Context.
IntTy;
16837 NewWidth = IntWidth;
16839 }
else if (ECD->getType() == BestType) {
16841 if (getLangOpts().CPlusPlus)
16845 ECD->setType(EnumType);
16849 NewWidth = BestWidth;
16854 InitVal = InitVal.extOrTrunc(NewWidth);
16855 InitVal.setIsSigned(NewSign);
16856 ECD->setInitVal(InitVal);
16859 if (ECD->getInitExpr() &&
16860 !Context.
hasSameType(NewTy, ECD->getInitExpr()->getType()))
16863 ECD->getInitExpr(),
16866 if (getLangOpts().CPlusPlus)
16870 ECD->setType(EnumType);
16872 ECD->setType(NewTy);
16876 NumPositiveBits, NumNegativeBits);
16881 for (
Decl *D : Elements) {
16883 if (!ECD)
continue;
16886 if (InitVal != 0 && !InitVal.isPowerOf2() &&
16887 !IsValueInFlagEnum(Enum, InitVal,
true))
16895 CheckAlignasUnderalignment(Enum);
16904 AsmString, StartLoc,
16906 CurContext->addDecl(New);
16912 bool FromInclude =
false) {
16915 if (
auto *LSD = dyn_cast<LinkageSpecDecl>(DC)) {
16916 switch (LSD->getLanguage()) {
16919 ExternCLoc = LSD->getBeginLoc();
16927 while (isa<LinkageSpecDecl>(DC) || isa<ExportDecl>(DC))
16930 if (!isa<TranslationUnitDecl>(DC)) {
16932 ? diag::ext_module_import_not_at_top_level_noop
16933 : diag::err_module_import_not_at_top_level_fatal)
16935 S.
Diag(cast<Decl>(DC)->getBeginLoc(),
16936 diag::note_module_import_not_at_top_level)
16939 S.
Diag(ImportLoc, diag::ext_module_import_in_extern_c)
16941 S.
Diag(ExternCLoc, diag::note_extern_c_begins_here);
16949 assert(getLangOpts().ModulesTS &&
16950 "should only have module decl in modules TS");
16955 switch (getLangOpts().getCompilingModule()) {
16961 if (MDK != ModuleDeclKind::Implementation)
16966 Diag(ModuleLoc, diag::err_module_interface_implementation_mismatch)
16968 MDK = ModuleDeclKind::Interface;
16972 Diag(ModuleLoc, diag::err_module_decl_in_module_map_module);
16976 Diag(ModuleLoc, diag::err_module_decl_in_header_module);
16980 assert(ModuleScopes.size() == 1 &&
"expected to be at global module scope");
16987 Diag(ModuleLoc, diag::err_module_redeclaration);
16988 Diag(VisibleModules.getImportLoc(ModuleScopes.back().Module),
16989 diag::note_prev_module_declaration);
16996 std::string ModuleName;
16997 for (
auto &Piece : Path) {
16998 if (!ModuleName.empty())
17000 ModuleName += Piece.first->getName();
17005 if (!getLangOpts().CurrentModule.empty() &&
17006 getLangOpts().CurrentModule != ModuleName) {
17007 Diag(Path.front().second, diag::err_current_module_name_mismatch)
17008 <<
SourceRange(Path.front().second, Path.back().second)
17009 << getLangOpts().CurrentModule;
17012 const_cast<LangOptions&
>(getLangOpts()).CurrentModule = ModuleName;
17014 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
17018 case ModuleDeclKind::Interface: {
17021 if (
auto *M = Map.findModule(ModuleName)) {
17022 Diag(Path[0].second, diag::err_module_redefinition) << ModuleName;
17023 if (M->DefinitionLoc.isValid())
17024 Diag(M->DefinitionLoc, diag::note_prev_module_definition);
17025 else if (
const auto *FE = M->getASTFile())
17026 Diag(M->DefinitionLoc, diag::note_prev_module_definition_from_ast_file)
17033 Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
17034 ModuleScopes.front().Module);
17035 assert(Mod &&
"module creation should not fail");
17039 case ModuleDeclKind::Partition:
17043 case ModuleDeclKind::Implementation:
17044 std::pair<IdentifierInfo *, SourceLocation> ModuleNameLoc(
17045 PP.getIdentifierInfo(ModuleName), Path[0].second);
17046 Mod = getModuleLoader().loadModule(ModuleLoc, {ModuleNameLoc},
17050 Diag(ModuleLoc, diag::err_module_not_defined) << ModuleName;
17052 Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
17053 ModuleScopes.front().Module);
17059 ModuleScopes.back().Module = Mod;
17060 ModuleScopes.back().ModuleInterface = MDK != ModuleDeclKind::Implementation;
17061 VisibleModules.setVisible(Mod, ModuleLoc);
17068 TU->setLocalOwningModule(Mod);
17078 std::pair<IdentifierInfo *, SourceLocation> ModuleNameLoc;
17079 if (getLangOpts().ModulesTS) {
17080 std::string ModuleName;
17081 for (
auto &Piece : Path) {
17082 if (!ModuleName.empty())
17084 ModuleName += Piece.first->getName();
17086 ModuleNameLoc = {PP.getIdentifierInfo(ModuleName), Path[0].second};
17096 VisibleModules.setVisible(Mod, ImportLoc);
17106 (getLangOpts().isCompilingModule() || !getLangOpts().ModulesTS))
17107 Diag(ImportLoc, getLangOpts().isCompilingModule()
17108 ? diag::err_module_self_import
17109 : diag::err_module_import_in_implementation)
17114 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
17119 ModCheck = ModCheck->
Parent;
17121 IdentifierLocs.push_back(Path[I].second);
17125 Mod, IdentifierLocs);
17126 if (!ModuleScopes.empty())
17128 CurContext->addDecl(Import);
17132 !ModuleScopes.empty() && ModuleScopes.back().ModuleInterface)
17133 getCurrentModule()->Exports.emplace_back(Mod,
false);
17140 BuildModuleInclude(DirectiveLoc, Mod);
17149 bool IsInModuleIncludes =
17151 getSourceManager().isWrittenInMainFile(DirectiveLoc);
17153 bool ShouldAddImport = !IsInModuleIncludes;
17157 if (ShouldAddImport) {
17162 if (!ModuleScopes.empty())
17165 Consumer.HandleImplicitImportDecl(ImportD);
17169 VisibleModules.setVisible(Mod, DirectiveLoc);
17175 ModuleScopes.push_back({});
17176 ModuleScopes.back().Module = Mod;
17177 if (getLangOpts().ModulesLocalVisibility)
17178 ModuleScopes.back().OuterVisibleModules = std::move(VisibleModules);
17180 VisibleModules.setVisible(Mod, DirectiveLoc);
17185 if (getLangOpts().trackLocalOwningModule()) {
17186 for (
auto *DC = CurContext; DC; DC = DC->getLexicalParent()) {
17187 cast<Decl>(DC)->setModuleOwnershipKind(
17188 getLangOpts().ModulesLocalVisibility
17191 cast<Decl>(DC)->setLocalOwningModule(Mod);
17197 if (getLangOpts().ModulesLocalVisibility) {
17198 VisibleModules = std::move(ModuleScopes.back().OuterVisibleModules);
17201 VisibleNamespaceCache.clear();
17204 assert(!ModuleScopes.empty() && ModuleScopes.back().Module == Mod &&
17205 "left the wrong module scope");
17206 ModuleScopes.pop_back();
17210 FileID File = getSourceManager().getFileID(EomLoc);
17212 if (EomLoc == getSourceManager().getLocForEndOfFile(File)) {
17214 assert(File != getSourceManager().getMainFileID() &&
17215 "end of submodule in main source file");
17216 DirectiveLoc = getSourceManager().getIncludeLoc(File);
17219 DirectiveLoc = EomLoc;
17221 BuildModuleInclude(DirectiveLoc, Mod);
17224 if (getLangOpts().trackLocalOwningModule()) {
17227 for (
auto *DC = CurContext; DC; DC = DC->getLexicalParent()) {
17228 cast<Decl>(DC)->setLocalOwningModule(getCurrentModule());
17229 if (!getCurrentModule())
17230 cast<Decl>(DC)->setModuleOwnershipKind(
17239 if (isSFINAEContext() || !getLangOpts().ModulesErrorRecovery ||
17240 VisibleModules.isVisible(Mod))
17248 Consumer.HandleImplicitImportDecl(ImportD);
17252 VisibleModules.setVisible(Mod, Loc);
17264 if (ModuleScopes.empty() || !ModuleScopes.back().ModuleInterface)
17265 Diag(ExportLoc, diag::err_export_not_in_module_interface);
17273 Diag(ExportLoc, diag::err_export_within_export);
17275 CurContext->addDecl(D);
17276 PushDeclContext(S, D);
17283 auto *ED = cast<ExportDecl>(D);
17285 ED->setRBraceLoc(RBraceLoc);
17299 NamedDecl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc,
17300 LookupOrdinaryName);
17301 AsmLabelAttr *
Attr =
17302 AsmLabelAttr::CreateImplicit(Context, AliasName->
getName(), AliasNameLoc);
17308 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
17312 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
17313 << (isa<FunctionDecl>(PrevDecl) ? 0 : 1) << PrevDecl;
17316 (
void)ExtnameUndeclaredIdentifiers.insert(std::make_pair(Name, Attr));
17322 Decl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName);
17325 PrevDecl->
addAttr(WeakAttr::CreateImplicit(Context, PragmaLoc));
17327 (void)WeakUndeclaredIdentifiers.insert(
17328 std::pair<IdentifierInfo*,WeakInfo>
17338 Decl *PrevDecl = LookupSingleName(TUScope, AliasName, AliasNameLoc,
17339 LookupOrdinaryName);
17342 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
17343 if (!PrevDecl->
hasAttr<AliasAttr>())
17344 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
17345 DeclApplyPragmaWeak(TUScope, ND, W);
17347 (void)WeakUndeclaredIdentifiers.insert(
17348 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W));
17353 return (dyn_cast_or_null<ObjCContainerDecl>(CurContext));
static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, const FunctionDecl *&PossibleZeroParamPrototype)
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
A call to an overloaded operator written using operator syntax.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
Defines the clang::ASTContext interface.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCallToStdMove() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
PragmaStack< StringLiteral * > CodeSegStack
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
Represents a function declaration or definition.
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Name lookup found a set of overloaded functions that met the criteria.
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Decl * ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
bool isPure(unsigned ID) const
Return true if this function has no side effects.
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
void setNonTrivialToPrimitiveDestroy(bool V)
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
static void CheckForDuplicateEnumValues(Sema &S, ArrayRef< Decl *> Elements, EnumDecl *Enum, QualType EnumType)
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
bool CheckNontrivialField(FieldDecl *FD)
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
no exception specification
QualType getObjCIdType() const
Represents the Objective-CC id type.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void setAnonymousStructOrUnion(bool Anon)
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
A (possibly-)qualified type.
Keeps information about an identifier in a nested-name-spec.
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, tok::ObjCKeywordKind visibility)
ActOnIvar - Each ivar field of an objective-c class is passed into this in order to create an IvarDec...
bool isBlockPointerType() const
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
Simple class containing the result of Sema::CorrectTypo.
void addThisCapture(bool isNested, SourceLocation Loc, Expr *Cpy, bool ByCopy)
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
void InstantiatedLocal(const Decl *D, Decl *Inst)
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc, bool IsTemplateId)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword)...
const DeclarationNameLoc & getInfo() const
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
static void adjustDeclContextForDeclaratorDecl(DeclaratorDecl *NewD, DeclaratorDecl *OldD)
If necessary, adjust the semantic declaration context for a qualified declaration to name the correct...
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
A class which encapsulates the logic for delaying diagnostics during parsing and other processing...
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
void MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New, LookupResult &OldDecls)
MergeTypedefNameDecl - We just parsed a typedef 'New' which has the same name and scope as a previous...
This declaration has an owning module, but is only visible to lookups that occur within that module...
ExtInfo withNoCallerSavedRegs(bool noCallerSavedRegs) const
static ShadowedDeclKind computeShadowedDeclKind(const NamedDecl *ShadowedDecl, const DeclContext *OldDC)
Determine what kind of declaration we're shadowing.
void setAttrs(const AttrVec &Attrs)
void CheckCompleteVariableDeclaration(VarDecl *VD)
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
void setNonTrivialToPrimitiveDefaultInitialize(bool V)
AmbiguityKind getAmbiguityKind() const
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl *> CH)
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
void setStarLoc(SourceLocation Loc)
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
Filter makeFilter()
Create a filter for this result set.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function...
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
An instance of this object exists for each enum constant that is defined.
bool EvaluateAsInitializer(APValue &Result, const ASTContext &Ctx, const VarDecl *VD, SmallVectorImpl< PartialDiagnosticAt > &Notes) const
EvaluateAsInitializer - Evaluate an expression as if it were the initializer of the given declaration...
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
RAII object that pops an ExpressionEvaluationContext when exiting a function body.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Defines the SourceManager interface.
void setObjCClassRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, TemplateArgumentListInfo TemplateArgs)
bool hasVolatileMember() const
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
bool isRecordType() const
bool isEmpty() const
No scope specifier.
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
void erase()
Erase the last element returned from this iterator.
static const TST TST_typeofExpr
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
bool isVariadic() const
Whether this function prototype is variadic.
SourceLocation getBeginLoc() const LLVM_READONLY
void forgetBuiltin(unsigned ID, IdentifierTable &Table)
Completely forget that the given ID was ever considered a builtin, e.g., because the user provided a ...
const RecordType * getAsStructureType() const
CommonAttr * mergeCommonAttr(Decl *D, const ParsedAttr &AL)
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
void setArgPassingRestrictions(ArgPassingKind Kind)
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
bool isModuleVisible(const Module *M, bool ModulePrivate=false)
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true)
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function...
static StringRef getHeaderName(ASTContext::GetBuiltinTypeError Error)
bool isPrintfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like printf in its formatting rules and, if so, set the index to th...
SmallVectorImpl< NamedDecl * >::const_iterator const_decl_iterator
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
bool isPOD() const
Whether this class is a POD-type (C++ [class]p4)
Defines the C++ template declaration subclasses.
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...
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Represents a C++11 auto or C++14 decltype(auto) type.
static bool canRedefineFunction(const FunctionDecl *FD, const LangOptions &LangOpts)
canRedefineFunction - checks if a function can be redefined.
void setPure(bool P=true)
void setPreviousDeclaration(FunctionDecl *PrevDecl)
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
bool hasWrittenPrototype() const
Whether this function has a written prototype.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD, bool &Redeclaration, NamedDecl *&OldDecl, bool &MergeTypeWithPrevious, LookupResult &Previous)
Check the validity of a mulitversion function declaration.
A constructor named via a template-id.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
The base class of the type hierarchy.
static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New)
static void checkDuplicateDefaultInit(Sema &S, CXXRecordDecl *Parent, SourceLocation DefaultInitLoc)
SourceLocation getBeginLoc() const LLVM_READONLY
One instance of this struct is used for each type in a declarator that is parsed. ...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
Represent a C++ namespace.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
Represents a call to a C++ constructor.
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getEndLoc() const LLVM_READONLY
virtual void completeDefinition()
Note that the definition of this type is now complete.
bool isZero() const
isZero - Test whether the quantity equals zero.
SourceLocation getEndLoc() const LLVM_READONLY
const TargetInfo & getTargetInfo() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
void ActOnExitFunctionContext()
const NestedNameSpecifier * Specifier
A container of type source information.
static Attr * getImplicitCodeSegAttrFromClass(Sema &S, const FunctionDecl *FD)
Return a CodeSegAttr from a containing class.
Wrapper for void* pointer.
capture_const_range captures() const
Look up of a name that precedes the '::' scope resolution operator in C++.
static NestedNameSpecifier * synthesizeCurrentNestedNameSpecifier(ASTContext &Context, DeclContext *DC)
SourceRange getIntegerTypeRange() const LLVM_READONLY
Retrieve the source range that covers the underlying type if specified.
An overloaded operator name, e.g., operator+.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
static unsigned GetDiagnosticTypeSpecifierID(DeclSpec::TST T)
TSCS getThreadStorageClassSpec() const
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
void setInitStyle(InitializationStyle Style)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
unsigned getCharWidth() const
param_const_iterator param_end() const
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext...
size_t param_size() const
SourceLocation getEndLoc() const
Get the end source location.
const ParsedAttributes & getAttributes() const
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
bool hasAttribute(ParsedAttr::Kind K) const
QualType getElementType() const
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
***static FixItHint createFriendTagNNSFixIt(Sema &SemaRef, NamedDecl *ND, Scope *S, SourceLocation NameLoc)
The type would be trivial except that it is volatile-qualified.
Retains information about a function, method, or block that is currently being parsed.
This file provides some common utility functions for processing Lambda related AST Constructs...
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class, then each of the following shall have a name different from T:
void setRAngleLoc(SourceLocation Loc)
void ActOnObjCReenterContainerContext(DeclContext *DC)
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
enumerator_range enumerators() const
Compiling a C++ modules TS module interface unit.
Represents a variable declaration or definition.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool isStructureType() const
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isExplicit, bool isConstexpr, SourceLocation EndLocation)
static const TST TST_underlyingType
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
DeclarationName getLookupName() const
Gets the name to look up.
Information about one declarator, including the parsed type information and the identifier.
QualType getReturnType() const
DiagnosticsEngine & Diags
unsigned getNumParams() const
bool isEnumeralType() const
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
const T * getAs() const
Member-template getAs<specific type>'.
static void SetNestedNameSpecifier(Sema &S, DeclaratorDecl *DD, Declarator &D)
Extra information about a function prototype.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
TypeSpecifierType
Specifies the kind of type.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
The "__interface" keyword.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
ExtInfo withProducesResult(bool producesResult) const
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
void ActOnObjCTemporaryExitContainerContext(DeclContext *DC)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
static const TST TST_interface
bool isZeroLengthBitField(const ASTContext &Ctx) const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
bool isInvalidDecl() const
bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD)
AddOverriddenMethods - See if a method overrides any in the base classes, and if so, check that it's a valid override and remember it.
QualType getObjCClassType() const
Represents the Objective-C Class type.
Stores a list of template parameters for a TemplateDecl and its derived classes.
static StringRef getTagTypeKindName(TagTypeKind Kind)
bool isCallingConv() const
Describes how types, statements, expressions, and declarations should be printed. ...
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Decl * ActOnParamDeclarator(Scope *S, Declarator &D)
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
llvm::SmallVector< ShadowedOuterDecl, 4 > ShadowingDecls
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *&Init)
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
bool hasDefinition() const
static QualType getCoreType(QualType Ty)
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
static const NamedDecl * getDefinition(const Decl *D)
Represents a parameter to a function.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
void removeDecl(Decl *D)
Removes a declaration from this context.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
static TypeSourceInfo * TryToFixInvalidVariablyModifiedTypeSourceInfo(TypeSourceInfo *TInfo, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
Helper method to turn variable array types into constant array types in certain situations which woul...
bool isVariableArrayType() const
Information about a template-id annotation token.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
ModuleKind Kind
The kind of this module.
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
HandleField - Analyze a field of a C struct or a C++ data member.
static bool CheckMultiVersionFirstFunction(Sema &S, FunctionDecl *FD, MultiVersionKind MVType, const TargetAttr *TA, const CPUDispatchAttr *CPUDisp, const CPUSpecificAttr *CPUSpec)
Check the validity of a multiversion function declaration that is the first of its kind...
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
void ActOnUninitializedDecl(Decl *dcl)
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
bool isRedeclaration() const
Represents a struct/union/class.
void DiagnoseSizeOfParametersAndReturnValue(ArrayRef< ParmVarDecl *> Parameters, QualType ReturnTy, NamedDecl *D)
Diagnose whether the size of parameters or return value of a function or obj-c method definition is p...
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
static bool CheckTargetCausesMultiVersioning(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, const TargetAttr *NewTA, bool &Redeclaration, NamedDecl *&OldDecl, bool &MergeTypeWithPrevious, LookupResult &Previous)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
bool isComplete() const
Returns true if this can be considered a complete type.
One of these records is kept for each identifier that is lexed.
void setIntegerType(QualType T)
Set the underlying integer type.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations. ...
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
static bool isFunctionDefinitionDiscarded(Sema &S, FunctionDecl *FD)
Given that we are within the definition of the given function, will that definition behave like C99's...
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S)
Register the given locally-scoped extern "C" declaration so that it can be found later for redeclarat...
static bool isDeclExternC(const Decl *D)
Returns true if given declaration has external C language linkage.
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld)
MergeVarDeclTypes - We parsed a variable 'New' which has the same name and scope as a previous declar...
static bool hasDeducedAuto(DeclaratorDecl *DD)
unsigned getRegParm() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
void setManglingNumber(const NamedDecl *ND, unsigned Number)
static void mergeParamDeclTypes(ParmVarDecl *NewParam, const ParmVarDecl *OldParam, Sema &S)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
ArrayRef< QualType > getParamTypes() const
The results of name lookup within a DeclContext.
SourceLocation getTypeSpecTypeLoc() const
const ParmVarDecl *const * param_const_iterator
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
TypeLoc getInnerLoc() const
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e...
Missing a type from <ucontext.h>
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
unsigned getFunctionPrototypeDepth() const
Returns the number of function prototype scopes in this scope chain.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
field_range fields() const
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
SourceLocation getBeginLoc() const LLVM_READONLY
static const TST TST_class
NameKind getNameKind() const
Determine what kind of name this is.
bool isObjCIdType() const
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl *> Bindings)
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
Represents a member of a struct/union/class.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
const llvm::APSInt & getInitVal() const
bool supportsMultiVersioning() const
Identify whether this target supports multiversioning of functions, which requires support for cpu_su...
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
OverloadedOperatorKind Operator
The kind of overloaded operator.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
static bool isIncrementDecrementOp(Opcode Op)
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
bool isFunctionDefinition() const
void startDefinition()
Starts the definition of this tag declaration.
Attr * getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, bool IsDefinition)
Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a containing class...
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
bool hasAutoTypeSpec() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
bool isReferenceType() const
void setElaboratedKeywordLoc(SourceLocation Loc)
The iterator over UnresolvedSets.
static const TST TST_error
Token - This structure provides full information about a lexed token.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
bool isInIdentifierNamespace(unsigned NS) const
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT)
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool isLinkageValid() const
True if the computed linkage is valid.
This declaration is definitely a definition.
static const TST TST_enum
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, bool IsExplicit, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation)
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
LookupResultKind getResultKind() const
bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S)
isMicrosoftMissingTypename - In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal...
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
void ClearStorageClassSpecs()
SourceLocation getBeginLoc() const LLVM_READONLY
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Declaration of a function specialization at template class scope.
ArrayRef< std::pair< IdentifierInfo *, SourceLocation > > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule, e.g., std.vector.
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
SourceLocation getTemplateLoc() const
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, SourceRange Range, TypeVisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
void PopExpressionEvaluationContext()
Compiling a module from a module map.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
A user-defined literal name, e.g., operator "" _i.
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Describes a module or submodule.
RawCommentList & getRawCommentList()
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
ArrayRef< ParmVarDecl * > parameters() const
bool canKeyFunctionBeInline() const
Can an out-of-line inline function serve as a key function?
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool getProducesResult() const
DeclClass * getAsSingle() const
static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, DeclContext *Owner, RecordDecl *AnonRecord, AccessSpecifier AS, SmallVectorImpl< NamedDecl *> &Chaining)
InjectAnonymousStructOrUnionMembers - Inject the members of the anonymous struct or union AnonRecord ...
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
bool isReplaceableGlobalAllocationFunction(bool *IsAligned=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
Describes an C or C++ initializer list.
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
Represents a C++ unqualified-id that has been parsed.
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
bool isBitField() const
Determines whether this field is a bitfield.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
void setNameLoc(SourceLocation Loc)
Represents the results of name lookup.
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, unsigned AttrSpellingListIndex)
Attribute merging methods. Return true if a new attribute was added.
bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn)
We've just determined that Old and New both appear to be definitions of the same variable.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl *> Bindings=None)
bool isElidable() const
Whether this construction is elidable.
ObjCContainerDecl - Represents a container for method declarations.
static void filterNonConflictingPreviousTypedefDecls(Sema &S, TypedefNameDecl *Decl, LookupResult &Previous)
Typedef declarations don't have linkage, but they still denote the same entity if their types are the...
TagKind getTagKind() const
bool isReferenced() const
Whether any declaration of this entity was referenced.
CharUnits - This is an opaque type for sizes expressed in character units.
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
void setcudaConfigureCallDecl(FunctionDecl *FD)
void setParamDestroyedInCallee(bool V)
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
bool ActOnDuplicateDefinition(DeclSpec &DS, Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old)
Merge alignment attributes from Old to New, taking into account the special semantics of C11's _Align...
bool hasAddressSpace() const
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes, if any.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
Wrapper for source info for functions.
static void RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator, Sema &S)
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
SCS
storage-class-specifier
static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl *> Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Decl * getObjCDeclContext() const
Visibility
Describes the different kinds of visibility that a declaration may have.
Decl * ActOnObjCContainerStartDefinition(Decl *IDecl)
static ParsedType recoverFromTypeInKnownDependentBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc)
A friend of a previously-undeclared entity.
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
SourceLocation getBeginLoc() const LLVM_READONLY
Concrete class used by the front-end to report problems and issues.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
bool isConstWithoutErrno(unsigned ID) const
Return true if this function has no side effects and doesn't read memory, except for possibly errno...
const clang::PrintingPolicy & getPrintingPolicy() const
static bool isRecordType(QualType T)
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
void setRedeclaration(bool Val)
void setHasObjectMember(bool val)
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isShadowed() const
Determine whether the lookup result was shadowed by some other declaration that lookup ignored...
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
static void checkIsValidOpenCLKernelParameter(Sema &S, Declarator &D, ParmVarDecl *Param, llvm::SmallPtrSetImpl< const Type *> &ValidTypes)
static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization, bool IsDefinition)
SourceLocation getLParenLoc() const
static SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI, const VarDecl *VD)
Return the location of the capture if the given lambda captures the given variable VD...
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
void setHasImplicitReturnZero(bool IRZ)
State that falling off this function implicitly returns null/zero.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
FormatAttr * mergeFormatAttr(Decl *D, SourceRange Range, IdentifierInfo *Format, int FormatIdx, int FirstArg, unsigned AttrSpellingListIndex)
Module * Parent
The parent of this module.
static bool isAcceptableTagRedeclContext(Sema &S, DeclContext *OldDC, DeclContext *NewDC)
Determine whether a tag originally declared in context OldDC can be redeclared with an unqualified na...
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
unsigned getMSLastManglingNumber() const
The argument of this type cannot be passed directly in registers.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
DeclContextLookupResult slice(size_t N) const
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
The parser has processed a module import translated from a #include or similar preprocessing directiv...
Expr * getSizeExpr() const
Scope - A scope is a transient data structure that is used while parsing the program.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
field_iterator field_begin() const
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl *> &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions...
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
void DiagnoseUnusedDecl(const NamedDecl *ND)
DiagnoseUnusedDecl - Emit warnings about declarations that are not used unless they are marked attr(u...
const Expr * getInitExpr() const
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Represents a C++ nested-name-specifier or a global scope specifier.
const T * getAsAdjusted() const
Member-template getAsAdjusted<specific type>.
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, bool AllowMask) const
IsValueInFlagEnum - Determine if a value is allowed as part of a flag enum.
bool isNoreturnSpecified() const
void setRedeclarationKind(Sema::RedeclarationKind RK)
Change this lookup's redeclaration kind.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
static bool mergeDeclAttribute(Sema &S, NamedDecl *D, const InheritableAttr *Attr, Sema::AvailabilityMergeKind AMK)
static Scope * getTagInjectionScope(Scope *S, const LangOptions &LangOpts)
Find the Scope in which a tag is implicitly declared if we see an elaborated type specifier in the sp...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
void UpdateExprRep(Expr *Rep)
void CheckVariableDeclarationType(VarDecl *NewVD)
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
SourceLocation getConstSpecLoc() const
void setLocalOwningModule(Module *M)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool isScalarType() const
SourceLocation getLSquareLoc() const
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Represents an ObjC class declaration.
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
void revertBuiltin()
Revert the identifier to a non-builtin identifier.
Represents a linkage specification.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
SourceLocation getTypeSpecStartLoc() const
SourceRange getSourceRange() const LLVM_READONLY
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
MinSizeAttr * mergeMinSizeAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
bool isExported() const
Whether this declaration is exported (by virtue of being lexically within an ExportDecl or by being a...
The type does not fall into any of the following categories.
IdentifierInfo * getIdentifier() const
static bool isUsingDecl(NamedDecl *D)
CanQualType UnsignedCharTy
unsigned getLength() const
Efficiently return the length of this identifier info.
bool getNoCallerSavedRegs() const
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
UnionParsedType ConstructorName
When Kind == IK_ConstructorName, the class-name of the type whose constructor is being referenced...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
This object can be modified without requiring retains or releases.
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
param_iterator param_begin()
void setHasInheritedPrototype(bool P=true)
State that this function inherited its prototype from a previous declaration.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
ExtInfo withCallingConv(CallingConv cc) const
ImplicitCaptureStyle ImpCaptureStyle
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
bool isExternInLinkageSpec() const
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
CXXSpecialMember
Kinds of C++ special members.
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
void completeDefinition(QualType NewType, QualType PromotionType, unsigned NumPositiveBits, unsigned NumNegativeBits)
When created, the EnumDecl corresponds to a forward-declared enum.
static ImportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef< SourceLocation > IdentifierLocs)
Create a new module import declaration.
ConditionalOperator - The ?: ternary operator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Sema - This implements semantic analysis and AST building for C.
void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name)
Make the given externally-produced declaration visible at the top level scope.
StringRef getString() const
Merge availability attributes for an implementation of a protocol requirement.
enum clang::DeclaratorChunk::@215 Kind
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl *> DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
bool Mutable
Whether this is a mutable lambda.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
SmallVector< ReturnStmt *, 4 > Returns
The list of return statements that occur within the function or block, if there is any chance of appl...
SourceLocation getUnalignedSpecLoc() const
Represents a prototype with parameter type info, e.g.
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration...
static void mergeParamDeclAttributes(ParmVarDecl *newDecl, const ParmVarDecl *oldDecl, Sema &S)
mergeParamDeclAttributes - Copy attributes from the old parameter to the new one. ...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S)
isTagName() - This method is called for error recovery purposes only to determine if the specified na...
bool inferObjCARCLifetime(ValueDecl *decl)
Represents a ValueDecl that came out of a declarator.
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, unsigned AttrSpellingListIndex, MSInheritanceAttr::Spelling SemanticSpelling)
void SetRangeStart(SourceLocation Loc)
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclarationNameTable DeclarationNames
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S, bool MergeTypeWithOld)
MergeFunctionDecl - We just parsed a function 'New' from declarator D which has the same name and sco...
const char * getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl)
Checks if the new declaration declared in dependent context must be put in the same redeclaration cha...
bool isEnabled(llvm::StringRef Ext) const
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl *> Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
A conversion function name, e.g., operator int.
SourceRange getRange() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Captures information about a #pragma weak directive.
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.
TypeSourceInfo * getTypeSourceInfo() const
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
TST getTypeSpecType() const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
static NamedDecl * DiagnoseInvalidRedeclaration(Sema &SemaRef, LookupResult &Previous, FunctionDecl *NewFD, ActOnFDArgs &ExtraArgs, bool IsLocalFriend, Scope *S)
Generate diagnostics for an invalid function redeclaration.
static bool isDeclRep(TST T)
bool isVariableCapture() const
Exposes information about the current target.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
bool isCLike() const
True if this class is C-like, without C++-specific features, e.g.
bool isMsStruct(const ASTContext &C) const
Get whether or not this is an ms_struct which can be turned on with an attribute, pragma...
bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD, QualType NewT, QualType OldT)
Determines if we can perform a correct type check for D as a redeclaration of PrevDecl.
SourceLocation getBeginLoc() const
Get the begin source location.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Type source information for an attributed type.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
bool isObjCGCStrong() const
true when Type is objc's strong.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
LookupNameKind
Describes the kind of name lookup to perform.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e...
static bool isResultTypeOrTemplate(LookupResult &R, const Token &NextToken)
Determine whether the given result set contains either a type name or.
known_extensions_range known_extensions() const
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
bool isFunctionNoProtoType() const
bool isVariadic() const
Whether this function is variadic.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
bool isExplicitSpecified() const
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
void ResetObjCLayout(const ObjCContainerDecl *CD)
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
static bool checkForConflictWithNonVisibleExternC(Sema &S, const T *ND, LookupResult &Previous)
Apply special rules for handling extern "C" declarations.
DeclContext * getEntity() const
static SourceLocation findLocationAfterToken(SourceLocation loc, tok::TokenKind TKind, const SourceManager &SM, const LangOptions &LangOpts, bool SkipTrailingWhitespaceAndNewLine)
Checks that the given token is the first token that occurs after the given location (this excludes co...
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
unsigned SymbolLocations[3]
The source locations of the individual tokens that name the operator, e.g., the "new", "[", and "]" tokens in operator new [].
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
bool getHasRegParm() const
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI)
Diagnose shadowing for variables shadowed in the lambda record LambdaRD when these variables are capt...
static bool ValidDuplicateEnum(EnumConstantDecl *ECD, EnumDecl *Enum)
OpaquePtr< T > get() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
Compiling a module from a list of header files.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
QualType getParenType(QualType NamedType) const
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc, ModuleDeclKind MDK, ModuleIdPath Path)
The parser has processed a module-declaration that begins the definition of a module interface or imp...
SourceLocation getVolatileSpecLoc() const
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
SourceLocation getThreadStorageClassSpecLoc() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure...
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
bool isPredefinedRuntimeFunction(unsigned ID) const
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache"...
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
static void CheckPoppedLabel(LabelDecl *L, Sema &S)
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
field_iterator field_end() const
Not compiling a module interface at all.
overridden_method_range overridden_methods() const
ObjCLifetime getObjCLifetime() const
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
bool isFileContext() const
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
SourceLocation getBeginLoc() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
bool isConstexprSpecified() const
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
This declaration is a tentative definition.
static bool PreviousDeclsHaveMultiVersionAttribute(const FunctionDecl *FD)
void setObjCIdRedefinitionType(QualType RedefType)
Set the user-written type that redefines id.
TLSKind getTLSKind() const
AttributeFactory & getFactory() const
static QualType getNextLargerIntegralType(ASTContext &Context, QualType T)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
void setMemberSpecialization()
Note that this member template is a specialization.
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Decl * ActOnFinishExportDecl(Scope *S, Decl *ExportDecl, SourceLocation RBraceLoc)
Complete the definition of an export declaration.
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
Represents a C++ template name within the type system.
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name...
SourceLocation getStorageClassSpecLoc() const
ParmVarDecl *const * param_iterator
Decl * ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth)
ActOnField - Each field of a C struct/union is passed into this in order to create a FieldDecl object...
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
unsigned short getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
void UpdateTypeRep(ParsedType Rep)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
bool shouldInheritEvenIfAlreadyPresent() const
Should this attribute be inherited from a prior declaration even if it's explicitly provided in the c...
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
void setConstexpr(bool IC)
FieldDecl * CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitfieldWidth, InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D=nullptr)
Build a new FieldDecl and check its well-formedness.
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old)
checkNewAttributesAfterDef - If we already have a definition, check that there are no new attributes ...
bool isFunctionOrMethod() const
static StorageClass getFunctionStorageClass(Sema &SemaRef, Declarator &D)
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
static bool hasSimilarParameters(ASTContext &Context, FunctionDecl *Declaration, FunctionDecl *Definition, SmallVectorImpl< unsigned > &Params)
hasSimilarParameters - Determine whether the C++ functions Declaration and Definition have "nearly" m...
StorageClass
Storage classes.
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
Qualifiers getTypeQualifiers() const
virtual bool validateCpuSupports(StringRef Name) const
static bool HasNonMultiVersionAttributes(const FunctionDecl *FD, MultiVersionKind MVType)
Direct list-initialization (C++11)
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
static bool hasParsedAttr(Scope *S, const Declarator &PD, ParsedAttr::Kind Kind)
InClassInitStyle
In-class initialization styles for non-static data members.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
This declaration has an owning module, and is visible when that module is imported.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
An expression that sends a message to the given Objective-C object or class.
QualType getRecordType(const RecordDecl *Decl) const
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
SourceLocation getEnd() const
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
struct CXXOpName CXXOperatorName
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getContainingDC(DeclContext *DC)
bool isFriendSpecified() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
bool isCompoundStmtScope() const
Determine whether this scope is a compound statement scope.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
void setStorageClass(StorageClass SC)
Represents a C++ conversion function within a class.
sema::LambdaScopeInfo * PushLambdaScope()
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
This template specialization was implicitly instantiated from a template.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
VisibilityAttr * mergeVisibilityAttr(Decl *D, SourceRange Range, VisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
QualType withoutLocalFastQualifiers() const
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static bool shouldConsiderLinkage(const VarDecl *VD)
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
static StringRef getIdentifier(const Token &Tok)
static void ReportOverrides(Sema &S, unsigned DiagID, const CXXMethodDecl *MD, OverrideErrorKind OEK=OEK_All)
Report an error regarding overriding, along with any relevant overridden methods. ...
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList *> TPLists)
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr)
Perform name lookup on the given name, classifying it based on the results of name lookup and the fol...
static CharSourceRange getCharRange(SourceRange R)
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
ExtInfo withNoReturn(bool noReturn) const
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isVoidPointerType() const
static bool checkGlobalOrExternCConflict(Sema &S, const T *ND, bool IsGlobal, LookupResult &Previous)
Check for conflict between this global or extern "C" declaration and previous global or extern "C" de...
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
static UnqualifiedTypeNameLookupResult lookupUnqualifiedTypeNameInBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc, const CXXRecordDecl *RD)
Tries to perform unqualified lookup of the type decls in bases for dependent class.
RecordDecl * getDecl() const
static bool CheckMultiVersionValue(Sema &S, const FunctionDecl *FD)
Check the target attribute of the function for MultiVersion validity.
SourceLocation getNoreturnSpecLoc() const
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Decl * ActOnSkippedFunctionBody(Decl *Decl)
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
UnqualifiedTypeNameLookupResult
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
static bool isIncompleteDeclExternC(Sema &S, const T *D)
Determine whether a variable is extern "C" prior to attaching an initializer.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
void setTypeForDecl(const Type *TD)
char * location_data() const
Retrieve the data associated with the source-location information.
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
bool isAuxBuiltinID(unsigned ID) const
Return true if builtin ID belongs to AuxTarget.
Wrapper for source info for arrays.
Represents a C++ Modules TS module export declaration.
static unsigned getMSManglingNumber(const LangOptions &LO, Scope *S)
There is no lifetime qualification on this type.
Decl::Kind getDeclKind() const
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
This declaration has an owning module, but is globally visible (typically because its owning module i...
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
TypeLoc IgnoreParens() const
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
VarDecl * getVariable() const
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
ExtProtoInfo getExtProtoInfo() const
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SCS getStorageClassSpec() const
ASTContext & getASTContext() const
Expr * getAsmLabel() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
unsigned getMSCurManglingNumber() const
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
unsigned getNumExprs() const
Return the number of expressions in this paren list.
static bool AllowOverloadingOfFunction(LookupResult &Previous, ASTContext &Context, const FunctionDecl *New)
Determine whether we allow overloading of the function PrevDecl with another declaration.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
bool isTypeSpecOwned() const
Sugar for parentheses used when specifying types.
void setTopLevelDeclInObjCContainer(bool V=true)
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
bool isPure() const
Whether this virtual function is pure, i.e.
bool CheckForConstantInitializer(Expr *e, QualType t)
type checking declaration initializers (C99 6.7.8)
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
void ActOnDocumentableDecls(ArrayRef< Decl *> Group)
SourceLocation CurrentPragmaLocation
static ExportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExportLoc)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
LangAS getAddressSpace() const
Return the address space of this type.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
Expr * getSubExpr() const
FunctionDefinitionKind getFunctionDefinitionKind() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
CXXRecordDecl * Lambda
The class that describes the lambda.
void setBraceRange(SourceRange R)
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
Attr * clone(ASTContext &C) const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
CastKind getCastKind() const
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function...
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
void setFreeStanding(bool isFreeStanding=true)
True if this tag is free standing, e.g. "struct foo;".
void disableCheckFallThrough()
DeclarationName getName() const
getName - Returns the embedded declaration name.
void ExitDeclaratorContext(Scope *S)
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
MutableArrayRef< Expr * > MultiExprArg
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
bool isModulePrivateSpecified() const
static const TST TST_union
CallingConv getCC() const
bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context, will replace the declaration OldD if introduced into scope.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
unsigned getSpellingListIndex() const
ExitFunctionBodyRAII(Sema &S, bool IsLambda)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList *> TPLists)
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
Represents the declaration of a label.
ParsedAttr - Represents a syntactic attribute.
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error...
const DecompositionDeclarator & getDecompositionDeclarator() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
void setDefaulted(bool D=true)
void setHasFlexibleArrayMember(bool V)
SourceLocation getStrTokenLoc(unsigned TokNum) const
Get one of the string literal token.
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *&Init)
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used...
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
bool isConst(unsigned ID) const
Return true if this function has no side effects and doesn't read memory.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void addOverriddenMethod(const CXXMethodDecl *MD)
static ParsedType buildNestedType(Sema &S, CXXScopeSpec &SS, QualType T, SourceLocation NameLoc)
Build a ParsedType for a simple-type-specifier with a nested-name-specifier.
void setEntity(DeclContext *E)
SectionAttr * mergeSectionAttr(Decl *D, SourceRange Range, StringRef Name, unsigned AttrSpellingListIndex)
const ParmVarDecl * getParamDecl(unsigned i) const
void demoteThisDefinitionToDeclaration()
This is a definition which should be demoted to a declaration.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
SourceLocation getLocation() const
A friend of a previously-declared entity.
Name lookup found an unresolvable value declaration and cannot yet complete.
MemberPointerTypeInfo Mem
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
static bool CheckMultiVersionAdditionalRules(Sema &S, const FunctionDecl *OldFD, const FunctionDecl *NewFD, bool CausesMV, MultiVersionKind MVType)
ObjCCategoryDecl - Represents a category declaration.
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible. ...
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
bool isObjCObjectPointerType() const
Decl * getRepAsDecl() const
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
A class for iterating through a result set and possibly filtering out results.
This declaration is only a declaration.
SmallVector< Capture, 4 > Captures
Captures - The captures.
bool isMSAsmLabel() const
bool isSimpleTypeSpecifier(tok::TokenKind Kind) const
Determine whether the token kind starts a simple-type-specifier.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
uint32_t TypeID
An ID number that refers to a type in an AST file.
bool isFunctionProtoType() const
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
static const TST TST_typeofType
bool hasLinkageBeenComputed() const
True if something has required us to compute the linkage of this declaration.
Decl * ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, SourceLocation LBraceLoc)
We have parsed the start of an export declaration, including the '{' (if present).
No entity found met the criteria.
bool isHeaderDependentFunction(unsigned ID) const
Returns true if this builtin requires appropriate header in other compilers.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
SourceLocation getRAngleLoc() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
DeclarationNameInfo getNameInfo() const
bool isStaticMember()
Returns true if this declares a static member.
static ImportDecl * CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc)
Create a new module import declaration for an implicitly-generated import.
virtual bool validateCpuIs(StringRef Name) const
SourceLocation getInlineSpecLoc() const
static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl *Old)
Assigning into this object requires a lifetime extension.
static bool isExternC(T *D)
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
bool isScanfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like scanf in its formatting rules and, if so, set the index to the...
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
void setObjCSuperType(QualType ST)
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
bool hasFlexibleArrayMember() const
void setLAngleLoc(SourceLocation Loc)
bool isInvalid() const
An error occurred during parsing of the scope specifier.
static bool isRepresentableIntegerValue(ASTContext &Context, llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T...
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
UuidAttr * mergeUuidAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex, StringRef Uuid)
static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag)
static void LookupPredefedObjCSuperType(Sema &ThisSema, Scope *S, IdentifierInfo *II)
Looks up the declaration of "struct objc_super" and saves it for later use in building builtin declar...
static unsigned getRedeclDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for redeclaration diagnostic message.
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface...
DLLImportAttr * mergeDLLImportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
MultiVersionKind getMultiVersionKind() const
Gets the kind of multiversioning attribute this declaration has.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
TypeLoc getElementLoc() const
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
SourceLocation getModulePrivateSpecLoc() const
ObjCDeclQualifier getObjCDeclQualifier() const
StringRef getName() const
Return the actual identifier string.
static bool isOutOfScopePreviousDeclaration(NamedDecl *, DeclContext *, ASTContext &)
Determines whether the given declaration is an out-of-scope previous declaration. ...
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
NamedDecl * getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R)
Return the declaration shadowed by the given typedef D, or null if it doesn't shadow any declaration ...
CanQualType UnsignedShortTy
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
void createImplicitModuleImportForErrorRecovery(SourceLocation Loc, Module *Mod)
Create an implicit import of the given module at the given source location, for error recovery...
bool isObjCGCWeak() const
true when Type is objc's weak.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
Base class for declarations which introduce a typedef-name.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
TLS with a dynamic initializer.
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
LabelStmt * getStmt() const
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
TagTypeKind
The kind of a tag type.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Dataflow Directional Tag Classes.
static void FixInvalidVariablyModifiedTypeLoc(TypeLoc SrcTL, TypeLoc DstTL)
bool isValid() const
Return true if this is a valid SourceLocation object.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
ExtInfo getExtInfo() const
void setHasVolatileMember(bool val)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
A qualifier set is used to build a set of qualifiers.
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false)
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
static const CXXRecordDecl * findRecordWithDependentBasesOfEnclosingMethod(const DeclContext *DC)
Find the parent class with dependent bases of the innermost enclosing method context.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
The base class of all kinds of template declarations (e.g., class, function, etc.).
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
static const TST TST_decltype
static const TST TST_auto
const Scope * getParent() const
getParent - Return the scope that this is nested in.
static bool CheckAnonMemberRedeclaration(Sema &SemaRef, Scope *S, DeclContext *Owner, DeclarationName Name, SourceLocation NameLoc, bool IsUnion)
We are trying to inject an anonymous member into the given scope; check if there's an existing declar...
QualType getType() const
Get the type for which this source info wrapper provides information.
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
Represents a field injected from an anonymous union/struct into the parent scope. ...
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
bool isDependentAddressSpaceType() const
void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod)
The parsed has entered a submodule.
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
QualType getUnderlyingType() const
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
unsigned getNextFunctionPrototypeIndex()
Return the number of parameters declared in this function prototype, increasing it by one for the nex...
CanQualType UnsignedLongLongTy
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
SourceLocation getIncludeLoc(FileID FID) const
Returns the include location if FID is a #include'd file otherwise it returns an invalid location...
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
const Expr * getInit() const
AccessSpecifier getAccess() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
A decomposition declaration.
MapType::iterator iterator
This is a scope that corresponds to the template parameters of a C++ template.
void setShadowed()
Note that we found and ignored a declaration while performing lookup.
void setWillHaveBody(bool V=true)
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
The name of a declaration.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
static ObjCIvarDecl::AccessControl TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility)
TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
static FunctionDecl * CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, DeclContext *DC, QualType &R, TypeSourceInfo *TInfo, StorageClass SC, bool &IsVirtualOkay)
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
A mapping from each virtual member function to its set of final overriders.
unsigned getNumTemplateParameterLists() const
redecl_iterator redecls_end() const
void setInlineSpecified()
void mergeNRVOIntoParent()
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
static bool isTagTypeWithMissingTag(Sema &SemaRef, LookupResult &Result, Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc)
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D)
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
void setPreviousDeclInSameBlockScope(bool Same)
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
The name refers to a template whose specialization produces a type.
SourceLocation getBeginLoc() const LLVM_READONLY
static const TST TST_unspecified
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
IdentifierInfo * getCorrectionAsIdentifierInfo() const
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
This declaration is not owned by a module.
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
static std::pair< diag::kind, SourceLocation > getNoteDiagForInvalidRedeclaration(const T *Old, const T *New)
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
All of the names in this module are visible.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
llvm::APInt getValue() const
QualType getModifiedType() const
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
void setNameLoc(SourceLocation Loc)
SourceLocation getRBracketLoc() const
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated", "unavailable", and "availability").
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
SourceLocation DefinitionLoc
The location of the module definition.
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
Name lookup found a single declaration that met the criteria.
void setImplicitlyInline()
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
TypeLoc getPointeeLoc() const
unsigned getIntWidth(QualType T) const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
bool isIncompleteArrayType() const
bool isClosedFlag() const
Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(ope...
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl *> Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx, FixItHint &Hint)
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
SourceLocation getVirtualSpecLoc() const
bool isReserveIDT() const
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant...
CanQualType UnsignedLongTy
bool hasNonTrivialObjCLifetime() const
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl *> Elements, Scope *S, const ParsedAttributesView &Attr)
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false)
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S'...
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value...
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope...
bool isFunctionType() const
void setTypeSourceInfo(TypeSourceInfo *TI)
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
TypeSourceInfo * getTypeSourceInfo() const
static const TST TST_typename
Expr * getSizeExpr() const
Expr * getArg(unsigned Arg)
Return the specified argument.
param_const_iterator param_begin() const
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
SourceLocation getLBracketLoc() const
void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaRedefineExtname - Called on well formed #pragma redefine_extname oldname newname...
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
void setCXXForRangeDecl(bool FRD)
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
void ActOnCXXForRangeDecl(Decl *D)
static bool isOpenCLSizeDependentType(ASTContext &C, QualType Ty)
Decl * BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy)
BuildAnonymousStructOrUnion - Handle the declaration of an anonymous structure or union...
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.
static SourceLocation findDefaultInitializer(const CXXRecordDecl *Record)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
void setInherited(bool I)
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, ParsedAttributes &Attrs, SourceLocation AttrEnd)
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
bool isConstantArrayType() const
DeclResult ActOnModuleImport(SourceLocation AtLoc, SourceLocation ImportLoc, ModuleIdPath Path)
The parser has processed a module import declaration.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Represents a base class of a C++ class.
CXXScopeSpec & getTypeSpecScope()
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
static void checkModuleImportContext(Sema &S, Module *M, SourceLocation ImportLoc, DeclContext *DC, bool FromInclude=false)
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
This is a scope that can contain a declaration.
SourceManager & getSourceManager()
void * SkippedDefinitionContext
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any...
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setPromotionType(QualType T)
Set the promotion type.
ObjCInterfaceDecl * getObjCInterfaceDecl(IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
bool isSet() const
Deprecated.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
SourceRange getSourceRange() const
bool isNoThrow(unsigned ID) const
Return true if we know this builtin never throws an exception.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
TypedefNameDecl * getDecl() const
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
void setInvalidType(bool Val=true)
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Reading or writing from this object requires a barrier call.
ExternCContextDecl * getExternCContextDecl() const
static bool isClassCompatTagKind(TagTypeKind Tag)
Determine if tag kind is a class-key compatible with class for redeclaration (class, struct, or __interface).
static bool isMainFileLoc(const Sema &S, SourceLocation Loc)
bool isResolvedMSAsmLabel() const
An attributed type is a type to which a type attribute has been applied.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
Call-style initialization (C++98)
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
bool Failed() const
Determine whether the initialization sequence is invalid.
TranslationUnitDecl * getTranslationUnitDecl() const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Describes the sequence of initializations required to initialize a given object or reference with a s...
static QualType TryToFixInvalidVariablyModifiedType(QualType T, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
Helper method to turn variable array types into constant array types in certain situations which woul...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
static DeclContext * getTagInjectionContext(DeclContext *DC)
Find the DeclContext in which a tag is implicitly declared if we see an elaborated type specifier in ...
Captures information about "declaration specifiers".
SourceLocation getRestrictSpecLoc() const
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization)
Perform semantic checking of a new function declaration.
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl *> Group)
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
ShadowedDeclKind
Enum describing the select options in diag::warn_decl_shadow.
Represents a C++ struct/union/class.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
static bool isCompoundAssignmentOp(Opcode Opc)
static const TSCS TSCS_thread_local
void setTSCSpec(ThreadStorageClassSpecifier TSC)
static void RemoveUsingDecls(LookupResult &R)
Removes using shadow declarations from the lookup results.
void MergeVarDecl(VarDecl *New, LookupResult &Previous)
MergeVarDecl - We just parsed a variable 'New' which has the same name and scope as a previous declar...
SmallVectorImpl< UniqueVirtualMethod >::iterator overriding_iterator
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
Represents a C array with an unspecified size.
static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, DeclarationName Name)
NeedsRebuildingInCurrentInstantiation - Checks whether the given declarator needs to be rebuilt in th...
ExprResult VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth, bool *ZeroWidth=nullptr)
VerifyBitField - verifies that a bit field expression is an ICE and has the correct width...
Missing a type from <stdio.h>
Look up a friend of a local class.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
void setConstexpr(bool IC)
static bool hasIdenticalPassObjectSizeAttrs(const FunctionDecl *A, const FunctionDecl *B)
bool isTLSSupported() const
Whether the target supports thread-local storage.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
The parameter type of a method or function.
ObjCIvarDecl - Represents an ObjC instance variable.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
LambdaCaptureDefault getLambdaCaptureDefault() const
void setLParenLoc(SourceLocation Loc)
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Builtin::Context & BuiltinInfo
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void ActOnPopScope(SourceLocation Loc, Scope *S)
Scope actions.
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Declaration of a class template.
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool isVirtualSpecified() const
static StorageClass StorageClassSpecToVarDeclStorageClass(const DeclSpec &DS)
StorageClassSpecToVarDeclStorageClass - Maps a DeclSpec::SCS to a VarDecl::StorageClass.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
This class is used for builtin types like 'int'.
void addVLATypeCapture(SourceLocation Loc, QualType CaptureType)
unsigned getRegParmType() const
A template-id, e.g., f<int>.
AttributePool & getPool() const
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
ParsedType getRepAsType() const
TranslationUnitKind TUKind
The kind of translation unit we are processing.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U)
Determine whether two function types are the same, ignoring exception specifications in cases where t...
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
bool isInlineSpecified() const
TLS with a known-constant initializer.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
SourceLocation getAtomicSpecLoc() const
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
The translation unit is a complete translation unit.
static bool CheckMultiVersionAdditionalDecl(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, MultiVersionKind NewMVType, const TargetAttr *NewTA, const CPUDispatchAttr *NewCPUDisp, const CPUSpecificAttr *NewCPUSpec, bool &Redeclaration, NamedDecl *&OldDecl, bool &MergeTypeWithPrevious, LookupResult &Previous)
Check the validity of a new function declaration being added to an existing multiversioned declaratio...
static TagDecl * castFromDeclContext(const DeclContext *DC)
void setObjCSelRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
const VariableArrayType * getAsVariableArrayType(QualType T) const
static bool DeclHasAttr(const Decl *D, const Attr *A)
DeclhasAttr - returns true if decl Declaration already has the target attribute.
__DEVICE__ int max(int __a, int __b)
static OpaquePtr make(QualType P)
static bool checkUsingShadowRedecl(Sema &S, UsingShadowDecl *OldS, ExpectedDecl *New)
Check whether a redeclaration of an entity introduced by a using-declaration is valid, given that we know it's not an overload (nor a hidden tag declaration).
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
The top declaration context.
SourceLocation getExplicitSpecLoc() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
SourceLocation getConstexprSpecLoc() const
bool isEvaluatable(const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-e...
A reference to a declared variable, function, enum, etc.
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Represents a type template specialization; the template must be a class template, a type alias templa...
Visibility getVisibility() const
Determines the visibility of this entity.
static const TST TST_atomic
bool isDeleted() const
Whether this function has been deleted.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
bool isPointerType() const
bool hasObjectMember() const
NamedDecl * findLocallyScopedExternCDecl(DeclarationName Name)
Look for a locally scoped extern "C" declaration by the given name.
DLLExportAttr * mergeDLLExportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
void ActOnObjCContainerFinishDefinition()
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
SourceManager & SourceMgr
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
static const TST TST_struct
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, Expr *Cpy)
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
bool isStaticDataMember() const
Determines whether this is a static data member.
SourceLocation getInnerLocStart() const
Return SourceLocation representing start of source range ignoring outer template declarations.
static bool hasDependentAlignment(VarDecl *VD)
Determines if a variable's alignment is dependent.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
void ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod)
The parser has left a submodule.
static StringRef getNameForCallConv(CallingConv CC)
bool empty() const
Return true if no decls were found.
void setRParenLoc(SourceLocation Loc)
bool isFloatingType() const
A trivial tuple used to represent a source range.
bool hasUnrecoverableErrorOccurred() const
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
void setLexicalDeclContext(DeclContext *DC)
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool isTranslationUnit() const
Expr * getRepAsExpr() const
void setTypeSourceInfo(TypeSourceInfo *newType)
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
Represents a C array with a specified size that is not an integer-constant-expression.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
static bool shouldWarnIfShadowedDecl(const DiagnosticsEngine &Diags, const LookupResult &R)
No keyword precedes the qualified type name.
bool isInline() const
Whether this variable is (C++1z) inline.
static bool IsDisallowedCopyOrAssign(const CXXMethodDecl *D)
Check for this common pattern:
static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND)
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool IsTemplateTypeArg)
Attempt to behave like MSVC in situations where lookup of an unqualified type name has failed in a de...
static bool mergeTypeWithPrevious(Sema &S, VarDecl *NewVD, VarDecl *OldVD, LookupResult &Previous)
SourceLocation getNameLoc() const
Gets the location of the identifier.
Describes an entity that is being initialized.
bool isFunctionPointerType() const
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
attr::Kind getKind() const
unsigned NumArgs
NumArgs - The number of template arguments.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
bool isReturnsTwice(unsigned ID) const
Return true if we know this builtin can return twice.
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
void SetRangeEnd(SourceLocation Loc)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Missing a type from <setjmp.h>
void setType(QualType newType)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
Wrapper for source info for pointers.
SourceLocation getBegin() const
TranslationUnitDecl * getTranslationUnitDecl()
ParsedAttributes - A collection of parsed attributes.
const LangOptions & getLangOpts() const
void setNonTrivialToPrimitiveCopy(bool V)
void setDeletedAsWritten(bool D=true)
static bool isAttributeTargetADefinition(Decl *D)
An implicit 'self' parameter.
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
This class handles loading and caching of source files into memory.
bool isGlobal() const
Determines whether this is a global function.
Defines enum values for all the target-independent builtin functions.
A deduction-guide name (a template-name)
Declaration of a template function.
iterator - Iterate over the decls of a specified declaration name.
ExtInfo withRegParm(unsigned RegParm) const
CodeSegAttr * mergeCodeSegAttr(Decl *D, SourceRange Range, StringRef Name, unsigned AttrSpellingListIndex)
A class which abstracts out some details necessary for making a call.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
bool hasLinkage() const
Determine whether this declaration has linkage.
void setElaboratedKeywordLoc(SourceLocation Loc)
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result=nullptr, SourceLocation *Loc=nullptr) const
isCXX11ConstantExpr - Return true if this expression is a constant expression in C++11.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool isExternallyVisible() const
QualType getType() const
Return the type wrapped by this type source info.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
bool isBeingDefined() const
Return true if this decl is currently being defined.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
ObjCCompatibleAliasDecl - Represents alias of a class.
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Decl * ActOnDeclarator(Scope *S, Declarator &D)
CanQualType UnsignedIntTy
This is a C++ Modules TS module interface unit.
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, const ParsedAttributesView &Attrs, SourceLocation EqualLoc, Expr *Val)
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
The translation unit is a module.
QualType getType() const
Retrieves the type of the base class.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.