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;
175 return UnqualifiedTypeNameLookupResult::NotFound;
178 UnqualifiedTypeNameLookupResult::NotFound;
181 if (
auto *BaseTT =
Base.getType()->getAs<
TagType>())
182 BaseRD = BaseTT->getAsCXXRecordDecl();
186 if (!TST || !TST->isDependentType())
188 auto *TD = TST->getTemplateName().getAsTemplateDecl();
191 if (
auto *BasePrimaryTemplate =
192 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
194 BaseRD = BasePrimaryTemplate;
195 else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
197 CTD->findPartialSpecialization(
Base.getType()))
205 if (!isa<TypeDecl>(ND))
206 return UnqualifiedTypeNameLookupResult::FoundNonType;
207 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
209 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
211 case UnqualifiedTypeNameLookupResult::FoundNonType:
212 return UnqualifiedTypeNameLookupResult::FoundNonType;
213 case UnqualifiedTypeNameLookupResult::FoundType:
214 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
216 case UnqualifiedTypeNameLookupResult::NotFound:
223 return FoundTypeDecl;
232 UnqualifiedTypeNameLookupResult::NotFound;
234 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
235 DC = DC->getParent()) {
242 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
248 S.
Diag(NameLoc, diag::ext_found_via_dependent_bases_lookup) << &II;
276 bool isClassName,
bool HasTrailingDot,
278 bool IsCtorOrDtorName,
279 bool WantNontrivialTypeSourceInfo,
280 bool IsClassTemplateDeductionContext,
283 bool AllowDeducedTemplate = IsClassTemplateDeductionContext &&
284 getLangOpts().CPlusPlus17 && !IsCtorOrDtorName &&
285 !isClassName && !HasTrailingDot;
292 LookupCtx = computeDeclContext(ObjectType);
294 LookupCtx = computeDeclContext(*SS,
false);
297 if (isDependentScopeSpecifier(*SS)) {
307 if (!isClassName && !IsCtorOrDtorName)
312 if (WantNontrivialTypeSourceInfo)
313 return ActOnTypenameType(S,
SourceLocation(), *SS, II, NameLoc).get();
325 RequireCompleteDeclContext(*SS, LookupCtx))
339 LookupQualifiedName(Result, LookupCtx);
341 if (ObjectTypePtr && Result.
empty()) {
348 LookupName(Result, S);
352 LookupName(Result, S);
356 if (Result.
empty() && getLangOpts().MSVCCompat && (!SS || SS->
isEmpty())) {
370 llvm::make_unique<TypeNameValidatorCCC>(
371 true, isClassName, AllowDeducedTemplate),
375 bool MemberOfUnknownSpecialization;
384 if (Correction && (NNS || NewII != &II) &&
389 isTemplateName(S, *NewSSPtr,
false, TemplateName,
nullptr,
false,
390 Template, MemberOfUnknownSpecialization))) {
392 isClassName, HasTrailingDot, ObjectTypePtr,
394 WantNontrivialTypeSourceInfo,
395 IsClassTemplateDeductionContext);
397 diagnoseTypo(Correction,
398 PDiag(diag::err_unknown_type_or_class_name_suggest)
401 SS->MakeTrivial(Context, NNS,
SourceRange(NameLoc));
402 *CorrectedII = NewII;
427 Res != ResEnd; ++Res) {
428 if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res) ||
459 assert(IIDecl &&
"Didn't find decl");
462 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
466 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
468 if (!isClassName && !IsCtorOrDtorName && LookupRD && FoundRD &&
469 FoundRD->isInjectedClassName() &&
471 Diag(NameLoc, diag::err_out_of_line_qualified_id_type_names_constructor)
474 DiagnoseUseOfDecl(IIDecl, NameLoc);
477 MarkAnyDeclReferenced(TD->getLocation(), TD,
false);
479 (void)DiagnoseUseOfDecl(IDecl, NameLoc);
482 }
else if (AllowDeducedTemplate) {
497 if (SS && SS->
isNotEmpty() && !IsCtorOrDtorName &&
498 !isa<ObjCInterfaceDecl>(IIDecl)) {
499 if (WantNontrivialTypeSourceInfo) {
504 T = getElaboratedType(
ETK_None, *SS, T);
510 T = getElaboratedType(
ETK_None, *SS, T);
523 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
525 else if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
527 RD->getTypeForDecl());
528 else if (isa<TranslationUnitDecl>(DC))
531 llvm_unreachable(
"something isn't in TU scope?");
542 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
543 if (MD->getParent()->hasAnyDependentBases())
551 bool IsTemplateTypeArg) {
552 assert(getLangOpts().MSVCCompat &&
"shouldn't be called in non-MSVC mode");
555 if (IsTemplateTypeArg && getCurScope()->isTemplateParamScope()) {
564 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
570 RD->getTypeForDecl());
574 Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
605 LookupName(R, S,
false);
609 switch (TD->getTagKind()) {
636 if (CurContext->isRecord()) {
656 bool IsTemplateName) {
661 SuggestedType =
nullptr;
667 llvm::make_unique<TypeNameValidatorCCC>(
668 false,
false, IsTemplateName, !IsTemplateName),
669 CTK_ErrorRecovery)) {
671 bool CanRecover = !IsTemplateName;
672 if (Corrected.isKeyword()) {
674 diagnoseTypo(Corrected,
675 PDiag(IsTemplateName ? diag::err_no_template_suggest
676 : diag::err_unknown_typename_suggest)
678 II = Corrected.getCorrectionAsIdentifierInfo();
681 if (!SS || !SS->
isSet()) {
682 diagnoseTypo(Corrected,
683 PDiag(IsTemplateName ? diag::err_no_template_suggest
684 : diag::err_unknown_typename_suggest)
686 }
else if (
DeclContext *DC = computeDeclContext(*SS,
false)) {
687 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
688 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
689 II->
getName().equals(CorrectedStr);
690 diagnoseTypo(Corrected,
692 ? diag::err_no_member_template_suggest
693 : diag::err_unknown_nested_typename_suggest)
694 << II << DC << DroppedSpecifier << SS->
getRange(),
697 llvm_unreachable(
"could not have corrected a typo here");
704 if (Corrected.getCorrectionSpecifier())
705 tmpSS.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
709 getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc, S,
710 tmpSS.
isSet() ? &tmpSS : SS,
false,
false,
nullptr,
717 if (getLangOpts().CPlusPlus && !IsTemplateName) {
723 bool MemberOfUnknownSpecialization;
724 if (isTemplateName(S, SS ? *SS : EmptySS,
false,
725 Name,
nullptr,
true, TemplateResult,
728 Diag(IILoc, diag::err_template_missing_args)
729 << (int)getTemplateNameKindForDiagnostics(TplName) << TplName;
731 Diag(TplDecl->getLocation(), diag::note_template_decl_here)
732 << TplDecl->getTemplateParameters()->getSourceRange();
742 Diag(IILoc, IsTemplateName ? diag::err_no_template
743 : diag::err_unknown_typename)
745 else if (
DeclContext *DC = computeDeclContext(*SS,
false))
746 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
747 : diag::err_typename_nested_not_found)
749 else if (isDependentScopeSpecifier(*SS)) {
750 unsigned DiagID = diag::err_typename_missing;
751 if (getLangOpts().MSVCCompat && isMicrosoftMissingTypename(SS, S))
752 DiagID = diag::ext_typename_missing;
759 *SS, *II, IILoc).
get();
762 "Invalid scope specifier has already been diagnosed");
770 NextToken.
is(tok::less);
773 if (isa<TypeDecl>(*I) || isa<ObjCInterfaceDecl>(*I))
776 if (CheckTemplate && isa<TemplateDecl>(*I))
790 StringRef FixItTagName;
791 switch (Tag->getTagKind()) {
793 FixItTagName =
"class ";
797 FixItTagName =
"enum ";
801 FixItTagName =
"struct ";
805 FixItTagName =
"__interface ";
809 FixItTagName =
"union ";
813 StringRef TagName = FixItTagName.drop_back();
814 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
815 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
820 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
850 bool IsAddressOfOperand,
851 std::unique_ptr<CorrectionCandidateCallback> CCC) {
855 if (NextToken.
is(tok::coloncolon)) {
857 BuildCXXNestedNameSpecifier(S, IdInfo,
false, SS,
nullptr,
false);
859 isCurrentClassName(*Name, S, &SS)) {
867 LookupResult Result(*
this, Name, NameLoc, LookupOrdinaryName);
868 LookupParsedName(Result, S, &SS, !CurMethod);
872 if (Result.
empty() && SS.
isEmpty() && getLangOpts().MSVCCompat) {
883 ExprResult E = LookupInObjCMethod(Result, S, Name,
true);
888 bool SecondTry =
false;
889 bool IsFilteredTemplateName =
false;
896 if (!SS.
isSet() && NextToken.
is(tok::l_paren)) {
899 if (getLangOpts().CPlusPlus)
900 return BuildDeclarationNameExpr(SS, Result,
true);
914 if (
NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *Name, S)) {
917 return BuildDeclarationNameExpr(SS, Result,
false);
924 if (!getLangOpts().
CPlusPlus && !SecondTry &&
931 if (!SecondTry && CCC) {
936 CTK_ErrorRecovery)) {
937 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
938 unsigned QualifiedDiag = diag::err_no_member_suggest;
940 NamedDecl *FirstDecl = Corrected.getFoundDecl();
941 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
942 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
943 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
944 UnqualifiedDiag = diag::err_no_template_suggest;
945 QualifiedDiag = diag::err_no_member_template_suggest;
946 }
else if (UnderlyingFirstDecl &&
947 (isa<TypeDecl>(UnderlyingFirstDecl) ||
948 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
949 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
950 UnqualifiedDiag = diag::err_unknown_typename_suggest;
951 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
955 diagnoseTypo(Corrected, PDiag(UnqualifiedDiag) << Name);
957 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
958 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
959 Name->
getName().equals(CorrectedStr);
960 diagnoseTypo(Corrected, PDiag(QualifiedDiag)
961 << Name << computeDeclContext(SS,
false)
962 << DroppedSpecifier << SS.getRange());
966 Name = Corrected.getCorrectionAsIdentifierInfo();
969 if (Corrected.isKeyword())
985 ExprResult E(LookupInObjCMethod(Result, S, Ivar->getIdentifier()));
1013 NameInfo, IsAddressOfOperand,
1023 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
1024 hasAnyAcceptableTemplateNames(Result)) {
1036 FilterAcceptableTemplateNames(Result);
1038 IsFilteredTemplateName =
true;
1047 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
1048 (IsFilteredTemplateName || hasAnyAcceptableTemplateNames(Result))) {
1055 if (!IsFilteredTemplateName)
1056 FilterAcceptableTemplateNames(Result);
1058 if (!Result.
empty()) {
1059 bool IsFunctionTemplate;
1062 if (Result.
end() - Result.
begin() > 1) {
1063 IsFunctionTemplate =
true;
1068 = cast<TemplateDecl>((*Result.
begin())->getUnderlyingDecl());
1069 IsFunctionTemplate = isa<FunctionTemplateDecl>(TD);
1070 IsVarTemplate = isa<VarTemplateDecl>(TD);
1080 if (IsFunctionTemplate) {
1086 return NameClassification::FunctionTemplate(Template);
1089 return IsVarTemplate ? NameClassification::VarTemplate(Template)
1090 : NameClassification::TypeTemplate(Template);
1096 DiagnoseUseOfDecl(
Type, NameLoc);
1097 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
1108 dyn_cast<ObjCCompatibleAliasDecl>(FirstDecl))
1109 Class = Alias->getClassInterface();
1113 DiagnoseUseOfDecl(Class, NameLoc);
1115 if (NextToken.
is(tok::period)) {
1127 if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl) &&
1128 !isa<VarTemplateDecl>(FirstDecl))
1129 return NameClassification::TypeTemplate(
1134 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1135 if ((NextToken.
is(tok::identifier) ||
1140 DiagnoseUseOfDecl(Type, NameLoc);
1148 return BuildPossibleImplicitMemberExpr(SS,
SourceLocation(), Result,
1151 bool ADL = UseArgumentDependentLookup(SS, Result, NextToken.
is(tok::l_paren));
1152 return BuildDeclarationNameExpr(SS, Result, ADL);
1159 return TemplateNameKindForDiagnostics::DependentTemplate;
1160 if (isa<ClassTemplateDecl>(TD))
1161 return TemplateNameKindForDiagnostics::ClassTemplate;
1162 if (isa<FunctionTemplateDecl>(TD))
1163 return TemplateNameKindForDiagnostics::FunctionTemplate;
1164 if (isa<VarTemplateDecl>(TD))
1165 return TemplateNameKindForDiagnostics::VarTemplate;
1166 if (isa<TypeAliasTemplateDecl>(TD))
1167 return TemplateNameKindForDiagnostics::AliasTemplate;
1168 if (isa<TemplateTemplateParmDecl>(TD))
1169 return TemplateNameKindForDiagnostics::TemplateTemplateParam;
1170 return TemplateNameKindForDiagnostics::DependentTemplate;
1195 if (!isa<CXXRecordDecl>(DC))
1213 assert(getContainingDC(DC) == CurContext &&
1214 "The next DeclContext should be lexically contained in the current one.");
1220 assert(CurContext &&
"DeclContext imbalance!");
1222 CurContext = getContainingDC(CurContext);
1223 assert(CurContext &&
"Popped translation unit!");
1233 assert(CurContext &&
"skipping definition of undefined tag");
1236 S->
setEntity(CurContext->getLookupParent());
1241 CurContext =
static_cast<decltype(CurContext)
>(Context);
1264 assert(!S->
getEntity() &&
"scope already has entity");
1268 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1269 assert(Ancestor->getEntity() == CurContext &&
"ancestor context mismatch");
1277 assert(S->
getEntity() == CurContext &&
"Context imbalance!");
1282 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1299 "The next DeclContext should be lexically contained in the current one.");
1303 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1308 IdResolver.AddDecl(Param);
1316 assert(CurContext &&
"DeclContext imbalance!");
1317 CurContext = CurContext->getLexicalParent();
1318 assert(CurContext &&
"Popped translation unit!");
1341 New->
hasAttr<OverloadableAttr>());
1356 CurContext->addDecl(D);
1367 if (isa<FunctionDecl>(D) &&
1368 cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
1373 IEnd = IdResolver.end();
1374 for (; I != IEnd; ++I) {
1377 IdResolver.RemoveDecl(*I);
1386 if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) {
1390 for (I = IdResolver.begin(D->
getDeclName()); I != IEnd; ++I) {
1392 if (IDC == CurContext) {
1395 }
else if (IDC->
Encloses(CurContext))
1399 IdResolver.InsertDeclAfter(I, D);
1401 IdResolver.AddDecl(D);
1406 if (IdResolver.tryAddTopLevelDecl(D, Name) && TUScope)
1407 TUScope->AddDecl(D);
1411 bool AllowInlineNamespace) {
1412 return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace);
1419 if (ScopeDC->getPrimaryContext() == TargetDC)
1433 bool ConsiderLinkage,
1434 bool AllowInlineNamespace) {
1439 if (isDeclInScope(D, Ctx, S, AllowInlineNamespace))
1461 makeMergedDefinitionVisible(New);
1473 if (NewIsModuleInterface || OldIsModuleInterface) {
1479 << NewIsModuleInterface
1481 << OldIsModuleInterface
1492 return isa<UsingShadowDecl>(D) ||
1493 isa<UnresolvedUsingTypenameDecl>(D) ||
1494 isa<UnresolvedUsingValueDecl>(D);
1521 return CD->isCopyConstructor();
1522 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
1523 return Method->isCopyAssignmentOperator();
1539 bool Sema::mightHaveNonExternalLinkage(
const DeclaratorDecl *D) {
1542 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1543 if (!RD->hasNameForLinkage())
1572 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1578 FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
1581 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1586 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1590 if (FD->doesThisDeclarationHaveABody() &&
1593 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1603 if (VD->isStaticDataMember() &&
1606 if (VD->isStaticDataMember() &&
1608 VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
1611 if (VD->isInline() && !
isMainFileLoc(*
this, VD->getLocation()))
1620 return mightHaveNonExternalLinkage(D);
1627 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1629 if (FD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1633 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1635 if (VD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1639 if (ShouldWarnIfUnusedFileScopedDecl(D))
1640 UnusedFileScopedDecls.push_back(D);
1647 bool Referenced =
false;
1648 if (
auto *DD = dyn_cast<DecompositionDecl>(D)) {
1652 for (
auto *BD : DD->bindings()) {
1653 if (BD->isReferenced()) {
1664 if (Referenced || D->
hasAttr<UnusedAttr>() ||
1665 D->
hasAttr<ObjCPreciseLifetimeAttr>())
1668 if (isa<LabelDecl>(D))
1674 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->
getDeclContext()))
1677 WithinFunction || (R->isLocalClass() && !R->isDependentType());
1678 if (!WithinFunction)
1681 if (isa<TypedefNameDecl>(D))
1685 if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D))
1689 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1692 const auto *Ty = VD->getType().getTypePtr();
1696 if (TT->getDecl()->hasAttr<UnusedAttr>())
1702 if (Ty->isIncompleteType() || Ty->isDependentType())
1707 Ty = Ty->getBaseElementTypeUnsafe();
1710 const TagDecl *Tag = TT->getDecl();
1711 if (Tag->
hasAttr<UnusedAttr>())
1714 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) {
1715 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
1718 if (
const Expr *Init = VD->getInit()) {
1720 dyn_cast<ExprWithCleanups>(Init))
1721 Init = Cleanups->getSubExpr();
1726 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
1727 (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
1742 if (isa<LabelDecl>(D)) {
1756 for (
auto *TmpD : D->
decls()) {
1757 if (
const auto *
T = dyn_cast<TypedefNameDecl>(TmpD))
1758 DiagnoseUnusedDecl(
T);
1759 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
1760 DiagnoseUnusedNestedTypedefs(R);
1770 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1773 UnusedLocalTypedefNameCandidates.insert(TD);
1781 if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
1782 DiagID = diag::warn_unused_exception_param;
1783 else if (isa<LabelDecl>(D))
1784 DiagID = diag::warn_unused_label;
1786 DiagID = diag::warn_unused_variable;
1796 bool Diagnose =
false;
1800 Diagnose = L->
getStmt() ==
nullptr;
1810 "Scope shouldn't contain decls!");
1812 for (
auto *TmpD : S->
decls()) {
1813 assert(TmpD &&
"This decl didn't get pushed??");
1815 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
1820 DiagnoseUnusedDecl(D);
1821 if (
const auto *RD = dyn_cast<RecordDecl>(D))
1822 DiagnoseUnusedNestedTypedefs(RD);
1828 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
1833 IdResolver.RemoveDecl(D);
1834 auto ShadowI = ShadowingDecls.find(D);
1835 if (ShadowI != ShadowingDecls.end()) {
1836 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
1838 << D << FD << FD->getParent();
1839 Diag(FD->getLocation(), diag::note_previous_declaration);
1841 ShadowingDecls.erase(ShadowI);
1861 bool DoTypoCorrection) {
1864 NamedDecl *IDecl = LookupSingleName(TUScope, Id, IdLoc, LookupOrdinaryName);
1866 if (!IDecl && DoTypoCorrection) {
1872 CTK_ErrorRecovery)) {
1873 diagnoseTypo(C, PDiag(diag::err_undef_interface_suggest) << Id);
1922 if (!II->
isStr(
"objc_msgSendSuper"))
1943 return "ucontext.h";
1945 llvm_unreachable(
"unhandled error kind");
1953 Scope *S,
bool ForRedeclaration,
1960 if (ForRedeclaration)
1961 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
1966 if (!ForRedeclaration &&
1969 Diag(Loc, diag::ext_implicit_lib_function_decl)
1972 !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc))
1973 Diag(Loc, diag::note_include_header_or_declare)
1987 Parent->
addDecl(CLinkageDecl);
1988 Parent = CLinkageDecl;
1993 Loc, Loc, II, R,
nullptr,
2003 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2006 nullptr, FT->getParamType(i),
nullptr,
2009 Params.push_back(parm);
2011 New->setParams(Params);
2014 AddKnownFunctionAttributes(New);
2015 RegisterLocallyScopedExternCDecl(New, S);
2023 PushOnScopeChains(New, TUScope);
2024 CurContext = SavedContext;
2040 if (Previous.
empty())
2053 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2060 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2074 OldType = OldTypedef->getUnderlyingType();
2081 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2082 Diag(New->
getLocation(), diag::err_redefinition_variably_modified_typedef)
2090 if (OldType != NewType &&
2094 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2096 << Kind << NewType << OldType;
2118 if (getLangOpts().ObjC1) {
2124 if (!TypeID->
isStr(
"id"))
2140 if (!TypeID->
isStr(
"Class"))
2147 if (!TypeID->
isStr(
"SEL"))
2174 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2175 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2178 if (OldTag && NewTag &&
2179 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
2180 !hasVisibleDefinition(OldTag, &Hidden)) {
2184 if (OldTD->isModed())
2186 OldTD->getUnderlyingType());
2191 makeMergedDefinitionVisible(Hidden);
2195 if (isa<EnumDecl>(NewTag)) {
2196 Scope *EnumScope = getNonFieldDeclScope(S);
2197 for (
auto *D : NewTag->decls()) {
2198 auto *ED = cast<EnumConstantDecl>(D);
2201 IdResolver.RemoveDecl(ED);
2202 ED->getLexicalDeclContext()->removeDecl(ED);
2210 if (isIncompatibleTypedef(Old, New))
2217 mergeDeclAttributes(New, Old);
2220 if (getLangOpts().MicrosoftExt)
2228 if (!isa<CXXRecordDecl>(CurContext))
2252 if (!isa<TypedefNameDecl>(Old))
2262 if (getLangOpts().Modules || getLangOpts().
C11)
2269 if (getDiagnostics().getSuppressSystemWarnings() &&
2284 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2285 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2286 for (
const auto *i : D->
attrs())
2287 if (i->getKind() == A->
getKind()) {
2289 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2294 if (OA && isa<OwnershipAttr>(i))
2295 return OA->getOwnKind() == cast<OwnershipAttr>(i)->getOwnKind();
2303 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2304 return VD->isThisDeclarationADefinition();
2305 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2306 return TD->isCompleteDefinition() || TD->isBeingDefined();
2317 AlignedAttr *OldAlignasAttr =
nullptr;
2318 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2319 unsigned OldAlign = 0;
2327 if (I->isAlignmentDependent())
2333 unsigned Align = I->getAlignment(S.
Context);
2334 if (Align > OldAlign) {
2336 OldStrictestAlignAttr = I;
2341 AlignedAttr *NewAlignasAttr =
nullptr;
2342 unsigned NewAlign = 0;
2344 if (I->isAlignmentDependent())
2350 unsigned Align = I->getAlignment(S.
Context);
2351 if (Align > NewAlign)
2355 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2363 if (OldAlign == 0 || NewAlign == 0) {
2365 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2376 if (OldAlign != NewAlign) {
2377 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2380 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2395 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2399 bool AnyAdded =
false;
2402 if (OldAlign > NewAlign) {
2403 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2404 Clone->setInherited(
true);
2410 if (OldAlignasAttr && !NewAlignasAttr &&
2411 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2412 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2413 Clone->setInherited(
true);
2433 if (
const auto *AA = dyn_cast<AvailabilityAttr>(Attr))
2436 AA->getDeprecated(),
2437 AA->getObsoleted(), AA->getUnavailable(),
2438 AA->getMessage(), AA->getStrict(),
2439 AA->getReplacement(), AMK,
2440 AttrSpellingListIndex);
2441 else if (
const auto *VA = dyn_cast<VisibilityAttr>(Attr))
2443 AttrSpellingListIndex);
2444 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(Attr))
2446 AttrSpellingListIndex);
2447 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(Attr))
2449 AttrSpellingListIndex);
2450 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(Attr))
2452 AttrSpellingListIndex);
2453 else if (
const auto *FA = dyn_cast<FormatAttr>(Attr))
2455 FA->getFormatIdx(), FA->getFirstArg(),
2456 AttrSpellingListIndex);
2457 else if (
const auto *SA = dyn_cast<SectionAttr>(Attr))
2459 AttrSpellingListIndex);
2460 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(Attr))
2462 AttrSpellingListIndex,
2463 IA->getSemanticSpelling());
2464 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(Attr))
2467 AttrSpellingListIndex);
2468 else if (S.
getLangOpts().CUDA && isa<FunctionDecl>(D) &&
2469 (isa<CUDAHostAttr>(Attr) || isa<CUDADeviceAttr>(Attr) ||
2470 isa<CUDAGlobalAttr>(Attr))) {
2474 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(Attr))
2476 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(Attr))
2478 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(Attr))
2480 D, InternalLinkageA->getRange(),
2482 AttrSpellingListIndex);
2483 else if (
const auto *CommonA = dyn_cast<CommonAttr>(Attr))
2486 AttrSpellingListIndex);
2487 else if (isa<AlignedAttr>(Attr))
2491 else if ((isa<DeprecatedAttr>(Attr) || isa<UnavailableAttr>(Attr)) &&
2495 else if (
const auto *UA = dyn_cast<UuidAttr>(Attr))
2496 NewAttr = S.
mergeUuidAttr(D, UA->getRange(), AttrSpellingListIndex,
2499 NewAttr = cast<InheritableAttr>(Attr->
clone(S.
Context));
2504 if (isa<MSInheritanceAttr>(NewAttr))
2513 if (
const TagDecl *TD = dyn_cast<TagDecl>(D))
2514 return TD->getDefinition();
2515 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2521 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
2527 for (
const auto *Attribute : D->
attrs())
2528 if (Attribute->getKind() ==
Kind)
2540 if (!Def || Def == New)
2544 for (
unsigned I = 0, E = NewAttributes.size(); I != E;) {
2545 const Attr *NewAttribute = NewAttributes[I];
2547 if (isa<AliasAttr>(NewAttribute) || isa<IFuncAttr>(NewAttribute)) {
2554 NewAttributes.erase(NewAttributes.begin() + I);
2559 VarDecl *VD = cast<VarDecl>(New);
2560 unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
2562 ? diag::err_alias_after_tentative
2563 : diag::err_redefinition;
2565 if (Diag == diag::err_redefinition)
2575 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
2588 if (isa<C11NoReturnAttr>(NewAttribute)) {
2592 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
2593 if (AA->isAlignas()) {
2604 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
2606 NewAttributes.erase(NewAttributes.begin() + I);
2613 diag::warn_attribute_precede_definition);
2615 NewAttributes.erase(NewAttributes.begin() + I);
2624 UsedAttr *NewAttr = OldAttr->clone(Context);
2625 NewAttr->setInherited(
true);
2635 if (AsmLabelAttr *NewA = New->
getAttr<AsmLabelAttr>()) {
2636 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
2637 if (OldA->getLabel() != NewA->getLabel()) {
2640 Diag(OldA->getLocation(), diag::note_previous_declaration);
2642 }
else if (Old->
isUsed()) {
2646 << isa<FunctionDecl>(Old) << New->
getAttr<AsmLabelAttr>()->getRange();
2651 if (
const auto *NewAbiTagAttr = New->
getAttr<AbiTagAttr>()) {
2652 if (
const auto *OldAbiTagAttr = Old->
getAttr<AbiTagAttr>()) {
2653 for (
const auto &NewTag : NewAbiTagAttr->tags()) {
2654 if (std::find(OldAbiTagAttr->tags_begin(), OldAbiTagAttr->tags_end(),
2655 NewTag) == OldAbiTagAttr->tags_end()) {
2656 Diag(NewAbiTagAttr->getLocation(),
2657 diag::err_new_abi_tag_on_redeclaration)
2659 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
2663 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
2669 if (New->
hasAttr<SectionAttr>() && !Old->
hasAttr<SectionAttr>()) {
2670 if (
auto *VD = dyn_cast<VarDecl>(New)) {
2672 Diag(New->
getLocation(), diag::warn_attribute_section_on_redeclaration);
2690 if (isa<DeprecatedAttr>(I) ||
2691 isa<UnavailableAttr>(I) ||
2692 isa<AvailabilityAttr>(I)) {
2697 case AMK_Redeclaration:
2699 case AMK_ProtocolImplementation:
2706 if (isa<UsedAttr>(I))
2728 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
2729 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
2730 S.
Diag(CDA->getLocation(),
2731 diag::err_carries_dependency_missing_on_first_decl) << 1;
2739 diag::note_carries_dependency_missing_first_decl) << 1;
2745 bool foundAny = newDecl->
hasAttrs();
2754 cast<InheritableParamAttr>(I->clone(S.
Context));
2769 if (*Oldnullability != *Newnullability) {
2770 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
2795 struct GNUCompatibleParamWarning {
2806 if (Ctor->isDefaultConstructor())
2809 if (Ctor->isCopyConstructor())
2812 if (Ctor->isMoveConstructor())
2814 }
else if (isa<CXXDestructorDecl>(MD)) {
2827 template <
typename T>
2828 static std::pair<diag::kind, SourceLocation>
2832 if (Old->isThisDeclarationADefinition())
2833 PrevDiag = diag::note_previous_definition;
2834 else if (Old->isImplicit()) {
2835 PrevDiag = diag::note_previous_implicit_declaration;
2837 OldLocation = New->getLocation();
2839 PrevDiag = diag::note_previous_declaration;
2840 return std::make_pair(PrevDiag, OldLocation);
2848 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
2849 !LangOpts.CPlusPlus &&
2861 template <
typename T>
2875 template<
typename T>
static bool isExternC(
T *D) {
return D->isExternC(); }
2881 template<
typename ExpectedDecl>
2883 ExpectedDecl *New) {
2903 !Old->getDeclContext()->getRedeclContext()->Equals(
2904 New->getDeclContext()->getRedeclContext()) &&
2909 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
2922 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
2923 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
2926 return AttrA && AttrB && AttrA->getType() == AttrB->getType();
2929 return std::equal(A->param_begin(), A->param_end(), B->
param_begin(), AttrEq);
2944 Scope *S,
bool MergeTypeWithOld) {
2951 Diag(Shadow->getTargetDecl()->getLocation(),
2952 diag::note_using_decl_target);
2953 Diag(Shadow->getUsingDecl()->getLocation(),
2954 diag::note_using_decl) << 0;
2959 if (checkUsingShadowRedecl<FunctionDecl>(*
this, Shadow, New))
2961 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
2976 std::tie(PrevDiag, OldLocation) =
2983 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
2988 if (getLangOpts().MicrosoftExt) {
2990 Diag(OldLocation, PrevDiag);
2993 Diag(OldLocation, PrevDiag);
2998 if (New->
hasAttr<InternalLinkageAttr>() &&
2999 !Old->
hasAttr<InternalLinkageAttr>()) {
3003 New->
dropAttr<InternalLinkageAttr>();
3006 if (CheckRedeclarationModuleOwnership(New, Old))
3009 if (!getLangOpts().CPlusPlus) {
3010 bool OldOvl = Old->
hasAttr<OverloadableAttr>();
3021 const Decl *DiagOld = Old;
3023 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *D) {
3024 const auto *A = D->
getAttr<OverloadableAttr>();
3025 return A && !A->isImplicit();
3029 DiagOld = OldIter == Old->
redecls_end() ? nullptr : *OldIter;
3033 Diag(DiagOld->getLocation(),
3034 diag::note_attribute_overloadable_prev_overload)
3038 New->
addAttr(OverloadableAttr::CreateImplicit(Context));
3059 const FunctionType *OldType = cast<FunctionType>(OldQType);
3060 const FunctionType *NewType = cast<FunctionType>(NewQType);
3063 bool RequiresAdjustment =
false;
3065 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC()) {
3070 bool NewCCExplicit = getCallingConvAttributedType(New->
getType());
3071 if (!NewCCExplicit) {
3075 RequiresAdjustment =
true;
3078 bool FirstCCExplicit = getCallingConvAttributedType(First->
getType());
3082 << (!FirstCCExplicit ?
"" :
3092 if (OldTypeInfo.getNoReturn() && !NewTypeInfo.
getNoReturn()) {
3094 RequiresAdjustment =
true;
3098 if (OldTypeInfo.getHasRegParm() != NewTypeInfo.
getHasRegParm() ||
3099 OldTypeInfo.getRegParm() != NewTypeInfo.
getRegParm()) {
3102 << NewType->getRegParmType()
3104 Diag(OldLocation, diag::note_previous_declaration);
3108 NewTypeInfo = NewTypeInfo.
withRegParm(OldTypeInfo.getRegParm());
3109 RequiresAdjustment =
true;
3116 <<
"'ns_returns_retained'";
3117 Diag(OldLocation, diag::note_previous_declaration);
3122 RequiresAdjustment =
true;
3125 if (OldTypeInfo.getNoCallerSavedRegs() !=
3128 AnyX86NoCallerSavedRegistersAttr *
Attr =
3129 New->
getAttr<AnyX86NoCallerSavedRegistersAttr>();
3130 Diag(New->
getLocation(), diag::err_function_attribute_mismatch) << Attr;
3131 Diag(OldLocation, diag::note_previous_declaration);
3136 RequiresAdjustment =
true;
3139 if (RequiresAdjustment) {
3144 NewType = cast<FunctionType>(NewQType);
3150 !New->
hasAttr<GNUInlineAttr>() &&
3151 !getLangOpts().GNUInline &&
3159 if (New->
hasAttr<GNUInlineAttr>() &&
3170 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3185 if (CheckEquivalentExceptionSpec(Old, New))
3198 : OldType)->getReturnType();
3202 : NewType)->getReturnType();
3203 if (!Context.
hasSameType(OldDeclaredReturnType, NewDeclaredReturnType) &&
3212 Diag(New->
getLocation(), diag::err_member_def_does_not_match_ret_type)
3217 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
3226 QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType();
3227 if (OldReturnType != NewReturnType) {
3237 SubstAutoType(NewQType,
3245 if (OldMethod && NewMethod) {
3252 bool IsClassScopeExplicitSpecialization =
3254 NewMethod->isFunctionTemplateSpecialization();
3255 bool isFriend = NewMethod->getFriendObjectKind();
3257 if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() &&
3258 !IsClassScopeExplicitSpecialization) {
3262 if (OldMethod->
isStatic() != NewMethod->isStatic()) {
3264 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3272 if (!inTemplateInstantiation()) {
3274 if (isa<CXXConstructorDecl>(OldMethod))
3275 NewDiag = diag::err_constructor_redeclared;
3276 else if (isa<CXXDestructorDecl>(NewMethod))
3277 NewDiag = diag::err_destructor_redeclared;
3278 else if (isa<CXXConversionDecl>(NewMethod))
3279 NewDiag = diag::err_conv_function_redeclared;
3281 NewDiag = diag::err_member_redeclared;
3285 Diag(New->
getLocation(), diag::err_member_redeclared_in_instantiation)
3288 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3298 NewMethod->setImplicit();
3300 Diag(NewMethod->getLocation(),
3301 diag::err_definition_of_implicitly_declared_member)
3302 << New << getSpecialMember(OldMethod);
3306 Diag(NewMethod->getLocation(),
3307 diag::err_definition_of_explicitly_defaulted_member)
3308 << getSpecialMember(OldMethod);
3317 const CXX11NoReturnAttr *NRA = New->
getAttr<CXX11NoReturnAttr>();
3318 if (NRA && !Old->
hasAttr<CXX11NoReturnAttr>()) {
3319 Diag(NRA->getLocation(), diag::err_noreturn_missing_on_first_decl);
3321 diag::note_noreturn_missing_first_decl);
3328 const CarriesDependencyAttr *CDA = New->
getAttr<CarriesDependencyAttr>();
3329 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
3330 Diag(CDA->getLocation(),
3331 diag::err_carries_dependency_missing_on_first_decl) << 0;
3333 diag::note_carries_dependency_missing_first_decl) << 0;
3342 QualType OldQTypeForComparison = OldQType;
3343 if (!OldTypeInfo.getNoReturn() && NewTypeInfo.
getNoReturn()) {
3347 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
3348 assert(OldQTypeForComparison.isCanonical());
3362 Diag(OldLocation, PrevDiag);
3364 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3365 Diag(OldLocation, PrevDiag);
3370 if (OldQTypeForComparison == NewQType)
3371 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3386 if (!getLangOpts().CPlusPlus &&
3391 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
3395 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
3399 OldProto->getExtProtoInfo());
3405 for (
const auto &ParamType : OldProto->param_types()) {
3412 Params.push_back(Param);
3415 New->setParams(Params);
3418 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3445 NewProto->getReturnType());
3446 bool LooseCompatible = !MergedReturn.
isNull();
3448 LooseCompatible && Idx !=
End; ++Idx) {
3452 NewProto->getParamType(Idx))) {
3453 ArgTypes.push_back(NewParm->
getType());
3457 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
3458 NewProto->getParamType(Idx) };
3459 Warnings.push_back(Warn);
3460 ArgTypes.push_back(NewParm->
getType());
3462 LooseCompatible =
false;
3465 if (LooseCompatible) {
3466 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
3467 Diag(Warnings[Warn].NewParm->getLocation(),
3468 diag::ext_param_promoted_not_compatible_with_prototype)
3469 << Warnings[Warn].PromotedType
3470 << Warnings[Warn].OldParm->getType();
3471 if (Warnings[Warn].OldParm->getLocation().isValid())
3472 Diag(Warnings[Warn].OldParm->getLocation(),
3473 diag::note_previous_declaration);
3476 if (MergeTypeWithOld)
3479 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3496 Diag(OldLocation, diag::note_previous_builtin_declaration)
3513 PrevDiag = diag::note_previous_builtin_declaration;
3517 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3531 Scope *S,
bool MergeTypeWithOld) {
3533 mergeDeclAttributes(New, Old);
3546 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
3554 return MergeCXXFunctionDecl(New, Old, S);
3560 if (!Merged.
isNull() && MergeTypeWithOld)
3571 ? AMK_ProtocolImplementation
3572 : isa<ObjCImplDecl>(newMethod->
getDeclContext()) ? AMK_Redeclaration
3575 mergeDeclAttributes(newMethod, oldMethod, MergeKind);
3582 ni != ne && oi != oe; ++ni, ++oi)
3590 ? diag::err_redefinition_different_type
3591 : diag::err_redeclaration_different_type)
3596 std::tie(PrevDiag, OldLocation)
3598 S.
Diag(OldLocation, PrevDiag);
3610 bool MergeTypeWithOld) {
3615 if (getLangOpts().CPlusPlus) {
3621 return MergeVarDeclExceptionSpecs(New, Old);
3692 if (MergeTypeWithOld)
3738 if (!shouldLinkPossiblyHiddenDecl(Previous, New))
3753 if (checkUsingShadowRedecl<VarTemplateDecl>(*
this, Shadow, NewTemplate))
3760 if (checkUsingShadowRedecl<VarDecl>(*
this, Shadow, New))
3776 true, TPL_TemplateMatch))
3790 mergeDeclAttributes(New, Old);
3793 if (New->
hasAttr<WeakImportAttr>() &&
3795 !Old->
hasAttr<WeakImportAttr>()) {
3802 if (New->
hasAttr<InternalLinkageAttr>() &&
3803 !Old->
hasAttr<InternalLinkageAttr>()) {
3807 New->
dropAttr<InternalLinkageAttr>();
3812 if (MostRecent != Old) {
3813 MergeVarDeclTypes(New, MostRecent,
3825 std::tie(PrevDiag, OldLocation) =
3832 if (getLangOpts().MicrosoftExt) {
3835 Diag(OldLocation, PrevDiag);
3839 Diag(OldLocation, PrevDiag);
3858 Diag(OldLocation, PrevDiag);
3866 Diag(OldLocation, PrevDiag);
3872 Diag(OldLocation, PrevDiag);
3876 if (CheckRedeclarationModuleOwnership(New, Old))
3888 Diag(OldLocation, PrevDiag);
3898 Diag(Def->getLocation(), diag::note_previous_definition);
3912 Diag(OldLocation, PrevDiag);
3915 Diag(OldLocation, PrevDiag);
3923 Diag(OldLocation, PrevDiag);
3934 diag::warn_deprecated_redundant_constexpr_static_def);
3936 if (checkVarDeclRedefinition(Def, New))
3942 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3943 Diag(OldLocation, PrevDiag);
3972 auto &HSI = PP.getHeaderSearchInfo();
3973 StringRef HdrFilename =
3976 auto noteFromModuleOrInclude = [&](
Module *Mod,
3982 if (IncLoc.isValid()) {
3984 Diag(IncLoc, diag::note_redefinition_modules_same_file)
3990 Diag(IncLoc, diag::note_redefinition_include_same_file)
3991 << HdrFilename.str();
4001 bool EmittedDiag =
false;
4002 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
4005 EmittedDiag = noteFromModuleOrInclude(Old->
getOwningModule(), OldIncLoc);
4006 EmittedDiag |= noteFromModuleOrInclude(getCurrentModule(), NewIncLoc);
4009 if (FOld && !HSI.isFileMultipleIncludeGuarded(FOld))
4023 if (!hasVisibleDefinition(Old) &&
4035 makeMergedDefinitionVisible(OldTD);
4036 makeMergedDefinitionVisible(Old);
4071 if (isa<CXXRecordDecl>(Tag->
getParent())) {
4085 Decl *ManglingContextDecl;
4089 Tag, MCtx->getManglingNumber(
4109 if (getLangOpts().CPlusPlus)
4124 tagLoc = getLocForEndOfToken(tagLoc);
4127 textToInsert +=
' ';
4129 Diag(tagLoc, diag::note_typedef_changes_linkage)
4151 llvm_unreachable(
"unexpected type specifier");
4161 bool IsExplicitInstantiation,
4163 Decl *TagD =
nullptr;
4178 if (isa<TagDecl>(TagD))
4179 Tag = cast<TagDecl>(TagD);
4181 Tag = CTD->getTemplatedDecl();
4185 handleTagNumbering(Tag, S);
4196 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
4202 << getLangOpts().CPlusPlus17;
4216 DiagnoseFunctionSpecifiers(DS);
4223 return ActOnFriendTypeDecl(S, DS, TemplateParams);
4227 bool IsExplicitSpecialization =
4228 !TemplateParams.empty() && TemplateParams.back()->size() == 0;
4230 !IsExplicitInstantiation && !IsExplicitSpecialization &&
4231 !isa<ClassTemplatePartialSpecializationDecl>(Tag)) {
4240 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
4246 bool DeclaresAnything =
true;
4249 if (
RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
4250 if (!Record->getDeclName() && Record->isCompleteDefinition() &&
4252 if (getLangOpts().CPlusPlus ||
4253 Record->getDeclContext()->isRecord()) {
4261 if (CurContext->isFunctionOrMethod())
4262 AnonRecord = Record;
4263 return BuildAnonymousStructOrUnion(S, DS, AS, Record,
4267 DeclaresAnything =
false;
4277 if (!getLangOpts().CPlusPlus && CurContext->isRecord() &&
4293 Record = RT->getDecl();
4295 Record = UT->getDecl();
4297 if (Record && getLangOpts().MicrosoftExt) {
4300 return BuildMicrosoftCAnonymousStruct(S, DS, Record);
4303 DeclaresAnything =
false;
4312 if (getLangOpts().CPlusPlus &&
4314 if (
EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Tag))
4315 if (Enum->enumerator_begin() == Enum->enumerator_end() &&
4316 !Enum->getIdentifier() && !Enum->isInvalidDecl())
4317 DeclaresAnything =
false;
4325 DeclaresAnything =
false;
4334 ActOnDocumentableDecl(TagD);
4344 if (!DeclaresAnything) {
4359 unsigned DiagID = diag::warn_standalone_specifier;
4361 DiagID = diag::ext_standalone_specifier;
4403 Diag(attrs->getLoc(), diag::warn_declspec_attribute_ignored)
4427 assert(PrevDecl &&
"Expected a non-null Decl");
4432 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
4434 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
4459 bool Invalid =
false;
4462 for (
auto *D : AnonRecord->
decls()) {
4463 if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
4464 cast<NamedDecl>(D)->getDeclName()) {
4480 unsigned OldChainingSize = Chaining.size();
4482 Chaining.append(IF->chain_begin(), IF->chain_end());
4484 Chaining.push_back(VD);
4486 assert(Chaining.size() >= 2);
4489 for (
unsigned i = 0; i < Chaining.size(); i++)
4490 NamedChain[i] = Chaining[i];
4494 VD->
getType(), {NamedChain, Chaining.size()});
4506 Chaining.resize(OldChainingSize);
4521 "Parser allowed 'typedef' as storage class VarDecl.");
4522 switch (StorageClassSpec) {
4536 llvm_unreachable(
"unknown storage class specifier");
4542 for (
const auto *I : Record->
decls()) {
4543 const auto *FD = dyn_cast<
FieldDecl>(I);
4544 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
4545 FD = IFD->getAnonField();
4546 if (FD && FD->hasInClassInitializer())
4550 llvm_unreachable(
"couldn't find in-class initializer");
4558 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
4581 if (Record->
isUnion() && !getLangOpts().CPlusPlus && !getLangOpts().C11)
4583 else if (!Record->
isUnion() && getLangOpts().CPlusPlus)
4585 else if (!Record->
isUnion() && !getLangOpts().C11)
4590 bool Invalid =
false;
4591 if (getLangOpts().CPlusPlus) {
4592 const char *PrevSpec =
nullptr;
4599 (isa<TranslationUnitDecl>(Owner) ||
4600 (isa<NamespaceDecl>(Owner) &&
4601 cast<NamespaceDecl>(Owner)->getDeclName()))) {
4607 PrevSpec, DiagID, Policy);
4613 isa<RecordDecl>(Owner)) {
4615 diag::err_anonymous_union_with_storage_spec)
4629 << Record->
isUnion() <<
"const" 4633 diag::ext_anonymous_struct_union_qualified)
4634 << Record->
isUnion() <<
"volatile" 4638 diag::ext_anonymous_struct_union_qualified)
4639 << Record->
isUnion() <<
"restrict" 4643 diag::ext_anonymous_struct_union_qualified)
4644 << Record->
isUnion() <<
"_Atomic" 4648 diag::ext_anonymous_struct_union_qualified)
4649 << Record->
isUnion() <<
"__unaligned" 4659 for (
auto *Mem : Record->
decls()) {
4660 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
4664 assert(FD->getAccess() !=
AS_none);
4666 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
4676 if (CheckNontrivialField(FD))
4678 }
else if (Mem->isImplicit()) {
4680 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
4685 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
4686 if (!MemRecord->isAnonymousStructOrUnion() &&
4687 MemRecord->getDeclName()) {
4689 if (getLangOpts().MicrosoftExt)
4690 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
4694 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
4702 Diag(MemRecord->getLocation(),
4703 diag::ext_anonymous_record_with_anonymous_type)
4706 }
else if (isa<AccessSpecDecl>(Mem)) {
4708 }
else if (isa<StaticAssertDecl>(Mem)) {
4713 unsigned DK = diag::err_anonymous_record_bad_member;
4714 if (isa<TypeDecl>(Mem))
4715 DK = diag::err_anonymous_record_with_type;
4716 else if (isa<FunctionDecl>(Mem))
4717 DK = diag::err_anonymous_record_with_function;
4718 else if (isa<VarDecl>(Mem))
4719 DK = diag::err_anonymous_record_with_static;
4722 if (getLangOpts().MicrosoftExt &&
4723 DK == diag::err_anonymous_record_with_type)
4724 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
4727 Diag(Mem->getLocation(), DK) << Record->
isUnion();
4736 if (cast<CXXRecordDecl>(Record)->hasInClassInitializer() &&
4739 cast<CXXRecordDecl>(Record));
4744 << getLangOpts().CPlusPlus;
4751 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
4755 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
4766 FieldCollector->Add(cast<FieldDecl>(Anon));
4788 ActOnUninitializedDecl(Anon);
4804 Chain.push_back(Anon);
4809 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
4810 if (getLangOpts().
CPlusPlus && NewVD->isStaticLocal()) {
4811 Decl *ManglingContextDecl;
4813 NewVD->getDeclContext(), ManglingContextDecl)) {
4815 NewVD, MCtx->getManglingNumber(
4843 assert(Record &&
"expected a record!");
4848 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
4850 auto *ParentDecl = cast<RecordDecl>(CurContext);
4866 CurContext->addDecl(Anon);
4872 Chain.push_back(Anon);
4875 if (RequireCompleteType(Anon->
getLocation(), RecTy,
4876 diag::err_field_incomplete) ||
4880 ParentDecl->setInvalidDecl();
4889 return GetNameFromUnqualifiedId(D.
getName());
4919 if (!Template || !isa<ClassTemplateDecl>(Template)) {
4921 diag::err_deduction_guide_name_not_class_template)
4922 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
4924 Diag(Template->getLocation(), diag::note_template_decl_here);
5018 llvm_unreachable(
"Unknown name kind");
5046 for (
unsigned Idx = 0; Idx < Declaration->
param_size(); ++Idx) {
5060 (DeclTyName && DeclTyName == DefTyName))
5061 Params.push_back(Idx);
5102 if (!TSI)
return true;
5147 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer() &&
5151 if (getLangOpts().OpenCL)
5152 setCurrentOpenCLExtensionForDecl(Dcl);
5170 Record = dyn_cast<CXXRecordDecl>(Record->
getParent());
5172 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
5196 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
5210 Diag(Loc, LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
5211 : diag::err_member_extra_qualification)
5215 Diag(Loc, diag::warn_namespace_member_extra_qualification) << Name;
5224 Diag(Loc, diag::err_member_qualification)
5226 else if (isa<TranslationUnitDecl>(DC))
5227 Diag(Loc, diag::err_invalid_declarator_global_scope)
5229 else if (isa<FunctionDecl>(Cur))
5230 Diag(Loc, diag::err_invalid_declarator_in_function)
5232 else if (isa<BlockDecl>(Cur))
5233 Diag(Loc, diag::err_invalid_declarator_in_block)
5236 Diag(Loc, diag::err_invalid_declarator_scope)
5237 << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.
getRange();
5244 Diag(Loc, diag::err_member_qualification)
5264 while (SpecLoc.getPrefix())
5266 if (dyn_cast_or_null<DecltypeType>(
5267 SpecLoc.getNestedNameSpecifier()->getAsType()))
5268 Diag(Loc, diag::err_decltype_in_declarator)
5269 << SpecLoc.getTypeLoc().getSourceRange();
5283 return ActOnDecompositionDeclarator(S, D, TemplateParamLists);
5287 diag::err_declarator_need_ident)
5290 }
else if (DiagnoseUnexpandedParameterPack(NameInfo, UPPC_DeclarationType))
5304 UPPC_DeclarationQualifier))
5309 if (!DC || isa<EnumDecl>(DC)) {
5315 diag::err_template_qualified_declarator_no_match)
5322 if (!IsDependentContext &&
5327 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
5329 diag::err_member_def_undefined_record)
5345 if (EnteringContext && IsDependentContext &&
5346 TemplateParamLists.size() != 0) {
5357 UPPC_DeclarationType))
5361 forRedeclarationInCurContext());
5365 bool IsLinkageLookup =
false;
5366 bool CreateBuiltins =
false;
5377 else if (CurContext->isFunctionOrMethod() &&
5380 IsLinkageLookup =
true;
5382 CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
5383 }
else if (CurContext->getRedeclContext()->isTranslationUnit() &&
5385 CreateBuiltins =
true;
5387 if (IsLinkageLookup) {
5388 Previous.
clear(LookupRedeclarationWithLinkage);
5392 LookupName(Previous, S, CreateBuiltins);
5394 LookupQualifiedName(Previous, DC);
5436 if (!R->
isFunctionType() && DiagnoseClassNameShadow(DC, NameInfo))
5452 CheckExtraCXXDefaultArguments(D);
5456 bool AddToScope =
true;
5458 if (TemplateParamLists.size()) {
5463 New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous);
5465 New = ActOnFunctionDeclarator(S, D, DC, TInfo, Previous,
5469 New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists,
5483 PushOnScopeChains(New, S, AddToContext);
5485 CurContext->addHiddenDecl(New);
5488 if (isInOpenMPDeclareTargetContext())
5489 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
5499 bool &SizeIsNegative,
5500 llvm::APSInt &Oversized) {
5505 SizeIsNegative =
false;
5514 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
5519 if (FixedType.
isNull())
return FixedType;
5521 return Qs.
apply(Context, FixedType);
5523 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
5524 QualType Inner = PTy->getInnerType();
5528 if (FixedType.
isNull())
return FixedType;
5530 return Qs.
apply(Context, FixedType);
5546 if (Res.isSigned() && Res.isNegative()) {
5547 SizeIsNegative =
true;
5552 unsigned ActiveSizeBits
5586 TypeLoc DstElemTL = DstATL.getElementLoc();
5599 bool &SizeIsNegative,
5600 llvm::APSInt &Oversized) {
5603 SizeIsNegative, Oversized);
5630 return Result.empty() ? nullptr : *Result.begin();
5640 diag::err_virtual_non_function);
5644 diag::err_explicit_non_function);
5648 diag::err_noreturn_non_function);
5668 << getLangOpts().CPlusPlus17;
5676 diag::err_deduction_guide_invalid_specifier)
5685 if (!NewTD)
return nullptr;
5688 ProcessDeclAttributes(S, NewTD, D);
5690 CheckTypedefForVariablyModifiedType(S, NewTD);
5693 NamedDecl *ND = ActOnTypedefNameDecl(S, DC, NewTD, Previous, Redeclaration);
5707 getCurFunction()->setHasBranchProtectedScope();
5710 bool SizeIsNegative;
5711 llvm::APSInt Oversized;
5724 else if (Oversized.getBoolValue())
5726 << Oversized.toString(10);
5743 NamedDecl *ShadowedDecl = getShadowedDeclaration(NewTD, Previous);
5747 FilterLookupForScope(Previous, DC, S,
false,
5750 if (!Previous.
empty()) {
5751 Redeclaration =
true;
5752 MergeTypedefNameDecl(S, NewTD, Previous);
5755 if (ShadowedDecl && !Redeclaration)
5756 CheckShadow(NewTD, ShadowedDecl, Previous);
5762 if (II->isStr(
"FILE"))
5764 else if (II->isStr(
"jmp_buf"))
5766 else if (II->isStr(
"sigjmp_buf"))
5768 else if (II->isStr(
"ucontext_t"))
5826 if (!OuterContext->
Equals(PrevOuterContext))
5835 if (!SS.
isSet())
return;
5844 unsigned kind = -1U;
5845 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5846 if (var->hasAttr<BlocksAttr>())
5848 else if (!var->hasLocalStorage())
5850 }
else if (isa<ObjCIvarDecl>(decl)) {
5852 }
else if (isa<FieldDecl>(decl)) {
5870 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5873 var->getTLSKind()) {
5874 Diag(var->getLocation(), diag::err_arc_thread_ownership)
5895 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
5903 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
5904 if (VD->hasInit()) {
5905 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
5906 assert(VD->isThisDeclarationADefinition() &&
5907 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
5909 VD->dropAttr<AliasAttr>();
5916 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
5919 diag::err_attribute_selectany_non_extern_data);
5927 auto *VD = dyn_cast<
VarDecl>(&ND);
5937 if (
auto *MD = dyn_cast<CXXMethodDecl>(&ND))
5938 if (MD->isVirtual()) {
5940 diag::err_invalid_attribute_on_virtual_function)
5948 bool IsSpecialization,
5949 bool IsDefinition) {
5953 bool IsTemplate =
false;
5954 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
5955 OldDecl = OldTD->getTemplatedDecl();
5957 if (!IsSpecialization)
5958 IsDefinition =
false;
5960 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
5961 NewDecl = NewTD->getTemplatedDecl();
5965 if (!OldDecl || !NewDecl)
5968 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
5969 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
5970 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
5971 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
5975 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
5976 (NewExportAttr && !NewExportAttr->isInherited());
5982 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
5984 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
5986 bool JustWarn =
false;
5988 auto *VD = dyn_cast<
VarDecl>(OldDecl);
5989 if (VD && !VD->getDescribedVarTemplate())
6000 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
6003 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
6004 : diag::err_attribute_dll_redeclaration;
6007 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
6020 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
6022 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
6025 IsStaticDataMember = VD->isStaticDataMember();
6026 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
6028 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
6029 IsInline = FD->isInlined();
6030 IsQualifiedFriend = FD->getQualifier() &&
6034 if (OldImportAttr && !HasNewAttr &&
6035 (!IsInline || (IsMicrosoft && IsTemplate)) && !IsStaticDataMember &&
6037 if (IsMicrosoft && IsDefinition) {
6039 diag::warn_redeclaration_without_import_attribute)
6042 NewDecl->
dropAttr<DLLImportAttr>();
6044 NewImportAttr->getRange(), S.
Context,
6045 NewImportAttr->getSpellingListIndex()));
6048 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
6049 << NewDecl << OldImportAttr;
6051 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
6052 OldDecl->
dropAttr<DLLImportAttr>();
6053 NewDecl->
dropAttr<DLLImportAttr>();
6055 }
else if (IsInline && OldImportAttr && !IsMicrosoft) {
6058 OldDecl->
dropAttr<DLLImportAttr>();
6059 NewDecl->
dropAttr<DLLImportAttr>();
6061 diag::warn_dllimport_dropped_from_inline_function)
6062 << NewDecl << OldImportAttr;
6069 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
6071 !NewImportAttr && !NewExportAttr) {
6072 if (
const DLLExportAttr *ParentExportAttr =
6073 MD->getParent()->getAttr<DLLExportAttr>()) {
6074 DLLExportAttr *NewAttr = ParentExportAttr->clone(S.
Context);
6075 NewAttr->setInherited(
true);
6115 template<
typename T>
6119 if (!D->isInExternCContext() || D->template hasAttr<OverloadableAttr>())
6123 if (S.
getLangOpts().CUDA && (D->template hasAttr<CUDADeviceAttr>() ||
6124 D->template hasAttr<CUDAHostAttr>()))
6127 return D->isExternC();
6138 llvm_unreachable(
"Unexpected context");
6144 isa<OMPDeclareReductionDecl>(DC))
6148 llvm_unreachable(
"Unexpected context");
6154 if (L->getKind() ==
Kind)
6202 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
6203 return FD->isExternC();
6204 if (
const auto *VD = dyn_cast<VarDecl>(D))
6205 return VD->isExternC();
6207 llvm_unreachable(
"Unknown type of decl!");
6223 if (!Decomp.bindings().empty()) {
6224 II = Decomp.bindings()[0].Name;
6232 if (getLangOpts().OpenCL) {
6238 diag::err_opencl_type_can_only_be_used_as_function_parameter)
6251 diag::err_invalid_type_for_program_scope_var) << R;
6268 if (!getOpenCLOptions().
isEnabled(
"cl_khr_fp16")) {
6319 bool IsLocalExternDecl = SC ==
SC_Extern &&
6320 adjustContextForLocalExternDecl(DC);
6331 !D.
getAsmLabel() && !getSourceManager().isInSystemMacro(
6337 getLangOpts().CPlusPlus17 ? diag::ext_register_storage_class
6338 : diag::warn_deprecated_register)
6354 bool IsMemberSpecialization =
false;
6355 bool IsVariableTemplateSpecialization =
false;
6357 bool IsVariableTemplate =
false;
6366 if (R->getContainedDeducedType())
6367 ParsingInitForAutoVars.insert(NewVD);
6372 bool Invalid =
false;
6374 if (DC->
isRecord() && !CurContext->isRecord()) {
6381 diag::err_static_out_of_line)
6393 diag::err_storage_class_for_static_member)
6397 llvm_unreachable(
"C storage class in c++!");
6401 if (SC ==
SC_Static && CurContext->isRecord()) {
6402 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
6403 if (RD->isLocalClass())
6405 diag::err_static_data_member_not_allowed_in_local_class)
6406 << Name << RD->getDeclName();
6412 getLangOpts().CPlusPlus11
6413 ? diag::warn_cxx98_compat_static_data_member_in_union
6414 : diag::ext_static_data_member_in_union) << Name;
6416 else if (!RD->getDeclName())
6418 diag::err_static_data_member_not_allowed_in_anon_struct)
6419 << Name << RD->isUnion();
6425 TemplateParams = MatchTemplateParametersToScopeSpecifier(
6432 false, IsMemberSpecialization, Invalid);
6434 if (TemplateParams) {
6435 if (!TemplateParams->
size() &&
6440 diag::err_template_variable_noparams)
6444 TemplateParams =
nullptr;
6449 IsVariableTemplateSpecialization =
true;
6450 IsPartialSpecialization = TemplateParams->
size() > 0;
6453 IsVariableTemplate =
true;
6456 if (CheckTemplateDeclScope(S, TemplateParams))
6461 getLangOpts().CPlusPlus14
6462 ? diag::warn_cxx11_compat_variable_template
6463 : diag::ext_variable_template);
6469 "should have a 'template<>' for this decl");
6472 if (IsVariableTemplateSpecialization) {
6474 TemplateParamLists.size() > 0
6475 ? TemplateParamLists[0]->getTemplateLoc()
6477 DeclResult Res = ActOnVarTemplateSpecialization(
6478 S, D, TInfo, TemplateKWLoc, TemplateParams, SC,
6479 IsPartialSpecialization);
6482 NewVD = cast<VarDecl>(Res.
get());
6493 if (IsVariableTemplate) {
6496 TemplateParams, NewVD);
6497 NewVD->setDescribedVarTemplate(NewTemplate);
6502 if (R->getContainedDeducedType())
6503 ParsingInitForAutoVars.insert(NewVD);
6515 unsigned VDTemplateParamLists = TemplateParams ? 1 : 0;
6516 if (TemplateParamLists.size() > VDTemplateParamLists)
6517 NewVD->setTemplateParameterListsInfo(
6518 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
6521 NewVD->setConstexpr(
true);
6525 if (NewVD->isStaticDataMember() && getLangOpts().CPlusPlus17)
6526 NewVD->setImplicitlyInline();
6531 if (!getLangOpts().CPlusPlus) {
6534 }
else if (CurContext->isFunctionOrMethod()) {
6537 diag::err_inline_declaration_block_scope) << Name
6541 getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_inline_variable
6542 : diag::ext_inline_variable);
6553 if (IsLocalExternDecl) {
6555 for (
auto *B : Bindings)
6556 B->setLocalExternDecl();
6561 bool EmitTLSUnsupportedError =
false;
6574 diag::err_thread_non_global)
6577 if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
6581 EmitTLSUnsupportedError =
true;
6588 diag::err_thread_unsupported);
6607 diag::warn_static_local_in_extern_inline);
6608 MaybeSuggestAddingStaticToDecl(CurFD);
6613 if (IsVariableTemplateSpecialization)
6615 << (IsPartialSpecialization ? 1 : 0)
6618 else if (IsMemberSpecialization)
6631 for (
auto *B : Bindings)
6632 B->setModulePrivate();
6637 ProcessDeclAttributes(S, NewVD, D);
6639 if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
6640 if (EmitTLSUnsupportedError &&
6642 (getLangOpts().OpenMPIsDevice &&
6643 NewVD->
hasAttr<OMPDeclareTargetDeclAttr>())))
6645 diag::err_thread_unsupported);
6649 (NewVD->
hasAttr<CUDASharedAttr>() ||
6650 NewVD->
hasAttr<CUDAConstantAttr>())) {
6658 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
6659 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
6664 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewVD))
6676 Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
6682 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6693 bool HasSizeMismatch;
6695 if (!TI.isValidGCCRegisterName(Label))
6696 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6697 else if (!TI.validateGlobalRegisterVariable(Label,
6700 Diag(E->getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
6701 else if (HasSizeMismatch)
6702 Diag(E->getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
6712 Context,
Label, 0));
6713 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
6714 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
6716 if (I != ExtnameUndeclaredIdentifiers.end()) {
6719 ExtnameUndeclaredIdentifiers.erase(I);
6728 ? getShadowedDeclaration(NewVD, Previous)
6736 IsMemberSpecialization ||
6737 IsVariableTemplateSpecialization);
6741 if (getLangOpts().CPlusPlus &&
6745 isDeclInScope(Previous.
getFoundDecl(), OriginalDC, S,
false));
6747 if (!getLangOpts().CPlusPlus) {
6752 CheckMemberSpecialization(NewVD, Previous))
6756 if (!Previous.
empty()) {
6775 if (!IsVariableTemplateSpecialization)
6787 if (CheckTemplateParameterList(
6793 ? TPC_ClassTemplateMember
6799 if (PrevVarTemplate &&
6807 CheckShadow(NewVD, ShadowedDecl, Previous);
6809 ProcessPragmaWeak(S, NewVD);
6815 RegisterLocallyScopedExternCDecl(NewVD, S);
6818 Decl *ManglingContextDecl;
6822 NewVD, MCtx->getManglingNumber(
6835 if (getLangOpts().CPlusPlus)
6853 ActOnDocumentableDecl(NewTemplate);
6858 CompleteMemberSpecialization(NewVD, Previous);
6876 if (isa<TypeAliasDecl>(ShadowedDecl))
6878 else if (isa<TypedefDecl>(ShadowedDecl))
6880 else if (isa<RecordDecl>(OldDC))
6890 for (
const LambdaScopeInfo::Capture &Capture : LSI->
Captures) {
6891 if (Capture.isVariableCapture() && Capture.getVariable() == VD)
6892 return Capture.getLocation();
6919 return isa<VarDecl>(ShadowedDecl) || isa<FieldDecl>(ShadowedDecl)
6936 return isa<TypedefNameDecl>(ShadowedDecl) ? ShadowedDecl :
nullptr;
6952 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
6960 if (isa<CXXConstructorDecl>(NewDC))
6961 if (
const auto PVD = dyn_cast<ParmVarDecl>(D)) {
6964 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
6969 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
6970 if (shadowedVar->isExternC()) {
6973 for (
auto I : shadowedVar->redecls())
6974 if (I->isFileVarDecl()) {
6982 unsigned WarningDiag = diag::warn_decl_shadow;
6984 if (isa<VarDecl>(D) && isa<VarDecl>(ShadowedDecl) && NewDC &&
6985 isa<CXXMethodDecl>(NewDC)) {
6986 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
6988 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
6990 const auto *LSI = cast<LambdaScopeInfo>(getCurFunction());
6993 if (CaptureLoc.isInvalid())
6994 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
6998 cast<LambdaScopeInfo>(getCurFunction())
6999 ->ShadowingDecls.push_back(
7000 {cast<VarDecl>(D), cast<VarDecl>(ShadowedDecl)});
7005 if (cast<VarDecl>(ShadowedDecl)->hasLocalStorage()) {
7009 ParentDC && !ParentDC->
Equals(OldDC);
7013 if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) &&
7040 if (getSourceManager().isInSystemMacro(R.
getNameLoc()))
7045 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7054 const VarDecl *ShadowedDecl = Shadow.ShadowedDecl;
7059 ? diag::warn_decl_shadow_uncaptured_local
7060 : diag::warn_decl_shadow)
7061 << Shadow.VD->getDeclName()
7064 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7065 << Shadow.VD->getDeclName() << 0;
7072 if (Diags.isIgnored(diag::warn_decl_shadow, D->
getLocation()))
7078 if (
NamedDecl *ShadowedDecl = getShadowedDeclaration(D, R))
7079 CheckShadow(D, ShadowedDecl, R);
7086 if (!getLangOpts().
CPlusPlus || ShadowingDecls.empty())
7092 const NamedDecl *D = cast<NamedDecl>(DRE->getDecl()->getCanonicalDecl());
7093 auto I = ShadowingDecls.find(D);
7094 if (I == ShadowingDecls.end())
7096 const NamedDecl *ShadowedDecl = I->second;
7098 Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
7103 ShadowingDecls.erase(I);
7108 template<
typename T>
7111 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
7132 if (!isa<VarDecl>(ND))
7142 if (isa<VarDecl>(*I)) {
7152 if (isa<VarDecl>(*I)) {
7170 assert(Prev &&
"should have found a previous declaration to diagnose");
7172 Prev = FD->getFirstDecl();
7174 Prev = cast<VarDecl>(Prev)->getFirstDecl();
7176 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
7178 S.
Diag(Prev->getLocation(), diag::note_extern_c_global_conflict)
7191 template<
typename T>
7198 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
7210 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
7236 CheckAlignasUnderalignment(NewVD);
7258 if (getLangOpts().OpenCLVersion == 120 &&
7259 !getOpenCLOptions().
isEnabled(
"cl_clang_storage_class_specifiers") &&
7266 if (getLangOpts().OpenCL) {
7268 if (NewVD->
hasAttr<BlocksAttr>()) {
7277 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
7283 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
7298 getLangOpts().OpenCLVersion == 200))) {
7300 if (getLangOpts().OpenCLVersion == 200)
7301 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7302 << Scope <<
"global or constant";
7304 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7305 << Scope <<
"constant";
7321 if (FD && !FD->
hasAttr<OpenCLKernelAttr>()) {
7333 if (FD && FD->
hasAttr<OpenCLKernelAttr>()) {
7334 if (!getCurScope()->isFunctionScope()) {
7355 && !NewVD->
hasAttr<BlocksAttr>()) {
7359 assert(!getLangOpts().ObjCAutoRefCount);
7365 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
7367 getCurFunction()->setHasBranchProtectedScope();
7371 bool SizeIsNegative;
7372 llvm::APSInt Oversized;
7375 SizeIsNegative, Oversized);
7426 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
7434 diag::err_constexpr_var_non_literal)) {
7453 CheckVariableDeclarationType(NewVD);
7461 if (Previous.
empty() &&
7465 if (!Previous.
empty()) {
7466 MergeVarDecl(NewVD, Previous);
7473 struct FindOverriddenMethod {
7499 if (MD->isVirtual() && !S->
IsOverload(Method, MD,
false))
7524 if ((OEK == OEK_All) ||
7525 (OEK == OEK_NonDeleted && !O->isDeleted()) ||
7526 (OEK == OEK_Deleted && O->isDeleted()))
7527 S.
Diag(O->getLocation(), diag::note_overridden_virtual_function);
7536 FindOverriddenMethod FOM;
7539 bool hasDeletedOverridenMethods =
false;
7540 bool hasNonDeletedOverridenMethods =
false;
7541 bool AddedAny =
false;
7546 if (!CheckOverridingFunctionReturnType(MD, OldMD) &&
7547 !CheckOverridingFunctionAttributes(MD, OldMD) &&
7548 !CheckOverridingFunctionExceptionSpec(MD, OldMD) &&
7549 !CheckIfOverriddenFunctionIsMarkedFinal(MD, OldMD)) {
7550 hasDeletedOverridenMethods |= OldMD->isDeleted();
7551 hasNonDeletedOverridenMethods |= !OldMD->isDeleted();
7558 if (hasDeletedOverridenMethods && !MD->
isDeleted()) {
7559 ReportOverrides(*
this, diag::err_non_deleted_override, MD, OEK_Deleted);
7561 if (hasNonDeletedOverridenMethods && MD->
isDeleted()) {
7562 ReportOverrides(*
this, diag::err_deleted_override, MD, OEK_NonDeleted);
7571 struct ActOnFDArgs {
7587 : Context(Context), OriginalFD(TypoFD),
7590 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
7596 CDeclEnd = candidate.
end();
7597 CDecl != CDeclEnd; ++CDecl) {
7606 }
else if (!ExpectedParent) {
7624 TypoCorrectedFunctionDefinitions.insert(F);
7638 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *S) {
7644 bool IsDefinition = ExtraArgs.D.isFunctionDefinition();
7645 unsigned DiagMsg = IsLocalFriend ? diag::err_no_matching_local_friend
7646 : diag::err_member_decl_does_not_match;
7657 assert(!Prev.isAmbiguous() &&
7658 "Cannot have an ambiguity in previous-declaration lookup");
7660 if (!Prev.empty()) {
7662 Func != FuncEnd; ++Func) {
7669 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
7670 NearMatches.push_back(std::make_pair(FD, ParamNum));
7675 Prev.getLookupNameInfo(), Prev.getLookupKind(), S,
7676 &ExtraArgs.D.getCXXScopeSpec(),
7677 llvm::make_unique<DifferentNameValidatorCCC>(
7682 ExtraArgs.D.getIdentifierLoc());
7686 CDeclEnd = Correction.
end();
7687 CDecl != CDeclEnd; ++CDecl) {
7694 bool wasRedeclaration = ExtraArgs.D.isRedeclaration();
7707 ExtraArgs.S, ExtraArgs.D,
7710 ExtraArgs.AddToScope);
7721 if ((*I)->getCanonicalDecl() == Canonical)
7728 SemaRef.
PDiag(IsLocalFriend
7729 ? diag::err_no_matching_local_friend_suggest
7730 : diag::err_member_decl_does_not_match_suggest)
7731 << Name << NewDC << IsDefinition);
7737 ExtraArgs.D.getIdentifierLoc());
7738 ExtraArgs.D.setRedeclaration(wasRedeclaration);
7744 << Name << NewDC << IsDefinition << NewFD->
getLocation();
7746 bool NewFDisConst =
false;
7748 NewFDisConst = NewMD->isConst();
7751 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
7752 NearMatch != NearMatchEnd; ++NearMatch) {
7755 bool FDisConst = MD && MD->
isConst();
7756 bool IsMember = MD || !IsLocalFriend;
7759 if (
unsigned Idx = NearMatch->second) {
7763 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
7764 : diag::note_local_decl_close_param_match)
7767 }
else if (FDisConst != NewFDisConst) {
7768 SemaRef.
Diag(FD->
getLocation(), diag::note_member_def_close_const_match)
7772 IsMember ? diag::note_member_def_close_match
7773 : diag::note_local_decl_close_match);
7780 default: llvm_unreachable(
"Unknown storage class!");
7785 diag::err_typecheck_sclass_func);
7802 diag::err_static_block_func);
7818 bool &IsVirtualOkay) {
7838 TInfo, SC, isInline,
7839 HasPrototype,
false);
7861 "Constructors can only be declared in a member context");
7866 R, TInfo, isExplicit, isInline,
7878 NameInfo, R, TInfo, isInline,
7890 IsVirtualOkay =
true;
7909 diag::err_conv_function_not_member);
7914 IsVirtualOkay =
true;
7917 R, TInfo, isInline, isExplicit,
7924 isExplicit, NameInfo, R, TInfo,
7941 cast<CXXRecordDecl>(DC),
7943 TInfo, SC, isInline,
7958 NameInfo, R, TInfo, SC, isInline,
8009 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
8067 HistoryStack.push_back(
nullptr);
8070 VisitStack.push_back(PD);
8072 assert(VisitStack.back() &&
"First decl null?");
8075 const Decl *Next = VisitStack.pop_back_val();
8077 assert(!HistoryStack.empty());
8079 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
8080 ValidTypes.insert(Hist->getType().getTypePtr());
8088 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(Next)) {
8089 HistoryStack.push_back(Field);
8090 RD = Field->getType()->castAs<
RecordType>()->getDecl();
8092 RD = cast<RecordDecl>(Next);
8096 VisitStack.push_back(
nullptr);
8098 for (
const auto *FD : RD->
fields()) {
8109 VisitStack.push_back(FD);
8120 diag::err_record_with_pointers_kernel_param)
8133 I = HistoryStack.begin() + 1,
8134 E = HistoryStack.end();
8141 S.
Diag(FD->getLocation(), diag::note_illegal_field_declared_here)
8147 }
while (!VisitStack.empty());
8164 (LangOpts.CPlusPlus &&
8188 diag::err_invalid_thread)
8195 bool isFriend =
false;
8197 bool isMemberSpecialization =
false;
8198 bool isFunctionTemplateSpecialization =
false;
8200 bool isDependentClassScopeExplicitSpecialization =
false;
8201 bool HasExplicitTemplateArgs =
false;
8204 bool isVirtualOkay =
false;
8207 bool IsLocalExternDecl = adjustContextForLocalExternDecl(DC);
8211 if (!NewFD)
return nullptr;
8213 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer())
8221 if (IsLocalExternDecl)
8242 if (
Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
8247 if (isVirtual &&
Parent->isUnion())
8252 isMemberSpecialization =
false;
8253 isFunctionTemplateSpecialization =
false;
8259 bool Invalid =
false;
8261 MatchTemplateParametersToScopeSpecifier(
8267 TemplateParamLists, isFriend, isMemberSpecialization,
8269 if (TemplateParams->size() > 0) {
8273 if (CheckTemplateDeclScope(S, TemplateParams))
8287 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
8293 Name, TemplateParams,
8299 if (TemplateParamLists.size() > 1) {
8301 TemplateParamLists.drop_back(1));
8305 isFunctionTemplateSpecialization =
true;
8307 if (TemplateParamLists.size() > 0)
8313 SourceRange RemoveRange = TemplateParams->getSourceRange();
8323 InsertLoc = getLocForEndOfToken(InsertLoc);
8327 << Name << RemoveRange
8336 if (TemplateParamLists.size() > 0)
8343 if (FunctionTemplate)
8353 if (!isVirtualOkay) {
8355 diag::err_virtual_non_function);
8356 }
else if (!CurContext->isRecord()) {
8359 diag::err_virtual_out_of_class)
8365 diag::err_virtual_member_function_template)
8377 if (getLangOpts().CPlusPlus14 &&
8379 (isFriend && CurContext->isDependentContext())) &&
8399 if (CurContext->isFunctionOrMethod()) {
8402 diag::err_inline_declaration_block_scope) << Name
8412 !isa<CXXDeductionGuideDecl>(NewFD)) {
8413 if (!CurContext->isRecord()) {
8416 diag::err_explicit_out_of_class)
8418 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
8419 !isa<CXXConversionDecl>(NewFD)) {
8423 diag::err_explicit_non_ctor_or_conv_function)
8436 if (isa<CXXDestructorDecl>(NewFD))
8442 if (isFunctionTemplateSpecialization) {
8445 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
8450 if (FunctionTemplate)
8456 if (FunctionTemplate) {
8481 if (isa<CXXMethodDecl>(NewFD) && DC == CurContext &&
8489 if (SC ==
SC_Static && isa<CXXMethodDecl>(NewFD) &&
8490 !CurContext->isRecord()) {
8499 diag::err_static_out_of_line)
8509 getLangOpts().CPlusPlus11 && FPT && !FPT->hasExceptionSpec())
8511 FPT->getReturnType(), FPT->getParamTypes(),
8518 isMemberSpecialization ||
8519 isFunctionTemplateSpecialization);
8527 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
8528 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
8530 if (I != ExtnameUndeclaredIdentifiers.end()) {
8533 ExtnameUndeclaredIdentifiers.erase(I);
8553 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
8557 Params.push_back(Param);
8572 auto *TD = dyn_cast<
TagDecl>(NonParmDecl);
8577 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
8578 TD = cast<EnumDecl>(ECD->getDeclContext());
8586 TD->setDeclContext(NewFD);
8594 if (TagDC != PrototypeTagContext)
8595 TD->setLexicalDeclContext(TagDC);
8609 for (
const auto &AI : FT->param_types()) {
8613 Params.push_back(Param);
8617 "Should not need args for typedef of non-prototype fn");
8621 NewFD->setParams(Params);
8638 !NewFD->
hasAttr<SectionAttr>()) {
8639 NewFD->
addAttr(PragmaClangTextSectionAttr::CreateImplicit(Context,
8640 PragmaClangTextSection.SectionName,
8641 PragmaClangTextSection.PragmaLocation));
8646 !NewFD->
hasAttr<SectionAttr>()) {
8648 SectionAttr::CreateImplicit(Context, SectionAttr::Declspec_allocate,
8649 CodeSegStack.CurrentValue->getString(),
8650 CodeSegStack.CurrentPragmaLocation));
8651 if (UnifySection(CodeSegStack.CurrentValue->getString(),
8659 ProcessDeclAttributes(S, NewFD, D);
8661 if (getLangOpts().OpenCL) {
8667 diag::err_opencl_return_value_with_address_space);
8678 CheckMSVCRTEntryPoint(NewFD);
8682 isMemberSpecialization));
8683 else if (!Previous.
empty())
8688 "previous declaration set still overloaded");
8700 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
8717 diag::ext_operator_new_delete_declared_inline)
8728 translateTemplateArguments(TemplateArgsPtr,
8731 HasExplicitTemplateArgs =
true;
8734 HasExplicitTemplateArgs =
false;
8735 }
else if (FunctionTemplate) {
8740 HasExplicitTemplateArgs =
false;
8742 assert((isFunctionTemplateSpecialization ||
8744 "should have a 'template<>' for this decl");
8746 isFunctionTemplateSpecialization =
true;
8748 }
else if (isFriend && isFunctionTemplateSpecialization) {
8755 HasExplicitTemplateArgs =
true;
8766 if (getLangOpts().CUDA & !isFunctionTemplateSpecialization)
8767 maybeAddCUDAHostDeviceAttrs(NewFD, Previous);
8773 bool InstantiationDependent =
false;
8774 if (isFunctionTemplateSpecialization && isFriend &&
8778 InstantiationDependent))) {
8779 assert(HasExplicitTemplateArgs &&
8780 "friend function specialization without template args");
8781 if (CheckDependentFunctionTemplateSpecialization(NewFD, TemplateArgs,
8784 }
else if (isFunctionTemplateSpecialization) {
8785 if (CurContext->isDependentContext() && CurContext->isRecord()
8787 isDependentClassScopeExplicitSpecialization =
true;
8789 diag::ext_function_specialization_in_class :
8790 diag::err_function_specialization_in_class)
8793 CheckFunctionTemplateSpecialization(
8794 NewFD, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr),
8806 diag::err_explicit_specialization_inconsistent_storage_class)
8813 diag::ext_explicit_specialization_storage_class)
8817 }
else if (isMemberSpecialization && isa<CXXMethodDecl>(NewFD)) {
8818 if (CheckMemberSpecialization(NewFD, Previous))
8823 if (!isDependentClassScopeExplicitSpecialization) {
8828 CheckMSVCRTEntryPoint(NewFD);
8832 isMemberSpecialization));
8833 else if (!Previous.
empty())
8840 "previous declaration set still overloaded");
8842 NamedDecl *PrincipalDecl = (FunctionTemplate
8843 ? cast<NamedDecl>(FunctionTemplate)
8852 if (FunctionTemplate) FunctionTemplate->
setAccess(Access);
8861 if (FunctionTemplate) {
8869 ? TPC_FriendFunctionTemplateDefinition
8870 : TPC_FriendFunctionTemplate)
8874 ? TPC_ClassTemplateMember
8875 : TPC_FunctionTemplate);
8881 struct ActOnFDArgs ExtraArgs = { S, D, TemplateParamLists,
8899 (TemplateParamLists.size() ||
8901 CurContext->isDependentContext())) {
8920 *
this, Previous, NewFD, ExtraArgs,
false,
nullptr)) {
8921 AddToScope = ExtraArgs.AddToScope;
8928 }
else if (isFriend && cast<CXXRecordDecl>(CurContext)->isLocalClass()) {
8930 *
this, Previous, NewFD, ExtraArgs,
true, S)) {
8931 AddToScope = ExtraArgs.AddToScope;
8936 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
8937 !isFriend && !isFunctionTemplateSpecialization &&
8938 !isMemberSpecialization) {
8951 ProcessPragmaWeak(S, NewFD);
8954 AddKnownFunctionAttributes(NewFD);
8956 if (NewFD->
hasAttr<OverloadableAttr>() &&
8959 diag::err_attribute_overloadable_no_prototype)
8967 EPI.ExtInfo = FT->getExtInfo();
8976 AddPushedVisibilityAttribute(NewFD);
8980 AddCFAuditedAttribute(NewFD);
8985 AddRangeBasedOptnone(NewFD);
8991 RegisterLocallyScopedExternCDecl(NewFD, S);
8999 isMemberSpecialization || isFunctionTemplateSpecialization,
9003 if (getLangOpts().CUDA) {
9016 if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->
isVariadic() &&
9017 (NewFD->
hasAttr<CUDADeviceAttr>() ||
9018 NewFD->
hasAttr<CUDAGlobalAttr>()) &&
9025 MarkUnusedFileScopedDecl(NewFD);
9028 if (FunctionTemplate) {
9031 return FunctionTemplate;
9035 CompleteMemberSpecialization(NewFD, Previous);
9038 if (NewFD->
hasAttr<OpenCLKernelAttr>()) {
9040 if ((getLangOpts().OpenCLVersion >= 120)
9055 llvm::SmallPtrSet<const Type *, 16> ValidTypes;
9064 if (getLangOpts().OpenCLVersion >= 200) {
9066 QualType ElemTy = PipeTy->getElementType();
9068 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type );
9078 if (isDependentClassScopeExplicitSpecialization) {
9082 cast<CXXMethodDecl>(NewFD),
9083 HasExplicitTemplateArgs, TemplateArgs);
9084 CurContext->addDecl(NewSpec);
9136 bool IsMemberSpecialization) {
9138 "Variably modified return types are not handled here");
9143 bool MergeTypeWithPrevious = !getLangOpts().CPlusPlus &&
9146 bool Redeclaration =
false;
9148 bool MayNeedOverloadableChecks =
false;
9152 if (!Previous.
empty()) {
9159 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
9160 Redeclaration =
true;
9161 OldDecl = Candidate;
9164 MayNeedOverloadableChecks =
true;
9165 switch (CheckOverload(S, NewFD, Previous, OldDecl,
9168 Redeclaration =
true;
9171 case Ovl_NonFunction:
9172 Redeclaration =
true;
9176 Redeclaration =
false;
9183 if (!Redeclaration &&
9185 if (!Previous.
empty()) {
9188 Redeclaration =
true;
9190 MergeTypeWithPrevious =
false;
9193 if (OldDecl->
hasAttr<OverloadableAttr>() ||
9194 NewFD->
hasAttr<OverloadableAttr>()) {
9195 if (IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
9196 MayNeedOverloadableChecks =
true;
9197 Redeclaration =
false;
9214 if (!getLangOpts().CPlusPlus14 && MD && MD->
isConstexpr() &&
9215 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
9219 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
9220 if (!OldMD || !OldMD->
isStatic()) {
9230 if (!inTemplateInstantiation()) {
9234 AddConstLoc = getLocForEndOfToken(FTL.getRParenLoc());
9242 if (Redeclaration) {
9245 if (MergeFunctionDecl(NewFD, OldDecl, S, MergeTypeWithPrevious)) {
9247 return Redeclaration;
9254 = dyn_cast<FunctionTemplateDecl>(OldDecl)) {
9258 assert(NewTemplateDecl &&
"Template/non-template mismatch");
9261 Method->setAccess(OldTemplateDecl->getAccess());
9262 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
9267 if (IsMemberSpecialization &&
9270 assert(OldTemplateDecl->isMemberSpecialization());
9273 if (OldTemplateDecl->getTemplatedDecl()->isDeleted()) {
9275 OldTemplateDecl->getTemplatedDecl();
9284 if (shouldLinkDependentDeclWithPrevious(NewFD, OldDecl)) {
9287 if (isa<CXXMethodDecl>(NewFD))
9291 }
else if (!getLangOpts().CPlusPlus && MayNeedOverloadableChecks &&
9292 !NewFD->
getAttr<OverloadableAttr>()) {
9293 assert((Previous.
empty() ||
9294 llvm::any_of(Previous,
9296 return ND->
hasAttr<OverloadableAttr>();
9298 "Non-redecls shouldn't happen without overloadable present");
9300 auto OtherUnmarkedIter = llvm::find_if(Previous, [](
const NamedDecl *ND) {
9302 return FD && !FD->
hasAttr<OverloadableAttr>();
9305 if (OtherUnmarkedIter != Previous.
end()) {
9307 diag::err_attribute_overloadable_multiple_unmarked_overloads);
9308 Diag((*OtherUnmarkedIter)->getLocation(),
9309 diag::note_attribute_overloadable_prev_overload)
9312 NewFD->
addAttr(OverloadableAttr::CreateImplicit(Context));
9321 CheckConstructor(Constructor);
9323 dyn_cast<CXXDestructorDecl>(NewFD)) {
9336 return Redeclaration;
9340 = dyn_cast<CXXConversionDecl>(NewFD)) {
9341 ActOnConversionDeclarator(Conversion);
9342 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
9343 if (
auto *TD = Guide->getDescribedFunctionTemplate())
9344 CheckDeductionGuideTemplate(TD);
9349 Diag(Guide->getLocStart(), diag::err_deduction_guide_specialized)
9354 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
9355 if (!Method->isFunctionTemplateSpecialization() &&
9356 !Method->getDescribedFunctionTemplate() &&
9357 Method->isCanonicalDecl()) {
9358 if (AddOverriddenMethods(Method->getParent(), Method)) {
9366 if (Method->isStatic())
9367 checkThisInStaticMemberFunctionType(Method);
9372 CheckOverloadedOperatorDeclaration(NewFD)) {
9374 return Redeclaration;
9379 CheckLiteralOperatorDeclaration(NewFD)) {
9381 return Redeclaration;
9387 if (!CurContext->isRecord())
9388 CheckCXXDefaultArguments(NewFD);
9419 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
9432 auto HasNoexcept = [&](
QualType T) ->
bool {
9443 if (FPT->isNothrow(Context))
9449 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
9451 AnyNoexcept |= HasNoexcept(
T);
9454 diag::warn_cxx17_compat_exception_spec_in_signature)
9458 if (!Redeclaration && LangOpts.CUDA)
9459 checkCUDATargetOverload(NewFD, Previous);
9461 return Redeclaration;
9474 ? diag::err_static_main : diag::warn_static_main)
9481 SourceRange NoreturnRange(NoreturnLoc, getLocForEndOfToken(NoreturnLoc));
9482 Diag(NoreturnLoc, diag::ext_noreturn_main);
9483 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
9492 if (getLangOpts().
OpenCL) {
9494 << FD->
hasAttr<OpenCLKernelAttr>();
9500 assert(T->
isFunctionType() &&
"function decl is not of function type");
9504 if (FT->getCallConv() !=
CC_C) {
9510 if (getLangOpts().GNUMode && !getLangOpts().CPlusPlus) {
9521 if (RTRange.isValid())
9522 Diag(RTRange.getBegin(), diag::note_main_change_return_type)
9544 if (isa<FunctionNoProtoType>(FT))
return;
9550 bool HasExtraParameters = (nparams > 3);
9562 HasExtraParameters =
false;
9564 if (HasExtraParameters) {
9577 for (
unsigned i = 0; i < nparams; ++i) {
9580 bool mismatch =
true;
9584 else if (Expected[i] == CharPP) {
9597 mismatch = !qs.
empty();
9602 Diag(FD->
getLocation(), diag::err_main_arg_wrong) << i << Expected[i];
9620 assert(T->
isFunctionType() &&
"function decl is not of function type");
9625 if (FT->getReturnType()->isIntegralOrEnumerationType() ||
9626 FT->getReturnType()->isAnyPointerType() ||
9627 FT->getReturnType()->isNullPtrType())
9629 if (FD->
getName() !=
"DllMain")
9647 const Expr *Culprit;
9658 class SelfReferenceChecker
9664 bool isReferenceType;
9673 S(S), OrigDecl(OrigDecl) {
9675 isRecordType =
false;
9676 isReferenceType =
false;
9678 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
9679 isPODType = VD->getType().isPODType(S.
Context);
9680 isRecordType = VD->getType()->isRecordType();
9681 isReferenceType = VD->getType()->isReferenceType();
9688 void CheckExpr(
Expr *E) {
9697 InitFieldIndex.push_back(0);
9698 for (
auto Child : InitList->
children()) {
9699 CheckExpr(cast<Expr>(Child));
9700 ++InitFieldIndex.back();
9702 InitFieldIndex.pop_back();
9707 bool CheckInitListMemberExpr(
MemberExpr *E,
bool CheckReference) {
9710 bool ReferenceField =
false;
9713 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
9717 Fields.push_back(FD);
9719 ReferenceField =
true;
9725 if (!DRE || DRE->
getDecl() != OrigDecl)
9729 if (CheckReference && !ReferenceField)
9734 for (
const FieldDecl *I : llvm::reverse(Fields))
9735 UsedFieldIndex.push_back(I->getFieldIndex());
9740 for (
auto UsedIter = UsedFieldIndex.begin(),
9741 UsedEnd = UsedFieldIndex.end(),
9742 OrigIter = InitFieldIndex.begin(),
9743 OrigEnd = InitFieldIndex.end();
9744 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
9745 if (*UsedIter < *OrigIter)
9747 if (*UsedIter > *OrigIter)
9752 HandleDeclRefExpr(DRE);
9759 void HandleValue(
Expr *E) {
9761 if (
DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
9762 HandleDeclRefExpr(DRE);
9767 Visit(CO->getCond());
9768 HandleValue(CO->getTrueExpr());
9769 HandleValue(CO->getFalseExpr());
9774 dyn_cast<BinaryConditionalOperator>(E)) {
9775 Visit(BCO->getCond());
9776 HandleValue(BCO->getFalseExpr());
9781 HandleValue(OVE->getSourceExpr());
9786 if (BO->getOpcode() == BO_Comma) {
9787 Visit(BO->getLHS());
9788 HandleValue(BO->getRHS());
9793 if (isa<MemberExpr>(E)) {
9795 if (CheckInitListMemberExpr(cast<MemberExpr>(E),
9801 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
9803 if (!isa<FieldDecl>(ME->getMemberDecl()))
9807 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base))
9808 HandleDeclRefExpr(DRE);
9818 if (isReferenceType)
9819 HandleDeclRefExpr(E);
9828 Inherited::VisitImplicitCastExpr(E);
9833 if (CheckInitListMemberExpr(E,
true ))
9843 bool Warn = (MD && !MD->
isStatic());
9845 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
9846 if (!isa<FieldDecl>(ME->getMemberDecl()))
9851 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
9853 HandleDeclRefExpr(DRE);
9865 if (isa<UnresolvedLookupExpr>(Callee))
9866 return Inherited::VisitCXXOperatorCallExpr(E);
9870 HandleValue(Arg->IgnoreParenImpCasts());
9875 if (E->
getOpcode() == UO_AddrOf && isRecordType &&
9887 Inherited::VisitUnaryOperator(E);
9895 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
9896 if (ILE->getNumInits() == 1)
9897 ArgExpr = ILE->getInit(0);
9899 if (ICE->getCastKind() == CK_NoOp)
9900 ArgExpr = ICE->getSubExpr();
9901 HandleValue(ArgExpr);
9904 Inherited::VisitCXXConstructExpr(E);
9910 HandleValue(E->
getArg(0));
9914 Inherited::VisitCallExpr(E);
9919 HandleValue(E->
getLHS());
9924 Inherited::VisitBinaryOperator(E);
9937 if (OrigDecl != ReferenceDecl)
return;
9939 if (isReferenceType) {
9940 diag = diag::warn_uninit_self_reference_in_reference_init;
9941 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
9942 diag = diag::warn_static_self_reference_in_init;
9943 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
9946 diag = diag::warn_uninit_self_reference_in_init;
9961 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *E,
9965 if (isa<ParmVarDecl>(OrigDecl))
9972 if (!DirectInit && !cast<VarDecl>(OrigDecl)->getType()->
isRecordType())
9974 if (ICE->getCastKind() == CK_LValueToRValue)
9975 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
9976 if (DRE->getDecl() == OrigDecl)
9979 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
9986 struct VarDeclOrName {
9992 return VN.VDecl ? Diag << VN.VDecl : Diag << VN.Name;
10002 bool IsInitCapture = !VDecl;
10004 "init captures are expected to be deduced prior to initialization");
10006 VarDeclOrName VN{VDecl, Name};
10009 assert(Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
10013 assert(VDecl &&
"no init for init capture deduction?");
10021 if (
auto *PL = dyn_cast_or_null<ParenListExpr>(Init))
10022 DeduceInits = PL->exprs();
10025 if (isa<DeducedTemplateSpecializationType>(Deduced)) {
10026 assert(VDecl &&
"non-auto type for init capture deduction?");
10032 return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind,
10037 if (
auto *IL = dyn_cast<InitListExpr>(Init))
10038 DeduceInits = IL->inits();
10042 if (DeduceInits.empty()) {
10046 ? diag::err_init_capture_no_expression
10047 : diag::err_auto_var_init_no_expression)
10048 << VN << Type << Range;
10052 if (DeduceInits.size() > 1) {
10053 Diag(DeduceInits[1]->getLocStart(),
10054 IsInitCapture ? diag::err_init_capture_multiple_expressions
10055 : diag::err_auto_var_init_multiple_expressions)
10056 << VN << Type << Range;
10060 Expr *DeduceInit = DeduceInits[0];
10061 if (DirectInit && isa<InitListExpr>(DeduceInit)) {
10063 ? diag::err_init_capture_paren_braces
10064 : diag::err_auto_var_init_paren_braces)
10065 << isa<InitListExpr>(Init) << VN << Type << Range;
10070 bool DefaultedAnyToId =
false;
10071 if (getLangOpts().DebuggerCastResultToId &&
10077 Init = Result.
get();
10078 DefaultedAnyToId =
true;
10084 if (VDecl && isa<DecompositionDecl>(VDecl) &&
10091 if (DeduceAutoType(TSI, DeduceInit, DeducedType) == DAR_Failed) {
10092 if (!IsInitCapture)
10093 DiagnoseAutoDeductionFailure(VDecl, DeduceInit);
10094 else if (isa<InitListExpr>(Init))
10096 diag::err_init_capture_deduction_failure_from_init_list)
10102 Diag(Range.
getBegin(), diag::err_init_capture_deduction_failure)
10114 if (!inTemplateInstantiation() && !DefaultedAnyToId && !IsInitCapture &&
10117 Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
10120 return DeducedType;
10128 if (DeducedType.
isNull()) {
10137 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(VDecl))
10145 MergeVarDeclTypes(VDecl, Old,
false);
10149 CheckVariableDeclarationType(VDecl);
10160 CorrectDelayedTyposInExpr(Init, dyn_cast_or_null<VarDecl>(RealDecl));
10164 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
10166 Diag(Method->getLocation(), diag::err_member_function_initialization)
10168 Method->setInvalidDecl();
10174 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
10185 ExprResult Res = CorrectDelayedTyposInExpr(Init, VDecl);
10192 if (DeduceVariableDeclarationType(VDecl, DirectInit, Init))
10198 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
10216 BaseDeclType = Array->getElementType();
10217 if (RequireCompleteType(VDecl->
getLocation(), BaseDeclType,
10218 diag::err_typecheck_decl_incomplete_type)) {
10225 diag::err_abstract_type_in_decl,
10226 AbstractVariableType))
10237 checkVarDeclRedefinition(Def, VDecl))
10240 if (getLangOpts().CPlusPlus) {
10254 Diag(Init->
getExprLoc(), diag::err_static_data_member_reinitialization)
10257 diag::note_previous_initializer)
10263 getCurFunction()->setHasBranchProtectedScope();
10265 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer)) {
10292 Init = Result.
get();
10308 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
10310 Args[Idx], VDecl, [
this, Entity, Kind](
Expr *E) {
10316 }
else if (Res.
get() != Args[Idx]) {
10317 Args[Idx] = Res.
get();
10340 CheckSelfReference(*
this, RealDecl, Init, DirectInit);
10353 if (VDecl->
hasAttr<BlocksAttr>())
10354 checkRetainCycles(VDecl, Init);
10365 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
10367 getCurFunction()->markSafeWeakUse(Init);
10388 Init = Result.
get();
10401 CheckForConstantInitializer(Init, DclT);
10410 CheckForConstantInitializer(Init, DclT);
10417 isa<InitListExpr>(Init)) {
10418 const Expr *Culprit;
10421 diag::ext_aggregate_init_not_constant)
10477 Diag(Loc, diag::ext_in_class_initializer_non_constant)
10482 Diag(Loc, diag::err_in_class_initializer_non_constant)
10491 if (getLangOpts().CPlusPlus11) {
10493 diag::ext_in_class_initializer_float_type_cxx11)
10496 diag::note_in_class_initializer_float_type_cxx11)
10499 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
10503 Diag(Init->
getExprLoc(), diag::err_in_class_initializer_non_constant)
10511 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
10530 ((!getLangOpts().CPlusPlus && !VDecl->
hasAttr<SelectAnyAttr>()) ||
10532 !(getLangOpts().CPlusPlus && VDecl->
isExternC()) &&
10538 CheckForConstantInitializer(Init, DclT);
10555 if (CXXDirectInit) {
10556 assert(DirectInit &&
"Call-style initializer must be direct init.");
10558 }
else if (DirectInit) {
10563 CheckCompleteVariableDeclaration(VDecl);
10578 if (
auto *DD = dyn_cast<DecompositionDecl>(D))
10579 for (
auto *BD : DD->bindings())
10583 if (ParsingInitForAutoVars.count(D)) {
10594 diag::err_typecheck_decl_incomplete_type)) {
10600 if (RequireNonAbstractType(VD->
getLocation(), Ty,
10601 diag::err_abstract_type_in_decl,
10602 AbstractVariableType)) {
10616 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
10620 if (isa<DecompositionDecl>(RealDecl)) {
10621 Diag(Var->getLocation(), diag::err_decomp_decl_requires_init) << Var;
10622 Var->setInvalidDecl();
10627 DeduceVariableDeclarationType(Var,
false,
nullptr))
10636 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
10637 !Var->isThisDeclarationADemotedDefinition()) {
10638 if (Var->isStaticDataMember()) {
10641 if (!getLangOpts().CPlusPlus17) {
10642 Diag(Var->getLocation(),
10643 diag::err_constexpr_static_mem_var_requires_init)
10644 << Var->getDeclName();
10645 Var->setInvalidDecl();
10649 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
10650 Var->setInvalidDecl();
10657 if (!Var->isInvalidDecl() &&
10659 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
10660 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
10661 Var->setInvalidDecl();
10665 switch (Var->isThisDeclarationADefinition()) {
10667 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
10683 !Var->hasLinkage() && !Var->isInvalidDecl() &&
10684 RequireCompleteType(Var->getLocation(), Type,
10685 diag::err_typecheck_decl_incomplete_type))
10686 Var->setInvalidDecl();
10690 RequireNonAbstractType(Var->getLocation(), Type,
10691 diag::err_abstract_type_in_decl,
10692 AbstractVariableType))
10693 Var->setInvalidDecl();
10696 Diag(Var->getLocation(), diag::warn_private_extern);
10697 Diag(Var->getLocation(), diag::note_private_extern);
10708 if (!Var->isInvalidDecl()) {
10711 if (RequireCompleteType(Var->getLocation(),
10712 ArrayT->getElementType(),
10713 diag::err_illegal_decl_array_incomplete_type))
10714 Var->setInvalidDecl();
10715 }
else if (Var->getStorageClass() ==
SC_Static) {
10725 if (Var->isFirstDecl())
10726 RequireCompleteType(Var->getLocation(), Type,
10727 diag::ext_typecheck_decl_incomplete_type);
10732 if (!Var->isInvalidDecl())
10733 TentativeDefinitions.push_back(Var);
10740 Diag(Var->getLocation(),
10741 diag::err_typecheck_incomplete_array_needs_initializer);
10742 Var->setInvalidDecl();
10749 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
10750 << Var->getDeclName()
10751 <<
SourceRange(Var->getLocation(), Var->getLocation());
10752 Var->setInvalidDecl();
10761 if (Var->isInvalidDecl())
10764 if (!Var->hasAttr<AliasAttr>()) {
10765 if (RequireCompleteType(Var->getLocation(),
10767 diag::err_typecheck_decl_incomplete_type)) {
10768 Var->setInvalidDecl();
10776 if (RequireNonAbstractType(Var->getLocation(), Type,
10777 diag::err_abstract_type_in_decl,
10778 AbstractVariableType)) {
10779 Var->setInvalidDecl();
10793 if (getLangOpts().
CPlusPlus && Var->hasLocalStorage()) {
10796 CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl());
10800 if (!CXXRecord->
isPOD())
10801 getCurFunction()->setHasBranchProtectedScope();
10824 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, None);
10826 Var->setInvalidDecl();
10827 else if (Init.
get()) {
10828 Var->setInit(MaybeCreateExprWithCleanups(Init.
get()));
10833 CheckCompleteVariableDeclaration(Var);
10891 const char *PrevSpec;
10894 getPrintingPolicy());
10902 EmptyAttrs, IdentLoc);
10903 Decl *Var = ActOnDeclarator(S, D);
10904 cast<VarDecl>(Var)->setCXXForRangeDecl(
true);
10905 FinalizeDeclaration(Var);
10906 return ActOnDeclStmt(FinalizeDeclaratorGroup(S, DS, Var), IdentLoc,
10907 AttrEnd.
isValid() ? AttrEnd : IdentLoc);
10913 if (getLangOpts().OpenCL) {
10927 if (getLangOpts().ObjC1 &&
10937 getCurFunction()->setHasBranchProtectedScope();
10950 !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
10958 Diag(var->
getLocation(), diag::warn_missing_variable_declarations) << var;
10963 const Expr *CacheCulprit;
10964 auto checkConstInit = [&]()
mutable {
10965 if (!CacheHasConstInit)
10968 return *CacheHasConstInit;
10977 if (getLangOpts().CPlusPlus11)
10979 }
else if (getLangOpts().CPlusPlus && var->
hasInit()) {
10980 if (!checkConstInit()) {
10996 !inTemplateInstantiation()) {
11000 Stack = &ConstSegStack;
11002 Stack = &BSSSegStack;
11005 Stack = &DataSegStack;
11009 var->
addAttr(SectionAttr::CreateImplicit(
11010 Context, SectionAttr::Declspec_allocate,
11013 if (
const SectionAttr *SA = var->
getAttr<SectionAttr>())
11014 if (UnifySection(SA->getName(), SectionFlags, var))
11020 if (CurInitSeg && var->
getInit())
11021 var->
addAttr(InitSegAttr::CreateImplicit(Context, CurInitSeg->getString(),
11026 if (!getLangOpts().CPlusPlus) {
11034 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
11035 CheckCompleteDecompositionDeclaration(DD);
11041 if (var->
hasAttr<BlocksAttr>()) {
11049 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
11053 = PerformMoveOrCopyInitialization(
11055 var, var->
getType(), varRef,
true);
11057 result = MaybeCreateExprWithCleanups(result);
11075 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
11076 diag::note_invalid_subexpr_in_const_expr) {
11077 DiagLoc = Notes[0].first;
11080 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
11082 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
11083 Diag(Notes[I].first, Notes[I].second);
11095 var->
hasAttr<RequireConstantInitAttr>()) {
11097 bool DiagErr = getLangOpts().CPlusPlus11
11100 auto attr = var->
getAttr<RequireConstantInitAttr>();
11103 Diag(attr->getLocation(), diag::note_declared_required_constant_init_here)
11104 << attr->getRange();
11109 for (
auto &it : Notes)
11110 Diag(it.first, it.second);
11113 diag::note_invalid_subexpr_in_const_expr)
11119 !getDiagnostics().isIgnored(diag::warn_global_constructor,
11126 if (!checkConstInit())
11148 if (I->isAlignmentDependent())
11157 ParsingInitForAutoVars.erase(ThisDecl);
11159 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
11165 !inTemplateInstantiation() && !VD->
hasAttr<SectionAttr>()) {
11166 if (PragmaClangBSSSection.Valid)
11167 VD->
addAttr(PragmaClangBSSSectionAttr::CreateImplicit(Context,
11168 PragmaClangBSSSection.SectionName,
11169 PragmaClangBSSSection.PragmaLocation));
11170 if (PragmaClangDataSection.Valid)
11171 VD->
addAttr(PragmaClangDataSectionAttr::CreateImplicit(Context,
11172 PragmaClangDataSection.SectionName,
11173 PragmaClangDataSection.PragmaLocation));
11174 if (PragmaClangRodataSection.Valid)
11175 VD->
addAttr(PragmaClangRodataSectionAttr::CreateImplicit(Context,
11176 PragmaClangRodataSection.SectionName,
11177 PragmaClangRodataSection.PragmaLocation));
11180 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
11181 for (
auto *BD : DD->bindings()) {
11182 FinalizeDeclaration(BD);
11210 auto *NewAttr = cast<InheritableAttr>(A->clone(getASTContext()));
11211 NewAttr->setInherited(
true);
11217 if (getLangOpts().CUDA && !VD->
hasAttr<CUDASharedAttr>() &&
11219 diag::err_device_static_local_var)
11220 << CurrentCUDATarget())
11230 if (getLangOpts().CUDA) {
11233 if (VD->
hasAttr<CUDADeviceAttr>() || VD->
hasAttr<CUDAConstantAttr>() ||
11234 VD->
hasAttr<CUDASharedAttr>()) {
11236 bool AllowedInit =
false;
11239 isEmptyCudaConstructor(VD->
getLocation(), CE->getConstructor());
11243 if (!AllowedInit &&
11244 (VD->
hasAttr<CUDADeviceAttr>() || VD->
hasAttr<CUDAConstantAttr>()))
11252 isEmptyCudaDestructor(VD->
getLocation(), RD->getDestructor());
11254 if (!AllowedInit) {
11256 ? diag::err_shared_var_init
11257 : diag::err_dynamic_var_init)
11266 InitFn = CE->getConstructor();
11267 }
else if (
const CallExpr *CE = dyn_cast<CallExpr>(Init)) {
11268 InitFn = CE->getDirectCallee();
11272 if (InitFnTarget != CFT_Host && InitFnTarget != CFT_HostDevice) {
11274 << InitFnTarget << InitFn;
11287 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
11294 bool IsClassTemplateMember =
11295 isa<ClassTemplatePartialSpecializationDecl>(Context) ||
11299 IsClassTemplateMember
11300 ? diag::warn_attribute_dllimport_static_field_definition
11301 : diag::err_attribute_dllimport_static_field_definition);
11302 Diag(IA->getLocation(), diag::note_attribute);
11303 if (!IsClassTemplateMember)
11335 AddPushedVisibilityAttribute(VD);
11338 if (VD->
isFileVarDecl() && !isa<VarTemplatePartialSpecializationDecl>(VD))
11339 MarkUnusedFileScopedDecl(VD);
11343 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
11347 for (
const auto *I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
11349 if (!MagicValueExpr) {
11352 llvm::APSInt MagicValueInt;
11354 Diag(I->getRange().getBegin(),
11355 diag::err_type_tag_for_datatype_not_ice)
11359 if (MagicValueInt.getActiveBits() > 64) {
11360 Diag(I->getRange().getBegin(),
11361 diag::err_type_tag_for_datatype_too_large)
11365 uint64_t MagicValue = MagicValueInt.getZExtValue();
11366 RegisterTypeTagForDatatype(I->getArgumentKind(),
11368 I->getMatchingCType(),
11369 I->getLayoutCompatible(),
11370 I->getMustBeNull());
11375 auto *VD = dyn_cast<
VarDecl>(DD);
11388 bool DiagnosedMultipleDecomps =
false;
11390 bool DiagnosedNonDeducedAuto =
false;
11392 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
11393 if (
Decl *D = Group[i]) {
11396 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
11397 if (!FirstDeclaratorInGroup)
11398 FirstDeclaratorInGroup = DD;
11399 if (!FirstDecompDeclaratorInGroup)
11403 FirstNonDeducedAutoInGroup = DD;
11405 if (FirstDeclaratorInGroup != DD) {
11408 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
11410 diag::err_decomp_decl_not_alone)
11412 << DD->getSourceRange();
11413 DiagnosedMultipleDecomps =
true;
11419 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
11421 diag::err_auto_non_deduced_not_alone)
11422 << FirstNonDeducedAutoInGroup->
getType()
11425 << DD->getSourceRange();
11426 DiagnosedNonDeducedAuto =
true;
11431 Decls.push_back(D);
11437 handleTagNumbering(Tag, S);
11438 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
11439 getLangOpts().CPlusPlus)
11444 return BuildDeclaratorGroup(Decls);
11454 if (Group.size() > 1) {
11456 VarDecl *DeducedDecl =
nullptr;
11457 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
11468 auto *AT = dyn_cast<
AutoType>(DT);
11470 diag::err_auto_different_deductions)
11471 << (AT ? (
unsigned)AT->getKeyword() : 3)
11482 ActOnDocumentableDecls(Group);
11484 return DeclGroupPtrTy::make(
11489 ActOnDocumentableDecls(D);
11494 if (Group.empty() || !Group[0])
11497 if (Diags.isIgnored(diag::warn_doc_param_not_found,
11498 Group[0]->getLocation()) &&
11499 Diags.isIgnored(diag::warn_unknown_comment_command_name,
11500 Group[0]->getLocation()))
11503 if (Group.size() >= 2) {
11511 Decl *MaybeTagDecl = Group[0];
11512 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
11513 Group = Group.slice(1);
11519 if (!Comments.empty() &&
11520 !Comments.back()->isAttached()) {
11528 for (
unsigned i = 0, e = Group.size(); i != e; ++i)
11546 if (getLangOpts().CPlusPlus11) {
11548 getLangOpts().CPlusPlus17 ? diag::ext_register_storage_class
11549 : diag::warn_deprecated_register)
11552 }
else if (getLangOpts().CPlusPlus &&
11557 diag::err_invalid_storage_class_in_func_decl);
11566 << getLangOpts().CPlusPlus17;
11571 DiagnoseFunctionSpecifiers(DS);
11579 CheckExtraCXXDefaultArguments(D);
11595 << GetNameForDeclarator(D).getName();
11603 ForVisibleRedeclaration);
11605 if (R.isSingleResult()) {
11606 NamedDecl *PrevDecl = R.getFoundDecl();
11611 PrevDecl =
nullptr;
11630 parmDeclType, TInfo,
11644 IdResolver.AddDecl(New);
11646 ProcessDeclAttributes(S, New, D);
11654 if (New->
hasAttr<BlocksAttr>()) {
11678 if (inTemplateInstantiation())
11684 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
11692 if (LangOpts.NumLargeByValueCopy == 0)
11699 if (Size > LangOpts.NumLargeByValueCopy)
11711 if (Size > LangOpts.NumLargeByValueCopy)
11722 if (getLangOpts().ObjCAutoRefCount &&
11735 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
11746 TSInfo, SC,
nullptr);
11751 if (!CurContext->isRecord() &&
11752 RequireNonAbstractType(NameLoc, T, diag::err_abstract_type_in_decl,
11753 AbstractParamType))
11762 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
11775 !(getLangOpts().OpenCL &&
11777 Diag(NameLoc, diag::err_arg_with_address_space);
11791 for (
int i = FTI.
NumParams; i != 0; ) {
11795 llvm::raw_svector_ostream(Code)
11805 const char* PrevSpec;
11814 FTI.
Params[i].
Param = ActOnParamDeclarator(S, ParamD);
11824 assert(getCurFunctionDecl() ==
nullptr &&
"Function parsing confused");
11829 Decl *DP = HandleDeclarator(ParentScope, D, TemplateParameterLists);
11830 return ActOnStartOfFunctionDef(FnBodyScope, DP, SkipBody);
11834 Consumer.HandleInlineFunctionDefinition(D);
11848 if (isa<CXXMethodDecl>(FD))
11868 if (FD->
hasAttr<OpenCLKernelAttr>())
11875 bool MissingPrototype =
true;
11880 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
11883 MissingPrototype = !Prev->getType()->isFunctionProtoType();
11885 PossibleZeroParamPrototype = Prev;
11889 return MissingPrototype;
11906 if (TypoCorrectedFunctionDefinitions.count(Definition))
11911 if (SkipBody && !hasVisibleDefinition(Definition) &&
11918 makeMergedDefinitionVisible(TD);
11919 makeMergedDefinitionVisible(const_cast<FunctionDecl*>(Definition));
11940 LSI->
Lambda = LambdaClass;
11958 for (
const auto &C : LambdaClass->
captures()) {
11959 if (C.capturesVariable()) {
11960 VarDecl *VD = C.getCapturedVar();
11964 const bool ByRef = C.getCaptureKind() ==
LCK_ByRef;
11966 true, C.getLocation(),
11967 C.isPackExpansion()
11969 CaptureType,
nullptr);
11971 }
else if (C.capturesThis()) {
11989 FD = FunTmpl->getTemplatedDecl();
11991 FD = cast<FunctionDecl>(D);
11994 if (
const auto *
Attr = FD->
getAttr<AliasAttr>()) {
11999 if (
const auto *
Attr = FD->
getAttr<IFuncAttr>()) {
12008 CheckForFunctionRedefinition(FD,
nullptr, SkipBody);
12030 assert(inTemplateInstantiation() &&
12031 "There should be an active template instantiation on the stack " 12032 "when instantiating a generic lambda!");
12036 PushFunctionScope();
12053 RequireCompleteType(FD->
getLocation(), ResultType,
12054 diag::err_func_def_incomplete_result))
12058 PushDeclContext(FnBodyScope, FD);
12068 auto *NonParmDecl = dyn_cast<
NamedDecl>(NPD);
12071 assert(!isa<ParmVarDecl>(NonParmDecl) &&
12072 "parameters should not be in newly created FD yet");
12075 if (NonParmDecl->getDeclName())
12076 PushOnScopeChains(NonParmDecl, FnBodyScope,
false);
12080 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
12081 for (
auto *EI : ED->enumerators())
12082 PushOnScopeChains(EI, FnBodyScope,
false);
12089 Param->setOwningFunction(FD);
12092 if (Param->getIdentifier() && FnBodyScope) {
12093 CheckShadow(FnBodyScope, Param);
12095 PushOnScopeChains(Param, FnBodyScope);
12106 assert(!FD->
hasAttr<DLLExportAttr>());
12107 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
12113 ActOnDocumentableDecl(D);
12114 if (getCurLexicalContext()->isObjCContainer() &&
12115 getCurLexicalContext()->getDeclKind() != Decl::ObjCCategoryImpl &&
12116 getCurLexicalContext()->getDeclKind() != Decl::ObjCImplementation)
12137 for (
unsigned I = 0, E = Scope->
Returns.size(); I != E; ++I) {
12138 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
12139 if (!NRVOCandidate->isNRVOVariable())
12140 Returns[I]->setNRVOCandidate(
nullptr);
12158 Outer.Fun.hasTrailingReturnType()) {
12159 QualType Ty = GetTypeFromParser(Outer.Fun.getTrailingReturnType());
12176 if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
12178 return Consumer.shouldSkipFunctionBody(D);
12185 FD->setHasSkippedBody();
12187 MD->setHasSkippedBody();
12192 return ActOnFinishFunctionBody(D, BodyArg,
false);
12196 bool IsInstantiation) {
12202 if (getLangOpts().CoroutinesTS && getCurFunction()->isCoroutine())
12203 CheckCompletedCoroutineBody(FD, Body);
12221 TypeLoc ResultType = getReturnTypeLoc(FD);
12229 auto *LSI = getCurLambda();
12230 if (LSI->HasImplicitReturnType) {
12231 deduceClosureReturnType(*LSI);
12237 LSI->ReturnType.isNull() ? Context.
VoidTy : LSI->ReturnType;
12261 DiagnoseSizeOfParametersAndReturnValue(FD->
parameters(),
12266 MarkVTableUsed(FD->
getLocation(), Constructor->getParent());
12268 MarkVTableUsed(FD->
getLocation(), Destructor->getParent());
12275 computeNRVO(Body, getCurFunction());
12283 const FunctionDecl *PossibleZeroParamPrototype =
nullptr;
12287 if (PossibleZeroParamPrototype) {
12292 TypeLoc TL = TI->getTypeLoc();
12295 diag::note_declaration_not_a_prototype)
12296 << PossibleZeroParamPrototype
12309 !LangOpts.CPlusPlus) {
12317 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
12319 if (MD->isOutOfLine() && (MD = MD->getCanonicalDecl()) &&
12332 if (KeyFunction && KeyFunction->
isDefined(Definition))
12333 MarkVTableUsed(Definition->
getLocation(), MD->getParent(),
true);
12336 MarkVTableUsed(FD->
getLocation(), MD->getParent(),
true);
12341 assert((FD == getCurFunctionDecl() || getCurLambda()->CallOperator == FD) &&
12342 "Function parsing confused");
12343 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
12344 assert(MD == getCurMethodDecl() &&
"Method parsing confused");
12346 if (!MD->isInvalidDecl()) {
12347 DiagnoseUnusedParameters(MD->parameters());
12348 DiagnoseSizeOfParametersAndReturnValue(MD->parameters(),
12349 MD->getReturnType(), MD);
12352 computeNRVO(Body, getCurFunction());
12354 if (getCurFunction()->ObjCShouldCallSuper) {
12355 Diag(MD->getLocEnd(), diag::warn_objc_missing_super_call)
12356 << MD->getSelector().getAsString();
12357 getCurFunction()->ObjCShouldCallSuper =
false;
12359 if (getCurFunction()->ObjCWarnForNoDesignatedInitChain) {
12361 bool isDesignated =
12363 assert(isDesignated && InitMethod);
12364 (void)isDesignated;
12367 auto IFace = MD->getClassInterface();
12370 auto SuperD = IFace->getSuperClass();
12373 return SuperD->getIdentifier() ==
12378 if (!MD->isUnavailable() && !superIsNSObject(MD)) {
12379 Diag(MD->getLocation(),
12380 diag::warn_objc_designated_init_missing_super_call);
12382 diag::note_objc_designated_init_marked_here);
12384 getCurFunction()->ObjCWarnForNoDesignatedInitChain =
false;
12386 if (getCurFunction()->ObjCWarnForNoInitDelegation) {
12388 if (!MD->isUnavailable())
12389 Diag(MD->getLocation(),
12390 diag::warn_objc_secondary_init_missing_init_call);
12391 getCurFunction()->ObjCWarnForNoInitDelegation =
false;
12397 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
12398 DiagnoseUnguardedAvailabilityViolations(dcl);
12400 assert(!getCurFunction()->ObjCShouldCallSuper &&
12401 "This should only be set for ObjC methods, which should have been " 12402 "handled in the block above.");
12409 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
12410 DiagnoseReturnInConstructorExceptionHandler(cast<CXXTryStmt>(Body));
12413 if (getCurFunction()->NeedsScopeChecking() &&
12414 !PP.isCodeCompletionEnabled())
12415 DiagnoseInvalidJumps(Body);
12418 if (!Destructor->getParent()->isDependentType())
12419 CheckDestructor(Destructor);
12421 MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(),
12422 Destructor->getParent());
12428 if (getDiagnostics().hasErrorOccurred() ||
12429 getDiagnostics().getSuppressAllDiagnostics()) {
12430 DiscardCleanupsInEvaluationContext();
12432 if (!getDiagnostics().hasUncompilableErrorOccurred() &&
12433 !isa<FunctionTemplateDecl>(dcl)) {
12436 ActivePolicy = &WP;
12440 (!CheckConstexprFunctionDecl(FD) ||
12441 !CheckConstexprFunctionBody(FD, Body)))
12444 if (FD && FD->
hasAttr<NakedAttr>()) {
12448 bool RegisterVariables =
false;
12449 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
12450 for (
const auto *
Decl : DS->decls()) {
12451 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
12452 RegisterVariables =
12453 Var->hasAttr<AsmLabelAttr>() && !Var->hasInit();
12454 if (!RegisterVariables)
12459 if (RegisterVariables)
12461 if (!isa<AsmStmt>(S) && !isa<NullStmt>(S)) {
12462 Diag(S->getLocStart(), diag::err_non_asm_stmt_in_naked_function);
12463 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
12470 assert(ExprCleanupObjects.size() ==
12471 ExprEvalContexts.back().NumCleanupObjects &&
12472 "Leftover temporaries in function");
12473 assert(!Cleanup.exprNeedsCleanups() &&
"Unaccounted cleanups in function");
12474 assert(MaybeODRUseExprs.empty() &&
12475 "Leftover expressions for odr-use checking");
12478 if (!IsInstantiation)
12481 PopFunctionScopeInfo(ActivePolicy, dcl);
12485 if (getDiagnostics().hasErrorOccurred()) {
12486 DiscardCleanupsInEvaluationContext();
12498 D = TD->getTemplatedDecl();
12499 ProcessDeclAttributeList(S, D, Attrs.
getList());
12501 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D))
12502 if (Method->isStatic())
12503 checkThisInStaticMemberFunctionAttributes(Method);
12510 Scope *BlockScope = S;
12518 NamedDecl *ExternCPrev = findLocallyScopedExternCDecl(&II);
12522 PushOnScopeChains(ExternCPrev, BlockScope,
false);
12527 if (!isa<FunctionDecl>(ExternCPrev) ||
12529 cast<FunctionDecl>(ExternCPrev)->getType(),
12531 Diag(Loc, diag::ext_use_out_of_scope_declaration)
12532 << ExternCPrev << !getLangOpts().C99;
12534 return ExternCPrev;
12541 if (II.
getName().startswith(
"__builtin_"))
12542 diag_id = diag::warn_builtin_unknown;
12543 else if (getLangOpts().C99 || getLangOpts().OpenCL)
12544 diag_id = diag::ext_implicit_function_decl;
12546 diag_id = diag::warn_implicit_function_decl;
12547 Diag(Loc, diag_id) << &II << getLangOpts().OpenCL;
12553 return ExternCPrev;
12560 (Corrected = CorrectTypo(
12563 diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion),
12575 assert(!Error &&
"Error setting up implicit decl!");
12606 FunctionDecl *FD = cast<FunctionDecl>(ActOnDeclarator(BlockScope, D));
12609 AddKnownFunctionAttributes(FD);
12631 unsigned FormatIdx;
12634 if (!FD->
hasAttr<FormatAttr>()) {
12635 const char *fmt =
"printf";
12637 if (FormatIdx < NumParams &&
12640 FD->
addAttr(FormatAttr::CreateImplicit(Context,
12643 HasVAListArg ? 0 : FormatIdx+2,
12649 if (!FD->
hasAttr<FormatAttr>())
12650 FD->
addAttr(FormatAttr::CreateImplicit(Context,
12653 HasVAListArg ? 0 : FormatIdx+2,
12660 if (!getLangOpts().MathErrno && !FD->
hasAttr<ConstAttr>() &&
12668 if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
12670 switch (BuiltinID) {
12671 case Builtin::BI__builtin_fma:
12672 case Builtin::BI__builtin_fmaf:
12673 case Builtin::BI__builtin_fmal:
12674 case Builtin::BIfma:
12675 case Builtin::BIfmaf:
12676 case Builtin::BIfmal:
12685 !FD->
hasAttr<ReturnsTwiceAttr>())
12686 FD->
addAttr(ReturnsTwiceAttr::CreateImplicit(Context,
12695 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
12699 if (getLangOpts().CUDAIsDevice !=
12710 if (getLangOpts().CXXExceptions && getLangOpts().ExternCNoUnwind &&
12713 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
12730 if (Name->
isStr(
"asprintf") || Name->
isStr(
"vasprintf")) {
12733 if (!FD->
hasAttr<FormatAttr>())
12734 FD->
addAttr(FormatAttr::CreateImplicit(Context,
12736 Name->
isStr(
"vasprintf") ? 0 : 3,
12740 if (Name->
isStr(
"__CFStringMakeConstantString")) {
12743 if (!FD->
hasAttr<FormatArgAttr>())
12744 FD->
addAttr(FormatArgAttr::CreateImplicit(Context, 1,
12751 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
12752 assert(!T.
isNull() &&
"GetTypeForDeclarator() returned null type");
12755 assert(D.
isInvalidType() &&
"no declarator info for valid type");
12773 if (CurContext->isFunctionOrMethod())
12795 setTagNameForLinkagePurposes(tagFromDeclSpec, NewTD);
12815 if (BT->isInteger())
12818 Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) <<
T;
12826 bool EnumUnderlyingIsImplicit,
const EnumDecl *Prev) {
12827 bool IsFixed = !EnumUnderlyingTy.
isNull();
12829 if (IsScoped != Prev->
isScoped()) {
12830 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
12836 if (IsFixed && Prev->
isFixed()) {
12842 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
12848 }
else if (IsFixed && !Prev->
isFixed() && EnumUnderlyingIsImplicit) {
12852 }
else if (IsFixed != Prev->
isFixed()) {
12853 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
12872 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
12887 if (isa<TypedefDecl>(PrevDecl))
12888 return NTK_Typedef;
12889 else if (isa<TypeAliasDecl>(PrevDecl))
12890 return NTK_TypeAlias;
12891 else if (isa<ClassTemplateDecl>(PrevDecl))
12892 return NTK_Template;
12893 else if (isa<TypeAliasTemplateDecl>(PrevDecl))
12894 return NTK_TypeAliasTemplate;
12895 else if (isa<TemplateTemplateParmDecl>(PrevDecl))
12896 return NTK_TemplateTemplateArgument;
12901 return getLangOpts().CPlusPlus ? NTK_NonClass : NTK_NonStruct;
12903 return NTK_NonUnion;
12905 return NTK_NonEnum;
12907 llvm_unreachable(
"invalid TTK");
12933 if (OldTag == NewTag)
12939 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Previous))
12940 isTemplate = Record->getDescribedClassTemplate();
12942 if (inTemplateInstantiation()) {
12945 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
12951 if (isDefinition) {
12959 bool previousMismatch =
false;
12960 for (
auto I : Previous->
redecls()) {
12961 if (I->getTagKind() != NewTag) {
12962 if (!previousMismatch) {
12963 previousMismatch =
true;
12964 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
12968 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
12986 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
12993 Diag(NewTagLoc, diag::note_struct_class_suggestion)
13027 Namespaces.push_back(II);
13030 if (Lookup == Namespace)
13037 llvm::raw_svector_ostream OS(Insertion);
13040 std::reverse(Namespaces.begin(), Namespaces.end());
13041 for (
auto *II : Namespaces)
13042 OS << II->getName() <<
"::";
13055 if (OldDC->
Equals(NewDC))
13083 bool &OwnedDecl,
bool &IsDependent,
13085 bool ScopedEnumUsesClassTag,
13087 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
13091 assert((Name !=
nullptr || TUK == TUK_Definition) &&
13092 "Nameless record must be a definition!");
13093 assert(TemplateParameterLists.size() == 0 || TUK != TUK_Reference);
13097 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
13100 bool isMemberSpecialization =
false;
13101 bool Invalid =
false;
13106 if (TemplateParameterLists.size() > 0 ||
13107 (SS.
isNotEmpty() && TUK != TUK_Reference)) {
13109 MatchTemplateParametersToScopeSpecifier(
13110 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
13111 TUK == TUK_Friend, isMemberSpecialization, Invalid)) {
13113 Diag(KWLoc, diag::err_enum_template);
13117 if (TemplateParams->size() > 0) {
13125 DeclResult Result = CheckClassTemplate(S, TagSpec, TUK, KWLoc,
13126 SS, Name, NameLoc, Attr,
13127 TemplateParams, AS,
13130 TemplateParameterLists.size()-1,
13131 TemplateParameterLists.data(),
13133 return Result.
get();
13136 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
13138 isMemberSpecialization =
true;
13146 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
13147 bool EnumUnderlyingIsImplicit =
false;
13150 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum))
13154 else if (UnderlyingType.
get()) {
13158 GetTypeFromParser(UnderlyingType.
get(), &TI);
13159 EnumUnderlying = TI;
13161 if (CheckEnumUnderlyingType(TI))
13166 UPPC_FixedUnderlyingType))
13170 if (getLangOpts().MSVCCompat || TUK == TUK_Definition) {
13173 EnumUnderlyingIsImplicit =
true;
13180 bool isStdBadAlloc =
false;
13181 bool isStdAlignValT =
false;
13184 if (TUK == TUK_Friend || TUK == TUK_Reference)
13185 Redecl = NotForRedeclaration;
13190 auto createTagFromNewDecl = [&]() ->
TagDecl * {
13191 assert(!getLangOpts().
CPlusPlus &&
"not meant for C++ usage");
13200 ScopedEnum, ScopedEnumUsesClassTag,
13201 !EnumUnderlying.isNull());
13203 if (TUK != TUK_Definition && !Invalid)
13205 if (EnumUnderlying) {
13206 EnumDecl *ED = cast<EnumDecl>(New);
13218 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
13228 if (TUK == TUK_Definition) {
13229 AddAlignmentAttributesForRecord(RD);
13230 AddMsStructLayoutForRecord(RD);
13244 goto CreateNewDecl;
13249 if (TUK == TUK_Friend || TUK == TUK_Reference) {
13250 DC = computeDeclContext(SS,
false);
13252 IsDependent =
true;
13256 DC = computeDeclContext(SS,
true);
13264 if (RequireCompleteDeclContext(SS, DC))
13269 LookupQualifiedName(Previous, DC);
13274 if (Previous.
empty()) {
13282 (TUK == TUK_Reference || TUK == TUK_Friend)) {
13283 IsDependent =
true;
13288 Diag(NameLoc, diag::err_not_tag_in_scope)
13289 << Kind << Name << DC << SS.
getRange();
13292 goto CreateNewDecl;
13299 if (TUK != TUK_Reference && TUK != TUK_Friend &&
13308 LookupName(Previous, S);
13313 (TUK == TUK_Definition || TUK == TUK_Declaration)) {
13337 if (!Previous.
empty() && TUK == TUK_Friend) {
13340 bool FriendSawTagOutsideEnclosingNamespace =
false;
13346 if (getLangOpts().MSVCCompat)
13347 FriendSawTagOutsideEnclosingNamespace =
true;
13356 if (Previous.
isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
13358 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
13367 if (!getLangOpts().CPlusPlus && TUK != TUK_Reference) {
13372 while (isa<RecordDecl>(SearchDC) || isa<EnumDecl>(SearchDC))
13380 DiagnoseTemplateParameterShadow(NameLoc, Previous.
getFoundDecl());
13385 if (getLangOpts().
CPlusPlus && Name && DC && StdNamespace &&
13386 DC->
Equals(getStdNamespace())) {
13387 if (Name->
isStr(
"bad_alloc")) {
13389 isStdBadAlloc =
true;
13394 if (Previous.
empty() && StdBadAlloc)
13395 Previous.
addDecl(getStdBadAlloc());
13396 }
else if (Name->
isStr(
"align_val_t")) {
13397 isStdAlignValT =
true;
13398 if (Previous.
empty() && StdAlignValT)
13399 Previous.
addDecl(getStdAlignValT());
13407 if (Name && Previous.
empty() &&
13408 (TUK == TUK_Reference || TUK == TUK_Friend || IsTemplateParamOrArg)) {
13409 if (Invalid)
goto CreateNewDecl;
13412 if (TUK == TUK_Reference || IsTemplateParamOrArg) {
13446 assert(TUK == TUK_Friend);
13462 LookupQualifiedName(Previous, SearchDC);
13465 LookupName(Previous, S);
13473 if (!Previous.
empty()) {
13489 TagDecl *Tag = TT->getDecl();
13492 ->
Equals(TD->getDeclContext()->getRedeclContext())) {
13505 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
13506 auto *OldTag = dyn_cast<
TagDecl>(PrevDecl);
13507 if (SS.
isEmpty() && TUK != TUK_Reference && TUK != TUK_Friend &&
13508 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
13510 *
this, OldTag->getDeclContext(), SearchDC))) {
13511 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
13512 Diag(Shadow->getTargetDecl()->getLocation(),
13513 diag::note_using_decl_target);
13514 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl)
13518 goto CreateNewDecl;
13522 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
13526 if (TUK == TUK_Reference || TUK == TUK_Friend ||
13527 isDeclInScope(DirectPrevDecl, SearchDC, S,
13528 SS.
isNotEmpty() || isMemberSpecialization)) {
13531 if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind,
13532 TUK == TUK_Definition, KWLoc,
13534 bool SafeToContinue
13535 = (PrevTagDecl->getTagKind() !=
TTK_Enum &&
13537 if (SafeToContinue)
13538 Diag(KWLoc, diag::err_use_with_wrong_tag)
13541 PrevTagDecl->getKindName());
13543 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
13544 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
13546 if (SafeToContinue)
13547 Kind = PrevTagDecl->getTagKind();
13557 const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
13561 if (TUK == TUK_Reference || TUK == TUK_Friend) {
13563 Diag(ScopedEnumKWLoc, diag::err_enum_class_reference)
13566 return PrevTagDecl;
13571 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
13572 else if (
const Type *
T = EnumUnderlying.dyn_cast<
const Type*>())
13578 if (CheckEnumRedeclaration(NameLoc.
isValid() ? NameLoc : KWLoc,
13579 ScopedEnum, EnumUnderlyingTy,
13580 EnumUnderlyingIsImplicit, PrevEnum))
13581 return TUK == TUK_Declaration ? PrevTagDecl :
nullptr;
13590 Diag(NameLoc, diag::ext_member_redeclared);
13591 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
13597 if (TUK == TUK_Reference || TUK == TUK_Friend) {
13601 }
else if (TUK == TUK_Reference &&
13602 (PrevTagDecl->getFriendObjectKind() ==
13615 return PrevTagDecl;
13620 return PrevTagDecl;
13625 if (TUK == TUK_Definition) {
13626 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
13630 bool IsExplicitSpecializationAfterInstantiation =
false;
13631 if (isMemberSpecialization) {
13633 IsExplicitSpecializationAfterInstantiation =
13634 RD->getTemplateSpecializationKind() !=
13636 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
13637 IsExplicitSpecializationAfterInstantiation =
13638 ED->getTemplateSpecializationKind() !=
13647 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
13658 SkipBody->
New = createTagFromNewDecl();
13662 makeMergedDefinitionVisible(Hidden);
13665 }
else if (!IsExplicitSpecializationAfterInstantiation) {
13669 Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name;
13671 Diag(NameLoc, diag::err_redefinition) << Name;
13672 notePreviousDefinition(Def,
13673 NameLoc.
isValid() ? NameLoc : KWLoc);
13685 if (TD->isBeingDefined()) {
13686 Diag(NameLoc, diag::err_nested_redefinition) << Name;
13687 Diag(PrevTagDecl->getLocation(),
13688 diag::note_previous_definition);
13702 if (TUK == TUK_Friend || TUK == TUK_Reference) {
13703 SearchDC = PrevTagDecl->getDeclContext();
13728 if ((TUK == TUK_Reference || TUK == TUK_Friend) &&
13730 NonTagKind NTK = getNonTagTypeDeclKind(PrevDecl, Kind);
13731 Diag(NameLoc, diag::err_tag_reference_non_tag) << PrevDecl << NTK
13737 }
else if (!isDeclInScope(DirectPrevDecl, SearchDC, S,
13738 SS.
isNotEmpty() || isMemberSpecialization)) {
13742 }
else if (TUK == TUK_Reference || TUK == TUK_Friend) {
13743 NonTagKind NTK = getNonTagTypeDeclKind(PrevDecl, Kind);
13744 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
13750 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
13752 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
13753 Diag(NameLoc, diag::err_tag_definition_of_typedef)
13754 << Name << Kind << TND->getUnderlyingType();
13762 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
13763 notePreviousDefinition(PrevDecl, NameLoc);
13790 bool IsForwardReference =
false;
13795 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
13796 ScopedEnumUsesClassTag, !EnumUnderlying.isNull());
13798 if (isStdAlignValT && (!StdAlignValT || getStdAlignValT()->isImplicit()))
13799 StdAlignValT = cast<EnumDecl>(New);
13802 if (TUK != TUK_Definition && !Invalid) {
13804 if (!EnumUnderlyingIsImplicit &&
13805 (getLangOpts().
CPlusPlus11 || getLangOpts().ObjC2) &&
13806 cast<EnumDecl>(New)->isFixed()) {
13810 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
13811 Diag(Loc, diag::ext_forward_ref_enum_def)
13815 unsigned DiagID = diag::ext_forward_ref_enum;
13816 if (getLangOpts().MSVCCompat)
13817 DiagID = diag::ext_ms_forward_ref_enum;
13818 else if (getLangOpts().CPlusPlus)
13819 DiagID = diag::err_forward_ref_enum;
13825 if (TUK == TUK_Reference)
13826 IsForwardReference =
true;
13830 if (EnumUnderlying) {
13831 EnumDecl *ED = cast<EnumDecl>(New);
13843 if (getLangOpts().CPlusPlus) {
13846 cast_or_null<CXXRecordDecl>(PrevDecl));
13848 if (isStdBadAlloc && (!StdBadAlloc || getStdBadAlloc()->isImplicit()))
13849 StdBadAlloc = cast<CXXRecordDecl>(New);
13852 cast_or_null<RecordDecl>(PrevDecl));
13857 if (getLangOpts().
CPlusPlus && (IsTypeSpecifier || IsTemplateParamOrArg) &&
13858 TUK == TUK_Definition) {
13864 if (!Invalid && getLangOpts().
CPlusPlus && TUK == TUK_Definition &&
13879 if (!isMemberSpecialization &&
13880 (TUK == TUK_Definition || TUK == TUK_Declaration) &&
13881 diagnoseQualifiedDeclaration(SS, DC, OrigName, Loc))
13885 if (TemplateParameterLists.size() > 0) {
13893 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
13903 if (TUK == TUK_Definition) {
13904 AddAlignmentAttributesForRecord(RD);
13905 AddMsStructLayoutForRecord(RD);
13909 if (ModulePrivateLoc.
isValid()) {
13910 if (isMemberSpecialization)
13923 if (isMemberSpecialization && CheckMemberSpecialization(New, Previous))
13930 getNonFieldDeclScope(S)->isFunctionPrototypeScope()) {
13934 if (TUK == TUK_Definition && !IsTypeSpecifier) {
13935 Diag(Loc, diag::err_type_defined_in_param_type)
13939 }
else if (!PrevDecl) {
13955 if (TUK == TUK_Friend)
13959 if (!Invalid && SearchDC->
isRecord())
13960 SetMemberAccessSpecifier(New, PrevDecl, AS);
13963 CheckRedeclarationModuleOwnership(New, PrevDecl);
13965 if (TUK == TUK_Definition)
13969 ProcessDeclAttributeList(S, New, Attr);
13970 AddPragmaAttributes(S, New);
13973 if (TUK == TUK_Friend) {
13982 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
13983 PushOnScopeChains(New, EnclosingScope,
false);
13985 S = getNonFieldDeclScope(S);
13986 PushOnScopeChains(New, S, !IsForwardReference);
13987 if (IsForwardReference)
13990 CurContext->addDecl(New);
14001 mergeDeclAttributes(New, PrevDecl);
14005 AddPushedVisibilityAttribute(New);
14008 CompleteMemberSpecialization(New, Previous);
14013 if (Invalid && getLangOpts().CPlusPlus) {
14015 if (
auto RD = dyn_cast<RecordDecl>(New))
14016 RD->completeDefinition();
14024 AdjustDeclIfTemplate(TagD);
14025 TagDecl *Tag = cast<TagDecl>(TagD);
14028 PushDeclContext(S, Tag);
14030 ActOnDocumentableDecl(TagD);
14034 AddPushedVisibilityAttribute(Tag);
14039 if (!hasStructuralCompatLayout(Prev, SkipBody.
New))
14043 makeMergedDefinitionVisible(SkipBody.
Previous);
14048 assert(isa<ObjCContainerDecl>(IDecl) &&
14049 "ActOnObjCContainerStartDefinition - Not ObjCContainerDecl");
14051 assert(getContainingDC(OCD) == CurContext &&
14052 "The next DeclContext should be lexically contained in the current one.");
14059 bool IsFinalSpelledSealed,
14061 AdjustDeclIfTemplate(TagD);
14064 FieldCollector->StartClass();
14070 Record->
addAttr(new (Context)
14071 FinalAttr(FinalLoc, Context, IsFinalSpelledSealed));
14089 PushOnScopeChains(InjectedClassName, S);
14091 "Broken injected-class-name");
14096 AdjustDeclIfTemplate(TagD);
14097 TagDecl *Tag = cast<TagDecl>(TagD);
14102 assert(Tag->
isInvalidDecl() &&
"We should already have completed it");
14103 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
14104 RD->completeDefinition();
14107 if (isa<CXXRecordDecl>(Tag)) {
14108 FieldCollector->FinishClass();
14114 if (getCurLexicalContext()->isObjCContainer() &&
14120 Consumer.HandleTagDeclDefinition(Tag);
14129 assert(DC == CurContext &&
"Mismatch of container contexts");
14130 OriginalLexicalContext = DC;
14131 ActOnObjCContainerFinishDefinition();
14135 ActOnObjCContainerStartDefinition(cast<Decl>(DC));
14136 OriginalLexicalContext =
nullptr;
14140 AdjustDeclIfTemplate(TagD);
14141 TagDecl *Tag = cast<TagDecl>(TagD);
14146 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
14147 RD->completeDefinition();
14160 QualType FieldTy,
bool IsMsStruct,
14161 Expr *BitWidth,
bool *ZeroWidth) {
14170 if (RequireCompleteType(FieldLoc, FieldTy, diag::err_field_incomplete))
14173 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
14175 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
14177 }
else if (DiagnoseUnexpandedParameterPack(const_cast<Expr *>(BitWidth),
14178 UPPC_BitFieldWidth))
14186 llvm::APSInt
Value;
14187 ExprResult ICE = VerifyIntegerConstantExpression(BitWidth, &Value);
14190 BitWidth = ICE.
get();
14192 if (Value != 0 && ZeroWidth)
14193 *ZeroWidth =
false;
14196 if (Value == 0 && FieldName)
14197 return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
14199 if (Value.isSigned() && Value.isNegative()) {
14201 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
14202 << FieldName << Value.toString(10);
14203 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
14204 << Value.toString(10);
14208 uint64_t TypeStorageSize = Context.
getTypeSize(FieldTy);
14209 uint64_t TypeWidth = Context.
getIntWidth(FieldTy);
14210 bool BitfieldIsOverwide = Value.ugt(TypeWidth);
14214 bool CStdConstraintViolation =
14215 BitfieldIsOverwide && !getLangOpts().CPlusPlus;
14216 bool MSBitfieldViolation =
14217 Value.ugt(TypeStorageSize) &&
14219 if (CStdConstraintViolation || MSBitfieldViolation) {
14220 unsigned DiagWidth =
14221 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
14223 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
14224 << FieldName << (unsigned)Value.getZExtValue()
14225 << !CStdConstraintViolation << DiagWidth;
14227 return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width)
14228 << (unsigned)Value.getZExtValue() << !CStdConstraintViolation
14237 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
14238 << FieldName << (unsigned)Value.getZExtValue()
14239 << (unsigned)TypeWidth;
14241 Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_width)
14242 << (unsigned)Value.getZExtValue() << (unsigned)TypeWidth;
14253 FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD),
14254 DeclStart, D, static_cast<Expr*>(BitfieldWidth),
14280 CheckExtraCXXDefaultArguments(D);
14283 UPPC_DataMemberType)) {
14294 Diag(Loc, diag::err_field_with_address_space);
14302 Diag(Loc, diag::err_opencl_type_struct_or_union_field) <<
T;
14310 << getLangOpts().CPlusPlus17;
14313 diag::err_invalid_thread)
14319 ForVisibleRedeclaration);
14320 LookupName(Previous, S);
14342 PrevDecl =
nullptr;
14345 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
14346 PrevDecl =
nullptr;
14352 = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
14353 TSSL, AS, PrevDecl, &D);
14365 PushOnScopeChains(NewFD, S);
14385 bool Mutable,
Expr *BitWidth,
14391 bool InvalidDecl =
false;
14397 InvalidDecl =
true;
14403 if (RequireCompleteType(Loc, EltTy, diag::err_field_incomplete)) {
14406 InvalidDecl =
true;
14412 InvalidDecl =
true;
14418 if (BitWidth && getLangOpts().OpenCL) {
14419 Diag(Loc, diag::err_opencl_bitfields);
14420 InvalidDecl =
true;
14426 bool SizeIsNegative;
14427 llvm::APSInt Oversized;
14434 Diag(Loc, diag::warn_illegal_constant_array_size);
14435 TInfo = FixedTInfo;
14438 if (SizeIsNegative)
14439 Diag(Loc, diag::err_typecheck_negative_array_size);
14440 else if (Oversized.getBoolValue())
14441 Diag(Loc, diag::err_array_too_large)
14442 << Oversized.toString(10);
14444 Diag(Loc, diag::err_typecheck_field_variable_size);
14445 InvalidDecl =
true;
14450 if (!InvalidDecl && RequireNonAbstractType(Loc, T,
14451 diag::err_abstract_type_in_decl,
14452 AbstractFieldType))
14453 InvalidDecl =
true;
14455 bool ZeroWidth =
false;
14457 BitWidth =
nullptr;
14460 BitWidth = VerifyBitField(Loc, II, T, Record->
isMsStruct(Context), BitWidth,
14463 InvalidDecl =
true;
14464 BitWidth =
nullptr;
14470 if (!InvalidDecl && Mutable) {
14471 unsigned DiagID = 0;
14473 DiagID = getLangOpts().MSVCCompat ? diag::ext_mutable_reference
14474 : diag::err_mutable_reference;
14476 DiagID = diag::err_mutable_const;
14482 Diag(ErrLoc, DiagID);
14483 if (DiagID != diag::ext_mutable_reference) {
14485 InvalidDecl =
true;
14497 BitWidth, Mutable, InitStyle);
14501 if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
14502 Diag(Loc, diag::err_duplicate_member) << II;
14507 if (!InvalidDecl && getLangOpts().
CPlusPlus) {
14517 if (CheckNontrivialField(NewFD))
14527 diag::ext_union_member_of_reference_type :
14528 diag::err_union_member_of_reference_type)
14530 if (!getLangOpts().MicrosoftExt)
14540 ProcessDeclAttributes(getCurScope(), NewFD, *D);
14543 CheckAlignasUnderalignment(NewFD);
14548 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewFD))
14552 Diag(Loc, diag::warn_attribute_weak_on_field);
14560 assert(getLangOpts().
CPlusPlus &&
"valid check only for C++");
14580 member = CXXCopyConstructor;
14582 member = CXXDefaultConstructor;
14584 member = CXXCopyAssignment;
14586 member = CXXDestructor;
14588 if (member != CXXInvalid) {
14589 if (!getLangOpts().CPlusPlus11 &&
14597 if (getSourceManager().isInSystemHeader(Loc)) {
14598 if (!FD->
hasAttr<UnavailableAttr>())
14599 FD->
addAttr(UnavailableAttr::CreateImplicit(Context,
"",
14600 UnavailableAttr::IR_ARCFieldWithOwnership, Loc));
14606 diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member :
14607 diag::err_illegal_union_or_anon_struct_member)
14609 DiagnoseNontrivial(RDecl, member);
14610 return !getLangOpts().CPlusPlus11;
14622 switch (ivarVisibility) {
14623 default: llvm_unreachable(
"Unknown visitibility kind");
14639 Expr *BitWidth = (
Expr*)BitfieldWidth;
14651 BitWidth = VerifyBitField(Loc, II, T,
false, BitWidth).get();
14661 Diag(Loc, diag::err_ivar_reference_type);
14667 Diag(Loc, diag::err_typecheck_ivar_variable_size);
14681 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
14682 if (LangOpts.ObjCRuntime.isFragile()) {
14684 EnclosingContext = IMPDecl->getClassInterface();
14685 assert(EnclosingContext &&
"Implementation has no class interface!");
14688 EnclosingContext = EnclosingDecl;
14691 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
14692 if (LangOpts.ObjCRuntime.isFragile() || !CDecl->IsClassExtension()) {
14693 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
14697 EnclosingContext = EnclosingDecl;
14702 DeclStart, Loc, II, T,
14703 TInfo, ac, (
Expr *)BitfieldWidth);
14706 NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
14707 ForVisibleRedeclaration);
14708 if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S)
14709 && !isa<TagDecl>(PrevDecl)) {
14710 Diag(Loc, diag::err_duplicate_member) << II;
14717 ProcessDeclAttributes(S, NewID, D);
14723 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewID))
14733 IdResolver.AddDecl(NewID);
14736 if (LangOpts.ObjCRuntime.isNonFragile() &&
14737 !NewID->
isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
14738 Diag(Loc, diag::warn_ivars_in_interface);
14749 if (LangOpts.ObjCRuntime.isFragile() || AllIvarDecls.empty())
14752 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
14760 if (!CD->IsClassExtension())
14772 DeclLoc, DeclLoc,
nullptr,
14778 AllIvarDecls.push_back(Ivar);
14784 assert(EnclosingDecl &&
"missing record or interface decl");
14789 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
14793 case Decl::ObjCCategory:
14794 Context.
ResetObjCLayout(cast<ObjCCategoryDecl>(DC)->getClassInterface());
14796 case Decl::ObjCImplementation:
14798 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
14807 unsigned NumNamedMembers = 0;
14809 for (
const auto *I : Record->
decls()) {
14810 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
14811 if (IFD->getDeclName())
14819 bool ObjCFieldLifetimeErrReported =
false;
14829 RecFields.push_back(FD);
14849 bool IsLastField = (i + 1 == Fields.end());
14858 (Record || isa<ObjCContainerDecl>(EnclosingDecl))) {
14864 unsigned DiagID = 0;
14865 if (!Record->
isUnion() && !IsLastField) {
14868 Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
14872 }
else if (Record->
isUnion())
14873 DiagID = getLangOpts().MicrosoftExt
14874 ? diag::ext_flexible_array_union_ms
14875 : getLangOpts().CPlusPlus
14876 ? diag::ext_flexible_array_union_gnu
14877 : diag::err_flexible_array_union;
14878 else if (NumNamedMembers < 1)
14879 DiagID = getLangOpts().MicrosoftExt
14880 ? diag::ext_flexible_array_empty_aggregate_ms
14881 : getLangOpts().CPlusPlus
14882 ? diag::ext_flexible_array_empty_aggregate_gnu
14883 : diag::err_flexible_array_empty_aggregate;
14894 if (RD->getNumVBases() != 0)
14897 if (!getLangOpts().
C99)
14908 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
14923 diag::err_field_incomplete)) {
14948 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
14950 diag::err_abstract_type_in_decl,
14951 AbstractIvarType)) {
14965 }
else if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
14966 Record && !ObjCFieldLifetimeErrReported &&
14976 if (getSourceManager().isInSystemHeader(loc)) {
14977 if (!FD->
hasAttr<UnavailableAttr>()) {
14978 FD->
addAttr(UnavailableAttr::CreateImplicit(Context,
"",
14979 UnavailableAttr::IR_ARCFieldWithOwnership, loc));
14985 ObjCFieldLifetimeErrReported =
true;
14987 }
else if (getLangOpts().ObjC1 &&
15012 bool Completed =
false;
15013 if (
CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) {
15014 if (!CXXRecord->isInvalidDecl()) {
15017 I = CXXRecord->conversion_begin(),
15018 E = CXXRecord->conversion_end(); I != E; ++I)
15019 I.setAccess((*I)->getAccess());
15022 if (!CXXRecord->isDependentType()) {
15023 if (CXXRecord->hasUserDeclaredDestructor()) {
15025 if (getLangOpts().CPlusPlus11)
15026 AdjustDestructorExceptionSpec(CXXRecord,
15027 CXXRecord->getDestructor());
15030 if (!CXXRecord->isInvalidDecl()) {
15032 AddImplicitlyDeclaredMembersToClass(CXXRecord);
15037 if (CXXRecord->getNumVBases()) {
15039 CXXRecord->getFinalOverriders(FinalOverriders);
15041 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
15042 MEnd = FinalOverriders.end();
15045 SOEnd = M->second.end();
15046 SO != SOEnd; ++SO) {
15047 assert(SO->second.size() > 0 &&
15048 "Virtual function without overridding functions?");
15049 if (SO->second.size() == 1)
15057 << (
const NamedDecl *)M->first << Record;
15058 Diag(M->first->getLocation(),
15059 diag::note_overridden_virtual_function);
15061 OM = SO->second.begin(),
15062 OMEnd = SO->second.end();
15064 Diag(OM->Method->getLocation(), diag::note_final_overrider)
15065 << (
const NamedDecl *)M->first << OM->Method->getParent();
15070 CXXRecord->completeDefinition(&FinalOverriders);
15081 if (
CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) {
15082 auto *Dtor = CXXRecord->getDestructor();
15083 if (Dtor && Dtor->isImplicit() &&
15084 ShouldDeleteSpecialMember(Dtor, CXXDestructor)) {
15085 CXXRecord->setImplicitDestructorIsDeleted();
15086 SetDeclDeleted(Dtor, CXXRecord->getLocation());
15091 CheckAlignasUnderalignment(Record);
15093 if (
const MSInheritanceAttr *IA = Record->
getAttr<MSInheritanceAttr>())
15094 checkMSInheritanceAttrOnDefinition(cast<CXXRecordDecl>(Record),
15095 IA->getRange(), IA->getBestCase(),
15096 IA->getSemanticSpelling());
15102 bool CheckForZeroSize;
15103 if (!getLangOpts().CPlusPlus) {
15104 CheckForZeroSize =
true;
15113 if (CheckForZeroSize) {
15114 bool ZeroSize =
true;
15115 bool IsEmpty =
true;
15116 unsigned NonBitFields = 0;
15119 (NonBitFields == 0 || ZeroSize) && I != E; ++I) {
15121 if (I->isUnnamedBitfield()) {
15122 if (I->getBitWidthValue(Context) > 0)
15126 QualType FieldType = I->getType();
15138 diag::warn_zero_size_struct_union_in_extern_c :
15139 diag::warn_zero_size_struct_union_compat)
15140 << IsEmpty << Record->
isUnion() << (NonBitFields > 1);
15145 if (NonBitFields == 0 && !getLangOpts().CPlusPlus) {
15146 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union :
15147 diag::ext_no_named_members_in_struct_union)
15155 ID->setEndOfDefinitionLoc(RBrac);
15157 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
15159 ID->addDecl(ClsFields[i]);
15163 if (
ID->getSuperClass())
15164 DiagnoseDuplicateIvars(
ID,
ID->getSuperClass());
15166 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
15167 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
15168 for (
unsigned I = 0, N = RecFields.size(); I != N; ++I)
15171 ClsFields[I]->setLexicalDeclContext(IMPDecl);
15172 CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
15173 IMPDecl->setIvarLBraceLoc(LBrac);
15174 IMPDecl->setIvarRBraceLoc(RBrac);
15176 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
15184 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
15188 Diag(ClsFields[i]->getLocation(),
15189 diag::err_duplicate_ivar_declaration);
15190 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
15196 Diag(ClsFields[i]->getLocation(),
15197 diag::err_duplicate_ivar_declaration);
15198 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
15204 CDecl->addDecl(ClsFields[i]);
15206 CDecl->setIvarLBraceLoc(LBrac);
15207 CDecl->setIvarRBraceLoc(RBrac);
15212 ProcessDeclAttributeList(S, Record, Attr);
15218 llvm::APSInt &
Value,
15221 "Integral type required!");
15224 if (Value.isUnsigned() || Value.isNonNegative()) {
15227 return Value.getActiveBits() <= BitWidth;
15229 return Value.getMinSignedBits() <= BitWidth;
15239 const unsigned NumTypes = 4;
15240 QualType SignedIntegralTypes[NumTypes] = {
15243 QualType UnsignedIntegralTypes[NumTypes] = {
15250 : UnsignedIntegralTypes;
15251 for (
unsigned I = 0; I != NumTypes; ++I)
15264 llvm::APSInt EnumVal(IntWidth);
15267 if (Val && DiagnoseUnexpandedParameterPack(Val, UPPC_EnumeratorValue))
15271 Val = DefaultLvalueConversion(Val).get();
15277 if (getLangOpts().CPlusPlus11 && Enum->
isFixed() &&
15278 !getLangOpts().MSVCCompat) {
15289 Val = Converted.
get();
15291 !(Val = VerifyIntegerConstantExpression(Val,
15292 &EnumVal).get())) {
15303 if (getLangOpts().MSVCCompat) {
15304 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
15305 Val = ImpCastExprToType(Val, EltTy, CK_IntegralCast).get();
15307 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
15309 Val = ImpCastExprToType(Val, EltTy,
15311 CK_IntegralToBoolean : CK_IntegralCast)
15328 Diag(IdLoc, diag::ext_enum_value_not_int)
15330 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
15333 Val = ImpCastExprToType(Val, Context.
IntTy, CK_IntegralCast).get();
15342 if (Enum->isDependentType())
15344 else if (!LastEnumConst) {
15353 if (Enum->isFixed()) {
15354 EltTy = Enum->getIntegerType();
15357 EltTy = Context.
IntTy;
15361 EnumVal = LastEnumConst->getInitVal();
15363 EltTy = LastEnumConst->getType();
15366 if (EnumVal < LastEnumConst->getInitVal()) {
15378 if (T.
isNull() || Enum->isFixed()) {
15381 EnumVal = LastEnumConst->getInitVal();
15382 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
15384 if (Enum->isFixed())
15386 Diag(IdLoc, diag::err_enumerator_wrapped)
15387 << EnumVal.toString(10)
15390 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
15391 << EnumVal.toString(10);
15399 EnumVal = LastEnumConst->getInitVal();
15400 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
15401 EnumVal = EnumVal.zextOrTrunc(Context.
getIntWidth(EltTy));
15409 if (!getLangOpts().CPlusPlus && !T.
isNull())
15410 Diag(IdLoc, diag::warn_enum_value_overflow);
15411 }
else if (!getLangOpts().CPlusPlus &&
15414 Diag(IdLoc, diag::ext_enum_value_not_int)
15415 << EnumVal.toString(10) << 1;
15420 if (!EltTy->isDependentType()) {
15423 EnumVal = EnumVal.extOrTrunc(Context.
getIntWidth(EltTy));
15424 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
15433 if (!(getLangOpts().Modules || getLangOpts().ModulesLocalVisibility) ||
15440 NamedDecl *PrevDecl = LookupSingleName(S, II, IILoc, LookupOrdinaryName,
15441 forRedeclarationInCurContext());
15442 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
15446 EnumDecl *PrevED = cast<EnumDecl>(PrevECD->getDeclContext());
15448 if (!PrevED->
getDeclName() && !hasVisibleDefinition(PrevED, &Hidden)) {
15461 EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl);
15463 cast_or_null<EnumConstantDecl>(lastEnumConst);
15467 S = getNonFieldDeclScope(S);
15471 NamedDecl *PrevDecl = LookupSingleName(S, Id, IdLoc, LookupOrdinaryName,
15472 ForVisibleRedeclaration);
15475 DiagnoseTemplateParameterShadow(IdLoc, PrevDecl);
15477 PrevDecl =
nullptr;
15490 CheckEnumConstant(TheEnumDecl, LastEnumConst, IdLoc, Id, Val);
15497 assert((getLangOpts().
CPlusPlus || !isa<TagDecl>(PrevDecl)) &&
15498 "Received TagDecl when not in C++!");
15499 if (!isa<TagDecl>(PrevDecl) && isDeclInScope(PrevDecl, CurContext, S)) {
15500 if (isa<EnumConstantDecl>(PrevDecl))
15501 Diag(IdLoc, diag::err_redefinition_of_enumerator) <<
Id;
15503 Diag(IdLoc, diag::err_redefinition) <<
Id;
15504 notePreviousDefinition(PrevDecl, IdLoc);
15510 if (Attr) ProcessDeclAttributeList(S, New, Attr);
15511 AddPragmaAttributes(S, New);
15515 PushOnScopeChains(New, S);
15517 ActOnDocumentableDecl(New);
15535 if (!BO->isAdditiveOp())
15543 InitExpr = BO->getLHS();
15565 bool isTombstoneOrEmptyKey;
15566 DupKey(int64_t val,
bool isTombstoneOrEmptyKey)
15567 : val(val), isTombstoneOrEmptyKey(isTombstoneOrEmptyKey) {}
15570 static DupKey GetDupKey(
const llvm::APSInt& Val) {
15571 return DupKey(Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue(),
15575 struct DenseMapInfoDupKey {
15576 static DupKey getEmptyKey() {
return DupKey(0,
true); }
15577 static DupKey getTombstoneKey() {
return DupKey(1,
true); }
15578 static unsigned getHashValue(
const DupKey Key) {
15579 return (
unsigned)(Key.val * 37);
15581 static bool isEqual(
const DupKey& LHS,
const DupKey& RHS) {
15582 return LHS.isTombstoneOrEmptyKey == RHS.isTombstoneOrEmptyKey &&
15583 LHS.val == RHS.val;
15606 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
15607 typedef llvm::DenseMap<DupKey, DeclOrVector, DenseMapInfoDupKey>
15610 DuplicatesVector DupVector;
15611 ValueToVectorMap EnumMap;
15615 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
15628 DeclOrVector &Entry = EnumMap[Key];
15631 if (Entry.isNull())
15636 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
15643 DeclOrVector& Entry = EnumMap[Key];
15644 if (Entry.isNull())
15653 ECDVector *Vec =
new ECDVector();
15655 Vec->push_back(ECD);
15662 DupVector.push_back(Vec);
15666 ECDVector *Vec = Entry.get<ECDVector*>();
15668 if (*Vec->begin() == ECD)
15671 Vec->push_back(ECD);
15675 for (DuplicatesVector::iterator DupVectorIter = DupVector.begin(),
15676 DupVectorEnd = DupVector.end();
15677 DupVectorIter != DupVectorEnd; ++DupVectorIter) {
15678 ECDVector *Vec = *DupVectorIter;
15679 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
15682 ECDVector::iterator I = Vec->begin();
15683 S.
Diag((*I)->getLocation(), diag::warn_duplicate_enum_values)
15684 << (*I)->getName() << (*I)->getInitVal().toString(10)
15685 << (*I)->getSourceRange();
15690 for (ECDVector::iterator E = Vec->end(); I != E; ++I)
15691 S.
Diag((*I)->getLocation(), diag::note_duplicate_element)
15692 << (*I)->getName() << (*I)->getInitVal().toString(10)
15693 << (*I)->getSourceRange();
15699 bool AllowMask)
const {
15700 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
15703 auto R = FlagBitsCache.insert(std::make_pair(ED, llvm::APInt()));
15704 llvm::APInt &FlagBits = R.first->second;
15708 const auto &EVal = E->getInitVal();
15710 if (EVal.isPowerOf2())
15711 FlagBits = FlagBits.zextOrSelf(EVal.getBitWidth()) | EVal;
15723 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
15724 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
15731 EnumDecl *Enum = cast<EnumDecl>(EnumDeclX);
15735 ProcessDeclAttributeList(S, Enum, Attr);
15738 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
15740 cast_or_null<EnumConstantDecl>(Elements[i]);
15741 if (!ECD)
continue;
15759 unsigned NumNegativeBits = 0;
15760 unsigned NumPositiveBits = 0;
15763 bool AllElementsInt =
true;
15765 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
15767 cast_or_null<EnumConstantDecl>(Elements[i]);
15768 if (!ECD)
continue;
15770 const llvm::APSInt &InitVal = ECD->
getInitVal();
15773 if (InitVal.isUnsigned() || InitVal.isNonNegative())
15774 NumPositiveBits =
std::max(NumPositiveBits,
15775 (
unsigned)InitVal.getActiveBits());
15777 NumNegativeBits =
std::max(NumNegativeBits,
15778 (
unsigned)InitVal.getMinSignedBits());
15781 if (AllElementsInt)
15787 unsigned BestWidth;
15800 bool Packed = Enum->
hasAttr<PackedAttr>();
15803 if (LangOpts.ShortEnums)
15811 BestPromotionType = BestType;
15815 else if (NumNegativeBits) {
15819 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
15821 BestWidth = CharWidth;
15822 }
else if (Packed && NumNegativeBits <= ShortWidth &&
15823 NumPositiveBits < ShortWidth) {
15825 BestWidth = ShortWidth;
15826 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
15827 BestType = Context.
IntTy;
15828 BestWidth = IntWidth;
15832 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
15833 BestType = Context.
LongTy;
15837 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
15842 BestPromotionType = (BestWidth <= IntWidth ? Context.
IntTy : BestType);
15847 if (Packed && NumPositiveBits <= CharWidth) {
15849 BestPromotionType = Context.
IntTy;
15850 BestWidth = CharWidth;
15851 }
else if (Packed && NumPositiveBits <= ShortWidth) {
15853 BestPromotionType = Context.
IntTy;
15854 BestWidth = ShortWidth;
15855 }
else if (NumPositiveBits <= IntWidth) {
15857 BestWidth = IntWidth;
15859 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
15861 }
else if (NumPositiveBits <=
15865 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
15869 assert(NumPositiveBits <= BestWidth &&
15870 "How could an initializer get larger than ULL?");
15873 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
15880 for (
auto *D : Elements) {
15881 auto *ECD = cast_or_null<EnumConstantDecl>(D);
15882 if (!ECD)
continue;
15891 llvm::APSInt InitVal = ECD->getInitVal();
15901 NewTy = Context.
IntTy;
15902 NewWidth = IntWidth;
15904 }
else if (ECD->getType() == BestType) {
15906 if (getLangOpts().CPlusPlus)
15910 ECD->setType(EnumType);
15914 NewWidth = BestWidth;
15919 InitVal = InitVal.extOrTrunc(NewWidth);
15920 InitVal.setIsSigned(NewSign);
15921 ECD->setInitVal(InitVal);
15924 if (ECD->getInitExpr() &&
15925 !Context.
hasSameType(NewTy, ECD->getInitExpr()->getType()))
15928 ECD->getInitExpr(),
15931 if (getLangOpts().CPlusPlus)
15935 ECD->setType(EnumType);
15937 ECD->setType(NewTy);
15941 NumPositiveBits, NumNegativeBits);
15946 for (
Decl *D : Elements) {
15948 if (!ECD)
continue;
15951 if (InitVal != 0 && !InitVal.isPowerOf2() &&
15952 !IsValueInFlagEnum(Enum, InitVal,
true))
15960 CheckAlignasUnderalignment(Enum);
15969 AsmString, StartLoc,
15971 CurContext->addDecl(New);
15977 bool FromInclude =
false) {
15980 if (
auto *LSD = dyn_cast<LinkageSpecDecl>(DC)) {
15981 switch (LSD->getLanguage()) {
15984 ExternCLoc = LSD->getLocStart();
15992 while (isa<LinkageSpecDecl>(DC) || isa<ExportDecl>(DC))
15995 if (!isa<TranslationUnitDecl>(DC)) {
15997 ? diag::ext_module_import_not_at_top_level_noop
15998 : diag::err_module_import_not_at_top_level_fatal)
16000 S.
Diag(cast<Decl>(DC)->getLocStart(),
16001 diag::note_module_import_not_at_top_level) << DC;
16003 S.
Diag(ImportLoc, diag::ext_module_import_in_extern_c)
16005 S.
Diag(ExternCLoc, diag::note_extern_c_begins_here);
16013 assert(getLangOpts().ModulesTS &&
16014 "should only have module decl in modules TS");
16019 switch (getLangOpts().getCompilingModule()) {
16025 if (MDK != ModuleDeclKind::Implementation)
16030 Diag(ModuleLoc, diag::err_module_interface_implementation_mismatch)
16032 MDK = ModuleDeclKind::Interface;
16036 Diag(ModuleLoc, diag::err_module_decl_in_module_map_module);
16040 assert(ModuleScopes.size() == 1 &&
"expected to be at global module scope");
16047 Diag(ModuleLoc, diag::err_module_redeclaration);
16048 Diag(VisibleModules.getImportLoc(ModuleScopes.back().Module),
16049 diag::note_prev_module_declaration);
16056 std::string ModuleName;
16057 for (
auto &Piece : Path) {
16058 if (!ModuleName.empty())
16060 ModuleName += Piece.first->getName();
16065 if (!getLangOpts().CurrentModule.empty() &&
16066 getLangOpts().CurrentModule != ModuleName) {
16067 Diag(Path.front().second, diag::err_current_module_name_mismatch)
16068 <<
SourceRange(Path.front().second, Path.back().second)
16069 << getLangOpts().CurrentModule;
16072 const_cast<LangOptions&
>(getLangOpts()).CurrentModule = ModuleName;
16074 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
16078 case ModuleDeclKind::Interface: {
16081 if (
auto *M = Map.findModule(ModuleName)) {
16082 Diag(Path[0].second, diag::err_module_redefinition) << ModuleName;
16083 if (M->DefinitionLoc.isValid())
16084 Diag(M->DefinitionLoc, diag::note_prev_module_definition);
16085 else if (
const auto *FE = M->getASTFile())
16086 Diag(M->DefinitionLoc, diag::note_prev_module_definition_from_ast_file)
16093 Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
16094 ModuleScopes.front().Module);
16095 assert(Mod &&
"module creation should not fail");
16099 case ModuleDeclKind::Partition:
16103 case ModuleDeclKind::Implementation:
16104 std::pair<IdentifierInfo *, SourceLocation> ModuleNameLoc(
16105 PP.getIdentifierInfo(ModuleName), Path[0].second);
16109 Diag(ModuleLoc, diag::err_module_not_defined) << ModuleName;
16111 Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
16112 ModuleScopes.front().Module);
16118 ModuleScopes.back().Module = Mod;
16119 ModuleScopes.back().ModuleInterface = MDK != ModuleDeclKind::Implementation;
16120 VisibleModules.setVisible(Mod, ModuleLoc);
16127 TU->setLocalOwningModule(Mod);
16142 VisibleModules.setVisible(Mod, ImportLoc);
16152 (getLangOpts().isCompilingModule() || !getLangOpts().ModulesTS))
16153 Diag(ImportLoc, getLangOpts().isCompilingModule()
16154 ? diag::err_module_self_import
16155 : diag::err_module_import_in_implementation)
16160 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
16165 ModCheck = ModCheck->
Parent;
16167 IdentifierLocs.push_back(Path[I].second);
16171 Mod, IdentifierLocs);
16172 if (!ModuleScopes.empty())
16174 CurContext->addDecl(Import);
16178 !ModuleScopes.empty() && ModuleScopes.back().ModuleInterface)
16179 getCurrentModule()->Exports.emplace_back(Mod,
false);
16186 BuildModuleInclude(DirectiveLoc, Mod);
16195 bool IsInModuleIncludes =
16197 getSourceManager().isWrittenInMainFile(DirectiveLoc);
16199 bool ShouldAddImport = !IsInModuleIncludes;
16203 if (ShouldAddImport) {
16208 if (!ModuleScopes.empty())
16211 Consumer.HandleImplicitImportDecl(ImportD);
16215 VisibleModules.setVisible(Mod, DirectiveLoc);
16221 ModuleScopes.push_back({});
16222 ModuleScopes.back().Module = Mod;
16223 if (getLangOpts().ModulesLocalVisibility)
16224 ModuleScopes.back().OuterVisibleModules = std::move(VisibleModules);
16226 VisibleModules.setVisible(Mod, DirectiveLoc);
16231 if (getLangOpts().trackLocalOwningModule()) {
16232 for (
auto *DC = CurContext; DC; DC = DC->getLexicalParent()) {
16233 cast<Decl>(DC)->setModuleOwnershipKind(
16234 getLangOpts().ModulesLocalVisibility
16237 cast<Decl>(DC)->setLocalOwningModule(Mod);
16243 if (getLangOpts().ModulesLocalVisibility) {
16244 VisibleModules = std::move(ModuleScopes.back().OuterVisibleModules);
16247 VisibleNamespaceCache.clear();
16250 assert(!ModuleScopes.empty() && ModuleScopes.back().Module == Mod &&
16251 "left the wrong module scope");
16252 ModuleScopes.pop_back();
16256 FileID File = getSourceManager().getFileID(EomLoc);
16258 if (EomLoc == getSourceManager().getLocForEndOfFile(File)) {
16260 assert(File != getSourceManager().getMainFileID() &&
16261 "end of submodule in main source file");
16262 DirectiveLoc = getSourceManager().getIncludeLoc(File);
16265 DirectiveLoc = EomLoc;
16267 BuildModuleInclude(DirectiveLoc, Mod);
16270 if (getLangOpts().trackLocalOwningModule()) {
16273 for (
auto *DC = CurContext; DC; DC = DC->getLexicalParent()) {
16274 cast<Decl>(DC)->setLocalOwningModule(getCurrentModule());
16275 if (!getCurrentModule())
16276 cast<Decl>(DC)->setModuleOwnershipKind(
16285 if (isSFINAEContext() || !getLangOpts().ModulesErrorRecovery ||
16286 VisibleModules.isVisible(Mod))
16294 Consumer.HandleImplicitImportDecl(ImportD);
16298 VisibleModules.setVisible(Mod, Loc);
16310 if (ModuleScopes.empty() || !ModuleScopes.back().ModuleInterface)
16311 Diag(ExportLoc, diag::err_export_not_in_module_interface);
16319 Diag(ExportLoc, diag::err_export_within_export);
16321 CurContext->addDecl(D);
16322 PushDeclContext(S, D);
16329 auto *ED = cast<ExportDecl>(D);
16331 ED->setRBraceLoc(RBraceLoc);
16345 NamedDecl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc,
16346 LookupOrdinaryName);
16347 AsmLabelAttr *
Attr =
16348 AsmLabelAttr::CreateImplicit(Context, AliasName->
getName(), AliasNameLoc);
16354 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
16358 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
16359 << (isa<FunctionDecl>(PrevDecl) ? 0 : 1) << PrevDecl;
16362 (
void)ExtnameUndeclaredIdentifiers.insert(std::make_pair(Name, Attr));
16368 Decl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName);
16371 PrevDecl->
addAttr(WeakAttr::CreateImplicit(Context, PragmaLoc));
16373 (void)WeakUndeclaredIdentifiers.insert(
16374 std::pair<IdentifierInfo*,WeakInfo>
16384 Decl *PrevDecl = LookupSingleName(TUScope, AliasName, AliasNameLoc,
16385 LookupOrdinaryName);
16388 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
16389 if (!PrevDecl->
hasAttr<AliasAttr>())
16390 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
16391 DeclApplyPragmaWeak(TUScope, ND, W);
16393 (void)WeakUndeclaredIdentifiers.insert(
16394 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W));
16399 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.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
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)
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)
An instance of this class is created to represent 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.
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.
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
static void CheckForDuplicateEnumValues(Sema &S, ArrayRef< Decl *> Elements, EnumDecl *Enum, QualType EnumType)
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
bool CheckNontrivialField(FieldDecl *FD)
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
no exception specification
QualType getObjCIdType() const
Represents the Objective-CC id type.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void setAnonymousStructOrUnion(bool Anon)
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
A (possibly-)qualified type.
Keeps information about an identifier in a nested-name-spec.
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, tok::ObjCKeywordKind visibility)
ActOnIvar - Each ivar field of an objective-c class is passed into this in order to create an IvarDec...
bool isBlockPointerType() const
TagDecl * getDefinition() const
getDefinition - 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)
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
isOverloadedOperator - Whether this function declaration represents an C++ overloaded 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
AttributeList * getNext() 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...
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
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.
AmbiguityKind getAmbiguityKind() const
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl *> CH)
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.
EnumConstantDecl - 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)
TypedefDecl - 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.
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, TemplateArgumentListInfo TemplateArgs)
bool hasVolatileMember() const
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
bool isRecordType() const
bool isEmpty() const
No scope specifier.
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
void erase()
Erase the last element returned from this iterator.
static const TST TST_typeofExpr
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
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.
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...
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
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
A constructor named via a template-id.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this field is ...
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.
NamespaceDecl - 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()
completeDefinition - Notes 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.
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 is defined at all, including a deleted definition.
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.
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext...
size_t param_size() const
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
QualType getElementType() const
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
bool isCompleteDefinition() const
isCompleteDefinition - 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)
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.
VarDecl - An instance of this class is created to represent 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
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)
ParmVarDecl - Represents a parameter to a function.
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
AttributeList * getList() const
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
isAnonymousStructOrUnion - Determines whether this field is a representative for an anonymous struct ...
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
getIdentifier - 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
RecordDecl - 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
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
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.
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
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
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.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
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...
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
ArrayRef< QualType > getParamTypes() const
The results of name lookup within a DeclContext.
SourceLocation getTypeSpecTypeLoc() const
const ParmVarDecl *const * param_const_iterator
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
TypeLoc getInnerLoc() const
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e...
Missing a type from <ucontext.h>
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
unsigned getFunctionPrototypeDepth() const
Returns the number of function prototype scopes in this scope chain.
RecordDecl * getDefinition() const
getDefinition - 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.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
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)
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.
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().
SourceLocation getLocStart() const LLVM_READONLY
LookupResultKind getResultKind() const
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, AttributeList *Attrs, SourceLocation EqualLoc, Expr *Val)
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.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
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...
Decl * ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
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)
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...
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl *> Elements, Scope *S, AttributeList *Attr)
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
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
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.
TypeDecl - 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.
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 unqualfied nam...
enum clang::DeclaratorChunk::@198 Kind
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
unsigned getMSLastManglingNumber() const
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
unsigned getBitWidthValue(const ASTContext &Ctx) 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>.
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
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...
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...
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
isAnonymousStructOrUnion - 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...
SmallVectorImpl< NamedDecl * >::const_iterator const_decl_iterator
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)
completeDefinition - 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
isFileVarDecl - 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.
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
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)
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...
SourceLocation getBeginLoc() const
Get the begin source location.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
bool isObjCGCStrong() const
true when Type is objc's strong.
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
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
hasLocalStorage - 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.
const FunctionProtoType * T
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"...
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
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.
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 (definition).
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)
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.
Direct list-initialization (C++11)
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
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)
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 overriden 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 TypeLock is not of the desire...
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr)
Perform name lookup on the given name, classifying it based on the results of name lookup and the fol...
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.
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)
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.
const AttributeList * getAttributes() const
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...
static bool hasParsedAttr(Scope *S, const AttributeList *AttrList, AttributeList::Kind Kind)
QualType getCanonicalType() const
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
TypeLoc IgnoreParens() const
param_type_range param_types() const
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
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
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...
bool duplicatesAllowed() const
By default, attributes cannot be duplicated when being merged; however, an attribute can override thi...
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.
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)
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 ...
TagDecl - 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...
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
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.
LabelDecl - Represents the declaration of a label.
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)
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T)
Retrieve a version of the type 'T' that is elaborated by Keyword and qualified by the nested-name-spe...
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 isAnyPointerType() const
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.
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.
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)
SourceLocation getLocStart() const LLVM_READONLY
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...
MutableArrayRef< Expr * > MultiExprArg
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
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...
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
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.
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool EnumUnderlyingIsImplicit, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
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.
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
EnumDecl - Represents an enum.
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.
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
DeclarationNameInfo getNameInfo() 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)
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
isStaticLocal - 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)
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.
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)
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
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.
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
isThisDeclarationADefinition() - Return true if this declaration is a completion definition of the ty...
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)
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
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
getIntegerType - Return the integer type this enum decl corresponds to.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body - that is, if it is a non-delete...
StringRef getName() const
getName - 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.
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.
TranslationUnitDecl - 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.
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
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
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.
bool isLocalVarDecl() const
isLocalVarDecl - 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)
NamedDecl - This represents a decl with a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool isTranslationUnit() const
Expr * getRepAsExpr() const
void setTypeSourceInfo(TypeSourceInfo *newType)
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
Represents a C array with a specified size that is not an integer-constant-expression.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
static bool shouldWarnIfShadowedDecl(const DiagnosticsEngine &Diags, const LookupResult &R)
No keyword precedes the qualified type name.
bool isInline() const
Whether this variable is (C++1z) inline.
static bool IsDisallowedCopyOrAssign(const CXXMethodDecl *D)
Check for this common pattern:
static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND)
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool IsTemplateTypeArg)
Attempt to behave like MSVC in situations where lookup of an unqualified type name has failed in a de...
static bool mergeTypeWithPrevious(Sema &S, VarDecl *NewVD, VarDecl *OldVD, LookupResult &Previous)
SourceLocation getNameLoc() const
Gets the location of the identifier.
Describes an entity that is being initialized.
bool isFunctionPointerType() const
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
attr::Kind getKind() const
unsigned NumArgs
NumArgs - The number of template arguments.
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl *> Fields, SourceLocation LBrac, SourceLocation RBrac, AttributeList *AttrList)
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)
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Missing a type from <setjmp.h>
SourceLocation getLocStart() const LLVM_READONLY
void setType(QualType newType)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
Wrapper for source info for pointers.
SourceLocation getBegin() const
TranslationUnitDecl * getTranslationUnitDecl()
ParsedAttributes - A collection of parsed attributes.
const LangOptions & getLangOpts() const
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
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
isBeingDefined - 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)
AttributeList - Represents a syntactic attribute.
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.
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.