45 #include "llvm/ADT/SmallString.h"
46 #include "llvm/ADT/Triple.h"
51 using namespace clang;
56 Decl *Group[2] = { OwnedType, Ptr };
67 TypeNameValidatorCCC(
bool AllowInvalid,
bool WantClass =
false,
68 bool AllowTemplates =
false,
69 bool AllowNonTemplates =
true)
70 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
71 AllowTemplates(AllowTemplates), AllowNonTemplates(AllowNonTemplates) {
72 WantExpressionKeywords =
false;
73 WantCXXNamedCasts =
false;
74 WantRemainingKeywords =
false;
79 if (!AllowInvalidDecl && ND->isInvalidDecl())
83 return AllowTemplates;
85 bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
89 if (AllowNonTemplates)
96 if (!RD || !RD->isInjectedClassName())
98 RD = cast<CXXRecordDecl>(RD->getDeclContext());
100 isa<ClassTemplateSpecializationDecl>(RD);
106 return !WantClassName && candidate.
isKeyword();
110 bool AllowInvalidDecl;
113 bool AllowNonTemplates;
125 case tok::kw___int64:
126 case tok::kw___int128:
128 case tok::kw_unsigned:
135 case tok::kw___float128:
136 case tok::kw_wchar_t:
138 case tok::kw___underlying_type:
139 case tok::kw___auto_type:
142 case tok::annot_typename:
143 case tok::kw_char16_t:
144 case tok::kw_char32_t:
146 case tok::annot_decltype:
147 case tok::kw_decltype:
148 return getLangOpts().CPlusPlus;
174 return UnqualifiedTypeNameLookupResult::NotFound;
177 UnqualifiedTypeNameLookupResult::NotFound;
180 if (
auto *BaseTT =
Base.getType()->getAs<
TagType>())
181 BaseRD = BaseTT->getAsCXXRecordDecl();
185 if (!TST || !TST->isDependentType())
187 auto *TD = TST->getTemplateName().getAsTemplateDecl();
190 if (
auto *BasePrimaryTemplate =
191 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
193 BaseRD = BasePrimaryTemplate;
194 else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
196 CTD->findPartialSpecialization(
Base.getType()))
204 if (!isa<TypeDecl>(ND))
205 return UnqualifiedTypeNameLookupResult::FoundNonType;
206 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
208 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
210 case UnqualifiedTypeNameLookupResult::FoundNonType:
211 return UnqualifiedTypeNameLookupResult::FoundNonType;
212 case UnqualifiedTypeNameLookupResult::FoundType:
213 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
215 case UnqualifiedTypeNameLookupResult::NotFound:
222 return FoundTypeDecl;
231 UnqualifiedTypeNameLookupResult::NotFound;
233 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
234 DC = DC->getParent()) {
241 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
247 S.
Diag(NameLoc, diag::ext_found_via_dependent_bases_lookup) << &II;
275 bool isClassName,
bool HasTrailingDot,
277 bool IsCtorOrDtorName,
278 bool WantNontrivialTypeSourceInfo,
279 bool IsClassTemplateDeductionContext,
282 bool AllowDeducedTemplate = IsClassTemplateDeductionContext &&
283 getLangOpts().CPlusPlus1z && !IsCtorOrDtorName &&
284 !isClassName && !HasTrailingDot;
291 LookupCtx = computeDeclContext(ObjectType);
293 LookupCtx = computeDeclContext(*SS,
false);
296 if (isDependentScopeSpecifier(*SS)) {
306 if (!isClassName && !IsCtorOrDtorName)
311 if (WantNontrivialTypeSourceInfo)
312 return ActOnTypenameType(S,
SourceLocation(), *SS, II, NameLoc).get();
324 RequireCompleteDeclContext(*SS, LookupCtx))
338 LookupQualifiedName(Result, LookupCtx);
340 if (ObjectTypePtr && Result.
empty()) {
347 LookupName(Result, S);
351 LookupName(Result, S);
355 if (Result.
empty() && getLangOpts().MSVCCompat && (!SS || SS->
isEmpty())) {
369 llvm::make_unique<TypeNameValidatorCCC>(
370 true, isClassName, AllowDeducedTemplate),
374 bool MemberOfUnknownSpecialization;
383 if (Correction && (NNS || NewII != &II) &&
388 isTemplateName(S, *NewSSPtr,
false, TemplateName,
nullptr,
false,
389 Template, MemberOfUnknownSpecialization))) {
391 isClassName, HasTrailingDot, ObjectTypePtr,
393 WantNontrivialTypeSourceInfo,
394 IsClassTemplateDeductionContext);
396 diagnoseTypo(Correction,
397 PDiag(diag::err_unknown_type_or_class_name_suggest)
401 *CorrectedII = NewII;
426 Res != ResEnd; ++Res) {
427 if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res) ||
458 assert(IIDecl &&
"Didn't find decl");
461 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
465 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
467 if (!isClassName && !IsCtorOrDtorName && LookupRD && FoundRD &&
468 FoundRD->isInjectedClassName() &&
470 Diag(NameLoc, diag::err_out_of_line_qualified_id_type_names_constructor)
473 DiagnoseUseOfDecl(IIDecl, NameLoc);
476 MarkAnyDeclReferenced(TD->getLocation(), TD,
false);
478 (void)DiagnoseUseOfDecl(IDecl, NameLoc);
481 }
else if (AllowDeducedTemplate) {
496 if (SS && SS->
isNotEmpty() && !IsCtorOrDtorName &&
497 !isa<ObjCInterfaceDecl>(IIDecl)) {
498 if (WantNontrivialTypeSourceInfo) {
503 T = getElaboratedType(
ETK_None, *SS, T);
509 T = getElaboratedType(
ETK_None, *SS, T);
522 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
524 else if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
526 RD->getTypeForDecl());
527 else if (isa<TranslationUnitDecl>(DC))
530 llvm_unreachable(
"something isn't in TU scope?");
541 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
542 if (MD->getParent()->hasAnyDependentBases())
550 bool IsTemplateTypeArg) {
551 assert(getLangOpts().MSVCCompat &&
"shouldn't be called in non-MSVC mode");
554 if (IsTemplateTypeArg && getCurScope()->isTemplateParamScope()) {
563 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
569 RD->getTypeForDecl());
573 Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
604 LookupName(R, S,
false);
608 switch (TD->getTagKind()) {
635 if (CurContext->isRecord()) {
655 bool IsTemplateName) {
660 SuggestedType =
nullptr;
666 llvm::make_unique<TypeNameValidatorCCC>(
667 false,
false, IsTemplateName, !IsTemplateName),
668 CTK_ErrorRecovery)) {
670 bool CanRecover = !IsTemplateName;
671 if (Corrected.isKeyword()) {
673 diagnoseTypo(Corrected,
674 PDiag(IsTemplateName ? diag::err_no_template_suggest
675 : diag::err_unknown_typename_suggest)
677 II = Corrected.getCorrectionAsIdentifierInfo();
680 if (!SS || !SS->
isSet()) {
681 diagnoseTypo(Corrected,
682 PDiag(IsTemplateName ? diag::err_no_template_suggest
683 : diag::err_unknown_typename_suggest)
685 }
else if (
DeclContext *DC = computeDeclContext(*SS,
false)) {
686 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
687 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
688 II->
getName().equals(CorrectedStr);
689 diagnoseTypo(Corrected,
691 ? diag::err_no_member_template_suggest
692 : diag::err_unknown_nested_typename_suggest)
693 << II << DC << DroppedSpecifier << SS->
getRange(),
696 llvm_unreachable(
"could not have corrected a typo here");
703 if (Corrected.getCorrectionSpecifier())
708 getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc,
S,
709 tmpSS.
isSet() ? &tmpSS : SS,
false,
false,
nullptr,
716 if (getLangOpts().CPlusPlus && !IsTemplateName) {
722 bool MemberOfUnknownSpecialization;
723 if (isTemplateName(S, SS ? *SS : EmptySS,
false,
724 Name,
nullptr,
true, TemplateResult,
727 Diag(IILoc, diag::err_template_missing_args)
728 << (int)getTemplateNameKindForDiagnostics(TplName) << TplName;
730 Diag(TplDecl->getLocation(), diag::note_template_decl_here)
731 << TplDecl->getTemplateParameters()->getSourceRange();
741 Diag(IILoc, IsTemplateName ? diag::err_no_template
742 : diag::err_unknown_typename)
744 else if (
DeclContext *DC = computeDeclContext(*SS,
false))
745 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
746 : diag::err_typename_nested_not_found)
748 else if (isDependentScopeSpecifier(*SS)) {
749 unsigned DiagID = diag::err_typename_missing;
750 if (getLangOpts().MSVCCompat && isMicrosoftMissingTypename(SS, S))
751 DiagID = diag::ext_typename_missing;
758 *SS, *II, IILoc).
get();
761 "Invalid scope specifier has already been diagnosed");
769 NextToken.
is(tok::less);
772 if (isa<TypeDecl>(*
I) || isa<ObjCInterfaceDecl>(*I))
775 if (CheckTemplate && isa<TemplateDecl>(*
I))
789 StringRef FixItTagName;
790 switch (Tag->getTagKind()) {
792 FixItTagName =
"class ";
796 FixItTagName =
"enum ";
800 FixItTagName =
"struct ";
804 FixItTagName =
"__interface ";
808 FixItTagName =
"union ";
812 StringRef TagName = FixItTagName.drop_back();
813 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
814 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
819 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
849 bool IsAddressOfOperand,
850 std::unique_ptr<CorrectionCandidateCallback> CCC) {
854 if (NextToken.
is(tok::coloncolon)) {
856 BuildCXXNestedNameSpecifier(S, IdInfo,
false, SS,
nullptr,
false);
858 isCurrentClassName(*Name, S, &SS)) {
867 LookupParsedName(Result, S, &SS, !CurMethod);
871 if (Result.
empty() && SS.
isEmpty() && getLangOpts().MSVCCompat) {
882 ExprResult E = LookupInObjCMethod(Result, S, Name,
true);
887 bool SecondTry =
false;
888 bool IsFilteredTemplateName =
false;
895 if (!SS.
isSet() && NextToken.
is(tok::l_paren)) {
898 if (getLangOpts().CPlusPlus)
899 return BuildDeclarationNameExpr(SS, Result,
true);
913 if (
NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *Name, S)) {
916 return BuildDeclarationNameExpr(SS, Result,
false);
923 if (!getLangOpts().
CPlusPlus && !SecondTry &&
930 if (!SecondTry && CCC) {
935 CTK_ErrorRecovery)) {
936 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
937 unsigned QualifiedDiag = diag::err_no_member_suggest;
939 NamedDecl *FirstDecl = Corrected.getFoundDecl();
940 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
941 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
942 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
943 UnqualifiedDiag = diag::err_no_template_suggest;
944 QualifiedDiag = diag::err_no_member_template_suggest;
945 }
else if (UnderlyingFirstDecl &&
946 (isa<TypeDecl>(UnderlyingFirstDecl) ||
947 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
948 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
949 UnqualifiedDiag = diag::err_unknown_typename_suggest;
950 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
954 diagnoseTypo(Corrected, PDiag(UnqualifiedDiag) << Name);
956 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
957 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
958 Name->
getName().equals(CorrectedStr);
959 diagnoseTypo(Corrected, PDiag(QualifiedDiag)
960 << Name << computeDeclContext(SS,
false)
961 << DroppedSpecifier << SS.getRange());
965 Name = Corrected.getCorrectionAsIdentifierInfo();
968 if (Corrected.isKeyword())
984 ExprResult E(LookupInObjCMethod(Result, S, Ivar->getIdentifier()));
1012 NameInfo, IsAddressOfOperand,
1022 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
1023 hasAnyAcceptableTemplateNames(Result)) {
1035 FilterAcceptableTemplateNames(Result);
1037 IsFilteredTemplateName =
true;
1046 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
1047 (IsFilteredTemplateName || hasAnyAcceptableTemplateNames(Result))) {
1054 if (!IsFilteredTemplateName)
1055 FilterAcceptableTemplateNames(Result);
1057 if (!Result.
empty()) {
1058 bool IsFunctionTemplate;
1061 if (Result.
end() - Result.
begin() > 1) {
1062 IsFunctionTemplate =
true;
1067 = cast<TemplateDecl>((*Result.
begin())->getUnderlyingDecl());
1068 IsFunctionTemplate = isa<FunctionTemplateDecl>(TD);
1069 IsVarTemplate = isa<VarTemplateDecl>(TD);
1079 if (IsFunctionTemplate) {
1085 return NameClassification::FunctionTemplate(Template);
1088 return IsVarTemplate ? NameClassification::VarTemplate(Template)
1089 : NameClassification::TypeTemplate(Template);
1095 DiagnoseUseOfDecl(
Type, NameLoc);
1096 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
1107 dyn_cast<ObjCCompatibleAliasDecl>(FirstDecl))
1108 Class = Alias->getClassInterface();
1112 DiagnoseUseOfDecl(Class, NameLoc);
1114 if (NextToken.
is(tok::period)) {
1126 if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl) &&
1127 !isa<VarTemplateDecl>(FirstDecl))
1128 return NameClassification::TypeTemplate(
1133 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1134 if ((NextToken.
is(tok::identifier) ||
1139 DiagnoseUseOfDecl(Type, NameLoc);
1147 return BuildPossibleImplicitMemberExpr(SS,
SourceLocation(), Result,
1150 bool ADL = UseArgumentDependentLookup(SS, Result, NextToken.
is(tok::l_paren));
1151 return BuildDeclarationNameExpr(SS, Result, ADL);
1158 return TemplateNameKindForDiagnostics::DependentTemplate;
1159 if (isa<ClassTemplateDecl>(TD))
1160 return TemplateNameKindForDiagnostics::ClassTemplate;
1161 if (isa<FunctionTemplateDecl>(TD))
1162 return TemplateNameKindForDiagnostics::FunctionTemplate;
1163 if (isa<VarTemplateDecl>(TD))
1164 return TemplateNameKindForDiagnostics::VarTemplate;
1165 if (isa<TypeAliasTemplateDecl>(TD))
1166 return TemplateNameKindForDiagnostics::AliasTemplate;
1167 if (isa<TemplateTemplateParmDecl>(TD))
1168 return TemplateNameKindForDiagnostics::TemplateTemplateParam;
1169 return TemplateNameKindForDiagnostics::DependentTemplate;
1194 if (!isa<CXXRecordDecl>(DC))
1212 assert(getContainingDC(DC) == CurContext &&
1213 "The next DeclContext should be lexically contained in the current one.");
1219 assert(CurContext &&
"DeclContext imbalance!");
1221 CurContext = getContainingDC(CurContext);
1222 assert(CurContext &&
"Popped translation unit!");
1232 assert(CurContext &&
"skipping definition of undefined tag");
1235 S->
setEntity(CurContext->getLookupParent());
1240 CurContext =
static_cast<decltype(CurContext)
>(
Context);
1263 assert(!S->
getEntity() &&
"scope already has entity");
1267 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1268 assert(Ancestor->getEntity() == CurContext &&
"ancestor context mismatch");
1276 assert(S->
getEntity() == CurContext &&
"Context imbalance!");
1281 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1298 "The next DeclContext should be lexically contained in the current one.");
1302 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1307 IdResolver.AddDecl(Param);
1315 assert(CurContext &&
"DeclContext imbalance!");
1316 CurContext = CurContext->getLexicalParent();
1317 assert(CurContext &&
"Popped translation unit!");
1340 New->
hasAttr<OverloadableAttr>());
1355 CurContext->addDecl(D);
1366 if (isa<FunctionDecl>(D) &&
1367 cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
1372 IEnd = IdResolver.end();
1373 for (; I != IEnd; ++
I) {
1376 IdResolver.RemoveDecl(*I);
1385 if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) {
1389 for (I = IdResolver.begin(D->
getDeclName()); I != IEnd; ++
I) {
1391 if (IDC == CurContext) {
1394 }
else if (IDC->
Encloses(CurContext))
1398 IdResolver.InsertDeclAfter(I, D);
1400 IdResolver.AddDecl(D);
1405 if (IdResolver.tryAddTopLevelDecl(D, Name) && TUScope)
1406 TUScope->AddDecl(D);
1410 bool AllowInlineNamespace) {
1411 return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace);
1418 if (ScopeDC->getPrimaryContext() == TargetDC)
1432 bool ConsiderLinkage,
1433 bool AllowInlineNamespace) {
1438 if (isDeclInScope(D, Ctx, S, AllowInlineNamespace))
1451 return isa<UsingShadowDecl>(D) ||
1452 isa<UnresolvedUsingTypenameDecl>(D) ||
1453 isa<UnresolvedUsingValueDecl>(D);
1480 return CD->isCopyConstructor();
1481 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
1482 return Method->isCopyAssignmentOperator();
1498 bool Sema::mightHaveNonExternalLinkage(
const DeclaratorDecl *D) {
1501 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1502 if (!RD->hasNameForLinkage())
1531 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1537 FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
1540 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1545 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1549 if (FD->doesThisDeclarationHaveABody() &&
1552 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1562 if (VD->isStaticDataMember() &&
1565 if (VD->isStaticDataMember() &&
1567 VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
1570 if (VD->isInline() && !
isMainFileLoc(*
this, VD->getLocation()))
1579 return mightHaveNonExternalLinkage(D);
1586 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1588 if (FD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1592 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1594 if (VD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1598 if (ShouldWarnIfUnusedFileScopedDecl(D))
1599 UnusedFileScopedDecls.push_back(D);
1607 D->
hasAttr<ObjCPreciseLifetimeAttr>())
1610 if (isa<LabelDecl>(D))
1616 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->
getDeclContext()))
1619 WithinFunction || (R->isLocalClass() && !R->isDependentType());
1620 if (!WithinFunction)
1623 if (isa<TypedefNameDecl>(D))
1627 if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D))
1631 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1634 const auto *Ty = VD->getType().getTypePtr();
1638 if (TT->getDecl()->hasAttr<UnusedAttr>())
1644 if (Ty->isIncompleteType() || Ty->isDependentType())
1649 Ty = Ty->getBaseElementTypeUnsafe();
1652 const TagDecl *Tag = TT->getDecl();
1653 if (Tag->
hasAttr<UnusedAttr>())
1656 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) {
1657 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
1660 if (
const Expr *Init = VD->getInit()) {
1662 dyn_cast<ExprWithCleanups>(Init))
1663 Init = Cleanups->getSubExpr();
1668 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>())
1683 if (isa<LabelDecl>(D)) {
1697 for (
auto *TmpD : D->
decls()) {
1698 if (
const auto *T = dyn_cast<TypedefNameDecl>(TmpD))
1699 DiagnoseUnusedDecl(T);
1700 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
1701 DiagnoseUnusedNestedTypedefs(R);
1711 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1714 UnusedLocalTypedefNameCandidates.insert(TD);
1722 if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
1723 DiagID = diag::warn_unused_exception_param;
1724 else if (isa<LabelDecl>(D))
1725 DiagID = diag::warn_unused_label;
1727 DiagID = diag::warn_unused_variable;
1737 bool Diagnose =
false;
1741 Diagnose = L->
getStmt() ==
nullptr;
1751 "Scope shouldn't contain decls!");
1753 for (
auto *TmpD : S->
decls()) {
1754 assert(TmpD &&
"This decl didn't get pushed??");
1756 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
1763 DiagnoseUnusedDecl(D);
1764 if (
const auto *RD = dyn_cast<RecordDecl>(D))
1765 DiagnoseUnusedNestedTypedefs(RD);
1769 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
1774 IdResolver.RemoveDecl(D);
1775 auto ShadowI = ShadowingDecls.find(D);
1776 if (ShadowI != ShadowingDecls.end()) {
1777 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
1779 << D << FD << FD->getParent();
1780 Diag(FD->getLocation(), diag::note_previous_declaration);
1782 ShadowingDecls.erase(ShadowI);
1802 bool DoTypoCorrection) {
1805 NamedDecl *IDecl = LookupSingleName(TUScope, Id, IdLoc, LookupOrdinaryName);
1807 if (!IDecl && DoTypoCorrection) {
1813 CTK_ErrorRecovery)) {
1814 diagnoseTypo(C, PDiag(diag::err_undef_interface_suggest) << Id);
1863 if (!II->
isStr(
"objc_msgSendSuper"))
1884 return "ucontext.h";
1886 llvm_unreachable(
"unhandled error kind");
1894 Scope *
S,
bool ForRedeclaration,
1901 if (ForRedeclaration)
1902 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
1907 if (!ForRedeclaration &&
1910 Diag(Loc, diag::ext_implicit_lib_function_decl)
1913 !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc))
1914 Diag(Loc, diag::note_include_header_or_declare)
1928 Parent->
addDecl(CLinkageDecl);
1929 Parent = CLinkageDecl;
1934 Loc, Loc, II, R,
nullptr,
1944 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
1947 nullptr, FT->getParamType(i),
nullptr,
1950 Params.push_back(parm);
1952 New->setParams(Params);
1955 AddKnownFunctionAttributes(New);
1956 RegisterLocallyScopedExternCDecl(New, S);
1963 CurContext = Parent;
1964 PushOnScopeChains(New, TUScope);
1965 CurContext = SavedContext;
1981 if (Previous.
empty())
1994 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2001 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2015 OldType = OldTypedef->getUnderlyingType();
2022 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2023 Diag(New->
getLocation(), diag::err_redefinition_variably_modified_typedef)
2031 if (OldType != NewType &&
2035 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2037 << Kind << NewType << OldType;
2059 if (getLangOpts().ObjC1) {
2065 if (!TypeID->
isStr(
"id"))
2081 if (!TypeID->
isStr(
"Class"))
2088 if (!TypeID->
isStr(
"SEL"))
2115 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2116 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2119 if (OldTag && NewTag &&
2120 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
2121 !hasVisibleDefinition(OldTag, &Hidden)) {
2125 if (OldTD->isModed())
2127 OldTD->getUnderlyingType());
2132 makeMergedDefinitionVisible(Hidden);
2136 if (isa<EnumDecl>(NewTag)) {
2137 Scope *EnumScope = getNonFieldDeclScope(S);
2138 for (
auto *D : NewTag->decls()) {
2139 auto *ED = cast<EnumConstantDecl>(D);
2142 IdResolver.RemoveDecl(ED);
2143 ED->getLexicalDeclContext()->removeDecl(ED);
2151 if (isIncompatibleTypedef(Old, New))
2158 mergeDeclAttributes(New, Old);
2161 if (getLangOpts().MicrosoftExt)
2169 if (!isa<CXXRecordDecl>(CurContext))
2193 if (!isa<TypedefNameDecl>(Old))
2203 if (getLangOpts().Modules || getLangOpts().
C11)
2210 if (getDiagnostics().getSuppressSystemWarnings() &&
2225 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2226 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2227 for (
const auto *i : D->
attrs())
2228 if (i->getKind() == A->
getKind()) {
2230 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2235 if (OA && isa<OwnershipAttr>(i))
2236 return OA->getOwnKind() == cast<OwnershipAttr>(i)->getOwnKind();
2244 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2245 return VD->isThisDeclarationADefinition();
2246 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2247 return TD->isCompleteDefinition() || TD->isBeingDefined();
2258 AlignedAttr *OldAlignasAttr =
nullptr;
2259 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2260 unsigned OldAlign = 0;
2268 if (
I->isAlignmentDependent())
2274 unsigned Align =
I->getAlignment(S.
Context);
2275 if (Align > OldAlign) {
2277 OldStrictestAlignAttr =
I;
2282 AlignedAttr *NewAlignasAttr =
nullptr;
2283 unsigned NewAlign = 0;
2285 if (
I->isAlignmentDependent())
2291 unsigned Align =
I->getAlignment(S.
Context);
2292 if (Align > NewAlign)
2296 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2304 if (OldAlign == 0 || NewAlign == 0) {
2306 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2317 if (OldAlign != NewAlign) {
2318 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2321 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2336 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2340 bool AnyAdded =
false;
2343 if (OldAlign > NewAlign) {
2344 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2345 Clone->setInherited(
true);
2351 if (OldAlignasAttr && !NewAlignasAttr &&
2352 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2353 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2354 Clone->setInherited(
true);
2374 if (
const auto *AA = dyn_cast<AvailabilityAttr>(Attr))
2377 AA->getDeprecated(),
2378 AA->getObsoleted(), AA->getUnavailable(),
2379 AA->getMessage(), AA->getStrict(),
2380 AA->getReplacement(), AMK,
2381 AttrSpellingListIndex);
2382 else if (
const auto *VA = dyn_cast<VisibilityAttr>(Attr))
2384 AttrSpellingListIndex);
2385 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(Attr))
2387 AttrSpellingListIndex);
2388 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(Attr))
2390 AttrSpellingListIndex);
2391 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(Attr))
2393 AttrSpellingListIndex);
2394 else if (
const auto *FA = dyn_cast<FormatAttr>(Attr))
2396 FA->getFormatIdx(), FA->getFirstArg(),
2397 AttrSpellingListIndex);
2398 else if (
const auto *SA = dyn_cast<SectionAttr>(Attr))
2400 AttrSpellingListIndex);
2401 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(Attr))
2403 AttrSpellingListIndex,
2404 IA->getSemanticSpelling());
2405 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(Attr))
2408 AttrSpellingListIndex);
2409 else if (S.
getLangOpts().CUDA && isa<FunctionDecl>(D) &&
2410 (isa<CUDAHostAttr>(Attr) || isa<CUDADeviceAttr>(Attr) ||
2411 isa<CUDAGlobalAttr>(Attr))) {
2415 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(Attr))
2417 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(Attr))
2419 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(Attr))
2421 D, InternalLinkageA->getRange(),
2423 AttrSpellingListIndex);
2424 else if (
const auto *CommonA = dyn_cast<CommonAttr>(Attr))
2427 AttrSpellingListIndex);
2428 else if (isa<AlignedAttr>(Attr))
2432 else if ((isa<DeprecatedAttr>(Attr) || isa<UnavailableAttr>(Attr)) &&
2436 else if (
const auto *UA = dyn_cast<UuidAttr>(Attr))
2437 NewAttr = S.
mergeUuidAttr(D, UA->getRange(), AttrSpellingListIndex,
2440 NewAttr = cast<InheritableAttr>(Attr->
clone(S.
Context));
2445 if (isa<MSInheritanceAttr>(NewAttr))
2454 if (
const TagDecl *TD = dyn_cast<TagDecl>(D))
2455 return TD->getDefinition();
2456 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2462 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
2468 for (
const auto *Attribute : D->
attrs())
2469 if (Attribute->getKind() ==
Kind)
2481 if (!Def || Def == New)
2485 for (
unsigned I = 0,
E = NewAttributes.size();
I !=
E;) {
2486 const Attr *NewAttribute = NewAttributes[
I];
2488 if (isa<AliasAttr>(NewAttribute) || isa<IFuncAttr>(NewAttribute)) {
2495 NewAttributes.erase(NewAttributes.begin() +
I);
2500 VarDecl *VD = cast<VarDecl>(New);
2501 unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
2503 ? diag::err_alias_after_tentative
2504 : diag::err_redefinition;
2506 if (Diag == diag::err_redefinition)
2516 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
2529 if (isa<C11NoReturnAttr>(NewAttribute)) {
2533 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
2534 if (AA->isAlignas()) {
2545 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
2547 NewAttributes.erase(NewAttributes.begin() +
I);
2554 diag::warn_attribute_precede_definition);
2556 NewAttributes.erase(NewAttributes.begin() +
I);
2565 UsedAttr *NewAttr = OldAttr->clone(
Context);
2566 NewAttr->setInherited(
true);
2576 if (AsmLabelAttr *NewA = New->
getAttr<AsmLabelAttr>()) {
2577 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
2578 if (OldA->getLabel() != NewA->getLabel()) {
2581 Diag(OldA->getLocation(), diag::note_previous_declaration);
2583 }
else if (Old->
isUsed()) {
2587 << isa<FunctionDecl>(Old) << New->
getAttr<AsmLabelAttr>()->getRange();
2592 if (
const auto *NewAbiTagAttr = New->
getAttr<AbiTagAttr>()) {
2593 if (
const auto *OldAbiTagAttr = Old->
getAttr<AbiTagAttr>()) {
2594 for (
const auto &NewTag : NewAbiTagAttr->tags()) {
2595 if (std::find(OldAbiTagAttr->tags_begin(), OldAbiTagAttr->tags_end(),
2596 NewTag) == OldAbiTagAttr->tags_end()) {
2597 Diag(NewAbiTagAttr->getLocation(),
2598 diag::err_new_abi_tag_on_redeclaration)
2600 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
2604 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
2621 if (isa<DeprecatedAttr>(
I) ||
2622 isa<UnavailableAttr>(
I) ||
2623 isa<AvailabilityAttr>(
I)) {
2628 case AMK_Redeclaration:
2630 case AMK_ProtocolImplementation:
2637 if (isa<UsedAttr>(
I))
2659 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
2660 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
2661 S.
Diag(CDA->getLocation(),
2662 diag::err_carries_dependency_missing_on_first_decl) << 1;
2670 diag::note_carries_dependency_missing_first_decl) << 1;
2676 bool foundAny = newDecl->
hasAttrs();
2685 cast<InheritableParamAttr>(
I->clone(S.
Context));
2700 if (*Oldnullability != *Newnullability) {
2701 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
2726 struct GNUCompatibleParamWarning {
2737 if (Ctor->isDefaultConstructor())
2740 if (Ctor->isCopyConstructor())
2743 if (Ctor->isMoveConstructor())
2745 }
else if (isa<CXXDestructorDecl>(MD)) {
2758 template <
typename T>
2759 static std::pair<diag::kind, SourceLocation>
2763 if (Old->isThisDeclarationADefinition())
2764 PrevDiag = diag::note_previous_definition;
2765 else if (Old->isImplicit()) {
2766 PrevDiag = diag::note_previous_implicit_declaration;
2768 OldLocation = New->getLocation();
2770 PrevDiag = diag::note_previous_declaration;
2771 return std::make_pair(PrevDiag, OldLocation);
2779 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
2780 !LangOpts.CPlusPlus &&
2792 template <
typename T>
2806 template<
typename T>
static bool isExternC(T *D) {
return D->isExternC(); }
2812 template<
typename ExpectedDecl>
2814 ExpectedDecl *New) {
2834 !Old->getDeclContext()->getRedeclContext()->Equals(
2835 New->getDeclContext()->getRedeclContext()) &&
2840 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
2853 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
2854 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
2857 return AttrA && AttrB && AttrA->getType() == AttrB->getType();
2860 return std::equal(A->param_begin(), A->param_end(), B->
param_begin(), AttrEq);
2875 Scope *
S,
bool MergeTypeWithOld) {
2882 Diag(Shadow->getTargetDecl()->getLocation(),
2883 diag::note_using_decl_target);
2884 Diag(Shadow->getUsingDecl()->getLocation(),
2885 diag::note_using_decl) << 0;
2890 if (checkUsingShadowRedecl<FunctionDecl>(*
this, Shadow, New))
2892 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
2907 std::tie(PrevDiag, OldLocation) =
2914 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
2919 if (getLangOpts().MicrosoftExt) {
2921 Diag(OldLocation, PrevDiag);
2924 Diag(OldLocation, PrevDiag);
2929 if (New->
hasAttr<InternalLinkageAttr>() &&
2930 !Old->
hasAttr<InternalLinkageAttr>()) {
2934 New->
dropAttr<InternalLinkageAttr>();
2937 if (!getLangOpts().CPlusPlus) {
2938 bool OldOvl = Old->
hasAttr<OverloadableAttr>();
2949 const Decl *DiagOld = Old;
2951 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *D) {
2952 const auto *A = D->
getAttr<OverloadableAttr>();
2953 return A && !A->isImplicit();
2957 DiagOld = OldIter == Old->
redecls_end() ?
nullptr : *OldIter;
2961 Diag(DiagOld->getLocation(),
2962 diag::note_attribute_overloadable_prev_overload)
2987 const FunctionType *OldType = cast<FunctionType>(OldQType);
2988 const FunctionType *NewType = cast<FunctionType>(NewQType);
2991 bool RequiresAdjustment =
false;
2993 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC()) {
2998 bool NewCCExplicit = getCallingConvAttributedType(New->
getType());
2999 if (!NewCCExplicit) {
3003 RequiresAdjustment =
true;
3006 bool FirstCCExplicit = getCallingConvAttributedType(First->
getType());
3010 << (!FirstCCExplicit ?
"" :
3020 if (OldTypeInfo.getNoReturn() && !NewTypeInfo.
getNoReturn()) {
3022 RequiresAdjustment =
true;
3026 if (OldTypeInfo.getHasRegParm() != NewTypeInfo.
getHasRegParm() ||
3027 OldTypeInfo.getRegParm() != NewTypeInfo.
getRegParm()) {
3030 << NewType->getRegParmType()
3032 Diag(OldLocation, diag::note_previous_declaration);
3036 NewTypeInfo = NewTypeInfo.
withRegParm(OldTypeInfo.getRegParm());
3037 RequiresAdjustment =
true;
3044 <<
"'ns_returns_retained'";
3045 Diag(OldLocation, diag::note_previous_declaration);
3050 RequiresAdjustment =
true;
3053 if (OldTypeInfo.getNoCallerSavedRegs() !=
3056 AnyX86NoCallerSavedRegistersAttr *
Attr =
3057 New->
getAttr<AnyX86NoCallerSavedRegistersAttr>();
3058 Diag(New->
getLocation(), diag::err_function_attribute_mismatch) << Attr;
3059 Diag(OldLocation, diag::note_previous_declaration);
3064 RequiresAdjustment =
true;
3067 if (RequiresAdjustment) {
3072 NewType = cast<FunctionType>(NewQType);
3078 !New->
hasAttr<GNUInlineAttr>() &&
3079 !getLangOpts().GNUInline &&
3087 if (New->
hasAttr<GNUInlineAttr>() &&
3098 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3113 if (CheckEquivalentExceptionSpec(Old, New))
3126 : OldType)->getReturnType();
3130 : NewType)->getReturnType();
3140 Diag(New->
getLocation(), diag::err_member_def_does_not_match_ret_type)
3145 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
3154 QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType();
3155 if (OldReturnType != NewReturnType) {
3165 SubstAutoType(NewQType,
3173 if (OldMethod && NewMethod) {
3180 bool IsClassScopeExplicitSpecialization =
3182 NewMethod->isFunctionTemplateSpecialization();
3183 bool isFriend = NewMethod->getFriendObjectKind();
3185 if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() &&
3186 !IsClassScopeExplicitSpecialization) {
3190 if (OldMethod->
isStatic() != NewMethod->isStatic()) {
3192 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3200 if (!inTemplateInstantiation()) {
3202 if (isa<CXXConstructorDecl>(OldMethod))
3203 NewDiag = diag::err_constructor_redeclared;
3204 else if (isa<CXXDestructorDecl>(NewMethod))
3205 NewDiag = diag::err_destructor_redeclared;
3206 else if (isa<CXXConversionDecl>(NewMethod))
3207 NewDiag = diag::err_conv_function_redeclared;
3209 NewDiag = diag::err_member_redeclared;
3213 Diag(New->
getLocation(), diag::err_member_redeclared_in_instantiation)
3216 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3226 NewMethod->setImplicit();
3228 Diag(NewMethod->getLocation(),
3229 diag::err_definition_of_implicitly_declared_member)
3230 << New << getSpecialMember(OldMethod);
3234 Diag(NewMethod->getLocation(),
3235 diag::err_definition_of_explicitly_defaulted_member)
3236 << getSpecialMember(OldMethod);
3245 const CXX11NoReturnAttr *NRA = New->
getAttr<CXX11NoReturnAttr>();
3246 if (NRA && !Old->
hasAttr<CXX11NoReturnAttr>()) {
3247 Diag(NRA->getLocation(), diag::err_noreturn_missing_on_first_decl);
3249 diag::note_noreturn_missing_first_decl);
3256 const CarriesDependencyAttr *CDA = New->
getAttr<CarriesDependencyAttr>();
3257 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
3258 Diag(CDA->getLocation(),
3259 diag::err_carries_dependency_missing_on_first_decl) << 0;
3261 diag::note_carries_dependency_missing_first_decl) << 0;
3270 QualType OldQTypeForComparison = OldQType;
3271 if (!OldTypeInfo.getNoReturn() && NewTypeInfo.
getNoReturn()) {
3275 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
3290 Diag(OldLocation, PrevDiag);
3292 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3293 Diag(OldLocation, PrevDiag);
3298 if (OldQTypeForComparison == NewQType)
3299 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3314 if (!getLangOpts().CPlusPlus &&
3319 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
3323 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
3327 OldProto->getExtProtoInfo());
3333 for (
const auto &ParamType : OldProto->param_types()) {
3340 Params.push_back(Param);
3343 New->setParams(Params);
3346 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3373 NewProto->getReturnType());
3374 bool LooseCompatible = !MergedReturn.
isNull();
3376 LooseCompatible && Idx !=
End; ++Idx) {
3380 NewProto->getParamType(Idx))) {
3381 ArgTypes.push_back(NewParm->
getType());
3385 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
3386 NewProto->getParamType(Idx) };
3387 Warnings.push_back(Warn);
3388 ArgTypes.push_back(NewParm->
getType());
3390 LooseCompatible =
false;
3393 if (LooseCompatible) {
3394 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
3395 Diag(Warnings[Warn].NewParm->getLocation(),
3396 diag::ext_param_promoted_not_compatible_with_prototype)
3397 << Warnings[Warn].PromotedType
3398 << Warnings[Warn].OldParm->getType();
3399 if (Warnings[Warn].OldParm->getLocation().isValid())
3400 Diag(Warnings[Warn].OldParm->getLocation(),
3401 diag::note_previous_declaration);
3404 if (MergeTypeWithOld)
3407 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3424 Diag(OldLocation, diag::note_previous_builtin_declaration)
3441 PrevDiag = diag::note_previous_builtin_declaration;
3445 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3459 Scope *
S,
bool MergeTypeWithOld) {
3461 mergeDeclAttributes(New, Old);
3474 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
3482 return MergeCXXFunctionDecl(New, Old, S);
3488 if (!Merged.
isNull() && MergeTypeWithOld)
3499 ? AMK_ProtocolImplementation
3500 : isa<ObjCImplDecl>(newMethod->
getDeclContext()) ? AMK_Redeclaration
3503 mergeDeclAttributes(newMethod, oldMethod, MergeKind);
3510 ni != ne && oi != oe; ++ni, ++oi)
3513 CheckObjCMethodOverride(newMethod, oldMethod);
3520 ? diag::err_redefinition_different_type
3521 : diag::err_redeclaration_different_type)
3526 std::tie(PrevDiag, OldLocation)
3528 S.
Diag(OldLocation, PrevDiag);
3540 bool MergeTypeWithOld) {
3545 if (getLangOpts().CPlusPlus) {
3551 return MergeVarDeclExceptionSpecs(New, Old);
3622 if (MergeTypeWithOld)
3668 if (!shouldLinkPossiblyHiddenDecl(Previous, New))
3683 if (checkUsingShadowRedecl<VarTemplateDecl>(*
this, Shadow, NewTemplate))
3690 if (checkUsingShadowRedecl<VarDecl>(*
this, Shadow, New))
3706 true, TPL_TemplateMatch))
3720 mergeDeclAttributes(New, Old);
3723 if (New->
hasAttr<WeakImportAttr>() &&
3725 !Old->
hasAttr<WeakImportAttr>()) {
3732 if (New->
hasAttr<InternalLinkageAttr>() &&
3733 !Old->
hasAttr<InternalLinkageAttr>()) {
3737 New->
dropAttr<InternalLinkageAttr>();
3742 if (MostRecent != Old) {
3743 MergeVarDeclTypes(New, MostRecent,
3755 std::tie(PrevDiag, OldLocation) =
3762 if (getLangOpts().MicrosoftExt) {
3765 Diag(OldLocation, PrevDiag);
3769 Diag(OldLocation, PrevDiag);
3788 Diag(OldLocation, PrevDiag);
3796 Diag(OldLocation, PrevDiag);
3802 Diag(OldLocation, PrevDiag);
3815 Diag(OldLocation, PrevDiag);
3825 Diag(Def->getLocation(), diag::note_previous_definition);
3839 Diag(OldLocation, PrevDiag);
3842 Diag(OldLocation, PrevDiag);
3850 Diag(OldLocation, PrevDiag);
3861 diag::warn_deprecated_redundant_constexpr_static_def);
3863 if (checkVarDeclRedefinition(Def, New))
3869 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3870 Diag(OldLocation, PrevDiag);
3899 auto &HSI = PP.getHeaderSearchInfo();
3900 StringRef HdrFilename =
3903 auto noteFromModuleOrInclude = [&](
Module *Mod,
3909 if (IncLoc.isValid()) {
3911 Diag(IncLoc, diag::note_redefinition_modules_same_file)
3917 Diag(IncLoc, diag::note_redefinition_include_same_file)
3918 << HdrFilename.str();
3928 bool EmittedDiag =
false;
3929 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
3932 EmittedDiag = noteFromModuleOrInclude(Old->
getOwningModule(), OldIncLoc);
3933 EmittedDiag |= noteFromModuleOrInclude(getCurrentModule(), NewIncLoc);
3936 if (FOld && !HSI.isFileMultipleIncludeGuarded(FOld))
3950 if (!hasVisibleDefinition(Old) &&
3962 makeMergedDefinitionVisible(OldTD);
3963 makeMergedDefinitionVisible(Old);
3998 if (isa<CXXRecordDecl>(Tag->
getParent())) {
4012 Decl *ManglingContextDecl;
4016 Tag, MCtx->getManglingNumber(
4036 if (getLangOpts().CPlusPlus)
4051 tagLoc = getLocForEndOfToken(tagLoc);
4054 textToInsert +=
' ';
4056 Diag(tagLoc, diag::note_typedef_changes_linkage)
4078 llvm_unreachable(
"unexpected type specifier");
4088 bool IsExplicitInstantiation,
4090 Decl *TagD =
nullptr;
4105 if (isa<TagDecl>(TagD))
4106 Tag = cast<TagDecl>(TagD);
4108 Tag = CTD->getTemplatedDecl();
4112 handleTagNumbering(Tag, S);
4123 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
4129 << getLangOpts().CPlusPlus1z;
4151 DiagnoseFunctionSpecifiers(DS);
4158 return ActOnFriendTypeDecl(S, DS, TemplateParams);
4162 bool IsExplicitSpecialization =
4163 !TemplateParams.empty() && TemplateParams.back()->size() == 0;
4165 !IsExplicitInstantiation && !IsExplicitSpecialization &&
4166 !isa<ClassTemplatePartialSpecializationDecl>(Tag)) {
4175 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
4181 bool DeclaresAnything =
true;
4184 if (
RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
4185 if (!Record->getDeclName() && Record->isCompleteDefinition() &&
4187 if (getLangOpts().CPlusPlus ||
4188 Record->getDeclContext()->isRecord()) {
4196 if (CurContext->isFunctionOrMethod())
4197 AnonRecord = Record;
4198 return BuildAnonymousStructOrUnion(S, DS, AS, Record,
4202 DeclaresAnything =
false;
4212 if (!getLangOpts().CPlusPlus && CurContext->isRecord() &&
4228 Record = RT->getDecl();
4230 Record = UT->getDecl();
4232 if (Record && getLangOpts().MicrosoftExt) {
4235 return BuildMicrosoftCAnonymousStruct(S, DS, Record);
4238 DeclaresAnything =
false;
4247 if (getLangOpts().CPlusPlus &&
4249 if (
EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Tag))
4250 if (Enum->enumerator_begin() == Enum->enumerator_end() &&
4251 !Enum->getIdentifier() && !Enum->isInvalidDecl())
4252 DeclaresAnything =
false;
4260 DeclaresAnything =
false;
4269 ActOnDocumentableDecl(TagD);
4279 if (!DeclaresAnything) {
4294 unsigned DiagID = diag::warn_standalone_specifier;
4296 DiagID = diag::ext_standalone_specifier;
4338 Diag(attrs->getLoc(), diag::warn_declspec_attribute_ignored)
4362 assert(PrevDecl &&
"Expected a non-null Decl");
4367 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
4369 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
4394 bool Invalid =
false;
4397 for (
auto *D : AnonRecord->
decls()) {
4398 if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
4399 cast<NamedDecl>(D)->getDeclName()) {
4415 unsigned OldChainingSize = Chaining.size();
4417 Chaining.append(IF->chain_begin(), IF->chain_end());
4419 Chaining.push_back(VD);
4421 assert(Chaining.size() >= 2);
4424 for (
unsigned i = 0; i < Chaining.size(); i++)
4425 NamedChain[i] = Chaining[i];
4429 VD->
getType(), {NamedChain, Chaining.size()});
4441 Chaining.resize(OldChainingSize);
4456 "Parser allowed 'typedef' as storage class VarDecl.");
4457 switch (StorageClassSpec) {
4471 llvm_unreachable(
"unknown storage class specifier");
4477 for (
const auto *
I : Record->
decls()) {
4479 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(
I))
4480 FD = IFD->getAnonField();
4481 if (FD && FD->hasInClassInitializer())
4485 llvm_unreachable(
"couldn't find in-class initializer");
4493 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
4516 if (Record->
isUnion() && !getLangOpts().CPlusPlus && !getLangOpts().C11)
4518 else if (!Record->
isUnion() && getLangOpts().CPlusPlus)
4520 else if (!Record->
isUnion() && !getLangOpts().C11)
4525 bool Invalid =
false;
4526 if (getLangOpts().CPlusPlus) {
4527 const char *PrevSpec =
nullptr;
4534 (isa<TranslationUnitDecl>(Owner) ||
4535 (isa<NamespaceDecl>(Owner) &&
4536 cast<NamespaceDecl>(Owner)->getDeclName()))) {
4542 PrevSpec, DiagID, Policy);
4548 isa<RecordDecl>(Owner)) {
4550 diag::err_anonymous_union_with_storage_spec)
4564 << Record->
isUnion() <<
"const"
4568 diag::ext_anonymous_struct_union_qualified)
4569 << Record->
isUnion() <<
"volatile"
4573 diag::ext_anonymous_struct_union_qualified)
4574 << Record->
isUnion() <<
"restrict"
4578 diag::ext_anonymous_struct_union_qualified)
4579 << Record->
isUnion() <<
"_Atomic"
4583 diag::ext_anonymous_struct_union_qualified)
4584 << Record->
isUnion() <<
"__unaligned"
4594 for (
auto *Mem : Record->
decls()) {
4595 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
4599 assert(FD->getAccess() !=
AS_none);
4601 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
4611 if (CheckNontrivialField(FD))
4613 }
else if (Mem->isImplicit()) {
4615 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
4620 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
4621 if (!MemRecord->isAnonymousStructOrUnion() &&
4622 MemRecord->getDeclName()) {
4624 if (getLangOpts().MicrosoftExt)
4625 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
4629 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
4637 Diag(MemRecord->getLocation(),
4638 diag::ext_anonymous_record_with_anonymous_type)
4641 }
else if (isa<AccessSpecDecl>(Mem)) {
4643 }
else if (isa<StaticAssertDecl>(Mem)) {
4648 unsigned DK = diag::err_anonymous_record_bad_member;
4649 if (isa<TypeDecl>(Mem))
4650 DK = diag::err_anonymous_record_with_type;
4651 else if (isa<FunctionDecl>(Mem))
4652 DK = diag::err_anonymous_record_with_function;
4653 else if (isa<VarDecl>(Mem))
4654 DK = diag::err_anonymous_record_with_static;
4657 if (getLangOpts().MicrosoftExt &&
4658 DK == diag::err_anonymous_record_with_type)
4659 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
4662 Diag(Mem->getLocation(), DK) << Record->
isUnion();
4671 if (cast<CXXRecordDecl>(Record)->hasInClassInitializer() &&
4674 cast<CXXRecordDecl>(Record));
4679 << getLangOpts().CPlusPlus;
4686 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
4690 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
4701 FieldCollector->Add(cast<FieldDecl>(Anon));
4723 ActOnUninitializedDecl(Anon);
4739 Chain.push_back(Anon);
4744 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
4745 if (getLangOpts().
CPlusPlus && NewVD->isStaticLocal()) {
4746 Decl *ManglingContextDecl;
4748 NewVD->getDeclContext(), ManglingContextDecl)) {
4750 NewVD, MCtx->getManglingNumber(
4778 assert(Record &&
"expected a record!");
4783 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
4785 auto *ParentDecl = cast<RecordDecl>(CurContext);
4801 CurContext->addDecl(Anon);
4807 Chain.push_back(Anon);
4810 if (RequireCompleteType(Anon->
getLocation(), RecTy,
4811 diag::err_field_incomplete) ||
4815 ParentDecl->setInvalidDecl();
4824 return GetNameFromUnqualifiedId(D.
getName());
4854 if (!Template || !isa<ClassTemplateDecl>(Template)) {
4856 diag::err_deduction_guide_name_not_class_template)
4857 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
4859 Diag(Template->getLocation(), diag::note_template_decl_here);
4953 llvm_unreachable(
"Unknown name kind");
4981 for (
unsigned Idx = 0; Idx < Declaration->
param_size(); ++Idx) {
4995 (DeclTyName && DeclTyName == DefTyName))
4996 Params.push_back(Idx);
5037 if (!TSI)
return true;
5082 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer() &&
5086 if (getLangOpts().
OpenCL)
5087 setCurrentOpenCLExtensionForDecl(Dcl);
5105 Record = dyn_cast<CXXRecordDecl>(Record->
getParent());
5107 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
5131 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
5145 Diag(Loc, LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
5146 : diag::err_member_extra_qualification)
5150 Diag(Loc, diag::warn_namespace_member_extra_qualification) <<
Name;
5159 Diag(Loc, diag::err_member_qualification)
5161 else if (isa<TranslationUnitDecl>(DC))
5162 Diag(Loc, diag::err_invalid_declarator_global_scope)
5164 else if (isa<FunctionDecl>(Cur))
5165 Diag(Loc, diag::err_invalid_declarator_in_function)
5167 else if (isa<BlockDecl>(Cur))
5168 Diag(Loc, diag::err_invalid_declarator_in_block)
5171 Diag(Loc, diag::err_invalid_declarator_scope)
5172 << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.
getRange();
5179 Diag(Loc, diag::err_member_qualification)
5199 while (SpecLoc.getPrefix())
5201 if (dyn_cast_or_null<DecltypeType>(
5202 SpecLoc.getNestedNameSpecifier()->getAsType()))
5203 Diag(Loc, diag::err_decltype_in_declarator)
5204 << SpecLoc.getTypeLoc().getSourceRange();
5218 return ActOnDecompositionDeclarator(S, D, TemplateParamLists);
5222 diag::err_declarator_need_ident)
5225 }
else if (DiagnoseUnexpandedParameterPack(NameInfo, UPPC_DeclarationType))
5239 UPPC_DeclarationQualifier))
5244 if (!DC || isa<EnumDecl>(DC)) {
5250 diag::err_template_qualified_declarator_no_match)
5257 if (!IsDependentContext &&
5262 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
5264 diag::err_member_def_undefined_record)
5280 if (EnteringContext && IsDependentContext &&
5281 TemplateParamLists.size() != 0) {
5291 if (!R->
isFunctionType() && DiagnoseClassNameShadow(DC, NameInfo))
5299 UPPC_DeclarationType))
5307 bool IsLinkageLookup =
false;
5308 bool CreateBuiltins =
false;
5319 else if (CurContext->isFunctionOrMethod() &&
5322 IsLinkageLookup =
true;
5324 CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
5325 }
else if (CurContext->getRedeclContext()->isTranslationUnit() &&
5327 CreateBuiltins =
true;
5329 if (IsLinkageLookup)
5330 Previous.
clear(LookupRedeclarationWithLinkage);
5332 LookupName(Previous, S, CreateBuiltins);
5334 LookupQualifiedName(Previous, DC);
5387 CheckExtraCXXDefaultArguments(D);
5393 if (!TemplateParamLists.size()) {
5395 diag:: err_concept_wrong_decl_kind);
5401 diag::err_concept_decls_may_only_appear_in_namespace_scope);
5408 bool AddToScope =
true;
5410 if (TemplateParamLists.size()) {
5415 New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous);
5417 New = ActOnFunctionDeclarator(S, D, DC, TInfo, Previous,
5421 New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists,
5435 PushOnScopeChains(New, S, AddToContext);
5437 CurContext->addHiddenDecl(New);
5440 if (isInOpenMPDeclareTargetContext())
5441 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
5451 bool &SizeIsNegative,
5452 llvm::APSInt &Oversized) {
5457 SizeIsNegative =
false;
5466 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
5471 if (FixedType.
isNull())
return FixedType;
5473 return Qs.
apply(Context, FixedType);
5475 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
5476 QualType Inner = PTy->getInnerType();
5480 if (FixedType.
isNull())
return FixedType;
5482 return Qs.
apply(Context, FixedType);
5498 if (Res.isSigned() && Res.isNegative()) {
5499 SizeIsNegative =
true;
5504 unsigned ActiveSizeBits
5538 TypeLoc DstElemTL = DstATL.getElementLoc();
5551 bool &SizeIsNegative,
5552 llvm::APSInt &Oversized) {
5555 SizeIsNegative, Oversized);
5592 diag::err_virtual_non_function);
5596 diag::err_explicit_non_function);
5600 diag::err_noreturn_non_function);
5620 << getLangOpts().CPlusPlus1z;
5626 diag::err_concept_wrong_decl_kind);
5631 diag::err_deduction_guide_invalid_specifier)
5640 if (!NewTD)
return nullptr;
5643 ProcessDeclAttributes(S, NewTD, D);
5645 CheckTypedefForVariablyModifiedType(S, NewTD);
5648 NamedDecl *ND = ActOnTypedefNameDecl(S, DC, NewTD, Previous, Redeclaration);
5662 getCurFunction()->setHasBranchProtectedScope();
5665 bool SizeIsNegative;
5666 llvm::APSInt Oversized;
5679 else if (Oversized.getBoolValue())
5681 << Oversized.toString(10);
5698 NamedDecl *ShadowedDecl = getShadowedDeclaration(NewTD, Previous);
5702 FilterLookupForScope(Previous, DC, S,
false,
5705 if (!Previous.
empty()) {
5706 Redeclaration =
true;
5707 MergeTypedefNameDecl(S, NewTD, Previous);
5710 if (ShadowedDecl && !Redeclaration)
5711 CheckShadow(NewTD, ShadowedDecl, Previous);
5717 if (II->isStr(
"FILE"))
5719 else if (II->isStr(
"jmp_buf"))
5721 else if (II->isStr(
"sigjmp_buf"))
5723 else if (II->isStr(
"ucontext_t"))
5781 if (!OuterContext->
Equals(PrevOuterContext))
5790 if (!SS.
isSet())
return;
5799 unsigned kind = -1U;
5800 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5801 if (var->hasAttr<BlocksAttr>())
5803 else if (!var->hasLocalStorage())
5805 }
else if (isa<ObjCIvarDecl>(decl)) {
5807 }
else if (isa<FieldDecl>(decl)) {
5825 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5828 var->getTLSKind()) {
5829 Diag(var->getLocation(), diag::err_arc_thread_ownership)
5850 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
5858 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
5859 if (VD->hasInit()) {
5860 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
5861 assert(VD->isThisDeclarationADefinition() &&
5862 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
5864 VD->dropAttr<AliasAttr>();
5871 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
5874 diag::err_attribute_selectany_non_extern_data);
5882 auto *VD = dyn_cast<
VarDecl>(&ND);
5892 if (
auto *MD = dyn_cast<CXXMethodDecl>(&ND))
5893 if (MD->isVirtual()) {
5895 diag::err_invalid_attribute_on_virtual_function)
5903 bool IsSpecialization,
5904 bool IsDefinition) {
5908 bool IsTemplate =
false;
5909 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
5910 OldDecl = OldTD->getTemplatedDecl();
5912 if (!IsSpecialization)
5913 IsDefinition =
false;
5915 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
5916 NewDecl = NewTD->getTemplatedDecl();
5920 if (!OldDecl || !NewDecl)
5923 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
5924 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
5925 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
5926 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
5930 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
5931 (NewExportAttr && !NewExportAttr->isInherited());
5937 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
5939 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
5941 bool JustWarn =
false;
5943 auto *VD = dyn_cast<
VarDecl>(OldDecl);
5944 if (VD && !VD->getDescribedVarTemplate())
5955 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
5958 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
5959 : diag::err_attribute_dll_redeclaration;
5962 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
5975 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
5977 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
5980 IsStaticDataMember = VD->isStaticDataMember();
5981 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
5983 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
5984 IsInline = FD->isInlined();
5985 IsQualifiedFriend = FD->getQualifier() &&
5989 if (OldImportAttr && !HasNewAttr &&
5990 (!IsInline || (IsMicrosoft && IsTemplate)) && !IsStaticDataMember &&
5992 if (IsMicrosoft && IsDefinition) {
5994 diag::warn_redeclaration_without_import_attribute)
5997 NewDecl->
dropAttr<DLLImportAttr>();
5999 NewImportAttr->getRange(), S.
Context,
6000 NewImportAttr->getSpellingListIndex()));
6003 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
6004 << NewDecl << OldImportAttr;
6006 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
6007 OldDecl->
dropAttr<DLLImportAttr>();
6008 NewDecl->
dropAttr<DLLImportAttr>();
6010 }
else if (IsInline && OldImportAttr && !IsMicrosoft) {
6012 OldDecl->
dropAttr<DLLImportAttr>();
6013 NewDecl->
dropAttr<DLLImportAttr>();
6015 diag::warn_dllimport_dropped_from_inline_function)
6016 << NewDecl << OldImportAttr;
6053 template<
typename T>
6057 if (!D->isInExternCContext() || D->template hasAttr<OverloadableAttr>())
6061 if (S.
getLangOpts().CUDA && (D->template hasAttr<CUDADeviceAttr>() ||
6062 D->template hasAttr<CUDAHostAttr>()))
6065 return D->isExternC();
6076 llvm_unreachable(
"Unexpected context");
6082 isa<OMPDeclareReductionDecl>(DC))
6086 llvm_unreachable(
"Unexpected context");
6092 if (L->getKind() ==
Kind)
6140 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
6141 return FD->isExternC();
6142 if (
const auto *VD = dyn_cast<VarDecl>(D))
6143 return VD->isExternC();
6145 llvm_unreachable(
"Unknown type of decl!");
6162 if (!Decomp.bindings().empty()) {
6163 II = Decomp.bindings()[0].Name;
6171 if (getLangOpts().OpenCL) {
6177 diag::err_opencl_type_can_only_be_used_as_function_parameter)
6190 diag::err_invalid_type_for_program_scope_var) << R;
6207 if (!getOpenCLOptions().
isEnabled(
"cl_khr_fp16")) {
6258 bool IsLocalExternDecl = SC ==
SC_Extern &&
6259 adjustContextForLocalExternDecl(DC);
6270 !D.
getAsmLabel() && !getSourceManager().isInSystemMacro(
6276 getLangOpts().CPlusPlus1z ? diag::ext_register_storage_class
6277 : diag::warn_deprecated_register)
6293 bool IsMemberSpecialization =
false;
6294 bool IsVariableTemplateSpecialization =
false;
6296 bool IsVariableTemplate =
false;
6305 if (R->getContainedDeducedType())
6306 ParsingInitForAutoVars.insert(NewVD);
6311 bool Invalid =
false;
6313 if (DC->
isRecord() && !CurContext->isRecord()) {
6320 diag::err_static_out_of_line)
6332 diag::err_storage_class_for_static_member)
6336 llvm_unreachable(
"C storage class in c++!");
6340 if (SC ==
SC_Static && CurContext->isRecord()) {
6341 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
6342 if (RD->isLocalClass())
6344 diag::err_static_data_member_not_allowed_in_local_class)
6345 << Name << RD->getDeclName();
6351 getLangOpts().CPlusPlus11
6352 ? diag::warn_cxx98_compat_static_data_member_in_union
6353 : diag::ext_static_data_member_in_union) << Name;
6355 else if (!RD->getDeclName())
6357 diag::err_static_data_member_not_allowed_in_anon_struct)
6358 << Name << RD->isUnion();
6364 TemplateParams = MatchTemplateParametersToScopeSpecifier(
6371 false, IsMemberSpecialization, Invalid);
6373 if (TemplateParams) {
6374 if (!TemplateParams->
size() &&
6379 diag::err_template_variable_noparams)
6383 TemplateParams =
nullptr;
6388 IsVariableTemplateSpecialization =
true;
6389 IsPartialSpecialization = TemplateParams->
size() > 0;
6392 IsVariableTemplate =
true;
6395 if (CheckTemplateDeclScope(S, TemplateParams))
6400 getLangOpts().CPlusPlus14
6401 ? diag::warn_cxx11_compat_variable_template
6402 : diag::ext_variable_template);
6408 "should have a 'template<>' for this decl");
6411 if (IsVariableTemplateSpecialization) {
6413 TemplateParamLists.size() > 0
6414 ? TemplateParamLists[0]->getTemplateLoc()
6416 DeclResult Res = ActOnVarTemplateSpecialization(
6417 S, D, TInfo, TemplateKWLoc, TemplateParams, SC,
6418 IsPartialSpecialization);
6421 NewVD = cast<VarDecl>(Res.
get());
6432 if (IsVariableTemplate) {
6435 TemplateParams, NewVD);
6441 if (R->getContainedDeducedType())
6442 ParsingInitForAutoVars.insert(NewVD);
6454 unsigned VDTemplateParamLists = TemplateParams ? 1 : 0;
6455 if (TemplateParamLists.size() > VDTemplateParamLists)
6457 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
6477 diag::err_concept_decl_invalid_specifiers)
6484 diag::err_concept_decl_invalid_specifiers)
6492 if (IsVariableTemplateSpecialization) {
6494 diag::err_concept_specified_specialization)
6495 << (IsPartialSpecialization ? 2 : 1);
6510 if (!getLangOpts().CPlusPlus) {
6513 }
else if (CurContext->isFunctionOrMethod()) {
6516 diag::err_inline_declaration_block_scope) << Name
6520 getLangOpts().CPlusPlus1z ? diag::warn_cxx14_compat_inline_variable
6521 : diag::ext_inline_variable);
6532 if (IsLocalExternDecl) {
6534 for (
auto *B : Bindings)
6535 B->setLocalExternDecl();
6540 bool EmitTLSUnsupportedError =
false;
6553 diag::err_thread_non_global)
6556 if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
6560 EmitTLSUnsupportedError =
true;
6567 diag::err_thread_unsupported);
6586 diag::warn_static_local_in_extern_inline);
6587 MaybeSuggestAddingStaticToDecl(CurFD);
6592 if (IsVariableTemplateSpecialization)
6594 << (IsPartialSpecialization ? 1 : 0)
6597 else if (IsMemberSpecialization)
6610 for (
auto *B : Bindings)
6611 B->setModulePrivate();
6616 ProcessDeclAttributes(S, NewVD, D);
6618 if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
6619 if (EmitTLSUnsupportedError &&
6621 (getLangOpts().OpenMPIsDevice &&
6622 NewVD->
hasAttr<OMPDeclareTargetDeclAttr>())))
6624 diag::err_thread_unsupported);
6628 (NewVD->
hasAttr<CUDASharedAttr>() ||
6629 NewVD->
hasAttr<CUDAConstantAttr>())) {
6637 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
6638 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
6643 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewVD))
6655 Diag(
E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
6661 Diag(
E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6672 bool HasSizeMismatch;
6674 if (!TI.isValidGCCRegisterName(Label))
6675 Diag(
E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6676 else if (!TI.validateGlobalRegisterVariable(Label,
6679 Diag(
E->getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
6680 else if (HasSizeMismatch)
6681 Diag(
E->getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
6692 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
6693 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator
I =
6695 if (I != ExtnameUndeclaredIdentifiers.end()) {
6698 ExtnameUndeclaredIdentifiers.erase(I);
6707 ? getShadowedDeclaration(NewVD, Previous)
6715 IsMemberSpecialization ||
6716 IsVariableTemplateSpecialization);
6720 if (getLangOpts().CPlusPlus &&
6724 isDeclInScope(Previous.
getFoundDecl(), OriginalDC,
S,
false));
6726 if (!getLangOpts().CPlusPlus) {
6731 CheckMemberSpecialization(NewVD, Previous))
6735 if (!Previous.
empty()) {
6754 if (!IsVariableTemplateSpecialization)
6760 if (IsVariableTemplateSpecialization &&
6764 if (
VarTemplateDecl *VarTmpl = dyn_cast<VarTemplateDecl>(PreviousDecl)) {
6765 if (VarTmpl->isConcept()) {
6768 << (IsPartialSpecialization ? 2
6770 Diag(VarTmpl->getLocation(), diag::note_previous_declaration);
6785 if (CheckTemplateParameterList(
6791 ? TPC_ClassTemplateMember
6797 if (PrevVarTemplate &&
6805 CheckShadow(NewVD, ShadowedDecl, Previous);
6807 ProcessPragmaWeak(S, NewVD);
6813 RegisterLocallyScopedExternCDecl(NewVD, S);
6816 Decl *ManglingContextDecl;
6820 NewVD, MCtx->getManglingNumber(
6833 if (getLangOpts().CPlusPlus)
6851 ActOnDocumentableDecl(NewTemplate);
6856 CompleteMemberSpecialization(NewVD, Previous);
6874 if (isa<TypeAliasDecl>(ShadowedDecl))
6876 else if (isa<TypedefDecl>(ShadowedDecl))
6878 else if (isa<RecordDecl>(OldDC))
6888 for (
const LambdaScopeInfo::Capture &Capture : LSI->
Captures) {
6889 if (Capture.isVariableCapture() && Capture.getVariable() == VD)
6890 return Capture.getLocation();
6917 return isa<VarDecl>(ShadowedDecl) || isa<FieldDecl>(ShadowedDecl)
6934 return isa<TypedefNameDecl>(ShadowedDecl) ? ShadowedDecl :
nullptr;
6950 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
6958 if (isa<CXXConstructorDecl>(NewDC))
6959 if (
const auto PVD = dyn_cast<ParmVarDecl>(D)) {
6962 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
6967 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
6968 if (shadowedVar->isExternC()) {
6971 for (
auto I : shadowedVar->redecls())
6972 if (
I->isFileVarDecl()) {
6980 unsigned WarningDiag = diag::warn_decl_shadow;
6982 if (isa<VarDecl>(D) && isa<VarDecl>(ShadowedDecl) && NewDC &&
6983 isa<CXXMethodDecl>(NewDC)) {
6984 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
6986 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
6988 const auto *LSI = cast<LambdaScopeInfo>(getCurFunction());
6991 if (CaptureLoc.isInvalid())
6992 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
6996 cast<LambdaScopeInfo>(getCurFunction())
6997 ->ShadowingDecls.push_back(
6998 {cast<VarDecl>(D), cast<VarDecl>(ShadowedDecl)});
7003 if (cast<VarDecl>(ShadowedDecl)->hasLocalStorage()) {
7007 ParentDC && !ParentDC->
Equals(OldDC);
7011 if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) &&
7021 if (NewDC && NewDC->isRecord()) {
7023 if (!OldDC->isRecord())
7038 if (getSourceManager().isInSystemMacro(R.getNameLoc()))
7041 Diag(R.getNameLoc(), WarningDiag) <<
Name <<
Kind << OldDC;
7042 if (!CaptureLoc.isInvalid())
7043 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7045 Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration);
7052 const VarDecl *ShadowedDecl = Shadow.ShadowedDecl;
7057 ? diag::warn_decl_shadow_uncaptured_local
7058 : diag::warn_decl_shadow)
7059 << Shadow.VD->getDeclName()
7062 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7063 << Shadow.VD->getDeclName() << 0;
7090 const NamedDecl *D = cast<NamedDecl>(DRE->getDecl()->getCanonicalDecl());
7091 auto I = ShadowingDecls.find(D);
7092 if (I == ShadowingDecls.end())
7094 const NamedDecl *ShadowedDecl = I->second;
7096 Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
7101 ShadowingDecls.erase(I);
7106 template<
typename T>
7109 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
7130 if (!isa<VarDecl>(ND))
7140 if (isa<VarDecl>(*
I)) {
7150 if (isa<VarDecl>(*
I)) {
7168 assert(Prev &&
"should have found a previous declaration to diagnose");
7170 Prev = FD->getFirstDecl();
7172 Prev = cast<VarDecl>(Prev)->getFirstDecl();
7174 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
7176 S.
Diag(Prev->getLocation(), diag::note_extern_c_global_conflict)
7189 template<
typename T>
7196 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
7208 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
7266 if (NewVD->
hasAttr<BlocksAttr>()) {
7275 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
7281 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
7299 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7300 << Scope <<
"global or constant";
7302 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7303 << Scope <<
"constant";
7319 if (FD && !FD->
hasAttr<OpenCLKernelAttr>()) {
7331 if (FD && FD->
hasAttr<OpenCLKernelAttr>()) {
7353 && !NewVD->
hasAttr<BlocksAttr>()) {
7363 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
7369 bool SizeIsNegative;
7370 llvm::APSInt Oversized;
7373 SizeIsNegative, Oversized);
7424 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
7432 diag::err_constexpr_var_non_literal)) {
7459 if (Previous.
empty() &&
7463 if (!Previous.
empty()) {
7471 struct FindOverriddenMethod {
7497 if (MD->isVirtual() && !
S->
IsOverload(Method, MD,
false))
7524 if ((OEK == OEK_All) ||
7525 (OEK == OEK_NonDeleted && !(*I)->isDeleted()) ||
7526 (OEK == OEK_Deleted && (*I)->isDeleted()))
7527 S.
Diag((*I)->getLocation(), diag::note_overridden_virtual_function);
7536 FindOverriddenMethod FOM;
7539 bool hasDeletedOverridenMethods =
false;
7540 bool hasNonDeletedOverridenMethods =
false;
7541 bool AddedAny =
false;
7550 hasDeletedOverridenMethods |= OldMD->isDeleted();
7551 hasNonDeletedOverridenMethods |= !OldMD->isDeleted();
7558 if (hasDeletedOverridenMethods && !MD->
isDeleted()) {
7559 ReportOverrides(*
this, diag::err_non_deleted_override, MD, OEK_Deleted);
7561 if (hasNonDeletedOverridenMethods && MD->
isDeleted()) {
7562 ReportOverrides(*
this, diag::err_deleted_override, MD, OEK_NonDeleted);
7571 struct ActOnFDArgs {
7587 : Context(Context), OriginalFD(TypoFD),
7590 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
7596 CDeclEnd = candidate.
end();
7597 CDecl != CDeclEnd; ++CDecl) {
7606 }
else if (!ExpectedParent) {
7638 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *
S) {
7644 bool IsDefinition = ExtraArgs.D.isFunctionDefinition();
7645 unsigned DiagMsg = IsLocalFriend ? diag::err_no_matching_local_friend
7646 : diag::err_member_decl_does_not_match;
7657 assert(!Prev.isAmbiguous() &&
7658 "Cannot have an ambiguity in previous-declaration lookup");
7660 if (!Prev.empty()) {
7662 Func != FuncEnd; ++Func) {
7669 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
7670 NearMatches.push_back(std::make_pair(FD, ParamNum));
7675 Prev.getLookupNameInfo(), Prev.getLookupKind(),
S,
7676 &ExtraArgs.D.getCXXScopeSpec(),
7677 llvm::make_unique<DifferentNameValidatorCCC>(
7682 ExtraArgs.D.getIdentifierLoc());
7686 CDeclEnd = Correction.
end();
7687 CDecl != CDeclEnd; ++CDecl) {
7694 bool wasRedeclaration = ExtraArgs.D.isRedeclaration();
7707 ExtraArgs.S, ExtraArgs.D,
7710 ExtraArgs.AddToScope);
7721 if ((*I)->getCanonicalDecl() == Canonical)
7728 SemaRef.
PDiag(IsLocalFriend
7729 ? diag::err_no_matching_local_friend_suggest
7730 : diag::err_member_decl_does_not_match_suggest)
7731 << Name << NewDC << IsDefinition);
7737 ExtraArgs.D.getIdentifierLoc());
7738 ExtraArgs.D.setRedeclaration(wasRedeclaration);
7744 << Name << NewDC << IsDefinition << NewFD->
getLocation();
7746 bool NewFDisConst =
false;
7748 NewFDisConst = NewMD->isConst();
7751 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
7752 NearMatch != NearMatchEnd; ++NearMatch) {
7755 bool FDisConst = MD && MD->
isConst();
7756 bool IsMember = MD || !IsLocalFriend;
7759 if (
unsigned Idx = NearMatch->second) {
7763 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
7764 : diag::note_local_decl_close_param_match)
7767 }
else if (FDisConst != NewFDisConst) {
7768 SemaRef.
Diag(FD->
getLocation(), diag::note_member_def_close_const_match)
7772 IsMember ? diag::note_member_def_close_match
7773 : diag::note_local_decl_close_match);
7780 default: llvm_unreachable(
"Unknown storage class!");
7785 diag::err_typecheck_sclass_func);
7802 diag::err_static_block_func);
7818 bool &IsVirtualOkay) {
7838 TInfo, SC, isInline,
7839 HasPrototype,
false);
7861 "Constructors can only be declared in a member context");
7866 R, TInfo, isExplicit, isInline,
7878 NameInfo, R, TInfo, isInline,
7890 IsVirtualOkay =
true;
7909 diag::err_conv_function_not_member);
7914 IsVirtualOkay =
true;
7917 R, TInfo, isInline, isExplicit,
7924 isExplicit, NameInfo, R, TInfo,
7941 cast<CXXRecordDecl>(DC),
7943 TInfo, SC, isInline,
7958 NameInfo, R, TInfo, SC, isInline,
8008 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
8066 HistoryStack.push_back(
nullptr);
8069 VisitStack.push_back(PD);
8071 assert(VisitStack.back() &&
"First decl null?");
8074 const Decl *
Next = VisitStack.pop_back_val();
8076 assert(!HistoryStack.empty());
8078 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
8079 ValidTypes.insert(Hist->getType().getTypePtr());
8087 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(Next)) {
8088 HistoryStack.push_back(Field);
8089 RD = Field->getType()->castAs<
RecordType>()->getDecl();
8091 RD = cast<RecordDecl>(
Next);
8095 VisitStack.push_back(
nullptr);
8097 for (
const auto *FD : RD->
fields()) {
8108 VisitStack.push_back(FD);
8119 diag::err_record_with_pointers_kernel_param)
8132 I = HistoryStack.begin() + 1,
8133 E = HistoryStack.end();
8146 }
while (!VisitStack.empty());
8163 (LangOpts.CPlusPlus &&
8187 diag::err_invalid_thread)
8194 bool isFriend =
false;
8196 bool isMemberSpecialization =
false;
8197 bool isFunctionTemplateSpecialization =
false;
8199 bool isDependentClassScopeExplicitSpecialization =
false;
8200 bool HasExplicitTemplateArgs =
false;
8203 bool isVirtualOkay =
false;
8210 if (!NewFD)
return nullptr;
8220 if (IsLocalExternDecl)
8242 if (Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
8247 if (isVirtual && Parent->isUnion())
8252 isMemberSpecialization =
false;
8253 isFunctionTemplateSpecialization =
false;
8259 bool Invalid =
false;
8267 TemplateParamLists, isFriend, isMemberSpecialization,
8269 if (TemplateParams->size() > 0) {
8293 Name, TemplateParams,
8299 if (TemplateParamLists.size() > 1) {
8301 TemplateParamLists.drop_back(1));
8305 isFunctionTemplateSpecialization =
true;
8307 if (TemplateParamLists.size() > 0)
8313 SourceRange RemoveRange = TemplateParams->getSourceRange();
8327 << Name << RemoveRange
8336 if (TemplateParamLists.size() > 0)
8343 if (FunctionTemplate)
8353 if (!isVirtualOkay) {
8355 diag::err_virtual_non_function);
8359 diag::err_virtual_out_of_class)
8365 diag::err_virtual_member_function_template)
8402 diag::err_inline_declaration_block_scope) << Name
8412 !isa<CXXDeductionGuideDecl>(NewFD)) {
8416 diag::err_explicit_out_of_class)
8418 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
8419 !isa<CXXConversionDecl>(NewFD)) {
8423 diag::err_explicit_non_ctor_or_conv_function)
8436 if (isa<CXXDestructorDecl>(NewFD))
8449 diag::err_function_concept_not_defined);
8457 if (FPT->hasExceptionSpec()) {
8480 if (FPT->getNumParams() > 0 || FPT->isVariadic())
8493 diag::err_concept_decl_invalid_specifiers)
8500 diag::err_concept_decl_invalid_specifiers)
8507 diag::err_concept_decl_invalid_specifiers)
8515 if (isFunctionTemplateSpecialization) {
8517 diag::err_concept_specified_specialization) << 1;
8525 if (isFunctionTemplateSpecialization) {
8528 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
8533 if (FunctionTemplate)
8539 if (FunctionTemplate) {
8564 if (isa<CXXMethodDecl>(NewFD) && DC ==
CurContext &&
8572 if (SC ==
SC_Static && isa<CXXMethodDecl>(NewFD) &&
8582 diag::err_static_out_of_line)
8601 isMemberSpecialization ||
8602 isFunctionTemplateSpecialization);
8611 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator
I =
8636 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
8640 Params.push_back(Param);
8655 auto *TD = dyn_cast<
TagDecl>(NonParmDecl);
8660 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
8661 TD = cast<EnumDecl>(ECD->getDeclContext());
8669 TD->setDeclContext(NewFD);
8677 if (TagDC != PrototypeTagContext)
8678 TD->setLexicalDeclContext(TagDC);
8692 for (
const auto &AI : FT->param_types()) {
8696 Params.push_back(Param);
8700 "Should not need args for typedef of non-prototype fn");
8704 NewFD->setParams(Params);
8721 !NewFD->
hasAttr<SectionAttr>()) {
8722 NewFD->
addAttr(PragmaClangTextSectionAttr::CreateImplicit(
Context,
8729 !NewFD->
hasAttr<SectionAttr>()) {
8731 SectionAttr::CreateImplicit(
Context, SectionAttr::Declspec_allocate,
8752 diag::err_opencl_return_value_with_address_space);
8767 isMemberSpecialization));
8768 else if (!Previous.
empty())
8773 "previous declaration set still overloaded");
8785 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
8802 diag::ext_operator_new_delete_declared_inline)
8816 HasExplicitTemplateArgs =
true;
8819 HasExplicitTemplateArgs =
false;
8820 }
else if (FunctionTemplate) {
8825 HasExplicitTemplateArgs =
false;
8827 assert((isFunctionTemplateSpecialization ||
8829 "should have a 'template<>' for this decl");
8831 isFunctionTemplateSpecialization =
true;
8833 }
else if (isFriend && isFunctionTemplateSpecialization) {
8840 HasExplicitTemplateArgs =
true;
8851 if (
getLangOpts().CUDA & !isFunctionTemplateSpecialization)
8858 bool InstantiationDependent =
false;
8859 if (isFunctionTemplateSpecialization && isFriend &&
8863 InstantiationDependent))) {
8864 assert(HasExplicitTemplateArgs &&
8865 "friend function specialization without template args");
8869 }
else if (isFunctionTemplateSpecialization) {
8872 isDependentClassScopeExplicitSpecialization =
true;
8874 diag::ext_function_specialization_in_class :
8875 diag::err_function_specialization_in_class)
8878 (HasExplicitTemplateArgs ? &TemplateArgs
8891 diag::err_explicit_specialization_inconsistent_storage_class)
8898 diag::ext_explicit_specialization_storage_class)
8902 }
else if (isMemberSpecialization && isa<CXXMethodDecl>(NewFD)) {
8908 if (!isDependentClassScopeExplicitSpecialization) {
8917 isMemberSpecialization));
8918 else if (!Previous.
empty())
8925 "previous declaration set still overloaded");
8927 NamedDecl *PrincipalDecl = (FunctionTemplate
8928 ? cast<NamedDecl>(FunctionTemplate)
8937 if (FunctionTemplate) FunctionTemplate->
setAccess(Access);
8946 if (FunctionTemplate) {
8966 struct ActOnFDArgs ExtraArgs = {
S, D, TemplateParamLists,
8984 (TemplateParamLists.size() ||
9005 *
this, Previous, NewFD, ExtraArgs,
false,
nullptr)) {
9006 AddToScope = ExtraArgs.AddToScope;
9013 }
else if (isFriend && cast<CXXRecordDecl>(
CurContext)->isLocalClass()) {
9015 *
this, Previous, NewFD, ExtraArgs,
true, S)) {
9016 AddToScope = ExtraArgs.AddToScope;
9021 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
9022 !isFriend && !isFunctionTemplateSpecialization &&
9023 !isMemberSpecialization) {
9041 if (NewFD->
hasAttr<OverloadableAttr>() &&
9044 diag::err_attribute_overloadable_no_prototype)
9052 EPI.ExtInfo = FT->getExtInfo();
9084 isMemberSpecialization || isFunctionTemplateSpecialization,
9102 (NewFD->
hasAttr<CUDADeviceAttr>() ||
9103 NewFD->
hasAttr<CUDAGlobalAttr>()) &&
9113 if (FunctionTemplate) {
9116 return FunctionTemplate;
9123 if (NewFD->
hasAttr<OpenCLKernelAttr>()) {
9140 llvm::SmallPtrSet<const Type *, 16> ValidTypes;
9151 QualType ElemTy = PipeTy->getElementType();
9153 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type );
9163 if (isDependentClassScopeExplicitSpecialization) {
9167 cast<CXXMethodDecl>(NewFD),
9168 HasExplicitTemplateArgs, TemplateArgs);
9221 bool IsMemberSpecialization) {
9223 "Variably modified return types are not handled here");
9228 bool MergeTypeWithPrevious = !
getLangOpts().CPlusPlus &&
9231 bool Redeclaration =
false;
9233 bool MayNeedOverloadableChecks =
false;
9237 if (!Previous.
empty()) {
9244 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
9245 Redeclaration =
true;
9246 OldDecl = Candidate;
9249 MayNeedOverloadableChecks =
true;
9253 Redeclaration =
true;
9257 Redeclaration =
true;
9261 Redeclaration =
false;
9268 if (!Redeclaration &&
9270 if (!Previous.
empty()) {
9273 Redeclaration =
true;
9275 MergeTypeWithPrevious =
false;
9278 if (OldDecl->
hasAttr<OverloadableAttr>() ||
9279 NewFD->
hasAttr<OverloadableAttr>()) {
9280 if (
IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
9281 MayNeedOverloadableChecks =
true;
9282 Redeclaration =
false;
9300 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
9304 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
9305 if (!OldMD || !OldMD->
isStatic()) {
9327 if (Redeclaration) {
9332 return Redeclaration;
9339 = dyn_cast<FunctionTemplateDecl>(OldDecl)) {
9343 assert(NewTemplateDecl &&
"Template/non-template mismatch");
9346 Method->setAccess(OldTemplateDecl->getAccess());
9347 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
9352 if (IsMemberSpecialization &&
9355 assert(OldTemplateDecl->isMemberSpecialization());
9358 if (OldTemplateDecl->getTemplatedDecl()->isDeleted()) {
9360 OldTemplateDecl->getTemplatedDecl();
9372 if (isa<CXXMethodDecl>(NewFD))
9376 }
else if (!
getLangOpts().CPlusPlus && MayNeedOverloadableChecks &&
9377 !NewFD->
getAttr<OverloadableAttr>()) {
9378 assert((Previous.
empty() ||
9379 llvm::any_of(Previous,
9381 return ND->
hasAttr<OverloadableAttr>();
9383 "Non-redecls shouldn't happen without overloadable present");
9385 auto OtherUnmarkedIter = llvm::find_if(Previous, [](
const NamedDecl *ND) {
9387 return FD && !FD->
hasAttr<OverloadableAttr>();
9390 if (OtherUnmarkedIter != Previous.
end()) {
9392 diag::err_attribute_overloadable_multiple_unmarked_overloads);
9393 Diag((*OtherUnmarkedIter)->getLocation(),
9394 diag::note_attribute_overloadable_prev_overload)
9408 dyn_cast<CXXDestructorDecl>(NewFD)) {
9421 return Redeclaration;
9425 = dyn_cast<CXXConversionDecl>(NewFD)) {
9427 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
9428 if (
auto *TD = Guide->getDescribedFunctionTemplate())
9434 Diag(Guide->getLocStart(), diag::err_deduction_guide_specialized)
9439 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
9440 if (!Method->isFunctionTemplateSpecialization() &&
9441 !Method->getDescribedFunctionTemplate() &&
9442 Method->isCanonicalDecl()) {
9451 if (Method->isStatic())
9459 return Redeclaration;
9466 return Redeclaration;
9504 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
9517 auto HasNoexcept = [&](
QualType T) ->
bool {
9534 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
9535 for (
QualType T : FPT->param_types())
9536 AnyNoexcept |= HasNoexcept(T);
9539 diag::warn_cxx1z_compat_exception_spec_in_signature)
9543 if (!Redeclaration &&
LangOpts.CUDA)
9546 return Redeclaration;
9559 ? diag::err_static_main : diag::warn_static_main)
9567 Diag(NoreturnLoc, diag::ext_noreturn_main);
9568 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
9579 << FD->
hasAttr<OpenCLKernelAttr>();
9585 assert(T->
isFunctionType() &&
"function decl is not of function type");
9599 if (RTRange.isValid())
9600 Diag(RTRange.getBegin(), diag::note_main_change_return_type)
9622 if (isa<FunctionNoProtoType>(FT))
return;
9628 bool HasExtraParameters = (nparams > 3);
9640 HasExtraParameters =
false;
9642 if (HasExtraParameters) {
9655 for (
unsigned i = 0; i < nparams; ++i) {
9658 bool mismatch =
true;
9662 else if (Expected[i] == CharPP) {
9675 mismatch = !qs.
empty();
9680 Diag(FD->
getLocation(), diag::err_main_arg_wrong) << i << Expected[i];
9698 assert(T->
isFunctionType() &&
"function decl is not of function type");
9703 if (FT->getReturnType()->isIntegralOrEnumerationType() ||
9704 FT->getReturnType()->isAnyPointerType() ||
9705 FT->getReturnType()->isNullPtrType())
9707 if (FD->
getName() !=
"DllMain")
9725 const Expr *Culprit;
9736 class SelfReferenceChecker
9742 bool isReferenceType;
9751 S(S), OrigDecl(OrigDecl) {
9754 isReferenceType =
false;
9756 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
9757 isPODType = VD->getType().isPODType(S.
Context);
9759 isReferenceType = VD->getType()->isReferenceType();
9766 void CheckExpr(
Expr *
E) {
9775 InitFieldIndex.push_back(0);
9776 for (
auto Child : InitList->
children()) {
9777 CheckExpr(cast<Expr>(Child));
9778 ++InitFieldIndex.back();
9780 InitFieldIndex.pop_back();
9785 bool CheckInitListMemberExpr(
MemberExpr *E,
bool CheckReference) {
9788 bool ReferenceField =
false;
9791 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
9795 Fields.push_back(FD);
9797 ReferenceField =
true;
9803 if (!DRE || DRE->
getDecl() != OrigDecl)
9807 if (CheckReference && !ReferenceField)
9812 for (
const FieldDecl *
I : llvm::reverse(Fields))
9813 UsedFieldIndex.push_back(
I->getFieldIndex());
9818 for (
auto UsedIter = UsedFieldIndex.begin(),
9819 UsedEnd = UsedFieldIndex.end(),
9820 OrigIter = InitFieldIndex.begin(),
9821 OrigEnd = InitFieldIndex.end();
9822 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
9823 if (*UsedIter < *OrigIter)
9825 if (*UsedIter > *OrigIter)
9830 HandleDeclRefExpr(DRE);
9837 void HandleValue(
Expr *E) {
9839 if (
DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
9840 HandleDeclRefExpr(DRE);
9845 Visit(CO->getCond());
9846 HandleValue(CO->getTrueExpr());
9847 HandleValue(CO->getFalseExpr());
9852 dyn_cast<BinaryConditionalOperator>(E)) {
9853 Visit(BCO->getCond());
9854 HandleValue(BCO->getFalseExpr());
9859 HandleValue(OVE->getSourceExpr());
9864 if (BO->getOpcode() == BO_Comma) {
9865 Visit(BO->getLHS());
9866 HandleValue(BO->getRHS());
9871 if (isa<MemberExpr>(E)) {
9873 if (CheckInitListMemberExpr(cast<MemberExpr>(E),
9879 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
9881 if (!isa<FieldDecl>(ME->getMemberDecl()))
9885 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base))
9886 HandleDeclRefExpr(DRE);
9896 if (isReferenceType)
9897 HandleDeclRefExpr(E);
9906 Inherited::VisitImplicitCastExpr(E);
9911 if (CheckInitListMemberExpr(E,
true ))
9921 bool Warn = (MD && !MD->
isStatic());
9923 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
9924 if (!isa<FieldDecl>(ME->getMemberDecl()))
9929 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
9931 HandleDeclRefExpr(DRE);
9943 if (isa<UnresolvedLookupExpr>(Callee))
9944 return Inherited::VisitCXXOperatorCallExpr(E);
9948 HandleValue(Arg->IgnoreParenImpCasts());
9965 Inherited::VisitUnaryOperator(E);
9973 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
9974 if (ILE->getNumInits() == 1)
9975 ArgExpr = ILE->getInit(0);
9977 if (ICE->getCastKind() == CK_NoOp)
9978 ArgExpr = ICE->getSubExpr();
9979 HandleValue(ArgExpr);
9982 Inherited::VisitCXXConstructExpr(E);
9991 HandleValue(E->
getArg(0));
9997 Inherited::VisitCallExpr(E);
10002 HandleValue(E->
getLHS());
10007 Inherited::VisitBinaryOperator(E);
10020 if (OrigDecl != ReferenceDecl)
return;
10022 if (isReferenceType) {
10023 diag = diag::warn_uninit_self_reference_in_reference_init;
10024 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
10025 diag = diag::warn_static_self_reference_in_init;
10026 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
10029 diag = diag::warn_uninit_self_reference_in_init;
10044 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *E,
10048 if (isa<ParmVarDecl>(OrigDecl))
10055 if (!DirectInit && !cast<VarDecl>(OrigDecl)->getType()->
isRecordType())
10057 if (ICE->getCastKind() == CK_LValueToRValue)
10058 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
10059 if (DRE->
getDecl() == OrigDecl)
10062 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
10069 struct VarDeclOrName {
10075 return VN.VDecl ? Diag << VN.VDecl : Diag << VN.Name;
10085 bool IsInitCapture = !VDecl;
10087 "init captures are expected to be deduced prior to initialization");
10089 VarDeclOrName VN{VDecl, Name};
10092 assert(Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
10096 assert(VDecl &&
"no init for init capture deduction?");
10104 if (
auto *PL = dyn_cast_or_null<ParenListExpr>(Init))
10105 DeduceInits = PL->exprs();
10108 if (isa<DeducedTemplateSpecializationType>(Deduced)) {
10109 assert(VDecl &&
"non-auto type for init capture deduction?");
10120 if (
auto *IL = dyn_cast<InitListExpr>(Init))
10121 DeduceInits = IL->inits();
10125 if (DeduceInits.empty()) {
10129 ? diag::err_init_capture_no_expression
10130 : diag::err_auto_var_init_no_expression)
10131 << VN << Type << Range;
10135 if (DeduceInits.size() > 1) {
10136 Diag(DeduceInits[1]->getLocStart(),
10137 IsInitCapture ? diag::err_init_capture_multiple_expressions
10138 : diag::err_auto_var_init_multiple_expressions)
10139 << VN << Type << Range;
10143 Expr *DeduceInit = DeduceInits[0];
10144 if (DirectInit && isa<InitListExpr>(DeduceInit)) {
10146 ? diag::err_init_capture_paren_braces
10147 : diag::err_auto_var_init_paren_braces)
10148 << isa<InitListExpr>(Init) << VN << Type << Range;
10153 bool DefaultedAnyToId =
false;
10160 Init = Result.
get();
10161 DefaultedAnyToId =
true;
10167 if (VDecl && isa<DecompositionDecl>(VDecl) &&
10175 if (!IsInitCapture)
10177 else if (isa<InitListExpr>(Init))
10179 diag::err_init_capture_deduction_failure_from_init_list)
10185 Diag(Range.
getBegin(), diag::err_init_capture_deduction_failure)
10200 Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
10203 return DeducedType;
10211 if (DeducedType.
isNull()) {
10247 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
10249 Diag(Method->getLocation(), diag::err_member_function_initialization)
10251 Method->setInvalidDecl();
10257 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
10281 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
10299 BaseDeclType = Array->getElementType();
10301 diag::err_typecheck_decl_incomplete_type)) {
10308 diag::err_abstract_type_in_decl,
10337 Diag(Init->
getExprLoc(), diag::err_static_data_member_reinitialization)
10340 diag::note_previous_initializer)
10375 Init = Result.
get();
10391 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
10393 Args[Idx], VDecl, [
this, Entity, Kind](
Expr *E) {
10399 }
else if (Res.
get() != Args[Idx]) {
10400 Args[Idx] = Res.
get();
10423 CheckSelfReference(*
this, RealDecl, Init, DirectInit);
10436 if (VDecl->
hasAttr<BlocksAttr>())
10471 Init = Result.
get();
10500 isa<InitListExpr>(Init)) {
10501 const Expr *Culprit;
10504 diag::ext_aggregate_init_not_constant)
10560 Diag(Loc, diag::ext_in_class_initializer_non_constant)
10565 Diag(Loc, diag::err_in_class_initializer_non_constant)
10576 diag::ext_in_class_initializer_float_type_cxx11)
10579 diag::note_in_class_initializer_float_type_cxx11)
10582 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
10586 Diag(Init->
getExprLoc(), diag::err_in_class_initializer_non_constant)
10594 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
10638 if (CXXDirectInit) {
10639 assert(DirectInit &&
"Call-style initializer must be direct init.");
10641 }
else if (DirectInit) {
10661 if (
auto *DD = dyn_cast<DecompositionDecl>(D))
10662 for (
auto *BD : DD->bindings())
10677 diag::err_typecheck_decl_incomplete_type)) {
10684 diag::err_abstract_type_in_decl,
10699 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
10703 if (isa<DecompositionDecl>(RealDecl)) {
10704 Diag(Var->getLocation(), diag::err_decomp_decl_requires_init) << Var;
10705 Var->setInvalidDecl();
10719 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
10720 !Var->isThisDeclarationADemotedDefinition()) {
10721 if (Var->isStaticDataMember()) {
10725 Diag(Var->getLocation(),
10726 diag::err_constexpr_static_mem_var_requires_init)
10727 << Var->getDeclName();
10728 Var->setInvalidDecl();
10732 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
10733 Var->setInvalidDecl();
10742 if (VTD->isConcept()) {
10743 Diag(Var->getLocation(), diag::err_var_concept_not_initialized);
10744 Var->setInvalidDecl();
10751 if (!Var->isInvalidDecl() &&
10753 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
10754 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
10755 Var->setInvalidDecl();
10759 switch (Var->isThisDeclarationADefinition()) {
10761 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
10777 !Var->hasLinkage() && !Var->isInvalidDecl() &&
10779 diag::err_typecheck_decl_incomplete_type))
10780 Var->setInvalidDecl();
10785 diag::err_abstract_type_in_decl,
10787 Var->setInvalidDecl();
10790 Diag(Var->getLocation(), diag::warn_private_extern);
10791 Diag(Var->getLocation(), diag::note_private_extern);
10802 if (!Var->isInvalidDecl()) {
10806 ArrayT->getElementType(),
10807 diag::err_illegal_decl_array_incomplete_type))
10808 Var->setInvalidDecl();
10809 }
else if (Var->getStorageClass() ==
SC_Static) {
10819 if (Var->isFirstDecl())
10821 diag::ext_typecheck_decl_incomplete_type);
10826 if (!Var->isInvalidDecl())
10834 Diag(Var->getLocation(),
10835 diag::err_typecheck_incomplete_array_needs_initializer);
10836 Var->setInvalidDecl();
10843 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
10844 << Var->getDeclName()
10845 <<
SourceRange(Var->getLocation(), Var->getLocation());
10846 Var->setInvalidDecl();
10855 if (Var->isInvalidDecl())
10858 if (!Var->hasAttr<AliasAttr>()) {
10861 diag::err_typecheck_decl_incomplete_type)) {
10862 Var->setInvalidDecl();
10871 diag::err_abstract_type_in_decl,
10873 Var->setInvalidDecl();
10890 CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl());
10894 if (!CXXRecord->
isPOD())
10920 Var->setInvalidDecl();
10921 else if (Init.
get()) {
10985 const char *PrevSpec;
10996 EmptyAttrs, IdentLoc);
10998 cast<VarDecl>(Var)->setCXXForRangeDecl(
true);
11001 AttrEnd.
isValid() ? AttrEnd : IdentLoc);
11052 Diag(var->
getLocation(), diag::warn_missing_variable_declarations) << var;
11057 const Expr *CacheCulprit;
11058 auto checkConstInit = [&]()
mutable {
11059 if (!CacheHasConstInit)
11062 return *CacheHasConstInit;
11074 if (!checkConstInit()) {
11103 var->
addAttr(SectionAttr::CreateImplicit(
11104 Context, SectionAttr::Declspec_allocate,
11107 if (
const SectionAttr *SA = var->
getAttr<SectionAttr>())
11128 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
11135 if (var->
hasAttr<BlocksAttr>()) {
11149 var, var->
getType(), varRef,
true);
11169 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
11170 diag::note_invalid_subexpr_in_const_expr) {
11171 DiagLoc = Notes[0].first;
11174 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
11176 for (
unsigned I = 0, N = Notes.size();
I != N; ++
I)
11177 Diag(Notes[
I].first, Notes[
I].second);
11189 var->
hasAttr<RequireConstantInitAttr>()) {
11194 auto attr = var->
getAttr<RequireConstantInitAttr>();
11197 Diag(attr->getLocation(), diag::note_declared_required_constant_init_here)
11198 << attr->getRange();
11203 for (
auto &it : Notes)
11204 Diag(it.first, it.second);
11207 diag::note_invalid_subexpr_in_const_expr)
11220 if (!checkConstInit())
11242 if (
I->isAlignmentDependent())
11253 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
11269 VD->
addAttr(PragmaClangRodataSectionAttr::CreateImplicit(
Context,
11274 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
11275 for (
auto *BD : DD->bindings()) {
11304 auto *NewAttr = cast<InheritableAttr>(A->clone(
getASTContext()));
11305 NewAttr->setInherited(
true);
11313 diag::err_device_static_local_var)
11327 if (VD->
hasAttr<CUDADeviceAttr>() || VD->
hasAttr<CUDAConstantAttr>() ||
11328 VD->
hasAttr<CUDASharedAttr>()) {
11330 bool AllowedInit =
false;
11337 if (!AllowedInit &&
11338 (VD->
hasAttr<CUDADeviceAttr>() || VD->
hasAttr<CUDAConstantAttr>()))
11348 if (!AllowedInit) {
11350 ? diag::err_shared_var_init
11351 : diag::err_dynamic_var_init)
11360 InitFn = CE->getConstructor();
11361 }
else if (
const CallExpr *CE = dyn_cast<CallExpr>(Init)) {
11362 InitFn = CE->getDirectCallee();
11368 << InitFnTarget << InitFn;
11381 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
11388 bool IsClassTemplateMember =
11389 isa<ClassTemplatePartialSpecializationDecl>(
Context) ||
11393 IsClassTemplateMember
11394 ? diag::warn_attribute_dllimport_static_field_definition
11395 : diag::err_attribute_dllimport_static_field_definition);
11396 Diag(IA->getLocation(), diag::note_attribute);
11397 if (!IsClassTemplateMember)
11432 if (VD->
isFileVarDecl() && !isa<VarTemplatePartialSpecializationDecl>(VD))
11437 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
11441 for (
const auto *
I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
11443 if (!MagicValueExpr) {
11446 llvm::APSInt MagicValueInt;
11448 Diag(
I->getRange().getBegin(),
11449 diag::err_type_tag_for_datatype_not_ice)
11453 if (MagicValueInt.getActiveBits() > 64) {
11454 Diag(
I->getRange().getBegin(),
11455 diag::err_type_tag_for_datatype_too_large)
11459 uint64_t MagicValue = MagicValueInt.getZExtValue();
11462 I->getMatchingCType(),
11463 I->getLayoutCompatible(),
11464 I->getMustBeNull());
11469 auto *VD = dyn_cast<
VarDecl>(DD);
11482 bool DiagnosedMultipleDecomps =
false;
11484 bool DiagnosedNonDeducedAuto =
false;
11486 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
11487 if (
Decl *D = Group[i]) {
11490 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
11491 if (!FirstDeclaratorInGroup)
11492 FirstDeclaratorInGroup = DD;
11493 if (!FirstDecompDeclaratorInGroup)
11497 FirstNonDeducedAutoInGroup = DD;
11499 if (FirstDeclaratorInGroup != DD) {
11502 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
11504 diag::err_decomp_decl_not_alone)
11506 << DD->getSourceRange();
11507 DiagnosedMultipleDecomps =
true;
11513 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
11515 diag::err_auto_non_deduced_not_alone)
11516 << FirstNonDeducedAutoInGroup->
getType()
11519 << DD->getSourceRange();
11520 DiagnosedNonDeducedAuto =
true;
11525 Decls.push_back(D);
11532 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
11548 if (Group.size() > 1) {
11550 VarDecl *DeducedDecl =
nullptr;
11551 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
11562 auto *AT = dyn_cast<
AutoType>(DT);
11564 diag::err_auto_different_deductions)
11565 << (AT ? (
unsigned)AT->getKeyword() : 3)
11588 if (Group.empty() || !Group[0])
11592 Group[0]->getLocation()) &&
11594 Group[0]->getLocation()))
11597 if (Group.size() >= 2) {
11605 Decl *MaybeTagDecl = Group[0];
11606 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
11607 Group = Group.slice(1);
11613 if (!Comments.empty() &&
11614 !Comments.back()->isAttached()) {
11622 for (
unsigned i = 0, e = Group.size(); i != e; ++i)
11643 diag::err_invalid_storage_class_in_func_decl);
11693 if (R.isSingleResult()) {
11694 NamedDecl *PrevDecl = R.getFoundDecl();
11699 PrevDecl =
nullptr;
11718 parmDeclType, TInfo,
11742 if (New->
hasAttr<BlocksAttr>()) {
11772 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
11780 if (
LangOpts.NumLargeByValueCopy == 0)
11787 if (Size >
LangOpts.NumLargeByValueCopy)
11799 if (Size >
LangOpts.NumLargeByValueCopy)
11823 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
11834 TSInfo, SC,
nullptr);
11850 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
11864 Diag(NameLoc, diag::err_arg_with_address_space);
11879 for (
int i = FTI.
NumParams; i != 0; ) {
11883 llvm::raw_svector_ostream(Code)
11893 const char* PrevSpec;
11936 if (isa<CXXMethodDecl>(FD))
11956 if (FD->
hasAttr<OpenCLKernelAttr>())
11963 bool MissingPrototype =
true;
11968 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
11971 MissingPrototype = !Prev->getType()->isFunctionProtoType();
11973 PossibleZeroParamPrototype = Prev;
11977 return MissingPrototype;
12028 LSI->
Lambda = LambdaClass;
12046 for (
const auto &C : LambdaClass->
captures()) {
12047 if (C.capturesVariable()) {
12048 VarDecl *VD = C.getCapturedVar();
12052 const bool ByRef = C.getCaptureKind() ==
LCK_ByRef;
12054 true, C.getLocation(),
12055 C.isPackExpansion()
12057 CaptureType,
nullptr);
12059 }
else if (C.capturesThis()) {
12077 FD = FunTmpl->getTemplatedDecl();
12079 FD = cast<FunctionDecl>(D);
12082 if (
const auto *
Attr = FD->
getAttr<AliasAttr>()) {
12087 if (
const auto *
Attr = FD->
getAttr<IFuncAttr>()) {
12119 "There should be an active template instantiation on the stack "
12120 "when instantiating a generic lambda!");
12142 diag::err_func_def_incomplete_result))
12156 auto *NonParmDecl = dyn_cast<
NamedDecl>(NPD);
12159 assert(!isa<ParmVarDecl>(NonParmDecl) &&
12160 "parameters should not be in newly created FD yet");
12163 if (NonParmDecl->getDeclName())
12168 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
12169 for (
auto *EI : ED->enumerators())
12177 Param->setOwningFunction(FD);
12180 if (Param->getIdentifier() && FnBodyScope) {
12194 assert(!FD->
hasAttr<DLLExportAttr>());
12195 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
12225 for (
unsigned I = 0, E = Scope->
Returns.size();
I !=
E; ++
I) {
12226 if (
const VarDecl *NRVOCandidate = Returns[
I]->getNRVOCandidate()) {
12227 if (!NRVOCandidate->isNRVOVariable())
12228 Returns[
I]->setNRVOCandidate(
nullptr);
12246 Outer.Fun.hasTrailingReturnType()) {
12264 if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
12270 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Decl))
12271 FD->setHasSkippedBody();
12272 else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(Decl))
12282 bool IsInstantiation) {
12316 if (LSI->HasImplicitReturnType) {
12323 LSI->ReturnType.isNull() ?
Context.
VoidTy : LSI->ReturnType;
12381 const FunctionDecl *PossibleZeroParamPrototype =
nullptr;
12385 if (PossibleZeroParamPrototype) {
12390 TypeLoc TL = TI->getTypeLoc();
12393 diag::note_declaration_not_a_prototype)
12394 << PossibleZeroParamPrototype
12415 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
12430 if (KeyFunction && KeyFunction->
isDefined(Definition))
12440 "Function parsing confused");
12441 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
12454 << MD->getSelector().getAsString();
12459 bool isDesignated =
12460 MD->isDesignatedInitializerForTheInterface(&InitMethod);
12461 assert(isDesignated && InitMethod);
12462 (void)isDesignated;
12465 auto IFace = MD->getClassInterface();
12468 auto SuperD = IFace->getSuperClass();
12478 diag::warn_objc_designated_init_missing_super_call);
12480 diag::note_objc_designated_init_marked_here);
12488 diag::warn_objc_secondary_init_missing_init_call);
12495 if (Body &&
getCurFunction()->HasPotentialAvailabilityViolations)
12499 "This should only be set for ObjC methods, which should have been "
12500 "handled in the block above.");
12507 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
12516 if (!Destructor->getParent()->isDependentType())
12520 Destructor->getParent());
12531 !isa<FunctionTemplateDecl>(dcl)) {
12534 ActivePolicy = &WP;
12542 if (FD && FD->
hasAttr<NakedAttr>()) {
12546 bool RegisterVariables =
false;
12547 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
12548 for (
const auto *
Decl : DS->decls()) {
12549 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
12550 RegisterVariables =
12551 Var->hasAttr<AsmLabelAttr>() && !Var->hasInit();
12552 if (!RegisterVariables)
12557 if (RegisterVariables)
12559 if (!isa<AsmStmt>(S) && !isa<NullStmt>(S)) {
12560 Diag(S->getLocStart(), diag::err_non_asm_stmt_in_naked_function);
12561 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
12570 "Leftover temporaries in function");
12573 "Leftover expressions for odr-use checking");
12576 if (!IsInstantiation)
12596 D = TD->getTemplatedDecl();
12599 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D))
12600 if (Method->isStatic())
12613 Diag(Loc, diag::warn_use_out_of_scope_declaration) << ExternCPrev;
12614 Diag(ExternCPrev->getLocation(), diag::note_previous_declaration);
12615 return ExternCPrev;
12620 if (II.
getName().startswith(
"__builtin_"))
12621 diag_id = diag::warn_builtin_unknown;
12624 diag_id = diag::err_opencl_implicit_function_decl;
12626 diag_id = diag::ext_implicit_function_decl;
12628 diag_id = diag::warn_implicit_function_decl;
12629 Diag(Loc, diag_id) << &II;
12651 assert(!Error &&
"Error setting up implicit decl!");
12713 unsigned FormatIdx;
12716 if (!FD->
hasAttr<FormatAttr>()) {
12717 const char *fmt =
"printf";
12719 if (FormatIdx < NumParams &&
12725 HasVAListArg ? 0 : FormatIdx+2,
12731 if (!FD->
hasAttr<FormatAttr>())
12735 HasVAListArg ? 0 : FormatIdx+2,
12744 if (!FD->
hasAttr<ConstAttr>())
12749 !FD->
hasAttr<ReturnsTwiceAttr>())
12759 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
12777 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
12794 if (Name->
isStr(
"asprintf") || Name->
isStr(
"vasprintf")) {
12797 if (!FD->
hasAttr<FormatAttr>())
12800 Name->
isStr(
"vasprintf") ? 0 : 3,
12804 if (Name->
isStr(
"__CFStringMakeConstantString")) {
12807 if (!FD->
hasAttr<FormatArgAttr>())
12815 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
12816 assert(!T.
isNull() &&
"GetTypeForDeclarator() returned null type");
12819 assert(D.
isInvalidType() &&
"no declarator info for valid type");
12879 if (BT->isInteger())
12882 Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T;
12890 bool EnumUnderlyingIsImplicit,
const EnumDecl *Prev) {
12891 bool IsFixed = !EnumUnderlyingTy.
isNull();
12893 if (IsScoped != Prev->
isScoped()) {
12894 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
12900 if (IsFixed && Prev->
isFixed()) {
12906 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
12912 }
else if (IsFixed && !Prev->
isFixed() && EnumUnderlyingIsImplicit) {
12916 }
else if (IsFixed != Prev->
isFixed()) {
12917 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
12936 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
12951 if (isa<TypedefDecl>(PrevDecl))
12953 else if (isa<TypeAliasDecl>(PrevDecl))
12955 else if (isa<ClassTemplateDecl>(PrevDecl))
12957 else if (isa<TypeAliasTemplateDecl>(PrevDecl))
12959 else if (isa<TemplateTemplateParmDecl>(PrevDecl))
12971 llvm_unreachable(
"invalid TTK");
12997 if (OldTag == NewTag)
13003 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Previous))
13004 isTemplate = Record->getDescribedClassTemplate();
13009 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
13015 if (isDefinition) {
13023 bool previousMismatch =
false;
13024 for (
auto I : Previous->
redecls()) {
13025 if (
I->getTagKind() != NewTag) {
13026 if (!previousMismatch) {
13027 previousMismatch =
true;
13028 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
13032 Diag(
I->getInnerLocStart(), diag::note_struct_class_suggestion)
13050 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
13057 Diag(NewTagLoc, diag::note_struct_class_suggestion)
13091 Namespaces.push_back(II);
13094 if (Lookup == Namespace)
13101 llvm::raw_svector_ostream OS(Insertion);
13104 std::reverse(Namespaces.begin(), Namespaces.end());
13105 for (
auto *II : Namespaces)
13106 OS << II->getName() <<
"::";
13119 if (OldDC->
Equals(NewDC))
13147 bool &OwnedDecl,
bool &IsDependent,
13149 bool ScopedEnumUsesClassTag,
13151 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
13156 "Nameless record must be a definition!");
13157 assert(TemplateParameterLists.size() == 0 || TUK !=
TUK_Reference);
13161 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
13164 bool isMemberSpecialization =
false;
13165 bool Invalid =
false;
13170 if (TemplateParameterLists.size() > 0 ||
13174 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
13175 TUK ==
TUK_Friend, isMemberSpecialization, Invalid)) {
13177 Diag(KWLoc, diag::err_enum_template);
13181 if (TemplateParams->size() > 0) {
13190 SS, Name, NameLoc, Attr,
13191 TemplateParams, AS,
13194 TemplateParameterLists.size()-1,
13195 TemplateParameterLists.data(),
13197 return Result.
get();
13200 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
13202 isMemberSpecialization =
true;
13210 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
13211 bool EnumUnderlyingIsImplicit =
false;
13214 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum))
13218 else if (UnderlyingType.
get()) {
13223 EnumUnderlying = TI;
13237 EnumUnderlyingIsImplicit =
true;
13244 bool isStdBadAlloc =
false;
13245 bool isStdAlignValT =
false;
13254 auto createTagFromNewDecl = [&]() ->
TagDecl * {
13264 ScopedEnum, ScopedEnumUsesClassTag,
13265 !EnumUnderlying.isNull());
13269 if (EnumUnderlying) {
13270 EnumDecl *ED = cast<EnumDecl>(New);
13282 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
13308 goto CreateNewDecl;
13316 IsDependent =
true;
13338 if (Previous.
empty()) {
13347 IsDependent =
true;
13352 Diag(NameLoc, diag::err_not_tag_in_scope)
13353 << Kind << Name << DC << SS.
getRange();
13356 goto CreateNewDecl;
13404 bool FriendSawTagOutsideEnclosingNamespace =
false;
13411 FriendSawTagOutsideEnclosingNamespace =
true;
13420 if (Previous.
isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
13422 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
13436 while (isa<RecordDecl>(SearchDC) || isa<EnumDecl>(SearchDC))
13451 if (Name->
isStr(
"bad_alloc")) {
13453 isStdBadAlloc =
true;
13460 }
else if (Name->
isStr(
"align_val_t")) {
13461 isStdAlignValT =
true;
13471 if (Name && Previous.
empty() &&
13473 if (Invalid)
goto CreateNewDecl;
13537 if (!Previous.
empty()) {
13553 TagDecl *Tag = TT->getDecl();
13556 ->
Equals(TD->getDeclContext()->getRedeclContext())) {
13569 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
13570 auto *OldTag = dyn_cast<
TagDecl>(PrevDecl);
13572 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
13574 *
this, OldTag->getDeclContext(), SearchDC))) {
13575 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
13576 Diag(Shadow->getTargetDecl()->getLocation(),
13577 diag::note_using_decl_target);
13578 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl)
13582 goto CreateNewDecl;
13586 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
13592 SS.
isNotEmpty() || isMemberSpecialization)) {
13598 bool SafeToContinue
13599 = (PrevTagDecl->getTagKind() !=
TTK_Enum &&
13601 if (SafeToContinue)
13602 Diag(KWLoc, diag::err_use_with_wrong_tag)
13605 PrevTagDecl->getKindName());
13607 Diag(KWLoc, diag::err_use_with_wrong_tag) <<
Name;
13608 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
13610 if (SafeToContinue)
13611 Kind = PrevTagDecl->getTagKind();
13621 const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
13627 Diag(ScopedEnumKWLoc, diag::err_enum_class_reference)
13630 return PrevTagDecl;
13635 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
13636 else if (
const Type *T = EnumUnderlying.dyn_cast<
const Type*>())
13637 EnumUnderlyingTy =
QualType(T, 0);
13643 ScopedEnum, EnumUnderlyingTy,
13644 EnumUnderlyingIsImplicit, PrevEnum))
13654 Diag(NameLoc, diag::ext_member_redeclared);
13655 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
13666 (PrevTagDecl->getFriendObjectKind() ==
13679 return PrevTagDecl;
13684 return PrevTagDecl;
13690 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
13694 bool IsExplicitSpecializationAfterInstantiation =
false;
13695 if (isMemberSpecialization) {
13697 IsExplicitSpecializationAfterInstantiation =
13698 RD->getTemplateSpecializationKind() !=
13700 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
13701 IsExplicitSpecializationAfterInstantiation =
13702 ED->getTemplateSpecializationKind() !=
13722 SkipBody->
New = createTagFromNewDecl();
13729 }
else if (!IsExplicitSpecializationAfterInstantiation) {
13733 Diag(NameLoc, diag::warn_redefinition_in_param_list) <<
Name;
13735 Diag(NameLoc, diag::err_redefinition) <<
Name;
13737 NameLoc.
isValid() ? NameLoc : KWLoc);
13749 if (TD->isBeingDefined()) {
13750 Diag(NameLoc, diag::err_nested_redefinition) <<
Name;
13751 Diag(PrevTagDecl->getLocation(),
13752 diag::note_previous_definition);
13767 SearchDC = PrevTagDecl->getDeclContext();
13795 Diag(NameLoc, diag::err_tag_reference_non_tag) << PrevDecl << NTK
13802 SS.
isNotEmpty() || isMemberSpecialization)) {
13808 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
13814 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
13816 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
13817 Diag(NameLoc, diag::err_tag_definition_of_typedef)
13818 << Name << Kind << TND->getUnderlyingType();
13826 Diag(NameLoc, diag::err_redefinition_different_kind) <<
Name;
13854 bool IsForwardReference =
false;
13859 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
13860 ScopedEnumUsesClassTag, !EnumUnderlying.isNull());
13868 if (!EnumUnderlyingIsImplicit &&
13870 cast<EnumDecl>(New)->isFixed()) {
13874 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
13875 Diag(Loc, diag::ext_forward_ref_enum_def)
13879 unsigned DiagID = diag::ext_forward_ref_enum;
13881 DiagID = diag::ext_ms_forward_ref_enum;
13883 DiagID = diag::err_forward_ref_enum;
13890 IsForwardReference =
true;
13894 if (EnumUnderlying) {
13895 EnumDecl *ED = cast<EnumDecl>(New);
13910 cast_or_null<CXXRecordDecl>(PrevDecl));
13916 cast_or_null<RecordDecl>(PrevDecl));
13936 if (!isMemberSpecialization &&
13942 if (TemplateParameterLists.size() > 0) {
13950 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
13966 if (ModulePrivateLoc.
isValid()) {
13967 if (isMemberSpecialization)
13992 Diag(Loc, diag::err_type_defined_in_param_type)
13996 }
else if (!PrevDecl) {
14016 if (!Invalid && SearchDC->
isRecord())
14041 if (IsForwardReference)
14069 if (
auto RD = dyn_cast<RecordDecl>(New))
14070 RD->completeDefinition();
14079 TagDecl *Tag = cast<TagDecl>(TagD);
14102 assert(isa<ObjCContainerDecl>(IDecl) &&
14103 "ActOnObjCContainerStartDefinition - Not ObjCContainerDecl");
14106 "The next DeclContext should be lexically contained in the current one.");
14113 bool IsFinalSpelledSealed,
14125 FinalAttr(FinalLoc,
Context, IsFinalSpelledSealed));
14145 "Broken injected-class-name");
14151 TagDecl *Tag = cast<TagDecl>(TagD);
14156 assert(Tag->
isInvalidDecl() &&
"We should already have completed it");
14157 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
14158 RD->completeDefinition();
14161 if (isa<CXXRecordDecl>(Tag)) {
14183 assert(DC ==
CurContext &&
"Mismatch of container contexts");
14195 TagDecl *Tag = cast<TagDecl>(TagD);
14200 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
14201 RD->completeDefinition();
14214 QualType FieldTy,
bool IsMsStruct,
14215 Expr *BitWidth,
bool *ZeroWidth) {
14227 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
14229 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
14240 llvm::APSInt
Value;
14244 BitWidth = ICE.
get();
14246 if (Value != 0 && ZeroWidth)
14247 *ZeroWidth =
false;
14250 if (Value == 0 && FieldName)
14251 return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
14253 if (Value.isSigned() && Value.isNegative()) {
14255 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
14256 << FieldName << Value.toString(10);
14257 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
14258 << Value.toString(10);
14264 bool BitfieldIsOverwide = Value.ugt(TypeWidth);
14268 bool CStdConstraintViolation =
14270 bool MSBitfieldViolation =
14271 Value.ugt(TypeStorageSize) &&
14273 if (CStdConstraintViolation || MSBitfieldViolation) {
14274 unsigned DiagWidth =
14275 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
14277 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
14278 << FieldName << (
unsigned)Value.getZExtValue()
14279 << !CStdConstraintViolation << DiagWidth;
14281 return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width)
14282 << (
unsigned)Value.getZExtValue() << !CStdConstraintViolation
14291 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
14292 << FieldName << (
unsigned)Value.getZExtValue()
14295 Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_width)
14308 DeclStart, D, static_cast<Expr*>(BitfieldWidth),
14346 Diag(Loc, diag::err_field_with_address_space);
14354 Diag(Loc, diag::err_opencl_type_struct_or_union_field) << T;
14365 diag::err_invalid_thread)
14393 PrevDecl =
nullptr;
14397 PrevDecl =
nullptr;
14403 =
CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
14404 TSSL, AS, PrevDecl, &D);
14436 bool Mutable,
Expr *BitWidth,
14442 bool InvalidDecl =
false;
14448 InvalidDecl =
true;
14457 InvalidDecl =
true;
14463 InvalidDecl =
true;
14470 Diag(Loc, diag::err_opencl_bitfields);
14471 InvalidDecl =
true;
14477 bool SizeIsNegative;
14478 llvm::APSInt Oversized;
14485 Diag(Loc, diag::warn_illegal_constant_array_size);
14486 TInfo = FixedTInfo;
14489 if (SizeIsNegative)
14490 Diag(Loc, diag::err_typecheck_negative_array_size);
14491 else if (Oversized.getBoolValue())
14492 Diag(Loc, diag::err_array_too_large)
14493 << Oversized.toString(10);
14495 Diag(Loc, diag::err_typecheck_field_variable_size);
14496 InvalidDecl =
true;
14502 diag::err_abstract_type_in_decl,
14504 InvalidDecl =
true;
14506 bool ZeroWidth =
false;
14508 BitWidth =
nullptr;
14514 InvalidDecl =
true;
14515 BitWidth =
nullptr;
14521 if (!InvalidDecl && Mutable) {
14522 unsigned DiagID = 0;
14524 DiagID =
getLangOpts().MSVCCompat ? diag::ext_mutable_reference
14525 : diag::err_mutable_reference;
14527 DiagID = diag::err_mutable_const;
14533 Diag(ErrLoc, DiagID);
14534 if (DiagID != diag::ext_mutable_reference) {
14536 InvalidDecl =
true;
14548 BitWidth, Mutable, InitStyle);
14552 if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
14553 Diag(Loc, diag::err_duplicate_member) << II;
14578 diag::ext_union_member_of_reference_type :
14579 diag::err_union_member_of_reference_type)
14603 Diag(Loc, diag::warn_attribute_weak_on_field);
14649 if (!FD->
hasAttr<UnavailableAttr>())
14651 UnavailableAttr::IR_ARCFieldWithOwnership, Loc));
14657 diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member :
14658 diag::err_illegal_union_or_anon_struct_member)
14673 switch (ivarVisibility) {
14674 default: llvm_unreachable(
"Unknown visitibility kind");
14690 Expr *BitWidth = (
Expr*)BitfieldWidth;
14712 Diag(Loc, diag::err_ivar_reference_type);
14718 Diag(Loc, diag::err_typecheck_ivar_variable_size);
14732 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
14735 EnclosingContext = IMPDecl->getClassInterface();
14736 assert(EnclosingContext &&
"Implementation has no class interface!");
14739 EnclosingContext = EnclosingDecl;
14742 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
14744 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
14748 EnclosingContext = EnclosingDecl;
14753 DeclStart, Loc, II, T,
14754 TInfo, ac, (
Expr *)BitfieldWidth);
14759 if (PrevDecl &&
isDeclInScope(PrevDecl, EnclosingContext, S)
14760 && !isa<TagDecl>(PrevDecl)) {
14761 Diag(Loc, diag::err_duplicate_member) << II;
14788 !NewID->
isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
14789 Diag(Loc, diag::warn_ivars_in_interface);
14803 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
14811 if (!CD->IsClassExtension())
14823 DeclLoc, DeclLoc,
nullptr,
14829 AllIvarDecls.push_back(Ivar);
14835 assert(EnclosingDecl &&
"missing record or interface decl");
14840 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
14844 case Decl::ObjCCategory:
14847 case Decl::ObjCImplementation:
14849 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
14858 unsigned NumNamedMembers = 0;
14860 for (
const auto *
I : Record->
decls()) {
14861 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(
I))
14862 if (IFD->getDeclName())
14870 bool ObjCFieldLifetimeErrReported =
false;
14880 RecFields.push_back(FD);
14908 ((i + 1 == Fields.end() && !Record->
isUnion()) ||
14911 (i + 1 == Fields.end() || Record->
isUnion())))) {
14916 unsigned DiagID = 0;
14919 ? diag::ext_flexible_array_union_ms
14921 ? diag::ext_flexible_array_union_gnu
14922 : diag::err_flexible_array_union;
14923 else if (NumNamedMembers < 1)
14925 ? diag::ext_flexible_array_empty_aggregate_ms
14927 ? diag::ext_flexible_array_empty_aggregate_gnu
14928 : diag::err_flexible_array_empty_aggregate;
14939 if (RD->getNumVBases() != 0)
14953 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
14963 diag::err_field_incomplete)) {
14977 if (i + 1 != Fields.end())
14988 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
14990 diag::err_abstract_type_in_decl,
15005 }
else if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
15006 Record && !ObjCFieldLifetimeErrReported &&
15017 if (!FD->
hasAttr<UnavailableAttr>()) {
15019 UnavailableAttr::IR_ARCFieldWithOwnership, loc));
15025 ObjCFieldLifetimeErrReported =
true;
15052 bool Completed =
false;
15053 if (
CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) {
15054 if (!CXXRecord->isInvalidDecl()) {
15057 I = CXXRecord->conversion_begin(),
15058 E = CXXRecord->conversion_end();
I !=
E; ++
I)
15059 I.setAccess((*I)->getAccess());
15062 if (!CXXRecord->isDependentType()) {
15063 if (CXXRecord->hasUserDeclaredDestructor()) {
15067 CXXRecord->getDestructor());
15070 if (!CXXRecord->isInvalidDecl()) {
15077 if (CXXRecord->getNumVBases()) {
15079 CXXRecord->getFinalOverriders(FinalOverriders);
15081 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
15082 MEnd = FinalOverriders.end();
15085 SOEnd = M->second.end();
15086 SO != SOEnd; ++SO) {
15087 assert(SO->second.size() > 0 &&
15088 "Virtual function without overridding functions?");
15089 if (SO->second.size() == 1)
15097 << (
const NamedDecl *)M->first << Record;
15098 Diag(M->first->getLocation(),
15099 diag::note_overridden_virtual_function);
15101 OM = SO->second.begin(),
15102 OMEnd = SO->second.end();
15104 Diag(OM->Method->getLocation(), diag::note_final_overrider)
15105 << (
const NamedDecl *)M->first << OM->Method->getParent();
15110 CXXRecord->completeDefinition(&FinalOverriders);
15121 if (
CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) {
15122 auto *Dtor = CXXRecord->getDestructor();
15123 if (Dtor && Dtor->isImplicit() &&
15131 if (
const MSInheritanceAttr *IA = Record->
getAttr<MSInheritanceAttr>())
15133 IA->getRange(), IA->getBestCase(),
15134 IA->getSemanticSpelling());
15140 bool CheckForZeroSize;
15142 CheckForZeroSize =
true;
15151 if (CheckForZeroSize) {
15152 bool ZeroSize =
true;
15153 bool IsEmpty =
true;
15154 unsigned NonBitFields = 0;
15157 (NonBitFields == 0 || ZeroSize) &&
I != E; ++
I) {
15159 if (
I->isUnnamedBitfield()) {
15160 if (
I->getBitWidthValue(
Context) > 0)
15176 diag::warn_zero_size_struct_union_in_extern_c :
15177 diag::warn_zero_size_struct_union_compat)
15178 << IsEmpty << Record->
isUnion() << (NonBitFields > 1);
15183 if (NonBitFields == 0 && !
getLangOpts().CPlusPlus) {
15184 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union :
15185 diag::ext_no_named_members_in_struct_union)
15193 ID->setEndOfDefinitionLoc(RBrac);
15195 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
15197 ID->addDecl(ClsFields[i]);
15201 if (
ID->getSuperClass())
15204 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
15205 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
15206 for (
unsigned I = 0, N = RecFields.size();
I != N; ++
I)
15209 ClsFields[
I]->setLexicalDeclContext(IMPDecl);
15211 IMPDecl->setIvarLBraceLoc(LBrac);
15212 IMPDecl->setIvarRBraceLoc(RBrac);
15214 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
15222 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
15226 Diag(ClsFields[i]->getLocation(),
15227 diag::err_duplicate_ivar_declaration);
15228 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
15234 Diag(ClsFields[i]->getLocation(),
15235 diag::err_duplicate_ivar_declaration);
15236 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
15242 CDecl->addDecl(ClsFields[i]);
15244 CDecl->setIvarLBraceLoc(LBrac);
15245 CDecl->setIvarRBraceLoc(RBrac);
15256 llvm::APSInt &
Value,
15258 assert(T->
isIntegralType(Context) &&
"Integral type required!");
15261 if (Value.isUnsigned() || Value.isNonNegative()) {
15264 return Value.getActiveBits() <= BitWidth;
15266 return Value.getMinSignedBits() <= BitWidth;
15274 assert(T->
isIntegralType(Context) &&
"Integral type required!");
15275 const unsigned NumTypes = 4;
15276 QualType SignedIntegralTypes[NumTypes] = {
15279 QualType UnsignedIntegralTypes[NumTypes] = {
15286 : UnsignedIntegralTypes;
15287 for (
unsigned I = 0;
I != NumTypes; ++
I)
15300 llvm::APSInt EnumVal(IntWidth);
15326 Val = Converted.
get();
15329 &EnumVal).
get())) {
15341 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
15344 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
15348 CK_IntegralToBoolean : CK_IntegralCast)
15365 Diag(IdLoc, diag::ext_enum_value_not_int)
15367 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
15379 if (Enum->isDependentType())
15381 else if (!LastEnumConst) {
15390 if (Enum->isFixed()) {
15391 EltTy = Enum->getIntegerType();
15398 EnumVal = LastEnumConst->getInitVal();
15400 EltTy = LastEnumConst->getType();
15403 if (EnumVal < LastEnumConst->getInitVal()) {
15418 EnumVal = LastEnumConst->getInitVal();
15419 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
15421 if (
Enum->isFixed())
15423 Diag(IdLoc, diag::err_enumerator_wrapped)
15424 << EnumVal.toString(10)
15427 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
15428 << EnumVal.toString(10);
15436 EnumVal = LastEnumConst->getInitVal();
15437 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
15446 if (!getLangOpts().CPlusPlus && !T.
isNull())
15447 Diag(IdLoc, diag::warn_enum_value_overflow);
15448 }
else if (!getLangOpts().CPlusPlus &&
15451 Diag(IdLoc, diag::ext_enum_value_not_int)
15452 << EnumVal.toString(10) << 1;
15457 if (!EltTy->isDependentType()) {
15461 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
15479 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
15483 EnumDecl *PrevED = cast<EnumDecl>(PrevECD->getDeclContext());
15498 EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl);
15500 cast_or_null<EnumConstantDecl>(lastEnumConst);
15514 PrevDecl =
nullptr;
15535 "Received TagDecl when not in C++!");
15537 shouldLinkPossiblyHiddenDecl(PrevDecl, New)) {
15538 if (isa<EnumConstantDecl>(PrevDecl))
15539 Diag(IdLoc, diag::err_redefinition_of_enumerator) << Id;
15541 Diag(IdLoc, diag::err_redefinition) << Id;
15573 if (!BO->isAdditiveOp())
15581 InitExpr = BO->getLHS();
15603 bool isTombstoneOrEmptyKey;
15604 DupKey(int64_t val,
bool isTombstoneOrEmptyKey)
15605 : val(val), isTombstoneOrEmptyKey(isTombstoneOrEmptyKey) {}
15608 static DupKey GetDupKey(
const llvm::APSInt& Val) {
15609 return DupKey(Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue(),
15613 struct DenseMapInfoDupKey {
15614 static DupKey getEmptyKey() {
return DupKey(0,
true); }
15615 static DupKey getTombstoneKey() {
return DupKey(1,
true); }
15616 static unsigned getHashValue(
const DupKey Key) {
15617 return (
unsigned)(Key.val * 37);
15619 static bool isEqual(
const DupKey& LHS,
const DupKey& RHS) {
15620 return LHS.isTombstoneOrEmptyKey == RHS.isTombstoneOrEmptyKey &&
15621 LHS.val == RHS.val;
15644 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
15645 typedef llvm::DenseMap<DupKey, DeclOrVector, DenseMapInfoDupKey>
15648 DuplicatesVector DupVector;
15649 ValueToVectorMap EnumMap;
15653 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
15666 DeclOrVector &Entry = EnumMap[Key];
15669 if (Entry.isNull())
15674 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
15681 DeclOrVector& Entry = EnumMap[Key];
15682 if (Entry.isNull())
15691 ECDVector *Vec =
new ECDVector();
15693 Vec->push_back(ECD);
15700 DupVector.push_back(Vec);
15704 ECDVector *Vec = Entry.get<ECDVector*>();
15706 if (*Vec->begin() == ECD)
15709 Vec->push_back(ECD);
15713 for (DuplicatesVector::iterator DupVectorIter = DupVector.begin(),
15714 DupVectorEnd = DupVector.end();
15715 DupVectorIter != DupVectorEnd; ++DupVectorIter) {
15716 ECDVector *Vec = *DupVectorIter;
15717 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
15720 ECDVector::iterator
I = Vec->begin();
15721 S.
Diag((*I)->getLocation(), diag::warn_duplicate_enum_values)
15722 << (*I)->getName() << (*I)->getInitVal().toString(10)
15723 << (*I)->getSourceRange();
15728 for (ECDVector::iterator E = Vec->end(); I !=
E; ++
I)
15729 S.
Diag((*I)->getLocation(), diag::note_duplicate_element)
15730 << (*I)->getName() << (*I)->getInitVal().toString(10)
15731 << (*I)->getSourceRange();
15737 bool AllowMask)
const {
15738 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
15741 auto R =
FlagBitsCache.insert(std::make_pair(ED, llvm::APInt()));
15742 llvm::APInt &FlagBits = R.first->second;
15746 const auto &EVal = E->getInitVal();
15748 if (EVal.isPowerOf2())
15749 FlagBits = FlagBits.zextOrSelf(EVal.getBitWidth()) | EVal;
15761 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
15762 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
15769 EnumDecl *Enum = cast<EnumDecl>(EnumDeclX);
15776 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
15778 cast_or_null<EnumConstantDecl>(Elements[i]);
15779 if (!ECD)
continue;
15797 unsigned NumNegativeBits = 0;
15798 unsigned NumPositiveBits = 0;
15801 bool AllElementsInt =
true;
15803 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
15805 cast_or_null<EnumConstantDecl>(Elements[i]);
15806 if (!ECD)
continue;
15808 const llvm::APSInt &InitVal = ECD->
getInitVal();
15811 if (InitVal.isUnsigned() || InitVal.isNonNegative())
15812 NumPositiveBits =
std::max(NumPositiveBits,
15813 (
unsigned)InitVal.getActiveBits());
15815 NumNegativeBits =
std::max(NumNegativeBits,
15816 (
unsigned)InitVal.getMinSignedBits());
15819 if (AllElementsInt)
15825 unsigned BestWidth;
15838 bool Packed = Enum->
hasAttr<PackedAttr>();
15849 BestPromotionType = BestType;
15853 else if (NumNegativeBits) {
15857 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
15859 BestWidth = CharWidth;
15860 }
else if (Packed && NumNegativeBits <= ShortWidth &&
15861 NumPositiveBits < ShortWidth) {
15863 BestWidth = ShortWidth;
15864 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
15866 BestWidth = IntWidth;
15870 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
15875 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
15880 BestPromotionType = (BestWidth <= IntWidth ?
Context.
IntTy : BestType);
15885 if (Packed && NumPositiveBits <= CharWidth) {
15888 BestWidth = CharWidth;
15889 }
else if (Packed && NumPositiveBits <= ShortWidth) {
15892 BestWidth = ShortWidth;
15893 }
else if (NumPositiveBits <= IntWidth) {
15895 BestWidth = IntWidth;
15897 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
15899 }
else if (NumPositiveBits <=
15903 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
15907 assert(NumPositiveBits <= BestWidth &&
15908 "How could an initializer get larger than ULL?");
15911 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
15918 for (
auto *D : Elements) {
15919 auto *ECD = cast_or_null<EnumConstantDecl>(D);
15920 if (!ECD)
continue;
15929 llvm::APSInt InitVal = ECD->getInitVal();
15940 NewWidth = IntWidth;
15942 }
else if (ECD->getType() == BestType) {
15948 ECD->setType(EnumType);
15952 NewWidth = BestWidth;
15957 InitVal = InitVal.extOrTrunc(NewWidth);
15958 InitVal.setIsSigned(NewSign);
15959 ECD->setInitVal(InitVal);
15962 if (ECD->getInitExpr() &&
15966 ECD->getInitExpr(),
15973 ECD->setType(EnumType);
15975 ECD->setType(NewTy);
15979 NumPositiveBits, NumNegativeBits);
15984 for (
Decl *D : Elements) {
15986 if (!ECD)
continue;
15989 if (InitVal != 0 && !InitVal.isPowerOf2() &&
16007 AsmString, StartLoc,
16015 bool FromInclude =
false) {
16018 if (
auto *LSD = dyn_cast<LinkageSpecDecl>(DC)) {
16019 switch (LSD->getLanguage()) {
16022 ExternCLoc = LSD->getLocStart();
16030 while (isa<LinkageSpecDecl>(DC))
16033 if (!isa<TranslationUnitDecl>(DC)) {
16035 ? diag::ext_module_import_not_at_top_level_noop
16036 : diag::err_module_import_not_at_top_level_fatal)
16038 S.
Diag(cast<Decl>(DC)->getLocStart(),
16039 diag::note_module_import_not_at_top_level) << DC;
16041 S.
Diag(ImportLoc, diag::ext_module_import_in_extern_c)
16043 S.
Diag(ExternCLoc, diag::note_extern_c_begins_here);
16065 Diag(ModuleLoc, diag::err_module_interface_implementation_mismatch)
16070 Diag(ModuleLoc, diag::err_module_decl_in_module_map_module);
16080 std::string ModuleName;
16081 for (
auto &Piece : Path) {
16082 if (!ModuleName.empty())
16084 ModuleName += Piece.first->getName();
16093 Diag(Path.front().second, diag::err_current_module_name_mismatch)
16094 <<
SourceRange(Path.front().second, Path.back().second)
16109 if (
auto *M =
Map.findModule(ModuleName)) {
16110 Diag(Path[0].second, diag::err_module_redefinition) << ModuleName;
16111 if (M->DefinitionLoc.isValid())
16112 Diag(M->DefinitionLoc, diag::note_prev_module_definition);
16113 else if (
const auto *FE = M->getASTFile())
16114 Diag(M->DefinitionLoc, diag::note_prev_module_definition_from_ast_file)
16120 Mod =
Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
16121 assert(Mod &&
"module creation should not fail");
16130 std::pair<IdentifierInfo *, SourceLocation> ModuleNameLoc(
16140 ModuleScopes.push_back({});
16141 ModuleScopes.back().Module = Mod;
16142 ModuleScopes.back().OuterVisibleModules = std::move(VisibleModules);
16175 ? diag::err_module_self_import
16176 : diag::err_module_import_in_implementation)
16181 for (
unsigned I = 0, N = Path.size();
I != N; ++
I) {
16186 ModCheck = ModCheck->
Parent;
16188 IdentifierLocs.push_back(Path[
I].second);
16193 Mod, IdentifierLocs);
16194 if (!ModuleScopes.empty())
16211 bool IsInModuleIncludes =
16215 bool ShouldAddImport = !IsInModuleIncludes;
16219 if (ShouldAddImport) {
16224 if (!ModuleScopes.empty())
16231 VisibleModules.
setVisible(Mod, DirectiveLoc);
16237 ModuleScopes.push_back({});
16238 ModuleScopes.back().Module = Mod;
16240 ModuleScopes.back().OuterVisibleModules = std::move(VisibleModules);
16242 VisibleModules.
setVisible(Mod, DirectiveLoc);
16249 cast<Decl>(DC)->setModuleOwnershipKind(
16253 cast<Decl>(DC)->setLocalOwningModule(Mod);
16260 VisibleModules = std::move(ModuleScopes.back().OuterVisibleModules);
16266 assert(!ModuleScopes.empty() && ModuleScopes.back().Module == Mod &&
16267 "left the wrong module scope");
16268 ModuleScopes.pop_back();
16277 "end of submodule in main source file");
16281 DirectiveLoc = EomLoc;
16290 cast<Decl>(DC)->setLocalOwningModule(getCurrentModule());
16291 if (!getCurrentModule())
16292 cast<Decl>(DC)->setModuleOwnershipKind(
16326 if (ModuleScopes.empty() || !ModuleScopes.back().Module ||
16328 Diag(ExportLoc, diag::err_export_not_in_module_interface);
16336 Diag(ExportLoc, diag::err_export_within_export);
16346 auto *ED = cast<ExportDecl>(D);
16348 ED->setRBraceLoc(RBraceLoc);
16364 AsmLabelAttr *
Attr =
16365 AsmLabelAttr::CreateImplicit(
Context, AliasName->
getName(), AliasNameLoc);
16371 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
16375 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
16376 << (isa<FunctionDecl>(PrevDecl) ? 0 : 1) << PrevDecl;
16388 PrevDecl->
addAttr(WeakAttr::CreateImplicit(
Context, PragmaLoc));
16391 std::pair<IdentifierInfo*,WeakInfo>
16405 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
16406 if (!PrevDecl->
hasAttr<AliasAttr>())
16407 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
16411 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W));
16416 return (dyn_cast_or_null<ObjCContainerDecl>(
CurContext));
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
PragmaStack< StringLiteral * > CodeSegStack
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)
void setImplicit(bool I=true)
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.
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
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.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
Scope * getCurScope() const
Retrieve the parser's current scope.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
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.
bool isConstantArrayType() const
Keeps information about an identifier in a nested-name-spec.
bool isObjCContainer() const
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 T * getAsAdjusted() const
Member-template getAsAdjusted<specific type>.
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
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.
SourceLocation getExplicitSpecLoc() const
ExtInfo withCallingConv(CallingConv cc) const
DeclContext * getCurLexicalContext() 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...
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
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 ...
PragmaStack< StringLiteral * > DataSegStack
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.
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
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.
void setAttrs(const AttrVec &Attrs)
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
void CheckCompleteVariableDeclaration(VarDecl *VD)
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
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
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
Stmt - This represents one statement.
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 "...
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
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'.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
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.
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
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
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
void forgetBuiltin(unsigned ID, IdentifierTable &Table)
Completely forget that the given ID was ever considered a builtin, e.g., because the user provided a ...
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)
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)
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
bool hasFlexibleArrayMember() const
void setPreviousDeclaration(FunctionDecl *PrevDecl)
SourceRange getSourceRange() const
bool hasAutoTypeSpec() const
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
bool hasErrorOccurred() const
SCS getStorageClassSpec() const
bool hasDefinition() const
FunctionDefinitionKind getFunctionDefinitionKind() const
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
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.
ExtInfo withNoCallerSavedRegs(bool noCallerSavedRegs) const
bool isInStdNamespace() const
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
const DecompositionDeclarator & getDecompositionDeclarator() 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.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
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()
const NestedNameSpecifier * Specifier
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...
SourceLocation getLocEnd() const LLVM_READONLY
void setInitStyle(InitializationStyle Style)
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLock is not of the desire...
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.
void maybeAddCUDAHostDeviceAttrs(FunctionDecl *FD, const LookupResult &Previous)
May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD, depending on FD and the current co...
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...
void CheckCXXDefaultArguments(FunctionDecl *FD)
CheckCXXDefaultArguments - Verify that the default arguments for a function declaration are well-form...
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
***static FixItHint createFriendTagNNSFixIt(Sema &SemaRef, NamedDecl *ND, Scope *S, SourceLocation NameLoc)
void DiagnoseInvalidJumps(Stmt *Body)
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...
Compiling a C++ modules TS module interface unit.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
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.
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
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
SourceLocation getLSquareLoc() const
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool IsForUsingDecl)
Determine whether the given New declaration is an overload of the declarations in Old...
llvm::SmallPtrSet< const NamedDecl *, 4 > TypoCorrectedFunctionDefinitions
The function definitions which were renamed as part of typo-correction to match their respective decl...
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Extra information about a function prototype.
AccessSpecifier getAccess() 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
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
PragmaClangSection PragmaClangBSSSection
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.
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...
llvm::SmallVector< ShadowedOuterDecl, 4 > ShadowingDecls
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
bool 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...
static const NamedDecl * getDefinition(const Decl *D)
ParmVarDecl - Represents a parameter to a function.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
void setHasBranchProtectedScope()
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...
Information about a template-id annotation token.
UuidAttr * mergeUuidAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex, StringRef Uuid)
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.
void ActOnUninitializedDecl(Decl *dcl)
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
unsigned getNumParams() const
RecordDecl - Represents a struct/union/class.
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted...
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.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
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.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
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.
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S)
Register the given locally-scoped extern "C" declaration so that it can be found later for redeclarat...
static bool isDeclExternC(const Decl *D)
Returns true if given declaration has external C language linkage.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld)
MergeVarDeclTypes - We parsed a variable 'New' which has the same name and scope as a previous declar...
static bool hasDeducedAuto(DeclaratorDecl *DD)
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...
Enumerator value with fixed underlying type.
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).
virtual void HandleInlineFunctionDefinition(FunctionDecl *D)
This callback is invoked each time an inline (method or friend) function definition in a class is com...
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.
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
The results of name lookup within a DeclContext.
ArrayRef< QualType > getParamTypes() const
bool isHeaderDependentFunction(unsigned ID) const
Returns true if this builtin requires appropriate header in other compilers.
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...
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo &ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
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.
bool isInIdentifierNamespace(unsigned NS) const
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
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
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.
The current expression is potentially evaluated at run time, which means that code may be generated t...
bool isAnyPointerType() const
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 isReferenced() const
Whether any declaration of this entity was referenced.
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.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
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
Retrieves the "canonical" declaration of the given declaration.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
This is not an overload because the signature exactly matches an existing declaration.
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.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
static const TST TST_error
Token - This structure provides full information about a lexed token.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
bool isVisible(const Module *M) const
Determine whether a module is visible.
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6...
static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT)
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.
This declaration is definitely a definition.
static const TST TST_enum
The fixed underlying type of an enumeration.
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, bool IsExplicit, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation)
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)
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
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...
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
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.
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Compiling a module from a module map.
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
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...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
RawCommentList & getRawCommentList()
EnumDecl * getStdAlignValT() const
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.
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
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.
void adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly...
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
Represents a C++ unqualified-id that has been parsed.
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.
bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn)
We've just determined that Old and New both appear to be definitions of the same variable.
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...
Decl * ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
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...
bool ActOnDuplicateDefinition(DeclSpec &DS, Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old)
Merge alignment attributes from Old to New, taking into account the special semantics of C11's _Align...
bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
bool exprNeedsCleanups() const
DeclarationNameInfo getNameInfo() const
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
QualType getReturnType() const
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...
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec...
AmbiguityKind getAmbiguityKind() const
bool isDefaulted() const
Whether this function is defaulted per C++0x.
bool CheckConstexprFunctionDecl(const FunctionDecl *FD)
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
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)
A friend of a previously-undeclared entity.
Concrete class used by the front-end to report problems and issues.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
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)
HeaderSearch & getHeaderSearchInfo() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
TypeDecl - Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
void setRedeclaration(bool Val)
void setHasObjectMember(bool val)
An implicit 'self' parameter.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization, bool IsDefinition)
static SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI, const VarDecl *VD)
Return the location of the capture if the given lambda captures the given variable VD...
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
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 UnifySection(StringRef SectionName, int SectionFlags, DeclaratorDecl *TheDecl)
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
bool isVariadic() const
Whether this function is variadic.
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
The parser has processed a module import translated from a #include or similar preprocessing directiv...
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...
The type of a data member.
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
bool isEmptyCudaConstructor(SourceLocation Loc, CXXConstructorDecl *CD)
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
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
enum clang::DeclaratorChunk::@196 Kind
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
bool 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...
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
static bool mergeDeclAttribute(Sema &S, NamedDecl *D, const InheritableAttr *Attr, Sema::AvailabilityMergeKind AMK)
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 isExported() const
Whether this declaration is exported (by virtue of being lexically within an ExportDecl or by being a...
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
void UpdateExprRep(Expr *Rep)
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 isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
bool isExternInLinkageSpec() const
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
void setLocalOwningModule(Module *M)
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)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
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.
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
void revertBuiltin()
Revert the identifier to a non-builtin identifier.
Represents a linkage specification.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
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...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
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...
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
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.
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
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.
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...
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 CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
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.
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...
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
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 FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
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 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.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
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.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
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)
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
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.
bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl)
Checks if the new declaration declared in dependent context must be put in the same redeclaration cha...
SourceLocation getTypeSpecStartLoc() const
std::vector< bool > & Stack
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
Captures information about a #pragma weak directive.
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
bool getNoCallerSavedRegs() const
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
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
unsigned getTypeQualifiers() 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.
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
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location...
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.
void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI)
Diagnose shadowing for variables shadowed in the lambda record LambdaRD when these variables are capt...
static bool ValidDuplicateEnum(EnumConstantDecl *ECD, EnumDecl *Enum)
Represents a C++ destructor within a class.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
TranslationUnitDecl * getTranslationUnitDecl() const
DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc, ModuleDeclKind MDK, ModuleIdPath Path)
The parser has processed a module-declaration that begins the definition of a module interface or imp...
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isObjCGCWeak() const
true when Type is objc's weak.
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
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)
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
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.
Not compiling a module interface at all.
SourceLocation getVolatileSpecLoc() const
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
bool 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.
DeclContext * getDeclContext()
void CheckAlignasUnderalignment(Decl *D)
void PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, const BlockExpr *blkExpr=nullptr)
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
This declaration is a tentative definition.
PragmaStack< StringLiteral * > BSSSegStack
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.
Decl * ActOnFinishExportDecl(Scope *S, Decl *ExportDecl, SourceLocation RBraceLoc)
Complete the definition of an export declaration.
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
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.
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given function template specialization.
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 RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
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 DiscardCleanupsInEvaluationContext()
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 setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
bool isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *CD)
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)
bool isReplaceableGlobalAllocationFunction(bool *IsAligned=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
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
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
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.
SourceLocation getIncludeLoc(FileID FID) const
Returns the include location if FID is a #include'd file otherwise it returns an invalid location...
Direct list-initialization (C++11)
bool isFunctionOrMethod() const
clang::ObjCRuntime ObjCRuntime
InClassInitStyle
In-class initialization styles for non-static data members.
This declaration has an owning module, and is visible when that module is imported.
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.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
bool isExternallyVisible() const
unsigned Map[FirstTargetAddressSpace]
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
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.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal 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...
DiagnosticsEngine & getDiagnostics() const
CXXRecordDecl * getStdBadAlloc() const
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
DeclContext * getContainingDC(DeclContext *DC)
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
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...
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
static StringRef getIdentifier(const Token &Tok)
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 '@'.
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
TypedefNameDecl * getTypedefNameForAnonDecl() const
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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.
This is a legitimate overload: the existing declarations are functions or function templates with dif...
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.
ExprResult ActOnFinishFullExpr(Expr *Expr)
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body)
Check the body for the given constexpr function declaration only contains the permitted types of stat...
bool EvaluateAsInitializer(APValue &Result, const ASTContext &Ctx, const VarDecl *VD, SmallVectorImpl< PartialDiagnosticAt > &Notes) const
EvaluateAsInitializer - Evaluate an expression as if it were the initializer of the given declaration...
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...
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
OpaquePtr< T > get() const
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.
SourceLocation getLocStart() const LLVM_READONLY
UnqualifiedTypeNameLookupResult
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
static bool isIncompleteDeclExternC(Sema &S, const T *D)
Determine whether a variable is extern "C" prior to attaching an initializer.
void AddRangeBasedOptnone(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based o...
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
TypeLoc getInnerLoc() const
void setTypeForDecl(const Type *TD)
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
Wrapper for source info for arrays.
Represents a C++ Modules TS module export declaration.
static unsigned getMSManglingNumber(const LangOptions &LO, Scope *S)
void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID)
DiagnoseDuplicateIvars - Check for duplicate ivars in the entire class at the start of @implementatio...
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...
This declaration has an owning module, but is globally visible (typically because its owning module i...
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)
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
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.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
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.
This is not an overload because the lookup results contain a non-function.
SourceLocation getOuterLocStart() const
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
static bool AllowOverloadingOfFunction(LookupResult &Previous, ASTContext &Context, const FunctionDecl *New)
Determine whether we allow overloading of the function PrevDecl with another declaration.
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 ...
llvm::SmallPtrSet< Expr *, 2 > MaybeODRUseExprs
Store a list of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) ...
Sugar for parentheses used when specifying types.
void setTopLevelDeclInObjCContainer(bool V=true)
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
static ExportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExportLoc)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl * > Bindings)
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
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"...
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle...
CXXRecordDecl * Lambda
The class that describes the lambda.
void setBraceRange(SourceRange R)
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.
A deduction-guide name (a template-name)
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...
SourceLocation getLParenLoc() const
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
void setFreeStanding(bool isFreeStanding=true)
void disableCheckFallThrough()
void ExitDeclaratorContext(Scope *S)
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
TagDecl - Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
ASTContext & getASTContext() const LLVM_READONLY
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
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.
bool getSuppressAllDiagnostics() const
static const TST TST_union
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
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...
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
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...
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
ExprResult DefaultLvalueConversion(Expr *E)
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.
redecl_iterator redecls_end() const
void setEntity(DeclContext *E)
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckForFunctionMarkedFinal - Checks whether a virtual member function overrides a virtual member fun...
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
void demoteThisDefinitionToDeclaration()
This is a definition which should be demoted to a declaration.
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
A friend of a previously-declared entity.
Name lookup found an unresolvable value declaration and cannot yet complete.
void DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init)
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. ...
void push_back(const T &LocalValue)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
SourceLocation PragmaLocation
Describes the kind of initialization being performed, along with location information for tokens rela...
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
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.
SmallVector< Capture, 4 > Captures
Captures - The captures.
bool isReserveIDT() const
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
void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, uint64_t MagicValue, QualType Type, bool LayoutCompatible, bool MustBeNull)
Register a magic integral constant to be used as a type tag.
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>.
Decl * ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, SourceLocation LBraceLoc)
We have parsed the start of an export declaration, including the '{' (if present).
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.
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
bool isFileContext() const
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool ObjCShouldCallSuper
A flag that is set when parsing a method that must call super's implementation, such as -dealloc...
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.
sema::FunctionScopeInfo * getCurFunction() const
bool isStaticMember()
Returns true if this declares a static member.
static ImportDecl * CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc)
Create a new module import declaration for an implicitly-generated import.
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 RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
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)
CUDAFunctionTarget CurrentCUDATarget()
Gets the CUDA target for the current context.
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 unsigned isEnabled(DiagnosticsEngine &D, unsigned diag)
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
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.
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
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
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
NamedDecl * getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R)
Return the declaration shadowed by the given typedef D, or null if it doesn't shadow any declaration ...
CanQualType UnsignedShortTy
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.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
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.
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...
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
TagTypeKind
The kind of a tag type.
bool isEnabled(llvm::StringRef Ext) const
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
TSCS getThreadStorageClassSpec() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword)...
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
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. ...
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl...
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.
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
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body...
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.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
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.
void ProcessPragmaWeak(Scope *S, Decl *D)
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
bool isInvalidDecl() const
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...
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings=None)
TypeLoc IgnoreParens() const
void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod)
The parsed has entered a submodule.
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceAttr::Spelling SemanticSpelling)
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)
A decomposition declaration.
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.
bool hasWrittenPrototype() const
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.
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
void setWillHaveBody(bool V=true)
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)
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Expr * getSizeExpr() const
PragmaClangSection PragmaClangRodataSection
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
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
Returns whether this specific declaration of the function is also a definition that does not contain ...
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.
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
VisibilityAttr * mergeVisibilityAttr(Decl *D, SourceRange Range, VisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
void setInlineSpecified()
detail::InMemoryDirectory::const_iterator E
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
void mergeNRVOIntoParent()
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getModifiedType() const
static bool isTagTypeWithMissingTag(Sema &SemaRef, LookupResult &Result, Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc)
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
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.
IdentifierResolver IdResolver
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)
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
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.
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
This declaration is not owned by a module.
const RecordType * getAsStructureType() const
static std::pair< diag::kind, SourceLocation > getNoteDiagForInvalidRedeclaration(const T *Old, const T *New)
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
All of the names in this module are visible.
known_extensions_range known_extensions() const
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
const VariableArrayType * getAsVariableArrayType(QualType T) const
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
void checkCUDATargetOverload(FunctionDecl *NewFD, const LookupResult &Previous)
Check whether NewFD is a valid overload for CUDA.
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
void setNameLoc(SourceLocation Loc)
void markSafeWeakUse(const Expr *E)
Record that a given expression is a "safe" access of a weak object (e.g.
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...
PragmaClangSection PragmaClangDataSection
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
SourceLocation DefinitionLoc
The location of the module definition.
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.
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
SourceManager & getSourceManager() const
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
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>'.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
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 AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool isRedeclaration() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
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'...
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
Module * getOwningModule() const
Get the module that owns this declaration.
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
bool isClosedFlag() const
Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(ope...
static const TST TST_typename
Expr * getArg(unsigned Arg)
Return the specified argument.
Base for LValueReferenceType and RValueReferenceType.
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...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
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.
DeduceAutoResult DeduceAutoType(TypeSourceInfo *AutoType, Expr *&Initializer, QualType &Result, Optional< unsigned > DependentDeductionDepth=None)
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
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)
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
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...
SmallVector< BlockDecl *, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
DeclResult ActOnModuleImport(SourceLocation AtLoc, SourceLocation ImportLoc, ModuleIdPath Path)
The parser has processed a module import declaration.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
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.
PragmaStack< StringLiteral * > ConstSegStack
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
PragmaClangSection PragmaClangTextSection
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 hasNonTrivialObjCLifetime() const
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
bool isObjCGCStrong() const
true when Type is objc's strong.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
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)
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity, const VarDecl *NRVOCandidate, QualType ResultType, Expr *Value, bool AllowNRVO=true)
Perform the initialization of a potentially-movable value, which is the result of return value...
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.
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
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".
Policy getDefaultPolicy()
bool isExplicitSpecified() const
SourceLocation getIdentifierLoc() const
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization)
Perform semantic checking of a new function declaration.
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or 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)
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
static bool hasIdenticalPassObjectSizeAttrs(const FunctionDecl *A, const FunctionDecl *B)
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
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.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult{return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
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.
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant, according to C++ [class.virtual]p5.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
bool isTypeSpecOwned() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
TranslationUnitKind TUKind
The kind of translation unit we are processing.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U)
Determine whether two function types are the same, ignoring exception specifications in cases where t...
bool 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
Source range that this declaration covers.
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
The translation unit is a complete translation unit.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
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
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
bool isCompilingModule() const
Are we compiling a module interface (.cppm or module map)?
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.
Represents a type template specialization; the template must be a class template, a type alias templa...
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.
virtual bool shouldSkipFunctionBody(Decl *D)
This callback is called for each function if the Parser was initialized with SkipFunctionBodies set t...
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.
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness, issuing any diagnostics required.
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS)
checkUnsafeAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained type...
void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body)
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.
'module implementation X;'
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.
SourceLocation getLocation() const
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
void setLexicalDeclContext(DeclContext *DC)
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
NamedDecl - This represents a decl with a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
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)
void setAccess(AccessSpecifier AS)
Represents a C array with a specified size that is not an integer-constant-expression.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
static bool shouldWarnIfShadowedDecl(const DiagnosticsEngine &Diags, const LookupResult &R)
No keyword precedes the qualified type name.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
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 AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
SourceLocation getLocEnd() const LLVM_READONLY
void SetRangeEnd(SourceLocation Loc)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
NamespaceDecl * getStdNamespace() const
Missing a type from <setjmp.h>
SourceLocation getLocStart() const LLVM_READONLY
void setType(QualType newType)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
Wrapper for source info for pointers.
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)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions, such as the default constructor, copy constructor, or destructor, to the given C++ class (C++ [special]p1).
static bool isAttributeTargetADefinition(Decl *D)
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.
This class handles loading and caching of source files into memory.
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, unsigned AttrSpellingListIndex)
Attribute merging methods. Return true if a new attribute was added.
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.
CUDADiagBuilder CUDADiagIfDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a CUDADiagBuilder that emits the diagnostic if the current context is "used as device code"...
void PushFunctionScope()
Enter a new function scope.
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.
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void AddCFAuditedAttribute(Decl *D)
AddCFAuditedAttribute - Check whether we're currently within '#pragma clang arc_cf_code_audited' and...
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 field is ...
ObjCCompatibleAliasDecl - Represents alias of a class.
Helper class that creates diagnostics with optional template instantiation stacks.
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.
This is a C++ Modules TS module interface unit.
CanQualType UnsignedIntTy
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
virtual void HandleTagDeclDefinition(TagDecl *D)
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
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)
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++1z deduced class template specialization type.
The translation unit is a module.
SourceLocation CurInitSegLoc
const AttributeList * getAttributes() const
SourceLocation getTemplateLoc() const
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.