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)) {
1751 for (
auto *TmpD : D->
decls()) {
1752 if (
const auto *T = dyn_cast<TypedefNameDecl>(TmpD))
1753 DiagnoseUnusedDecl(T);
1754 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
1755 DiagnoseUnusedNestedTypedefs(R);
1765 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1768 UnusedLocalTypedefNameCandidates.insert(TD);
1776 if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
1777 DiagID = diag::warn_unused_exception_param;
1778 else if (isa<LabelDecl>(D))
1779 DiagID = diag::warn_unused_label;
1781 DiagID = diag::warn_unused_variable;
1791 bool Diagnose =
false;
1795 Diagnose = L->
getStmt() ==
nullptr;
1805 "Scope shouldn't contain decls!");
1807 for (
auto *TmpD : S->
decls()) {
1808 assert(TmpD &&
"This decl didn't get pushed??");
1810 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
1815 DiagnoseUnusedDecl(D);
1816 if (
const auto *RD = dyn_cast<RecordDecl>(D))
1817 DiagnoseUnusedNestedTypedefs(RD);
1823 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
1828 IdResolver.RemoveDecl(D);
1829 auto ShadowI = ShadowingDecls.find(D);
1830 if (ShadowI != ShadowingDecls.end()) {
1831 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
1833 << D << FD << FD->getParent();
1834 Diag(FD->getLocation(), diag::note_previous_declaration);
1836 ShadowingDecls.erase(ShadowI);
1856 bool DoTypoCorrection) {
1859 NamedDecl *IDecl = LookupSingleName(TUScope, Id, IdLoc, LookupOrdinaryName);
1861 if (!IDecl && DoTypoCorrection) {
1867 CTK_ErrorRecovery)) {
1868 diagnoseTypo(C, PDiag(diag::err_undef_interface_suggest) << Id);
1917 if (!II->
isStr(
"objc_msgSendSuper"))
1938 return "ucontext.h";
1940 llvm_unreachable(
"unhandled error kind");
1948 Scope *S,
bool ForRedeclaration,
1955 if (ForRedeclaration)
1956 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
1961 if (!ForRedeclaration &&
1964 Diag(Loc, diag::ext_implicit_lib_function_decl)
1967 !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc))
1968 Diag(Loc, diag::note_include_header_or_declare)
1982 Parent->
addDecl(CLinkageDecl);
1983 Parent = CLinkageDecl;
1988 Loc, Loc, II, R,
nullptr,
1998 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2001 nullptr, FT->getParamType(i),
nullptr,
2004 Params.push_back(parm);
2006 New->setParams(Params);
2009 AddKnownFunctionAttributes(New);
2010 RegisterLocallyScopedExternCDecl(New, S);
2018 PushOnScopeChains(New, TUScope);
2019 CurContext = SavedContext;
2035 if (Previous.
empty())
2048 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2055 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2069 OldType = OldTypedef->getUnderlyingType();
2076 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2077 Diag(New->
getLocation(), diag::err_redefinition_variably_modified_typedef)
2085 if (OldType != NewType &&
2089 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2091 << Kind << NewType << OldType;
2113 if (getLangOpts().ObjC1) {
2119 if (!TypeID->
isStr(
"id"))
2135 if (!TypeID->
isStr(
"Class"))
2142 if (!TypeID->
isStr(
"SEL"))
2169 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2170 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2173 if (OldTag && NewTag &&
2174 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
2175 !hasVisibleDefinition(OldTag, &Hidden)) {
2179 if (OldTD->isModed())
2181 OldTD->getUnderlyingType());
2186 makeMergedDefinitionVisible(Hidden);
2190 if (isa<EnumDecl>(NewTag)) {
2191 Scope *EnumScope = getNonFieldDeclScope(S);
2192 for (
auto *D : NewTag->decls()) {
2193 auto *ED = cast<EnumConstantDecl>(D);
2196 IdResolver.RemoveDecl(ED);
2197 ED->getLexicalDeclContext()->removeDecl(ED);
2205 if (isIncompatibleTypedef(Old, New))
2212 mergeDeclAttributes(New, Old);
2215 if (getLangOpts().MicrosoftExt)
2223 if (!isa<CXXRecordDecl>(CurContext))
2247 if (!isa<TypedefNameDecl>(Old))
2257 if (getLangOpts().Modules || getLangOpts().
C11)
2264 if (getDiagnostics().getSuppressSystemWarnings() &&
2279 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2280 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2281 for (
const auto *i : D->
attrs())
2282 if (i->getKind() == A->
getKind()) {
2284 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2289 if (OA && isa<OwnershipAttr>(i))
2290 return OA->getOwnKind() == cast<OwnershipAttr>(i)->getOwnKind();
2298 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2299 return VD->isThisDeclarationADefinition();
2300 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2301 return TD->isCompleteDefinition() || TD->isBeingDefined();
2312 AlignedAttr *OldAlignasAttr =
nullptr;
2313 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2314 unsigned OldAlign = 0;
2322 if (I->isAlignmentDependent())
2328 unsigned Align = I->getAlignment(S.
Context);
2329 if (Align > OldAlign) {
2331 OldStrictestAlignAttr = I;
2336 AlignedAttr *NewAlignasAttr =
nullptr;
2337 unsigned NewAlign = 0;
2339 if (I->isAlignmentDependent())
2345 unsigned Align = I->getAlignment(S.
Context);
2346 if (Align > NewAlign)
2350 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2358 if (OldAlign == 0 || NewAlign == 0) {
2360 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2371 if (OldAlign != NewAlign) {
2372 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2375 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2390 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2394 bool AnyAdded =
false;
2397 if (OldAlign > NewAlign) {
2398 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2399 Clone->setInherited(
true);
2405 if (OldAlignasAttr && !NewAlignasAttr &&
2406 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2407 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2408 Clone->setInherited(
true);
2428 if (
const auto *AA = dyn_cast<AvailabilityAttr>(Attr))
2431 AA->getDeprecated(),
2432 AA->getObsoleted(), AA->getUnavailable(),
2433 AA->getMessage(), AA->getStrict(),
2434 AA->getReplacement(), AMK,
2435 AttrSpellingListIndex);
2436 else if (
const auto *VA = dyn_cast<VisibilityAttr>(Attr))
2438 AttrSpellingListIndex);
2439 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(Attr))
2441 AttrSpellingListIndex);
2442 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(Attr))
2444 AttrSpellingListIndex);
2445 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(Attr))
2447 AttrSpellingListIndex);
2448 else if (
const auto *FA = dyn_cast<FormatAttr>(Attr))
2450 FA->getFormatIdx(), FA->getFirstArg(),
2451 AttrSpellingListIndex);
2452 else if (
const auto *SA = dyn_cast<SectionAttr>(Attr))
2454 AttrSpellingListIndex);
2455 else if (
const auto *CSA = dyn_cast<CodeSegAttr>(Attr))
2457 AttrSpellingListIndex);
2458 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(Attr))
2460 AttrSpellingListIndex,
2461 IA->getSemanticSpelling());
2462 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(Attr))
2465 AttrSpellingListIndex);
2466 else if (S.
getLangOpts().CUDA && isa<FunctionDecl>(D) &&
2467 (isa<CUDAHostAttr>(Attr) || isa<CUDADeviceAttr>(Attr) ||
2468 isa<CUDAGlobalAttr>(Attr))) {
2472 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(Attr))
2474 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(Attr))
2476 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(Attr))
2478 D, InternalLinkageA->getRange(),
2480 AttrSpellingListIndex);
2481 else if (
const auto *CommonA = dyn_cast<CommonAttr>(Attr))
2484 AttrSpellingListIndex);
2485 else if (isa<AlignedAttr>(Attr))
2489 else if ((isa<DeprecatedAttr>(Attr) || isa<UnavailableAttr>(Attr)) &&
2493 else if (
const auto *UA = dyn_cast<UuidAttr>(Attr))
2494 NewAttr = S.
mergeUuidAttr(D, UA->getRange(), AttrSpellingListIndex,
2497 NewAttr = cast<InheritableAttr>(Attr->
clone(S.
Context));
2502 if (isa<MSInheritanceAttr>(NewAttr))
2511 if (
const TagDecl *TD = dyn_cast<TagDecl>(D))
2512 return TD->getDefinition();
2513 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2519 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
2525 for (
const auto *Attribute : D->
attrs())
2526 if (Attribute->getKind() ==
Kind)
2538 if (!Def || Def == New)
2542 for (
unsigned I = 0, E = NewAttributes.size(); I != E;) {
2543 const Attr *NewAttribute = NewAttributes[I];
2545 if (isa<AliasAttr>(NewAttribute) || isa<IFuncAttr>(NewAttribute)) {
2552 NewAttributes.erase(NewAttributes.begin() + I);
2557 VarDecl *VD = cast<VarDecl>(New);
2558 unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
2560 ? diag::err_alias_after_tentative
2561 : diag::err_redefinition;
2563 if (Diag == diag::err_redefinition)
2573 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
2586 if (isa<C11NoReturnAttr>(NewAttribute)) {
2590 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
2591 if (AA->isAlignas()) {
2602 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
2604 NewAttributes.erase(NewAttributes.begin() + I);
2611 diag::warn_attribute_precede_definition);
2613 NewAttributes.erase(NewAttributes.begin() + I);
2622 UsedAttr *NewAttr = OldAttr->clone(Context);
2623 NewAttr->setInherited(
true);
2633 if (AsmLabelAttr *NewA = New->
getAttr<AsmLabelAttr>()) {
2634 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
2635 if (OldA->getLabel() != NewA->getLabel()) {
2638 Diag(OldA->getLocation(), diag::note_previous_declaration);
2640 }
else if (Old->
isUsed()) {
2644 << isa<FunctionDecl>(Old) << New->
getAttr<AsmLabelAttr>()->getRange();
2649 if (
const auto *NewAbiTagAttr = New->
getAttr<AbiTagAttr>()) {
2650 if (
const auto *OldAbiTagAttr = Old->
getAttr<AbiTagAttr>()) {
2651 for (
const auto &NewTag : NewAbiTagAttr->tags()) {
2652 if (std::find(OldAbiTagAttr->tags_begin(), OldAbiTagAttr->tags_end(),
2653 NewTag) == OldAbiTagAttr->tags_end()) {
2654 Diag(NewAbiTagAttr->getLocation(),
2655 diag::err_new_abi_tag_on_redeclaration)
2657 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
2661 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
2667 if (New->
hasAttr<SectionAttr>() && !Old->
hasAttr<SectionAttr>()) {
2668 if (
auto *VD = dyn_cast<VarDecl>(New)) {
2670 Diag(New->
getLocation(), diag::warn_attribute_section_on_redeclaration);
2677 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
2678 if (NewCSA && !Old->
hasAttr<CodeSegAttr>() &&
2679 !NewCSA->isImplicit() && isa<CXXMethodDecl>(New)) {
2697 if (isa<DeprecatedAttr>(I) ||
2698 isa<UnavailableAttr>(I) ||
2699 isa<AvailabilityAttr>(I)) {
2704 case AMK_Redeclaration:
2706 case AMK_ProtocolImplementation:
2713 if (isa<UsedAttr>(I))
2735 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
2736 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
2737 S.
Diag(CDA->getLocation(),
2738 diag::err_carries_dependency_missing_on_first_decl) << 1;
2746 diag::note_carries_dependency_missing_first_decl) << 1;
2752 bool foundAny = newDecl->
hasAttrs();
2761 cast<InheritableParamAttr>(I->clone(S.
Context));
2776 if (*Oldnullability != *Newnullability) {
2777 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
2802 struct GNUCompatibleParamWarning {
2813 if (Ctor->isDefaultConstructor())
2816 if (Ctor->isCopyConstructor())
2819 if (Ctor->isMoveConstructor())
2821 }
else if (isa<CXXDestructorDecl>(MD)) {
2834 template <
typename T>
2835 static std::pair<diag::kind, SourceLocation>
2839 if (Old->isThisDeclarationADefinition())
2840 PrevDiag = diag::note_previous_definition;
2841 else if (Old->isImplicit()) {
2842 PrevDiag = diag::note_previous_implicit_declaration;
2844 OldLocation = New->getLocation();
2846 PrevDiag = diag::note_previous_declaration;
2847 return std::make_pair(PrevDiag, OldLocation);
2855 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
2856 !LangOpts.CPlusPlus &&
2868 template <
typename T>
2882 template<
typename T>
static bool isExternC(T *D) {
return D->isExternC(); }
2888 template<
typename ExpectedDecl>
2890 ExpectedDecl *New) {
2910 !Old->getDeclContext()->getRedeclContext()->Equals(
2911 New->getDeclContext()->getRedeclContext()) &&
2916 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
2929 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
2930 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
2933 return AttrA && AttrB && AttrA->getType() == AttrB->getType();
2936 return std::equal(A->param_begin(), A->param_end(), B->
param_begin(), AttrEq);
2959 if (NamedDC->Equals(SemaDC))
2962 assert((NamedDC->InEnclosingNamespaceSetOf(SemaDC) ||
2964 "unexpected context for redeclaration");
2975 if (
auto *FD = dyn_cast<FunctionDecl>(NewD))
2976 FixSemaDC(FD->getDescribedFunctionTemplate());
2977 else if (
auto *VD = dyn_cast<VarDecl>(NewD))
2978 FixSemaDC(VD->getDescribedVarTemplate());
2993 Scope *S,
bool MergeTypeWithOld) {
3000 Diag(Shadow->getTargetDecl()->getLocation(),
3001 diag::note_using_decl_target);
3002 Diag(Shadow->getUsingDecl()->getLocation(),
3003 diag::note_using_decl) << 0;
3008 if (checkUsingShadowRedecl<FunctionDecl>(*
this, Shadow, New))
3010 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
3024 if (!getASTContext().canBuiltinBeRedeclared(Old)) {
3033 std::tie(PrevDiag, OldLocation) =
3040 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
3045 if (getLangOpts().MicrosoftExt) {
3047 Diag(OldLocation, PrevDiag);
3050 Diag(OldLocation, PrevDiag);
3055 if (New->
hasAttr<InternalLinkageAttr>() &&
3056 !Old->
hasAttr<InternalLinkageAttr>()) {
3060 New->
dropAttr<InternalLinkageAttr>();
3063 if (CheckRedeclarationModuleOwnership(New, Old))
3066 if (!getLangOpts().CPlusPlus) {
3067 bool OldOvl = Old->
hasAttr<OverloadableAttr>();
3078 const Decl *DiagOld = Old;
3080 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *D) {
3081 const auto *A = D->
getAttr<OverloadableAttr>();
3082 return A && !A->isImplicit();
3086 DiagOld = OldIter == Old->
redecls_end() ? nullptr : *OldIter;
3090 Diag(DiagOld->getLocation(),
3091 diag::note_attribute_overloadable_prev_overload)
3095 New->
addAttr(OverloadableAttr::CreateImplicit(Context));
3116 const FunctionType *OldType = cast<FunctionType>(OldQType);
3117 const FunctionType *NewType = cast<FunctionType>(NewQType);
3120 bool RequiresAdjustment =
false;
3122 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC()) {
3127 bool NewCCExplicit = getCallingConvAttributedType(New->
getType());
3128 if (!NewCCExplicit) {
3132 RequiresAdjustment =
true;
3135 bool FirstCCExplicit = getCallingConvAttributedType(First->
getType());
3139 << (!FirstCCExplicit ?
"" :
3149 if (OldTypeInfo.getNoReturn() && !NewTypeInfo.
getNoReturn()) {
3151 RequiresAdjustment =
true;
3155 if (OldTypeInfo.getHasRegParm() != NewTypeInfo.
getHasRegParm() ||
3156 OldTypeInfo.getRegParm() != NewTypeInfo.
getRegParm()) {
3159 << NewType->getRegParmType()
3161 Diag(OldLocation, diag::note_previous_declaration);
3165 NewTypeInfo = NewTypeInfo.
withRegParm(OldTypeInfo.getRegParm());
3166 RequiresAdjustment =
true;
3173 <<
"'ns_returns_retained'";
3174 Diag(OldLocation, diag::note_previous_declaration);
3179 RequiresAdjustment =
true;
3182 if (OldTypeInfo.getNoCallerSavedRegs() !=
3185 AnyX86NoCallerSavedRegistersAttr *
Attr =
3186 New->
getAttr<AnyX86NoCallerSavedRegistersAttr>();
3187 Diag(New->
getLocation(), diag::err_function_attribute_mismatch) << Attr;
3188 Diag(OldLocation, diag::note_previous_declaration);
3193 RequiresAdjustment =
true;
3196 if (RequiresAdjustment) {
3201 NewType = cast<FunctionType>(NewQType);
3207 !New->
hasAttr<GNUInlineAttr>() &&
3208 !getLangOpts().GNUInline &&
3216 if (New->
hasAttr<GNUInlineAttr>() &&
3227 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3242 if (CheckEquivalentExceptionSpec(Old, New))
3255 : OldType)->getReturnType();
3259 : NewType)->getReturnType();
3260 if (!Context.
hasSameType(OldDeclaredReturnType, NewDeclaredReturnType) &&
3269 Diag(New->
getLocation(), diag::err_member_def_does_not_match_ret_type)
3274 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
3283 QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType();
3284 if (OldReturnType != NewReturnType) {
3294 SubstAutoType(NewQType,
3302 if (OldMethod && NewMethod) {
3309 bool IsClassScopeExplicitSpecialization =
3311 NewMethod->isFunctionTemplateSpecialization();
3312 bool isFriend = NewMethod->getFriendObjectKind();
3314 if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() &&
3315 !IsClassScopeExplicitSpecialization) {
3319 if (OldMethod->
isStatic() != NewMethod->isStatic()) {
3321 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3329 if (!inTemplateInstantiation()) {
3331 if (isa<CXXConstructorDecl>(OldMethod))
3332 NewDiag = diag::err_constructor_redeclared;
3333 else if (isa<CXXDestructorDecl>(NewMethod))
3334 NewDiag = diag::err_destructor_redeclared;
3335 else if (isa<CXXConversionDecl>(NewMethod))
3336 NewDiag = diag::err_conv_function_redeclared;
3338 NewDiag = diag::err_member_redeclared;
3342 Diag(New->
getLocation(), diag::err_member_redeclared_in_instantiation)
3345 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3355 NewMethod->setImplicit();
3357 Diag(NewMethod->getLocation(),
3358 diag::err_definition_of_implicitly_declared_member)
3359 << New << getSpecialMember(OldMethod);
3363 Diag(NewMethod->getLocation(),
3364 diag::err_definition_of_explicitly_defaulted_member)
3365 << getSpecialMember(OldMethod);
3374 const CXX11NoReturnAttr *NRA = New->
getAttr<CXX11NoReturnAttr>();
3375 if (NRA && !Old->
hasAttr<CXX11NoReturnAttr>()) {
3376 Diag(NRA->getLocation(), diag::err_noreturn_missing_on_first_decl);
3378 diag::note_noreturn_missing_first_decl);
3385 const CarriesDependencyAttr *CDA = New->
getAttr<CarriesDependencyAttr>();
3386 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
3387 Diag(CDA->getLocation(),
3388 diag::err_carries_dependency_missing_on_first_decl) << 0;
3390 diag::note_carries_dependency_missing_first_decl) << 0;
3399 QualType OldQTypeForComparison = OldQType;
3400 if (!OldTypeInfo.getNoReturn() && NewTypeInfo.
getNoReturn()) {
3404 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
3405 assert(OldQTypeForComparison.isCanonical());
3419 Diag(OldLocation, PrevDiag);
3421 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3422 Diag(OldLocation, PrevDiag);
3427 if (OldQTypeForComparison == NewQType)
3428 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3443 if (!getLangOpts().CPlusPlus &&
3448 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
3452 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
3456 OldProto->getExtProtoInfo());
3462 for (
const auto &ParamType : OldProto->param_types()) {
3469 Params.push_back(Param);
3472 New->setParams(Params);
3475 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3502 NewProto->getReturnType());
3503 bool LooseCompatible = !MergedReturn.
isNull();
3505 LooseCompatible && Idx !=
End; ++Idx) {
3509 NewProto->getParamType(Idx))) {
3510 ArgTypes.push_back(NewParm->
getType());
3514 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
3515 NewProto->getParamType(Idx) };
3516 Warnings.push_back(Warn);
3517 ArgTypes.push_back(NewParm->
getType());
3519 LooseCompatible =
false;
3522 if (LooseCompatible) {
3523 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
3524 Diag(Warnings[Warn].NewParm->getLocation(),
3525 diag::ext_param_promoted_not_compatible_with_prototype)
3526 << Warnings[Warn].PromotedType
3527 << Warnings[Warn].OldParm->getType();
3528 if (Warnings[Warn].OldParm->getLocation().isValid())
3529 Diag(Warnings[Warn].OldParm->getLocation(),
3530 diag::note_previous_declaration);
3533 if (MergeTypeWithOld)
3536 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3553 Diag(OldLocation, diag::note_previous_builtin_declaration)
3570 PrevDiag = diag::note_previous_builtin_declaration;
3574 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3588 Scope *S,
bool MergeTypeWithOld) {
3590 mergeDeclAttributes(New, Old);
3603 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
3611 return MergeCXXFunctionDecl(New, Old, S);
3617 if (!Merged.
isNull() && MergeTypeWithOld)
3628 ? AMK_ProtocolImplementation
3629 : isa<ObjCImplDecl>(newMethod->
getDeclContext()) ? AMK_Redeclaration
3632 mergeDeclAttributes(newMethod, oldMethod, MergeKind);
3639 ni != ne && oi != oe; ++ni, ++oi)
3642 CheckObjCMethodOverride(newMethod, oldMethod);
3649 ? diag::err_redefinition_different_type
3650 : diag::err_redeclaration_different_type)
3655 std::tie(PrevDiag, OldLocation)
3657 S.
Diag(OldLocation, PrevDiag);
3669 bool MergeTypeWithOld) {
3674 if (getLangOpts().CPlusPlus) {
3680 return MergeVarDeclExceptionSpecs(New, Old);
3751 if (MergeTypeWithOld)
3797 if (!shouldLinkPossiblyHiddenDecl(Previous, New))
3812 if (checkUsingShadowRedecl<VarTemplateDecl>(*
this, Shadow, NewTemplate))
3819 if (checkUsingShadowRedecl<VarDecl>(*
this, Shadow, New))
3835 true, TPL_TemplateMatch))
3849 mergeDeclAttributes(New, Old);
3852 if (New->
hasAttr<WeakImportAttr>() &&
3854 !Old->
hasAttr<WeakImportAttr>()) {
3861 if (New->
hasAttr<InternalLinkageAttr>() &&
3862 !Old->
hasAttr<InternalLinkageAttr>()) {
3866 New->
dropAttr<InternalLinkageAttr>();
3871 if (MostRecent != Old) {
3872 MergeVarDeclTypes(New, MostRecent,
3884 std::tie(PrevDiag, OldLocation) =
3891 if (getLangOpts().MicrosoftExt) {
3894 Diag(OldLocation, PrevDiag);
3898 Diag(OldLocation, PrevDiag);
3917 Diag(OldLocation, PrevDiag);
3925 Diag(OldLocation, PrevDiag);
3931 Diag(OldLocation, PrevDiag);
3935 if (CheckRedeclarationModuleOwnership(New, Old))
3947 Diag(OldLocation, PrevDiag);
3957 Diag(Def->getLocation(), diag::note_previous_definition);
3971 Diag(OldLocation, PrevDiag);
3974 Diag(OldLocation, PrevDiag);
3982 Diag(OldLocation, PrevDiag);
3993 diag::warn_deprecated_redundant_constexpr_static_def);
3995 if (checkVarDeclRedefinition(Def, New))
4001 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
4002 Diag(OldLocation, PrevDiag);
4032 auto &HSI = PP.getHeaderSearchInfo();
4033 StringRef HdrFilename =
4036 auto noteFromModuleOrInclude = [&](
Module *Mod,
4042 if (IncLoc.isValid()) {
4044 Diag(IncLoc, diag::note_redefinition_modules_same_file)
4050 Diag(IncLoc, diag::note_redefinition_include_same_file)
4051 << HdrFilename.str();
4061 bool EmittedDiag =
false;
4062 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
4065 EmittedDiag = noteFromModuleOrInclude(Old->
getOwningModule(), OldIncLoc);
4066 EmittedDiag |= noteFromModuleOrInclude(getCurrentModule(), NewIncLoc);
4069 if (FOld && !HSI.isFileMultipleIncludeGuarded(FOld))
4084 if (!hasVisibleDefinition(Old) &&
4096 makeMergedDefinitionVisible(OldTD);
4097 makeMergedDefinitionVisible(Old);
4132 if (isa<CXXRecordDecl>(Tag->
getParent())) {
4146 Decl *ManglingContextDecl;
4150 Tag, MCtx->getManglingNumber(
4170 if (getLangOpts().CPlusPlus)
4185 tagLoc = getLocForEndOfToken(tagLoc);
4188 textToInsert +=
' ';
4190 Diag(tagLoc, diag::note_typedef_changes_linkage)
4212 llvm_unreachable(
"unexpected type specifier");
4222 bool IsExplicitInstantiation,
4224 Decl *TagD =
nullptr;
4239 if (isa<TagDecl>(TagD))
4240 Tag = cast<TagDecl>(TagD);
4242 Tag = CTD->getTemplatedDecl();
4246 handleTagNumbering(Tag, S);
4257 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
4263 << getLangOpts().CPlusPlus17;
4277 DiagnoseFunctionSpecifiers(DS);
4284 return ActOnFriendTypeDecl(S, DS, TemplateParams);
4288 bool IsExplicitSpecialization =
4289 !TemplateParams.empty() && TemplateParams.back()->size() == 0;
4291 !IsExplicitInstantiation && !IsExplicitSpecialization &&
4292 !isa<ClassTemplatePartialSpecializationDecl>(Tag)) {
4301 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
4307 bool DeclaresAnything =
true;
4310 if (
RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
4311 if (!Record->getDeclName() && Record->isCompleteDefinition() &&
4313 if (getLangOpts().CPlusPlus ||
4314 Record->getDeclContext()->isRecord()) {
4322 if (CurContext->isFunctionOrMethod())
4323 AnonRecord = Record;
4324 return BuildAnonymousStructOrUnion(S, DS, AS, Record,
4328 DeclaresAnything =
false;
4338 if (!getLangOpts().CPlusPlus && CurContext->isRecord() &&
4354 Record = RT->getDecl();
4356 Record = UT->getDecl();
4358 if (Record && getLangOpts().MicrosoftExt) {
4361 return BuildMicrosoftCAnonymousStruct(S, DS, Record);
4364 DeclaresAnything =
false;
4373 if (getLangOpts().CPlusPlus &&
4375 if (
EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Tag))
4376 if (Enum->enumerator_begin() == Enum->enumerator_end() &&
4377 !Enum->getIdentifier() && !Enum->isInvalidDecl())
4378 DeclaresAnything =
false;
4386 DeclaresAnything =
false;
4395 ActOnDocumentableDecl(TagD);
4405 if (!DeclaresAnything) {
4420 unsigned DiagID = diag::warn_standalone_specifier;
4422 DiagID = diag::ext_standalone_specifier;
4463 Diag(AL.getLoc(), diag::warn_declspec_attribute_ignored)
4487 assert(PrevDecl &&
"Expected a non-null Decl");
4492 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
4494 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
4519 bool Invalid =
false;
4522 for (
auto *D : AnonRecord->
decls()) {
4523 if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
4524 cast<NamedDecl>(D)->getDeclName()) {
4540 unsigned OldChainingSize = Chaining.size();
4542 Chaining.append(IF->chain_begin(), IF->chain_end());
4544 Chaining.push_back(VD);
4546 assert(Chaining.size() >= 2);
4549 for (
unsigned i = 0; i < Chaining.size(); i++)
4550 NamedChain[i] = Chaining[i];
4554 VD->
getType(), {NamedChain, Chaining.size()});
4566 Chaining.resize(OldChainingSize);
4581 "Parser allowed 'typedef' as storage class VarDecl.");
4582 switch (StorageClassSpec) {
4596 llvm_unreachable(
"unknown storage class specifier");
4602 for (
const auto *I : Record->
decls()) {
4603 const auto *FD = dyn_cast<
FieldDecl>(I);
4604 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
4605 FD = IFD->getAnonField();
4606 if (FD && FD->hasInClassInitializer())
4610 llvm_unreachable(
"couldn't find in-class initializer");
4618 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
4641 if (Record->
isUnion() && !getLangOpts().CPlusPlus && !getLangOpts().C11)
4643 else if (!Record->
isUnion() && getLangOpts().CPlusPlus)
4645 else if (!Record->
isUnion() && !getLangOpts().C11)
4650 bool Invalid =
false;
4651 if (getLangOpts().CPlusPlus) {
4652 const char *PrevSpec =
nullptr;
4663 !cast<NamespaceDecl>(OwnerScope)->isAnonymousNamespace()))) {
4669 PrevSpec, DiagID, Policy);
4675 isa<RecordDecl>(Owner)) {
4677 diag::err_anonymous_union_with_storage_spec)
4691 << Record->
isUnion() <<
"const" 4695 diag::ext_anonymous_struct_union_qualified)
4696 << Record->
isUnion() <<
"volatile" 4700 diag::ext_anonymous_struct_union_qualified)
4701 << Record->
isUnion() <<
"restrict" 4705 diag::ext_anonymous_struct_union_qualified)
4706 << Record->
isUnion() <<
"_Atomic" 4710 diag::ext_anonymous_struct_union_qualified)
4711 << Record->
isUnion() <<
"__unaligned" 4721 for (
auto *Mem : Record->
decls()) {
4722 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
4726 assert(FD->getAccess() !=
AS_none);
4728 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
4738 if (CheckNontrivialField(FD))
4740 }
else if (Mem->isImplicit()) {
4742 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
4747 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
4748 if (!MemRecord->isAnonymousStructOrUnion() &&
4749 MemRecord->getDeclName()) {
4751 if (getLangOpts().MicrosoftExt)
4752 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
4756 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
4764 Diag(MemRecord->getLocation(),
4765 diag::ext_anonymous_record_with_anonymous_type)
4768 }
else if (isa<AccessSpecDecl>(Mem)) {
4770 }
else if (isa<StaticAssertDecl>(Mem)) {
4775 unsigned DK = diag::err_anonymous_record_bad_member;
4776 if (isa<TypeDecl>(Mem))
4777 DK = diag::err_anonymous_record_with_type;
4778 else if (isa<FunctionDecl>(Mem))
4779 DK = diag::err_anonymous_record_with_function;
4780 else if (isa<VarDecl>(Mem))
4781 DK = diag::err_anonymous_record_with_static;
4784 if (getLangOpts().MicrosoftExt &&
4785 DK == diag::err_anonymous_record_with_type)
4786 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
4789 Diag(Mem->getLocation(), DK) << Record->
isUnion();
4798 if (cast<CXXRecordDecl>(Record)->hasInClassInitializer() &&
4801 cast<CXXRecordDecl>(Record));
4806 << getLangOpts().CPlusPlus;
4813 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
4817 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
4828 FieldCollector->Add(cast<FieldDecl>(Anon));
4850 ActOnUninitializedDecl(Anon);
4866 Chain.push_back(Anon);
4871 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
4872 if (getLangOpts().
CPlusPlus && NewVD->isStaticLocal()) {
4873 Decl *ManglingContextDecl;
4875 NewVD->getDeclContext(), ManglingContextDecl)) {
4877 NewVD, MCtx->getManglingNumber(
4905 assert(Record &&
"expected a record!");
4910 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
4912 auto *ParentDecl = cast<RecordDecl>(CurContext);
4928 CurContext->addDecl(Anon);
4934 Chain.push_back(Anon);
4937 if (RequireCompleteType(Anon->
getLocation(), RecTy,
4938 diag::err_field_incomplete) ||
4942 ParentDecl->setInvalidDecl();
4951 return GetNameFromUnqualifiedId(D.
getName());
4981 if (!Template || !isa<ClassTemplateDecl>(Template)) {
4983 diag::err_deduction_guide_name_not_class_template)
4984 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
4986 Diag(Template->getLocation(), diag::note_template_decl_here);
5080 llvm_unreachable(
"Unknown name kind");
5108 for (
unsigned Idx = 0; Idx < Declaration->
param_size(); ++Idx) {
5122 (DeclTyName && DeclTyName == DefTyName))
5123 Params.push_back(Idx);
5164 if (!TSI)
return true;
5209 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer() &&
5213 if (getLangOpts().OpenCL)
5214 setCurrentOpenCLExtensionForDecl(Dcl);
5232 Record = dyn_cast<CXXRecordDecl>(Record->
getParent());
5234 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
5261 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
5275 Diag(Loc, LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
5276 : diag::err_member_extra_qualification)
5280 Diag(Loc, diag::warn_namespace_member_extra_qualification) << Name;
5288 if (!Cur->
Encloses(DC) && !IsTemplateId) {
5290 Diag(Loc, diag::err_member_qualification)
5292 else if (isa<TranslationUnitDecl>(DC))
5293 Diag(Loc, diag::err_invalid_declarator_global_scope)
5295 else if (isa<FunctionDecl>(Cur))
5296 Diag(Loc, diag::err_invalid_declarator_in_function)
5298 else if (isa<BlockDecl>(Cur))
5299 Diag(Loc, diag::err_invalid_declarator_in_block)
5302 Diag(Loc, diag::err_invalid_declarator_scope)
5303 << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.
getRange();
5310 Diag(Loc, diag::err_member_qualification)
5330 while (SpecLoc.getPrefix())
5332 if (dyn_cast_or_null<DecltypeType>(
5333 SpecLoc.getNestedNameSpecifier()->getAsType()))
5334 Diag(Loc, diag::err_decltype_in_declarator)
5335 << SpecLoc.getTypeLoc().getSourceRange();
5349 return ActOnDecompositionDeclarator(S, D, TemplateParamLists);
5353 diag::err_declarator_need_ident)
5356 }
else if (DiagnoseUnexpandedParameterPack(NameInfo, UPPC_DeclarationType))
5370 UPPC_DeclarationQualifier))
5375 if (!DC || isa<EnumDecl>(DC)) {
5381 diag::err_template_qualified_declarator_no_match)
5388 if (!IsDependentContext &&
5393 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
5395 diag::err_member_def_undefined_record)
5400 if (diagnoseQualifiedDeclaration(
5412 if (EnteringContext && IsDependentContext &&
5413 TemplateParamLists.size() != 0) {
5424 UPPC_DeclarationType))
5428 forRedeclarationInCurContext());
5432 bool IsLinkageLookup =
false;
5433 bool CreateBuiltins =
false;
5444 else if (CurContext->isFunctionOrMethod() &&
5447 IsLinkageLookup =
true;
5449 CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
5450 }
else if (CurContext->getRedeclContext()->isTranslationUnit() &&
5452 CreateBuiltins =
true;
5454 if (IsLinkageLookup) {
5455 Previous.
clear(LookupRedeclarationWithLinkage);
5459 LookupName(Previous, S, CreateBuiltins);
5461 LookupQualifiedName(Previous, DC);
5503 if (!R->
isFunctionType() && DiagnoseClassNameShadow(DC, NameInfo))
5519 CheckExtraCXXDefaultArguments(D);
5523 bool AddToScope =
true;
5525 if (TemplateParamLists.size()) {
5530 New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous);
5532 New = ActOnFunctionDeclarator(S, D, DC, TInfo, Previous,
5536 New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists,
5550 PushOnScopeChains(New, S, AddToContext);
5552 CurContext->addHiddenDecl(New);
5555 if (isInOpenMPDeclareTargetContext())
5556 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
5566 bool &SizeIsNegative,
5567 llvm::APSInt &Oversized) {
5572 SizeIsNegative =
false;
5581 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
5586 if (FixedType.
isNull())
return FixedType;
5588 return Qs.
apply(Context, FixedType);
5590 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
5591 QualType Inner = PTy->getInnerType();
5595 if (FixedType.
isNull())
return FixedType;
5597 return Qs.
apply(Context, FixedType);
5613 if (Res.isSigned() && Res.isNegative()) {
5614 SizeIsNegative =
true;
5619 unsigned ActiveSizeBits
5653 TypeLoc DstElemTL = DstATL.getElementLoc();
5666 bool &SizeIsNegative,
5667 llvm::APSInt &Oversized) {
5670 SizeIsNegative, Oversized);
5697 return Result.empty() ? nullptr : *Result.begin();
5707 diag::err_virtual_non_function);
5711 diag::err_explicit_non_function);
5715 diag::err_noreturn_non_function);
5735 << getLangOpts().CPlusPlus17;
5743 diag::err_deduction_guide_invalid_specifier)
5752 if (!NewTD)
return nullptr;
5755 ProcessDeclAttributes(S, NewTD, D);
5757 CheckTypedefForVariablyModifiedType(S, NewTD);
5760 NamedDecl *ND = ActOnTypedefNameDecl(S, DC, NewTD, Previous, Redeclaration);
5774 setFunctionHasBranchProtectedScope();
5777 bool SizeIsNegative;
5778 llvm::APSInt Oversized;
5791 else if (Oversized.getBoolValue())
5793 << Oversized.toString(10);
5810 NamedDecl *ShadowedDecl = getShadowedDeclaration(NewTD, Previous);
5814 FilterLookupForScope(Previous, DC, S,
false,
5817 if (!Previous.
empty()) {
5818 Redeclaration =
true;
5819 MergeTypedefNameDecl(S, NewTD, Previous);
5822 if (ShadowedDecl && !Redeclaration)
5823 CheckShadow(NewTD, ShadowedDecl, Previous);
5829 if (II->isStr(
"FILE"))
5831 else if (II->isStr(
"jmp_buf"))
5833 else if (II->isStr(
"sigjmp_buf"))
5835 else if (II->isStr(
"ucontext_t"))
5893 if (!OuterContext->
Equals(PrevOuterContext))
5902 if (!SS.
isSet())
return;
5911 unsigned kind = -1U;
5912 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5913 if (var->hasAttr<BlocksAttr>())
5915 else if (!var->hasLocalStorage())
5917 }
else if (isa<ObjCIvarDecl>(decl)) {
5919 }
else if (isa<FieldDecl>(decl)) {
5937 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5940 var->getTLSKind()) {
5941 Diag(var->getLocation(), diag::err_arc_thread_ownership)
5962 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
5970 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
5971 if (VD->hasInit()) {
5972 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
5973 assert(VD->isThisDeclarationADefinition() &&
5974 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
5976 VD->dropAttr<AliasAttr>();
5983 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
5986 diag::err_attribute_selectany_non_extern_data);
5994 auto *VD = dyn_cast<
VarDecl>(&ND);
6004 if (
auto *MD = dyn_cast<CXXMethodDecl>(&ND))
6005 if (MD->isVirtual()) {
6007 diag::err_invalid_attribute_on_virtual_function)
6013 if (
const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
6018 for (
TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
6026 if (!MD || MD->isStatic()) {
6029 }
else if (isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD)) {
6040 bool IsSpecialization,
6041 bool IsDefinition) {
6045 bool IsTemplate =
false;
6046 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
6047 OldDecl = OldTD->getTemplatedDecl();
6049 if (!IsSpecialization)
6050 IsDefinition =
false;
6052 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
6053 NewDecl = NewTD->getTemplatedDecl();
6057 if (!OldDecl || !NewDecl)
6060 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
6061 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
6062 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
6063 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
6067 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
6068 (NewExportAttr && !NewExportAttr->isInherited());
6074 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
6076 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
6078 bool JustWarn =
false;
6080 auto *VD = dyn_cast<
VarDecl>(OldDecl);
6081 if (VD && !VD->getDescribedVarTemplate())
6092 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
6095 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
6096 : diag::err_attribute_dll_redeclaration;
6099 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
6112 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
6114 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
6117 IsStaticDataMember = VD->isStaticDataMember();
6118 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
6120 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
6121 IsInline = FD->isInlined();
6122 IsQualifiedFriend = FD->getQualifier() &&
6126 if (OldImportAttr && !HasNewAttr &&
6127 (!IsInline || (IsMicrosoft && IsTemplate)) && !IsStaticDataMember &&
6129 if (IsMicrosoft && IsDefinition) {
6131 diag::warn_redeclaration_without_import_attribute)
6134 NewDecl->
dropAttr<DLLImportAttr>();
6136 NewImportAttr->getRange(), S.
Context,
6137 NewImportAttr->getSpellingListIndex()));
6140 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
6141 << NewDecl << OldImportAttr;
6143 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
6144 OldDecl->
dropAttr<DLLImportAttr>();
6145 NewDecl->
dropAttr<DLLImportAttr>();
6147 }
else if (IsInline && OldImportAttr && !IsMicrosoft) {
6150 OldDecl->
dropAttr<DLLImportAttr>();
6151 NewDecl->
dropAttr<DLLImportAttr>();
6153 diag::warn_dllimport_dropped_from_inline_function)
6154 << NewDecl << OldImportAttr;
6161 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
6163 !NewImportAttr && !NewExportAttr) {
6164 if (
const DLLExportAttr *ParentExportAttr =
6165 MD->getParent()->getAttr<DLLExportAttr>()) {
6166 DLLExportAttr *NewAttr = ParentExportAttr->clone(S.
Context);
6167 NewAttr->setInherited(
true);
6207 template<
typename T>
6211 if (!D->isInExternCContext() || D->template hasAttr<OverloadableAttr>())
6215 if (S.
getLangOpts().CUDA && (D->template hasAttr<CUDADeviceAttr>() ||
6216 D->template hasAttr<CUDAHostAttr>()))
6219 return D->isExternC();
6230 llvm_unreachable(
"Unexpected context");
6236 isa<OMPDeclareReductionDecl>(DC))
6240 llvm_unreachable(
"Unexpected context");
6286 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
6287 return FD->isExternC();
6288 if (
const auto *VD = dyn_cast<VarDecl>(D))
6289 return VD->isExternC();
6291 llvm_unreachable(
"Unknown type of decl!");
6307 if (!Decomp.bindings().empty()) {
6308 II = Decomp.bindings()[0].Name;
6316 if (getLangOpts().OpenCL) {
6322 diag::err_opencl_type_can_only_be_used_as_function_parameter)
6335 diag::err_invalid_type_for_program_scope_var) << R;
6352 if (!getOpenCLOptions().
isEnabled(
"cl_khr_fp16")) {
6396 bool IsCXX = getLangOpts().OpenCLCPlusPlus;
6398 diag::err_opencl_unknown_type_specifier)
6399 << IsCXX << getLangOpts().getOpenCLVersionTuple().getAsString()
6417 bool IsLocalExternDecl = SC ==
SC_Extern &&
6418 adjustContextForLocalExternDecl(DC);
6429 !D.
getAsmLabel() && !getSourceManager().isInSystemMacro(
6435 getLangOpts().CPlusPlus17 ? diag::ext_register_storage_class
6436 : diag::warn_deprecated_register)
6452 bool IsMemberSpecialization =
false;
6453 bool IsVariableTemplateSpecialization =
false;
6455 bool IsVariableTemplate =
false;
6464 if (R->getContainedDeducedType())
6465 ParsingInitForAutoVars.insert(NewVD);
6470 bool Invalid =
false;
6472 if (DC->
isRecord() && !CurContext->isRecord()) {
6479 diag::err_static_out_of_line)
6491 diag::err_storage_class_for_static_member)
6495 llvm_unreachable(
"C storage class in c++!");
6499 if (SC ==
SC_Static && CurContext->isRecord()) {
6500 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
6501 if (RD->isLocalClass())
6503 diag::err_static_data_member_not_allowed_in_local_class)
6504 << Name << RD->getDeclName();
6510 getLangOpts().CPlusPlus11
6511 ? diag::warn_cxx98_compat_static_data_member_in_union
6512 : diag::ext_static_data_member_in_union) << Name;
6514 else if (!RD->getDeclName())
6516 diag::err_static_data_member_not_allowed_in_anon_struct)
6517 << Name << RD->isUnion();
6523 TemplateParams = MatchTemplateParametersToScopeSpecifier(
6530 false, IsMemberSpecialization, Invalid);
6532 if (TemplateParams) {
6533 if (!TemplateParams->
size() &&
6538 diag::err_template_variable_noparams)
6542 TemplateParams =
nullptr;
6547 IsVariableTemplateSpecialization =
true;
6548 IsPartialSpecialization = TemplateParams->
size() > 0;
6551 IsVariableTemplate =
true;
6554 if (CheckTemplateDeclScope(S, TemplateParams))
6559 getLangOpts().CPlusPlus14
6560 ? diag::warn_cxx11_compat_variable_template
6561 : diag::ext_variable_template);
6567 "should have a 'template<>' for this decl");
6570 if (IsVariableTemplateSpecialization) {
6572 TemplateParamLists.size() > 0
6573 ? TemplateParamLists[0]->getTemplateLoc()
6575 DeclResult Res = ActOnVarTemplateSpecialization(
6576 S, D, TInfo, TemplateKWLoc, TemplateParams, SC,
6577 IsPartialSpecialization);
6580 NewVD = cast<VarDecl>(Res.
get());
6591 if (IsVariableTemplate) {
6594 TemplateParams, NewVD);
6595 NewVD->setDescribedVarTemplate(NewTemplate);
6600 if (R->getContainedDeducedType())
6601 ParsingInitForAutoVars.insert(NewVD);
6613 unsigned VDTemplateParamLists = TemplateParams ? 1 : 0;
6614 if (TemplateParamLists.size() > VDTemplateParamLists)
6615 NewVD->setTemplateParameterListsInfo(
6616 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
6619 NewVD->setConstexpr(
true);
6623 if (NewVD->isStaticDataMember() && getLangOpts().CPlusPlus17)
6624 NewVD->setImplicitlyInline();
6629 if (!getLangOpts().CPlusPlus) {
6632 }
else if (CurContext->isFunctionOrMethod()) {
6635 diag::err_inline_declaration_block_scope) << Name
6639 getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_inline_variable
6640 : diag::ext_inline_variable);
6651 if (IsLocalExternDecl) {
6653 for (
auto *B : Bindings)
6654 B->setLocalExternDecl();
6659 bool EmitTLSUnsupportedError =
false;
6672 diag::err_thread_non_global)
6675 if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
6679 EmitTLSUnsupportedError =
true;
6686 diag::err_thread_unsupported);
6705 diag::warn_static_local_in_extern_inline);
6706 MaybeSuggestAddingStaticToDecl(CurFD);
6711 if (IsVariableTemplateSpecialization)
6713 << (IsPartialSpecialization ? 1 : 0)
6716 else if (IsMemberSpecialization)
6729 for (
auto *B : Bindings)
6730 B->setModulePrivate();
6735 ProcessDeclAttributes(S, NewVD, D);
6737 if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
6738 if (EmitTLSUnsupportedError &&
6740 (getLangOpts().OpenMPIsDevice &&
6741 NewVD->
hasAttr<OMPDeclareTargetDeclAttr>())))
6743 diag::err_thread_unsupported);
6747 (NewVD->
hasAttr<CUDASharedAttr>() ||
6748 NewVD->
hasAttr<CUDAConstantAttr>())) {
6756 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
6757 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
6762 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewVD))
6774 Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
6780 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6791 bool HasSizeMismatch;
6793 if (!TI.isValidGCCRegisterName(Label))
6794 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6795 else if (!TI.validateGlobalRegisterVariable(Label,
6798 Diag(E->getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
6799 else if (HasSizeMismatch)
6800 Diag(E->getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
6810 Context,
Label, 0));
6811 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
6812 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
6814 if (I != ExtnameUndeclaredIdentifiers.end()) {
6817 ExtnameUndeclaredIdentifiers.erase(I);
6826 ? getShadowedDeclaration(NewVD, Previous)
6834 IsMemberSpecialization ||
6835 IsVariableTemplateSpecialization);
6839 if (getLangOpts().CPlusPlus &&
6843 isDeclInScope(Previous.
getFoundDecl(), OriginalDC, S,
false));
6845 if (!getLangOpts().CPlusPlus) {
6850 CheckMemberSpecialization(NewVD, Previous))
6854 if (!Previous.
empty()) {
6873 if (!IsVariableTemplateSpecialization)
6885 if (CheckTemplateParameterList(
6891 ? TPC_ClassTemplateMember
6897 if (PrevVarTemplate &&
6905 CheckShadow(NewVD, ShadowedDecl, Previous);
6907 ProcessPragmaWeak(S, NewVD);
6913 RegisterLocallyScopedExternCDecl(NewVD, S);
6916 Decl *ManglingContextDecl;
6920 NewVD, MCtx->getManglingNumber(
6933 if (getLangOpts().CPlusPlus)
6951 ActOnDocumentableDecl(NewTemplate);
6956 CompleteMemberSpecialization(NewVD, Previous);
6974 if (isa<TypeAliasDecl>(ShadowedDecl))
6976 else if (isa<TypedefDecl>(ShadowedDecl))
6978 else if (isa<RecordDecl>(OldDC))
7017 return isa<VarDecl>(ShadowedDecl) || isa<FieldDecl>(ShadowedDecl)
7034 return isa<TypedefNameDecl>(ShadowedDecl) ? ShadowedDecl :
nullptr;
7050 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
7058 if (isa<CXXConstructorDecl>(NewDC))
7059 if (
const auto PVD = dyn_cast<ParmVarDecl>(D)) {
7062 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
7067 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
7068 if (shadowedVar->isExternC()) {
7071 for (
auto I : shadowedVar->redecls())
7072 if (I->isFileVarDecl()) {
7080 unsigned WarningDiag = diag::warn_decl_shadow;
7082 if (isa<VarDecl>(D) && isa<VarDecl>(ShadowedDecl) && NewDC &&
7083 isa<CXXMethodDecl>(NewDC)) {
7084 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
7086 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
7088 const auto *LSI = cast<LambdaScopeInfo>(getCurFunction());
7091 if (CaptureLoc.isInvalid())
7092 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
7096 cast<LambdaScopeInfo>(getCurFunction())
7097 ->ShadowingDecls.push_back(
7098 {cast<VarDecl>(D), cast<VarDecl>(ShadowedDecl)});
7103 if (cast<VarDecl>(ShadowedDecl)->hasLocalStorage()) {
7107 ParentDC && !ParentDC->
Equals(OldDC);
7111 if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) &&
7138 if (getSourceManager().isInSystemMacro(R.
getNameLoc()))
7143 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7152 const VarDecl *ShadowedDecl = Shadow.ShadowedDecl;
7157 ? diag::warn_decl_shadow_uncaptured_local
7158 : diag::warn_decl_shadow)
7159 << Shadow.VD->getDeclName()
7162 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7163 << Shadow.VD->getDeclName() << 0;
7170 if (Diags.isIgnored(diag::warn_decl_shadow, D->
getLocation()))
7176 if (
NamedDecl *ShadowedDecl = getShadowedDeclaration(D, R))
7177 CheckShadow(D, ShadowedDecl, R);
7184 if (!getLangOpts().
CPlusPlus || ShadowingDecls.empty())
7190 const NamedDecl *D = cast<NamedDecl>(DRE->getDecl()->getCanonicalDecl());
7191 auto I = ShadowingDecls.find(D);
7192 if (I == ShadowingDecls.end())
7194 const NamedDecl *ShadowedDecl = I->second;
7196 Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
7201 ShadowingDecls.erase(I);
7206 template<
typename T>
7209 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
7230 if (!isa<VarDecl>(ND))
7240 if (isa<VarDecl>(*I)) {
7250 if (isa<VarDecl>(*I)) {
7268 assert(Prev &&
"should have found a previous declaration to diagnose");
7270 Prev = FD->getFirstDecl();
7272 Prev = cast<VarDecl>(Prev)->getFirstDecl();
7274 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
7276 S.
Diag(Prev->getLocation(), diag::note_extern_c_global_conflict)
7289 template<
typename T>
7296 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
7308 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
7333 CheckAlignasUnderalignment(NewVD);
7355 if (getLangOpts().OpenCLVersion == 120 &&
7356 !getOpenCLOptions().
isEnabled(
"cl_clang_storage_class_specifiers") &&
7363 if (getLangOpts().OpenCL) {
7365 if (NewVD->
hasAttr<BlocksAttr>()) {
7374 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
7380 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
7395 getLangOpts().OpenCLVersion == 200))) {
7397 if (getLangOpts().OpenCLVersion == 200)
7398 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7399 << Scope <<
"global or constant";
7401 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7402 << Scope <<
"constant";
7418 if (FD && !FD->
hasAttr<OpenCLKernelAttr>()) {
7430 if (FD && FD->
hasAttr<OpenCLKernelAttr>()) {
7431 if (!getCurScope()->isFunctionScope()) {
7452 && !NewVD->
hasAttr<BlocksAttr>()) {
7456 assert(!getLangOpts().ObjCAutoRefCount);
7462 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
7464 setFunctionHasBranchProtectedScope();
7468 bool SizeIsNegative;
7469 llvm::APSInt Oversized;
7474 FixedT = FixedTInfo->
getType();
7475 else if (FixedTInfo) {
7531 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
7539 diag::err_constexpr_var_non_literal)) {
7558 CheckVariableDeclarationType(NewVD);
7566 if (Previous.
empty() &&
7570 if (!Previous.
empty()) {
7571 MergeVarDecl(NewVD, Previous);
7578 struct FindOverriddenMethod {
7604 if (MD->isVirtual() && !S->
IsOverload(Method, MD,
false))
7629 if ((OEK == OEK_All) ||
7630 (OEK == OEK_NonDeleted && !O->isDeleted()) ||
7631 (OEK == OEK_Deleted && O->isDeleted()))
7632 S.
Diag(O->getLocation(), diag::note_overridden_virtual_function);
7641 FindOverriddenMethod FOM;
7644 bool hasDeletedOverridenMethods =
false;
7645 bool hasNonDeletedOverridenMethods =
false;
7646 bool AddedAny =
false;
7651 if (!CheckOverridingFunctionReturnType(MD, OldMD) &&
7652 !CheckOverridingFunctionAttributes(MD, OldMD) &&
7653 !CheckOverridingFunctionExceptionSpec(MD, OldMD) &&
7654 !CheckIfOverriddenFunctionIsMarkedFinal(MD, OldMD)) {
7655 hasDeletedOverridenMethods |= OldMD->isDeleted();
7656 hasNonDeletedOverridenMethods |= !OldMD->isDeleted();
7663 if (hasDeletedOverridenMethods && !MD->
isDeleted()) {
7664 ReportOverrides(*
this, diag::err_non_deleted_override, MD, OEK_Deleted);
7666 if (hasNonDeletedOverridenMethods && MD->
isDeleted()) {
7667 ReportOverrides(*
this, diag::err_deleted_override, MD, OEK_NonDeleted);
7676 struct ActOnFDArgs {
7692 : Context(Context), OriginalFD(TypoFD),
7695 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
7701 CDeclEnd = candidate.
end();
7702 CDecl != CDeclEnd; ++CDecl) {
7711 }
else if (!ExpectedParent) {
7729 TypoCorrectedFunctionDefinitions.insert(F);
7743 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *S) {
7749 bool IsDefinition = ExtraArgs.D.isFunctionDefinition();
7750 unsigned DiagMsg = IsLocalFriend ? diag::err_no_matching_local_friend
7751 : diag::err_member_decl_does_not_match;
7762 assert(!Prev.isAmbiguous() &&
7763 "Cannot have an ambiguity in previous-declaration lookup");
7765 if (!Prev.empty()) {
7767 Func != FuncEnd; ++Func) {
7774 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
7775 NearMatches.push_back(std::make_pair(FD, ParamNum));
7780 Prev.getLookupNameInfo(), Prev.getLookupKind(), S,
7781 &ExtraArgs.D.getCXXScopeSpec(),
7782 llvm::make_unique<DifferentNameValidatorCCC>(
7787 ExtraArgs.D.getIdentifierLoc());
7791 CDeclEnd = Correction.
end();
7792 CDecl != CDeclEnd; ++CDecl) {
7799 bool wasRedeclaration = ExtraArgs.D.isRedeclaration();
7812 ExtraArgs.S, ExtraArgs.D,
7815 ExtraArgs.AddToScope);
7826 if ((*I)->getCanonicalDecl() == Canonical)
7833 SemaRef.
PDiag(IsLocalFriend
7834 ? diag::err_no_matching_local_friend_suggest
7835 : diag::err_member_decl_does_not_match_suggest)
7836 << Name << NewDC << IsDefinition);
7842 ExtraArgs.D.getIdentifierLoc());
7843 ExtraArgs.D.setRedeclaration(wasRedeclaration);
7849 << Name << NewDC << IsDefinition << NewFD->
getLocation();
7851 bool NewFDisConst =
false;
7853 NewFDisConst = NewMD->isConst();
7856 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
7857 NearMatch != NearMatchEnd; ++NearMatch) {
7860 bool FDisConst = MD && MD->
isConst();
7861 bool IsMember = MD || !IsLocalFriend;
7864 if (
unsigned Idx = NearMatch->second) {
7868 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
7869 : diag::note_local_decl_close_param_match)
7872 }
else if (FDisConst != NewFDisConst) {
7873 SemaRef.
Diag(FD->
getLocation(), diag::note_member_def_close_const_match)
7877 IsMember ? diag::note_member_def_close_match
7878 : diag::note_local_decl_close_match);
7885 default: llvm_unreachable(
"Unknown storage class!");
7890 diag::err_typecheck_sclass_func);
7907 diag::err_static_block_func);
7923 bool &IsVirtualOkay) {
7943 TInfo, SC, isInline,
7944 HasPrototype,
false);
7966 "Constructors can only be declared in a member context");
7971 R, TInfo, isExplicit, isInline,
7983 NameInfo, R, TInfo, isInline,
7995 IsVirtualOkay =
true;
8014 diag::err_conv_function_not_member);
8019 IsVirtualOkay =
true;
8022 R, TInfo, isInline, isExplicit,
8029 isExplicit, NameInfo, R, TInfo,
8046 cast<CXXRecordDecl>(DC),
8048 TInfo, SC, isInline,
8063 NameInfo, R, TInfo, SC, isInline,
8081 StringRef SizeTypeNames[] = {
"size_t",
"intptr_t",
"uintptr_t",
"ptrdiff_t"};
8089 std::find(Names.begin(), Names.end(), DesugaredTy.
getAsString());
8090 if (Names.end() != Match)
8095 }
while (DesugaredTy != Ty);
8151 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
8198 S.
Diag(Loc, diag::note_entity_declared_at) << PT;
8221 HistoryStack.push_back(
nullptr);
8230 VisitStack.push_back(RecTy->
getDecl());
8231 assert(VisitStack.back() &&
"First decl null?");
8234 const Decl *Next = VisitStack.pop_back_val();
8236 assert(!HistoryStack.empty());
8238 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
8239 ValidTypes.insert(Hist->getType().getTypePtr());
8247 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(Next)) {
8248 HistoryStack.push_back(Field);
8250 QualType FieldTy = Field->getType();
8254 "Unexpected type.");
8259 RD = cast<RecordDecl>(Next);
8263 VisitStack.push_back(
nullptr);
8265 for (
const auto *FD : RD->
fields()) {
8276 VisitStack.push_back(FD);
8287 diag::err_record_with_pointers_kernel_param)
8294 S.
Diag(OrigRecDecl->getLocation(), diag::note_within_field_of_type)
8295 << OrigRecDecl->getDeclName();
8300 I = HistoryStack.begin() + 1,
8301 E = HistoryStack.end();
8308 S.
Diag(FD->getLocation(), diag::note_illegal_field_declared_here)
8314 }
while (!VisitStack.empty());
8331 (LangOpts.CPlusPlus &&
8355 diag::err_invalid_thread)
8362 bool isFriend =
false;
8364 bool isMemberSpecialization =
false;
8365 bool isFunctionTemplateSpecialization =
false;
8367 bool isDependentClassScopeExplicitSpecialization =
false;
8368 bool HasExplicitTemplateArgs =
false;
8371 bool isVirtualOkay =
false;
8374 bool IsLocalExternDecl = adjustContextForLocalExternDecl(DC);
8378 if (!NewFD)
return nullptr;
8380 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer())
8388 if (IsLocalExternDecl)
8409 if (
Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
8414 if (isVirtual &&
Parent->isUnion())
8419 isMemberSpecialization =
false;
8420 isFunctionTemplateSpecialization =
false;
8426 bool Invalid =
false;
8428 MatchTemplateParametersToScopeSpecifier(
8434 TemplateParamLists, isFriend, isMemberSpecialization,
8436 if (TemplateParams->size() > 0) {
8440 if (CheckTemplateDeclScope(S, TemplateParams))
8454 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
8460 Name, TemplateParams,
8466 if (TemplateParamLists.size() > 1) {
8468 TemplateParamLists.drop_back(1));
8472 isFunctionTemplateSpecialization =
true;
8474 if (TemplateParamLists.size() > 0)
8480 SourceRange RemoveRange = TemplateParams->getSourceRange();
8490 InsertLoc = getLocForEndOfToken(InsertLoc);
8494 << Name << RemoveRange
8503 if (TemplateParamLists.size() > 0)
8510 if (FunctionTemplate)
8520 if (!isVirtualOkay) {
8522 diag::err_virtual_non_function);
8523 }
else if (!CurContext->isRecord()) {
8526 diag::err_virtual_out_of_class)
8532 diag::err_virtual_member_function_template)
8544 if (getLangOpts().CPlusPlus14 &&
8546 (isFriend && CurContext->isDependentContext())) &&
8566 if (CurContext->isFunctionOrMethod()) {
8569 diag::err_inline_declaration_block_scope) << Name
8579 !isa<CXXDeductionGuideDecl>(NewFD)) {
8580 if (!CurContext->isRecord()) {
8583 diag::err_explicit_out_of_class)
8585 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
8586 !isa<CXXConversionDecl>(NewFD)) {
8590 diag::err_explicit_non_ctor_or_conv_function)
8603 if (isa<CXXDestructorDecl>(NewFD))
8609 if (isFunctionTemplateSpecialization) {
8612 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
8617 if (FunctionTemplate)
8623 if (FunctionTemplate) {
8648 if (isa<CXXMethodDecl>(NewFD) && DC == CurContext &&
8656 if (SC ==
SC_Static && isa<CXXMethodDecl>(NewFD) &&
8657 !CurContext->isRecord()) {
8666 diag::err_static_out_of_line)
8676 getLangOpts().CPlusPlus11 && FPT && !FPT->hasExceptionSpec())
8678 FPT->getReturnType(), FPT->getParamTypes(),
8685 isMemberSpecialization ||
8686 isFunctionTemplateSpecialization);
8694 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
8695 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
8697 if (I != ExtnameUndeclaredIdentifiers.end()) {
8700 ExtnameUndeclaredIdentifiers.erase(I);
8720 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
8724 Params.push_back(Param);
8739 auto *TD = dyn_cast<
TagDecl>(NonParmDecl);
8744 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
8745 TD = cast<EnumDecl>(ECD->getDeclContext());
8753 TD->setDeclContext(NewFD);
8761 if (TagDC != PrototypeTagContext)
8762 TD->setLexicalDeclContext(TagDC);
8776 for (
const auto &AI : FT->param_types()) {
8780 Params.push_back(Param);
8784 "Should not need args for typedef of non-prototype fn");
8788 NewFD->setParams(Params);
8805 !NewFD->
hasAttr<SectionAttr>()) {
8806 NewFD->
addAttr(PragmaClangTextSectionAttr::CreateImplicit(Context,
8807 PragmaClangTextSection.SectionName,
8808 PragmaClangTextSection.PragmaLocation));
8813 !NewFD->
hasAttr<SectionAttr>()) {
8815 SectionAttr::CreateImplicit(Context, SectionAttr::Declspec_allocate,
8816 CodeSegStack.CurrentValue->getString(),
8817 CodeSegStack.CurrentPragmaLocation));
8818 if (UnifySection(CodeSegStack.CurrentValue->getString(),
8827 if (!NewFD->
hasAttr<CodeSegAttr>()) {
8828 if (
Attr *SAttr = getImplicitCodeSegOrSectionAttrForFunction(NewFD,
8835 ProcessDeclAttributes(S, NewFD, D);
8837 if (getLangOpts().OpenCL) {
8843 diag::err_opencl_return_value_with_address_space);
8854 CheckMSVCRTEntryPoint(NewFD);
8858 isMemberSpecialization));
8859 else if (!Previous.
empty())
8864 "previous declaration set still overloaded");
8876 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
8893 diag::ext_operator_new_delete_declared_inline)
8904 translateTemplateArguments(TemplateArgsPtr,
8907 HasExplicitTemplateArgs =
true;
8910 HasExplicitTemplateArgs =
false;
8911 }
else if (FunctionTemplate) {
8916 HasExplicitTemplateArgs =
false;
8918 assert((isFunctionTemplateSpecialization ||
8920 "should have a 'template<>' for this decl");
8922 isFunctionTemplateSpecialization =
true;
8924 }
else if (isFriend && isFunctionTemplateSpecialization) {
8931 HasExplicitTemplateArgs =
true;
8942 if (getLangOpts().CUDA & !isFunctionTemplateSpecialization)
8943 maybeAddCUDAHostDeviceAttrs(NewFD, Previous);
8949 bool InstantiationDependent =
false;
8950 if (isFunctionTemplateSpecialization && isFriend &&
8954 InstantiationDependent))) {
8955 assert(HasExplicitTemplateArgs &&
8956 "friend function specialization without template args");
8957 if (CheckDependentFunctionTemplateSpecialization(NewFD, TemplateArgs,
8960 }
else if (isFunctionTemplateSpecialization) {
8961 if (CurContext->isDependentContext() && CurContext->isRecord()
8963 isDependentClassScopeExplicitSpecialization =
true;
8965 CheckFunctionTemplateSpecialization(
8966 NewFD, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr),
8978 diag::err_explicit_specialization_inconsistent_storage_class)
8985 diag::ext_explicit_specialization_storage_class)
8989 }
else if (isMemberSpecialization && isa<CXXMethodDecl>(NewFD)) {
8990 if (CheckMemberSpecialization(NewFD, Previous))
8995 if (!isDependentClassScopeExplicitSpecialization) {
9000 CheckMSVCRTEntryPoint(NewFD);
9004 isMemberSpecialization));
9005 else if (!Previous.
empty())
9012 "previous declaration set still overloaded");
9014 NamedDecl *PrincipalDecl = (FunctionTemplate
9015 ? cast<NamedDecl>(FunctionTemplate)
9024 if (FunctionTemplate) FunctionTemplate->
setAccess(Access);
9033 if (FunctionTemplate) {
9041 ? TPC_FriendFunctionTemplateDefinition
9042 : TPC_FriendFunctionTemplate)
9046 ? TPC_ClassTemplateMember
9047 : TPC_FunctionTemplate);
9053 struct ActOnFDArgs ExtraArgs = { S, D, TemplateParamLists,
9071 (TemplateParamLists.size() ||
9073 CurContext->isDependentContext())) {
9092 *
this, Previous, NewFD, ExtraArgs,
false,
nullptr)) {
9093 AddToScope = ExtraArgs.AddToScope;
9100 }
else if (isFriend && cast<CXXRecordDecl>(CurContext)->isLocalClass()) {
9102 *
this, Previous, NewFD, ExtraArgs,
true, S)) {
9103 AddToScope = ExtraArgs.AddToScope;
9108 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
9109 !isFriend && !isFunctionTemplateSpecialization &&
9110 !isMemberSpecialization) {
9123 ProcessPragmaWeak(S, NewFD);
9126 AddKnownFunctionAttributes(NewFD);
9128 if (NewFD->
hasAttr<OverloadableAttr>() &&
9131 diag::err_attribute_overloadable_no_prototype)
9139 EPI.ExtInfo = FT->getExtInfo();
9148 AddPushedVisibilityAttribute(NewFD);
9152 AddCFAuditedAttribute(NewFD);
9157 AddRangeBasedOptnone(NewFD);
9163 RegisterLocallyScopedExternCDecl(NewFD, S);
9171 isMemberSpecialization ||
9172 isFunctionTemplateSpecialization,
9176 if (getLangOpts().CUDA) {
9179 II->
isStr(getLangOpts().HIP ?
"hipConfigureCall" 9180 :
"cudaConfigureCall") &&
9191 if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->
isVariadic() &&
9192 (NewFD->
hasAttr<CUDADeviceAttr>() ||
9193 NewFD->
hasAttr<CUDAGlobalAttr>()) &&
9200 MarkUnusedFileScopedDecl(NewFD);
9203 if (FunctionTemplate) {
9206 return FunctionTemplate;
9210 CompleteMemberSpecialization(NewFD, Previous);
9213 if (NewFD->
hasAttr<OpenCLKernelAttr>()) {
9215 if ((getLangOpts().OpenCLVersion >= 120)
9230 llvm::SmallPtrSet<const Type *, 16> ValidTypes;
9239 if (getLangOpts().OpenCLVersion >= 200) {
9241 QualType ElemTy = PipeTy->getElementType();
9243 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type );
9253 if (isDependentClassScopeExplicitSpecialization) {
9257 cast<CXXMethodDecl>(NewFD),
9258 HasExplicitTemplateArgs, TemplateArgs);
9259 CurContext->addDecl(NewSpec);
9265 if (
const auto *attr = NewFD->
getAttr<AvailabilityAttr>()) {
9266 if (NewFD->
hasAttr<ConstructorAttr>()) {
9267 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer)
9269 NewFD->
dropAttr<AvailabilityAttr>();
9271 if (NewFD->
hasAttr<DestructorAttr>()) {
9272 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer)
9274 NewFD->
dropAttr<AvailabilityAttr>();
9296 if (
const auto *SAttr = Parent->
getAttr<CodeSegAttr>()) {
9307 while ((Parent = dyn_cast<CXXRecordDecl>(Parent->
getParent()))) {
9308 if (
const auto *SAttr = Parent->
getAttr<CodeSegAttr>()) {
9327 bool IsDefinition) {
9330 if (!FD->
hasAttr<SectionAttr>() && IsDefinition &&
9331 CodeSegStack.CurrentValue) {
9332 return SectionAttr::CreateImplicit(getASTContext(),
9333 SectionAttr::Declspec_allocate,
9334 CodeSegStack.CurrentValue->getString(),
9335 CodeSegStack.CurrentPragmaLocation);
9371 if (FD->
hasAttr<TargetAttr>())
9373 if (FD->
hasAttr<CPUDispatchAttr>())
9375 if (FD->
hasAttr<CPUSpecificAttr>())
9384 const auto *TA = FD->
getAttr<TargetAttr>();
9385 assert(TA &&
"MultiVersion Candidate requires a target attribute");
9386 TargetAttr::ParsedTargetAttr ParseInfo = TA->parse();
9388 enum ErrType { Feature = 0, Architecture = 1 };
9390 if (!ParseInfo.Architecture.empty() &&
9393 << Architecture << ParseInfo.Architecture;
9397 for (
const auto &Feat : ParseInfo.Features) {
9398 auto BareFeat = StringRef{Feat}.substr(1);
9399 if (Feat[0] ==
'-') {
9401 << Feature << (
"no-" + BareFeat).str();
9408 << Feature << BareFeat;
9419 enum DoesntSupport {
9438 bool IsCPUSpecificCPUDispatchMVType =
9460 if (CausesMV && OldFD &&
9463 << IsCPUSpecificCPUDispatchMVType;
9469 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_no_other_attrs)
9470 << IsCPUSpecificCPUDispatchMVType;
9473 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_doesnt_support)
9474 << IsCPUSpecificCPUDispatchMVType << FuncTemplates;
9476 if (
const auto *NewCXXFD = dyn_cast<CXXMethodDecl>(NewFD)) {
9477 if (NewCXXFD->isVirtual())
9478 return S.
Diag(NewCXXFD->getLocation(),
9479 diag::err_multiversion_doesnt_support)
9480 << IsCPUSpecificCPUDispatchMVType << VirtFuncs;
9482 if (
const auto *NewCXXCtor = dyn_cast<CXXConstructorDecl>(NewFD))
9483 return S.
Diag(NewCXXCtor->getLocation(),
9484 diag::err_multiversion_doesnt_support)
9485 << IsCPUSpecificCPUDispatchMVType << Constructors;
9487 if (
const auto *NewCXXDtor = dyn_cast<CXXDestructorDecl>(NewFD))
9488 return S.
Diag(NewCXXDtor->getLocation(),
9489 diag::err_multiversion_doesnt_support)
9490 << IsCPUSpecificCPUDispatchMVType << Destructors;
9494 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_doesnt_support)
9495 << IsCPUSpecificCPUDispatchMVType << DeletedFuncs;
9498 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_doesnt_support)
9499 << IsCPUSpecificCPUDispatchMVType << DefaultedFuncs;
9503 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_doesnt_support)
9504 << IsCPUSpecificCPUDispatchMVType << ConstexprFuncs;
9507 const auto *NewType = cast<FunctionType>(NewQType);
9508 QualType NewReturnType = NewType->getReturnType();
9510 if (NewReturnType->isUndeducedType())
9511 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_doesnt_support)
9512 << IsCPUSpecificCPUDispatchMVType << DeducedReturn;
9515 if (OldFD && CausesMV && OldFD->
isUsed(
false))
9516 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
9521 const auto *OldType = cast<FunctionType>(OldQType);
9525 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC())
9529 QualType OldReturnType = OldType->getReturnType();
9531 if (OldReturnType != NewReturnType)
9567 const TargetAttr *TA,
9568 const CPUDispatchAttr *CPUDisp,
9569 const CPUSpecificAttr *CPUSpec) {
9571 "Function lacks multiversion attribute");
9594 bool &Redeclaration,
NamedDecl *&OldDecl,
bool &MergeTypeWithPrevious,
9596 const auto *OldTA = OldFD->
getAttr<TargetAttr>();
9597 TargetAttr::ParsedTargetAttr NewParsed = NewTA->parse();
9599 llvm::sort(NewParsed.Features.begin(), NewParsed.Features.end());
9603 if (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())
9631 TargetAttr::ParsedTargetAttr OldParsed =
9632 OldTA->parse(std::less<std::string>());
9634 if (OldParsed == NewParsed) {
9641 for (
const auto *FD : OldFD->
redecls()) {
9642 const auto *CurTA = FD->getAttr<TargetAttr>();
9643 if (!CurTA || CurTA->isInherited()) {
9644 S.
Diag(FD->getLocation(), diag::err_multiversion_required_in_redecl)
9654 Redeclaration =
false;
9655 MergeTypeWithPrevious =
false;
9666 const CPUDispatchAttr *NewCPUDisp,
const CPUSpecificAttr *NewCPUSpec,
9667 bool &Redeclaration,
NamedDecl *&OldDecl,
bool &MergeTypeWithPrevious,
9682 TargetAttr::ParsedTargetAttr NewParsed;
9684 NewParsed = NewTA->parse();
9685 llvm::sort(NewParsed.Features.begin(), NewParsed.Features.end());
9688 bool UseMemberUsingDeclRules =
9697 if (S.
IsOverload(NewFD, CurFD, UseMemberUsingDeclRules))
9701 const auto *CurTA = CurFD->
getAttr<TargetAttr>();
9702 if (CurTA->getFeaturesStr() == NewTA->getFeaturesStr()) {
9704 Redeclaration =
true;
9709 TargetAttr::ParsedTargetAttr CurParsed =
9710 CurTA->parse(std::less<std::string>());
9711 if (CurParsed == NewParsed) {
9718 const auto *CurCPUSpec = CurFD->
getAttr<CPUSpecificAttr>();
9719 const auto *CurCPUDisp = CurFD->
getAttr<CPUDispatchAttr>();
9724 CurFD->
hasAttr<CPUDispatchAttr>()) {
9725 if (CurCPUDisp->cpus_size() == NewCPUDisp->cpus_size() &&
9727 CurCPUDisp->cpus_begin(), CurCPUDisp->cpus_end(),
9728 NewCPUDisp->cpus_begin(),
9730 return Cur->
getName() == New->getName();
9733 Redeclaration =
true;
9746 if (CurCPUSpec->cpus_size() == NewCPUSpec->cpus_size() &&
9748 CurCPUSpec->cpus_begin(), CurCPUSpec->cpus_end(),
9749 NewCPUSpec->cpus_begin(),
9751 return Cur->
getName() == New->getName();
9754 Redeclaration =
true;
9762 if (CurII == NewII) {
9792 Redeclaration =
false;
9793 MergeTypeWithPrevious =
false;
9807 bool &Redeclaration,
NamedDecl *&OldDecl,
9808 bool &MergeTypeWithPrevious,
9810 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
9811 const auto *NewCPUDisp = NewFD->
getAttr<CPUDispatchAttr>();
9812 const auto *NewCPUSpec = NewFD->
getAttr<CPUSpecificAttr>();
9815 if ((NewTA && NewCPUDisp) || (NewTA && NewCPUSpec) ||
9816 (NewCPUDisp && NewCPUSpec)) {
9830 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_not_allowed_on_main);
9854 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_required_in_redecl)
9863 Redeclaration, OldDecl,
9864 MergeTypeWithPrevious, Previous);
9867 S.
Diag(OldFD->
getLocation(), diag::err_multiversion_required_in_redecl)
9878 S, OldFD, NewFD, MVType, NewTA, NewCPUDisp, NewCPUSpec, Redeclaration,
9879 OldDecl, MergeTypeWithPrevious, Previous);
9901 bool IsMemberSpecialization) {
9903 "Variably modified return types are not handled here");
9908 bool MergeTypeWithPrevious = !getLangOpts().CPlusPlus &&
9911 bool Redeclaration =
false;
9913 bool MayNeedOverloadableChecks =
false;
9917 if (!Previous.
empty()) {
9924 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
9925 Redeclaration =
true;
9926 OldDecl = Candidate;
9929 MayNeedOverloadableChecks =
true;
9930 switch (CheckOverload(S, NewFD, Previous, OldDecl,
9933 Redeclaration =
true;
9936 case Ovl_NonFunction:
9937 Redeclaration =
true;
9941 Redeclaration =
false;
9948 if (!Redeclaration &&
9950 if (!Previous.
empty()) {
9953 Redeclaration =
true;
9955 MergeTypeWithPrevious =
false;
9958 if (OldDecl->
hasAttr<OverloadableAttr>() ||
9959 NewFD->
hasAttr<OverloadableAttr>()) {
9960 if (IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
9961 MayNeedOverloadableChecks =
true;
9962 Redeclaration =
false;
9970 MergeTypeWithPrevious, Previous))
9971 return Redeclaration;
9983 if (!getLangOpts().CPlusPlus14 && MD && MD->
isConstexpr() &&
9984 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
9988 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
9989 if (!OldMD || !OldMD->
isStatic()) {
9999 if (!inTemplateInstantiation()) {
10003 AddConstLoc = getLocForEndOfToken(FTL.getRParenLoc());
10011 if (Redeclaration) {
10014 if (MergeFunctionDecl(NewFD, OldDecl, S, MergeTypeWithPrevious)) {
10016 return Redeclaration;
10023 dyn_cast<FunctionTemplateDecl>(OldDecl)) {
10024 auto *OldFD = OldTemplateDecl->getTemplatedDecl();
10029 assert(NewTemplateDecl &&
"Template/non-template mismatch");
10031 NewFD->
setAccess(OldTemplateDecl->getAccess());
10032 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
10037 if (IsMemberSpecialization &&
10040 assert(OldTemplateDecl->isMemberSpecialization());
10043 if (OldFD->isDeleted()) {
10045 assert(OldFD->getCanonicalDecl() == OldFD);
10047 OldFD->setDeletedAsWritten(
false);
10052 if (shouldLinkDependentDeclWithPrevious(NewFD, OldDecl)) {
10053 auto *OldFD = cast<FunctionDecl>(OldDecl);
10061 }
else if (!getLangOpts().CPlusPlus && MayNeedOverloadableChecks &&
10062 !NewFD->
getAttr<OverloadableAttr>()) {
10063 assert((Previous.
empty() ||
10064 llvm::any_of(Previous,
10066 return ND->
hasAttr<OverloadableAttr>();
10068 "Non-redecls shouldn't happen without overloadable present");
10070 auto OtherUnmarkedIter = llvm::find_if(Previous, [](
const NamedDecl *ND) {
10072 return FD && !FD->
hasAttr<OverloadableAttr>();
10075 if (OtherUnmarkedIter != Previous.
end()) {
10077 diag::err_attribute_overloadable_multiple_unmarked_overloads);
10078 Diag((*OtherUnmarkedIter)->getLocation(),
10079 diag::note_attribute_overloadable_prev_overload)
10082 NewFD->
addAttr(OverloadableAttr::CreateImplicit(Context));
10091 CheckConstructor(Constructor);
10093 dyn_cast<CXXDestructorDecl>(NewFD)) {
10106 return Redeclaration;
10110 = dyn_cast<CXXConversionDecl>(NewFD)) {
10111 ActOnConversionDeclarator(Conversion);
10112 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
10113 if (
auto *TD = Guide->getDescribedFunctionTemplate())
10114 CheckDeductionGuideTemplate(TD);
10119 Diag(Guide->getLocStart(), diag::err_deduction_guide_specialized)
10124 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
10125 if (!Method->isFunctionTemplateSpecialization() &&
10126 !Method->getDescribedFunctionTemplate() &&
10127 Method->isCanonicalDecl()) {
10128 if (AddOverriddenMethods(Method->getParent(), Method)) {
10136 if (Method->isStatic())
10137 checkThisInStaticMemberFunctionType(Method);
10142 CheckOverloadedOperatorDeclaration(NewFD)) {
10144 return Redeclaration;
10149 CheckLiteralOperatorDeclaration(NewFD)) {
10151 return Redeclaration;
10157 if (!CurContext->isRecord())
10158 CheckCXXDefaultArguments(NewFD);
10189 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
10202 auto HasNoexcept = [&](
QualType T) ->
bool {
10208 else if (T->isAnyPointerType())
10213 if (FPT->isNothrow())
10219 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
10220 for (
QualType T : FPT->param_types())
10221 AnyNoexcept |= HasNoexcept(T);
10224 diag::warn_cxx17_compat_exception_spec_in_signature)
10228 if (!Redeclaration && LangOpts.CUDA)
10229 checkCUDATargetOverload(NewFD, Previous);
10231 return Redeclaration;
10244 ? diag::err_static_main : diag::warn_static_main)
10251 SourceRange NoreturnRange(NoreturnLoc, getLocForEndOfToken(NoreturnLoc));
10252 Diag(NoreturnLoc, diag::ext_noreturn_main);
10253 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
10262 if (getLangOpts().OpenCL) {
10264 << FD->
hasAttr<OpenCLKernelAttr>();
10270 assert(T->
isFunctionType() &&
"function decl is not of function type");
10274 if (FT->getCallConv() !=
CC_C) {
10280 if (getLangOpts().GNUMode && !getLangOpts().CPlusPlus) {
10291 if (RTRange.isValid())
10292 Diag(RTRange.getBegin(), diag::note_main_change_return_type)
10314 if (isa<FunctionNoProtoType>(FT))
return;
10320 bool HasExtraParameters = (nparams > 3);
10332 HasExtraParameters =
false;
10334 if (HasExtraParameters) {
10347 for (
unsigned i = 0; i < nparams; ++i) {
10350 bool mismatch =
true;
10354 else if (Expected[i] == CharPP) {
10367 mismatch = !qs.
empty();
10372 Diag(FD->
getLocation(), diag::err_main_arg_wrong) << i << Expected[i];
10390 assert(T->
isFunctionType() &&
"function decl is not of function type");
10395 if (FT->getReturnType()->isIntegralOrEnumerationType() ||
10396 FT->getReturnType()->isAnyPointerType() ||
10397 FT->getReturnType()->isNullPtrType())
10399 if (FD->
getName() !=
"DllMain")
10417 const Expr *Culprit;
10420 Diag(Culprit->
getExprLoc(), diag::err_init_element_not_constant)
10428 class SelfReferenceChecker
10434 bool isReferenceType;
10442 SelfReferenceChecker(
Sema &S,
Decl *OrigDecl) : Inherited(S.
Context),
10443 S(S), OrigDecl(OrigDecl) {
10445 isRecordType =
false;
10446 isReferenceType =
false;
10447 isInitList =
false;
10448 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
10449 isPODType = VD->getType().isPODType(S.
Context);
10450 isRecordType = VD->getType()->isRecordType();
10451 isReferenceType = VD->getType()->isReferenceType();
10458 void CheckExpr(
Expr *E) {
10467 InitFieldIndex.push_back(0);
10468 for (
auto Child : InitList->
children()) {
10469 CheckExpr(cast<Expr>(Child));
10470 ++InitFieldIndex.back();
10472 InitFieldIndex.pop_back();
10477 bool CheckInitListMemberExpr(
MemberExpr *E,
bool CheckReference) {
10480 bool ReferenceField =
false;
10483 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
10487 Fields.push_back(FD);
10489 ReferenceField =
true;
10495 if (!DRE || DRE->
getDecl() != OrigDecl)
10499 if (CheckReference && !ReferenceField)
10504 for (
const FieldDecl *I : llvm::reverse(Fields))
10505 UsedFieldIndex.push_back(I->getFieldIndex());
10510 for (
auto UsedIter = UsedFieldIndex.begin(),
10511 UsedEnd = UsedFieldIndex.end(),
10512 OrigIter = InitFieldIndex.begin(),
10513 OrigEnd = InitFieldIndex.end();
10514 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
10515 if (*UsedIter < *OrigIter)
10517 if (*UsedIter > *OrigIter)
10522 HandleDeclRefExpr(DRE);
10529 void HandleValue(
Expr *E) {
10531 if (
DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
10532 HandleDeclRefExpr(DRE);
10537 Visit(CO->getCond());
10538 HandleValue(CO->getTrueExpr());
10539 HandleValue(CO->getFalseExpr());
10544 dyn_cast<BinaryConditionalOperator>(E)) {
10545 Visit(BCO->getCond());
10546 HandleValue(BCO->getFalseExpr());
10551 HandleValue(OVE->getSourceExpr());
10556 if (BO->getOpcode() == BO_Comma) {
10557 Visit(BO->getLHS());
10558 HandleValue(BO->getRHS());
10563 if (isa<MemberExpr>(E)) {
10565 if (CheckInitListMemberExpr(cast<MemberExpr>(E),
10571 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
10573 if (!isa<FieldDecl>(ME->getMemberDecl()))
10577 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base))
10578 HandleDeclRefExpr(DRE);
10588 if (isReferenceType)
10589 HandleDeclRefExpr(E);
10598 Inherited::VisitImplicitCastExpr(E);
10603 if (CheckInitListMemberExpr(E,
true ))
10613 bool Warn = (MD && !MD->
isStatic());
10615 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
10616 if (!isa<FieldDecl>(ME->getMemberDecl()))
10621 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
10623 HandleDeclRefExpr(DRE);
10635 if (isa<UnresolvedLookupExpr>(Callee))
10636 return Inherited::VisitCXXOperatorCallExpr(E);
10640 HandleValue(Arg->IgnoreParenImpCasts());
10645 if (E->
getOpcode() == UO_AddrOf && isRecordType &&
10657 Inherited::VisitUnaryOperator(E);
10665 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
10666 if (ILE->getNumInits() == 1)
10667 ArgExpr = ILE->getInit(0);
10669 if (ICE->getCastKind() == CK_NoOp)
10670 ArgExpr = ICE->getSubExpr();
10671 HandleValue(ArgExpr);
10674 Inherited::VisitCXXConstructExpr(E);
10680 HandleValue(E->
getArg(0));
10684 Inherited::VisitCallExpr(E);
10689 HandleValue(E->
getLHS());
10694 Inherited::VisitBinaryOperator(E);
10707 if (OrigDecl != ReferenceDecl)
return;
10709 if (isReferenceType) {
10710 diag = diag::warn_uninit_self_reference_in_reference_init;
10711 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
10712 diag = diag::warn_static_self_reference_in_init;
10713 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
10716 diag = diag::warn_uninit_self_reference_in_init;
10731 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *E,
10735 if (isa<ParmVarDecl>(OrigDecl))
10742 if (!DirectInit && !cast<VarDecl>(OrigDecl)->getType()->
isRecordType())
10744 if (ICE->getCastKind() == CK_LValueToRValue)
10745 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
10746 if (DRE->getDecl() == OrigDecl)
10749 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
10756 struct VarDeclOrName {
10762 return VN.VDecl ? Diag << VN.VDecl : Diag << VN.Name;
10772 bool IsInitCapture = !VDecl;
10774 "init captures are expected to be deduced prior to initialization");
10776 VarDeclOrName VN{VDecl, Name};
10779 assert(Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
10783 assert(VDecl &&
"no init for init capture deduction?");
10787 if (!isa<DeducedTemplateSpecializationType>(Deduced) ||
10798 DeduceInits = Init;
10801 if (
auto *PL = dyn_cast_or_null<ParenListExpr>(Init))
10802 DeduceInits = PL->exprs();
10805 if (isa<DeducedTemplateSpecializationType>(Deduced)) {
10806 assert(VDecl &&
"non-auto type for init capture deduction?");
10812 return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind,
10817 if (
auto *IL = dyn_cast<InitListExpr>(Init))
10818 DeduceInits = IL->inits();
10822 if (DeduceInits.empty()) {
10826 ? diag::err_init_capture_no_expression
10827 : diag::err_auto_var_init_no_expression)
10828 << VN << Type << Range;
10832 if (DeduceInits.size() > 1) {
10833 Diag(DeduceInits[1]->getLocStart(),
10834 IsInitCapture ? diag::err_init_capture_multiple_expressions
10835 : diag::err_auto_var_init_multiple_expressions)
10836 << VN << Type << Range;
10840 Expr *DeduceInit = DeduceInits[0];
10841 if (DirectInit && isa<InitListExpr>(DeduceInit)) {
10843 ? diag::err_init_capture_paren_braces
10844 : diag::err_auto_var_init_paren_braces)
10845 << isa<InitListExpr>(Init) << VN << Type << Range;
10850 bool DefaultedAnyToId =
false;
10851 if (getLangOpts().DebuggerCastResultToId &&
10857 Init = Result.
get();
10858 DefaultedAnyToId =
true;
10864 if (VDecl && isa<DecompositionDecl>(VDecl) &&
10871 if (DeduceAutoType(TSI, DeduceInit, DeducedType) == DAR_Failed) {
10872 if (!IsInitCapture)
10873 DiagnoseAutoDeductionFailure(VDecl, DeduceInit);
10874 else if (isa<InitListExpr>(Init))
10876 diag::err_init_capture_deduction_failure_from_init_list)
10882 Diag(Range.
getBegin(), diag::err_init_capture_deduction_failure)
10894 if (!inTemplateInstantiation() && !DefaultedAnyToId && !IsInitCapture &&
10897 Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
10900 return DeducedType;
10908 if (DeducedType.
isNull()) {
10917 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(VDecl))
10925 MergeVarDeclTypes(VDecl, Old,
false);
10929 CheckVariableDeclarationType(VDecl);
10940 CorrectDelayedTyposInExpr(Init, dyn_cast_or_null<VarDecl>(RealDecl));
10944 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
10946 Diag(Method->getLocation(), diag::err_member_function_initialization)
10948 Method->setInvalidDecl();
10954 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
10965 ExprResult Res = CorrectDelayedTyposInExpr(Init, VDecl);
10972 if (DeduceVariableDeclarationType(VDecl, DirectInit, Init))
10978 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
10996 BaseDeclType = Array->getElementType();
10997 if (RequireCompleteType(VDecl->
getLocation(), BaseDeclType,
10998 diag::err_typecheck_decl_incomplete_type)) {
11005 diag::err_abstract_type_in_decl,
11006 AbstractVariableType))
11017 checkVarDeclRedefinition(Def, VDecl))
11020 if (getLangOpts().CPlusPlus) {
11034 Diag(Init->
getExprLoc(), diag::err_static_data_member_reinitialization)
11037 diag::note_previous_initializer)
11043 setFunctionHasBranchProtectedScope();
11045 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer)) {
11072 Init = Result.
get();
11088 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
11090 Args[Idx], VDecl, [
this, Entity, Kind](
Expr *E) {
11096 }
else if (Res.
get() != Args[Idx]) {
11097 Args[Idx] = Res.
get();
11120 CheckSelfReference(*
this, RealDecl, Init, DirectInit);
11133 if (VDecl->
hasAttr<BlocksAttr>())
11134 checkRetainCycles(VDecl, Init);
11146 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
11148 FSI->markSafeWeakUse(Init);
11169 Init = Result.
get();
11182 CheckForConstantInitializer(Init, DclT);
11191 CheckForConstantInitializer(Init, DclT);
11198 isa<InitListExpr>(Init)) {
11199 const Expr *Culprit;
11202 diag::ext_aggregate_init_not_constant)
11261 Diag(Loc, diag::ext_in_class_initializer_non_constant)
11266 Diag(Loc, diag::err_in_class_initializer_non_constant)
11275 if (getLangOpts().CPlusPlus11) {
11277 diag::ext_in_class_initializer_float_type_cxx11)
11280 diag::note_in_class_initializer_float_type_cxx11)
11283 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
11287 Diag(Init->
getExprLoc(), diag::err_in_class_initializer_non_constant)
11295 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
11314 ((!getLangOpts().CPlusPlus && !VDecl->
hasAttr<SelectAnyAttr>()) ||
11316 !(getLangOpts().CPlusPlus && VDecl->
isExternC()) &&
11322 CheckForConstantInitializer(Init, DclT);
11339 if (CXXDirectInit) {
11340 assert(DirectInit &&
"Call-style initializer must be direct init.");
11342 }
else if (DirectInit) {
11347 CheckCompleteVariableDeclaration(VDecl);
11362 if (
auto *DD = dyn_cast<DecompositionDecl>(D))
11363 for (
auto *BD : DD->bindings())
11367 if (ParsingInitForAutoVars.count(D)) {
11378 diag::err_typecheck_decl_incomplete_type)) {
11384 if (RequireNonAbstractType(VD->
getLocation(), Ty,
11385 diag::err_abstract_type_in_decl,
11386 AbstractVariableType)) {
11400 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
11404 if (isa<DecompositionDecl>(RealDecl)) {
11405 Diag(Var->getLocation(), diag::err_decomp_decl_requires_init) << Var;
11406 Var->setInvalidDecl();
11411 DeduceVariableDeclarationType(Var,
false,
nullptr))
11420 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
11421 !Var->isThisDeclarationADemotedDefinition()) {
11422 if (Var->isStaticDataMember()) {
11425 if (!getLangOpts().CPlusPlus17) {
11426 Diag(Var->getLocation(),
11427 diag::err_constexpr_static_mem_var_requires_init)
11428 << Var->getDeclName();
11429 Var->setInvalidDecl();
11433 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
11434 Var->setInvalidDecl();
11441 if (!Var->isInvalidDecl() &&
11443 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
11444 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
11445 Var->setInvalidDecl();
11449 switch (Var->isThisDeclarationADefinition()) {
11451 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
11467 !Var->hasLinkage() && !Var->isInvalidDecl() &&
11468 RequireCompleteType(Var->getLocation(), Type,
11469 diag::err_typecheck_decl_incomplete_type))
11470 Var->setInvalidDecl();
11474 RequireNonAbstractType(Var->getLocation(), Type,
11475 diag::err_abstract_type_in_decl,
11476 AbstractVariableType))
11477 Var->setInvalidDecl();
11480 Diag(Var->getLocation(), diag::warn_private_extern);
11481 Diag(Var->getLocation(), diag::note_private_extern);
11492 if (!Var->isInvalidDecl()) {
11495 if (RequireCompleteType(Var->getLocation(),
11496 ArrayT->getElementType(),
11497 diag::err_illegal_decl_array_incomplete_type))
11498 Var->setInvalidDecl();
11499 }
else if (Var->getStorageClass() ==
SC_Static) {
11509 if (Var->isFirstDecl())
11510 RequireCompleteType(Var->getLocation(), Type,
11511 diag::ext_typecheck_decl_incomplete_type);
11516 if (!Var->isInvalidDecl())
11517 TentativeDefinitions.push_back(Var);
11524 Diag(Var->getLocation(),
11525 diag::err_typecheck_incomplete_array_needs_initializer);
11526 Var->setInvalidDecl();
11533 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
11534 << Var->getDeclName()
11535 <<
SourceRange(Var->getLocation(), Var->getLocation());
11536 Var->setInvalidDecl();
11545 if (Var->isInvalidDecl())
11548 if (!Var->hasAttr<AliasAttr>()) {
11549 if (RequireCompleteType(Var->getLocation(),
11551 diag::err_typecheck_decl_incomplete_type)) {
11552 Var->setInvalidDecl();
11560 if (RequireNonAbstractType(Var->getLocation(), Type,
11561 diag::err_abstract_type_in_decl,
11562 AbstractVariableType)) {
11563 Var->setInvalidDecl();
11577 if (getLangOpts().
CPlusPlus && Var->hasLocalStorage()) {
11580 CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl());
11584 if (!CXXRecord->
isPOD())
11585 setFunctionHasBranchProtectedScope();
11608 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, None);
11610 Var->setInvalidDecl();
11611 else if (Init.
get()) {
11612 Var->setInit(MaybeCreateExprWithCleanups(Init.
get()));
11617 CheckCompleteVariableDeclaration(Var);
11675 const char *PrevSpec;
11678 getPrintingPolicy());
11687 Decl *Var = ActOnDeclarator(S, D);
11688 cast<VarDecl>(Var)->setCXXForRangeDecl(
true);
11689 FinalizeDeclaration(Var);
11690 return ActOnDeclStmt(FinalizeDeclaratorGroup(S, DS, Var), IdentLoc,
11691 AttrEnd.
isValid() ? AttrEnd : IdentLoc);
11697 if (getLangOpts().OpenCL) {
11711 if (getLangOpts().ObjC1 &&
11721 setFunctionHasBranchProtectedScope();
11728 setFunctionHasBranchProtectedScope();
11740 !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
11748 Diag(var->
getLocation(), diag::warn_missing_variable_declarations) << var;
11753 const Expr *CacheCulprit;
11754 auto checkConstInit = [&]()
mutable {
11755 if (!CacheHasConstInit)
11758 return *CacheHasConstInit;
11767 if (getLangOpts().CPlusPlus11)
11769 }
else if (getLangOpts().CPlusPlus && var->
hasInit()) {
11770 if (!checkConstInit()) {
11786 !inTemplateInstantiation()) {
11790 Stack = &ConstSegStack;
11792 Stack = &BSSSegStack;
11795 Stack = &DataSegStack;
11799 var->
addAttr(SectionAttr::CreateImplicit(
11800 Context, SectionAttr::Declspec_allocate,
11803 if (
const SectionAttr *SA = var->
getAttr<SectionAttr>())
11804 if (UnifySection(SA->getName(), SectionFlags, var))
11810 if (CurInitSeg && var->
getInit())
11811 var->
addAttr(InitSegAttr::CreateImplicit(Context, CurInitSeg->getString(),
11816 if (!getLangOpts().CPlusPlus) {
11824 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
11825 CheckCompleteDecompositionDeclaration(DD);
11831 if (var->
hasAttr<BlocksAttr>()) {
11839 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
11843 = PerformMoveOrCopyInitialization(
11845 var, var->
getType(), varRef,
true);
11847 result = MaybeCreateExprWithCleanups(result);
11865 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
11866 diag::note_invalid_subexpr_in_const_expr) {
11867 DiagLoc = Notes[0].first;
11870 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
11872 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
11873 Diag(Notes[I].first, Notes[I].second);
11885 var->
hasAttr<RequireConstantInitAttr>()) {
11887 bool DiagErr = getLangOpts().CPlusPlus11
11890 auto attr = var->
getAttr<RequireConstantInitAttr>();
11893 Diag(attr->getLocation(), diag::note_declared_required_constant_init_here)
11894 << attr->getRange();
11899 for (
auto &it : Notes)
11900 Diag(it.first, it.second);
11903 diag::note_invalid_subexpr_in_const_expr)
11909 !getDiagnostics().isIgnored(diag::warn_global_constructor,
11916 if (!checkConstInit())
11938 if (I->isAlignmentDependent())
11947 ParsingInitForAutoVars.erase(ThisDecl);
11949 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
11955 !inTemplateInstantiation() && !VD->
hasAttr<SectionAttr>()) {
11956 if (PragmaClangBSSSection.Valid)
11957 VD->
addAttr(PragmaClangBSSSectionAttr::CreateImplicit(Context,
11958 PragmaClangBSSSection.SectionName,
11959 PragmaClangBSSSection.PragmaLocation));
11960 if (PragmaClangDataSection.Valid)
11961 VD->
addAttr(PragmaClangDataSectionAttr::CreateImplicit(Context,
11962 PragmaClangDataSection.SectionName,
11963 PragmaClangDataSection.PragmaLocation));
11964 if (PragmaClangRodataSection.Valid)
11965 VD->
addAttr(PragmaClangRodataSectionAttr::CreateImplicit(Context,
11966 PragmaClangRodataSection.SectionName,
11967 PragmaClangRodataSection.PragmaLocation));
11970 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
11971 for (
auto *BD : DD->bindings()) {
11972 FinalizeDeclaration(BD);
12000 auto *NewAttr = cast<InheritableAttr>(A->clone(getASTContext()));
12001 NewAttr->setInherited(
true);
12011 if (!getLangOpts().CUDA)
12013 if (VD->
hasAttr<CUDASharedAttr>())
12016 !(VD->
hasAttr<CUDADeviceAttr>() || VD->
hasAttr<CUDAConstantAttr>()))
12019 diag::err_device_static_local_var)
12020 << CurrentCUDATarget())
12031 if (getLangOpts().CUDA)
12032 checkAllowedCUDAInitializer(VD);
12038 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
12045 bool IsClassTemplateMember =
12046 isa<ClassTemplatePartialSpecializationDecl>(Context) ||
12050 IsClassTemplateMember
12051 ? diag::warn_attribute_dllimport_static_field_definition
12052 : diag::err_attribute_dllimport_static_field_definition);
12053 Diag(IA->getLocation(), diag::note_attribute);
12054 if (!IsClassTemplateMember)
12086 AddPushedVisibilityAttribute(VD);
12089 if (VD->
isFileVarDecl() && !isa<VarTemplatePartialSpecializationDecl>(VD))
12090 MarkUnusedFileScopedDecl(VD);
12094 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
12098 for (
const auto *I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
12100 if (!MagicValueExpr) {
12103 llvm::APSInt MagicValueInt;
12105 Diag(I->getRange().getBegin(),
12106 diag::err_type_tag_for_datatype_not_ice)
12110 if (MagicValueInt.getActiveBits() > 64) {
12111 Diag(I->getRange().getBegin(),
12112 diag::err_type_tag_for_datatype_too_large)
12116 uint64_t MagicValue = MagicValueInt.getZExtValue();
12117 RegisterTypeTagForDatatype(I->getArgumentKind(),
12119 I->getMatchingCType(),
12120 I->getLayoutCompatible(),
12121 I->getMustBeNull());
12126 auto *VD = dyn_cast<
VarDecl>(DD);
12139 bool DiagnosedMultipleDecomps =
false;
12141 bool DiagnosedNonDeducedAuto =
false;
12143 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
12144 if (
Decl *D = Group[i]) {
12147 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
12148 if (!FirstDeclaratorInGroup)
12149 FirstDeclaratorInGroup = DD;
12150 if (!FirstDecompDeclaratorInGroup)
12154 FirstNonDeducedAutoInGroup = DD;
12156 if (FirstDeclaratorInGroup != DD) {
12159 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
12161 diag::err_decomp_decl_not_alone)
12163 << DD->getSourceRange();
12164 DiagnosedMultipleDecomps =
true;
12170 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
12172 diag::err_auto_non_deduced_not_alone)
12173 << FirstNonDeducedAutoInGroup->
getType()
12176 << DD->getSourceRange();
12177 DiagnosedNonDeducedAuto =
true;
12182 Decls.push_back(D);
12188 handleTagNumbering(Tag, S);
12189 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
12190 getLangOpts().CPlusPlus)
12195 return BuildDeclaratorGroup(Decls);
12205 if (Group.size() > 1) {
12207 VarDecl *DeducedDecl =
nullptr;
12208 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
12219 auto *AT = dyn_cast<
AutoType>(DT);
12221 diag::err_auto_different_deductions)
12222 << (AT ? (
unsigned)AT->getKeyword() : 3)
12233 ActOnDocumentableDecls(Group);
12235 return DeclGroupPtrTy::make(
12240 ActOnDocumentableDecls(D);
12245 if (Group.empty() || !Group[0])
12248 if (Diags.isIgnored(diag::warn_doc_param_not_found,
12249 Group[0]->getLocation()) &&
12250 Diags.isIgnored(diag::warn_unknown_comment_command_name,
12251 Group[0]->getLocation()))
12254 if (Group.size() >= 2) {
12262 Decl *MaybeTagDecl = Group[0];
12263 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
12264 Group = Group.slice(1);
12270 if (!Comments.empty() &&
12271 !Comments.back()->isAttached()) {
12279 for (
unsigned i = 0, e = Group.size(); i != e; ++i)
12297 if (getLangOpts().CPlusPlus11) {
12299 getLangOpts().CPlusPlus17 ? diag::ext_register_storage_class
12300 : diag::warn_deprecated_register)
12303 }
else if (getLangOpts().CPlusPlus &&
12308 diag::err_invalid_storage_class_in_func_decl);
12317 << getLangOpts().CPlusPlus17;
12322 DiagnoseFunctionSpecifiers(DS);
12330 CheckExtraCXXDefaultArguments(D);
12346 << GetNameForDeclarator(D).getName();
12354 ForVisibleRedeclaration);
12356 if (R.isSingleResult()) {
12357 NamedDecl *PrevDecl = R.getFoundDecl();
12362 PrevDecl =
nullptr;
12381 parmDeclType, TInfo,
12395 IdResolver.AddDecl(New);
12397 ProcessDeclAttributes(S, New, D);
12405 if (New->
hasAttr<BlocksAttr>()) {
12429 if (inTemplateInstantiation())
12435 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
12443 if (LangOpts.NumLargeByValueCopy == 0)
12450 if (Size > LangOpts.NumLargeByValueCopy)
12462 if (Size > LangOpts.NumLargeByValueCopy)
12473 if (getLangOpts().ObjCAutoRefCount &&
12486 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
12497 TSInfo, SC,
nullptr);
12502 if (!CurContext->isRecord() &&
12503 RequireNonAbstractType(NameLoc, T, diag::err_abstract_type_in_decl,
12504 AbstractParamType))
12513 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
12526 !(getLangOpts().OpenCL &&
12528 Diag(NameLoc, diag::err_arg_with_address_space);
12542 for (
int i = FTI.
NumParams; i != 0; ) {
12546 llvm::raw_svector_ostream(Code)
12556 const char* PrevSpec;
12565 FTI.
Params[i].
Param = ActOnParamDeclarator(S, ParamD);
12575 assert(getCurFunctionDecl() ==
nullptr &&
"Function parsing confused");
12580 Decl *DP = HandleDeclarator(ParentScope, D, TemplateParameterLists);
12581 return ActOnStartOfFunctionDef(FnBodyScope, DP, SkipBody);
12585 Consumer.HandleInlineFunctionDefinition(D);
12599 if (isa<CXXMethodDecl>(FD))
12619 if (FD->
hasAttr<OpenCLKernelAttr>())
12626 bool MissingPrototype =
true;
12631 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
12634 MissingPrototype = !Prev->getType()->isFunctionProtoType();
12636 PossibleZeroParamPrototype = Prev;
12640 return MissingPrototype;
12664 for (
auto I : FD->
redecls()) {
12665 if (I != FD && !I->isInvalidDecl() &&
12667 if (
FunctionDecl *Original = I->getInstantiatedFromMemberFunction()) {
12677 if (Original->isThisDeclarationADefinition()) {
12693 if (TypoCorrectedFunctionDefinitions.count(Definition))
12698 if (SkipBody && !hasVisibleDefinition(Definition) &&
12705 makeMergedDefinitionVisible(TD);
12706 makeMergedDefinitionVisible(const_cast<FunctionDecl*>(Definition));
12727 LSI->
Lambda = LambdaClass;
12745 for (
const auto &C : LambdaClass->
captures()) {
12746 if (C.capturesVariable()) {
12747 VarDecl *VD = C.getCapturedVar();
12751 const bool ByRef = C.getCaptureKind() ==
LCK_ByRef;
12753 true, C.getLocation(),
12754 C.isPackExpansion()
12756 CaptureType,
nullptr);
12758 }
else if (C.capturesThis()) {
12774 PushFunctionScope();
12781 FD = FunTmpl->getTemplatedDecl();
12783 FD = cast<FunctionDecl>(D);
12786 if (
const auto *
Attr = FD->
getAttr<AliasAttr>()) {
12791 if (
const auto *
Attr = FD->
getAttr<IFuncAttr>()) {
12800 CheckForFunctionRedefinition(FD,
nullptr, SkipBody);
12822 assert(inTemplateInstantiation() &&
12823 "There should be an active template instantiation on the stack " 12824 "when instantiating a generic lambda!");
12828 PushFunctionScope();
12845 RequireCompleteType(FD->
getLocation(), ResultType,
12846 diag::err_func_def_incomplete_result))
12850 PushDeclContext(FnBodyScope, FD);
12860 auto *NonParmDecl = dyn_cast<
NamedDecl>(NPD);
12863 assert(!isa<ParmVarDecl>(NonParmDecl) &&
12864 "parameters should not be in newly created FD yet");
12867 if (NonParmDecl->getDeclName())
12868 PushOnScopeChains(NonParmDecl, FnBodyScope,
false);
12872 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
12873 for (
auto *EI : ED->enumerators())
12874 PushOnScopeChains(EI, FnBodyScope,
false);
12881 Param->setOwningFunction(FD);
12884 if (Param->getIdentifier() && FnBodyScope) {
12885 CheckShadow(FnBodyScope, Param);
12887 PushOnScopeChains(Param, FnBodyScope);
12898 assert(!FD->
hasAttr<DLLExportAttr>());
12899 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
12905 ActOnDocumentableDecl(D);
12906 if (getCurLexicalContext()->isObjCContainer() &&
12907 getCurLexicalContext()->getDeclKind() != Decl::ObjCCategoryImpl &&
12908 getCurLexicalContext()->getDeclKind() != Decl::ObjCImplementation)
12929 for (
unsigned I = 0, E = Scope->
Returns.size(); I != E; ++I) {
12930 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
12931 if (!NRVOCandidate->isNRVOVariable())
12932 Returns[I]->setNRVOCandidate(
nullptr);
12950 Outer.Fun.hasTrailingReturnType()) {
12951 QualType Ty = GetTypeFromParser(Outer.Fun.getTrailingReturnType());
12968 if (FD->isConstexpr())
12973 if (FD->getReturnType()->getContainedDeducedType())
12976 return Consumer.shouldSkipFunctionBody(D);
12983 FD->setHasSkippedBody();
12985 MD->setHasSkippedBody();
12990 return ActOnFinishFunctionBody(D, BodyArg,
false);
12994 bool IsInstantiation) {
13000 if (getLangOpts().CoroutinesTS && getCurFunction()->isCoroutine())
13001 CheckCompletedCoroutineBody(FD, Body);
13019 TypeLoc ResultType = getReturnTypeLoc(FD);
13027 auto *LSI = getCurLambda();
13028 if (LSI->HasImplicitReturnType) {
13029 deduceClosureReturnType(*LSI);
13035 LSI->ReturnType.isNull() ? Context.
VoidTy : LSI->ReturnType;
13059 DiagnoseSizeOfParametersAndReturnValue(FD->
parameters(),
13064 MarkVTableUsed(FD->
getLocation(), Constructor->getParent());
13066 MarkVTableUsed(FD->
getLocation(), Destructor->getParent());
13073 computeNRVO(Body, getCurFunction());
13081 const FunctionDecl *PossibleZeroParamPrototype =
nullptr;
13085 if (PossibleZeroParamPrototype) {
13090 TypeLoc TL = TI->getTypeLoc();
13093 diag::note_declaration_not_a_prototype)
13094 << PossibleZeroParamPrototype
13107 !LangOpts.CPlusPlus) {
13117 if (
const auto *CmpndBody = dyn_cast<CompoundStmt>(Body))
13118 if (!CmpndBody->body_empty())
13119 Diag(CmpndBody->body_front()->getLocStart(),
13120 diag::warn_dispatch_body_ignored);
13122 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13124 if (MD->isOutOfLine() && (MD = MD->getCanonicalDecl()) &&
13137 if (KeyFunction && KeyFunction->
isDefined(Definition))
13138 MarkVTableUsed(Definition->
getLocation(), MD->getParent(),
true);
13141 MarkVTableUsed(FD->
getLocation(), MD->getParent(),
true);
13146 assert((FD == getCurFunctionDecl() || getCurLambda()->CallOperator == FD) &&
13147 "Function parsing confused");
13148 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
13149 assert(MD == getCurMethodDecl() &&
"Method parsing confused");
13151 if (!MD->isInvalidDecl()) {
13152 DiagnoseUnusedParameters(MD->parameters());
13153 DiagnoseSizeOfParametersAndReturnValue(MD->parameters(),
13154 MD->getReturnType(), MD);
13157 computeNRVO(Body, getCurFunction());
13159 if (getCurFunction()->ObjCShouldCallSuper) {
13160 Diag(MD->getLocEnd(), diag::warn_objc_missing_super_call)
13161 << MD->getSelector().getAsString();
13162 getCurFunction()->ObjCShouldCallSuper =
false;
13164 if (getCurFunction()->ObjCWarnForNoDesignatedInitChain) {
13166 bool isDesignated =
13168 assert(isDesignated && InitMethod);
13169 (void)isDesignated;
13172 auto IFace = MD->getClassInterface();
13175 auto SuperD = IFace->getSuperClass();
13178 return SuperD->getIdentifier() ==
13183 if (!MD->isUnavailable() && !superIsNSObject(MD)) {
13184 Diag(MD->getLocation(),
13185 diag::warn_objc_designated_init_missing_super_call);
13187 diag::note_objc_designated_init_marked_here);
13189 getCurFunction()->ObjCWarnForNoDesignatedInitChain =
false;
13191 if (getCurFunction()->ObjCWarnForNoInitDelegation) {
13193 if (!MD->isUnavailable())
13194 Diag(MD->getLocation(),
13195 diag::warn_objc_secondary_init_missing_init_call);
13196 getCurFunction()->ObjCWarnForNoInitDelegation =
false;
13201 PopFunctionScopeInfo(ActivePolicy, dcl);
13205 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
13206 DiagnoseUnguardedAvailabilityViolations(dcl);
13208 assert(!getCurFunction()->ObjCShouldCallSuper &&
13209 "This should only be set for ObjC methods, which should have been " 13210 "handled in the block above.");
13217 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
13218 DiagnoseReturnInConstructorExceptionHandler(cast<CXXTryStmt>(Body));
13221 if (getCurFunction()->NeedsScopeChecking() &&
13222 !PP.isCodeCompletionEnabled())
13223 DiagnoseInvalidJumps(Body);
13226 if (!Destructor->getParent()->isDependentType())
13227 CheckDestructor(Destructor);
13229 MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(),
13230 Destructor->getParent());
13236 if (getDiagnostics().hasErrorOccurred() ||
13237 getDiagnostics().getSuppressAllDiagnostics()) {
13238 DiscardCleanupsInEvaluationContext();
13240 if (!getDiagnostics().hasUncompilableErrorOccurred() &&
13241 !isa<FunctionTemplateDecl>(dcl)) {
13244 ActivePolicy = &WP;
13248 (!CheckConstexprFunctionDecl(FD) ||
13249 !CheckConstexprFunctionBody(FD, Body)))
13252 if (FD && FD->
hasAttr<NakedAttr>()) {
13256 bool RegisterVariables =
false;
13257 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
13258 for (
const auto *
Decl : DS->decls()) {
13259 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
13260 RegisterVariables =
13261 Var->hasAttr<AsmLabelAttr>() && !Var->hasInit();
13262 if (!RegisterVariables)
13267 if (RegisterVariables)
13269 if (!isa<AsmStmt>(S) && !isa<NullStmt>(S)) {
13270 Diag(S->getLocStart(), diag::err_non_asm_stmt_in_naked_function);
13271 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
13278 assert(ExprCleanupObjects.size() ==
13279 ExprEvalContexts.back().NumCleanupObjects &&
13280 "Leftover temporaries in function");
13281 assert(!Cleanup.exprNeedsCleanups() &&
"Unaccounted cleanups in function");
13282 assert(MaybeODRUseExprs.empty() &&
13283 "Leftover expressions for odr-use checking");
13286 if (!IsInstantiation)
13289 PopFunctionScopeInfo(ActivePolicy, dcl);
13293 if (getDiagnostics().hasErrorOccurred()) {
13294 DiscardCleanupsInEvaluationContext();
13306 D = TD->getTemplatedDecl();
13307 ProcessDeclAttributeList(S, D, Attrs);
13309 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D))
13310 if (Method->isStatic())
13311 checkThisInStaticMemberFunctionAttributes(Method);
13323 Scope *BlockScope = S;
13327 Scope *ContextScope = BlockScope;
13329 ContextScope = ContextScope->
getParent();
13336 NamedDecl *ExternCPrev = findLocallyScopedExternCDecl(&II);
13340 PushOnScopeChains(ExternCPrev, BlockScope,
false);
13345 if (!isa<FunctionDecl>(ExternCPrev) ||
13347 cast<FunctionDecl>(ExternCPrev)->getType(),
13349 Diag(Loc, diag::ext_use_out_of_scope_declaration)
13350 << ExternCPrev << !getLangOpts().C99;
13351 Diag(ExternCPrev->getLocation(), diag::note_previous_declaration);
13352 return ExternCPrev;
13359 if (II.
getName().startswith(
"__builtin_"))
13360 diag_id = diag::warn_builtin_unknown;
13361 else if (getLangOpts().C99 || getLangOpts().OpenCL)
13362 diag_id = diag::ext_implicit_function_decl;
13364 diag_id = diag::warn_implicit_function_decl;
13365 Diag(Loc, diag_id) << &II << getLangOpts().OpenCL;
13371 return ExternCPrev;
13378 (Corrected = CorrectTypo(
13381 diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion),
13393 assert(!Error &&
"Error setting up implicit decl!");
13422 FunctionDecl *FD = cast<FunctionDecl>(ActOnDeclarator(BlockScope, D));
13425 AddKnownFunctionAttributes(FD);
13447 unsigned FormatIdx;
13450 if (!FD->
hasAttr<FormatAttr>()) {
13451 const char *fmt =
"printf";
13453 if (FormatIdx < NumParams &&
13456 FD->
addAttr(FormatAttr::CreateImplicit(Context,
13459 HasVAListArg ? 0 : FormatIdx+2,
13465 if (!FD->
hasAttr<FormatAttr>())
13466 FD->
addAttr(FormatAttr::CreateImplicit(Context,
13469 HasVAListArg ? 0 : FormatIdx+2,
13476 if (!getLangOpts().MathErrno && !FD->
hasAttr<ConstAttr>() &&
13484 if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
13486 switch (BuiltinID) {
13487 case Builtin::BI__builtin_fma:
13488 case Builtin::BI__builtin_fmaf:
13489 case Builtin::BI__builtin_fmal:
13490 case Builtin::BIfma:
13491 case Builtin::BIfmaf:
13492 case Builtin::BIfmal:
13501 !FD->
hasAttr<ReturnsTwiceAttr>())
13502 FD->
addAttr(ReturnsTwiceAttr::CreateImplicit(Context,
13511 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
13515 if (getLangOpts().CUDAIsDevice !=
13526 if (getLangOpts().CXXExceptions && getLangOpts().ExternCNoUnwind &&
13529 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
13546 if (Name->
isStr(
"asprintf") || Name->
isStr(
"vasprintf")) {
13549 if (!FD->
hasAttr<FormatAttr>())
13550 FD->
addAttr(FormatAttr::CreateImplicit(Context,
13552 Name->
isStr(
"vasprintf") ? 0 : 3,
13556 if (Name->
isStr(
"__CFStringMakeConstantString")) {
13559 if (!FD->
hasAttr<FormatArgAttr>())
13567 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
13568 assert(!T.
isNull() &&
"GetTypeForDeclarator() returned null type");
13571 assert(D.
isInvalidType() &&
"no declarator info for valid type");
13589 if (CurContext->isFunctionOrMethod())
13611 setTagNameForLinkagePurposes(tagFromDeclSpec, NewTD);
13631 if (BT->isInteger())
13634 Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T;
13641 QualType EnumUnderlyingTy,
bool IsFixed,
13643 if (IsScoped != Prev->
isScoped()) {
13644 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
13650 if (IsFixed && Prev->
isFixed()) {
13656 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
13662 }
else if (IsFixed != Prev->
isFixed()) {
13663 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
13682 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
13697 if (isa<TypedefDecl>(PrevDecl))
13698 return NTK_Typedef;
13699 else if (isa<TypeAliasDecl>(PrevDecl))
13700 return NTK_TypeAlias;
13701 else if (isa<ClassTemplateDecl>(PrevDecl))
13702 return NTK_Template;
13703 else if (isa<TypeAliasTemplateDecl>(PrevDecl))
13704 return NTK_TypeAliasTemplate;
13705 else if (isa<TemplateTemplateParmDecl>(PrevDecl))
13706 return NTK_TemplateTemplateArgument;
13711 return getLangOpts().CPlusPlus ? NTK_NonClass : NTK_NonStruct;
13713 return NTK_NonUnion;
13715 return NTK_NonEnum;
13717 llvm_unreachable(
"invalid TTK");
13743 if (OldTag == NewTag)
13749 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Previous))
13750 isTemplate = Record->getDescribedClassTemplate();
13752 if (inTemplateInstantiation()) {
13755 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
13761 if (isDefinition) {
13769 bool previousMismatch =
false;
13770 for (
auto I : Previous->
redecls()) {
13771 if (I->getTagKind() != NewTag) {
13772 if (!previousMismatch) {
13773 previousMismatch =
true;
13774 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
13778 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
13796 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
13803 Diag(NewTagLoc, diag::note_struct_class_suggestion)
13837 Namespaces.push_back(II);
13840 if (Lookup == Namespace)
13847 llvm::raw_svector_ostream OS(Insertion);
13850 std::reverse(Namespaces.begin(), Namespaces.end());
13851 for (
auto *II : Namespaces)
13852 OS << II->getName() <<
"::";
13865 if (OldDC->
Equals(NewDC))
13893 bool &OwnedDecl,
bool &IsDependent,
13895 bool ScopedEnumUsesClassTag,
TypeResult UnderlyingType,
13896 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
13900 assert((Name !=
nullptr || TUK == TUK_Definition) &&
13901 "Nameless record must be a definition!");
13902 assert(TemplateParameterLists.size() == 0 || TUK != TUK_Reference);
13906 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
13909 bool isMemberSpecialization =
false;
13910 bool Invalid =
false;
13915 if (TemplateParameterLists.size() > 0 ||
13916 (SS.
isNotEmpty() && TUK != TUK_Reference)) {
13918 MatchTemplateParametersToScopeSpecifier(
13919 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
13920 TUK == TUK_Friend, isMemberSpecialization, Invalid)) {
13922 Diag(KWLoc, diag::err_enum_template);
13926 if (TemplateParams->size() > 0) {
13935 S, TagSpec, TUK, KWLoc, SS, Name, NameLoc, Attrs, TemplateParams,
13936 AS, ModulePrivateLoc,
13938 TemplateParameterLists.data(), SkipBody);
13939 return Result.
get();
13942 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
13944 isMemberSpecialization =
true;
13952 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
13953 bool IsFixed = !UnderlyingType.
isUnset() || ScopedEnum;
13956 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum)) {
13960 }
else if (UnderlyingType.
get()) {
13964 GetTypeFromParser(UnderlyingType.
get(), &TI);
13965 EnumUnderlying = TI;
13967 if (CheckEnumUnderlyingType(TI))
13972 UPPC_FixedUnderlyingType))
13980 if (TUK == TUK_Definition || getLangOpts().MSVCCompat)
13987 bool isStdBadAlloc =
false;
13988 bool isStdAlignValT =
false;
13991 if (TUK == TUK_Friend || TUK == TUK_Reference)
13992 Redecl = NotForRedeclaration;
13997 auto createTagFromNewDecl = [&]() ->
TagDecl * {
13998 assert(!getLangOpts().
CPlusPlus &&
"not meant for C++ usage");
14007 ScopedEnum, ScopedEnumUsesClassTag, IsFixed);
14009 if (TUK != TUK_Definition && !Invalid)
14011 if (EnumUnderlying) {
14012 EnumDecl *ED = cast<EnumDecl>(New);
14024 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
14034 if (TUK == TUK_Definition) {
14035 AddAlignmentAttributesForRecord(RD);
14036 AddMsStructLayoutForRecord(RD);
14050 goto CreateNewDecl;
14055 if (TUK == TUK_Friend || TUK == TUK_Reference) {
14056 DC = computeDeclContext(SS,
false);
14058 IsDependent =
true;
14062 DC = computeDeclContext(SS,
true);
14070 if (RequireCompleteDeclContext(SS, DC))
14075 LookupQualifiedName(Previous, DC);
14080 if (Previous.
empty()) {
14088 (TUK == TUK_Reference || TUK == TUK_Friend)) {
14089 IsDependent =
true;
14094 Diag(NameLoc, diag::err_not_tag_in_scope)
14095 << Kind << Name << DC << SS.
getRange();
14098 goto CreateNewDecl;
14105 if (TUK != TUK_Reference && TUK != TUK_Friend &&
14114 LookupName(Previous, S);
14119 (TUK == TUK_Definition || TUK == TUK_Declaration)) {
14143 if (!Previous.
empty() && TUK == TUK_Friend) {
14146 bool FriendSawTagOutsideEnclosingNamespace =
false;
14152 if (getLangOpts().MSVCCompat)
14153 FriendSawTagOutsideEnclosingNamespace =
true;
14162 if (Previous.
isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
14164 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
14173 if (!getLangOpts().CPlusPlus && TUK != TUK_Reference) {
14178 while (isa<RecordDecl>(SearchDC) || isa<EnumDecl>(SearchDC))
14186 DiagnoseTemplateParameterShadow(NameLoc, Previous.
getFoundDecl());
14191 if (getLangOpts().
CPlusPlus && Name && DC && StdNamespace &&
14192 DC->
Equals(getStdNamespace())) {
14193 if (Name->
isStr(
"bad_alloc")) {
14195 isStdBadAlloc =
true;
14200 if (Previous.
empty() && StdBadAlloc)
14201 Previous.
addDecl(getStdBadAlloc());
14202 }
else if (Name->
isStr(
"align_val_t")) {
14203 isStdAlignValT =
true;
14204 if (Previous.
empty() && StdAlignValT)
14205 Previous.
addDecl(getStdAlignValT());
14213 if (Name && Previous.
empty() &&
14214 (TUK == TUK_Reference || TUK == TUK_Friend || IsTemplateParamOrArg)) {
14215 if (Invalid)
goto CreateNewDecl;
14218 if (TUK == TUK_Reference || IsTemplateParamOrArg) {
14252 assert(TUK == TUK_Friend);
14268 LookupQualifiedName(Previous, SearchDC);
14271 LookupName(Previous, S);
14279 if (!Previous.
empty()) {
14295 TagDecl *Tag = TT->getDecl();
14298 ->
Equals(TD->getDeclContext()->getRedeclContext())) {
14311 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
14312 auto *OldTag = dyn_cast<
TagDecl>(PrevDecl);
14313 if (SS.
isEmpty() && TUK != TUK_Reference && TUK != TUK_Friend &&
14314 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
14316 *
this, OldTag->getDeclContext(), SearchDC))) {
14317 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
14318 Diag(Shadow->getTargetDecl()->getLocation(),
14319 diag::note_using_decl_target);
14320 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl)
14324 goto CreateNewDecl;
14328 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
14332 if (TUK == TUK_Reference || TUK == TUK_Friend ||
14333 isDeclInScope(DirectPrevDecl, SearchDC, S,
14334 SS.
isNotEmpty() || isMemberSpecialization)) {
14337 if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind,
14338 TUK == TUK_Definition, KWLoc,
14340 bool SafeToContinue
14341 = (PrevTagDecl->getTagKind() !=
TTK_Enum &&
14343 if (SafeToContinue)
14344 Diag(KWLoc, diag::err_use_with_wrong_tag)
14347 PrevTagDecl->getKindName());
14349 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
14350 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
14352 if (SafeToContinue)
14353 Kind = PrevTagDecl->getTagKind();
14363 const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
14367 if (TUK == TUK_Reference || TUK == TUK_Friend) {
14369 Diag(ScopedEnumKWLoc, diag::err_enum_class_reference)
14372 return PrevTagDecl;
14377 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
14378 else if (
const Type *T = EnumUnderlying.dyn_cast<
const Type*>())
14379 EnumUnderlyingTy =
QualType(T, 0);
14384 if (CheckEnumRedeclaration(NameLoc.
isValid() ? NameLoc : KWLoc,
14385 ScopedEnum, EnumUnderlyingTy,
14386 IsFixed, PrevEnum))
14387 return TUK == TUK_Declaration ? PrevTagDecl :
nullptr;
14396 Diag(NameLoc, diag::ext_member_redeclared);
14397 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
14403 if (TUK == TUK_Reference || TUK == TUK_Friend) {
14404 if (!Attrs.
empty()) {
14407 }
else if (TUK == TUK_Reference &&
14408 (PrevTagDecl->getFriendObjectKind() ==
14421 return PrevTagDecl;
14426 return PrevTagDecl;
14431 if (TUK == TUK_Definition) {
14432 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
14436 bool IsExplicitSpecializationAfterInstantiation =
false;
14437 if (isMemberSpecialization) {
14439 IsExplicitSpecializationAfterInstantiation =
14440 RD->getTemplateSpecializationKind() !=
14442 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
14443 IsExplicitSpecializationAfterInstantiation =
14444 ED->getTemplateSpecializationKind() !=
14453 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
14464 SkipBody->
New = createTagFromNewDecl();
14468 makeMergedDefinitionVisible(Hidden);
14471 }
else if (!IsExplicitSpecializationAfterInstantiation) {
14475 Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name;
14477 Diag(NameLoc, diag::err_redefinition) << Name;
14478 notePreviousDefinition(Def,
14479 NameLoc.
isValid() ? NameLoc : KWLoc);
14491 if (TD->isBeingDefined()) {
14492 Diag(NameLoc, diag::err_nested_redefinition) << Name;
14493 Diag(PrevTagDecl->getLocation(),
14494 diag::note_previous_definition);
14508 if (TUK == TUK_Friend || TUK == TUK_Reference) {
14509 SearchDC = PrevTagDecl->getDeclContext();
14534 if ((TUK == TUK_Reference || TUK == TUK_Friend) &&
14536 NonTagKind NTK = getNonTagTypeDeclKind(PrevDecl, Kind);
14537 Diag(NameLoc, diag::err_tag_reference_non_tag) << PrevDecl << NTK
14543 }
else if (!isDeclInScope(DirectPrevDecl, SearchDC, S,
14544 SS.
isNotEmpty() || isMemberSpecialization)) {
14548 }
else if (TUK == TUK_Reference || TUK == TUK_Friend) {
14549 NonTagKind NTK = getNonTagTypeDeclKind(PrevDecl, Kind);
14550 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
14556 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
14558 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
14559 Diag(NameLoc, diag::err_tag_definition_of_typedef)
14560 << Name << Kind << TND->getUnderlyingType();
14568 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
14569 notePreviousDefinition(PrevDecl, NameLoc);
14600 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
14601 ScopedEnumUsesClassTag, IsFixed);
14603 if (isStdAlignValT && (!StdAlignValT || getStdAlignValT()->isImplicit()))
14604 StdAlignValT = cast<EnumDecl>(New);
14607 if (TUK != TUK_Definition && !Invalid) {
14609 if (IsFixed && (getLangOpts().
CPlusPlus11 || getLangOpts().ObjC2) &&
14610 cast<EnumDecl>(New)->isFixed()) {
14614 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
14615 Diag(Loc, diag::ext_forward_ref_enum_def)
14619 unsigned DiagID = diag::ext_forward_ref_enum;
14620 if (getLangOpts().MSVCCompat)
14621 DiagID = diag::ext_ms_forward_ref_enum;
14622 else if (getLangOpts().CPlusPlus)
14623 DiagID = diag::err_forward_ref_enum;
14628 if (EnumUnderlying) {
14629 EnumDecl *ED = cast<EnumDecl>(New);
14635 assert(ED->
isComplete() &&
"enum with type should be complete");
14642 if (getLangOpts().CPlusPlus) {
14645 cast_or_null<CXXRecordDecl>(PrevDecl));
14647 if (isStdBadAlloc && (!StdBadAlloc || getStdBadAlloc()->isImplicit()))
14648 StdBadAlloc = cast<CXXRecordDecl>(New);
14651 cast_or_null<RecordDecl>(PrevDecl));
14656 if (getLangOpts().
CPlusPlus && (IsTypeSpecifier || IsTemplateParamOrArg) &&
14657 TUK == TUK_Definition) {
14663 if (!Invalid && getLangOpts().
CPlusPlus && TUK == TUK_Definition &&
14675 if ((TUK == TUK_Definition || TUK == TUK_Declaration) &&
14676 diagnoseQualifiedDeclaration(SS, DC, OrigName, Loc,
14677 isMemberSpecialization))
14681 if (TemplateParameterLists.size() > 0) {
14689 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
14699 if (TUK == TUK_Definition) {
14700 AddAlignmentAttributesForRecord(RD);
14701 AddMsStructLayoutForRecord(RD);
14705 if (ModulePrivateLoc.
isValid()) {
14706 if (isMemberSpecialization)
14719 if (isMemberSpecialization && CheckMemberSpecialization(New, Previous))
14726 getNonFieldDeclScope(S)->isFunctionPrototypeScope()) {
14730 if (TUK == TUK_Definition && !IsTypeSpecifier) {
14731 Diag(Loc, diag::err_type_defined_in_param_type)
14735 }
else if (!PrevDecl) {
14751 if (TUK == TUK_Friend)
14755 if (!Invalid && SearchDC->
isRecord())
14756 SetMemberAccessSpecifier(New, PrevDecl, AS);
14759 CheckRedeclarationModuleOwnership(New, PrevDecl);
14761 if (TUK == TUK_Definition)
14764 ProcessDeclAttributeList(S, New, Attrs);
14765 AddPragmaAttributes(S, New);
14768 if (TUK == TUK_Friend) {
14777 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
14778 PushOnScopeChains(New, EnclosingScope,
false);
14780 S = getNonFieldDeclScope(S);
14781 PushOnScopeChains(New, S,
true);
14783 CurContext->addDecl(New);
14794 mergeDeclAttributes(New, PrevDecl);
14798 AddPushedVisibilityAttribute(New);
14801 CompleteMemberSpecialization(New, Previous);
14806 if (Invalid && getLangOpts().CPlusPlus) {
14808 if (
auto RD = dyn_cast<RecordDecl>(New))
14809 RD->completeDefinition();
14817 AdjustDeclIfTemplate(TagD);
14818 TagDecl *Tag = cast<TagDecl>(TagD);
14821 PushDeclContext(S, Tag);
14823 ActOnDocumentableDecl(TagD);
14827 AddPushedVisibilityAttribute(Tag);
14832 if (!hasStructuralCompatLayout(Prev, SkipBody.
New))
14836 makeMergedDefinitionVisible(SkipBody.
Previous);
14841 assert(isa<ObjCContainerDecl>(IDecl) &&
14842 "ActOnObjCContainerStartDefinition - Not ObjCContainerDecl");
14844 assert(getContainingDC(OCD) == CurContext &&
14845 "The next DeclContext should be lexically contained in the current one.");
14852 bool IsFinalSpelledSealed,
14854 AdjustDeclIfTemplate(TagD);
14857 FieldCollector->StartClass();
14863 Record->
addAttr(new (Context)
14864 FinalAttr(FinalLoc, Context, IsFinalSpelledSealed));
14882 PushOnScopeChains(InjectedClassName, S);
14884 "Broken injected-class-name");
14889 AdjustDeclIfTemplate(TagD);
14890 TagDecl *Tag = cast<TagDecl>(TagD);
14895 assert(Tag->
isInvalidDecl() &&
"We should already have completed it");
14896 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
14897 RD->completeDefinition();
14900 if (isa<CXXRecordDecl>(Tag)) {
14901 FieldCollector->FinishClass();
14907 if (getCurLexicalContext()->isObjCContainer() &&
14913 Consumer.HandleTagDeclDefinition(Tag);
14922 assert(DC == CurContext &&
"Mismatch of container contexts");
14923 OriginalLexicalContext = DC;
14924 ActOnObjCContainerFinishDefinition();
14928 ActOnObjCContainerStartDefinition(cast<Decl>(DC));
14929 OriginalLexicalContext =
nullptr;
14933 AdjustDeclIfTemplate(TagD);
14934 TagDecl *Tag = cast<TagDecl>(TagD);
14939 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
14940 RD->completeDefinition();
14953 QualType FieldTy,
bool IsMsStruct,
14954 Expr *BitWidth,
bool *ZeroWidth) {
14963 if (RequireCompleteType(FieldLoc, FieldTy, diag::err_field_incomplete))
14966 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
14968 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
14970 }
else if (DiagnoseUnexpandedParameterPack(const_cast<Expr *>(BitWidth),
14971 UPPC_BitFieldWidth))
14979 llvm::APSInt
Value;
14980 ExprResult ICE = VerifyIntegerConstantExpression(BitWidth, &Value);
14983 BitWidth = ICE.
get();
14985 if (Value != 0 && ZeroWidth)
14986 *ZeroWidth =
false;
14989 if (Value == 0 && FieldName)
14990 return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
14992 if (Value.isSigned() && Value.isNegative()) {
14994 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
14995 << FieldName << Value.toString(10);
14996 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
14997 << Value.toString(10);
15001 uint64_t TypeStorageSize = Context.
getTypeSize(FieldTy);
15002 uint64_t TypeWidth = Context.
getIntWidth(FieldTy);
15003 bool BitfieldIsOverwide = Value.ugt(TypeWidth);
15007 bool CStdConstraintViolation =
15008 BitfieldIsOverwide && !getLangOpts().CPlusPlus;
15009 bool MSBitfieldViolation =
15010 Value.ugt(TypeStorageSize) &&
15012 if (CStdConstraintViolation || MSBitfieldViolation) {
15013 unsigned DiagWidth =
15014 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
15016 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
15017 << FieldName << (unsigned)Value.getZExtValue()
15018 << !CStdConstraintViolation << DiagWidth;
15020 return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width)
15021 << (unsigned)Value.getZExtValue() << !CStdConstraintViolation
15030 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
15031 << FieldName << (unsigned)Value.getZExtValue()
15032 << (unsigned)TypeWidth;
15034 Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_width)
15035 << (unsigned)Value.getZExtValue() << (unsigned)TypeWidth;
15046 FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD),
15047 DeclStart, D, static_cast<Expr*>(BitfieldWidth),
15073 CheckExtraCXXDefaultArguments(D);
15076 UPPC_DataMemberType)) {
15087 Diag(Loc, diag::err_field_with_address_space);
15095 Diag(Loc, diag::err_opencl_type_struct_or_union_field) << T;
15103 << getLangOpts().CPlusPlus17;
15106 diag::err_invalid_thread)
15112 ForVisibleRedeclaration);
15113 LookupName(Previous, S);
15135 PrevDecl =
nullptr;
15138 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
15139 PrevDecl =
nullptr;
15145 = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
15146 TSSL, AS, PrevDecl, &D);
15158 PushOnScopeChains(NewFD, S);
15178 bool Mutable,
Expr *BitWidth,
15184 bool InvalidDecl =
false;
15190 InvalidDecl =
true;
15196 if (RequireCompleteType(Loc, EltTy, diag::err_field_incomplete)) {
15199 InvalidDecl =
true;
15205 InvalidDecl =
true;
15211 if (BitWidth && getLangOpts().OpenCL) {
15212 Diag(Loc, diag::err_opencl_bitfields);
15213 InvalidDecl =
true;
15217 if (!InvalidDecl && getLangOpts().
CPlusPlus && !II && BitWidth &&
15219 InvalidDecl =
true;
15220 Diag(Loc, diag::err_anon_bitfield_qualifiers);
15226 bool SizeIsNegative;
15227 llvm::APSInt Oversized;
15234 Diag(Loc, diag::warn_illegal_constant_array_size);
15235 TInfo = FixedTInfo;
15238 if (SizeIsNegative)
15239 Diag(Loc, diag::err_typecheck_negative_array_size);
15240 else if (Oversized.getBoolValue())
15241 Diag(Loc, diag::err_array_too_large)
15242 << Oversized.toString(10);
15244 Diag(Loc, diag::err_typecheck_field_variable_size);
15245 InvalidDecl =
true;
15250 if (!InvalidDecl && RequireNonAbstractType(Loc, T,
15251 diag::err_abstract_type_in_decl,
15252 AbstractFieldType))
15253 InvalidDecl =
true;
15255 bool ZeroWidth =
false;
15257 BitWidth =
nullptr;
15260 BitWidth = VerifyBitField(Loc, II, T, Record->
isMsStruct(Context), BitWidth,
15263 InvalidDecl =
true;
15264 BitWidth =
nullptr;
15270 if (!InvalidDecl && Mutable) {
15271 unsigned DiagID = 0;
15273 DiagID = getLangOpts().MSVCCompat ? diag::ext_mutable_reference
15274 : diag::err_mutable_reference;
15276 DiagID = diag::err_mutable_const;
15282 Diag(ErrLoc, DiagID);
15283 if (DiagID != diag::ext_mutable_reference) {
15285 InvalidDecl =
true;
15297 BitWidth, Mutable, InitStyle);
15301 if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
15302 Diag(Loc, diag::err_duplicate_member) << II;
15307 if (!InvalidDecl && getLangOpts().
CPlusPlus) {
15317 if (CheckNontrivialField(NewFD))
15327 diag::ext_union_member_of_reference_type :
15328 diag::err_union_member_of_reference_type)
15330 if (!getLangOpts().MicrosoftExt)
15340 ProcessDeclAttributes(getCurScope(), NewFD, *D);
15343 CheckAlignasUnderalignment(NewFD);
15348 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewFD))
15352 Diag(Loc, diag::warn_attribute_weak_on_field);
15360 assert(getLangOpts().
CPlusPlus &&
"valid check only for C++");
15380 member = CXXCopyConstructor;
15382 member = CXXDefaultConstructor;
15384 member = CXXCopyAssignment;
15386 member = CXXDestructor;
15388 if (member != CXXInvalid) {
15389 if (!getLangOpts().CPlusPlus11 &&
15397 if (getSourceManager().isInSystemHeader(Loc)) {
15398 if (!FD->
hasAttr<UnavailableAttr>())
15399 FD->
addAttr(UnavailableAttr::CreateImplicit(Context,
"",
15400 UnavailableAttr::IR_ARCFieldWithOwnership, Loc));
15406 diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member :
15407 diag::err_illegal_union_or_anon_struct_member)
15409 DiagnoseNontrivial(RDecl, member);
15410 return !getLangOpts().CPlusPlus11;
15422 switch (ivarVisibility) {
15423 default: llvm_unreachable(
"Unknown visitibility kind");
15439 Expr *BitWidth = (
Expr*)BitfieldWidth;
15451 BitWidth = VerifyBitField(Loc, II, T,
false, BitWidth).get();
15461 Diag(Loc, diag::err_ivar_reference_type);
15467 Diag(Loc, diag::err_typecheck_ivar_variable_size);
15481 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
15482 if (LangOpts.ObjCRuntime.isFragile()) {
15484 EnclosingContext = IMPDecl->getClassInterface();
15485 assert(EnclosingContext &&
"Implementation has no class interface!");
15488 EnclosingContext = EnclosingDecl;
15491 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
15492 if (LangOpts.ObjCRuntime.isFragile() || !CDecl->IsClassExtension()) {
15493 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
15497 EnclosingContext = EnclosingDecl;
15502 DeclStart, Loc, II, T,
15503 TInfo, ac, (
Expr *)BitfieldWidth);
15506 NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
15507 ForVisibleRedeclaration);
15508 if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S)
15509 && !isa<TagDecl>(PrevDecl)) {
15510 Diag(Loc, diag::err_duplicate_member) << II;
15517 ProcessDeclAttributes(S, NewID, D);
15523 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewID))
15533 IdResolver.AddDecl(NewID);
15536 if (LangOpts.ObjCRuntime.isNonFragile() &&
15537 !NewID->
isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
15538 Diag(Loc, diag::warn_ivars_in_interface);
15549 if (LangOpts.ObjCRuntime.isFragile() || AllIvarDecls.empty())
15552 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
15560 if (!CD->IsClassExtension())
15572 DeclLoc, DeclLoc,
nullptr,
15578 AllIvarDecls.push_back(Ivar);
15585 assert(EnclosingDecl &&
"missing record or interface decl");
15590 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
15594 case Decl::ObjCCategory:
15595 Context.
ResetObjCLayout(cast<ObjCCategoryDecl>(DC)->getClassInterface());
15597 case Decl::ObjCImplementation:
15599 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
15608 unsigned NumNamedMembers = 0;
15610 for (
const auto *I : Record->
decls()) {
15611 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
15612 if (IFD->getDeclName())
15620 bool ObjCFieldLifetimeErrReported =
false;
15630 RecFields.push_back(FD);
15650 bool IsLastField = (i + 1 == Fields.end());
15659 (Record || isa<ObjCContainerDecl>(EnclosingDecl))) {
15665 unsigned DiagID = 0;
15666 if (!Record->
isUnion() && !IsLastField) {
15669 Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
15673 }
else if (Record->
isUnion())
15674 DiagID = getLangOpts().MicrosoftExt
15675 ? diag::ext_flexible_array_union_ms
15676 : getLangOpts().CPlusPlus
15677 ? diag::ext_flexible_array_union_gnu
15678 : diag::err_flexible_array_union;
15679 else if (NumNamedMembers < 1)
15680 DiagID = getLangOpts().MicrosoftExt
15681 ? diag::ext_flexible_array_empty_aggregate_ms
15682 : getLangOpts().CPlusPlus
15683 ? diag::ext_flexible_array_empty_aggregate_gnu
15684 : diag::err_flexible_array_empty_aggregate;
15695 if (RD->getNumVBases() != 0)
15698 if (!getLangOpts().
C99)
15709 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
15724 diag::err_field_incomplete)) {
15749 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
15751 diag::err_abstract_type_in_decl,
15752 AbstractIvarType)) {
15766 }
else if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
15767 Record && !ObjCFieldLifetimeErrReported && Record->
isUnion()) {
15776 if (getSourceManager().isInSystemHeader(loc)) {
15777 if (!FD->
hasAttr<UnavailableAttr>()) {
15778 FD->
addAttr(UnavailableAttr::CreateImplicit(Context,
"",
15779 UnavailableAttr::IR_ARCFieldWithOwnership, loc));
15785 ObjCFieldLifetimeErrReported =
true;
15787 }
else if (getLangOpts().ObjC1 &&
15804 if (Record && !getLangOpts().
CPlusPlus && !FD->
hasAttr<UnavailableAttr>()) {
15817 if (RT->getDecl()->getArgPassingRestrictions() ==
15833 bool Completed =
false;
15834 if (
CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) {
15835 if (!CXXRecord->isInvalidDecl()) {
15838 I = CXXRecord->conversion_begin(),
15839 E = CXXRecord->conversion_end(); I != E; ++I)
15840 I.setAccess((*I)->getAccess());
15843 if (!CXXRecord->isDependentType()) {
15844 if (CXXRecord->hasUserDeclaredDestructor()) {
15846 if (getLangOpts().CPlusPlus11)
15847 AdjustDestructorExceptionSpec(CXXRecord,
15848 CXXRecord->getDestructor());
15852 AddImplicitlyDeclaredMembersToClass(CXXRecord);
15854 if (!CXXRecord->isInvalidDecl()) {
15858 if (CXXRecord->getNumVBases()) {
15860 CXXRecord->getFinalOverriders(FinalOverriders);
15862 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
15863 MEnd = FinalOverriders.end();
15866 SOEnd = M->second.end();
15867 SO != SOEnd; ++SO) {
15868 assert(SO->second.size() > 0 &&
15869 "Virtual function without overriding functions?");
15870 if (SO->second.size() == 1)
15878 << (
const NamedDecl *)M->first << Record;
15879 Diag(M->first->getLocation(),
15880 diag::note_overridden_virtual_function);
15882 OM = SO->second.begin(),
15883 OMEnd = SO->second.end();
15885 Diag(OM->Method->getLocation(), diag::note_final_overrider)
15886 << (
const NamedDecl *)M->first << OM->Method->getParent();
15891 CXXRecord->completeDefinition(&FinalOverriders);
15902 ProcessDeclAttributeList(S, Record, Attrs);
15905 if (
CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) {
15906 auto *Dtor = CXXRecord->getDestructor();
15907 if (Dtor && Dtor->isImplicit() &&
15908 ShouldDeleteSpecialMember(Dtor, CXXDestructor)) {
15909 CXXRecord->setImplicitDestructorIsDeleted();
15910 SetDeclDeleted(Dtor, CXXRecord->getLocation());
15915 CheckAlignasUnderalignment(Record);
15917 if (
const MSInheritanceAttr *IA = Record->
getAttr<MSInheritanceAttr>())
15918 checkMSInheritanceAttrOnDefinition(cast<CXXRecordDecl>(Record),
15919 IA->getRange(), IA->getBestCase(),
15920 IA->getSemanticSpelling());
15926 bool CheckForZeroSize;
15927 if (!getLangOpts().CPlusPlus) {
15928 CheckForZeroSize =
true;
15937 if (CheckForZeroSize) {
15938 bool ZeroSize =
true;
15939 bool IsEmpty =
true;
15940 unsigned NonBitFields = 0;
15943 (NonBitFields == 0 || ZeroSize) && I != E; ++I) {
15945 if (I->isUnnamedBitfield()) {
15946 if (!I->isZeroLengthBitField(Context))
15950 QualType FieldType = I->getType();
15962 diag::warn_zero_size_struct_union_in_extern_c :
15963 diag::warn_zero_size_struct_union_compat)
15964 << IsEmpty << Record->
isUnion() << (NonBitFields > 1);
15969 if (NonBitFields == 0 && !getLangOpts().CPlusPlus) {
15970 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union :
15971 diag::ext_no_named_members_in_struct_union)
15979 ID->setEndOfDefinitionLoc(RBrac);
15981 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
15983 ID->addDecl(ClsFields[i]);
15987 if (
ID->getSuperClass())
15988 DiagnoseDuplicateIvars(
ID,
ID->getSuperClass());
15990 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
15991 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
15992 for (
unsigned I = 0, N = RecFields.size(); I != N; ++I)
15995 ClsFields[I]->setLexicalDeclContext(IMPDecl);
15996 CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
15997 IMPDecl->setIvarLBraceLoc(LBrac);
15998 IMPDecl->setIvarRBraceLoc(RBrac);
16000 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
16008 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
16012 Diag(ClsFields[i]->getLocation(),
16013 diag::err_duplicate_ivar_declaration);
16014 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
16020 Diag(ClsFields[i]->getLocation(),
16021 diag::err_duplicate_ivar_declaration);
16022 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
16028 CDecl->addDecl(ClsFields[i]);
16030 CDecl->setIvarLBraceLoc(LBrac);
16031 CDecl->setIvarRBraceLoc(RBrac);
16039 llvm::APSInt &
Value,
16042 "Integral type required!");
16045 if (Value.isUnsigned() || Value.isNonNegative()) {
16048 return Value.getActiveBits() <= BitWidth;
16050 return Value.getMinSignedBits() <= BitWidth;
16060 const unsigned NumTypes = 4;
16061 QualType SignedIntegralTypes[NumTypes] = {
16064 QualType UnsignedIntegralTypes[NumTypes] = {
16071 : UnsignedIntegralTypes;
16072 for (
unsigned I = 0; I != NumTypes; ++I)
16085 llvm::APSInt EnumVal(IntWidth);
16088 if (Val && DiagnoseUnexpandedParameterPack(Val, UPPC_EnumeratorValue))
16092 Val = DefaultLvalueConversion(Val).get();
16098 if (getLangOpts().CPlusPlus11 && Enum->
isFixed() &&
16099 !getLangOpts().MSVCCompat) {
16110 Val = Converted.
get();
16112 !(Val = VerifyIntegerConstantExpression(Val,
16113 &EnumVal).get())) {
16124 if (getLangOpts().MSVCCompat) {
16125 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
16126 Val = ImpCastExprToType(Val, EltTy, CK_IntegralCast).get();
16128 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
16130 Val = ImpCastExprToType(Val, EltTy,
16132 CK_IntegralToBoolean : CK_IntegralCast)
16149 Diag(IdLoc, diag::ext_enum_value_not_int)
16151 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
16154 Val = ImpCastExprToType(Val, Context.
IntTy, CK_IntegralCast).get();
16163 if (Enum->isDependentType())
16165 else if (!LastEnumConst) {
16174 if (Enum->isFixed()) {
16175 EltTy = Enum->getIntegerType();
16178 EltTy = Context.
IntTy;
16182 EnumVal = LastEnumConst->getInitVal();
16184 EltTy = LastEnumConst->getType();
16187 if (EnumVal < LastEnumConst->getInitVal()) {
16199 if (T.
isNull() || Enum->isFixed()) {
16202 EnumVal = LastEnumConst->getInitVal();
16203 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
16205 if (Enum->isFixed())
16207 Diag(IdLoc, diag::err_enumerator_wrapped)
16208 << EnumVal.toString(10)
16211 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
16212 << EnumVal.toString(10);
16220 EnumVal = LastEnumConst->getInitVal();
16221 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
16222 EnumVal = EnumVal.zextOrTrunc(Context.
getIntWidth(EltTy));
16230 if (!getLangOpts().CPlusPlus && !T.
isNull())
16231 Diag(IdLoc, diag::warn_enum_value_overflow);
16232 }
else if (!getLangOpts().CPlusPlus &&
16235 Diag(IdLoc, diag::ext_enum_value_not_int)
16236 << EnumVal.toString(10) << 1;
16241 if (!EltTy->isDependentType()) {
16244 EnumVal = EnumVal.extOrTrunc(Context.
getIntWidth(EltTy));
16245 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
16254 if (!(getLangOpts().Modules || getLangOpts().ModulesLocalVisibility) ||
16261 NamedDecl *PrevDecl = LookupSingleName(S, II, IILoc, LookupOrdinaryName,
16262 forRedeclarationInCurContext());
16263 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
16267 EnumDecl *PrevED = cast<EnumDecl>(PrevECD->getDeclContext());
16269 if (!PrevED->
getDeclName() && !hasVisibleDefinition(PrevED, &Hidden)) {
16282 EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl);
16284 cast_or_null<EnumConstantDecl>(lastEnumConst);
16288 S = getNonFieldDeclScope(S);
16292 NamedDecl *PrevDecl = LookupSingleName(S, Id, IdLoc, LookupOrdinaryName,
16293 ForVisibleRedeclaration);
16296 DiagnoseTemplateParameterShadow(IdLoc, PrevDecl);
16298 PrevDecl =
nullptr;
16311 CheckEnumConstant(TheEnumDecl, LastEnumConst, IdLoc, Id, Val);
16318 assert((getLangOpts().
CPlusPlus || !isa<TagDecl>(PrevDecl)) &&
16319 "Received TagDecl when not in C++!");
16320 if (!isa<TagDecl>(PrevDecl) && isDeclInScope(PrevDecl, CurContext, S)) {
16321 if (isa<EnumConstantDecl>(PrevDecl))
16322 Diag(IdLoc, diag::err_redefinition_of_enumerator) <<
Id;
16324 Diag(IdLoc, diag::err_redefinition) <<
Id;
16325 notePreviousDefinition(PrevDecl, IdLoc);
16331 ProcessDeclAttributeList(S, New, Attrs);
16332 AddPragmaAttributes(S, New);
16336 PushOnScopeChains(New, S);
16338 ActOnDocumentableDecl(New);
16356 if (!BO->isAdditiveOp())
16364 InitExpr = BO->getLHS();
16401 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
16402 typedef llvm::DenseMap<int64_t, DeclOrVector> ValueToVectorMap;
16406 llvm::APSInt Val = D->getInitVal();
16407 return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
16410 DuplicatesVector DupVector;
16411 ValueToVectorMap EnumMap;
16415 for (
auto *Element : Elements) {
16429 EnumMap.insert({EnumConstantToKey(ECD), ECD});
16432 if (EnumMap.size() == 0)
16436 for (
auto *Element : Elements) {
16442 auto Iter = EnumMap.find(EnumConstantToKey(ECD));
16443 if (Iter == EnumMap.end())
16446 DeclOrVector& Entry = Iter->second;
16453 auto Vec = llvm::make_unique<ECDVector>();
16455 Vec->push_back(ECD);
16462 DupVector.emplace_back(std::move(Vec));
16466 ECDVector *Vec = Entry.get<ECDVector*>();
16468 if (*Vec->begin() == ECD)
16471 Vec->push_back(ECD);
16475 for (
const auto &Vec : DupVector) {
16476 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
16479 auto *FirstECD = Vec->front();
16480 S.
Diag(FirstECD->getLocation(), diag::warn_duplicate_enum_values)
16481 << FirstECD << FirstECD->getInitVal().toString(10)
16482 << FirstECD->getSourceRange();
16486 for (
auto *ECD : llvm::make_range(Vec->begin() + 1, Vec->end()))
16487 S.
Diag(ECD->getLocation(), diag::note_duplicate_element)
16488 << ECD << ECD->getInitVal().toString(10)
16489 << ECD->getSourceRange();
16494 bool AllowMask)
const {
16495 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
16498 auto R = FlagBitsCache.insert(std::make_pair(ED, llvm::APInt()));
16499 llvm::APInt &FlagBits = R.first->second;
16503 const auto &EVal = E->getInitVal();
16505 if (EVal.isPowerOf2())
16506 FlagBits = FlagBits.zextOrSelf(EVal.getBitWidth()) | EVal;
16518 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
16519 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
16525 EnumDecl *Enum = cast<EnumDecl>(EnumDeclX);
16528 ProcessDeclAttributeList(S, Enum, Attrs);
16531 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
16533 cast_or_null<EnumConstantDecl>(Elements[i]);
16534 if (!ECD)
continue;
16552 unsigned NumNegativeBits = 0;
16553 unsigned NumPositiveBits = 0;
16556 bool AllElementsInt =
true;
16558 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
16560 cast_or_null<EnumConstantDecl>(Elements[i]);
16561 if (!ECD)
continue;
16563 const llvm::APSInt &InitVal = ECD->
getInitVal();
16566 if (InitVal.isUnsigned() || InitVal.isNonNegative())
16567 NumPositiveBits =
std::max(NumPositiveBits,
16568 (
unsigned)InitVal.getActiveBits());
16570 NumNegativeBits =
std::max(NumNegativeBits,
16571 (
unsigned)InitVal.getMinSignedBits());
16574 if (AllElementsInt)
16580 unsigned BestWidth;
16593 bool Packed = Enum->
hasAttr<PackedAttr>();
16596 if (LangOpts.ShortEnums)
16606 BestPromotionType = BestType;
16610 else if (NumNegativeBits) {
16614 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
16616 BestWidth = CharWidth;
16617 }
else if (Packed && NumNegativeBits <= ShortWidth &&
16618 NumPositiveBits < ShortWidth) {
16620 BestWidth = ShortWidth;
16621 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
16622 BestType = Context.
IntTy;
16623 BestWidth = IntWidth;
16627 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
16628 BestType = Context.
LongTy;
16632 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
16637 BestPromotionType = (BestWidth <= IntWidth ? Context.
IntTy : BestType);
16642 if (Packed && NumPositiveBits <= CharWidth) {
16644 BestPromotionType = Context.
IntTy;
16645 BestWidth = CharWidth;
16646 }
else if (Packed && NumPositiveBits <= ShortWidth) {
16648 BestPromotionType = Context.
IntTy;
16649 BestWidth = ShortWidth;
16650 }
else if (NumPositiveBits <= IntWidth) {
16652 BestWidth = IntWidth;
16654 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
16656 }
else if (NumPositiveBits <=
16660 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
16664 assert(NumPositiveBits <= BestWidth &&
16665 "How could an initializer get larger than ULL?");
16668 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
16675 for (
auto *D : Elements) {
16676 auto *ECD = cast_or_null<EnumConstantDecl>(D);
16677 if (!ECD)
continue;
16686 llvm::APSInt InitVal = ECD->getInitVal();
16696 NewTy = Context.
IntTy;
16697 NewWidth = IntWidth;
16699 }
else if (ECD->getType() == BestType) {
16701 if (getLangOpts().CPlusPlus)
16705 ECD->setType(EnumType);
16709 NewWidth = BestWidth;
16714 InitVal = InitVal.extOrTrunc(NewWidth);
16715 InitVal.setIsSigned(NewSign);
16716 ECD->setInitVal(InitVal);
16719 if (ECD->getInitExpr() &&
16720 !Context.
hasSameType(NewTy, ECD->getInitExpr()->getType()))
16723 ECD->getInitExpr(),
16726 if (getLangOpts().CPlusPlus)
16730 ECD->setType(EnumType);
16732 ECD->setType(NewTy);
16736 NumPositiveBits, NumNegativeBits);
16741 for (
Decl *D : Elements) {
16743 if (!ECD)
continue;
16746 if (InitVal != 0 && !InitVal.isPowerOf2() &&
16747 !IsValueInFlagEnum(Enum, InitVal,
true))
16755 CheckAlignasUnderalignment(Enum);
16764 AsmString, StartLoc,
16766 CurContext->addDecl(New);
16772 bool FromInclude =
false) {
16775 if (
auto *LSD = dyn_cast<LinkageSpecDecl>(DC)) {
16776 switch (LSD->getLanguage()) {
16779 ExternCLoc = LSD->getLocStart();
16787 while (isa<LinkageSpecDecl>(DC) || isa<ExportDecl>(DC))
16790 if (!isa<TranslationUnitDecl>(DC)) {
16792 ? diag::ext_module_import_not_at_top_level_noop
16793 : diag::err_module_import_not_at_top_level_fatal)
16795 S.
Diag(cast<Decl>(DC)->getLocStart(),
16796 diag::note_module_import_not_at_top_level) << DC;
16798 S.
Diag(ImportLoc, diag::ext_module_import_in_extern_c)
16800 S.
Diag(ExternCLoc, diag::note_extern_c_begins_here);
16808 assert(getLangOpts().ModulesTS &&
16809 "should only have module decl in modules TS");
16814 switch (getLangOpts().getCompilingModule()) {
16820 if (MDK != ModuleDeclKind::Implementation)
16825 Diag(ModuleLoc, diag::err_module_interface_implementation_mismatch)
16827 MDK = ModuleDeclKind::Interface;
16831 Diag(ModuleLoc, diag::err_module_decl_in_module_map_module);
16835 assert(ModuleScopes.size() == 1 &&
"expected to be at global module scope");
16842 Diag(ModuleLoc, diag::err_module_redeclaration);
16843 Diag(VisibleModules.getImportLoc(ModuleScopes.back().Module),
16844 diag::note_prev_module_declaration);
16851 std::string ModuleName;
16852 for (
auto &Piece : Path) {
16853 if (!ModuleName.empty())
16855 ModuleName += Piece.first->getName();
16860 if (!getLangOpts().CurrentModule.empty() &&
16861 getLangOpts().CurrentModule != ModuleName) {
16862 Diag(Path.front().second, diag::err_current_module_name_mismatch)
16863 <<
SourceRange(Path.front().second, Path.back().second)
16864 << getLangOpts().CurrentModule;
16867 const_cast<LangOptions&
>(getLangOpts()).CurrentModule = ModuleName;
16869 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
16873 case ModuleDeclKind::Interface: {
16876 if (
auto *M = Map.findModule(ModuleName)) {
16877 Diag(Path[0].second, diag::err_module_redefinition) << ModuleName;
16878 if (M->DefinitionLoc.isValid())
16879 Diag(M->DefinitionLoc, diag::note_prev_module_definition);
16880 else if (
const auto *FE = M->getASTFile())
16881 Diag(M->DefinitionLoc, diag::note_prev_module_definition_from_ast_file)
16888 Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
16889 ModuleScopes.front().Module);
16890 assert(Mod &&
"module creation should not fail");
16894 case ModuleDeclKind::Partition:
16898 case ModuleDeclKind::Implementation:
16899 std::pair<IdentifierInfo *, SourceLocation> ModuleNameLoc(
16900 PP.getIdentifierInfo(ModuleName), Path[0].second);
16904 Diag(ModuleLoc, diag::err_module_not_defined) << ModuleName;
16906 Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
16907 ModuleScopes.front().Module);
16913 ModuleScopes.back().Module = Mod;
16914 ModuleScopes.back().ModuleInterface = MDK != ModuleDeclKind::Implementation;
16915 VisibleModules.setVisible(Mod, ModuleLoc);
16922 TU->setLocalOwningModule(Mod);
16937 VisibleModules.setVisible(Mod, ImportLoc);
16947 (getLangOpts().isCompilingModule() || !getLangOpts().ModulesTS))
16948 Diag(ImportLoc, getLangOpts().isCompilingModule()
16949 ? diag::err_module_self_import
16950 : diag::err_module_import_in_implementation)
16955 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
16960 ModCheck = ModCheck->
Parent;
16962 IdentifierLocs.push_back(Path[I].second);
16966 Mod, IdentifierLocs);
16967 if (!ModuleScopes.empty())
16969 CurContext->addDecl(Import);
16973 !ModuleScopes.empty() && ModuleScopes.back().ModuleInterface)
16974 getCurrentModule()->Exports.emplace_back(Mod,
false);
16981 BuildModuleInclude(DirectiveLoc, Mod);
16990 bool IsInModuleIncludes =
16992 getSourceManager().isWrittenInMainFile(DirectiveLoc);
16994 bool ShouldAddImport = !IsInModuleIncludes;
16998 if (ShouldAddImport) {
17003 if (!ModuleScopes.empty())
17006 Consumer.HandleImplicitImportDecl(ImportD);
17010 VisibleModules.setVisible(Mod, DirectiveLoc);
17016 ModuleScopes.push_back({});
17017 ModuleScopes.back().Module = Mod;
17018 if (getLangOpts().ModulesLocalVisibility)
17019 ModuleScopes.back().OuterVisibleModules = std::move(VisibleModules);
17021 VisibleModules.setVisible(Mod, DirectiveLoc);
17026 if (getLangOpts().trackLocalOwningModule()) {
17027 for (
auto *DC = CurContext; DC; DC = DC->getLexicalParent()) {
17028 cast<Decl>(DC)->setModuleOwnershipKind(
17029 getLangOpts().ModulesLocalVisibility
17032 cast<Decl>(DC)->setLocalOwningModule(Mod);
17038 if (getLangOpts().ModulesLocalVisibility) {
17039 VisibleModules = std::move(ModuleScopes.back().OuterVisibleModules);
17042 VisibleNamespaceCache.clear();
17045 assert(!ModuleScopes.empty() && ModuleScopes.back().Module == Mod &&
17046 "left the wrong module scope");
17047 ModuleScopes.pop_back();
17051 FileID File = getSourceManager().getFileID(EomLoc);
17053 if (EomLoc == getSourceManager().getLocForEndOfFile(File)) {
17055 assert(File != getSourceManager().getMainFileID() &&
17056 "end of submodule in main source file");
17057 DirectiveLoc = getSourceManager().getIncludeLoc(File);
17060 DirectiveLoc = EomLoc;
17062 BuildModuleInclude(DirectiveLoc, Mod);
17065 if (getLangOpts().trackLocalOwningModule()) {
17068 for (
auto *DC = CurContext; DC; DC = DC->getLexicalParent()) {
17069 cast<Decl>(DC)->setLocalOwningModule(getCurrentModule());
17070 if (!getCurrentModule())
17071 cast<Decl>(DC)->setModuleOwnershipKind(
17080 if (isSFINAEContext() || !getLangOpts().ModulesErrorRecovery ||
17081 VisibleModules.isVisible(Mod))
17089 Consumer.HandleImplicitImportDecl(ImportD);
17093 VisibleModules.setVisible(Mod, Loc);
17105 if (ModuleScopes.empty() || !ModuleScopes.back().ModuleInterface)
17106 Diag(ExportLoc, diag::err_export_not_in_module_interface);
17114 Diag(ExportLoc, diag::err_export_within_export);
17116 CurContext->addDecl(D);
17117 PushDeclContext(S, D);
17124 auto *ED = cast<ExportDecl>(D);
17126 ED->setRBraceLoc(RBraceLoc);
17140 NamedDecl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc,
17141 LookupOrdinaryName);
17142 AsmLabelAttr *
Attr =
17143 AsmLabelAttr::CreateImplicit(Context, AliasName->
getName(), AliasNameLoc);
17149 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
17153 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
17154 << (isa<FunctionDecl>(PrevDecl) ? 0 : 1) << PrevDecl;
17157 (
void)ExtnameUndeclaredIdentifiers.insert(std::make_pair(Name, Attr));
17163 Decl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName);
17166 PrevDecl->
addAttr(WeakAttr::CreateImplicit(Context, PragmaLoc));
17168 (void)WeakUndeclaredIdentifiers.insert(
17169 std::pair<IdentifierInfo*,WeakInfo>
17179 Decl *PrevDecl = LookupSingleName(TUScope, AliasName, AliasNameLoc,
17180 LookupOrdinaryName);
17183 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
17184 if (!PrevDecl->
hasAttr<AliasAttr>())
17185 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
17186 DeclApplyPragmaWeak(TUScope, ND, W);
17188 (void)WeakUndeclaredIdentifiers.insert(
17189 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W));
17194 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...
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.
CodeSegAttr * mergeCodeSegAttr(Decl *D, SourceRange Range, StringRef Name, unsigned AttrSpellingListIndex)
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.
SourceLocation getLocStart() const LLVM_READONLY
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)
attr_iterator attr_begin() const
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)) {...
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 bool CheckMultiVersionAdditionalDecl(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, MultiVersioning::Type 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 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)
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
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 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...
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
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)
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".
virtual void completeDefinition()
Note that the definition of this type is now complete.
bool isZero() const
isZero - Test whether the quantity equals zero.
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.
SourceLocation getLocEnd() const LLVM_READONLY
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.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext...
size_t param_size() const
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.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
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 EvaluateAsInt(llvm::APSInt &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...
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
RAII object that enters a new expression evaluation context.
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...
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
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>'.
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 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.
FormatAttr * mergeFormatAttr(Decl *D, SourceRange Range, IdentifierInfo *Format, int FormatIdx, int FirstArg, unsigned AttrSpellingListIndex)
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.
static bool CheckMultiVersionFirstFunction(Sema &S, FunctionDecl *FD, MultiVersioning::Type 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...
UuidAttr * mergeUuidAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex, StringRef Uuid)
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.
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.
attr_iterator attr_end() const
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
static const TST TST_class
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)
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
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
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.
unsigned getTypeQualifiers() const
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.
SourceLocation getLocStart() const LLVM_READONLY
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()
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.
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
SourceLocation getTemplateLoc() const
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
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
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type, bool NRVO)
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 ...
bool isModuleVisible(const Module *M)
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.
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, SourceRange Range, TypeVisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
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.
MinSizeAttr * mergeMinSizeAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
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.
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.
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)
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
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...
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
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>.
enum clang::DeclaratorChunk::@196 Kind
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'.
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.
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
SourceLocation getTypeSpecStartLoc() const
SourceRange getSourceRange() const LLVM_READONLY
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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)
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.
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.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
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.
SourceLocation getLocStart() const LLVM_READONLY
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
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.
void SetRangeStart(SourceLocation Loc)
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclarationNameTable DeclarationNames
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
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...
static bool CheckMultiVersionAdditionalRules(Sema &S, const FunctionDecl *OldFD, const FunctionDecl *NewFD, bool CausesMV, MultiVersioning::Type MVType)
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.
static MultiVersioning::Type getMultiVersionType(const FunctionDecl *FD)
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.
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 ...
Expr - 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
Represents a character-granular source range.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
bool isFunctionNoProtoType() const
bool isVariadic() const
Whether this function is variadic.
DLLImportAttr * mergeDLLImportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
bool isDefaulted() const
Whether this function is defaulted per C++0x.
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, 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())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
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.
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...
const Expr * getCallee() const
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.
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
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
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.
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, unsigned AttrSpellingListIndex, MSInheritanceAttr::Spelling SemanticSpelling)
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)
void AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl, CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
virtual bool validateCpuSupports(StringRef Name) const
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.
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
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.
SourceLocation getLocEnd() const LLVM_READONLY
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.
AttributedType::Kind getAttrKind() const
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...
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)
virtual bool supportsMultiVersioning() const
Identify whether this taret supports multiversioning of functions, which requires support for cpu_sup...
SourceLocation getLocStart() const LLVM_READONLY
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)
bool isStructureOrClassType() const
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
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
DLLExportAttr * mergeDLLExportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
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)
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
ASTContext & getASTContext() const LLVM_READONLY
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
bool isModulePrivateSpecified() const
SourceLocation getLocStart() const LLVM_READONLY
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.
CommonAttr * mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
unsigned getSpellingListIndex() const
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
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)
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.
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.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
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.
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).
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...
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...
void setVirtualAsWritten(bool V)
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.
void setImplicitlyInline()
Flag that this function is implicitly inline.
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...
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) ...
SectionAttr * mergeSectionAttr(Decl *D, SourceRange Range, StringRef Name, unsigned AttrSpellingListIndex)
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.
DeclarationName - 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.
SourceLocation getLocStart() const LLVM_READONLY
unsigned getNumTemplateParameterLists() const
VisibilityAttr * mergeVisibilityAttr(Decl *D, SourceRange Range, VisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
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.
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.
static void SetNestedNameSpecifier(DeclaratorDecl *DD, Declarator &D)
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)
void setBlockVarCopyInits(VarDecl *VD, Expr *Init)
Set the copy inialization expression of a block var decl.
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
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
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 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.
bool isPointerType() const
bool hasObjectMember() const
NamedDecl * findLocallyScopedExternCDecl(DeclarationName Name)
Look for a locally scoped extern "C" declaration by the given name.
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)
An l-value expression is a reference to an object with independent storage.
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.
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
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.
SourceRange getLocalSourceRange() const
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.
SourceLocation getLocEnd() const LLVM_READONLY
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.
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 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.
void clear()
Clears out any current state.
ExtInfo withRegParm(unsigned RegParm) const
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.