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 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
70 AllowClassTemplates(AllowTemplates) {
71 WantExpressionKeywords =
false;
72 WantCXXNamedCasts =
false;
73 WantRemainingKeywords =
false;
78 bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
79 bool AllowedTemplate = AllowClassTemplates && isa<ClassTemplateDecl>(ND);
80 return (IsType || AllowedTemplate) &&
81 (AllowInvalidDecl || !ND->isInvalidDecl());
83 return !WantClassName && candidate.
isKeyword();
87 bool AllowInvalidDecl;
89 bool AllowClassTemplates;
101 case tok::kw___int64:
102 case tok::kw___int128:
104 case tok::kw_unsigned:
111 case tok::kw___float128:
112 case tok::kw_wchar_t:
114 case tok::kw___underlying_type:
115 case tok::kw___auto_type:
118 case tok::annot_typename:
119 case tok::kw_char16_t:
120 case tok::kw_char32_t:
122 case tok::annot_decltype:
123 case tok::kw_decltype:
124 return getLangOpts().CPlusPlus;
150 return UnqualifiedTypeNameLookupResult::NotFound;
153 UnqualifiedTypeNameLookupResult::NotFound;
156 if (
auto *BaseTT =
Base.getType()->getAs<
TagType>())
157 BaseRD = BaseTT->getAsCXXRecordDecl();
161 if (!TST || !TST->isDependentType())
163 auto *TD = TST->getTemplateName().getAsTemplateDecl();
166 if (
auto *BasePrimaryTemplate =
167 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
169 BaseRD = BasePrimaryTemplate;
170 else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
172 CTD->findPartialSpecialization(
Base.getType()))
180 if (!isa<TypeDecl>(ND))
181 return UnqualifiedTypeNameLookupResult::FoundNonType;
182 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
184 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
186 case UnqualifiedTypeNameLookupResult::FoundNonType:
187 return UnqualifiedTypeNameLookupResult::FoundNonType;
188 case UnqualifiedTypeNameLookupResult::FoundType:
189 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
191 case UnqualifiedTypeNameLookupResult::NotFound:
198 return FoundTypeDecl;
207 UnqualifiedTypeNameLookupResult::NotFound;
209 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
210 DC = DC->getParent()) {
217 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
223 S.
Diag(NameLoc, diag::ext_found_via_dependent_bases_lookup) << &II;
251 bool isClassName,
bool HasTrailingDot,
253 bool IsCtorOrDtorName,
254 bool WantNontrivialTypeSourceInfo,
261 LookupCtx = computeDeclContext(ObjectType);
263 LookupCtx = computeDeclContext(*SS,
false);
266 if (isDependentScopeSpecifier(*SS)) {
276 if (!isClassName && !IsCtorOrDtorName)
281 if (WantNontrivialTypeSourceInfo)
282 return ActOnTypenameType(S,
SourceLocation(), *SS, II, NameLoc).get();
294 RequireCompleteDeclContext(*SS, LookupCtx))
308 LookupQualifiedName(Result, LookupCtx);
310 if (ObjectTypePtr && Result.
empty()) {
317 LookupName(Result, S);
321 LookupName(Result, S);
325 if (Result.
empty() && getLangOpts().MSVCCompat && (!SS || SS->
isEmpty())) {
339 llvm::make_unique<TypeNameValidatorCCC>(
true, isClassName),
343 bool MemberOfUnknownSpecialization;
352 if (Correction && (NNS || NewII != &II) &&
357 isTemplateName(S, *NewSSPtr,
false, TemplateName,
nullptr,
false,
358 Template, MemberOfUnknownSpecialization))) {
360 isClassName, HasTrailingDot, ObjectTypePtr,
362 WantNontrivialTypeSourceInfo);
364 diagnoseTypo(Correction,
365 PDiag(diag::err_unknown_type_or_class_name_suggest)
369 *CorrectedII = NewII;
393 Res != ResEnd; ++Res) {
394 if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res)) {
396 (*Res)->getLocation().getRawEncoding() <
397 IIDecl->getLocation().getRawEncoding())
424 assert(IIDecl &&
"Didn't find decl");
427 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
428 DiagnoseUseOfDecl(IIDecl, NameLoc);
431 MarkAnyDeclReferenced(TD->getLocation(), TD,
false);
436 if (SS && SS->
isNotEmpty() && !IsCtorOrDtorName) {
437 if (WantNontrivialTypeSourceInfo) {
442 T = getElaboratedType(
ETK_None, *SS, T);
448 T = getElaboratedType(
ETK_None, *SS, T);
452 (void)DiagnoseUseOfDecl(IDecl, NameLoc);
471 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
473 else if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
475 RD->getTypeForDecl());
476 else if (isa<TranslationUnitDecl>(DC))
479 llvm_unreachable(
"something isn't in TU scope?");
490 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
491 if (MD->getParent()->hasAnyDependentBases())
499 bool IsTemplateTypeArg) {
500 assert(getLangOpts().MSVCCompat &&
"shouldn't be called in non-MSVC mode");
503 if (IsTemplateTypeArg && getCurScope()->isTemplateParamScope()) {
512 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
518 RD->getTypeForDecl());
522 Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
553 LookupName(R, S,
false);
557 switch (TD->getTagKind()) {
584 if (CurContext->isRecord()) {
604 bool AllowClassTemplates) {
606 SuggestedType =
nullptr;
612 llvm::make_unique<TypeNameValidatorCCC>(
613 false,
false, AllowClassTemplates),
614 CTK_ErrorRecovery)) {
615 if (Corrected.isKeyword()) {
617 diagnoseTypo(Corrected, PDiag(diag::err_unknown_typename_suggest) << II);
618 II = Corrected.getCorrectionAsIdentifierInfo();
621 if (!SS || !SS->
isSet()) {
622 diagnoseTypo(Corrected,
623 PDiag(diag::err_unknown_typename_suggest) << II);
624 }
else if (
DeclContext *DC = computeDeclContext(*SS,
false)) {
625 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
626 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
627 II->
getName().equals(CorrectedStr);
628 diagnoseTypo(Corrected,
629 PDiag(diag::err_unknown_nested_typename_suggest)
630 << II << DC << DroppedSpecifier << SS->
getRange());
632 llvm_unreachable(
"could not have corrected a typo here");
636 if (Corrected.getCorrectionSpecifier())
640 getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc,
S,
641 tmpSS.
isSet() ? &tmpSS : SS,
false,
false,
nullptr,
648 if (getLangOpts().CPlusPlus) {
654 bool MemberOfUnknownSpecialization;
655 if (isTemplateName(S, SS ? *SS : EmptySS,
false,
656 Name,
nullptr,
true, TemplateResult,
659 Diag(IILoc, diag::err_template_missing_args) << TplName;
661 Diag(TplDecl->getLocation(), diag::note_template_decl_here)
662 << TplDecl->getTemplateParameters()->getSourceRange();
672 Diag(IILoc, diag::err_unknown_typename) << II;
673 else if (
DeclContext *DC = computeDeclContext(*SS,
false))
674 Diag(IILoc, diag::err_typename_nested_not_found)
676 else if (isDependentScopeSpecifier(*SS)) {
677 unsigned DiagID = diag::err_typename_missing;
678 if (getLangOpts().MSVCCompat && isMicrosoftMissingTypename(SS, S))
679 DiagID = diag::ext_typename_missing;
686 *SS, *II, IILoc).
get();
689 "Invalid scope specifier has already been diagnosed");
697 NextToken.
is(tok::less);
700 if (isa<TypeDecl>(*
I) || isa<ObjCInterfaceDecl>(*I))
703 if (CheckTemplate && isa<TemplateDecl>(*
I))
717 StringRef FixItTagName;
718 switch (Tag->getTagKind()) {
720 FixItTagName =
"class ";
724 FixItTagName =
"enum ";
728 FixItTagName =
"struct ";
732 FixItTagName =
"__interface ";
736 FixItTagName =
"union ";
740 StringRef TagName = FixItTagName.drop_back();
741 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
742 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
747 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
777 bool IsAddressOfOperand,
778 std::unique_ptr<CorrectionCandidateCallback> CCC) {
782 if (NextToken.
is(tok::coloncolon)) {
783 BuildCXXNestedNameSpecifier(S, *Name, NameLoc, NextToken.
getLocation(),
784 QualType(),
false, SS,
nullptr,
false);
788 LookupParsedName(Result, S, &SS, !CurMethod);
792 if (Result.
empty() && SS.
isEmpty() && getLangOpts().MSVCCompat) {
803 ExprResult E = LookupInObjCMethod(Result, S, Name,
true);
808 bool SecondTry =
false;
809 bool IsFilteredTemplateName =
false;
816 if (!SS.
isSet() && NextToken.
is(tok::l_paren)) {
819 if (getLangOpts().CPlusPlus)
820 return BuildDeclarationNameExpr(SS, Result,
true);
834 if (
NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *Name, S)) {
837 return BuildDeclarationNameExpr(SS, Result,
false);
844 if (!getLangOpts().
CPlusPlus && !SecondTry &&
851 if (!SecondTry && CCC) {
856 CTK_ErrorRecovery)) {
857 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
858 unsigned QualifiedDiag = diag::err_no_member_suggest;
860 NamedDecl *FirstDecl = Corrected.getFoundDecl();
861 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
862 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
863 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
864 UnqualifiedDiag = diag::err_no_template_suggest;
865 QualifiedDiag = diag::err_no_member_template_suggest;
866 }
else if (UnderlyingFirstDecl &&
867 (isa<TypeDecl>(UnderlyingFirstDecl) ||
868 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
869 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
870 UnqualifiedDiag = diag::err_unknown_typename_suggest;
871 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
875 diagnoseTypo(Corrected, PDiag(UnqualifiedDiag) << Name);
877 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
878 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
879 Name->
getName().equals(CorrectedStr);
880 diagnoseTypo(Corrected, PDiag(QualifiedDiag)
881 << Name << computeDeclContext(SS,
false)
882 << DroppedSpecifier << SS.getRange());
886 Name = Corrected.getCorrectionAsIdentifierInfo();
889 if (Corrected.isKeyword())
905 ExprResult E(LookupInObjCMethod(Result, S, Ivar->getIdentifier()));
933 NameInfo, IsAddressOfOperand,
943 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
944 hasAnyAcceptableTemplateNames(Result)) {
956 FilterAcceptableTemplateNames(Result);
958 IsFilteredTemplateName =
true;
967 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
968 (IsFilteredTemplateName || hasAnyAcceptableTemplateNames(Result))) {
975 if (!IsFilteredTemplateName)
976 FilterAcceptableTemplateNames(Result);
978 if (!Result.
empty()) {
979 bool IsFunctionTemplate;
982 if (Result.
end() - Result.
begin() > 1) {
983 IsFunctionTemplate =
true;
988 = cast<TemplateDecl>((*Result.
begin())->getUnderlyingDecl());
989 IsFunctionTemplate = isa<FunctionTemplateDecl>(TD);
990 IsVarTemplate = isa<VarTemplateDecl>(TD);
1000 if (IsFunctionTemplate) {
1006 return NameClassification::FunctionTemplate(Template);
1009 return IsVarTemplate ? NameClassification::VarTemplate(Template)
1010 : NameClassification::TypeTemplate(Template);
1016 DiagnoseUseOfDecl(
Type, NameLoc);
1017 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
1028 dyn_cast<ObjCCompatibleAliasDecl>(FirstDecl))
1029 Class = Alias->getClassInterface();
1033 DiagnoseUseOfDecl(Class, NameLoc);
1035 if (NextToken.
is(tok::period)) {
1047 if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl))
1048 return NameClassification::TypeTemplate(
1053 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1054 if ((NextToken.
is(tok::identifier) ||
1059 DiagnoseUseOfDecl(Type, NameLoc);
1067 return BuildPossibleImplicitMemberExpr(SS,
SourceLocation(), Result,
1070 bool ADL = UseArgumentDependentLookup(SS, Result, NextToken.
is(tok::l_paren));
1071 return BuildDeclarationNameExpr(SS, Result, ADL);
1096 if (!isa<CXXRecordDecl>(DC))
1114 assert(getContainingDC(DC) == CurContext &&
1115 "The next DeclContext should be lexically contained in the current one.");
1121 assert(CurContext &&
"DeclContext imbalance!");
1123 CurContext = getContainingDC(CurContext);
1124 assert(CurContext &&
"Popped translation unit!");
1134 assert(CurContext &&
"skipping definition of undefined tag");
1137 S->
setEntity(CurContext->getLookupParent());
1142 CurContext =
static_cast<decltype(CurContext)
>(
Context);
1165 assert(!S->
getEntity() &&
"scope already has entity");
1169 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1170 assert(Ancestor->getEntity() == CurContext &&
"ancestor context mismatch");
1178 assert(S->
getEntity() == CurContext &&
"Context imbalance!");
1183 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1200 "The next DeclContext should be lexically contained in the current one.");
1204 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1209 IdResolver.AddDecl(Param);
1217 assert(CurContext &&
"DeclContext imbalance!");
1218 CurContext = CurContext->getLexicalParent();
1219 assert(CurContext &&
"Popped translation unit!");
1240 && Previous.
getFoundDecl()->hasAttr<OverloadableAttr>());
1255 CurContext->addDecl(D);
1259 if (getLangOpts().
CPlusPlus && D->isOutOfLine() &&
1260 !D->getDeclContext()->getRedeclContext()->Equals(
1261 D->getLexicalDeclContext()->getRedeclContext()) &&
1262 !D->getLexicalDeclContext()->isFunctionOrMethod())
1266 if (isa<FunctionDecl>(D) &&
1267 cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
1272 IEnd = IdResolver.end();
1273 for (; I != IEnd; ++
I) {
1276 IdResolver.RemoveDecl(*I);
1285 if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) {
1289 for (I = IdResolver.begin(D->
getDeclName()); I != IEnd; ++
I) {
1291 if (IDC == CurContext) {
1294 }
else if (IDC->
Encloses(CurContext))
1298 IdResolver.InsertDeclAfter(I, D);
1300 IdResolver.AddDecl(D);
1305 if (IdResolver.tryAddTopLevelDecl(D, Name) && TUScope)
1306 TUScope->AddDecl(D);
1310 bool AllowInlineNamespace) {
1311 return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace);
1318 if (ScopeDC->getPrimaryContext() == TargetDC)
1332 bool ConsiderLinkage,
1333 bool AllowInlineNamespace) {
1338 if (isDeclInScope(D, Ctx, S, AllowInlineNamespace))
1351 return isa<UsingShadowDecl>(D) ||
1352 isa<UnresolvedUsingTypenameDecl>(D) ||
1353 isa<UnresolvedUsingValueDecl>(D);
1380 return CD->isCopyConstructor();
1381 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
1382 return Method->isCopyAssignmentOperator();
1398 bool Sema::mightHaveNonExternalLinkage(
const DeclaratorDecl *D) {
1401 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1402 if (!RD->hasNameForLinkage())
1422 if (D->isInvalidDecl() || D->isUsed() || D->hasAttr<UnusedAttr>())
1427 if (D->getDeclContext()->isDependentContext() ||
1428 D->getLexicalDeclContext()->isDependentContext())
1431 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1435 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1440 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1444 if (FD->doesThisDeclarationHaveABody() &&
1447 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1457 if (VD->isStaticDataMember() &&
1461 if (VD->isInline() && !
isMainFileLoc(*
this, VD->getLocation()))
1470 return mightHaveNonExternalLinkage(D);
1477 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1479 if (FD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1483 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1485 if (VD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1489 if (ShouldWarnIfUnusedFileScopedDecl(D))
1490 UnusedFileScopedDecls.push_back(D);
1494 if (D->isInvalidDecl())
1497 if (D->isReferenced() || D->isUsed() || D->hasAttr<UnusedAttr>() ||
1498 D->hasAttr<ObjCPreciseLifetimeAttr>())
1501 if (isa<LabelDecl>(D))
1506 bool WithinFunction = D->getDeclContext()->isFunctionOrMethod();
1507 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->getDeclContext()))
1510 WithinFunction || (R->isLocalClass() && !R->isDependentType());
1511 if (!WithinFunction)
1514 if (isa<TypedefNameDecl>(D))
1518 if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D))
1522 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1529 if (TT->getDecl()->hasAttr<UnusedAttr>())
1539 const TagDecl *Tag = TT->getDecl();
1540 if (Tag->hasAttr<UnusedAttr>())
1543 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) {
1544 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
1547 if (
const Expr *Init = VD->getInit()) {
1549 dyn_cast<ExprWithCleanups>(Init))
1550 Init = Cleanups->getSubExpr();
1555 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>())
1570 if (isa<LabelDecl>(D)) {
1576 getCharRange(D->getLocStart(), AfterColon));
1584 for (
auto *TmpD : D->
decls()) {
1585 if (
const auto *T = dyn_cast<TypedefNameDecl>(TmpD))
1586 DiagnoseUnusedDecl(T);
1587 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
1588 DiagnoseUnusedNestedTypedefs(R);
1598 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1601 UnusedLocalTypedefNameCandidates.insert(TD);
1609 if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
1610 DiagID = diag::warn_unused_exception_param;
1611 else if (isa<LabelDecl>(D))
1612 DiagID = diag::warn_unused_label;
1614 DiagID = diag::warn_unused_variable;
1624 bool Diagnose =
false;
1628 Diagnose = L->
getStmt() ==
nullptr;
1630 S.
Diag(L->getLocation(), diag::err_undeclared_label_use) <<L->
getDeclName();
1638 "Scope shouldn't contain decls!");
1640 for (
auto *TmpD : S->
decls()) {
1641 assert(TmpD &&
"This decl didn't get pushed??");
1643 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
1650 DiagnoseUnusedDecl(D);
1651 if (
const auto *RD = dyn_cast<RecordDecl>(D))
1652 DiagnoseUnusedNestedTypedefs(RD);
1656 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
1661 IdResolver.RemoveDecl(D);
1662 auto ShadowI = ShadowingDecls.find(D);
1663 if (ShadowI != ShadowingDecls.end()) {
1664 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
1665 Diag(D->getLocation(), diag::warn_ctor_parm_shadows_field)
1666 << D << FD << FD->getParent();
1667 Diag(FD->getLocation(), diag::note_previous_declaration);
1669 ShadowingDecls.erase(ShadowI);
1689 bool DoTypoCorrection) {
1692 NamedDecl *IDecl = LookupSingleName(TUScope, Id, IdLoc, LookupOrdinaryName);
1694 if (!IDecl && DoTypoCorrection) {
1700 CTK_ErrorRecovery)) {
1701 diagnoseTypo(C, PDiag(diag::err_undef_interface_suggest) << Id);
1750 if (!II->
isStr(
"objc_msgSendSuper"))
1771 return "ucontext.h";
1773 llvm_unreachable(
"unhandled error kind");
1781 Scope *
S,
bool ForRedeclaration,
1788 if (ForRedeclaration)
1789 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
1795 Diag(Loc, diag::ext_implicit_lib_function_decl)
1798 !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc))
1799 Diag(Loc, diag::note_include_header_or_declare)
1812 CLinkageDecl->setImplicit();
1813 Parent->
addDecl(CLinkageDecl);
1814 Parent = CLinkageDecl;
1819 Loc, Loc, II, R,
nullptr,
1829 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
1832 nullptr, FT->getParamType(i),
nullptr,
1835 Params.push_back(parm);
1837 New->setParams(Params);
1840 AddKnownFunctionAttributes(New);
1841 RegisterLocallyScopedExternCDecl(New, S);
1848 CurContext = Parent;
1849 PushOnScopeChains(New, TUScope);
1850 CurContext = SavedContext;
1866 if (Previous.
empty())
1879 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
1887 OldTD->getAnonDeclWithTypedefName(
true) &&
1901 OldType = OldTypedef->getUnderlyingType();
1908 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
1909 Diag(New->getLocation(), diag::err_redefinition_variably_modified_typedef)
1911 if (Old->getLocation().isValid())
1912 Diag(Old->getLocation(), diag::note_previous_definition);
1913 New->setInvalidDecl();
1917 if (OldType != NewType &&
1921 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
1922 Diag(New->getLocation(), diag::err_redefinition_different_typedef)
1923 << Kind << NewType << OldType;
1924 if (Old->getLocation().isValid())
1925 Diag(Old->getLocation(), diag::note_previous_definition);
1926 New->setInvalidDecl();
1941 if (New->isInvalidDecl())
return;
1945 if (getLangOpts().ObjC1) {
1951 if (!TypeID->
isStr(
"id"))
1967 if (!TypeID->
isStr(
"Class"))
1974 if (!TypeID->
isStr(
"SEL"))
1987 Diag(New->getLocation(), diag::err_redefinition_different_kind)
1991 if (OldD->getLocation().isValid())
1992 Diag(OldD->getLocation(), diag::note_previous_definition);
1994 return New->setInvalidDecl();
1998 if (Old->isInvalidDecl())
1999 return New->setInvalidDecl();
2001 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2005 if (getLangOpts().
CPlusPlus && OldTag && NewTag &&
2006 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
2007 !hasVisibleDefinition(OldTag, &Hidden)) {
2011 if (OldTD->isModed())
2013 OldTD->getUnderlyingType());
2018 makeMergedDefinitionVisible(Hidden, NewTag->getLocation());
2022 if (isa<EnumDecl>(NewTag)) {
2023 Scope *EnumScope = getNonFieldDeclScope(S);
2024 for (
auto *D : NewTag->decls()) {
2025 auto *ED = cast<EnumConstantDecl>(D);
2028 IdResolver.RemoveDecl(ED);
2029 ED->getLexicalDeclContext()->removeDecl(ED);
2037 if (isIncompatibleTypedef(Old, New))
2044 mergeDeclAttributes(New, Old);
2047 if (getLangOpts().MicrosoftExt)
2055 if (!isa<CXXRecordDecl>(CurContext))
2079 if (!isa<TypedefNameDecl>(Old))
2082 Diag(New->getLocation(), diag::err_redefinition)
2084 Diag(Old->getLocation(), diag::note_previous_definition);
2085 return New->setInvalidDecl();
2089 if (getLangOpts().Modules || getLangOpts().
C11)
2096 if (getDiagnostics().getSuppressSystemWarnings() &&
2101 Diag(New->getLocation(), diag::ext_redefinition_of_typedef)
2103 Diag(Old->getLocation(), diag::note_previous_definition);
2109 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2110 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2111 for (
const auto *i : D->attrs())
2112 if (i->getKind() == A->
getKind()) {
2114 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2119 if (OA && isa<OwnershipAttr>(i))
2120 return OA->getOwnKind() == cast<OwnershipAttr>(i)->getOwnKind();
2128 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2129 return VD->isThisDeclarationADefinition();
2130 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2131 return TD->isCompleteDefinition() || TD->isBeingDefined();
2142 AlignedAttr *OldAlignasAttr =
nullptr;
2143 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2144 unsigned OldAlign = 0;
2145 for (
auto *
I : Old->specific_attrs<AlignedAttr>()) {
2152 if (
I->isAlignmentDependent())
2158 unsigned Align =
I->getAlignment(S.
Context);
2159 if (Align > OldAlign) {
2161 OldStrictestAlignAttr =
I;
2166 AlignedAttr *NewAlignasAttr =
nullptr;
2167 unsigned NewAlign = 0;
2168 for (
auto *
I : New->specific_attrs<AlignedAttr>()) {
2169 if (
I->isAlignmentDependent())
2175 unsigned Align =
I->getAlignment(S.
Context);
2176 if (Align > NewAlign)
2180 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2188 if (OldAlign == 0 || NewAlign == 0) {
2190 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2201 if (OldAlign != NewAlign) {
2202 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2205 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2218 S.
Diag(New->getLocation(), diag::err_alignas_missing_on_definition)
2220 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2224 bool AnyAdded =
false;
2227 if (OldAlign > NewAlign) {
2228 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2229 Clone->setInherited(
true);
2230 New->addAttr(Clone);
2235 if (OldAlignasAttr && !NewAlignasAttr &&
2236 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2237 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2238 Clone->setInherited(
true);
2239 New->addAttr(Clone);
2251 if (
const auto *AA = dyn_cast<AvailabilityAttr>(Attr))
2253 AA->isImplicit(), AA->getIntroduced(),
2254 AA->getDeprecated(),
2255 AA->getObsoleted(), AA->getUnavailable(),
2256 AA->getMessage(), AA->getStrict(),
2257 AA->getReplacement(), AMK,
2258 AttrSpellingListIndex);
2259 else if (
const auto *VA = dyn_cast<VisibilityAttr>(Attr))
2261 AttrSpellingListIndex);
2262 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(Attr))
2264 AttrSpellingListIndex);
2265 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(Attr))
2267 AttrSpellingListIndex);
2268 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(Attr))
2270 AttrSpellingListIndex);
2271 else if (
const auto *FA = dyn_cast<FormatAttr>(Attr))
2273 FA->getFormatIdx(), FA->getFirstArg(),
2274 AttrSpellingListIndex);
2275 else if (
const auto *SA = dyn_cast<SectionAttr>(Attr))
2277 AttrSpellingListIndex);
2278 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(Attr))
2280 AttrSpellingListIndex,
2281 IA->getSemanticSpelling());
2282 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(Attr))
2285 AttrSpellingListIndex);
2286 else if (
const auto *MA = dyn_cast<MinSizeAttr>(Attr))
2288 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(Attr))
2290 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(Attr))
2292 D, InternalLinkageA->getRange(),
2294 AttrSpellingListIndex);
2295 else if (
const auto *CommonA = dyn_cast<CommonAttr>(Attr))
2298 AttrSpellingListIndex);
2299 else if (isa<AlignedAttr>(Attr))
2303 else if ((isa<DeprecatedAttr>(Attr) || isa<UnavailableAttr>(Attr)) &&
2308 NewAttr = cast<InheritableAttr>(Attr->
clone(S.
Context));
2312 D->addAttr(NewAttr);
2313 if (isa<MSInheritanceAttr>(NewAttr))
2322 if (
const TagDecl *TD = dyn_cast<TagDecl>(D))
2323 return TD->getDefinition();
2324 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2330 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
2336 for (
const auto *Attribute : D->attrs())
2337 if (Attribute->getKind() ==
Kind)
2345 if (!New->hasAttrs())
2349 if (!Def || Def == New)
2352 AttrVec &NewAttributes = New->getAttrs();
2353 for (
unsigned I = 0,
E = NewAttributes.size();
I !=
E;) {
2354 const Attr *NewAttribute = NewAttributes[
I];
2356 if (isa<AliasAttr>(NewAttribute) || isa<IFuncAttr>(NewAttribute)) {
2363 NewAttributes.erase(NewAttributes.begin() +
I);
2368 VarDecl *VD = cast<VarDecl>(New);
2369 unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
2371 ? diag::err_alias_after_tentative
2372 : diag::err_redefinition;
2374 S.
Diag(Def->getLocation(), diag::note_previous_definition);
2375 VD->setInvalidDecl();
2381 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
2394 if (isa<C11NoReturnAttr>(NewAttribute)) {
2398 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
2399 if (AA->isAlignas()) {
2408 S.
Diag(Def->getLocation(), diag::err_alignas_missing_on_definition)
2410 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
2412 NewAttributes.erase(NewAttributes.begin() +
I);
2419 diag::warn_attribute_precede_definition);
2420 S.
Diag(Def->getLocation(), diag::note_previous_definition);
2421 NewAttributes.erase(NewAttributes.begin() +
I);
2429 if (UsedAttr *OldAttr = Old->getMostRecentDecl()->getAttr<UsedAttr>()) {
2430 UsedAttr *NewAttr = OldAttr->clone(
Context);
2431 NewAttr->setInherited(
true);
2432 New->addAttr(NewAttr);
2435 if (!Old->hasAttrs() && !New->hasAttrs())
2441 if (AsmLabelAttr *NewA = New->getAttr<AsmLabelAttr>()) {
2442 if (AsmLabelAttr *OldA = Old->getAttr<AsmLabelAttr>()) {
2443 if (OldA->getLabel() != NewA->getLabel()) {
2445 Diag(New->getLocation(), diag::err_different_asm_label);
2446 Diag(OldA->getLocation(), diag::note_previous_declaration);
2448 }
else if (Old->isUsed()) {
2451 Diag(New->getLocation(), diag::err_late_asm_label_name)
2452 << isa<FunctionDecl>(Old) << New->getAttr<AsmLabelAttr>()->getRange();
2457 if (
const auto *NewAbiTagAttr = New->getAttr<AbiTagAttr>()) {
2458 if (
const auto *OldAbiTagAttr = Old->getAttr<AbiTagAttr>()) {
2459 for (
const auto &NewTag : NewAbiTagAttr->tags()) {
2460 if (std::find(OldAbiTagAttr->tags_begin(), OldAbiTagAttr->tags_end(),
2461 NewTag) == OldAbiTagAttr->tags_end()) {
2462 Diag(NewAbiTagAttr->getLocation(),
2463 diag::err_new_abi_tag_on_redeclaration)
2465 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
2469 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
2470 Diag(Old->getLocation(), diag::note_previous_declaration);
2474 if (!Old->hasAttrs())
2477 bool foundAny = New->hasAttrs();
2481 if (!foundAny) New->setAttrs(
AttrVec());
2486 if (isa<DeprecatedAttr>(
I) ||
2487 isa<UnavailableAttr>(
I) ||
2488 isa<AvailabilityAttr>(
I)) {
2493 case AMK_Redeclaration:
2495 case AMK_ProtocolImplementation:
2502 if (isa<UsedAttr>(
I))
2512 if (!foundAny) New->dropAttrs();
2524 const CarriesDependencyAttr *CDA = newDecl->getAttr<CarriesDependencyAttr>();
2525 if (CDA && !oldDecl->hasAttr<CarriesDependencyAttr>()) {
2526 S.
Diag(CDA->getLocation(),
2527 diag::err_carries_dependency_missing_on_first_decl) << 1;
2531 cast<FunctionDecl>(oldDecl->getDeclContext())->getFirstDecl();
2534 S.
Diag(FirstVD->getLocation(),
2535 diag::note_carries_dependency_missing_first_decl) << 1;
2538 if (!oldDecl->hasAttrs())
2541 bool foundAny = newDecl->hasAttrs();
2545 if (!foundAny) newDecl->setAttrs(
AttrVec());
2550 cast<InheritableParamAttr>(
I->clone(S.
Context));
2552 newDecl->addAttr(newAttr);
2557 if (!foundAny) newDecl->dropAttrs();
2565 if (*Oldnullability != *Newnullability) {
2566 S.
Diag(NewParam->getLocation(), diag::warn_mismatched_nullability_attr)
2575 S.
Diag(OldParam->getLocation(), diag::note_previous_declaration);
2591 struct GNUCompatibleParamWarning {
2602 if (Ctor->isDefaultConstructor())
2605 if (Ctor->isCopyConstructor())
2608 if (Ctor->isMoveConstructor())
2610 }
else if (isa<CXXDestructorDecl>(MD)) {
2623 template <
typename T>
2624 static std::pair<diag::kind, SourceLocation>
2628 if (Old->isThisDeclarationADefinition())
2629 PrevDiag = diag::note_previous_definition;
2630 else if (Old->isImplicit()) {
2631 PrevDiag = diag::note_previous_implicit_declaration;
2633 OldLocation = New->getLocation();
2635 PrevDiag = diag::note_previous_declaration;
2636 return std::make_pair(PrevDiag, OldLocation);
2644 return ((FD->hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
2645 !LangOpts.CPlusPlus &&
2657 template <
typename T>
2671 template<
typename T>
static bool isExternC(T *D) {
return D->isExternC(); }
2677 template<
typename ExpectedDecl>
2679 ExpectedDecl *New) {
2699 !Old->getDeclContext()->getRedeclContext()->Equals(
2700 New->getDeclContext()->getRedeclContext()) &&
2705 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
2718 const auto *AttrA = A->getAttr<PassObjectSizeAttr>();
2719 const auto *AttrB = B->getAttr<PassObjectSizeAttr>();
2722 return AttrA && AttrB && AttrA->
getType() == AttrB->getType();
2725 return std::equal(A->param_begin(), A->param_end(), B->
param_begin(), AttrEq);
2740 Scope *
S,
bool MergeTypeWithOld) {
2745 if (New->getFriendObjectKind()) {
2746 Diag(New->getLocation(), diag::err_using_decl_friend);
2747 Diag(Shadow->getTargetDecl()->getLocation(),
2748 diag::note_using_decl_target);
2749 Diag(Shadow->getUsingDecl()->getLocation(),
2750 diag::note_using_decl) << 0;
2755 if (checkUsingShadowRedecl<FunctionDecl>(*
this, Shadow, New))
2757 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
2759 Diag(New->getLocation(), diag::err_redefinition_different_kind)
2761 Diag(OldD->getLocation(), diag::note_previous_definition);
2767 if (Old->isInvalidDecl())
2772 std::tie(PrevDiag, OldLocation) =
2779 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
2784 if (getLangOpts().MicrosoftExt) {
2785 Diag(New->getLocation(), diag::ext_static_non_static) << New;
2786 Diag(OldLocation, PrevDiag);
2788 Diag(New->getLocation(), diag::err_static_non_static) << New;
2789 Diag(OldLocation, PrevDiag);
2794 if (New->hasAttr<InternalLinkageAttr>() &&
2795 !Old->hasAttr<InternalLinkageAttr>()) {
2796 Diag(New->getLocation(), diag::err_internal_linkage_redeclaration)
2798 Diag(Old->getLocation(), diag::note_previous_definition);
2799 New->dropAttr<InternalLinkageAttr>();
2817 const FunctionType *OldType = cast<FunctionType>(OldQType);
2818 const FunctionType *NewType = cast<FunctionType>(NewQType);
2821 bool RequiresAdjustment =
false;
2823 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC()) {
2828 bool NewCCExplicit = getCallingConvAttributedType(New->
getType());
2829 if (!NewCCExplicit) {
2833 RequiresAdjustment =
true;
2836 bool FirstCCExplicit = getCallingConvAttributedType(First->
getType());
2837 Diag(New->getLocation(), diag::err_cconv_change)
2840 << (!FirstCCExplicit ?
"" :
2844 Diag(First->getLocation(), diag::note_previous_declaration);
2850 if (OldTypeInfo.getNoReturn() && !NewTypeInfo.
getNoReturn()) {
2852 RequiresAdjustment =
true;
2856 if (OldTypeInfo.getHasRegParm() != NewTypeInfo.
getHasRegParm() ||
2857 OldTypeInfo.getRegParm() != NewTypeInfo.
getRegParm()) {
2859 Diag(New->getLocation(), diag::err_regparm_mismatch)
2860 << NewType->getRegParmType()
2862 Diag(OldLocation, diag::note_previous_declaration);
2866 NewTypeInfo = NewTypeInfo.
withRegParm(OldTypeInfo.getRegParm());
2867 RequiresAdjustment =
true;
2873 Diag(New->getLocation(), diag::err_returns_retained_mismatch);
2874 Diag(OldLocation, diag::note_previous_declaration);
2879 RequiresAdjustment =
true;
2882 if (RequiresAdjustment) {
2887 NewType = cast<FunctionType>(NewQType);
2893 !New->hasAttr<GNUInlineAttr>() &&
2894 !getLangOpts().GNUInline &&
2895 Old->isUsed(
false) &&
2902 if (New->hasAttr<GNUInlineAttr>() &&
2903 Old->
isInlined() && !Old->hasAttr<GNUInlineAttr>()) {
2911 Diag(New->getLocation(), diag::err_different_pass_object_size_params)
2913 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
2931 : OldType)->getReturnType();
2935 : NewType)->getReturnType();
2939 New->isLocalExternDecl())) {
2945 Diag(New->getLocation(), diag::err_member_def_does_not_match_ret_type)
2948 Diag(New->getLocation(), diag::err_ovl_diff_return_type)
2950 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
2959 QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType();
2960 if (OldReturnType != NewReturnType) {
2970 SubstAutoType(NewQType,
2978 if (OldMethod && NewMethod) {
2985 bool IsClassScopeExplicitSpecialization =
2987 NewMethod->isFunctionTemplateSpecialization();
2988 bool isFriend = NewMethod->getFriendObjectKind();
2990 if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() &&
2991 !IsClassScopeExplicitSpecialization) {
2995 if (OldMethod->
isStatic() != NewMethod->isStatic()) {
2996 Diag(New->getLocation(), diag::err_ovl_static_nonstatic_member);
2997 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3005 if (ActiveTemplateInstantiations.empty()) {
3007 if (isa<CXXConstructorDecl>(OldMethod))
3008 NewDiag = diag::err_constructor_redeclared;
3009 else if (isa<CXXDestructorDecl>(NewMethod))
3010 NewDiag = diag::err_destructor_redeclared;
3011 else if (isa<CXXConversionDecl>(NewMethod))
3012 NewDiag = diag::err_conv_function_redeclared;
3014 NewDiag = diag::err_member_redeclared;
3016 Diag(New->getLocation(), NewDiag);
3018 Diag(New->getLocation(), diag::err_member_redeclared_in_instantiation)
3021 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3029 }
else if (OldMethod->isImplicit()) {
3031 NewMethod->setImplicit();
3033 Diag(NewMethod->getLocation(),
3034 diag::err_definition_of_implicitly_declared_member)
3035 << New << getSpecialMember(OldMethod);
3039 Diag(NewMethod->getLocation(),
3040 diag::err_definition_of_explicitly_defaulted_member)
3041 << getSpecialMember(OldMethod);
3050 const CXX11NoReturnAttr *NRA = New->getAttr<CXX11NoReturnAttr>();
3051 if (NRA && !Old->hasAttr<CXX11NoReturnAttr>()) {
3052 Diag(NRA->getLocation(), diag::err_noreturn_missing_on_first_decl);
3054 diag::note_noreturn_missing_first_decl);
3061 const CarriesDependencyAttr *CDA = New->getAttr<CarriesDependencyAttr>();
3062 if (CDA && !Old->hasAttr<CarriesDependencyAttr>()) {
3063 Diag(CDA->getLocation(),
3064 diag::err_carries_dependency_missing_on_first_decl) << 0;
3066 diag::note_carries_dependency_missing_first_decl) << 0;
3075 QualType OldQTypeForComparison = OldQType;
3076 if (!OldTypeInfo.getNoReturn() && NewTypeInfo.
getNoReturn()) {
3077 assert(OldQType ==
QualType(OldType, 0));
3080 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
3093 if (New->getFriendObjectKind() != Decl::FOK_None) {
3094 Diag(New->getLocation(), diag::ext_retained_language_linkage) << New;
3095 Diag(OldLocation, PrevDiag);
3097 Diag(New->getLocation(), diag::err_different_language_linkage) << New;
3098 Diag(OldLocation, PrevDiag);
3103 if (OldQTypeForComparison == NewQType)
3104 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3107 New->isLocalExternDecl()) {
3119 if (!getLangOpts().CPlusPlus &&
3124 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
3128 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
3132 OldProto->getExtProtoInfo());
3138 for (
const auto &ParamType : OldProto->param_types()) {
3144 Param->setImplicit();
3145 Params.push_back(Param);
3148 New->setParams(Params);
3151 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3178 NewProto->getReturnType());
3179 bool LooseCompatible = !MergedReturn.
isNull();
3181 LooseCompatible && Idx !=
End; ++Idx) {
3185 NewProto->getParamType(Idx))) {
3186 ArgTypes.push_back(NewParm->
getType());
3190 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
3191 NewProto->getParamType(Idx) };
3192 Warnings.push_back(Warn);
3193 ArgTypes.push_back(NewParm->
getType());
3195 LooseCompatible =
false;
3198 if (LooseCompatible) {
3199 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
3200 Diag(Warnings[Warn].NewParm->getLocation(),
3201 diag::ext_param_promoted_not_compatible_with_prototype)
3202 << Warnings[Warn].PromotedType
3203 << Warnings[Warn].OldParm->getType();
3204 if (Warnings[Warn].OldParm->getLocation().isValid())
3205 Diag(Warnings[Warn].OldParm->getLocation(),
3206 diag::note_previous_declaration);
3209 if (MergeTypeWithOld)
3212 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3224 if (Old->isImplicit() && (BuiltinID = Old->
getBuiltinID())) {
3228 Diag(New->getLocation(), diag::warn_redecl_library_builtin) << New;
3229 Diag(OldLocation, diag::note_previous_builtin_declaration)
3246 PrevDiag = diag::note_previous_builtin_declaration;
3249 Diag(New->getLocation(), diag::err_conflicting_types) << New->
getDeclName();
3250 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3264 Scope *
S,
bool MergeTypeWithOld) {
3266 mergeDeclAttributes(New, Old);
3279 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
3287 return MergeCXXFunctionDecl(New, Old, S);
3293 if (!Merged.
isNull() && MergeTypeWithOld)
3303 isa<ObjCProtocolDecl>(oldMethod->getDeclContext())
3304 ? AMK_ProtocolImplementation
3305 : isa<ObjCImplDecl>(newMethod->getDeclContext()) ? AMK_Redeclaration
3308 mergeDeclAttributes(newMethod, oldMethod, MergeKind);
3315 ni != ne && oi != oe; ++ni, ++oi)
3318 CheckObjCMethodOverride(newMethod, oldMethod);
3325 ? diag::err_redefinition_different_type
3326 : diag::err_redeclaration_different_type)
3331 std::tie(PrevDiag, OldLocation)
3333 S.
Diag(OldLocation, PrevDiag);
3334 New->setInvalidDecl();
3345 bool MergeTypeWithOld) {
3346 if (New->isInvalidDecl() || Old->isInvalidDecl())
3350 if (getLangOpts().CPlusPlus) {
3356 return MergeVarDeclExceptionSpecs(New, Old);
3427 if (MergeTypeWithOld)
3450 (!OldVD->getLexicalDeclContext()->isFunctionOrMethod() &&
3451 !NewVD->getLexicalDeclContext()->isFunctionOrMethod());
3455 return !OldVD->getLexicalDeclContext()->isFunctionOrMethod() ||
3456 OldVD->getLexicalDeclContext() == NewVD->getLexicalDeclContext();
3470 if (New->isInvalidDecl())
3473 if (!shouldLinkPossiblyHiddenDecl(Previous, New))
3488 if (checkUsingShadowRedecl<VarTemplateDecl>(*
this, Shadow, NewTemplate))
3489 return New->setInvalidDecl();
3495 if (checkUsingShadowRedecl<VarDecl>(*
this, Shadow, New))
3496 return New->setInvalidDecl();
3500 Diag(New->getLocation(), diag::err_redefinition_different_kind)
3503 diag::note_previous_definition);
3504 return New->setInvalidDecl();
3511 true, TPL_TemplateMatch))
3512 return New->setInvalidDecl();
3519 Diag(New->getLocation(), diag::err_duplicate_member)
3521 Diag(Old->getLocation(), diag::note_previous_declaration);
3522 New->setInvalidDecl();
3525 mergeDeclAttributes(New, Old);
3528 if (New->hasAttr<WeakImportAttr>() &&
3530 !Old->hasAttr<WeakImportAttr>()) {
3531 Diag(New->getLocation(), diag::warn_weak_import) << New->
getDeclName();
3532 Diag(Old->getLocation(), diag::note_previous_definition);
3534 New->dropAttr<WeakImportAttr>();
3537 if (New->hasAttr<InternalLinkageAttr>() &&
3538 !Old->hasAttr<InternalLinkageAttr>()) {
3539 Diag(New->getLocation(), diag::err_internal_linkage_redeclaration)
3541 Diag(Old->getLocation(), diag::note_previous_definition);
3542 New->dropAttr<InternalLinkageAttr>();
3547 if (MostRecent != Old) {
3548 MergeVarDeclTypes(New, MostRecent,
3550 if (New->isInvalidDecl())
3555 if (New->isInvalidDecl())
3560 std::tie(PrevDiag, OldLocation) =
3567 if (getLangOpts().MicrosoftExt) {
3568 Diag(New->getLocation(), diag::ext_static_non_static)
3570 Diag(OldLocation, PrevDiag);
3572 Diag(New->getLocation(), diag::err_static_non_static)
3574 Diag(OldLocation, PrevDiag);
3575 return New->setInvalidDecl();
3592 Diag(New->getLocation(), diag::err_non_static_static) << New->
getDeclName();
3593 Diag(OldLocation, PrevDiag);
3594 return New->setInvalidDecl();
3600 Diag(New->getLocation(), diag::err_extern_non_extern) << New->
getDeclName();
3601 Diag(OldLocation, PrevDiag);
3602 return New->setInvalidDecl();
3606 Diag(New->getLocation(), diag::err_non_extern_extern) << New->
getDeclName();
3607 Diag(OldLocation, PrevDiag);
3608 return New->setInvalidDecl();
3617 !(Old->getLexicalDeclContext()->isRecord() &&
3618 !New->getLexicalDeclContext()->isRecord())) {
3619 Diag(New->getLocation(), diag::err_redefinition) << New->
getDeclName();
3620 Diag(OldLocation, PrevDiag);
3621 return New->setInvalidDecl();
3629 Diag(New->getLocation(), diag::err_inline_decl_follows_def) << New;
3630 Diag(Def->getLocation(), diag::note_previous_definition);
3643 Diag(New->getLocation(), diag::err_thread_non_thread) << New->
getDeclName();
3644 Diag(OldLocation, PrevDiag);
3646 Diag(New->getLocation(), diag::err_non_thread_thread) << New->
getDeclName();
3647 Diag(OldLocation, PrevDiag);
3653 Diag(New->getLocation(), diag::err_thread_thread_different_kind)
3655 Diag(OldLocation, PrevDiag);
3665 if (!hasVisibleDefinition(Def, &Hidden) &&
3669 New->getDeclContext()->isDependentContext())) {
3676 Diag(New->getLocation(),
3677 diag::warn_deprecated_redundant_constexpr_static_def);
3679 Diag(New->getLocation(), diag::err_redefinition) << New;
3680 Diag(Def->getLocation(), diag::note_previous_definition);
3681 New->setInvalidDecl();
3687 Diag(New->getLocation(), diag::err_different_language_linkage) << New;
3688 Diag(OldLocation, PrevDiag);
3689 New->setInvalidDecl();
3703 New->setAccess(Old->getAccess());
3705 NewTemplate->setAccess(New->getAccess());
3736 if (isa<CXXRecordDecl>(Tag->
getParent())) {
3750 Decl *ManglingContextDecl;
3752 Tag->getDeclContext(), ManglingContextDecl)) {
3754 Tag, MCtx->getManglingNumber(
3761 if (TagFromDeclSpec->isInvalidDecl())
3774 if (getLangOpts().CPlusPlus)
3786 Diag(NewTD->getLocation(), diag::err_typedef_changes_linkage);
3789 tagLoc = getLocForEndOfToken(tagLoc);
3792 textToInsert +=
' ';
3794 Diag(tagLoc, diag::note_typedef_changes_linkage)
3816 llvm_unreachable(
"unexpected type specifier");
3826 bool IsExplicitInstantiation,
3828 Decl *TagD =
nullptr;
3843 if (isa<TagDecl>(TagD))
3844 Tag = cast<TagDecl>(TagD);
3846 Tag = CTD->getTemplatedDecl();
3850 handleTagNumbering(Tag, S);
3852 if (Tag->isInvalidDecl())
3861 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
3867 << getLangOpts().CPlusPlus1z;
3889 DiagnoseFunctionSpecifiers(DS);
3896 return ActOnFriendTypeDecl(S, DS, TemplateParams);
3900 bool IsExplicitSpecialization =
3901 !TemplateParams.empty() && TemplateParams.back()->size() == 0;
3903 !IsExplicitInstantiation && !IsExplicitSpecialization &&
3904 !isa<ClassTemplatePartialSpecializationDecl>(Tag)) {
3913 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
3919 bool DeclaresAnything =
true;
3922 if (
RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
3923 if (!Record->getDeclName() && Record->isCompleteDefinition() &&
3925 if (getLangOpts().CPlusPlus ||
3926 Record->getDeclContext()->isRecord()) {
3934 if (CurContext->isFunctionOrMethod())
3935 AnonRecord = Record;
3936 return BuildAnonymousStructOrUnion(S, DS, AS, Record,
3940 DeclaresAnything =
false;
3950 if (!getLangOpts().CPlusPlus && CurContext->isRecord() &&
3966 Record = RT->getDecl();
3968 Record = UT->getDecl();
3970 if (Record && getLangOpts().MicrosoftExt) {
3973 return BuildMicrosoftCAnonymousStruct(S, DS, Record);
3976 DeclaresAnything =
false;
3982 (TagD && TagD->isInvalidDecl()))
3985 if (getLangOpts().CPlusPlus &&
3987 if (
EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Tag))
3988 if (Enum->enumerator_begin() == Enum->enumerator_end() &&
3989 !Enum->getIdentifier() && !Enum->isInvalidDecl())
3990 DeclaresAnything =
false;
3998 DeclaresAnything =
false;
4007 ActOnDocumentableDecl(TagD);
4017 if (!DeclaresAnything) {
4032 unsigned DiagID = diag::warn_standalone_specifier;
4034 DiagID = diag::ext_standalone_specifier;
4076 Diag(attrs->getLoc(), diag::warn_declspec_attribute_ignored)
4100 assert(PrevDecl &&
"Expected a non-null Decl");
4105 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
4107 SemaRef.
Diag(PrevDecl->getLocation(), diag::note_previous_declaration);
4132 bool Invalid =
false;
4135 for (
auto *D : AnonRecord->
decls()) {
4136 if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
4137 cast<NamedDecl>(D)->getDeclName()) {
4153 unsigned OldChainingSize = Chaining.size();
4155 Chaining.append(IF->chain_begin(), IF->chain_end());
4157 Chaining.push_back(VD);
4159 assert(Chaining.size() >= 2);
4162 for (
unsigned i = 0; i < Chaining.size(); i++)
4163 NamedChain[i] = Chaining[i];
4167 VD->
getType(), {NamedChain, Chaining.size()});
4169 for (
const auto *
Attr : VD->attrs())
4172 IndirectField->setAccess(AS);
4173 IndirectField->setImplicit();
4177 if (AS !=
AS_none) IndirectField->setAccess(AS);
4179 Chaining.resize(OldChainingSize);
4194 "Parser allowed 'typedef' as storage class VarDecl.");
4195 switch (StorageClassSpec) {
4209 llvm_unreachable(
"unknown storage class specifier");
4215 for (
const auto *
I : Record->
decls()) {
4217 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(
I))
4218 FD = IFD->getAnonField();
4219 if (FD && FD->hasInClassInitializer())
4220 return FD->getLocation();
4223 llvm_unreachable(
"couldn't find in-class initializer");
4231 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
4254 if (Record->
isUnion() && !getLangOpts().CPlusPlus && !getLangOpts().C11)
4255 Diag(Record->getLocation(), diag::ext_anonymous_union);
4256 else if (!Record->
isUnion() && getLangOpts().CPlusPlus)
4257 Diag(Record->getLocation(), diag::ext_gnu_anonymous_struct);
4258 else if (!Record->
isUnion() && !getLangOpts().C11)
4259 Diag(Record->getLocation(), diag::ext_c11_anonymous_struct);
4263 bool Invalid =
false;
4264 if (getLangOpts().CPlusPlus) {
4265 const char *PrevSpec =
nullptr;
4272 (isa<TranslationUnitDecl>(Owner) ||
4273 (isa<NamespaceDecl>(Owner) &&
4274 cast<NamespaceDecl>(Owner)->getDeclName()))) {
4275 Diag(Record->getLocation(), diag::err_anonymous_union_not_static)
4280 PrevSpec, DiagID, Policy);
4286 isa<RecordDecl>(Owner)) {
4288 diag::err_anonymous_union_with_storage_spec)
4302 << Record->
isUnion() <<
"const"
4306 diag::ext_anonymous_struct_union_qualified)
4307 << Record->
isUnion() <<
"volatile"
4311 diag::ext_anonymous_struct_union_qualified)
4312 << Record->
isUnion() <<
"restrict"
4316 diag::ext_anonymous_struct_union_qualified)
4317 << Record->
isUnion() <<
"_Atomic"
4321 diag::ext_anonymous_struct_union_qualified)
4322 << Record->
isUnion() <<
"__unaligned"
4332 for (
auto *Mem : Record->
decls()) {
4333 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
4337 assert(FD->getAccess() !=
AS_none);
4339 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
4349 if (CheckNontrivialField(FD))
4351 }
else if (Mem->isImplicit()) {
4353 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
4358 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
4359 if (!MemRecord->isAnonymousStructOrUnion() &&
4360 MemRecord->getDeclName()) {
4362 if (getLangOpts().MicrosoftExt)
4363 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
4367 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
4375 Diag(MemRecord->getLocation(),
4376 diag::ext_anonymous_record_with_anonymous_type)
4379 }
else if (isa<AccessSpecDecl>(Mem)) {
4381 }
else if (isa<StaticAssertDecl>(Mem)) {
4386 unsigned DK = diag::err_anonymous_record_bad_member;
4387 if (isa<TypeDecl>(Mem))
4388 DK = diag::err_anonymous_record_with_type;
4389 else if (isa<FunctionDecl>(Mem))
4390 DK = diag::err_anonymous_record_with_function;
4391 else if (isa<VarDecl>(Mem))
4392 DK = diag::err_anonymous_record_with_static;
4395 if (getLangOpts().MicrosoftExt &&
4396 DK == diag::err_anonymous_record_with_type)
4397 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
4400 Diag(Mem->getLocation(), DK) << Record->
isUnion();
4409 if (cast<CXXRecordDecl>(Record)->hasInClassInitializer() &&
4412 cast<CXXRecordDecl>(Record));
4416 Diag(Record->getLocation(), diag::err_anonymous_struct_not_member)
4417 << getLangOpts().CPlusPlus;
4424 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
4428 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
4431 Record->getLocation(),
4437 Anon->setAccess(AS);
4439 FieldCollector->Add(cast<FieldDecl>(Anon));
4446 Diag(Record->getLocation(), diag::err_mutable_nonmember);
4453 Record->getLocation(),
nullptr,
4461 ActOnUninitializedDecl(Anon,
false);
4463 Anon->setImplicit();
4477 Chain.push_back(Anon);
4482 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
4483 if (getLangOpts().
CPlusPlus && NewVD->isStaticLocal()) {
4484 Decl *ManglingContextDecl;
4486 NewVD->getDeclContext(), ManglingContextDecl)) {
4488 NewVD, MCtx->getManglingNumber(
4496 Anon->setInvalidDecl();
4516 assert(Record &&
"expected a record!");
4521 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
4523 auto *ParentDecl = cast<RecordDecl>(CurContext);
4536 Anon->setImplicit();
4539 CurContext->addDecl(Anon);
4545 Chain.push_back(Anon);
4548 if (RequireCompleteType(Anon->getLocation(), RecTy,
4549 diag::err_field_incomplete) ||
4552 Anon->setInvalidDecl();
4553 ParentDecl->setInvalidDecl();
4562 return GetNameFromUnqualifiedId(D.
getName());
4663 llvm_unreachable(
"Unknown name kind");
4691 for (
unsigned Idx = 0; Idx < Declaration->
param_size(); ++Idx) {
4705 (DeclTyName && DeclTyName == DefTyName))
4706 Params.push_back(Idx);
4747 if (!TSI)
return true;
4792 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer() &&
4793 Dcl && Dcl->getDeclContext()->isFileContext())
4794 Dcl->setTopLevelDeclInObjCContainer();
4812 Record = dyn_cast<CXXRecordDecl>(Record->
getParent());
4814 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
4838 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
4852 Diag(Loc, LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
4853 : diag::err_member_extra_qualification)
4857 Diag(Loc, diag::warn_namespace_member_extra_qualification) <<
Name;
4866 Diag(Loc, diag::err_member_qualification)
4868 else if (isa<TranslationUnitDecl>(DC))
4869 Diag(Loc, diag::err_invalid_declarator_global_scope)
4871 else if (isa<FunctionDecl>(Cur))
4872 Diag(Loc, diag::err_invalid_declarator_in_function)
4874 else if (isa<BlockDecl>(Cur))
4875 Diag(Loc, diag::err_invalid_declarator_in_block)
4878 Diag(Loc, diag::err_invalid_declarator_scope)
4879 << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.
getRange();
4886 Diag(Loc, diag::err_member_qualification)
4906 while (SpecLoc.getPrefix())
4908 if (dyn_cast_or_null<DecltypeType>(
4909 SpecLoc.getNestedNameSpecifier()->getAsType()))
4910 Diag(Loc, diag::err_decltype_in_declarator)
4911 << SpecLoc.getTypeLoc().getSourceRange();
4927 diag::err_declarator_need_ident)
4930 }
else if (DiagnoseUnexpandedParameterPack(NameInfo, UPPC_DeclarationType))
4944 UPPC_DeclarationQualifier))
4949 if (!DC || isa<EnumDecl>(DC)) {
4955 diag::err_template_qualified_declarator_no_match)
4962 if (!IsDependentContext &&
4967 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
4969 diag::err_member_def_undefined_record)
4985 if (EnteringContext && IsDependentContext &&
4986 TemplateParamLists.size() != 0) {
4996 if (!R->
isFunctionType() && DiagnoseClassNameShadow(DC, NameInfo))
5004 UPPC_DeclarationType))
5012 bool IsLinkageLookup =
false;
5013 bool CreateBuiltins =
false;
5024 else if (CurContext->isFunctionOrMethod() &&
5027 IsLinkageLookup =
true;
5029 CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
5030 }
else if (CurContext->getRedeclContext()->isTranslationUnit() &&
5032 CreateBuiltins =
true;
5034 if (IsLinkageLookup)
5035 Previous.
clear(LookupRedeclarationWithLinkage);
5037 LookupName(Previous, S, CreateBuiltins);
5039 LookupQualifiedName(Previous, DC);
5092 CheckExtraCXXDefaultArguments(D);
5098 if (!TemplateParamLists.size()) {
5100 diag:: err_concept_wrong_decl_kind);
5106 diag::err_concept_decls_may_only_appear_in_namespace_scope);
5113 bool AddToScope =
true;
5115 if (TemplateParamLists.size()) {
5120 New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous);
5122 New = ActOnFunctionDeclarator(S, D, DC, TInfo, Previous,
5126 New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists,
5139 bool AddToContext = !D.
isRedeclaration() || !New->isLocalExternDecl();
5140 PushOnScopeChains(New, S, AddToContext);
5142 CurContext->addHiddenDecl(New);
5145 if (isInOpenMPDeclareTargetContext())
5146 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
5156 bool &SizeIsNegative,
5157 llvm::APSInt &Oversized) {
5162 SizeIsNegative =
false;
5171 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
5176 if (FixedType.
isNull())
return FixedType;
5178 return Qs.
apply(Context, FixedType);
5180 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
5181 QualType Inner = PTy->getInnerType();
5185 if (FixedType.
isNull())
return FixedType;
5187 return Qs.
apply(Context, FixedType);
5203 if (Res.isSigned() && Res.isNegative()) {
5204 SizeIsNegative =
true;
5209 unsigned ActiveSizeBits
5243 TypeLoc DstElemTL = DstATL.getElementLoc();
5256 bool &SizeIsNegative,
5257 llvm::APSInt &Oversized) {
5260 SizeIsNegative, Oversized);
5276 ND->getLexicalDeclContext()->getRedeclContext()->isTranslationUnit())
5297 diag::err_virtual_non_function);
5301 diag::err_explicit_non_function);
5305 diag::err_noreturn_non_function);
5325 << getLangOpts().CPlusPlus1z;
5331 diag::err_concept_wrong_decl_kind);
5340 if (!NewTD)
return nullptr;
5343 ProcessDeclAttributes(S, NewTD, D);
5345 CheckTypedefForVariablyModifiedType(S, NewTD);
5348 NamedDecl *ND = ActOnTypedefNameDecl(S, DC, NewTD, Previous, Redeclaration);
5362 getCurFunction()->setHasBranchProtectedScope();
5365 bool SizeIsNegative;
5366 llvm::APSInt Oversized;
5372 Diag(NewTD->getLocation(), diag::warn_illegal_constant_array_size);
5376 Diag(NewTD->getLocation(), diag::err_typecheck_negative_array_size);
5378 Diag(NewTD->getLocation(), diag::err_vla_decl_in_file_scope);
5379 else if (Oversized.getBoolValue())
5380 Diag(NewTD->getLocation(), diag::err_array_too_large)
5381 << Oversized.toString(10);
5383 Diag(NewTD->getLocation(), diag::err_vm_decl_in_file_scope);
5384 NewTD->setInvalidDecl();
5398 FilterLookupForScope(Previous, DC, S,
false,
5401 if (!Previous.
empty()) {
5402 Redeclaration =
true;
5403 MergeTypedefNameDecl(S, NewTD, Previous);
5408 if (!NewTD->isInvalidDecl() &&
5409 NewTD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
5410 if (II->isStr(
"FILE"))
5412 else if (II->isStr(
"jmp_buf"))
5414 else if (II->isStr(
"sigjmp_buf"))
5416 else if (II->isStr(
"ucontext_t"))
5462 DeclContext *PrevOuterContext = PrevDecl->getDeclContext();
5474 if (!OuterContext->
Equals(PrevOuterContext))
5483 if (!SS.
isSet())
return;
5492 unsigned kind = -1U;
5493 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5494 if (var->hasAttr<BlocksAttr>())
5496 else if (!var->hasLocalStorage())
5498 }
else if (isa<ObjCIvarDecl>(decl)) {
5500 }
else if (isa<FieldDecl>(decl)) {
5505 Diag(decl->getLocation(), diag::err_arc_autoreleasing_var)
5518 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5521 var->getTLSKind()) {
5522 Diag(var->getLocation(), diag::err_arc_thread_ownership)
5537 if (WeakAttr *
Attr = ND.getAttr<WeakAttr>()) {
5540 ND.dropAttr<WeakAttr>();
5543 if (WeakRefAttr *
Attr = ND.getAttr<WeakRefAttr>()) {
5546 ND.dropAttr<WeakRefAttr>();
5547 ND.dropAttr<AliasAttr>();
5551 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
5552 if (VD->hasInit()) {
5553 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
5554 assert(VD->isThisDeclarationADefinition() &&
5555 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
5557 VD->dropAttr<AliasAttr>();
5564 if (SelectAnyAttr *
Attr = ND.getAttr<SelectAnyAttr>()) {
5567 diag::err_attribute_selectany_non_extern_data);
5568 ND.dropAttr<SelectAnyAttr>();
5575 auto *VD = dyn_cast<
VarDecl>(&ND);
5577 S.
Diag(ND.getLocation(), diag::err_attribute_dll_not_extern)
5579 ND.setInvalidDecl();
5584 if (
auto *
Attr = ND.getAttr<NotTailCalledAttr>())
5585 if (
auto *MD = dyn_cast<CXXMethodDecl>(&ND))
5586 if (MD->isVirtual()) {
5587 S.
Diag(ND.getLocation(),
5588 diag::err_invalid_attribute_on_virtual_function)
5590 ND.dropAttr<NotTailCalledAttr>();
5596 bool IsSpecialization,
5597 bool IsDefinition) {
5598 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
5599 OldDecl = OldTD->getTemplatedDecl();
5600 if (!IsSpecialization)
5601 IsDefinition =
false;
5603 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl))
5604 NewDecl = NewTD->getTemplatedDecl();
5606 if (!OldDecl || !NewDecl)
5609 const DLLImportAttr *OldImportAttr = OldDecl->getAttr<DLLImportAttr>();
5610 const DLLExportAttr *OldExportAttr = OldDecl->getAttr<DLLExportAttr>();
5611 const DLLImportAttr *NewImportAttr = NewDecl->getAttr<DLLImportAttr>();
5612 const DLLExportAttr *NewExportAttr = NewDecl->getAttr<DLLExportAttr>();
5616 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
5617 (NewExportAttr && !NewExportAttr->isInherited());
5623 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
5625 if (AddsAttr && !IsSpecialization && !OldDecl->isImplicit()) {
5627 bool JustWarn =
false;
5629 auto *VD = dyn_cast<
VarDecl>(OldDecl);
5630 if (VD && !VD->getDescribedVarTemplate())
5640 if (OldDecl->isUsed())
5641 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
5644 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
5645 : diag::err_attribute_dll_redeclaration;
5646 S.
Diag(NewDecl->getLocation(), DiagID)
5648 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
5649 S.
Diag(OldDecl->getLocation(), diag::note_previous_declaration);
5651 NewDecl->setInvalidDecl();
5660 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
5662 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
5665 IsStaticDataMember = VD->isStaticDataMember();
5666 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
5668 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
5669 IsInline = FD->isInlined();
5670 IsQualifiedFriend = FD->getQualifier() &&
5671 FD->getFriendObjectKind() == Decl::FOK_Declared;
5674 if (OldImportAttr && !HasNewAttr && !IsInline && !IsStaticDataMember &&
5675 !NewDecl->isLocalExternDecl() && !IsQualifiedFriend) {
5676 if (IsMicrosoft && IsDefinition) {
5677 S.
Diag(NewDecl->getLocation(),
5678 diag::warn_redeclaration_without_import_attribute)
5680 S.
Diag(OldDecl->getLocation(), diag::note_previous_declaration);
5681 NewDecl->dropAttr<DLLImportAttr>();
5682 NewDecl->addAttr(::
new (S.
Context) DLLExportAttr(
5683 NewImportAttr->getRange(), S.
Context,
5684 NewImportAttr->getSpellingListIndex()));
5686 S.
Diag(NewDecl->getLocation(),
5687 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
5688 << NewDecl << OldImportAttr;
5689 S.
Diag(OldDecl->getLocation(), diag::note_previous_declaration);
5690 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
5691 OldDecl->dropAttr<DLLImportAttr>();
5692 NewDecl->dropAttr<DLLImportAttr>();
5694 }
else if (IsInline && OldImportAttr && !IsMicrosoft) {
5696 OldDecl->dropAttr<DLLImportAttr>();
5697 NewDecl->dropAttr<DLLImportAttr>();
5698 S.
Diag(NewDecl->getLocation(),
5699 diag::warn_dllimport_dropped_from_inline_function)
5700 << NewDecl << OldImportAttr;
5714 if (S.
getLangOpts().CPlusPlus && !FD->hasAttr<GNUInlineAttr>())
5753 template<
typename T>
5757 if (!D->isInExternCContext() || D->template hasAttr<OverloadableAttr>())
5761 if (S.
getLangOpts().CUDA && (D->template hasAttr<CUDADeviceAttr>() ||
5762 D->template hasAttr<CUDAHostAttr>()))
5765 return D->isExternC();
5769 const DeclContext *DC = VD->getDeclContext()->getRedeclContext();
5776 llvm_unreachable(
"Unexpected context");
5782 isa<OMPDeclareReductionDecl>(DC))
5786 llvm_unreachable(
"Unexpected context");
5792 if (L->getKind() ==
Kind)
5840 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
5841 return FD->isExternC();
5842 if (
const auto *VD = dyn_cast<VarDecl>(D))
5843 return VD->isExternC();
5845 llvm_unreachable(
"Unknown type of decl!");
5861 diag::err_opencl_type_can_only_be_used_as_function_parameter)
5878 bool IsLocalExternDecl = SC ==
SC_Extern &&
5879 adjustContextForLocalExternDecl(DC);
5881 if (getLangOpts().OpenCL) {
5893 if (!getOpenCLOptions().cl_khr_fp16) {
5912 !D.
getAsmLabel() && !getSourceManager().isInSystemMacro(
5918 getLangOpts().CPlusPlus1z ? diag::ext_register_storage_class
5919 : diag::warn_deprecated_register)
5942 if (getLangOpts().OpenCL) {
5968 bool IsExplicitSpecialization =
false;
5969 bool IsVariableTemplateSpecialization =
false;
5970 bool IsPartialSpecialization =
false;
5971 bool IsVariableTemplate =
false;
5981 ParsingInitForAutoVars.insert(NewVD);
5984 NewVD->setInvalidDecl();
5986 bool Invalid =
false;
5988 if (DC->
isRecord() && !CurContext->isRecord()) {
5995 diag::err_static_out_of_line)
6007 diag::err_storage_class_for_static_member)
6011 llvm_unreachable(
"C storage class in c++!");
6015 if (SC ==
SC_Static && CurContext->isRecord()) {
6016 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
6017 if (RD->isLocalClass())
6019 diag::err_static_data_member_not_allowed_in_local_class)
6020 << Name << RD->getDeclName();
6026 getLangOpts().CPlusPlus11
6027 ? diag::warn_cxx98_compat_static_data_member_in_union
6028 : diag::ext_static_data_member_in_union) << Name;
6030 else if (!RD->getDeclName())
6032 diag::err_static_data_member_not_allowed_in_anon_struct)
6033 << Name << RD->isUnion();
6039 TemplateParams = MatchTemplateParametersToScopeSpecifier(
6046 false, IsExplicitSpecialization, Invalid);
6048 if (TemplateParams) {
6049 if (!TemplateParams->
size() &&
6054 diag::err_template_variable_noparams)
6058 TemplateParams =
nullptr;
6063 IsVariableTemplateSpecialization =
true;
6064 IsPartialSpecialization = TemplateParams->
size() > 0;
6067 IsVariableTemplate =
true;
6070 if (CheckTemplateDeclScope(S, TemplateParams))
6075 getLangOpts().CPlusPlus14
6076 ? diag::warn_cxx11_compat_variable_template
6077 : diag::ext_variable_template);
6083 "should have a 'template<>' for this decl");
6086 if (IsVariableTemplateSpecialization) {
6088 TemplateParamLists.size() > 0
6089 ? TemplateParamLists[0]->getTemplateLoc()
6091 DeclResult Res = ActOnVarTemplateSpecialization(
6092 S, D, TInfo, TemplateKWLoc, TemplateParams, SC,
6093 IsPartialSpecialization);
6096 NewVD = cast<VarDecl>(Res.
get());
6103 if (IsVariableTemplate) {
6106 TemplateParams, NewVD);
6113 ParsingInitForAutoVars.insert(NewVD);
6116 NewVD->setInvalidDecl();
6118 NewTemplate->setInvalidDecl();
6125 unsigned VDTemplateParamLists = TemplateParams ? 1 : 0;
6126 if (TemplateParamLists.size() > VDTemplateParamLists)
6128 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
6148 diag::err_concept_decl_invalid_specifiers)
6150 NewVD->setInvalidDecl(
true);
6155 diag::err_concept_decl_invalid_specifiers)
6157 NewVD->setInvalidDecl(
true);
6163 if (IsVariableTemplateSpecialization) {
6165 diag::err_concept_specified_specialization)
6166 << (IsPartialSpecialization ? 2 : 1);
6173 !NewVD->isInvalidDecl()) {
6175 NewVD->setInvalidDecl(
true);
6181 if (!getLangOpts().CPlusPlus) {
6184 }
else if (CurContext->isFunctionOrMethod()) {
6187 diag::err_inline_declaration_block_scope) << Name
6191 getLangOpts().CPlusPlus1z ? diag::warn_cxx14_compat_inline_variable
6192 : diag::ext_inline_variable);
6199 NewVD->setLexicalDeclContext(CurContext);
6201 NewTemplate->setLexicalDeclContext(CurContext);
6203 if (IsLocalExternDecl)
6204 NewVD->setLocalExternDecl();
6206 bool EmitTLSUnsupportedError =
false;
6219 diag::err_thread_non_global)
6222 if (getLangOpts().CUDA) {
6226 EmitTLSUnsupportedError =
true;
6233 diag::err_thread_unsupported);
6252 diag::warn_static_local_in_extern_inline);
6253 MaybeSuggestAddingStaticToDecl(CurFD);
6258 if (IsVariableTemplateSpecialization)
6259 Diag(NewVD->getLocation(), diag::err_module_private_specialization)
6260 << (IsPartialSpecialization ? 1 : 0)
6263 else if (IsExplicitSpecialization)
6264 Diag(NewVD->getLocation(), diag::err_module_private_specialization)
6268 Diag(NewVD->getLocation(), diag::err_module_private_local)
6273 NewVD->setModulePrivate();
6275 NewTemplate->setModulePrivate();
6280 ProcessDeclAttributes(S, NewVD, D);
6282 if (getLangOpts().CUDA) {
6285 diag::err_thread_unsupported);
6289 (NewVD->hasAttr<CUDASharedAttr>() ||
6290 NewVD->hasAttr<CUDAConstantAttr>())) {
6298 assert(!NewVD->hasAttr<DLLImportAttr>() ||
6299 NewVD->getAttr<DLLImportAttr>()->isInherited() ||
6304 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewVD))
6305 NewVD->setInvalidDecl();
6316 Diag(
E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
6322 Diag(
E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6333 bool HasSizeMismatch;
6335 if (!TI.isValidGCCRegisterName(Label))
6336 Diag(
E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6337 else if (!TI.validateGlobalRegisterVariable(Label,
6340 Diag(
E->getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
6341 else if (HasSizeMismatch)
6342 Diag(
E->getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
6347 NewVD->setInvalidDecl(
true);
6353 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
6356 if (I != ExtnameUndeclaredIdentifiers.end()) {
6358 NewVD->addAttr(I->second);
6359 ExtnameUndeclaredIdentifiers.erase(I);
6361 Diag(NewVD->getLocation(), diag::warn_redefine_extname_not_applied)
6368 CheckShadow(S, NewVD, Previous);
6375 IsExplicitSpecialization ||
6376 IsVariableTemplateSpecialization);
6380 if (getLangOpts().CPlusPlus &&
6384 isDeclInScope(Previous.
getFoundDecl(), OriginalDC,
S,
false));
6386 if (!getLangOpts().CPlusPlus) {
6390 if (IsExplicitSpecialization && !NewVD->isInvalidDecl() &&
6391 CheckMemberSpecialization(NewVD, Previous))
6392 NewVD->setInvalidDecl();
6395 if (!Previous.
empty()) {
6401 Diag(NewVD->getLocation(), diag::err_nonstatic_member_out_of_line)
6404 NewVD->setInvalidDecl();
6411 NewVD->setInvalidDecl();
6414 if (!IsVariableTemplateSpecialization)
6420 if (IsVariableTemplateSpecialization &&
6424 if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(PreviousDecl)) {
6425 if (VarTmpl->isConcept()) {
6426 Diag(NewVD->getLocation(), diag::err_concept_specialized)
6428 << (IsPartialSpecialization ? 2
6430 Diag(VarTmpl->getLocation(), diag::note_previous_declaration);
6431 NewVD->setInvalidDecl();
6445 if (CheckTemplateParameterList(
6451 ? TPC_ClassTemplateMember
6453 NewVD->setInvalidDecl();
6457 if (PrevVarTemplate &&
6463 ProcessPragmaWeak(S, NewVD);
6467 if (NewVD->
isFirstDecl() && !NewVD->isInvalidDecl() &&
6469 RegisterLocallyScopedExternCDecl(NewVD, S);
6472 Decl *ManglingContextDecl;
6474 NewVD->getDeclContext(), ManglingContextDecl)) {
6476 NewVD, MCtx->getManglingNumber(
6484 NewVD->getDeclContext()->getRedeclContext()->isTranslationUnit() &&
6489 if (getLangOpts().CPlusPlus)
6505 if (NewVD->isInvalidDecl())
6506 NewTemplate->setInvalidDecl();
6507 ActOnDocumentableDecl(NewTemplate);
6520 if (isa<RecordDecl>(OldDC))
6536 if (Diags.isIgnored(diag::warn_decl_shadow, R.
getNameLoc()))
6550 if (!isa<VarDecl>(ShadowedDecl) && !isa<FieldDecl>(ShadowedDecl))
6553 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
6561 if (isa<CXXConstructorDecl>(NewDC) && isa<ParmVarDecl>(D)) {
6565 ShadowingDecls.insert({D, FD});
6570 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
6571 if (shadowedVar->isExternC()) {
6574 for (
auto I : shadowedVar->redecls())
6575 if (
I->isFileVarDecl()) {
6581 DeclContext *OldDC = ShadowedDecl->getDeclContext();
6601 if (getSourceManager().isInSystemMacro(R.
getNameLoc()))
6604 Diag(R.
getNameLoc(), diag::warn_decl_shadow) << Name << Kind << OldDC;
6605 Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration);
6610 if (Diags.isIgnored(diag::warn_decl_shadow, D->getLocation()))
6616 CheckShadow(S, D, R);
6623 if (!getLangOpts().
CPlusPlus || ShadowingDecls.empty())
6629 const NamedDecl *D = cast<NamedDecl>(DRE->getDecl()->getCanonicalDecl());
6630 auto I = ShadowingDecls.find(D);
6631 if (I == ShadowingDecls.end())
6633 const NamedDecl *ShadowedDecl = I->second;
6634 const DeclContext *OldDC = ShadowedDecl->getDeclContext();
6635 Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
6636 Diag(D->getLocation(), diag::note_var_declared_here) << D;
6637 Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration);
6640 ShadowingDecls.erase(I);
6645 template<
typename T>
6648 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
6669 if (!isa<VarDecl>(ND))
6679 if (isa<VarDecl>(*
I)) {
6689 if (isa<VarDecl>(*
I)) {
6707 assert(Prev &&
"should have found a previous declaration to diagnose");
6709 Prev = FD->getFirstDecl();
6711 Prev = cast<VarDecl>(Prev)->getFirstDecl();
6713 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
6715 S.
Diag(Prev->getLocation(), diag::note_extern_c_global_conflict)
6728 template<
typename T>
6735 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
6747 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
6762 if (NewVD->isInvalidDecl())
6772 if (NewVD->hasAttrs())
6773 CheckAlignasUnderalignment(NewVD);
6776 Diag(NewVD->getLocation(), diag::err_statically_allocated_object)
6786 if (!getLangOpts().OpenCL
6788 Diag(NewVD->getLocation(), diag::err_as_qualified_auto_decl);
6789 NewVD->setInvalidDecl();
6795 if (getLangOpts().OpenCLVersion == 120 &&
6796 !getOpenCLOptions().cl_clang_storage_class_specifiers &&
6798 Diag(NewVD->getLocation(), diag::err_static_function_scope);
6799 NewVD->setInvalidDecl();
6803 if (getLangOpts().OpenCL) {
6805 if (NewVD->hasAttr<BlocksAttr>()) {
6806 Diag(NewVD->getLocation(), diag::err_opencl_block_storage_type);
6814 Diag(NewVD->getLocation(), diag::err_opencl_invalid_block_declaration)
6816 NewVD->setInvalidDecl();
6820 Diag(NewVD->getLocation(), diag::err_opencl_extern_block_declaration);
6821 NewVD->setInvalidDecl();
6829 if (FTy && FTy->isVariadic()) {
6830 Diag(NewVD->getLocation(), diag::err_opencl_block_proto_variadic)
6832 NewVD->setInvalidDecl();
6846 getLangOpts().OpenCLVersion == 200))) {
6848 if (getLangOpts().OpenCLVersion == 200)
6849 Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space)
6850 << Scope <<
"global or constant";
6852 Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space)
6853 << Scope <<
"constant";
6854 NewVD->setInvalidDecl();
6859 Diag(NewVD->getLocation(), diag::err_opencl_function_variable)
6861 NewVD->setInvalidDecl();
6869 if (FD && !FD->hasAttr<OpenCLKernelAttr>()) {
6871 Diag(NewVD->getLocation(), diag::err_opencl_function_variable)
6874 Diag(NewVD->getLocation(), diag::err_opencl_function_variable)
6876 NewVD->setInvalidDecl();
6884 && !NewVD->hasAttr<BlocksAttr>()) {
6886 Diag(NewVD->getLocation(), diag::warn_gc_attribute_weak_on_local);
6888 assert(!getLangOpts().ObjCAutoRefCount);
6889 Diag(NewVD->getLocation(), diag::warn_attribute_weak_on_local);
6894 if (isVM || NewVD->hasAttr<CleanupAttr>() ||
6895 NewVD->hasAttr<BlocksAttr>())
6896 getCurFunction()->setHasBranchProtectedScope();
6900 bool SizeIsNegative;
6901 llvm::APSInt Oversized;
6904 SizeIsNegative, Oversized);
6912 Diag(NewVD->getLocation(), diag::err_vla_decl_in_file_scope)
6915 Diag(NewVD->getLocation(), diag::err_vla_decl_has_static_storage)
6918 Diag(NewVD->getLocation(), diag::err_vla_decl_has_extern_linkage)
6920 NewVD->setInvalidDecl();
6926 Diag(NewVD->getLocation(), diag::err_vm_decl_in_file_scope);
6928 Diag(NewVD->getLocation(), diag::err_vm_decl_has_extern_linkage);
6929 NewVD->setInvalidDecl();
6933 Diag(NewVD->getLocation(), diag::warn_illegal_constant_array_size);
6942 Diag(NewVD->getLocation(), diag::err_typecheck_decl_incomplete_type)
6944 NewVD->setInvalidDecl();
6950 Diag(NewVD->getLocation(), diag::err_block_on_nonlocal);
6951 NewVD->setInvalidDecl();
6955 if (isVM && NewVD->hasAttr<BlocksAttr>()) {
6956 Diag(NewVD->getLocation(), diag::err_block_on_vm);
6957 NewVD->setInvalidDecl();
6962 RequireLiteralType(NewVD->getLocation(), T,
6963 diag::err_constexpr_var_non_literal)) {
6964 NewVD->setInvalidDecl();
6982 CheckVariableDeclarationType(NewVD);
6985 if (NewVD->isInvalidDecl())
6990 if (Previous.
empty() &&
6994 if (!Previous.
empty()) {
6995 MergeVarDecl(NewVD, Previous);
7002 struct FindOverriddenMethod {
7028 if (MD->isVirtual() && !
S->
IsOverload(Method, MD,
false))
7055 if ((OEK == OEK_All) ||
7056 (OEK == OEK_NonDeleted && !(*I)->isDeleted()) ||
7057 (OEK == OEK_Deleted && (*I)->isDeleted()))
7058 S.
Diag((*I)->getLocation(), diag::note_overridden_virtual_function);
7067 FindOverriddenMethod FOM;
7070 bool hasDeletedOverridenMethods =
false;
7071 bool hasNonDeletedOverridenMethods =
false;
7072 bool AddedAny =
false;
7077 if (!CheckOverridingFunctionReturnType(MD, OldMD) &&
7078 !CheckOverridingFunctionAttributes(MD, OldMD) &&
7079 !CheckOverridingFunctionExceptionSpec(MD, OldMD) &&
7080 !CheckIfOverriddenFunctionIsMarkedFinal(MD, OldMD)) {
7081 hasDeletedOverridenMethods |= OldMD->isDeleted();
7082 hasNonDeletedOverridenMethods |= !OldMD->isDeleted();
7089 if (hasDeletedOverridenMethods && !MD->
isDeleted()) {
7090 ReportOverrides(*
this, diag::err_non_deleted_override, MD, OEK_Deleted);
7092 if (hasNonDeletedOverridenMethods && MD->
isDeleted()) {
7093 ReportOverrides(*
this, diag::err_deleted_override, MD, OEK_NonDeleted);
7102 struct ActOnFDArgs {
7118 : Context(Context), OriginalFD(TypoFD),
7121 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
7127 CDeclEnd = candidate.
end();
7128 CDecl != CDeclEnd; ++CDecl) {
7137 }
else if (!ExpectedParent) {
7165 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *
S) {
7171 bool IsDefinition = ExtraArgs.D.isFunctionDefinition();
7172 unsigned DiagMsg = IsLocalFriend ? diag::err_no_matching_local_friend
7173 : diag::err_member_decl_does_not_match;
7179 NewFD->setInvalidDecl();
7184 assert(!Prev.isAmbiguous() &&
7185 "Cannot have an ambiguity in previous-declaration lookup");
7187 if (!Prev.empty()) {
7189 Func != FuncEnd; ++Func) {
7196 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
7197 NearMatches.push_back(std::make_pair(FD, ParamNum));
7202 Prev.getLookupNameInfo(), Prev.getLookupKind(),
S,
7203 &ExtraArgs.D.getCXXScopeSpec(),
7204 llvm::make_unique<DifferentNameValidatorCCC>(
7209 ExtraArgs.D.getIdentifierLoc());
7213 CDeclEnd = Correction.
end();
7214 CDecl != CDeclEnd; ++CDecl) {
7221 bool wasRedeclaration = ExtraArgs.D.isRedeclaration();
7234 ExtraArgs.S, ExtraArgs.D,
7237 ExtraArgs.AddToScope);
7245 Decl *Canonical = Result->getCanonicalDecl();
7248 if ((*I)->getCanonicalDecl() == Canonical)
7253 SemaRef.
PDiag(IsLocalFriend
7254 ? diag::err_no_matching_local_friend_suggest
7255 : diag::err_member_decl_does_not_match_suggest)
7256 << Name << NewDC << IsDefinition);
7262 ExtraArgs.D.getIdentifierLoc());
7263 ExtraArgs.D.setRedeclaration(wasRedeclaration);
7268 SemaRef.
Diag(NewFD->getLocation(), DiagMsg)
7269 << Name << NewDC << IsDefinition << NewFD->getLocation();
7271 bool NewFDisConst =
false;
7273 NewFDisConst = NewMD->isConst();
7276 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
7277 NearMatch != NearMatchEnd; ++NearMatch) {
7280 bool FDisConst = MD && MD->
isConst();
7281 bool IsMember = MD || !IsLocalFriend;
7284 if (
unsigned Idx = NearMatch->second) {
7287 if (Loc.
isInvalid()) Loc = FD->getLocation();
7288 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
7289 : diag::note_local_decl_close_param_match)
7292 }
else if (FDisConst != NewFDisConst) {
7293 SemaRef.
Diag(FD->getLocation(), diag::note_member_def_close_const_match)
7296 SemaRef.
Diag(FD->getLocation(),
7297 IsMember ? diag::note_member_def_close_match
7298 : diag::note_local_decl_close_match);
7305 default: llvm_unreachable(
"Unknown storage class!");
7310 diag::err_typecheck_sclass_func);
7326 diag::err_static_block_func);
7342 bool &IsVirtualOkay) {
7361 TInfo, SC, isInline,
7362 HasPrototype,
false);
7364 NewFD->setInvalidDecl();
7384 "Constructors can only be declared in a member context");
7389 R, TInfo, isExplicit, isInline,
7401 NameInfo, R, TInfo, isInline,
7413 IsVirtualOkay =
true;
7432 diag::err_conv_function_not_member);
7437 IsVirtualOkay =
true;
7440 R, TInfo, isInline, isExplicit,
7458 cast<CXXRecordDecl>(DC),
7460 TInfo, SC, isInline,
7475 NameInfo, R, TInfo, SC, isInline,
7523 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
7536 S.
Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
7544 S.
Diag(Param->getLocation(), diag::err_opencl_private_ptr_kernel_param);
7558 S.
Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
7577 HistoryStack.push_back(
nullptr);
7580 VisitStack.push_back(PD);
7582 assert(VisitStack.back() &&
"First decl null?");
7585 const Decl *
Next = VisitStack.pop_back_val();
7587 assert(!HistoryStack.empty());
7589 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
7590 ValidTypes.insert(Hist->getType().getTypePtr());
7598 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(Next)) {
7599 HistoryStack.push_back(Field);
7600 RD = Field->getType()->castAs<
RecordType>()->getDecl();
7602 RD = cast<RecordDecl>(
Next);
7606 VisitStack.push_back(
nullptr);
7608 for (
const auto *FD : RD->
fields()) {
7619 VisitStack.push_back(FD);
7629 S.
Diag(Param->getLocation(),
7630 diag::err_record_with_pointers_kernel_param)
7634 S.
Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
7637 S.
Diag(PD->getLocation(), diag::note_within_field_of_type)
7643 I = HistoryStack.begin() + 1,
7644 E = HistoryStack.end();
7647 S.
Diag(OuterField->getLocation(), diag::note_within_field_of_type)
7651 S.
Diag(FD->getLocation(), diag::note_illegal_field_declared_here)
7657 }
while (!VisitStack.empty());
7676 diag::err_invalid_thread)
7683 bool isFriend =
false;
7685 bool isExplicitSpecialization =
false;
7686 bool isFunctionTemplateSpecialization =
false;
7688 bool isDependentClassScopeExplicitSpecialization =
false;
7689 bool HasExplicitTemplateArgs =
false;
7692 bool isVirtualOkay =
false;
7695 bool IsLocalExternDecl = adjustContextForLocalExternDecl(DC);
7699 if (!NewFD)
return nullptr;
7701 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer())
7702 NewFD->setTopLevelDeclInObjCContainer();
7707 NewFD->setLexicalDeclContext(CurContext);
7709 if (IsLocalExternDecl)
7710 NewFD->setLocalExternDecl();
7730 dyn_cast<CXXRecordDecl>(NewFD->getDeclContext())) {
7731 if (Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
7736 if (isVirtual && Parent->isUnion())
7741 isExplicitSpecialization =
false;
7742 isFunctionTemplateSpecialization =
false;
7744 NewFD->setInvalidDecl();
7748 bool Invalid =
false;
7750 MatchTemplateParametersToScopeSpecifier(
7756 TemplateParamLists, isFriend, isExplicitSpecialization,
7758 if (TemplateParams->size() > 0) {
7762 if (CheckTemplateDeclScope(S, TemplateParams))
7763 NewFD->setInvalidDecl();
7767 Diag(NewFD->getLocation(), diag::err_destructor_template);
7768 NewFD->setInvalidDecl();
7776 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
7781 NewFD->getLocation(),
7782 Name, TemplateParams,
7784 FunctionTemplate->setLexicalDeclContext(CurContext);
7788 if (TemplateParamLists.size() > 1) {
7790 TemplateParamLists.drop_back(1));
7794 isFunctionTemplateSpecialization =
true;
7796 if (TemplateParamLists.size() > 0)
7802 SourceRange RemoveRange = TemplateParams->getSourceRange();
7812 InsertLoc = getLocForEndOfToken(InsertLoc);
7816 << Name << RemoveRange
7825 if (TemplateParamLists.size() > 0)
7831 NewFD->setInvalidDecl();
7832 if (FunctionTemplate)
7833 FunctionTemplate->setInvalidDecl();
7841 if (isVirtual && !NewFD->isInvalidDecl()) {
7842 if (!isVirtualOkay) {
7844 diag::err_virtual_non_function);
7845 }
else if (!CurContext->isRecord()) {
7848 diag::err_virtual_out_of_class)
7854 diag::err_virtual_member_function_template)
7866 if (getLangOpts().CPlusPlus14 &&
7868 (isFriend && CurContext->isDependentContext())) &&
7887 if (isInline && !NewFD->isInvalidDecl()) {
7888 if (CurContext->isFunctionOrMethod()) {
7891 diag::err_inline_declaration_block_scope) << Name
7900 if (isExplicit && !NewFD->isInvalidDecl()) {
7901 if (!CurContext->isRecord()) {
7904 diag::err_explicit_out_of_class)
7906 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
7907 !isa<CXXConversionDecl>(NewFD)) {
7911 diag::err_explicit_non_ctor_or_conv_function)
7924 if (isa<CXXDestructorDecl>(NewFD))
7937 diag::err_function_concept_not_defined);
7938 NewFD->setInvalidDecl();
7945 if (FPT->hasExceptionSpec()) {
7949 Diag(NewFD->getLocation(), diag::err_function_concept_exception_spec)
7951 NewFD->setInvalidDecl();
7961 NewFD->setInvalidDecl();
7968 if (FPT->getNumParams() > 0 || FPT->isVariadic())
7969 Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
7981 diag::err_concept_decl_invalid_specifiers)
7983 NewFD->setInvalidDecl(
true);
7988 diag::err_concept_decl_invalid_specifiers)
7990 NewFD->setInvalidDecl(
true);
7995 diag::err_concept_decl_invalid_specifiers)
7997 NewFD->setInvalidDecl(
true);
8003 if (isFunctionTemplateSpecialization) {
8005 diag::err_concept_specified_specialization) << 1;
8006 NewFD->setInvalidDecl(
true);
8013 if (isFunctionTemplateSpecialization) {
8016 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
8020 NewFD->setModulePrivate();
8021 if (FunctionTemplate)
8022 FunctionTemplate->setModulePrivate();
8027 if (FunctionTemplate) {
8028 FunctionTemplate->setObjectOfFriendDecl();
8031 NewFD->setObjectOfFriendDecl();
8052 if (isa<CXXMethodDecl>(NewFD) && DC == CurContext &&
8060 if (SC ==
SC_Static && isa<CXXMethodDecl>(NewFD) &&
8061 !CurContext->isRecord()) {
8070 diag::err_static_out_of_line)
8089 isExplicitSpecialization ||
8090 isFunctionTemplateSpecialization);
8098 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
8101 if (I != ExtnameUndeclaredIdentifiers.end()) {
8103 NewFD->addAttr(I->second);
8104 ExtnameUndeclaredIdentifiers.erase(I);
8106 Diag(NewFD->getLocation(), diag::warn_redefine_extname_not_applied)
8123 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
8125 assert(Param->getDeclContext() != NewFD &&
"Was set before ?");
8126 Param->setDeclContext(NewFD);
8127 Params.push_back(Param);
8129 if (Param->isInvalidDecl())
8130 NewFD->setInvalidDecl();
8144 for (
const auto &AI : FT->param_types()) {
8148 Params.push_back(Param);
8152 "Should not need args for typedef of non-prototype fn");
8156 NewFD->setParams(Params);
8165 DeclsInPrototypeScope.clear();
8174 if (!NewFD->isInvalidDecl() &&
8176 Diag(NewFD->getLocation(), diag::err_vm_func_decl);
8177 NewFD->setInvalidDecl();
8182 !NewFD->hasAttr<SectionAttr>()) {
8184 SectionAttr::CreateImplicit(
Context, SectionAttr::Declspec_allocate,
8185 CodeSegStack.CurrentValue->getString(),
8186 CodeSegStack.CurrentPragmaLocation));
8187 if (UnifySection(CodeSegStack.CurrentValue->getString(),
8191 NewFD->dropAttr<SectionAttr>();
8195 ProcessDeclAttributes(S, NewFD, D);
8197 if (getLangOpts().CUDA)
8198 maybeAddCUDAHostDeviceAttrs(S, NewFD, Previous);
8200 if (getLangOpts().OpenCL) {
8207 Diag(NewFD->getLocation(),
8208 diag::err_opencl_return_value_with_address_space);
8209 NewFD->setInvalidDecl();
8215 bool isExplicitSpecialization=
false;
8216 if (!NewFD->isInvalidDecl() && NewFD->
isMain())
8220 CheckMSVCRTEntryPoint(NewFD);
8222 if (!NewFD->isInvalidDecl())
8224 isExplicitSpecialization));
8225 else if (!Previous.
empty())
8230 "previous declaration set still overloaded");
8242 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
8243 Diag(NewFD->getLocation(), DiagID)
8257 !NewFD->hasAttr<UsedAttr>())
8259 diag::ext_operator_new_delete_declared_inline)
8270 translateTemplateArguments(TemplateArgsPtr,
8273 HasExplicitTemplateArgs =
true;
8275 if (NewFD->isInvalidDecl()) {
8276 HasExplicitTemplateArgs =
false;
8277 }
else if (FunctionTemplate) {
8282 HasExplicitTemplateArgs =
false;
8284 assert((isFunctionTemplateSpecialization ||
8286 "should have a 'template<>' for this decl");
8288 isFunctionTemplateSpecialization =
true;
8290 }
else if (isFriend && isFunctionTemplateSpecialization) {
8297 HasExplicitTemplateArgs =
true;
8306 bool InstantiationDependent =
false;
8307 if (isFunctionTemplateSpecialization && isFriend &&
8311 InstantiationDependent))) {
8312 assert(HasExplicitTemplateArgs &&
8313 "friend function specialization without template args");
8314 if (CheckDependentFunctionTemplateSpecialization(NewFD, TemplateArgs,
8316 NewFD->setInvalidDecl();
8317 }
else if (isFunctionTemplateSpecialization) {
8318 if (CurContext->isDependentContext() && CurContext->isRecord()
8320 isDependentClassScopeExplicitSpecialization =
true;
8321 Diag(NewFD->getLocation(), getLangOpts().MicrosoftExt ?
8322 diag::ext_function_specialization_in_class :
8323 diag::err_function_specialization_in_class)
8325 }
else if (CheckFunctionTemplateSpecialization(NewFD,
8326 (HasExplicitTemplateArgs ? &TemplateArgs
8329 NewFD->setInvalidDecl();
8338 Diag(NewFD->getLocation(),
8339 diag::err_explicit_specialization_inconsistent_storage_class)
8345 Diag(NewFD->getLocation(),
8346 diag::ext_explicit_specialization_storage_class)
8350 }
else if (isExplicitSpecialization && isa<CXXMethodDecl>(NewFD)) {
8351 if (CheckMemberSpecialization(NewFD, Previous))
8352 NewFD->setInvalidDecl();
8356 if (!isDependentClassScopeExplicitSpecialization) {
8357 if (!NewFD->isInvalidDecl() && NewFD->
isMain())
8361 CheckMSVCRTEntryPoint(NewFD);
8363 if (!NewFD->isInvalidDecl())
8365 isExplicitSpecialization));
8366 else if (!Previous.
empty())
8373 "previous declaration set still overloaded");
8375 NamedDecl *PrincipalDecl = (FunctionTemplate
8376 ? cast<NamedDecl>(FunctionTemplate)
8381 if (!NewFD->isInvalidDecl())
8384 NewFD->setAccess(Access);
8385 if (FunctionTemplate) FunctionTemplate->setAccess(Access);
8389 PrincipalDecl->isInIdentifierNamespace(Decl::IDNS_Ordinary))
8390 PrincipalDecl->setNonMemberOperator();
8394 if (FunctionTemplate) {
8402 ? TPC_FriendFunctionTemplateDefinition
8403 : TPC_FriendFunctionTemplate)
8407 ? TPC_ClassTemplateMember
8408 : TPC_FunctionTemplate);
8411 if (NewFD->isInvalidDecl()) {
8414 struct ActOnFDArgs ExtraArgs = {
S, D, TemplateParamLists,
8417 if (isa<CXXRecordDecl>(NewFD->getDeclContext()))
8432 (TemplateParamLists.size() ||
8434 CurContext->isDependentContext())) {
8453 *
this, Previous, NewFD, ExtraArgs,
false,
nullptr)) {
8454 AddToScope = ExtraArgs.AddToScope;
8461 }
else if (isFriend && cast<CXXRecordDecl>(CurContext)->isLocalClass()) {
8463 *
this, Previous, NewFD, ExtraArgs,
true, S)) {
8464 AddToScope = ExtraArgs.AddToScope;
8469 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
8470 !isFriend && !isFunctionTemplateSpecialization &&
8471 !isExplicitSpecialization) {
8479 Diag(NewFD->getLocation(), diag::ext_out_of_line_declaration)
8484 ProcessPragmaWeak(S, NewFD);
8487 AddKnownFunctionAttributes(NewFD);
8489 if (NewFD->hasAttr<OverloadableAttr>() &&
8491 Diag(NewFD->getLocation(),
8492 diag::err_attribute_overloadable_no_prototype)
8500 EPI.ExtInfo = FT->getExtInfo();
8509 AddPushedVisibilityAttribute(NewFD);
8513 AddCFAuditedAttribute(NewFD);
8518 AddRangeBasedOptnone(NewFD);
8522 if (NewFD->
isFirstDecl() && !NewFD->isInvalidDecl() &&
8524 RegisterLocallyScopedExternCDecl(NewFD, S);
8532 isExplicitSpecialization || isFunctionTemplateSpecialization,
8536 if (getLangOpts().CUDA) {
8538 if (II && II->
isStr(
"cudaConfigureCall") && !NewFD->isInvalidDecl() &&
8541 Diag(NewFD->getLocation(), diag::err_config_scalar_return);
8549 if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->
isVariadic() &&
8550 (NewFD->hasAttr<CUDADeviceAttr>() ||
8551 NewFD->hasAttr<CUDAGlobalAttr>()) &&
8554 Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
8558 if (getLangOpts().CPlusPlus) {
8559 if (FunctionTemplate) {
8560 if (NewFD->isInvalidDecl())
8561 FunctionTemplate->setInvalidDecl();
8562 return FunctionTemplate;
8566 if (NewFD->hasAttr<OpenCLKernelAttr>()) {
8568 if ((getLangOpts().OpenCLVersion >= 120)
8583 llvm::SmallPtrSet<const Type *, 16> ValidTypes;
8592 if (getLangOpts().OpenCLVersion >= 200) {
8594 QualType ElemTy = PipeTy->getElementType();
8596 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type );
8603 MarkUnusedFileScopedDecl(NewFD);
8608 if (isDependentClassScopeExplicitSpecialization) {
8612 cast<CXXMethodDecl>(NewFD),
8613 HasExplicitTemplateArgs, TemplateArgs);
8614 CurContext->addDecl(NewSpec);
8639 bool IsExplicitSpecialization) {
8641 "Variably modified return types are not handled here");
8646 bool MergeTypeWithPrevious = !getLangOpts().CPlusPlus &&
8649 bool Redeclaration =
false;
8654 if (!Previous.
empty()) {
8661 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
8662 Redeclaration =
true;
8663 OldDecl = Candidate;
8666 switch (CheckOverload(S, NewFD, Previous, OldDecl,
8669 Redeclaration =
true;
8672 case Ovl_NonFunction:
8673 Redeclaration =
true;
8677 Redeclaration =
false;
8681 if (!getLangOpts().
CPlusPlus && !NewFD->hasAttr<OverloadableAttr>()) {
8684 Diag(NewFD->getLocation(), diag::err_attribute_overloadable_missing)
8685 << Redeclaration << NewFD;
8688 OverloadedDecl = OldDecl;
8689 else if (!Previous.
empty())
8692 Diag(OverloadedDecl->getLocation(),
8693 diag::note_attribute_overloadable_prev_overload);
8694 NewFD->addAttr(OverloadableAttr::CreateImplicit(
Context));
8700 if (!Redeclaration &&
8702 if (!Previous.
empty()) {
8705 Redeclaration =
true;
8707 MergeTypeWithPrevious =
false;
8710 if (OldDecl->hasAttr<OverloadableAttr>()) {
8711 if (!getLangOpts().
CPlusPlus && !NewFD->hasAttr<OverloadableAttr>()) {
8712 Diag(NewFD->getLocation(), diag::err_attribute_overloadable_missing)
8713 << Redeclaration << NewFD;
8715 diag::note_attribute_overloadable_prev_overload);
8716 NewFD->addAttr(OverloadableAttr::CreateImplicit(
Context));
8718 if (IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
8719 Redeclaration =
false;
8736 if (!getLangOpts().CPlusPlus14 && MD && MD->
isConstexpr() &&
8737 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
8741 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->getAsFunction());
8742 if (!OldMD || !OldMD->
isStatic()) {
8752 if (ActiveTemplateInstantiations.empty()) {
8756 AddConstLoc = getLocForEndOfToken(FTL.getRParenLoc());
8758 Diag(MD->getLocation(), diag::warn_cxx14_compat_constexpr_not_const)
8764 if (Redeclaration) {
8767 if (MergeFunctionDecl(NewFD, OldDecl, S, MergeTypeWithPrevious)) {
8768 NewFD->setInvalidDecl();
8769 return Redeclaration;
8776 = dyn_cast<FunctionTemplateDecl>(OldDecl)) {
8780 assert(NewTemplateDecl &&
"Template/non-template mismatch");
8783 Method->setAccess(OldTemplateDecl->getAccess());
8784 NewTemplateDecl->setAccess(OldTemplateDecl->getAccess());
8789 if (IsExplicitSpecialization &&
8792 assert(OldTemplateDecl->isMemberSpecialization());
8795 if (OldTemplateDecl->getTemplatedDecl()->isDeleted()) {
8797 OldTemplateDecl->getTemplatedDecl();
8807 if (isa<CXXMethodDecl>(NewFD))
8808 NewFD->setAccess(OldDecl->getAccess());
8814 if (getLangOpts().CPlusPlus) {
8817 CheckConstructor(Constructor);
8819 dyn_cast<CXXDestructorDecl>(NewFD)) {
8830 Diag(NewFD->getLocation(), diag::err_destructor_name);
8831 NewFD->setInvalidDecl();
8832 return Redeclaration;
8836 = dyn_cast<CXXConversionDecl>(NewFD)) {
8837 ActOnConversionDeclarator(Conversion);
8841 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
8842 if (!Method->isFunctionTemplateSpecialization() &&
8843 !Method->getDescribedFunctionTemplate() &&
8844 Method->isCanonicalDecl()) {
8845 if (AddOverriddenMethods(Method->getParent(), Method)) {
8853 if (Method->isStatic())
8854 checkThisInStaticMemberFunctionType(Method);
8859 CheckOverloadedOperatorDeclaration(NewFD)) {
8860 NewFD->setInvalidDecl();
8861 return Redeclaration;
8866 CheckLiteralOperatorDeclaration(NewFD)) {
8867 NewFD->setInvalidDecl();
8868 return Redeclaration;
8874 if (!CurContext->isRecord())
8875 CheckCXXDefaultArguments(NewFD);
8897 Diag(NewFD->getLocation(), diag::warn_return_value_udt_incomplete)
8901 Diag(NewFD->getLocation(), diag::warn_return_value_udt) << NewFD << R;
8904 return Redeclaration;
8917 ? diag::err_static_main : diag::warn_static_main)
8924 SourceRange NoreturnRange(NoreturnLoc, getLocForEndOfToken(NoreturnLoc));
8925 Diag(NoreturnLoc, diag::ext_noreturn_main);
8926 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
8935 if (getLangOpts().OpenCL) {
8936 Diag(FD->getLocation(), diag::err_opencl_no_main)
8937 << FD->hasAttr<OpenCLKernelAttr>();
8938 FD->setInvalidDecl();
8943 assert(T->
isFunctionType() &&
"function decl is not of function type");
8946 if (getLangOpts().GNUMode && !getLangOpts().CPlusPlus) {
8957 if (RTRange.isValid())
8958 Diag(RTRange.getBegin(), diag::note_main_change_return_type)
8975 FD->setInvalidDecl(
true);
8980 if (isa<FunctionNoProtoType>(FT))
return;
8986 bool HasExtraParameters = (nparams > 3);
8989 Diag(FD->getLocation(), diag::ext_variadic_main);
8998 HasExtraParameters =
false;
9000 if (HasExtraParameters) {
9001 Diag(FD->getLocation(), diag::err_main_surplus_args) << nparams;
9002 FD->setInvalidDecl(
true);
9013 for (
unsigned i = 0; i < nparams; ++i) {
9016 bool mismatch =
true;
9020 else if (Expected[i] == CharPP) {
9033 mismatch = !qs.
empty();
9038 Diag(FD->getLocation(), diag::err_main_arg_wrong) << i << Expected[i];
9040 FD->setInvalidDecl(
true);
9044 if (nparams == 1 && !FD->isInvalidDecl()) {
9045 Diag(FD->getLocation(), diag::warn_main_one_arg);
9049 Diag(FD->getLocation(), diag::err_mainlike_template_decl) << FD;
9050 FD->setInvalidDecl();
9056 assert(T->
isFunctionType() &&
"function decl is not of function type");
9061 if (FT->getReturnType()->isIntegralOrEnumerationType() ||
9062 FT->getReturnType()->isAnyPointerType() ||
9063 FT->getReturnType()->isNullPtrType())
9065 if (FD->
getName() !=
"DllMain")
9069 Diag(FD->getLocation(), diag::err_mainlike_template_decl) << FD;
9070 FD->setInvalidDecl();
9083 const Expr *Culprit;
9087 << Culprit->getSourceRange();
9094 class SelfReferenceChecker
9100 bool isReferenceType;
9109 S(S), OrigDecl(OrigDecl) {
9112 isReferenceType =
false;
9114 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
9115 isPODType = VD->getType().isPODType(S.
Context);
9117 isReferenceType = VD->getType()->isReferenceType();
9124 void CheckExpr(
Expr *
E) {
9133 InitFieldIndex.push_back(0);
9134 for (
auto Child : InitList->
children()) {
9135 CheckExpr(cast<Expr>(Child));
9136 ++InitFieldIndex.back();
9138 InitFieldIndex.pop_back();
9143 bool CheckInitListMemberExpr(
MemberExpr *E,
bool CheckReference) {
9146 bool ReferenceField =
false;
9149 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
9153 Fields.push_back(FD);
9155 ReferenceField =
true;
9161 if (!DRE || DRE->
getDecl() != OrigDecl)
9165 if (CheckReference && !ReferenceField)
9170 for (
const FieldDecl *
I : llvm::reverse(Fields))
9171 UsedFieldIndex.push_back(
I->getFieldIndex());
9176 for (
auto UsedIter = UsedFieldIndex.begin(),
9177 UsedEnd = UsedFieldIndex.end(),
9178 OrigIter = InitFieldIndex.begin(),
9179 OrigEnd = InitFieldIndex.end();
9180 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
9181 if (*UsedIter < *OrigIter)
9183 if (*UsedIter > *OrigIter)
9188 HandleDeclRefExpr(DRE);
9195 void HandleValue(
Expr *E) {
9197 if (
DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
9198 HandleDeclRefExpr(DRE);
9203 Visit(CO->getCond());
9204 HandleValue(CO->getTrueExpr());
9205 HandleValue(CO->getFalseExpr());
9210 dyn_cast<BinaryConditionalOperator>(E)) {
9211 Visit(BCO->getCond());
9212 HandleValue(BCO->getFalseExpr());
9217 HandleValue(OVE->getSourceExpr());
9222 if (BO->getOpcode() == BO_Comma) {
9223 Visit(BO->getLHS());
9224 HandleValue(BO->getRHS());
9229 if (isa<MemberExpr>(E)) {
9231 if (CheckInitListMemberExpr(cast<MemberExpr>(E),
9237 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
9239 if (!isa<FieldDecl>(ME->getMemberDecl()))
9243 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base))
9244 HandleDeclRefExpr(DRE);
9254 if (isReferenceType)
9255 HandleDeclRefExpr(E);
9264 Inherited::VisitImplicitCastExpr(E);
9269 if (CheckInitListMemberExpr(E,
true ))
9279 bool Warn = (MD && !MD->
isStatic());
9281 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
9282 if (!isa<FieldDecl>(ME->getMemberDecl()))
9287 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
9289 HandleDeclRefExpr(DRE);
9301 if (isa<UnresolvedLookupExpr>(Callee))
9302 return Inherited::VisitCXXOperatorCallExpr(E);
9306 HandleValue(Arg->IgnoreParenImpCasts());
9323 Inherited::VisitUnaryOperator(E);
9331 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
9332 if (ILE->getNumInits() == 1)
9333 ArgExpr = ILE->getInit(0);
9335 if (ICE->getCastKind() == CK_NoOp)
9336 ArgExpr = ICE->getSubExpr();
9337 HandleValue(ArgExpr);
9340 Inherited::VisitCXXConstructExpr(E);
9349 HandleValue(E->
getArg(0));
9355 Inherited::VisitCallExpr(E);
9360 HandleValue(E->
getLHS());
9365 Inherited::VisitBinaryOperator(E);
9378 if (OrigDecl != ReferenceDecl)
return;
9380 if (isReferenceType) {
9381 diag = diag::warn_uninit_self_reference_in_reference_init;
9382 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
9383 diag = diag::warn_static_self_reference_in_init;
9384 }
else if (isa<TranslationUnitDecl>(OrigDecl->getDeclContext()) ||
9385 isa<NamespaceDecl>(OrigDecl->getDeclContext()) ||
9387 diag = diag::warn_uninit_self_reference_in_init;
9396 << OrigDecl->getLocation()
9397 << DRE->getSourceRange());
9402 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *E,
9406 if (isa<ParmVarDecl>(OrigDecl))
9413 if (!DirectInit && !cast<VarDecl>(OrigDecl)->getType()->
isRecordType())
9415 if (ICE->getCastKind() == CK_LValueToRValue)
9416 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
9417 if (DRE->
getDecl() == OrigDecl)
9420 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
9429 bool IsInitCapture = !VDecl;
9431 "init captures are expected to be deduced prior to initialization");
9435 if (
auto *PL = dyn_cast<ParenListExpr>(Init))
9436 DeduceInits = PL->exprs();
9437 else if (
auto *IL = dyn_cast<InitListExpr>(Init))
9438 DeduceInits = IL->inits();
9442 if (DeduceInits.empty()) {
9445 Diag(Init->getLocStart(), IsInitCapture
9446 ? diag::err_init_capture_no_expression
9447 : diag::err_auto_var_init_no_expression)
9448 << Name << Type << Range;
9452 if (DeduceInits.size() > 1) {
9453 Diag(DeduceInits[1]->getLocStart(),
9454 IsInitCapture ? diag::err_init_capture_multiple_expressions
9455 : diag::err_auto_var_init_multiple_expressions)
9456 << Name << Type << Range;
9460 Expr *DeduceInit = DeduceInits[0];
9461 if (DirectInit && isa<InitListExpr>(DeduceInit)) {
9462 Diag(Init->getLocStart(), IsInitCapture
9463 ? diag::err_init_capture_paren_braces
9464 : diag::err_auto_var_init_paren_braces)
9465 << isa<InitListExpr>(Init) << Name << Type << Range;
9470 bool DefaultedAnyToId =
false;
9471 if (getLangOpts().DebuggerCastResultToId &&
9477 Init = Result.
get();
9478 DefaultedAnyToId =
true;
9482 if (DeduceAutoType(TSI, DeduceInit, DeducedType) == DAR_Failed) {
9484 DiagnoseAutoDeductionFailure(VDecl, DeduceInit);
9485 else if (isa<InitListExpr>(Init))
9487 diag::err_init_capture_deduction_failure_from_init_list)
9491 << DeduceInit->getSourceRange();
9493 Diag(Range.
getBegin(), diag::err_init_capture_deduction_failure)
9497 << DeduceInit->getSourceRange();
9505 if (ActiveTemplateInstantiations.empty() && !DefaultedAnyToId &&
9508 Diag(Loc, diag::warn_auto_var_is_id) << Name << Range;
9518 bool DirectInit,
bool TypeMayContainAuto) {
9521 if (!RealDecl || RealDecl->isInvalidDecl()) {
9522 CorrectDelayedTyposInExpr(Init, dyn_cast_or_null<VarDecl>(RealDecl));
9526 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
9528 Diag(Method->getLocation(), diag::err_member_function_initialization)
9529 << Method->getDeclName() << Init->getSourceRange();
9530 Method->setInvalidDecl();
9536 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
9537 Diag(RealDecl->getLocation(), diag::err_illegal_initializer);
9538 RealDecl->setInvalidDecl();
9547 ExprResult Res = CorrectDelayedTyposInExpr(Init, VDecl);
9549 RealDecl->setInvalidDecl();
9554 QualType DeducedType = deduceVarTypeFromInitializer(
9557 if (DeducedType.
isNull()) {
9558 RealDecl->setInvalidDecl();
9566 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(VDecl))
9567 VDecl->setInvalidDecl();
9574 MergeVarDeclTypes(VDecl, Old,
false);
9578 CheckVariableDeclarationType(VDecl);
9579 if (VDecl->isInvalidDecl())
9585 Diag(VDecl->getLocation(), diag::err_attribute_dllimport_data_definition);
9586 VDecl->setInvalidDecl();
9592 Diag(VDecl->getLocation(), diag::err_block_extern_cant_init);
9593 VDecl->setInvalidDecl();
9603 BaseDeclType = Array->getElementType();
9604 if (RequireCompleteType(VDecl->getLocation(), BaseDeclType,
9605 diag::err_typecheck_decl_incomplete_type)) {
9606 RealDecl->setInvalidDecl();
9611 if (RequireNonAbstractType(VDecl->getLocation(), VDecl->
getType(),
9612 diag::err_abstract_type_in_decl,
9613 AbstractVariableType))
9614 VDecl->setInvalidDecl();
9620 if (!hasVisibleDefinition(Def, &Hidden) &&
9624 VDecl->getDeclContext()->isDependentContext())) {
9628 Diag(VDecl->getLocation(), diag::err_redefinition)
9630 Diag(Def->getLocation(), diag::note_previous_definition);
9631 VDecl->setInvalidDecl();
9650 Diag(Init->
getExprLoc(), diag::err_static_data_member_reinitialization)
9653 diag::note_previous_initializer)
9659 getCurFunction()->setHasBranchProtectedScope();
9661 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer)) {
9662 VDecl->setInvalidDecl();
9670 Diag(VDecl->getLocation(), diag::err_local_cant_init);
9671 VDecl->setInvalidDecl();
9685 VDecl->setInvalidDecl();
9688 Init = Result.
get();
9693 if (!VDecl->isInvalidDecl()) {
9699 Init->getLocStart(),
9703 Init->getLocStart());
9711 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
9713 Args[Idx], VDecl, [
this, Entity, Kind](
Expr *E) {
9718 VDecl->setInvalidDecl();
9719 }
else if (Res.
get() != Args[Idx]) {
9720 Args[Idx] = Res.
get();
9723 if (VDecl->isInvalidDecl())
9731 VDecl->setInvalidDecl();
9743 CheckSelfReference(*
this, RealDecl, Init, DirectInit);
9750 if (!VDecl->isInvalidDecl() && (DclT != SavT))
9753 if (!VDecl->isInvalidDecl()) {
9754 checkUnsafeAssigns(VDecl->getLocation(), VDecl->
getType(), Init);
9756 if (VDecl->hasAttr<BlocksAttr>())
9757 checkRetainCycles(VDecl, Init);
9767 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
9768 Init->getLocStart()))
9769 getCurFunction()->markSafeWeakUse(Init);
9787 VDecl->setInvalidDecl();
9790 Init = Result.
get();
9799 if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl()) {
9800 const Expr *Culprit;
9802 CheckForConstantInitializer(Init, DclT);
9808 isa<InitListExpr>(Init) &&
9811 diag::ext_aggregate_init_not_constant)
9812 << Culprit->getSourceRange();
9815 VDecl->getLexicalDeclContext()->isRecord()) {
9847 Diag(VDecl->getLocation(), diag::err_in_class_initializer_non_const)
9848 << Init->getSourceRange();
9849 VDecl->setInvalidDecl();
9858 Diag(VDecl->getLocation(), diag::err_in_class_initializer_volatile);
9866 Diag(Loc, diag::ext_in_class_initializer_non_constant)
9867 << Init->getSourceRange();
9871 Diag(Loc, diag::err_in_class_initializer_non_constant)
9872 << Init->getSourceRange();
9873 VDecl->setInvalidDecl();
9880 if (getLangOpts().CPlusPlus11) {
9881 Diag(VDecl->getLocation(),
9882 diag::ext_in_class_initializer_float_type_cxx11)
9883 << DclT << Init->getSourceRange();
9885 diag::note_in_class_initializer_float_type_cxx11)
9888 Diag(VDecl->getLocation(), diag::ext_in_class_initializer_float_type)
9889 << DclT << Init->getSourceRange();
9892 Diag(Init->
getExprLoc(), diag::err_in_class_initializer_non_constant)
9893 << Init->getSourceRange();
9894 VDecl->setInvalidDecl();
9900 Diag(VDecl->getLocation(), diag::err_in_class_initializer_literal_type)
9901 << DclT << Init->getSourceRange()
9906 Diag(VDecl->getLocation(), diag::err_in_class_initializer_bad_type)
9907 << DclT << Init->getSourceRange();
9908 VDecl->setInvalidDecl();
9912 (!getLangOpts().CPlusPlus ||
9916 Diag(VDecl->getLocation(), diag::warn_extern_init);
9919 if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl())
9920 CheckForConstantInitializer(Init, DclT);
9937 if (CXXDirectInit) {
9938 assert(DirectInit &&
"Call-style initializer must be direct init.");
9940 }
else if (DirectInit) {
9945 CheckCompleteVariableDeclaration(VDecl);
9954 if (!D || D->isInvalidDecl())
return;
9960 if (ParsingInitForAutoVars.count(D)) {
9961 D->setInvalidDecl();
9969 if (RequireCompleteType(VD->getLocation(),
9971 diag::err_typecheck_decl_incomplete_type)) {
9972 VD->setInvalidDecl();
9977 if (RequireNonAbstractType(VD->getLocation(), Ty,
9978 diag::err_abstract_type_in_decl,
9979 AbstractVariableType)) {
9980 VD->setInvalidDecl();
9989 bool TypeMayContainAuto) {
9994 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
9999 Diag(Var->getLocation(), diag::err_auto_var_requires_init)
10000 << Var->getDeclName() << Type;
10001 Var->setInvalidDecl();
10011 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) {
10012 if (Var->isStaticDataMember()) {
10015 if (!getLangOpts().CPlusPlus1z) {
10016 Diag(Var->getLocation(),
10017 diag::err_constexpr_static_mem_var_requires_init)
10018 << Var->getDeclName();
10019 Var->setInvalidDecl();
10023 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
10024 Var->setInvalidDecl();
10033 if (VTD->isConcept()) {
10034 Diag(Var->getLocation(), diag::err_var_concept_not_initialized);
10035 Var->setInvalidDecl();
10042 if (!Var->isInvalidDecl() &&
10044 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
10045 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
10046 Var->setInvalidDecl();
10050 switch (Var->isThisDeclarationADefinition()) {
10052 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
10068 !Var->hasLinkage() && !Var->isInvalidDecl() &&
10069 RequireCompleteType(Var->getLocation(), Type,
10070 diag::err_typecheck_decl_incomplete_type))
10071 Var->setInvalidDecl();
10075 RequireNonAbstractType(Var->getLocation(), Type,
10076 diag::err_abstract_type_in_decl,
10077 AbstractVariableType))
10078 Var->setInvalidDecl();
10081 Diag(Var->getLocation(), diag::warn_private_extern);
10082 Diag(Var->getLocation(), diag::note_private_extern);
10093 if (!Var->isInvalidDecl()) {
10096 if (RequireCompleteType(Var->getLocation(),
10097 ArrayT->getElementType(),
10098 diag::err_illegal_decl_array_incomplete_type))
10099 Var->setInvalidDecl();
10100 }
else if (Var->getStorageClass() ==
SC_Static) {
10110 if (Var->isFirstDecl())
10111 RequireCompleteType(Var->getLocation(), Type,
10112 diag::ext_typecheck_decl_incomplete_type);
10117 if (!Var->isInvalidDecl())
10118 TentativeDefinitions.push_back(Var);
10125 Diag(Var->getLocation(),
10126 diag::err_typecheck_incomplete_array_needs_initializer);
10127 Var->setInvalidDecl();
10134 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
10135 << Var->getDeclName()
10136 <<
SourceRange(Var->getLocation(), Var->getLocation());
10137 Var->setInvalidDecl();
10146 if (Var->isInvalidDecl())
10149 if (!Var->hasAttr<AliasAttr>()) {
10150 if (RequireCompleteType(Var->getLocation(),
10152 diag::err_typecheck_decl_incomplete_type)) {
10153 Var->setInvalidDecl();
10161 if (RequireNonAbstractType(Var->getLocation(), Type,
10162 diag::err_abstract_type_in_decl,
10163 AbstractVariableType)) {
10164 Var->setInvalidDecl();
10178 if (getLangOpts().
CPlusPlus && Var->hasLocalStorage()) {
10181 CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl());
10185 if (!CXXRecord->
isPOD())
10186 getCurFunction()->setHasBranchProtectedScope();
10211 Var->setInvalidDecl();
10212 else if (Init.
get()) {
10213 Var->setInit(MaybeCreateExprWithCleanups(Init.
get()));
10218 CheckCompleteVariableDeclaration(Var);
10229 Diag(D->getLocation(), diag::err_for_range_decl_must_be_var);
10230 D->setInvalidDecl();
10260 D->setInvalidDecl();
10276 const char *PrevSpec;
10279 getPrintingPolicy());
10287 EmptyAttrs, IdentLoc);
10288 Decl *Var = ActOnDeclarator(S, D);
10289 cast<VarDecl>(Var)->setCXXForRangeDecl(
true);
10290 FinalizeDeclaration(Var);
10291 return ActOnDeclStmt(FinalizeDeclaratorGroup(S, DS, Var), IdentLoc,
10292 AttrEnd.
isValid() ? AttrEnd : IdentLoc);
10296 if (var->isInvalidDecl())
return;
10298 if (getLangOpts().OpenCL) {
10303 Diag(var->getLocation(), diag::err_opencl_invalid_block_declaration)
10305 var->setInvalidDecl();
10312 if (getLangOpts().ObjC1 &&
10322 getCurFunction()->setHasBranchProtectedScope();
10333 var->getDeclContext()->getRedeclContext()->isFileContext() &&
10335 !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
10336 var->getLocation())) {
10343 Diag(var->getLocation(), diag::warn_missing_variable_declarations) << var;
10347 const Expr *Culprit;
10352 Diag(var->getLocation(), diag::err_thread_nontrivial_dtor);
10353 if (getLangOpts().CPlusPlus11)
10354 Diag(var->getLocation(), diag::note_use_thread_local);
10355 }
else if (getLangOpts().CPlusPlus && var->
hasInit() &&
10363 << Culprit->getSourceRange();
10365 Diag(var->getLocation(), diag::note_use_thread_local);
10372 ActiveTemplateInstantiations.empty()) {
10376 Stack = &ConstSegStack;
10378 Stack = &BSSSegStack;
10381 Stack = &DataSegStack;
10384 if (Stack->
CurrentValue && !var->hasAttr<SectionAttr>()) {
10385 var->addAttr(SectionAttr::CreateImplicit(
10386 Context, SectionAttr::Declspec_allocate,
10389 if (
const SectionAttr *SA = var->getAttr<SectionAttr>())
10390 if (UnifySection(SA->getName(), SectionFlags, var))
10391 var->dropAttr<SectionAttr>();
10396 if (CurInitSeg && var->
getInit())
10397 var->addAttr(InitSegAttr::CreateImplicit(
Context, CurInitSeg->getString(),
10402 if (!getLangOpts().CPlusPlus)
return;
10408 if (var->hasAttr<BlocksAttr>()) {
10419 = PerformMoveOrCopyInitialization(
10421 var, var->
getType(), varRef,
true);
10423 result = MaybeCreateExprWithCleanups(result);
10434 if (!var->getDeclContext()->isDependentContext() &&
10437 !getDiagnostics().isIgnored(diag::warn_global_constructor,
10438 var->getLocation())) {
10445 Diag(var->getLocation(), diag::warn_global_constructor)
10446 << Init->getSourceRange();
10455 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
10456 diag::note_invalid_subexpr_in_const_expr) {
10457 DiagLoc = Notes[0].first;
10460 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
10461 << var << Init->getSourceRange();
10462 for (
unsigned I = 0, N = Notes.size();
I != N; ++
I)
10463 Diag(Notes[
I].first, Notes[
I].second);
10475 FinalizeVarWithDestructor(var, recordType);
10482 for (
auto *
I : VD->specific_attrs<AlignedAttr>())
10483 if (
I->isAlignmentDependent())
10493 ParsingInitForAutoVars.erase(ThisDecl);
10495 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
10510 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
10519 dyn_cast_or_null<FunctionDecl>(VD->getParentFunctionOrMethod())) {
10522 auto *NewAttr = cast<InheritableAttr>(A->clone(getASTContext()));
10523 NewAttr->setInherited(
true);
10524 VD->addAttr(NewAttr);
10529 if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
10530 (FD->hasAttr<CUDADeviceAttr>() || FD->hasAttr<CUDAGlobalAttr>()) &&
10531 !VD->hasAttr<CUDASharedAttr>()) {
10532 Diag(VD->getLocation(), diag::err_device_static_local_var);
10533 VD->setInvalidDecl();
10543 if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
10546 (VD->hasAttr<CUDADeviceAttr>() || VD->hasAttr<CUDAConstantAttr>() ||
10547 VD->hasAttr<CUDASharedAttr>())) {
10548 assert((!VD->
isStaticLocal() || VD->hasAttr<CUDASharedAttr>()));
10549 bool AllowedInit =
false;
10552 isEmptyCudaConstructor(VD->getLocation(), CE->getConstructor());
10556 if (!AllowedInit &&
10557 (VD->hasAttr<CUDADeviceAttr>() || VD->hasAttr<CUDAConstantAttr>()))
10565 isEmptyCudaDestructor(VD->getLocation(), RD->getDestructor());
10567 if (!AllowedInit) {
10568 Diag(VD->getLocation(), VD->hasAttr<CUDASharedAttr>()
10569 ? diag::err_shared_var_init
10570 : diag::err_dynamic_var_init)
10571 << Init->getSourceRange();
10572 VD->setInvalidDecl();
10581 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
10587 cast<CXXRecordDecl>(VD->
getFirstDecl()->getDeclContext());
10588 bool IsClassTemplateMember =
10589 isa<ClassTemplatePartialSpecializationDecl>(
Context) ||
10592 Diag(VD->getLocation(),
10593 IsClassTemplateMember
10594 ? diag::warn_attribute_dllimport_static_field_definition
10595 : diag::err_attribute_dllimport_static_field_definition);
10596 Diag(IA->getLocation(), diag::note_attribute);
10597 if (!IsClassTemplateMember)
10598 VD->setInvalidDecl();
10605 auto *F = dyn_cast_or_null<FunctionDecl>(VD->getParentFunctionOrMethod());
10612 Diag(VD->getLocation(), diag::err_attribute_dll_thread_local) << VD
10614 VD->setInvalidDecl();
10618 if (UsedAttr *
Attr = VD->getAttr<UsedAttr>()) {
10621 VD->dropAttr<UsedAttr>();
10629 AddPushedVisibilityAttribute(VD);
10633 !isa<VarTemplatePartialSpecializationDecl>(VD))
10634 MarkUnusedFileScopedDecl(VD);
10638 if (!VD->hasAttr<TypeTagForDatatypeAttr>() ||
10642 for (
const auto *
I : ThisDecl->specific_attrs<TypeTagForDatatypeAttr>()) {
10644 if (!MagicValueExpr) {
10647 llvm::APSInt MagicValueInt;
10649 Diag(
I->getRange().getBegin(),
10650 diag::err_type_tag_for_datatype_not_ice)
10651 << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange();
10654 if (MagicValueInt.getActiveBits() > 64) {
10655 Diag(
I->getRange().getBegin(),
10656 diag::err_type_tag_for_datatype_too_large)
10657 << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange();
10660 uint64_t MagicValue = MagicValueInt.getZExtValue();
10661 RegisterTypeTagForDatatype(
I->getArgumentKind(),
10663 I->getMatchingCType(),
10664 I->getLayoutCompatible(),
10665 I->getMustBeNull());
10677 for (
unsigned i = 0, e = Group.size(); i != e; ++i)
10678 if (
Decl *D = Group[i]) {
10680 if (!FirstDeclaratorInGroup)
10681 FirstDeclaratorInGroup = DD;
10682 Decls.push_back(D);
10687 handleTagNumbering(Tag, S);
10688 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
10689 getLangOpts().CPlusPlus)
10701 bool TypeMayContainAuto) {
10709 if (TypeMayContainAuto && Group.size() > 1) {
10712 VarDecl *DeducedDecl =
nullptr;
10713 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
10714 if (
VarDecl *D = dyn_cast<VarDecl>(Group[i])) {
10715 AutoType *AT = D->getType()->getContainedAutoType();
10717 if (AT && D->isInvalidDecl())
10724 DeducedCanon = UCanon;
10726 }
else if (DeducedCanon != UCanon) {
10727 Diag(D->getTypeSourceInfo()->getTypeLoc().getBeginLoc(),
10728 diag::err_auto_different_deductions)
10732 << DeducedDecl->
getInit()->getSourceRange()
10733 << D->getInit()->getSourceRange();
10734 D->setInvalidDecl();
10742 ActOnDocumentableDecls(Group);
10744 return DeclGroupPtrTy::make(
10749 ActOnDocumentableDecls(D);
10754 if (Group.empty() || !Group[0])
10757 if (Diags.isIgnored(diag::warn_doc_param_not_found,
10758 Group[0]->getLocation()) &&
10759 Diags.isIgnored(diag::warn_unknown_comment_command_name,
10760 Group[0]->getLocation()))
10763 if (Group.size() >= 2) {
10771 Decl *MaybeTagDecl = Group[0];
10772 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
10773 Group = Group.slice(1);
10779 if (!Comments.empty() &&
10780 !Comments.back()->isAttached()) {
10788 for (
unsigned i = 0, e = Group.size(); i != e; ++i)
10804 }
else if (getLangOpts().CPlusPlus &&
10809 diag::err_invalid_storage_class_in_func_decl);
10818 << getLangOpts().CPlusPlus1z;
10825 DiagnoseFunctionSpecifiers(DS);
10833 CheckExtraCXXDefaultArguments(D);
10849 << GetNameForDeclarator(D).getName();
10859 if (R.isSingleResult()) {
10860 NamedDecl *PrevDecl = R.getFoundDecl();
10861 if (PrevDecl->isTemplateParameter()) {
10865 PrevDecl =
nullptr;
10868 Diag(PrevDecl->getLocation(), diag::note_previous_declaration);
10884 parmDeclType, TInfo,
10888 New->setInvalidDecl();
10898 IdResolver.AddDecl(New);
10900 ProcessDeclAttributes(S, New, D);
10903 Diag(New->getLocation(), diag::err_module_private_local)
10908 if (New->hasAttr<BlocksAttr>()) {
10909 Diag(New->getLocation(), diag::err_block_on_nonlocal);
10925 Param->setImplicit();
10932 if (!ActiveTemplateInstantiations.empty())
10938 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
10946 if (LangOpts.NumLargeByValueCopy == 0)
10953 if (Size > LangOpts.NumLargeByValueCopy)
10954 Diag(D->getLocation(), diag::warn_return_value_size)
10965 if (Size > LangOpts.NumLargeByValueCopy)
10976 if (getLangOpts().ObjCAutoRefCount &&
10989 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
11000 TSInfo, SC,
nullptr);
11005 if (!CurContext->isRecord() &&
11006 RequireNonAbstractType(NameLoc, T, diag::err_abstract_type_in_decl,
11007 AbstractParamType))
11008 New->setInvalidDecl();
11016 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
11029 if (!(getLangOpts().OpenCL && T->
isArrayType())) {
11030 Diag(NameLoc, diag::err_arg_with_address_space);
11031 New->setInvalidDecl();
11045 for (
int i = FTI.
NumParams; i != 0; ) {
11049 llvm::raw_svector_ostream(Code)
11059 const char* PrevSpec;
11068 FTI.
Params[i].
Param = ActOnParamDeclarator(S, ParamD);
11078 assert(getCurFunctionDecl() ==
nullptr &&
"Function parsing confused");
11083 Decl *DP = HandleDeclarator(ParentScope, D, TemplateParameterLists);
11084 return ActOnStartOfFunctionDef(FnBodyScope, DP, SkipBody);
11088 Consumer.HandleInlineFunctionDefinition(D);
11094 if (FD->isInvalidDecl())
11102 if (isa<CXXMethodDecl>(FD))
11122 if (FD->hasAttr<OpenCLKernelAttr>())
11129 bool MissingPrototype =
true;
11134 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
11137 MissingPrototype = !Prev->getType()->isFunctionProtoType();
11139 PossibleZeroParamPrototype = Prev;
11143 return MissingPrototype;
11162 if (SkipBody && !hasVisibleDefinition(Definition) &&
11169 makeMergedDefinitionVisible(TD, FD->getLocation());
11171 makeMergedDefinitionVisible(const_cast<FunctionDecl*>(Definition),
11172 FD->getLocation());
11178 Diag(FD->getLocation(), diag::err_redefinition_extern_inline)
11181 Diag(FD->getLocation(), diag::err_redefinition) << FD->
getDeclName();
11183 Diag(Definition->getLocation(), diag::note_previous_definition);
11184 FD->setInvalidDecl();
11193 LSI->
Lambda = LambdaClass;
11211 for (
const auto &C : LambdaClass->
captures()) {
11212 if (C.capturesVariable()) {
11213 VarDecl *VD = C.getCapturedVar();
11217 const bool ByRef = C.getCaptureKind() ==
LCK_ByRef;
11219 true, C.getLocation(),
11220 C.isPackExpansion()
11222 CaptureType,
nullptr);
11224 }
else if (C.capturesThis()) {
11245 FD = FunTmpl->getTemplatedDecl();
11247 FD = cast<FunctionDecl>(D);
11251 CheckForFunctionRedefinition(FD,
nullptr, SkipBody);
11268 assert(ActiveTemplateInstantiations.size() &&
11269 "There should be an active template instantiation on the stack "
11270 "when instantiating a generic lambda!");
11275 PushFunctionScope();
11281 Diag(FD->getLocation(), diag::err_builtin_definition) << FD;
11282 FD->setInvalidDecl();
11290 !FD->isInvalidDecl() &&
11291 RequireCompleteType(FD->getLocation(), ResultType,
11292 diag::err_func_def_incomplete_result))
11293 FD->setInvalidDecl();
11296 PushDeclContext(FnBodyScope, FD);
11304 Param->setOwningFunction(FD);
11307 if (Param->getIdentifier() && FnBodyScope) {
11308 CheckShadow(FnBodyScope, Param);
11310 PushOnScopeChains(Param, FnBodyScope);
11331 D->setLexicalDeclContext(CurContext);
11336 PushOnScopeChains(D, FnBodyScope,
false);
11340 if (
auto *ED = dyn_cast<EnumDecl>(D)) {
11341 for (
auto *EI : ED->enumerators())
11342 PushOnScopeChains(EI, FnBodyScope,
false);
11349 ResolveExceptionSpec(D->getLocation(), FPT);
11352 if (FD->hasAttr<DLLImportAttr>() && !FD->
isInlined() &&
11354 assert(!FD->hasAttr<DLLExportAttr>());
11355 Diag(FD->getLocation(), diag::err_attribute_dllimport_function_definition);
11356 FD->setInvalidDecl();
11361 ActOnDocumentableDecl(D);
11362 if (getCurLexicalContext()->isObjCContainer() &&
11363 getCurLexicalContext()->getDeclKind() != Decl::ObjCCategoryImpl &&
11364 getCurLexicalContext()->getDeclKind() != Decl::ObjCImplementation)
11365 Diag(FD->getLocation(), diag::warn_function_def_in_objc_container);
11385 for (
unsigned I = 0, E = Scope->
Returns.size();
I !=
E; ++
I) {
11386 if (
const VarDecl *NRVOCandidate = Returns[
I]->getNRVOCandidate()) {
11387 if (!NRVOCandidate->isNRVOVariable())
11388 Returns[
I]->setNRVOCandidate(
nullptr);
11406 Outer.Fun.hasTrailingReturnType()) {
11407 QualType Ty = GetTypeFromParser(Outer.Fun.getTrailingReturnType());
11424 if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
11426 return Consumer.shouldSkipFunctionBody(D);
11430 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Decl))
11431 FD->setHasSkippedBody();
11432 else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(Decl))
11438 return ActOnFinishFunctionBody(D, BodyArg,
false);
11442 bool IsInstantiation) {
11443 FunctionDecl *FD = dcl ? dcl->getAsFunction() :
nullptr;
11448 if (getLangOpts().Coroutines && !getCurFunction()->CoroutineStmts.empty())
11449 CheckCompletedCoroutineBody(FD, Body);
11461 Diag(dcl->getLocation(), diag::err_auto_fn_no_return_but_not_auto)
11463 FD->setInvalidDecl();
11466 TypeLoc ResultType = getReturnTypeLoc(FD);
11474 auto *LSI = getCurLambda();
11475 if (LSI->HasImplicitReturnType) {
11476 deduceClosureReturnType(*LSI);
11482 LSI->ReturnType.isNull() ?
Context.
VoidTy : LSI->ReturnType;
11497 UndefinedButUsed.erase(FD);
11499 !LangOpts.GNUInline &&
11501 UndefinedButUsed.erase(FD);
11511 if (getLangOpts().MicrosoftExt && FD->
isPure() && FD->isCanonicalDecl())
11512 Diag(FD->getLocation(), diag::ext_pure_function_definition);
11514 if (!FD->isInvalidDecl()) {
11518 DiagnoseSizeOfParametersAndReturnValue(FD->
parameters(),
11523 MarkVTableUsed(FD->getLocation(), Constructor->getParent());
11525 MarkVTableUsed(FD->getLocation(), Destructor->getParent());
11532 computeNRVO(Body, getCurFunction());
11540 const FunctionDecl *PossibleZeroParamPrototype =
nullptr;
11542 Diag(FD->getLocation(), diag::warn_missing_prototype) << FD;
11544 if (PossibleZeroParamPrototype) {
11549 TypeLoc TL = TI->getTypeLoc();
11551 Diag(PossibleZeroParamPrototype->getLocation(),
11552 diag::note_declaration_not_a_prototype)
11553 << PossibleZeroParamPrototype
11559 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
11574 if (KeyFunction && KeyFunction->
isDefined(Definition))
11575 MarkVTableUsed(Definition->getLocation(), MD->
getParent(),
true);
11578 MarkVTableUsed(FD->getLocation(), MD->
getParent(),
true);
11583 assert((FD == getCurFunctionDecl() || getCurLambda()->CallOperator == FD) &&
11584 "Function parsing confused");
11585 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
11586 assert(MD == getCurMethodDecl() &&
"Method parsing confused");
11588 if (!MD->isInvalidDecl()) {
11590 DiagnoseSizeOfParametersAndReturnValue(MD->
parameters(),
11594 computeNRVO(Body, getCurFunction());
11596 if (getCurFunction()->ObjCShouldCallSuper) {
11597 Diag(MD->getLocEnd(), diag::warn_objc_missing_super_call)
11598 << MD->getSelector().getAsString();
11599 getCurFunction()->ObjCShouldCallSuper =
false;
11601 if (getCurFunction()->ObjCWarnForNoDesignatedInitChain) {
11603 bool isDesignated =
11604 MD->isDesignatedInitializerForTheInterface(&InitMethod);
11605 assert(isDesignated && InitMethod);
11606 (void)isDesignated;
11609 auto IFace = MD->getClassInterface();
11612 auto SuperD = IFace->getSuperClass();
11620 if (!MD->isUnavailable() && !superIsNSObject(MD)) {
11621 Diag(MD->getLocation(),
11622 diag::warn_objc_designated_init_missing_super_call);
11623 Diag(InitMethod->getLocation(),
11624 diag::note_objc_designated_init_marked_here);
11626 getCurFunction()->ObjCWarnForNoDesignatedInitChain =
false;
11628 if (getCurFunction()->ObjCWarnForNoInitDelegation) {
11630 if (!MD->isUnavailable())
11631 Diag(MD->getLocation(),
11632 diag::warn_objc_secondary_init_missing_init_call);
11633 getCurFunction()->ObjCWarnForNoInitDelegation =
false;
11639 assert(!getCurFunction()->ObjCShouldCallSuper &&
11640 "This should only be set for ObjC methods, which should have been "
11641 "handled in the block above.");
11648 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
11649 DiagnoseReturnInConstructorExceptionHandler(cast<CXXTryStmt>(Body));
11652 if (getCurFunction()->NeedsScopeChecking() &&
11653 !PP.isCodeCompletionEnabled())
11654 DiagnoseInvalidJumps(Body);
11657 if (!Destructor->getParent()->isDependentType())
11658 CheckDestructor(Destructor);
11660 MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(),
11661 Destructor->getParent());
11667 if (getDiagnostics().hasErrorOccurred() ||
11668 getDiagnostics().getSuppressAllDiagnostics()) {
11669 DiscardCleanupsInEvaluationContext();
11671 if (!getDiagnostics().hasUncompilableErrorOccurred() &&
11672 !isa<FunctionTemplateDecl>(dcl)) {
11675 ActivePolicy = &WP;
11678 if (!IsInstantiation && FD && FD->
isConstexpr() && !FD->isInvalidDecl() &&
11679 (!CheckConstexprFunctionDecl(FD) ||
11680 !CheckConstexprFunctionBody(FD, Body)))
11681 FD->setInvalidDecl();
11683 if (FD && FD->hasAttr<NakedAttr>()) {
11684 for (
const Stmt *S : Body->children()) {
11685 if (!isa<AsmStmt>(S) && !isa<NullStmt>(
S)) {
11686 Diag(S->getLocStart(), diag::err_non_asm_stmt_in_naked_function);
11687 Diag(FD->getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
11688 FD->setInvalidDecl();
11694 assert(ExprCleanupObjects.size() ==
11695 ExprEvalContexts.back().NumCleanupObjects &&
11696 "Leftover temporaries in function");
11697 assert(!Cleanup.exprNeedsCleanups() &&
"Unaccounted cleanups in function");
11698 assert(MaybeODRUseExprs.empty() &&
11699 "Leftover expressions for odr-use checking");
11702 if (!IsInstantiation)
11705 PopFunctionScopeInfo(ActivePolicy, dcl);
11709 if (getDiagnostics().hasErrorOccurred()) {
11710 DiscardCleanupsInEvaluationContext();
11722 D = TD->getTemplatedDecl();
11723 ProcessDeclAttributeList(S, D, Attrs.
getList());
11725 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D))
11726 if (Method->isStatic())
11727 checkThisInStaticMemberFunctionAttributes(Method);
11738 if (
NamedDecl *ExternCPrev = findLocallyScopedExternCDecl(&II)) {
11739 Diag(Loc, diag::warn_use_out_of_scope_declaration) << ExternCPrev;
11740 Diag(ExternCPrev->getLocation(), diag::note_previous_declaration);
11741 return ExternCPrev;
11746 if (II.
getName().startswith(
"__builtin_"))
11747 diag_id = diag::warn_builtin_unknown;
11748 else if (getLangOpts().C99)
11749 diag_id = diag::ext_implicit_function_decl;
11751 diag_id = diag::warn_implicit_function_decl;
11752 Diag(Loc, diag_id) << &II;
11759 (Corrected = CorrectTypo(
11762 diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion),
11774 assert(!Error &&
"Error setting up implicit decl!");
11808 FunctionDecl *FD = cast<FunctionDecl>(ActOnDeclarator(TUScope, D));
11811 CurContext = PrevDC;
11813 AddKnownFunctionAttributes(FD);
11828 if (FD->isInvalidDecl())
11835 unsigned FormatIdx;
11838 if (!FD->hasAttr<FormatAttr>()) {
11839 const char *fmt =
"printf";
11841 if (FormatIdx < NumParams &&
11844 FD->addAttr(FormatAttr::CreateImplicit(
Context,
11847 HasVAListArg ? 0 : FormatIdx+2,
11848 FD->getLocation()));
11853 if (!FD->hasAttr<FormatAttr>())
11854 FD->addAttr(FormatAttr::CreateImplicit(
Context,
11857 HasVAListArg ? 0 : FormatIdx+2,
11858 FD->getLocation()));
11864 if (!getLangOpts().MathErrno &&
11866 if (!FD->hasAttr<ConstAttr>())
11867 FD->addAttr(ConstAttr::CreateImplicit(
Context, FD->getLocation()));
11871 !FD->hasAttr<ReturnsTwiceAttr>())
11872 FD->addAttr(ReturnsTwiceAttr::CreateImplicit(
Context,
11873 FD->getLocation()));
11875 FD->addAttr(NoThrowAttr::CreateImplicit(
Context, FD->getLocation()));
11877 FD->addAttr(PureAttr::CreateImplicit(
Context, FD->getLocation()));
11879 FD->addAttr(ConstAttr::CreateImplicit(
Context, FD->getLocation()));
11881 !FD->hasAttr<CUDADeviceAttr>() && !FD->hasAttr<CUDAHostAttr>()) {
11885 if (getLangOpts().CUDAIsDevice !=
11887 FD->addAttr(CUDADeviceAttr::CreateImplicit(
Context, FD->getLocation()));
11889 FD->addAttr(CUDAHostAttr::CreateImplicit(
Context, FD->getLocation()));
11896 if (getLangOpts().CXXExceptions && getLangOpts().ExternCNoUnwind &&
11897 FD->
isExternC() && !FD->hasAttr<NoThrowAttr>()) {
11899 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
11900 FD->addAttr(NoThrowAttr::CreateImplicit(
Context, FD->getLocation()));
11908 (isa<LinkageSpecDecl>(FD->getDeclContext()) &&
11909 cast<LinkageSpecDecl>(FD->getDeclContext())->getLanguage() ==
11916 if (Name->
isStr(
"asprintf") || Name->
isStr(
"vasprintf")) {
11919 if (!FD->hasAttr<FormatAttr>())
11920 FD->addAttr(FormatAttr::CreateImplicit(
Context,
11922 Name->
isStr(
"vasprintf") ? 0 : 3,
11923 FD->getLocation()));
11926 if (Name->
isStr(
"__CFStringMakeConstantString")) {
11929 if (!FD->hasAttr<FormatArgAttr>())
11930 FD->addAttr(FormatArgAttr::CreateImplicit(
Context, 1,
11931 FD->getLocation()));
11937 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
11938 assert(!T.
isNull() &&
"GetTypeForDeclarator() returned null type");
11941 assert(D.
isInvalidType() &&
"no declarator info for valid type");
11954 NewTD->setInvalidDecl();
11959 if (CurContext->isFunctionOrMethod())
11960 Diag(NewTD->getLocation(), diag::err_module_private_local)
11965 NewTD->setModulePrivate();
11981 setTagNameForLinkagePurposes(tagFromDeclSpec, NewTD);
12001 if (BT->isInteger())
12004 Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T;
12012 bool EnumUnderlyingIsImplicit,
const EnumDecl *Prev) {
12013 bool IsFixed = !EnumUnderlyingTy.
isNull();
12015 if (IsScoped != Prev->
isScoped()) {
12016 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
12018 Diag(Prev->getLocation(), diag::note_previous_declaration);
12022 if (IsFixed && Prev->
isFixed()) {
12028 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
12030 Diag(Prev->getLocation(), diag::note_previous_declaration)
12034 }
else if (IsFixed && !Prev->
isFixed() && EnumUnderlyingIsImplicit) {
12038 }
else if (IsFixed != Prev->
isFixed()) {
12039 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
12041 Diag(Prev->getLocation(), diag::note_previous_declaration);
12058 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
12094 if (OldTag == NewTag)
12100 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Previous))
12101 isTemplate = Record->getDescribedClassTemplate();
12103 if (!ActiveTemplateInstantiations.empty()) {
12106 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
12112 if (isDefinition) {
12120 bool previousMismatch =
false;
12121 for (
auto I : Previous->
redecls()) {
12122 if (
I->getTagKind() != NewTag) {
12123 if (!previousMismatch) {
12124 previousMismatch =
true;
12125 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
12129 Diag(
I->getInnerLocStart(), diag::note_struct_class_suggestion)
12147 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
12150 Diag(Redecl->getLocation(), diag::note_previous_use);
12154 Diag(NewTagLoc, diag::note_struct_class_suggestion)
12180 DeclContext *DC = ND->getDeclContext()->getRedeclContext();
12188 Namespaces.push_back(II);
12191 if (Lookup == Namespace)
12198 llvm::raw_svector_ostream OS(Insertion);
12201 std::reverse(Namespaces.begin(), Namespaces.end());
12202 for (
auto *II : Namespaces)
12203 OS << II->getName() <<
"::";
12216 if (OldDC->
Equals(NewDC))
12242 (LangOpts.CPlusPlus &&
12266 bool &OwnedDecl,
bool &IsDependent,
12268 bool ScopedEnumUsesClassTag,
12273 assert((Name !=
nullptr || TUK == TUK_Definition) &&
12274 "Nameless record must be a definition!");
12275 assert(TemplateParameterLists.size() == 0 || TUK != TUK_Reference);
12279 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
12282 bool isExplicitSpecialization =
false;
12283 bool Invalid =
false;
12288 if (TemplateParameterLists.size() > 0 ||
12289 (SS.
isNotEmpty() && TUK != TUK_Reference)) {
12291 MatchTemplateParametersToScopeSpecifier(
12292 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
12293 TUK == TUK_Friend, isExplicitSpecialization, Invalid)) {
12295 Diag(KWLoc, diag::err_enum_template);
12299 if (TemplateParams->size() > 0) {
12308 SS, Name, NameLoc, Attr,
12309 TemplateParams, AS,
12312 TemplateParameterLists.size()-1,
12313 TemplateParameterLists.data(),
12315 return Result.
get();
12318 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
12320 isExplicitSpecialization =
true;
12328 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
12329 bool EnumUnderlyingIsImplicit =
false;
12332 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum))
12336 else if (UnderlyingType.
get()) {
12340 GetTypeFromParser(UnderlyingType.
get(), &TI);
12341 EnumUnderlying = TI;
12343 if (CheckEnumUnderlyingType(TI))
12348 UPPC_FixedUnderlyingType))
12352 if (getLangOpts().MSVCCompat || TUK == TUK_Definition) {
12355 EnumUnderlyingIsImplicit =
true;
12362 bool isStdBadAlloc =
false;
12365 if (TUK == TUK_Friend || TUK == TUK_Reference)
12366 Redecl = NotForRedeclaration;
12375 goto CreateNewDecl;
12380 if (TUK == TUK_Friend || TUK == TUK_Reference) {
12381 DC = computeDeclContext(SS,
false);
12383 IsDependent =
true;
12387 DC = computeDeclContext(SS,
true);
12395 if (RequireCompleteDeclContext(SS, DC))
12400 LookupQualifiedName(Previous, DC);
12405 if (Previous.
empty()) {
12413 (TUK == TUK_Reference || TUK == TUK_Friend)) {
12414 IsDependent =
true;
12419 Diag(NameLoc, diag::err_not_tag_in_scope)
12420 << Kind << Name << DC << SS.
getRange();
12423 goto CreateNewDecl;
12430 if (TUK != TUK_Reference && TUK != TUK_Friend &&
12439 LookupName(Previous, S);
12444 (TUK == TUK_Definition || TUK == TUK_Declaration)) {
12448 if (!ND->getDeclContext()->getRedeclContext()->Equals(
12468 if (!Previous.
empty() && TUK == TUK_Friend) {
12471 bool FriendSawTagOutsideEnclosingNamespace =
false;
12474 DeclContext *DC = ND->getDeclContext()->getRedeclContext();
12476 !EnclosingNS->
Encloses(ND->getDeclContext())) {
12477 if (getLangOpts().MSVCCompat)
12478 FriendSawTagOutsideEnclosingNamespace =
true;
12487 if (Previous.
isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
12489 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
12498 if (!getLangOpts().CPlusPlus && TUK != TUK_Reference) {
12503 while (isa<RecordDecl>(SearchDC) || isa<EnumDecl>(SearchDC))
12511 DiagnoseTemplateParameterShadow(NameLoc, Previous.
getFoundDecl());
12516 if (getLangOpts().
CPlusPlus && Name && DC && StdNamespace &&
12517 DC->
Equals(getStdNamespace()) && Name->
isStr(
"bad_alloc")) {
12519 isStdBadAlloc =
true;
12521 if (Previous.
empty() && StdBadAlloc) {
12525 Previous.
addDecl(getStdBadAlloc());
12533 if (Name && Previous.
empty() &&
12534 (TUK == TUK_Reference || TUK == TUK_Friend)) {
12535 if (Invalid)
goto CreateNewDecl;
12538 if (TUK == TUK_Reference) {
12572 assert(TUK == TUK_Friend);
12588 LookupQualifiedName(Previous, SearchDC);
12591 LookupName(Previous, S);
12599 if (!Previous.
empty()) {
12615 TagDecl *Tag = TT->getDecl();
12618 ->
Equals(TD->getDeclContext()->getRedeclContext())) {
12631 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
12632 auto *OldTag = dyn_cast<
TagDecl>(PrevDecl);
12633 if (SS.
isEmpty() && TUK != TUK_Reference && TUK != TUK_Friend &&
12634 isDeclInScope(Shadow, SearchDC, S, isExplicitSpecialization) &&
12636 *
this, OldTag->getDeclContext(), SearchDC))) {
12637 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
12638 Diag(Shadow->getTargetDecl()->getLocation(),
12639 diag::note_using_decl_target);
12640 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl)
12644 goto CreateNewDecl;
12648 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
12652 if (TUK == TUK_Reference || TUK == TUK_Friend ||
12653 isDeclInScope(DirectPrevDecl, SearchDC, S,
12654 SS.
isNotEmpty() || isExplicitSpecialization)) {
12657 if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind,
12658 TUK == TUK_Definition, KWLoc,
12660 bool SafeToContinue
12661 = (PrevTagDecl->getTagKind() !=
TTK_Enum &&
12663 if (SafeToContinue)
12664 Diag(KWLoc, diag::err_use_with_wrong_tag)
12667 PrevTagDecl->getKindName());
12669 Diag(KWLoc, diag::err_use_with_wrong_tag) <<
Name;
12670 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
12672 if (SafeToContinue)
12673 Kind = PrevTagDecl->getTagKind();
12683 const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
12687 if (TUK == TUK_Reference || TUK == TUK_Friend) {
12689 Diag(ScopedEnumKWLoc, diag::err_enum_class_reference)
12692 return PrevTagDecl;
12697 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
12698 else if (
const Type *T = EnumUnderlying.dyn_cast<
const Type*>())
12699 EnumUnderlyingTy =
QualType(T, 0);
12704 if (CheckEnumRedeclaration(NameLoc.
isValid() ? NameLoc : KWLoc,
12705 ScopedEnum, EnumUnderlyingTy,
12706 EnumUnderlyingIsImplicit, PrevEnum))
12707 return TUK == TUK_Declaration ? PrevTagDecl :
nullptr;
12716 Diag(NameLoc, diag::ext_member_redeclared);
12717 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
12723 if (TUK == TUK_Reference || TUK == TUK_Friend) {
12727 }
else if (TUK == TUK_Reference &&
12728 (PrevTagDecl->getFriendObjectKind() ==
12729 Decl::FOK_Undeclared ||
12730 PP.getModuleContainingLocation(
12731 PrevDecl->getLocation()) !=
12732 PP.getModuleContainingLocation(KWLoc)) &&
12742 ->
Equals(PrevDecl->getDeclContext()->getRedeclContext()))
12743 return PrevTagDecl;
12748 return PrevTagDecl;
12753 if (TUK == TUK_Definition) {
12754 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
12758 bool IsExplicitSpecializationAfterInstantiation =
false;
12759 if (isExplicitSpecialization) {
12761 IsExplicitSpecializationAfterInstantiation =
12762 RD->getTemplateSpecializationKind() !=
12764 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
12765 IsExplicitSpecializationAfterInstantiation =
12766 ED->getTemplateSpecializationKind() !=
12771 if (SkipBody && getLangOpts().
CPlusPlus &&
12772 !hasVisibleDefinition(Def, &Hidden)) {
12779 makeMergedDefinitionVisible(Hidden, KWLoc);
12781 }
else if (!IsExplicitSpecializationAfterInstantiation) {
12785 Diag(NameLoc, diag::warn_redefinition_in_param_list) <<
Name;
12787 Diag(NameLoc, diag::err_redefinition) <<
Name;
12788 Diag(Def->getLocation(), diag::note_previous_definition);
12800 if (TD->isBeingDefined()) {
12801 Diag(NameLoc, diag::err_nested_redefinition) <<
Name;
12802 Diag(PrevTagDecl->getLocation(),
12803 diag::note_previous_definition);
12817 if (TUK == TUK_Friend || TUK == TUK_Reference) {
12818 SearchDC = PrevTagDecl->getDeclContext();
12843 if ((TUK == TUK_Reference || TUK == TUK_Friend) &&
12846 if (isa<TypedefDecl>(PrevDecl)) Kind = 1;
12847 else if (isa<TypeAliasDecl>(PrevDecl)) Kind = 2;
12848 else if (isa<ClassTemplateDecl>(PrevDecl)) Kind = 3;
12849 Diag(NameLoc, diag::err_tag_reference_non_tag) <<
Kind;
12850 Diag(PrevDecl->getLocation(), diag::note_declared_at);
12854 }
else if (!isDeclInScope(DirectPrevDecl, SearchDC, S,
12855 SS.
isNotEmpty() || isExplicitSpecialization)) {
12859 }
else if (TUK == TUK_Reference || TUK == TUK_Friend) {
12861 if (isa<TypedefDecl>(PrevDecl)) Kind = 1;
12862 else if (isa<TypeAliasDecl>(PrevDecl)) Kind = 2;
12863 else if (isa<ClassTemplateDecl>(PrevDecl)) Kind = 3;
12864 Diag(NameLoc, diag::err_tag_reference_conflict) <<
Kind;
12865 Diag(PrevDecl->getLocation(), diag::note_previous_decl) << PrevDecl;
12870 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
12872 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
12873 Diag(NameLoc, diag::err_tag_definition_of_typedef)
12874 << Name << Kind << TND->getUnderlyingType();
12875 Diag(PrevDecl->getLocation(), diag::note_previous_decl) << PrevDecl;
12882 Diag(NameLoc, diag::err_redefinition_different_kind) <<
Name;
12883 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
12910 bool IsForwardReference =
false;
12915 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
12916 ScopedEnumUsesClassTag, !EnumUnderlying.isNull());
12918 if (TUK != TUK_Definition && !Invalid) {
12920 if ((getLangOpts().
CPlusPlus11 || getLangOpts().ObjC2) &&
12921 cast<EnumDecl>(New)->isFixed()) {
12925 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
12926 Diag(Loc, diag::ext_forward_ref_enum_def)
12928 Diag(Def->getLocation(), diag::note_previous_definition);
12930 unsigned DiagID = diag::ext_forward_ref_enum;
12931 if (getLangOpts().MSVCCompat)
12932 DiagID = diag::ext_ms_forward_ref_enum;
12933 else if (getLangOpts().CPlusPlus)
12934 DiagID = diag::err_forward_ref_enum;
12940 if (TUK == TUK_Reference)
12941 IsForwardReference =
true;
12945 if (EnumUnderlying) {
12946 EnumDecl *ED = cast<EnumDecl>(New);
12958 if (getLangOpts().CPlusPlus) {
12961 cast_or_null<CXXRecordDecl>(PrevDecl));
12963 if (isStdBadAlloc && (!StdBadAlloc || getStdBadAlloc()->isImplicit()))
12964 StdBadAlloc = cast<CXXRecordDecl>(New);
12967 cast_or_null<RecordDecl>(PrevDecl));
12972 if (getLangOpts().
CPlusPlus && IsTypeSpecifier && TUK == TUK_Definition) {
12973 Diag(New->getLocation(), diag::err_type_defined_in_type_specifier)
12986 if (!isExplicitSpecialization &&
12987 (TUK == TUK_Definition || TUK == TUK_Declaration) &&
12988 diagnoseQualifiedDeclaration(SS, DC, OrigName, Loc))
12992 if (TemplateParameterLists.size() > 0) {
13000 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
13010 if (TUK == TUK_Definition) {
13011 AddAlignmentAttributesForRecord(RD);
13012 AddMsStructLayoutForRecord(RD);
13016 if (ModulePrivateLoc.
isValid()) {
13017 if (isExplicitSpecialization)
13018 Diag(New->getLocation(), diag::err_module_private_specialization)
13025 New->setModulePrivate();
13030 if (isExplicitSpecialization && CheckMemberSpecialization(New, Previous))
13037 getNonFieldDeclScope(S)->isFunctionPrototypeScope()) {
13041 if (TUK == TUK_Definition && !IsTypeSpecifier) {
13042 Diag(Loc, diag::err_type_defined_in_param_type)
13046 }
else if (!PrevDecl) {
13049 DeclsInPrototypeScope.push_back(New);
13053 New->setInvalidDecl();
13056 ProcessDeclAttributeList(S, New, Attr);
13060 New->setLexicalDeclContext(CurContext);
13066 if (TUK == TUK_Friend)
13067 New->setObjectOfFriendDecl(getLangOpts().MSVCCompat);
13070 if (!Invalid && SearchDC->
isRecord())
13071 SetMemberAccessSpecifier(New, PrevDecl, AS);
13073 if (TUK == TUK_Definition)
13077 if (TUK == TUK_Friend) {
13081 New->setAccess(PrevDecl->getAccess());
13086 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
13087 PushOnScopeChains(New, EnclosingScope,
false);
13089 S = getNonFieldDeclScope(S);
13090 PushOnScopeChains(New, S, !IsForwardReference);
13091 if (IsForwardReference)
13094 CurContext->addDecl(New);
13099 if (!New->isInvalidDecl() &&
13105 mergeDeclAttributes(New, PrevDecl);
13109 AddPushedVisibilityAttribute(New);
13114 return (Invalid && getLangOpts().
CPlusPlus) ?
nullptr : New;
13118 AdjustDeclIfTemplate(TagD);
13119 TagDecl *Tag = cast<TagDecl>(TagD);
13122 PushDeclContext(S, Tag);
13124 ActOnDocumentableDecl(TagD);
13128 AddPushedVisibilityAttribute(Tag);
13132 assert(isa<ObjCContainerDecl>(IDecl) &&
13133 "ActOnObjCContainerStartDefinition - Not ObjCContainerDecl");
13135 assert(getContainingDC(OCD) == CurContext &&
13136 "The next DeclContext should be lexically contained in the current one.");
13143 bool IsFinalSpelledSealed,
13145 AdjustDeclIfTemplate(TagD);
13148 FieldCollector->StartClass();
13154 Record->addAttr(new (
Context)
13155 FinalAttr(FinalLoc,
Context, IsFinalSpelledSealed));
13169 InjectedClassName->setImplicit();
13170 InjectedClassName->setAccess(
AS_public);
13173 PushOnScopeChains(InjectedClassName, S);
13175 "Broken injected-class-name");
13180 AdjustDeclIfTemplate(TagD);
13181 TagDecl *Tag = cast<TagDecl>(TagD);
13186 assert(Tag->isInvalidDecl() &&
"We should already have completed it");
13187 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
13188 RD->completeDefinition();
13191 if (isa<CXXRecordDecl>(Tag))
13192 FieldCollector->FinishClass();
13197 if (getCurLexicalContext()->isObjCContainer() &&
13199 Tag->setTopLevelDeclInObjCContainer();
13202 if (!Tag->isInvalidDecl())
13203 Consumer.HandleTagDeclDefinition(Tag);
13212 assert(DC == CurContext &&
"Mismatch of container contexts");
13213 OriginalLexicalContext = DC;
13214 ActOnObjCContainerFinishDefinition();
13218 ActOnObjCContainerStartDefinition(cast<Decl>(DC));
13219 OriginalLexicalContext =
nullptr;
13223 AdjustDeclIfTemplate(TagD);
13224 TagDecl *Tag = cast<TagDecl>(TagD);
13225 Tag->setInvalidDecl();
13229 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
13243 QualType FieldTy,
bool IsMsStruct,
13244 Expr *BitWidth,
bool *ZeroWidth) {
13253 if (RequireCompleteType(FieldLoc, FieldTy, diag::err_field_incomplete))
13256 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
13257 << FieldName << FieldTy << BitWidth->getSourceRange();
13258 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
13259 << FieldTy << BitWidth->getSourceRange();
13260 }
else if (DiagnoseUnexpandedParameterPack(const_cast<Expr *>(BitWidth),
13261 UPPC_BitFieldWidth))
13269 llvm::APSInt
Value;
13270 ExprResult ICE = VerifyIntegerConstantExpression(BitWidth, &Value);
13273 BitWidth = ICE.
get();
13275 if (Value != 0 && ZeroWidth)
13276 *ZeroWidth =
false;
13279 if (Value == 0 && FieldName)
13280 return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
13282 if (Value.isSigned() && Value.isNegative()) {
13284 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
13285 << FieldName << Value.toString(10);
13286 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
13287 << Value.toString(10);
13293 bool BitfieldIsOverwide = Value.ugt(TypeWidth);
13297 bool CStdConstraintViolation =
13298 BitfieldIsOverwide && !getLangOpts().CPlusPlus;
13299 bool MSBitfieldViolation =
13300 Value.ugt(TypeStorageSize) &&
13302 if (CStdConstraintViolation || MSBitfieldViolation) {
13303 unsigned DiagWidth =
13304 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
13306 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
13307 << FieldName << (
unsigned)Value.getZExtValue()
13308 << !CStdConstraintViolation << DiagWidth;
13310 return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width)
13311 << (
unsigned)Value.getZExtValue() << !CStdConstraintViolation
13320 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
13321 << FieldName << (
unsigned)Value.getZExtValue()
13324 Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_width)
13336 FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD),
13337 DeclStart, D, static_cast<Expr*>(BitfieldWidth),
13356 CheckExtraCXXDefaultArguments(D);
13359 UPPC_DataMemberType)) {
13368 Diag(Loc, diag::err_field_with_address_space);
13376 Diag(Loc, diag::err_opencl_type_struct_or_union_field) << T;
13384 << getLangOpts().CPlusPlus1z;
13387 diag::err_invalid_thread)
13393 LookupName(Previous, S);
13411 if (PrevDecl && PrevDecl->isTemplateParameter()) {
13415 PrevDecl =
nullptr;
13418 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
13419 PrevDecl =
nullptr;
13425 = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
13426 TSSL, AS, PrevDecl, &D);
13428 if (NewFD->isInvalidDecl())
13429 Record->setInvalidDecl();
13432 NewFD->setModulePrivate();
13434 if (NewFD->isInvalidDecl() && PrevDecl) {
13438 PushOnScopeChains(NewFD, S);
13458 bool Mutable,
Expr *BitWidth,
13464 bool InvalidDecl =
false;
13470 InvalidDecl =
true;
13476 if (RequireCompleteType(Loc, EltTy, diag::err_field_incomplete)) {
13478 Record->setInvalidDecl();
13479 InvalidDecl =
true;
13483 if (Def && Def->isInvalidDecl()) {
13484 Record->setInvalidDecl();
13485 InvalidDecl =
true;
13491 if (BitWidth && getLangOpts().OpenCL) {
13492 Diag(Loc, diag::err_opencl_bitfields);
13493 InvalidDecl =
true;
13499 bool SizeIsNegative;
13500 llvm::APSInt Oversized;
13507 Diag(Loc, diag::warn_illegal_constant_array_size);
13508 TInfo = FixedTInfo;
13511 if (SizeIsNegative)
13512 Diag(Loc, diag::err_typecheck_negative_array_size);
13513 else if (Oversized.getBoolValue())
13514 Diag(Loc, diag::err_array_too_large)
13515 << Oversized.toString(10);
13517 Diag(Loc, diag::err_typecheck_field_variable_size);
13518 InvalidDecl =
true;
13523 if (!InvalidDecl && RequireNonAbstractType(Loc, T,
13524 diag::err_abstract_type_in_decl,
13525 AbstractFieldType))
13526 InvalidDecl =
true;
13528 bool ZeroWidth =
false;
13530 BitWidth =
nullptr;
13536 InvalidDecl =
true;
13537 BitWidth =
nullptr;
13543 if (!InvalidDecl && Mutable) {
13544 unsigned DiagID = 0;
13546 DiagID = getLangOpts().MSVCCompat ? diag::ext_mutable_reference
13547 : diag::err_mutable_reference;
13549 DiagID = diag::err_mutable_const;
13555 Diag(ErrLoc, DiagID);
13556 if (DiagID != diag::ext_mutable_reference) {
13558 InvalidDecl =
true;
13570 BitWidth, Mutable, InitStyle);
13572 NewFD->setInvalidDecl();
13574 if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
13575 Diag(Loc, diag::err_duplicate_member) << II;
13576 Diag(PrevDecl->getLocation(), diag::note_previous_declaration);
13577 NewFD->setInvalidDecl();
13580 if (!InvalidDecl && getLangOpts().
CPlusPlus) {
13590 if (CheckNontrivialField(NewFD))
13591 NewFD->setInvalidDecl();
13599 Diag(NewFD->getLocation(), getLangOpts().MicrosoftExt ?
13600 diag::ext_union_member_of_reference_type :
13601 diag::err_union_member_of_reference_type)
13603 if (!getLangOpts().MicrosoftExt)
13604 NewFD->setInvalidDecl();
13613 ProcessDeclAttributes(getCurScope(), NewFD, *D);
13615 if (NewFD->hasAttrs())
13616 CheckAlignasUnderalignment(NewFD);
13621 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewFD))
13622 NewFD->setInvalidDecl();
13625 Diag(Loc, diag::warn_attribute_weak_on_field);
13627 NewFD->setAccess(AS);
13633 assert(getLangOpts().
CPlusPlus &&
"valid check only for C++");
13653 member = CXXCopyConstructor;
13655 member = CXXDefaultConstructor;
13657 member = CXXCopyAssignment;
13659 member = CXXDestructor;
13661 if (member != CXXInvalid) {
13662 if (!getLangOpts().CPlusPlus11 &&
13670 if (getSourceManager().isInSystemHeader(Loc)) {
13671 if (!FD->hasAttr<UnavailableAttr>())
13672 FD->addAttr(UnavailableAttr::CreateImplicit(
Context,
"",
13673 UnavailableAttr::IR_ARCFieldWithOwnership, Loc));
13678 Diag(FD->getLocation(), getLangOpts().CPlusPlus11 ?
13679 diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member :
13680 diag::err_illegal_union_or_anon_struct_member)
13682 DiagnoseNontrivial(RDecl, member);
13683 return !getLangOpts().CPlusPlus11;
13695 switch (ivarVisibility) {
13696 default: llvm_unreachable(
"Unknown visitibility kind");
13712 Expr *BitWidth = (
Expr*)BitfieldWidth;
13724 BitWidth = VerifyBitField(Loc, II, T,
false, BitWidth).get();
13734 Diag(Loc, diag::err_ivar_reference_type);
13740 Diag(Loc, diag::err_typecheck_ivar_variable_size);
13750 if (!EnclosingDecl || EnclosingDecl->isInvalidDecl())
13754 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
13755 if (LangOpts.ObjCRuntime.isFragile()) {
13757 EnclosingContext = IMPDecl->getClassInterface();
13758 assert(EnclosingContext &&
"Implementation has no class interface!");
13761 EnclosingContext = EnclosingDecl;
13764 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
13765 if (LangOpts.ObjCRuntime.isFragile() || !CDecl->IsClassExtension()) {
13766 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
13770 EnclosingContext = EnclosingDecl;
13775 DeclStart, Loc, II, T,
13776 TInfo, ac, (
Expr *)BitfieldWidth);
13779 NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
13781 if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S)
13782 && !isa<TagDecl>(PrevDecl)) {
13783 Diag(Loc, diag::err_duplicate_member) << II;
13784 Diag(PrevDecl->getLocation(), diag::note_previous_declaration);
13785 NewID->setInvalidDecl();
13790 ProcessDeclAttributes(S, NewID, D);
13793 NewID->setInvalidDecl();
13796 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewID))
13797 NewID->setInvalidDecl();
13800 NewID->setModulePrivate();
13806 IdResolver.AddDecl(NewID);
13809 if (LangOpts.ObjCRuntime.isNonFragile() &&
13810 !NewID->isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
13811 Diag(Loc, diag::warn_ivars_in_interface);
13822 if (LangOpts.ObjCRuntime.isFragile() || AllIvarDecls.empty())
13825 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
13833 if (!CD->IsClassExtension())
13845 DeclLoc, DeclLoc,
nullptr,
13851 AllIvarDecls.push_back(Ivar);
13857 assert(EnclosingDecl &&
"missing record or interface decl");
13862 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
13864 switch (DC->getKind()) {
13866 case Decl::ObjCCategory:
13869 case Decl::ObjCImplementation:
13871 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
13880 unsigned NumNamedMembers = 0;
13882 for (
const auto *
I : Record->
decls()) {
13883 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(
I))
13884 if (IFD->getDeclName())
13892 bool ARCErrReported =
false;
13902 RecFields.push_back(FD);
13907 if (FD->isInvalidDecl()) {
13908 EnclosingDecl->setInvalidDecl();
13924 Diag(FD->getLocation(), diag::err_field_declared_as_function)
13926 FD->setInvalidDecl();
13927 EnclosingDecl->setInvalidDecl();
13930 ((i + 1 == Fields.end() && !Record->
isUnion()) ||
13931 ((getLangOpts().MicrosoftExt ||
13933 (i + 1 == Fields.end() || Record->
isUnion())))) {
13938 unsigned DiagID = 0;
13940 DiagID = getLangOpts().MicrosoftExt
13941 ? diag::ext_flexible_array_union_ms
13942 : getLangOpts().CPlusPlus
13943 ? diag::ext_flexible_array_union_gnu
13944 : diag::err_flexible_array_union;
13945 else if (NumNamedMembers < 1)
13946 DiagID = getLangOpts().MicrosoftExt
13947 ? diag::ext_flexible_array_empty_aggregate_ms
13948 : getLangOpts().CPlusPlus
13949 ? diag::ext_flexible_array_empty_aggregate_gnu
13950 : diag::err_flexible_array_empty_aggregate;
13961 if (RD->getNumVBases() != 0)
13962 Diag(FD->getLocation(), diag::err_flexible_array_virtual_base)
13964 if (!getLangOpts().
C99)
13965 Diag(FD->getLocation(), diag::ext_c99_flexible_array_member)
13975 Diag(FD->getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
13977 FD->setInvalidDecl();
13978 EnclosingDecl->setInvalidDecl();
13984 RequireCompleteType(FD->getLocation(), FD->
getType(),
13985 diag::err_field_incomplete)) {
13987 FD->setInvalidDecl();
13988 EnclosingDecl->setInvalidDecl();
13999 if (i + 1 != Fields.end())
14000 Diag(FD->getLocation(), diag::ext_variable_sized_type_in_struct)
14005 Diag(FD->getLocation(), diag::ext_flexible_array_in_struct)
14010 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
14011 RequireNonAbstractType(FD->getLocation(), FD->
getType(),
14012 diag::err_abstract_type_in_decl,
14013 AbstractIvarType)) {
14015 FD->setInvalidDecl();
14023 Diag(FD->getLocation(), diag::err_statically_allocated_object)
14027 }
else if (getLangOpts().ObjCAutoRefCount && Record && !ARCErrReported &&
14038 if (getSourceManager().isInSystemHeader(loc)) {
14039 if (!FD->hasAttr<UnavailableAttr>()) {
14040 FD->addAttr(UnavailableAttr::CreateImplicit(
Context,
"",
14041 UnavailableAttr::IR_ARCFieldWithOwnership, loc));
14044 Diag(FD->getLocation(), diag::err_arc_objc_object_in_tag)
14047 ARCErrReported =
true;
14049 }
else if (getLangOpts().ObjC1 &&
14074 bool Completed =
false;
14075 if (
CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) {
14076 if (!CXXRecord->isInvalidDecl()) {
14079 I = CXXRecord->conversion_begin(),
14080 E = CXXRecord->conversion_end();
I !=
E; ++
I)
14081 I.setAccess((*I)->getAccess());
14084 if (!CXXRecord->isDependentType()) {
14085 if (CXXRecord->hasUserDeclaredDestructor()) {
14087 if (getLangOpts().CPlusPlus11)
14088 AdjustDestructorExceptionSpec(CXXRecord,
14089 CXXRecord->getDestructor());
14092 if (!CXXRecord->isInvalidDecl()) {
14094 AddImplicitlyDeclaredMembersToClass(CXXRecord);
14099 if (CXXRecord->getNumVBases()) {
14101 CXXRecord->getFinalOverriders(FinalOverriders);
14104 MEnd = FinalOverriders.end();
14107 SOEnd = M->second.end();
14108 SO != SOEnd; ++SO) {
14109 assert(SO->second.size() > 0 &&
14110 "Virtual function without overridding functions?");
14111 if (SO->second.size() == 1)
14118 Diag(Record->getLocation(), diag::err_multiple_final_overriders)
14119 << (
const NamedDecl *)M->first << Record;
14120 Diag(M->first->getLocation(),
14121 diag::note_overridden_virtual_function);
14123 OM = SO->second.begin(),
14124 OMEnd = SO->second.end();
14126 Diag(OM->Method->getLocation(), diag::note_final_overrider)
14127 << (
const NamedDecl *)M->first << OM->Method->getParent();
14129 Record->setInvalidDecl();
14142 if (Record->hasAttrs()) {
14143 CheckAlignasUnderalignment(Record);
14145 if (
const MSInheritanceAttr *IA = Record->getAttr<MSInheritanceAttr>())
14146 checkMSInheritanceAttrOnDefinition(cast<CXXRecordDecl>(Record),
14147 IA->getRange(), IA->getBestCase(),
14148 IA->getSemanticSpelling());
14154 bool CheckForZeroSize;
14155 if (!getLangOpts().CPlusPlus) {
14156 CheckForZeroSize =
true;
14165 if (CheckForZeroSize) {
14166 bool ZeroSize =
true;
14167 bool IsEmpty =
true;
14168 unsigned NonBitFields = 0;
14171 (NonBitFields == 0 || ZeroSize) &&
I != E; ++
I) {
14173 if (
I->isUnnamedBitfield()) {
14174 if (
I->getBitWidthValue(
Context) > 0)
14190 diag::warn_zero_size_struct_union_in_extern_c :
14191 diag::warn_zero_size_struct_union_compat)
14192 << IsEmpty << Record->
isUnion() << (NonBitFields > 1);
14197 if (NonBitFields == 0 && !getLangOpts().CPlusPlus) {
14198 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union :
14199 diag::ext_no_named_members_in_struct_union)
14207 ID->setEndOfDefinitionLoc(RBrac);
14209 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
14210 ClsFields[i]->setLexicalDeclContext(
ID);
14211 ID->addDecl(ClsFields[i]);
14215 if (
ID->getSuperClass())
14216 DiagnoseDuplicateIvars(
ID,
ID->getSuperClass());
14218 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
14219 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
14220 for (
unsigned I = 0, N = RecFields.size();
I != N; ++
I)
14223 ClsFields[
I]->setLexicalDeclContext(IMPDecl);
14224 CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
14225 IMPDecl->setIvarLBraceLoc(LBrac);
14226 IMPDecl->setIvarRBraceLoc(RBrac);
14228 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
14236 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
14240 Diag(ClsFields[i]->getLocation(),
14241 diag::err_duplicate_ivar_declaration);
14242 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
14248 Diag(ClsFields[i]->getLocation(),
14249 diag::err_duplicate_ivar_declaration);
14250 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
14255 ClsFields[i]->setLexicalDeclContext(CDecl);
14256 CDecl->addDecl(ClsFields[i]);
14258 CDecl->setIvarLBraceLoc(LBrac);
14259 CDecl->setIvarRBraceLoc(RBrac);
14264 ProcessDeclAttributeList(S, Record, Attr);
14270 llvm::APSInt &
Value,
14272 assert(T->
isIntegralType(Context) &&
"Integral type required!");
14275 if (Value.isUnsigned() || Value.isNonNegative()) {
14278 return Value.getActiveBits() <= BitWidth;
14280 return Value.getMinSignedBits() <= BitWidth;
14288 assert(T->
isIntegralType(Context) &&
"Integral type required!");
14289 const unsigned NumTypes = 4;
14290 QualType SignedIntegralTypes[NumTypes] = {
14293 QualType UnsignedIntegralTypes[NumTypes] = {
14300 : UnsignedIntegralTypes;
14301 for (
unsigned I = 0;
I != NumTypes; ++
I)
14314 llvm::APSInt EnumVal(IntWidth);
14317 if (Val && DiagnoseUnexpandedParameterPack(Val, UPPC_EnumeratorValue))
14321 Val = DefaultLvalueConversion(Val).get();
14328 if (getLangOpts().CPlusPlus11 && Enum->
isFixed() &&
14329 !getLangOpts().MSVCCompat) {
14340 Val = Converted.
get();
14342 !(Val = VerifyIntegerConstantExpression(Val,
14343 &EnumVal).get())) {
14354 if (getLangOpts().MSVCCompat) {
14355 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
14356 Val = ImpCastExprToType(Val, EltTy, CK_IntegralCast).get();
14358 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
14360 Val = ImpCastExprToType(Val, EltTy,
14362 CK_IntegralToBoolean : CK_IntegralCast)
14379 Diag(IdLoc, diag::ext_enum_value_not_int)
14380 << EnumVal.toString(10) << Val->getSourceRange()
14381 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
14384 Val = ImpCastExprToType(Val,
Context.
IntTy, CK_IntegralCast).get();
14393 if (Enum->isDependentType())
14395 else if (!LastEnumConst) {
14404 if (Enum->isFixed()) {
14405 EltTy = Enum->getIntegerType();
14412 EnumVal = LastEnumConst->getInitVal();
14414 EltTy = LastEnumConst->getType();
14417 if (EnumVal < LastEnumConst->getInitVal()) {
14432 EnumVal = LastEnumConst->getInitVal();
14433 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
14435 if (
Enum->isFixed())
14437 Diag(IdLoc, diag::err_enumerator_wrapped)
14438 << EnumVal.toString(10)
14441 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
14442 << EnumVal.toString(10);
14450 EnumVal = LastEnumConst->getInitVal();
14451 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
14460 if (!getLangOpts().CPlusPlus && !T.
isNull())
14461 Diag(IdLoc, diag::warn_enum_value_overflow);
14462 }
else if (!getLangOpts().CPlusPlus &&
14465 Diag(IdLoc, diag::ext_enum_value_not_int)
14466 << EnumVal.toString(10) << 1;
14471 if (!EltTy->isDependentType()) {
14475 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
14493 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
14497 EnumDecl *PrevED = cast<EnumDecl>(PrevECD->getDeclContext());
14512 EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl);
14514 cast_or_null<EnumConstantDecl>(lastEnumConst);
14524 if (PrevDecl && PrevDecl->isTemplateParameter()) {
14528 PrevDecl =
nullptr;
14549 "Received TagDecl when not in C++!");
14551 shouldLinkPossiblyHiddenDecl(PrevDecl, New)) {
14552 if (isa<EnumConstantDecl>(PrevDecl))
14553 Diag(IdLoc, diag::err_redefinition_of_enumerator) << Id;
14555 Diag(IdLoc, diag::err_redefinition) << Id;
14556 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
14565 New->setAccess(TheEnumDecl->getAccess());
14586 if (!BO->isAdditiveOp())
14594 InitExpr = BO->getLHS();
14616 bool isTombstoneOrEmptyKey;
14617 DupKey(int64_t val,
bool isTombstoneOrEmptyKey)
14618 : val(val), isTombstoneOrEmptyKey(isTombstoneOrEmptyKey) {}
14621 static DupKey GetDupKey(
const llvm::APSInt& Val) {
14622 return DupKey(Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue(),
14626 struct DenseMapInfoDupKey {
14627 static DupKey getEmptyKey() {
return DupKey(0,
true); }
14628 static DupKey getTombstoneKey() {
return DupKey(1,
true); }
14629 static unsigned getHashValue(
const DupKey Key) {
14630 return (
unsigned)(Key.val * 37);
14632 static bool isEqual(
const DupKey& LHS,
const DupKey& RHS) {
14633 return LHS.isTombstoneOrEmptyKey == RHS.isTombstoneOrEmptyKey &&
14634 LHS.val == RHS.val;
14644 if (S.
Diags.
isIgnored(diag::warn_duplicate_enum_values, Enum->getLocation()))
14657 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
14658 typedef llvm::DenseMap<DupKey, DeclOrVector, DenseMapInfoDupKey>
14661 DuplicatesVector DupVector;
14662 ValueToVectorMap EnumMap;
14666 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
14679 DeclOrVector &Entry = EnumMap[Key];
14682 if (Entry.isNull())
14687 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
14694 DeclOrVector& Entry = EnumMap[Key];
14695 if (Entry.isNull())
14704 ECDVector *Vec =
new ECDVector();
14706 Vec->push_back(ECD);
14713 DupVector.push_back(Vec);
14717 ECDVector *Vec = Entry.get<ECDVector*>();
14719 if (*Vec->begin() == ECD)
14722 Vec->push_back(ECD);
14727 DupVectorEnd = DupVector.end();
14728 DupVectorIter != DupVectorEnd; ++DupVectorIter) {
14729 ECDVector *Vec = *DupVectorIter;
14730 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
14734 S.
Diag((*I)->getLocation(), diag::warn_duplicate_enum_values)
14735 << (*I)->getName() << (*I)->getInitVal().toString(10)
14736 << (*I)->getSourceRange();
14742 S.
Diag((*I)->getLocation(), diag::note_duplicate_element)
14743 << (*I)->getName() << (*I)->getInitVal().toString(10)
14744 << (*I)->getSourceRange();
14750 bool AllowMask)
const {
14751 assert(ED->hasAttr<FlagEnumAttr>() &&
"looking for value in non-flag enum");
14754 auto R =
FlagBitsCache.insert(std::make_pair(ED, llvm::APInt()));
14755 llvm::APInt &FlagBits = R.first->second;
14759 const auto &EVal = E->getInitVal();
14761 if (EVal.isPowerOf2())
14762 FlagBits = FlagBits.zextOrSelf(EVal.getBitWidth()) | EVal;
14774 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
14775 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
14782 EnumDecl *Enum = cast<EnumDecl>(EnumDeclX);
14789 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
14791 cast_or_null<EnumConstantDecl>(Elements[i]);
14792 if (!ECD)
continue;
14810 unsigned NumNegativeBits = 0;
14811 unsigned NumPositiveBits = 0;
14814 bool AllElementsInt =
true;
14816 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
14818 cast_or_null<EnumConstantDecl>(Elements[i]);
14819 if (!ECD)
continue;
14821 const llvm::APSInt &InitVal = ECD->
getInitVal();
14824 if (InitVal.isUnsigned() || InitVal.isNonNegative())
14825 NumPositiveBits =
std::max(NumPositiveBits,
14826 (
unsigned)InitVal.getActiveBits());
14828 NumNegativeBits =
std::max(NumNegativeBits,
14829 (
unsigned)InitVal.getMinSignedBits());
14832 if (AllElementsInt)
14838 unsigned BestWidth;
14851 bool Packed = Enum->hasAttr<PackedAttr>();
14862 BestPromotionType = BestType;
14866 else if (NumNegativeBits) {
14870 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
14872 BestWidth = CharWidth;
14873 }
else if (Packed && NumNegativeBits <= ShortWidth &&
14874 NumPositiveBits < ShortWidth) {
14876 BestWidth = ShortWidth;
14877 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
14879 BestWidth = IntWidth;
14883 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
14888 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
14889 Diag(Enum->getLocation(), diag::ext_enum_too_large);
14893 BestPromotionType = (BestWidth <= IntWidth ?
Context.
IntTy : BestType);
14898 if (Packed && NumPositiveBits <= CharWidth) {
14901 BestWidth = CharWidth;
14902 }
else if (Packed && NumPositiveBits <= ShortWidth) {
14905 BestWidth = ShortWidth;
14906 }
else if (NumPositiveBits <= IntWidth) {
14908 BestWidth = IntWidth;
14910 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
14912 }
else if (NumPositiveBits <=
14916 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
14920 assert(NumPositiveBits <= BestWidth &&
14921 "How could an initializer get larger than ULL?");
14924 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
14931 for (
auto *D : Elements) {
14932 auto *ECD = cast_or_null<EnumConstantDecl>(D);
14933 if (!ECD)
continue;
14942 llvm::APSInt InitVal = ECD->getInitVal();
14953 NewWidth = IntWidth;
14955 }
else if (ECD->getType() == BestType) {
14961 ECD->setType(EnumType);
14965 NewWidth = BestWidth;
14970 InitVal = InitVal.extOrTrunc(NewWidth);
14971 InitVal.setIsSigned(NewSign);
14972 ECD->setInitVal(InitVal);
14975 if (ECD->getInitExpr() &&
14979 ECD->getInitExpr(),
14986 ECD->setType(EnumType);
14988 ECD->setType(NewTy);
14992 NumPositiveBits, NumNegativeBits);
14996 if (Enum->hasAttr<FlagEnumAttr>()) {
14997 for (
Decl *D : Elements) {
14999 if (!ECD)
continue;
15002 if (InitVal != 0 && !InitVal.isPowerOf2() &&
15004 Diag(ECD->getLocation(), diag::warn_flag_enum_constant_out_of_range)
15010 if (Enum->hasAttrs())
15020 AsmString, StartLoc,
15028 bool FromInclude =
false) {
15031 if (
auto *LSD = dyn_cast<LinkageSpecDecl>(DC)) {
15032 switch (LSD->getLanguage()) {
15035 ExternCLoc = LSD->getLocStart();
15043 while (isa<LinkageSpecDecl>(DC))
15046 if (!isa<TranslationUnitDecl>(DC)) {
15048 ? diag::ext_module_import_not_at_top_level_noop
15049 : diag::err_module_import_not_at_top_level_fatal)
15051 S.
Diag(cast<Decl>(DC)->getLocStart(),
15052 diag::note_module_import_not_at_top_level) << DC;
15054 S.
Diag(ImportLoc, diag::ext_module_import_in_extern_c)
15056 S.
Diag(ExternCLoc, diag::note_module_import_in_extern_c);
15082 ? diag::err_module_self_import
15083 : diag::err_module_import_in_implementation)
15088 for (
unsigned I = 0, N = Path.size();
I != N; ++
I) {
15093 ModCheck = ModCheck->
Parent;
15095 IdentifierLocs.push_back(Path[
I].second);
15100 AtLoc.
isValid()? AtLoc : ImportLoc,
15101 Mod, IdentifierLocs);
15114 bool IsInModuleIncludes =
15120 bool ShouldAddImport =
15121 !IsInModuleIncludes &&
15128 if (ShouldAddImport) {
15138 VisibleModules.
setVisible(Mod, DirectiveLoc);
15145 VisibleModulesStack.push_back(std::move(VisibleModules));
15146 VisibleModules.
setVisible(Mod, DirectiveLoc);
15153 VisibleModules = std::move(VisibleModulesStack.back());
15154 VisibleModulesStack.pop_back();
15155 VisibleModules.
setVisible(Mod, DirectiveLoc);
15187 AsmLabelAttr *
Attr =
15188 AsmLabelAttr::CreateImplicit(
Context, AliasName->
getName(), AliasNameLoc);
15194 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
15196 PrevDecl->addAttr(Attr);
15198 Diag(PrevDecl->getLocation(), diag::warn_redefine_extname_not_applied)
15199 << (isa<FunctionDecl>(PrevDecl) ? 0 : 1) << PrevDecl;
15211 PrevDecl->addAttr(WeakAttr::CreateImplicit(
Context, PragmaLoc));
15214 std::pair<IdentifierInfo*,WeakInfo>
15228 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
15229 if (!PrevDecl->hasAttr<AliasAttr>())
15230 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
15234 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W));
15239 return (dyn_cast_or_null<ObjCContainerDecl>(
CurContext));
15256 D = MD->getClassInterface();
15261 dyn_cast<ObjCImplementationDecl>(D)) {
15262 D =
ID->getClassInterface();
static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, const FunctionDecl *&PossibleZeroParamPrototype)
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
unsigned getFlags() const
getFlags - Return the flags for this scope.
A call to an overloaded operator written using operator syntax.
unsigned getAddressSpace() const
Return the address space of this type.
SourceLocation getThreadStorageClassSpecLoc() const
param_const_iterator param_begin() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
void setHasSkippedBody(bool Skipped=true)
Defines the clang::ASTContext interface.
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
SourceLocation getEnd() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
CastKind getCastKind() const
IdKind getKind() const
Determine what kind of name we have.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
static const Decl * getCanonicalDecl(const Decl *D)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
void setDeclsInPrototypeScope(ArrayRef< NamedDecl * > NewDecls)
Name lookup found a set of overloaded functions that met the criteria.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
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 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.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
bool CheckNontrivialField(FieldDecl *FD)
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
no exception specification
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
void setAnonymousStructOrUnion(bool Anon)
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
SourceLocation getRestrictSpecLoc() const
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
A (possibly-)qualified type.
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 ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
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).
capture_const_range captures() const
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any...
void InstantiatedLocal(const Decl *D, Decl *Inst)
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
SourceLocation getConstSpecLoc() const
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 isReplaceableGlobalAllocationFunction() const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
SourceLocation getExplicitSpecLoc() const
ExtInfo withCallingConv(CallingConv cc) const
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
bool isBitField() const
Determines whether this field is a bitfield.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
bool hasLinkageBeenComputed() const
True if something has required us to compute the linkage of this declaration.
QualType getType() const
Retrieves the type of the base class.
bool isElidable() const
Whether this construction is elidable.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
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 ...
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.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
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...
Decl * getRepAsDecl() const
static ShadowedDeclKind computeShadowedDeclKind(const NamedDecl *ShadowedDecl, const DeclContext *OldDC)
Determine what kind of declaration we're shadowing.
const LangOptions & getLangOpts() const
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.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
static void CheckForDuplicateEnumValues(Sema &S, ArrayRef< Decl * > Elements, EnumDecl *Enum, QualType EnumType)
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
DeclClass * getAsSingle() const
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void setStarLoc(SourceLocation Loc)
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Filter makeFilter()
Create a filter for this result set.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
const Expr * getInitExpr() const
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 "...
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
unsigned getIntWidth(QualType T) const
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
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 ActOnDocumentableDecls(ArrayRef< Decl * > Group)
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...
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)
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
A conversion function name, e.g., operator int.
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsExplicitSpecialization)
Perform semantic checking of a new function declaration.
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
void erase()
Erase the last element returned from this iterator.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
bool isRecordType() const
static const TST TST_typeofExpr
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
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 ...
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.
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...
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
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...
bool isVoidPointerType() const
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
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)
bool hasFlexibleArrayMember() const
void setPreviousDeclaration(FunctionDecl *PrevDecl)
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
SCS getStorageClassSpec() const
bool hasDefinition() const
FunctionDefinitionKind getFunctionDefinitionKind() const
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
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, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
bool hasLinkage() const
Determine whether this declaration has linkage.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
unsigned getLength() const
Efficiently return the length of this identifier info.
static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New)
static void checkDuplicateDefaultInit(Sema &S, CXXRecordDecl *Parent, SourceLocation DefaultInitLoc)
MapType::iterator iterator
QualType getRecordType(const RecordDecl *Decl) const
One instance of this struct is used for each type in a declarator that is parsed. ...
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
const Expr * getInit() const
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.
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.
ObjCDeclQualifier getObjCDeclQualifier() const
SourceLocation getInlineSpecLoc() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool isBooleanType() const
void ActOnExitFunctionContext()
A container of type source information.
Wrapper for void* pointer.
Look up of a name that precedes the '::' scope resolution operator in C++.
static NestedNameSpecifier * synthesizeCurrentNestedNameSpecifier(ASTContext &Context, DeclContext *DC)
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
unsigned getFunctionPrototypeDepth() const
Returns the number of function prototype scopes in this scope chain.
SourceRange getIntegerTypeRange() const LLVM_READONLY
Retrieve the source range that covers the underlying type if specified.
bool isBlockPointerType() const
static unsigned GetDiagnosticTypeSpecifierID(DeclSpec::TST T)
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
void setInitStyle(InitializationStyle Style)
bool isConceptSpecified() const
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
Represents a C++ constructor within a class.
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
***static FixItHint createFriendTagNNSFixIt(Sema &SemaRef, NamedDecl *ND, Scope *S, SourceLocation NameLoc)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group, bool TypeMayContainAuto=true)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Retains information about a function, method, or block that is currently being parsed.
This file provides some common utility functions for processing Lambda related AST Constructs...
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class, then each of the following shall have a name different from T:
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
void setRAngleLoc(SourceLocation Loc)
void ActOnObjCReenterContainerContext(DeclContext *DC)
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
RAII object that enters a new expression evaluation context.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
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)
bool isFileVarDecl() const
isFileVarDecl - Returns true for file scoped variable declaration.
static const TST TST_underlyingType
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Information about one declarator, including the parsed type information and the identifier.
DiagnosticsEngine & Diags
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
const Expr * getCallee() const
TLSKind getTLSKind() const
Extra information about a function prototype.
AutoTypeKeyword getKeyword() const
TypeSpecifierType
Specifies the kind of type.
QualType getObjCClassType() const
Represents the Objective-C Class type.
field_iterator field_begin() const
bool isCLike() const
True if this class is C-like, without C++-specific features, e.g.
The "__interface" keyword.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
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...
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
static const TST TST_interface
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.
Stores a list of template parameters for a TemplateDecl and its derived classes.
static StringRef getTagTypeKindName(TagTypeKind Kind)
Visibility getVisibility() const
Determines the visibility of this entity.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value...
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...
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
static QualType getCoreType(QualType Ty)
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
ParmVarDecl - Represents a parameter to a function.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Defines the clang::Expr interface and subclasses for C++ expressions.
FormatAttr * mergeFormatAttr(Decl *D, SourceRange Range, IdentifierInfo *Format, int FormatIdx, int FirstArg, unsigned AttrSpellingListIndex)
void removeDecl(Decl *D)
Removes a declaration from this context.
bool isEmpty() const
No scope specifier.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
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...
void ActOnUninitializedDecl(Decl *dcl, bool TypeMayContainAuto)
Information about a template-id annotation token.
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
HandleField - Analyze a field of a C struct or a C++ data member.
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
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...
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
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)
unsigned getNumParams() const
RecordDecl - Represents a struct/union/class.
std::string getFullModuleName() const
Retrieve the full name of this module, including the path from its top-level module.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getName() const
getName - Returns the embedded declaration name.
One of these records is kept for each identifier that is lexed.
void setIntegerType(QualType T)
Set the underlying integer type.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
ExtInfo withProducesResult(bool producesResult) const
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
bool isScalarType() const
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
bool isAuxBuiltinID(unsigned ID) const
Return true if builtin ID belongs to AuxTarget.
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.
method_iterator end_overridden_methods() const
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
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...
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes, if any.
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)
IdentifierInfo * getCorrectionAsIdentifierInfo() const
AttributeList * getList() const
void setManglingNumber(const NamedDecl *ND, unsigned Number)
Expr * getSizeExpr() const
static void mergeParamDeclTypes(ParmVarDecl *NewParam, const ParmVarDecl *OldParam, Sema &S)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
TypeLoc getPointeeLoc() const
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.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
The results of name lookup within a DeclContext.
ArrayRef< QualType > getParamTypes() 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.
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
bool isReferenceType() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
static const TST TST_class
QualType getReturnType() 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...
bool isStructureOrClassType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
void completeDefinition()
Completes the definition of this tag declaration.
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
OverloadedOperatorKind Operator
The kind of overloaded operator.
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, AttributeList *Attr)
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
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.
bool isPure() const
Whether this virtual function is pure, i.e.
static bool isIncrementDecrementOp(Opcode Op)
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void startDefinition()
Starts the definition of this tag declaration.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
CXXMethodDecl * getCanonicalDecl() override
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
CXXRecordDecl * getDefinition() const
bool isTranslationUnit() const
bool isNoreturnSpecified() const
void setElaboratedKeywordLoc(SourceLocation Loc)
TagKind getTagKind() const
The iterator over UnresolvedSets.
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static const TST TST_error
Token - This structure provides full information about a lexed token.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
SmallVector< Attr *, 2 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
This declaration is definitely a definition.
static const TST TST_enum
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
SourceLocation getTypeSpecTypeLoc() const
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
SourceLocation getLocStart() const LLVM_READONLY
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()
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
unsigned getRegParm() const
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.
Decl * ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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...
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.
bool isThisDeclarationADefinition() const
isThisDeclarationADefinition() - Return true if this declaration is a completion definition of the ty...
void diagnoseMisplacedModuleImport(Module *M, SourceLocation ImportLoc)
Check if module import may be found in the current context, emit error if not.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
RawCommentList & getRawCommentList()
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type, bool NRVO)
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool isLinkageValid() const
True if the computed linkage is valid.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
unsigned getRegParmType() const
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
SourceLocation getBeginLoc() const
Get the begin source location.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
Describes an C or C++ initializer list.
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
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 ...
QualType getParenType(QualType NamedType) const
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.
const TargetInfo & getTargetInfo() const
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.
MinSizeAttr * mergeMinSizeAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
ObjCContainerDecl - Represents a container for method declarations.
const LangOptions & getLangOpts() const
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...
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
CharUnits - This is an opaque type for sizes expressed in character units.
A convenient class for passing around template argument information.
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
void setcudaConfigureCallDecl(FunctionDecl *FD)
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
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 isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
DeclarationNameInfo getNameInfo() const
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
QualType getReturnType() const
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)
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
AmbiguityKind getAmbiguityKind() const
bool isDefaulted() const
Whether this function is defaulted per C++0x.
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Visibility
Describes the different kinds of visibility that a declaration may have.
field_range fields() const
Decl * ActOnObjCContainerStartDefinition(Decl *IDecl)
static ParsedType recoverFromTypeInKnownDependentBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc)
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
char * location_data() const
Retrieve the data associated with the source-location information.
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)
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)
An implicit 'self' parameter.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
static OpenCLParamType getOpenCLKernelParameterType(QualType PT)
static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization, bool IsDefinition)
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
QualType withoutLocalFastQualifiers() 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...
bool isOverloadedOperator() const
isOverloadedOperator - Whether this function declaration represents an C++ overloaded operator...
LabelStmt * getStmt() const
bool isVariadic() const
Whether this function is variadic.
void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
The parser has processed a module import translated from a #include or similar preprocessing directiv...
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)
CXXRecordDecl * getCanonicalDecl() override
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
void DiagnoseUnusedDecl(const NamedDecl *ND)
DiagnoseUnusedDecl - Emit warnings about declarations that are not used unless they are marked attr(u...
Represents a C++ nested-name-specifier or a global scope specifier.
bool hasUnrecoverableErrorOccurred() const
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 isStructureType() const
SourceLocation getConceptSpecLoc() const
void setRedeclarationKind(Sema::RedeclarationKind RK)
Change this lookup's redeclaration kind.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
static bool mergeDeclAttribute(Sema &S, NamedDecl *D, const InheritableAttr *Attr, Sema::AvailabilityMergeKind AMK)
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
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...
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
void UpdateExprRep(Expr *Rep)
void CheckCompleteVariableDeclaration(VarDecl *var)
void CheckVariableDeclarationType(VarDecl *NewVD)
SourceLocation getLocation() const
bool isStaticLocal() const
isStaticLocal - Returns true if a variable with function scope is a static local variable.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
bool isExternInLinkageSpec() const
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name...
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Represents an ObjC class declaration.
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.
SourceRange getSourceRange() const LLVM_READONLY
detail::InMemoryDirectory::const_iterator I
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared...
static bool isUsingDecl(NamedDecl *D)
CanQualType UnsignedCharTy
const LangOptions & LangOpts
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...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool AllowClassTemplates=false)
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, bool IncludeCXX11Attributes=true)
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
This object can be modified without requiring retains or releases.
SourceRange getRange() const
bool isDefined(const FunctionDecl *&Definition) const
isDefined - Returns true if the function is defined at all, including a deleted definition.
param_iterator param_begin()
unsigned getMSLastManglingNumber() const
void setHasInheritedPrototype(bool P=true)
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
field_iterator field_end() const
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
Class that aids in the construction of nested-name-specifiers along with source-location information ...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
AvailabilityResult
Captures the result of checking the availability of a declaration.
ImplicitCaptureStyle ImpCaptureStyle
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
static const Decl * getDefinition(const Decl *D)
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
SmallVectorImpl< NamedDecl * >::const_iterator const_decl_iterator
CXXSpecialMember
Kinds of C++ special members.
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.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
ConditionalOperator - The ?: ternary operator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
void setLazyBody(uint64_t Offset)
const ParmVarDecl *const * param_const_iterator
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
ExtInfo getExtInfo() const
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.
Merge availability attributes for an implementation of a protocol requirement.
llvm::APInt getValue() const
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
bool Mutable
Whether this is a mutable lambda.
TST getTypeSpecType() const
SmallVector< ReturnStmt *, 4 > Returns
The list of return statements that occur within the function or block, if there is any chance of appl...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit, bool TypeMayContainAuto)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool isReturnsTwice(unsigned ID) const
Return true if we know this builtin can return twice.
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getModulePrivateSpecLoc() const
std::string CurrentModule
The name of the current module, of which the main source file is a part.
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. ...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
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)
SourceLocation getFriendSpecLoc() const
DeclarationNameTable DeclarationNames
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
SourceLocation getLBracketLoc() const
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...
bool isPure(unsigned ID) const
Return true if this function has no side effects.
SourceLocation getTypeSpecStartLoc() const
std::vector< bool > & Stack
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
ArrayRef< NamedDecl * > getDeclsInPrototypeScope() const
Captures information about a #pragma weak directive.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
const CXXMethodDecl *const * method_iterator
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isFunctionPointerType() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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)
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void setVisible(Module *M, SourceLocation Loc, VisibleCallback Vis=[](Module *){}, ConflictCallback Cb=[](ArrayRef< Module * >, Module *, StringRef){})
Make a specific module visible.
bool canKeyFunctionBeInline() const
Can an out-of-line inline function serve as a key function?
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
unsigned getNumExprs() const
bool isDeleted() const
Whether this function has been deleted.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
bool isGlobal() const
Determines whether this is a global function.
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
bool isNoThrow(unsigned ID) const
Return true if we know this builtin never throws an exception.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
const Type * getTypeForDecl() const
SourceLocation getRBracketLoc() const
unsigned getTypeQualifiers() const
QualType getPointeeType() const
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Expr - This represents one expression.
DeclarationName getLookupName() const
Gets the name to look up.
LookupNameKind
Describes the kind of name lookup to perform.
StringRef getName() const
Return the actual identifier string.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e...
const char * getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
static bool isResultTypeOrTemplate(LookupResult &R, const Token &NextToken)
Determine whether the given result set contains either a type name or.
Represents a character-granular source range.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
DLLImportAttr * mergeDLLImportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
SourceLocation getAtomicSpecLoc() 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...
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.
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, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
static bool checkForConflictWithNonVisibleExternC(Sema &S, const T *ND, LookupResult &Previous)
Apply special rules for handling extern "C" declarations.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
bool isFunctionDefinition() 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...
unsigned SymbolLocations[3]
The source locations of the individual tokens that name the operator, e.g., the "new", "[", and "]" tokens in operator new [].
SourceLocation getNameLoc() const
Gets the location of the identifier.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
bool isModuleVisible(Module *M)
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static bool ValidDuplicateEnum(EnumConstantDecl *ECD, EnumDecl *Enum)
Represents a C++ destructor within a class.
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isObjCGCWeak() const
true when Type is objc's weak.
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
bool isVariableArrayType() const
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure...
Defines the clang::Preprocessor interface.
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
const ParmVarDecl * getParamDecl(unsigned i) const
ExtProtoInfo getExtProtoInfo() const
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &O)
static void CheckPoppedLabel(LabelDecl *L, Sema &S)
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
SourceLocation getVolatileSpecLoc() const
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
void CheckAlignasUnderalignment(Decl *D)
This declaration is a tentative definition.
bool isFloatingType() const
ParmVarDecl *const * param_iterator
void setObjCIdRedefinitionType(QualType RedefType)
Set the user-written type that redefines id.
static QualType getNextLargerIntegralType(ASTContext &Context, QualType T)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
void setMemberSpecialization()
Note that this member template is a specialization.
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
Represents a C++ template name within the type system.
bool isWrittenInMainFile(SourceLocation Loc) const
Returns true if the spelling location for the given location is in the main file buffer.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
enum clang::DeclaratorChunk::@185 Kind
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name...
bool isMSAsmLabel() const
bool isFunctionNoProtoType() const
bool isObjCIdType() const
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...
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void UpdateTypeRep(ParsedType Rep)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
bool isConstexprSpecified() const
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
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.
Expr * getAsmLabel() const
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, unsigned AttrSpellingListIndex, MSInheritanceAttr::Spelling SemanticSpelling)
QualType getType() const
Get the type for which this source info wrapper provides information.
static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old)
checkNewAttributesAfterDef - If we already have a definition, check that there are no new attributes ...
static StorageClass getFunctionStorageClass(Sema &SemaRef, Declarator &D)
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
static bool hasSimilarParameters(ASTContext &Context, FunctionDecl *Declaration, FunctionDecl *Definition, SmallVectorImpl< unsigned > &Params)
hasSimilarParameters - Determine whether the C++ functions Declaration and Definition have "nearly" m...
StorageClass
Storage classes.
Expr * getSubExpr() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
void AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl, CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
Direct list-initialization (C++11)
bool isFunctionOrMethod() const
InClassInitStyle
In-class initialization styles for non-static data members.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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...
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.
QualType getObjCIdType() const
Represents the Objective-CC id type.
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.
bool isExternallyVisible() const
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
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.
DeclContextLookupResult slice(size_t N) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
struct CXXOpName CXXOperatorName
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
DeclContext * getContainingDC(DeclContext *DC)
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)
TagDecl * getDefinition() const
getDefinition - Returns the TagDecl that actually defines this struct/union/class/enum.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
void setStorageClass(StorageClass SC)
Represents a C++ conversion function within a class.
sema::LambdaScopeInfo * PushLambdaScope()
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
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
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
SourceLocation getStorageClassSpecLoc() const
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
static bool shouldConsiderLinkage(const VarDecl *VD)
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
TypeSourceInfo * getTypeSourceInfo() const
bool isVirtualSpecified() const
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 '@'.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
TypedefNameDecl * getTypedefNameForAnonDecl() const
VarDecl * getCanonicalDecl() override
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
unsigned getSpellingListIndex() const
const clang::PrintingPolicy & getPrintingPolicy() const
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
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...
param_const_iterator param_end() 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...
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.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
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 isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
TypeLoc getInnerLoc() const
void setTypeForDecl(const Type *TD)
Wrapper for source info for arrays.
static unsigned getMSManglingNumber(const LangOptions &LO, Scope *S)
bool doesThisDeclarationHaveABody() const
doesThisDeclarationHaveABody - Returns whether this specific declaration of the function has a body -...
There is no lifetime qualification on this type.
ExtInfo withRegParm(unsigned RegParm) const
DeclContext * getEntity() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Assigning into this object requires the old value to be released and the new value to be retained...
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
static bool hasParsedAttr(Scope *S, const AttributeList *AttrList, AttributeList::Kind Kind)
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isConst(unsigned ID) const
Return true if this function has no side effects and doesn't read memory.
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.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
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.
SourceLocation getOuterLocStart() const
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
ExternCContextDecl * getExternCContextDecl() const
Encodes a location in the source.
enumerator_range enumerators() const
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Determines whether this field is a representative for an anonymous struct ...
Sugar for parentheses used when specifying types.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
bool CheckForConstantInitializer(Expr *e, QualType t)
type checking declaration initializers (C99 6.7.8)
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
SourceLocation CurrentPragmaLocation
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
const TemplateArgument * iterator
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
unsigned getBitWidthValue(const ASTContext &Ctx) const
method_iterator begin_overridden_methods() const
bool isPredefinedRuntimeFunction(unsigned ID) const
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache"...
CXXRecordDecl * Lambda
The class that describes the lambda.
void setBraceRange(SourceRange R)
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
An overloaded operator name, e.g., operator+.
Expr * getRepAsExpr() const
bool isShadowed() const
Determine whether the lookup result was shadowed by some other declaration that lookup ignored...
DLLExportAttr * mergeDLLExportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
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.
bool isValid() const
Return true if this is a valid SourceLocation object.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
void setFreeStanding(bool isFreeStanding=true)
void disableCheckFallThrough()
void ExitDeclaratorContext(Scope *S)
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...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ASTContext & getASTContext() const
bool isLocalVarDecl() const
isLocalVarDecl - Returns true for local variable declarations other than parameters.
static const TST TST_union
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
CommonAttr * mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
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...
ParsedType getRepAsType() const
bool isConstWithoutErrno(unsigned ID) const
Return true if this function has no side effects and doesn't read memory, except for possibly errno...
Represents a static or instance method of a struct/union/class.
void setDefaulted(bool D=true)
void setHasFlexibleArrayMember(bool V)
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used...
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
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...
ArrayRef< ParmVarDecl * > parameters() const
ExtInfo withNoReturn(bool noReturn) const
SourceRange getExceptionSpecRange() const
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
SourceLocation getStrTokenLoc(unsigned TokNum) const
Name lookup found an unresolvable value declaration and cannot yet complete.
MemberPointerTypeInfo Mem
ObjCCategoryDecl - Represents a category declaration.
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...
SourceLocation getConstexprSpecLoc() const
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible. ...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool hasVolatileMember() const
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or NULL if no such declaration exists...
A class for iterating through a result set and possibly filtering out results.
This declaration is only a declaration.
SourceLocation getVirtualSpecLoc() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
SourceLocation getUnalignedSpecLoc() const
static const TST TST_typeofType
SourceLocation getBegin() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const T * castAs() const
Member-template castAs<specific type>.
SourceLocation getBeginLoc() const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
No entity found met the criteria.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
const IdentifierInfo * getIdentifier() const
bool isFileContext() const
static bool AllowOverloadingOfFunction(LookupResult &Previous, ASTContext &Context)
Determine whether we allow overloading of the function PrevDecl with another declaration.
SourceRange getSourceRange() const override LLVM_READONLY
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)) {...
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions...
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...
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
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.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl *Old)
Assigning into this object requires a lifetime extension.
bool hasObjectMember() const
static bool isExternC(T *D)
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
Attr * clone(ASTContext &C) const
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
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...
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, AttributeList *AttrList)
void setObjCSuperType(QualType ST)
SourceLocation getLocStart() const LLVM_READONLY
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
void setLAngleLoc(SourceLocation Loc)
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)
QualType getType() const
Return the type wrapped by this type source info.
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.
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...
bool isFunctionProtoType() const
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
QualType getPointeeType() const
void setVirtualAsWritten(bool V)
A constructor named via a template-id.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
bool containsPlaceholderType() const
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
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...
AttributeFactory & getFactory() const
CanQualType UnsignedShortTy
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void createImplicitModuleImportForErrorRecovery(SourceLocation Loc, Module *Mod)
Create an implicit import of the given module at the given source location, for error recovery...
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
attr::Kind getKind() const
Base class for declarations which introduce a typedef-name.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
TLS with a dynamic initializer.
Represents a template argument.
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
TagTypeKind
The kind of a tag type.
TSCS getThreadStorageClassSpec() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword)...
static void FixInvalidVariablyModifiedTypeLoc(TypeLoc SrcTL, TypeLoc DstTL)
void setImplicitlyInline()
Flag that this function is implicitly inline.
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)
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...
unsigned getMSCurManglingNumber() const
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
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 ...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
A template instantiation that is currently in progress.
bool isZero() const
isZero - Test whether the quantity equals zero.
static const TST TST_decltype
SmallVectorImpl< UniqueVirtualMethod >::iterator overriding_iterator
static const TST TST_auto
bool isFriendSpecified() const
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
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...
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
unsigned getCharWidth() const
bool getProducesResult() const
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...
TypeLoc IgnoreParens() const
void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod)
The parsed has entered a submodule.
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 isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
bool isCallingConv() const
const llvm::APSInt & getInitVal() 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)
This is a scope that corresponds to the template parameters of a C++ template.
virtual void HandleImplicitImportDecl(ImportDecl *D)
Handle an ImportDecl that was implicitly created due to an inclusion directive.
void setShadowed()
Note that we found and ignored a declaration while performing lookup.
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
DeclarationName - The name of a declaration.
unsigned short getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
static ObjCIvarDecl::AccessControl TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility)
TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value.
CallingConv getCC() 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)
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Expr * getSizeExpr() const
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
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.
A mapping from each virtual member function to its set of final overriders.
StringRef getString() const
virtual ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, Module::NameVisibilityKind Visibility, bool IsInclusionDirective)=0
Attempt to load the given module.
bool isThisDeclarationADefinition() const
isThisDeclarationADefinition - Returns whether this specific declaration of the function is also a de...
SourceLocation getLocStart() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
size_t param_size() const
EnumDecl - Represents an enum.
VisibilityAttr * mergeVisibilityAttr(Decl *D, SourceRange Range, VisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
void setInlineSpecified()
detail::InMemoryDirectory::const_iterator E
void mergeNRVOIntoParent()
QualType getModifiedType() const
static bool isTagTypeWithMissingTag(Sema &SemaRef, LookupResult &Result, Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc)
bool isSimpleTypeSpecifier(tok::TokenKind Kind) const
Determine whether the token kind starts a simple-type-specifier.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
SourceLocation getNoreturnSpecLoc() const
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical 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 isMsStruct(const ASTContext &C) const
isMsStrust - Get whether or not this is an ms_struct which can be turned on with an attribute...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setPreviousDeclInSameBlockScope(bool Same)
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)
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).
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
const RecordType * getAsStructureType() const
static std::pair< diag::kind, SourceLocation > getNoteDiagForInvalidRedeclaration(const T *Old, const T *New)
All of the names in this module are visible.
known_extensions_range known_extensions() const
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
const VariableArrayType * getAsVariableArrayType(QualType T) const
void setNameLoc(SourceLocation Loc)
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated", "unavailable", and "availability").
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...
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
Name lookup found a single declaration that met the criteria.
bool empty() const
Return true if no decls were found.
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)
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...
bool isObjCObjectType() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
SourceManager & getSourceManager() const
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
const T * getAs() const
Member-template getAs<specific type>'.
static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx, FixItHint &Hint)
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
QualType getCanonicalType() const
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
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...
CanQualType UnsignedLongTy
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool isRedeclaration() const
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)
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope...
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
void setTypeSourceInfo(TypeSourceInfo *TI)
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
bool isFunctionType() const
static const TST TST_typename
Expr * getArg(unsigned Arg)
Return the specified argument.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
const DeclarationNameLoc & getInfo() const
static void SetNestedNameSpecifier(DeclaratorDecl *DD, Declarator &D)
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
void CheckShadow(Scope *S, VarDecl *D, const LookupResult &R)
Diagnose variable or built-in function shadowing.
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...
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
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.
bool isInlineSpecified() const
StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, ParsedAttributes &Attrs, SourceLocation AttrEnd)
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
A template-id, e.g., f<int>.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
DeclResult ActOnModuleImport(SourceLocation AtLoc, SourceLocation ImportLoc, ModuleIdPath Path)
The parser has processed a module import declaration.
bool isStaticDataMember() const
Determines whether this is a static data member.
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.
This is a scope that can contain a declaration.
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
SourceManager & getSourceManager()
void * SkippedDefinitionContext
bool isTLSSupported() const
Whether the target supports thread-local storage.
IdentifierInfo * getIdentifier() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
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 isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
const DeclContext * getCurObjCLexicalContext() const
bool isObjCGCStrong() const
true when Type is objc's strong.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
void setInvalidType(bool Val=true)
Reading or writing from this object requires a barrier call.
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).
llvm::DenseMap< NamedDecl *, NamedDecl * > VisibleNamespaceCache
Map from the most recent declaration of a namespace to the most recent visible declaration of that na...
static bool isMainFileLoc(const Sema &S, SourceLocation Loc)
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).
bool hasAddressSpace() const
Call-style initialization (C++98)
AttributePool & getPool() const
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.
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...
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".
bool isExplicitSpecified() const
SourceLocation getIdentifierLoc() const
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or NULL if there isn't one...
ShadowedDeclKind
Enum describing the select options in diag::warn_decl_shadow.
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl * > CH)
static bool isCompoundAssignmentOp(Opcode Opc)
static const TSCS TSCS_thread_local
void setTSCSpec(ThreadStorageClassSpecifier TSC)
A user-defined literal name, e.g., operator "" _i.
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...
bool isObjCObjectPointerType() const
void setDescribedVarTemplate(VarTemplateDecl *Template)
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>
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
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)
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)
CallingConv getDefaultCallingConvention(bool isVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
bool duplicatesAllowed() const
By default, attributes cannot be duplicated when being merged; however, an attribute can override thi...
TypeLoc getElementLoc() const
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
bool isInline() const
Whether this variable is (C++1z) inline.
void setLParenLoc(SourceLocation Loc)
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.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static StorageClass StorageClassSpecToVarDeclStorageClass(const DeclSpec &DS)
StorageClassSpecToVarDeclStorageClass - Maps a DeclSpec::SCS to a VarDecl::StorageClass.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
void addVLATypeCapture(SourceLocation Loc, QualType CaptureType)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
LookupResultKind getResultKind() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
bool isTypeSpecOwned() 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 Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
TLS with a known-constant initializer.
SourceRange getSourceRange() const override LLVM_READONLY
AvailabilityResult getCurContextAvailability() const
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
The translation unit is a complete translation unit.
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated, or computed.
static TagDecl * castFromDeclContext(const DeclContext *DC)
bool getHasRegParm() const
void setObjCSelRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
static bool DeclHasAttr(const Decl *D, const Attr *A)
DeclhasAttr - returns true if decl Declaration already has the target attribute.
bool isIncompleteArrayType() const
static OpaquePtr make(QualTypeP)
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.
A reference to a declared variable, function, enum, etc.
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
bool isSet() const
Deprecated.
SourceLocation getRAngleLoc() const
static const TST TST_atomic
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...
QualType getElementType() 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...
void ActOnObjCContainerFinishDefinition()
SourceManager & SourceMgr
bool isResolvedMSAsmLabel() const
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
static const TST TST_struct
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)
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
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.
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.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
void ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod)
The parser has left a submodule.
AttributeList * getNext() const
static StringRef getNameForCallConv(CallingConv CC)
uint32_t TypeID
An ID number that refers to a type in an AST file.
An l-value expression is a reference to an object with independent storage.
void setRParenLoc(SourceLocation Loc)
A trivial tuple used to represent a source range.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
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
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.
DeclarationNameInfo getNameInfo() const
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
bool isInvalidType() const
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
bool isModulePrivateSpecified() const
void setTypeSourceInfo(TypeSourceInfo *newType)
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...
No keyword precedes the qualified type name.
static bool IsDisallowedCopyOrAssign(const CXXMethodDecl *D)
Check for this common pattern:
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
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)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
TypeSourceInfo * getTypeSourceInfo() const
LambdaCaptureDefault getLambdaCaptureDefault() const
virtual void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, SourceLocation ImportLoc)=0
Make the given module visible.
Describes an entity that is being initialized.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
unsigned NumArgs
NumArgs - The number of template arguments.
Decl * getObjCDeclContext() const
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
void SetRangeEnd(SourceLocation Loc)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
Missing a type from <setjmp.h>
void setType(QualType newType)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
Wrapper for source info for pointers.
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
ParsedAttributes - A collection of parsed attributes.
void setDeletedAsWritten(bool D=true)
static bool isAttributeTargetADefinition(Decl *D)
TemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon, QualType Aliased)
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
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.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
enum clang::UnqualifiedId::IdKind Kind
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_bits attribute.
iterator - Iterate over the decls of a specified declaration name.
void clear()
Clears out any current state.
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...
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this method is...
ObjCCompatibleAliasDecl - Represents alias of a class.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Decl * ActOnDeclarator(Scope *S, Declarator &D)
AttributeList - Represents a syntactic attribute.
CanQualType UnsignedIntTy
static void checkIsValidOpenCLKernelParameter(Sema &S, Declarator &D, ParmVarDecl *Param, llvm::SmallPtrSetImpl< const Type * > &ValidTypes)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
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...
bool isPointerType() const
unsigned getNumTemplateParameterLists() const
bool isPOD() const
Whether this class is a POD-type (C++ [class]p4)
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
The translation unit is a module.
const AttributeList * getAttributes() const
SourceLocation getTemplateLoc() const
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
QualType getDeducedType() const
Get the type deduced for this auto type, or null if it's either not been deduced or was deduced to a ...