61#include "llvm/ADT/STLForwardCompat.h"
62#include "llvm/ADT/SmallPtrSet.h"
63#include "llvm/ADT/SmallString.h"
64#include "llvm/ADT/StringExtras.h"
65#include "llvm/Support/SaveAndRestore.h"
66#include "llvm/TargetParser/Triple.h"
70#include <unordered_map>
77 Decl *Group[2] = { OwnedType, Ptr };
88 TypeNameValidatorCCC(
bool AllowInvalid,
bool WantClass =
false,
89 bool AllowTemplates =
false,
90 bool AllowNonTemplates =
true)
91 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
92 AllowTemplates(AllowTemplates), AllowNonTemplates(AllowNonTemplates) {
93 WantExpressionKeywords =
false;
94 WantCXXNamedCasts =
false;
95 WantRemainingKeywords =
false;
100 if (!AllowInvalidDecl && ND->isInvalidDecl())
104 return AllowTemplates;
106 bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
110 if (AllowNonTemplates)
115 if (AllowTemplates) {
116 auto *RD = dyn_cast<CXXRecordDecl>(ND);
117 if (!RD || !RD->isInjectedClassName())
119 RD = cast<CXXRecordDecl>(RD->getDeclContext());
120 return RD->getDescribedClassTemplate() ||
121 isa<ClassTemplateSpecializationDecl>(RD);
127 return !WantClassName && candidate.
isKeyword();
130 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
131 return std::make_unique<TypeNameValidatorCCC>(*
this);
135 bool AllowInvalidDecl;
138 bool AllowNonTemplates;
145 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
146 auto *FoundRD = dyn_cast<CXXRecordDecl>(TD);
148 FoundRD->isInjectedClassName() &&
152 ? diag::ext_out_of_line_qualified_id_type_names_constructor
153 : diag::err_out_of_line_qualified_id_type_names_constructor)
163enum class UnqualifiedTypeNameLookupResult {
174static UnqualifiedTypeNameLookupResult
179 return UnqualifiedTypeNameLookupResult::NotFound;
181 UnqualifiedTypeNameLookupResult FoundTypeDecl =
182 UnqualifiedTypeNameLookupResult::NotFound;
186 }
else if (
auto *TST = dyn_cast<TemplateSpecializationType>(
187 Base.getType().getCanonicalType())) {
190 if (!TST->isDependentType())
192 auto *TD = TST->getTemplateName().getAsTemplateDecl();
195 if (
auto *BasePrimaryTemplate =
196 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
198 BaseRD = BasePrimaryTemplate;
199 else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
201 CTD->findPartialSpecialization(
Base.getType()))
209 if (!isa<TypeDecl>(ND))
210 return UnqualifiedTypeNameLookupResult::FoundNonType;
211 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
213 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
215 case UnqualifiedTypeNameLookupResult::FoundNonType:
216 return UnqualifiedTypeNameLookupResult::FoundNonType;
217 case UnqualifiedTypeNameLookupResult::FoundType:
218 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
220 case UnqualifiedTypeNameLookupResult::NotFound:
227 return FoundTypeDecl;
235 UnqualifiedTypeNameLookupResult FoundTypeDecl =
236 UnqualifiedTypeNameLookupResult::NotFound;
238 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
242 RD = dyn_cast<CXXRecordDecl>(DC);
246 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
252 S.
Diag(NameLoc, diag::ext_found_in_dependent_base) << &II;
272 bool HasTrailingDot,
ParsedType ObjectTypePtr,
273 bool IsCtorOrDtorName,
274 bool WantNontrivialTypeSourceInfo,
275 bool IsClassTemplateDeductionContext,
278 bool IsImplicitTypename = !isClassName && !IsCtorOrDtorName;
280 bool AllowDeducedTemplate = IsClassTemplateDeductionContext &&
306 if (IsImplicitTypename) {
311 auto DB =
DiagCompat(QualifiedLoc, diag_compat::implicit_typename)
320 if (WantNontrivialTypeSourceInfo)
356 if (ObjectTypePtr &&
Result.empty()) {
380 switch (
Result.getResultKind()) {
383 TypeNameValidatorCCC CCC(
true, isClassName,
384 AllowDeducedTemplate);
390 bool MemberOfUnknownSpecialization;
399 if (Correction && (NNS || NewII != &II) &&
405 Template, MemberOfUnknownSpecialization))) {
407 isClassName, HasTrailingDot, ObjectTypePtr,
409 WantNontrivialTypeSourceInfo,
410 IsClassTemplateDeductionContext);
413 PDiag(diag::err_unknown_type_or_class_name_suggest)
414 <<
Result.getLookupName() << isClassName);
417 *CorrectedII = NewII;
422 Result.suppressDiagnostics();
438 Result.suppressDiagnostics();
448 Result.suppressDiagnostics();
454 Res != ResEnd; ++Res) {
456 if (isa<TypeDecl, ObjCInterfaceDecl, UnresolvedUsingIfExistsDecl>(
463 FoundUsingShadow = dyn_cast<UsingShadowDecl>(*Res);
475 Result.suppressDiagnostics();
486 IIDecl =
Result.getFoundDecl();
487 FoundUsingShadow = dyn_cast<UsingShadowDecl>(*
Result.begin());
491 assert(IIDecl &&
"Didn't find decl");
494 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
500 if (FoundUsingShadow) {
504 if (!WantNontrivialTypeSourceInfo)
510 }
else if (
auto *Tag = dyn_cast<TagDecl>(TD)) {
514 if (!WantNontrivialTypeSourceInfo)
520 TL.setNameLoc(NameLoc);
521 }
else if (
auto *TN = dyn_cast<TypedefNameDecl>(TD);
522 TN && !isa<ObjCTypeParamDecl>(TN)) {
525 if (!WantNontrivialTypeSourceInfo)
531 }
else if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD)) {
535 if (!WantNontrivialTypeSourceInfo)
543 if (!WantNontrivialTypeSourceInfo)
545 if (isa<ObjCTypeParamType>(
T))
554 if (!HasTrailingDot) {
557 if (!WantNontrivialTypeSourceInfo)
562 TL.setNameEndLoc(NameLoc);
565 }
else if (
auto *UD = dyn_cast<UnresolvedUsingIfExistsDecl>(IIDecl)) {
569 }
else if (AllowDeducedTemplate) {
571 assert(!FoundUsingShadow || FoundUsingShadow->
getTargetDecl() == TD);
580 TL.setNameLoc(NameLoc);
588 Result.suppressDiagnostics();
597 auto *ND = dyn_cast<NamespaceDecl>(DC);
598 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
600 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
602 if (isa<TranslationUnitDecl>(DC))
605 llvm_unreachable(
"something isn't in TU scope?");
616 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
617 if (MD->getParent()->hasAnyDependentBases())
625 bool IsTemplateTypeArg) {
626 assert(
getLangOpts().MSVCCompat &&
"shouldn't be called in non-MSVC mode");
629 if (IsTemplateTypeArg &&
getCurScope()->isTemplateParamScope()) {
638 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
647 Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
678 switch (TD->getTagKind()) {
710 return S->isFunctionPrototypeScope();
719 bool IsTemplateName) {
724 SuggestedType =
nullptr;
728 TypeNameValidatorCCC CCC(
false,
false,
735 bool CanRecover = !IsTemplateName;
736 if (Corrected.isKeyword()) {
739 PDiag(IsTemplateName ? diag::err_no_template_suggest
740 : diag::err_unknown_typename_suggest)
742 II = Corrected.getCorrectionAsIdentifierInfo();
745 if (!SS || !SS->
isSet()) {
747 PDiag(IsTemplateName ? diag::err_no_template_suggest
748 : diag::err_unknown_typename_suggest)
751 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
752 bool DroppedSpecifier =
753 Corrected.WillReplaceSpecifier() && II->
getName() == CorrectedStr;
756 ? diag::err_no_member_template_suggest
757 : diag::err_unknown_nested_typename_suggest)
758 << II << DC << DroppedSpecifier << SS->
getRange(),
761 llvm_unreachable(
"could not have corrected a typo here");
768 if (Corrected.getCorrectionSpecifier())
773 getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc, S,
774 tmpSS.
isSet() ? &tmpSS : SS,
false,
false,
nullptr,
784 Name.setIdentifier(II, IILoc);
787 bool MemberOfUnknownSpecialization;
789 Name,
nullptr,
true, TemplateResult,
800 Diag(IILoc, IsTemplateName ? diag::err_no_template
801 : diag::err_unknown_typename)
804 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
805 : diag::err_typename_nested_not_found)
811 unsigned DiagID = diag::err_typename_missing;
813 DiagID = diag::ext_typename_missing;
824 "Invalid scope specifier has already been diagnosed");
832 NextToken.
is(tok::less);
835 if (isa<TypeDecl>(*I) || isa<ObjCInterfaceDecl>(*I))
838 if (CheckTemplate && isa<TemplateDecl>(*I))
852 StringRef FixItTagName;
853 switch (Tag->getTagKind()) {
855 FixItTagName =
"class ";
859 FixItTagName =
"enum ";
863 FixItTagName =
"struct ";
867 FixItTagName =
"__interface ";
871 FixItTagName =
"union ";
875 StringRef TagName = FixItTagName.drop_back();
876 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
877 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
882 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
897 const Token &NextToken,
902 assert(NextToken.
isNot(tok::coloncolon) &&
903 "parse nested name specifiers before calling ClassifyName");
944 bool SecondTry =
false;
945 bool IsFilteredTemplateName =
false;
948 switch (
Result.getResultKind()) {
952 if (SS.
isEmpty() && NextToken.
is(tok::l_paren)) {
998 if (!SecondTry && CCC) {
1003 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
1004 unsigned QualifiedDiag = diag::err_no_member_suggest;
1007 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
1009 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
1010 UnqualifiedDiag = diag::err_no_template_suggest;
1011 QualifiedDiag = diag::err_no_member_template_suggest;
1012 }
else if (UnderlyingFirstDecl &&
1013 (isa<TypeDecl>(UnderlyingFirstDecl) ||
1014 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
1015 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
1016 UnqualifiedDiag = diag::err_unknown_typename_suggest;
1017 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
1023 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
1024 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
1025 Name->getName() == CorrectedStr;
1028 << DroppedSpecifier << SS.
getRange());
1032 Name = Corrected.getCorrectionAsIdentifierInfo();
1035 if (Corrected.isKeyword())
1041 Result.setLookupName(Corrected.getCorrection());
1063 Result.suppressDiagnostics();
1105 if (!
Result.isAmbiguous()) {
1106 IsFilteredTemplateName =
true;
1116 (IsFilteredTemplateName ||
1132 if (!IsFilteredTemplateName)
1135 bool IsFunctionTemplate;
1139 IsFunctionTemplate =
true;
1142 }
else if (!
Result.empty()) {
1146 IsFunctionTemplate = isa<FunctionTemplateDecl>(TD);
1147 IsVarTemplate = isa<VarTemplateDecl>(TD);
1150 dyn_cast<UsingShadowDecl>(*
Result.begin());
1151 assert(!FoundUsingShadow ||
1152 TD == cast<TemplateDecl>(FoundUsingShadow->
getTargetDecl()));
1160 IsFunctionTemplate =
true;
1164 if (IsFunctionTemplate) {
1168 Result.suppressDiagnostics();
1180 if (
const auto *USD = dyn_cast<UsingShadowDecl>(
Found)) {
1188 if (isa<TagType>(
T)) {
1192 TTL.setNameLoc(NameLoc);
1193 }
else if (isa<TypedefType>(
T)) {
1197 }
else if (isa<UnresolvedUsingType>(
T)) {
1219 dyn_cast<ObjCCompatibleAliasDecl>(
FirstDecl))
1220 Class = Alias->getClassInterface();
1226 if (NextToken.
is(tok::period)) {
1229 Result.suppressDiagnostics();
1239 if (
auto *USD = dyn_cast<UsingShadowDecl>(
Result.getRepresentativeDecl()))
1245 if (
auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(
FirstDecl)) {
1258 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1259 if ((NextToken.
is(tok::identifier) ||
1261 FirstDecl->getUnderlyingDecl()->isFunctionOrFunctionTemplate())) &&
1273 if (
Result.isSingleResult() && !ADL &&
1278 Result.suppressDiagnostics();
1298 bool IsAddressOfOperand) {
1301 NameInfo, IsAddressOfOperand,
1308 const Token &NextToken) {
1310 if (
auto *Ivar = dyn_cast<ObjCIvarDecl>(
Found->getUnderlyingDecl()))
1325 auto *ULE = cast<UnresolvedLookupExpr>(
E);
1326 if ((*ULE->decls_begin())->isCXXClassMember()) {
1328 SS.
Adopt(ULE->getQualifierLoc());
1333 Result.setNamingClass(ULE->getNamingClass());
1334 for (
auto I = ULE->decls_begin(),
E = ULE->decls_end(); I !=
E; ++I)
1335 Result.addDecl(*I, I.getAccess());
1348 auto *TD = Name.getAsTemplateDecl();
1351 if (isa<ClassTemplateDecl>(TD))
1353 if (isa<FunctionTemplateDecl>(TD))
1355 if (isa<VarTemplateDecl>(TD))
1357 if (isa<TypeAliasTemplateDecl>(TD))
1359 if (isa<TemplateTemplateParmDecl>(TD))
1361 if (isa<ConceptDecl>(TD))
1368 "The next DeclContext should be lexically contained in the current one.");
1374 assert(
CurContext &&
"DeclContext imbalance!");
1377 assert(
CurContext &&
"Popped translation unit!");
1387 assert(
CurContext &&
"skipping definition of undefined tag");
1415 assert(!S->getEntity() &&
"scope already has entity");
1418 Scope *Ancestor = S->getParent();
1426 if (S->getParent()->isTemplateParamScope()) {
1434 assert(S->getEntity() ==
CurContext &&
"Context imbalance!");
1438 Scope *Ancestor = S->getParent();
1447 assert(S->isTemplateParamScope() &&
1448 "expected to be initializing a template parameter scope");
1472 for (; S && S->isTemplateParamScope(); S = S->getParent(), --ScopeDepth) {
1476 cast<Decl>(DC)->getDescribedTemplateParams()) {
1477 unsigned DCDepth = TPL->getDepth() + 1;
1478 if (DCDepth > ScopeDepth)
1480 if (ScopeDepth == DCDepth)
1485 S->setLookupEntity(SearchDCAfterScope);
1499 "The next DeclContext should be lexically contained in the current one.");
1503 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1516 assert(
CurContext &&
"DeclContext imbalance!");
1518 assert(
CurContext &&
"Popped translation unit!");
1532 if (Context.
getLangOpts().CPlusPlus ||
New->hasAttr<OverloadableAttr>())
1547 return ND->
hasAttr<OverloadableAttr>();
1550 return Previous.getFoundDecl()->hasAttr<OverloadableAttr>();
1559 while (S->getEntity() && S->getEntity()->isTransparentContext())
1574 if (isa<FunctionDecl>(
D) &&
1575 cast<FunctionDecl>(
D)->isFunctionTemplateSpecialization())
1578 if (isa<UsingEnumDecl>(
D) &&
D->getDeclName().isEmpty()) {
1585 for (; I != IEnd; ++I) {
1586 if (S->isDeclScope(*I) &&
D->declarationReplaces(*I)) {
1597 if (isa<LabelDecl>(
D) && !cast<LabelDecl>(
D)->isGnuLocal()) {
1604 if (!S->isDeclScope(*I))
1618 bool AllowInlineNamespace)
const {
1626 if (ScopeDC->getPrimaryContext() == TargetDC)
1628 }
while ((S = S->getParent()));
1638 bool ConsiderLinkage,
1639 bool AllowInlineNamespace) {
1664 if (
New->getFriendObjectKind() &&
1697 if (NewIsModuleInterface || OldIsModuleInterface) {
1701 Diag(
New->getLocation(), diag::err_mismatched_owning_module)
1703 << NewIsModuleInterface
1705 << OldIsModuleInterface
1708 New->setInvalidDecl();
1721 if (!
New->getLexicalDeclContext()
1722 ->getNonTransparentContext()
1723 ->isFileContext() ||
1729 bool IsNewExported =
New->isInExportDeclContext();
1733 if (!IsNewExported && !IsOldExported)
1745 New->getOwningModule()->isImplicitGlobalModule())
1748 assert(IsNewExported);
1756 Diag(
New->getLocation(), diag::err_redeclaration_non_exported) <<
New << S;
1774 "New and Old are not the same definition, we should diagnostic it "
1775 "immediately instead of checking it.");
1778 "We shouldn't see unreachable definitions here.");
1826 return OldM == NewM;
1833 return isa<UsingShadowDecl>(
D) ||
1834 isa<UnresolvedUsingTypenameDecl>(
D) ||
1835 isa<UnresolvedUsingValueDecl>(
D);
1859 if (
D->doesThisDeclarationHaveABody())
1863 return CD->isCopyConstructor();
1864 return D->isCopyAssignmentOperator();
1870 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1871 if (!RD->hasNameForLinkage())
1877 return !
D->isExternallyVisible();
1906 FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
1909 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1914 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1918 if (FD->doesThisDeclarationHaveABody() &&
1921 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(
D)) {
1931 if (VD->isStaticDataMember() &&
1934 if (VD->isStaticDataMember() &&
1936 VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
1939 if (VD->isInline() && !
isMainFileLoc(*
this, VD->getLocation()))
1948 return mightHaveNonExternalLinkage(
D);
1961 if (
const VarDecl *VD = dyn_cast<VarDecl>(
D)) {
1976 if (
const auto *DD = dyn_cast<DecompositionDecl>(
D)) {
1980 bool IsAllIgnored =
true;
1981 for (
const auto *BD : DD->bindings()) {
1982 if (BD->isReferenced())
1984 IsAllIgnored = IsAllIgnored && (BD->isPlaceholderVar(LangOpts) ||
1985 BD->hasAttr<UnusedAttr>());
1989 }
else if (!
D->getDeclName()) {
1995 if (
D->isPlaceholderVar(LangOpts))
2002 if (isa<LabelDecl>(
D))
2011 WithinFunction || (R->isLocalClass() && !R->isDependentType());
2012 if (!WithinFunction)
2015 if (isa<TypedefNameDecl>(
D))
2019 if (!isa<VarDecl>(
D) || isa<ParmVarDecl>(
D) || isa<ImplicitParamDecl>(
D))
2023 if (
const VarDecl *VD = dyn_cast<VarDecl>(
D)) {
2026 if (
const auto *Cleanups = dyn_cast_if_present<ExprWithCleanups>(
Init))
2027 Init = Cleanups->getSubExpr();
2029 const auto *Ty = VD->getType().getTypePtr();
2034 if (TT->getDecl()->hasAttr<UnusedAttr>())
2040 if (
const auto *MTE = dyn_cast_if_present<MaterializeTemporaryExpr>(
Init);
2041 MTE && MTE->getExtendingDecl()) {
2042 Ty = VD->getType().getNonReferenceType().getTypePtr();
2043 Init = MTE->getSubExpr()->IgnoreImplicitAsWritten();
2048 if (Ty->isIncompleteType() || Ty->isDependentType())
2053 Ty = Ty->getBaseElementTypeUnsafe();
2055 if (
const TagDecl *Tag = Ty->getAsTagDecl()) {
2056 if (Tag->hasAttr<UnusedAttr>())
2059 if (
const auto *RD = dyn_cast<CXXRecordDecl>(Tag)) {
2060 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
2064 const auto *Construct =
2065 dyn_cast<CXXConstructExpr>(
Init->IgnoreImpCasts());
2066 if (Construct && !Construct->isElidable()) {
2068 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
2069 (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
2075 if (
Init->isTypeDependent()) {
2077 if (!Ctor->isTrivial())
2083 if (isa<CXXUnresolvedConstructExpr>(
Init))
2097 if (isa<LabelDecl>(
D)) {
2115 if (
D->isDependentType())
2118 for (
auto *TmpD :
D->decls()) {
2119 if (
const auto *
T = dyn_cast<TypedefNameDecl>(TmpD))
2121 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
2135 if (
auto *TD = dyn_cast<TypedefNameDecl>(
D)) {
2146 if (isa<VarDecl>(
D) && cast<VarDecl>(
D)->isExceptionVariable())
2147 DiagID = diag::warn_unused_exception_param;
2148 else if (isa<LabelDecl>(
D))
2149 DiagID = diag::warn_unused_label;
2151 DiagID = diag::warn_unused_variable;
2170 if (Ty->isReferenceType() || Ty->isDependentType())
2173 if (
const TagDecl *Tag = Ty->getAsTagDecl()) {
2174 if (Tag->hasAttr<UnusedAttr>())
2178 if (
const auto *RD = dyn_cast<CXXRecordDecl>(Tag);
2179 RD && !RD->hasAttr<WarnUnusedAttr>())
2186 if (VD->
hasAttr<BlocksAttr>() && Ty->isObjCObjectPointerType())
2192 if (VD->
hasAttr<ObjCPreciseLifetimeAttr>() && Ty->isObjCObjectPointerType())
2199 assert(iter->getSecond() >= 0 &&
2200 "Found a negative number of references to a VarDecl");
2201 if (
int RefCnt = iter->getSecond(); RefCnt > 0) {
2211 bool UnusedCXXCondDecl = VD->
isCXXCondDecl() && (RefCnt == 1);
2212 if (!UnusedCXXCondDecl)
2216 unsigned DiagID = isa<ParmVarDecl>(VD) ? diag::warn_unused_but_set_parameter
2217 : diag::warn_unused_but_set_variable;
2227 bool Diagnose =
false;
2231 Diagnose = L->
getStmt() ==
nullptr;
2240 if (S->decl_empty())
return;
2242 "Scope shouldn't contain decls!");
2249 std::optional<SourceLocation> PreviousDeclLoc;
2254 DeclDiags.push_back(LocAndDiag{
Loc, std::nullopt, std::move(PD)});
2259 DeclDiags.push_back(LocAndDiag{
Loc, PreviousDeclLoc, std::move(PD)});
2262 for (
auto *TmpD : S->decls()) {
2263 assert(TmpD &&
"This decl didn't get pushed??");
2265 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
2269 if (!S->hasUnrecoverableErrorOccurred()) {
2271 if (
const auto *RD = dyn_cast<RecordDecl>(
D))
2273 if (
VarDecl *VD = dyn_cast<VarDecl>(
D)) {
2279 if (!
D->getDeclName())
continue;
2293 auto ShadowI = ShadowingDecls.find(
D);
2294 if (ShadowI != ShadowingDecls.end()) {
2295 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
2297 PDiag(diag::warn_ctor_parm_shadows_field)
2298 <<
D << FD << FD->getParent());
2300 ShadowingDecls.erase(ShadowI);
2304 llvm::sort(DeclDiags,
2305 [](
const LocAndDiag &LHS,
const LocAndDiag &RHS) ->
bool {
2310 return LHS.Loc.getRawEncoding() < RHS.Loc.getRawEncoding();
2312 for (
const LocAndDiag &
D : DeclDiags) {
2314 if (
D.PreviousDeclLoc)
2315 Diag(*
D.PreviousDeclLoc, diag::note_previous_declaration);
2321 (S->getEntity() && S->getEntity()->isTransparentContext()) ||
2339 return "ucontext.h";
2341 llvm_unreachable(
"unhandled error kind");
2352 Parent->addDecl(CLinkageDecl);
2359 "consteval builtins should only be available in C++20 mode");
2368 New->addAttr(BuiltinAttr::CreateImplicit(
Context, ID));
2374 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2377 FT->getParamType(i),
nullptr,
SC_None,
nullptr);
2379 Params.push_back(parm);
2381 New->setParams(Params);
2389 Scope *S,
bool ForRedeclaration,
2396 if (!ForRedeclaration)
2408 Diag(
Loc, diag::warn_implicit_decl_no_jmp_buf)
2415 Diag(
Loc, diag::warn_implicit_decl_requires_sysheader)
2421 if (!ForRedeclaration &&
2425 : diag::ext_implicit_lib_function_decl)
2428 Diag(
Loc, diag::note_include_header_or_declare)
2465 while (Filter.hasNext()) {
2474 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2476 Decl->getUnderlyingType()))
2481 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2482 Decl->getAnonDeclWithTypedefName())
2494 if (
const TypedefNameDecl *OldTypedef = dyn_cast<TypedefNameDecl>(Old))
2495 OldType = OldTypedef->getUnderlyingType();
2502 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2503 Diag(
New->getLocation(), diag::err_redefinition_variably_modified_typedef)
2507 New->setInvalidDecl();
2511 if (OldType != NewType &&
2515 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2516 Diag(
New->getLocation(), diag::err_redefinition_different_typedef)
2517 << Kind << NewType << OldType;
2520 New->setInvalidDecl();
2530 if (
New->isInvalidDecl())
return;
2536 switch (TypeID->getLength()) {
2540 if (!TypeID->isStr(
"id"))
2552 New->setModedTypeSourceInfo(
New->getTypeSourceInfo(),
2557 if (!TypeID->isStr(
"Class"))
2561 New->setModedTypeSourceInfo(
New->getTypeSourceInfo(),
2565 if (!TypeID->isStr(
"SEL"))
2569 New->setModedTypeSourceInfo(
New->getTypeSourceInfo(),
2579 Diag(
New->getLocation(), diag::err_redefinition_different_kind)
2580 <<
New->getDeclName();
2586 return New->setInvalidDecl();
2591 return New->setInvalidDecl();
2593 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2594 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2595 auto *
NewTag =
New->getAnonDeclWithTypedefName();
2598 OldTag->getCanonicalDecl() !=
NewTag->getCanonicalDecl() &&
2602 if (OldTD->isModed())
2603 New->setModedTypeSourceInfo(OldTD->getTypeSourceInfo(),
2604 OldTD->getUnderlyingType());
2606 New->setTypeSourceInfo(OldTD->getTypeSourceInfo());
2659 if (!isa<TypedefNameDecl>(Old))
2662 Diag(
New->getLocation(), diag::err_redefinition)
2663 <<
New->getDeclName();
2665 return New->setInvalidDecl();
2683 Diag(
New->getLocation(), diag::ext_redefinition_of_typedef)
2684 <<
New->getDeclName();
2691 if (
auto *ED = dyn_cast<EnumDecl>(
New); ED && !ED->isScoped()) {
2693 for (
auto *ECD : ED->enumerators()) {
2704 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2705 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2706 for (
const auto *i :
D->
attrs())
2707 if (i->getKind() == A->
getKind()) {
2709 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2714 if (OA && isa<OwnershipAttr>(i))
2715 return OA->getOwnKind() == cast<OwnershipAttr>(i)->getOwnKind();
2723 if (
VarDecl *VD = dyn_cast<VarDecl>(
D))
2724 return VD->isThisDeclarationADefinition();
2725 if (
TagDecl *TD = dyn_cast<TagDecl>(
D))
2726 return TD->isCompleteDefinition() || TD->isBeingDefined();
2737 AlignedAttr *OldAlignasAttr =
nullptr;
2738 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2739 unsigned OldAlign = 0;
2747 if (I->isAlignmentDependent())
2753 unsigned Align = I->getAlignment(S.
Context);
2754 if (Align > OldAlign) {
2756 OldStrictestAlignAttr = I;
2761 AlignedAttr *NewAlignasAttr =
nullptr;
2762 unsigned NewAlign = 0;
2763 for (
auto *I :
New->specific_attrs<AlignedAttr>()) {
2764 if (I->isAlignmentDependent())
2770 unsigned Align = I->getAlignment(S.
Context);
2771 if (Align > NewAlign)
2775 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2783 if (OldAlign == 0 || NewAlign == 0) {
2796 if (OldAlign != NewAlign) {
2797 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2800 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2813 S.
Diag(
New->getLocation(), diag::err_alignas_missing_on_definition)
2815 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2819 bool AnyAdded =
false;
2822 if (OldAlign > NewAlign) {
2823 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2824 Clone->setInherited(
true);
2825 New->addAttr(Clone);
2830 if (OldAlignasAttr && !NewAlignasAttr &&
2831 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2832 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2833 Clone->setInherited(
true);
2834 New->addAttr(Clone);
2841#define WANT_DECL_MERGE_LOGIC
2842#include "clang/Sema/AttrParsedAttrImpl.inc"
2843#undef WANT_DECL_MERGE_LOGIC
2850 if (!DiagnoseMutualExclusions(S,
D,
Attr))
2861 if (
const auto *AA = dyn_cast<AvailabilityAttr>(
Attr))
2863 D, *AA, AA->getPlatform(), AA->
isImplicit(), AA->getIntroduced(),
2864 AA->getDeprecated(), AA->getObsoleted(), AA->getUnavailable(),
2865 AA->getMessage(), AA->getStrict(), AA->getReplacement(), AMK,
2866 AA->getPriority(), AA->getEnvironment());
2867 else if (
const auto *VA = dyn_cast<VisibilityAttr>(
Attr))
2869 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(
Attr))
2871 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(
Attr))
2873 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(
Attr))
2875 else if (
const auto *EA = dyn_cast<ErrorAttr>(
Attr))
2877 else if (
const auto *FA = dyn_cast<FormatAttr>(
Attr))
2880 else if (
const auto *FMA = dyn_cast<FormatMatchesAttr>(
Attr))
2882 D, *FMA, FMA->getType(), FMA->getFormatIdx(), FMA->getFormatString());
2883 else if (
const auto *SA = dyn_cast<SectionAttr>(
Attr))
2885 else if (
const auto *CSA = dyn_cast<CodeSegAttr>(
Attr))
2887 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(
Attr))
2889 IA->getInheritanceModel());
2890 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(
Attr))
2893 else if (S.
getLangOpts().CUDA && isa<FunctionDecl>(
D) &&
2894 (isa<CUDAHostAttr>(
Attr) || isa<CUDADeviceAttr>(
Attr) ||
2895 isa<CUDAGlobalAttr>(
Attr))) {
2899 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(
Attr))
2901 else if (
const auto *SNA = dyn_cast<SwiftNameAttr>(
Attr))
2903 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(
Attr))
2905 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(
Attr))
2907 else if (isa<AlignedAttr>(
Attr))
2911 else if ((isa<DeprecatedAttr>(
Attr) || isa<UnavailableAttr>(
Attr)) &&
2916 else if (
const auto *UA = dyn_cast<UuidAttr>(
Attr))
2917 NewAttr = S.
mergeUuidAttr(
D, *UA, UA->getGuid(), UA->getGuidDecl());
2918 else if (
const auto *IMA = dyn_cast<WebAssemblyImportModuleAttr>(
Attr))
2920 else if (
const auto *INA = dyn_cast<WebAssemblyImportNameAttr>(
Attr))
2922 else if (
const auto *TCBA = dyn_cast<EnforceTCBAttr>(
Attr))
2924 else if (
const auto *TCBLA = dyn_cast<EnforceTCBLeafAttr>(
Attr))
2926 else if (
const auto *BTFA = dyn_cast<BTFDeclTagAttr>(
Attr))
2928 else if (
const auto *NT = dyn_cast<HLSLNumThreadsAttr>(
Attr))
2931 else if (
const auto *WS = dyn_cast<HLSLWaveSizeAttr>(
Attr))
2934 WS->getSpelledArgsCount());
2935 else if (
const auto *CI = dyn_cast<HLSLVkConstantIdAttr>(
Attr))
2937 else if (
const auto *SA = dyn_cast<HLSLShaderAttr>(
Attr))
2939 else if (isa<SuppressAttr>(
Attr))
2942 else if (
const auto *RD = dyn_cast<OpenACCRoutineDeclAttr>(
Attr))
2950 if (isa<MSInheritanceAttr>(NewAttr))
2959 if (
const TagDecl *TD = dyn_cast<TagDecl>(
D)) {
2960 if (
const auto *Def = TD->getDefinition(); Def && !Def->isBeingDefined())
2964 if (
const VarDecl *VD = dyn_cast<VarDecl>(
D)) {
2972 if (FD->isDefined(Def,
true))
2979 for (
const auto *Attribute :
D->
attrs())
2980 if (Attribute->getKind() == Kind)
2988 if (!
New->hasAttrs())
2992 if (!Def || Def ==
New)
2996 for (
unsigned I = 0,
E = NewAttributes.size(); I !=
E;) {
2997 Attr *NewAttribute = NewAttributes[I];
2999 if (isa<AliasAttr>(NewAttribute) || isa<IFuncAttr>(NewAttribute)) {
3006 NewAttributes.erase(NewAttributes.begin() + I);
3012 unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
3014 ? diag::err_alias_after_tentative
3015 : diag::err_redefinition;
3017 if (
Diag == diag::err_redefinition)
3027 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
3040 if (isa<C11NoReturnAttr>(NewAttribute)) {
3044 }
else if (isa<UuidAttr>(NewAttribute)) {
3048 }
else if (isa<DeprecatedAttr, WarnUnusedResultAttr, UnusedAttr>(
3063 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
3064 if (AA->isAlignas()) {
3075 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
3077 NewAttributes.erase(NewAttributes.begin() + I);
3081 }
else if (isa<LoaderUninitializedAttr>(NewAttribute)) {
3087 diag::err_loader_uninitialized_redeclaration);
3089 NewAttributes.erase(NewAttributes.begin() + I);
3093 }
else if (isa<SelectAnyAttr>(NewAttribute) &&
3094 cast<VarDecl>(
New)->isInline() &&
3095 !cast<VarDecl>(
New)->isInlineSpecified()) {
3102 }
else if (isa<OMPDeclareVariantAttr>(NewAttribute)) {
3107 }
else if (isa<SYCLKernelEntryPointAttr>(NewAttribute)) {
3112 diag::err_sycl_entry_point_after_definition)
3115 cast<SYCLKernelEntryPointAttr>(NewAttribute)->setInvalidAttr();
3118 }
else if (isa<SYCLExternalAttr>(NewAttribute)) {
3125 diag::warn_attribute_precede_definition);
3127 NewAttributes.erase(NewAttributes.begin() + I);
3133 const ConstInitAttr *CIAttr,
3134 bool AttrBeforeInit) {
3141 std::string SuitableSpelling;
3143 SuitableSpelling = std::string(
3145 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
3147 InsertLoc, {tok::l_square, tok::l_square,
3148 S.PP.getIdentifierInfo(
"clang"), tok::coloncolon,
3149 S.PP.getIdentifierInfo(
"require_constant_initialization"),
3150 tok::r_square, tok::r_square}));
3151 if (SuitableSpelling.empty())
3153 InsertLoc, {tok::kw___attribute, tok::l_paren, tok::r_paren,
3154 S.PP.getIdentifierInfo(
"require_constant_initialization"),
3155 tok::r_paren, tok::r_paren}));
3156 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus20)
3157 SuitableSpelling =
"constinit";
3158 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
3159 SuitableSpelling =
"[[clang::require_constant_initialization]]";
3160 if (SuitableSpelling.empty())
3161 SuitableSpelling =
"__attribute__((require_constant_initialization))";
3162 SuitableSpelling +=
" ";
3164 if (AttrBeforeInit) {
3167 assert(CIAttr->isConstinit() &&
"should not diagnose this for attribute");
3170 S.
Diag(CIAttr->getLocation(), diag::note_constinit_specified_here);
3174 S.
Diag(CIAttr->getLocation(),
3175 CIAttr->isConstinit() ? diag::err_constinit_added_too_late
3176 : diag::warn_require_const_init_added_too_late)
3179 << CIAttr->isConstinit()
3187 UsedAttr *NewAttr = OldAttr->clone(
Context);
3188 NewAttr->setInherited(
true);
3189 New->addAttr(NewAttr);
3192 RetainAttr *NewAttr = OldAttr->clone(
Context);
3193 NewAttr->setInherited(
true);
3194 New->addAttr(NewAttr);
3203 const auto *OldConstInit = Old->
getAttr<ConstInitAttr>();
3204 const auto *NewConstInit =
New->getAttr<ConstInitAttr>();
3205 if (
bool(OldConstInit) !=
bool(NewConstInit)) {
3206 const auto *OldVD = cast<VarDecl>(Old);
3207 auto *NewVD = cast<VarDecl>(
New);
3213 (NewVD->hasInit() || NewVD->isThisDeclarationADefinition()))
3216 if (InitDecl == NewVD) {
3220 if (OldConstInit && OldConstInit->isConstinit())
3223 }
else if (NewConstInit) {
3227 if (InitDecl && InitDecl != NewVD) {
3230 NewVD->dropAttr<ConstInitAttr>();
3238 if (AsmLabelAttr *NewA =
New->getAttr<AsmLabelAttr>()) {
3239 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
3240 if (!OldA->isEquivalent(NewA)) {
3242 Diag(
New->getLocation(), diag::err_different_asm_label);
3243 Diag(OldA->getLocation(), diag::note_previous_declaration);
3245 }
else if (Old->
isUsed()) {
3248 Diag(
New->getLocation(), diag::err_late_asm_label_name)
3249 << isa<FunctionDecl>(Old) <<
New->getAttr<AsmLabelAttr>()->
getRange();
3254 if (
const auto *NewAbiTagAttr =
New->getAttr<AbiTagAttr>()) {
3255 if (
const auto *OldAbiTagAttr = Old->
getAttr<AbiTagAttr>()) {
3256 for (
const auto &
NewTag : NewAbiTagAttr->tags()) {
3257 if (!llvm::is_contained(OldAbiTagAttr->tags(),
NewTag)) {
3258 Diag(NewAbiTagAttr->getLocation(),
3259 diag::err_new_abi_tag_on_redeclaration)
3261 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
3265 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
3271 if (
New->hasAttr<SectionAttr>() && !Old->
hasAttr<SectionAttr>()) {
3272 if (
auto *VD = dyn_cast<VarDecl>(
New)) {
3274 Diag(
New->getLocation(), diag::warn_attribute_section_on_redeclaration);
3281 const auto *NewCSA =
New->getAttr<CodeSegAttr>();
3282 if (NewCSA && !Old->
hasAttr<CodeSegAttr>() &&
3283 !NewCSA->isImplicit() && isa<CXXMethodDecl>(
New)) {
3284 Diag(
New->getLocation(), diag::warn_mismatched_section)
3292 bool foundAny =
New->hasAttrs();
3301 if (isa<DeprecatedAttr>(I) ||
3302 isa<UnavailableAttr>(I) ||
3303 isa<AvailabilityAttr>(I)) {
3318 if (isa<UsedAttr>(I) || isa<RetainAttr>(I))
3321 if (isa<InferredNoReturnAttr>(I)) {
3322 if (
auto *FD = dyn_cast<FunctionDecl>(
New);
3335 if (!foundAny)
New->dropAttrs();
3345 T *newAttr = cast<T>(I->clone(S.
Context));
3346 newAttr->setInherited(
true);
3368 foundAny |= std::forward<F>(propagator)(To, From) != 0;
3383 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
3384 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
3385 S.
Diag(CDA->getLocation(),
3386 diag::err_carries_dependency_missing_on_first_decl) << 1;
3394 diag::note_carries_dependency_missing_first_decl) << 1;
3400 found += propagateAttribute<InheritableParamAttr>(To, From, S);
3405 found += propagateAttribute<LifetimeBoundAttr>(To, From, S);
3413 auto NoSizeInfo = [&Ctx](
QualType Ty) {
3414 if (Ty->isIncompleteArrayType() || Ty->isPointerType())
3422 if (NoSizeInfo(Old) && NoSizeInfo(
New))
3454 if (*Oldnullability != *Newnullability) {
3455 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
3472 const auto *OldParamDT = dyn_cast<DecayedType>(OldParam->
getType());
3473 const auto *NewParamDT = dyn_cast<DecayedType>(NewParam->
getType());
3474 if (OldParamDT && NewParamDT &&
3475 OldParamDT->getPointeeType() == NewParamDT->getPointeeType()) {
3476 QualType OldParamOT = OldParamDT->getOriginalType();
3477 QualType NewParamOT = NewParamDT->getOriginalType();
3480 << NewParam << NewParamOT;
3491struct GNUCompatibleParamWarning {
3501template <
typename T>
3502static std::pair<diag::kind, SourceLocation>
3506 if (Old->isThisDeclarationADefinition())
3507 PrevDiag = diag::note_previous_definition;
3508 else if (Old->isImplicit()) {
3509 PrevDiag = diag::note_previous_implicit_declaration;
3510 if (
const auto *FD = dyn_cast<FunctionDecl>(Old)) {
3511 if (FD->getBuiltinID())
3512 PrevDiag = diag::note_previous_builtin_declaration;
3515 OldLocation =
New->getLocation();
3517 PrevDiag = diag::note_previous_declaration;
3518 return std::make_pair(PrevDiag, OldLocation);
3526 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
3527 !LangOpts.CPlusPlus &&
3539template <
typename T>
3560template<
typename ExpectedDecl>
3582 !Old->getDeclContext()->getRedeclContext()->Equals(
3583 New->getDeclContext()->getRedeclContext()) &&
3588 S.
Diag(
New->getLocation(), diag::err_using_decl_conflict_reverse);
3601 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
3602 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
3605 return AttrA && AttrB && AttrA->getType() == AttrB->getType() &&
3606 AttrA->isDynamic() == AttrB->isDynamic();
3632 if (NamedDC->Equals(SemaDC))
3635 assert((NamedDC->InEnclosingNamespaceSetOf(SemaDC) ||
3637 "unexpected context for redeclaration");
3648 if (
auto *FD = dyn_cast<FunctionDecl>(NewD))
3649 FixSemaDC(FD->getDescribedFunctionTemplate());
3650 else if (
auto *VD = dyn_cast<VarDecl>(NewD))
3651 FixSemaDC(VD->getDescribedVarTemplate());
3655 bool MergeTypeWithOld,
bool NewDeclIsDefn) {
3663 Diag(
New->getLocation(), diag::err_using_decl_friend);
3664 Diag(Shadow->getTargetDecl()->getLocation(),
3665 diag::note_using_decl_target);
3666 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl)
3674 New->getDescribedFunctionTemplate()) {
3675 if (checkUsingShadowRedecl<FunctionTemplateDecl>(*
this, Shadow,
3678 OldD = Old = cast<FunctionTemplateDecl>(Shadow->getTargetDecl())
3681 if (checkUsingShadowRedecl<FunctionDecl>(*
this, Shadow,
New))
3683 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
3686 Diag(
New->getLocation(), diag::err_redefinition_different_kind)
3687 <<
New->getDeclName();
3711 std::tie(PrevDiag, OldLocation) =
3718 if (!isa<CXXMethodDecl>(
New) && !isa<CXXMethodDecl>(Old) &&
3721 !
New->getTemplateSpecializationInfo() &&
3724 Diag(
New->getLocation(), diag::ext_static_non_static) <<
New;
3725 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3727 Diag(
New->getLocation(), diag::err_static_non_static) <<
New;
3728 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3733 if (
const auto *ILA =
New->getAttr<InternalLinkageAttr>())
3734 if (!Old->
hasAttr<InternalLinkageAttr>()) {
3735 Diag(
New->getLocation(), diag::err_attribute_missing_on_first_decl)
3738 New->dropAttr<InternalLinkageAttr>();
3741 if (
auto *EA =
New->getAttr<ErrorAttr>()) {
3742 if (!Old->
hasAttr<ErrorAttr>()) {
3743 Diag(EA->getLocation(), diag::err_attribute_missing_on_first_decl) << EA;
3745 New->dropAttr<ErrorAttr>();
3753 bool OldOvl = Old->
hasAttr<OverloadableAttr>();
3754 if (OldOvl !=
New->hasAttr<OverloadableAttr>() && !Old->
isImplicit()) {
3755 Diag(
New->getLocation(), diag::err_attribute_overloadable_mismatch)
3764 const Decl *DiagOld = Old;
3766 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *
D) {
3767 const auto *A = D->getAttr<OverloadableAttr>();
3768 return A && !A->isImplicit();
3772 DiagOld = OldIter == Old->
redecls_end() ? nullptr : *OldIter;
3777 diag::note_attribute_overloadable_prev_overload)
3781 New->addAttr(OverloadableAttr::CreateImplicit(
Context));
3783 New->dropAttr<OverloadableAttr>();
3790 Diag(
New->getLocation(), diag::err_sme_attr_mismatch)
3792 Diag(OldLocation, diag::note_previous_declaration);
3811 const FunctionType *OldType = cast<FunctionType>(OldQType);
3812 const FunctionType *NewType = cast<FunctionType>(NewQType);
3815 bool RequiresAdjustment =
false;
3817 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC()) {
3823 if (!NewCCExplicit) {
3827 RequiresAdjustment =
true;
3835 Diag(
New->getLocation(), diag::warn_cconv_unsupported)
3839 RequiresAdjustment =
true;
3843 Diag(
New->getLocation(), diag::err_cconv_change)
3846 << (!FirstCCExplicit ?
"" :
3850 Diag(
First->getLocation(), diag::note_previous_declaration);
3858 RequiresAdjustment =
true;
3865 Diag(
New->getLocation(), diag::err_regparm_mismatch)
3868 Diag(OldLocation, diag::note_previous_declaration);
3873 RequiresAdjustment =
true;
3879 Diag(
New->getLocation(), diag::err_function_attribute_mismatch)
3880 <<
"'ns_returns_retained'";
3881 Diag(OldLocation, diag::note_previous_declaration);
3886 RequiresAdjustment =
true;
3892 AnyX86NoCallerSavedRegistersAttr *
Attr =
3893 New->getAttr<AnyX86NoCallerSavedRegistersAttr>();
3894 Diag(
New->getLocation(), diag::err_function_attribute_mismatch) <<
Attr;
3895 Diag(OldLocation, diag::note_previous_declaration);
3900 RequiresAdjustment =
true;
3903 if (RequiresAdjustment) {
3912 if (!Old->
isInlined() &&
New->isInlined() && !
New->hasAttr<GNUInlineAttr>() &&
3920 if (
New->hasAttr<GNUInlineAttr>() &&
3929 Diag(
New->getLocation(), diag::err_different_pass_object_size_params)
3930 <<
New->getDeclName();
3931 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3935 QualType OldQTypeForComparison = OldQType;
3938 const auto NewFX =
New->getFunctionEffects();
3939 if (OldFX != NewFX) {
3941 for (
const auto &Diff : Diffs) {
3942 if (Diff.shouldDiagnoseRedeclaration(*Old, OldFX, *
New, NewFX)) {
3944 diag::warn_mismatched_func_effect_redeclaration)
3945 << Diff.effectName();
3956 if (!MergeErrs.empty())
3963 NewFPT->getParamTypes(), EPI);
3965 New->setType(ModQT);
3966 NewQType =
New->getType();
3971 EPI = OldFPT->getExtProtoInfo();
3974 OldFPT->getReturnType(), OldFPT->getParamTypes(), EPI);
3976 if (OldFX.empty()) {
3995 QualType NewDeclaredReturnType =
New->getDeclaredReturnType();
3998 OldDeclaredReturnType)) {
4005 if (
New->isCXXClassMember() &&
New->isOutOfLine())
4006 Diag(
New->getLocation(), diag::err_member_def_does_not_match_ret_type)
4007 <<
New <<
New->getReturnTypeSourceRange();
4009 !Old->
hasAttr<OverloadableAttr>() &&
4010 !
New->hasAttr<OverloadableAttr>())
4011 Diag(
New->getLocation(), diag::err_conflicting_types) <<
New;
4013 Diag(
New->getLocation(), diag::err_ovl_diff_return_type)
4014 <<
New->getReturnTypeSourceRange();
4015 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
4024 QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType();
4025 if (OldReturnType != NewReturnType) {
4041 const CXXMethodDecl *OldMethod = dyn_cast<CXXMethodDecl>(Old);
4043 if (OldMethod && NewMethod) {
4050 bool IsClassScopeExplicitSpecialization =
4056 !IsClassScopeExplicitSpecialization) {
4061 Diag(
New->getLocation(), diag::err_ovl_static_nonstatic_member);
4062 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4072 if (isa<CXXConstructorDecl>(OldMethod))
4073 NewDiag = diag::err_constructor_redeclared;
4074 else if (isa<CXXDestructorDecl>(NewMethod))
4075 NewDiag = diag::err_destructor_redeclared;
4076 else if (isa<CXXConversionDecl>(NewMethod))
4077 NewDiag = diag::err_conv_function_redeclared;
4079 NewDiag = diag::err_member_redeclared;
4081 Diag(
New->getLocation(), NewDiag);
4083 Diag(
New->getLocation(), diag::err_member_redeclared_in_instantiation)
4084 <<
New <<
New->getType();
4086 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4099 diag::err_definition_of_implicitly_declared_member)
4105 diag::err_definition_of_explicitly_defaulted_member)
4128 if (
const auto *NRA =
New->getAttr<CXX11NoReturnAttr>())
4129 if (!Old->
hasAttr<CXX11NoReturnAttr>()) {
4130 Diag(NRA->getLocation(), diag::err_attribute_missing_on_first_decl)
4139 const CarriesDependencyAttr *CDA =
New->getAttr<CarriesDependencyAttr>();
4140 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
4141 Diag(CDA->getLocation(),
4142 diag::err_carries_dependency_missing_on_first_decl) << 0;
4144 diag::note_carries_dependency_missing_first_decl) << 0;
4152 const SYCLExternalAttr *SEA =
New->getAttr<SYCLExternalAttr>();
4153 if (SEA && !Old->
hasAttr<SYCLExternalAttr>()) {
4154 Diag(SEA->getLocation(), diag::warn_sycl_external_missing_on_first_decl)
4169 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
4183 Diag(
New->getLocation(), diag::ext_retained_language_linkage) <<
New;
4184 Diag(OldLocation, PrevDiag);
4186 Diag(
New->getLocation(), diag::err_different_language_linkage) <<
New;
4187 Diag(OldLocation, PrevDiag);
4194 if (
HLSL().CheckCompatibleParameterABI(
New, Old))
4240 if (Old->
hasPrototype() && !
New->hasWrittenPrototype() && NewDeclIsDefn &&
4244 Diag(
New->getLocation(), diag::err_conflicting_types) <<
New;
4262 if (
New->hasWrittenPrototype()) {
4274 bool IsWithoutProtoADef =
false, IsWithProtoADef =
false;
4275 if (WithoutProto ==
New)
4276 IsWithoutProtoADef = NewDeclIsDefn;
4278 IsWithProtoADef = NewDeclIsDefn;
4280 diag::warn_non_prototype_changes_behavior)
4281 << IsWithoutProtoADef << (WithoutProto->
getNumParams() ? 0 : 1)
4282 << (WithoutProto == Old) << IsWithProtoADef;
4292 !IsWithoutProtoADef)
4302 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
4303 (OldProto = dyn_cast<FunctionProtoType>(OldFuncType))) {
4306 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
4308 OldProto->getParamTypes(),
4309 OldProto->getExtProtoInfo());
4310 New->setType(NewQType);
4311 New->setHasInheritedPrototype();
4315 for (
const auto &ParamType : OldProto->param_types()) {
4318 ParamType,
nullptr,
SC_None,
nullptr);
4321 Params.push_back(Param);
4324 New->setParams(Params);
4360 NewProto->getReturnType());
4361 bool LooseCompatible = !MergedReturn.
isNull();
4363 LooseCompatible && Idx != End; ++Idx) {
4367 NewProto->getParamType(Idx))) {
4368 ArgTypes.push_back(NewParm->
getType());
4372 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
4373 NewProto->getParamType(Idx) };
4374 Warnings.push_back(Warn);
4375 ArgTypes.push_back(NewParm->
getType());
4377 LooseCompatible =
false;
4380 if (LooseCompatible) {
4381 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
4382 Diag(Warnings[Warn].NewParm->getLocation(),
4383 diag::ext_param_promoted_not_compatible_with_prototype)
4384 << Warnings[Warn].PromotedType
4385 << Warnings[Warn].OldParm->getType();
4386 if (Warnings[Warn].OldParm->getLocation().isValid())
4387 Diag(Warnings[Warn].OldParm->getLocation(),
4388 diag::note_previous_declaration);
4391 if (MergeTypeWithOld)
4410 Diag(
New->getLocation(), diag::warn_redecl_library_builtin) <<
New;
4411 Diag(OldLocation, diag::note_previous_builtin_declaration)
4416 PrevDiag = diag::note_previous_builtin_declaration;
4419 Diag(
New->getLocation(), diag::err_conflicting_types) <<
New->getDeclName();
4420 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4425 Scope *S,
bool MergeTypeWithOld) {
4431 New->setIsPureVirtual();
4440 for (
unsigned i = 0, e =
New->getNumParams(); i != e; ++i) {
4454 if (!Merged.isNull() && MergeTypeWithOld)
4455 New->setType(Merged);
4479 ni != ne && oi != oe; ++ni, ++oi)
4488 S.
Diag(
New->getLocation(),
New->isThisDeclarationADefinition()
4489 ? diag::err_redefinition_different_type
4490 : diag::err_redeclaration_different_type)
4495 std::tie(PrevDiag, OldLocation)
4497 S.
Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4498 New->setInvalidDecl();
4502 bool MergeTypeWithOld) {
4508 if (
New->getType()->isUndeducedType()) {
4530 QualType PrevVDTy = PrevVD->getType();
4542 MergedT =
New->getType();
4553 else if (
New->getType()->isObjCObjectPointerType() &&
4570 if ((
New->getType()->isDependentType() ||
4575 if (!
New->getType()->isDependentType() && MergeTypeWithOld)
4584 if (MergeTypeWithOld)
4585 New->setType(MergedT);
4619 if (
New->isInvalidDecl())
4632 OldTemplate = dyn_cast<VarTemplateDecl>(
Previous.getFoundDecl());
4636 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4637 if (checkUsingShadowRedecl<VarTemplateDecl>(*
this, Shadow, NewTemplate))
4638 return New->setInvalidDecl();
4640 Old = dyn_cast<VarDecl>(
Previous.getFoundDecl());
4643 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4644 if (checkUsingShadowRedecl<VarDecl>(*
this, Shadow,
New))
4645 return New->setInvalidDecl();
4649 Diag(
New->getLocation(), diag::err_redefinition_different_kind)
4650 <<
New->getDeclName();
4652 New->getLocation());
4653 return New->setInvalidDecl();
4665 return New->setInvalidDecl();
4672 Diag(
New->getLocation(), diag::err_duplicate_member)
4673 <<
New->getIdentifier();
4675 New->setInvalidDecl();
4681 if (
New->hasAttr<WeakImportAttr>())
4684 Diag(
New->getLocation(), diag::warn_weak_import) <<
New->getDeclName();
4687 New->dropAttr<WeakImportAttr>();
4692 if (
const auto *ILA =
New->getAttr<InternalLinkageAttr>())
4693 if (!Old->
hasAttr<InternalLinkageAttr>()) {
4694 Diag(
New->getLocation(), diag::err_attribute_missing_on_first_decl)
4697 New->dropAttr<InternalLinkageAttr>();
4702 if (MostRecent != Old) {
4705 if (
New->isInvalidDecl())
4710 if (
New->isInvalidDecl())
4715 std::tie(PrevDiag, OldLocation) =
4720 !
New->isStaticDataMember() &&
4723 Diag(
New->getLocation(), diag::ext_static_non_static)
4724 <<
New->getDeclName();
4725 Diag(OldLocation, PrevDiag);
4727 Diag(
New->getLocation(), diag::err_static_non_static)
4728 <<
New->getDeclName();
4729 Diag(OldLocation, PrevDiag);
4730 return New->setInvalidDecl();
4744 else if (
New->getCanonicalDecl()->getStorageClass() !=
SC_Static &&
4745 !
New->isStaticDataMember() &&
4747 Diag(
New->getLocation(), diag::err_non_static_static) <<
New->getDeclName();
4748 Diag(OldLocation, PrevDiag);
4749 return New->setInvalidDecl();
4753 if (
New->hasExternalStorage() &&
4755 Diag(
New->getLocation(), diag::err_extern_non_extern) <<
New->getDeclName();
4756 Diag(OldLocation, PrevDiag);
4757 return New->setInvalidDecl();
4760 !
New->hasExternalStorage()) {
4761 Diag(
New->getLocation(), diag::err_non_extern_extern) <<
New->getDeclName();
4762 Diag(OldLocation, PrevDiag);
4763 return New->setInvalidDecl();
4773 if (!
New->hasExternalStorage() && !
New->isFileVarDecl() &&
4776 !
New->getLexicalDeclContext()->isRecord())) {
4777 Diag(
New->getLocation(), diag::err_redefinition) <<
New->getDeclName();
4778 Diag(OldLocation, PrevDiag);
4779 return New->setInvalidDecl();
4787 Diag(
New->getLocation(), diag::err_inline_decl_follows_def) <<
New;
4788 Diag(Def->getLocation(), diag::note_previous_definition);
4802 Diag(
New->getLocation(), diag::err_thread_non_thread) <<
New->getDeclName();
4803 Diag(OldLocation, PrevDiag);
4804 }
else if (!
New->getTLSKind()) {
4805 Diag(
New->getLocation(), diag::err_non_thread_thread) <<
New->getDeclName();
4806 Diag(OldLocation, PrevDiag);
4812 Diag(
New->getLocation(), diag::err_thread_thread_different_kind)
4814 Diag(OldLocation, PrevDiag);
4824 diag::warn_deprecated_redundant_constexpr_static_def);
4837 Diag(
New->getLocation(), diag::warn_cxx_compat_tentative_definition)
4844 Diag(
New->getLocation(), diag::err_different_language_linkage) <<
New;
4845 Diag(OldLocation, PrevDiag);
4846 New->setInvalidDecl();
4855 New->setPreviousDecl(Old);
4865 New->setImplicitlyInline();
4875 StringRef HdrFilename =
4878 auto noteFromModuleOrInclude = [&](
Module *Mod,
4884 if (IncLoc.isValid()) {
4886 Diag(IncLoc, diag::note_redefinition_modules_same_file)
4892 Diag(IncLoc, diag::note_redefinition_include_same_file)
4893 << HdrFilename.str();
4903 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
4911 if (FOld && !HSI.isFileMultipleIncludeGuarded(*FOld))
4926 isa<VarTemplateSpecializationDecl>(
New) ||
4927 New->getDescribedVarTemplate() ||
New->getNumTemplateParameterLists() ||
4928 New->getDeclContext()->isDependentContext() ||
4929 New->hasAttr<SelectAnyAttr>())) {
4932 New->demoteThisDefinitionToDeclaration();
4940 Diag(
New->getLocation(), diag::err_redefinition) <<
New;
4942 New->setInvalidDecl();
4963 ? S->getMSCurManglingNumber()
4964 : S->getMSLastManglingNumber();
4971 if (isa<CXXRecordDecl>(Tag->getParent())) {
4974 if (!Tag->getName().empty() || Tag->getTypedefNameForAnonDecl())
4986 Decl *ManglingContextDecl;
4987 std::tie(MCtx, ManglingContextDecl) =
4997struct NonCLikeKind {
5017 return {NonCLikeKind::Invalid, {}};
5024 return {NonCLikeKind::BaseClass,
5036 if (
auto *FD = dyn_cast<FieldDecl>(
D)) {
5037 if (FD->hasInClassInitializer()) {
5038 auto *
Init = FD->getInClassInitializer();
5039 return {NonCLikeKind::DefaultMemberInit,
5047 if (isa<FriendDecl>(
D))
5052 if (isa<StaticAssertDecl>(
D) || isa<IndirectFieldDecl>(
D) ||
5055 auto *MemberRD = dyn_cast<CXXRecordDecl>(
D);
5063 if (MemberRD->isLambda())
5064 return {NonCLikeKind::Lambda, MemberRD->getSourceRange()};
5068 if (MemberRD->isThisDeclarationADefinition()) {
5074 return {
Invalid ? NonCLikeKind::Invalid : NonCLikeKind::None, {}};
5104 const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(TagFromDeclSpec);
5108 if (NonCLike || ChangesLinkage) {
5109 if (NonCLike.Kind == NonCLikeKind::Invalid)
5112 unsigned DiagID = diag::ext_non_c_like_anon_struct_in_typedef;
5113 if (ChangesLinkage) {
5115 if (NonCLike.Kind == NonCLikeKind::None)
5116 DiagID = diag::err_typedef_changes_linkage;
5118 DiagID = diag::err_non_c_like_anon_struct_in_typedef;
5124 TextToInsert +=
' ';
5127 Diag(FixitLoc, DiagID)
5128 << isa<TypeAliasDecl>(NewTD)
5130 if (NonCLike.Kind != NonCLikeKind::None) {
5131 Diag(NonCLike.Range.getBegin(), diag::note_non_c_like_anon_struct)
5132 << NonCLike.Kind - 1 << NonCLike.Range;
5135 << NewTD << isa<TypeAliasDecl>(NewTD);
5160 if (
const auto *ED = dyn_cast<EnumDecl>(DS.
getRepAsDecl())) {
5161 if (ED->isScopedUsingClassTag())
5168 llvm_unreachable(
"unexpected type specifier");
5176 bool IsExplicitInstantiation,
5179 Decl *TagD =
nullptr;
5194 if (isa<TagDecl>(TagD))
5195 Tag = cast<TagDecl>(TagD);
5197 Tag = CTD->getTemplatedDecl();
5202 Tag->setFreeStanding();
5203 if (Tag->isInvalidDecl())
5212 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
5249 "Friend ellipsis but not friend-specified?");
5252 bool DeclaresAnything =
true;
5256 if (!
Record->getDeclName() &&
Record->isCompleteDefinition() &&
5259 Record->getDeclContext()->isRecord()) {
5273 DeclaresAnything =
false;
5292 if ((Tag && Tag->getDeclName()) ||
5302 DeclaresAnything =
false;
5314 if (
Enum->enumerators().empty() && !
Enum->getIdentifier() &&
5315 !
Enum->isInvalidDecl())
5316 DeclaresAnything =
false;
5324 DeclaresAnything =
false;
5328 Tag && Tag->getDeclContext()->isFunctionOrMethod())
5330 << Tag->getTagKind()
5343 if (!DeclaresAnything) {
5346 Diag(DS.
getBeginLoc(), (IsExplicitInstantiation || !TemplateParams.empty())
5347 ? diag::err_no_declarators
5348 : diag::ext_no_declarators)
5361 unsigned DiagID = diag::warn_standalone_specifier;
5363 DiagID = diag::ext_standalone_specifier;
5404 auto EmitAttributeDiagnostic = [
this, &DS](
const ParsedAttr &AL) {
5405 unsigned DiagnosticId = diag::warn_declspec_attribute_ignored;
5407 DiagnosticId = diag::warn_attribute_ignored;
5408 else if (AL.isRegularKeywordAttribute())
5409 DiagnosticId = diag::err_declspec_keyword_has_no_effect;
5411 DiagnosticId = diag::warn_declspec_attribute_ignored;
5412 Diag(AL.getLoc(), DiagnosticId)
5416 llvm::for_each(DS.
getAttributes(), EmitAttributeDiagnostic);
5417 llvm::for_each(DeclAttrs, EmitAttributeDiagnostic);
5436 RedeclarationKind::ForVisibleRedeclaration);
5441 assert(PrevDecl &&
"Expected a non-null Decl");
5454 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
5456 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
5462 if (
auto *RD = dyn_cast_if_present<RecordDecl>(
D))
5472 if (
Record->isAnonymousStructOrUnion())
5477 const NamedDecl *ND = dyn_cast<NamedDecl>(
D);
5511 for (
auto *
D : AnonRecord->
decls()) {
5512 if ((isa<FieldDecl>(
D) || isa<IndirectFieldDecl>(
D)) &&
5513 cast<NamedDecl>(
D)->getDeclName()) {
5534 unsigned OldChainingSize = Chaining.size();
5536 Chaining.append(IF->chain_begin(), IF->chain_end());
5538 Chaining.push_back(VD);
5540 assert(Chaining.size() >= 2);
5543 for (
unsigned i = 0; i < Chaining.size(); i++)
5544 NamedChain[i] = Chaining[i];
5548 VD->
getType(), {NamedChain, Chaining.size()});
5562 Chaining.resize(OldChainingSize);
5576 "Parser allowed 'typedef' as storage class VarDecl.");
5577 switch (StorageClassSpec) {
5591 llvm_unreachable(
"unknown storage class specifier");
5595 assert(
Record->hasInClassInitializer());
5597 for (
const auto *I :
Record->decls()) {
5598 const auto *FD = dyn_cast<FieldDecl>(I);
5599 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
5600 FD = IFD->getAnonField();
5601 if (FD && FD->hasInClassInitializer())
5602 return FD->getLocation();
5605 llvm_unreachable(
"couldn't find in-class initializer");
5610 if (!
Parent->isUnion() || !
Parent->hasInClassInitializer())
5613 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
5619 if (!
Parent->isUnion() || !
Parent->hasInClassInitializer())
5633 Diag(
Record->getLocation(), diag::ext_anonymous_union);
5635 Diag(
Record->getLocation(), diag::ext_gnu_anonymous_struct);
5637 Diag(
Record->getLocation(), diag::ext_c11_anonymous_struct);
5643 const char *PrevSpec =
nullptr;
5654 !cast<NamespaceDecl>(OwnerScope)->isAnonymousNamespace()))) {
5655 Diag(
Record->getLocation(), diag::err_anonymous_union_not_static)
5660 PrevSpec, DiagID, Policy);
5666 isa<RecordDecl>(Owner)) {
5668 diag::err_anonymous_union_with_storage_spec)
5682 <<
Record->isUnion() <<
"const"
5686 diag::ext_anonymous_struct_union_qualified)
5687 <<
Record->isUnion() <<
"volatile"
5691 diag::ext_anonymous_struct_union_qualified)
5692 <<
Record->isUnion() <<
"restrict"
5696 diag::ext_anonymous_struct_union_qualified)
5697 <<
Record->isUnion() <<
"_Atomic"
5701 diag::ext_anonymous_struct_union_qualified)
5702 <<
Record->isUnion() <<
"__unaligned"
5712 for (
auto *Mem :
Record->decls()) {
5714 if (Mem->isInvalidDecl())
5717 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
5721 assert(FD->getAccess() !=
AS_none);
5723 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
5735 }
else if (Mem->isImplicit()) {
5737 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() !=
Record) {
5742 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
5743 if (!MemRecord->isAnonymousStructOrUnion() &&
5744 MemRecord->getDeclName()) {
5747 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
5751 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
5759 Diag(MemRecord->getLocation(),
5760 diag::ext_anonymous_record_with_anonymous_type)
5763 }
else if (isa<AccessSpecDecl>(Mem)) {
5765 }
else if (isa<StaticAssertDecl>(Mem)) {
5770 unsigned DK = diag::err_anonymous_record_bad_member;
5771 if (isa<TypeDecl>(Mem))
5772 DK = diag::err_anonymous_record_with_type;
5773 else if (isa<FunctionDecl>(Mem))
5774 DK = diag::err_anonymous_record_with_function;
5775 else if (isa<VarDecl>(Mem))
5776 DK = diag::err_anonymous_record_with_static;
5780 DK == diag::err_anonymous_record_with_type)
5781 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
5784 Diag(Mem->getLocation(), DK) <<
Record->isUnion();
5793 if (cast<CXXRecordDecl>(
Record)->hasInClassInitializer() &&
5796 cast<CXXRecordDecl>(
Record));
5800 Diag(
Record->getLocation(), diag::err_anonymous_struct_not_member)
5821 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
5825 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
5841 Diag(
Record->getLocation(), diag::err_mutable_nonmember);
5847 Record->getLocation(),
nullptr,
5863 Record->setAnonymousStructOrUnion(
true);
5874 Chain.push_back(Anon);
5880 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
5883 Decl *ManglingContextDecl;
5884 std::tie(MCtx, ManglingContextDecl) =
5903 assert(
Record &&
"expected a record!");
5908 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
5910 auto *ParentDecl = cast<RecordDecl>(
CurContext);
5916 nullptr, RecTy, TInfo,
5928 Chain.push_back(Anon);
5932 diag::err_field_incomplete_or_sizeless) ||
5937 ParentDecl->setInvalidDecl();
5950 NameInfo.
setLoc(Name.StartLocation);
5952 switch (Name.getKind()) {
5956 NameInfo.
setName(Name.Identifier);
5973 Diag(Name.StartLocation,
5974 diag::err_deduction_guide_name_not_class_template)
5988 Name.OperatorFunctionId.Operator));
5990 Name.OperatorFunctionId.SymbolLocations[0], Name.EndLocation));
6026 if (!CurClass || CurClass->
getIdentifier() != Name.TemplateId->Name)
6062 llvm_unreachable(
"Unknown name kind");
6090 for (
unsigned Idx = 0; Idx <
Declaration->param_size(); ++Idx) {
6104 (DeclTyName && DeclTyName == DefTyName))
6105 Params.push_back(Idx);
6132#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case DeclSpec::TST_##Trait:
6133#include "clang/Basic/TransformTypeTraits.def"
6148 if (!TSI)
return true;
6161 if (
Result.isInvalid())
return true;
6172 for (
unsigned I = 0,
E =
D.getNumTypeObjects(); I !=
E; ++I) {
6206 << D << static_cast<int>(Status);
6217 if (
OpenMP().getOMPTraitInfoForSurroundingScope()->isExtensionActive(
6218 llvm::omp::TraitProperty::
6219 implementation_extension_bind_to_declaration))
6244 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
6255 bool IsMemberSpecialization) {
6256 assert(SS.
isValid() &&
"diagnoseQualifiedDeclaration called for declaration "
6257 "without nested-name-specifier");
6259 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
6273 Diag(
Loc,
LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
6274 : diag::err_member_extra_qualification)
6278 Diag(
Loc, diag::warn_namespace_member_extra_qualification) << Name;
6286 if (!Cur->
Encloses(DC) && !(TemplateId || IsMemberSpecialization)) {
6288 Diag(
Loc, diag::err_member_qualification)
6290 else if (isa<TranslationUnitDecl>(DC))
6291 Diag(
Loc, diag::err_invalid_declarator_global_scope)
6293 else if (isa<FunctionDecl>(Cur))
6294 Diag(
Loc, diag::err_invalid_declarator_in_function)
6296 else if (isa<BlockDecl>(Cur))
6297 Diag(
Loc, diag::err_invalid_declarator_in_block)
6299 else if (isa<ExportDecl>(Cur)) {
6300 if (!isa<NamespaceDecl>(DC))
6301 Diag(
Loc, diag::err_export_non_namespace_scope_name)
6308 Diag(
Loc, diag::err_invalid_declarator_scope)
6309 << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.
getRange();
6316 Diag(
Loc, diag::err_member_qualification)
6326 Name.getCXXNameType(),
6343 Diag(
Loc, diag::ext_template_after_declarative_nns)
6348 TL = std::exchange(NextTL,
TypeLoc())) {
6350 switch (TL.getTypeLocClass()) {
6351 case TypeLoc::TemplateSpecialization: {
6353 TemplateKeywordLoc = TST.getTemplateKeywordLoc();
6355 Diag(
Loc, diag::ext_alias_template_in_declarative_nns)
6356 << TST.getLocalSourceRange();
6359 case TypeLoc::Decltype:
6360 case TypeLoc::PackIndexing: {
6361 const Type *
T = TL.getTypePtr();
6368 Diag(
Loc, diag::err_computed_type_in_declarative_nns)
6372 case TypeLoc::DependentName:
6376 case TypeLoc::DependentTemplateSpecialization: {
6378 TemplateKeywordLoc = TST.getTemplateKeywordLoc();
6379 NextTL = TST.getQualifierLoc().getAsTypeLoc();
6385 if (TemplateKeywordLoc.
isValid())
6386 Diag(
Loc, diag::ext_template_after_declarative_nns)
6401 if (
D.isDecompositionDeclarator()) {
6404 if (!
D.isInvalidType())
6412 if (
D.getCXXScopeSpec().isInvalid())
6414 else if (
D.getCXXScopeSpec().isSet()) {
6419 bool EnteringContext = !
D.getDeclSpec().isFriendSpecified();
6421 if (!DC || isa<EnumDecl>(DC)) {
6426 Diag(
D.getIdentifierLoc(),
6427 diag::err_template_qualified_declarator_no_match)
6428 <<
D.getCXXScopeSpec().getScopeRep()
6429 <<
D.getCXXScopeSpec().getRange();
6434 if (!IsDependentContext &&
6439 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
6440 Diag(
D.getIdentifierLoc(),
6441 diag::err_member_def_undefined_record)
6442 << Name << DC <<
D.getCXXScopeSpec().getRange();
6445 if (!
D.getDeclSpec().isFriendSpecified()) {
6448 ?
D.getName().TemplateId
6451 D.getIdentifierLoc(), TemplateId,
6462 if (EnteringContext && IsDependentContext &&
6463 TemplateParamLists.size() != 0) {
6481 if (!
D.getCXXScopeSpec().isSet()) {
6482 bool IsLinkageLookup =
false;
6483 bool CreateBuiltins =
false;
6497 IsLinkageLookup =
true;
6502 CreateBuiltins =
true;
6504 if (IsLinkageLookup) {
6507 RedeclarationKind::ForExternalRedeclaration);
6545 if (!
D.isInvalidType()) {
6546 bool AllowForCompatibility =
false;
6547 if (
Scope *DeclParent = S->getDeclParent();
6548 Scope *TemplateParamParent = S->getTemplateParamParent()) {
6549 AllowForCompatibility = DeclParent->Contains(*TemplateParamParent) &&
6550 TemplateParamParent->isDeclScope(TPD);
6553 AllowForCompatibility);
6579 S = S->getDeclParent();
6583 bool AddToScope =
true;
6585 if (TemplateParamLists.size()) {
6586 Diag(
D.getIdentifierLoc(), diag::err_template_typedef);
6607 if (
New->getDeclName() && AddToScope)
6610 if (
OpenMP().isInOpenMPDeclareTargetContext())
6621 bool &SizeIsNegative,
6622 llvm::APSInt &Oversized) {
6627 SizeIsNegative =
false;
6636 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
6641 if (FixedType.
isNull())
return FixedType;
6643 return Qs.
apply(Context, FixedType);
6645 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
6646 QualType Inner = PTy->getInnerType();
6650 if (FixedType.
isNull())
return FixedType;
6652 return Qs.
apply(Context, FixedType);
6662 SizeIsNegative, Oversized);
6672 llvm::APSInt Res =
Result.Val.getInt();
6675 if (Res.isSigned() && Res.isNegative()) {
6676 SizeIsNegative =
true;
6681 unsigned ActiveSizeBits =
6685 : Res.getActiveBits();
6693 return Qs.
apply(Context, FoldedArrayType);
6718 TypeLoc DstElemTL = DstATL.getElementLoc();
6737 bool &SizeIsNegative,
6738 llvm::APSInt &Oversized) {
6741 SizeIsNegative, Oversized);
6752 unsigned FailedFoldDiagID) {
6753 bool SizeIsNegative;
6754 llvm::APSInt Oversized;
6756 TInfo,
Context, SizeIsNegative, Oversized);
6758 Diag(
Loc, diag::ext_vla_folded_to_constant);
6765 Diag(
Loc, diag::err_typecheck_negative_array_size);
6766 else if (Oversized.getBoolValue())
6768 else if (FailedFoldDiagID)
6795 diag::err_virtual_non_function);
6799 diag::err_explicit_non_function);
6803 diag::err_noreturn_non_function);
6810 if (
D.getCXXScopeSpec().isSet()) {
6811 Diag(
D.getIdentifierLoc(), diag::err_qualified_typedef_declarator)
6812 <<
D.getCXXScopeSpec().getRange();
6821 if (
D.getDeclSpec().isInlineSpecified())
6822 Diag(
D.getDeclSpec().getInlineSpecLoc(),
6824 ? diag::warn_ms_inline_non_function
6825 : diag::err_inline_non_function)
6827 if (
D.getDeclSpec().hasConstexprSpecifier())
6828 Diag(
D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr)
6829 << 1 <<
static_cast<int>(
D.getDeclSpec().getConstexprSpecifier());
6833 Diag(
D.getName().StartLocation,
6834 diag::err_deduction_guide_invalid_specifier)
6837 Diag(
D.getName().StartLocation, diag::err_typedef_not_identifier)
6843 if (!NewTD)
return nullptr;
6867 if (S->getFnParent() ==
nullptr) {
6868 bool SizeIsNegative;
6869 llvm::APSInt Oversized;
6882 else if (Oversized.getBoolValue())
6919 switch (II->getNotableIdentifierID()) {
6920 case tok::NotableIdentifierKind::FILE:
6923 case tok::NotableIdentifierKind::jmp_buf:
6926 case tok::NotableIdentifierKind::sigjmp_buf:
6929 case tok::NotableIdentifierKind::ucontext_t:
6932 case tok::NotableIdentifierKind::float_t:
6933 case tok::NotableIdentifierKind::double_t:
6934 NewTD->
addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(
Context));
6995 if (!OuterContext->
Equals(PrevOuterContext))
7004 if (!SS.
isSet())
return;
7009 if (
Decl->getType().hasAddressSpace())
7011 if (
Decl->getType()->isDependentType())
7023 Var->hasGlobalStorage())
7027 if (
auto DT = dyn_cast<DecayedType>(
Type)) {
7028 auto OrigTy = DT->getOriginalType();
7029 if (!OrigTy.hasAddressSpace() && OrigTy->isArrayType()) {
7060 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
7069 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
7070 if (VD->hasInit()) {
7071 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
7072 assert(VD->isThisDeclarationADefinition() &&
7073 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
7075 VD->dropAttr<AliasAttr>();
7084 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
7087 diag::err_attribute_selectany_non_extern_data);
7094 if (HybridPatchableAttr *
Attr = ND.
getAttr<HybridPatchableAttr>()) {
7097 diag::warn_attribute_hybrid_patchable_non_extern);
7103 auto *VD = dyn_cast<VarDecl>(&ND);
7104 bool IsAnonymousNS =
false;
7107 const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(VD->getDeclContext());
7108 while (NS && !IsAnonymousNS) {
7110 NS = dyn_cast<NamespaceDecl>(NS->
getParent());
7117 bool AnonNSInMicrosoftMode = IsAnonymousNS && IsMicrosoft;
7119 (!AnonNSInMicrosoftMode &&
7130 if (
const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
7131 FD = FD->getMostRecentDecl();
7136 for (
TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
7142 if (
const auto *A = ATL.
getAttrAs<LifetimeBoundAttr>()) {
7143 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
7144 int NoImplicitObjectError = -1;
7146 NoImplicitObjectError = 0;
7147 else if (MD->isStatic())
7148 NoImplicitObjectError = 1;
7149 else if (MD->isExplicitObjectMemberFunction())
7150 NoImplicitObjectError = 2;
7151 if (NoImplicitObjectError != -1) {
7152 S.
Diag(A->getLocation(), diag::err_lifetimebound_no_object_param)
7153 << NoImplicitObjectError << A->getRange();
7154 }
else if (isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD)) {
7155 S.
Diag(A->getLocation(), diag::err_lifetimebound_ctor_dtor)
7156 << isa<CXXDestructorDecl>(MD) << A->getRange();
7157 }
else if (MD->getReturnType()->isVoidType()) {
7161 err_lifetimebound_implicit_object_parameter_void_return_type);
7166 for (
unsigned int I = 0; I < FD->getNumParams(); ++I) {
7171 if (
auto *A =
P->getAttr<LifetimeBoundAttr>()) {
7172 if (!isa<CXXConstructorDecl>(FD) && FD->getReturnType()->isVoidType()) {
7173 S.
Diag(A->getLocation(),
7174 diag::err_lifetimebound_parameter_void_return_type);
7197 bool IsSpecialization,
7198 bool IsDefinition) {
7202 bool IsTemplate =
false;
7203 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
7204 OldDecl = OldTD->getTemplatedDecl();
7206 if (!IsSpecialization)
7207 IsDefinition =
false;
7209 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
7210 NewDecl = NewTD->getTemplatedDecl();
7214 if (!OldDecl || !NewDecl)
7217 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
7218 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
7219 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
7220 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
7224 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
7225 (NewExportAttr && !NewExportAttr->isInherited());
7231 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
7233 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
7235 bool JustWarn =
false;
7237 auto *VD = dyn_cast<VarDecl>(OldDecl);
7238 if (VD && !VD->getDescribedVarTemplate())
7240 auto *FD = dyn_cast<FunctionDecl>(OldDecl);
7249 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
7252 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
7253 : diag::err_attribute_dll_redeclaration;
7256 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
7269 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
7271 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
7274 IsStaticDataMember = VD->isStaticDataMember();
7275 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
7277 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
7278 IsInline = FD->isInlined();
7279 IsQualifiedFriend = FD->getQualifier() &&
7283 if (OldImportAttr && !HasNewAttr &&
7284 (!IsInline || (IsMicrosoftABI && IsTemplate)) && !IsStaticDataMember &&
7286 if (IsMicrosoftABI && IsDefinition) {
7287 if (IsSpecialization) {
7290 diag::err_attribute_dllimport_function_specialization_definition);
7291 S.
Diag(OldImportAttr->getLocation(), diag::note_attribute);
7292 NewDecl->
dropAttr<DLLImportAttr>();
7295 diag::warn_redeclaration_without_import_attribute)
7298 NewDecl->
dropAttr<DLLImportAttr>();
7299 NewDecl->
addAttr(DLLExportAttr::CreateImplicit(
7300 S.
Context, NewImportAttr->getRange()));
7302 }
else if (IsMicrosoftABI && IsSpecialization) {
7303 assert(!IsDefinition);
7307 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
7308 << NewDecl << OldImportAttr;
7310 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
7311 OldDecl->
dropAttr<DLLImportAttr>();
7312 NewDecl->
dropAttr<DLLImportAttr>();
7314 }
else if (IsInline && OldImportAttr && !IsMicrosoftABI) {
7317 OldDecl->
dropAttr<DLLImportAttr>();
7318 NewDecl->
dropAttr<DLLImportAttr>();
7320 diag::warn_dllimport_dropped_from_inline_function)
7321 << NewDecl << OldImportAttr;
7328 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
7330 !NewImportAttr && !NewExportAttr) {
7331 if (
const DLLExportAttr *ParentExportAttr =
7332 MD->getParent()->getAttr<DLLExportAttr>()) {
7333 DLLExportAttr *NewAttr = ParentExportAttr->clone(S.
Context);
7334 NewAttr->setInherited(
true);
7378 if (!
D->isInExternCContext() ||
D->template hasAttr<OverloadableAttr>())
7382 if (S.
getLangOpts().CUDA && (
D->template hasAttr<CUDADeviceAttr>() ||
7383 D->template hasAttr<CUDAHostAttr>()))
7386 return D->isExternC();
7392 isa<OMPDeclareMapperDecl>(DC))
7401 if (isa<RequiresExprBodyDecl>(DC))
7403 llvm_unreachable(
"Unexpected context");
7409 isa<OMPDeclareReductionDecl>(DC) || isa<OMPDeclareMapperDecl>(DC))
7413 llvm_unreachable(
"Unexpected context");
7458 if (
const auto *FD = dyn_cast<FunctionDecl>(
D))
7459 return FD->isExternC();
7460 if (
const auto *VD = dyn_cast<VarDecl>(
D))
7461 return VD->isExternC();
7463 llvm_unreachable(
"Unknown type of decl!");
7476 diag::err_opencl_type_can_only_be_used_as_function_parameter)
7490 diag::err_invalid_type_for_program_scope_var)
7519 Se.
Diag(NewVD->
getLocation(), diag::err_opencl_half_declaration) << R;
7552 Se.
Diag(NewVD->
getLocation(), diag::err_opencl_nonconst_global_sampler);
7562template <
typename AttrTy>
7565 if (
const auto *Attribute = TND->
getAttr<AttrTy>()) {
7566 AttrTy *Clone = Attribute->clone(S.
Context);
7567 Clone->setInherited(
true);
7595 if (
const auto *ConstDecl = RD->
getAttr<ReadOnlyPlacementAttr>()) {
7597 S.
Diag(ConstDecl->getLocation(), diag::note_enforce_read_only_placement);
7604 return Name.getAsIdentifierInfo() &&
7605 Name.getAsIdentifierInfo()->isStr(
"main") &&
7619 bool IsPlaceholderVariable =
false;
7621 if (
D.isDecompositionDeclarator()) {
7624 auto &Decomp =
D.getDecompositionDeclarator();
7625 if (!Decomp.bindings().empty()) {
7626 II = Decomp.bindings()[0].Name;
7630 Diag(
D.getIdentifierLoc(), diag::err_bad_variable_name) << Name;
7640 IsPlaceholderVariable =
true;
7647 IsPlaceholderVariable = !isa<ParmVarDecl>(PrevDecl);
7648 if (IsPlaceholderVariable)
7662 bool IsLocalExternDecl = SC ==
SC_Extern &&
7668 Diag(
D.getIdentifierLoc(), diag::err_mutable_nonmember);
7675 D.getDeclSpec().getStorageClassSpecLoc())) {
7679 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
7681 : diag::warn_deprecated_register)
7687 if (!DC->
isRecord() && S->getFnParent() ==
nullptr) {
7692 Diag(
D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope);
7704 const AutoType *AT = TL.getTypePtr();
7708 bool IsMemberSpecialization =
false;
7709 bool IsVariableTemplateSpecialization =
false;
7711 bool IsVariableTemplate =
false;
7722 if (
D.isInvalidType())
7735 D.getCXXScopeSpec(),
7737 ?
D.getName().TemplateId
7740 false, IsMemberSpecialization,
Invalid);
7742 if (TemplateParams) {
7749 if (!TemplateParams->
size() &&
7754 diag::err_template_variable_noparams)
7758 TemplateParams =
nullptr;
7766 IsVariableTemplateSpecialization =
true;
7770 IsVariableTemplate =
true;
7773 DiagCompat(
D.getIdentifierLoc(), diag_compat::variable_template);
7778 if (!TemplateParamLists.empty() && IsMemberSpecialization &&
7783 "should have a 'template<>' for this decl");
7786 bool IsExplicitSpecialization =
7797 (IsExplicitSpecialization || IsMemberSpecialization)) {
7798 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
7799 diag::ext_explicit_specialization_storage_class)
7805 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
7811 if (Ctxt->isFunctionOrMethod()) {
7812 FunctionOrMethod = Ctxt;
7815 const CXXRecordDecl *ParentDecl = dyn_cast<CXXRecordDecl>(Ctxt);
7817 AnonStruct = ParentDecl;
7821 if (FunctionOrMethod) {
7824 Diag(
D.getIdentifierLoc(),
7825 diag::err_static_data_member_not_allowed_in_local_class)
7826 << Name << RD->getDeclName() << RD->getTagKind();
7827 }
else if (AnonStruct) {
7831 Diag(
D.getIdentifierLoc(),
7832 diag::err_static_data_member_not_allowed_in_anon_struct)
7835 }
else if (RD->isUnion()) {
7839 diag_compat::static_data_member_in_union)
7845 Diag(
D.getIdentifierLoc(), diag::err_template_member)
7856 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
7857 diag::err_static_out_of_line)
7859 D.getDeclSpec().getStorageClassSpecLoc());
7869 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
7870 diag::err_storage_class_for_static_member)
7872 D.getDeclSpec().getStorageClassSpecLoc());
7875 llvm_unreachable(
"C storage class in c++!");
7879 if (IsVariableTemplateSpecialization) {
7881 TemplateParamLists.size() > 0
7882 ? TemplateParamLists[0]->getTemplateLoc()
7885 S,
D, TInfo,
Previous, TemplateKWLoc, TemplateParams, SC,
7889 NewVD = cast<VarDecl>(Res.
get());
7891 }
else if (
D.isDecompositionDeclarator()) {
7893 D.getIdentifierLoc(), R, TInfo, SC,
7897 D.getIdentifierLoc(), II, R, TInfo, SC);
7900 if (IsVariableTemplate) {
7903 TemplateParams, NewVD);
7912 if (
D.isInvalidType() ||
Invalid) {
7924 unsigned VDTemplateParamLists =
7925 (TemplateParams && !IsExplicitSpecialization) ? 1 : 0;
7926 if (TemplateParamLists.size() > VDTemplateParamLists)
7928 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
7931 if (
D.getDeclSpec().isInlineSpecified()) {
7933 Diag(
D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
7937 Diag(
D.getDeclSpec().getInlineSpecLoc(),
7938 diag::err_inline_declaration_block_scope) << Name
7941 Diag(
D.getDeclSpec().getInlineSpecLoc(),
7943 : diag::compat_pre_cxx17_inline_variable);
7954 if (IsLocalExternDecl) {
7955 if (
D.isDecompositionDeclarator())
7957 B->setLocalExternDecl();
7962 bool EmitTLSUnsupportedError =
false;
7963 if (
DeclSpec::TSCS TSCS =
D.getDeclSpec().getThreadStorageClassSpec()) {
7974 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
7975 diag::err_thread_non_global)
7982 EmitTLSUnsupportedError =
true;
7988 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
7989 diag::err_thread_unsupported);
7994 switch (
D.getDeclSpec().getConstexprSpecifier()) {
7999 Diag(
D.getDeclSpec().getConstexprSpecLoc(),
8000 diag::err_constexpr_wrong_decl_kind)
8001 <<
static_cast<int>(
D.getDeclSpec().getConstexprSpecifier());
8017 Diag(
D.getDeclSpec().getConstexprSpecLoc(),
8018 diag::err_constinit_local_variable);
8021 ConstInitAttr::Create(
Context,
D.getDeclSpec().getConstexprSpecLoc(),
8022 ConstInitAttr::Keyword_constinit));
8035 if (SC ==
SC_Static && S->getFnParent() !=
nullptr &&
8039 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
8040 diag::warn_static_local_in_extern_inline);
8045 if (
D.getDeclSpec().isModulePrivateSpecified()) {
8046 if (IsVariableTemplateSpecialization)
8050 D.getDeclSpec().getModulePrivateSpecLoc());
8051 else if (IsMemberSpecialization)
8058 <<
SourceRange(
D.getDeclSpec().getModulePrivateSpecLoc())
8060 D.getDeclSpec().getModulePrivateSpecLoc());
8066 B->setModulePrivate();
8075 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
8076 diag::err_opencl_unknown_type_specifier)
8086 if (
const auto *ATy = dyn_cast<ArrayType>(NewVD->
getType())) {
8087 if (ATy && ATy->getElementType().isWebAssemblyReferenceType() &&
8110 copyAttrFromTypedefToDecl<AllocSizeAttr>(*
this, NewVD, TT);
8113 if (EmitTLSUnsupportedError &&
8116 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD))))
8117 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
8118 diag::err_thread_unsupported);
8120 if (EmitTLSUnsupportedError &&
8123 targetDiag(
D.getIdentifierLoc(), diag::err_thread_unsupported);
8126 if (SC ==
SC_None && S->getFnParent() !=
nullptr &&
8127 (NewVD->
hasAttr<CUDASharedAttr>() ||
8128 NewVD->
hasAttr<CUDAConstantAttr>())) {
8136 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
8137 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
8142 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(NewVD))
8146 if (
Expr *
E =
D.getAsmLabel()) {
8150 if (S->getFnParent() !=
nullptr) {
8171 bool HasSizeMismatch;
8173 if (!TI.isValidGCCRegisterName(
Label))
8175 else if (!TI.validateGlobalRegisterVariable(
Label,
8179 else if (HasSizeMismatch)
8185 diag::err_asm_unsupported_register_type)
8193 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
8206 NamedDecl *ShadowedDecl =
D.getCXXScopeSpec().isEmpty()
8214 D.getCXXScopeSpec().isNotEmpty() ||
8215 IsMemberSpecialization ||
8216 IsVariableTemplateSpecialization);
8230 if (IsMemberSpecialization && !IsVariableTemplate &&
8231 !IsVariableTemplateSpecialization && !NewVD->
isInvalidDecl() &&
8238 isa<FieldDecl>(
Previous.getFoundDecl()) &&
8239 D.getCXXScopeSpec().isSet()) {
8243 <<
D.getCXXScopeSpec().getRange();
8247 }
else if (
D.getCXXScopeSpec().isSet() &&
8248 !IsVariableTemplateSpecialization) {
8250 Diag(
D.getIdentifierLoc(), diag::err_no_member)
8252 <<
D.getCXXScopeSpec().getRange();
8256 if (!IsPlaceholderVariable)
8279 (
D.getCXXScopeSpec().isSet() && DC && DC->
isRecord() &&
8287 if (PrevVarTemplate &&
8294 if (!IsPlaceholderVariable && ShadowedDecl && !
D.isRedeclaration())
8307 Decl *ManglingContextDecl;
8308 std::tie(MCtx, ManglingContextDecl) =
8335 if (
D.isRedeclaration() && !
Previous.empty()) {
8338 D.isFunctionDefinition());
8370 if (isa<TypeAliasDecl>(ShadowedDecl))
8372 else if (isa<TypedefDecl>(ShadowedDecl))
8374 else if (isa<BindingDecl>(ShadowedDecl))
8376 else if (isa<RecordDecl>(OldDC))
8409 if (
D->hasGlobalStorage() && !
D->isStaticLocal())
8413 return isa<VarDecl, FieldDecl, BindingDecl>(ShadowedDecl) ? ShadowedDecl
8427 return isa<TypedefNameDecl>(ShadowedDecl) ? ShadowedDecl :
nullptr;
8436 return isa<VarDecl, FieldDecl, BindingDecl>(ShadowedDecl) ? ShadowedDecl
8444 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
8450 if (!MD->getParent()->isLambda() && MD->isExplicitObjectMemberFunction())
8455 if (isa<CXXConstructorDecl>(NewDC))
8456 if (
const auto PVD = dyn_cast<ParmVarDecl>(
D)) {
8459 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
8464 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
8465 if (shadowedVar->isExternC()) {
8468 for (
auto *I : shadowedVar->redecls())
8469 if (I->isFileVarDecl()) {
8477 unsigned WarningDiag = diag::warn_decl_shadow;
8479 if (isa<VarDecl>(
D) && NewDC && isa<CXXMethodDecl>(NewDC)) {
8480 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
8482 if (
const auto *VD = dyn_cast<VarDecl>(ShadowedDecl)) {
8484 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
8490 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
8496 ->ShadowingDecls.push_back({
D, VD});
8500 if (isa<FieldDecl>(ShadowedDecl)) {
8507 ->ShadowingDecls.push_back({
D, ShadowedDecl});
8511 if (
const auto *VD = dyn_cast<VarDecl>(ShadowedDecl);
8512 VD && VD->hasLocalStorage()) {
8516 ParentDC && !ParentDC->
Equals(OldDC);
8520 if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) &&
8542 if (ReDC->
isRecord() && isa<EnumConstantDecl>(
D) && !OldDC->
Equals(ReDC))
8559 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
8566 const NamedDecl *ShadowedDecl = Shadow.ShadowedDecl;
8569 if (
const auto *VD = dyn_cast<VarDecl>(ShadowedDecl)) {
8571 Diag(Shadow.VD->getLocation(),
8572 CaptureLoc.
isInvalid() ? diag::warn_decl_shadow_uncaptured_local
8573 : diag::warn_decl_shadow)
8574 << Shadow.VD->getDeclName()
8577 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
8578 << Shadow.VD->getDeclName() << 0;
8580 }
else if (isa<FieldDecl>(ShadowedDecl)) {
8581 Diag(Shadow.VD->getLocation(),
8583 : diag::warn_decl_shadow_uncaptured_local)
8584 << Shadow.VD->getDeclName()
8597 RedeclarationKind::ForVisibleRedeclaration);
8610 auto *DRE = dyn_cast<DeclRefExpr>(
E);
8613 const NamedDecl *
D = cast<NamedDecl>(DRE->getDecl()->getCanonicalDecl());
8614 auto I = ShadowingDecls.find(
D);
8615 if (I == ShadowingDecls.end())
8617 const NamedDecl *ShadowedDecl = I->second;
8619 Diag(
Loc, diag::warn_modifying_shadowing_decl) <<
D << OldDC;
8624 ShadowingDecls.erase(I);
8632 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
8653 if (!isa<VarDecl>(ND))
8663 if (isa<VarDecl>(*I)) {
8673 if (isa<VarDecl>(*I)) {
8691 assert(Prev &&
"should have found a previous declaration to diagnose");
8693 Prev = FD->getFirstDecl();
8695 Prev = cast<VarDecl>(Prev)->getFirstDecl();
8697 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
8719 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
8731 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
8751 SemaRef.
Diag(VarLoc, diag::err_c23_constexpr_invalid_type) <<
T;
8761 SemaRef.
Diag(VarLoc, diag::err_c23_constexpr_invalid_type) <<
T;
8769 return CheckC23ConstexprVarType(SemaRef, VarLoc, F->getType());
8825 if (NewVD->
hasAttr<BlocksAttr>()) {
8833 if (!
T.isConstQualified()) {
8834 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
8840 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
8856 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
8857 <<
Scope <<
"global or constant";
8859 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
8860 <<
Scope <<
"constant";
8876 if (FD && !FD->
hasAttr<DeviceKernelAttr>()) {
8888 if (FD && FD->
hasAttr<DeviceKernelAttr>()) {
8913 && !NewVD->
hasAttr<BlocksAttr>()) {
8935 const auto *ATy = dyn_cast<ConstantArrayType>(
T.getTypePtr());
8936 if (!ATy || ATy->getZExtSize() != 0) {
8938 diag::err_typecheck_wasm_table_must_have_zero_length);
8948 (FD->hasAttr<CUDADeviceAttr>() || FD->hasAttr<CUDAGlobalAttr>())) {
8958 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
8964 bool SizeIsNegative;
8965 llvm::APSInt Oversized;
8970 FixedT = FixedTInfo->
getType();
8971 else if (FixedTInfo) {
9034 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
9049 diag::err_constexpr_var_non_literal)) {
9065 llvm::StringMap<bool> CallerFeatureMap;
9076 diag::err_sve_vector_in_non_streaming_function)
9086 llvm::StringMap<bool> CallerFeatureMap;
9120 CXXRecordDecl *BaseRecord = Specifier->getType()->getAsCXXRecordDecl();
9131 dyn_cast<CXXMethodDecl>(BaseND->getCanonicalDecl());
9138 if (Overridden.insert(BaseMD).second) {
9155 return !Overridden.empty();
9161 struct ActOnFDArgs {
9177 : Context(Context), OriginalFD(TypoFD),
9180 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
9186 CDeclEnd = candidate.
end();
9187 CDecl != CDeclEnd; ++CDecl) {
9194 if (
Parent &&
Parent->getCanonicalDecl() == ExpectedParent)
9196 }
else if (!ExpectedParent) {
9205 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
9206 return std::make_unique<DifferentNameValidatorCCC>(*
this);
9232 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *S) {
9238 bool IsDefinition = ExtraArgs.D.isFunctionDefinition();
9240 IsLocalFriend ? diag::err_no_matching_local_friend :
9242 diag::err_member_decl_does_not_match;
9246 RedeclarationKind::ForVisibleRedeclaration);
9254 "Cannot have an ambiguity in previous-declaration lookup");
9256 DifferentNameValidatorCCC CCC(SemaRef.
Context, NewFD,
9258 if (!Prev.
empty()) {
9267 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
9268 NearMatches.push_back(std::make_pair(FD, ParamNum));
9274 &ExtraArgs.D.getCXXScopeSpec(), CCC,
9276 IsLocalFriend ?
nullptr : NewDC))) {
9279 ExtraArgs.D.getIdentifierLoc());
9283 CDeclEnd = Correction.
end();
9284 CDecl != CDeclEnd; ++CDecl) {
9291 bool wasRedeclaration = ExtraArgs.D.isRedeclaration();
9304 ExtraArgs.S, ExtraArgs.D,
9307 ExtraArgs.AddToScope);
9315 Decl *Canonical =
Result->getCanonicalDecl();
9318 if ((*I)->getCanonicalDecl() == Canonical)
9325 SemaRef.
PDiag(IsLocalFriend
9326 ? diag::err_no_matching_local_friend_suggest
9327 : diag::err_member_decl_does_not_match_suggest)
9328 << Name << NewDC << IsDefinition);
9333 ExtraArgs.D.SetIdentifier(Name.getAsIdentifierInfo(),
9334 ExtraArgs.D.getIdentifierLoc());
9335 ExtraArgs.D.setRedeclaration(wasRedeclaration);
9341 << Name << NewDC << IsDefinition << NewFD->
getLocation();
9344 if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
9350 bool NewFDisConst = NewMD && NewMD->
isConst();
9353 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
9354 NearMatch != NearMatchEnd; ++NearMatch) {
9357 bool FDisConst = MD && MD->
isConst();
9358 bool IsMember = MD || !IsLocalFriend;
9361 if (
unsigned Idx = NearMatch->second) {
9365 SemaRef.
Diag(
Loc, IsMember ? diag::note_member_def_close_param_match
9366 : diag::note_local_decl_close_param_match)
9369 }
else if (FDisConst != NewFDisConst) {
9371 diag::note_member_def_close_const_match)
9373 if (
const auto &FTI = ExtraArgs.D.getFunctionTypeInfo(); !NewFDisConst)
9376 else if (FTI.hasMethodTypeQualifiers() &&
9377 FTI.getConstQualifierLoc().isValid())
9381 IsMember ? diag::note_member_def_close_match
9382 : diag::note_local_decl_close_match);
9389 switch (
D.getDeclSpec().getStorageClassSpec()) {
9390 default: llvm_unreachable(
"Unknown storage class!");
9394 SemaRef.
Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
9395 diag::err_typecheck_sclass_func);
9396 D.getMutableDeclSpec().ClearStorageClassSpecs();
9401 if (
D.getDeclSpec().isExternInLinkageSpec())
9411 SemaRef.
Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
9412 diag::err_static_block_func);
9428 bool &IsVirtualOkay) {
9433 bool isInline =
D.getDeclSpec().isInlineSpecified();
9441 SemaRef.
Diag(
D.getDeclSpec().getConstexprSpecLoc(),
9442 diag::err_c23_constexpr_not_variable);
9444 SemaRef.
Diag(
D.getDeclSpec().getConstexprSpecLoc(),
9445 diag::err_constexpr_wrong_decl_kind)
9446 <<
static_cast<int>(ConstexprKind);
9448 D.getMutableDeclSpec().ClearConstexprSpec();
9463 (
D.isFunctionDeclarator() &&
D.getFunctionTypeInfo().hasPrototype) ||
9464 (
D.getDeclSpec().isTypeRep() &&
9466 ->isFunctionProtoType()) ||
9470 "Strict prototypes are required");
9477 if (
D.isInvalidType())
9491 "Constructors can only be declared in a member context");
9497 isInline,
false, ConstexprKind,
9508 false, ConstexprKind,
9509 TrailingRequiresClause);
9512 if (
Record->isBeingDefined())
9521 IsVirtualOkay =
true;
9525 SemaRef.
Diag(
D.getIdentifierLoc(), diag::err_destructor_not_member);
9533 true, ConstexprKind, TrailingRequiresClause);
9538 SemaRef.
Diag(
D.getIdentifierLoc(),
9539 diag::err_conv_function_not_member);
9544 if (
D.isInvalidType())
9547 IsVirtualOkay =
true;
9552 TrailingRequiresClause);
9566 if (Name.getAsIdentifierInfo() &&
9567 Name.getAsIdentifierInfo() == cast<CXXRecordDecl>(DC)->getIdentifier()){
9568 SemaRef.
Diag(
D.getIdentifierLoc(), diag::err_constructor_return_type)
9579 IsVirtualOkay = !Ret->isStatic();
9583 SemaRef.
getLangOpts().CPlusPlus &&
D.getDeclSpec().isFriendSpecified();
9593 true , ConstexprKind, TrailingRequiresClause);
9610 StringRef SizeTypeNames[] = {
"size_t",
"intptr_t",
"uintptr_t",
"ptrdiff_t"};
9618 if (Names.end() !=
Match)
9623 }
while (DesugaredTy != Ty);
9662 "__cl_clang_non_portable_kernel_param_types", S.
getLangOpts())) {
9664 bool IsStandardLayoutType =
true;
9670 if (!CXXRec->hasDefinition())
9672 if (!CXXRec || !CXXRec->hasDefinition() || !CXXRec->isStandardLayout())
9673 IsStandardLayoutType =
false;
9676 !IsStandardLayoutType)
9724 "__cl_clang_non_portable_kernel_param_types", S.
getLangOpts()) &&
9738 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
9785 S.
Diag(
Loc, diag::note_entity_declared_at) << PT;
9808 HistoryStack.push_back(
nullptr);
9813 VisitStack.push_back(PD);
9814 assert(VisitStack.back() &&
"First decl null?");
9817 const Decl *Next = VisitStack.pop_back_val();
9819 assert(!HistoryStack.empty());
9821 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
9822 ValidTypes.insert(Hist->getType().getTypePtr());
9830 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(Next)) {
9831 HistoryStack.push_back(Field);
9833 QualType FieldTy = Field->getType();
9837 "Unexpected type.");
9842 RD = cast<RecordDecl>(Next);
9846 VisitStack.push_back(
nullptr);
9848 for (
const auto *FD : RD->
fields()) {
9859 VisitStack.push_back(FD);
9871 diag::err_record_with_pointers_kernel_param)
9878 S.
Diag(PD->getLocation(), diag::note_within_field_of_type)
9879 << PD->getDeclName();
9884 I = HistoryStack.begin() + 1,
9885 E = HistoryStack.end();
9898 }
while (!VisitStack.empty());
9914 while (S->isClassScope() ||
9915 (LangOpts.CPlusPlus &&
9916 S->isFunctionPrototypeScope()) ||
9918 (S->getEntity() && S->getEntity()->isTransparentContext()))
9925 unsigned BuiltinID) {
9926 switch (BuiltinID) {
9927 case Builtin::BI__GetExceptionInfo:
9931 case Builtin::BIaddressof:
9932 case Builtin::BI__addressof:
9933 case Builtin::BIforward:
9934 case Builtin::BIforward_like:
9935 case Builtin::BImove:
9936 case Builtin::BImove_if_noexcept:
9937 case Builtin::BIas_const: {
9959 Diag(
D.getIdentifierLoc(), diag::err_function_decl_cmse_ns_call);
9962 llvm::append_range(TemplateParamLists, TemplateParamListsRef);
9964 if (!TemplateParamLists.empty() && !TemplateParamLists.back()->empty() &&
9965 Invented->getDepth() == TemplateParamLists.back()->getDepth())
9966 TemplateParamLists.back() = Invented;
9968 TemplateParamLists.push_back(Invented);
9976 if (
DeclSpec::TSCS TSCS =
D.getDeclSpec().getThreadStorageClassSpec())
9977 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
9978 diag::err_invalid_thread)
9981 if (
D.isFirstDeclarationOfMember())
9983 R, !(
D.isStaticMember() ||
D.isExplicitObjectMemberFunction()),
9984 D.isCtorOrDtor(),
D.getIdentifierLoc());
9986 bool isFriend =
false;
9988 bool isMemberSpecialization =
false;
9989 bool isFunctionTemplateSpecialization =
false;
9991 bool HasExplicitTemplateArgs =
false;
9994 bool isVirtualOkay =
false;
10001 if (!NewFD)
return nullptr;
10011 if (IsLocalExternDecl)
10021 bool ImplicitInlineCXX20 = !
getLangOpts().CPlusPlusModules ||
10025 bool isInline =
D.getDeclSpec().isInlineSpecified();
10026 bool isVirtual =
D.getDeclSpec().isVirtualSpecified();
10027 bool hasExplicit =
D.getDeclSpec().hasExplicitSpecifier();
10028 isFriend =
D.getDeclSpec().isFriendSpecified();
10029 if (ImplicitInlineCXX20 && isFriend &&
D.isFunctionDefinition()) {
10044 if (
Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
10049 if (isVirtual &&
Parent->isUnion()) {
10050 Diag(
D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_in_union);
10054 Parent->hasAttr<SYCLSpecialClassAttr>() &&
10056 NewFD->
getName() ==
"__init" &&
D.isFunctionDefinition()) {
10057 if (
auto *Def =
Parent->getDefinition())
10058 Def->setInitMethod(
true);
10063 isMemberSpecialization =
false;
10064 isFunctionTemplateSpecialization =
false;
10065 if (
D.isInvalidType())
10073 ?
D.getName().TemplateId
10078 D.getCXXScopeSpec(), TemplateId, TemplateParamLists, isFriend,
10079 isMemberSpecialization,
Invalid);
10080 if (TemplateParams) {
10085 if (TemplateParams->
size() > 0) {
10093 }
else if (TemplateId) {
10094 Diag(
D.getIdentifierLoc(), diag::err_function_template_partial_spec)
10110 Name, TemplateParams,
10116 if (TemplateParamLists.size() > 1) {
10123 isFunctionTemplateSpecialization =
true;
10125 if (TemplateParamLists.size() > 0)
10144 Diag(
D.getIdentifierLoc(), diag::err_template_spec_decl_friend)
10145 << Name << RemoveRange
10151 HasExplicitTemplateArgs =
true;
10158 if (!TemplateParamLists.empty() && isMemberSpecialization &&
10164 if (TemplateParamLists.size() > 0)
10169 if (isFriend && TemplateId)
10170 isFunctionTemplateSpecialization =
true;
10176 if (isFunctionTemplateSpecialization && TemplateId) {
10177 HasExplicitTemplateArgs =
true;
10208 if (!isVirtualOkay) {
10209 Diag(
D.getDeclSpec().getVirtualSpecLoc(),
10210 diag::err_virtual_non_function);
10213 Diag(
D.getDeclSpec().getVirtualSpecLoc(),
10214 diag::err_virtual_out_of_class)
10219 Diag(
D.getDeclSpec().getVirtualSpecLoc(),
10220 diag::err_virtual_member_function_template)
10229 Diag(
D.getDeclSpec().getVirtualSpecLoc(), diag::err_auto_fn_virtual);
10238 Diag(
D.getDeclSpec().getInlineSpecLoc(),
10239 diag::err_inline_declaration_block_scope) << Name
10249 !isa<CXXDeductionGuideDecl>(NewFD)) {
10252 Diag(
D.getDeclSpec().getExplicitSpecLoc(),
10253 diag::err_explicit_out_of_class)
10255 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
10256 !isa<CXXConversionDecl>(NewFD)) {
10259 Diag(
D.getDeclSpec().getExplicitSpecLoc(),
10260 diag::err_explicit_non_ctor_or_conv_function)
10274 if (isa<CXXDestructorDecl>(NewFD) &&
10277 Diag(
D.getDeclSpec().getConstexprSpecLoc(), diag::err_constexpr_dtor)
10278 <<
static_cast<int>(ConstexprKind);
10288 Diag(
D.getDeclSpec().getConstexprSpecLoc(),
10289 diag::err_invalid_consteval_decl_kind)
10296 if (
D.getDeclSpec().isModulePrivateSpecified()) {
10297 if (isFunctionTemplateSpecialization) {
10299 =
D.getDeclSpec().getModulePrivateSpecLoc();
10300 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
10321 switch (
D.getFunctionDefinitionKind()) {
10335 if (ImplicitInlineCXX20 && isa<CXXMethodDecl>(NewFD) && DC ==
CurContext &&
10336 D.isFunctionDefinition()) {
10346 if (!isFriend && SC !=
SC_None) {
10354 if (isFunctionTemplateSpecialization || isMemberSpecialization) {
10355 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
10356 diag::ext_explicit_specialization_storage_class)
10358 D.getDeclSpec().getStorageClassSpecLoc());
10362 assert(isa<CXXMethodDecl>(NewFD) &&
10363 "Out-of-line member function should be a CXXMethodDecl");
10375 Diag(
D.getDeclSpec().getStorageClassSpecLoc(),
10377 cast<CXXRecordDecl>(DC)->getDescribedClassTemplate()) ||
10380 ? diag::ext_static_out_of_line
10381 : diag::err_static_out_of_line)
10383 D.getDeclSpec().getStorageClassSpecLoc());
10391 if (Name.isAnyOperatorDelete() &&
getLangOpts().CPlusPlus11 && FPT &&
10404 if (isInline && !
D.isFunctionDefinition() &&
getLangOpts().CPlusPlus20 &&
10406 PendingInlineFuncDecls.insert(NewFD);
10412 D.getCXXScopeSpec().isNotEmpty() ||
10413 isMemberSpecialization ||
10414 isFunctionTemplateSpecialization);
10417 if (
Expr *
E =
D.getAsmLabel()) {
10423 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
10439 if (
D.isFunctionDeclarator(FTIIdx)) {
10448 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
10452 Params.push_back(Param);
10467 auto *TD = dyn_cast<TagDecl>(NonParmDecl);
10472 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
10473 TD = cast<EnumDecl>(ECD->getDeclContext());
10477 DeclContext *TagDC = TD->getLexicalDeclContext();
10481 TD->setDeclContext(NewFD);
10489 if (TagDC != PrototypeTagContext)
10490 TD->setLexicalDeclContext(TagDC);
10504 for (
const auto &AI : FT->param_types()) {
10508 Params.push_back(Param);
10512 "Should not need args for typedef of non-prototype fn");
10516 NewFD->setParams(Params);
10522 if (!
D.isFunctionDefinition()) {
10527 if (
D.getDeclSpec().isNoreturnSpecified())
10529 C11NoReturnAttr::Create(
Context,
D.getDeclSpec().getNoreturnSpecLoc()));
10541 !NewFD->
hasAttr<SectionAttr>())
10542 NewFD->
addAttr(PragmaClangTextSectionAttr::CreateImplicit(
10547 if (
CodeSegStack.CurrentValue &&
D.isFunctionDefinition() &&
10548 !NewFD->
hasAttr<SectionAttr>()) {
10549 NewFD->
addAttr(SectionAttr::CreateImplicit(
10551 CodeSegStack.CurrentPragmaLocation, SectionAttr::Declspec_allocate));
10562 !NewFD->
hasAttr<StrictGuardStackCheckAttr>())
10563 NewFD->
addAttr(StrictGuardStackCheckAttr::CreateImplicit(
10568 if (!NewFD->
hasAttr<CodeSegAttr>()) {
10570 D.isFunctionDefinition())) {
10577 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
10579 !NewTVA->isDefaultVersion() &&
10582 AddToScope =
false;
10594 Diag(NewFD->
getLocation(), diag::err_return_value_with_address_space);
10609 isMemberSpecialization,
10610 D.isFunctionDefinition()));
10613 D.setRedeclaration(
true);
10616 "previous declaration set still overloaded");
10622 if (isa<FunctionNoProtoType>(FT) && !
D.isFunctionDefinition()) {
10628 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
10647 if (
D.getDeclSpec().isInlineSpecified() &&
10650 Diag(
D.getDeclSpec().getInlineSpecLoc(),
10651 diag::ext_operator_new_delete_declared_inline)
10678 if (isFunctionTemplateSpecialization || isMemberSpecialization) {
10690 Diag(TRC->getBeginLoc(), diag::err_non_temp_spec_requires_clause)
10693 !
D.isFunctionDefinition()) {
10698 diag::err_non_temp_friend_decl_with_requires_clause_must_be_def);
10701 !(isa<CXXMethodDecl>(NewFD) ||
D.isFunctionDefinition())) {
10702 Diag(TRC->getBeginLoc(),
10703 diag::err_constrained_non_templated_function);
10720 if (isFunctionTemplateSpecialization) {
10721 bool isDependentSpecialization =
false;
10726 isDependentSpecialization =
10728 (HasExplicitTemplateArgs &&
10732 assert((!isDependentSpecialization ||
10733 (HasExplicitTemplateArgs == isDependentSpecialization)) &&
10734 "dependent friend function specialization without template "
10740 isDependentSpecialization =
10745 HasExplicitTemplateArgs ? &TemplateArgs :
nullptr;
10746 if (isDependentSpecialization) {
10753 NewFD, ExplicitTemplateArgs,
Previous))
10774 isMemberSpecialization,
10775 D.isFunctionDefinition()));
10778 D.setRedeclaration(
true);
10781 !
D.isRedeclaration() ||
10783 "previous declaration set still overloaded");
10810 D.getDeclSpec().isFriendSpecified()
10811 ? (
D.isFunctionDefinition()
10814 : (
D.getCXXScopeSpec().isSet() &&
10823 }
else if (!
D.isRedeclaration()) {
10824 struct ActOnFDArgs ExtraArgs = { S,
D, TemplateParamLists,
10831 if (
D.getCXXScopeSpec().isSet()) {
10846 (
D.getCXXScopeSpec().getScopeRep().isDependent() ||
10870 *
this,
Previous, NewFD, ExtraArgs,
false,
nullptr)) {
10871 AddToScope = ExtraArgs.AddToScope;
10878 }
else if (isFriend && cast<CXXRecordDecl>(
CurContext)->isLocalClass()) {
10880 *
this,
Previous, NewFD, ExtraArgs,
true, S)) {
10881 AddToScope = ExtraArgs.AddToScope;
10885 }
else if (!
D.isFunctionDefinition() &&
10886 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
10887 !isFriend && !isFunctionTemplateSpecialization &&
10888 !isMemberSpecialization) {
10897 <<
D.getCXXScopeSpec().getRange();
10903 if (!NewFD->
isInvalidDecl() && S->getDepth() == 0 && Name.isIdentifier())
10906 if (NewFD->
hasAttr<HLSLShaderAttr>())
10912 if (!
D.isRedeclaration()) {
10914 if (
unsigned BuiltinID = II->getBuiltinID()) {
10916 if (!InStdNamespace &&
10922 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
10931 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
10936 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
10947 if (NewFD->
hasAttr<OverloadableAttr>() &&
10950 diag::err_attribute_overloadable_no_prototype)
10952 NewFD->
dropAttr<OverloadableAttr>();
10966 if (
D.isFunctionDefinition()) {
10982 if (
D.isRedeclaration() && !
Previous.empty()) {
10985 isMemberSpecialization ||
10986 isFunctionTemplateSpecialization,
10987 D.isFunctionDefinition());
10992 if (II && II->
isStr(
CUDA().getConfigureFuncName()) &&
11005 (NewFD->
hasAttr<CUDADeviceAttr>() ||
11006 NewFD->
hasAttr<CUDAGlobalAttr>()) &&
11008 !
D.isFunctionDefinition())) {
11018 Diag(
D.getIdentifierLoc(), diag::err_static_kernel);
11019 D.setInvalidType();
11025 Diag(
D.getIdentifierLoc(), diag::err_expected_kernel_void_return_type)
11028 D.setInvalidType();
11037 Diag(
D.getIdentifierLoc(), diag::err_method_kernel);
11038 D.setInvalidType();
11041 Diag(
D.getIdentifierLoc(), diag::err_template_kernel);
11042 D.setInvalidType();
11057 if (!
D.isFunctionDefinition()) {
11059 diag::err_friend_decl_with_enclosing_temp_constraint_must_be_def);
11079 if (
getLangOpts().getOpenCLCompatibleVersion() >= 200) {
11081 QualType ElemTy = PipeTy->getElementType();
11083 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type);
11084 D.setInvalidType();
11091 Diag(Param->getTypeSpecStartLoc(),
11092 diag::err_wasm_table_as_function_parameter);
11093 D.setInvalidType();
11100 if (
const auto *
attr = NewFD->
getAttr<AvailabilityAttr>()) {
11101 if (NewFD->
hasAttr<ConstructorAttr>()) {
11102 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
11104 NewFD->
dropAttr<AvailabilityAttr>();
11106 if (NewFD->
hasAttr<DestructorAttr>()) {
11107 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
11109 NewFD->
dropAttr<AvailabilityAttr>();
11120 if (
const auto *NBA = NewFD->
getAttr<NoBuiltinAttr>())
11121 switch (
D.getFunctionDefinitionKind()) {
11124 Diag(NBA->getLocation(),
11125 diag::err_attribute_no_builtin_on_defaulted_deleted_function)
11126 << NBA->getSpelling();
11129 Diag(NBA->getLocation(), diag::err_attribute_no_builtin_on_non_definition)
11130 << NBA->getSpelling();
11163 const auto *
Method = dyn_cast<CXXMethodDecl>(FD);
11167 if (
const auto *SAttr =
Parent->getAttr<CodeSegAttr>()) {
11178 while ((
Parent = dyn_cast<CXXRecordDecl>(
Parent->getParent()))) {
11179 if (
const auto *SAttr =
Parent->getAttr<CodeSegAttr>()) {
11189 bool IsDefinition) {
11192 if (!FD->
hasAttr<SectionAttr>() && IsDefinition &&
11194 return SectionAttr::CreateImplicit(
11196 CodeSegStack.CurrentPragmaLocation, SectionAttr::Declspec_allocate);
11244 auto *VD = dyn_cast<ValueDecl>(
D);
11245 auto *PrevVD = dyn_cast<ValueDecl>(PrevDecl);
11246 return !VD || !PrevVD ||
11248 PrevVD->getType());
11256 const auto *TA = FD->
getAttr<TargetAttr>();
11257 const auto *TVA = FD->
getAttr<TargetVersionAttr>();
11259 assert((TA || TVA) &&
"Expecting target or target_version attribute");
11272 for (
const auto &Feat : ParseInfo.
Features) {
11273 auto BareFeat = StringRef{Feat}.substr(1);
11274 if (Feat[0] ==
'-') {
11276 <<
Feature << (
"no-" + BareFeat).str();
11296 for (
auto &Feat : ParseInfo.
Features)
11297 Feats.push_back(StringRef{Feat}.substr(1));
11300 TVA->getFeatures(Feats);
11302 for (
const auto &Feat : Feats) {
11322 case attr::ArmLocallyStreaming:
11327 case attr::NonNull:
11328 case attr::NoThrow:
11337 const auto Diagnose = [FD, CausedFD, MVKind](
Sema &S,
const Attr *A) {
11338 S.
Diag(FD->
getLocation(), diag::err_multiversion_disallowed_other_attr)
11339 <<
static_cast<unsigned>(MVKind) << A;
11341 S.
Diag(CausedFD->
getLocation(), diag::note_multiversioning_caused_here);
11346 switch (A->getKind()) {
11347 case attr::CPUDispatch:
11348 case attr::CPUSpecific:
11351 return Diagnose(S, A);
11355 return Diagnose(S, A);
11357 case attr::TargetVersion:
11360 return Diagnose(S, A);
11362 case attr::TargetClones:
11365 return Diagnose(S, A);
11369 return Diagnose(S, A);
11382 bool ConstexprSupported,
bool CLinkageMayDiffer) {
11383 enum DoesntSupport {
11390 DefaultedFuncs = 6,
11391 ConstexprFuncs = 7,
11392 ConstevalFuncs = 8,
11404 if (NoProtoDiagID.
getDiagID() != 0 && OldFD &&
11407 Diag(NoteCausedDiagIDAt.first, NoteCausedDiagIDAt.second);
11415 if (!TemplatesSupported &&
11417 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11420 if (
const auto *NewCXXFD = dyn_cast<CXXMethodDecl>(NewFD)) {
11421 if (NewCXXFD->isVirtual())
11422 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11425 if (isa<CXXConstructorDecl>(NewCXXFD))
11426 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11429 if (isa<CXXDestructorDecl>(NewCXXFD))
11430 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11435 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11439 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11443 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11444 << (NewFD->
isConsteval() ? ConstevalFuncs : ConstexprFuncs);
11447 const auto *NewType = cast<FunctionType>(NewQType);
11448 QualType NewReturnType = NewType->getReturnType();
11451 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11457 const auto *OldType = cast<FunctionType>(OldQType);
11464 bool ArmStreamingCCMismatched =
false;
11465 if (OldFPT && NewFPT) {
11472 ArmStreamingCCMismatched =
true;
11475 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC() || ArmStreamingCCMismatched)
11478 QualType OldReturnType = OldType->getReturnType();
11480 if (OldReturnType != NewReturnType)
11481 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ReturnType;
11484 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ConstexprSpec;
11487 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << InlineSpec;
11490 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) <<
Linkage;
11513 bool IsCPUSpecificCPUDispatchMVKind =
11517 if (CausesMV && OldFD &&
11525 if (OldFD && CausesMV && OldFD->
isUsed(
false)) {
11532 OldFD, NewFD, S.
PDiag(diag::err_multiversion_noproto),
11534 S.
PDiag(diag::note_multiversioning_caused_here)),
11536 S.
PDiag(diag::err_multiversion_doesnt_support)
11537 <<
static_cast<unsigned>(MVKind)),
11539 S.
PDiag(diag::err_multiversion_diff)),
11541 !IsCPUSpecificCPUDispatchMVKind,
11554 "Function lacks multiversion attribute");
11555 const auto *TA = FD->
getAttr<TargetAttr>();
11556 const auto *TVA = FD->
getAttr<TargetVersionAttr>();
11559 if (TA && !TA->isDefaultVersion())
11596 To->
addAttr(TargetVersionAttr::CreateImplicit(
11607 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11608 const auto *OldTA = OldFD->
getAttr<TargetAttr>();
11609 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11610 const auto *OldTVA = OldFD->
getAttr<TargetVersionAttr>();
11612 assert((NewTA || NewTVA) &&
"Excpecting target or target_version attribute");
11621 if (NewTA && !NewTA->isDefaultVersion() &&
11622 (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr()))
11639 if ((NewTA && NewTA->isDefaultVersion() && !OldTA) ||
11640 (NewTVA && NewTVA->isDefaultVersion() && !OldTVA)) {
11649 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
11657 OldTA->getFeaturesStr());
11661 NewTA->getFeaturesStr());
11664 if (OldParsed == NewParsed) {
11672 for (
const auto *FD : OldFD->
redecls()) {
11673 const auto *CurTA = FD->
getAttr<TargetAttr>();
11674 const auto *CurTVA = FD->
getAttr<TargetVersionAttr>();
11678 ((NewTA && (!CurTA || CurTA->isInherited())) ||
11679 (NewTVA && (!CurTVA || CurTVA->isInherited())))) {
11681 << (NewTA ? 0 : 2);
11682 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
11729 const CPUDispatchAttr *NewCPUDisp,
const CPUSpecificAttr *NewCPUSpec,
11745 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11746 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11753 NewTA->getFeaturesStr());
11758 NewTVA->getFeatures(NewFeats);
11759 llvm::sort(NewFeats);
11762 bool UseMemberUsingDeclRules =
11765 bool MayNeedOverloadableChecks =
11774 if (MayNeedOverloadableChecks &&
11775 S.
IsOverload(NewFD, CurFD, UseMemberUsingDeclRules))
11778 switch (NewMVKind) {
11781 "Only target_clones can be omitted in subsequent declarations");
11784 const auto *CurTA = CurFD->
getAttr<TargetAttr>();
11785 if (CurTA->getFeaturesStr() == NewTA->getFeaturesStr()) {
11794 CurTA->getFeaturesStr());
11796 if (CurParsed == NewParsed) {
11805 if (
const auto *CurTVA = CurFD->
getAttr<TargetVersionAttr>()) {
11806 if (CurTVA->getName() == NewTVA->getName()) {
11813 CurTVA->getFeatures(CurFeats);
11814 llvm::sort(CurFeats);
11816 if (CurFeats == NewFeats) {
11822 }
else if (
const auto *CurClones = CurFD->
getAttr<TargetClonesAttr>()) {
11824 if (NewFeats.empty())
11827 for (
unsigned I = 0; I < CurClones->featuresStrs_size(); ++I) {
11829 CurClones->getFeatures(CurFeats, I);
11830 llvm::sort(CurFeats);
11832 if (CurFeats == NewFeats) {
11843 assert(NewClones &&
"MultiVersionKind does not match attribute type");
11844 if (
const auto *CurClones = CurFD->
getAttr<TargetClonesAttr>()) {
11845 if (CurClones->featuresStrs_size() != NewClones->featuresStrs_size() ||
11846 !std::equal(CurClones->featuresStrs_begin(),
11847 CurClones->featuresStrs_end(),
11848 NewClones->featuresStrs_begin())) {
11854 }
else if (
const auto *CurTVA = CurFD->
getAttr<TargetVersionAttr>()) {
11856 CurTVA->getFeatures(CurFeats);
11857 llvm::sort(CurFeats);
11860 if (CurFeats.empty())
11863 for (
unsigned I = 0; I < NewClones->featuresStrs_size(); ++I) {
11865 NewClones->getFeatures(NewFeats, I);
11866 llvm::sort(NewFeats);
11868 if (CurFeats == NewFeats) {
11884 const auto *CurCPUSpec = CurFD->
getAttr<CPUSpecificAttr>();
11885 const auto *CurCPUDisp = CurFD->
getAttr<CPUDispatchAttr>();
11890 CurFD->
hasAttr<CPUDispatchAttr>()) {
11891 if (CurCPUDisp->cpus_size() == NewCPUDisp->cpus_size() &&
11893 CurCPUDisp->cpus_begin(), CurCPUDisp->cpus_end(),
11894 NewCPUDisp->cpus_begin(),
11896 return Cur->getName() == New->getName();
11911 if (CurCPUSpec->cpus_size() == NewCPUSpec->cpus_size() &&
11913 CurCPUSpec->cpus_begin(), CurCPUSpec->cpus_end(),
11914 NewCPUSpec->cpus_begin(),
11916 return Cur->getName() == New->getName();
11927 if (CurII == NewII) {
11987 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11988 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11989 const auto *NewCPUDisp = NewFD->
getAttr<CPUDispatchAttr>();
11990 const auto *NewCPUSpec = NewFD->
getAttr<CPUSpecificAttr>();
11991 const auto *NewClones = NewFD->
getAttr<TargetClonesAttr>();
12001 NewTVA->isDefaultVersion())) {
12002 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_not_allowed_on_main);
12010 if (NewTA && TI.
getTriple().isAArch64())
12037 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_required_in_redecl)
12050 if (OldFD->
isUsed(
false)) {
12052 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
12073 bool IsPure = NewFD->
hasAttr<PureAttr>();
12074 bool IsConst = NewFD->
hasAttr<ConstAttr>();
12077 if (!IsPure && !IsConst)
12084 if (IsPure && IsConst) {
12094 NewFD->
dropAttrs<PureAttr, ConstAttr>();
12100 bool IsMemberSpecialization,
12103 "Variably modified return types are not handled here");
12108 bool MergeTypeWithPrevious = !
getLangOpts().CPlusPlus &&
12113 bool MayNeedOverloadableChecks =
false;
12125 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
12127 OldDecl = Candidate;
12130 MayNeedOverloadableChecks =
true;
12155 OldDecl =
Previous.getFoundDecl();
12156 MergeTypeWithPrevious =
false;
12159 if (OldDecl->
hasAttr<OverloadableAttr>() ||
12160 NewFD->
hasAttr<OverloadableAttr>()) {
12161 if (
IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
12162 MayNeedOverloadableChecks =
true;
12221 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
12225 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
12226 if (!OldMD || !OldMD->
isStatic()) {
12261 dyn_cast<FunctionTemplateDecl>(OldDecl)) {
12262 auto *OldFD = OldTemplateDecl->getTemplatedDecl();
12265 assert(NewTemplateDecl &&
"Template/non-template mismatch");
12274 NewFD->
setAccess(OldTemplateDecl->getAccess());
12275 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
12280 if (IsMemberSpecialization &&
12283 assert(OldTemplateDecl->isMemberSpecialization());
12286 if (OldFD->isDeleted()) {
12288 assert(OldFD->getCanonicalDecl() == OldFD);
12290 OldFD->setDeletedAsWritten(
false);
12296 auto *OldFD = cast<FunctionDecl>(OldDecl);
12304 !NewFD->
getAttr<OverloadableAttr>()) {
12308 return ND->hasAttr<OverloadableAttr>();
12310 "Non-redecls shouldn't happen without overloadable present");
12313 const auto *FD = dyn_cast<FunctionDecl>(ND);
12314 return FD && !FD->
hasAttr<OverloadableAttr>();
12317 if (OtherUnmarkedIter !=
Previous.end()) {
12319 diag::err_attribute_overloadable_multiple_unmarked_overloads);
12320 Diag((*OtherUnmarkedIter)->getLocation(),
12321 diag::note_attribute_overloadable_prev_overload)
12331 if (NewFD->
hasAttr<SYCLKernelEntryPointAttr>())
12334 if (NewFD->
hasAttr<SYCLExternalAttr>())
12344 dyn_cast<CXXDestructorDecl>(NewFD)) {
12352 !
Destructor->getFunctionObjectParameterType()->isDependentType()) {
12364 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
12365 if (
auto *TD = Guide->getDescribedFunctionTemplate())
12371 Diag(Guide->getBeginLoc(), diag::err_deduction_guide_specialized)
12377 if (!
Method->isFunctionTemplateSpecialization() &&
12378 !
Method->getDescribedFunctionTemplate() &&
12379 Method->isCanonicalDecl()) {
12386 diag::err_constrained_virtual_method);
12426 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
12439 auto HasNoexcept = [&](
QualType T) ->
bool {
12450 if (FPT->isNothrow())
12456 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
12458 AnyNoexcept |= HasNoexcept(
T);
12461 diag::warn_cxx17_compat_exception_spec_in_signature)
12466 bool IsKernel = NewFD->
hasAttr<CUDAGlobalAttr>();
12468 if (!Parm->getType()->isDependentType() &&
12469 Parm->hasAttr<CUDAGridConstantAttr>() &&
12470 !(IsKernel && Parm->getType().isConstQualified()))
12471 Diag(Parm->getAttr<CUDAGridConstantAttr>()->getLocation(),
12472 diag::err_cuda_grid_constant_not_allowed);
12488 Diag(FD->
getLocation(), diag::ext_main_invalid_linkage_specification);
12499 ? diag::err_static_main : diag::warn_static_main)
12507 Diag(NoreturnLoc, diag::ext_noreturn_main);
12508 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
12520 << FD->
hasAttr<DeviceKernelAttr>();
12525 if (FD->
hasAttr<SYCLExternalAttr>()) {
12527 << FD->
getAttr<SYCLExternalAttr>();
12538 assert(
T->
isFunctionType() &&
"function decl is not of function type");
12560 Diag(RTRange.
getBegin(), diag::note_main_change_return_type)
12585 Diag(start, diag::warn_main_in_named_module)
12591 if (isa<FunctionNoProtoType>(FT))
return;
12597 bool HasExtraParameters = (nparams > 3);
12609 HasExtraParameters =
false;
12611 if (HasExtraParameters) {
12624 for (
unsigned i = 0; i < nparams; ++i) {
12627 bool mismatch =
true;
12644 mismatch = !qs.
empty();
12673 if (
T.isOSCygMing())
12678 if (
T.isOSWindows() &&
T.getArch() == llvm::Triple::x86)
12686 assert(
T->
isFunctionType() &&
"function decl is not of function type");
12695 if (FD->
getName() !=
"DllMain")
12729 if (
Init->isValueDependent()) {
12730 assert(
Init->containsErrors() &&
12731 "Dependent code should only occur in error-recovery path.");
12734 const Expr *Culprit;
12735 if (
Init->isConstantInitializer(
Context,
false, &Culprit))
12744 class SelfReferenceChecker
12750 bool isReferenceType;
12751 bool isInCXXOperatorCall;
12759 SelfReferenceChecker(
Sema &S,
Decl *OrigDecl) : Inherited(S.Context),
12760 S(S), OrigDecl(OrigDecl) {
12763 isReferenceType =
false;
12764 isInCXXOperatorCall =
false;
12765 isInitList =
false;
12766 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
12767 isPODType = VD->getType().isPODType(S.
Context);
12769 isReferenceType = VD->getType()->isReferenceType();
12776 void CheckExpr(
Expr *
E) {
12785 InitFieldIndex.push_back(0);
12786 for (
auto *Child : InitList->
children()) {
12787 CheckExpr(cast<Expr>(Child));
12788 ++InitFieldIndex.back();
12790 InitFieldIndex.pop_back();
12795 bool CheckInitListMemberExpr(
MemberExpr *
E,
bool CheckReference) {
12798 bool ReferenceField =
false;
12802 FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl());
12805 Fields.push_back(FD);
12807 ReferenceField =
true;
12808 Base = ME->getBase()->IgnoreParenImpCasts();
12813 if (!DRE || DRE->
getDecl() != OrigDecl)
12817 if (CheckReference && !ReferenceField)
12822 for (
const FieldDecl *I : llvm::reverse(Fields))
12823 UsedFieldIndex.push_back(I->getFieldIndex());
12828 for (
auto UsedIter = UsedFieldIndex.begin(),
12829 UsedEnd = UsedFieldIndex.end(),
12830 OrigIter = InitFieldIndex.begin(),
12831 OrigEnd = InitFieldIndex.end();
12832 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
12833 if (*UsedIter < *OrigIter)
12835 if (*UsedIter > *OrigIter)
12840 HandleDeclRefExpr(DRE);
12847 void HandleValue(
Expr *
E) {
12850 HandleDeclRefExpr(DRE);
12855 Visit(CO->getCond());
12856 HandleValue(CO->getTrueExpr());
12857 HandleValue(CO->getFalseExpr());
12862 dyn_cast<BinaryConditionalOperator>(
E)) {
12863 Visit(BCO->getCond());
12864 HandleValue(BCO->getFalseExpr());
12869 if (
Expr *SE = OVE->getSourceExpr())
12875 if (BO->getOpcode() == BO_Comma) {
12876 Visit(BO->getLHS());
12877 HandleValue(BO->getRHS());
12882 if (isa<MemberExpr>(
E)) {
12884 if (CheckInitListMemberExpr(cast<MemberExpr>(
E),
12892 if (!isa<FieldDecl>(ME->getMemberDecl()))
12894 Base = ME->getBase()->IgnoreParenImpCasts();
12897 HandleDeclRefExpr(DRE);
12907 if (isReferenceType)
12908 HandleDeclRefExpr(
E);
12912 if (
E->getCastKind() == CK_LValueToRValue) {
12913 HandleValue(
E->getSubExpr());
12917 Inherited::VisitImplicitCastExpr(
E);
12922 if (CheckInitListMemberExpr(
E,
true ))
12931 CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(
E->getMemberDecl());
12932 bool Warn = (MD && !MD->
isStatic());
12935 if (!isa<FieldDecl>(ME->getMemberDecl()))
12937 Base = ME->getBase()->IgnoreParenImpCasts();
12942 HandleDeclRefExpr(DRE);
12955 if (isa<UnresolvedLookupExpr>(Callee))
12956 return Inherited::VisitCXXOperatorCallExpr(
E);
12959 for (
auto Arg:
E->arguments())
12960 HandleValue(Arg->IgnoreParenImpCasts());
12964 if (!isInCXXOperatorCall) {
12965 Inherited::VisitLambdaExpr(
E);
12971 HandleDeclRefExpr(DRE);
12981 HandleValue(
E->getSubExpr());
12985 if (
E->isIncrementDecrementOp()) {
12986 HandleValue(
E->getSubExpr());
12990 Inherited::VisitUnaryOperator(
E);
12996 if (
E->getConstructor()->isCopyConstructor()) {
12997 Expr *ArgExpr =
E->getArg(0);
12998 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
12999 if (ILE->getNumInits() == 1)
13000 ArgExpr = ILE->getInit(0);
13002 if (ICE->getCastKind() == CK_NoOp)
13003 ArgExpr = ICE->getSubExpr();
13004 HandleValue(ArgExpr);
13007 Inherited::VisitCXXConstructExpr(
E);
13012 if (
E->isCallToStdMove()) {
13013 HandleValue(
E->getArg(0));
13017 Inherited::VisitCallExpr(
E);
13021 if (
E->isCompoundAssignmentOp()) {
13022 HandleValue(
E->getLHS());
13023 Visit(
E->getRHS());
13027 Inherited::VisitBinaryOperator(
E);
13034 Visit(
E->getCond());
13035 Visit(
E->getFalseExpr());
13040 if (OrigDecl != ReferenceDecl)
return;
13042 if (isReferenceType) {
13043 diag = diag::warn_uninit_self_reference_in_reference_init;
13044 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
13045 diag = diag::warn_static_self_reference_in_init;
13046 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
13049 diag = diag::warn_uninit_self_reference_in_init;
13063 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *
E,
13067 if (isa<ParmVarDecl>(OrigDecl))
13076 if (ICE->getCastKind() == CK_LValueToRValue)
13077 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
13078 if (DRE->
getDecl() == OrigDecl)
13081 SelfReferenceChecker(S, OrigDecl).CheckExpr(
E);
13088 struct VarDeclOrName {
13094 return VN.VDecl ?
Diag << VN.VDecl :
Diag << VN.Name;
13104 bool IsInitCapture = !VDecl;
13106 "init captures are expected to be deduced prior to initialization");
13108 VarDeclOrName VN{VDecl, Name};
13111 assert(Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
13115 !isa_and_present<StringLiteral, InitListExpr>(
Init)) {
13124 assert(VDecl &&
"no init for init capture deduction?");
13128 if (!isa<DeducedTemplateSpecializationType>(Deduced) ||
13139 DeduceInits =
Init;
13141 auto *PL = dyn_cast_if_present<ParenListExpr>(
Init);
13143 DeduceInits = PL->exprs();
13145 if (isa<DeducedTemplateSpecializationType>(Deduced)) {
13146 assert(VDecl &&
"non-auto type for init capture deduction?");
13157 if (
auto *IL = dyn_cast<InitListExpr>(
Init))
13158 DeduceInits = IL->inits();
13162 if (DeduceInits.empty()) {
13165 Diag(
Init->getBeginLoc(), IsInitCapture
13166 ? diag::err_init_capture_no_expression
13167 : diag::err_auto_var_init_no_expression)
13172 if (DeduceInits.size() > 1) {
13173 Diag(DeduceInits[1]->getBeginLoc(),
13174 IsInitCapture ? diag::err_init_capture_multiple_expressions
13175 : diag::err_auto_var_init_multiple_expressions)
13180 Expr *DeduceInit = DeduceInits[0];
13181 if (
DirectInit && isa<InitListExpr>(DeduceInit)) {
13182 Diag(
Init->getBeginLoc(), IsInitCapture
13183 ? diag::err_init_capture_paren_braces
13184 : diag::err_auto_var_init_paren_braces)
13190 bool DefaultedAnyToId =
false;
13194 if (
Result.isInvalid()) {
13198 DefaultedAnyToId =
true;
13204 if (VDecl && isa<DecompositionDecl>(VDecl) &&
13208 Type.getQualifiers());
13216 if (!IsInitCapture)
13218 else if (isa<InitListExpr>(
Init))
13220 diag::err_init_capture_deduction_failure_from_init_list)
13249 assert(!
Init || !
Init->containsErrors());
13262 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(VDecl))
13286 if (
auto *EWC = dyn_cast<ExprWithCleanups>(
Init))
13287 Init = EWC->getSubExpr();
13289 if (
auto *CE = dyn_cast<ConstantExpr>(
Init))
13290 Init = CE->getSubExpr();
13295 "shouldn't be called if type doesn't have a non-trivial C struct");
13296 if (
auto *ILE = dyn_cast<InitListExpr>(
Init)) {
13297 for (
auto *I : ILE->inits()) {
13298 if (!I->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion() &&
13299 !I->getType().hasNonTrivialToPrimitiveCopyCUnion())
13307 if (isa<ImplicitValueInitExpr>(
Init)) {
13325bool shouldIgnoreForRecordTriviality(
const FieldDecl *FD) {
13331 return FD->
hasAttr<UnavailableAttr>();
13334struct DiagNonTrivalCUnionDefaultInitializeVisitor
13341 DiagNonTrivalCUnionDefaultInitializeVisitor(
13344 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13347 const FieldDecl *FD,
bool InNonTrivialUnion) {
13350 InNonTrivialUnion);
13351 return Super::visitWithKind(PDIK, QT, FD, InNonTrivialUnion);
13355 bool InNonTrivialUnion) {
13356 if (InNonTrivialUnion)
13358 << 1 << 0 << QT << FD->
getName();
13362 if (InNonTrivialUnion)
13364 << 1 << 0 << QT << FD->
getName();
13369 if (RD->isUnion()) {
13370 if (OrigLoc.isValid()) {
13371 bool IsUnion =
false;
13372 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13374 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13375 << 0 << OrigTy << IsUnion << UseContext;
13379 InNonTrivialUnion =
true;
13382 if (InNonTrivialUnion)
13383 S.
Diag(RD->getLocation(), diag::note_non_trivial_c_union)
13386 for (
const FieldDecl *FD : RD->fields())
13387 if (!shouldIgnoreForRecordTriviality(FD))
13388 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13401struct DiagNonTrivalCUnionDestructedTypeVisitor
13406 DiagNonTrivalCUnionDestructedTypeVisitor(
QualType OrigTy,
13410 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13413 const FieldDecl *FD,
bool InNonTrivialUnion) {
13416 InNonTrivialUnion);
13417 return Super::visitWithKind(DK, QT, FD, InNonTrivialUnion);
13421 bool InNonTrivialUnion) {
13422 if (InNonTrivialUnion)
13424 << 1 << 1 << QT << FD->
getName();
13428 if (InNonTrivialUnion)
13430 << 1 << 1 << QT << FD->
getName();
13435 if (RD->isUnion()) {
13436 if (OrigLoc.isValid()) {
13437 bool IsUnion =
false;
13438 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13440 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13441 << 1 << OrigTy << IsUnion << UseContext;
13445 InNonTrivialUnion =
true;
13448 if (InNonTrivialUnion)
13449 S.
Diag(RD->getLocation(), diag::note_non_trivial_c_union)
13452 for (
const FieldDecl *FD : RD->fields())
13453 if (!shouldIgnoreForRecordTriviality(FD))
13454 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13459 bool InNonTrivialUnion) {}
13469struct DiagNonTrivalCUnionCopyVisitor
13475 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13478 const FieldDecl *FD,
bool InNonTrivialUnion) {
13481 InNonTrivialUnion);
13482 return Super::visitWithKind(PCK, QT, FD, InNonTrivialUnion);
13486 bool InNonTrivialUnion) {
13487 if (InNonTrivialUnion)
13489 << 1 << 2 << QT << FD->
getName();
13493 if (InNonTrivialUnion)
13495 << 1 << 2 << QT << FD->
getName();
13500 if (RD->isUnion()) {
13501 if (OrigLoc.isValid()) {
13502 bool IsUnion =
false;
13503 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13505 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13506 << 2 << OrigTy << IsUnion << UseContext;
13510 InNonTrivialUnion =
true;
13513 if (InNonTrivialUnion)
13514 S.
Diag(RD->getLocation(), diag::note_non_trivial_c_union)
13517 for (
const FieldDecl *FD : RD->fields())
13518 if (!shouldIgnoreForRecordTriviality(FD))
13519 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13523 if (InNonTrivialUnion)
13525 << 1 << 2 << QT << FD->
getName();
13529 const FieldDecl *FD,
bool InNonTrivialUnion) {}
13532 bool InNonTrivialUnion) {}
13546 unsigned NonTrivialKind) {
13550 "shouldn't be called if type doesn't have a non-trivial C union");
13554 DiagNonTrivalCUnionDefaultInitializeVisitor(QT,
Loc, UseContext, *
this)
13555 .
visit(QT,
nullptr,
false);
13558 DiagNonTrivalCUnionDestructedTypeVisitor(QT,
Loc, UseContext, *
this)
13559 .visit(QT,
nullptr,
false);
13561 DiagNonTrivalCUnionCopyVisitor(QT,
Loc, UseContext, *
this)
13562 .visit(QT,
nullptr,
false);
13586 bool TargetIsInline = Dcl->
isInline();
13587 bool TargetWasTemplated =
13597 dyn_cast_if_present<FunctionDecl>(Ctx->getNonClosureAncestor());
13604 TargetWasTemplated =
13614 if (!TargetIsInline || TargetWasTemplated)
13625 if (
Target->hasAttr<DLLExportAttr>() ||
Target->hasAttr<DLLImportAttr>())
13631 dyn_cast<CXXRecordDecl>(
Target->getDeclContext());
13632 if (Ctx && (Ctx->hasAttr<DLLExportAttr>() || Ctx->hasAttr<DLLImportAttr>()))
13654 T =
T.getNonReferenceType();
13657 if (!
T.isConstant(Ctx))
13677 Diag(VD->
getLocation(), diag::warn_possible_object_duplication_mutable)
13689 !isa<CXXNewExpr>(
Init->IgnoreParenImpCasts())) {
13690 Diag(
Init->getExprLoc(), diag::warn_possible_object_duplication_init)
13703 if (
auto *
Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
13704 if (!
Method->isInvalidDecl()) {
13706 Diag(
Method->getLocation(), diag::err_member_function_initialization)
13707 <<
Method->getDeclName() <<
Init->getSourceRange();
13708 Method->setInvalidDecl();
13713 VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl);
13715 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
13730 if (!
Init->getType().isNull() &&
Init->getType()->isWebAssemblyTableType()) {
13731 Diag(
Init->getExprLoc(), diag::err_wasm_table_art) << 0;
13738 if (
Init->containsErrors()) {
13751 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
13772 BaseDeclType = Array->getElementType();
13774 diag::err_typecheck_decl_incomplete_type)) {
13781 diag::err_abstract_type_in_decl,
13791 !VDecl->
isTemplated() && !isa<VarTemplateSpecializationDecl>(VDecl) &&
13801 if (Def != VDecl &&
13821 Diag(
Init->getExprLoc(), diag::err_static_data_member_reinitialization)
13824 diag::note_previous_initializer)
13849 if (VDecl->
hasAttr<LoaderUninitializedAttr>()) {
13850 Diag(VDecl->
getLocation(), diag::err_loader_uninitialized_cant_init);
13856 if (!
HLSL().handleInitialization(VDecl,
Init))
13868 if (!
Result.isUsable()) {
13876 bool InitializedFromParenListExpr =
false;
13877 bool IsParenListInit =
false;
13884 if (
auto *CXXDirectInit = dyn_cast<ParenListExpr>(
Init)) {
13886 MultiExprArg(CXXDirectInit->getExprs(), CXXDirectInit->getNumExprs());
13887 InitializedFromParenListExpr =
true;
13888 }
else if (
auto *CXXDirectInit = dyn_cast<CXXParenListInitExpr>(
Init)) {
13889 Args = CXXDirectInit->getInitExprs();
13890 InitializedFromParenListExpr =
true;
13897 if (!
Result.isUsable()) {
13911 if (isa<DecompositionDecl>(VDecl))
13917 IsParenListInit = !InitSeq.
steps().empty() &&
13921 if (!
Init->getType().isNull() && !
Init->getType()->isDependentType() &&
13953 if (VDecl->
hasAttr<BlocksAttr>())
13967 Init->getBeginLoc()))
13968 FSI->markSafeWeakUse(
Init);
13985 if (!
Result.isUsable()) {
14018 isa<InitListExpr>(
Init)) {
14022 if (
auto *
E = dyn_cast<ExprWithCleanups>(
Init))
14023 if (
auto *BE = dyn_cast<BlockExpr>(
E->getSubExpr()->
IgnoreParens()))
14025 BE->getBlockDecl()->setCanAvoidCopyToHeap();
14060 <<
Init->getSourceRange();
14076 diag::ext_in_class_initializer_float_type_cxx11)
14077 << DclT <<
Init->getSourceRange();
14079 diag::note_in_class_initializer_float_type_cxx11)
14082 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
14083 << DclT <<
Init->getSourceRange();
14086 Diag(
Init->getExprLoc(), diag::err_in_class_initializer_non_constant)
14087 <<
Init->getSourceRange();
14094 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
14095 << DclT <<
Init->getSourceRange()
14101 << DclT <<
Init->getSourceRange();
14135 if (!InitType.
isNull() &&
14153 if (InitializedFromParenListExpr) {
14154 assert(
DirectInit &&
"Call-style initializer must be direct init.");
14177 VarDecl *VD = dyn_cast<VarDecl>(
D);
14181 if (
auto *DD = dyn_cast<DecompositionDecl>(
D))
14182 for (
auto *BD : DD->bindings())
14183 BD->setInvalidDecl();
14197 diag::err_typecheck_decl_incomplete_type)) {
14204 diag::err_abstract_type_in_decl,
14219 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
14223 if (isa<DecompositionDecl>(RealDecl)) {
14224 Diag(Var->getLocation(), diag::err_decomp_decl_requires_init) << Var;
14225 Var->setInvalidDecl();
14239 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
14240 !Var->isThisDeclarationADemotedDefinition()) {
14241 if (Var->isStaticDataMember()) {
14246 Diag(Var->getLocation(),
14247 diag::err_constexpr_static_mem_var_requires_init)
14249 Var->setInvalidDecl();
14253 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
14254 Var->setInvalidDecl();
14261 if (!Var->isInvalidDecl() &&
14263 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
14264 bool HasConstExprDefaultConstructor =
false;
14265 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
14266 for (
auto *Ctor : RD->ctors()) {
14267 if (Ctor->isConstexpr() && Ctor->getNumParams() == 0 &&
14268 Ctor->getMethodQualifiers().getAddressSpace() ==
14270 HasConstExprDefaultConstructor =
true;
14274 if (!HasConstExprDefaultConstructor) {
14275 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
14276 Var->setInvalidDecl();
14282 if (!Var->isInvalidDecl() && Var->hasAttr<HLSLVkConstantIdAttr>()) {
14283 Diag(Var->getLocation(), diag::err_specialization_const);
14284 Var->setInvalidDecl();
14288 if (!Var->isInvalidDecl() && RealDecl->
hasAttr<LoaderUninitializedAttr>()) {
14289 if (Var->getStorageClass() ==
SC_Extern) {
14290 Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
14292 Var->setInvalidDecl();
14296 diag::err_typecheck_decl_incomplete_type)) {
14297 Var->setInvalidDecl();
14300 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
14301 if (!RD->hasTrivialDefaultConstructor()) {
14302 Diag(Var->getLocation(), diag::err_loader_uninitialized_trivial_ctor);
14303 Var->setInvalidDecl();
14313 Var->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion())
14320 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
14336 !Var->hasLinkage() && !Var->isInvalidDecl() &&
14338 diag::err_typecheck_decl_incomplete_type))
14339 Var->setInvalidDecl();
14344 diag::err_abstract_type_in_decl,
14346 Var->setInvalidDecl();
14349 Diag(Var->getLocation(), diag::warn_private_extern);
14350 Diag(Var->getLocation(), diag::note_private_extern);
14354 !Var->isInvalidDecl())
14365 if (!Var->isInvalidDecl()) {
14369 Var->getLocation(), ArrayT->getElementType(),
14370 diag::err_array_incomplete_or_sizeless_type))
14371 Var->setInvalidDecl();
14373 if (Var->getStorageClass() ==
SC_Static) {
14383 if (Var->isFirstDecl())
14385 diag::ext_typecheck_decl_incomplete_type,
14391 if (!Var->isInvalidDecl())
14399 if (Var->isConstexpr())
14400 Diag(Var->getLocation(), diag::err_constexpr_var_requires_const_init)
14403 Diag(Var->getLocation(),
14404 diag::err_typecheck_incomplete_array_needs_initializer);
14405 Var->setInvalidDecl();
14412 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
14413 << Var <<
SourceRange(Var->getLocation(), Var->getLocation());
14422 if (Var->isInvalidDecl())
14425 if (!Var->hasAttr<AliasAttr>()) {
14428 diag::err_typecheck_decl_incomplete_type)) {
14429 Var->setInvalidDecl();
14438 diag::err_abstract_type_in_decl,
14440 Var->setInvalidDecl();
14447 unsigned DiagID = diag::warn_default_init_const_unsafe;
14448 if (Var->getStorageDuration() ==
SD_Static ||
14449 Var->getStorageDuration() ==
SD_Thread)
14450 DiagID = diag::warn_default_init_const;
14453 diag::warn_cxx_compat_hack_fake_diagnostic_do_not_emit,
14454 Var->getLocation());
14456 Diag(Var->getLocation(), DiagID) <<
Type << EmitCppCompat;
14470 if (
const auto *CXXRecord =
14475 if (!CXXRecord->isPOD())
14520 }
else if (
Init.isInvalid()) {
14538 VarDecl *VD = dyn_cast<VarDecl>(
D);
14597 const char *PrevSpec;
14603 D.SetIdentifier(Ident, IdentLoc);
14604 D.takeAttributes(Attrs);
14609 cast<VarDecl>(Var)->setCXXForRangeDecl(
true);
14617 if (var->isInvalidDecl())
return;
14624 if (var->getTypeSourceInfo()->getType()->isBlockPointerType() &&
14626 Diag(var->getLocation(), diag::err_opencl_invalid_block_declaration)
14628 var->setInvalidDecl();
14636 var->hasLocalStorage()) {
14637 switch (var->getType().getObjCLifetime()) {
14650 if (var->hasLocalStorage() &&
14659 if (var->isThisDeclarationADefinition() &&
14660 var->getDeclContext()->getRedeclContext()->isFileContext() &&
14661 var->isExternallyVisible() && var->hasLinkage() &&
14662 !var->isInline() && !var->getDescribedVarTemplate() &&
14664 !isa<VarTemplatePartialSpecializationDecl>(var) &&
14666 !
getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
14667 var->getLocation())) {
14669 VarDecl *prev = var->getPreviousDecl();
14674 Diag(var->getLocation(), diag::warn_missing_variable_declarations) << var;
14675 Diag(var->getTypeSpecStartLoc(), diag::note_static_for_internal_linkage)
14681 std::optional<bool> CacheHasConstInit;
14682 const Expr *CacheCulprit =
nullptr;
14683 auto checkConstInit = [&]()
mutable {
14684 const Expr *
Init = var->getInit();
14685 if (
Init->isInstantiationDependent())
14688 if (!CacheHasConstInit)
14689 CacheHasConstInit = var->getInit()->isConstantInitializer(
14690 Context, var->getType()->isReferenceType(), &CacheCulprit);
14691 return *CacheHasConstInit;
14695 if (var->getType().isDestructedType()) {
14699 Diag(var->getLocation(), diag::err_thread_nontrivial_dtor);
14701 Diag(var->getLocation(), diag::note_use_thread_local);
14703 if (!checkConstInit()) {
14711 Diag(var->getLocation(), diag::note_use_thread_local);
14717 if (!var->getType()->isStructureType() && var->hasInit() &&
14718 isa<InitListExpr>(var->getInit())) {
14719 const auto *ILE = cast<InitListExpr>(var->getInit());
14720 unsigned NumInits = ILE->getNumInits();
14722 for (
unsigned I = 0; I < NumInits; ++I) {
14723 const auto *
Init = ILE->getInit(I);
14726 const auto *SL = dyn_cast<StringLiteral>(
Init->IgnoreImpCasts());
14730 unsigned NumConcat = SL->getNumConcatenated();
14734 if (NumConcat == 2 && !SL->getBeginLoc().isMacroID()) {
14735 bool OnlyOneMissingComma =
true;
14736 for (
unsigned J = I + 1; J < NumInits; ++J) {
14737 const auto *
Init = ILE->getInit(J);
14740 const auto *SLJ = dyn_cast<StringLiteral>(
Init->IgnoreImpCasts());
14741 if (!SLJ || SLJ->getNumConcatenated() > 1) {
14742 OnlyOneMissingComma =
false;
14747 if (OnlyOneMissingComma) {
14749 for (
unsigned i = 0; i < NumConcat - 1; ++i)
14753 Diag(SL->getStrTokenLoc(1),
14754 diag::warn_concatenated_literal_array_init)
14756 Diag(SL->getBeginLoc(),
14757 diag::note_concatenated_string_literal_silence);
14768 if (var->hasAttr<BlocksAttr>())
14772 bool GlobalStorage = var->hasGlobalStorage();
14773 bool IsGlobal = GlobalStorage && !var->isStaticLocal();
14775 bool HasConstInit =
true;
14778 Diag(var->getLocation(), diag::err_constexpr_var_requires_const_init)
14783 !
type->isDependentType() &&
Init && !
Init->isValueDependent() &&
14784 (GlobalStorage || var->isConstexpr() ||
14785 var->mightBeUsableInConstantExpressions(
Context))) {
14797 HasConstInit = checkConstInit();
14801 if (HasConstInit) {
14802 if (var->isStaticDataMember() && !var->isInline() &&
14803 var->getLexicalDeclContext()->isRecord() &&
14804 type->isIntegralOrEnumerationType()) {
14809 diag::ext_in_class_initializer_non_constant)
14810 <<
Init->getSourceRange();
14813 (void)var->checkForConstantInitialization(Notes);
14815 }
else if (CacheCulprit) {
14816 Notes.emplace_back(CacheCulprit->
getExprLoc(),
14817 PDiag(diag::note_invalid_subexpr_in_const_expr));
14822 HasConstInit = var->checkForConstantInitialization(Notes);
14825 if (HasConstInit) {
14827 }
else if (var->isConstexpr()) {
14831 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
14832 diag::note_invalid_subexpr_in_const_expr) {
14833 DiagLoc = Notes[0].first;
14836 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
14837 << var <<
Init->getSourceRange();
14838 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
14839 Diag(Notes[I].first, Notes[I].second);
14840 }
else if (GlobalStorage && var->hasAttr<ConstInitAttr>()) {
14841 auto *
Attr = var->getAttr<ConstInitAttr>();
14842 Diag(var->getLocation(), diag::err_require_constant_init_failed)
14843 <<
Init->getSourceRange();
14846 for (
auto &it : Notes)
14847 Diag(it.first, it.second);
14848 }
else if (var->isStaticDataMember() && !var->isInline() &&
14849 var->getLexicalDeclContext()->isRecord()) {
14850 Diag(var->getLocation(), diag::err_in_class_initializer_non_constant)
14851 <<
Init->getSourceRange();
14852 for (
auto &it : Notes)
14853 Diag(it.first, it.second);
14854 var->setInvalidDecl();
14855 }
else if (IsGlobal &&
14857 var->getLocation())) {
14866 if (!checkConstInit())
14867 Diag(var->getLocation(), diag::warn_global_constructor)
14868 <<
Init->getSourceRange();
14874 if (GlobalStorage && var->isThisDeclarationADefinition() &&
14880 std::optional<QualType::NonConstantStorageReason> Reason;
14881 if (HasConstInit &&
14882 !(Reason = var->getType().isNonConstantStorage(
Context,
true,
false))) {
14888 if (
const SectionAttr *SA = var->getAttr<SectionAttr>()) {
14892 }
else if (Stack->CurrentValue) {
14895 var->getType().isConstQualified()) {
14897 NonConstNonReferenceType) &&
14898 "This case should've already been handled elsewhere");
14899 Diag(var->getLocation(), diag::warn_section_msvc_compat)
14905 auto SectionName = Stack->CurrentValue->getString();
14906 var->addAttr(SectionAttr::CreateImplicit(
Context, SectionName,
14907 Stack->CurrentPragmaLocation,
14908 SectionAttr::Declspec_allocate));
14910 var->dropAttr<SectionAttr>();
14933 if (!
type->isDependentType())
14943 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
14954 !FD->
hasAttr<DLLExportStaticLocalAttr>() &&
14955 !FD->
hasAttr<DLLImportStaticLocalAttr>()) {
14964 auto *NewAttr = cast<InheritableAttr>(A->clone(
getASTContext()));
14965 NewAttr->setInherited(
true);
14967 }
else if (
Attr *A = FD->
getAttr<DLLExportStaticLocalAttr>()) {
14968 auto *NewAttr = DLLExportAttr::CreateImplicit(
getASTContext(), *A);
14969 NewAttr->setInherited(
true);
14974 if (!FD->
hasAttr<DLLExportAttr>())
14977 }
else if (
Attr *A = FD->
getAttr<DLLImportStaticLocalAttr>()) {
14978 auto *NewAttr = DLLImportAttr::CreateImplicit(
getASTContext(), *A);
14979 NewAttr->setInherited(
true);
15008 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
15016 VD->
addAttr(PragmaClangBSSSectionAttr::CreateImplicit(
15020 VD->
addAttr(PragmaClangDataSectionAttr::CreateImplicit(
15024 VD->
addAttr(PragmaClangRodataSectionAttr::CreateImplicit(
15028 VD->
addAttr(PragmaClangRelroSectionAttr::CreateImplicit(
15033 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
15034 for (
auto *BD : DD->bindings()) {
15039 CheckInvalidBuiltinCountedByRef(VD->
getInit(),
15062 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
15069 bool IsClassTemplateMember =
15070 isa<ClassTemplatePartialSpecializationDecl>(
Context) ||
15071 Context->getDescribedClassTemplate();
15074 IsClassTemplateMember
15075 ? diag::warn_attribute_dllimport_static_field_definition
15076 : diag::err_attribute_dllimport_static_field_definition);
15077 Diag(IA->getLocation(), diag::note_attribute);
15078 if (!IsClassTemplateMember)
15106 if (RetainAttr *
Attr = VD->
getAttr<RetainAttr>()) {
15121 if (VD->
isFileVarDecl() && !isa<VarTemplatePartialSpecializationDecl>(VD))
15126 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
15130 for (
const auto *I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
15132 if (!MagicValueExpr) {
15135 std::optional<llvm::APSInt> MagicValueInt;
15137 Diag(I->getRange().getBegin(),
15138 diag::err_type_tag_for_datatype_not_ice)
15142 if (MagicValueInt->getActiveBits() > 64) {
15143 Diag(I->getRange().getBegin(),
15144 diag::err_type_tag_for_datatype_too_large)
15148 uint64_t MagicValue = MagicValueInt->getZExtValue();
15151 I->getMatchingCType(),
15152 I->getLayoutCompatible(),
15153 I->getMustBeNull());
15158 auto *VD = dyn_cast<VarDecl>(DD);
15159 return VD && !VD->getType()->hasAutoForTrailingReturnType();
15171 bool DiagnosedMultipleDecomps =
false;
15173 bool DiagnosedNonDeducedAuto =
false;
15175 for (
Decl *
D : Group) {
15180 if (
auto *VD = dyn_cast<VarDecl>(
D);
15181 LangOpts.OpenMP && VD && VD->hasAttr<OMPDeclareTargetDeclAttr>() &&
15182 VD->hasGlobalStorage())
15186 if (
auto *DD = dyn_cast<DeclaratorDecl>(
D)) {
15187 if (!FirstDeclaratorInGroup)
15188 FirstDeclaratorInGroup = DD;
15189 if (!FirstDecompDeclaratorInGroup)
15190 FirstDecompDeclaratorInGroup = dyn_cast<DecompositionDecl>(
D);
15193 FirstNonDeducedAutoInGroup = DD;
15195 if (FirstDeclaratorInGroup != DD) {
15198 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
15200 diag::err_decomp_decl_not_alone)
15202 << DD->getSourceRange();
15203 DiagnosedMultipleDecomps =
true;
15209 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
15211 diag::err_auto_non_deduced_not_alone)
15212 << FirstNonDeducedAutoInGroup->
getType()
15215 << DD->getSourceRange();
15216 DiagnosedNonDeducedAuto =
true;
15221 Decls.push_back(
D);
15227 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
15241 if (Group.size() > 1) {
15243 VarDecl *DeducedDecl =
nullptr;
15244 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
15245 VarDecl *
D = dyn_cast<VarDecl>(Group[i]);
15248 DeducedType *DT =
D->getType()->getContainedDeducedType();
15255 auto *AT = dyn_cast<AutoType>(DT);
15257 diag::err_auto_different_deductions)
15258 << (AT ? (
unsigned)AT->getKeyword() : 3) << Deduced
15260 <<
D->getDeclName();
15283 if (Group.empty() || !Group[0])
15287 Group[0]->getLocation()) &&
15289 Group[0]->getLocation()))
15292 if (Group.size() >= 2) {
15300 Decl *MaybeTagDecl = Group[0];
15301 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
15302 Group = Group.slice(1);
15319 if (
D.getCXXScopeSpec().isSet()) {
15320 Diag(
D.getIdentifierLoc(), diag::err_qualified_param_declarator)
15321 <<
D.getCXXScopeSpec().getRange();
15337 Diag(
D.getIdentifierLoc(), diag::err_bad_parameter_name)
15344 Diag(
D.getIdentifierLoc(), diag::err_bad_parameter_name_template_id);
15355 const auto *VD = dyn_cast<ValueDecl>(
D);
15369 unsigned Kind = TD->isEnum() ? 2 : TD->isUnion() ? 1 : 0;
15371 Diag(TD->getLocation(), diag::note_declared_at);
15377 if (!ExplicitThisLoc.
isValid())
15380 "explicit parameter in non-cplusplus mode");
15382 S.
Diag(ExplicitThisLoc, diag::err_cxx20_deducing_this)
15383 <<
P->getSourceRange();
15387 if (
P->isParameterPack()) {
15388 S.
Diag(
P->getBeginLoc(), diag::err_explicit_object_parameter_pack)
15389 <<
P->getSourceRange();
15392 P->setExplicitObjectParameterLoc(ExplicitThisLoc);
15394 LSI->ExplicitObjectParameter =
P;
15417 ? diag::ext_register_storage_class
15418 : diag::warn_deprecated_register)
15422 D.getNumTypeObjects() == 0) {
15424 diag::err_invalid_storage_class_in_func_decl)
15426 D.getMutableDeclSpec().ClearStorageClassSpecs();
15433 diag::err_invalid_storage_class_in_func_decl);
15434 D.getMutableDeclSpec().ClearStorageClassSpecs();
15445 << 0 <<
static_cast<int>(
D.getDeclSpec().getConstexprSpecifier());
15458 RedeclarationKind::ForVisibleRedeclaration);
15466 PrevDecl =
nullptr;
15468 if (PrevDecl && S->isDeclScope(PrevDecl)) {
15469 Diag(
D.getIdentifierLoc(), diag::err_param_redefinition) << II;
15473 D.SetIdentifier(
nullptr,
D.getIdentifierLoc());
15474 D.setInvalidType(
true);
15484 D.getIdentifierLoc(), II, parmDeclType, TInfo, SC);
15486 if (
D.isInvalidType())
15487 New->setInvalidDecl();
15491 assert(S->isFunctionPrototypeScope());
15492 assert(S->getFunctionPrototypeDepth() >= 1);
15493 New->setScopeInfo(S->getFunctionPrototypeDepth() - 1,
15494 S->getNextFunctionPrototypeIndex());
15505 if (
D.getDeclSpec().isModulePrivateSpecified())
15506 Diag(
New->getLocation(), diag::err_module_private_local)
15507 << 1 <<
New <<
SourceRange(
D.getDeclSpec().getModulePrivateSpecLoc())
15510 if (
New->hasAttr<BlocksAttr>()) {
15511 Diag(
New->getLocation(), diag::err_block_on_nonlocal);
15542 !
Parameter->getIdentifier()->isPlaceholder()) {
15543 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
15551 if (
LangOpts.NumLargeByValueCopy == 0)
15558 if (Size >
LangOpts.NumLargeByValueCopy)
15569 if (Size >
LangOpts.NumLargeByValueCopy)
15590 if (!
T.isConstQualified()) {
15594 NameLoc, diag::err_arc_array_param_no_ownership,
T,
false));
15596 Diag(NameLoc, diag::err_arc_array_param_no_ownership)
15608 TSInfo, SC,
nullptr);
15613 if (
New->isParameterPack())
15615 CSI->LocalPacks.push_back(
New);
15617 if (
New->getType().hasNonTrivialToPrimitiveDestructCUnion() ||
15618 New->getType().hasNonTrivialToPrimitiveCopyCUnion())
15629 diag::err_object_cannot_be_passed_returned_by_value) << 1 <<
T
15636 if (
T.getPointerAuth()) {
15637 Diag(NameLoc, diag::err_ptrauth_qualifier_invalid) <<
T << 1;
15638 New->setInvalidDecl();
15654 Diag(NameLoc, diag::err_arg_with_address_space);
15655 New->setInvalidDecl();
15660 PPC().CheckPPCMMAType(
New->getOriginalType(),
New->getLocation())) {
15661 New->setInvalidDecl();
15682 for (
int i = FTI.
NumParams; i != 0; ) {
15687 llvm::raw_svector_ostream(Code)
15698 const char* PrevSpec;
15719 assert(
D.isFunctionDeclarator() &&
"Not a function declarator!");
15730 if (
LangOpts.OpenMP &&
OpenMP().isInOpenMPDeclareVariantScope())
15732 ParentScope,
D, TemplateParameterLists, Bases);
15738 if (!Bases.empty())
15755 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
15758 PossiblePrototype = Prev;
15776 if (isa<CXXMethodDecl>(FD))
15782 if (II->isStr(
"main") || II->isStr(
"efi_main"))
15801 if (FD->
hasAttr<DeviceKernelAttr>())
15850 bool DefinitionVisible =
false;
15854 Definition->getNumTemplateParameterLists())) {
15857 if (!DefinitionVisible) {
15858 if (
auto *TD =
Definition->getDescribedFunctionTemplate())
15872 Diag(
Definition->getLocation(), diag::note_previous_definition);
15881 LSI->
Lambda = LambdaClass;
15920 for (
const auto &
C : LambdaClass->
captures()) {
15921 if (
C.capturesVariable()) {
15925 const bool ByRef =
C.getCaptureKind() ==
LCK_ByRef;
15927 true,
C.getLocation(),
15928 C.isPackExpansion()
15930 I->getType(),
false);
15932 }
else if (
C.capturesThis()) {
15958 FD = FunTmpl->getTemplatedDecl();
15960 FD = cast<FunctionDecl>(
D);
15969 if (
const auto *
Attr = FD->
getAttr<AliasAttr>()) {
15974 if (
const auto *
Attr = FD->
getAttr<IFuncAttr>()) {
15979 if (
const auto *
Attr = FD->
getAttr<TargetVersionAttr>()) {
15982 !
Attr->isDefaultVersion()) {
15991 if (
auto *Ctor = dyn_cast<CXXConstructorDecl>(FD)) {
15993 Ctor->isDefaultConstructor() &&
16036 "There should be an active template instantiation on the stack "
16037 "when instantiating a generic lambda!");
16063 diag::err_func_def_incomplete_result) ||
16065 diag::err_abstract_type_in_decl,
16081 auto *NonParmDecl = dyn_cast<NamedDecl>(NPD);
16084 assert(!isa<ParmVarDecl>(NonParmDecl) &&
16085 "parameters should not be in newly created FD yet");
16088 if (NonParmDecl->getDeclName())
16093 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
16094 for (
auto *EI : ED->enumerators())
16102 Param->setOwningFunction(FD);
16105 if (Param->getIdentifier() && FnBodyScope) {
16134 assert(!FD->
hasAttr<DLLExportAttr>());
16135 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
16160 if (
auto *TD = dyn_cast<FunctionTemplateDecl>(FD))
16161 FD = TD->getTemplatedDecl();
16162 if (FD && FD->
hasAttr<OptimizeNoneAttr>()) {
16174 for (
unsigned I = 0,
E =
Scope->Returns.size(); I !=
E; ++I) {
16175 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
16176 if (!NRVOCandidate->isNRVOVariable()) {
16177 Diag(Returns[I]->getRetValue()->getExprLoc(),
16178 diag::warn_not_eliding_copy_on_return);
16187 if (
D.getDeclSpec().hasConstexprSpecifier())
16192 if (
D.getDeclSpec().hasAutoTypeSpec()) {
16195 if (
D.getNumTypeObjects()) {
16196 const auto &Outer =
D.getTypeObject(
D.getNumTypeObjects() - 1);
16198 Outer.Fun.hasTrailingReturnType()) {
16216 if (FD->isConstexpr())
16221 if (FD->getReturnType()->getContainedDeducedType())
16231 FD->setHasSkippedBody();
16249 bool IsLambda =
false;
16253 llvm::DenseMap<const BlockDecl *, bool> EscapeInfo;
16255 auto IsOrNestedInEscapingBlock = [&](
const BlockDecl *BD) {
16256 auto [It, Inserted] = EscapeInfo.try_emplace(BD);
16270 return It->second = R;
16275 for (
const std::pair<SourceLocation, const BlockDecl *> &
P :
16277 if (IsOrNestedInEscapingBlock(
P.second))
16278 S.
Diag(
P.first, diag::warn_implicitly_retains_self)
16283 return isa<CXXMethodDecl>(FD) && FD->
param_empty() &&
16293 methodHasName(FD,
"get_return_object_on_allocation_failure");
16303 if (!FD->
hasAttr<CoroWrapperAttr>())
16308 bool RetainFunctionScopeInfo) {
16335 SYCLKernelEntryPointAttr *SKEPAttr =
16336 FD->
getAttr<SYCLKernelEntryPointAttr>();
16338 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16340 SKEPAttr->setInvalidAttr();
16342 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16344 SKEPAttr->setInvalidAttr();
16346 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16348 SKEPAttr->setInvalidAttr();
16349 }
else if (Body && isa<CXXTryStmt>(Body)) {
16350 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16352 SKEPAttr->setInvalidAttr();
16355 if (Body && !FD->
isTemplated() && !SKEPAttr->isInvalidAttr()) {
16365 SYCLExternalAttr *SEAttr = FD->
getAttr<SYCLExternalAttr>();
16367 Diag(SEAttr->getLocation(),
16368 diag::err_sycl_external_invalid_deleted_function)
16398 Expr *Dummy =
nullptr;
16409 if (LSI->HasImplicitReturnType) {
16416 LSI->ReturnType.isNull() ?
Context.
VoidTy : LSI->ReturnType;
16421 Proto->getExtProtoInfo()));
16454 dyn_cast<CXXDestructorDecl>(FD))
16474 if (PossiblePrototype) {
16478 TypeLoc TL = TI->getTypeLoc();
16481 diag::note_declaration_not_a_prototype)
16484 FTL.getRParenLoc(),
"void")
16492 if (LocInfo.first.isInvalid())
16496 StringRef Buffer =
SM.getBufferData(LocInfo.first, &
Invalid);
16500 if (LocInfo.second > Buffer.size())
16503 const char *LexStart = Buffer.data() + LocInfo.second;
16504 StringRef StartTok(LexStart, Buffer.size() - LocInfo.second);
16506 return StartTok.consume_front(
"const") &&
16508 StartTok.starts_with(
"/*") || StartTok.starts_with(
"//"));
16511 auto findBeginLoc = [&]() {
16527 diag::note_static_for_internal_linkage)
16538 if (!PossiblePrototype)
16584 if (PossiblePrototype)
16586 diag::warn_non_prototype_changes_behavior)
16593 if (
const auto *CmpndBody = dyn_cast<CompoundStmt>(Body))
16594 if (!CmpndBody->body_empty())
16595 Diag(CmpndBody->body_front()->getBeginLoc(),
16596 diag::warn_dispatch_body_ignored);
16598 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
16623 "Function parsing confused");
16624 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
16636 << MD->getSelector().getAsString();
16641 bool isDesignated =
16642 MD->isDesignatedInitializerForTheInterface(&InitMethod);
16643 assert(isDesignated && InitMethod);
16644 (void)isDesignated;
16647 auto IFace = MD->getClassInterface();
16650 auto SuperD = IFace->getSuperClass();
16660 diag::warn_objc_designated_init_missing_super_call);
16662 diag::note_objc_designated_init_marked_here);
16670 diag::warn_objc_secondary_init_missing_init_call);
16686 "This should only be set for ObjC methods, which should have been "
16687 "handled in the block above.");
16694 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
16702 if (!
Destructor->getParent()->isDependentType())
16720 ActivePolicy = &WP;
16723 if (!IsInstantiation && FD &&
16729 if (FD && FD->
hasAttr<NakedAttr>()) {
16733 bool RegisterVariables =
false;
16734 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
16735 for (
const auto *
Decl : DS->decls()) {
16736 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
16737 RegisterVariables =
16738 Var->hasAttr<AsmLabelAttr>() && !Var->hasInit();
16739 if (!RegisterVariables)
16744 if (RegisterVariables)
16746 if (!isa<AsmStmt>(S) && !isa<NullStmt>(S)) {
16747 Diag(S->getBeginLoc(), diag::err_non_asm_stmt_in_naked_function);
16748 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
16757 "Leftover temporaries in function");
16759 "Unaccounted cleanups in function");
16761 "Leftover expressions for odr-use checking");
16770 if (!IsInstantiation)
16773 if (!RetainFunctionScopeInfo)
16802 D = TD->getTemplatedDecl();
16815 "Implicit function declarations aren't allowed in this language mode");
16822 Scope *BlockScope = S;
16830 Scope *ContextScope = BlockScope;
16834 ContextScope = ContextScope->
getParent();
16850 if (!isa<FunctionDecl>(ExternCPrev) ||
16852 cast<FunctionDecl>(ExternCPrev)->getType(),
16854 Diag(
Loc, diag::ext_use_out_of_scope_declaration)
16857 return ExternCPrev;
16863 if (II.
getName().starts_with(
"__builtin_"))
16864 diag_id = diag::warn_builtin_unknown;
16867 diag_id = diag::ext_implicit_function_decl_c99;
16869 diag_id = diag::warn_implicit_function_decl;
16877 if (S && !ExternCPrev &&
16900 return ExternCPrev;
16910 assert(!Error &&
"Error setting up implicit decl!");
16932 D.SetIdentifier(&II,
Loc);
16953 bool IsNothrow =
false;
16965 if (!IsNothrow && !FD->
hasAttr<ReturnsNonNullAttr>() &&
16983 if (!FD->
hasAttr<AllocSizeAttr>()) {
16984 FD->
addAttr(AllocSizeAttr::CreateImplicit(
16995 if (AlignmentParam && !FD->
hasAttr<AllocAlignAttr>()) {
16996 FD->
addAttr(AllocAlignAttr::CreateImplicit(
17020 unsigned FormatIdx;
17023 if (!FD->
hasAttr<FormatAttr>()) {
17024 const char *fmt =
"printf";
17026 if (FormatIdx < NumParams &&
17032 HasVAListArg ? 0 : FormatIdx+2,
17038 if (!FD->
hasAttr<FormatAttr>())
17042 HasVAListArg ? 0 : FormatIdx+2,
17048 if (!FD->
hasAttr<CallbackAttr>() &&
17050 FD->
addAttr(CallbackAttr::CreateImplicit(
17056 bool NoExceptions =
17058 bool ConstWithoutErrnoAndExceptions =
17060 bool ConstWithoutExceptions =
17062 if (!FD->
hasAttr<ConstAttr>() &&
17063 (ConstWithoutErrnoAndExceptions || ConstWithoutExceptions) &&
17064 (!ConstWithoutErrnoAndExceptions ||
17066 (!ConstWithoutExceptions || NoExceptions))
17073 if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
17075 switch (BuiltinID) {
17076 case Builtin::BI__builtin_fma:
17077 case Builtin::BI__builtin_fmaf:
17078 case Builtin::BI__builtin_fmal:
17079 case Builtin::BIfma:
17080 case Builtin::BIfmaf:
17081 case Builtin::BIfmal:
17090 !FD->
hasAttr<ReturnsTwiceAttr>())
17100 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
17112 switch (BuiltinID) {
17113 case Builtin::BImemalign:
17114 case Builtin::BIaligned_alloc:
17115 if (!FD->
hasAttr<AllocAlignAttr>())
17124 switch (BuiltinID) {
17125 case Builtin::BIcalloc:
17126 FD->
addAttr(AllocSizeAttr::CreateImplicit(
17129 case Builtin::BImemalign:
17130 case Builtin::BIaligned_alloc:
17131 case Builtin::BIrealloc:
17135 case Builtin::BImalloc:
17155 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
17171 if (Name->isStr(
"asprintf") || Name->isStr(
"vasprintf")) {
17174 if (!FD->
hasAttr<FormatAttr>())
17177 Name->isStr(
"vasprintf") ? 0 : 3,
17181 if (Name->isStr(
"__CFStringMakeConstantString")) {
17184 if (!FD->
hasAttr<FormatArgAttr>())
17192 assert(
D.getIdentifier() &&
"Wrong callback for declspec without declarator");
17193 assert(!
T.isNull() &&
"GetTypeForDeclarator() returned null type");
17196 assert(
D.isInvalidType() &&
"no declarator info for valid type");
17203 D.getIdentifierLoc(),
D.getIdentifier(), TInfo);
17206 if (
D.isInvalidType()) {
17211 if (
D.getDeclSpec().isModulePrivateSpecified()) {
17215 <<
SourceRange(
D.getDeclSpec().getModulePrivateSpecLoc())
17217 D.getDeclSpec().getModulePrivateSpecLoc());
17228 switch (
D.getDeclSpec().getTypeSpecType()) {
17234 TagDecl *tagFromDeclSpec = cast<TagDecl>(
D.getDeclSpec().getRepAsDecl());
17261 Diag(UnderlyingLoc, diag::warn_atomic_stripped_in_enum);
17264 std::optional<unsigned> QualSelect;
17266 QualSelect = diag::CVQualList::Both;
17268 QualSelect = diag::CVQualList::Const;
17270 QualSelect = diag::CVQualList::Volatile;
17273 Diag(UnderlyingLoc, diag::warn_cv_stripped_in_enum) << *QualSelect;
17275 T =
T.getAtomicUnqualifiedType();
17280 if (BT->isInteger())
17283 return Diag(UnderlyingLoc, diag::err_enum_invalid_underlying)
17288 QualType EnumUnderlyingTy,
bool IsFixed,
17290 if (IsScoped != Prev->
isScoped()) {
17291 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
17297 if (IsFixed && Prev->
isFixed()) {
17303 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
17309 }
else if (IsFixed != Prev->
isFixed()) {
17310 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
17332 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
17347 if (isa<TypedefDecl>(PrevDecl))
17349 else if (isa<TypeAliasDecl>(PrevDecl))
17351 else if (isa<ClassTemplateDecl>(PrevDecl))
17353 else if (isa<TypeAliasTemplateDecl>(PrevDecl))
17355 else if (isa<TemplateTemplateParmDecl>(PrevDecl))
17368 llvm_unreachable(
"invalid TTK");
17407 if (IsIgnoredLoc(NewTagLoc))
17410 auto IsIgnored = [&](
const TagDecl *Tag) {
17411 return IsIgnoredLoc(Tag->getLocation());
17428 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
17436 if (isDefinition) {
17444 bool previousMismatch =
false;
17446 if (I->getTagKind() !=
NewTag) {
17451 if (!previousMismatch) {
17452 previousMismatch =
true;
17453 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
17457 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
17470 if (PrevDef && IsIgnored(PrevDef))
17474 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
17481 Diag(NewTagLoc, diag::note_struct_class_suggestion)
17511 if (!Namespace || Namespace->isAnonymousNamespace())
17514 Namespaces.push_back(II);
17517 if (Lookup == Namespace)
17524 llvm::raw_svector_ostream OS(Insertion);
17527 std::reverse(Namespaces.begin(), Namespaces.end());
17528 for (
auto *II : Namespaces)
17529 OS << II->getName() <<
"::";
17542 if (OldDC->
Equals(NewDC))
17561 bool ScopedEnumUsesClassTag,
TypeResult UnderlyingType,
17562 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
17567 "Nameless record must be a definition!");
17572 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
17575 bool isMemberSpecialization =
false;
17576 bool IsInjectedClassName =
false;
17582 if (TemplateParameterLists.size() > 0 ||
17586 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
17603 !isMemberSpecialization)
17604 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
17607 if (TemplateParams) {
17609 Diag(KWLoc, diag::err_enum_template);
17613 if (TemplateParams->
size() > 0) {
17622 S, TagSpec, TUK, KWLoc, SS, Name, NameLoc, Attrs, TemplateParams,
17623 AS, ModulePrivateLoc,
17625 TemplateParameterLists.data(), SkipBody);
17631 isMemberSpecialization =
true;
17635 if (!TemplateParameterLists.empty() && isMemberSpecialization &&
17654 ScopedEnum ?
SourceRange(KWLoc, ScopedEnumKWLoc) : KWLoc);
17655 assert(ScopedEnum || !ScopedEnumUsesClassTag);
17656 Diag(KWLoc, diag::note_enum_friend)
17657 << (ScopedEnum + ScopedEnumUsesClassTag);
17663 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
17664 bool IsFixed = !UnderlyingType.
isUnset() || ScopedEnum;
17667 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum)) {
17671 }
else if (UnderlyingType.
get()) {
17679 EnumUnderlying = TI;
17697 if (
TypeSourceInfo *TI = dyn_cast<TypeSourceInfo *>(EnumUnderlying);
17698 TI && TI->
getType()->isAtomicType())
17713 bool isStdBadAlloc =
false;
17714 bool isStdAlignValT =
false;
17718 Redecl = RedeclarationKind::NotForRedeclaration;
17723 auto createTagFromNewDecl = [&]() ->
TagDecl * {
17733 ScopedEnum, ScopedEnumUsesClassTag, IsFixed);
17737 if (EnumUnderlying) {
17739 if (
TypeSourceInfo *TI = dyn_cast<TypeSourceInfo *>(EnumUnderlying))
17766 RD->addAttr(PackedAttr::CreateImplicit(
Context));
17782 goto CreateNewDecl;
17790 IsDependent =
true;
17819 if (
Previous.wasNotFoundInCurrentInstantiation() &&
17821 IsDependent =
true;
17826 Diag(NameLoc, diag::err_not_tag_in_scope)
17827 << Kind << Name << DC << SS.
getRange();
17830 goto CreateNewDecl;
17878 bool FriendSawTagOutsideEnclosingNamespace =
false;
17885 FriendSawTagOutsideEnclosingNamespace =
true;
17894 if (
Previous.isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
17896 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
17910 while (isa<RecordDecl, EnumDecl, ObjCContainerDecl>(SearchDC))
17916 while (isa<ObjCContainerDecl>(SearchDC))
17922 while (isa<ObjCContainerDecl>(SearchDC))
17927 Previous.getFoundDecl()->isTemplateParameter()) {
17936 if (Name->isStr(
"bad_alloc")) {
17938 isStdBadAlloc =
true;
17945 }
else if (Name->isStr(
"align_val_t")) {
17946 isStdAlignValT =
true;
17958 IsTemplateParamOrArg)) {
17959 if (
Invalid)
goto CreateNewDecl;
18042 if (
TagDecl *Tag = TD->getUnderlyingType()->getAsTagDecl()) {
18043 if (Tag->getDeclName() == Name &&
18044 Tag->getDeclContext()->getRedeclContext()
18045 ->Equals(TD->getDeclContext()->getRedeclContext())) {
18052 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(PrevDecl);
18054 RD->isInjectedClassName()) {
18057 PrevDecl = cast<TagDecl>(RD->getDeclContext());
18061 IsInjectedClassName =
true;
18068 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
18069 auto *OldTag = dyn_cast<TagDecl>(PrevDecl);
18072 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
18074 *
this, OldTag->getDeclContext(), SearchDC))) {
18075 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
18076 Diag(Shadow->getTargetDecl()->getLocation(),
18077 diag::note_using_decl_target);
18078 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl)
18082 goto CreateNewDecl;
18086 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
18092 SS.
isNotEmpty() || isMemberSpecialization)) {
18098 bool SafeToContinue =
18101 if (SafeToContinue)
18102 Diag(KWLoc, diag::err_use_with_wrong_tag)
18105 PrevTagDecl->getKindName());
18107 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
18108 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
18110 if (SafeToContinue)
18111 Kind = PrevTagDecl->getTagKind();
18122 const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
18124 return PrevTagDecl;
18128 dyn_cast_if_present<TypeSourceInfo *>(EnumUnderlying))
18129 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
18130 else if (
const Type *
T =
18131 dyn_cast_if_present<const Type *>(EnumUnderlying))
18138 ScopedEnum, EnumUnderlyingTy,
18139 IsFixed, PrevEnum))
18148 S->isDeclScope(PrevDecl)) {
18149 Diag(NameLoc, diag::ext_member_redeclared);
18150 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
18157 if (!Attrs.
empty()) {
18161 (PrevTagDecl->getFriendObjectKind() ==
18174 return PrevTagDecl;
18179 return PrevTagDecl;
18188 if (Def->isBeingDefined()) {
18189 Diag(NameLoc, diag::err_nested_redefinition) << Name;
18190 Diag(PrevTagDecl->getLocation(),
18191 diag::note_previous_definition);
18199 bool IsExplicitSpecializationAfterInstantiation =
false;
18200 if (isMemberSpecialization) {
18202 IsExplicitSpecializationAfterInstantiation =
18203 RD->getTemplateSpecializationKind() !=
18205 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
18206 IsExplicitSpecializationAfterInstantiation =
18207 ED->getTemplateSpecializationKind() !=
18216 bool HiddenDefVisible =
false;
18230 SkipBody->
New = createTagFromNewDecl();
18239 if (!HiddenDefVisible && Hidden)
18244 }
else if (!IsExplicitSpecializationAfterInstantiation) {
18248 S->containedInPrototypeScope())
18249 Diag(NameLoc, diag::warn_redefinition_in_param_list)
18252 Diag(NameLoc, diag::err_redefinition) << Name;
18254 NameLoc.
isValid() ? NameLoc : KWLoc);
18273 SearchDC = PrevTagDecl->getDeclContext();
18301 Diag(NameLoc, diag::err_tag_reference_non_tag)
18302 << PrevDecl << NTK << Kind;
18308 SS.
isNotEmpty() || isMemberSpecialization)) {
18314 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
18320 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
18322 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
18323 Diag(NameLoc, diag::err_tag_definition_of_typedef)
18324 << Name << Kind << TND->getUnderlyingType();
18332 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
18348 PrevDecl = cast<TagDecl>(
Previous.getFoundDecl());
18364 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
18365 ScopedEnumUsesClassTag, IsFixed);
18373 if (IsFixed && cast<EnumDecl>(
New)->isFixed()) {
18377 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
18378 Diag(
Loc, diag::ext_forward_ref_enum_def)
18382 unsigned DiagID = diag::ext_forward_ref_enum;
18384 DiagID = diag::ext_ms_forward_ref_enum;
18386 DiagID = diag::err_forward_ref_enum;
18391 if (EnumUnderlying) {
18393 if (
TypeSourceInfo *TI = dyn_cast<TypeSourceInfo *>(EnumUnderlying))
18401 assert(ED->
isComplete() &&
"enum with type should be complete");
18411 cast_or_null<CXXRecordDecl>(PrevDecl));
18417 cast_or_null<RecordDecl>(PrevDecl));
18423 Diag(
New->getLocation(), diag::ext_type_defined_in_offsetof)
18429 (IsTypeSpecifier || IsTemplateParamOrArg) &&
18431 Diag(
New->getLocation(), diag::err_type_defined_in_type_specifier)
18438 Diag(
New->getLocation(), diag::err_type_defined_in_enum)
18451 isMemberSpecialization))
18455 if (TemplateParameterLists.size() > 0) {
18456 New->setTemplateParameterListsInfo(
Context, TemplateParameterLists);
18475 RD->addAttr(PackedAttr::CreateImplicit(
Context));
18481 if (ModulePrivateLoc.
isValid()) {
18482 if (isMemberSpecialization)
18483 Diag(
New->getLocation(), diag::err_module_private_specialization)
18490 New->setModulePrivate();
18510 Diag(
Loc, diag::err_type_defined_in_param_type)
18516 }
else if (!PrevDecl) {
18520 Diag(
Loc, diag::warn_decl_in_param_list)
18526 New->setInvalidDecl();
18548 New->startDefinition();
18550 New->setCompleteDefinition();
18551 New->demoteThisDefinitionToDeclaration();
18579 if (!
New->isInvalidDecl() &&
18580 New->getDeclContext()->getRedeclContext()->isTranslationUnit() &&
18587 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(
New)) {
18600 if (isMemberSpecialization && !
New->isInvalidDecl())
18607 if (
New->isBeingDefined())
18608 if (
auto RD = dyn_cast<RecordDecl>(
New))
18609 RD->completeDefinition();
18611 }
else if (SkipBody && SkipBody->
ShouldSkip) {
18620 TagDecl *Tag = cast<TagDecl>(TagD);
18652 if (!
Record->getIdentifier())
18660 IsFinalSpelledSealed
18661 ? FinalAttr::Keyword_sealed
18662 : FinalAttr::Keyword_final));
18665 if (TriviallyRelocatable.
isValid())
18667 TriviallyRelocatableAttr::Create(
Context, TriviallyRelocatable));
18670 Record->addAttr(ReplaceableAttr::Create(
Context, Replaceable));
18687 "Broken injected-class-name");
18693 TagDecl *Tag = cast<TagDecl>(TagD);
18694 Tag->setBraceRange(BraceRange);
18697 if (Tag->isBeingDefined()) {
18698 assert(Tag->isInvalidDecl() &&
"We should already have completed it");
18699 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
18700 RD->completeDefinition();
18703 if (
auto *RD = dyn_cast<CXXRecordDecl>(Tag)) {
18705 if (RD->hasAttr<SYCLSpecialClassAttr>()) {
18706 auto *Def = RD->getDefinition();
18707 assert(Def &&
"The record is expected to have a completed definition");
18708 unsigned NumInitMethods = 0;
18709 for (
auto *
Method : Def->methods()) {
18710 if (!
Method->getIdentifier())
18712 if (
Method->getName() ==
"__init")
18715 if (NumInitMethods > 1 || !Def->hasInitMethod())
18716 Diag(RD->getLocation(), diag::err_sycl_special_type_num_init_method);
18733 Tag->getDeclContext()->isFileContext())
18734 Tag->setTopLevelDeclInObjCContainer();
18737 if (!Tag->isInvalidDecl())
18748 const RecordDecl *RD = dyn_cast<RecordDecl>(Tag);
18752 if (llvm::any_of(RD->
fields(),
18753 [](
const FieldDecl *FD) { return FD->isBitField(); }))
18754 Diag(BraceRange.
getBegin(), diag::warn_pragma_align_not_xl_compatible);
18760 TagDecl *Tag = cast<TagDecl>(TagD);
18761 Tag->setInvalidDecl();
18764 if (Tag->isBeingDefined()) {
18765 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
18766 RD->completeDefinition();
18779 QualType FieldTy,
bool IsMsStruct,
18790 diag::err_field_incomplete_or_sizeless))
18793 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
18795 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
18805 llvm::APSInt
Value;
18810 BitWidth = ICE.
get();
18813 if (
Value == 0 && FieldName)
18814 return Diag(FieldLoc, diag::err_bitfield_has_zero_width)
18817 if (
Value.isSigned() &&
Value.isNegative()) {
18819 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
18821 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
18828 return Diag(FieldLoc, diag::err_bitfield_too_wide)
18835 bool BitfieldIsOverwide =
Value.ugt(TypeWidth);
18839 bool CStdConstraintViolation =
18841 bool MSBitfieldViolation =
18842 Value.ugt(TypeStorageSize) &&
18844 if (CStdConstraintViolation || MSBitfieldViolation) {
18845 unsigned DiagWidth =
18846 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
18847 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
18849 << !CStdConstraintViolation << DiagWidth;
18855 if (BitfieldIsOverwide && !FieldTy->
isBooleanType() && FieldName) {
18856 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
18862 if (isa<ConstantExpr>(BitWidth))
18880 if (
D.isDecompositionDeclarator()) {
18889 if (II)
Loc =
D.getIdentifierLoc();
18898 D.setInvalidType();
18906 if (
D.getDeclSpec().isInlineSpecified())
18907 Diag(
D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
18909 if (
DeclSpec::TSCS TSCS =
D.getDeclSpec().getThreadStorageClassSpec())
18910 Diag(
D.getDeclSpec().getThreadStorageClassSpecLoc(),
18911 diag::err_invalid_thread)
18917 RedeclarationKind::ForVisibleRedeclaration);
18919 switch (
Previous.getResultKind()) {
18926 PrevDecl =
Previous.getRepresentativeDecl();
18940 PrevDecl =
nullptr;
18944 PrevDecl =
nullptr;
18951 TSSL, AS, PrevDecl, &
D);
18954 Record->setInvalidDecl();
18956 if (
D.getDeclSpec().isModulePrivateSpecified())
18973 bool Mutable,
Expr *BitWidth,
18979 bool InvalidDecl =
false;
18980 if (
D) InvalidDecl =
D->isInvalidType();
18985 InvalidDecl =
true;
18991 bool isIncomplete =
18995 diag::err_field_incomplete_or_sizeless);
18996 if (isIncomplete) {
18998 Record->setInvalidDecl();
18999 InvalidDecl =
true;
19004 Record->setInvalidDecl();
19005 InvalidDecl =
true;
19013 Diag(
Loc, diag::err_field_with_address_space);
19014 Record->setInvalidDecl();
19015 InvalidDecl =
true;
19023 Diag(
Loc, diag::err_opencl_type_struct_or_union_field) <<
T;
19024 Record->setInvalidDecl();
19025 InvalidDecl =
true;
19030 "__cl_clang_bitfields",
LangOpts)) {
19031 Diag(
Loc, diag::err_opencl_bitfields);
19032 InvalidDecl =
true;
19038 T.hasQualifiers()) {
19039 InvalidDecl =
true;
19040 Diag(
Loc, diag::err_anon_bitfield_qualifiers);
19047 TInfo,
T,
Loc, diag::err_typecheck_field_variable_size))
19048 InvalidDecl =
true;
19053 diag::err_abstract_type_in_decl,
19055 InvalidDecl =
true;
19058 BitWidth =
nullptr;
19064 InvalidDecl =
true;
19065 BitWidth =
nullptr;
19070 if (!InvalidDecl && Mutable) {
19071 unsigned DiagID = 0;
19073 DiagID =
getLangOpts().MSVCCompat ? diag::ext_mutable_reference
19074 : diag::err_mutable_reference;
19075 else if (
T.isConstQualified())
19076 DiagID = diag::err_mutable_const;
19080 if (
D &&
D->getDeclSpec().getStorageClassSpecLoc().isValid())
19081 ErrLoc =
D->getDeclSpec().getStorageClassSpecLoc();
19082 Diag(ErrLoc, DiagID);
19083 if (DiagID != diag::ext_mutable_reference) {
19085 InvalidDecl =
true;
19097 BitWidth, Mutable, InitStyle);
19104 if (PrevDecl && !isa<TagDecl>(PrevDecl) &&
19106 Diag(
Loc, diag::err_duplicate_member) << II;
19112 if (
Record->isUnion()) {
19114 RD && (RD->isBeingDefined() || RD->isCompleteDefinition())) {
19129 const bool HaveMSExt =
19134 HaveMSExt ? diag::ext_union_member_of_reference_type
19135 : diag::err_union_member_of_reference_type)
19155 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(NewFD))
19158 if (
T.isObjCGCWeak())
19159 Diag(
Loc, diag::warn_attribute_weak_on_field);
19179 RDecl && (RDecl->isBeingDefined() || RDecl->isCompleteDefinition())) {
19190 if (RDecl->hasNonTrivialCopyConstructor())
19192 else if (!RDecl->hasTrivialDefaultConstructor())
19194 else if (RDecl->hasNonTrivialCopyAssignment())
19196 else if (RDecl->hasNonTrivialDestructor())
19201 RDecl->hasObjectMember()) {
19209 if (!FD->
hasAttr<UnavailableAttr>())
19210 FD->
addAttr(UnavailableAttr::CreateImplicit(
19211 Context,
"", UnavailableAttr::IR_ARCFieldWithOwnership,
Loc));
19218 ? diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member
19219 : diag::err_illegal_union_or_anon_struct_member)
19234 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
19242 if (!CD->IsClassExtension())
19259 AllIvarDecls.push_back(Ivar);
19271 if (!
Record->hasUserDeclaredDestructor()) {
19279 if (
auto *DD = dyn_cast<CXXDestructorDecl>(
Decl)) {
19280 if (DD->isInvalidDecl())
19284 assert(DD->isIneligibleOrNotSelected() &&
"Selecting a destructor but a destructor was already selected.");
19298 Record->addedSelectedDestructor(dyn_cast<CXXDestructorDecl>(Best->Function));
19302 Msg = diag::err_ambiguous_destructor;
19307 Msg = diag::err_no_viable_destructor;
19318 Record->setInvalidDecl();
19325 Record->addedSelectedDestructor(dyn_cast<CXXDestructorDecl>(OCS.
begin()->Function));
19369 if (!
Method->getTrailingRequiresClause())
19370 SatisfactionStatus.push_back(
true);
19374 SatisfactionStatus.push_back(
false);
19376 SatisfactionStatus.push_back(Satisfaction.
IsSatisfied);
19380 for (
size_t i = 0; i < Methods.size(); i++) {
19381 if (!SatisfactionStatus[i])
19386 OrigMethod = cast<CXXMethodDecl>(MF);
19389 bool AnotherMethodIsMoreConstrained =
false;
19390 for (
size_t j = 0; j < Methods.size(); j++) {
19391 if (i == j || !SatisfactionStatus[j])
19395 OtherMethod = cast<CXXMethodDecl>(MF);
19405 AnotherMethodIsMoreConstrained =
true;
19409 AnotherMethodIsMoreConstrained)) {
19412 AnotherMethodIsMoreConstrained =
true;
19414 if (AnotherMethodIsMoreConstrained)
19419 if (!AnotherMethodIsMoreConstrained) {
19420 Method->setIneligibleOrNotSelected(
false);
19422 1 << llvm::to_underlying(CSM));
19436 auto *MD = dyn_cast<CXXMethodDecl>(
Decl);
19438 auto *FTD = dyn_cast<FunctionTemplateDecl>(
Decl);
19440 MD = dyn_cast<CXXMethodDecl>(FTD->getTemplatedDecl());
19444 if (
auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
19445 if (CD->isInvalidDecl())
19447 if (CD->isDefaultConstructor())
19448 DefaultConstructors.push_back(MD);
19449 else if (CD->isCopyConstructor())
19450 CopyConstructors.push_back(MD);
19451 else if (CD->isMoveConstructor())
19452 MoveConstructors.push_back(MD);
19454 CopyAssignmentOperators.push_back(MD);
19456 MoveAssignmentOperators.push_back(MD);
19474 auto IsFunctionPointerOrForwardDecl = [&](
const Decl *
D) {
19475 const FieldDecl *FD = dyn_cast<FieldDecl>(
D);
19488 if (
const auto *TD = dyn_cast<TagDecl>(
D))
19489 return !TD->isCompleteDefinition();
19493 if (isa<PointerType>(FieldType)) {
19504 return llvm::all_of(
Record->decls(), IsFunctionPointerOrForwardDecl);
19511 assert(EnclosingDecl &&
"missing record or interface decl");
19516 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
19520 case Decl::ObjCCategory:
19523 case Decl::ObjCImplementation:
19525 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
19531 CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(EnclosingDecl);
19535 unsigned NumNamedMembers = 0;
19537 for (
const auto *I :
Record->decls()) {
19538 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
19539 if (IFD->getDeclName())
19546 const FieldDecl *PreviousField =
nullptr;
19548 i != end; PreviousField = cast<FieldDecl>(*i), ++i) {
19556 RecFields.push_back(FD);
19576 bool IsLastField = (i + 1 == Fields.end());
19585 (
Record || isa<ObjCContainerDecl>(EnclosingDecl))) {
19591 unsigned DiagID = 0;
19592 if (!
Record->isUnion() && !IsLastField) {
19595 Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
19599 }
else if (
Record->isUnion())
19601 ? diag::ext_flexible_array_union_ms
19602 : diag::ext_flexible_array_union_gnu;
19603 else if (NumNamedMembers < 1)
19605 ? diag::ext_flexible_array_empty_aggregate_ms
19606 : diag::ext_flexible_array_empty_aggregate_gnu;
19616 if (CXXRecord && CXXRecord->getNumVBases() != 0)
19630 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
19637 Record->setHasFlexibleArrayMember(
true);
19646 diag::err_incomplete_type)
19649 diag::err_field_incomplete_or_sizeless))) {
19655 if (
Record && RD->hasFlexibleArrayMember()) {
19658 Record->setHasFlexibleArrayMember(
true);
19659 if (!
Record->isUnion()) {
19674 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
19676 diag::err_abstract_type_in_decl,
19681 if (
Record && RD->hasObjectMember())
19682 Record->setHasObjectMember(
true);
19683 if (
Record && RD->hasVolatileMember())
19684 Record->setHasVolatileMember(
true);
19703 FD->
addAttr(UnavailableAttr::CreateImplicit(
19704 Context,
"", UnavailableAttr::IR_ARCFieldWithOwnership,
19708 !
Record->hasObjectMember()) {
19711 Record->setHasObjectMember(
true);
19716 Record->setHasObjectMember(
true);
19719 Record->setHasObjectMember(
true);
19724 !shouldIgnoreForRecordTriviality(FD)) {
19727 Record->setNonTrivialToPrimitiveDefaultInitialize(
true);
19730 Record->setHasNonTrivialToPrimitiveDefaultInitializeCUnion(
true);
19734 Record->setNonTrivialToPrimitiveCopy(
true);
19736 Record->setHasNonTrivialToPrimitiveCopyCUnion(
true);
19738 if (FD->
hasAttr<ExplicitInitAttr>())
19739 Record->setHasUninitializedExplicitInitFields(
true);
19741 Record->setNonTrivialToPrimitiveDestroy(
true);
19742 Record->setParamDestroyedInCallee(
true);
19744 Record->setHasNonTrivialToPrimitiveDestructCUnion(
true);
19748 if (RD->getArgPassingRestrictions() ==
19750 Record->setArgPassingRestrictions(
19753 Record->setArgPassingRestrictions(
19757 Record->setArgPassingRestrictions(
19759 Record->setNonTrivialToPrimitiveCopy(
true);
19764 Record->setHasVolatileMember(
true);
19765 bool ReportMSBitfieldStoragePacking =
19766 Record && PreviousField &&
19767 !
Diags.
isIgnored(diag::warn_ms_bitfield_mismatched_storage_packing,
19769 auto IsNonDependentBitField = [](
const FieldDecl *FD) {
19773 if (ReportMSBitfieldStoragePacking && IsNonDependentBitField(FD) &&
19774 IsNonDependentBitField(PreviousField)) {
19778 if (FDStorageSize != PreviousFieldStorageSize) {
19780 diag::warn_ms_bitfield_mismatched_storage_packing)
19784 diag::note_ms_bitfield_mismatched_storage_size_previous)
19785 << PreviousField << PreviousField->
getType();
19795 bool Completed =
false;
19799 Parent->isTemplateParamScope())
19800 Record->setInvalidDecl();
19804 if (!CXXRecord->isInvalidDecl()) {
19807 I = CXXRecord->conversion_begin(),
19808 E = CXXRecord->conversion_end(); I !=
E; ++I)
19809 I.setAccess((*I)->getAccess());
19815 if (!CXXRecord->isDependentType()) {
19816 if (!CXXRecord->isInvalidDecl()) {
19820 if (CXXRecord->getNumVBases()) {
19822 CXXRecord->getFinalOverriders(FinalOverriders);
19824 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
19825 MEnd = FinalOverriders.end();
19828 SOEnd = M->second.end();
19829 SO != SOEnd; ++SO) {
19830 assert(SO->second.size() > 0 &&
19831 "Virtual function without overriding functions?");
19832 if (SO->second.size() == 1)
19839 Diag(
Record->getLocation(), diag::err_multiple_final_overriders)
19841 Diag(M->first->getLocation(),
19842 diag::note_overridden_virtual_function);
19844 OM = SO->second.begin(),
19845 OMEnd = SO->second.end();
19847 Diag(OM->Method->getLocation(), diag::note_final_overrider)
19848 << (
const NamedDecl *)M->first << OM->Method->getParent();
19850 Record->setInvalidDecl();
19853 CXXRecord->completeDefinition(&FinalOverriders);
19863 Record->completeDefinition();
19872 (
Record->hasAttr<RandomizeLayoutAttr>() ||
19873 (!
Record->hasAttr<NoRandomizeLayoutAttr>() &&
19874 EntirelyFunctionPointers(
Record)))) {
19878 Record->reorderDecls(NewDeclOrdering);
19883 auto *Dtor = CXXRecord->getDestructor();
19884 if (Dtor && Dtor->isImplicit() &&
19886 CXXRecord->setImplicitDestructorIsDeleted();
19891 if (
Record->hasAttrs()) {
19894 if (
const MSInheritanceAttr *IA =
Record->getAttr<MSInheritanceAttr>())
19896 IA->getRange(), IA->getBestCase(),
19897 IA->getInheritanceModel());
19903 bool CheckForZeroSize;
19905 CheckForZeroSize =
true;
19910 CXXRecord->getLexicalDeclContext()->isExternCContext() &&
19912 CXXRecord->isCLike();
19914 if (CheckForZeroSize) {
19915 bool ZeroSize =
true;
19916 bool IsEmpty =
true;
19917 unsigned NonBitFields = 0;
19920 (NonBitFields == 0 || ZeroSize) && I !=
E; ++I) {
19922 if (I->isUnnamedBitField()) {
19923 if (!I->isZeroLengthBitField())
19927 QualType FieldType = I->getType();
19939 diag::warn_zero_size_struct_union_in_extern_c :
19940 diag::warn_zero_size_struct_union_compat)
19941 << IsEmpty <<
Record->isUnion() << (NonBitFields > 1);
19948 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union
19949 : diag::ext_no_named_members_in_struct_union)
19957 ID->setEndOfDefinitionLoc(RBrac);
19959 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
19961 ID->addDecl(ClsFields[i]);
19965 if (ID->getSuperClass())
19968 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
19969 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
19970 for (
unsigned I = 0, N = RecFields.size(); I != N; ++I)
19976 IMPDecl->setIvarLBraceLoc(LBrac);
19977 IMPDecl->setIvarRBraceLoc(RBrac);
19979 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
19987 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
19991 Diag(ClsFields[i]->getLocation(),
19992 diag::err_duplicate_ivar_declaration);
19993 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
19999 Diag(ClsFields[i]->getLocation(),
20000 diag::err_duplicate_ivar_declaration);
20001 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
20007 CDecl->addDecl(ClsFields[i]);
20009 CDecl->setIvarLBraceLoc(LBrac);
20010 CDecl->setIvarRBraceLoc(RBrac);
20023 const unsigned NumTypes = 4;
20024 QualType SignedIntegralTypes[NumTypes] = {
20027 QualType UnsignedIntegralTypes[NumTypes] = {
20034 : UnsignedIntegralTypes;
20035 for (
unsigned I = 0; I != NumTypes; ++I)
20048 llvm::APSInt EnumVal(IntWidth);
20068 EltTy =
Enum->getIntegerType();
20074 Val = Converted.
get();
20081 if (
Enum->isComplete()) {
20082 EltTy =
Enum->getIntegerType();
20091 .isWindowsMSVCEnvironment()) {
20092 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
20094 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
20119 ? diag::warn_c17_compat_enum_value_not_int
20120 : diag::ext_c23_enum_value_not_int)
20122 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
20134 if (
Enum->isDependentType())
20136 else if (!LastEnumConst) {
20145 if (
Enum->isFixed()) {
20146 EltTy =
Enum->getIntegerType();
20155 EltTy = LastEnumConst->
getType();
20158 if (EnumVal < LastEnumConst->getInitVal()) {
20170 if (
T.isNull() ||
Enum->isFixed()) {
20174 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
20176 if (
Enum->isFixed())
20178 Diag(IdLoc, diag::err_enumerator_wrapped)
20182 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
20205 ? diag::warn_c17_compat_enum_value_not_int
20206 : diag::ext_c23_enum_value_not_int)
20207 << 1 <<
toString(EnumVal, 10) << 1;
20212 : diag::ext_c23_enum_value_not_int)
20213 << 1 <<
toString(EnumVal, 10) << 1;
20240 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
20244 EnumDecl *PrevED = cast<EnumDecl>(PrevECD->getDeclContext());
20248 Skip.Previous = Hidden;
20260 EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl);
20262 cast_or_null<EnumConstantDecl>(lastEnumConst);
20271 RedeclarationKind::ForVisibleRedeclaration);
20279 PrevDecl =
nullptr;
20298 if (!TheEnumDecl->
isScoped() && isa<ValueDecl>(PrevDecl)) {
20306 "Received TagDecl when not in C++!");
20308 if (isa<EnumConstantDecl>(PrevDecl))
20309 Diag(IdLoc, diag::err_redefinition_of_enumerator) <<
Id;
20311 Diag(IdLoc, diag::err_redefinition) <<
Id;
20344 if (!BO->isAdditiveOp())
20352 InitExpr = BO->getLHS();
20356 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InitExpr);
20376 if (!
Enum->getIdentifier())
20380 if (
Enum->getNumPositiveBits() > 63 ||
Enum->getNumNegativeBits() > 64)
20389 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
20392 typedef std::unordered_map<int64_t, DeclOrVector> ValueToVectorMap;
20396 llvm::APSInt Val =
D->getInitVal();
20397 return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
20400 DuplicatesVector DupVector;
20401 ValueToVectorMap EnumMap;
20405 for (
auto *Element : Elements) {
20419 EnumMap.insert({EnumConstantToKey(ECD), ECD});
20422 if (EnumMap.size() == 0)
20426 for (
auto *Element : Elements) {
20432 auto Iter = EnumMap.find(EnumConstantToKey(ECD));
20433 if (
Iter == EnumMap.end())
20436 DeclOrVector& Entry =
Iter->second;
20443 auto Vec = std::make_unique<ECDVector>();
20445 Vec->push_back(ECD);
20452 DupVector.emplace_back(std::move(Vec));
20456 ECDVector *Vec = cast<ECDVector *>(Entry);
20458 if (*Vec->begin() == ECD)
20461 Vec->push_back(ECD);
20465 for (
const auto &Vec : DupVector) {
20466 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
20469 auto *FirstECD = Vec->front();
20470 S.
Diag(FirstECD->getLocation(), diag::warn_duplicate_enum_values)
20471 << FirstECD <<
toString(FirstECD->getInitVal(), 10)
20472 << FirstECD->getSourceRange();
20476 for (
auto *ECD : llvm::drop_begin(*Vec))
20477 S.
Diag(ECD->getLocation(), diag::note_duplicate_element)
20478 << ECD <<
toString(ECD->getInitVal(), 10)
20479 << ECD->getSourceRange();
20484 bool AllowMask)
const {
20485 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
20489 llvm::APInt &FlagBits = R.first->second;
20493 const auto &EVal =
E->getInitVal();
20495 if (EVal.isPowerOf2())
20496 FlagBits = FlagBits.zext(EVal.getBitWidth()) | EVal;
20508 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
20509 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
20521 if (
Enum->isDependentType()) {
20522 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
20524 cast_or_null<EnumConstantDecl>(Elements[i]);
20525 if (!ECD)
continue;
20536 unsigned NumNegativeBits = 0;
20537 unsigned NumPositiveBits = 0;
20538 bool MembersRepresentableByInt =
20543 unsigned BestWidth;
20564 if (
Enum->isComplete()) {
20565 BestType =
Enum->getIntegerType();
20569 BestPromotionType = BestType;
20574 Packed, NumNegativeBits, NumPositiveBits, BestType, BestPromotionType);
20577 Diag(
Enum->getLocation(), diag::ext_enum_too_large);
20582 for (
auto *
D : Elements) {
20583 auto *ECD = cast_or_null<EnumConstantDecl>(
D);
20584 if (!ECD)
continue;
20593 llvm::APSInt InitVal = ECD->getInitVal();
20601 MembersRepresentableByInt) {
20611 }
else if (ECD->getType() == BestType) {
20621 NewWidth = BestWidth;
20626 InitVal = InitVal.extOrTrunc(NewWidth);
20627 InitVal.setIsSigned(NewSign);
20628 ECD->setInitVal(
Context, InitVal);
20631 if (ECD->getInitExpr() &&
20634 Context, NewTy, CK_IntegralCast, ECD->getInitExpr(),
20642 ECD->setType(NewTy);
20645 Enum->completeDefinition(BestType, BestPromotionType,
20646 NumPositiveBits, NumNegativeBits);
20650 if (
Enum->isClosedFlag()) {
20651 for (
Decl *
D : Elements) {
20653 if (!ECD)
continue;
20656 if (InitVal != 0 && !InitVal.isPowerOf2() &&
20664 if (
Enum->hasAttrs())
20688 D->setStmt(Statement);
20703 AsmLabelAttr *
Attr =
20704 AsmLabelAttr::CreateImplicit(
Context, AliasName->
getName(), Info);
20710 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
20714 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
20715 << (isa<FunctionDecl>(PrevDecl) ? 0 : 1) << PrevDecl;
20727 PrevDecl->
addAttr(WeakAttr::CreateImplicit(
Context, PragmaLoc));
20742 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
20743 if (!PrevDecl->
hasAttr<AliasAttr>())
20744 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
20753 assert(FD &&
"Expected non-null FunctionDecl");
20765 auto IsEmittedForExternalSymbol = [
this, FD]() {
20777 if (
LangOpts.OpenMPIsTargetDevice) {
20780 std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
20787 if (*DevTy == OMPDeclareTargetDeclAttr::DT_Host)
20791 if (
OpenMP().isInOpenMPDeclareTargetContext() || DevTy)
20792 if (IsEmittedForExternalSymbol())
20798 }
else if (
LangOpts.OpenMP > 45) {
20802 std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
20805 if (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost)
20824 if (IsEmittedForExternalSymbol())
20829 if (
auto *
Destructor = dyn_cast<CXXDestructorDecl>(FD)) {
20831 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
20834 Spec->getTemplateSpecializationKind();
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines enum values for all the target-independent builtin functions.
enum clang::sema::@1840::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::Target Target
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 functions specific to ARM.
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 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 NestedNameSpecifier synthesizeCurrentNestedNameSpecifier(ASTContext &Context, DeclContext *DC)
static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx, FixItHint &Hint)
static void CheckExplicitObjectParameter(Sema &S, ParmVarDecl *P, SourceLocation ExplicitThisLoc)
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 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 unsigned propagateAttribute(ParmVarDecl *To, const ParmVarDecl *From, Sema &S)
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 looksMutable(QualType T, const ASTContext &Ctx)
static bool isUsingDeclNotAtClassScope(NamedDecl *D)
static void propagateAttributes(ParmVarDecl *To, const ParmVarDecl *From, F &&propagator)
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 mergeDeclAttribute(Sema &S, NamedDecl *D, const InheritableAttr *Attr, AvailabilityMergeKind AMK)
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 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 OpenACC constructs and clauses.
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 for SYCL constructs.
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.
RAII object that pops an ExpressionEvaluationContext when exiting a function body.
ExitFunctionBodyRAII(Sema &S, bool IsLambda)
llvm::APInt getValue() const
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
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 ...
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.
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 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.
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 getUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType=QualType()) const
Builtin::Context & BuiltinInfo
bool computeEnumBits(RangeT EnumConstants, unsigned &NumNegativeBits, unsigned &NumPositiveBits)
Compute NumNegativeBits and NumPositiveBits for an enum based on the constant values of its enumerato...
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 getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
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.
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
CanQualType UnsignedLongTy
bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits, unsigned NumPositiveBits, QualType &BestType, QualType &BestPromotionType)
Compute BestType and BestPromotionType for an enum based on the highest number of negative and positi...
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 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
void ResetObjCLayout(const ObjCInterfaceDecl *D)
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.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
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 UnsignedIntTy
QualType getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
CanQualType UnsignedShortTy
bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
void setcudaConfigureCallDecl(FunctionDecl *FD)
QualType getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
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.
QualType getUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D) const
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.
QualType getDeducedTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
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 ...
CanQualType getCanonicalTagType(const TagDecl *TD) const
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
bool isStandardAttributeSyntax() const
The attribute is spelled [[]] in either C or C++ mode, including standard attributes spelled with a k...
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 the builtin ID belongs exclusively to the AuxTarget, and false if it belongs to both p...
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name.
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.
std::string getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
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(), const AssociatedConstraint &TrailingRequiresClause={})
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, const AssociatedConstraint &TrailingRequiresClause={})
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, const AssociatedConstraint &TrailingRequiresClause={}, const CXXDeductionGuideDecl *SourceDG=nullptr, SourceDeductionGuideKind SK=SourceDeductionGuideKind::None)
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, const AssociatedConstraint &TrailingRequiresClause={})
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)
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, const AssociatedConstraint &TrailingRequiresClause={})
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.
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.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
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.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
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.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
LambdaCaptureDefault getLambdaCaptureDefault() const
void setDescribedClassTemplate(ClassTemplateDecl *Template)
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.
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
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.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
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 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 semantically 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
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.
bool isInAnotherModuleUnit() const
Whether this declaration comes from another module unit.
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 setImplicit(bool I=true)
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.
bool isAnyOperatorNewOrDelete() const
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.
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
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
void setTypeSourceInfo(TypeSourceInfo *TI)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
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
void setElaboratedKeywordLoc(SourceLocation Loc)
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...
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.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
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...
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.
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)
bool isZeroLengthBitField() const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, Expr *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.
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, const AssociatedConstraint &TrailingRequiresClause={})
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 isReplaceableGlobalAllocationFunction(UnsignedOrNone *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
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
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.
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 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.
void setConstexprKind(ConstexprSpecKind CSK)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
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)
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
unsigned getRegParmType() const
CallingConv getCallConv() const
QualType getReturnType() const
bool getCmseNSCallAttr() const
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, 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
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
@ 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.
bool isTargetDevice() const
True when compiling for an offloading target device.
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...
Visibility getVisibility() const
Linkage getLinkage() const
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.
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.
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.
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 getAsTypeLoc() const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
static constexpr NestedNameSpecifier getGlobal()
bool containsErrors() const
Whether this nested name specifier contains an error.
const Type * getAsType() const
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Type
A type, stored as a Type*.
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
Wrapper for source info for ObjC interfaces.
void setNameLoc(SourceLocation Loc)
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" ...
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
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...
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)
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
Pointer-authentication qualifiers.
bool isAddressDiscriminated() 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...
PointerAuthQualifier getPointerAuth() const
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.
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
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.
The collection of all-type qualifiers we support.
@ 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)
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
field_iterator field_begin() 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.
void CheckSMEFunctionDefAttributes(const FunctionDecl *FD)
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId, bool DeferHint=false)
Emit a compatibility diagnostic.
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)
HLSLVkConstantIdAttr * mergeVkConstantIdAttr(Decl *D, const AttributeCommonInfo &AL, int Id)
HLSLNumThreadsAttr * mergeNumThreadsAttr(Decl *D, const AttributeCommonInfo &AL, int X, int Y, int Z)
void deduceAddressSpace(VarDecl *Decl)
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 ActOnVariableDeclarator(VarDecl *VD)
Function called when a variable declarator is created, which lets us implement the 'routine' 'functio...
OpenACCRoutineDeclAttr * mergeRoutineDeclAttr(const OpenACCRoutineDeclAttr &Old)
void ActOnFunctionDeclarator(FunctionDecl *FD)
Called when a function decl is created, which lets us implement the 'routine' 'doesn't match next thi...
void ActOnVariableInit(VarDecl *VD, QualType InitType)
Called when a variable is initialized, so we can implement the 'routine 'doesn't match the next thing...
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)
void CheckSYCLExternalFunctionDecl(FunctionDecl *FD)
StmtResult BuildSYCLKernelCallStmt(FunctionDecl *FD, CompoundStmt *Body)
void CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD)
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.
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.
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...
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.
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, const ParsedAttributesView &Attrs, SourceLocation EqualLoc, Expr *Val, SkipBodyInfo *SkipBody=nullptr)
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)
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.
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation=false, bool RetainFunctionScopeInfo=false)
Performs semantic analysis at the end of a function body.
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)
bool isRedefinitionAllowedFor(NamedDecl *D, NamedDecl **Suggested, bool &Visible)
Determine if D has a definition which allows we redefine it in current TU.
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.
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 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)
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, bool StrictPackMatch=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
const LangOptions & LangOpts
bool ActOnDuplicateDefinition(Scope *S, Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
void PushExpressionEvaluationContextForFunction(ExpressionEvaluationContext NewContext, FunctionDecl *FD)
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.
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...
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.
llvm::SmallSetVector< Decl *, 4 > DeclsToCheckForDeferredDiags
Function or variable declarations to be checked for whether the deferred diagnostics should be emitte...
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
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.
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)
void DiagnoseUniqueObjectDuplication(const VarDecl *Dcl)
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)
void CleanupMergedEnum(Scope *S, Decl *New)
CleanupMergedEnum - We have just merged the decl 'New' by making another definition visible.
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.
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.
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.
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)
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
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.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
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...
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....
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
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.
void warnOnCTypeHiddenInCPlusPlus(const NamedDecl *D)
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.
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AvailabilityMergeKind::Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
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
bool IsAtLeastAsConstrained(const NamedDecl *D1, MutableArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, MutableArrayRef< AssociatedConstraint > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
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...
bool GloballyUniqueObjectMightBeAccidentallyDuplicated(const VarDecl *Dcl)
Certain globally-unique variables might be accidentally duplicated if built into multiple shared libr...
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...
FormatMatchesAttr * mergeFormatMatchesAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, StringLiteral *FormatStr)
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 checkTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK, TypeDecl *TD, SourceLocation NameLoc)
Returns the TypeDeclType for the given type declaration, as ASTContext::getTypeDeclType would,...
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.
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation TriviallyRelocatable, SourceLocation Replaceable, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
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.
FileIDAndOffset getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
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.
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.
SourceLocation getEndLoc() const LLVM_READONLY
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)
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
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 setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
TagKind getTagKind() const
void setElaboratedKeywordLoc(SourceLocation Loc)
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
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.
bool isTLSSupported() const
Whether the target supports thread-local storage.
virtual llvm::APInt getFMVPriority(ArrayRef< StringRef > Features) const
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.
virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const
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)
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
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(Ts... Ks) 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.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
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 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.
void setNameLoc(SourceLocation Loc)
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
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.
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
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
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.
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
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.
RecordDecl * castAsRecordDecl() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool isHLSLSpecificType() 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
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
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
QualType getUnderlyingType() const
void setTypeSourceInfo(TypeSourceInfo *newType)
Wrapper for source info for typedefs.
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.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
NestedNameSpecifier getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
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.
Wrapper for source info for unresolved typename using decls.
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.
Wrapper for source info for types used via transparent aliases.
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...
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
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 getPolicyInEffectAt(SourceLocation Loc)
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 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.
@ NonFunction
This is not an overload because the lookup results contain a non-function.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
std::pair< FileID, unsigned > FileIDAndOffset
@ 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)
int hasAttribute(AttributeCommonInfo::Syntax Syntax, llvm::StringRef ScopeName, llvm::StringRef AttrName, const TargetInfo &Target, const LangOptions &LangOpts, bool CheckPlugins)
Return the version number associated with the attribute if we recognize and implement the attribute s...
ConstexprSpecKind
Define the kind of constexpr specifier.
@ 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.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ Found
Name lookup found a single declaration that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
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.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
@ TemplateTemplateArgument
@ DefaultInitializedObject
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
@ None
Don't merge availability attributes at all.
@ Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
@ OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
@ Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
@ ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
@ 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.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
@ AmbiguousTagHiding
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
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)
@ SD_Thread
Thread storage duration.
@ SD_Static
Static storage duration.
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.
@ Template
We are parsing a template declaration.
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.
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 isExternalFormalLinkage(Linkage L)
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.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ 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.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ Enumerator
Enumerator value with fixed underlying type.
@ 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.
@ Other
Other implicit parameter.
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
@ HiddenVisibility
Objects with "hidden" visibility are not seen by the dynamic linker.
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
MutableArrayRef< Expr * > MultiExprArg
const Expr * ConstraintExpr
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.
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
enum clang::DeclaratorChunk::@211 Kind
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.
FunctionEffectsRef FunctionEffects
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &ESI)
static StringRef getTagTypeKindName(TagTypeKind Kind)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
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.