58#include "llvm/ADT/STLForwardCompat.h"
59#include "llvm/ADT/SmallString.h"
60#include "llvm/ADT/StringExtras.h"
61#include "llvm/TargetParser/Triple.h"
65#include <unordered_map>
72 Decl *Group[2] = { OwnedType, Ptr };
83 TypeNameValidatorCCC(
bool AllowInvalid,
bool WantClass =
false,
84 bool AllowTemplates =
false,
85 bool AllowNonTemplates =
true)
86 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
87 AllowTemplates(AllowTemplates), AllowNonTemplates(AllowNonTemplates) {
88 WantExpressionKeywords =
false;
89 WantCXXNamedCasts =
false;
90 WantRemainingKeywords =
false;
95 if (!AllowInvalidDecl && ND->isInvalidDecl())
99 return AllowTemplates;
101 bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
105 if (AllowNonTemplates)
110 if (AllowTemplates) {
111 auto *RD = dyn_cast<CXXRecordDecl>(ND);
112 if (!RD || !RD->isInjectedClassName())
114 RD = cast<CXXRecordDecl>(RD->getDeclContext());
115 return RD->getDescribedClassTemplate() ||
116 isa<ClassTemplateSpecializationDecl>(RD);
122 return !WantClassName && candidate.
isKeyword();
125 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
126 return std::make_unique<TypeNameValidatorCCC>(*
this);
130 bool AllowInvalidDecl;
133 bool AllowNonTemplates;
139enum class UnqualifiedTypeNameLookupResult {
150static UnqualifiedTypeNameLookupResult
155 return UnqualifiedTypeNameLookupResult::NotFound;
157 UnqualifiedTypeNameLookupResult FoundTypeDecl =
158 UnqualifiedTypeNameLookupResult::NotFound;
161 if (
auto *BaseTT =
Base.getType()->getAs<
TagType>())
162 BaseRD = BaseTT->getAsCXXRecordDecl();
166 if (!TST || !TST->isDependentType())
168 auto *TD = TST->getTemplateName().getAsTemplateDecl();
171 if (
auto *BasePrimaryTemplate =
172 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
174 BaseRD = BasePrimaryTemplate;
175 else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
177 CTD->findPartialSpecialization(
Base.getType()))
185 if (!isa<TypeDecl>(ND))
186 return UnqualifiedTypeNameLookupResult::FoundNonType;
187 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
189 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
191 case UnqualifiedTypeNameLookupResult::FoundNonType:
192 return UnqualifiedTypeNameLookupResult::FoundNonType;
193 case UnqualifiedTypeNameLookupResult::FoundType:
194 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
196 case UnqualifiedTypeNameLookupResult::NotFound:
203 return FoundTypeDecl;
211 UnqualifiedTypeNameLookupResult FoundTypeDecl =
212 UnqualifiedTypeNameLookupResult::NotFound;
214 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
218 RD = dyn_cast<CXXRecordDecl>(DC);
222 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
228 S.
Diag(NameLoc, diag::ext_found_in_dependent_base) << &II;
250 bool WantNontrivialTypeSourceInfo =
true) {
252 case Type::DeducedTemplateSpecialization:
254 case Type::InjectedClassName:
257 case Type::UnresolvedUsing:
262 case Type::ObjCInterface:
263 case Type::ObjCTypeParam:
264 case Type::TemplateTypeParm:
267 llvm_unreachable(
"Unexpected Type Class");
275 if (!WantNontrivialTypeSourceInfo)
279 Builder.pushTypeSpec(
T).setNameLoc(NameLoc);
288 bool HasTrailingDot,
ParsedType ObjectTypePtr,
289 bool IsCtorOrDtorName,
290 bool WantNontrivialTypeSourceInfo,
291 bool IsClassTemplateDeductionContext,
295 bool AllowDeducedTemplate = IsClassTemplateDeductionContext &&
297 !isClassName && !HasTrailingDot;
322 !isClassName && !IsCtorOrDtorName)
324 bool IsImplicitTypename = !isClassName && !IsCtorOrDtorName;
325 if (IsImplicitTypename) {
328 Diag(QualifiedLoc, diag::warn_cxx17_compat_implicit_typename);
330 Diag(QualifiedLoc, diag::ext_implicit_typename)
337 if (WantNontrivialTypeSourceInfo)
373 if (ObjectTypePtr &&
Result.empty()) {
397 switch (
Result.getResultKind()) {
400 TypeNameValidatorCCC CCC(
true, isClassName,
401 AllowDeducedTemplate);
406 bool MemberOfUnknownSpecialization;
415 if (Correction && (NNS || NewII != &II) &&
421 Template, MemberOfUnknownSpecialization))) {
423 isClassName, HasTrailingDot, ObjectTypePtr,
425 WantNontrivialTypeSourceInfo,
426 IsClassTemplateDeductionContext);
429 PDiag(diag::err_unknown_type_or_class_name_suggest)
430 <<
Result.getLookupName() << isClassName);
433 *CorrectedII = NewII;
438 Result.suppressDiagnostics();
454 Result.suppressDiagnostics();
464 Result.suppressDiagnostics();
470 Res != ResEnd; ++Res) {
472 if (isa<TypeDecl, ObjCInterfaceDecl, UnresolvedUsingIfExistsDecl>(
479 FoundUsingShadow = dyn_cast<UsingShadowDecl>(*Res);
491 Result.suppressDiagnostics();
502 IIDecl =
Result.getFoundDecl();
503 FoundUsingShadow = dyn_cast<UsingShadowDecl>(*
Result.begin());
507 assert(IIDecl &&
"Didn't find decl");
510 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
514 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
515 auto *FoundRD = dyn_cast<CXXRecordDecl>(TD);
516 if (!isClassName && !IsCtorOrDtorName && LookupRD && FoundRD &&
517 FoundRD->isInjectedClassName() &&
519 Diag(NameLoc, diag::err_out_of_line_qualified_id_type_names_constructor)
530 FoundUsingShadow =
nullptr;
531 }
else if (
auto *UD = dyn_cast<UnresolvedUsingIfExistsDecl>(IIDecl)) {
535 }
else if (AllowDeducedTemplate) {
537 assert(!FoundUsingShadow || FoundUsingShadow->
getTargetDecl() == TD);
544 FoundUsingShadow =
nullptr;
550 Result.suppressDiagnostics();
554 if (FoundUsingShadow)
557 return buildNamedType(*
this, SS,
T, NameLoc, WantNontrivialTypeSourceInfo);
565 auto *ND = dyn_cast<NamespaceDecl>(DC);
566 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
568 else if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
570 RD->getTypeForDecl());
571 else if (isa<TranslationUnitDecl>(DC))
574 llvm_unreachable(
"something isn't in TU scope?");
585 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
586 if (MD->getParent()->hasAnyDependentBases())
594 bool IsTemplateTypeArg) {
595 assert(
getLangOpts().MSVCCompat &&
"shouldn't be called in non-MSVC mode");
598 if (IsTemplateTypeArg &&
getCurScope()->isTemplateParamScope()) {
607 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
613 RD->getTypeForDecl());
617 Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
648 switch (TD->getTagKind()) {
676 return S->isFunctionPrototypeScope();
686 bool IsTemplateName) {
691 SuggestedType =
nullptr;
695 TypeNameValidatorCCC CCC(
false,
false,
702 bool CanRecover = !IsTemplateName;
703 if (Corrected.isKeyword()) {
706 PDiag(IsTemplateName ? diag::err_no_template_suggest
707 : diag::err_unknown_typename_suggest)
709 II = Corrected.getCorrectionAsIdentifierInfo();
712 if (!SS || !SS->
isSet()) {
714 PDiag(IsTemplateName ? diag::err_no_template_suggest
715 : diag::err_unknown_typename_suggest)
718 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
719 bool DroppedSpecifier =
720 Corrected.WillReplaceSpecifier() && II->
getName() == CorrectedStr;
723 ? diag::err_no_member_template_suggest
724 : diag::err_unknown_nested_typename_suggest)
725 << II << DC << DroppedSpecifier << SS->
getRange(),
728 llvm_unreachable(
"could not have corrected a typo here");
735 if (Corrected.getCorrectionSpecifier())
740 getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc, S,
741 tmpSS.
isSet() ? &tmpSS : SS,
false,
false,
nullptr,
751 Name.setIdentifier(II, IILoc);
754 bool MemberOfUnknownSpecialization;
756 Name,
nullptr,
true, TemplateResult,
767 Diag(IILoc, IsTemplateName ? diag::err_no_template
768 : diag::err_unknown_typename)
771 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
772 : diag::err_typename_nested_not_found)
778 unsigned DiagID = diag::err_typename_missing;
780 DiagID = diag::ext_typename_missing;
787 *SS, *II, IILoc).
get();
790 "Invalid scope specifier has already been diagnosed");
798 NextToken.
is(tok::less);
801 if (isa<TypeDecl>(*I) || isa<ObjCInterfaceDecl>(*I))
804 if (CheckTemplate && isa<TemplateDecl>(*I))
818 StringRef FixItTagName;
819 switch (Tag->getTagKind()) {
821 FixItTagName =
"class ";
825 FixItTagName =
"enum ";
829 FixItTagName =
"struct ";
833 FixItTagName =
"__interface ";
837 FixItTagName =
"union ";
841 StringRef TagName = FixItTagName.drop_back();
842 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
843 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
848 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
863 const Token &NextToken,
868 assert(NextToken.
isNot(tok::coloncolon) &&
869 "parse nested name specifiers before calling ClassifyName");
910 bool SecondTry =
false;
911 bool IsFilteredTemplateName =
false;
914 switch (
Result.getResultKind()) {
918 if (SS.
isEmpty() && NextToken.
is(tok::l_paren)) {
964 if (!SecondTry && CCC) {
969 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
970 unsigned QualifiedDiag = diag::err_no_member_suggest;
973 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
975 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
976 UnqualifiedDiag = diag::err_no_template_suggest;
977 QualifiedDiag = diag::err_no_member_template_suggest;
978 }
else if (UnderlyingFirstDecl &&
979 (isa<TypeDecl>(UnderlyingFirstDecl) ||
980 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
981 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
982 UnqualifiedDiag = diag::err_unknown_typename_suggest;
983 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
989 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
990 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
991 Name->getName() == CorrectedStr;
994 << DroppedSpecifier << SS.
getRange());
998 Name = Corrected.getCorrectionAsIdentifierInfo();
1001 if (Corrected.isKeyword())
1007 Result.setLookupName(Corrected.getCorrection());
1029 Result.suppressDiagnostics();
1071 if (!
Result.isAmbiguous()) {
1072 IsFilteredTemplateName =
true;
1082 (IsFilteredTemplateName ||
1098 if (!IsFilteredTemplateName)
1101 bool IsFunctionTemplate;
1105 IsFunctionTemplate =
true;
1108 }
else if (!
Result.empty()) {
1112 IsFunctionTemplate = isa<FunctionTemplateDecl>(TD);
1113 IsVarTemplate = isa<VarTemplateDecl>(TD);
1116 dyn_cast<UsingShadowDecl>(*
Result.begin());
1117 assert(!FoundUsingShadow ||
1118 TD == cast<TemplateDecl>(FoundUsingShadow->
getTargetDecl()));
1126 IsFunctionTemplate =
true;
1130 if (IsFunctionTemplate) {
1134 Result.suppressDiagnostics();
1145 if (
const auto *USD = dyn_cast<UsingShadowDecl>(
Found))
1161 dyn_cast<ObjCCompatibleAliasDecl>(
FirstDecl))
1162 Class = Alias->getClassInterface();
1168 if (NextToken.
is(tok::period)) {
1171 Result.suppressDiagnostics();
1181 if (
auto *USD = dyn_cast<UsingShadowDecl>(
Result.getRepresentativeDecl()))
1187 if (
auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(
FirstDecl)) {
1200 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1201 if ((NextToken.
is(tok::identifier) ||
1203 FirstDecl->getUnderlyingDecl()->isFunctionOrFunctionTemplate())) &&
1215 if (
Result.isSingleResult() && !ADL &&
1220 Result.suppressDiagnostics();
1240 bool IsAddressOfOperand) {
1243 NameInfo, IsAddressOfOperand,
1250 const Token &NextToken) {
1252 if (
auto *Ivar = dyn_cast<ObjCIvarDecl>(
Found->getUnderlyingDecl()))
1267 auto *ULE = cast<UnresolvedLookupExpr>(
E);
1268 if ((*ULE->decls_begin())->isCXXClassMember()) {
1270 SS.
Adopt(ULE->getQualifierLoc());
1275 Result.setNamingClass(ULE->getNamingClass());
1276 for (
auto I = ULE->decls_begin(),
E = ULE->decls_end(); I !=
E; ++I)
1277 Result.addDecl(*I, I.getAccess());
1290 auto *TD = Name.getAsTemplateDecl();
1293 if (isa<ClassTemplateDecl>(TD))
1295 if (isa<FunctionTemplateDecl>(TD))
1297 if (isa<VarTemplateDecl>(TD))
1299 if (isa<TypeAliasTemplateDecl>(TD))
1301 if (isa<TemplateTemplateParmDecl>(TD))
1303 if (isa<ConceptDecl>(TD))
1310 "The next DeclContext should be lexically contained in the current one.");
1316 assert(
CurContext &&
"DeclContext imbalance!");
1319 assert(
CurContext &&
"Popped translation unit!");
1329 assert(
CurContext &&
"skipping definition of undefined tag");
1357 assert(!S->getEntity() &&
"scope already has entity");
1360 Scope *Ancestor = S->getParent();
1368 if (S->getParent()->isTemplateParamScope()) {
1376 assert(S->getEntity() ==
CurContext &&
"Context imbalance!");
1380 Scope *Ancestor = S->getParent();
1389 assert(S->isTemplateParamScope() &&
1390 "expected to be initializing a template parameter scope");
1414 for (; S && S->isTemplateParamScope(); S = S->getParent(), --ScopeDepth) {
1418 cast<Decl>(DC)->getDescribedTemplateParams()) {
1419 unsigned DCDepth = TPL->getDepth() + 1;
1420 if (DCDepth > ScopeDepth)
1422 if (ScopeDepth == DCDepth)
1427 S->setLookupEntity(SearchDCAfterScope);
1441 "The next DeclContext should be lexically contained in the current one.");
1445 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1458 assert(
CurContext &&
"DeclContext imbalance!");
1460 assert(
CurContext &&
"Popped translation unit!");
1489 return ND->
hasAttr<OverloadableAttr>();
1492 return Previous.getFoundDecl()->hasAttr<OverloadableAttr>();
1501 while (S->getEntity() && S->getEntity()->isTransparentContext())
1516 if (isa<FunctionDecl>(
D) &&
1517 cast<FunctionDecl>(
D)->isFunctionTemplateSpecialization())
1520 if (isa<UsingEnumDecl>(
D) &&
D->getDeclName().isEmpty()) {
1527 for (; I != IEnd; ++I) {
1528 if (S->isDeclScope(*I) &&
D->declarationReplaces(*I)) {
1539 if (isa<LabelDecl>(
D) && !cast<LabelDecl>(
D)->isGnuLocal()) {
1546 if (!S->isDeclScope(*I))
1560 bool AllowInlineNamespace)
const {
1568 if (ScopeDC->getPrimaryContext() == TargetDC)
1570 }
while ((S = S->getParent()));
1580 bool ConsiderLinkage,
1581 bool AllowInlineNamespace) {
1639 if (NewIsModuleInterface || OldIsModuleInterface) {
1645 << NewIsModuleInterface
1647 << OldIsModuleInterface
1675 if (!IsNewExported && !IsOldExported)
1690 assert(IsNewExported);
1698 Diag(New->
getLocation(), diag::err_redeclaration_non_exported) << New << S;
1716 "New and Old are not the same definition, we should diagnostic it "
1717 "immediately instead of checking it.");
1720 "We shouldn't see unreachable definitions here.");
1768 return OldM == NewM;
1775 return isa<UsingShadowDecl>(
D) ||
1776 isa<UnresolvedUsingTypenameDecl>(
D) ||
1777 isa<UnresolvedUsingValueDecl>(
D);
1801 if (
D->doesThisDeclarationHaveABody())
1805 return CD->isCopyConstructor();
1806 return D->isCopyAssignmentOperator();
1812 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1813 if (!RD->hasNameForLinkage())
1819 return !
D->isExternallyVisible();
1848 FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
1851 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1856 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1860 if (FD->doesThisDeclarationHaveABody() &&
1863 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(
D)) {
1873 if (VD->isStaticDataMember() &&
1876 if (VD->isStaticDataMember() &&
1878 VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
1881 if (VD->isInline() && !
isMainFileLoc(*
this, VD->getLocation()))
1890 return mightHaveNonExternalLinkage(
D);
1903 if (
const VarDecl *VD = dyn_cast<VarDecl>(
D)) {
1918 if (
const auto *DD = dyn_cast<DecompositionDecl>(
D)) {
1922 bool IsAllPlaceholders =
true;
1923 for (
const auto *BD : DD->bindings()) {
1924 if (BD->isReferenced() || BD->hasAttr<UnusedAttr>())
1926 IsAllPlaceholders = IsAllPlaceholders && BD->isPlaceholderVar(LangOpts);
1928 if (IsAllPlaceholders)
1930 }
else if (!
D->getDeclName()) {
1936 if (
D->isPlaceholderVar(LangOpts))
1943 if (isa<LabelDecl>(
D))
1952 WithinFunction || (R->isLocalClass() && !R->isDependentType());
1953 if (!WithinFunction)
1956 if (isa<TypedefNameDecl>(
D))
1960 if (!isa<VarDecl>(
D) || isa<ParmVarDecl>(
D) || isa<ImplicitParamDecl>(
D))
1964 if (
const VarDecl *VD = dyn_cast<VarDecl>(
D)) {
1967 if (
const auto *Cleanups = dyn_cast_if_present<ExprWithCleanups>(
Init))
1968 Init = Cleanups->getSubExpr();
1970 const auto *Ty = VD->getType().getTypePtr();
1975 if (TT->getDecl()->hasAttr<UnusedAttr>())
1981 if (
const auto *MTE = dyn_cast_if_present<MaterializeTemporaryExpr>(
Init);
1982 MTE && MTE->getExtendingDecl()) {
1983 Ty = VD->getType().getNonReferenceType().getTypePtr();
1984 Init = MTE->getSubExpr()->IgnoreImplicitAsWritten();
1989 if (Ty->isIncompleteType() || Ty->isDependentType())
1994 Ty = Ty->getBaseElementTypeUnsafe();
1997 const TagDecl *Tag = TT->getDecl();
1998 if (Tag->hasAttr<UnusedAttr>())
2001 if (
const auto *RD = dyn_cast<CXXRecordDecl>(Tag)) {
2002 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
2006 const auto *Construct =
2007 dyn_cast<CXXConstructExpr>(
Init->IgnoreImpCasts());
2008 if (Construct && !Construct->isElidable()) {
2010 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
2011 (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
2017 if (
Init->isTypeDependent()) {
2019 if (!Ctor->isTrivial())
2025 if (isa<CXXUnresolvedConstructExpr>(
Init))
2039 if (isa<LabelDecl>(
D)) {
2057 if (
D->getTypeForDecl()->isDependentType())
2060 for (
auto *TmpD :
D->decls()) {
2061 if (
const auto *
T = dyn_cast<TypedefNameDecl>(TmpD))
2063 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
2077 if (
auto *TD = dyn_cast<TypedefNameDecl>(
D)) {
2088 if (isa<VarDecl>(
D) && cast<VarDecl>(
D)->isExceptionVariable())
2089 DiagID = diag::warn_unused_exception_param;
2090 else if (isa<LabelDecl>(
D))
2091 DiagID = diag::warn_unused_label;
2093 DiagID = diag::warn_unused_variable;
2112 if (Ty->isReferenceType() || Ty->isDependentType())
2116 const TagDecl *Tag = TT->getDecl();
2117 if (Tag->hasAttr<UnusedAttr>())
2121 if (
const auto *RD = dyn_cast<CXXRecordDecl>(Tag);
2122 RD && !RD->hasAttr<WarnUnusedAttr>())
2129 if (VD->
hasAttr<BlocksAttr>() && Ty->isObjCObjectPointerType())
2135 if (VD->
hasAttr<ObjCPreciseLifetimeAttr>() && Ty->isObjCObjectPointerType())
2142 assert(iter->getSecond() >= 0 &&
2143 "Found a negative number of references to a VarDecl");
2144 if (
int RefCnt = iter->getSecond(); RefCnt > 0) {
2154 bool UnusedCXXCondDecl = VD->
isCXXCondDecl() && (RefCnt == 1);
2155 if (!UnusedCXXCondDecl)
2159 unsigned DiagID = isa<ParmVarDecl>(VD) ? diag::warn_unused_but_set_parameter
2160 : diag::warn_unused_but_set_variable;
2170 bool Diagnose =
false;
2174 Diagnose = L->
getStmt() ==
nullptr;
2183 if (S->decl_empty())
return;
2185 "Scope shouldn't contain decls!");
2192 std::optional<SourceLocation> PreviousDeclLoc;
2197 DeclDiags.push_back(LocAndDiag{
Loc, std::nullopt, std::move(PD)});
2202 DeclDiags.push_back(LocAndDiag{
Loc, PreviousDeclLoc, std::move(PD)});
2205 for (
auto *TmpD : S->decls()) {
2206 assert(TmpD &&
"This decl didn't get pushed??");
2208 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
2212 if (!S->hasUnrecoverableErrorOccurred()) {
2214 if (
const auto *RD = dyn_cast<RecordDecl>(
D))
2216 if (
VarDecl *VD = dyn_cast<VarDecl>(
D)) {
2222 if (!
D->getDeclName())
continue;
2236 auto ShadowI = ShadowingDecls.find(
D);
2237 if (ShadowI != ShadowingDecls.end()) {
2238 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
2240 PDiag(diag::warn_ctor_parm_shadows_field)
2241 <<
D << FD << FD->getParent());
2243 ShadowingDecls.erase(ShadowI);
2247 llvm::sort(DeclDiags,
2248 [](
const LocAndDiag &LHS,
const LocAndDiag &RHS) ->
bool {
2253 return LHS.Loc.getRawEncoding() < RHS.Loc.getRawEncoding();
2255 for (
const LocAndDiag &
D : DeclDiags) {
2257 if (
D.PreviousDeclLoc)
2258 Diag(*
D.PreviousDeclLoc, diag::note_previous_declaration);
2264 (S->getEntity() && S->getEntity()->isTransparentContext()) ||
2282 return "ucontext.h";
2284 llvm_unreachable(
"unhandled error kind");
2295 Parent->addDecl(CLinkageDecl);
2302 "consteval builtins should only be available in C++20 mode");
2317 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2320 FT->getParamType(i),
nullptr,
SC_None,
nullptr);
2322 Params.push_back(parm);
2324 New->setParams(Params);
2332 Scope *S,
bool ForRedeclaration,
2339 if (!ForRedeclaration)
2351 Diag(
Loc, diag::warn_implicit_decl_no_jmp_buf)
2358 Diag(
Loc, diag::warn_implicit_decl_requires_sysheader)
2364 if (!ForRedeclaration &&
2368 : diag::ext_implicit_lib_function_decl)
2371 Diag(
Loc, diag::note_include_header_or_declare)
2408 while (Filter.hasNext()) {
2417 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2419 Decl->getUnderlyingType()))
2424 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2425 Decl->getAnonDeclWithTypedefName())
2437 if (
const TypedefNameDecl *OldTypedef = dyn_cast<TypedefNameDecl>(Old))
2438 OldType = OldTypedef->getUnderlyingType();
2445 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2446 Diag(New->
getLocation(), diag::err_redefinition_variably_modified_typedef)
2454 if (OldType != NewType &&
2458 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2460 << Kind << NewType << OldType;
2479 switch (TypeID->getLength()) {
2483 if (!TypeID->isStr(
"id"))
2499 if (!TypeID->isStr(
"Class"))
2506 if (!TypeID->isStr(
"SEL"))
2533 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2534 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2538 OldTag->getCanonicalDecl() !=
NewTag->getCanonicalDecl() &&
2543 if (OldTD->isModed())
2545 OldTD->getUnderlyingType());
2554 if (isa<EnumDecl>(
NewTag)) {
2556 for (
auto *
D :
NewTag->decls()) {
2557 auto *ED = cast<EnumConstantDecl>(
D);
2561 ED->getLexicalDeclContext()->removeDecl(ED);
2611 if (!isa<TypedefNameDecl>(Old))
2643 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2644 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2645 for (
const auto *i :
D->
attrs())
2646 if (i->getKind() == A->
getKind()) {
2648 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2653 if (OA && isa<OwnershipAttr>(i))
2654 return OA->getOwnKind() == cast<OwnershipAttr>(i)->getOwnKind();
2662 if (
VarDecl *VD = dyn_cast<VarDecl>(
D))
2663 return VD->isThisDeclarationADefinition();
2664 if (
TagDecl *TD = dyn_cast<TagDecl>(
D))
2665 return TD->isCompleteDefinition() || TD->isBeingDefined();
2676 AlignedAttr *OldAlignasAttr =
nullptr;
2677 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2678 unsigned OldAlign = 0;
2686 if (I->isAlignmentDependent())
2692 unsigned Align = I->getAlignment(S.
Context);
2693 if (Align > OldAlign) {
2695 OldStrictestAlignAttr = I;
2700 AlignedAttr *NewAlignasAttr =
nullptr;
2701 unsigned NewAlign = 0;
2703 if (I->isAlignmentDependent())
2709 unsigned Align = I->getAlignment(S.
Context);
2710 if (Align > NewAlign)
2714 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2722 if (OldAlign == 0 || NewAlign == 0) {
2724 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2735 if (OldAlign != NewAlign) {
2736 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2739 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2754 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2758 bool AnyAdded =
false;
2761 if (OldAlign > NewAlign) {
2762 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2763 Clone->setInherited(
true);
2769 if (OldAlignasAttr && !NewAlignasAttr &&
2770 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2771 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2772 Clone->setInherited(
true);
2780#define WANT_DECL_MERGE_LOGIC
2781#include "clang/Sema/AttrParsedAttrImpl.inc"
2782#undef WANT_DECL_MERGE_LOGIC
2789 if (!DiagnoseMutualExclusions(S,
D,
Attr))
2800 if (
const auto *AA = dyn_cast<AvailabilityAttr>(
Attr))
2802 D, *AA, AA->getPlatform(), AA->
isImplicit(), AA->getIntroduced(),
2803 AA->getDeprecated(), AA->getObsoleted(), AA->getUnavailable(),
2804 AA->getMessage(), AA->getStrict(), AA->getReplacement(), AMK,
2805 AA->getPriority(), AA->getEnvironment());
2806 else if (
const auto *VA = dyn_cast<VisibilityAttr>(
Attr))
2808 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(
Attr))
2810 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(
Attr))
2812 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(
Attr))
2814 else if (
const auto *EA = dyn_cast<ErrorAttr>(
Attr))
2816 else if (
const auto *FA = dyn_cast<FormatAttr>(
Attr))
2819 else if (
const auto *SA = dyn_cast<SectionAttr>(
Attr))
2821 else if (
const auto *CSA = dyn_cast<CodeSegAttr>(
Attr))
2823 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(
Attr))
2825 IA->getInheritanceModel());
2826 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(
Attr))
2829 else if (S.
getLangOpts().CUDA && isa<FunctionDecl>(
D) &&
2830 (isa<CUDAHostAttr>(
Attr) || isa<CUDADeviceAttr>(
Attr) ||
2831 isa<CUDAGlobalAttr>(
Attr))) {
2835 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(
Attr))
2837 else if (
const auto *SNA = dyn_cast<SwiftNameAttr>(
Attr))
2839 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(
Attr))
2841 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(
Attr))
2843 else if (isa<AlignedAttr>(
Attr))
2847 else if ((isa<DeprecatedAttr>(
Attr) || isa<UnavailableAttr>(
Attr)) &&
2852 else if (
const auto *UA = dyn_cast<UuidAttr>(
Attr))
2853 NewAttr = S.
mergeUuidAttr(
D, *UA, UA->getGuid(), UA->getGuidDecl());
2854 else if (
const auto *IMA = dyn_cast<WebAssemblyImportModuleAttr>(
Attr))
2856 else if (
const auto *INA = dyn_cast<WebAssemblyImportNameAttr>(
Attr))
2858 else if (
const auto *TCBA = dyn_cast<EnforceTCBAttr>(
Attr))
2860 else if (
const auto *TCBLA = dyn_cast<EnforceTCBLeafAttr>(
Attr))
2862 else if (
const auto *BTFA = dyn_cast<BTFDeclTagAttr>(
Attr))
2864 else if (
const auto *NT = dyn_cast<HLSLNumThreadsAttr>(
Attr))
2867 else if (
const auto *WS = dyn_cast<HLSLWaveSizeAttr>(
Attr))
2870 WS->getSpelledArgsCount());
2871 else if (
const auto *SA = dyn_cast<HLSLShaderAttr>(
Attr))
2873 else if (isa<SuppressAttr>(
Attr))
2882 if (isa<MSInheritanceAttr>(NewAttr))
2891 if (
const TagDecl *TD = dyn_cast<TagDecl>(
D))
2892 return TD->getDefinition();
2893 if (
const VarDecl *VD = dyn_cast<VarDecl>(
D)) {
2901 if (FD->isDefined(Def,
true))
2908 for (
const auto *Attribute :
D->
attrs())
2909 if (Attribute->getKind() == Kind)
2921 if (!Def || Def == New)
2925 for (
unsigned I = 0,
E = NewAttributes.size(); I !=
E;) {
2926 const Attr *NewAttribute = NewAttributes[I];
2928 if (isa<AliasAttr>(NewAttribute) || isa<IFuncAttr>(NewAttribute)) {
2935 NewAttributes.erase(NewAttributes.begin() + I);
2940 VarDecl *VD = cast<VarDecl>(New);
2941 unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
2943 ? diag::err_alias_after_tentative
2944 : diag::err_redefinition;
2946 if (
Diag == diag::err_redefinition)
2956 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
2969 if (isa<C11NoReturnAttr>(NewAttribute)) {
2973 }
else if (isa<UuidAttr>(NewAttribute)) {
2977 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
2978 if (AA->isAlignas()) {
2989 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
2991 NewAttributes.erase(NewAttributes.begin() + I);
2995 }
else if (isa<LoaderUninitializedAttr>(NewAttribute)) {
3001 diag::err_loader_uninitialized_redeclaration);
3003 NewAttributes.erase(NewAttributes.begin() + I);
3007 }
else if (isa<SelectAnyAttr>(NewAttribute) &&
3008 cast<VarDecl>(New)->isInline() &&
3009 !cast<VarDecl>(New)->isInlineSpecified()) {
3016 }
else if (isa<OMPDeclareVariantAttr>(NewAttribute)) {
3024 diag::warn_attribute_precede_definition);
3026 NewAttributes.erase(NewAttributes.begin() + I);
3032 const ConstInitAttr *CIAttr,
3033 bool AttrBeforeInit) {
3040 std::string SuitableSpelling;
3042 SuitableSpelling = std::string(
3044 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
3046 InsertLoc, {tok::l_square, tok::l_square,
3047 S.PP.getIdentifierInfo(
"clang"), tok::coloncolon,
3048 S.PP.getIdentifierInfo(
"require_constant_initialization"),
3049 tok::r_square, tok::r_square}));
3050 if (SuitableSpelling.empty())
3052 InsertLoc, {tok::kw___attribute, tok::l_paren, tok::r_paren,
3053 S.PP.getIdentifierInfo(
"require_constant_initialization"),
3054 tok::r_paren, tok::r_paren}));
3055 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus20)
3056 SuitableSpelling =
"constinit";
3057 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
3058 SuitableSpelling =
"[[clang::require_constant_initialization]]";
3059 if (SuitableSpelling.empty())
3060 SuitableSpelling =
"__attribute__((require_constant_initialization))";
3061 SuitableSpelling +=
" ";
3063 if (AttrBeforeInit) {
3066 assert(CIAttr->isConstinit() &&
"should not diagnose this for attribute");
3069 S.
Diag(CIAttr->getLocation(), diag::note_constinit_specified_here);
3073 S.
Diag(CIAttr->getLocation(),
3074 CIAttr->isConstinit() ? diag::err_constinit_added_too_late
3075 : diag::warn_require_const_init_added_too_late)
3078 << CIAttr->isConstinit()
3086 UsedAttr *NewAttr = OldAttr->clone(
Context);
3087 NewAttr->setInherited(
true);
3091 RetainAttr *NewAttr = OldAttr->clone(
Context);
3092 NewAttr->setInherited(
true);
3102 const auto *OldConstInit = Old->
getAttr<ConstInitAttr>();
3103 const auto *NewConstInit = New->
getAttr<ConstInitAttr>();
3104 if (
bool(OldConstInit) !=
bool(NewConstInit)) {
3105 const auto *OldVD = cast<VarDecl>(Old);
3106 auto *NewVD = cast<VarDecl>(New);
3112 (NewVD->hasInit() || NewVD->isThisDeclarationADefinition()))
3115 if (InitDecl == NewVD) {
3119 if (OldConstInit && OldConstInit->isConstinit())
3122 }
else if (NewConstInit) {
3126 if (InitDecl && InitDecl != NewVD) {
3129 NewVD->dropAttr<ConstInitAttr>();
3137 if (AsmLabelAttr *NewA = New->
getAttr<AsmLabelAttr>()) {
3138 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
3139 if (!OldA->isEquivalent(NewA)) {
3142 Diag(OldA->getLocation(), diag::note_previous_declaration);
3144 }
else if (Old->
isUsed()) {
3148 << isa<FunctionDecl>(Old) << New->
getAttr<AsmLabelAttr>()->
getRange();
3153 if (
const auto *NewAbiTagAttr = New->
getAttr<AbiTagAttr>()) {
3154 if (
const auto *OldAbiTagAttr = Old->
getAttr<AbiTagAttr>()) {
3155 for (
const auto &
NewTag : NewAbiTagAttr->tags()) {
3156 if (!llvm::is_contained(OldAbiTagAttr->tags(),
NewTag)) {
3157 Diag(NewAbiTagAttr->getLocation(),
3158 diag::err_new_abi_tag_on_redeclaration)
3160 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
3164 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
3170 if (New->
hasAttr<SectionAttr>() && !Old->
hasAttr<SectionAttr>()) {
3171 if (
auto *VD = dyn_cast<VarDecl>(New)) {
3173 Diag(New->
getLocation(), diag::warn_attribute_section_on_redeclaration);
3180 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
3181 if (NewCSA && !Old->
hasAttr<CodeSegAttr>() &&
3182 !NewCSA->isImplicit() && isa<CXXMethodDecl>(New)) {
3200 if (isa<DeprecatedAttr>(I) ||
3201 isa<UnavailableAttr>(I) ||
3202 isa<AvailabilityAttr>(I)) {
3217 if (isa<UsedAttr>(I) || isa<RetainAttr>(I))
3239 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
3240 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
3241 S.
Diag(CDA->getLocation(),
3242 diag::err_carries_dependency_missing_on_first_decl) << 1;
3250 diag::note_carries_dependency_missing_first_decl) << 1;
3256 bool foundAny = newDecl->
hasAttrs();
3265 cast<InheritableParamAttr>(I->clone(S.
Context));
3278 auto NoSizeInfo = [&Ctx](
QualType Ty) {
3279 if (Ty->isIncompleteArrayType() || Ty->isPointerType())
3287 if (NoSizeInfo(Old) && NoSizeInfo(New))
3319 if (*Oldnullability != *Newnullability) {
3320 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
3337 const auto *OldParamDT = dyn_cast<DecayedType>(OldParam->
getType());
3338 const auto *NewParamDT = dyn_cast<DecayedType>(NewParam->
getType());
3339 if (OldParamDT && NewParamDT &&
3340 OldParamDT->getPointeeType() == NewParamDT->getPointeeType()) {
3341 QualType OldParamOT = OldParamDT->getOriginalType();
3342 QualType NewParamOT = NewParamDT->getOriginalType();
3345 << NewParam << NewParamOT;
3356struct GNUCompatibleParamWarning {
3366template <
typename T>
3367static std::pair<diag::kind, SourceLocation>
3371 if (Old->isThisDeclarationADefinition())
3372 PrevDiag = diag::note_previous_definition;
3373 else if (Old->isImplicit()) {
3374 PrevDiag = diag::note_previous_implicit_declaration;
3375 if (
const auto *FD = dyn_cast<FunctionDecl>(Old)) {
3376 if (FD->getBuiltinID())
3377 PrevDiag = diag::note_previous_builtin_declaration;
3380 OldLocation = New->getLocation();
3382 PrevDiag = diag::note_previous_declaration;
3383 return std::make_pair(PrevDiag, OldLocation);
3391 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
3392 !LangOpts.CPlusPlus &&
3404template <
typename T>
3425template<
typename ExpectedDecl>
3447 !Old->getDeclContext()->getRedeclContext()->Equals(
3448 New->getDeclContext()->getRedeclContext()) &&
3453 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
3466 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
3467 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
3470 return AttrA && AttrB && AttrA->getType() == AttrB->getType() &&
3471 AttrA->isDynamic() == AttrB->isDynamic();
3497 if (NamedDC->Equals(SemaDC))
3500 assert((NamedDC->InEnclosingNamespaceSetOf(SemaDC) ||
3502 "unexpected context for redeclaration");
3513 if (
auto *FD = dyn_cast<FunctionDecl>(NewD))
3514 FixSemaDC(FD->getDescribedFunctionTemplate());
3515 else if (
auto *VD = dyn_cast<VarDecl>(NewD))
3516 FixSemaDC(VD->getDescribedVarTemplate());
3520 bool MergeTypeWithOld,
bool NewDeclIsDefn) {
3527 Diag(Shadow->getTargetDecl()->getLocation(),
3528 diag::note_using_decl_target);
3529 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl)
3538 if (checkUsingShadowRedecl<FunctionTemplateDecl>(*
this, Shadow,
3541 OldD = Old = cast<FunctionTemplateDecl>(Shadow->getTargetDecl())
3544 if (checkUsingShadowRedecl<FunctionDecl>(*
this, Shadow, New))
3546 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
3574 std::tie(PrevDiag, OldLocation) =
3581 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
3588 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3591 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3596 if (
const auto *ILA = New->
getAttr<InternalLinkageAttr>())
3597 if (!Old->
hasAttr<InternalLinkageAttr>()) {
3601 New->
dropAttr<InternalLinkageAttr>();
3604 if (
auto *EA = New->
getAttr<ErrorAttr>()) {
3605 if (!Old->
hasAttr<ErrorAttr>()) {
3606 Diag(EA->getLocation(), diag::err_attribute_missing_on_first_decl) << EA;
3616 bool OldOvl = Old->
hasAttr<OverloadableAttr>();
3627 const Decl *DiagOld = Old;
3629 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *
D) {
3630 const auto *A = D->getAttr<OverloadableAttr>();
3631 return A && !A->isImplicit();
3635 DiagOld = OldIter == Old->
redecls_end() ? nullptr : *OldIter;
3640 diag::note_attribute_overloadable_prev_overload)
3655 Diag(OldLocation, diag::note_previous_declaration);
3674 const FunctionType *OldType = cast<FunctionType>(OldQType);
3675 const FunctionType *NewType = cast<FunctionType>(NewQType);
3678 bool RequiresAdjustment =
false;
3680 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC()) {
3686 if (!NewCCExplicit) {
3690 RequiresAdjustment =
true;
3702 RequiresAdjustment =
true;
3709 << (!FirstCCExplicit ?
"" :
3713 Diag(
First->getLocation(), diag::note_previous_declaration);
3721 RequiresAdjustment =
true;
3731 Diag(OldLocation, diag::note_previous_declaration);
3736 RequiresAdjustment =
true;
3743 <<
"'ns_returns_retained'";
3744 Diag(OldLocation, diag::note_previous_declaration);
3749 RequiresAdjustment =
true;
3755 AnyX86NoCallerSavedRegistersAttr *
Attr =
3756 New->
getAttr<AnyX86NoCallerSavedRegistersAttr>();
3758 Diag(OldLocation, diag::note_previous_declaration);
3763 RequiresAdjustment =
true;
3766 if (RequiresAdjustment) {
3776 !New->
hasAttr<GNUInlineAttr>() &&
3785 if (New->
hasAttr<GNUInlineAttr>() &&
3796 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3800 QualType OldQTypeForComparison = OldQType;
3804 if (OldFX != NewFX) {
3806 for (
const auto &Diff : Diffs) {
3807 if (Diff.shouldDiagnoseRedeclaration(*Old, OldFX, *New, NewFX)) {
3809 diag::warn_mismatched_func_effect_redeclaration)
3810 << Diff.effectName();
3821 if (!MergeErrs.empty())
3828 NewFPT->getParamTypes(), EPI);
3836 EPI = OldFPT->getExtProtoInfo();
3839 OldFPT->getReturnType(), OldFPT->getParamTypes(), EPI);
3841 if (OldFX.empty()) {
3863 OldDeclaredReturnType)) {
3871 Diag(New->
getLocation(), diag::err_member_def_does_not_match_ret_type)
3874 !Old->
hasAttr<OverloadableAttr>() &&
3875 !New->
hasAttr<OverloadableAttr>())
3880 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
3889 QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType();
3890 if (OldReturnType != NewReturnType) {
3906 const CXXMethodDecl *OldMethod = dyn_cast<CXXMethodDecl>(Old);
3908 if (OldMethod && NewMethod) {
3915 bool IsClassScopeExplicitSpecialization =
3921 !IsClassScopeExplicitSpecialization) {
3927 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3937 if (isa<CXXConstructorDecl>(OldMethod))
3938 NewDiag = diag::err_constructor_redeclared;
3939 else if (isa<CXXDestructorDecl>(NewMethod))
3940 NewDiag = diag::err_destructor_redeclared;
3941 else if (isa<CXXConversionDecl>(NewMethod))
3942 NewDiag = diag::err_conv_function_redeclared;
3944 NewDiag = diag::err_member_redeclared;
3948 Diag(New->
getLocation(), diag::err_member_redeclared_in_instantiation)
3951 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3964 diag::err_definition_of_implicitly_declared_member)
3970 diag::err_definition_of_explicitly_defaulted_member)
3993 if (
const auto *NRA = New->
getAttr<CXX11NoReturnAttr>())
3994 if (!Old->
hasAttr<CXX11NoReturnAttr>()) {
3995 Diag(NRA->getLocation(), diag::err_attribute_missing_on_first_decl)
4004 const CarriesDependencyAttr *CDA = New->
getAttr<CarriesDependencyAttr>();
4005 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
4006 Diag(CDA->getLocation(),
4007 diag::err_carries_dependency_missing_on_first_decl) << 0;
4009 diag::note_carries_dependency_missing_first_decl) << 0;
4022 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
4037 Diag(OldLocation, PrevDiag);
4039 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
4040 Diag(OldLocation, PrevDiag);
4047 if (
HLSL().CheckCompatibleParameterABI(New, Old))
4127 bool IsWithoutProtoADef =
false, IsWithProtoADef =
false;
4128 if (WithoutProto == New)
4129 IsWithoutProtoADef = NewDeclIsDefn;
4131 IsWithProtoADef = NewDeclIsDefn;
4133 diag::warn_non_prototype_changes_behavior)
4134 << IsWithoutProtoADef << (WithoutProto->
getNumParams() ? 0 : 1)
4135 << (WithoutProto == Old) << IsWithProtoADef;
4145 !IsWithoutProtoADef)
4155 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
4156 (OldProto = dyn_cast<FunctionProtoType>(OldFuncType))) {
4159 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
4161 OldProto->getParamTypes(),
4162 OldProto->getExtProtoInfo());
4168 for (
const auto &ParamType : OldProto->param_types()) {
4171 ParamType,
nullptr,
SC_None,
nullptr);
4174 Params.push_back(Param);
4177 New->setParams(Params);
4213 NewProto->getReturnType());
4214 bool LooseCompatible = !MergedReturn.
isNull();
4216 LooseCompatible && Idx != End; ++Idx) {
4220 NewProto->getParamType(Idx))) {
4221 ArgTypes.push_back(NewParm->
getType());
4225 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
4226 NewProto->getParamType(Idx) };
4227 Warnings.push_back(Warn);
4228 ArgTypes.push_back(NewParm->
getType());
4230 LooseCompatible =
false;
4233 if (LooseCompatible) {
4234 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
4235 Diag(Warnings[Warn].NewParm->getLocation(),
4236 diag::ext_param_promoted_not_compatible_with_prototype)
4237 << Warnings[Warn].PromotedType
4238 << Warnings[Warn].OldParm->getType();
4239 if (Warnings[Warn].OldParm->getLocation().isValid())
4240 Diag(Warnings[Warn].OldParm->getLocation(),
4241 diag::note_previous_declaration);
4244 if (MergeTypeWithOld)
4264 Diag(OldLocation, diag::note_previous_builtin_declaration)
4269 PrevDiag = diag::note_previous_builtin_declaration;
4273 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4278 Scope *S,
bool MergeTypeWithOld) {
4293 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
4307 if (!Merged.isNull() && MergeTypeWithOld)
4330 ni != ne && oi != oe; ++ni, ++oi)
4340 ? diag::err_redefinition_different_type
4341 : diag::err_redeclaration_different_type)
4346 std::tie(PrevDiag, OldLocation)
4348 S.
Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4353 bool MergeTypeWithOld) {
4381 QualType PrevVDTy = PrevVD->getType();
4435 if (MergeTypeWithOld)
4473 if (!shouldLinkPossiblyHiddenDecl(
Previous, New))
4483 OldTemplate = dyn_cast<VarTemplateDecl>(
Previous.getFoundDecl());
4487 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4488 if (checkUsingShadowRedecl<VarTemplateDecl>(*
this, Shadow, NewTemplate))
4491 Old = dyn_cast<VarDecl>(
Previous.getFoundDecl());
4494 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4495 if (checkUsingShadowRedecl<VarDecl>(*
this, Shadow, New))
4532 if (New->
hasAttr<WeakImportAttr>())
4543 if (
const auto *ILA = New->
getAttr<InternalLinkageAttr>())
4544 if (!Old->
hasAttr<InternalLinkageAttr>()) {
4548 New->
dropAttr<InternalLinkageAttr>();
4553 if (MostRecent != Old) {
4566 std::tie(PrevDiag, OldLocation) =
4576 Diag(OldLocation, PrevDiag);
4580 Diag(OldLocation, PrevDiag);
4599 Diag(OldLocation, PrevDiag);
4607 Diag(OldLocation, PrevDiag);
4613 Diag(OldLocation, PrevDiag);
4629 Diag(OldLocation, PrevDiag);
4639 Diag(Def->getLocation(), diag::note_previous_definition);
4653 Diag(OldLocation, PrevDiag);
4656 Diag(OldLocation, PrevDiag);
4664 Diag(OldLocation, PrevDiag);
4674 diag::warn_deprecated_redundant_constexpr_static_def);
4683 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
4684 Diag(OldLocation, PrevDiag);
4714 StringRef HdrFilename =
4717 auto noteFromModuleOrInclude = [&](
Module *Mod,
4723 if (IncLoc.isValid()) {
4725 Diag(IncLoc, diag::note_redefinition_modules_same_file)
4731 Diag(IncLoc, diag::note_redefinition_include_same_file)
4732 << HdrFilename.str();
4742 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
4750 if (FOld && !HSI.isFileMultipleIncludeGuarded(*FOld))
4765 isa<VarTemplateSpecializationDecl>(New) ||
4801 ? S->getMSCurManglingNumber()
4802 : S->getMSLastManglingNumber();
4809 if (isa<CXXRecordDecl>(Tag->getParent())) {
4812 if (!Tag->getName().empty() || Tag->getTypedefNameForAnonDecl())
4824 Decl *ManglingContextDecl;
4825 std::tie(MCtx, ManglingContextDecl) =
4835struct NonCLikeKind {
4855 return {NonCLikeKind::Invalid, {}};
4862 return {NonCLikeKind::BaseClass,
4874 if (
auto *FD = dyn_cast<FieldDecl>(
D)) {
4875 if (FD->hasInClassInitializer()) {
4876 auto *
Init = FD->getInClassInitializer();
4877 return {NonCLikeKind::DefaultMemberInit,
4885 if (isa<FriendDecl>(
D))
4890 if (isa<StaticAssertDecl>(
D) || isa<IndirectFieldDecl>(
D) ||
4893 auto *MemberRD = dyn_cast<CXXRecordDecl>(
D);
4901 if (MemberRD->isLambda())
4902 return {NonCLikeKind::Lambda, MemberRD->getSourceRange()};
4906 if (MemberRD->isThisDeclarationADefinition()) {
4912 return {
Invalid ? NonCLikeKind::Invalid : NonCLikeKind::None, {}};
4942 const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(TagFromDeclSpec);
4946 if (NonCLike || ChangesLinkage) {
4947 if (NonCLike.Kind == NonCLikeKind::Invalid)
4950 unsigned DiagID = diag::ext_non_c_like_anon_struct_in_typedef;
4951 if (ChangesLinkage) {
4953 if (NonCLike.Kind == NonCLikeKind::None)
4954 DiagID = diag::err_typedef_changes_linkage;
4956 DiagID = diag::err_non_c_like_anon_struct_in_typedef;
4962 TextToInsert +=
' ';
4965 Diag(FixitLoc, DiagID)
4966 << isa<TypeAliasDecl>(NewTD)
4968 if (NonCLike.Kind != NonCLikeKind::None) {
4969 Diag(NonCLike.Range.getBegin(), diag::note_non_c_like_anon_struct)
4970 << NonCLike.Kind - 1 << NonCLike.Range;
4973 << NewTD << isa<TypeAliasDecl>(NewTD);
4998 if (
const auto *ED = dyn_cast<EnumDecl>(DS.
getRepAsDecl())) {
4999 if (ED->isScopedUsingClassTag())
5006 llvm_unreachable(
"unexpected type specifier");
5014 bool IsExplicitInstantiation,
5017 Decl *TagD =
nullptr;
5032 if (isa<TagDecl>(TagD))
5033 Tag = cast<TagDecl>(TagD);
5035 Tag = CTD->getTemplatedDecl();
5040 Tag->setFreeStanding();
5041 if (Tag->isInvalidDecl())
5050 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
5087 "Friend ellipsis but not friend-specified?");
5090 bool DeclaresAnything =
true;
5094 if (!
Record->getDeclName() &&
Record->isCompleteDefinition() &&
5097 Record->getDeclContext()->isRecord()) {
5111 DeclaresAnything =
false;
5130 if ((Tag && Tag->getDeclName()) ||
5134 Record = dyn_cast<RecordDecl>(Tag);
5147 DeclaresAnything =
false;
5159 if (
Enum->enumerator_begin() ==
Enum->enumerator_end() &&
5160 !
Enum->getIdentifier() && !
Enum->isInvalidDecl())
5161 DeclaresAnything =
false;
5169 DeclaresAnything =
false;
5173 Tag && Tag->getDeclContext()->isFunctionOrMethod())
5175 << llvm::to_underlying(Tag->getTagKind())
5188 if (!DeclaresAnything) {
5191 Diag(DS.
getBeginLoc(), (IsExplicitInstantiation || !TemplateParams.empty())
5192 ? diag::err_no_declarators
5193 : diag::ext_no_declarators)
5206 unsigned DiagID = diag::warn_standalone_specifier;
5208 DiagID = diag::ext_standalone_specifier;
5249 auto EmitAttributeDiagnostic = [
this, &DS](
const ParsedAttr &AL) {
5250 unsigned DiagnosticId = diag::warn_declspec_attribute_ignored;
5252 DiagnosticId = diag::warn_attribute_ignored;
5253 else if (AL.isRegularKeywordAttribute())
5254 DiagnosticId = diag::err_declspec_keyword_has_no_effect;
5256 DiagnosticId = diag::warn_declspec_attribute_ignored;
5257 Diag(AL.getLoc(), DiagnosticId)
5261 llvm::for_each(DS.
getAttributes(), EmitAttributeDiagnostic);
5262 llvm::for_each(DeclAttrs, EmitAttributeDiagnostic);
5281 RedeclarationKind::ForVisibleRedeclaration);
5286 assert(PrevDecl &&
"Expected a non-null Decl");
5299 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
5301 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
5307 if (
auto *RD = dyn_cast_if_present<RecordDecl>(
D))
5317 if (
Record->isAnonymousStructOrUnion())
5322 const NamedDecl *ND = dyn_cast<NamedDecl>(
D);
5356 for (
auto *
D : AnonRecord->
decls()) {
5357 if ((isa<FieldDecl>(
D) || isa<IndirectFieldDecl>(
D)) &&
5358 cast<NamedDecl>(
D)->getDeclName()) {
5374 unsigned OldChainingSize = Chaining.size();
5376 Chaining.append(IF->chain_begin(), IF->chain_end());
5378 Chaining.push_back(VD);
5380 assert(Chaining.size() >= 2);
5383 for (
unsigned i = 0; i < Chaining.size(); i++)
5384 NamedChain[i] = Chaining[i];
5388 VD->
getType(), {NamedChain, Chaining.size()});
5400 Chaining.resize(OldChainingSize);
5415 "Parser allowed 'typedef' as storage class VarDecl.");
5416 switch (StorageClassSpec) {
5430 llvm_unreachable(
"unknown storage class specifier");
5434 assert(
Record->hasInClassInitializer());
5436 for (
const auto *I :
Record->decls()) {
5437 const auto *FD = dyn_cast<FieldDecl>(I);
5438 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
5439 FD = IFD->getAnonField();
5440 if (FD && FD->hasInClassInitializer())
5441 return FD->getLocation();
5444 llvm_unreachable(
"couldn't find in-class initializer");
5449 if (!
Parent->isUnion() || !
Parent->hasInClassInitializer())
5452 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
5458 if (!
Parent->isUnion() || !
Parent->hasInClassInitializer())
5472 Diag(
Record->getLocation(), diag::ext_anonymous_union);
5474 Diag(
Record->getLocation(), diag::ext_gnu_anonymous_struct);
5476 Diag(
Record->getLocation(), diag::ext_c11_anonymous_struct);
5482 const char *PrevSpec =
nullptr;
5493 !cast<NamespaceDecl>(OwnerScope)->isAnonymousNamespace()))) {
5494 Diag(
Record->getLocation(), diag::err_anonymous_union_not_static)
5499 PrevSpec, DiagID, Policy);
5505 isa<RecordDecl>(Owner)) {
5507 diag::err_anonymous_union_with_storage_spec)
5521 <<
Record->isUnion() <<
"const"
5525 diag::ext_anonymous_struct_union_qualified)
5526 <<
Record->isUnion() <<
"volatile"
5530 diag::ext_anonymous_struct_union_qualified)
5531 <<
Record->isUnion() <<
"restrict"
5535 diag::ext_anonymous_struct_union_qualified)
5536 <<
Record->isUnion() <<
"_Atomic"
5540 diag::ext_anonymous_struct_union_qualified)
5541 <<
Record->isUnion() <<
"__unaligned"
5551 for (
auto *Mem :
Record->decls()) {
5553 if (Mem->isInvalidDecl())
5556 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
5560 assert(FD->getAccess() !=
AS_none);
5562 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
5574 }
else if (Mem->isImplicit()) {
5576 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() !=
Record) {
5581 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
5582 if (!MemRecord->isAnonymousStructOrUnion() &&
5583 MemRecord->getDeclName()) {
5586 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
5590 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
5598 Diag(MemRecord->getLocation(),
5599 diag::ext_anonymous_record_with_anonymous_type)
5602 }
else if (isa<AccessSpecDecl>(Mem)) {
5604 }
else if (isa<StaticAssertDecl>(Mem)) {
5609 unsigned DK = diag::err_anonymous_record_bad_member;
5610 if (isa<TypeDecl>(Mem))
5611 DK = diag::err_anonymous_record_with_type;
5612 else if (isa<FunctionDecl>(Mem))
5613 DK = diag::err_anonymous_record_with_function;
5614 else if (isa<VarDecl>(Mem))
5615 DK = diag::err_anonymous_record_with_static;
5619 DK == diag::err_anonymous_record_with_type)
5620 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
5623 Diag(Mem->getLocation(), DK) <<
Record->isUnion();
5632 if (cast<CXXRecordDecl>(
Record)->hasInClassInitializer() &&
5635 cast<CXXRecordDecl>(
Record));
5639 Diag(
Record->getLocation(), diag::err_anonymous_struct_not_member)
5660 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
5664 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
5680 Diag(
Record->getLocation(), diag::err_mutable_nonmember);
5686 Record->getLocation(),
nullptr,
5702 Record->setAnonymousStructOrUnion(
true);
5713 Chain.push_back(Anon);
5719 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
5722 Decl *ManglingContextDecl;
5723 std::tie(MCtx, ManglingContextDecl) =
5742 assert(
Record &&
"expected a record!");
5747 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
5749 auto *ParentDecl = cast<RecordDecl>(
CurContext);
5755 nullptr, RecTy, TInfo,
5767 Chain.push_back(Anon);
5771 diag::err_field_incomplete_or_sizeless) ||
5776 ParentDecl->setInvalidDecl();
5789 NameInfo.
setLoc(Name.StartLocation);
5791 switch (Name.getKind()) {
5795 NameInfo.
setName(Name.Identifier);
5811 if (!Template || !isa<ClassTemplateDecl>(Template)) {
5812 Diag(Name.StartLocation,
5813 diag::err_deduction_guide_name_not_class_template)
5827 Name.OperatorFunctionId.Operator));
5829 Name.OperatorFunctionId.SymbolLocations[0], Name.EndLocation));
5865 if (!CurClass || CurClass->
getIdentifier() != Name.TemplateId->Name)
5901 llvm_unreachable(
"Unknown name kind");
5929 for (
unsigned Idx = 0; Idx <
Declaration->param_size(); ++Idx) {
5943 (DeclTyName && DeclTyName == DefTyName))
5944 Params.push_back(Idx);
5971#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case DeclSpec::TST_##Trait:
5972#include "clang/Basic/TransformTypeTraits.def"
5987 if (!TSI)
return true;
6000 if (
Result.isInvalid())
return true;
6011 for (
unsigned I = 0,
E =
D.getNumTypeObjects(); I !=
E; ++I) {
6045 << D << static_cast<int>(Status);
6056 if (
OpenMP().getOMPTraitInfoForSurroundingScope()->isExtensionActive(
6057 llvm::omp::TraitProperty::
6058 implementation_extension_bind_to_declaration))
6083 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
6094 bool IsMemberSpecialization) {
6095 assert(SS.
isValid() &&
"diagnoseQualifiedDeclaration called for declaration "
6096 "without nested-name-specifier");
6098 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
6112 Diag(
Loc,
LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
6113 : diag::err_member_extra_qualification)
6117 Diag(
Loc, diag::warn_namespace_member_extra_qualification) << Name;
6125 if (!Cur->
Encloses(DC) && !(TemplateId || IsMemberSpecialization)) {
6127 Diag(
Loc, diag::err_member_qualification)
6129 else if (isa<TranslationUnitDecl>(DC))
6130 Diag(
Loc, diag::err_invalid_declarator_global_scope)
6132 else if (isa<FunctionDecl>(Cur))
6133 Diag(
Loc, diag::err_invalid_declarator_in_function)
6135 else if (isa<BlockDecl>(Cur))
6136 Diag(
Loc, diag::err_invalid_declarator_in_block)
6138 else if (isa<ExportDecl>(Cur)) {
6139 if (!isa<NamespaceDecl>(DC))
6140 Diag(
Loc, diag::err_export_non_namespace_scope_name)
6147 Diag(
Loc, diag::err_invalid_declarator_scope)
6148 << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.
getRange();
6155 Diag(
Loc, diag::err_member_qualification)
6181 Diag(
Loc, diag::ext_template_after_declarative_nns)
6188 Diag(
Loc, diag::ext_template_after_declarative_nns)
6199 if (TST->isDependentType() && TST->isTypeAlias())
6200 Diag(
Loc, diag::ext_alias_template_in_declarative_nns)
6209 Diag(
Loc, diag::err_computed_type_in_declarative_nns)
6213 }
while ((SpecLoc = SpecLoc.
getPrefix()));
6226 if (
D.isDecompositionDeclarator()) {
6229 if (!
D.isInvalidType())
6237 if (
D.getCXXScopeSpec().isInvalid())
6239 else if (
D.getCXXScopeSpec().isSet()) {
6244 bool EnteringContext = !
D.getDeclSpec().isFriendSpecified();
6246 if (!DC || isa<EnumDecl>(DC)) {
6251 Diag(
D.getIdentifierLoc(),
6252 diag::err_template_qualified_declarator_no_match)
6253 <<
D.getCXXScopeSpec().getScopeRep()
6254 <<
D.getCXXScopeSpec().getRange();
6259 if (!IsDependentContext &&
6264 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
6265 Diag(
D.getIdentifierLoc(),
6266 diag::err_member_def_undefined_record)
6267 << Name << DC <<
D.getCXXScopeSpec().getRange();
6270 if (!
D.getDeclSpec().isFriendSpecified()) {
6273 ?
D.getName().TemplateId
6276 D.getIdentifierLoc(), TemplateId,
6287 if (EnteringContext && IsDependentContext &&
6288 TemplateParamLists.size() != 0) {
6306 if (!
D.getCXXScopeSpec().isSet()) {
6307 bool IsLinkageLookup =
false;
6308 bool CreateBuiltins =
false;
6322 IsLinkageLookup =
true;
6327 CreateBuiltins =
true;
6329 if (IsLinkageLookup) {
6332 RedeclarationKind::ForExternalRedeclaration);
6370 if (!
D.isInvalidType()) {
6371 bool AllowForCompatibility =
false;
6372 if (
Scope *DeclParent = S->getDeclParent();
6373 Scope *TemplateParamParent = S->getTemplateParamParent()) {
6374 AllowForCompatibility = DeclParent->Contains(*TemplateParamParent) &&
6375 TemplateParamParent->isDeclScope(TPD);
6378 AllowForCompatibility);
6404 S = S->getDeclParent();
6408 bool AddToScope =
true;
6410 if (TemplateParamLists.size()) {
6411 Diag(
D.getIdentifierLoc(), diag::err_template_typedef);
6433 if (
OpenMP().isInOpenMPDeclareTargetContext())
6444 bool &SizeIsNegative,
6445 llvm::APSInt &Oversized) {
6450 SizeIsNegative =
false;
6459 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
6464 if (FixedType.
isNull())
return FixedType;
6466 return Qs.
apply(Context, FixedType);
6468 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
6469 QualType Inner = PTy->getInnerType();
6473 if (FixedType.
isNull())
return FixedType;
6475 return Qs.
apply(Context, FixedType);
6485 SizeIsNegative, Oversized);
6495 llvm::APSInt Res =
Result.Val.getInt();
6498 if (Res.isSigned() && Res.isNegative()) {
6499 SizeIsNegative =
true;
6504 unsigned ActiveSizeBits =
6508 : Res.getActiveBits();
6516 return Qs.
apply(Context, FoldedArrayType);
6541 TypeLoc DstElemTL = DstATL.getElementLoc();
6560 bool &SizeIsNegative,
6561 llvm::APSInt &Oversized) {
6564 SizeIsNegative, Oversized);
6575 unsigned FailedFoldDiagID) {
6576 bool SizeIsNegative;
6577 llvm::APSInt Oversized;
6579 TInfo,
Context, SizeIsNegative, Oversized);
6581 Diag(
Loc, diag::ext_vla_folded_to_constant);
6588 Diag(
Loc, diag::err_typecheck_negative_array_size);
6589 else if (Oversized.getBoolValue())
6591 else if (FailedFoldDiagID)
6618 diag::err_virtual_non_function);
6622 diag::err_explicit_non_function);
6626 diag::err_noreturn_non_function);
6633 if (
D.getCXXScopeSpec().isSet()) {
6634 Diag(
D.getIdentifierLoc(), diag::err_qualified_typedef_declarator)
6635 <<
D.getCXXScopeSpec().getRange();
6644 if (
D.getDeclSpec().isInlineSpecified())
6645 Diag(
D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
6647 if (
D.getDeclSpec().hasConstexprSpecifier())
6648 Diag(
D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr)
6649 << 1 <<
static_cast<int>(
D.getDeclSpec().getConstexprSpecifier());
6653 Diag(
D.getName().StartLocation,
6654 diag::err_deduction_guide_invalid_specifier)
6657 Diag(
D.getName().StartLocation, diag::err_typedef_not_identifier)
6663 if (!NewTD)
return nullptr;
6670 bool Redeclaration =
D.isRedeclaration();
6672 D.setRedeclaration(Redeclaration);
6687 if (S->getFnParent() ==
nullptr) {
6688 bool SizeIsNegative;
6689 llvm::APSInt Oversized;
6702 else if (Oversized.getBoolValue())
6726 Redeclaration =
true;
6732 if (ShadowedDecl && !Redeclaration)
6739 switch (II->getNotableIdentifierID()) {
6740 case tok::NotableIdentifierKind::FILE:
6743 case tok::NotableIdentifierKind::jmp_buf:
6746 case tok::NotableIdentifierKind::sigjmp_buf:
6749 case tok::NotableIdentifierKind::ucontext_t:
6752 case tok::NotableIdentifierKind::float_t:
6753 case tok::NotableIdentifierKind::double_t:
6754 NewTD->
addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(
Context));
6815 if (!OuterContext->
Equals(PrevOuterContext))
6824 if (!SS.
isSet())
return;
6829 if (
Decl->getType().hasAddressSpace())
6831 if (
Decl->getType()->isDependentType())
6843 Var->hasGlobalStorage())
6847 if (
auto DT = dyn_cast<DecayedType>(
Type)) {
6848 auto OrigTy = DT->getOriginalType();
6849 if (!OrigTy.hasAddressSpace() && OrigTy->isArrayType()) {
6880 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
6889 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
6890 if (VD->hasInit()) {
6891 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
6892 assert(VD->isThisDeclarationADefinition() &&
6893 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
6895 VD->dropAttr<AliasAttr>();
6904 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
6907 diag::err_attribute_selectany_non_extern_data);
6914 if (HybridPatchableAttr *
Attr = ND.
getAttr<HybridPatchableAttr>()) {
6917 diag::warn_attribute_hybrid_patchable_non_extern);
6923 auto *VD = dyn_cast<VarDecl>(&ND);
6924 bool IsAnonymousNS =
false;
6927 const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(VD->getDeclContext());
6928 while (NS && !IsAnonymousNS) {
6930 NS = dyn_cast<NamespaceDecl>(NS->
getParent());
6937 bool AnonNSInMicrosoftMode = IsAnonymousNS && IsMicrosoft;
6939 (!AnonNSInMicrosoftMode &&
6950 if (
const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
6955 for (
TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
6961 if (
const auto *A = ATL.
getAttrAs<LifetimeBoundAttr>()) {
6962 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
6963 int NoImplicitObjectError = -1;
6965 NoImplicitObjectError = 0;
6966 else if (MD->isStatic())
6967 NoImplicitObjectError = 1;
6968 else if (MD->isExplicitObjectMemberFunction())
6969 NoImplicitObjectError = 2;
6970 if (NoImplicitObjectError != -1) {
6971 S.
Diag(A->getLocation(), diag::err_lifetimebound_no_object_param)
6972 << NoImplicitObjectError << A->getRange();
6973 }
else if (isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD)) {
6974 S.
Diag(A->getLocation(), diag::err_lifetimebound_ctor_dtor)
6975 << isa<CXXDestructorDecl>(MD) << A->getRange();
6976 }
else if (MD->getReturnType()->isVoidType()) {
6980 err_lifetimebound_implicit_object_parameter_void_return_type);
6985 for (
unsigned int I = 0; I < FD->getNumParams(); ++I) {
6990 if (
auto *A =
P->getAttr<LifetimeBoundAttr>()) {
6991 if (!isa<CXXConstructorDecl>(FD) && FD->getReturnType()->isVoidType()) {
6992 S.
Diag(A->getLocation(),
6993 diag::err_lifetimebound_parameter_void_return_type);
7016 bool IsSpecialization,
7017 bool IsDefinition) {
7021 bool IsTemplate =
false;
7022 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
7023 OldDecl = OldTD->getTemplatedDecl();
7025 if (!IsSpecialization)
7026 IsDefinition =
false;
7028 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
7029 NewDecl = NewTD->getTemplatedDecl();
7033 if (!OldDecl || !NewDecl)
7036 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
7037 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
7038 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
7039 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
7043 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
7044 (NewExportAttr && !NewExportAttr->isInherited());
7050 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
7052 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
7054 bool JustWarn =
false;
7056 auto *VD = dyn_cast<VarDecl>(OldDecl);
7057 if (VD && !VD->getDescribedVarTemplate())
7059 auto *FD = dyn_cast<FunctionDecl>(OldDecl);
7068 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
7071 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
7072 : diag::err_attribute_dll_redeclaration;
7075 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
7088 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
7090 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
7093 IsStaticDataMember = VD->isStaticDataMember();
7094 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
7096 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
7097 IsInline = FD->isInlined();
7098 IsQualifiedFriend = FD->getQualifier() &&
7102 if (OldImportAttr && !HasNewAttr &&
7103 (!IsInline || (IsMicrosoftABI && IsTemplate)) && !IsStaticDataMember &&
7105 if (IsMicrosoftABI && IsDefinition) {
7106 if (IsSpecialization) {
7109 diag::err_attribute_dllimport_function_specialization_definition);
7110 S.
Diag(OldImportAttr->getLocation(), diag::note_attribute);
7111 NewDecl->
dropAttr<DLLImportAttr>();
7114 diag::warn_redeclaration_without_import_attribute)
7117 NewDecl->
dropAttr<DLLImportAttr>();
7118 NewDecl->
addAttr(DLLExportAttr::CreateImplicit(
7119 S.
Context, NewImportAttr->getRange()));
7121 }
else if (IsMicrosoftABI && IsSpecialization) {
7122 assert(!IsDefinition);
7126 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
7127 << NewDecl << OldImportAttr;
7129 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
7130 OldDecl->
dropAttr<DLLImportAttr>();
7131 NewDecl->
dropAttr<DLLImportAttr>();
7133 }
else if (IsInline && OldImportAttr && !IsMicrosoftABI) {
7136 OldDecl->
dropAttr<DLLImportAttr>();
7137 NewDecl->
dropAttr<DLLImportAttr>();
7139 diag::warn_dllimport_dropped_from_inline_function)
7140 << NewDecl << OldImportAttr;
7147 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
7149 !NewImportAttr && !NewExportAttr) {
7150 if (
const DLLExportAttr *ParentExportAttr =
7151 MD->getParent()->getAttr<DLLExportAttr>()) {
7152 DLLExportAttr *NewAttr = ParentExportAttr->clone(S.
Context);
7153 NewAttr->setInherited(
true);
7197 if (!
D->isInExternCContext() ||
D->template hasAttr<OverloadableAttr>())
7201 if (S.
getLangOpts().CUDA && (
D->template hasAttr<CUDADeviceAttr>() ||
7202 D->template hasAttr<CUDAHostAttr>()))
7205 return D->isExternC();
7211 isa<OMPDeclareMapperDecl>(DC))
7220 if (isa<RequiresExprBodyDecl>(DC))
7222 llvm_unreachable(
"Unexpected context");
7228 isa<OMPDeclareReductionDecl>(DC) || isa<OMPDeclareMapperDecl>(DC))
7232 llvm_unreachable(
"Unexpected context");
7277 if (
const auto *FD = dyn_cast<FunctionDecl>(
D))
7278 return FD->isExternC();
7279 if (
const auto *VD = dyn_cast<VarDecl>(
D))
7280 return VD->isExternC();
7282 llvm_unreachable(
"Unknown type of decl!");
7295 diag::err_opencl_type_can_only_be_used_as_function_parameter)
7309 diag::err_invalid_type_for_program_scope_var)
7338 Se.
Diag(NewVD->
getLocation(), diag::err_opencl_half_declaration) << R;
7371 Se.
Diag(NewVD->
getLocation(), diag::err_opencl_nonconst_global_sampler);
7381template <
typename AttrTy>
7384 if (
const auto *Attribute = TND->
getAttr<AttrTy>()) {
7385 AttrTy *Clone = Attribute->clone(S.
Context);
7386 Clone->setInherited(
true);
7414 if (
const auto *ConstDecl = RD->
getAttr<ReadOnlyPlacementAttr>()) {
7416 S.
Diag(ConstDecl->getLocation(), diag::note_enforce_read_only_placement);
7423 return Name.getAsIdentifierInfo() &&
7424 Name.getAsIdentifierInfo()->isStr(
"main") &&
7438 bool IsPlaceholderVariable =
false;
7440 if (
D.isDecompositionDeclarator()) {
7443 auto &Decomp =
D.getDecompositionDeclarator();
7444 if (!Decomp.bindings().empty()) {
7445 II = Decomp.bindings()[0].Name;
7449 Diag(
D.getIdentifierLoc(), diag::err_bad_variable_name) << Name;
7459 IsPlaceholderVariable =
true;
7477 bool IsLocalExternDecl = SC ==
SC_Extern &&
7483 Diag(
D.getIdentifierLoc(), diag::err_mutable_nonmember);
7490 D.getDeclSpec().getStorageClassSpecLoc())) {
7494 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
7496 : diag::warn_deprecated_register)
7502 if (!DC->
isRecord() && S->getFnParent() ==
nullptr) {
7507 Diag(
D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope);
7519 const AutoType *AT = TL.getTypePtr();
7523 bool IsMemberSpecialization =
false;
7524 bool IsVariableTemplateSpecialization =
false;
7526 bool IsVariableTemplate =
false;
7537 if (
D.isInvalidType())
7550 D.getCXXScopeSpec(),
7552 ?
D.getName().TemplateId
7555 false, IsMemberSpecialization,
Invalid);
7557 if (TemplateParams) {
7564 if (!TemplateParams->
size() &&
7569 diag::err_template_variable_noparams)
7573 TemplateParams =
nullptr;
7581 IsVariableTemplateSpecialization =
true;
7585 IsVariableTemplate =
true;
7588 Diag(
D.getIdentifierLoc(),
7590 ? diag::warn_cxx11_compat_variable_template
7591 : diag::ext_variable_template);
7596 if (!TemplateParamLists.empty() && IsMemberSpecialization &&
7601 "should have a 'template<>' for this decl");
7604 bool IsExplicitSpecialization =
7615 (IsExplicitSpecialization || IsMemberSpecialization)) {
7616 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
7617 diag::ext_explicit_specialization_storage_class)
7623 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
7629 if (Ctxt->isFunctionOrMethod()) {
7630 FunctionOrMethod = Ctxt;
7633 const CXXRecordDecl *ParentDecl = dyn_cast<CXXRecordDecl>(Ctxt);
7635 AnonStruct = ParentDecl;
7639 if (FunctionOrMethod) {
7642 Diag(
D.getIdentifierLoc(),
7643 diag::err_static_data_member_not_allowed_in_local_class)
7644 << Name << RD->getDeclName()
7645 << llvm::to_underlying(RD->getTagKind());
7646 }
else if (AnonStruct) {
7650 Diag(
D.getIdentifierLoc(),
7651 diag::err_static_data_member_not_allowed_in_anon_struct)
7652 << Name << llvm::to_underlying(AnonStruct->
getTagKind());
7654 }
else if (RD->isUnion()) {
7657 Diag(
D.getIdentifierLoc(),
7659 ? diag::warn_cxx98_compat_static_data_member_in_union
7660 : diag::ext_static_data_member_in_union)
7666 Diag(
D.getIdentifierLoc(), diag::err_template_member)
7677 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
7678 diag::err_static_out_of_line)
7680 D.getDeclSpec().getStorageClassSpecLoc());
7690 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
7691 diag::err_storage_class_for_static_member)
7693 D.getDeclSpec().getStorageClassSpecLoc());
7696 llvm_unreachable(
"C storage class in c++!");
7700 if (IsVariableTemplateSpecialization) {
7702 TemplateParamLists.size() > 0
7703 ? TemplateParamLists[0]->getTemplateLoc()
7706 S,
D, TInfo,
Previous, TemplateKWLoc, TemplateParams, SC,
7710 NewVD = cast<VarDecl>(Res.
get());
7712 }
else if (
D.isDecompositionDeclarator()) {
7714 D.getIdentifierLoc(), R, TInfo, SC,
7718 D.getIdentifierLoc(), II, R, TInfo, SC);
7721 if (IsVariableTemplate) {
7724 TemplateParams, NewVD);
7733 if (
D.isInvalidType() ||
Invalid) {
7745 unsigned VDTemplateParamLists =
7746 (TemplateParams && !IsExplicitSpecialization) ? 1 : 0;
7747 if (TemplateParamLists.size() > VDTemplateParamLists)
7749 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
7752 if (
D.getDeclSpec().isInlineSpecified()) {
7754 Diag(
D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
7758 Diag(
D.getDeclSpec().getInlineSpecLoc(),
7759 diag::err_inline_declaration_block_scope) << Name
7762 Diag(
D.getDeclSpec().getInlineSpecLoc(),
7764 : diag::ext_inline_variable);
7775 if (IsLocalExternDecl) {
7776 if (
D.isDecompositionDeclarator())
7778 B->setLocalExternDecl();
7783 bool EmitTLSUnsupportedError =
false;
7784 if (
DeclSpec::TSCS TSCS =
D.getDeclSpec().getThreadStorageClassSpec()) {
7795 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
7796 diag::err_thread_non_global)
7804 EmitTLSUnsupportedError =
true;
7810 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
7811 diag::err_thread_unsupported);
7816 switch (
D.getDeclSpec().getConstexprSpecifier()) {
7821 Diag(
D.getDeclSpec().getConstexprSpecLoc(),
7822 diag::err_constexpr_wrong_decl_kind)
7823 <<
static_cast<int>(
D.getDeclSpec().getConstexprSpecifier());
7839 Diag(
D.getDeclSpec().getConstexprSpecLoc(),
7840 diag::err_constinit_local_variable);
7843 ConstInitAttr::Create(
Context,
D.getDeclSpec().getConstexprSpecLoc(),
7844 ConstInitAttr::Keyword_constinit));
7857 if (SC ==
SC_Static && S->getFnParent() !=
nullptr &&
7861 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
7862 diag::warn_static_local_in_extern_inline);
7867 if (
D.getDeclSpec().isModulePrivateSpecified()) {
7868 if (IsVariableTemplateSpecialization)
7872 D.getDeclSpec().getModulePrivateSpecLoc());
7873 else if (IsMemberSpecialization)
7880 <<
SourceRange(
D.getDeclSpec().getModulePrivateSpecLoc())
7882 D.getDeclSpec().getModulePrivateSpecLoc());
7888 B->setModulePrivate();
7897 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
7898 diag::err_opencl_unknown_type_specifier)
7908 if (
const auto *ATy = dyn_cast<ArrayType>(NewVD->
getType())) {
7909 if (ATy && ATy->getElementType().isWebAssemblyReferenceType() &&
7929 copyAttrFromTypedefToDecl<AllocSizeAttr>(*
this, NewVD, TT);
7933 if (EmitTLSUnsupportedError &&
7936 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD))))
7937 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
7938 diag::err_thread_unsupported);
7940 if (EmitTLSUnsupportedError &&
7943 targetDiag(
D.getIdentifierLoc(), diag::err_thread_unsupported);
7946 if (SC ==
SC_None && S->getFnParent() !=
nullptr &&
7947 (NewVD->
hasAttr<CUDASharedAttr>() ||
7948 NewVD->
hasAttr<CUDAConstantAttr>())) {
7956 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
7957 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
7962 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(NewVD))
7970 if (S->getFnParent() !=
nullptr) {
7991 bool HasSizeMismatch;
7993 if (!TI.isValidGCCRegisterName(
Label))
7995 else if (!TI.validateGlobalRegisterVariable(
Label,
7999 else if (HasSizeMismatch)
8005 diag::err_asm_unsupported_register_type)
8015 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
8028 NamedDecl *ShadowedDecl =
D.getCXXScopeSpec().isEmpty()
8036 D.getCXXScopeSpec().isNotEmpty() ||
8037 IsMemberSpecialization ||
8038 IsVariableTemplateSpecialization);
8052 if (IsMemberSpecialization && !IsVariableTemplate &&
8053 !IsVariableTemplateSpecialization && !NewVD->
isInvalidDecl() &&
8060 isa<FieldDecl>(
Previous.getFoundDecl()) &&
8061 D.getCXXScopeSpec().isSet()) {
8065 <<
D.getCXXScopeSpec().getRange();
8069 }
else if (
D.getCXXScopeSpec().isSet() &&
8070 !IsVariableTemplateSpecialization) {
8072 Diag(
D.getIdentifierLoc(), diag::err_no_member)
8074 <<
D.getCXXScopeSpec().getRange();
8078 if (!IsPlaceholderVariable)
8101 (
D.getCXXScopeSpec().isSet() && DC && DC->
isRecord() &&
8109 if (PrevVarTemplate &&
8116 if (!IsPlaceholderVariable && ShadowedDecl && !
D.isRedeclaration())
8129 Decl *ManglingContextDecl;
8130 std::tie(MCtx, ManglingContextDecl) =
8157 if (
D.isRedeclaration() && !
Previous.empty()) {
8160 D.isFunctionDefinition());
8192 if (isa<TypeAliasDecl>(ShadowedDecl))
8194 else if (isa<TypedefDecl>(ShadowedDecl))
8196 else if (isa<BindingDecl>(ShadowedDecl))
8198 else if (isa<RecordDecl>(OldDC))
8231 if (
D->hasGlobalStorage() && !
D->isStaticLocal())
8235 return isa<VarDecl, FieldDecl, BindingDecl>(ShadowedDecl) ? ShadowedDecl
8249 return isa<TypedefNameDecl>(ShadowedDecl) ? ShadowedDecl :
nullptr;
8258 return isa<VarDecl, FieldDecl, BindingDecl>(ShadowedDecl) ? ShadowedDecl
8266 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
8272 if (!MD->getParent()->isLambda() && MD->isExplicitObjectMemberFunction())
8277 if (isa<CXXConstructorDecl>(NewDC))
8278 if (
const auto PVD = dyn_cast<ParmVarDecl>(
D)) {
8281 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
8286 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
8287 if (shadowedVar->isExternC()) {
8290 for (
auto *I : shadowedVar->redecls())
8291 if (I->isFileVarDecl()) {
8299 unsigned WarningDiag = diag::warn_decl_shadow;
8301 if (isa<VarDecl>(
D) && NewDC && isa<CXXMethodDecl>(NewDC)) {
8302 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
8304 if (
const auto *VD = dyn_cast<VarDecl>(ShadowedDecl)) {
8306 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
8312 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
8318 ->ShadowingDecls.push_back({
D, VD});
8322 if (isa<FieldDecl>(ShadowedDecl)) {
8329 ->ShadowingDecls.push_back({
D, ShadowedDecl});
8333 if (
const auto *VD = dyn_cast<VarDecl>(ShadowedDecl);
8334 VD && VD->hasLocalStorage()) {
8338 ParentDC && !ParentDC->
Equals(OldDC);
8342 if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) &&
8364 if (ReDC->
isRecord() && isa<EnumConstantDecl>(
D) && !OldDC->
Equals(ReDC))
8381 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
8388 const NamedDecl *ShadowedDecl = Shadow.ShadowedDecl;
8391 if (
const auto *VD = dyn_cast<VarDecl>(ShadowedDecl)) {
8393 Diag(Shadow.VD->getLocation(),
8394 CaptureLoc.
isInvalid() ? diag::warn_decl_shadow_uncaptured_local
8395 : diag::warn_decl_shadow)
8396 << Shadow.VD->getDeclName()
8399 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
8400 << Shadow.VD->getDeclName() << 0;
8402 }
else if (isa<FieldDecl>(ShadowedDecl)) {
8403 Diag(Shadow.VD->getLocation(),
8405 : diag::warn_decl_shadow_uncaptured_local)
8406 << Shadow.VD->getDeclName()
8419 RedeclarationKind::ForVisibleRedeclaration);
8432 auto *DRE = dyn_cast<DeclRefExpr>(
E);
8435 const NamedDecl *
D = cast<NamedDecl>(DRE->getDecl()->getCanonicalDecl());
8436 auto I = ShadowingDecls.find(
D);
8437 if (I == ShadowingDecls.end())
8439 const NamedDecl *ShadowedDecl = I->second;
8441 Diag(
Loc, diag::warn_modifying_shadowing_decl) <<
D << OldDC;
8446 ShadowingDecls.erase(I);
8454 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
8475 if (!isa<VarDecl>(ND))
8485 if (isa<VarDecl>(*I)) {
8495 if (isa<VarDecl>(*I)) {
8513 assert(Prev &&
"should have found a previous declaration to diagnose");
8515 Prev = FD->getFirstDecl();
8517 Prev = cast<VarDecl>(Prev)->getFirstDecl();
8519 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
8541 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
8553 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
8573 SemaRef.
Diag(VarLoc, diag::err_c23_constexpr_invalid_type) <<
T;
8583 SemaRef.
Diag(VarLoc, diag::err_c23_constexpr_invalid_type) <<
T;
8589 if (llvm::any_of(RD->
fields(), [&SemaRef, VarLoc](
const FieldDecl *F) {
8590 return CheckC23ConstexprVarType(SemaRef, VarLoc, F->getType());
8646 if (NewVD->
hasAttr<BlocksAttr>()) {
8654 if (!
T.isConstQualified()) {
8655 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
8661 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
8677 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
8678 <<
Scope <<
"global or constant";
8680 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
8681 <<
Scope <<
"constant";
8697 if (FD && !FD->
hasAttr<OpenCLKernelAttr>()) {
8709 if (FD && FD->
hasAttr<OpenCLKernelAttr>()) {
8734 && !NewVD->
hasAttr<BlocksAttr>()) {
8756 const auto *ATy = dyn_cast<ConstantArrayType>(
T.getTypePtr());
8757 if (!ATy || ATy->getZExtSize() != 0) {
8759 diag::err_typecheck_wasm_table_must_have_zero_length);
8769 (FD->hasAttr<CUDADeviceAttr>() || FD->hasAttr<CUDAGlobalAttr>())) {
8779 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
8785 bool SizeIsNegative;
8786 llvm::APSInt Oversized;
8791 FixedT = FixedTInfo->
getType();
8792 else if (FixedTInfo) {
8855 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
8870 diag::err_constexpr_var_non_literal)) {
8886 llvm::StringMap<bool> CallerFeatureMap;
8897 diag::err_sve_vector_in_non_streaming_function)
8907 llvm::StringMap<bool> CallerFeatureMap;
8953 dyn_cast<CXXMethodDecl>(BaseND->getCanonicalDecl());
8960 if (Overridden.insert(BaseMD).second) {
8977 return !Overridden.empty();
8983 struct ActOnFDArgs {
8999 : Context(Context), OriginalFD(TypoFD),
9002 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
9008 CDeclEnd = candidate.
end();
9009 CDecl != CDeclEnd; ++CDecl) {
9016 if (
Parent &&
Parent->getCanonicalDecl() == ExpectedParent)
9018 }
else if (!ExpectedParent) {
9027 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
9028 return std::make_unique<DifferentNameValidatorCCC>(*
this);
9054 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *S) {
9060 bool IsDefinition = ExtraArgs.D.isFunctionDefinition();
9062 IsLocalFriend ? diag::err_no_matching_local_friend :
9064 diag::err_member_decl_does_not_match;
9068 RedeclarationKind::ForVisibleRedeclaration);
9076 "Cannot have an ambiguity in previous-declaration lookup");
9078 DifferentNameValidatorCCC CCC(SemaRef.
Context, NewFD,
9080 if (!Prev.
empty()) {
9089 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
9090 NearMatches.push_back(std::make_pair(FD, ParamNum));
9097 IsLocalFriend ?
nullptr : NewDC))) {
9100 ExtraArgs.D.getIdentifierLoc());
9104 CDeclEnd = Correction.
end();
9105 CDecl != CDeclEnd; ++CDecl) {
9112 bool wasRedeclaration = ExtraArgs.D.isRedeclaration();
9125 ExtraArgs.S, ExtraArgs.D,
9128 ExtraArgs.AddToScope);
9136 Decl *Canonical =
Result->getCanonicalDecl();
9139 if ((*I)->getCanonicalDecl() == Canonical)
9146 SemaRef.
PDiag(IsLocalFriend
9147 ? diag::err_no_matching_local_friend_suggest
9148 : diag::err_member_decl_does_not_match_suggest)
9149 << Name << NewDC << IsDefinition);
9154 ExtraArgs.D.SetIdentifier(Name.getAsIdentifierInfo(),
9155 ExtraArgs.D.getIdentifierLoc());
9156 ExtraArgs.D.setRedeclaration(wasRedeclaration);
9162 << Name << NewDC << IsDefinition << NewFD->
getLocation();
9165 if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
9171 bool NewFDisConst = NewMD && NewMD->
isConst();
9174 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
9175 NearMatch != NearMatchEnd; ++NearMatch) {
9178 bool FDisConst = MD && MD->
isConst();
9179 bool IsMember = MD || !IsLocalFriend;
9182 if (
unsigned Idx = NearMatch->second) {
9186 SemaRef.
Diag(
Loc, IsMember ? diag::note_member_def_close_param_match
9187 : diag::note_local_decl_close_param_match)
9190 }
else if (FDisConst != NewFDisConst) {
9192 diag::note_member_def_close_const_match)
9194 if (
const auto &FTI = ExtraArgs.D.getFunctionTypeInfo(); !NewFDisConst)
9197 else if (FTI.hasMethodTypeQualifiers() &&
9198 FTI.getConstQualifierLoc().isValid())
9202 IsMember ? diag::note_member_def_close_match
9203 : diag::note_local_decl_close_match);
9210 switch (
D.getDeclSpec().getStorageClassSpec()) {
9211 default: llvm_unreachable(
"Unknown storage class!");
9215 SemaRef.
Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
9216 diag::err_typecheck_sclass_func);
9217 D.getMutableDeclSpec().ClearStorageClassSpecs();
9222 if (
D.getDeclSpec().isExternInLinkageSpec())
9232 SemaRef.
Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
9233 diag::err_static_block_func);
9249 bool &IsVirtualOkay) {
9254 bool isInline =
D.getDeclSpec().isInlineSpecified();
9262 SemaRef.
Diag(
D.getDeclSpec().getConstexprSpecLoc(),
9263 diag::err_c23_constexpr_not_variable);
9265 SemaRef.
Diag(
D.getDeclSpec().getConstexprSpecLoc(),
9266 diag::err_constexpr_wrong_decl_kind)
9267 <<
static_cast<int>(ConstexprKind);
9269 D.getMutableDeclSpec().ClearConstexprSpec();
9284 (
D.isFunctionDeclarator() &&
D.getFunctionTypeInfo().hasPrototype) ||
9285 (
D.getDeclSpec().isTypeRep() &&
9287 ->isFunctionProtoType()) ||
9291 "Strict prototypes are required");
9298 if (
D.isInvalidType())
9305 Expr *TrailingRequiresClause =
D.getTrailingRequiresClause();
9312 "Constructors can only be declared in a member context");
9318 isInline,
false, ConstexprKind,
9329 false, ConstexprKind,
9330 TrailingRequiresClause);
9333 if (
Record->isBeingDefined())
9342 IsVirtualOkay =
true;
9346 SemaRef.
Diag(
D.getIdentifierLoc(), diag::err_destructor_not_member);
9354 true, ConstexprKind, TrailingRequiresClause);
9359 SemaRef.
Diag(
D.getIdentifierLoc(),
9360 diag::err_conv_function_not_member);
9365 if (
D.isInvalidType())
9368 IsVirtualOkay =
true;
9373 TrailingRequiresClause);
9387 if (Name.getAsIdentifierInfo() &&
9388 Name.getAsIdentifierInfo() == cast<CXXRecordDecl>(DC)->getIdentifier()){
9389 SemaRef.
Diag(
D.getIdentifierLoc(), diag::err_constructor_return_type)
9400 IsVirtualOkay = !Ret->isStatic();
9404 SemaRef.
getLangOpts().CPlusPlus &&
D.getDeclSpec().isFriendSpecified();
9414 true , ConstexprKind, TrailingRequiresClause);
9431 StringRef SizeTypeNames[] = {
"size_t",
"intptr_t",
"uintptr_t",
"ptrdiff_t"};
9439 if (Names.end() != Match)
9444 }
while (DesugaredTy != Ty);
9483 "__cl_clang_non_portable_kernel_param_types", S.
getLangOpts())) {
9485 bool IsStandardLayoutType =
true;
9491 if (!CXXRec->hasDefinition())
9493 if (!CXXRec || !CXXRec->hasDefinition() || !CXXRec->isStandardLayout())
9494 IsStandardLayoutType =
false;
9497 !IsStandardLayoutType)
9545 "__cl_clang_non_portable_kernel_param_types", S.
getLangOpts()) &&
9559 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
9606 S.
Diag(
Loc, diag::note_entity_declared_at) << PT;
9629 HistoryStack.push_back(
nullptr);
9638 VisitStack.push_back(RecTy->
getDecl());
9639 assert(VisitStack.back() &&
"First decl null?");
9642 const Decl *Next = VisitStack.pop_back_val();
9644 assert(!HistoryStack.empty());
9646 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
9647 ValidTypes.insert(Hist->getType().getTypePtr());
9655 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(Next)) {
9656 HistoryStack.push_back(Field);
9658 QualType FieldTy = Field->getType();
9662 "Unexpected type.");
9667 RD = cast<RecordDecl>(Next);
9671 VisitStack.push_back(
nullptr);
9673 for (
const auto *FD : RD->
fields()) {
9684 VisitStack.push_back(FD);
9696 diag::err_record_with_pointers_kernel_param)
9703 S.
Diag(OrigRecDecl->getLocation(), diag::note_within_field_of_type)
9704 << OrigRecDecl->getDeclName();
9709 I = HistoryStack.begin() + 1,
9710 E = HistoryStack.end();
9723 }
while (!VisitStack.empty());
9739 while (S->isClassScope() ||
9740 (LangOpts.CPlusPlus &&
9741 S->isFunctionPrototypeScope()) ||
9743 (S->getEntity() && S->getEntity()->isTransparentContext()))
9750 unsigned BuiltinID) {
9751 switch (BuiltinID) {
9752 case Builtin::BI__GetExceptionInfo:
9756 case Builtin::BIaddressof:
9757 case Builtin::BI__addressof:
9758 case Builtin::BIforward:
9759 case Builtin::BIforward_like:
9760 case Builtin::BImove:
9761 case Builtin::BImove_if_noexcept:
9762 case Builtin::BIas_const: {
9784 Diag(
D.getIdentifierLoc(), diag::err_function_decl_cmse_ns_call);
9787 llvm::append_range(TemplateParamLists, TemplateParamListsRef);
9789 if (!TemplateParamLists.empty() && !TemplateParamLists.back()->empty() &&
9790 Invented->getDepth() == TemplateParamLists.back()->getDepth())
9791 TemplateParamLists.back() = Invented;
9793 TemplateParamLists.push_back(Invented);
9801 if (
DeclSpec::TSCS TSCS =
D.getDeclSpec().getThreadStorageClassSpec())
9802 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
9803 diag::err_invalid_thread)
9806 if (
D.isFirstDeclarationOfMember())
9808 R, !(
D.isStaticMember() ||
D.isExplicitObjectMemberFunction()),
9809 D.isCtorOrDtor(),
D.getIdentifierLoc());
9811 bool isFriend =
false;
9813 bool isMemberSpecialization =
false;
9814 bool isFunctionTemplateSpecialization =
false;
9816 bool HasExplicitTemplateArgs =
false;
9819 bool isVirtualOkay =
false;
9826 if (!NewFD)
return nullptr;
9836 if (IsLocalExternDecl)
9846 bool ImplicitInlineCXX20 = !
getLangOpts().CPlusPlusModules ||
9850 bool isInline =
D.getDeclSpec().isInlineSpecified();
9851 bool isVirtual =
D.getDeclSpec().isVirtualSpecified();
9852 bool hasExplicit =
D.getDeclSpec().hasExplicitSpecifier();
9853 isFriend =
D.getDeclSpec().isFriendSpecified();
9854 if (ImplicitInlineCXX20 && isFriend &&
D.isFunctionDefinition()) {
9869 if (
Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
9874 if (isVirtual &&
Parent->isUnion()) {
9875 Diag(
D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_in_union);
9879 Parent->hasAttr<SYCLSpecialClassAttr>() &&
9881 NewFD->
getName() ==
"__init" &&
D.isFunctionDefinition()) {
9882 if (
auto *Def =
Parent->getDefinition())
9883 Def->setInitMethod(
true);
9888 isMemberSpecialization =
false;
9889 isFunctionTemplateSpecialization =
false;
9890 if (
D.isInvalidType())
9898 ?
D.getName().TemplateId
9903 D.getCXXScopeSpec(), TemplateId, TemplateParamLists, isFriend,
9904 isMemberSpecialization,
Invalid);
9905 if (TemplateParams) {
9910 if (TemplateParams->
size() > 0) {
9918 }
else if (TemplateId) {
9919 Diag(
D.getIdentifierLoc(), diag::err_function_template_partial_spec)
9935 Name, TemplateParams,
9941 if (TemplateParamLists.size() > 1) {
9948 isFunctionTemplateSpecialization =
true;
9950 if (TemplateParamLists.size() > 0)
9969 Diag(
D.getIdentifierLoc(), diag::err_template_spec_decl_friend)
9970 << Name << RemoveRange
9976 HasExplicitTemplateArgs =
true;
9983 if (!TemplateParamLists.empty() && isMemberSpecialization &&
9989 if (TemplateParamLists.size() > 0)
9994 if (isFriend && TemplateId)
9995 isFunctionTemplateSpecialization =
true;
10001 if (isFunctionTemplateSpecialization && TemplateId) {
10002 HasExplicitTemplateArgs =
true;
10033 if (!isVirtualOkay) {
10034 Diag(
D.getDeclSpec().getVirtualSpecLoc(),
10035 diag::err_virtual_non_function);
10038 Diag(
D.getDeclSpec().getVirtualSpecLoc(),
10039 diag::err_virtual_out_of_class)
10044 Diag(
D.getDeclSpec().getVirtualSpecLoc(),
10045 diag::err_virtual_member_function_template)
10054 Diag(
D.getDeclSpec().getVirtualSpecLoc(), diag::err_auto_fn_virtual);
10063 Diag(
D.getDeclSpec().getInlineSpecLoc(),
10064 diag::err_inline_declaration_block_scope) << Name
10074 !isa<CXXDeductionGuideDecl>(NewFD)) {
10077 Diag(
D.getDeclSpec().getExplicitSpecLoc(),
10078 diag::err_explicit_out_of_class)
10080 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
10081 !isa<CXXConversionDecl>(NewFD)) {
10084 Diag(
D.getDeclSpec().getExplicitSpecLoc(),
10085 diag::err_explicit_non_ctor_or_conv_function)
10099 if (isa<CXXDestructorDecl>(NewFD) &&
10102 Diag(
D.getDeclSpec().getConstexprSpecLoc(), diag::err_constexpr_dtor)
10103 <<
static_cast<int>(ConstexprKind);
10116 Diag(
D.getDeclSpec().getConstexprSpecLoc(),
10117 diag::err_invalid_consteval_decl_kind)
10124 if (
D.getDeclSpec().isModulePrivateSpecified()) {
10125 if (isFunctionTemplateSpecialization) {
10127 =
D.getDeclSpec().getModulePrivateSpecLoc();
10128 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
10149 switch (
D.getFunctionDefinitionKind()) {
10163 if (ImplicitInlineCXX20 && isa<CXXMethodDecl>(NewFD) && DC ==
CurContext &&
10164 D.isFunctionDefinition()) {
10174 if (!isFriend && SC !=
SC_None) {
10182 if (isFunctionTemplateSpecialization || isMemberSpecialization) {
10183 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
10184 diag::ext_explicit_specialization_storage_class)
10186 D.getDeclSpec().getStorageClassSpecLoc());
10190 assert(isa<CXXMethodDecl>(NewFD) &&
10191 "Out-of-line member function should be a CXXMethodDecl");
10203 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
10205 cast<CXXRecordDecl>(DC)->getDescribedClassTemplate()) ||
10208 ? diag::ext_static_out_of_line
10209 : diag::err_static_out_of_line)
10211 D.getDeclSpec().getStorageClassSpecLoc());
10219 if ((Name.getCXXOverloadedOperator() == OO_Delete ||
10220 Name.getCXXOverloadedOperator() == OO_Array_Delete) &&
10233 if (isInline && !
D.isFunctionDefinition() &&
getLangOpts().CPlusPlus20 &&
10235 PendingInlineFuncDecls.insert(NewFD);
10241 D.getCXXScopeSpec().isNotEmpty() ||
10242 isMemberSpecialization ||
10243 isFunctionTemplateSpecialization);
10253 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
10269 if (
D.isFunctionDeclarator(FTIIdx)) {
10278 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
10282 Params.push_back(Param);
10297 auto *TD = dyn_cast<TagDecl>(NonParmDecl);
10302 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
10303 TD = cast<EnumDecl>(ECD->getDeclContext());
10307 DeclContext *TagDC = TD->getLexicalDeclContext();
10311 TD->setDeclContext(NewFD);
10319 if (TagDC != PrototypeTagContext)
10320 TD->setLexicalDeclContext(TagDC);
10334 for (
const auto &AI : FT->param_types()) {
10338 Params.push_back(Param);
10342 "Should not need args for typedef of non-prototype fn");
10346 NewFD->setParams(Params);
10348 if (
D.getDeclSpec().isNoreturnSpecified())
10350 C11NoReturnAttr::Create(
Context,
D.getDeclSpec().getNoreturnSpecLoc()));
10362 !NewFD->
hasAttr<SectionAttr>())
10363 NewFD->
addAttr(PragmaClangTextSectionAttr::CreateImplicit(
10368 if (
CodeSegStack.CurrentValue &&
D.isFunctionDefinition() &&
10369 !NewFD->
hasAttr<SectionAttr>()) {
10370 NewFD->
addAttr(SectionAttr::CreateImplicit(
10372 CodeSegStack.CurrentPragmaLocation, SectionAttr::Declspec_allocate));
10383 !NewFD->
hasAttr<StrictGuardStackCheckAttr>())
10384 NewFD->
addAttr(StrictGuardStackCheckAttr::CreateImplicit(
10389 if (!NewFD->
hasAttr<CodeSegAttr>()) {
10391 D.isFunctionDefinition())) {
10398 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
10400 !NewTVA->isDefaultVersion() &&
10403 AddToScope =
false;
10415 Diag(NewFD->
getLocation(), diag::err_return_value_with_address_space);
10430 isMemberSpecialization,
10431 D.isFunctionDefinition()));
10434 D.setRedeclaration(
true);
10437 "previous declaration set still overloaded");
10443 if (isa<FunctionNoProtoType>(FT) && !
D.isFunctionDefinition()) {
10449 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
10468 if (
D.getDeclSpec().isInlineSpecified() &&
10471 Diag(
D.getDeclSpec().getInlineSpecLoc(),
10472 diag::ext_operator_new_delete_declared_inline)
10499 if (isFunctionTemplateSpecialization || isMemberSpecialization) {
10511 Diag(TRC->getBeginLoc(), diag::err_non_temp_spec_requires_clause)
10514 !
D.isFunctionDefinition()) {
10519 diag::err_non_temp_friend_decl_with_requires_clause_must_be_def);
10522 !(isa<CXXMethodDecl>(NewFD) ||
D.isFunctionDefinition())) {
10523 Diag(TRC->getBeginLoc(),
10524 diag::err_constrained_non_templated_function);
10541 if (isFunctionTemplateSpecialization) {
10542 bool isDependentSpecialization =
false;
10547 isDependentSpecialization =
10549 (HasExplicitTemplateArgs &&
10553 assert((!isDependentSpecialization ||
10554 (HasExplicitTemplateArgs == isDependentSpecialization)) &&
10555 "dependent friend function specialization without template "
10561 isDependentSpecialization =
10566 HasExplicitTemplateArgs ? &TemplateArgs :
nullptr;
10567 if (isDependentSpecialization) {
10574 NewFD, ExplicitTemplateArgs,
Previous))
10595 isMemberSpecialization,
10596 D.isFunctionDefinition()));
10599 D.setRedeclaration(
true);
10602 !
D.isRedeclaration() ||
10604 "previous declaration set still overloaded");
10631 D.getDeclSpec().isFriendSpecified()
10632 ? (
D.isFunctionDefinition()
10635 : (
D.getCXXScopeSpec().isSet() &&
10644 }
else if (!
D.isRedeclaration()) {
10645 struct ActOnFDArgs ExtraArgs = { S,
D, TemplateParamLists,
10652 if (
D.getCXXScopeSpec().isSet()) {
10667 (
D.getCXXScopeSpec().getScopeRep()->isDependent() ||
10691 *
this,
Previous, NewFD, ExtraArgs,
false,
nullptr)) {
10692 AddToScope = ExtraArgs.AddToScope;
10699 }
else if (isFriend && cast<CXXRecordDecl>(
CurContext)->isLocalClass()) {
10701 *
this,
Previous, NewFD, ExtraArgs,
true, S)) {
10702 AddToScope = ExtraArgs.AddToScope;
10706 }
else if (!
D.isFunctionDefinition() &&
10707 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
10708 !isFriend && !isFunctionTemplateSpecialization &&
10709 !isMemberSpecialization) {
10718 <<
D.getCXXScopeSpec().getRange();
10724 if (!NewFD->
isInvalidDecl() && S->getDepth() == 0 && Name.isIdentifier())
10727 if (NewFD->
hasAttr<HLSLShaderAttr>())
10733 if (!
D.isRedeclaration()) {
10735 if (
unsigned BuiltinID = II->getBuiltinID()) {
10737 if (!InStdNamespace &&
10743 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
10752 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
10757 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
10768 if (NewFD->
hasAttr<OverloadableAttr>() &&
10771 diag::err_attribute_overloadable_no_prototype)
10773 NewFD->
dropAttr<OverloadableAttr>();
10787 if (
D.isFunctionDefinition()) {
10803 if (
D.isRedeclaration() && !
Previous.empty()) {
10806 isMemberSpecialization ||
10807 isFunctionTemplateSpecialization,
10808 D.isFunctionDefinition());
10813 if (II && II->
isStr(
CUDA().getConfigureFuncName()) &&
10826 (NewFD->
hasAttr<CUDADeviceAttr>() ||
10827 NewFD->
hasAttr<CUDAGlobalAttr>()) &&
10829 !
D.isFunctionDefinition())) {
10841 Diag(
D.getIdentifierLoc(), diag::err_static_kernel);
10842 D.setInvalidType();
10848 Diag(
D.getIdentifierLoc(), diag::err_expected_kernel_void_return_type)
10851 D.setInvalidType();
10860 Diag(
D.getIdentifierLoc(), diag::err_method_kernel);
10861 D.setInvalidType();
10864 Diag(
D.getIdentifierLoc(), diag::err_template_kernel);
10865 D.setInvalidType();
10880 if (!
D.isFunctionDefinition()) {
10882 diag::err_friend_decl_with_enclosing_temp_constraint_must_be_def);
10902 if (
getLangOpts().getOpenCLCompatibleVersion() >= 200) {
10904 QualType ElemTy = PipeTy->getElementType();
10906 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type);
10907 D.setInvalidType();
10914 Diag(Param->getTypeSpecStartLoc(),
10915 diag::err_wasm_table_as_function_parameter);
10916 D.setInvalidType();
10923 if (
const auto *
attr = NewFD->
getAttr<AvailabilityAttr>()) {
10924 if (NewFD->
hasAttr<ConstructorAttr>()) {
10925 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
10927 NewFD->
dropAttr<AvailabilityAttr>();
10929 if (NewFD->
hasAttr<DestructorAttr>()) {
10930 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
10932 NewFD->
dropAttr<AvailabilityAttr>();
10943 if (
const auto *NBA = NewFD->
getAttr<NoBuiltinAttr>())
10944 switch (
D.getFunctionDefinitionKind()) {
10947 Diag(NBA->getLocation(),
10948 diag::err_attribute_no_builtin_on_defaulted_deleted_function)
10949 << NBA->getSpelling();
10952 Diag(NBA->getLocation(), diag::err_attribute_no_builtin_on_non_definition)
10953 << NBA->getSpelling();
10981 const auto *Method = dyn_cast<CXXMethodDecl>(FD);
10985 if (
const auto *SAttr =
Parent->getAttr<CodeSegAttr>()) {
10996 while ((
Parent = dyn_cast<CXXRecordDecl>(
Parent->getParent()))) {
10997 if (
const auto *SAttr =
Parent->getAttr<CodeSegAttr>()) {
11007 bool IsDefinition) {
11010 if (!FD->
hasAttr<SectionAttr>() && IsDefinition &&
11012 return SectionAttr::CreateImplicit(
11014 CodeSegStack.CurrentPragmaLocation, SectionAttr::Declspec_allocate);
11062 auto *VD = dyn_cast<ValueDecl>(
D);
11063 auto *PrevVD = dyn_cast<ValueDecl>(PrevDecl);
11064 return !VD || !PrevVD ||
11066 PrevVD->getType());
11074 const auto *TA = FD->
getAttr<TargetAttr>();
11075 const auto *TVA = FD->
getAttr<TargetVersionAttr>();
11077 assert((TA || TVA) &&
"Expecting target or target_version attribute");
11090 for (
const auto &Feat : ParseInfo.
Features) {
11091 auto BareFeat = StringRef{Feat}.substr(1);
11092 if (Feat[0] ==
'-') {
11094 << Feature << (
"no-" + BareFeat).str();
11101 << Feature << BareFeat;
11113 for (
auto &Feat : ParseInfo.
Features)
11114 Feats.push_back(StringRef{Feat}.substr(1));
11117 TVA->getFeatures(Feats);
11119 for (
const auto &Feat : Feats) {
11122 << Feature << Feat;
11139 case attr::ArmLocallyStreaming:
11144 case attr::NonNull:
11145 case attr::NoThrow:
11154 const auto Diagnose = [FD, CausedFD, MVKind](
Sema &S,
const Attr *A) {
11155 S.
Diag(FD->
getLocation(), diag::err_multiversion_disallowed_other_attr)
11156 <<
static_cast<unsigned>(MVKind) << A;
11158 S.
Diag(CausedFD->
getLocation(), diag::note_multiversioning_caused_here);
11163 switch (A->getKind()) {
11164 case attr::CPUDispatch:
11165 case attr::CPUSpecific:
11168 return Diagnose(S, A);
11172 return Diagnose(S, A);
11174 case attr::TargetVersion:
11177 return Diagnose(S, A);
11179 case attr::TargetClones:
11182 return Diagnose(S, A);
11186 return Diagnose(S, A);
11199 bool ConstexprSupported,
bool CLinkageMayDiffer) {
11200 enum DoesntSupport {
11207 DefaultedFuncs = 6,
11208 ConstexprFuncs = 7,
11209 ConstevalFuncs = 8,
11221 if (NoProtoDiagID.
getDiagID() != 0 && OldFD &&
11224 Diag(NoteCausedDiagIDAt.first, NoteCausedDiagIDAt.second);
11232 if (!TemplatesSupported &&
11234 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11237 if (
const auto *NewCXXFD = dyn_cast<CXXMethodDecl>(NewFD)) {
11238 if (NewCXXFD->isVirtual())
11239 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11242 if (isa<CXXConstructorDecl>(NewCXXFD))
11243 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11246 if (isa<CXXDestructorDecl>(NewCXXFD))
11247 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11252 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11256 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11260 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11261 << (NewFD->
isConsteval() ? ConstevalFuncs : ConstexprFuncs);
11264 const auto *NewType = cast<FunctionType>(NewQType);
11265 QualType NewReturnType = NewType->getReturnType();
11268 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11274 const auto *OldType = cast<FunctionType>(OldQType);
11281 bool ArmStreamingCCMismatched =
false;
11282 if (OldFPT && NewFPT) {
11289 ArmStreamingCCMismatched =
true;
11292 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC() || ArmStreamingCCMismatched)
11295 QualType OldReturnType = OldType->getReturnType();
11297 if (OldReturnType != NewReturnType)
11298 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ReturnType;
11301 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ConstexprSpec;
11304 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << InlineSpec;
11307 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) <<
Linkage;
11330 bool IsCPUSpecificCPUDispatchMVKind =
11334 if (CausesMV && OldFD &&
11342 if (OldFD && CausesMV && OldFD->
isUsed(
false))
11343 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
11346 OldFD, NewFD, S.
PDiag(diag::err_multiversion_noproto),
11348 S.
PDiag(diag::note_multiversioning_caused_here)),
11350 S.
PDiag(diag::err_multiversion_doesnt_support)
11351 <<
static_cast<unsigned>(MVKind)),
11353 S.
PDiag(diag::err_multiversion_diff)),
11355 !IsCPUSpecificCPUDispatchMVKind,
11368 "Function lacks multiversion attribute");
11369 const auto *TA = FD->
getAttr<TargetAttr>();
11370 const auto *TVA = FD->
getAttr<TargetVersionAttr>();
11373 if (TA && !TA->isDefaultVersion())
11410 To->
addAttr(TargetVersionAttr::CreateImplicit(
11416 bool &Redeclaration,
11421 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11422 const auto *OldTA = OldFD->
getAttr<TargetAttr>();
11423 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11424 const auto *OldTVA = OldFD->
getAttr<TargetVersionAttr>();
11426 assert((NewTA || NewTVA) &&
"Excpecting target or target_version attribute");
11435 if (NewTA && !NewTA->isDefaultVersion() &&
11436 (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr()))
11453 if ((NewTA && NewTA->isDefaultVersion() && !OldTA) ||
11454 (NewTVA && NewTVA->isDefaultVersion() && !OldTVA)) {
11455 Redeclaration =
true;
11463 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
11471 OldTA->getFeaturesStr());
11475 NewTA->getFeaturesStr());
11478 if (OldParsed == NewParsed) {
11486 for (
const auto *FD : OldFD->
redecls()) {
11487 const auto *CurTA = FD->
getAttr<TargetAttr>();
11488 const auto *CurTVA = FD->
getAttr<TargetVersionAttr>();
11492 ((NewTA && (!CurTA || CurTA->isInherited())) ||
11493 (NewTVA && (!CurTVA || CurTVA->isInherited())))) {
11495 << (NewTA ? 0 : 2);
11496 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
11504 Redeclaration =
false;
11543 const CPUDispatchAttr *NewCPUDisp,
const CPUSpecificAttr *NewCPUSpec,
11544 const TargetClonesAttr *NewClones,
bool &Redeclaration,
NamedDecl *&OldDecl,
11559 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11560 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11567 NewTA->getFeaturesStr());
11572 NewTVA->getFeatures(NewFeats);
11573 llvm::sort(NewFeats);
11576 bool UseMemberUsingDeclRules =
11579 bool MayNeedOverloadableChecks =
11588 if (MayNeedOverloadableChecks &&
11589 S.
IsOverload(NewFD, CurFD, UseMemberUsingDeclRules))
11592 switch (NewMVKind) {
11595 "Only target_clones can be omitted in subsequent declarations");
11598 const auto *CurTA = CurFD->
getAttr<TargetAttr>();
11599 if (CurTA->getFeaturesStr() == NewTA->getFeaturesStr()) {
11601 Redeclaration =
true;
11608 CurTA->getFeaturesStr());
11610 if (CurParsed == NewParsed) {
11619 if (
const auto *CurTVA = CurFD->
getAttr<TargetVersionAttr>()) {
11620 if (CurTVA->getName() == NewTVA->getName()) {
11622 Redeclaration =
true;
11627 CurTVA->getFeatures(CurFeats);
11628 llvm::sort(CurFeats);
11630 if (CurFeats == NewFeats) {
11636 }
else if (
const auto *CurClones = CurFD->
getAttr<TargetClonesAttr>()) {
11638 if (NewFeats.empty())
11641 for (
unsigned I = 0; I < CurClones->featuresStrs_size(); ++I) {
11643 CurClones->getFeatures(CurFeats, I);
11644 llvm::sort(CurFeats);
11646 if (CurFeats == NewFeats) {
11657 assert(NewClones &&
"MultiVersionKind does not match attribute type");
11658 if (
const auto *CurClones = CurFD->
getAttr<TargetClonesAttr>()) {
11659 if (CurClones->featuresStrs_size() != NewClones->featuresStrs_size() ||
11660 !std::equal(CurClones->featuresStrs_begin(),
11661 CurClones->featuresStrs_end(),
11662 NewClones->featuresStrs_begin())) {
11668 }
else if (
const auto *CurTVA = CurFD->
getAttr<TargetVersionAttr>()) {
11670 CurTVA->getFeatures(CurFeats);
11671 llvm::sort(CurFeats);
11674 if (CurFeats.empty())
11677 for (
unsigned I = 0; I < NewClones->featuresStrs_size(); ++I) {
11679 NewClones->getFeatures(NewFeats, I);
11680 llvm::sort(NewFeats);
11682 if (CurFeats == NewFeats) {
11691 Redeclaration =
true;
11698 const auto *CurCPUSpec = CurFD->
getAttr<CPUSpecificAttr>();
11699 const auto *CurCPUDisp = CurFD->
getAttr<CPUDispatchAttr>();
11704 CurFD->
hasAttr<CPUDispatchAttr>()) {
11705 if (CurCPUDisp->cpus_size() == NewCPUDisp->cpus_size() &&
11707 CurCPUDisp->cpus_begin(), CurCPUDisp->cpus_end(),
11708 NewCPUDisp->cpus_begin(),
11710 return Cur->getName() == New->getName();
11713 Redeclaration =
true;
11725 if (CurCPUSpec->cpus_size() == NewCPUSpec->cpus_size() &&
11727 CurCPUSpec->cpus_begin(), CurCPUSpec->cpus_end(),
11728 NewCPUSpec->cpus_begin(),
11730 return Cur->getName() == New->getName();
11733 Redeclaration =
true;
11741 if (CurII == NewII) {
11774 Redeclaration =
true;
11780 Redeclaration =
false;
11793 bool &Redeclaration,
NamedDecl *&OldDecl,
11801 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11802 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11803 const auto *NewCPUDisp = NewFD->
getAttr<CPUDispatchAttr>();
11804 const auto *NewCPUSpec = NewFD->
getAttr<CPUSpecificAttr>();
11805 const auto *NewClones = NewFD->
getAttr<TargetClonesAttr>();
11815 NewTVA->isDefaultVersion())) {
11816 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_not_allowed_on_main);
11824 if (NewTA && TI.
getTriple().isAArch64())
11851 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_required_in_redecl)
11862 S, OldFD, NewFD, Redeclaration, OldDecl,
Previous);
11864 if (OldFD->
isUsed(
false)) {
11866 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
11882 NewCPUSpec, NewClones, Redeclaration,
11887 bool IsPure = NewFD->
hasAttr<PureAttr>();
11888 bool IsConst = NewFD->
hasAttr<ConstAttr>();
11891 if (!IsPure && !IsConst)
11898 if (IsPure && IsConst) {
11908 NewFD->
dropAttrs<PureAttr, ConstAttr>();
11914 bool IsMemberSpecialization,
11917 "Variably modified return types are not handled here");
11922 bool MergeTypeWithPrevious = !
getLangOpts().CPlusPlus &&
11925 bool Redeclaration =
false;
11927 bool MayNeedOverloadableChecks =
false;
11939 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
11940 Redeclaration =
true;
11941 OldDecl = Candidate;
11944 MayNeedOverloadableChecks =
true;
11948 Redeclaration =
true;
11952 Redeclaration =
true;
11956 Redeclaration =
false;
11963 if (!Redeclaration &&
11968 Redeclaration =
true;
11969 OldDecl =
Previous.getFoundDecl();
11970 MergeTypeWithPrevious =
false;
11973 if (OldDecl->
hasAttr<OverloadableAttr>() ||
11974 NewFD->
hasAttr<OverloadableAttr>()) {
11975 if (
IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
11976 MayNeedOverloadableChecks =
true;
11977 Redeclaration =
false;
11985 return Redeclaration;
12035 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
12039 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
12040 if (!OldMD || !OldMD->
isStatic()) {
12062 if (Redeclaration) {
12068 return Redeclaration;
12075 dyn_cast<FunctionTemplateDecl>(OldDecl)) {
12076 auto *OldFD = OldTemplateDecl->getTemplatedDecl();
12079 assert(NewTemplateDecl &&
"Template/non-template mismatch");
12088 NewFD->
setAccess(OldTemplateDecl->getAccess());
12089 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
12094 if (IsMemberSpecialization &&
12097 assert(OldTemplateDecl->isMemberSpecialization());
12100 if (OldFD->isDeleted()) {
12102 assert(OldFD->getCanonicalDecl() == OldFD);
12104 OldFD->setDeletedAsWritten(
false);
12110 auto *OldFD = cast<FunctionDecl>(OldDecl);
12118 !NewFD->
getAttr<OverloadableAttr>()) {
12122 return ND->hasAttr<OverloadableAttr>();
12124 "Non-redecls shouldn't happen without overloadable present");
12127 const auto *FD = dyn_cast<FunctionDecl>(ND);
12128 return FD && !FD->
hasAttr<OverloadableAttr>();
12131 if (OtherUnmarkedIter !=
Previous.end()) {
12133 diag::err_attribute_overloadable_multiple_unmarked_overloads);
12134 Diag((*OtherUnmarkedIter)->getLocation(),
12135 diag::note_attribute_overloadable_prev_overload)
12155 dyn_cast<CXXDestructorDecl>(NewFD)) {
12163 !
Destructor->getFunctionObjectParameterType()->isDependentType()) {
12172 return Redeclaration;
12175 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
12176 if (
auto *TD = Guide->getDescribedFunctionTemplate())
12182 Diag(Guide->getBeginLoc(), diag::err_deduction_guide_specialized)
12187 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
12188 if (!Method->isFunctionTemplateSpecialization() &&
12189 !Method->getDescribedFunctionTemplate() &&
12190 Method->isCanonicalDecl()) {
12197 diag::err_constrained_virtual_method);
12199 if (Method->isStatic())
12210 return Redeclaration;
12217 return Redeclaration;
12237 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
12250 auto HasNoexcept = [&](
QualType T) ->
bool {
12261 if (FPT->isNothrow())
12267 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
12269 AnyNoexcept |= HasNoexcept(
T);
12272 diag::warn_cxx17_compat_exception_spec_in_signature)
12276 if (!Redeclaration &&
LangOpts.CUDA) {
12277 bool IsKernel = NewFD->
hasAttr<CUDAGlobalAttr>();
12279 if (!Parm->getType()->isDependentType() &&
12280 Parm->hasAttr<CUDAGridConstantAttr>() &&
12281 !(IsKernel && Parm->getType().isConstQualified()))
12282 Diag(Parm->getAttr<CUDAGridConstantAttr>()->getLocation(),
12283 diag::err_cuda_grid_constant_not_allowed);
12294 bool UsesSM = NewFD->
hasAttr<ArmLocallyStreamingAttr>();
12295 bool UsesZA =
Attr &&
Attr->isNewZA();
12296 bool UsesZT0 =
Attr &&
Attr->isNewZT0();
12298 if (NewFD->
hasAttr<ArmLocallyStreamingAttr>()) {
12301 diag::warn_sme_locally_streaming_has_vl_args_returns)
12304 return P->getOriginalType()->isSizelessVectorType();
12307 diag::warn_sme_locally_streaming_has_vl_args_returns)
12320 if (UsesSM || UsesZA) {
12321 llvm::StringMap<bool> FeatureMap;
12323 if (!FeatureMap.contains(
"sme")) {
12326 diag::err_sme_definition_using_sm_in_non_sme_target);
12329 diag::err_sme_definition_using_za_in_non_sme_target);
12333 llvm::StringMap<bool> FeatureMap;
12335 if (!FeatureMap.contains(
"sme2")) {
12337 diag::err_sme_definition_using_zt0_in_non_sme2_target);
12342 return Redeclaration;
12351 Diag(FD->
getLocation(), diag::ext_main_invalid_linkage_specification)
12363 ? diag::err_static_main : diag::warn_static_main)
12371 Diag(NoreturnLoc, diag::ext_noreturn_main);
12372 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
12384 << FD->
hasAttr<OpenCLKernelAttr>();
12395 assert(
T->
isFunctionType() &&
"function decl is not of function type");
12417 Diag(RTRange.
getBegin(), diag::note_main_change_return_type)
12439 if (isa<FunctionNoProtoType>(FT))
return;
12445 bool HasExtraParameters = (nparams > 3);
12457 HasExtraParameters =
false;
12459 if (HasExtraParameters) {
12472 for (
unsigned i = 0; i < nparams; ++i) {
12475 bool mismatch =
true;
12492 mismatch = !qs.
empty();
12521 if (
T.isWindowsGNUEnvironment())
12526 if (
T.isOSWindows() &&
T.getArch() == llvm::Triple::x86)
12534 assert(
T->
isFunctionType() &&
"function decl is not of function type");
12543 if (FD->
getName() !=
"DllMain")
12577 if (
Init->isValueDependent()) {
12578 assert(
Init->containsErrors() &&
12579 "Dependent code should only occur in error-recovery path.");
12582 const Expr *Culprit;
12583 if (
Init->isConstantInitializer(
Context,
false, &Culprit))
12592 class SelfReferenceChecker
12598 bool isReferenceType;
12606 SelfReferenceChecker(
Sema &S,
Decl *OrigDecl) : Inherited(S.Context),
12607 S(S), OrigDecl(OrigDecl) {
12610 isReferenceType =
false;
12611 isInitList =
false;
12612 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
12613 isPODType = VD->getType().isPODType(S.
Context);
12615 isReferenceType = VD->getType()->isReferenceType();
12622 void CheckExpr(
Expr *
E) {
12631 InitFieldIndex.push_back(0);
12632 for (
auto *Child : InitList->
children()) {
12633 CheckExpr(cast<Expr>(Child));
12634 ++InitFieldIndex.back();
12636 InitFieldIndex.pop_back();
12641 bool CheckInitListMemberExpr(
MemberExpr *
E,
bool CheckReference) {
12644 bool ReferenceField =
false;
12648 FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl());
12651 Fields.push_back(FD);
12653 ReferenceField =
true;
12654 Base = ME->getBase()->IgnoreParenImpCasts();
12659 if (!DRE || DRE->
getDecl() != OrigDecl)
12663 if (CheckReference && !ReferenceField)
12668 for (
const FieldDecl *I : llvm::reverse(Fields))
12669 UsedFieldIndex.push_back(I->getFieldIndex());
12674 for (
auto UsedIter = UsedFieldIndex.begin(),
12675 UsedEnd = UsedFieldIndex.end(),
12676 OrigIter = InitFieldIndex.begin(),
12677 OrigEnd = InitFieldIndex.end();
12678 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
12679 if (*UsedIter < *OrigIter)
12681 if (*UsedIter > *OrigIter)
12686 HandleDeclRefExpr(DRE);
12693 void HandleValue(
Expr *
E) {
12696 HandleDeclRefExpr(DRE);
12701 Visit(CO->getCond());
12702 HandleValue(CO->getTrueExpr());
12703 HandleValue(CO->getFalseExpr());
12708 dyn_cast<BinaryConditionalOperator>(
E)) {
12709 Visit(BCO->getCond());
12710 HandleValue(BCO->getFalseExpr());
12715 if (
Expr *SE = OVE->getSourceExpr())
12721 if (BO->getOpcode() == BO_Comma) {
12722 Visit(BO->getLHS());
12723 HandleValue(BO->getRHS());
12728 if (isa<MemberExpr>(
E)) {
12730 if (CheckInitListMemberExpr(cast<MemberExpr>(
E),
12738 if (!isa<FieldDecl>(ME->getMemberDecl()))
12740 Base = ME->getBase()->IgnoreParenImpCasts();
12743 HandleDeclRefExpr(DRE);
12753 if (isReferenceType)
12754 HandleDeclRefExpr(
E);
12758 if (
E->getCastKind() == CK_LValueToRValue) {
12759 HandleValue(
E->getSubExpr());
12763 Inherited::VisitImplicitCastExpr(
E);
12768 if (CheckInitListMemberExpr(
E,
true ))
12777 CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(
E->getMemberDecl());
12778 bool Warn = (MD && !MD->
isStatic());
12781 if (!isa<FieldDecl>(ME->getMemberDecl()))
12783 Base = ME->getBase()->IgnoreParenImpCasts();
12788 HandleDeclRefExpr(DRE);
12800 if (isa<UnresolvedLookupExpr>(Callee))
12801 return Inherited::VisitCXXOperatorCallExpr(
E);
12804 for (
auto Arg:
E->arguments())
12805 HandleValue(Arg->IgnoreParenImpCasts());
12813 HandleValue(
E->getSubExpr());
12817 if (
E->isIncrementDecrementOp()) {
12818 HandleValue(
E->getSubExpr());
12822 Inherited::VisitUnaryOperator(
E);
12828 if (
E->getConstructor()->isCopyConstructor()) {
12829 Expr *ArgExpr =
E->getArg(0);
12830 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
12831 if (ILE->getNumInits() == 1)
12832 ArgExpr = ILE->getInit(0);
12834 if (ICE->getCastKind() == CK_NoOp)
12835 ArgExpr = ICE->getSubExpr();
12836 HandleValue(ArgExpr);
12839 Inherited::VisitCXXConstructExpr(
E);
12844 if (
E->isCallToStdMove()) {
12845 HandleValue(
E->getArg(0));
12849 Inherited::VisitCallExpr(
E);
12853 if (
E->isCompoundAssignmentOp()) {
12854 HandleValue(
E->getLHS());
12855 Visit(
E->getRHS());
12859 Inherited::VisitBinaryOperator(
E);
12866 Visit(
E->getCond());
12867 Visit(
E->getFalseExpr());
12872 if (OrigDecl != ReferenceDecl)
return;
12874 if (isReferenceType) {
12875 diag = diag::warn_uninit_self_reference_in_reference_init;
12876 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
12877 diag = diag::warn_static_self_reference_in_init;
12878 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
12881 diag = diag::warn_uninit_self_reference_in_init;
12895 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *
E,
12899 if (isa<ParmVarDecl>(OrigDecl))
12908 if (ICE->getCastKind() == CK_LValueToRValue)
12909 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
12910 if (DRE->
getDecl() == OrigDecl)
12913 SelfReferenceChecker(S, OrigDecl).CheckExpr(
E);
12920 struct VarDeclOrName {
12926 return VN.VDecl ?
Diag << VN.VDecl :
Diag << VN.Name;
12936 bool IsInitCapture = !VDecl;
12938 "init captures are expected to be deduced prior to initialization");
12940 VarDeclOrName VN{VDecl, Name};
12943 assert(Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
12947 !isa_and_present<StringLiteral, InitListExpr>(
Init)) {
12956 assert(VDecl &&
"no init for init capture deduction?");
12960 if (!isa<DeducedTemplateSpecializationType>(Deduced) ||
12971 DeduceInits =
Init;
12973 auto *PL = dyn_cast_if_present<ParenListExpr>(
Init);
12975 DeduceInits = PL->exprs();
12977 if (isa<DeducedTemplateSpecializationType>(Deduced)) {
12978 assert(VDecl &&
"non-auto type for init capture deduction?");
12989 if (
auto *IL = dyn_cast<InitListExpr>(
Init))
12990 DeduceInits = IL->inits();
12994 if (DeduceInits.empty()) {
12997 Diag(
Init->getBeginLoc(), IsInitCapture
12998 ? diag::err_init_capture_no_expression
12999 : diag::err_auto_var_init_no_expression)
13004 if (DeduceInits.size() > 1) {
13005 Diag(DeduceInits[1]->getBeginLoc(),
13006 IsInitCapture ? diag::err_init_capture_multiple_expressions
13007 : diag::err_auto_var_init_multiple_expressions)
13012 Expr *DeduceInit = DeduceInits[0];
13013 if (
DirectInit && isa<InitListExpr>(DeduceInit)) {
13014 Diag(
Init->getBeginLoc(), IsInitCapture
13015 ? diag::err_init_capture_paren_braces
13016 : diag::err_auto_var_init_paren_braces)
13022 bool DefaultedAnyToId =
false;
13026 if (
Result.isInvalid()) {
13030 DefaultedAnyToId =
true;
13036 if (VDecl && isa<DecompositionDecl>(VDecl) &&
13040 Type.getQualifiers());
13048 if (!IsInitCapture)
13050 else if (isa<InitListExpr>(
Init))
13052 diag::err_init_capture_deduction_failure_from_init_list)
13081 assert(!
Init || !
Init->containsErrors());
13094 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(VDecl))
13115 if (
auto *EWC = dyn_cast<ExprWithCleanups>(
Init))
13116 Init = EWC->getSubExpr();
13118 if (
auto *CE = dyn_cast<ConstantExpr>(
Init))
13119 Init = CE->getSubExpr();
13124 "shouldn't be called if type doesn't have a non-trivial C struct");
13125 if (
auto *ILE = dyn_cast<InitListExpr>(
Init)) {
13126 for (
auto *I : ILE->inits()) {
13127 if (!I->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion() &&
13128 !I->getType().hasNonTrivialToPrimitiveCopyCUnion())
13136 if (isa<ImplicitValueInitExpr>(
Init)) {
13152bool shouldIgnoreForRecordTriviality(
const FieldDecl *FD) {
13158 return FD->
hasAttr<UnavailableAttr>();
13161struct DiagNonTrivalCUnionDefaultInitializeVisitor
13168 DiagNonTrivalCUnionDefaultInitializeVisitor(
13171 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13174 const FieldDecl *FD,
bool InNonTrivialUnion) {
13177 InNonTrivialUnion);
13178 return Super::visitWithKind(PDIK, QT, FD, InNonTrivialUnion);
13182 bool InNonTrivialUnion) {
13183 if (InNonTrivialUnion)
13185 << 1 << 0 << QT << FD->
getName();
13189 if (InNonTrivialUnion)
13191 << 1 << 0 << QT << FD->
getName();
13197 if (OrigLoc.isValid()) {
13198 bool IsUnion =
false;
13199 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13200 IsUnion = OrigRD->isUnion();
13201 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13202 << 0 << OrigTy << IsUnion << UseContext;
13206 InNonTrivialUnion =
true;
13209 if (InNonTrivialUnion)
13214 if (!shouldIgnoreForRecordTriviality(FD))
13215 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13228struct DiagNonTrivalCUnionDestructedTypeVisitor
13233 DiagNonTrivalCUnionDestructedTypeVisitor(
13236 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13239 const FieldDecl *FD,
bool InNonTrivialUnion) {
13242 InNonTrivialUnion);
13243 return Super::visitWithKind(DK, QT, FD, InNonTrivialUnion);
13247 bool InNonTrivialUnion) {
13248 if (InNonTrivialUnion)
13250 << 1 << 1 << QT << FD->
getName();
13254 if (InNonTrivialUnion)
13256 << 1 << 1 << QT << FD->
getName();
13262 if (OrigLoc.isValid()) {
13263 bool IsUnion =
false;
13264 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13265 IsUnion = OrigRD->isUnion();
13266 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13267 << 1 << OrigTy << IsUnion << UseContext;
13271 InNonTrivialUnion =
true;
13274 if (InNonTrivialUnion)
13279 if (!shouldIgnoreForRecordTriviality(FD))
13280 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13285 bool InNonTrivialUnion) {}
13295struct DiagNonTrivalCUnionCopyVisitor
13302 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13305 const FieldDecl *FD,
bool InNonTrivialUnion) {
13308 InNonTrivialUnion);
13309 return Super::visitWithKind(PCK, QT, FD, InNonTrivialUnion);
13313 bool InNonTrivialUnion) {
13314 if (InNonTrivialUnion)
13316 << 1 << 2 << QT << FD->
getName();
13320 if (InNonTrivialUnion)
13322 << 1 << 2 << QT << FD->
getName();
13328 if (OrigLoc.isValid()) {
13329 bool IsUnion =
false;
13330 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13331 IsUnion = OrigRD->isUnion();
13332 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13333 << 2 << OrigTy << IsUnion << UseContext;
13337 InNonTrivialUnion =
true;
13340 if (InNonTrivialUnion)
13345 if (!shouldIgnoreForRecordTriviality(FD))
13346 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13350 const FieldDecl *FD,
bool InNonTrivialUnion) {}
13353 bool InNonTrivialUnion) {}
13367 unsigned NonTrivialKind) {
13371 "shouldn't be called if type doesn't have a non-trivial C union");
13375 DiagNonTrivalCUnionDefaultInitializeVisitor(QT,
Loc, UseContext, *
this)
13376 .
visit(QT,
nullptr,
false);
13379 DiagNonTrivalCUnionDestructedTypeVisitor(QT,
Loc, UseContext, *
this)
13380 .visit(QT,
nullptr,
false);
13382 DiagNonTrivalCUnionCopyVisitor(QT,
Loc, UseContext, *
this)
13383 .visit(QT,
nullptr,
false);
13394 if (
auto *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
13395 if (!Method->isInvalidDecl()) {
13397 Diag(Method->getLocation(), diag::err_member_function_initialization)
13398 << Method->getDeclName() <<
Init->getSourceRange();
13399 Method->setInvalidDecl();
13404 VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl);
13406 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
13416 SubExprs.push_back(Res.
get());
13425 if (!
Init->getType().isNull() &&
Init->getType()->isWebAssemblyTableType()) {
13426 Diag(
Init->getExprLoc(), diag::err_wasm_table_art) << 0;
13457 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
13478 BaseDeclType = Array->getElementType();
13480 diag::err_typecheck_decl_incomplete_type)) {
13487 diag::err_abstract_type_in_decl,
13497 !VDecl->
isTemplated() && !isa<VarTemplateSpecializationDecl>(VDecl) &&
13507 if (Def != VDecl &&
13527 Diag(
Init->getExprLoc(), diag::err_static_data_member_reinitialization)
13530 diag::note_previous_initializer)
13553 if (VDecl->
hasAttr<LoaderUninitializedAttr>()) {
13554 Diag(VDecl->
getLocation(), diag::err_loader_uninitialized_cant_init);
13568 if (!
Result.isUsable()) {
13577 bool IsParenListInit =
false;
13589 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
13591 Args[Idx], VDecl,
true,
13592 [
this, Entity, Kind](
Expr *
E) {
13598 }
else if (Res.
get() != Args[Idx]) {
13599 Args[Idx] = Res.
get();
13609 if (!
Result.isUsable()) {
13623 if (isa<DecompositionDecl>(VDecl))
13629 IsParenListInit = !InitSeq.
steps().empty() &&
13633 if (!
Init->getType().isNull() && !
Init->getType()->isDependentType() &&
13665 if (VDecl->
hasAttr<BlocksAttr>())
13679 Init->getBeginLoc()))
13680 FSI->markSafeWeakUse(
Init);
13697 if (!
Result.isUsable()) {
13730 isa<InitListExpr>(
Init)) {
13734 if (
auto *
E = dyn_cast<ExprWithCleanups>(
Init))
13735 if (
auto *BE = dyn_cast<BlockExpr>(
E->getSubExpr()->
IgnoreParens()))
13737 BE->getBlockDecl()->setCanAvoidCopyToHeap();
13772 <<
Init->getSourceRange();
13783 else if (
Init->isValueDependent())
13787 else if (
Init->getType()->isScopedEnumeralType() &&
13793 Diag(
Loc, diag::ext_in_class_initializer_non_constant)
13794 <<
Init->getSourceRange();
13798 Diag(
Loc, diag::err_in_class_initializer_non_constant)
13799 <<
Init->getSourceRange();
13809 diag::ext_in_class_initializer_float_type_cxx11)
13810 << DclT <<
Init->getSourceRange();
13812 diag::note_in_class_initializer_float_type_cxx11)
13815 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
13816 << DclT <<
Init->getSourceRange();
13819 Diag(
Init->getExprLoc(), diag::err_in_class_initializer_non_constant)
13820 <<
Init->getSourceRange();
13827 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
13828 << DclT <<
Init->getSourceRange()
13834 << DclT <<
Init->getSourceRange();
13868 if (!InitType.
isNull() &&
13887 if (CXXDirectInit) {
13888 assert(
DirectInit &&
"Call-style initializer must be direct init.");
13899 DeclsToCheckForDeferredDiags.insert(VDecl);
13908 VarDecl *VD = dyn_cast<VarDecl>(
D);
13912 if (
auto *DD = dyn_cast<DecompositionDecl>(
D))
13913 for (
auto *BD : DD->bindings())
13914 BD->setInvalidDecl();
13928 diag::err_typecheck_decl_incomplete_type)) {
13935 diag::err_abstract_type_in_decl,
13950 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
13954 if (isa<DecompositionDecl>(RealDecl)) {
13955 Diag(Var->getLocation(), diag::err_decomp_decl_requires_init) << Var;
13956 Var->setInvalidDecl();
13970 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
13971 !Var->isThisDeclarationADemotedDefinition()) {
13972 if (Var->isStaticDataMember()) {
13977 Diag(Var->getLocation(),
13978 diag::err_constexpr_static_mem_var_requires_init)
13980 Var->setInvalidDecl();
13984 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
13985 Var->setInvalidDecl();
13992 if (!Var->isInvalidDecl() &&
13994 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
13995 bool HasConstExprDefaultConstructor =
false;
13996 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
13997 for (
auto *Ctor : RD->ctors()) {
13998 if (Ctor->isConstexpr() && Ctor->getNumParams() == 0 &&
13999 Ctor->getMethodQualifiers().getAddressSpace() ==
14001 HasConstExprDefaultConstructor =
true;
14005 if (!HasConstExprDefaultConstructor) {
14006 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
14007 Var->setInvalidDecl();
14012 if (!Var->isInvalidDecl() && RealDecl->
hasAttr<LoaderUninitializedAttr>()) {
14013 if (Var->getStorageClass() ==
SC_Extern) {
14014 Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
14016 Var->setInvalidDecl();
14020 diag::err_typecheck_decl_incomplete_type)) {
14021 Var->setInvalidDecl();
14024 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
14025 if (!RD->hasTrivialDefaultConstructor()) {
14026 Diag(Var->getLocation(), diag::err_loader_uninitialized_trivial_ctor);
14027 Var->setInvalidDecl();
14037 Var->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion())
14044 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
14060 !Var->hasLinkage() && !Var->isInvalidDecl() &&
14062 diag::err_typecheck_decl_incomplete_type))
14063 Var->setInvalidDecl();
14068 diag::err_abstract_type_in_decl,
14070 Var->setInvalidDecl();
14073 Diag(Var->getLocation(), diag::warn_private_extern);
14074 Diag(Var->getLocation(), diag::note_private_extern);
14078 !Var->isInvalidDecl())
14089 if (!Var->isInvalidDecl()) {
14093 Var->getLocation(), ArrayT->getElementType(),
14094 diag::err_array_incomplete_or_sizeless_type))
14095 Var->setInvalidDecl();
14096 }
else if (Var->getStorageClass() ==
SC_Static) {
14106 if (Var->isFirstDecl())
14108 diag::ext_typecheck_decl_incomplete_type);
14113 if (!Var->isInvalidDecl())
14121 if (Var->isConstexpr())
14122 Diag(Var->getLocation(), diag::err_constexpr_var_requires_const_init)
14125 Diag(Var->getLocation(),
14126 diag::err_typecheck_incomplete_array_needs_initializer);
14127 Var->setInvalidDecl();
14134 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
14135 << Var <<
SourceRange(Var->getLocation(), Var->getLocation());
14144 if (Var->isInvalidDecl())
14147 if (!Var->hasAttr<AliasAttr>()) {
14150 diag::err_typecheck_decl_incomplete_type)) {
14151 Var->setInvalidDecl();
14160 diag::err_abstract_type_in_decl,
14162 Var->setInvalidDecl();
14183 if (!CXXRecord->isPOD())
14217 }
else if (
Init.isInvalid()) {
14235 VarDecl *VD = dyn_cast<VarDecl>(
D);
14294 const char *PrevSpec;
14300 D.SetIdentifier(Ident, IdentLoc);
14301 D.takeAttributes(Attrs);
14306 cast<VarDecl>(Var)->setCXXForRangeDecl(
true);
14314 if (var->isInvalidDecl())
return;
14321 if (var->getTypeSourceInfo()->getType()->isBlockPointerType() &&
14323 Diag(var->getLocation(), diag::err_opencl_invalid_block_declaration)
14325 var->setInvalidDecl();
14333 var->hasLocalStorage()) {
14334 switch (var->getType().getObjCLifetime()) {
14347 if (var->hasLocalStorage() &&
14356 if (var->isThisDeclarationADefinition() &&
14357 var->getDeclContext()->getRedeclContext()->isFileContext() &&
14358 var->isExternallyVisible() && var->hasLinkage() &&
14359 !var->isInline() && !var->getDescribedVarTemplate() &&
14361 !isa<VarTemplatePartialSpecializationDecl>(var) &&
14363 !
getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
14364 var->getLocation())) {
14366 VarDecl *prev = var->getPreviousDecl();
14371 Diag(var->getLocation(), diag::warn_missing_variable_declarations) << var;
14372 Diag(var->getTypeSpecStartLoc(), diag::note_static_for_internal_linkage)
14378 std::optional<bool> CacheHasConstInit;
14379 const Expr *CacheCulprit =
nullptr;
14380 auto checkConstInit = [&]()
mutable {
14381 if (!CacheHasConstInit)
14382 CacheHasConstInit = var->getInit()->isConstantInitializer(
14383 Context, var->getType()->isReferenceType(), &CacheCulprit);
14384 return *CacheHasConstInit;
14388 if (var->getType().isDestructedType()) {
14392 Diag(var->getLocation(), diag::err_thread_nontrivial_dtor);
14394 Diag(var->getLocation(), diag::note_use_thread_local);
14396 if (!checkConstInit()) {
14404 Diag(var->getLocation(), diag::note_use_thread_local);
14410 if (!var->getType()->isStructureType() && var->hasInit() &&
14411 isa<InitListExpr>(var->getInit())) {
14412 const auto *ILE = cast<InitListExpr>(var->getInit());
14413 unsigned NumInits = ILE->getNumInits();
14415 for (
unsigned I = 0; I < NumInits; ++I) {
14416 const auto *
Init = ILE->getInit(I);
14419 const auto *SL = dyn_cast<StringLiteral>(
Init->IgnoreImpCasts());
14423 unsigned NumConcat = SL->getNumConcatenated();
14427 if (NumConcat == 2 && !SL->getBeginLoc().isMacroID()) {
14428 bool OnlyOneMissingComma =
true;
14429 for (
unsigned J = I + 1; J < NumInits; ++J) {
14430 const auto *
Init = ILE->getInit(J);
14433 const auto *SLJ = dyn_cast<StringLiteral>(
Init->IgnoreImpCasts());
14434 if (!SLJ || SLJ->getNumConcatenated() > 1) {
14435 OnlyOneMissingComma =
false;
14440 if (OnlyOneMissingComma) {
14442 for (
unsigned i = 0; i < NumConcat - 1; ++i)
14446 Diag(SL->getStrTokenLoc(1),
14447 diag::warn_concatenated_literal_array_init)
14449 Diag(SL->getBeginLoc(),
14450 diag::note_concatenated_string_literal_silence);
14461 if (var->hasAttr<BlocksAttr>())
14465 bool GlobalStorage = var->hasGlobalStorage();
14466 bool IsGlobal = GlobalStorage && !var->isStaticLocal();
14468 bool HasConstInit =
true;
14471 Diag(var->getLocation(), diag::err_constexpr_var_requires_const_init)
14476 !
type->isDependentType() &&
Init && !
Init->isValueDependent() &&
14477 (GlobalStorage || var->isConstexpr() ||
14478 var->mightBeUsableInConstantExpressions(
Context))) {
14490 HasConstInit = checkConstInit();
14494 if (HasConstInit) {
14495 (void)var->checkForConstantInitialization(Notes);
14497 }
else if (CacheCulprit) {
14498 Notes.emplace_back(CacheCulprit->
getExprLoc(),
14499 PDiag(diag::note_invalid_subexpr_in_const_expr));
14504 HasConstInit = var->checkForConstantInitialization(Notes);
14507 if (HasConstInit) {
14509 }
else if (var->isConstexpr()) {
14513 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
14514 diag::note_invalid_subexpr_in_const_expr) {
14515 DiagLoc = Notes[0].first;
14518 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
14519 << var <<
Init->getSourceRange();
14520 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
14521 Diag(Notes[I].first, Notes[I].second);
14522 }
else if (GlobalStorage && var->hasAttr<ConstInitAttr>()) {
14523 auto *
Attr = var->getAttr<ConstInitAttr>();
14524 Diag(var->getLocation(), diag::err_require_constant_init_failed)
14525 <<
Init->getSourceRange();
14528 for (
auto &it : Notes)
14529 Diag(it.first, it.second);
14530 }
else if (IsGlobal &&
14532 var->getLocation())) {
14541 if (!checkConstInit())
14542 Diag(var->getLocation(), diag::warn_global_constructor)
14543 <<
Init->getSourceRange();
14549 if (GlobalStorage && var->isThisDeclarationADefinition() &&
14555 std::optional<QualType::NonConstantStorageReason> Reason;
14556 if (HasConstInit &&
14557 !(Reason = var->getType().isNonConstantStorage(
Context,
true,
false))) {
14563 if (
const SectionAttr *SA = var->getAttr<SectionAttr>()) {
14567 }
else if (Stack->CurrentValue) {
14570 var->getType().isConstQualified()) {
14572 NonConstNonReferenceType) &&
14573 "This case should've already been handled elsewhere");
14574 Diag(var->getLocation(), diag::warn_section_msvc_compat)
14580 auto SectionName = Stack->CurrentValue->getString();
14581 var->addAttr(SectionAttr::CreateImplicit(
Context, SectionName,
14582 Stack->CurrentPragmaLocation,
14583 SectionAttr::Declspec_allocate));
14585 var->dropAttr<SectionAttr>();
14606 if (!
type->isDependentType())
14616 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
14627 !FD->
hasAttr<DLLExportStaticLocalAttr>() &&
14628 !FD->
hasAttr<DLLImportStaticLocalAttr>()) {
14637 auto *NewAttr = cast<InheritableAttr>(A->clone(
getASTContext()));
14638 NewAttr->setInherited(
true);
14640 }
else if (
Attr *A = FD->
getAttr<DLLExportStaticLocalAttr>()) {
14641 auto *NewAttr = DLLExportAttr::CreateImplicit(
getASTContext(), *A);
14642 NewAttr->setInherited(
true);
14647 if (!FD->
hasAttr<DLLExportAttr>())
14650 }
else if (
Attr *A = FD->
getAttr<DLLImportStaticLocalAttr>()) {
14651 auto *NewAttr = DLLImportAttr::CreateImplicit(
getASTContext(), *A);
14652 NewAttr->setInherited(
true);
14681 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
14689 VD->
addAttr(PragmaClangBSSSectionAttr::CreateImplicit(
14693 VD->
addAttr(PragmaClangDataSectionAttr::CreateImplicit(
14697 VD->
addAttr(PragmaClangRodataSectionAttr::CreateImplicit(
14701 VD->
addAttr(PragmaClangRelroSectionAttr::CreateImplicit(
14706 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
14707 for (
auto *BD : DD->bindings()) {
14712 CheckInvalidBuiltinCountedByRef(VD->
getInit(), InitializerKind);
14734 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
14741 bool IsClassTemplateMember =
14742 isa<ClassTemplatePartialSpecializationDecl>(
Context) ||
14743 Context->getDescribedClassTemplate();
14746 IsClassTemplateMember
14747 ? diag::warn_attribute_dllimport_static_field_definition
14748 : diag::err_attribute_dllimport_static_field_definition);
14749 Diag(IA->getLocation(), diag::note_attribute);
14750 if (!IsClassTemplateMember)
14778 if (RetainAttr *
Attr = VD->
getAttr<RetainAttr>()) {
14793 if (VD->
isFileVarDecl() && !isa<VarTemplatePartialSpecializationDecl>(VD))
14798 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
14802 for (
const auto *I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
14804 if (!MagicValueExpr) {
14807 std::optional<llvm::APSInt> MagicValueInt;
14809 Diag(I->getRange().getBegin(),
14810 diag::err_type_tag_for_datatype_not_ice)
14814 if (MagicValueInt->getActiveBits() > 64) {
14815 Diag(I->getRange().getBegin(),
14816 diag::err_type_tag_for_datatype_too_large)
14820 uint64_t MagicValue = MagicValueInt->getZExtValue();
14823 I->getMatchingCType(),
14824 I->getLayoutCompatible(),
14825 I->getMustBeNull());
14830 auto *VD = dyn_cast<VarDecl>(DD);
14831 return VD && !VD->getType()->hasAutoForTrailingReturnType();
14843 bool DiagnosedMultipleDecomps =
false;
14845 bool DiagnosedNonDeducedAuto =
false;
14847 for (
Decl *
D : Group) {
14852 if (
auto *VD = dyn_cast<VarDecl>(
D);
14853 LangOpts.OpenMP && VD && VD->hasAttr<OMPDeclareTargetDeclAttr>() &&
14854 VD->hasGlobalStorage())
14858 if (
auto *DD = dyn_cast<DeclaratorDecl>(
D)) {
14859 if (!FirstDeclaratorInGroup)
14860 FirstDeclaratorInGroup = DD;
14861 if (!FirstDecompDeclaratorInGroup)
14862 FirstDecompDeclaratorInGroup = dyn_cast<DecompositionDecl>(
D);
14865 FirstNonDeducedAutoInGroup = DD;
14867 if (FirstDeclaratorInGroup != DD) {
14870 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
14872 diag::err_decomp_decl_not_alone)
14874 << DD->getSourceRange();
14875 DiagnosedMultipleDecomps =
true;
14881 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
14883 diag::err_auto_non_deduced_not_alone)
14884 << FirstNonDeducedAutoInGroup->
getType()
14887 << DD->getSourceRange();
14888 DiagnosedNonDeducedAuto =
true;
14893 Decls.push_back(
D);
14899 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
14913 if (Group.size() > 1) {
14915 VarDecl *DeducedDecl =
nullptr;
14916 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
14917 VarDecl *
D = dyn_cast<VarDecl>(Group[i]);
14920 DeducedType *DT =
D->getType()->getContainedDeducedType();
14927 auto *AT = dyn_cast<AutoType>(DT);
14929 diag::err_auto_different_deductions)
14930 << (AT ? (
unsigned)AT->getKeyword() : 3) << Deduced
14932 <<
D->getDeclName();
14955 if (Group.empty() || !Group[0])
14959 Group[0]->getLocation()) &&
14961 Group[0]->getLocation()))
14964 if (Group.size() >= 2) {
14972 Decl *MaybeTagDecl = Group[0];
14973 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
14974 Group = Group.slice(1);
14991 if (
D.getCXXScopeSpec().isSet()) {
14992 Diag(
D.getIdentifierLoc(), diag::err_qualified_param_declarator)
14993 <<
D.getCXXScopeSpec().getRange();
15009 Diag(
D.getIdentifierLoc(), diag::err_bad_parameter_name)
15016 Diag(
D.getIdentifierLoc(), diag::err_bad_parameter_name_template_id);
15023 if (!ExplicitThisLoc.
isValid())
15026 "explicit parameter in non-cplusplus mode");
15028 S.
Diag(ExplicitThisLoc, diag::err_cxx20_deducing_this)
15029 <<
P->getSourceRange();
15033 if (
P->isParameterPack()) {
15034 S.
Diag(
P->getBeginLoc(), diag::err_explicit_object_parameter_pack)
15035 <<
P->getSourceRange();
15038 P->setExplicitObjectParameterLoc(ExplicitThisLoc);
15040 LSI->ExplicitObjectParameter =
P;
15063 ? diag::ext_register_storage_class
15064 : diag::warn_deprecated_register)
15068 D.getNumTypeObjects() == 0) {
15070 diag::err_invalid_storage_class_in_func_decl)
15072 D.getMutableDeclSpec().ClearStorageClassSpecs();
15079 diag::err_invalid_storage_class_in_func_decl);
15080 D.getMutableDeclSpec().ClearStorageClassSpecs();
15091 << 0 <<
static_cast<int>(
D.getDeclSpec().getConstexprSpecifier());
15104 RedeclarationKind::ForVisibleRedeclaration);
15112 PrevDecl =
nullptr;
15114 if (PrevDecl && S->isDeclScope(PrevDecl)) {
15115 Diag(
D.getIdentifierLoc(), diag::err_param_redefinition) << II;
15119 D.SetIdentifier(
nullptr,
D.getIdentifierLoc());
15120 D.setInvalidType(
true);
15130 D.getIdentifierLoc(), II, parmDeclType, TInfo, SC);
15132 if (
D.isInvalidType())
15137 assert(S->isFunctionPrototypeScope());
15138 assert(S->getFunctionPrototypeDepth() >= 1);
15140 S->getNextFunctionPrototypeIndex());
15149 if (
D.getDeclSpec().isModulePrivateSpecified())
15151 << 1 << New <<
SourceRange(
D.getDeclSpec().getModulePrivateSpecLoc())
15154 if (New->
hasAttr<BlocksAttr>()) {
15186 !
Parameter->getIdentifier()->isPlaceholder()) {
15187 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
15195 if (
LangOpts.NumLargeByValueCopy == 0)
15202 if (Size >
LangOpts.NumLargeByValueCopy)
15213 if (Size >
LangOpts.NumLargeByValueCopy)
15234 if (!
T.isConstQualified()) {
15238 NameLoc, diag::err_arc_array_param_no_ownership,
T,
false));
15240 Diag(NameLoc, diag::err_arc_array_param_no_ownership)
15252 TSInfo, SC,
nullptr);
15259 CSI->LocalPacks.push_back(New);
15272 diag::err_object_cannot_be_passed_returned_by_value) << 1 <<
T
15291 Diag(NameLoc, diag::err_arg_with_address_space);
15319 for (
int i = FTI.
NumParams; i != 0; ) {
15324 llvm::raw_svector_ostream(Code)
15335 const char* PrevSpec;
15356 assert(
D.isFunctionDeclarator() &&
"Not a function declarator!");
15367 if (
LangOpts.OpenMP &&
OpenMP().isInOpenMPDeclareVariantScope())
15369 ParentScope,
D, TemplateParameterLists, Bases);
15375 if (!Bases.empty())
15392 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
15395 PossiblePrototype = Prev;
15413 if (isa<CXXMethodDecl>(FD))
15419 if (II->isStr(
"main") || II->isStr(
"efi_main"))
15438 if (FD->
hasAttr<OpenCLKernelAttr>())
15492 Definition->getNumTemplateParameterLists())) {
15495 if (
auto *TD =
Definition->getDescribedFunctionTemplate())
15508 Diag(
Definition->getLocation(), diag::note_previous_definition);
15517 LSI->
Lambda = LambdaClass;
15556 for (
const auto &
C : LambdaClass->
captures()) {
15557 if (
C.capturesVariable()) {
15561 const bool ByRef =
C.getCaptureKind() ==
LCK_ByRef;
15563 true,
C.getLocation(),
15564 C.isPackExpansion()
15566 I->getType(),
false);
15568 }
else if (
C.capturesThis()) {
15594 FD = FunTmpl->getTemplatedDecl();
15596 FD = cast<FunctionDecl>(
D);
15621 if (
const auto *
Attr = FD->
getAttr<AliasAttr>()) {
15626 if (
const auto *
Attr = FD->
getAttr<IFuncAttr>()) {
15631 if (
const auto *
Attr = FD->
getAttr<TargetVersionAttr>()) {
15634 !
Attr->isDefaultVersion()) {
15643 if (
auto *Ctor = dyn_cast<CXXConstructorDecl>(FD)) {
15645 Ctor->isDefaultConstructor() &&
15688 "There should be an active template instantiation on the stack "
15689 "when instantiating a generic lambda!");
15715 diag::err_func_def_incomplete_result) ||
15717 diag::err_abstract_type_in_decl,
15733 auto *NonParmDecl = dyn_cast<NamedDecl>(NPD);
15736 assert(!isa<ParmVarDecl>(NonParmDecl) &&
15737 "parameters should not be in newly created FD yet");
15740 if (NonParmDecl->getDeclName())
15745 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
15746 for (
auto *EI : ED->enumerators())
15754 Param->setOwningFunction(FD);
15757 if (Param->getIdentifier() && FnBodyScope) {
15786 assert(!FD->
hasAttr<DLLExportAttr>());
15787 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
15812 if (
auto *TD = dyn_cast<FunctionTemplateDecl>(FD))
15813 FD = TD->getTemplatedDecl();
15814 if (FD && FD->
hasAttr<OptimizeNoneAttr>()) {
15826 for (
unsigned I = 0,
E =
Scope->Returns.size(); I !=
E; ++I) {
15827 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
15828 if (!NRVOCandidate->isNRVOVariable())
15836 if (
D.getDeclSpec().hasConstexprSpecifier())
15841 if (
D.getDeclSpec().hasAutoTypeSpec()) {
15844 if (
D.getNumTypeObjects()) {
15845 const auto &Outer =
D.getTypeObject(
D.getNumTypeObjects() - 1);
15847 Outer.Fun.hasTrailingReturnType()) {
15865 if (FD->isConstexpr())
15870 if (FD->getReturnType()->getContainedDeducedType())
15880 FD->setHasSkippedBody();
15902 bool IsLambda =
false;
15906 llvm::DenseMap<const BlockDecl *, bool> EscapeInfo;
15908 auto IsOrNestedInEscapingBlock = [&](
const BlockDecl *BD) {
15909 if (EscapeInfo.count(BD))
15910 return EscapeInfo[BD];
15922 return EscapeInfo[BD] = R;
15927 for (
const std::pair<SourceLocation, const BlockDecl *> &
P :
15929 if (IsOrNestedInEscapingBlock(
P.second))
15930 S.
Diag(
P.first, diag::warn_implicitly_retains_self)
15935 return isa<CXXMethodDecl>(FD) && FD->
param_empty() &&
15945 methodHasName(FD,
"get_return_object_on_allocation_failure");
15955 if (!FD->
hasAttr<CoroWrapperAttr>())
15960 bool IsInstantiation) {
16010 Expr *Dummy =
nullptr;
16021 if (LSI->HasImplicitReturnType) {
16028 LSI->ReturnType.isNull() ?
Context.
VoidTy : LSI->ReturnType;
16033 Proto->getExtProtoInfo()));
16061 dyn_cast<CXXDestructorDecl>(FD))
16081 if (PossiblePrototype) {
16085 TypeLoc TL = TI->getTypeLoc();
16088 diag::note_declaration_not_a_prototype)
16091 FTL.getRParenLoc(),
"void")
16098 std::pair<FileID, unsigned> LocInfo =
SM.getDecomposedLoc(
Loc);
16099 if (LocInfo.first.isInvalid())
16103 StringRef Buffer =
SM.getBufferData(LocInfo.first, &
Invalid);
16107 if (LocInfo.second > Buffer.size())
16110 const char *LexStart = Buffer.data() + LocInfo.second;
16111 StringRef StartTok(LexStart, Buffer.size() - LocInfo.second);
16113 return StartTok.consume_front(
"const") &&
16115 StartTok.starts_with(
"/*") || StartTok.starts_with(
"//"));
16118 auto findBeginLoc = [&]() {
16134 diag::note_static_for_internal_linkage)
16145 if (!PossiblePrototype)
16191 if (PossiblePrototype)
16193 diag::warn_non_prototype_changes_behavior)
16200 if (
const auto *CmpndBody = dyn_cast<CompoundStmt>(Body))
16201 if (!CmpndBody->body_empty())
16202 Diag(CmpndBody->body_front()->getBeginLoc(),
16203 diag::warn_dispatch_body_ignored);
16205 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
16230 "Function parsing confused");
16231 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
16243 << MD->getSelector().getAsString();
16248 bool isDesignated =
16249 MD->isDesignatedInitializerForTheInterface(&InitMethod);
16250 assert(isDesignated && InitMethod);
16251 (void)isDesignated;
16254 auto IFace = MD->getClassInterface();
16257 auto SuperD = IFace->getSuperClass();
16267 diag::warn_objc_designated_init_missing_super_call);
16269 diag::note_objc_designated_init_marked_here);
16277 diag::warn_objc_secondary_init_missing_init_call);
16293 "This should only be set for ObjC methods, which should have been "
16294 "handled in the block above.");
16301 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
16309 if (!
Destructor->getParent()->isDependentType())
16327 ActivePolicy = &WP;
16330 if (!IsInstantiation && FD &&
16336 if (FD && FD->
hasAttr<NakedAttr>()) {
16340 bool RegisterVariables =
false;
16341 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
16342 for (
const auto *
Decl : DS->decls()) {
16343 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
16344 RegisterVariables =
16345 Var->hasAttr<AsmLabelAttr>() && !Var->hasInit();
16346 if (!RegisterVariables)
16351 if (RegisterVariables)
16353 if (!isa<AsmStmt>(S) && !isa<NullStmt>(S)) {
16354 Diag(S->getBeginLoc(), diag::err_non_asm_stmt_in_naked_function);
16355 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
16364 "Leftover temporaries in function");
16366 "Unaccounted cleanups in function");
16368 "Leftover expressions for odr-use checking");
16374 if (!IsInstantiation)
16391 DeclsToCheckForDeferredDiags.insert(FD);
16406 D = TD->getTemplatedDecl();
16411 if (Method->isStatic())
16419 "Implicit function declarations aren't allowed in this language mode");
16426 Scope *BlockScope = S;
16434 Scope *ContextScope = BlockScope;
16438 ContextScope = ContextScope->
getParent();
16454 if (!isa<FunctionDecl>(ExternCPrev) ||
16456 cast<FunctionDecl>(ExternCPrev)->getType(),
16458 Diag(
Loc, diag::ext_use_out_of_scope_declaration)
16461 return ExternCPrev;
16467 if (II.
getName().starts_with(
"__builtin_"))
16468 diag_id = diag::warn_builtin_unknown;
16471 diag_id = diag::ext_implicit_function_decl_c99;
16473 diag_id = diag::warn_implicit_function_decl;
16481 if (S && !ExternCPrev &&
16504 return ExternCPrev;
16514 assert(!Error &&
"Error setting up implicit decl!");
16536 D.SetIdentifier(&II,
Loc);
16556 std::optional<unsigned> AlignmentParam;
16557 bool IsNothrow =
false;
16569 if (!IsNothrow && !FD->
hasAttr<ReturnsNonNullAttr>() &&
16587 if (!FD->
hasAttr<AllocSizeAttr>()) {
16588 FD->
addAttr(AllocSizeAttr::CreateImplicit(
16599 if (AlignmentParam && !FD->
hasAttr<AllocAlignAttr>()) {
16600 FD->
addAttr(AllocAlignAttr::CreateImplicit(
16624 unsigned FormatIdx;
16627 if (!FD->
hasAttr<FormatAttr>()) {
16628 const char *fmt =
"printf";
16630 if (FormatIdx < NumParams &&
16636 HasVAListArg ? 0 : FormatIdx+2,
16642 if (!FD->
hasAttr<FormatAttr>())
16646 HasVAListArg ? 0 : FormatIdx+2,
16652 if (!FD->
hasAttr<CallbackAttr>() &&
16654 FD->
addAttr(CallbackAttr::CreateImplicit(
16660 bool NoExceptions =
16662 bool ConstWithoutErrnoAndExceptions =
16664 bool ConstWithoutExceptions =
16666 if (!FD->
hasAttr<ConstAttr>() &&
16667 (ConstWithoutErrnoAndExceptions || ConstWithoutExceptions) &&
16668 (!ConstWithoutErrnoAndExceptions ||
16670 (!ConstWithoutExceptions || NoExceptions))
16677 if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
16679 switch (BuiltinID) {
16680 case Builtin::BI__builtin_fma:
16681 case Builtin::BI__builtin_fmaf:
16682 case Builtin::BI__builtin_fmal:
16683 case Builtin::BIfma:
16684 case Builtin::BIfmaf:
16685 case Builtin::BIfmal:
16694 !FD->
hasAttr<ReturnsTwiceAttr>())
16704 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
16716 switch (BuiltinID) {
16717 case Builtin::BImemalign:
16718 case Builtin::BIaligned_alloc:
16719 if (!FD->
hasAttr<AllocAlignAttr>())
16728 switch (BuiltinID) {
16729 case Builtin::BIcalloc:
16730 FD->
addAttr(AllocSizeAttr::CreateImplicit(
16733 case Builtin::BImemalign:
16734 case Builtin::BIaligned_alloc:
16735 case Builtin::BIrealloc:
16739 case Builtin::BImalloc:
16759 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
16775 if (Name->isStr(
"asprintf") || Name->isStr(
"vasprintf")) {
16778 if (!FD->
hasAttr<FormatAttr>())
16781 Name->isStr(
"vasprintf") ? 0 : 3,
16785 if (Name->isStr(
"__CFStringMakeConstantString")) {
16788 if (!FD->
hasAttr<FormatArgAttr>())
16796 assert(
D.getIdentifier() &&
"Wrong callback for declspec without declarator");
16797 assert(!
T.isNull() &&
"GetTypeForDeclarator() returned null type");
16800 assert(
D.isInvalidType() &&
"no declarator info for valid type");
16807 D.getIdentifierLoc(),
D.getIdentifier(), TInfo);
16810 if (
D.isInvalidType()) {
16815 if (
D.getDeclSpec().isModulePrivateSpecified()) {
16819 <<
SourceRange(
D.getDeclSpec().getModulePrivateSpecLoc())
16821 D.getDeclSpec().getModulePrivateSpecLoc());
16832 switch (
D.getDeclSpec().getTypeSpecType()) {
16838 TagDecl *tagFromDeclSpec = cast<TagDecl>(
D.getDeclSpec().getRepAsDecl());
16860 if (BT->isInteger())
16863 return Diag(UnderlyingLoc, diag::err_enum_invalid_underlying)
16868 QualType EnumUnderlyingTy,
bool IsFixed,
16870 if (IsScoped != Prev->
isScoped()) {
16871 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
16877 if (IsFixed && Prev->
isFixed()) {
16883 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
16889 }
else if (IsFixed != Prev->
isFixed()) {
16890 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
16912 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
16928 if (isa<TypedefDecl>(PrevDecl))
16930 else if (isa<TypeAliasDecl>(PrevDecl))
16932 else if (isa<ClassTemplateDecl>(PrevDecl))
16934 else if (isa<TypeAliasTemplateDecl>(PrevDecl))
16936 else if (isa<TemplateTemplateParmDecl>(PrevDecl))
16948 llvm_unreachable(
"invalid TTK");
16987 if (IsIgnoredLoc(NewTagLoc))
16990 auto IsIgnored = [&](
const TagDecl *Tag) {
16991 return IsIgnoredLoc(Tag->getLocation());
17008 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
17016 if (isDefinition) {
17024 bool previousMismatch =
false;
17026 if (I->getTagKind() !=
NewTag) {
17031 if (!previousMismatch) {
17032 previousMismatch =
true;
17033 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
17037 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
17050 if (PrevDef && IsIgnored(PrevDef))
17054 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
17061 Diag(NewTagLoc, diag::note_struct_class_suggestion)
17091 if (!Namespace || Namespace->isAnonymousNamespace())
17094 Namespaces.push_back(II);
17097 if (Lookup == Namespace)
17104 llvm::raw_svector_ostream OS(Insertion);
17107 std::reverse(Namespaces.begin(), Namespaces.end());
17108 for (
auto *II : Namespaces)
17109 OS << II->getName() <<
"::";
17122 if (OldDC->
Equals(NewDC))
17141 bool ScopedEnumUsesClassTag,
TypeResult UnderlyingType,
17142 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
17147 "Nameless record must be a definition!");
17152 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
17155 bool isMemberSpecialization =
false;
17161 if (TemplateParameterLists.size() > 0 ||
17165 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
17182 !isMemberSpecialization)
17183 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
17186 if (TemplateParams) {
17188 Diag(KWLoc, diag::err_enum_template);
17192 if (TemplateParams->
size() > 0) {
17201 S, TagSpec, TUK, KWLoc, SS, Name, NameLoc, Attrs, TemplateParams,
17202 AS, ModulePrivateLoc,
17204 TemplateParameterLists.data(), SkipBody);
17210 isMemberSpecialization =
true;
17214 if (!TemplateParameterLists.empty() && isMemberSpecialization &&
17233 ScopedEnum ?
SourceRange(KWLoc, ScopedEnumKWLoc) : KWLoc);
17234 assert(ScopedEnum || !ScopedEnumUsesClassTag);
17235 Diag(KWLoc, diag::note_enum_friend)
17236 << (ScopedEnum + ScopedEnumUsesClassTag);
17242 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
17243 bool IsFixed = !UnderlyingType.
isUnset() || ScopedEnum;
17246 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum)) {
17250 }
else if (UnderlyingType.
get()) {
17255 EnumUnderlying = TI;
17277 bool isStdBadAlloc =
false;
17278 bool isStdAlignValT =
false;
17282 Redecl = RedeclarationKind::NotForRedeclaration;
17287 auto createTagFromNewDecl = [&]() ->
TagDecl * {
17297 ScopedEnum, ScopedEnumUsesClassTag, IsFixed);
17301 if (EnumUnderlying) {
17302 EnumDecl *ED = cast<EnumDecl>(New);
17317 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
17344 goto CreateNewDecl;
17352 IsDependent =
true;
17381 if (
Previous.wasNotFoundInCurrentInstantiation() &&
17383 IsDependent =
true;
17388 Diag(NameLoc, diag::err_not_tag_in_scope)
17389 << llvm::to_underlying(Kind) << Name << DC << SS.
getRange();
17392 goto CreateNewDecl;
17440 bool FriendSawTagOutsideEnclosingNamespace =
false;
17447 FriendSawTagOutsideEnclosingNamespace =
true;
17456 if (
Previous.isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
17458 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
17472 while (isa<RecordDecl, EnumDecl, ObjCContainerDecl>(SearchDC))
17478 while (isa<ObjCContainerDecl>(SearchDC))
17484 while (isa<ObjCContainerDecl>(SearchDC))
17489 Previous.getFoundDecl()->isTemplateParameter()) {
17498 if (Name->isStr(
"bad_alloc")) {
17500 isStdBadAlloc =
true;
17507 }
else if (Name->isStr(
"align_val_t")) {
17508 isStdAlignValT =
true;
17520 IsTemplateParamOrArg)) {
17521 if (
Invalid)
goto CreateNewDecl;
17605 TagDecl *Tag = TT->getDecl();
17606 if (Tag->getDeclName() == Name &&
17607 Tag->getDeclContext()->getRedeclContext()
17608 ->Equals(TD->getDeclContext()->getRedeclContext())) {
17621 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
17622 auto *OldTag = dyn_cast<TagDecl>(PrevDecl);
17625 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
17627 *
this, OldTag->getDeclContext(), SearchDC))) {
17628 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
17629 Diag(Shadow->getTargetDecl()->getLocation(),
17630 diag::note_using_decl_target);
17631 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl)
17635 goto CreateNewDecl;
17639 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
17645 SS.
isNotEmpty() || isMemberSpecialization)) {
17651 bool SafeToContinue =
17654 if (SafeToContinue)
17655 Diag(KWLoc, diag::err_use_with_wrong_tag)
17658 PrevTagDecl->getKindName());
17660 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
17661 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
17663 if (SafeToContinue)
17664 Kind = PrevTagDecl->getTagKind();
17675 const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
17677 return PrevTagDecl;
17681 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
17682 else if (
const Type *
T = EnumUnderlying.dyn_cast<
const Type*>())
17689 ScopedEnum, EnumUnderlyingTy,
17690 IsFixed, PrevEnum))
17699 S->isDeclScope(PrevDecl)) {
17700 Diag(NameLoc, diag::ext_member_redeclared);
17701 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
17708 if (!Attrs.
empty()) {
17712 (PrevTagDecl->getFriendObjectKind() ==
17725 return PrevTagDecl;
17730 return PrevTagDecl;
17736 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
17740 bool IsExplicitSpecializationAfterInstantiation =
false;
17741 if (isMemberSpecialization) {
17743 IsExplicitSpecializationAfterInstantiation =
17744 RD->getTemplateSpecializationKind() !=
17746 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
17747 IsExplicitSpecializationAfterInstantiation =
17748 ED->getTemplateSpecializationKind() !=
17768 SkipBody->
New = createTagFromNewDecl();
17778 }
else if (!IsExplicitSpecializationAfterInstantiation) {
17782 Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name;
17784 Diag(NameLoc, diag::err_redefinition) << Name;
17786 NameLoc.
isValid() ? NameLoc : KWLoc);
17798 if (TD->isBeingDefined()) {
17799 Diag(NameLoc, diag::err_nested_redefinition) << Name;
17800 Diag(PrevTagDecl->getLocation(),
17801 diag::note_previous_definition);
17816 SearchDC = PrevTagDecl->getDeclContext();
17844 Diag(NameLoc, diag::err_tag_reference_non_tag)
17845 << PrevDecl << NTK << llvm::to_underlying(Kind);
17851 SS.
isNotEmpty() || isMemberSpecialization)) {
17857 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
17863 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
17865 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
17866 Diag(NameLoc, diag::err_tag_definition_of_typedef)
17867 << Name << Kind << TND->getUnderlyingType();
17875 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
17891 PrevDecl = cast<TagDecl>(
Previous.getFoundDecl());
17907 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
17908 ScopedEnumUsesClassTag, IsFixed);
17916 if (IsFixed && cast<EnumDecl>(New)->isFixed()) {
17920 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
17921 Diag(
Loc, diag::ext_forward_ref_enum_def)
17925 unsigned DiagID = diag::ext_forward_ref_enum;
17927 DiagID = diag::ext_ms_forward_ref_enum;
17929 DiagID = diag::err_forward_ref_enum;
17934 if (EnumUnderlying) {
17935 EnumDecl *ED = cast<EnumDecl>(New);
17944 assert(ED->
isComplete() &&
"enum with type should be complete");
17954 cast_or_null<CXXRecordDecl>(PrevDecl));
17960 cast_or_null<RecordDecl>(PrevDecl));
17972 (IsTypeSpecifier || IsTemplateParamOrArg) &&
17994 isMemberSpecialization))
17998 if (TemplateParameterLists.size() > 0) {
18006 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
18022 if (ModulePrivateLoc.
isValid()) {
18023 if (isMemberSpecialization)
18048 Diag(
Loc, diag::err_type_defined_in_param_type)
18054 }
else if (!PrevDecl) {
18115 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(New)) {
18132 if (
auto RD = dyn_cast<RecordDecl>(New))
18135 }
else if (SkipBody && SkipBody->
ShouldSkip) {
18144 TagDecl *Tag = cast<TagDecl>(TagD);
18167 bool IsFinalSpelledSealed,
18175 if (!
Record->getIdentifier())
18183 IsFinalSpelledSealed
18184 ? FinalAttr::Keyword_sealed
18185 : FinalAttr::Keyword_final));
18204 "Broken injected-class-name");
18210 TagDecl *Tag = cast<TagDecl>(TagD);
18211 Tag->setBraceRange(BraceRange);
18214 if (Tag->isBeingDefined()) {
18215 assert(Tag->isInvalidDecl() &&
"We should already have completed it");
18216 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
18220 if (
auto *RD = dyn_cast<CXXRecordDecl>(Tag)) {
18222 if (RD->
hasAttr<SYCLSpecialClassAttr>()) {
18224 assert(Def &&
"The record is expected to have a completed definition");
18225 unsigned NumInitMethods = 0;
18226 for (
auto *Method : Def->methods()) {
18227 if (!Method->getIdentifier())
18229 if (Method->getName() ==
"__init")
18232 if (NumInitMethods > 1 || !Def->hasInitMethod())
18233 Diag(RD->
getLocation(), diag::err_sycl_special_type_num_init_method);
18250 Tag->getDeclContext()->isFileContext())
18251 Tag->setTopLevelDeclInObjCContainer();
18254 if (!Tag->isInvalidDecl())
18265 const RecordDecl *RD = dyn_cast<RecordDecl>(Tag);
18269 if (llvm::any_of(RD->
fields(),
18270 [](
const FieldDecl *FD) { return FD->isBitField(); }))
18271 Diag(BraceRange.
getBegin(), diag::warn_pragma_align_not_xl_compatible);
18277 TagDecl *Tag = cast<TagDecl>(TagD);
18278 Tag->setInvalidDecl();
18281 if (Tag->isBeingDefined()) {
18282 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
18296 QualType FieldTy,
bool IsMsStruct,
18307 diag::err_field_incomplete_or_sizeless))
18310 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
18312 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
18323 llvm::APSInt
Value;
18327 BitWidth = ICE.
get();
18330 if (
Value == 0 && FieldName)
18331 return Diag(FieldLoc, diag::err_bitfield_has_zero_width)
18334 if (
Value.isSigned() &&
Value.isNegative()) {
18336 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
18338 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
18345 return Diag(FieldLoc, diag::err_bitfield_too_wide)
18352 bool BitfieldIsOverwide =
Value.ugt(TypeWidth);
18356 bool CStdConstraintViolation =
18358 bool MSBitfieldViolation =
18359 Value.ugt(TypeStorageSize) &&
18361 if (CStdConstraintViolation || MSBitfieldViolation) {
18362 unsigned DiagWidth =
18363 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
18364 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
18366 << !CStdConstraintViolation << DiagWidth;
18372 if (BitfieldIsOverwide && !FieldTy->
isBooleanType() && FieldName) {
18373 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
18395 if (
D.isDecompositionDeclarator()) {
18404 if (II)
Loc =
D.getIdentifierLoc();
18413 D.setInvalidType();
18421 if (
D.getDeclSpec().isInlineSpecified())
18422 Diag(
D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
18424 if (
DeclSpec::TSCS TSCS =
D.getDeclSpec().getThreadStorageClassSpec())
18425 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
18426 diag::err_invalid_thread)
18432 RedeclarationKind::ForVisibleRedeclaration);
18434 switch (
Previous.getResultKind()) {
18441 PrevDecl =
Previous.getRepresentativeDecl();
18455 PrevDecl =
nullptr;
18459 PrevDecl =
nullptr;
18466 TSSL, AS, PrevDecl, &
D);
18469 Record->setInvalidDecl();
18471 if (
D.getDeclSpec().isModulePrivateSpecified())
18488 bool Mutable,
Expr *BitWidth,
18494 bool InvalidDecl =
false;
18495 if (
D) InvalidDecl =
D->isInvalidType();
18500 InvalidDecl =
true;
18506 bool isIncomplete =
18510 diag::err_field_incomplete_or_sizeless);
18511 if (isIncomplete) {
18513 Record->setInvalidDecl();
18514 InvalidDecl =
true;
18519 Record->setInvalidDecl();
18520 InvalidDecl =
true;
18528 Diag(
Loc, diag::err_field_with_address_space);
18529 Record->setInvalidDecl();
18530 InvalidDecl =
true;
18538 Diag(
Loc, diag::err_opencl_type_struct_or_union_field) <<
T;
18539 Record->setInvalidDecl();
18540 InvalidDecl =
true;
18545 "__cl_clang_bitfields",
LangOpts)) {
18546 Diag(
Loc, diag::err_opencl_bitfields);
18547 InvalidDecl =
true;
18553 T.hasQualifiers()) {
18554 InvalidDecl =
true;
18555 Diag(
Loc, diag::err_anon_bitfield_qualifiers);
18562 TInfo,
T,
Loc, diag::err_typecheck_field_variable_size))
18563 InvalidDecl =
true;
18568 diag::err_abstract_type_in_decl,
18570 InvalidDecl =
true;
18573 BitWidth =
nullptr;
18579 InvalidDecl =
true;
18580 BitWidth =
nullptr;
18585 if (!InvalidDecl && Mutable) {
18586 unsigned DiagID = 0;
18588 DiagID =
getLangOpts().MSVCCompat ? diag::ext_mutable_reference
18589 : diag::err_mutable_reference;
18590 else if (
T.isConstQualified())
18591 DiagID = diag::err_mutable_const;
18595 if (
D &&
D->getDeclSpec().getStorageClassSpecLoc().isValid())
18596 ErrLoc =
D->getDeclSpec().getStorageClassSpecLoc();
18597 Diag(ErrLoc, DiagID);
18598 if (DiagID != diag::ext_mutable_reference) {
18600 InvalidDecl =
true;
18612 BitWidth, Mutable, InitStyle);
18616 if (PrevDecl && !isa<TagDecl>(PrevDecl) &&
18618 Diag(
Loc, diag::err_duplicate_member) << II;
18624 if (
Record->isUnion()) {
18642 const bool HaveMSExt =
18647 HaveMSExt ? diag::ext_union_member_of_reference_type
18648 : diag::err_union_member_of_reference_type)
18668 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(NewFD))
18671 if (
T.isObjCGCWeak())
18672 Diag(
Loc, diag::warn_attribute_weak_on_field);
18723 if (!FD->
hasAttr<UnavailableAttr>())
18725 UnavailableAttr::IR_ARCFieldWithOwnership,
Loc));
18733 ? diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member
18734 : diag::err_illegal_union_or_anon_struct_member)
18736 << llvm::to_underlying(member);
18751 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
18759 if (!CD->IsClassExtension())
18771 DeclLoc, DeclLoc,
nullptr,
18777 AllIvarDecls.push_back(Ivar);
18789 if (!
Record->hasUserDeclaredDestructor()) {
18797 if (
auto *DD = dyn_cast<CXXDestructorDecl>(
Decl)) {
18798 if (DD->isInvalidDecl())
18802 assert(DD->isIneligibleOrNotSelected() &&
"Selecting a destructor but a destructor was already selected.");
18816 Record->addedSelectedDestructor(dyn_cast<CXXDestructorDecl>(Best->Function));
18820 Msg = diag::err_ambiguous_destructor;
18825 Msg = diag::err_no_viable_destructor;
18836 Record->setInvalidDecl();
18843 Record->addedSelectedDestructor(dyn_cast<CXXDestructorDecl>(OCS.
begin()->Function));
18887 const Expr *Constraints = Method->getTrailingRequiresClause();
18889 SatisfactionStatus.push_back(
true);
18893 SatisfactionStatus.push_back(
false);
18895 SatisfactionStatus.push_back(Satisfaction.
IsSatisfied);
18899 for (
size_t i = 0; i < Methods.size(); i++) {
18900 if (!SatisfactionStatus[i])
18905 OrigMethod = cast<CXXMethodDecl>(MF);
18908 bool AnotherMethodIsMoreConstrained =
false;
18909 for (
size_t j = 0; j < Methods.size(); j++) {
18910 if (i == j || !SatisfactionStatus[j])
18914 OtherMethod = cast<CXXMethodDecl>(MF);
18921 if (!OtherConstraints)
18923 if (!Constraints) {
18924 AnotherMethodIsMoreConstrained =
true;
18929 AnotherMethodIsMoreConstrained)) {
18932 AnotherMethodIsMoreConstrained =
true;
18934 if (AnotherMethodIsMoreConstrained)
18939 if (!AnotherMethodIsMoreConstrained) {
18941 Record->addedEligibleSpecialMemberFunction(Method,
18942 1 << llvm::to_underlying(CSM));
18956 auto *MD = dyn_cast<CXXMethodDecl>(
Decl);
18958 auto *FTD = dyn_cast<FunctionTemplateDecl>(
Decl);
18960 MD = dyn_cast<CXXMethodDecl>(FTD->getTemplatedDecl());
18964 if (
auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
18965 if (CD->isInvalidDecl())
18967 if (CD->isDefaultConstructor())
18968 DefaultConstructors.push_back(MD);
18969 else if (CD->isCopyConstructor())
18970 CopyConstructors.push_back(MD);
18971 else if (CD->isMoveConstructor())
18972 MoveConstructors.push_back(MD);
18974 CopyAssignmentOperators.push_back(MD);
18976 MoveAssignmentOperators.push_back(MD);
18996 assert(EnclosingDecl &&
"missing record or interface decl");
19001 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
19005 case Decl::ObjCCategory:
19008 case Decl::ObjCImplementation:
19010 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
19016 CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(EnclosingDecl);
19020 unsigned NumNamedMembers = 0;
19022 for (
const auto *I :
Record->decls()) {
19023 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
19024 if (IFD->getDeclName())
19041 RecFields.push_back(FD);
19061 bool IsLastField = (i + 1 == Fields.end());
19070 (
Record || isa<ObjCContainerDecl>(EnclosingDecl))) {
19076 unsigned DiagID = 0;
19077 if (!
Record->isUnion() && !IsLastField) {
19080 << llvm::to_underlying(
Record->getTagKind());
19081 Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
19085 }
else if (
Record->isUnion())
19087 ? diag::ext_flexible_array_union_ms
19088 : diag::ext_flexible_array_union_gnu;
19089 else if (NumNamedMembers < 1)
19091 ? diag::ext_flexible_array_empty_aggregate_ms
19092 : diag::ext_flexible_array_empty_aggregate_gnu;
19102 if (CXXRecord && CXXRecord->getNumVBases() != 0)
19116 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
19123 Record->setHasFlexibleArrayMember(
true);
19132 diag::err_incomplete_type)
19135 diag::err_field_incomplete_or_sizeless))) {
19141 if (
Record && FDTTy->getDecl()->hasFlexibleArrayMember()) {
19144 Record->setHasFlexibleArrayMember(
true);
19145 if (!
Record->isUnion()) {
19160 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
19162 diag::err_abstract_type_in_decl,
19167 if (
Record && FDTTy->getDecl()->hasObjectMember())
19168 Record->setHasObjectMember(
true);
19169 if (
Record && FDTTy->getDecl()->hasVolatileMember())
19170 Record->setHasVolatileMember(
true);
19189 FD->
addAttr(UnavailableAttr::CreateImplicit(
19190 Context,
"", UnavailableAttr::IR_ARCFieldWithOwnership,
19194 !
Record->hasObjectMember()) {
19197 Record->setHasObjectMember(
true);
19202 Record->setHasObjectMember(
true);
19205 Record->setHasObjectMember(
true);
19210 !shouldIgnoreForRecordTriviality(FD)) {
19213 Record->setNonTrivialToPrimitiveDefaultInitialize(
true);
19216 Record->setHasNonTrivialToPrimitiveDefaultInitializeCUnion(
true);
19220 Record->setNonTrivialToPrimitiveCopy(
true);
19222 Record->setHasNonTrivialToPrimitiveCopyCUnion(
true);
19225 Record->setNonTrivialToPrimitiveDestroy(
true);
19226 Record->setParamDestroyedInCallee(
true);
19228 Record->setHasNonTrivialToPrimitiveDestructCUnion(
true);
19232 if (RT->getDecl()->getArgPassingRestrictions() ==
19234 Record->setArgPassingRestrictions(
19237 Record->setArgPassingRestrictions(
19242 Record->setHasVolatileMember(
true);
19250 bool Completed =
false;
19254 Parent->isTemplateParamScope())
19255 Record->setInvalidDecl();
19259 if (!CXXRecord->isInvalidDecl()) {
19262 I = CXXRecord->conversion_begin(),
19263 E = CXXRecord->conversion_end(); I !=
E; ++I)
19264 I.setAccess((*I)->getAccess());
19270 if (!CXXRecord->isDependentType()) {
19271 if (!CXXRecord->isInvalidDecl()) {
19275 if (CXXRecord->getNumVBases()) {
19277 CXXRecord->getFinalOverriders(FinalOverriders);
19279 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
19280 MEnd = FinalOverriders.end();
19283 SOEnd = M->second.end();
19284 SO != SOEnd; ++SO) {
19285 assert(SO->second.size() > 0 &&
19286 "Virtual function without overriding functions?");
19287 if (SO->second.size() == 1)
19294 Diag(
Record->getLocation(), diag::err_multiple_final_overriders)
19296 Diag(M->first->getLocation(),
19297 diag::note_overridden_virtual_function);
19299 OM = SO->second.begin(),
19300 OMEnd = SO->second.end();
19302 Diag(OM->Method->getLocation(), diag::note_final_overrider)
19303 << (
const NamedDecl *)M->first << OM->Method->getParent();
19305 Record->setInvalidDecl();
19308 CXXRecord->completeDefinition(&FinalOverriders);
19318 Record->completeDefinition();
19324 auto IsFunctionPointerOrForwardDecl = [&](
const Decl *
D) {
19325 const FieldDecl *FD = dyn_cast<FieldDecl>(
D);
19338 if (
const auto *TD = dyn_cast<TagDecl>(
D))
19339 return !TD->isCompleteDefinition();
19343 if (isa<PointerType>(FieldType)) {
19353 (
Record->hasAttr<RandomizeLayoutAttr>() ||
19354 (!
Record->hasAttr<NoRandomizeLayoutAttr>() &&
19355 llvm::all_of(
Record->decls(), IsFunctionPointerOrForwardDecl))) &&
19357 !
Record->isRandomized()) {
19361 Record->reorderDecls(NewDeclOrdering);
19366 auto *Dtor = CXXRecord->getDestructor();
19367 if (Dtor && Dtor->isImplicit() &&
19369 CXXRecord->setImplicitDestructorIsDeleted();
19374 if (
Record->hasAttrs()) {
19377 if (
const MSInheritanceAttr *IA =
Record->getAttr<MSInheritanceAttr>())
19379 IA->getRange(), IA->getBestCase(),
19380 IA->getInheritanceModel());
19386 bool CheckForZeroSize;
19388 CheckForZeroSize =
true;
19393 CXXRecord->getLexicalDeclContext()->isExternCContext() &&
19395 CXXRecord->isCLike();
19397 if (CheckForZeroSize) {
19398 bool ZeroSize =
true;
19399 bool IsEmpty =
true;
19400 unsigned NonBitFields = 0;
19403 (NonBitFields == 0 || ZeroSize) && I !=
E; ++I) {
19405 if (I->isUnnamedBitField()) {
19406 if (!I->isZeroLengthBitField(
Context))
19410 QualType FieldType = I->getType();
19422 diag::warn_zero_size_struct_union_in_extern_c :
19423 diag::warn_zero_size_struct_union_compat)
19424 << IsEmpty <<
Record->isUnion() << (NonBitFields > 1);
19431 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union
19432 : diag::ext_no_named_members_in_struct_union)
19440 ID->setEndOfDefinitionLoc(RBrac);
19442 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
19444 ID->addDecl(ClsFields[i]);
19448 if (ID->getSuperClass())
19451 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
19452 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
19453 for (
unsigned I = 0, N = RecFields.size(); I != N; ++I)
19459 IMPDecl->setIvarLBraceLoc(LBrac);
19460 IMPDecl->setIvarRBraceLoc(RBrac);
19462 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
19470 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
19474 Diag(ClsFields[i]->getLocation(),
19475 diag::err_duplicate_ivar_declaration);
19476 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
19482 Diag(ClsFields[i]->getLocation(),
19483 diag::err_duplicate_ivar_declaration);
19484 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
19490 CDecl->addDecl(ClsFields[i]);
19492 CDecl->setIvarLBraceLoc(LBrac);
19493 CDecl->setIvarRBraceLoc(RBrac);
19502 llvm::APSInt &
Value,
19505 "Integral type required!");
19508 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
19511 return Value.getActiveBits() <= BitWidth;
19513 return Value.getSignificantBits() <= BitWidth;
19523 const unsigned NumTypes = 4;
19524 QualType SignedIntegralTypes[NumTypes] = {
19527 QualType UnsignedIntegralTypes[NumTypes] = {
19534 : UnsignedIntegralTypes;
19535 for (
unsigned I = 0; I != NumTypes; ++I)
19548 llvm::APSInt EnumVal(IntWidth);
19568 EltTy =
Enum->getIntegerType();
19575 Val = Converted.
get();
19582 if (
Enum->isComplete()) {
19583 EltTy =
Enum->getIntegerType();
19592 .isWindowsMSVCEnvironment()) {
19593 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
19595 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
19620 ? diag::warn_c17_compat_enum_value_not_int
19621 : diag::ext_c23_enum_value_not_int)
19623 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
19635 if (
Enum->isDependentType())
19637 else if (!LastEnumConst) {
19646 if (
Enum->isFixed()) {
19647 EltTy =
Enum->getIntegerType();
19656 EltTy = LastEnumConst->
getType();
19659 if (EnumVal < LastEnumConst->getInitVal()) {
19671 if (
T.isNull() ||
Enum->isFixed()) {
19675 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
19677 if (
Enum->isFixed())
19679 Diag(IdLoc, diag::err_enumerator_wrapped)
19683 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
19706 ? diag::warn_c17_compat_enum_value_not_int
19707 : diag::ext_c23_enum_value_not_int)
19708 << 1 <<
toString(EnumVal, 10) << 1;
19713 : diag::ext_c23_enum_value_not_int)
19714 << 1 <<
toString(EnumVal, 10) << 1;
19741 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
19745 EnumDecl *PrevED = cast<EnumDecl>(PrevECD->getDeclContext());
19749 Skip.Previous = Hidden;
19760 EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl);
19762 cast_or_null<EnumConstantDecl>(lastEnumConst);
19771 RedeclarationKind::ForVisibleRedeclaration);
19779 PrevDecl =
nullptr;
19797 if (!TheEnumDecl->
isScoped() && isa<ValueDecl>(PrevDecl)) {
19805 "Received TagDecl when not in C++!");
19807 if (isa<EnumConstantDecl>(PrevDecl))
19808 Diag(IdLoc, diag::err_redefinition_of_enumerator) <<
Id;
19810 Diag(IdLoc, diag::err_redefinition) <<
Id;
19843 if (!BO->isAdditiveOp())
19851 InitExpr = BO->getLHS();
19855 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InitExpr);
19875 if (!
Enum->getIdentifier())
19879 if (
Enum->getNumPositiveBits() > 63 ||
Enum->getNumNegativeBits() > 64)
19888 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
19891 typedef std::unordered_map<int64_t, DeclOrVector> ValueToVectorMap;
19895 llvm::APSInt Val =
D->getInitVal();
19896 return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
19899 DuplicatesVector DupVector;
19900 ValueToVectorMap EnumMap;
19904 for (
auto *Element : Elements) {
19918 EnumMap.insert({EnumConstantToKey(ECD), ECD});
19921 if (EnumMap.size() == 0)
19925 for (
auto *Element : Elements) {
19931 auto Iter = EnumMap.find(EnumConstantToKey(ECD));
19932 if (
Iter == EnumMap.end())
19935 DeclOrVector& Entry =
Iter->second;
19942 auto Vec = std::make_unique<ECDVector>();
19944 Vec->push_back(ECD);
19951 DupVector.emplace_back(std::move(Vec));
19955 ECDVector *Vec = cast<ECDVector *>(Entry);
19957 if (*Vec->begin() == ECD)
19960 Vec->push_back(ECD);
19964 for (
const auto &Vec : DupVector) {
19965 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
19968 auto *FirstECD = Vec->front();
19969 S.
Diag(FirstECD->getLocation(), diag::warn_duplicate_enum_values)
19970 << FirstECD <<
toString(FirstECD->getInitVal(), 10)
19971 << FirstECD->getSourceRange();
19975 for (
auto *ECD : llvm::drop_begin(*Vec))
19976 S.
Diag(ECD->getLocation(), diag::note_duplicate_element)
19977 << ECD <<
toString(ECD->getInitVal(), 10)
19978 << ECD->getSourceRange();
19983 bool AllowMask)
const {
19984 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
19987 auto R =
FlagBitsCache.insert(std::make_pair(ED, llvm::APInt()));
19988 llvm::APInt &FlagBits = R.first->second;
19992 const auto &EVal =
E->getInitVal();
19994 if (EVal.isPowerOf2())
19995 FlagBits = FlagBits.zext(EVal.getBitWidth()) | EVal;
20007 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
20008 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
20020 if (
Enum->isDependentType()) {
20021 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
20023 cast_or_null<EnumConstantDecl>(Elements[i]);
20024 if (!ECD)
continue;
20039 unsigned NumNegativeBits = 0;
20040 unsigned NumPositiveBits = 0;
20041 bool MembersRepresentableByInt =
true;
20043 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
20045 cast_or_null<EnumConstantDecl>(Elements[i]);
20046 if (!ECD)
continue;
20051 if (InitVal.isUnsigned() || InitVal.isNonNegative()) {
20054 unsigned ActiveBits = InitVal.getActiveBits();
20055 NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u});
20058 std::max(NumNegativeBits, (
unsigned)InitVal.getSignificantBits());
20060 MembersRepresentableByInt &=
20068 if (!NumPositiveBits && !NumNegativeBits)
20069 NumPositiveBits = 1;
20073 unsigned BestWidth;
20086 bool Packed =
Enum->hasAttr<PackedAttr>();
20094 if (
Enum->isComplete()) {
20095 BestType =
Enum->getIntegerType();
20099 BestPromotionType = BestType;
20103 else if (NumNegativeBits) {
20107 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
20109 BestWidth = CharWidth;
20110 }
else if (Packed && NumNegativeBits <= ShortWidth &&
20111 NumPositiveBits < ShortWidth) {
20113 BestWidth = ShortWidth;
20114 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
20116 BestWidth = IntWidth;
20120 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
20125 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
20126 Diag(
Enum->getLocation(), diag::ext_enum_too_large);
20130 BestPromotionType = (BestWidth <= IntWidth ?
Context.
IntTy : BestType);
20135 if (Packed && NumPositiveBits <= CharWidth) {
20138 BestWidth = CharWidth;
20139 }
else if (Packed && NumPositiveBits <= ShortWidth) {
20142 BestWidth = ShortWidth;
20143 }
else if (NumPositiveBits <= IntWidth) {
20145 BestWidth = IntWidth;
20147 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
20149 }
else if (NumPositiveBits <=
20153 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
20157 if (NumPositiveBits > BestWidth) {
20162 Diag(
Enum->getLocation(), diag::ext_enum_too_large);
20166 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
20173 for (
auto *
D : Elements) {
20174 auto *ECD = cast_or_null<EnumConstantDecl>(
D);
20175 if (!ECD)
continue;
20184 llvm::APSInt InitVal = ECD->getInitVal();
20192 MembersRepresentableByInt) {
20200 NewWidth = IntWidth;
20202 }
else if (ECD->getType() == BestType) {
20212 NewWidth = BestWidth;
20217 InitVal = InitVal.extOrTrunc(NewWidth);
20218 InitVal.setIsSigned(NewSign);
20219 ECD->setInitVal(
Context, InitVal);
20222 if (ECD->getInitExpr() &&
20225 Context, NewTy, CK_IntegralCast, ECD->getInitExpr(),
20233 ECD->setType(NewTy);
20236 Enum->completeDefinition(BestType, BestPromotionType,
20237 NumPositiveBits, NumNegativeBits);
20241 if (
Enum->isClosedFlag()) {
20242 for (
Decl *
D : Elements) {
20244 if (!ECD)
continue;
20247 if (InitVal != 0 && !InitVal.isPowerOf2() &&
20255 if (
Enum->hasAttrs())
20265 AsmString, StartLoc,
20281 D->setStmt(Statement);
20296 AsmLabelAttr *
Attr = AsmLabelAttr::CreateImplicit(
20303 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
20307 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
20308 << (isa<FunctionDecl>(PrevDecl) ? 0 : 1) << PrevDecl;
20320 PrevDecl->
addAttr(WeakAttr::CreateImplicit(
Context, PragmaLoc));
20335 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
20336 if (!PrevDecl->
hasAttr<AliasAttr>())
20337 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
20346 assert(FD &&
"Expected non-null FunctionDecl");
20358 auto IsEmittedForExternalSymbol = [
this, FD]() {
20370 if (
LangOpts.OpenMPIsTargetDevice) {
20373 std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
20380 if (*DevTy == OMPDeclareTargetDeclAttr::DT_Host)
20384 if (
OpenMP().isInOpenMPDeclareTargetContext() || DevTy)
20385 if (IsEmittedForExternalSymbol())
20391 }
else if (
LangOpts.OpenMP > 45) {
20395 std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
20398 if (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost)
20417 if (IsEmittedForExternalSymbol())
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
static constexpr Builtin::Info BuiltinInfo[]
Defines enum values for all the target-independent builtin functions.
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
static bool isDeclExternC(const T &D)
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
Defines the clang::Expr interface and subclasses for C++ expressions.
static const Decl * getCanonicalDecl(const Decl *D)
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
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.
llvm::MachO::Architecture Architecture
llvm::MachO::Record Record
static bool isExternC(const NamedDecl *ND)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis for CUDA constructs.
static void diagnoseImplicitlyRetainedSelf(Sema &S)
static void SetNestedNameSpecifier(Sema &S, DeclaratorDecl *DD, Declarator &D)
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.
static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, const FunctionDecl *&PossiblePrototype)
static bool isMainVar(DeclarationName Name, VarDecl *VD)
static bool PreviousDeclsHaveMultiVersionAttribute(const FunctionDecl *FD)
static ParsedType recoverFromTypeInKnownDependentBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc)
static void mergeParamDeclTypes(ParmVarDecl *NewParam, const ParmVarDecl *OldParam, Sema &S)
static void checkHybridPatchableAttr(Sema &S, NamedDecl &ND)
static void adjustDeclContextForDeclaratorDecl(DeclaratorDecl *NewD, DeclaratorDecl *OldD)
If necessary, adjust the semantic declaration context for a qualified declaration to name the correct...
static bool isResultTypeOrTemplate(LookupResult &R, const Token &NextToken)
Determine whether the given result set contains either a type name or.
static void FixInvalidVariablyModifiedTypeLoc(TypeLoc SrcTL, TypeLoc DstTL)
static bool AllowOverloadingOfFunction(const LookupResult &Previous, ASTContext &Context, const FunctionDecl *New)
Determine whether overloading is allowed for a new function declaration considering prior declaration...
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...
static StringRef getHeaderName(Builtin::Context &BuiltinInfo, unsigned ID, ASTContext::GetBuiltinTypeError Error)
static StorageClass getFunctionStorageClass(Sema &SemaRef, Declarator &D)
static bool checkUsingShadowRedecl(Sema &S, UsingShadowDecl *OldS, ExpectedDecl *New)
Check whether a redeclaration of an entity introduced by a using-declaration is valid,...
static bool mergeDeclAttribute(Sema &S, NamedDecl *D, const InheritableAttr *Attr, Sema::AvailabilityMergeKind AMK)
static ShadowedDeclKind computeShadowedDeclKind(const NamedDecl *ShadowedDecl, const DeclContext *OldDC)
Determine what kind of declaration we're shadowing.
static void checkIsValidOpenCLKernelParameter(Sema &S, Declarator &D, ParmVarDecl *Param, llvm::SmallPtrSetImpl< const Type * > &ValidTypes)
static void mergeParamDeclAttributes(ParmVarDecl *newDecl, const ParmVarDecl *oldDecl, Sema &S)
mergeParamDeclAttributes - Copy attributes from the old parameter to the new one.
static bool CheckC23ConstexprVarType(Sema &SemaRef, SourceLocation VarLoc, QualType T)
static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD, bool &Redeclaration, NamedDecl *&OldDecl, LookupResult &Previous)
Check the validity of a mulitversion function declaration.
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...
static bool mergeTypeWithPrevious(Sema &S, VarDecl *NewVD, VarDecl *OldVD, LookupResult &Previous)
static void CheckConstPureAttributesUsage(Sema &S, FunctionDecl *NewFD)
static bool FindPossiblePrototype(const FunctionDecl *FD, const FunctionDecl *&PossiblePrototype)
static bool MultiVersionTypesCompatible(FunctionDecl *Old, FunctionDecl *New)
static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx, FixItHint &Hint)
static void CheckExplicitObjectParameter(Sema &S, ParmVarDecl *P, SourceLocation ExplicitThisLoc)
static NestedNameSpecifier * synthesizeCurrentNestedNameSpecifier(ASTContext &Context, DeclContext *DC)
static void checkLifetimeBoundAttr(Sema &S, NamedDecl &ND)
static void patchDefaultTargetVersion(FunctionDecl *From, FunctionDecl *To)
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...
static bool isRepresentableIntegerValue(ASTContext &Context, llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T.
static void CheckForDuplicateEnumValues(Sema &S, ArrayRef< Decl * > Elements, EnumDecl *Enum, QualType EnumType)
static unsigned GetDiagnosticTypeSpecifierID(const DeclSpec &DS)
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 bool isClassCompatTagKind(TagTypeKind Tag)
Determine if tag kind is a class-key compatible with class for redeclaration (class,...
static bool hasIdenticalPassObjectSizeAttrs(const FunctionDecl *A, const FunctionDecl *B)
static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND)
static bool hasSimilarParameters(ASTContext &Context, FunctionDecl *Declaration, FunctionDecl *Definition, SmallVectorImpl< unsigned > &Params)
hasSimilarParameters - Determine whether the C++ functions Declaration and Definition have "nearly" m...
static NonCLikeKind getNonCLikeKindForAnonymousStruct(const CXXRecordDecl *RD)
Determine whether a class is C-like, according to the rules of C++ [dcl.typedef] for anonymous classe...
static FunctionDecl * CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, DeclContext *DC, QualType &R, TypeSourceInfo *TInfo, StorageClass SC, bool &IsVirtualOkay)
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...
static bool methodHasName(const FunctionDecl *FD, StringRef Name)
static std::pair< diag::kind, SourceLocation > getNoteDiagForInvalidRedeclaration(const T *Old, const T *New)
static bool checkForConflictWithNonVisibleExternC(Sema &S, const T *ND, LookupResult &Previous)
Apply special rules for handling extern "C" declarations.
static bool DeclHasAttr(const Decl *D, const Attr *A)
DeclhasAttr - returns true if decl Declaration already has the target attribute.
static bool isOpenCLSizeDependentType(ASTContext &C, QualType Ty)
static void diagnoseMissingConstinit(Sema &S, const VarDecl *InitDecl, const ConstInitAttr *CIAttr, bool AttrBeforeInit)
static bool shouldWarnIfShadowedDecl(const DiagnosticsEngine &Diags, const LookupResult &R)
static FixItHint createFriendTagNNSFixIt(Sema &SemaRef, NamedDecl *ND, Scope *S, SourceLocation NameLoc)
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
static bool CheckAnonMemberRedeclaration(Sema &SemaRef, Scope *S, DeclContext *Owner, DeclarationName Name, SourceLocation NameLoc, bool IsUnion, StorageClass SC)
We are trying to inject an anonymous member into the given scope; check if there's an existing declar...
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 bool ShouldDiagnoseUnusedDecl(const LangOptions &LangOpts, const NamedDecl *D)
static bool isStdBuiltin(ASTContext &Ctx, FunctionDecl *FD, unsigned BuiltinID)
Determine whether a declaration matches a known function in namespace std.
static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, DeclContext *Owner, RecordDecl *AnonRecord, AccessSpecifier AS, StorageClass SC, SmallVectorImpl< NamedDecl * > &Chaining)
InjectAnonymousStructOrUnionMembers - Inject the members of the anonymous struct or union AnonRecord ...
@ InvalidAddrSpacePtrKernelParam
static bool isFromSystemHeader(SourceManager &SM, const Decl *D)
Returns true if the declaration is declared in a system header or from a system macro.
static bool AreSpecialMemberFunctionsSameKind(ASTContext &Context, CXXMethodDecl *M1, CXXMethodDecl *M2, CXXSpecialMemberKind CSM)
[class.mem.special]p5 Two special member functions are of the same kind if:
static const CXXRecordDecl * findRecordWithDependentBasesOfEnclosingMethod(const DeclContext *DC)
Find the parent class with dependent bases of the innermost enclosing method context.
static void ComputeSelectedDestructor(Sema &S, CXXRecordDecl *Record)
[class.dtor]p4: At the end of the definition of a class, overload resolution is performed among the p...
static bool shouldConsiderLinkage(const VarDecl *VD)
static SourceLocation findDefaultInitializer(const CXXRecordDecl *Record)
static bool CheckMultiVersionAdditionalRules(Sema &S, const FunctionDecl *OldFD, const FunctionDecl *NewFD, bool CausesMV, MultiVersionKind MVKind)
static DeclContext * getTagInjectionContext(DeclContext *DC)
Find the DeclContext in which a tag is implicitly declared if we see an elaborated type specifier in ...
static bool EquivalentArrayTypes(QualType Old, QualType New, const ASTContext &Ctx)
static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New)
static unsigned getRedeclDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for redeclaration diagnostic message.
static void checkInheritableAttr(Sema &S, NamedDecl &ND)
static void CheckPoppedLabel(LabelDecl *L, Sema &S, Sema::DiagReceiverTy DiagReceiver)
static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl *Old)
static NamedDecl * DiagnoseInvalidRedeclaration(Sema &SemaRef, LookupResult &Previous, FunctionDecl *NewFD, ActOnFDArgs &ExtraArgs, bool IsLocalFriend, Scope *S)
Generate diagnostics for an invalid function redeclaration.
static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, DeclarationName Name)
RebuildDeclaratorInCurrentInstantiation - Checks whether the given declarator needs to be rebuilt in ...
static void SetEligibleMethods(Sema &S, CXXRecordDecl *Record, ArrayRef< CXXMethodDecl * > Methods, CXXSpecialMemberKind CSM)
[class.mem.special]p6: An eligible special member function is a special member function for which:
static bool isTagTypeWithMissingTag(Sema &SemaRef, LookupResult &Result, Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc)
static bool hasParsedAttr(Scope *S, const Declarator &PD, ParsedAttr::Kind Kind)
ShadowedDeclKind
Enum describing the select options in diag::warn_decl_shadow.
static unsigned getMSManglingNumber(const LangOptions &LO, Scope *S)
static void emitReadOnlyPlacementAttrWarning(Sema &S, const VarDecl *VD)
static bool canRedefineFunction(const FunctionDecl *FD, const LangOptions &LangOpts)
canRedefineFunction - checks if a function can be redefined.
static void checkWeakAttr(Sema &S, NamedDecl &ND)
static void checkSelectAnyAttr(Sema &S, NamedDecl &ND)
static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT)
static void checkDuplicateDefaultInit(Sema &S, CXXRecordDecl *Parent, SourceLocation DefaultInitLoc)
static bool isDefaultStdCall(FunctionDecl *FD, Sema &S)
static bool diagnoseOpenCLTypes(Sema &Se, VarDecl *NewVD)
Returns true if there hasn't been any invalid type diagnosed.
static void RemoveUsingDecls(LookupResult &R)
Removes using shadow declarations not at class scope from the lookup results.
static void ComputeSpecialMemberFunctionsEligiblity(Sema &S, CXXRecordDecl *Record)
static bool AttrCompatibleWithMultiVersion(attr::Kind Kind, MultiVersionKind MVKind)
static bool isUsingDeclNotAtClassScope(NamedDecl *D)
static const NamedDecl * getDefinition(const Decl *D)
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 bool hasDeducedAuto(DeclaratorDecl *DD)
static void copyAttrFromTypedefToDecl(Sema &S, Decl *D, const TypedefType *TT)
static QualType getCoreType(QualType Ty)
static bool isMainFileLoc(const Sema &S, SourceLocation Loc)
static bool CheckMultiVersionValue(Sema &S, const FunctionDecl *FD)
Check the target or target_version attribute of the function for MultiVersion validity.
static bool isOutOfScopePreviousDeclaration(NamedDecl *, DeclContext *, ASTContext &)
Determines whether the given declaration is an out-of-scope previous declaration.
static StorageClass StorageClassSpecToVarDeclStorageClass(const DeclSpec &DS)
StorageClassSpecToVarDeclStorageClass - Maps a DeclSpec::SCS to a VarDecl::StorageClass.
static ParsedType buildNamedType(Sema &S, const CXXScopeSpec *SS, QualType T, SourceLocation NameLoc, bool WantNontrivialTypeSourceInfo=true)
Build a ParsedType for a simple-type-specifier with a nested-name-specifier.
static bool CheckMultiVersionAdditionalDecl(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, const CPUDispatchAttr *NewCPUDisp, const CPUSpecificAttr *NewCPUSpec, const TargetClonesAttr *NewClones, bool &Redeclaration, NamedDecl *&OldDecl, LookupResult &Previous)
Check the validity of a new function declaration being added to an existing multiversioned declaratio...
static SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI, const VarDecl *VD)
Return the location of the capture if the given lambda captures the given variable VD,...
static bool CheckMultiVersionFirstFunction(Sema &S, FunctionDecl *FD)
Check the validity of a multiversion function declaration that is the first of its kind.
static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization, bool IsDefinition)
static bool checkNonMultiVersionCompatAttributes(Sema &S, const FunctionDecl *FD, const FunctionDecl *CausedFD, MultiVersionKind MVKind)
static void checkAliasAttr(Sema &S, NamedDecl &ND)
static void filterNonConflictingPreviousTypedefDecls(Sema &S, const TypedefNameDecl *Decl, LookupResult &Previous)
Typedef declarations don't have linkage, but they still denote the same entity if their types are the...
static bool ValidDuplicateEnum(EnumConstantDecl *ECD, EnumDecl *Enum)
static QualType getNextLargerIntegralType(ASTContext &Context, QualType T)
static void checkWeakRefAttr(Sema &S, NamedDecl &ND)
static bool isIncompleteDeclExternC(Sema &S, const T *D)
Determine whether a variable is extern "C" prior to attaching an initializer.
static bool isAttributeTargetADefinition(Decl *D)
static Attr * getImplicitCodeSegAttrFromClass(Sema &S, const FunctionDecl *FD)
Return a CodeSegAttr from a containing class.
static bool CheckDeclarationCausesMultiVersioning(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, bool &Redeclaration, NamedDecl *&OldDecl, LookupResult &Previous)
static bool IsDisallowedCopyOrAssign(const CXXMethodDecl *D)
Check for this common pattern:
static bool isAcceptableTagRedeclContext(Sema &S, DeclContext *OldDC, DeclContext *NewDC)
Determine whether a tag originally declared in context OldDC can be redeclared with an unqualified na...
static bool isRecordType(QualType T)
This file declares semantic analysis for HLSL constructs.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis functions specific to PowerPC.
This file declares semantic analysis functions specific to RISC-V.
This file declares semantic analysis functions specific to Swift.
This file declares semantic analysis functions specific to Wasm.
static CharSourceRange getRange(const CharSourceRange &EditRange, const SourceManager &SM, const LangOptions &LangOpts, bool IncludeMacroExpansion)
Defines the SourceManager interface.
static QualType getPointeeType(const MemRegion *R)
C Language Family Type Representation.
const NestedNameSpecifier * Specifier
RAII object that pops an ExpressionEvaluationContext when exiting a function body.
ExitFunctionBodyRAII(Sema &S, bool IsLambda)
llvm::APInt getValue() const
virtual void HandleTagDeclDefinition(TagDecl *D)
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
virtual void HandleInlineFunctionDefinition(FunctionDecl *D)
This callback is invoked each time an inline (method or friend) function definition in a class is com...
virtual bool shouldSkipFunctionBody(Decl *D)
This callback is called for each function if the Parser was initialized with SkipFunctionBodies set t...
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getUsingType(const UsingShadowDecl *Found, QualType Underlying) const
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getParenType(QualType NamedType) const
unsigned getIntWidth(QualType T) const
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
ExternCContextDecl * getExternCContextDecl() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
DeclarationNameTable DeclarationNames
QualType getObjCClassType() const
Represents the Objective-C Class type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getRecordType(const RecordDecl *Decl) const
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
void setObjCIdRedefinitionType(QualType RedefType)
Set the user-written type that redefines id.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
void setObjCSelRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const
Determine whether two function types are the same, ignoring exception specifications in cases where t...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Builtin::Context & BuiltinInfo
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const LangOptions & getLangOpts() const
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
CanQualType UnsignedLongTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
bool hasAnyFunctionEffects() const
bool hasSameFunctionTypeIgnoringParamABI(QualType T, QualType U) const
Determine if two function types are the same, ignoring parameter ABI annotations.
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
const clang::PrintingPolicy & getPrintingPolicy() const
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
void registerSYCLEntryPointFunction(FunctionDecl *FD)
Generates and stores SYCL kernel metadata for the provided SYCL kernel entry point function.
CanQualType UnsignedShortTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
void setcudaConfigureCallDecl(FunctionDecl *FD)
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
const VariableArrayType * getAsVariableArrayType(QualType T) const
void setObjCClassRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void ResetObjCLayout(const ObjCContainerDecl *CD)
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
const TargetInfo & getTargetInfo() const
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
LangAS getLangASForBuiltinAddressSpace(unsigned AS) const
bool hasSameFunctionTypeIgnoringPtrSizes(QualType T, QualType U)
Determine whether two function types are the same, ignoring pointer sizes in the return type and para...
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
@ GE_Missing_stdio
Missing a type from <stdio.h>
@ GE_Missing_type
Missing a type.
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
The result of parsing/analyzing an expression, statement etc.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Wrapper for source info for arrays.
SourceLocation getLBracketLoc() const
Expr * getSizeExpr() const
TypeLoc getElementLoc() const
SourceLocation getRBracketLoc() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Attr - This represents one attribute.
attr::Kind getKind() const
Attr * clone(ASTContext &C) const
SourceLocation getLocation() const
@ AS_Declspec
__declspec(...)
SourceRange getRange() const
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
AttributeFactory & getFactory() const
Type source information for an attributed type.
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
An attributed type is a type to which a type attribute has been applied.
QualType getModifiedType() const
bool isCallingConv() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
AutoTypeKeyword getKeyword() const
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
A binding in a decomposition declaration.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
bool doesNotEscape() const
This class is used for builtin types like 'int'.
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
bool performsCallback(unsigned ID, llvm::SmallVectorImpl< int > &Encoding) const
Determine whether this builtin has callback behavior (see llvm::AbstractCallSites for details).
bool isAuxBuiltinID(unsigned ID) const
Return true if builtin ID belongs to AuxTarget.
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name.
llvm::StringRef getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
bool isReturnsTwice(unsigned ID) const
Return true if we know this builtin can return twice.
bool isImmediate(unsigned ID) const
Returns true if this is an immediate (consteval) function.
bool isConstWithoutErrnoAndExceptions(unsigned ID) const
Return true if this function has no side effects and doesn't read memory, except for possibly errno o...
bool allowTypeMismatch(unsigned ID) const
Determines whether a declaration of this builtin should be recognized even if the type doesn't match ...
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
bool isHeaderDependentFunction(unsigned ID) const
Returns true if this builtin requires appropriate header in other compilers.
bool isScanfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like scanf in its formatting rules and, if so, set the index to the...
bool isInStdNamespace(unsigned ID) const
Determines whether this builtin is a C++ standard library function that lives in (possibly-versioned)...
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc",...
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 isConstWithoutExceptions(unsigned ID) const
bool isPredefinedRuntimeFunction(unsigned ID) const
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache",...
bool isPure(unsigned ID) const
Return true if this function has no side effects.
bool isNoThrow(unsigned ID) const
Return true if we know this builtin never throws an exception.
bool isConst(unsigned ID) const
Return true if this function has no side effects and doesn't read memory.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a base class of a C++ class.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
Represents a call to a C++ constructor.
Represents a C++ constructor within a class.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), Expr *TrailingRequiresClause=nullptr)
Represents a C++ conversion function within a class.
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor=nullptr, DeductionCandidate Kind=DeductionCandidate::Normal, Expr *TrailingRequiresClause=nullptr)
Represents a C++ destructor within a class.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
A mapping from each virtual member function to its set of final overriders.
Represents a static or instance method of a struct/union/class.
bool isExplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An explicit object member function is a non-static member function with an explic...
void addOverriddenMethod(const CXXMethodDecl *MD)
QualType getFunctionObjectParameterReferenceType() const
Return the type of the object pointed by this.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
Qualifiers getMethodQualifiers() const
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
A call to an overloaded operator written using operator syntax.
Represents a C++ struct/union/class.
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class....
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
base_class_iterator bases_end()
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
CXXRecordDecl * getDefinition() const
unsigned getNumBases() const
Retrieves the number of base classes of this class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
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...
base_class_iterator bases_begin()
capture_const_range captures() const
bool hasDefinition() const
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
LambdaCaptureDefault getLambdaCaptureDefault() const
void setDescribedClassTemplate(ClassTemplateDecl *Template)
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6,...
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
char * location_data() const
Retrieve the data associated with the source-location information.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
static CharSourceRange getCharRange(SourceRange R)
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a class template.
bool exprNeedsCleanups() const
ConditionalOperator - The ?: ternary operator.
Represents the canonical version of C arrays with a specified constant size.
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
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 isZeroSize() const
Return true if the size is zero.
llvm::APInt getSize() const
Return the constant array size as an APInt.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isObjCContainer() const
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
const BlockDecl * getInnermostBlockDecl() const
Return this DeclContext if it is a BlockDecl.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void removeDecl(Decl *D)
Removes a declaration from this context.
void addDecl(Decl *D)
Add the declaration D into this context.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Decl::Kind getDeclKind() const
DeclContext * getNonTransparentContext()
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
A reference to a declared variable, function, enum, etc.
SourceLocation getBeginLoc() const LLVM_READONLY
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
bool isModulePrivateSpecified() const
static const TST TST_typeof_unqualType
bool hasAutoTypeSpec() const
static const TST TST_typename
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 isNoreturnSpecified() const
TST getTypeSpecType() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
void SetRangeEnd(SourceLocation Loc)
static const TST TST_interface
static const TST TST_typeofExpr
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void SetRangeStart(SourceLocation Loc)
SourceLocation getNoreturnSpecLoc() const
bool isExternInLinkageSpec() const
static const TST TST_union
SCS
storage-class-specifier
SourceLocation getExplicitSpecLoc() const
SourceLocation getModulePrivateSpecLoc() const
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
ParsedType getRepAsType() const
void UpdateTypeRep(ParsedType Rep)
TSCS getThreadStorageClassSpec() const
ParsedAttributes & getAttributes()
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
SourceLocation getConstSpecLoc() const
Expr * getRepAsExpr() const
static const TST TST_enum
static const TST TST_decltype
static bool isDeclRep(TST T)
bool isInlineSpecified() const
SourceLocation getRestrictSpecLoc() const
static const TST TST_typeof_unqualExpr
static const TST TST_class
static const TST TST_void
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
static const TST TST_atomic
SourceLocation getThreadStorageClassSpecLoc() const
Decl * getRepAsDecl() const
static const TST TST_unspecified
SourceLocation getAtomicSpecLoc() const
SourceLocation getVirtualSpecLoc() const
SourceLocation getConstexprSpecLoc() const
SourceLocation getTypeSpecTypeLoc() const
void UpdateExprRep(Expr *Rep)
static const TSCS TSCS_thread_local
static const TST TST_error
bool isTypeSpecOwned() const
SourceLocation getInlineSpecLoc() const
SourceLocation getUnalignedSpecLoc() const
SourceLocation getVolatileSpecLoc() const
FriendSpecified isFriendSpecified() const
bool hasExplicitSpecifier() const
bool hasConstexprSpecifier() const
static const TST TST_typeofType
static const TST TST_auto
ConstexprSpecKind getConstexprSpecifier() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
bool isInStdNamespace() const
SourceLocation getEndLoc() const LLVM_READONLY
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
bool isFromGlobalModule() const
Whether this declaration comes from global module.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setAttrs(const AttrVec &Attrs)
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
bool isInNamedModule() const
Whether this declaration comes from a named module.
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
void setTopLevelDeclInObjCContainer(bool V=true)
bool isInIdentifierNamespace(unsigned NS) const
@ FOK_Undeclared
A friend of a previously-undeclared entity.
@ FOK_None
Not a friend object.
@ FOK_Declared
A friend of a previously-declared entity.
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
bool isInExportDeclContext() const
Whether this declaration was exported in a lexical context.
bool isReferenced() const
Whether any declaration of this entity was referenced.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isInvalidDecl() const
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
@ IDNS_Ordinary
Ordinary names.
void setLocalOwningModule(Module *M)
void setImplicit(bool I=true)
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
Module * getOwningModuleForLinkage() const
Get the module that owns this declaration for linkage purposes.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
void setLexicalDeclContext(DeclContext *DC)
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
The name of a declaration.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Represents a ValueDecl that came out of a declarator.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
TypeSourceInfo * getTypeSourceInfo() const
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Information about one declarator, including the parsed type information and the identifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const ParsedAttributes & getAttributes() const
void SetIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const ParsedAttributesView & getDeclarationAttributes() const
A decomposition declaration.
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl * > Bindings)
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
SourceRange getSourceRange() const
SourceLocation getLSquareLoc() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Concrete class used by the front-end to report problems and issues.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
An instance of this object exists for each enum constant that is defined.
llvm::APSInt getInitVal() const
static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
const Expr * getInitExpr() const
enumerator_range enumerators() const
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
void setIntegerType(QualType T)
Set the underlying integer type.
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
bool isComplete() const
Returns true if this can be considered a complete type.
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
bool isClosedFlag() const
Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(ope...
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
SourceRange getIntegerTypeRange() const LLVM_READONLY
Retrieve the source range that covers the underlying type if specified.
void setPromotionType(QualType T)
Set the promotion type.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EvaluatedExprVisitor - This class visits 'Expr *'s.
Store information needed for an explicit specifier.
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool containsErrors() const
Whether this expression contains subexpressions which had errors, e.g.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
Represents difference between two FPOptions values.
void setDisallowOptimizations()
void applyChanges(FPOptionsOverride FPO)
bool isFPConstrained() const
FPOptionsOverride getChangesFrom(const FPOptions &Base) const
Return difference with the given option set.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
bool isZeroLengthBitField(const ASTContext &Ctx) const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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.
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
const ParmVarDecl * getParamDecl(unsigned i) const
ConstexprSpecKind getConstexprKind() const
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
void setPreviousDeclaration(FunctionDecl *PrevDecl)
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
void setIsPureVirtual(bool P=true)
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
void setFriendConstraintRefersToEnclosingTemplate(bool V=true)
void setHasSkippedBody(bool Skipped=true)
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
param_iterator param_end()
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool isCPUSpecificMultiVersion() const
True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
bool hasWrittenPrototype() const
Whether this function has a written prototype.
void setWillHaveBody(bool V=true)
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
param_iterator param_begin()
const ParmVarDecl * getNonObjectParameter(unsigned I) const
bool isVariadic() const
Whether this function is variadic.
bool isDeleted() const
Whether this function has been deleted.
FunctionEffectsRef getFunctionEffects() const
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
@ TK_MemberSpecialization
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
bool isDeletedAsWritten() const
void setHasInheritedPrototype(bool P=true)
State that this function inherited its prototype from a previous declaration.
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
bool isImmediateEscalating() const
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
FunctionDecl * getDefinition()
Get the definition for this declaration.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
bool isReplaceableGlobalAllocationFunction(std::optional< unsigned > *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause=nullptr)
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
void setRangeEnd(SourceLocation E)
bool isCPUDispatchMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...
bool isDefaulted() const
Whether this function is defaulted.
void setIneligibleOrNotSelected(bool II)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
void setConstexprKind(ConstexprSpecKind CSK)
void setDefaulted(bool D=true)
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
bool isGlobal() const
Determines whether this is a global function.
void setDeletedAsWritten(bool D=true, StringLiteral *Message=nullptr)
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
DeclarationNameInfo getNameInfo() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
void setHasImplicitReturnZero(bool IRZ)
State that falling off this function implicitly returns null/zero.
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
MultiVersionKind getMultiVersionKind() const
Gets the kind of multiversioning attribute this declaration has.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
A mutable set of FunctionEffects and possibly conditions attached to them.
static FunctionEffectSet getUnion(FunctionEffectsRef LHS, FunctionEffectsRef RHS, Conflicts &Errs)
An immutable set of FunctionEffects and possibly conditions attached to them.
Represents a prototype with parameter type info, e.g.
unsigned getNumParams() const
QualType getParamType(unsigned i) const
unsigned getAArch64SMEAttributes() const
Return a bitmask describing the SME attributes on the function type, see AArch64SMETypeAttributes for...
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
Wrapper for source info for functions.
A class which abstracts out some details necessary for making a call.
ExtInfo withCallingConv(CallingConv cc) const
CallingConv getCC() const
ExtInfo withProducesResult(bool producesResult) const
unsigned getRegParm() const
bool getNoCallerSavedRegs() const
ExtInfo withNoReturn(bool noReturn) const
bool getHasRegParm() const
bool getProducesResult() const
ExtInfo withNoCallerSavedRegs(bool noCallerSavedRegs) const
ExtInfo withRegParm(unsigned RegParm) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
static StringRef getNameForCallConv(CallingConv CC)
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
unsigned getRegParmType() const
CallingConv getCallConv() const
QualType getReturnType() const
bool getCmseNSCallAttr() const
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
bool isPlaceholder() const
StringRef getName() const
Return the actual identifier string.
iterator - Iterate over the decls of a specified declaration name.
iterator begin(DeclarationName Name)
Returns an iterator over decls with the name 'Name'.
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
void InsertDeclAfter(iterator Pos, NamedDecl *D)
Insert the given declaration after the given iterator position.
iterator end()
Returns the end iterator.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
Represents a C array with an unspecified size.
Represents a field injected from an anonymous union/struct into the parent scope.
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl * > CH)
void setInherited(bool I)
Description of a constructor that was inherited from a base class.
Describes an C or C++ initializer list.
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
Describes the sequence of initializations required to initialize a given object or reference with a s...
step_iterator step_begin() const
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.
@ SK_ParenthesizedListInit
Initialize an aggreagate with parenthesized list of values.
Describes an entity that is being initialized.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
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'.
Represents the declaration of a label.
bool isResolvedMSAsmLabel() const
LabelStmt * getStmt() const
bool isMSAsmLabel() const
@ FPE_Ignore
Assume that floating-point exceptions are masked.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
FPExceptionModeKind getDefaultExceptionMode() const
bool requiresStrictPrototypes() const
Returns true if functions without prototypes or functions with an identifier list (aka K&R C function...
clang::ObjCRuntime ObjCRuntime
std::string getOpenCLVersionString() const
Return the OpenCL C or C++ for OpenCL language name and version as a string.
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i....
bool implicitFunctionsAllowed() const
Returns true if implicit function declarations are allowed in the current language mode.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
void push_back(const T &LocalValue)
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...
Represents a linkage specification.
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LinkageSpecLanguageIDs Lang, bool HasBraces)
void InstantiatedLocal(const Decl *D, Decl *Inst)
A class for iterating through a result set and possibly filtering out results.
void erase()
Erase the last element returned from this iterator.
Represents the results of name lookup.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ Found
Name lookup found a single declaration that met the criteria.
DeclClass * getAsSingle() const
bool empty() const
Return true if no decls were found.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Filter makeFilter()
Create a filter for this result set.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
LookupResultKind getResultKind() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
@ AmbiguousTagHiding
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
virtual unsigned getStaticLocalNumber(const VarDecl *VD)=0
Static locals are numbered by source order.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Describes a module or submodule.
SourceLocation DefinitionLoc
The location of the module definition.
Module * Parent
The parent of this module.
bool isPrivateModule() const
bool isHeaderLikeModule() const
Is this module have similar semantics as headers.
bool isModuleImplementation() const
Is this a module implementation.
bool isModulePartition() const
Is this a module partition.
bool isImplicitGlobalModule() const
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
bool isNamedModule() const
Does this Module is a named module of a standard named module?
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isLinkageValid() const
True if the computed linkage is valid.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
bool isPlaceholderVar(const LangOptions &LangOpts) const
bool hasLinkageBeenComputed() const
True if something has required us to compute the linkage of this declaration.
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
bool hasLinkage() const
Determine whether this declaration has linkage.
bool isExternallyVisible() const
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represent a C++ namespace.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
A C++ nested-name-specifier augmented with source location information.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier,...
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool containsErrors() const
Whether this nested name specifier contains an error.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
ObjCCategoryDecl - Represents a category declaration.
ObjCCompatibleAliasDecl - Represents alias of a class.
ObjCContainerDecl - Represents a container for method declarations.
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
known_extensions_range known_extensions() const
ObjCIvarDecl - Represents an ObjC instance variable.
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
An expression that sends a message to the given Objective-C object or class.
ObjCMethodDecl - Represents an instance or class method declaration.
param_const_iterator param_end() const
param_const_iterator param_begin() const
const ParmVarDecl *const * param_const_iterator
ParmVarDecl *const * param_iterator
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
Wrapper for void* pointer.
static OpaquePtr make(PtrTy P)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
SmallVectorImpl< UniqueVirtualMethod >::iterator overriding_iterator
MapType::iterator iterator
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
unsigned getNumExprs() const
Return the number of expressions in this paren list.
void setRParenLoc(SourceLocation Loc)
TypeLoc getInnerLoc() const
void setLParenLoc(SourceLocation Loc)
Sugar for parentheses used when specifying types.
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
ObjCDeclQualifier getObjCDeclQualifier() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
QualType getOriginalType() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
ParsedAttr - Represents a syntactic attribute.
static const ParsedAttributesView & none()
bool hasAttribute(ParsedAttr::Kind K) const
ParsedAttributes - A collection of parsed attributes.
AttributePool & getPool() const
unsigned getDiagID() const
TypeLoc getPointeeLoc() const
Wrapper for source info for pointers.
void setStarLoc(SourceLocation Loc)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
bool isIncrementalProcessingEnabled() const
Returns true if incremental processing is enabled.
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
HeaderSearch & getHeaderSearchInfo() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
PrimitiveDefaultInitializeKind
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
QualType withoutLocalFastQualifiers() const
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
bool isObjCGCStrong() const
true when Type is objc's strong.
bool isConstQualified() const
Determine whether this type is const-qualified.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
@ PCK_Trivial
The type does not fall into any of the following categories.
@ PCK_VolatileTrivial
The type would be trivial except that it is volatile-qualified.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
ObjCLifetime getObjCLifetime() const
Represents a struct/union/class.
bool hasObjectMember() const
field_range fields() const
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
virtual void completeDefinition()
Note that the definition of this type is now complete.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
void setMemberSpecialization()
Note that this member template is a specialization.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
redecl_iterator redecls_end() const
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
void setNRVOCandidate(const VarDecl *Var)
Set the variable that might be used for the named return value optimization.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
bool isCompoundStmtScope() const
Determine whether this scope is a compound statement scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
@ DeclScope
This is a scope that can contain a declaration.
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
void checkAllowedInitializer(VarDecl *VD)
std::string getConfigureFuncName() const
Returns the name of the launch configuration function.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
void maybeAddHostDeviceAttrs(FunctionDecl *FD, const LookupResult &Previous)
May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD, depending on FD and the current co...
void checkTargetOverload(FunctionDecl *NewFD, const LookupResult &Previous)
Check whether NewFD is a valid overload for CUDA.
void MaybeAddConstantAttr(VarDecl *VD)
May add implicit CUDAConstantAttr attribute to VD, depending on VD and current compilation settings.
void CheckEntryPoint(FunctionDecl *FD)
HLSLNumThreadsAttr * mergeNumThreadsAttr(Decl *D, const AttributeCommonInfo &AL, int X, int Y, int Z)
void ActOnTopLevelFunction(FunctionDecl *FD)
HLSLShaderAttr * mergeShaderAttr(Decl *D, const AttributeCommonInfo &AL, llvm::Triple::EnvironmentType ShaderType)
HLSLWaveSizeAttr * mergeWaveSizeAttr(Decl *D, const AttributeCommonInfo &AL, int Min, int Max, int Preferred, int SpelledArgsCount)
void ActOnVariableDeclarator(VarDecl *VD)
void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID)
DiagnoseDuplicateIvars - Check for duplicate ivars in the entire class at the start of @implementatio...
void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden)
Check whether the given new method is a valid override of the given overridden method,...
DeclResult LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S, IdentifierInfo *II)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method.
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle.
ExprResult BuildIvarRefExpr(Scope *S, SourceLocation Loc, ObjCIvarDecl *IV)
void AddCFAuditedAttribute(Decl *D)
AddCFAuditedAttribute - Check whether we're currently within '#pragma clang arc_cf_code_audited' and,...
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
void ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(Decl *D)
Act on D, a function definition inside of an omp [begin/end] assumes.
void ActOnFinishedFunctionDefinitionInOpenMPDeclareVariantScope(Decl *D, SmallVectorImpl< FunctionDecl * > &Bases)
Register D as specialization of all base functions in Bases in the current omp begin/end declare vari...
void ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, SmallVectorImpl< FunctionDecl * > &Bases)
The declarator D defines a function in the scope S which is nested in an omp begin/end declare varian...
void ActOnOpenMPDeclareTargetInitializer(Decl *D)
Adds OMPDeclareTargetDeclAttr to referenced variables in declare target directive.
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
void checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D, const llvm::StringMap< bool > &FeatureMap)
SwiftNameAttr * mergeNameAttr(Decl *D, const SwiftNameAttr &SNA, StringRef Name)
WebAssemblyImportNameAttr * mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL)
WebAssemblyImportModuleAttr * mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL)
Mode getAlignMode() const
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
static NameClassification DependentNonType()
static NameClassification VarTemplate(TemplateName Name)
static NameClassification Unknown()
static NameClassification OverloadSet(ExprResult E)
static NameClassification UndeclaredTemplate(TemplateName Name)
static NameClassification FunctionTemplate(TemplateName Name)
static NameClassification NonType(NamedDecl *D)
static NameClassification Concept(TemplateName Name)
static NameClassification UndeclaredNonType()
static NameClassification TypeTemplate(TemplateName Name)
static NameClassification Error()
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Sema - This implements semantic analysis and AST building for C.
StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, ParsedAttributes &Attrs)
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
Attr * getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, bool IsDefinition)
Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a containing class.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
SmallVector< DeclaratorDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
sema::CapturingScopeInfo * getEnclosingLambdaOrBlock() const
Get the innermost lambda or block enclosing the current location, if any.
Scope * getCurScope() const
Retrieve the parser's current scope.
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...
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6....
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S)
Register the given locally-scoped extern "C" declaration so that it can be found later for redeclarat...
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
bool CheckExplicitObjectOverride(CXXMethodDecl *New, const CXXMethodDecl *Old)
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
LookupNameKind
Describes the kind of name lookup to perform.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
@ LookupLocalFriendName
Look up a friend of a local class.
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function.
void ActOnPopScope(SourceLocation Loc, Scope *S)
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
@ NTCUC_DefaultInitializedObject
bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S, bool MergeTypeWithOld, bool NewDeclIsDefn)
MergeFunctionDecl - We just parsed a function 'New' from declarator D which has the same name and sco...
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 diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc, TemplateIdAnnotation *TemplateId, bool IsMemberSpecialization)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID)
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body)
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings={})
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void CheckExplicitObjectMemberFunction(Declarator &D, DeclarationName Name, QualType R, bool IsLambda, DeclContext *DC=nullptr)
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class,...
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
PragmaClangSection PragmaClangRodataSection
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Decl * ActOnParamDeclarator(Scope *S, Declarator &D, SourceLocation ExplicitThisLoc={})
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted.
void ActOnExitFunctionContext()
void inferLifetimeCaptureByAttribute(FunctionDecl *FD)
Add [[clang:::lifetime_capture_by(this)]] to STL container methods.
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
Preprocessor & getPreprocessor() const
void deduceOpenCLAddressSpace(ValueDecl *decl)
PragmaStack< FPOptionsOverride > FpPragmaStack
PragmaStack< StringLiteral * > CodeSegStack
void AddRangeBasedOptnone(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based o...
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member function overrides a virtual...
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
static NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
bool CheckOverridingFunctionAttributes(CXXMethodDecl *New, const CXXMethodDecl *Old)
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic=false)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions,...
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver)
If VD is set but not otherwise used, diagnose, for a parameter or a variable.
@ Delete
deleted-function-body
ExprResult VerifyBitField(SourceLocation FieldLoc, const IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth)
VerifyBitField - verifies that a bit field expression is an ICE and has the correct width,...
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.
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
void CheckThreadLocalForLargeAlignment(VarDecl *VD)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
sema::LambdaScopeInfo * RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator)
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S)
isTagName() - This method is called for error recovery purposes only to determine if the specified na...
bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old)
[module.interface]p6: A redeclaration of an entity X is implicitly exported if X was introduced by an...
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation=false)
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
void LazyProcessLifetimeCaptureByParams(FunctionDecl *FD)
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
DiagnosticsEngine & getDiagnostics() const
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
void * SkippedDefinitionContext
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
void DiagPlaceholderFieldDeclDefinitions(RecordDecl *Record)
Emit diagnostic warnings for placeholder members.
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
PragmaStack< bool > StrictGuardStackCheckStack
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used.
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
ASTContext & getASTContext() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
void CheckCoroutineWrapper(FunctionDecl *FD)
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
Check the redefinition in C++20 Modules.
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
void PopExpressionEvaluationContext()
PragmaStack< StringLiteral * > ConstSegStack
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S)
isMicrosoftMissingTypename - In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal...
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord)
Add gsl::Pointer attribute to std::container::iterator.
bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn)
We've just determined that Old and New both appear to be definitions of the same variable.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
void ProcessPragmaWeak(Scope *S, Decl *D)
bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Decl * BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy)
BuildAnonymousStructOrUnion - Handle the declaration of an anonymous structure or union.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
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...
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
EnumDecl * getStdAlignValT() const
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
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...
void PushFunctionScope()
Enter a new function scope.
ExprResult ActOnNameClassifiedAsNonType(Scope *S, const CXXScopeSpec &SS, NamedDecl *Found, SourceLocation NameLoc, const Token &NextToken)
Act on the result of classifying a name as a specific non-type declaration.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
bool FriendConstraintsDependOnEnclosingTemplate(const FunctionDecl *FD)
FPOptions & getCurFPFeatures()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
sema::LambdaScopeInfo * PushLambdaScope()
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
@ UPPC_EnumeratorValue
The enumerator value.
@ UPPC_Initializer
An initializer.
@ UPPC_FriendDeclaration
A friend declaration.
@ UPPC_DeclarationType
The type of an arbitrary declaration.
@ UPPC_ExplicitSpecialization
Explicit specialization.
@ UPPC_DeclarationQualifier
A declaration qualifier.
@ UPPC_DataMemberType
The type of a data member.
@ UPPC_BitFieldWidth
The size of a bit-field.
const LangOptions & getLangOpts() const
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl, bool SupportedForCompatibility=false)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, 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...
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
void DiagnoseInvalidJumps(Stmt *Body)
SourceLocation CurInitSegLoc
void inferLifetimeBoundAttribute(FunctionDecl *FD)
Add [[clang:::lifetimebound]] attr for std:: functions and methods.
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
bool tryToFixVariablyModifiedVarType(TypeSourceInfo *&TInfo, QualType &T, SourceLocation Loc, unsigned FailedFoldDiagID)
Attempt to fold a variable-sized type to a constant-sized type, returning true if we were successful.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
NamedDecl * findLocallyScopedExternCDecl(DeclarationName Name)
Look for a locally scoped extern "C" declaration by the given name.
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, QualType ObjectType, 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 CheckConstexprFunctionDefinition(const FunctionDecl *FD, CheckConstexprKind Kind)
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
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 ...
void checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D=nullptr)
Check if the type is allowed to be used for the current target.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
const LangOptions & LangOpts
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
CXXRecordDecl * getStdBadAlloc() const
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Ident)
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.
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
PragmaClangSection PragmaClangRelroSection
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
void maybeAddDeclWithEffects(FuncOrBlockDecl *D)
Inline checks from the start of maybeAddDeclWithEffects, to minimize performance impact on code not u...
bool DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD, SourceLocation ReturnLoc, Expr *RetExpr, const AutoType *AT)
Deduce the return type for a function from a returned expression, per C++1y [dcl.spec....
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
void CheckCXXDefaultArguments(FunctionDecl *FD)
Helpers for dealing with blocks and functions.
bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS)
checkUnsafeAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained type.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
void AddImplicitMSFunctionNoBuiltinAttr(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based n...
PragmaStack< AlignPackInfo > AlignPackStack
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used,...
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
PragmaStack< StringLiteral * > BSSSegStack
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
DeclContext * getCurLexicalContext() const
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool UseMemberUsingDeclRules)
Determine whether the given New declaration is an overload of the declarations in Old.
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
bool hasExplicitCallingConv(QualType T)
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, CorrectionCandidateCallback *CCC=nullptr)
Perform name lookup on the given name, classifying it based on the results of name lookup and the fol...
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...
void ExitDeclaratorContext(Scope *S)
void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI)
Diagnose shadowing for variables shadowed in the lambda record LambdaRD when these variables are capt...
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMemberKind CSM)
Diagnose why the specified class does not have a trivial special member of the given kind.
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, const ParsedAttributesView &Attrs, SourceLocation EqualLoc, Expr *Val)
sema::FunctionScopeInfo * getCurFunction() const
void PushCompoundScope(bool IsStmtExpr)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
bool CheckNontrivialField(FieldDecl *FD)
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
ExprResult DefaultLvalueConversion(Expr *E)
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI, bool BestCase, MSInheritanceModel Model)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
bool CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD)
AddOverriddenMethods - See if a method overrides any in the base classes, and if so,...
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
void DiagPlaceholderVariableDefinition(SourceLocation Loc)
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams, SourceLocation EllipsisLoc)
Handle a friend type declaration.
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD, QualType NewT, QualType OldT)
Determines if we can perform a correct type check for D as a redeclaration of PrevDecl.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
@ NTK_TemplateTemplateArgument
SourceManager & getSourceManager() const
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_bits attribute.
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible.
void diagnoseFunctionEffectMergeConflicts(const FunctionEffectSet::Conflicts &Errs, SourceLocation NewLoc, SourceLocation OldLoc)
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
bool areMultiversionVariantFunctionsCompatible(const FunctionDecl *OldFD, const FunctionDecl *NewFD, const PartialDiagnostic &NoProtoDiagID, const PartialDiagnosticAt &NoteCausedDiagIDAt, const PartialDiagnosticAt &NoSupportDiagIDAt, const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported, bool ConstexprSupported, bool CLinkageMayDiffer)
Checks if the variant/multiversion functions are compatible.
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e....
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
PragmaClangSection PragmaClangTextSection
PragmaClangSection PragmaClangDataSection
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true)
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
bool IsAtLeastAsConstrained(NamedDecl *D1, MutableArrayRef< const Expr * > AC1, NamedDecl *D2, MutableArrayRef< const Expr * > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaRedefineExtname - Called on well formed #pragma redefine_extname oldname newname.
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
MaybeODRUseExprSet MaybeODRUseExprs
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
CheckParmsForFunctionDef - Check that the parameters of the given function are appropriate for the de...
TopLevelStmtDecl * ActOnStartTopLevelStmtDecl(Scope *S)
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc, ImplicitTypenameContext IsImplicitTypename=ImplicitTypenameContext::No)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
void CheckCompleteVariableDeclaration(VarDecl *VD)
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
void setFunctionHasBranchProtectedScope()
RedeclarationKind forRedeclarationInCurContext() const
void MergeVarDecl(VarDecl *New, LookupResult &Previous)
MergeVarDecl - We just parsed a variable 'New' which has the same name and scope as a previous declar...
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
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...
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
@ CCEK_Enumerator
Enumerator value with fixed underlying type.
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
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, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID=diag::err_init_element_not_constant)
type checking declaration initializers (C99 6.7.8)
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
SmallVector< ExprWithCleanups::CleanupObject, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
@ FirstDecl
Parsing the first decl in a TU.
void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc)
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
@ AMK_None
Don't merge availability attributes at all.
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, const ParsedAttributesView &DeclAttrs, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e....
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD)
Only called on function definitions; if there is a MSVC #pragma optimize in scope,...
bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl)
Checks if the new declaration declared in dependent context must be put in the same redeclaration cha...
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
void DiscardCleanupsInEvaluationContext()
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location.
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc, StringLiteral *Message=nullptr)
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure.
static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD)
DiagnosticsEngine & Diags
OpenCLOptions & getOpenCLOptions()
static bool CanBeGetReturnObject(const FunctionDecl *FD)
NamespaceDecl * getStdNamespace() const
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
PragmaStack< StringLiteral * > DataSegStack
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
@ TPC_FriendFunctionTemplate
@ TPC_ClassTemplateMember
@ TPC_FriendFunctionTemplateDefinition
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name,...
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
void DiagnoseUnusedDecl(const NamedDecl *ND)
void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init)
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
QualType SubstAutoTypeDependent(QualType TypeWithAuto)
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.
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it,...
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
void ActOnUninitializedDecl(Decl *dcl)
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec.
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...
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, IdentifierInfo *IIEnvironment)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void ActOnCXXForRangeDecl(Decl *D)
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
PragmaClangSection PragmaClangBSSSection
Decl * ActOnDeclarator(Scope *S, Declarator &D)
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
void CheckAlignasUnderalignment(Decl *D)
bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old)
A wrapper function for checking the semantic restrictions of a redeclaration within a module.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
ExprResult ActOnNameClassifiedAsDependentNonType(const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, bool IsAddressOfOperand)
Act on the result of classifying a name as an undeclared member of a dependent base class.
void adjustMemberFunctionCC(QualType &T, bool HasThisPointer, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly.
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
void CheckVariableDeclarationType(VarDecl *NewVD)
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New)
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
llvm::SmallPtrSet< const NamedDecl *, 4 > TypoCorrectedFunctionDefinitions
The function definitions which were renamed as part of typo-correction to match their respective decl...
void AddSectionMSAllocText(FunctionDecl *FD)
Only called on function definitions; if there is a #pragma alloc_text that decides which code section...
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 checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
IdentifierResolver IdResolver
bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, bool AllowMask) const
IsValueInFlagEnum - Determine if a value is allowed as part of a flag enum.
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
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...
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where 'self' is implicitly retained inside a block.
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
void warnOnReservedIdentifier(const NamedDecl *D)
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
void inferNullableClassAttribute(CXXRecordDecl *CRD)
Add _Nullable attributes for std:: types.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, 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...
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
OptionalFileEntryRef getFileEntryRefForID(FileID FID) const
Returns the FileEntryRef for the provided FileID.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
SourceLocation getIncludeLoc(FileID FID) const
Returns the include location if FID is a #include'd file otherwise it returns an invalid location.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
SourceLocation getStrTokenLoc(unsigned TokNum) const
Get one of the string literal token.
StringRef getString() const
Represents the declaration of a struct/union/class/enum.
static TagDecl * castFromDeclContext(const DeclContext *DC)
bool isBeingDefined() const
Return true if this decl is currently being defined.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
SourceLocation getInnerLocStart() const
Return SourceLocation representing start of source range ignoring outer template declarations.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
void startDefinition()
Starts the definition of this tag declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
TagKind getTagKind() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool canKeyFunctionBeInline() const
Can an out-of-line inline function serve as a key function?
Exposes information about the current target.
virtual bool validateCpuIs(StringRef Name) const
unsigned getShortWidth() const
getShortWidth/Align - Return the size of 'signed short' and 'unsigned short' for this target,...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
virtual bool allowDebugInfoForExternalRef() const
Whether target allows debuginfo types for decl only variables/functions.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
bool isTLSSupported() const
Whether the target supports thread-local storage.
unsigned getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
virtual bool validateCpuSupports(StringRef Name) const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
unsigned getCharWidth() const
virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target,...
bool supportsMultiVersioning() const
Identify whether this target supports multiversioning of functions, which requires support for cpu_su...
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getRAngleLoc() const
SourceLocation getTemplateLoc() const
Represents a type template specialization; the template must be a class template, a type alias templa...
static bool anyInstantiationDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args)
Token - This structure provides full information about a lexed token.
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 isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
A declaration that models statements at global scope.
static TopLevelStmtDecl * Create(ASTContext &C, Stmt *Statement)
Represents a declaration of a type.
void setTypeForDecl(const Type *TD)
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
SourceLocation getTemplateKeywordLoc() const
Get the SourceLocation of the template keyword (if any).
SourceLocation getEndLoc() const
Get the end source location.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
static StringRef getTagTypeKindName(TagTypeKind Kind)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
bool isStructureType() const
bool isDecltypeType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isDependentSizedArrayType() const
bool isBlockPointerType() const
bool isBooleanType() const
bool isFunctionReferenceType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isIncompleteArrayType() const
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
bool isDependentAddressSpaceType() const
bool isConstantArrayType() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
bool isVoidPointerType() const
bool isFunctionPointerType() const
bool isPointerType() const
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
bool isScalarType() const
bool isVariableArrayType() const
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isBitIntType() const
bool isOpenCLSpecificType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool isHLSLSpecificType() const
const RecordType * getAsStructureType() const
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
bool containsErrors() const
Whether this type is an error type.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isAtomicType() const
bool isFunctionProtoType() const
bool isObjCIdType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isObjCObjectType() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isPointerOrReferenceType() const
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
const T * getAsAdjusted() const
Member-template getAsAdjusted<specific type>.
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isMemberFunctionPointerType() const
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
bool isFloatingType() const
bool isAnyPointerType() const
TypeClass getTypeClass() const
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
bool isRecordType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isFunctionNoProtoType() const
bool isReserveIDT() const
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
bool isSizelessVectorType() const
Returns true for all scalable vector types.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
QualType getUnderlyingType() const
void setTypeSourceInfo(TypeSourceInfo *newType)
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes,...
TypedefNameDecl * getDecl() const
Simple class containing the result of Sema::CorrectTypo.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
SmallVectorImpl< NamedDecl * >::const_iterator const_decl_iterator
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represents a C++ unqualified-id that has been parsed.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
The iterator over UnresolvedSets.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
void setCXXForRangeDecl(bool FRD)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
TLSKind getTLSKind() const
void setInitStyle(InitializationStyle Style)
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool isCXXCondDecl() const
@ ListInit
Direct list-initialization (C++11)
@ ParenListInit
Parenthesized list-initialization (C++20)
@ CallInit
Call-style initialization (C++98)
void setStorageClass(StorageClass SC)
void setPreviousDeclInSameBlockScope(bool Same)
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
void setInlineSpecified()
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
void setTSCSpec(ThreadStorageClassSpecifier TSC)
bool isInline() const
Whether this variable is (C++1z) inline.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
VarDecl * getInitializingDeclaration()
Get the initializing declaration of this variable, if any.
void setConstexpr(bool IC)
@ TLS_Static
TLS with a known-constant initializer.
@ TLS_Dynamic
TLS with a dynamic initializer.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
@ TentativeDefinition
This declaration is a tentative definition.
@ DeclarationOnly
This declaration is only a declaration.
@ Definition
This declaration is definitely a definition.
void setDescribedVarTemplate(VarTemplateDecl *Template)
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setImplicitlyInline()
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
bool hasDependentAlignment() const
Determines if this variable's alignment is dependent.
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
void demoteThisDefinitionToDeclaration()
This is a definition which should be demoted to a declaration.
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
Declaration of a variable template.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Captures information about a #pragma weak directive.
void disableCheckFallThrough()
Policy getDefaultPolicy()
ValueDecl * getVariable() const
bool isVariableCapture() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
void addVLATypeCapture(SourceLocation Loc, const VariableArrayType *VLAType, QualType CaptureType)
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
SmallVector< Capture, 4 > Captures
Captures - The captures.
ImplicitCaptureStyle ImpCaptureStyle
bool isCXXThisCaptured() const
Determine whether the C++ 'this' is captured.
void addThisCapture(bool isNested, SourceLocation Loc, QualType CaptureType, bool ByCopy)
void addCapture(ValueDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
Retains information about a function, method, or block that is currently being parsed.
bool UsesFPIntrin
Whether this function uses constrained floating point intrinsics.
void addByrefBlockVar(VarDecl *VD)
bool NeedsScopeChecking() const
bool ObjCShouldCallSuper
A flag that is set when parsing a method that must call super's implementation, such as -dealloc,...
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
bool HasPotentialAvailabilityViolations
Whether we make reference to a declaration that could be unavailable.
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
TemplateParameterList * GLTemplateParameterList
If this is a generic lambda, and the template parameter list has been created (from the TemplateParam...
ParmVarDecl * ExplicitObjectParameter
llvm::SmallVector< ShadowedOuterDecl, 4 > ShadowingDecls
CXXRecordDecl * Lambda
The class that describes the lambda.
bool AfterParameterList
Indicate that we parsed the parameter list at which point the mutability of the lambda is known.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
bool Mutable
Whether this is a mutable lambda.
Provides information about an attempted template argument deduction, whose success or failure was des...
Defines the clang::TargetInfo interface.
bool evaluateRequiredTargetFeatures(llvm::StringRef RequiredFatures, const llvm::StringMap< bool > &TargetFetureMap)
Returns true if the required target features of a builtin function are enabled.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
bool randomizeStructureLayout(const ASTContext &Context, RecordDecl *RD, llvm::SmallVectorImpl< Decl * > &FinalOrdering)
The JSON file list parser is used to communicate input to InstallAPI.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
TypeSpecifierType
Specifies the kind of type.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
@ GVA_AvailableExternally
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
ConstexprSpecKind
Define the kind of constexpr specifier.
InClassInitStyle
In-class initialization styles for non-static data members.
@ ICIS_NoInit
No in-class initializer.
OverloadCandidateDisplayKind
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ LCK_ByRef
Capturing by reference.
@ LCK_StarThis
Capturing the *this object by copy.
@ IK_DeductionGuideName
A deduction-guide name (a template-name)
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_ConstructorTemplateId
A constructor named via a template-id.
@ IK_ConstructorName
A constructor name.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ IK_ConversionFunctionId
A conversion function name, e.g., operator int.
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.
StorageClass
Storage classes.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
@ TSCS_thread_local
C++11 thread_local.
@ TSCS__Thread_local
C11 _Thread_local.
@ TSCS___thread
GNU __thread.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
TagTypeKind
The kind of a tag type.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
bool isDiscardableGVALinkage(GVALinkage L)
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ CanNeverPassInRegs
The argument of this type cannot be passed directly in registers.
@ TU_Complete
The translation unit is a complete translation unit.
int hasAttribute(AttributeCommonInfo::Syntax 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...
CXXSpecialMemberKind
Kinds of C++ special members.
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
TemplateDeductionResult
Describes the result of template argument deduction.
@ Success
Template argument deduction was successful.
@ AlreadyDiagnosed
Some error which was already diagnosed.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ None
The alignment was not explicit in code.
@ None
No keyword precedes the qualified type name.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)
Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
MutableArrayRef< Expr * > MultiExprArg
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword).
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword).
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
const IdentifierInfo * Ident
One instance of this struct is used for each type in a declarator that is parsed.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
enum clang::DeclaratorChunk::@222 Kind
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
MemberPointerTypeInfo Mem
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
RetTy visit(QualType FT, Ts &&... Args)
EvalResult is a struct with detailed info about an evaluated expression.
Extra information about a function prototype.
unsigned AArch64SMEAttributes
FunctionEffectsRef FunctionEffects
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &ESI)
Contains information gathered from parsing the contents of TargetAttr.
std::vector< std::string > Features
Describes how types, statements, expressions, and declarations should be printed.
SourceLocation PragmaLocation
Information about a template-id annotation token.
unsigned NumArgs
NumArgs - The number of template arguments.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword.