64#include "llvm/ADT/ArrayRef.h"
65#include "llvm/ADT/STLForwardCompat.h"
66#include "llvm/ADT/ScopeExit.h"
67#include "llvm/ADT/SmallPtrSet.h"
68#include "llvm/ADT/SmallString.h"
69#include "llvm/ADT/StringExtras.h"
70#include "llvm/ADT/StringRef.h"
71#include "llvm/Support/SaveAndRestore.h"
72#include "llvm/TargetParser/Triple.h"
76#include <unordered_map>
83 Decl *Group[2] = { OwnedType, Ptr };
94 TypeNameValidatorCCC(
bool AllowInvalid,
bool WantClass =
false,
95 bool AllowTemplates =
false,
96 bool AllowNonTemplates =
true)
97 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
98 AllowTemplates(AllowTemplates), AllowNonTemplates(AllowNonTemplates) {
99 WantExpressionKeywords =
false;
100 WantCXXNamedCasts =
false;
101 WantRemainingKeywords =
false;
104 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
106 if (!AllowInvalidDecl && ND->isInvalidDecl())
110 return AllowTemplates;
116 if (AllowNonTemplates)
121 if (AllowTemplates) {
122 auto *RD = dyn_cast<CXXRecordDecl>(ND);
123 if (!RD || !RD->isInjectedClassName())
126 return RD->getDescribedClassTemplate() ||
133 return !WantClassName && candidate.
isKeyword();
136 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
137 return std::make_unique<TypeNameValidatorCCC>(*
this);
141 bool AllowInvalidDecl;
144 bool AllowNonTemplates;
151 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
152 auto *FoundRD = dyn_cast<CXXRecordDecl>(TD);
154 FoundRD->isInjectedClassName() &&
158 ? diag::ext_out_of_line_qualified_id_type_names_constructor
159 : diag::err_out_of_line_qualified_id_type_names_constructor)
169enum class UnqualifiedTypeNameLookupResult {
180static UnqualifiedTypeNameLookupResult
185 return UnqualifiedTypeNameLookupResult::NotFound;
187 UnqualifiedTypeNameLookupResult FoundTypeDecl =
188 UnqualifiedTypeNameLookupResult::NotFound;
192 }
else if (
auto *TST = dyn_cast<TemplateSpecializationType>(
193 Base.getType().getCanonicalType())) {
196 if (!TST->isDependentType())
198 auto *TD = TST->getTemplateName().getAsTemplateDecl();
201 if (
auto *BasePrimaryTemplate =
202 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
204 BaseRD = BasePrimaryTemplate;
205 else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
207 CTD->findPartialSpecialization(
Base.getType()))
216 return UnqualifiedTypeNameLookupResult::FoundNonType;
217 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
219 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
221 case UnqualifiedTypeNameLookupResult::FoundNonType:
222 return UnqualifiedTypeNameLookupResult::FoundNonType;
223 case UnqualifiedTypeNameLookupResult::FoundType:
224 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
226 case UnqualifiedTypeNameLookupResult::NotFound:
233 return FoundTypeDecl;
241 UnqualifiedTypeNameLookupResult FoundTypeDecl =
242 UnqualifiedTypeNameLookupResult::NotFound;
244 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
248 RD = dyn_cast<CXXRecordDecl>(DC);
252 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
258 S.
Diag(NameLoc, diag::ext_found_in_dependent_base) << &II;
278 bool HasTrailingDot,
ParsedType ObjectTypePtr,
279 bool IsCtorOrDtorName,
280 bool WantNontrivialTypeSourceInfo,
281 bool IsClassTemplateDeductionContext,
284 bool IsImplicitTypename = !isClassName && !IsCtorOrDtorName;
286 bool AllowDeducedTemplate = IsClassTemplateDeductionContext &&
312 if (IsImplicitTypename) {
317 auto DB =
DiagCompat(QualifiedLoc, diag_compat::implicit_typename)
326 if (WantNontrivialTypeSourceInfo)
362 if (ObjectTypePtr &&
Result.empty()) {
386 switch (
Result.getResultKind()) {
389 TypeNameValidatorCCC CCC(
true, isClassName,
390 AllowDeducedTemplate);
396 bool MemberOfUnknownSpecialization;
405 if (Correction && (NNS || NewII != &II) &&
411 Template, MemberOfUnknownSpecialization))) {
413 isClassName, HasTrailingDot, ObjectTypePtr,
415 WantNontrivialTypeSourceInfo,
416 IsClassTemplateDeductionContext);
419 PDiag(diag::err_unknown_type_or_class_name_suggest)
420 <<
Result.getLookupName() << isClassName);
423 *CorrectedII = NewII;
428 Result.suppressDiagnostics();
444 Result.suppressDiagnostics();
454 Result.suppressDiagnostics();
460 Res != ResEnd; ++Res) {
469 FoundUsingShadow = dyn_cast<UsingShadowDecl>(*Res);
481 Result.suppressDiagnostics();
492 IIDecl =
Result.getFoundDecl();
493 FoundUsingShadow = dyn_cast<UsingShadowDecl>(*
Result.begin());
497 assert(IIDecl &&
"Didn't find decl");
500 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
506 if (FoundUsingShadow) {
510 if (!WantNontrivialTypeSourceInfo)
516 }
else if (
auto *Tag = dyn_cast<TagDecl>(TD)) {
520 if (!WantNontrivialTypeSourceInfo)
526 TL.setNameLoc(NameLoc);
527 }
else if (
auto *TN = dyn_cast<TypedefNameDecl>(TD);
531 if (!WantNontrivialTypeSourceInfo)
537 }
else if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD)) {
541 if (!WantNontrivialTypeSourceInfo)
548 T =
Context.getTypeDeclType(TD);
549 if (!WantNontrivialTypeSourceInfo)
560 if (
auto *TD = dyn_cast_or_null<TemplateDecl>(
564 if (!ShorthandTy.
isNull())
571 if (!HasTrailingDot) {
574 if (!WantNontrivialTypeSourceInfo)
579 TL.setNameEndLoc(NameLoc);
582 }
else if (
auto *UD = dyn_cast<UnresolvedUsingIfExistsDecl>(IIDecl)) {
586 }
else if (AllowDeducedTemplate) {
588 assert(!FoundUsingShadow || FoundUsingShadow->
getTargetDecl() == TD);
598 TL.setNameLoc(NameLoc);
606 Result.suppressDiagnostics();
615 auto *ND = dyn_cast<NamespaceDecl>(DC);
616 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
618 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
623 llvm_unreachable(
"something isn't in TU scope?");
634 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
635 if (MD->getParent()->hasAnyDependentBases())
643 bool IsTemplateTypeArg) {
644 assert(
getLangOpts().MSVCCompat &&
"shouldn't be called in non-MSVC mode");
647 if (IsTemplateTypeArg &&
getCurScope()->isTemplateParamScope()) {
656 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
665 Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
693 R.suppressDiagnostics();
696 switch (TD->getTagKind()) {
723 if (
Context.hasSameUnqualifiedType(T,
Base.getType()))
737 bool IsTemplateName) {
742 SuggestedType =
nullptr;
746 TypeNameValidatorCCC CCC(
false,
false,
753 bool CanRecover = !IsTemplateName;
754 if (Corrected.isKeyword()) {
757 PDiag(IsTemplateName ? diag::err_no_template_suggest
758 : diag::err_unknown_typename_suggest)
760 II = Corrected.getCorrectionAsIdentifierInfo();
763 if (!SS || !SS->
isSet()) {
765 PDiag(IsTemplateName ? diag::err_no_template_suggest
766 : diag::err_unknown_typename_suggest)
769 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
770 bool DroppedSpecifier =
771 Corrected.WillReplaceSpecifier() && II->
getName() == CorrectedStr;
774 ? diag::err_no_member_template_suggest
775 : diag::err_unknown_nested_typename_suggest)
776 << II << DC << DroppedSpecifier << SS->
getRange(),
779 llvm_unreachable(
"could not have corrected a typo here");
786 if (Corrected.getCorrectionSpecifier())
791 getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc, S,
792 tmpSS.
isSet() ? &tmpSS : SS,
false,
false,
nullptr,
805 bool MemberOfUnknownSpecialization;
807 Name,
nullptr,
true, TemplateResult,
818 Diag(IILoc, IsTemplateName ? diag::err_no_template
819 : diag::err_unknown_typename)
822 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
823 : diag::err_typename_nested_not_found)
829 unsigned DiagID = diag::err_typename_missing;
831 DiagID = diag::ext_typename_missing;
842 "Invalid scope specifier has already been diagnosed");
849 bool CheckTemplate = R.getSema().getLangOpts().CPlusPlus &&
850 NextToken.
is(tok::less);
870 StringRef FixItTagName;
871 switch (Tag->getTagKind()) {
873 FixItTagName =
"class ";
877 FixItTagName =
"enum ";
881 FixItTagName =
"struct ";
885 FixItTagName =
"__interface ";
889 FixItTagName =
"union ";
893 StringRef TagName = FixItTagName.drop_back();
894 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
895 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
900 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
915 const Token &NextToken,
920 assert(NextToken.
isNot(tok::coloncolon) &&
921 "parse nested name specifiers before calling ClassifyName");
962 bool SecondTry =
false;
963 bool IsFilteredTemplateName =
false;
966 switch (
Result.getResultKind()) {
970 if (SS.
isEmpty() && NextToken.
is(tok::l_paren)) {
1016 if (!SecondTry && CCC) {
1021 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
1022 unsigned QualifiedDiag = diag::err_no_member_suggest;
1025 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
1028 UnqualifiedDiag = diag::err_no_template_suggest;
1029 QualifiedDiag = diag::err_no_member_template_suggest;
1030 }
else if (UnderlyingFirstDecl &&
1034 UnqualifiedDiag = diag::err_unknown_typename_suggest;
1035 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
1041 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
1042 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
1043 Name->
getName() == CorrectedStr;
1046 << DroppedSpecifier << SS.
getRange());
1050 Name = Corrected.getCorrectionAsIdentifierInfo();
1053 if (Corrected.isKeyword())
1059 Result.setLookupName(Corrected.getCorrection());
1081 Result.suppressDiagnostics();
1123 if (!
Result.isAmbiguous()) {
1124 IsFilteredTemplateName =
true;
1134 (IsFilteredTemplateName ||
1150 if (!IsFilteredTemplateName)
1153 bool IsFunctionTemplate;
1157 IsFunctionTemplate =
true;
1160 }
else if (!
Result.empty()) {
1168 dyn_cast<UsingShadowDecl>(*
Result.begin());
1169 assert(!FoundUsingShadow ||
1178 IsFunctionTemplate =
true;
1182 if (IsFunctionTemplate) {
1186 Result.suppressDiagnostics();
1198 if (
const auto *USD = dyn_cast<UsingShadowDecl>(
Found)) {
1210 TTL.setNameLoc(NameLoc);
1237 dyn_cast<ObjCCompatibleAliasDecl>(
FirstDecl))
1238 Class = Alias->getClassInterface();
1244 if (NextToken.
is(tok::period)) {
1247 Result.suppressDiagnostics();
1257 if (
auto *USD = dyn_cast<UsingShadowDecl>(
Result.getRepresentativeDecl()))
1263 if (
auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(
FirstDecl)) {
1276 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1277 if ((NextToken.
is(tok::identifier) ||
1279 FirstDecl->getUnderlyingDecl()->isFunctionOrFunctionTemplate())) &&
1291 if (
Result.isSingleResult() && !ADL &&
1296 Result.suppressDiagnostics();
1316 bool IsAddressOfOperand) {
1319 NameInfo, IsAddressOfOperand,
1326 const Token &NextToken) {
1328 if (
auto *Ivar = dyn_cast<ObjCIvarDecl>(
Found->getUnderlyingDecl()))
1344 if ((*ULE->decls_begin())->isCXXClassMember()) {
1346 SS.
Adopt(ULE->getQualifierLoc());
1351 Result.setNamingClass(ULE->getNamingClass());
1352 for (
auto I = ULE->decls_begin(), E = ULE->decls_end(); I != E; ++I)
1353 Result.addDecl(*I, I.getAccess());
1386 "The next DeclContext should be lexically contained in the current one.");
1393 assert(
CurContext &&
"DeclContext imbalance!");
1396 assert(
CurContext &&
"Popped translation unit!");
1406 assert(
CurContext &&
"skipping definition of undefined tag");
1434 assert(!S->
getEntity() &&
"scope already has entity");
1467 "expected to be initializing a template parameter scope");
1495 cast<Decl>(DC)->getDescribedTemplateParams()) {
1496 unsigned DCDepth = TPL->getDepth() + 1;
1497 if (DCDepth > ScopeDepth)
1499 if (ScopeDepth == DCDepth)
1518 "The next DeclContext should be lexically contained in the current one.");
1522 for (
unsigned P = 0, NumParams = FD->
getNumParams(); P < NumParams; ++P) {
1525 if (Param->getIdentifier()) {
1535 assert(
CurContext &&
"DeclContext imbalance!");
1537 assert(
CurContext &&
"Popped translation unit!");
1551 if (Context.getLangOpts().CPlusPlus ||
New->hasAttr<OverloadableAttr>())
1566 return ND->
hasAttr<OverloadableAttr>();
1569 return Previous.getFoundDecl()->hasAttr<OverloadableAttr>();
1624 for (; I != IEnd; ++I) {
1657 bool AllowInlineNamespace)
const {
1658 return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace);
1665 if (ScopeDC->getPrimaryContext() == TargetDC)
1677 bool ConsiderLinkage,
1678 bool AllowInlineNamespace) {
1696 if (
auto *VD = dyn_cast<VarDecl>(D))
1698 if (
auto *FD = dyn_cast<FunctionDecl>(D))
1700 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1714 if (
New->getFriendObjectKind() &&
1755 if (NewIsModuleInterface || OldIsModuleInterface) {
1759 Diag(
New->getLocation(), diag::err_mismatched_owning_module)
1761 << NewIsModuleInterface
1763 << OldIsModuleInterface
1766 New->setInvalidDecl();
1779 if (!
New->getLexicalDeclContext()
1780 ->getNonTransparentContext()
1781 ->isFileContext() ||
1787 bool IsNewExported =
New->isInExportDeclContext();
1791 if (!IsNewExported && !IsOldExported)
1803 New->getOwningModule()->isImplicitGlobalModule())
1806 assert(IsNewExported);
1814 Diag(
New->getLocation(), diag::err_redeclaration_non_exported) <<
New << S;
1832 "New and Old are not the same definition, we should diagnostic it "
1833 "immediately instead of checking it.");
1836 "We shouldn't see unreachable definitions here.");
1884 return OldM == NewM;
1921 return CD->isCopyConstructor();
1928 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1929 if (!RD->hasNameForLinkage())
1950 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1956 FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
1959 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1968 if (FD->doesThisDeclarationHaveABody() &&
1969 Context.DeclMustBeEmitted(FD))
1971 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1978 if (
Context.DeclMustBeEmitted(VD))
1981 if (VD->isStaticDataMember() &&
1984 if (VD->isStaticDataMember() &&
1986 VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
1998 return mightHaveNonExternalLinkage(D);
2005 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
2011 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2026 if (
const auto *DD = dyn_cast<DecompositionDecl>(D)) {
2030 bool IsAllIgnored =
true;
2031 for (
const auto *BD : DD->bindings()) {
2032 if (BD->isReferenced())
2034 IsAllIgnored = IsAllIgnored && (BD->isPlaceholderVar(LangOpts) ||
2035 BD->hasAttr<UnusedAttr>());
2048 if (D->
hasAttr<UnusedAttr>() || D->
hasAttr<ObjCPreciseLifetimeAttr>() ||
2058 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->
getDeclContext()))
2061 WithinFunction || (R->isLocalClass() && !R->isDependentType());
2062 if (!WithinFunction)
2073 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2076 if (
const auto *Cleanups = dyn_cast_if_present<ExprWithCleanups>(
Init))
2077 Init = Cleanups->getSubExpr();
2079 const auto *Ty = VD->getType().getTypePtr();
2084 if (TT->getDecl()->hasAttr<UnusedAttr>())
2090 if (
const auto *MTE = dyn_cast_if_present<MaterializeTemporaryExpr>(
Init);
2091 MTE && MTE->getExtendingDecl()) {
2092 Ty = VD->getType().getNonReferenceType().getTypePtr();
2093 Init = MTE->getSubExpr()->IgnoreImplicitAsWritten();
2098 if (Ty->isIncompleteType() || Ty->isDependentType())
2103 Ty = Ty->getBaseElementTypeUnsafe();
2105 if (
const TagDecl *Tag = Ty->getAsTagDecl()) {
2106 if (Tag->hasAttr<UnusedAttr>())
2109 if (
const auto *RD = dyn_cast<CXXRecordDecl>(Tag)) {
2110 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
2114 const auto *Construct =
2115 dyn_cast<CXXConstructExpr>(
Init->IgnoreImpCasts());
2116 if (Construct && !Construct->isElidable()) {
2118 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
2119 (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
2125 if (
Init->isTypeDependent()) {
2127 if (!Ctor->isTrivial())
2168 for (
auto *TmpD : D->
decls()) {
2169 if (
const auto *T = dyn_cast<TypedefNameDecl>(TmpD))
2171 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
2185 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
2197 DiagID = diag::warn_unused_exception_param;
2199 DiagID = diag::warn_unused_label;
2201 DiagID = diag::warn_unused_variable;
2220 if (Ty->isReferenceType() || Ty->isDependentType())
2223 if (
const TagDecl *Tag = Ty->getAsTagDecl()) {
2224 if (Tag->hasAttr<UnusedAttr>())
2228 if (
const auto *RD = dyn_cast<CXXRecordDecl>(Tag);
2229 RD && !RD->hasAttr<WarnUnusedAttr>())
2241 if (VD->
hasAttr<BlocksAttr>() && Ty->isObjCObjectPointerType())
2247 if (VD->
hasAttr<ObjCPreciseLifetimeAttr>() && Ty->isObjCObjectPointerType())
2254 assert(iter->getSecond() >= 0 &&
2255 "Found a negative number of references to a VarDecl");
2256 if (
int RefCnt = iter->getSecond(); RefCnt > 0) {
2266 bool UnusedCXXCondDecl = VD->
isCXXCondDecl() && (RefCnt == 1);
2267 if (!UnusedCXXCondDecl)
2273 DiagID = diag::warn_unused_but_set_parameter;
2275 DiagID = diag::warn_unused_but_set_global;
2277 DiagID = diag::warn_unused_but_set_variable;
2287 bool Diagnose =
false;
2291 Diagnose = L->
getStmt() ==
nullptr;
2302 "Scope shouldn't contain decls!");
2309 std::optional<SourceLocation> PreviousDeclLoc;
2314 DeclDiags.push_back(LocAndDiag{Loc, std::nullopt, std::move(PD)});
2319 DeclDiags.push_back(LocAndDiag{Loc, PreviousDeclLoc, std::move(PD)});
2322 for (
auto *TmpD : S->
decls()) {
2323 assert(TmpD &&
"This decl didn't get pushed??");
2331 if (
const auto *RD = dyn_cast<RecordDecl>(D))
2334 if (
auto *VD = dyn_cast<VarDecl>(D);
2335 VD && !VD->isInternalLinkageFileVar()) {
2344 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
2355 auto ShadowI = ShadowingDecls.find(D);
2356 if (ShadowI != ShadowingDecls.end()) {
2357 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
2358 addDiagWithPrev(D->
getLocation(), FD->getLocation(),
2359 PDiag(diag::warn_ctor_parm_shadows_field)
2360 << D << FD << FD->getParent());
2362 ShadowingDecls.erase(ShadowI);
2366 llvm::sort(DeclDiags,
2367 [](
const LocAndDiag &LHS,
const LocAndDiag &RHS) ->
bool {
2372 return LHS.Loc.getRawEncoding() < RHS.Loc.getRawEncoding();
2374 for (
const LocAndDiag &D : DeclDiags) {
2376 if (D.PreviousDeclLoc)
2377 Diag(*D.PreviousDeclLoc, diag::note_previous_declaration);
2401 return "ucontext.h";
2403 llvm_unreachable(
"unhandled error kind");
2414 Parent->
addDecl(CLinkageDecl);
2415 Parent = CLinkageDecl;
2419 if (
Context.BuiltinInfo.isImmediate(ID)) {
2421 "consteval builtins should only be available in C++20 mode");
2430 New->addAttr(BuiltinAttr::CreateImplicit(
Context, ID));
2436 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2439 FT->getParamType(i),
nullptr,
SC_None,
nullptr);
2441 Params.push_back(parm);
2443 New->setParams(Params);
2451 Scope *S,
bool ForRedeclaration,
2458 if (!ForRedeclaration)
2464 Context.BuiltinInfo.allowTypeMismatch(ID))
2470 Diag(Loc, diag::warn_implicit_decl_no_jmp_buf)
2471 <<
Context.BuiltinInfo.getName(ID);
2477 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
2479 <<
Context.BuiltinInfo.getName(ID);
2483 if (!ForRedeclaration &&
2484 (
Context.BuiltinInfo.isPredefinedLibFunction(ID) ||
2485 Context.BuiltinInfo.isHeaderDependentFunction(ID))) {
2486 Diag(Loc,
LangOpts.C99 ? diag::ext_implicit_lib_function_decl_c99
2487 : diag::ext_implicit_lib_function_decl)
2488 <<
Context.BuiltinInfo.getName(ID) << R;
2489 if (
const char *Header =
Context.BuiltinInfo.getHeaderName(ID))
2490 Diag(Loc, diag::note_include_header_or_declare)
2491 << Header <<
Context.BuiltinInfo.getName(ID);
2527 while (Filter.hasNext()) {
2536 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2538 Decl->getUnderlyingType()))
2543 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2544 Decl->getAnonDeclWithTypedefName())
2556 if (
const TypedefNameDecl *OldTypedef = dyn_cast<TypedefNameDecl>(Old))
2557 OldType = OldTypedef->getUnderlyingType();
2559 OldType =
Context.getTypeDeclType(Old);
2565 Diag(
New->getLocation(), diag::err_redefinition_variably_modified_typedef)
2569 New->setInvalidDecl();
2573 if (OldType != NewType &&
2576 !
Context.hasSameType(OldType, NewType)) {
2578 Diag(
New->getLocation(), diag::err_redefinition_different_typedef)
2579 << Kind << NewType << OldType;
2582 New->setInvalidDecl();
2592 if (
New->isInvalidDecl())
return;
2598 switch (TypeID->getLength()) {
2602 if (!TypeID->isStr(
"id"))
2605 if (!T->isPointerType())
2607 if (!T->isVoidPointerType()) {
2612 Context.setObjCIdRedefinitionType(T);
2614 New->setModedTypeSourceInfo(
New->getTypeSourceInfo(),
2619 if (!TypeID->isStr(
"Class"))
2621 Context.setObjCClassRedefinitionType(
New->getUnderlyingType());
2623 New->setModedTypeSourceInfo(
New->getTypeSourceInfo(),
2627 if (!TypeID->isStr(
"SEL"))
2629 Context.setObjCSelRedefinitionType(
New->getUnderlyingType());
2631 New->setModedTypeSourceInfo(
New->getTypeSourceInfo(),
2641 Diag(
New->getLocation(), diag::err_redefinition_different_kind)
2642 <<
New->getDeclName();
2648 return New->setInvalidDecl();
2653 return New->setInvalidDecl();
2655 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2656 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2657 auto *
NewTag =
New->getAnonDeclWithTypedefName();
2660 OldTag->getCanonicalDecl() !=
NewTag->getCanonicalDecl() &&
2664 if (OldTD->isModed())
2665 New->setModedTypeSourceInfo(OldTD->getTypeSourceInfo(),
2666 OldTD->getUnderlyingType());
2668 New->setTypeSourceInfo(OldTD->getTypeSourceInfo());
2724 Diag(
New->getLocation(), diag::err_redefinition)
2725 <<
New->getDeclName();
2727 return New->setInvalidDecl();
2742 Context.getSourceManager().isInSystemHeader(
New->getLocation())))
2745 Diag(
New->getLocation(), diag::ext_redefinition_of_typedef)
2746 <<
New->getDeclName();
2753 if (
auto *ED = dyn_cast<EnumDecl>(
New); ED && !ED->isScoped()) {
2755 for (
auto *ECD : ED->enumerators()) {
2766 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2767 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2768 for (
const auto *i : D->
attrs())
2769 if (i->getKind() == A->
getKind()) {
2785 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2786 return VD->isThisDeclarationADefinition();
2787 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2788 return TD->isCompleteDefinition() || TD->isBeingDefined();
2799 AlignedAttr *OldAlignasAttr =
nullptr;
2800 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2801 unsigned OldAlign = 0;
2809 if (I->isAlignmentDependent())
2815 unsigned Align = I->getAlignment(S.
Context);
2816 if (Align > OldAlign) {
2818 OldStrictestAlignAttr = I;
2823 AlignedAttr *NewAlignasAttr =
nullptr;
2824 unsigned NewAlign = 0;
2825 for (
auto *I :
New->specific_attrs<AlignedAttr>()) {
2826 if (I->isAlignmentDependent())
2832 unsigned Align = I->getAlignment(S.
Context);
2833 if (Align > NewAlign)
2837 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2845 if (OldAlign == 0 || NewAlign == 0) {
2858 if (OldAlign != NewAlign) {
2859 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2862 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2875 S.
Diag(
New->getLocation(), diag::err_alignas_missing_on_definition)
2877 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2881 bool AnyAdded =
false;
2884 if (OldAlign > NewAlign) {
2885 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2886 Clone->setInherited(
true);
2887 New->addAttr(Clone);
2892 if (OldAlignasAttr && !NewAlignasAttr &&
2893 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2894 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2895 Clone->setInherited(
true);
2896 New->addAttr(Clone);
2903#define WANT_DECL_MERGE_LOGIC
2904#include "clang/Sema/AttrParsedAttrImpl.inc"
2905#undef WANT_DECL_MERGE_LOGIC
2912 if (!DiagnoseMutualExclusions(S, D,
Attr))
2923 if (
const auto *AA = dyn_cast<AvailabilityAttr>(
Attr)) {
2925 if (AvailabilityAttr *
Inf = AA->getInferredAttrAs())
2926 InferredPlatformII =
Inf->getPlatform();
2928 D, *AA, AA->getPlatform(), AA->
isImplicit(), AA->getIntroduced(),
2929 AA->getDeprecated(), AA->getObsoleted(), AA->getUnavailable(),
2930 AA->getMessage(), AA->getStrict(), AA->getReplacement(), AMK,
2931 AA->getPriority(), AA->getEnvironment(), InferredPlatformII);
2932 }
else if (
const auto *VA = dyn_cast<VisibilityAttr>(
Attr))
2934 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(
Attr))
2936 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(
Attr))
2938 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(
Attr))
2940 else if (
const auto *EA = dyn_cast<ErrorAttr>(
Attr))
2942 else if (
const auto *FA = dyn_cast<FormatAttr>(
Attr))
2943 NewAttr = S.
mergeFormatAttr(D, *FA, FA->getType(), FA->getFormatIdx(),
2945 else if (
const auto *FMA = dyn_cast<FormatMatchesAttr>(
Attr))
2947 D, *FMA, FMA->getType(), FMA->getFormatIdx(), FMA->getFormatString());
2948 else if (
const auto *MFA = dyn_cast<ModularFormatAttr>(
Attr))
2950 D, *MFA, MFA->getModularImplFn(), MFA->getImplName(),
2952 else if (
const auto *SA = dyn_cast<SectionAttr>(
Attr))
2954 else if (
const auto *CSA = dyn_cast<CodeSegAttr>(
Attr))
2956 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(
Attr))
2958 IA->getInheritanceModel());
2959 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(
Attr))
2968 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(
Attr))
2970 else if (
const auto *SNA = dyn_cast<SwiftNameAttr>(
Attr))
2972 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(
Attr))
2974 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(
Attr))
2985 else if (
const auto *UA = dyn_cast<UuidAttr>(
Attr))
2986 NewAttr = S.
mergeUuidAttr(D, *UA, UA->getGuid(), UA->getGuidDecl());
2987 else if (
const auto *IMA = dyn_cast<WebAssemblyImportModuleAttr>(
Attr))
2989 else if (
const auto *INA = dyn_cast<WebAssemblyImportNameAttr>(
Attr))
2991 else if (
const auto *TCBA = dyn_cast<EnforceTCBAttr>(
Attr))
2993 else if (
const auto *TCBLA = dyn_cast<EnforceTCBLeafAttr>(
Attr))
2995 else if (
const auto *BTFA = dyn_cast<BTFDeclTagAttr>(
Attr))
2997 else if (
const auto *NT = dyn_cast<HLSLNumThreadsAttr>(
Attr))
3000 else if (
const auto *WS = dyn_cast<HLSLWaveSizeAttr>(
Attr))
3003 WS->getSpelledArgsCount());
3004 else if (
const auto *CI = dyn_cast<HLSLVkConstantIdAttr>(
Attr))
3006 else if (
const auto *SA = dyn_cast<HLSLShaderAttr>(
Attr))
3011 else if (
const auto *RD = dyn_cast<OpenACCRoutineDeclAttr>(
Attr))
3015 else if (
const auto *PA = dyn_cast<PersonalityAttr>(
Attr))
3030 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
3031 if (
const auto *Def = TD->getDefinition(); Def && !Def->isBeingDefined())
3035 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
3041 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
3043 if (FD->isDefined(Def,
true))
3050 for (
const auto *Attribute : D->
attrs())
3051 if (Attribute->getKind() == Kind)
3059 if (!
New->hasAttrs())
3063 if (!Def || Def ==
New)
3067 for (
unsigned I = 0, E = NewAttributes.size(); I != E;) {
3068 Attr *NewAttribute = NewAttributes[I];
3077 NewAttributes.erase(NewAttributes.begin() + I);
3085 ? diag::err_alias_after_tentative
3086 : diag::err_redefinition;
3088 if (
Diag == diag::err_redefinition)
3098 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
3134 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
3135 if (AA->isAlignas()) {
3146 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
3148 NewAttributes.erase(NewAttributes.begin() + I);
3158 diag::err_loader_uninitialized_redeclaration);
3160 NewAttributes.erase(NewAttributes.begin() + I);
3183 diag::err_sycl_entry_point_after_definition)
3196 diag::warn_attribute_precede_definition);
3198 NewAttributes.erase(NewAttributes.begin() + I);
3204 const ConstInitAttr *CIAttr,
3205 bool AttrBeforeInit) {
3212 std::string SuitableSpelling;
3214 SuitableSpelling = std::string(
3216 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
3218 InsertLoc, {tok::l_square, tok::l_square,
3219 S.PP.getIdentifierInfo(
"clang"), tok::coloncolon,
3220 S.PP.getIdentifierInfo(
"require_constant_initialization"),
3221 tok::r_square, tok::r_square}));
3222 if (SuitableSpelling.empty())
3224 InsertLoc, {tok::kw___attribute, tok::l_paren, tok::r_paren,
3225 S.PP.getIdentifierInfo(
"require_constant_initialization"),
3226 tok::r_paren, tok::r_paren}));
3227 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus20)
3228 SuitableSpelling =
"constinit";
3229 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
3230 SuitableSpelling =
"[[clang::require_constant_initialization]]";
3231 if (SuitableSpelling.empty())
3232 SuitableSpelling =
"__attribute__((require_constant_initialization))";
3233 SuitableSpelling +=
" ";
3235 if (AttrBeforeInit) {
3238 assert(CIAttr->isConstinit() &&
"should not diagnose this for attribute");
3241 S.
Diag(CIAttr->getLocation(), diag::note_constinit_specified_here);
3245 S.
Diag(CIAttr->getLocation(),
3246 CIAttr->isConstinit() ? diag::err_constinit_added_too_late
3247 : diag::warn_require_const_init_added_too_late)
3250 << CIAttr->isConstinit()
3258 UsedAttr *NewAttr = OldAttr->clone(
Context);
3259 NewAttr->setInherited(
true);
3260 New->addAttr(NewAttr);
3263 RetainAttr *NewAttr = OldAttr->clone(
Context);
3264 NewAttr->setInherited(
true);
3265 New->addAttr(NewAttr);
3274 const auto *OldConstInit = Old->
getAttr<ConstInitAttr>();
3275 const auto *NewConstInit =
New->getAttr<ConstInitAttr>();
3276 if (
bool(OldConstInit) !=
bool(NewConstInit)) {
3284 (NewVD->hasInit() || NewVD->isThisDeclarationADefinition()))
3287 if (InitDecl == NewVD) {
3291 if (OldConstInit && OldConstInit->isConstinit())
3294 }
else if (NewConstInit) {
3298 if (InitDecl && InitDecl != NewVD) {
3301 NewVD->dropAttr<ConstInitAttr>();
3309 if (AsmLabelAttr *NewA =
New->getAttr<AsmLabelAttr>()) {
3310 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
3311 if (!OldA->isEquivalent(NewA)) {
3313 Diag(
New->getLocation(), diag::err_different_asm_label);
3314 Diag(OldA->getLocation(), diag::note_previous_declaration);
3316 }
else if (Old->
isUsed()) {
3319 Diag(
New->getLocation(), diag::err_late_asm_label_name)
3325 if (
const auto *NewAbiTagAttr =
New->getAttr<AbiTagAttr>()) {
3326 if (
const auto *OldAbiTagAttr = Old->
getAttr<AbiTagAttr>()) {
3327 for (
const auto &
NewTag : NewAbiTagAttr->tags()) {
3328 if (!llvm::is_contained(OldAbiTagAttr->tags(),
NewTag)) {
3329 Diag(NewAbiTagAttr->getLocation(),
3330 diag::err_new_abi_tag_on_redeclaration)
3332 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
3336 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
3342 if (
New->hasAttr<SectionAttr>() && !Old->
hasAttr<SectionAttr>()) {
3343 if (
auto *VD = dyn_cast<VarDecl>(
New)) {
3345 Diag(
New->getLocation(), diag::warn_attribute_section_on_redeclaration);
3352 const auto *NewCSA =
New->getAttr<CodeSegAttr>();
3353 if (NewCSA && !Old->
hasAttr<CodeSegAttr>() &&
3355 Diag(
New->getLocation(), diag::warn_mismatched_section)
3363 bool foundAny =
New->hasAttrs();
3393 if (
auto *FD = dyn_cast<FunctionDecl>(
New);
3406 if (!foundAny)
New->dropAttrs();
3411 checkAttrIsTypeDependent(D, A);
3422 newAttr->setInherited(
true);
3444 foundAny |= std::forward<F>(propagator)(To, From) != 0;
3459 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
3460 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
3461 S.
Diag(CDA->getLocation(),
3462 diag::err_carries_dependency_missing_on_first_decl) << 1;
3470 diag::note_carries_dependency_missing_first_decl) << 1;
3489 auto NoSizeInfo = [&Ctx](
QualType Ty) {
3490 if (Ty->isIncompleteArrayType() || Ty->isPointerType())
3498 if (NoSizeInfo(Old) && NoSizeInfo(
New))
3530 if (*Oldnullability != *Newnullability) {
3531 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
3548 const auto *OldParamDT = dyn_cast<DecayedType>(OldParam->
getType());
3549 const auto *NewParamDT = dyn_cast<DecayedType>(NewParam->
getType());
3550 if (OldParamDT && NewParamDT &&
3551 OldParamDT->getPointeeType() == NewParamDT->getPointeeType()) {
3552 QualType OldParamOT = OldParamDT->getOriginalType();
3553 QualType NewParamOT = NewParamDT->getOriginalType();
3556 << NewParam << NewParamOT;
3567struct GNUCompatibleParamWarning {
3568 ParmVarDecl *OldParm;
3569 ParmVarDecl *NewParm;
3570 QualType PromotedType;
3577template <
typename T>
3578static std::pair<diag::kind, SourceLocation>
3582 if (Old->isThisDeclarationADefinition())
3583 PrevDiag = diag::note_previous_definition;
3584 else if (Old->isImplicit()) {
3585 PrevDiag = diag::note_previous_implicit_declaration;
3586 if (
const auto *FD = dyn_cast<FunctionDecl>(Old)) {
3587 if (FD->getBuiltinID())
3588 PrevDiag = diag::note_previous_builtin_declaration;
3591 OldLocation =
New->getLocation();
3593 PrevDiag = diag::note_previous_declaration;
3594 return std::make_pair(PrevDiag, OldLocation);
3602 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
3603 !LangOpts.CPlusPlus &&
3609 const AttributedType *AT = T->getAs<AttributedType>();
3610 while (AT && !AT->isCallingConv())
3611 AT = AT->getModifiedType()->getAs<AttributedType>();
3615template <
typename T>
3629template<
typename T>
static bool isExternC(T *D) {
return D->isExternC(); }
3636template<
typename ExpectedDecl>
3658 !Old->getDeclContext()->getRedeclContext()->Equals(
3659 New->getDeclContext()->getRedeclContext()) &&
3664 S.
Diag(
New->getLocation(), diag::err_using_decl_conflict_reverse);
3677 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
3678 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
3681 return AttrA && AttrB && AttrA->getType() == AttrB->getType() &&
3682 AttrA->isDynamic() == AttrB->isDynamic();
3708 if (NamedDC->Equals(SemaDC))
3711 assert((NamedDC->InEnclosingNamespaceSetOf(SemaDC) ||
3713 "unexpected context for redeclaration");
3724 if (
auto *FD = dyn_cast<FunctionDecl>(NewD))
3725 FixSemaDC(FD->getDescribedFunctionTemplate());
3726 else if (
auto *VD = dyn_cast<VarDecl>(NewD))
3727 FixSemaDC(VD->getDescribedVarTemplate());
3731 bool MergeTypeWithOld,
bool NewDeclIsDefn) {
3739 Diag(
New->getLocation(), diag::err_using_decl_friend);
3740 Diag(Shadow->getTargetDecl()->getLocation(),
3741 diag::note_using_decl_target);
3742 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl)
3750 New->getDescribedFunctionTemplate()) {
3762 Diag(
New->getLocation(), diag::err_redefinition_different_kind)
3763 <<
New->getDeclName();
3787 std::tie(PrevDiag, OldLocation) =
3797 !
New->getTemplateSpecializationInfo() &&
3800 Diag(
New->getLocation(), diag::ext_static_non_static) <<
New;
3801 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3803 Diag(
New->getLocation(), diag::err_static_non_static) <<
New;
3804 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3809 if (
const auto *ILA =
New->getAttr<InternalLinkageAttr>())
3810 if (!Old->
hasAttr<InternalLinkageAttr>()) {
3811 Diag(
New->getLocation(), diag::err_attribute_missing_on_first_decl)
3814 New->dropAttr<InternalLinkageAttr>();
3817 if (
auto *EA =
New->getAttr<ErrorAttr>()) {
3818 if (!Old->
hasAttr<ErrorAttr>()) {
3819 Diag(EA->getLocation(), diag::err_attribute_missing_on_first_decl) << EA;
3821 New->dropAttr<ErrorAttr>();
3829 bool OldOvl = Old->
hasAttr<OverloadableAttr>();
3830 if (OldOvl !=
New->hasAttr<OverloadableAttr>() && !Old->
isImplicit()) {
3831 Diag(
New->getLocation(), diag::err_attribute_overloadable_mismatch)
3840 const Decl *DiagOld = Old;
3842 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *D) {
3843 const auto *A = D->getAttr<OverloadableAttr>();
3844 return A && !A->isImplicit();
3853 diag::note_attribute_overloadable_prev_overload)
3857 New->addAttr(OverloadableAttr::CreateImplicit(
Context));
3859 New->dropAttr<OverloadableAttr>();
3866 Diag(
New->getLocation(), diag::err_sme_attr_mismatch)
3868 Diag(OldLocation, diag::note_previous_declaration);
3891 bool RequiresAdjustment =
false;
3893 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC()) {
3899 if (!NewCCExplicit) {
3903 RequiresAdjustment =
true;
3911 Diag(
New->getLocation(), diag::warn_cconv_unsupported)
3915 RequiresAdjustment =
true;
3919 Diag(
New->getLocation(), diag::err_cconv_change)
3922 << (!FirstCCExplicit ?
"" :
3926 Diag(
First->getLocation(), diag::note_previous_declaration);
3934 RequiresAdjustment =
true;
3946 NewQType =
Context.getFunctionType(FPT2->getReturnType(),
3947 FPT2->getParamTypes(), EPI2);
3949 New->setType(NewQType);
3958 Diag(
New->getLocation(), diag::err_regparm_mismatch)
3961 Diag(OldLocation, diag::note_previous_declaration);
3966 RequiresAdjustment =
true;
3972 Diag(
New->getLocation(), diag::err_function_attribute_mismatch)
3973 <<
"'ns_returns_retained'";
3974 Diag(OldLocation, diag::note_previous_declaration);
3979 RequiresAdjustment =
true;
3985 AnyX86NoCallerSavedRegistersAttr *
Attr =
3986 New->getAttr<AnyX86NoCallerSavedRegistersAttr>();
3987 Diag(
New->getLocation(), diag::err_function_attribute_mismatch) <<
Attr;
3988 Diag(OldLocation, diag::note_previous_declaration);
3993 RequiresAdjustment =
true;
3996 if (RequiresAdjustment) {
4000 NewQType =
Context.getCanonicalType(
New->getType());
4005 if (!Old->
isInlined() &&
New->isInlined() && !
New->hasAttr<GNUInlineAttr>() &&
4013 if (
New->hasAttr<GNUInlineAttr>() &&
4022 Diag(
New->getLocation(), diag::err_different_pass_object_size_params)
4023 <<
New->getDeclName();
4024 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4028 QualType OldQTypeForComparison = OldQType;
4029 if (
Context.hasAnyFunctionEffects()) {
4031 const auto NewFX =
New->getFunctionEffects();
4032 if (OldFX != NewFX) {
4034 for (
const auto &Diff : Diffs) {
4035 if (Diff.shouldDiagnoseRedeclaration(*Old, OldFX, *
New, NewFX)) {
4037 diag::warn_mismatched_func_effect_redeclaration)
4038 << Diff.effectName();
4049 if (!MergeErrs.empty())
4056 NewFPT->getParamTypes(), EPI);
4058 New->setType(ModQT);
4059 NewQType =
New->getType();
4064 EPI = OldFPT->getExtProtoInfo();
4066 OldQTypeForComparison =
Context.getFunctionType(
4067 OldFPT->getReturnType(), OldFPT->getParamTypes(), EPI);
4069 if (OldFX.empty()) {
4080 NewQType =
Context.getCanonicalType(
New->getType());
4088 QualType NewDeclaredReturnType =
New->getDeclaredReturnType();
4089 if (!
Context.hasSameType(OldDeclaredReturnType, NewDeclaredReturnType) &&
4091 OldDeclaredReturnType)) {
4096 ResQT =
Context.mergeObjCGCQualifiers(NewQType, OldQType);
4098 if (
New->isCXXClassMember() &&
New->isOutOfLine())
4099 Diag(
New->getLocation(), diag::err_member_def_does_not_match_ret_type)
4100 <<
New <<
New->getReturnTypeSourceRange();
4102 !Old->
hasAttr<OverloadableAttr>() &&
4103 !
New->hasAttr<OverloadableAttr>())
4104 Diag(
New->getLocation(), diag::err_conflicting_types) <<
New;
4106 Diag(
New->getLocation(), diag::err_ovl_diff_return_type)
4107 <<
New->getReturnTypeSourceRange();
4108 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
4118 if (OldReturnType != NewReturnType) {
4122 if (OldAT && OldAT->isDeduced()) {
4123 QualType DT = OldAT->getDeducedType();
4134 const CXXMethodDecl *OldMethod = dyn_cast<CXXMethodDecl>(Old);
4136 if (OldMethod && NewMethod) {
4143 bool IsClassScopeExplicitSpecialization =
4149 !IsClassScopeExplicitSpecialization) {
4154 Diag(
New->getLocation(), diag::err_ovl_static_nonstatic_member);
4155 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4166 NewDiag = diag::err_constructor_redeclared;
4168 NewDiag = diag::err_destructor_redeclared;
4170 NewDiag = diag::err_conv_function_redeclared;
4172 NewDiag = diag::err_member_redeclared;
4174 Diag(
New->getLocation(), NewDiag);
4176 Diag(
New->getLocation(), diag::err_member_redeclared_in_instantiation)
4177 <<
New <<
New->getType();
4179 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4192 diag::err_definition_of_implicitly_declared_member)
4198 diag::err_definition_of_explicitly_defaulted_member)
4221 if (
const auto *NRA =
New->getAttr<CXX11NoReturnAttr>())
4222 if (!Old->
hasAttr<CXX11NoReturnAttr>()) {
4223 Diag(NRA->getLocation(), diag::err_attribute_missing_on_first_decl)
4232 const CarriesDependencyAttr *CDA =
New->getAttr<CarriesDependencyAttr>();
4233 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
4234 Diag(CDA->getLocation(),
4235 diag::err_carries_dependency_missing_on_first_decl) << 0;
4237 diag::note_carries_dependency_missing_first_decl) << 0;
4245 const SYCLExternalAttr *SEA =
New->getAttr<SYCLExternalAttr>();
4246 if (SEA && !Old->
hasAttr<SYCLExternalAttr>()) {
4247 Diag(SEA->getLocation(), diag::warn_sycl_external_missing_on_first_decl)
4262 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
4276 Diag(
New->getLocation(), diag::ext_retained_language_linkage) <<
New;
4277 Diag(OldLocation, PrevDiag);
4279 Diag(
New->getLocation(), diag::err_different_language_linkage) <<
New;
4280 Diag(OldLocation, PrevDiag);
4287 if (
HLSL().CheckCompatibleParameterABI(
New, Old))
4295 if (
Context.hasSameFunctionTypeIgnoringParamABI(OldQTypeForComparison,
4305 if (
Context.hasSameFunctionTypeIgnoringExceptionSpec(OldQTypeForComparison,
4333 if (Old->
hasPrototype() && !
New->hasWrittenPrototype() && NewDeclIsDefn &&
4337 Diag(
New->getLocation(), diag::err_conflicting_types) <<
New;
4355 if (
New->hasWrittenPrototype()) {
4367 bool IsWithoutProtoADef =
false, IsWithProtoADef =
false;
4368 if (WithoutProto ==
New)
4369 IsWithoutProtoADef = NewDeclIsDefn;
4371 IsWithProtoADef = NewDeclIsDefn;
4373 diag::warn_non_prototype_changes_behavior)
4374 << IsWithoutProtoADef << (WithoutProto->
getNumParams() ? 0 : 1)
4375 << (WithoutProto == Old) << IsWithProtoADef;
4385 !IsWithoutProtoADef)
4391 if (
Context.typesAreCompatible(OldQType, NewQType)) {
4396 (OldProto = dyn_cast<FunctionProtoType>(OldFuncType))) {
4399 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
4400 NewQType =
Context.getFunctionType(NewFuncType->getReturnType(),
4401 OldProto->getParamTypes(),
4402 OldProto->getExtProtoInfo());
4403 New->setType(NewQType);
4404 New->setHasInheritedPrototype();
4408 for (
const auto &ParamType : OldProto->param_types()) {
4411 ParamType,
nullptr,
SC_None,
nullptr);
4412 Param->setScopeInfo(0, Params.size());
4413 Param->setImplicit();
4414 Params.push_back(Param);
4417 New->setParams(Params);
4426 if (
Context.hasSameFunctionTypeIgnoringPtrSizes(OldQType, NewQType))
4453 NewProto->getReturnType());
4454 bool LooseCompatible = !MergedReturn.isNull();
4456 LooseCompatible && Idx != End; ++Idx) {
4460 NewProto->getParamType(Idx))) {
4461 ArgTypes.push_back(NewParm->
getType());
4465 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
4466 NewProto->getParamType(Idx) };
4467 Warnings.push_back(Warn);
4468 ArgTypes.push_back(NewParm->
getType());
4470 LooseCompatible =
false;
4473 if (LooseCompatible) {
4474 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
4475 Diag(Warnings[Warn].NewParm->getLocation(),
4476 diag::ext_param_promoted_not_compatible_with_prototype)
4477 << Warnings[Warn].PromotedType
4478 << Warnings[Warn].OldParm->getType();
4479 if (Warnings[Warn].OldParm->getLocation().isValid())
4480 Diag(Warnings[Warn].OldParm->getLocation(),
4481 diag::note_previous_declaration);
4484 if (MergeTypeWithOld)
4485 New->setType(
Context.getFunctionType(MergedReturn, ArgTypes,
4502 if (
Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) {
4503 Diag(
New->getLocation(), diag::warn_redecl_library_builtin) <<
New;
4504 Diag(OldLocation, diag::note_previous_builtin_declaration)
4509 PrevDiag = diag::note_previous_builtin_declaration;
4512 Diag(
New->getLocation(), diag::err_conflicting_types) <<
New->getDeclName();
4513 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4518 Scope *S,
bool MergeTypeWithOld) {
4524 New->setIsPureVirtual();
4533 for (
unsigned i = 0, e =
New->getNumParams(); i != e; ++i) {
4547 if (!Merged.isNull() && MergeTypeWithOld)
4548 New->setType(Merged);
4572 ni != ne && oi != oe; ++ni, ++oi)
4581 S.
Diag(
New->getLocation(),
New->isThisDeclarationADefinition()
4582 ? diag::err_redefinition_different_type
4583 : diag::err_redeclaration_different_type)
4588 std::tie(PrevDiag, OldLocation)
4590 S.
Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4591 New->setInvalidDecl();
4595 bool MergeTypeWithOld) {
4601 if (
New->getType()->isUndeducedType()) {
4623 QualType PrevVDTy = PrevVD->getType();
4627 if (!
Context.hasSameType(
New->getType(), PrevVDTy))
4635 MergedT =
New->getType();
4646 else if (
New->getType()->isObjCObjectPointerType() &&
4648 MergedT =
Context.mergeObjCGCQualifiers(
New->getType(),
4663 if ((
New->getType()->isDependentType() ||
4668 if (!
New->getType()->isDependentType() && MergeTypeWithOld)
4677 if (MergeTypeWithOld)
4678 New->setType(MergedT);
4712 if (
New->isInvalidDecl())
4725 OldTemplate = dyn_cast<VarTemplateDecl>(
Previous.getFoundDecl());
4729 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4731 return New->setInvalidDecl();
4733 Old = dyn_cast<VarDecl>(
Previous.getFoundDecl());
4736 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4738 return New->setInvalidDecl();
4742 Diag(
New->getLocation(), diag::err_redefinition_different_kind)
4743 <<
New->getDeclName();
4745 New->getLocation());
4746 return New->setInvalidDecl();
4758 return New->setInvalidDecl();
4765 Diag(
New->getLocation(), diag::err_duplicate_member)
4766 <<
New->getIdentifier();
4768 New->setInvalidDecl();
4774 if (
New->hasAttr<WeakImportAttr>())
4777 Diag(
New->getLocation(), diag::warn_weak_import) <<
New->getDeclName();
4780 New->dropAttr<WeakImportAttr>();
4785 if (
const auto *ILA =
New->getAttr<InternalLinkageAttr>())
4786 if (!Old->
hasAttr<InternalLinkageAttr>()) {
4787 Diag(
New->getLocation(), diag::err_attribute_missing_on_first_decl)
4790 New->dropAttr<InternalLinkageAttr>();
4795 if (MostRecent != Old) {
4798 if (
New->isInvalidDecl())
4803 if (
New->isInvalidDecl())
4808 std::tie(PrevDiag, OldLocation) =
4813 !
New->isStaticDataMember() &&
4816 Diag(
New->getLocation(), diag::ext_static_non_static)
4817 <<
New->getDeclName();
4818 Diag(OldLocation, PrevDiag);
4820 Diag(
New->getLocation(), diag::err_static_non_static)
4821 <<
New->getDeclName();
4822 Diag(OldLocation, PrevDiag);
4823 return New->setInvalidDecl();
4837 else if (
New->getCanonicalDecl()->getStorageClass() !=
SC_Static &&
4838 !
New->isStaticDataMember() &&
4840 Diag(
New->getLocation(), diag::err_non_static_static) <<
New->getDeclName();
4841 Diag(OldLocation, PrevDiag);
4842 return New->setInvalidDecl();
4846 if (
New->hasExternalStorage() &&
4848 Diag(
New->getLocation(), diag::err_extern_non_extern) <<
New->getDeclName();
4849 Diag(OldLocation, PrevDiag);
4850 return New->setInvalidDecl();
4853 !
New->hasExternalStorage()) {
4854 Diag(
New->getLocation(), diag::err_non_extern_extern) <<
New->getDeclName();
4855 Diag(OldLocation, PrevDiag);
4856 return New->setInvalidDecl();
4866 if (!
New->hasExternalStorage() && !
New->isFileVarDecl() &&
4869 !
New->getLexicalDeclContext()->isRecord())) {
4870 Diag(
New->getLocation(), diag::err_redefinition) <<
New->getDeclName();
4871 Diag(OldLocation, PrevDiag);
4872 return New->setInvalidDecl();
4880 Diag(
New->getLocation(), diag::err_inline_decl_follows_def) <<
New;
4881 Diag(Def->getLocation(), diag::note_previous_definition);
4895 Diag(
New->getLocation(), diag::err_thread_non_thread) <<
New->getDeclName();
4896 Diag(OldLocation, PrevDiag);
4897 }
else if (!
New->getTLSKind()) {
4898 Diag(
New->getLocation(), diag::err_non_thread_thread) <<
New->getDeclName();
4899 Diag(OldLocation, PrevDiag);
4905 Diag(
New->getLocation(), diag::err_thread_thread_different_kind)
4907 Diag(OldLocation, PrevDiag);
4917 diag::warn_deprecated_redundant_constexpr_static_def);
4923 New->setInvalidDecl();
4932 Diag(
New->getLocation(), diag::warn_cxx_compat_tentative_definition)
4939 Diag(
New->getLocation(), diag::err_different_language_linkage) <<
New;
4940 Diag(OldLocation, PrevDiag);
4941 New->setInvalidDecl();
4950 New->setPreviousDecl(Old);
4960 New->setImplicitlyInline();
4965 auto FNewDecLoc =
SrcMgr.getDecomposedLoc(
New);
4967 auto *FNew =
SrcMgr.getFileEntryForID(FNewDecLoc.first);
4968 auto FOld =
SrcMgr.getFileEntryRefForID(FOldDecLoc.first);
4969 auto &HSI =
PP.getHeaderSearchInfo();
4970 StringRef HdrFilename =
4973 auto noteFromModuleOrInclude = [&](
Module *Mod,
4979 if (IncLoc.isValid()) {
4981 Diag(IncLoc, diag::note_redefinition_modules_same_file)
4987 Diag(IncLoc, diag::note_redefinition_include_same_file)
4988 << HdrFilename.str();
4998 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
5006 if (FOld && !HSI.isFileMultipleIncludeGuarded(*FOld))
5022 New->getDescribedVarTemplate() ||
5023 !
New->getTemplateParameterLists().empty() ||
5024 New->getDeclContext()->isDependentContext() ||
5025 New->hasAttr<SelectAnyAttr>())) {
5028 New->demoteThisDefinitionToDeclaration();
5036 Diag(
New->getLocation(), diag::err_redefinition) <<
New;
5038 New->setInvalidDecl();
5064 if (!
Context.getLangOpts().CPlusPlus)
5070 if (!Tag->getName().empty() || Tag->getTypedefNameForAnonDecl())
5073 Context.getManglingNumberContext(Tag->getParent());
5082 Decl *ManglingContextDecl;
5083 std::tie(MCtx, ManglingContextDecl) =
5093struct NonCLikeKind {
5105 explicit operator bool() {
return Kind !=
None; }
5113 return {NonCLikeKind::Invalid, {}};
5120 return {NonCLikeKind::BaseClass,
5132 if (
auto *FD = dyn_cast<FieldDecl>(D)) {
5133 if (FD->hasInClassInitializer()) {
5134 auto *
Init = FD->getInClassInitializer();
5135 return {NonCLikeKind::DefaultMemberInit,
5151 auto *MemberRD = dyn_cast<CXXRecordDecl>(D);
5159 if (MemberRD->isLambda())
5160 return {NonCLikeKind::Lambda, MemberRD->getSourceRange()};
5164 if (MemberRD->isThisDeclarationADefinition()) {
5170 return {
Invalid ? NonCLikeKind::Invalid : NonCLikeKind::None, {}};
5187 Context.getCanonicalTagType(TagFromDeclSpec))) {
5189 Context.addTypedefNameForUnnamedTagDecl(TagFromDeclSpec, NewTD);
5200 const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(TagFromDeclSpec);
5204 if (NonCLike || ChangesLinkage) {
5205 if (NonCLike.Kind == NonCLikeKind::Invalid)
5208 unsigned DiagID = diag::ext_non_c_like_anon_struct_in_typedef;
5209 if (ChangesLinkage) {
5211 if (NonCLike.Kind == NonCLikeKind::None)
5212 DiagID = diag::err_typedef_changes_linkage;
5214 DiagID = diag::err_non_c_like_anon_struct_in_typedef;
5220 TextToInsert +=
' ';
5223 Diag(FixitLoc, DiagID)
5226 if (NonCLike.Kind != NonCLikeKind::None) {
5227 Diag(NonCLike.Range.
getBegin(), diag::note_non_c_like_anon_struct)
5228 << NonCLike.Kind - 1 << NonCLike.Range;
5231 << NewTD << isa<TypeAliasDecl>(NewTD);
5256 if (
const auto *ED = dyn_cast<EnumDecl>(DS.
getRepAsDecl())) {
5257 if (ED->isScopedUsingClassTag())
5264 llvm_unreachable(
"unexpected type specifier");
5272 bool IsExplicitInstantiation,
5275 Decl *TagD =
nullptr;
5293 Tag = CTD->getTemplatedDecl();
5298 Tag->setFreeStanding();
5299 if (Tag->isInvalidDecl())
5308 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
5345 "Friend ellipsis but not friend-specified?");
5348 bool DeclaresAnything =
true;
5352 if (!
Record->getDeclName() &&
Record->isCompleteDefinition() &&
5355 Record->getDeclContext()->isRecord()) {
5369 DeclaresAnything =
false;
5388 if ((Tag && Tag->getDeclName()) ||
5398 DeclaresAnything =
false;
5410 if (
Enum->enumerators().empty() && !
Enum->getIdentifier() &&
5411 !
Enum->isInvalidDecl())
5412 DeclaresAnything =
false;
5420 DeclaresAnything =
false;
5424 Tag && Tag->getDeclContext()->isFunctionOrMethod())
5426 << Tag->getTagKind()
5439 if (!DeclaresAnything) {
5442 Diag(DS.
getBeginLoc(), (IsExplicitInstantiation || !TemplateParams.empty())
5443 ? diag::err_no_declarators
5444 : diag::ext_no_declarators)
5457 unsigned DiagID = diag::warn_standalone_specifier;
5459 DiagID = diag::ext_standalone_specifier;
5500 auto EmitAttributeDiagnostic = [
this, &DS](
const ParsedAttr &AL) {
5501 unsigned DiagnosticId = diag::warn_declspec_attribute_ignored;
5503 DiagnosticId = diag::warn_attribute_ignored;
5504 else if (AL.isRegularKeywordAttribute())
5505 DiagnosticId = diag::err_declspec_keyword_has_no_effect;
5507 DiagnosticId = diag::warn_declspec_attribute_ignored;
5508 Diag(AL.getLoc(), DiagnosticId)
5512 llvm::for_each(DS.
getAttributes(), EmitAttributeDiagnostic);
5513 llvm::for_each(DeclAttrs, EmitAttributeDiagnostic);
5536 NamedDecl *PrevDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
5537 assert(PrevDecl &&
"Expected a non-null Decl");
5550 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
5552 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
5558 if (
auto *RD = dyn_cast_if_present<RecordDecl>(D))
5568 if (
Record->isAnonymousStructOrUnion())
5573 const NamedDecl *ND = dyn_cast<NamedDecl>(D);
5607 for (
auto *D : AnonRecord->
decls()) {
5630 unsigned OldChainingSize = Chaining.size();
5632 Chaining.append(IF->chain_begin(), IF->chain_end());
5634 Chaining.push_back(VD);
5636 assert(Chaining.size() >= 2);
5639 for (
unsigned i = 0; i < Chaining.size(); i++)
5640 NamedChain[i] = Chaining[i];
5644 VD->
getType(), {NamedChain, Chaining.size()});
5658 Chaining.resize(OldChainingSize);
5672 "Parser allowed 'typedef' as storage class VarDecl.");
5673 switch (StorageClassSpec) {
5687 llvm_unreachable(
"unknown storage class specifier");
5691 assert(
Record->hasInClassInitializer());
5693 for (
const auto *I :
Record->decls()) {
5694 const auto *FD = dyn_cast<FieldDecl>(I);
5695 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
5696 FD = IFD->getAnonField();
5697 if (FD && FD->hasInClassInitializer())
5698 return FD->getLocation();
5701 llvm_unreachable(
"couldn't find in-class initializer");
5709 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
5729 Diag(
Record->getLocation(), diag::ext_anonymous_union);
5731 Diag(
Record->getLocation(), diag::ext_gnu_anonymous_struct);
5733 Diag(
Record->getLocation(), diag::ext_c11_anonymous_struct);
5739 const char *PrevSpec =
nullptr;
5751 Diag(
Record->getLocation(), diag::err_anonymous_union_not_static)
5756 PrevSpec, DiagID, Policy);
5764 diag::err_anonymous_union_with_storage_spec)
5770 PrevSpec, DiagID,
Context.getPrintingPolicy());
5778 <<
Record->isUnion() <<
"const"
5782 diag::ext_anonymous_struct_union_qualified)
5783 <<
Record->isUnion() <<
"volatile"
5787 diag::ext_anonymous_struct_union_qualified)
5788 <<
Record->isUnion() <<
"restrict"
5792 diag::ext_anonymous_struct_union_qualified)
5793 <<
Record->isUnion() <<
"_Atomic"
5797 diag::ext_anonymous_struct_union_qualified)
5798 <<
Record->isUnion() <<
"__unaligned"
5808 for (
auto *Mem :
Record->decls()) {
5810 if (Mem->isInvalidDecl())
5813 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
5817 assert(FD->getAccess() !=
AS_none);
5819 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
5831 }
else if (Mem->isImplicit()) {
5838 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
5839 if (!MemRecord->isAnonymousStructOrUnion() &&
5840 MemRecord->getDeclName()) {
5843 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
5847 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
5855 Diag(MemRecord->getLocation(),
5856 diag::ext_anonymous_record_with_anonymous_type)
5866 unsigned DK = diag::err_anonymous_record_bad_member;
5868 DK = diag::err_anonymous_record_with_type;
5870 DK = diag::err_anonymous_record_with_function;
5872 DK = diag::err_anonymous_record_with_static;
5876 DK == diag::err_anonymous_record_with_type)
5877 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
5880 Diag(Mem->getLocation(), DK) <<
Record->isUnion();
5896 Diag(
Record->getLocation(), diag::err_anonymous_struct_not_member)
5917 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
5921 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
5937 Diag(
Record->getLocation(), diag::err_mutable_nonmember);
5943 Record->getLocation(),
nullptr,
5959 Record->setAnonymousStructOrUnion(
true);
5970 Chain.push_back(Anon);
5976 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
5979 Decl *ManglingContextDecl;
5980 std::tie(MCtx, ManglingContextDecl) =
5999 assert(
Record &&
"expected a record!");
6004 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
6012 nullptr, RecTy, TInfo,
6024 Chain.push_back(Anon);
6028 diag::err_field_incomplete_or_sizeless) ||
6033 ParentDecl->setInvalidDecl();
6070 diag::err_deduction_guide_name_not_class_template)
6090 NameInfo.
setName(
Context.DeclarationNames.getCXXLiteralOperatorName(
6100 NameInfo.
setName(
Context.DeclarationNames.getCXXConversionFunctionName(
6101 Context.getCanonicalType(Ty)));
6112 Context.getCanonicalType(Ty)));
6133 Context.DeclarationNames.getCXXConstructorName(CurClassType));
6145 Context.getCanonicalType(Ty)));
6153 return Context.getNameForTemplate(TName, TNameLoc);
6158 llvm_unreachable(
"Unknown name kind");
6186 for (
unsigned Idx = 0; Idx <
Declaration->param_size(); ++Idx) {
6191 if (Context.hasSameUnqualifiedType(DefParamTy, DeclParamTy))
6199 if (Context.hasSameUnqualifiedType(DeclParamBaseTy, DefParamBaseTy) ||
6200 (DeclTyName && DeclTyName == DefTyName))
6201 Params.push_back(Idx);
6228#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case DeclSpec::TST_##Trait:
6229#include "clang/Basic/TransformTypeTraits.def"
6234 if (T.isNull() || !T->isInstantiationDependentType())
break;
6244 if (!TSI)
return true;
6257 if (
Result.isInvalid())
return true;
6302 << D << static_cast<int>(Status);
6313 if (
OpenMP().getOMPTraitInfoForSurroundingScope()->isExtensionActive(
6314 llvm::omp::TraitProperty::
6315 implementation_extension_bind_to_declaration))
6340 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
6351 bool IsMemberSpecialization) {
6352 assert(SS.
isValid() &&
"diagnoseQualifiedDeclaration called for declaration "
6353 "without nested-name-specifier");
6369 Diag(Loc,
LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
6370 : diag::err_member_extra_qualification)
6374 Diag(Loc, diag::warn_namespace_member_extra_qualification) << Name;
6382 if (!Cur->
Encloses(DC) && !(TemplateId || IsMemberSpecialization)) {
6384 Diag(Loc, diag::err_member_qualification)
6387 Diag(Loc, diag::err_invalid_declarator_global_scope)
6390 Diag(Loc, diag::err_invalid_declarator_in_function)
6393 Diag(Loc, diag::err_invalid_declarator_in_block)
6397 Diag(Loc, diag::err_export_non_namespace_scope_name)
6404 Diag(Loc, diag::err_invalid_declarator_scope)
6414 if (IsMemberSpecialization)
6418 Diag(Loc, diag::err_member_qualification)
6445 Diag(Loc, diag::ext_template_after_declarative_nns)
6450 TL = std::exchange(NextTL,
TypeLoc())) {
6452 switch (TL.getTypeLocClass()) {
6453 case TypeLoc::TemplateSpecialization: {
6455 TemplateKeywordLoc = TST.getTemplateKeywordLoc();
6456 if (
auto *T = TST.getTypePtr(); T->isDependentType() && T->isTypeAlias())
6457 Diag(Loc, diag::ext_alias_template_in_declarative_nns)
6458 << TST.getLocalSourceRange();
6461 case TypeLoc::Decltype:
6462 case TypeLoc::PackIndexing: {
6463 const Type *T = TL.getTypePtr();
6470 Diag(Loc, diag::err_computed_type_in_declarative_nns)
6471 << T->isDecltypeType() << TL.getSourceRange();
6474 case TypeLoc::DependentName:
6481 if (TemplateKeywordLoc.
isValid())
6482 Diag(Loc, diag::ext_template_after_declarative_nns)
6523 diag::err_template_qualified_declarator_no_match)
6530 if (!IsDependentContext &&
6537 diag::err_member_def_undefined_record)
6558 if (EnteringContext && IsDependentContext &&
6559 TemplateParamLists.size() != 0) {
6578 bool IsLinkageLookup =
false;
6579 bool CreateBuiltins =
false;
6592 R->isFunctionType())) {
6593 IsLinkageLookup =
true;
6595 CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
6596 }
else if (
CurContext->getRedeclContext()->isTranslationUnit() &&
6598 CreateBuiltins =
true;
6600 if (IsLinkageLookup) {
6642 bool AllowForCompatibility =
false;
6645 AllowForCompatibility = DeclParent->Contains(*TemplateParamParent) &&
6646 TemplateParamParent->isDeclScope(TPD);
6649 AllowForCompatibility);
6666 (TemplateParamLists.size() == 0 || R->isFunctionType()))
6679 bool AddToScope =
true;
6681 if (TemplateParamLists.size()) {
6687 }
else if (R->isFunctionType()) {
6703 if (
New->getDeclName() && AddToScope)
6706 if (
OpenMP().isInOpenMPDeclareTargetContext())
6717 bool &SizeIsNegative,
6718 llvm::APSInt &Oversized) {
6723 SizeIsNegative =
false;
6726 if (T->isDependentType())
6732 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
6737 if (FixedType.
isNull())
return FixedType;
6738 FixedType = Context.getPointerType(FixedType);
6739 return Qs.
apply(Context, FixedType);
6741 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
6742 QualType Inner = PTy->getInnerType();
6746 if (FixedType.
isNull())
return FixedType;
6747 FixedType = Context.getParenType(FixedType);
6748 return Qs.
apply(Context, FixedType);
6758 SizeIsNegative, Oversized);
6768 llvm::APSInt Res =
Result.Val.getInt();
6771 if (Res.isSigned() && Res.isNegative()) {
6772 SizeIsNegative =
true;
6777 unsigned ActiveSizeBits =
6781 : Res.getActiveBits();
6783 Oversized = std::move(Res);
6787 QualType FoldedArrayType = Context.getConstantArrayType(
6789 return Qs.
apply(Context, FoldedArrayType);
6814 TypeLoc DstElemTL = DstATL.getElementLoc();
6833 bool &SizeIsNegative,
6834 llvm::APSInt &Oversized) {
6837 SizeIsNegative, Oversized);
6840 TypeSourceInfo *FixedTInfo = Context.getTrivialTypeSourceInfo(FixedTy);
6848 unsigned FailedFoldDiagID) {
6849 bool SizeIsNegative;
6850 llvm::APSInt Oversized;
6852 TInfo,
Context, SizeIsNegative, Oversized);
6854 Diag(Loc, diag::ext_vla_folded_to_constant);
6861 Diag(Loc, diag::err_typecheck_negative_array_size);
6862 else if (Oversized.getBoolValue())
6864 Oversized, 10, Oversized.isSigned(),
false,
6866 else if (FailedFoldDiagID)
6867 Diag(Loc, FailedFoldDiagID);
6879 Context.getExternCContextDecl()->makeDeclVisibleInContext(ND);
6884 auto Result =
Context.getExternCContextDecl()->lookup(Name);
6893 diag::err_virtual_non_function);
6897 diag::err_explicit_non_function);
6901 diag::err_noreturn_non_function);
6922 ? diag::warn_ms_inline_non_function
6923 : diag::err_inline_non_function)
6927 << 1 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
6932 diag::err_deduction_guide_invalid_specifier)
6941 if (!NewTD)
return nullptr;
6962 if (T->isVariablyModifiedType()) {
6966 bool SizeIsNegative;
6967 llvm::APSInt Oversized;
6978 else if (T->isVariableArrayType())
6980 else if (Oversized.getBoolValue())
7017 switch (II->getNotableIdentifierID()) {
7018 case tok::NotableIdentifierKind::FILE:
7021 case tok::NotableIdentifierKind::jmp_buf:
7022 Context.setjmp_bufDecl(NewTD);
7024 case tok::NotableIdentifierKind::sigjmp_buf:
7025 Context.setsigjmp_bufDecl(NewTD);
7027 case tok::NotableIdentifierKind::ucontext_t:
7028 Context.setucontext_tDecl(NewTD);
7030 case tok::NotableIdentifierKind::float_t:
7031 case tok::NotableIdentifierKind::double_t:
7032 NewTD->
addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(
Context));
7069 if (Context.getLangOpts().CPlusPlus) {
7093 if (!OuterContext->
Equals(PrevOuterContext))
7102 if (!SS.
isSet())
return;
7129 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
7138 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
7139 if (VD->hasInit()) {
7140 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
7141 assert(VD->isThisDeclarationADefinition() &&
7142 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
7144 VD->dropAttr<AliasAttr>();
7153 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
7156 diag::err_attribute_selectany_non_extern_data);
7163 if (HybridPatchableAttr *
Attr = ND.
getAttr<HybridPatchableAttr>()) {
7166 diag::warn_attribute_hybrid_patchable_non_extern);
7172 auto *VD = dyn_cast<VarDecl>(&ND);
7173 bool IsAnonymousNS =
false;
7176 const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(VD->getDeclContext());
7177 while (NS && !IsAnonymousNS) {
7179 NS = dyn_cast<NamespaceDecl>(NS->
getParent());
7186 bool AnonNSInMicrosoftMode = IsAnonymousNS && IsMicrosoft;
7188 (!AnonNSInMicrosoftMode &&
7199 if (
const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
7200 FD = FD->getMostRecentDecl();
7205 for (
TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
7211 if (
const auto *A = ATL.
getAttrAs<LifetimeBoundAttr>()) {
7212 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
7213 int NoImplicitObjectError = -1;
7215 NoImplicitObjectError = 0;
7216 else if (MD->isStatic())
7217 NoImplicitObjectError = 1;
7218 else if (MD->isExplicitObjectMemberFunction())
7219 NoImplicitObjectError = 2;
7220 if (NoImplicitObjectError != -1) {
7221 S.
Diag(A->getLocation(), diag::err_lifetimebound_no_object_param)
7222 << NoImplicitObjectError << A->getRange();
7224 S.
Diag(A->getLocation(), diag::err_lifetimebound_ctor_dtor)
7226 }
else if (MD->getReturnType()->isVoidType()) {
7230 err_lifetimebound_implicit_object_parameter_void_return_type);
7235 for (
unsigned int I = 0; I < FD->getNumParams(); ++I) {
7240 if (
auto *A = P->
getAttr<LifetimeBoundAttr>()) {
7242 S.
Diag(A->getLocation(),
7243 diag::err_lifetimebound_parameter_void_return_type);
7251 if (ND.
hasAttr<ModularFormatAttr>() && !ND.
hasAttr<FormatAttr>())
7252 S.
Diag(ND.
getLocation(), diag::err_modular_format_attribute_no_format);
7271 bool IsSpecialization,
7272 bool IsDefinition) {
7276 bool IsTemplate =
false;
7277 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
7278 OldDecl = OldTD->getTemplatedDecl();
7280 if (!IsSpecialization)
7281 IsDefinition =
false;
7283 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
7284 NewDecl = NewTD->getTemplatedDecl();
7288 if (!OldDecl || !NewDecl)
7291 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
7292 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
7293 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
7294 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
7298 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
7299 (NewExportAttr && !NewExportAttr->isInherited());
7305 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
7307 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
7309 bool JustWarn =
false;
7311 auto *VD = dyn_cast<VarDecl>(OldDecl);
7312 if (VD && !VD->getDescribedVarTemplate())
7314 auto *FD = dyn_cast<FunctionDecl>(OldDecl);
7326 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
7327 : diag::err_attribute_dll_redeclaration;
7330 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
7343 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
7345 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
7348 IsStaticDataMember = VD->isStaticDataMember();
7349 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
7351 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
7352 IsInline = FD->isInlined();
7353 IsQualifiedFriend = FD->getQualifier() &&
7357 if (OldImportAttr && !HasNewAttr &&
7358 (!IsInline || (IsMicrosoftABI && IsTemplate)) && !IsStaticDataMember &&
7360 if (IsMicrosoftABI && IsDefinition) {
7361 if (IsSpecialization) {
7364 diag::err_attribute_dllimport_function_specialization_definition);
7365 S.
Diag(OldImportAttr->getLocation(), diag::note_attribute);
7366 NewDecl->
dropAttr<DLLImportAttr>();
7369 diag::warn_redeclaration_without_import_attribute)
7372 NewDecl->
dropAttr<DLLImportAttr>();
7373 NewDecl->
addAttr(DLLExportAttr::CreateImplicit(
7374 S.
Context, NewImportAttr->getRange()));
7376 }
else if (IsMicrosoftABI && IsSpecialization) {
7377 assert(!IsDefinition);
7381 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
7382 << NewDecl << OldImportAttr;
7384 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
7385 OldDecl->
dropAttr<DLLImportAttr>();
7386 NewDecl->
dropAttr<DLLImportAttr>();
7388 }
else if (IsInline && OldImportAttr && !IsMicrosoftABI) {
7391 OldDecl->
dropAttr<DLLImportAttr>();
7392 NewDecl->
dropAttr<DLLImportAttr>();
7394 diag::warn_dllimport_dropped_from_inline_function)
7395 << NewDecl << OldImportAttr;
7402 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
7404 !NewImportAttr && !NewExportAttr) {
7405 if (
const DLLExportAttr *ParentExportAttr =
7406 MD->getParent()->getAttr<DLLExportAttr>()) {
7407 DLLExportAttr *NewAttr = ParentExportAttr->clone(S.
Context);
7408 NewAttr->setInherited(
true);
7460 return D->isExternC();
7477 llvm_unreachable(
"Unexpected context");
7487 llvm_unreachable(
"Unexpected context");
7532 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
7533 return FD->isExternC();
7534 if (
const auto *VD = dyn_cast<VarDecl>(D))
7535 return VD->isExternC();
7537 llvm_unreachable(
"Unknown type of decl!");
7548 if (R->isImageType() || R->isPipeType()) {
7550 diag::err_opencl_type_can_only_be_used_as_function_parameter)
7562 if (R->isReserveIDT() || R->isClkEventT() || R->isEventT()) {
7564 diag::err_invalid_type_for_program_scope_var)
7574 QualType NR = R.getCanonicalType();
7593 Se.
Diag(NewVD->
getLocation(), diag::err_opencl_half_declaration) << R;
7602 if (R->isEventT()) {
7610 if (R->isSamplerT()) {
7625 R.isConstQualified())) {
7626 Se.
Diag(NewVD->
getLocation(), diag::err_opencl_nonconst_global_sampler);
7636template <
typename AttrTy>
7639 if (
const auto *Attribute = TND->
getAttr<AttrTy>()) {
7640 AttrTy *Clone = Attribute->clone(S.
Context);
7641 Clone->setInherited(
true);
7669 if (
const auto *ConstDecl = RD->
getAttr<ReadOnlyPlacementAttr>()) {
7671 S.
Diag(ConstDecl->getLocation(), diag::note_enforce_read_only_placement);
7678 "NewD is not a function or variable");
7687 if (IdentName ==
nullptr)
7691 auto &Label = PendingName->second;
7697 Diag(Label.NameLoc, diag::warn_pragma_not_applied) <<
"export" << NewD;
7707 (VD->
getDeclContext()->getRedeclContext()->isTranslationUnit() ||
7726 Diag(E->
getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
7730 if (!
Context.getTargetInfo().isValidGCCRegisterName(Label) &&
7732 Diag(E->
getExprLoc(), diag::err_asm_unknown_register_name) << Label;
7742 const auto &TI =
Context.getTargetInfo();
7743 bool HasSizeMismatch;
7745 if (!TI.isValidGCCRegisterName(Label))
7746 Diag(E->
getExprLoc(), diag::err_asm_unknown_register_name) << Label;
7747 else if (!TI.validateGlobalRegisterVariable(Label,
Context.getTypeSize(R),
7749 Diag(E->
getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
7750 else if (HasSizeMismatch)
7751 Diag(E->
getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
7754 if (!
R->isIntegralType(
Context) && !
R->isPointerType()) {
7756 diag::err_asm_unsupported_register_type)
7771 bool IsPlaceholderVariable =
false;
7777 if (!Decomp.bindings().empty()) {
7778 II = Decomp.bindings()[0].Name;
7792 IsPlaceholderVariable =
true;
7800 if (IsPlaceholderVariable)
7814 bool IsLocalExternDecl = SC ==
SC_Extern &&
7833 : diag::warn_deprecated_register)
7856 const AutoType *AT = TL.getTypePtr();
7860 bool IsMemberSpecialization =
false;
7861 bool IsVariableTemplateSpecialization =
false;
7863 bool IsVariableTemplate =
false;
7871 if (R->getContainedDeducedType())
7892 false, IsMemberSpecialization,
Invalid);
7894 if (TemplateParams) {
7901 if (!TemplateParams->
size() &&
7906 diag::err_template_variable_noparams)
7910 TemplateParams =
nullptr;
7918 IsVariableTemplateSpecialization =
true;
7922 IsVariableTemplate =
true;
7930 if (!TemplateParamLists.empty() && IsMemberSpecialization &&
7935 "should have a 'template<>' for this decl");
7938 bool IsExplicitSpecialization =
7949 (IsExplicitSpecialization || IsMemberSpecialization)) {
7951 diag::ext_explicit_specialization_storage_class)
7957 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
7963 if (Ctxt->isFunctionOrMethod()) {
7964 FunctionOrMethod = Ctxt;
7967 const CXXRecordDecl *ParentDecl = dyn_cast<CXXRecordDecl>(Ctxt);
7969 AnonStruct = ParentDecl;
7973 if (FunctionOrMethod) {
7977 diag::err_static_data_member_not_allowed_in_local_class)
7978 << Name << RD->getDeclName() << RD->getTagKind();
7980 }
else if (AnonStruct) {
7985 diag::err_static_data_member_not_allowed_in_anon_struct)
7988 }
else if (RD->isUnion()) {
7992 diag_compat::static_data_member_in_union)
8010 diag::err_static_out_of_line)
8023 diag::err_storage_class_for_static_member)
8028 llvm_unreachable(
"C storage class in c++!");
8032 if (IsVariableTemplateSpecialization) {
8034 TemplateParamLists.size() > 0
8035 ? TemplateParamLists[0]->getTemplateLoc()
8038 S, D, TInfo,
Previous, TemplateKWLoc, TemplateParams, SC,
8053 if (IsVariableTemplate) {
8056 TemplateParams, NewVD);
8062 if (R->getContainedDeducedType())
8077 unsigned VDTemplateParamLists =
8078 (TemplateParams && !IsExplicitSpecialization) ? 1 : 0;
8079 if (TemplateParamLists.size() > VDTemplateParamLists)
8081 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
8088 }
else if (
CurContext->isFunctionOrMethod()) {
8091 diag::err_inline_declaration_block_scope) << Name
8096 : diag::compat_pre_cxx17_inline_variable);
8107 if (IsLocalExternDecl) {
8110 B->setLocalExternDecl();
8115 bool EmitTLSUnsupportedError =
false;
8128 diag::err_thread_non_global)
8130 else if (!
Context.getTargetInfo().isTLSSupported()) {
8135 EmitTLSUnsupportedError =
true;
8142 diag::err_thread_unsupported);
8153 diag::err_constexpr_wrong_decl_kind)
8154 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
8164 Context.getTargetInfo().getCXXABI().isMicrosoft()))
8171 diag::err_constinit_local_variable);
8175 ConstInitAttr::Keyword_constinit));
8193 diag::warn_static_local_in_extern_inline);
8199 if (IsVariableTemplateSpecialization)
8204 else if (IsMemberSpecialization)
8219 B->setModulePrivate();
8229 diag::err_opencl_unknown_type_specifier)
8239 if (
const auto *ATy = dyn_cast<ArrayType>(NewVD->
getType())) {
8240 if (ATy && ATy->getElementType().isWebAssemblyReferenceType() &&
8258 llvm::MapVector<IdentifierInfo *, AsmLabelAttr *>::iterator I =
8285 if (R->isFunctionPointerType())
8290 if (EmitTLSUnsupportedError &&
8293 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD))))
8295 diag::err_thread_unsupported);
8297 if (EmitTLSUnsupportedError &&
8304 (NewVD->
hasAttr<CUDASharedAttr>() ||
8305 NewVD->
hasAttr<CUDAConstantAttr>())) {
8313 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
8314 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
8319 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(NewVD))
8326 CheckAsmLabel(S, D.
getAsmLabel(), SC, TInfo, NewVD);
8338 IsMemberSpecialization ||
8339 IsVariableTemplateSpecialization);
8353 if (IsMemberSpecialization && !IsVariableTemplate &&
8354 !IsVariableTemplateSpecialization && !NewVD->
isInvalidDecl() &&
8371 !IsVariableTemplateSpecialization) {
8382 if (NewTemplate && IsMemberSpecialization) {
8394 if (!IsPlaceholderVariable)
8425 if (IsMemberSpecialization) {
8430 ->setMemberSpecialization();
8449 Decl *ManglingContextDecl;
8450 std::tie(MCtx, ManglingContextDecl) =
8542 return !Diags.
isIgnored(diag::warn_decl_shadow, R.getNameLoc());
8554 NamedDecl *ShadowedDecl = R.getFoundDecl();
8568 NamedDecl *ShadowedDecl = R.getFoundDecl();
8577 NamedDecl *ShadowedDecl = R.getFoundDecl();
8586 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
8587 if (
const auto *MD =
8591 if (MD->isStatic() || MD->isExplicitObjectMemberFunction())
8597 if (
const auto PVD = dyn_cast<ParmVarDecl>(D)) {
8600 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
8605 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
8606 if (shadowedVar->isExternC()) {
8609 for (
auto *I : shadowedVar->redecls())
8610 if (I->isFileVarDecl()) {
8618 unsigned WarningDiag = diag::warn_decl_shadow;
8621 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
8627 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
8633 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
8639 ->ShadowingDecls.push_back({D, VD});
8650 ->ShadowingDecls.push_back({D, ShadowedDecl});
8656 bool HasLocalStorage =
false;
8657 if (
const auto *VD = dyn_cast<VarDecl>(ShadowedDecl))
8658 HasLocalStorage = VD->hasLocalStorage();
8659 else if (
const auto *BD = dyn_cast<BindingDecl>(ShadowedDecl))
8663 if (HasLocalStorage) {
8668 ParentDC && !ParentDC->
Equals(OldDC);
8709 Diag(R.getNameLoc(), WarningDiag) << Name << Kind << OldDC;
8711 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
8718 const NamedDecl *ShadowedDecl = Shadow.ShadowedDecl;
8724 Diag(Shadow.VD->getLocation(),
8725 CaptureLoc.
isInvalid() ? diag::warn_decl_shadow_uncaptured_local
8726 : diag::warn_decl_shadow)
8727 << Shadow.VD->getDeclName()
8730 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
8731 << Shadow.VD->getDeclName() << 0;
8734 Diag(Shadow.VD->getLocation(),
8736 : diag::warn_decl_shadow_uncaptured_local)
8737 << Shadow.VD->getDeclName()
8763 auto *DRE = dyn_cast<DeclRefExpr>(E);
8767 auto I = ShadowingDecls.find(D);
8768 if (I == ShadowingDecls.end())
8770 const NamedDecl *ShadowedDecl = I->second;
8772 Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
8777 ShadowingDecls.erase(I);
8785 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
8844 assert(Prev &&
"should have found a previous declaration to diagnose");
8846 Prev = FD->getFirstDecl();
8850 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
8872 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
8884 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
8904 SemaRef.
Diag(VarLoc, diag::err_c23_constexpr_invalid_type) << T;
8914 SemaRef.
Diag(VarLoc, diag::err_c23_constexpr_invalid_type) << T;
8922 return CheckC23ConstexprVarType(SemaRef, VarLoc, F->getType());
8938 if (T->isUndeducedType())
8944 if (T->isObjCObjectType()) {
8947 T =
Context.getObjCObjectPointerType(T);
8978 if (NewVD->
hasAttr<BlocksAttr>()) {
8983 if (T->isBlockPointerType()) {
8986 if (!T.isConstQualified()) {
8987 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
8993 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
9002 if (!T->isSamplerT() && !T->isDependentType() &&
9009 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
9010 <<
Scope <<
"global or constant";
9012 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
9013 <<
Scope <<
"constant";
9027 bool AllowFunctionScopeLocalVariables =
9030 "__cl_clang_function_scope_local_variables",
getLangOpts());
9031 if (AllowFunctionScopeLocalVariables) {
9038 if (FD && !FD->
hasAttr<DeviceKernelAttr>()) {
9050 if (FD && FD->
hasAttr<DeviceKernelAttr>()) {
9075 && !NewVD->
hasAttr<BlocksAttr>()) {
9086 if (T->isWebAssemblyTableType()) {
9097 const auto *ATy = dyn_cast<ConstantArrayType>(T.getTypePtr());
9098 if (!ATy || ATy->getZExtSize() != 0) {
9100 diag::err_typecheck_wasm_table_must_have_zero_length);
9110 (FD->hasAttr<CUDADeviceAttr>() || FD->hasAttr<CUDAGlobalAttr>())) {
9113 ArrayT && ArrayT->isZeroSize()) {
9119 bool isVM = T->isVariablyModifiedType();
9120 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
9126 bool SizeIsNegative;
9127 llvm::APSInt Oversized;
9132 FixedT = FixedTInfo->
getType();
9133 else if (FixedTInfo) {
9139 if ((!FixedTInfo || FixedT.
isNull()) && T->isVariableArrayType()) {
9172 if (T->isVoidType()) {
9184 !T.isWebAssemblyReferenceType() && !T->isHLSLSpecificType()) {
9190 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
9192 << diag::NotAllowedBlockVarReason::VariablyModifiedType;
9204 !T->isDependentType() &&
9206 diag::err_constexpr_var_non_literal)) {
9212 if (
Context.getTargetInfo().getTriple().isPPC64() &&
9222 llvm::StringMap<bool> CallerFeatureMap;
9223 Context.getFunctionFeatureMap(CallerFeatureMap, FD);
9225 CallerFeatureMap)) {
9233 llvm::StringMap<bool> CallerFeatureMap;
9234 Context.getFunctionFeatureMap(CallerFeatureMap, FD);
9239 if (T.hasAddressSpace() &&
9273 CXXRecordDecl *BaseRecord = Specifier->getType()->getAsCXXRecordDecl();
9278 Name =
Context.DeclarationNames.getCXXDestructorName(
9279 Context.getCanonicalTagType(BaseRecord));
9284 dyn_cast<CXXMethodDecl>(BaseND->getCanonicalDecl());
9291 if (Overridden.insert(BaseMD).second) {
9308 return !Overridden.empty();
9314 struct ActOnFDArgs {
9328 DifferentNameValidatorCCC(ASTContext &Context, FunctionDecl *TypoFD,
9329 CXXRecordDecl *Parent)
9330 : Context(Context), OriginalFD(TypoFD),
9333 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
9337 SmallVector<unsigned, 1> MismatchedParams;
9339 CDeclEnd = candidate.
end();
9340 CDecl != CDeclEnd; ++CDecl) {
9341 FunctionDecl *FD = dyn_cast<FunctionDecl>(*CDecl);
9345 if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
9346 CXXRecordDecl *Parent = MD->getParent();
9349 }
else if (!ExpectedParent) {
9358 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
9359 return std::make_unique<DifferentNameValidatorCCC>(*
this);
9363 ASTContext &Context;
9364 FunctionDecl *OriginalFD;
9365 CXXRecordDecl *ExpectedParent;
9385 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *S) {
9393 IsLocalFriend ? diag::err_no_matching_local_friend :
9395 diag::err_member_decl_does_not_match;
9407 "Cannot have an ambiguity in previous-declaration lookup");
9409 DifferentNameValidatorCCC CCC(SemaRef.
Context, NewFD,
9411 if (!Prev.
empty()) {
9420 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
9421 NearMatches.push_back(std::make_pair(FD, ParamNum));
9429 IsLocalFriend ?
nullptr : NewDC))) {
9436 CDeclEnd = Correction.
end();
9437 CDecl != CDeclEnd; ++CDecl) {
9457 ExtraArgs.S, ExtraArgs.D,
9460 ExtraArgs.AddToScope);
9468 Decl *Canonical =
Result->getCanonicalDecl();
9471 if ((*I)->getCanonicalDecl() == Canonical)
9478 SemaRef.
PDiag(IsLocalFriend
9479 ? diag::err_no_matching_local_friend_suggest
9480 : diag::err_member_decl_does_not_match_suggest)
9481 << Name << NewDC << IsDefinition);
9494 << Name << NewDC << IsDefinition << NewFD->
getLocation();
9497 if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
9503 bool NewFDisConst = NewMD && NewMD->
isConst();
9506 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
9507 NearMatch != NearMatchEnd; ++NearMatch) {
9510 bool FDisConst = MD && MD->
isConst();
9511 bool IsMember = MD || !IsLocalFriend;
9514 if (
unsigned Idx = NearMatch->second) {
9518 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
9519 : diag::note_local_decl_close_param_match)
9522 }
else if (FDisConst != NewFDisConst) {
9524 diag::note_member_def_close_const_match)
9529 else if (FTI.hasMethodTypeQualifiers() &&
9530 FTI.getConstQualifierLoc().isValid())
9534 IsMember ? diag::note_member_def_close_match
9535 : diag::note_local_decl_close_match);
9543 default: llvm_unreachable(
"Unknown storage class!");
9548 diag::err_typecheck_sclass_func);
9565 diag::err_static_block_func);
9581 bool &IsVirtualOkay) {
9595 diag::err_c23_constexpr_not_variable);
9598 diag::err_constexpr_wrong_decl_kind)
9599 <<
static_cast<int>(ConstexprKind);
9620 (!R->getAsAdjusted<
FunctionType>() && R->isFunctionProtoType());
9623 "Strict prototypes are required");
9644 "Constructors can only be declared in a member context");
9650 isInline,
false, ConstexprKind,
9661 false, ConstexprKind,
9662 TrailingRequiresClause);
9665 if (
Record->isBeingDefined())
9674 IsVirtualOkay =
true;
9686 true, ConstexprKind, TrailingRequiresClause);
9692 diag::err_conv_function_not_member);
9700 IsVirtualOkay =
true;
9705 TrailingRequiresClause);
9732 IsVirtualOkay = !Ret->isStatic();
9746 true , ConstexprKind, TrailingRequiresClause);
9763 StringRef SizeTypeNames[] = {
"size_t",
"intptr_t",
"uintptr_t",
"ptrdiff_t"};
9771 if (Names.end() !=
Match)
9776 }
while (DesugaredTy != Ty);
9815 "__cl_clang_non_portable_kernel_param_types", S.
getLangOpts())) {
9817 bool IsStandardLayoutType =
true;
9823 if (!CXXRec->hasDefinition())
9824 CXXRec = CXXRec->getTemplateInstantiationPattern();
9825 if (!CXXRec || !CXXRec->hasDefinition() || !CXXRec->isStandardLayout())
9826 IsStandardLayoutType =
false;
9829 !IsStandardLayoutType)
9877 "__cl_clang_non_portable_kernel_param_types", S.
getLangOpts()) &&
9891 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
9904 S.
Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
9913 S.
Diag(Param->getLocation(), diag::err_kernel_arg_address_space);
9930 S.
Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
9938 S.
Diag(Loc, diag::note_entity_declared_at) << PT;
9939 PT = Typedef->desugar();
9961 HistoryStack.push_back(
nullptr);
9966 VisitStack.push_back(PD);
9967 assert(VisitStack.back() &&
"First decl null?");
9970 const Decl *
Next = VisitStack.pop_back_val();
9972 assert(!HistoryStack.empty());
9974 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
9975 ValidTypes.insert(Hist->getType().getTypePtr());
9984 HistoryStack.push_back(Field);
9986 QualType FieldTy = Field->getType();
9990 "Unexpected type.");
9999 VisitStack.push_back(
nullptr);
10001 for (
const auto *FD : RD->
fields()) {
10012 VisitStack.push_back(FD);
10023 S.
Diag(Param->getLocation(),
10024 diag::err_record_with_pointers_kernel_param)
10028 S.
Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
10031 S.
Diag(PD->getLocation(), diag::note_within_field_of_type)
10032 << PD->getDeclName();
10037 I = HistoryStack.begin() + 1,
10038 E = HistoryStack.end();
10051 }
while (!VisitStack.empty());
10068 (LangOpts.CPlusPlus &&
10078 unsigned BuiltinID) {
10079 switch (BuiltinID) {
10080 case Builtin::BI__GetExceptionInfo:
10084 case Builtin::BIaddressof:
10085 case Builtin::BI__addressof:
10086 case Builtin::BIforward:
10087 case Builtin::BIforward_like:
10088 case Builtin::BImove:
10089 case Builtin::BImove_if_noexcept:
10090 case Builtin::BIas_const: {
10095 return FPT->
getNumParams() == 1 && !FPT->isVariadic();
10107 bool &AddToScope) {
10110 assert(R->isFunctionType());
10115 llvm::append_range(TemplateParamLists, TemplateParamListsRef);
10117 if (!TemplateParamLists.empty() && !TemplateParamLists.back()->empty() &&
10118 Invented->getDepth() == TemplateParamLists.back()->getDepth())
10119 TemplateParamLists.back() = Invented;
10121 TemplateParamLists.push_back(Invented);
10131 diag::err_invalid_thread)
10139 bool isFriend =
false;
10141 bool isMemberSpecialization =
false;
10142 bool isFunctionTemplateSpecialization =
false;
10144 bool HasExplicitTemplateArgs =
false;
10147 bool isVirtualOkay =
false;
10154 if (!NewFD)
return nullptr;
10164 if (IsLocalExternDecl)
10174 bool ImplicitInlineCXX20 = !
getLangOpts().CPlusPlusModules ||
10202 if (isVirtual && Parent->isUnion()) {
10206 if ((Parent->isClass() || Parent->isStruct()) &&
10207 Parent->hasAttr<SYCLSpecialClassAttr>() &&
10210 if (
auto *Def = Parent->getDefinition())
10211 Def->setInitMethod(
true);
10216 isMemberSpecialization =
false;
10217 isFunctionTemplateSpecialization =
false;
10232 isMemberSpecialization,
Invalid);
10233 if (TemplateParams) {
10238 if (TemplateParams->
size() > 0) {
10246 }
else if (TemplateId) {
10263 Name, TemplateParams,
10269 if (TemplateParamLists.size() > 1) {
10276 isFunctionTemplateSpecialization =
true;
10278 if (TemplateParamLists.size() > 0)
10298 << Name << RemoveRange
10304 HasExplicitTemplateArgs =
true;
10311 if (!TemplateParamLists.empty() && isMemberSpecialization &&
10317 if (TemplateParamLists.size() > 0)
10322 if (isFriend && TemplateId)
10323 isFunctionTemplateSpecialization =
true;
10329 if (isFunctionTemplateSpecialization && TemplateId) {
10330 HasExplicitTemplateArgs =
true;
10361 if (!isVirtualOkay) {
10363 diag::err_virtual_non_function);
10367 diag::err_virtual_out_of_class)
10373 diag::err_virtual_member_function_template)
10392 diag::err_inline_declaration_block_scope) << Name
10406 diag::err_explicit_out_of_class)
10413 diag::err_explicit_non_ctor_or_conv_function)
10431 <<
static_cast<int>(ConstexprKind);
10442 diag::err_invalid_consteval_decl_kind)
10450 if (isFunctionTemplateSpecialization) {
10453 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
10499 if (!isFriend && SC !=
SC_None) {
10507 if (isFunctionTemplateSpecialization || isMemberSpecialization) {
10509 diag::ext_explicit_specialization_storage_class)
10516 "Out-of-line member function should be a CXXMethodDecl");
10533 ? diag::ext_static_out_of_line
10534 : diag::err_static_out_of_line)
10559 PendingInlineFuncDecls.insert(NewFD);
10566 isMemberSpecialization ||
10567 isFunctionTemplateSpecialization);
10578 llvm::MapVector<IdentifierInfo *, AsmLabelAttr *>::iterator I =
10605 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
10607 assert(Param->getDeclContext() != NewFD &&
"Was set before ?");
10608 Param->setDeclContext(NewFD);
10609 Params.push_back(Param);
10611 if (Param->isInvalidDecl())
10624 auto *TD = dyn_cast<TagDecl>(NonParmDecl);
10629 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
10634 DeclContext *TagDC = TD->getLexicalDeclContext();
10638 TD->setDeclContext(NewFD);
10646 if (TagDC != PrototypeTagContext)
10647 TD->setLexicalDeclContext(TagDC);
10661 for (
const auto &AI : FT->param_types()) {
10664 Param->setScopeInfo(0, Params.size());
10665 Params.push_back(Param);
10668 assert(R->isFunctionNoProtoType() && NewFD->
getNumParams() == 0 &&
10669 "Should not need args for typedef of non-prototype fn");
10673 NewFD->setParams(Params);
10698 !NewFD->
hasAttr<SectionAttr>())
10699 NewFD->
addAttr(PragmaClangTextSectionAttr::CreateImplicit(
10705 !NewFD->
hasAttr<SectionAttr>()) {
10706 NewFD->
addAttr(SectionAttr::CreateImplicit(
10708 CodeSegStack.CurrentPragmaLocation, SectionAttr::Declspec_allocate));
10719 !NewFD->
hasAttr<StrictGuardStackCheckAttr>())
10720 NewFD->
addAttr(StrictGuardStackCheckAttr::CreateImplicit(
10725 if (!NewFD->
hasAttr<CodeSegAttr>()) {
10734 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
10735 if (
Context.getTargetInfo().getTriple().isAArch64() && NewTVA &&
10736 !NewTVA->isDefaultVersion() &&
10737 !
Context.getTargetInfo().hasFeature(
"fmv")) {
10739 AddToScope =
false;
10751 Diag(NewFD->
getLocation(), diag::err_return_value_with_address_space);
10766 isMemberSpecialization,
10773 "previous declaration set still overloaded");
10785 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
10808 diag::ext_operator_new_delete_declared_inline)
10835 if (isFunctionTemplateSpecialization || isMemberSpecialization) {
10847 Diag(TRC->getBeginLoc(), diag::err_non_temp_spec_requires_clause)
10855 diag::err_non_temp_friend_decl_with_requires_clause_must_be_def);
10859 Diag(TRC->getBeginLoc(),
10860 diag::err_constrained_non_templated_function);
10877 if (isFunctionTemplateSpecialization) {
10878 bool isDependentSpecialization =
false;
10883 isDependentSpecialization =
10885 (HasExplicitTemplateArgs &&
10886 TemplateSpecializationType::
10887 anyInstantiationDependentTemplateArguments(
10889 assert((!isDependentSpecialization ||
10890 (HasExplicitTemplateArgs == isDependentSpecialization)) &&
10891 "dependent friend function specialization without template "
10897 isDependentSpecialization =
10902 HasExplicitTemplateArgs ? &TemplateArgs :
nullptr;
10903 if (isDependentSpecialization) {
10910 NewFD, ExplicitTemplateArgs,
Previous))
10931 isMemberSpecialization,
10940 "previous declaration set still overloaded");
10981 struct ActOnFDArgs ExtraArgs = { S, D, TemplateParamLists,
11027 *
this,
Previous, NewFD, ExtraArgs,
false,
nullptr)) {
11028 AddToScope = ExtraArgs.AddToScope;
11037 *
this,
Previous, NewFD, ExtraArgs,
true, S)) {
11038 AddToScope = ExtraArgs.AddToScope;
11044 !isFriend && !isFunctionTemplateSpecialization &&
11045 !isMemberSpecialization) {
11063 if (NewFD->
hasAttr<HLSLShaderAttr>())
11067 if (
const NoInlineAttr *NoInline = NewFD->
getAttr<NoInlineAttr>()) {
11069 QualType ParamTy = PVD->getType().getNonReferenceType();
11077 Diag(PVD->getLocation(),
11078 diag::err_hlsl_resource_param_in_noinline_function)
11080 Diag(NoInline->getLocation(), diag::note_attribute);
11090 if (
unsigned BuiltinID = II->getBuiltinID()) {
11091 bool InStdNamespace =
Context.BuiltinInfo.isInStdNamespace(BuiltinID);
11092 if (!InStdNamespace &&
11097 if (
Context.BuiltinInfo.allowTypeMismatch(BuiltinID)) {
11098 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
11105 Context.hasSameFunctionTypeIgnoringExceptionSpec(
11107 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
11112 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
11128 if (NewFD->
hasAttr<OverloadableAttr>() &&
11131 diag::err_attribute_overloadable_no_prototype)
11133 NewFD->
dropAttr<OverloadableAttr>();
11166 isMemberSpecialization ||
11167 isFunctionTemplateSpecialization,
11178 Context.setcudaConfigureCallDecl(NewFD);
11180 if (II->isStr(
CUDA().getGetParameterBufferFuncName()) &&
11186 Context.setcudaGetParameterBufferDecl(NewFD);
11188 if (II->isStr(
CUDA().getLaunchDeviceFuncName()) &&
11194 Context.setcudaLaunchDeviceDecl(NewFD);
11245 diag::err_friend_decl_with_enclosing_temp_constraint_must_be_def);
11265 if (
getLangOpts().getOpenCLCompatibleVersion() >= 200) {
11267 QualType ElemTy = PipeTy->getElementType();
11269 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type);
11275 if (
Context.getTargetInfo().getTriple().isWasm()) {
11277 Diag(Param->getTypeSpecStartLoc(),
11278 diag::err_wasm_table_as_function_parameter);
11286 if (
const auto *
attr = NewFD->
getAttr<AvailabilityAttr>()) {
11287 if (NewFD->
hasAttr<ConstructorAttr>()) {
11288 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
11290 NewFD->
dropAttr<AvailabilityAttr>();
11292 if (NewFD->
hasAttr<DestructorAttr>()) {
11293 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
11295 NewFD->
dropAttr<AvailabilityAttr>();
11306 if (
const auto *NBA = NewFD->
getAttr<NoBuiltinAttr>())
11310 Diag(NBA->getLocation(),
11311 diag::err_attribute_no_builtin_on_defaulted_deleted_function)
11312 << NBA->getSpelling();
11315 Diag(NBA->getLocation(), diag::err_attribute_no_builtin_on_non_definition)
11316 << NBA->getSpelling();
11325 if (
Context.getTargetInfo().allowDebugInfoForExternalRef() &&
11349 const auto *Method = dyn_cast<CXXMethodDecl>(FD);
11353 if (
const auto *SAttr = Parent->
getAttr<CodeSegAttr>()) {
11364 while ((Parent = dyn_cast<CXXRecordDecl>(Parent->
getParent()))) {
11365 if (
const auto *SAttr = Parent->
getAttr<CodeSegAttr>()) {
11375 bool IsDefinition) {
11378 if (!FD->
hasAttr<SectionAttr>() && IsDefinition &&
11380 return SectionAttr::CreateImplicit(
11382 CodeSegStack.CurrentPragmaLocation, SectionAttr::Declspec_allocate);
11430 auto *VD = dyn_cast<ValueDecl>(D);
11431 auto *PrevVD = dyn_cast<ValueDecl>(PrevDecl);
11432 return !VD || !PrevVD ||
11434 PrevVD->getType());
11442 const auto *TA = FD->
getAttr<TargetAttr>();
11443 const auto *TVA = FD->
getAttr<TargetVersionAttr>();
11445 assert((TA || TVA) &&
"Expecting target or target_version attribute");
11458 for (
const auto &Feat : ParseInfo.
Features) {
11459 auto BareFeat = StringRef{Feat}.substr(1);
11460 if (Feat[0] ==
'-') {
11462 <<
Feature << (
"no-" + BareFeat);
11482 for (
auto &Feat : ParseInfo.
Features)
11483 Feats.push_back(StringRef{Feat}.substr(1));
11486 TVA->getFeatures(Feats);
11488 for (
const auto &Feat : Feats) {
11508 case attr::ArmLocallyStreaming:
11513 case attr::NonNull:
11514 case attr::NoThrow:
11523 const auto Diagnose = [FD, CausedFD, MVKind](
Sema &S,
const Attr *A) {
11524 S.
Diag(FD->
getLocation(), diag::err_multiversion_disallowed_other_attr)
11525 <<
static_cast<unsigned>(MVKind) << A;
11527 S.
Diag(CausedFD->
getLocation(), diag::note_multiversioning_caused_here);
11532 switch (A->getKind()) {
11533 case attr::CPUDispatch:
11534 case attr::CPUSpecific:
11537 return Diagnose(S, A);
11541 return Diagnose(S, A);
11543 case attr::TargetVersion:
11546 return Diagnose(S, A);
11548 case attr::TargetClones:
11551 return Diagnose(S, A);
11555 return Diagnose(S, A);
11568 bool ConstexprSupported,
bool CLinkageMayDiffer) {
11569 enum DoesntSupport {
11576 DefaultedFuncs = 6,
11577 ConstexprFuncs = 7,
11578 ConstevalFuncs = 8,
11590 if (NoProtoDiagID.
getDiagID() != 0 && OldFD &&
11593 Diag(NoteCausedDiagIDAt.first, NoteCausedDiagIDAt.second);
11601 if (!TemplatesSupported &&
11603 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11606 if (
const auto *NewCXXFD = dyn_cast<CXXMethodDecl>(NewFD)) {
11607 if (NewCXXFD->isVirtual())
11608 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11612 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11616 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11621 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11625 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11629 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11630 << (NewFD->
isConsteval() ? ConstevalFuncs : ConstexprFuncs);
11634 QualType NewReturnType = NewType->getReturnType();
11637 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11650 bool ArmStreamingCCMismatched =
false;
11651 if (OldFPT && NewFPT) {
11658 ArmStreamingCCMismatched =
true;
11661 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC() || ArmStreamingCCMismatched)
11664 QualType OldReturnType = OldType->getReturnType();
11666 if (OldReturnType != NewReturnType)
11667 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ReturnType;
11670 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ConstexprSpec;
11673 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << InlineSpec;
11676 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) <<
Linkage;
11699 bool IsCPUSpecificCPUDispatchMVKind =
11703 if (CausesMV && OldFD &&
11711 if (OldFD && CausesMV && OldFD->
isUsed(
false)) {
11718 OldFD, NewFD, S.
PDiag(diag::err_multiversion_noproto),
11720 S.
PDiag(diag::note_multiversioning_caused_here)),
11722 S.
PDiag(diag::err_multiversion_doesnt_support)
11723 <<
static_cast<unsigned>(MVKind)),
11725 S.
PDiag(diag::err_multiversion_diff)),
11727 !IsCPUSpecificCPUDispatchMVKind,
11740 "Function lacks multiversion attribute");
11741 const auto *TA = FD->
getAttr<TargetAttr>();
11742 const auto *TVA = FD->
getAttr<TargetVersionAttr>();
11745 if (TA && !TA->isDefaultVersion())
11782 To->
addAttr(TargetVersionAttr::CreateImplicit(
11793 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11794 const auto *OldTA = OldFD->
getAttr<TargetAttr>();
11795 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11796 const auto *OldTVA = OldFD->
getAttr<TargetVersionAttr>();
11798 assert((NewTA || NewTVA) &&
"Excpecting target or target_version attribute");
11807 if (NewTA && !NewTA->isDefaultVersion() &&
11808 (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr()))
11825 if ((NewTA && NewTA->isDefaultVersion() && !OldTA) ||
11826 (NewTVA && NewTVA->isDefaultVersion() && !OldTVA)) {
11835 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
11843 OldTA->getFeaturesStr());
11847 NewTA->getFeaturesStr());
11850 if (OldParsed == NewParsed) {
11858 for (
const auto *FD : OldFD->
redecls()) {
11859 const auto *CurTA = FD->
getAttr<TargetAttr>();
11860 const auto *CurTVA = FD->
getAttr<TargetVersionAttr>();
11864 ((NewTA && (!CurTA || CurTA->isInherited())) ||
11865 (NewTVA && (!CurTVA || CurTVA->isInherited())))) {
11867 << (NewTA ? 0 : 2);
11868 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
11915 const CPUDispatchAttr *NewCPUDisp,
const CPUSpecificAttr *NewCPUSpec,
11931 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11932 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11939 NewTA->getFeaturesStr());
11944 NewTVA->getFeatures(NewFeats);
11945 llvm::sort(NewFeats);
11948 bool UseMemberUsingDeclRules =
11951 bool MayNeedOverloadableChecks =
11960 if (MayNeedOverloadableChecks &&
11961 S.
IsOverload(NewFD, CurFD, UseMemberUsingDeclRules))
11964 switch (NewMVKind) {
11967 "Only target_clones can be omitted in subsequent declarations");
11970 const auto *CurTA = CurFD->
getAttr<TargetAttr>();
11971 if (CurTA->getFeaturesStr() == NewTA->getFeaturesStr()) {
11980 CurTA->getFeaturesStr());
11982 if (CurParsed == NewParsed) {
11991 if (
const auto *CurTVA = CurFD->
getAttr<TargetVersionAttr>()) {
11992 if (CurTVA->getName() == NewTVA->getName()) {
11999 CurTVA->getFeatures(CurFeats);
12000 llvm::sort(CurFeats);
12002 if (CurFeats == NewFeats) {
12008 }
else if (
const auto *CurClones = CurFD->
getAttr<TargetClonesAttr>()) {
12010 if (NewFeats.empty())
12013 for (
unsigned I = 0; I < CurClones->featuresStrs_size(); ++I) {
12015 CurClones->getFeatures(CurFeats, I);
12016 llvm::sort(CurFeats);
12018 if (CurFeats == NewFeats) {
12029 assert(NewClones &&
"MultiVersionKind does not match attribute type");
12030 if (
const auto *CurClones = CurFD->
getAttr<TargetClonesAttr>()) {
12031 if (CurClones->featuresStrs_size() != NewClones->featuresStrs_size() ||
12032 !std::equal(CurClones->featuresStrs_begin(),
12033 CurClones->featuresStrs_end(),
12034 NewClones->featuresStrs_begin())) {
12040 }
else if (
const auto *CurTVA = CurFD->
getAttr<TargetVersionAttr>()) {
12042 CurTVA->getFeatures(CurFeats);
12043 llvm::sort(CurFeats);
12046 if (CurFeats.empty())
12049 for (
unsigned I = 0; I < NewClones->featuresStrs_size(); ++I) {
12051 NewClones->getFeatures(NewFeats, I);
12052 llvm::sort(NewFeats);
12054 if (CurFeats == NewFeats) {
12070 const auto *CurCPUSpec = CurFD->
getAttr<CPUSpecificAttr>();
12071 const auto *CurCPUDisp = CurFD->
getAttr<CPUDispatchAttr>();
12076 CurFD->
hasAttr<CPUDispatchAttr>()) {
12077 if (CurCPUDisp->cpus_size() == NewCPUDisp->cpus_size() &&
12079 CurCPUDisp->cpus_begin(), CurCPUDisp->cpus_end(),
12080 NewCPUDisp->cpus_begin(),
12082 return Cur->getName() == New->getName();
12097 if (CurCPUSpec->cpus_size() == NewCPUSpec->cpus_size() &&
12099 CurCPUSpec->cpus_begin(), CurCPUSpec->cpus_end(),
12100 NewCPUSpec->cpus_begin(),
12102 return Cur->getName() == New->getName();
12113 if (CurII == NewII) {
12183 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
12184 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
12185 const auto *NewCPUDisp = NewFD->
getAttr<CPUDispatchAttr>();
12186 const auto *NewCPUSpec = NewFD->
getAttr<CPUSpecificAttr>();
12187 const auto *NewClones = NewFD->
getAttr<TargetClonesAttr>();
12197 NewTVA->isDefaultVersion())) {
12198 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_not_allowed_on_main);
12206 if (NewTA && TI.
getTriple().isAArch64())
12233 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_required_in_redecl)
12246 if (OldFD->
isUsed(
false)) {
12248 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
12270 bool IsPure = NewFD->
hasAttr<PureAttr>();
12271 bool IsConst = NewFD->
hasAttr<ConstAttr>();
12274 if (!IsPure && !IsConst)
12281 if (IsPure && IsConst) {
12291 NewFD->
dropAttrs<PureAttr, ConstAttr>();
12297 bool IsMemberSpecialization,
12300 "Variably modified return types are not handled here");
12305 bool MergeTypeWithPrevious = !
getLangOpts().CPlusPlus &&
12310 bool MayNeedOverloadableChecks =
false;
12322 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
12324 OldDecl = Candidate;
12327 MayNeedOverloadableChecks =
true;
12352 OldDecl =
Previous.getFoundDecl();
12353 MergeTypeWithPrevious =
false;
12356 if (OldDecl->
hasAttr<OverloadableAttr>() ||
12357 NewFD->
hasAttr<OverloadableAttr>()) {
12359 MayNeedOverloadableChecks =
true;
12371 if (
Context.getTargetInfo().getTriple().isPPC64() &&
12422 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
12423 if (!OldMD || !OldMD->
isStatic()) {
12458 dyn_cast<FunctionTemplateDecl>(OldDecl)) {
12459 auto *OldFD = OldTemplateDecl->getTemplatedDecl();
12462 assert(NewTemplateDecl &&
"Template/non-template mismatch");
12471 NewFD->
setAccess(OldTemplateDecl->getAccess());
12472 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
12477 if (IsMemberSpecialization &&
12480 assert(OldTemplateDecl->isMemberSpecialization());
12483 if (OldFD->isDeleted()) {
12485 assert(OldFD->getCanonicalDecl() == OldFD);
12487 OldFD->setDeletedAsWritten(
false);
12501 !NewFD->
getAttr<OverloadableAttr>()) {
12505 return ND->hasAttr<OverloadableAttr>();
12507 "Non-redecls shouldn't happen without overloadable present");
12510 const auto *FD = dyn_cast<FunctionDecl>(ND);
12511 return FD && !FD->
hasAttr<OverloadableAttr>();
12514 if (OtherUnmarkedIter !=
Previous.end()) {
12516 diag::err_attribute_overloadable_multiple_unmarked_overloads);
12517 Diag((*OtherUnmarkedIter)->getLocation(),
12518 diag::note_attribute_overloadable_prev_overload)
12528 if (NewFD->
hasAttr<SYCLKernelEntryPointAttr>())
12531 if (NewFD->
hasAttr<SYCLExternalAttr>())
12541 dyn_cast<CXXDestructorDecl>(NewFD)) {
12549 !
Destructor->getFunctionObjectParameterType()->isDependentType()) {
12554 Context.DeclarationNames.getCXXDestructorName(ClassType);
12561 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
12562 if (
auto *TD = Guide->getDescribedFunctionTemplate())
12568 Diag(Guide->getBeginLoc(), diag::err_deduction_guide_specialized)
12574 if (!
Method->isFunctionTemplateSpecialization() &&
12575 !
Method->getDescribedFunctionTemplate() &&
12576 Method->isCanonicalDecl()) {
12583 diag::err_constrained_virtual_method);
12618 if (R->isIncompleteType() && !R->isVoidType())
12621 else if (!R.isPODType(
Context) && !R->isVoidType() &&
12622 !R->isObjCObjectPointerType())
12623 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
12636 auto HasNoexcept = [&](
QualType T) ->
bool {
12641 T = RT->getPointeeType();
12642 else if (T->isAnyPointerType())
12643 T = T->getPointeeType();
12645 T = MPT->getPointeeType();
12647 if (FPT->isNothrow())
12653 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
12654 for (
QualType T : FPT->param_types())
12655 AnyNoexcept |= HasNoexcept(T);
12658 diag::warn_cxx17_compat_exception_spec_in_signature)
12663 bool IsKernel = NewFD->
hasAttr<CUDAGlobalAttr>();
12665 if (!Parm->getType()->isDependentType() &&
12666 Parm->hasAttr<CUDAGridConstantAttr>() &&
12667 !(IsKernel && Parm->getType().isConstQualified()))
12668 Diag(Parm->getAttr<CUDAGridConstantAttr>()->getLocation(),
12669 diag::err_cuda_grid_constant_not_allowed);
12675 if (DeclIsDefn &&
Context.getTargetInfo().getTriple().isAArch64())
12685 Diag(FD->
getLocation(), diag::ext_main_invalid_linkage_specification);
12696 ? diag::err_static_main : diag::warn_static_main)
12704 Diag(NoreturnLoc, diag::ext_noreturn_main);
12705 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
12717 << FD->
hasAttr<DeviceKernelAttr>();
12722 if (FD->
hasAttr<SYCLExternalAttr>()) {
12724 << FD->
getAttr<SYCLExternalAttr>();
12735 assert(T->isFunctionType() &&
"function decl is not of function type");
12757 Diag(RTRange.
getBegin(), diag::note_main_change_return_type)
12782 Diag(start, diag::warn_main_in_named_module)
12794 bool HasExtraParameters = (nparams > 3);
12805 if (nparams == 4 &&
Context.getTargetInfo().getTriple().isOSDarwin())
12806 HasExtraParameters =
false;
12808 if (HasExtraParameters) {
12821 for (
unsigned i = 0; i < nparams; ++i) {
12824 bool mismatch =
true;
12841 mismatch = !qs.
empty();
12870 if (T.isOSCygMing())
12875 if (T.isOSWindows() && T.getArch() == llvm::Triple::x86)
12883 assert(T->isFunctionType() &&
"function decl is not of function type");
12892 if (FD->
getName() !=
"DllMain")
12899 FT =
Context.adjustFunctionType(
12904 FT =
Context.adjustFunctionType(FT,
12926 if (
Init->isValueDependent()) {
12927 assert(
Init->containsErrors() &&
12928 "Dependent code should only occur in error-recovery path.");
12931 const Expr *Culprit;
12932 if (
Init->isConstantInitializer(
Context,
false, &Culprit))
12940 if (
auto ALE = dyn_cast<ObjCArrayLiteral>(
Init)) {
12941 for (
auto *Elm : ALE->elements()) {
12942 if (!Elm->isConstantInitializer(
Context)) {
12943 Diag(Elm->getExprLoc(),
12944 diag::err_objc_literal_nonconstant_at_file_scope)
12951 if (
auto DLE = dyn_cast<ObjCDictionaryLiteral>(
Init)) {
12952 for (
size_t I = 0, N = DLE->getNumElements(); I != N; ++I) {
12959 diag::err_objc_literal_nonconstant_at_file_scope)
12966 diag::err_objc_literal_nonconstant_at_file_scope)
12974 diag::err_objc_literal_nonconstant_at_file_scope)
12986 class SelfReferenceChecker
12992 bool isReferenceType;
12993 bool isInCXXOperatorCall;
13001 SelfReferenceChecker(
Sema &S,
Decl *OrigDecl) : Inherited(S.Context),
13002 S(S), OrigDecl(OrigDecl) {
13005 isReferenceType =
false;
13006 isInCXXOperatorCall =
false;
13007 isInitList =
false;
13008 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
13009 isPODType = VD->getType().isPODType(S.
Context);
13011 isReferenceType = VD->getType()->isReferenceType();
13018 void CheckExpr(Expr *E) {
13019 InitListExpr *InitList = dyn_cast<InitListExpr>(E);
13027 InitFieldIndex.push_back(0);
13028 for (
auto *Child : InitList->
children()) {
13030 ++InitFieldIndex.back();
13032 InitFieldIndex.pop_back();
13037 bool CheckInitListMemberExpr(MemberExpr *E,
bool CheckReference) {
13038 llvm::SmallVector<FieldDecl*, 4> Fields;
13040 bool ReferenceField =
false;
13043 while (MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
13044 FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl());
13047 Fields.push_back(FD);
13049 ReferenceField =
true;
13050 Base = ME->getBase()->IgnoreParenImpCasts();
13054 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base);
13055 if (!DRE || DRE->
getDecl() != OrigDecl)
13059 if (CheckReference && !ReferenceField)
13063 llvm::SmallVector<unsigned, 4> UsedFieldIndex;
13064 for (
const FieldDecl *I : llvm::reverse(Fields))
13065 UsedFieldIndex.push_back(I->getFieldIndex());
13070 for (
auto UsedIter = UsedFieldIndex.begin(),
13071 UsedEnd = UsedFieldIndex.end(),
13072 OrigIter = InitFieldIndex.begin(),
13073 OrigEnd = InitFieldIndex.end();
13074 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
13075 if (*UsedIter < *OrigIter)
13077 if (*UsedIter > *OrigIter)
13082 HandleDeclRefExpr(DRE);
13089 void HandleValue(Expr *E) {
13091 if (DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
13092 HandleDeclRefExpr(DRE);
13096 if (ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E)) {
13097 Visit(CO->getCond());
13098 HandleValue(CO->getTrueExpr());
13099 HandleValue(CO->getFalseExpr());
13103 if (BinaryConditionalOperator *BCO =
13104 dyn_cast<BinaryConditionalOperator>(E)) {
13105 Visit(BCO->getCond());
13106 HandleValue(BCO->getFalseExpr());
13110 if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E)) {
13111 if (Expr *SE = OVE->getSourceExpr())
13116 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
13117 if (BO->getOpcode() == BO_Comma) {
13118 Visit(BO->getLHS());
13119 HandleValue(BO->getRHS());
13132 while (MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
13136 Base = ME->getBase()->IgnoreParenImpCasts();
13138 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base))
13139 HandleDeclRefExpr(DRE);
13148 void VisitDeclRefExpr(DeclRefExpr *E) {
13149 if (isReferenceType)
13150 HandleDeclRefExpr(E);
13153 void VisitImplicitCastExpr(ImplicitCastExpr *E) {
13159 Inherited::VisitImplicitCastExpr(E);
13162 void VisitMemberExpr(MemberExpr *E) {
13164 if (CheckInitListMemberExpr(E,
true ))
13173 CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(E->
getMemberDecl());
13174 bool Warn = (MD && !MD->
isStatic());
13176 while (MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
13179 Base = ME->getBase()->IgnoreParenImpCasts();
13182 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
13184 HandleDeclRefExpr(DRE);
13193 void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
13194 llvm::SaveAndRestore CxxOpCallScope(isInCXXOperatorCall,
true);
13198 return Inherited::VisitCXXOperatorCallExpr(E);
13202 HandleValue(Arg->IgnoreParenImpCasts());
13206 if (!isInCXXOperatorCall) {
13207 Inherited::VisitLambdaExpr(E);
13212 if (DeclRefExpr *DRE = dyn_cast_if_present<DeclRefExpr>(
Init))
13213 HandleDeclRefExpr(DRE);
13218 void VisitUnaryOperator(UnaryOperator *E) {
13232 Inherited::VisitUnaryOperator(E);
13235 void VisitObjCMessageExpr(ObjCMessageExpr *E) {}
13237 void VisitCXXConstructExpr(CXXConstructExpr *E) {
13239 Expr *ArgExpr = E->
getArg(0);
13240 if (InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
13241 if (ILE->getNumInits() == 1)
13242 ArgExpr = ILE->getInit(0);
13243 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(ArgExpr))
13244 if (ICE->getCastKind() == CK_NoOp)
13245 ArgExpr = ICE->getSubExpr();
13246 HandleValue(ArgExpr);
13249 Inherited::VisitCXXConstructExpr(E);
13252 void VisitCallExpr(CallExpr *E) {
13255 HandleValue(E->
getArg(0));
13259 Inherited::VisitCallExpr(E);
13262 void VisitBinaryOperator(BinaryOperator *E) {
13264 HandleValue(E->
getLHS());
13269 Inherited::VisitBinaryOperator(E);
13275 void VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
13280 void HandleDeclRefExpr(DeclRefExpr *DRE) {
13282 if (OrigDecl != ReferenceDecl)
return;
13284 if (isReferenceType) {
13285 diag = diag::warn_uninit_self_reference_in_reference_init;
13287 diag = diag::warn_static_self_reference_in_init;
13291 diag = diag::warn_uninit_self_reference_in_init;
13305 static void CheckSelfReference(Sema &S, Decl* OrigDecl, Expr *E,
13315 if (
auto *VD = dyn_cast<VarDecl>(OrigDecl);
13316 VD && VD->isConstexpr() && VD->isFileVarDecl())
13324 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
13325 if (ICE->getCastKind() == CK_LValueToRValue)
13326 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
13327 if (DRE->
getDecl() == OrigDecl)
13330 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
13337 struct VarDeclOrName {
13339 DeclarationName Name;
13341 friend const Sema::SemaDiagnosticBuilder &
13342 operator<<(
const Sema::SemaDiagnosticBuilder &
Diag, VarDeclOrName VN) {
13343 return VN.VDecl ?
Diag << VN.VDecl :
Diag << VN.Name;
13353 bool IsInitCapture = !VDecl;
13355 "init captures are expected to be deduced prior to initialization");
13357 VarDeclOrName VN{VDecl, Name};
13360 assert(
Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
13364 !isa_and_present<StringLiteral, InitListExpr>(
Init)) {
13365 Diag(Range.getBegin(), diag::err_auto_not_allowed)
13366 << (int)
Deduced->getContainedAutoType()->getKeyword()
13373 assert(VDecl &&
"no init for init capture deduction?");
13388 DeduceInits =
Init;
13390 auto *PL = dyn_cast_if_present<ParenListExpr>(
Init);
13392 DeduceInits = PL->exprs();
13395 assert(VDecl &&
"non-auto type for init capture deduction?");
13406 if (
auto *IL = dyn_cast<InitListExpr>(
Init))
13407 DeduceInits = IL->inits();
13411 if (DeduceInits.empty()) {
13414 Diag(
Init->getBeginLoc(), IsInitCapture
13415 ? diag::err_init_capture_no_expression
13416 : diag::err_auto_var_init_no_expression)
13417 << VN <<
Type << Range;
13421 if (DeduceInits.size() > 1) {
13422 Diag(DeduceInits[1]->getBeginLoc(),
13423 IsInitCapture ? diag::err_init_capture_multiple_expressions
13424 : diag::err_auto_var_init_multiple_expressions)
13425 << VN <<
Type << Range;
13429 Expr *DeduceInit = DeduceInits[0];
13431 Diag(
Init->getBeginLoc(), IsInitCapture
13432 ? diag::err_init_capture_paren_braces
13433 : diag::err_auto_var_init_paren_braces)
13439 bool DefaultedAnyToId =
false;
13441 Init->getType() ==
Context.UnknownAnyTy && !IsInitCapture) {
13443 if (
Result.isInvalid()) {
13447 DefaultedAnyToId =
true;
13457 Type.getQualifiers());
13465 if (!IsInitCapture)
13468 Diag(Range.getBegin(),
13469 diag::err_init_capture_deduction_failure_from_init_list)
13475 Diag(Range.getBegin(), diag::err_init_capture_deduction_failure)
13490 Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
13493 return DeducedType;
13498 assert(!
Init || !
Init->containsErrors());
13502 if (DeducedType.
isNull()) {
13511 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(VDecl))
13535 if (
auto *EWC = dyn_cast<ExprWithCleanups>(
Init))
13536 Init = EWC->getSubExpr();
13538 if (
auto *CE = dyn_cast<ConstantExpr>(
Init))
13539 Init = CE->getSubExpr();
13544 "shouldn't be called if type doesn't have a non-trivial C struct");
13545 if (
auto *ILE = dyn_cast<InitListExpr>(
Init)) {
13546 for (
auto *I : ILE->inits()) {
13547 if (!I->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion() &&
13548 !I->getType().hasNonTrivialToPrimitiveCopyCUnion())
13574bool shouldIgnoreForRecordTriviality(
const FieldDecl *FD) {
13580 return FD->
hasAttr<UnavailableAttr>();
13583struct DiagNonTrivalCUnionDefaultInitializeVisitor
13590 DiagNonTrivalCUnionDefaultInitializeVisitor(
13593 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13596 const FieldDecl *FD,
bool InNonTrivialUnion) {
13599 InNonTrivialUnion);
13600 return Super::visitWithKind(PDIK, QT, FD, InNonTrivialUnion);
13603 void visitARCStrong(QualType QT,
const FieldDecl *FD,
13604 bool InNonTrivialUnion) {
13605 if (InNonTrivialUnion)
13607 << 1 << 0 << QT << FD->
getName();
13610 void visitARCWeak(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13611 if (InNonTrivialUnion)
13613 << 1 << 0 << QT << FD->
getName();
13616 void visitStruct(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13618 if (RD->isUnion()) {
13619 if (OrigLoc.isValid()) {
13620 bool IsUnion =
false;
13621 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13622 IsUnion = OrigRD->isUnion();
13623 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13624 << 0 << OrigTy << IsUnion << UseContext;
13626 OrigLoc = SourceLocation();
13628 InNonTrivialUnion =
true;
13631 if (InNonTrivialUnion)
13632 S.
Diag(RD->getLocation(), diag::note_non_trivial_c_union)
13635 for (
const FieldDecl *FD : RD->fields())
13636 if (!shouldIgnoreForRecordTriviality(FD))
13637 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13640 void visitTrivial(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {}
13645 SourceLocation OrigLoc;
13650struct DiagNonTrivalCUnionDestructedTypeVisitor
13653 DestructedTypeVisitor<DiagNonTrivalCUnionDestructedTypeVisitor, void>;
13655 DiagNonTrivalCUnionDestructedTypeVisitor(QualType OrigTy,
13656 SourceLocation OrigLoc,
13659 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13662 const FieldDecl *FD,
bool InNonTrivialUnion) {
13665 InNonTrivialUnion);
13666 return Super::visitWithKind(DK, QT, FD, InNonTrivialUnion);
13669 void visitARCStrong(QualType QT,
const FieldDecl *FD,
13670 bool InNonTrivialUnion) {
13671 if (InNonTrivialUnion)
13673 << 1 << 1 << QT << FD->
getName();
13676 void visitARCWeak(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13677 if (InNonTrivialUnion)
13679 << 1 << 1 << QT << FD->
getName();
13682 void visitStruct(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13684 if (RD->isUnion()) {
13685 if (OrigLoc.isValid()) {
13686 bool IsUnion =
false;
13687 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13688 IsUnion = OrigRD->isUnion();
13689 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13690 << 1 << OrigTy << IsUnion << UseContext;
13692 OrigLoc = SourceLocation();
13694 InNonTrivialUnion =
true;
13697 if (InNonTrivialUnion)
13698 S.
Diag(RD->getLocation(), diag::note_non_trivial_c_union)
13701 for (
const FieldDecl *FD : RD->fields())
13702 if (!shouldIgnoreForRecordTriviality(FD))
13703 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13706 void visitTrivial(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {}
13707 void visitCXXDestructor(QualType QT,
const FieldDecl *FD,
13708 bool InNonTrivialUnion) {}
13713 SourceLocation OrigLoc;
13718struct DiagNonTrivalCUnionCopyVisitor
13720 using Super = CopiedTypeVisitor<DiagNonTrivalCUnionCopyVisitor, false, void>;
13722 DiagNonTrivalCUnionCopyVisitor(QualType OrigTy, SourceLocation OrigLoc,
13724 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13727 const FieldDecl *FD,
bool InNonTrivialUnion) {
13730 InNonTrivialUnion);
13731 return Super::visitWithKind(PCK, QT, FD, InNonTrivialUnion);
13734 void visitARCStrong(QualType QT,
const FieldDecl *FD,
13735 bool InNonTrivialUnion) {
13736 if (InNonTrivialUnion)
13738 << 1 << 2 << QT << FD->
getName();
13741 void visitARCWeak(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13742 if (InNonTrivialUnion)
13744 << 1 << 2 << QT << FD->
getName();
13747 void visitStruct(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13749 if (RD->isUnion()) {
13750 if (OrigLoc.isValid()) {
13751 bool IsUnion =
false;
13752 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13753 IsUnion = OrigRD->isUnion();
13754 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13755 << 2 << OrigTy << IsUnion << UseContext;
13757 OrigLoc = SourceLocation();
13759 InNonTrivialUnion =
true;
13762 if (InNonTrivialUnion)
13763 S.
Diag(RD->getLocation(), diag::note_non_trivial_c_union)
13766 for (
const FieldDecl *FD : RD->fields())
13767 if (!shouldIgnoreForRecordTriviality(FD))
13768 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13771 void visitPtrAuth(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13772 if (InNonTrivialUnion)
13774 << 1 << 2 << QT << FD->
getName();
13778 const FieldDecl *FD,
bool InNonTrivialUnion) {}
13779 void visitTrivial(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {}
13780 void visitVolatileTrivial(QualType QT,
const FieldDecl *FD,
13781 bool InNonTrivialUnion) {}
13786 SourceLocation OrigLoc;
13795 unsigned NonTrivialKind) {
13799 "shouldn't be called if type doesn't have a non-trivial C union");
13803 DiagNonTrivalCUnionDefaultInitializeVisitor(QT, Loc, UseContext, *
this)
13804 .visit(QT,
nullptr,
false);
13807 DiagNonTrivalCUnionDestructedTypeVisitor(QT, Loc, UseContext, *
this)
13808 .visit(QT,
nullptr,
false);
13810 DiagNonTrivalCUnionCopyVisitor(QT, Loc, UseContext, *
this)
13811 .visit(QT,
nullptr,
false);
13835 bool TargetIsInline = Dcl->
isInline();
13836 bool TargetWasTemplated =
13853 TargetWasTemplated =
13863 if (!TargetIsInline || TargetWasTemplated)
13873 if (
Context.getTargetInfo().shouldDLLImportComdatSymbols()) {
13874 if (
Target->hasAttr<DLLExportAttr>() ||
Target->hasAttr<DLLImportAttr>())
13880 dyn_cast<CXXRecordDecl>(
Target->getDeclContext());
13881 if (Ctx && (Ctx->
hasAttr<DLLExportAttr>() || Ctx->
hasAttr<DLLImportAttr>()))
13903 T = T.getNonReferenceType();
13904 if (T->isFunctionType())
13906 if (!T.isConstant(Ctx))
13908 if (T->isPointerType())
13926 Diag(VD->
getLocation(), diag::warn_possible_object_duplication_mutable)
13927 << VD <<
Context.getTargetInfo().shouldDLLImportComdatSymbols();
13939 Diag(
Init->getExprLoc(), diag::warn_possible_object_duplication_init)
13940 << VD <<
Context.getTargetInfo().shouldDLLImportComdatSymbols();
13946 llvm::scope_exit ResetDeclForInitializer([
this]() {
13957 if (
auto *
Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
13958 if (!
Method->isInvalidDecl()) {
13960 Diag(
Method->getLocation(), diag::err_member_function_initialization)
13961 <<
Method->getDeclName() <<
Init->getSourceRange();
13962 Method->setInvalidDecl();
13967 VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl);
13969 assert(!
isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
13978 if (
Expr *E = Recovery.
get())
13985 Context.AMDGPUFeaturePredicateTy) {
13987 diag::err_amdgcn_predicate_type_is_not_constructible)
13994 if (!
Init->getType().isNull() &&
Init->getType()->isWebAssemblyTableType()) {
13995 Diag(
Init->getExprLoc(), diag::err_wasm_table_art) << 0;
14002 if (
Init->containsErrors()) {
14011 "decl should be invalidated when deduce fails");
14023 if (VDecl->
hasAttr<HLSLGroupSharedAddressSpaceAttr>()) {
14030 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
14050 if (
const ArrayType *Array =
Context.getAsIncompleteArrayType(BaseDeclType))
14051 BaseDeclType = Array->getElementType();
14053 diag::err_typecheck_decl_incomplete_type)) {
14060 diag::err_abstract_type_in_decl,
14078 !(VDecl->
hasAttr<SelectAnyAttr>() || VDecl->
hasAttr<WeakAttr>())) {
14087 if (Def != VDecl &&
14107 Diag(
Init->getExprLoc(), diag::err_static_data_member_reinitialization)
14110 diag::note_previous_initializer)
14135 if (VDecl->
hasAttr<LoaderUninitializedAttr>()) {
14136 Diag(VDecl->
getLocation(), diag::err_loader_uninitialized_cant_init);
14142 if (!
HLSL().handleInitialization(VDecl,
Init))
14154 if (!
Result.isUsable()) {
14162 bool InitializedFromParenListExpr =
false;
14163 bool IsParenListInit =
false;
14170 if (
auto *CXXDirectInit = dyn_cast<ParenListExpr>(
Init)) {
14172 MultiExprArg(CXXDirectInit->getExprs(), CXXDirectInit->getNumExprs());
14173 InitializedFromParenListExpr =
true;
14174 }
else if (
auto *CXXDirectInit = dyn_cast<CXXParenListInitExpr>(
Init)) {
14175 Args = CXXDirectInit->getInitExprs();
14176 InitializedFromParenListExpr =
true;
14183 if (!
Result.isUsable()) {
14203 IsParenListInit = !InitSeq.
steps().empty() &&
14207 if (!
Init->getType().isNull() && !
Init->getType()->isDependentType() &&
14209 Context.getAsIncompleteArrayType(VDeclType) &&
14210 Context.getAsIncompleteArrayType(
Init->getType())) {
14239 if (VDecl->
hasAttr<BlocksAttr>())
14252 !
Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
14253 Init->getBeginLoc()))
14254 FSI->markSafeWeakUse(
Init);
14275 if (!
Result.isUsable()) {
14315 if (
auto *E = dyn_cast<ExprWithCleanups>(
Init))
14316 if (
auto *BE = dyn_cast<BlockExpr>(E->getSubExpr()->
IgnoreParens()))
14318 BE->getBlockDecl()->setCanAvoidCopyToHeap();
14353 <<
Init->getSourceRange();
14369 diag::ext_in_class_initializer_float_type_cxx11)
14370 << DclT <<
Init->getSourceRange();
14372 diag::note_in_class_initializer_float_type_cxx11)
14375 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
14376 << DclT <<
Init->getSourceRange();
14379 Diag(
Init->getExprLoc(), diag::err_in_class_initializer_non_constant)
14380 <<
Init->getSourceRange();
14387 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
14388 << DclT <<
Init->getSourceRange()
14394 << DclT <<
Init->getSourceRange();
14407 !
Context.getBaseElementType(VDecl->
getType()).isConstQualified()) &&
14415 if (
Context.getTargetInfo().getCXXABI().isMicrosoft() &&
14428 if (!InitType.
isNull() &&
14446 if (InitializedFromParenListExpr) {
14447 assert(
DirectInit &&
"Call-style initializer must be direct init.");
14470 VarDecl *VD = dyn_cast<VarDecl>(D);
14474 if (
auto *DD = dyn_cast<DecompositionDecl>(D))
14475 for (
auto *BD : DD->bindings())
14476 BD->setInvalidDecl();
14489 Context.getBaseElementType(Ty),
14490 diag::err_typecheck_decl_incomplete_type)) {
14497 diag::err_abstract_type_in_decl,
14512 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
14516 Diag(Var->getLocation(),
14517 diag::err_amdgcn_predicate_type_is_not_constructible)
14519 Var->setInvalidDecl();
14525 auto NextLoc = dyn_cast<DecompositionDecl>(RealDecl)->getRSquareLoc();
14529 Diag(NextLoc, diag::err_decomp_decl_requires_init) << Var;
14530 Var->setInvalidDecl();
14546 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
14547 !Var->isThisDeclarationADemotedDefinition()) {
14548 if (Var->isStaticDataMember()) {
14552 !
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
14553 Diag(Var->getLocation(),
14554 diag::err_constexpr_static_mem_var_requires_init)
14556 Var->setInvalidDecl();
14560 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
14561 Var->setInvalidDecl();
14568 if (!Var->isInvalidDecl() &&
14570 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
14571 bool HasConstExprDefaultConstructor =
false;
14572 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
14573 for (
auto *Ctor : RD->ctors()) {
14574 if (Ctor->isConstexpr() && Ctor->getNumParams() == 0 &&
14575 Ctor->getMethodQualifiers().getAddressSpace() ==
14577 HasConstExprDefaultConstructor =
true;
14581 if (!HasConstExprDefaultConstructor) {
14582 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
14583 Var->setInvalidDecl();
14589 if (!Var->isInvalidDecl() && Var->hasAttr<HLSLVkConstantIdAttr>()) {
14590 Diag(Var->getLocation(), diag::err_specialization_const);
14591 Var->setInvalidDecl();
14595 if (!Var->isInvalidDecl() && RealDecl->
hasAttr<LoaderUninitializedAttr>()) {
14596 if (Var->getStorageClass() ==
SC_Extern) {
14597 Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
14599 Var->setInvalidDecl();
14603 diag::err_typecheck_decl_incomplete_type)) {
14604 Var->setInvalidDecl();
14607 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
14608 if (!RD->hasTrivialDefaultConstructor()) {
14609 Diag(Var->getLocation(), diag::err_loader_uninitialized_trivial_ctor);
14610 Var->setInvalidDecl();
14620 Var->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion())
14627 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
14643 !Var->hasLinkage() && !Var->isInvalidDecl() &&
14645 diag::err_typecheck_decl_incomplete_type))
14646 Var->setInvalidDecl();
14651 diag::err_abstract_type_in_decl,
14653 Var->setInvalidDecl();
14656 Diag(Var->getLocation(), diag::warn_private_extern);
14657 Diag(Var->getLocation(), diag::note_private_extern);
14660 if (
Context.getTargetInfo().allowDebugInfoForExternalRef() &&
14661 !Var->isInvalidDecl())
14672 if (!Var->isInvalidDecl()) {
14676 Var->getLocation(), ArrayT->getElementType(),
14677 diag::err_array_incomplete_or_sizeless_type))
14678 Var->setInvalidDecl();
14680 if (Var->getStorageClass() ==
SC_Static) {
14690 if (Var->isFirstDecl())
14692 diag::ext_typecheck_decl_incomplete_type,
14698 if (!Var->isInvalidDecl())
14709 if (Var->isConstexpr())
14710 Diag(Var->getLocation(), diag::err_constexpr_var_requires_const_init)
14713 Diag(Var->getLocation(),
14714 diag::err_typecheck_incomplete_array_needs_initializer);
14715 Var->setInvalidDecl();
14722 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
14723 << Var <<
SourceRange(Var->getLocation(), Var->getLocation());
14732 if (Var->isInvalidDecl())
14735 if (!Var->hasAttr<AliasAttr>()) {
14738 diag::err_typecheck_decl_incomplete_type)) {
14739 Var->setInvalidDecl();
14748 diag::err_abstract_type_in_decl,
14750 Var->setInvalidDecl();
14757 unsigned DiagID = diag::warn_default_init_const_unsafe;
14758 if (Var->getStorageDuration() ==
SD_Static ||
14759 Var->getStorageDuration() ==
SD_Thread)
14760 DiagID = diag::warn_default_init_const;
14762 bool EmitCppCompat = !
Diags.isIgnored(
14763 diag::warn_cxx_compat_hack_fake_diagnostic_do_not_emit,
14764 Var->getLocation());
14766 Diag(Var->getLocation(), DiagID) <<
Type << EmitCppCompat;
14780 if (
const auto *CXXRecord =
14781 Context.getBaseElementType(
Type)->getAsCXXRecordDecl()) {
14785 if (!CXXRecord->isPOD())
14830 }
else if (
Init.isInvalid()) {
14848 VarDecl *VD = dyn_cast<VarDecl>(D);
14851 << InExpansionStmt;
14893 << InExpansionStmt << VD <<
Error;
14908 const char *PrevSpec;
14933 Context.getAttributedType(
Attr, MethodType, MethodType);
14944 if (var->isInvalidDecl())
return;
14951 if (var->getTypeSourceInfo()->getType()->isBlockPointerType() &&
14953 Diag(var->getLocation(), diag::err_opencl_invalid_block_declaration)
14955 var->setInvalidDecl();
14963 var->hasLocalStorage()) {
14964 switch (var->getType().getObjCLifetime()) {
14977 if (var->hasLocalStorage() &&
14986 if (var->isThisDeclarationADefinition() &&
14987 var->getDeclContext()->getRedeclContext()->isFileContext() &&
14988 var->isExternallyVisible() && var->hasLinkage() &&
14989 !var->isInline() && !var->getDescribedVarTemplate() &&
14993 !
getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
14994 var->getLocation())) {
14996 VarDecl *prev = var->getPreviousDecl();
15001 Diag(var->getLocation(), diag::warn_missing_variable_declarations) << var;
15002 Diag(var->getTypeSpecStartLoc(), diag::note_static_for_internal_linkage)
15008 std::optional<bool> CacheHasConstInit;
15009 const Expr *CacheCulprit =
nullptr;
15010 auto checkConstInit = [&]()
mutable {
15011 const Expr *
Init = var->getInit();
15012 if (
Init->isInstantiationDependent())
15015 if (!CacheHasConstInit)
15016 CacheHasConstInit = var->getInit()->isConstantInitializer(
15017 Context, var->getType()->isReferenceType(), &CacheCulprit);
15018 return *CacheHasConstInit;
15022 if (var->getType().isDestructedType()) {
15026 Diag(var->getLocation(), diag::err_thread_nontrivial_dtor);
15028 Diag(var->getLocation(), diag::note_use_thread_local);
15030 if (!checkConstInit()) {
15038 Diag(var->getLocation(), diag::note_use_thread_local);
15044 if (!var->getType()->isStructureType() && var->hasInit() &&
15047 unsigned NumInits = ILE->getNumInits();
15049 for (
unsigned I = 0; I < NumInits; ++I) {
15050 const auto *
Init = ILE->getInit(I);
15053 const auto *SL = dyn_cast<StringLiteral>(
Init->IgnoreImpCasts());
15057 unsigned NumConcat = SL->getNumConcatenated();
15061 if (NumConcat == 2 && !SL->getBeginLoc().isMacroID()) {
15062 bool OnlyOneMissingComma =
true;
15063 for (
unsigned J = I + 1; J < NumInits; ++J) {
15064 const auto *
Init = ILE->getInit(J);
15067 const auto *SLJ = dyn_cast<StringLiteral>(
Init->IgnoreImpCasts());
15068 if (!SLJ || SLJ->getNumConcatenated() > 1) {
15069 OnlyOneMissingComma =
false;
15074 if (OnlyOneMissingComma) {
15076 for (
unsigned i = 0; i < NumConcat - 1; ++i)
15078 PP.getLocForEndOfToken(SL->getStrTokenLoc(i)),
","));
15080 Diag(SL->getStrTokenLoc(1),
15081 diag::warn_concatenated_literal_array_init)
15083 Diag(SL->getBeginLoc(),
15084 diag::note_concatenated_string_literal_silence);
15095 if (var->hasAttr<BlocksAttr>())
15099 bool GlobalStorage = var->hasGlobalStorage();
15100 bool IsGlobal = GlobalStorage && !var->isStaticLocal();
15102 bool HasConstInit =
true;
15105 Diag(var->getLocation(), diag::err_constexpr_var_requires_const_init)
15110 !
type->isDependentType() &&
Init && !
Init->isValueDependent() &&
15111 (GlobalStorage || var->isConstexpr() ||
15112 var->mightBeUsableInConstantExpressions(
Context))) {
15124 HasConstInit = checkConstInit();
15128 if (HasConstInit) {
15129 if (var->isStaticDataMember() && !var->isInline() &&
15130 var->getLexicalDeclContext()->isRecord() &&
15131 type->isIntegralOrEnumerationType()) {
15136 diag::ext_in_class_initializer_non_constant)
15137 <<
Init->getSourceRange();
15140 (void)var->checkForConstantInitialization(Notes);
15142 }
else if (CacheCulprit) {
15143 Notes.emplace_back(CacheCulprit->
getExprLoc(),
15144 PDiag(diag::note_invalid_subexpr_in_const_expr));
15149 HasConstInit = var->checkForConstantInitialization(Notes);
15152 if (HasConstInit) {
15154 }
else if (var->isConstexpr()) {
15158 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
15159 diag::note_invalid_subexpr_in_const_expr) {
15160 DiagLoc = Notes[0].first;
15163 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
15164 << var <<
Init->getSourceRange();
15165 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
15166 Diag(Notes[I].first, Notes[I].second);
15167 }
else if (GlobalStorage && var->hasAttr<ConstInitAttr>()) {
15168 auto *
Attr = var->getAttr<ConstInitAttr>();
15169 Diag(var->getLocation(), diag::err_require_constant_init_failed)
15170 <<
Init->getSourceRange();
15173 for (
auto &it : Notes)
15174 Diag(it.first, it.second);
15175 }
else if (var->isStaticDataMember() && !var->isInline() &&
15176 var->getLexicalDeclContext()->isRecord()) {
15177 Diag(var->getLocation(), diag::err_in_class_initializer_non_constant)
15178 <<
Init->getSourceRange();
15179 for (
auto &it : Notes)
15180 Diag(it.first, it.second);
15181 var->setInvalidDecl();
15182 }
else if (IsGlobal &&
15184 var->getLocation())) {
15193 if (!checkConstInit())
15194 Diag(var->getLocation(), diag::warn_global_constructor)
15195 <<
Init->getSourceRange();
15201 if (GlobalStorage && var->isThisDeclarationADefinition() &&
15206 Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment();
15207 std::optional<QualType::NonConstantStorageReason> Reason;
15208 if (HasConstInit &&
15209 !(Reason = var->getType().isNonConstantStorage(
Context,
true,
false))) {
15215 if (
const SectionAttr *SA = var->getAttr<SectionAttr>()) {
15222 var->getType().isConstQualified()) {
15224 NonConstNonReferenceType) &&
15225 "This case should've already been handled elsewhere");
15226 Diag(var->getLocation(), diag::warn_section_msvc_compat)
15227 << var <<
ConstSegStack.CurrentValue << (int)(!HasConstInit
15233 var->addAttr(SectionAttr::CreateImplicit(
Context, SectionName,
15235 SectionAttr::Declspec_allocate));
15237 var->dropAttr<SectionAttr>();
15252 if (
Context.DeclMustBeEmitted(var) && !ModuleScopes.empty())
15253 Context.addModuleInitializer(ModuleScopes.back().Module, var);
15260 if (!
type->isDependentType())
15266 if (
Context.DeclMustBeEmitted(var) && !ModuleScopes.empty() &&
15267 (ModuleScopes.back().Module->isHeaderLikeModule() ||
15270 Context.addModuleInitializer(ModuleScopes.back().Module, var);
15273 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
15284 !FD->
hasAttr<DLLExportStaticLocalAttr>() &&
15285 !FD->
hasAttr<DLLImportStaticLocalAttr>()) {
15295 NewAttr->setInherited(
true);
15297 }
else if (
Attr *A = FD->
getAttr<DLLExportStaticLocalAttr>()) {
15298 auto *NewAttr = DLLExportAttr::CreateImplicit(
getASTContext(), *A);
15299 NewAttr->setInherited(
true);
15304 if (!FD->
hasAttr<DLLExportAttr>())
15307 }
else if (
Attr *A = FD->
getAttr<DLLImportStaticLocalAttr>()) {
15308 auto *NewAttr = DLLImportAttr::CreateImplicit(
getASTContext(), *A);
15309 NewAttr->setInherited(
true);
15320 if (
unsigned MaxAlign =
Context.getTargetInfo().getMaxTLSAlign()) {
15325 if (
Context.getDeclAlign(VD) > MaxAlignChars) {
15338 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
15350 VD->
addAttr(PragmaClangBSSSectionAttr::CreateImplicit(
15354 VD->
addAttr(PragmaClangDataSectionAttr::CreateImplicit(
15358 VD->
addAttr(PragmaClangRodataSectionAttr::CreateImplicit(
15362 VD->
addAttr(PragmaClangRelroSectionAttr::CreateImplicit(
15367 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
15368 for (
auto *BD : DD->bindings()) {
15373 CheckInvalidBuiltinCountedByRef(VD->
getInit(),
15396 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
15403 bool IsClassTemplateMember =
15405 Context->getDescribedClassTemplate();
15408 IsClassTemplateMember
15409 ? diag::warn_attribute_dllimport_static_field_definition
15410 : diag::err_attribute_dllimport_static_field_definition);
15411 Diag(IA->getLocation(), diag::note_attribute);
15412 if (!IsClassTemplateMember)
15440 if (RetainAttr *
Attr = VD->
getAttr<RetainAttr>()) {
15460 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
15464 for (
const auto *I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
15466 if (!MagicValueExpr) {
15469 std::optional<llvm::APSInt> MagicValueInt;
15471 Diag(I->getRange().getBegin(),
15472 diag::err_type_tag_for_datatype_not_ice)
15476 if (MagicValueInt->getActiveBits() > 64) {
15477 Diag(I->getRange().getBegin(),
15478 diag::err_type_tag_for_datatype_too_large)
15482 uint64_t MagicValue = MagicValueInt->getZExtValue();
15485 I->getMatchingCType(),
15486 I->getLayoutCompatible(),
15487 I->getMustBeNull());
15492 auto *VD = dyn_cast<VarDecl>(DD);
15493 return VD && !VD->getType()->hasAutoForTrailingReturnType();
15505 bool DiagnosedMultipleDecomps =
false;
15507 bool DiagnosedNonDeducedAuto =
false;
15509 for (
Decl *D : Group) {
15514 if (
auto *VD = dyn_cast<VarDecl>(D);
15515 LangOpts.OpenMP && VD && VD->hasAttr<OMPDeclareTargetDeclAttr>() &&
15516 VD->hasGlobalStorage())
15520 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
15521 if (!FirstDeclaratorInGroup)
15522 FirstDeclaratorInGroup = DD;
15523 if (!FirstDecompDeclaratorInGroup)
15524 FirstDecompDeclaratorInGroup = dyn_cast<DecompositionDecl>(D);
15527 FirstNonDeducedAutoInGroup = DD;
15529 if (FirstDeclaratorInGroup != DD) {
15532 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
15534 diag::err_decomp_decl_not_alone)
15536 << DD->getSourceRange();
15537 DiagnosedMultipleDecomps =
true;
15543 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
15545 diag::err_auto_non_deduced_not_alone)
15546 << FirstNonDeducedAutoInGroup->
getType()
15549 << DD->getSourceRange();
15550 DiagnosedNonDeducedAuto =
true;
15555 Decls.push_back(D);
15561 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
15563 Context.addDeclaratorForUnnamedTagDecl(Tag, FirstDeclaratorInGroup);
15575 if (Group.size() > 1) {
15577 VarDecl *DeducedDecl =
nullptr;
15578 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
15579 VarDecl *D = dyn_cast<VarDecl>(Group[i]);
15583 if (!DT || DT->getDeducedType().isNull())
15586 Deduced = DT->getDeducedType();
15588 }
else if (!
Context.hasSameType(DT->getDeducedType(),
Deduced)) {
15589 auto *AT = dyn_cast<AutoType>(DT);
15591 diag::err_auto_different_deductions)
15593 << DeducedDecl->
getDeclName() << DT->getDeducedType()
15617 if (Group.empty() || !Group[0])
15620 if (
Diags.isIgnored(diag::warn_doc_param_not_found,
15621 Group[0]->getLocation()) &&
15622 Diags.isIgnored(diag::warn_unknown_comment_command_name,
15623 Group[0]->getLocation()))
15626 if (Group.size() >= 2) {
15634 Decl *MaybeTagDecl = Group[0];
15636 Group = Group.slice(1);
15689 const auto *VD = dyn_cast<ValueDecl>(D);
15703 unsigned Kind = TD->isEnum() ? 2 : TD->isUnion() ? 1 : 0;
15705 Diag(TD->getLocation(), diag::note_declared_at);
15711 if (!ExplicitThisLoc.
isValid())
15714 "explicit parameter in non-cplusplus mode");
15716 S.
Diag(ExplicitThisLoc, diag::err_cxx20_deducing_this)
15728 LSI->ExplicitObjectParameter = P;
15751 ? diag::ext_register_storage_class
15752 : diag::warn_deprecated_register)
15758 diag::err_invalid_storage_class_in_func_decl)
15767 diag::err_invalid_storage_class_in_func_decl);
15779 << 0 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
15800 PrevDecl =
nullptr;
15822 diag::err_hlsl_incomplete_resource_array_in_function_param);
15835 New->setInvalidDecl();
15854 Diag(
New->getLocation(), diag::err_module_private_local)
15858 if (
New->hasAttr<BlocksAttr>())
15859 Diag(
New->getLocation(), diag::err_block_not_allowed_on)
15860 << diag::NotAllowedBlockVarReason::NonlocalVariable;
15874 T,
Context.getTrivialTypeSourceInfo(T, Loc),
15876 Param->setImplicit();
15889 !
Parameter->getIdentifier()->isPlaceholder()) {
15890 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
15898 if (
LangOpts.NumLargeByValueCopy == 0)
15904 unsigned Size =
Context.getTypeSizeInChars(ReturnTy).getQuantity();
15905 if (Size >
LangOpts.NumLargeByValueCopy)
15913 if (T->isDependentType() || !T.isPODType(
Context))
15915 unsigned Size =
Context.getTypeSizeInChars(T).getQuantity();
15916 if (Size >
LangOpts.NumLargeByValueCopy)
15929 T->isObjCLifetimeType()) {
15936 if (T->isArrayType()) {
15937 if (!T.isConstQualified()) {
15941 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
15943 Diag(NameLoc, diag::err_arc_array_param_no_ownership)
15948 lifetime = T->getObjCARCImplicitLifetime();
15950 T =
Context.getLifetimeQualifiedType(T, lifetime);
15955 if (T->isArrayType() && !T.hasAddressSpace()) {
15961 T =
Context.getAddrSpaceQualType(T, ImplAS);
15968 Context.getAdjustedParameterType(T),
15969 TSInfo, SC,
nullptr);
15974 if (
New->isParameterPack())
15976 CSI->LocalPacks.push_back(
New);
15978 if (
New->getType().hasNonTrivialToPrimitiveDestructCUnion() ||
15979 New->getType().hasNonTrivialToPrimitiveCopyCUnion())
15986 if (T->isObjCObjectType()) {
15990 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
15992 T =
Context.getObjCObjectPointerType(T);
15997 if (T.getPointerAuth()) {
15998 Diag(NameLoc, diag::err_ptrauth_qualifier_invalid) << T << 1;
15999 New->setInvalidDecl();
16013 !(T->isFunctionPointerType() &&
16019 Diag(NameLoc, diag::err_arg_with_address_space);
16020 New->setInvalidDecl();
16024 if (
Context.getTargetInfo().getTriple().isPPC64() &&
16025 PPC().CheckPPCMMAType(
New->getOriginalType(),
New->getLocation())) {
16026 New->setInvalidDecl();
16047 for (
int i = FTI.
NumParams; i != 0; ) {
16052 llvm::raw_svector_ostream(Code)
16063 const char* PrevSpec;
16066 DiagID,
Context.getPrintingPolicy());
16095 if (
LangOpts.OpenMP &&
OpenMP().isInOpenMPDeclareVariantScope())
16097 ParentScope, D, TemplateParameterLists, Bases);
16103 if (!Bases.empty())
16111 Consumer.HandleInlineFunctionDefinition(D);
16120 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
16123 PossiblePrototype = Prev;
16147 if (II->isStr(
"main") || II->isStr(
"efi_main"))
16166 if (FD->
hasAttr<DeviceKernelAttr>())
16215 bool DefinitionVisible =
false;
16219 !
Definition->getTemplateParameterLists().empty())) {
16222 if (!DefinitionVisible) {
16223 if (
auto *TD =
Definition->getDescribedFunctionTemplate())
16237 Diag(
Definition->getLocation(), diag::note_previous_definition);
16246 LSI->
Lambda = LambdaClass;
16285 for (
const auto &
C : LambdaClass->
captures()) {
16286 if (
C.capturesVariable()) {
16290 const bool ByRef =
C.getCaptureKind() ==
LCK_ByRef;
16292 true,
C.getLocation(),
16293 C.isPackExpansion()
16295 I->getType(),
false);
16297 }
else if (
C.capturesThis()) {
16323 FD = FunTmpl->getTemplatedDecl();
16334 if (
const auto *
Attr = FD->
getAttr<AliasAttr>()) {
16339 if (
const auto *
Attr = FD->
getAttr<IFuncAttr>()) {
16344 if (
const auto *
Attr = FD->
getAttr<TargetVersionAttr>()) {
16345 if (
Context.getTargetInfo().getTriple().isAArch64() &&
16346 !
Context.getTargetInfo().hasFeature(
"fmv") &&
16347 !
Attr->isDefaultVersion()) {
16356 if (
auto *Ctor = dyn_cast<CXXConstructorDecl>(FD)) {
16358 Ctor->isDefaultConstructor() &&
16359 Context.getTargetInfo().getCXXABI().isMicrosoft()) {
16362 if (DLLExportAttr *
Attr = Ctor->getAttr<DLLExportAttr>())
16405 "There should be an active template instantiation on the stack "
16406 "when instantiating a generic lambda!");
16416 if (!
Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID) &&
16417 !
Context.BuiltinInfo.isPredefinedRuntimeFunction(BuiltinID)) {
16432 diag::err_func_def_incomplete_result) ||
16434 diag::err_abstract_type_in_decl,
16450 auto *NonParmDecl = dyn_cast<NamedDecl>(NPD);
16454 "parameters should not be in newly created FD yet");
16457 if (NonParmDecl->getDeclName())
16462 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
16463 for (
auto *EI : ED->enumerators())
16471 Param->setOwningFunction(FD);
16474 if (Param->getIdentifier() && FnBodyScope) {
16511 assert(!FD->
hasAttr<DLLExportAttr>());
16512 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
16542 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
16543 if (!SKEPAttr->isInvalidAttr()) {
16563 if (
auto *TD = dyn_cast<FunctionTemplateDecl>(FD))
16564 FD = TD->getTemplatedDecl();
16565 if (FD && FD->
hasAttr<OptimizeNoneAttr>()) {
16577 for (
unsigned I = 0, E =
Scope->Returns.size(); I != E; ++I) {
16578 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
16579 if (!NRVOCandidate->isNRVOVariable()) {
16580 Diag(Returns[I]->getRetValue()->getExprLoc(),
16581 diag::warn_not_eliding_copy_on_return);
16601 Outer.Fun.hasTrailingReturnType()) {
16619 if (FD->isConstexpr())
16624 if (FD->getReturnType()->getContainedDeducedType())
16627 return Consumer.shouldSkipFunctionBody(D);
16634 FD->setHasSkippedBody();
16647 S.PopExpressionEvaluationContext();
16652 bool IsLambda =
false;
16656 llvm::DenseMap<const BlockDecl *, bool> EscapeInfo;
16658 auto IsOrNestedInEscapingBlock = [&](
const BlockDecl *BD) {
16659 auto [It, Inserted] = EscapeInfo.try_emplace(BD);
16673 return It->second = R;
16678 for (
const std::pair<SourceLocation, const BlockDecl *> &P :
16680 if (IsOrNestedInEscapingBlock(P.second))
16681 S.
Diag(P.first, diag::warn_implicitly_retains_self)
16696 methodHasName(FD,
"get_return_object_on_allocation_failure");
16706 if (!FD->
hasAttr<CoroWrapperAttr>())
16711 bool RetainFunctionScopeInfo) {
16738 SYCLKernelEntryPointAttr *SKEPAttr =
16739 FD->
getAttr<SYCLKernelEntryPointAttr>();
16741 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16742 << SKEPAttr << diag::InvalidSKEPReason::DefaultedFn;
16743 SKEPAttr->setInvalidAttr();
16745 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16746 << SKEPAttr << diag::InvalidSKEPReason::DeletedFn;
16747 SKEPAttr->setInvalidAttr();
16749 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16750 << SKEPAttr << diag::InvalidSKEPReason::Coroutine;
16751 SKEPAttr->setInvalidAttr();
16753 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16754 << SKEPAttr << diag::InvalidSKEPReason::FunctionTryBlock;
16755 SKEPAttr->setInvalidAttr();
16763 if (Body && !SKEPAttr->isInvalidAttr()) {
16793 SYCLExternalAttr *SEAttr = FD->
getAttr<SYCLExternalAttr>();
16795 Diag(SEAttr->getLocation(),
16796 diag::err_sycl_external_invalid_deleted_function)
16826 Expr *Dummy =
nullptr;
16837 if (LSI->HasImplicitReturnType) {
16844 LSI->ReturnType.isNull() ?
Context.VoidTy : LSI->ReturnType;
16848 FD->
setType(
Context.getFunctionType(RetType, Proto->getParamTypes(),
16849 Proto->getExtProtoInfo()));
16882 dyn_cast<CXXDestructorDecl>(FD))
16902 if (PossiblePrototype) {
16906 TypeLoc TL = TI->getTypeLoc();
16909 diag::note_declaration_not_a_prototype)
16912 FTL.getRParenLoc(),
"void")
16920 if (LocInfo.first.isInvalid())
16924 StringRef Buffer =
SM.getBufferData(LocInfo.first, &
Invalid);
16928 if (LocInfo.second > Buffer.size())
16931 const char *LexStart = Buffer.data() + LocInfo.second;
16932 StringRef StartTok(LexStart, Buffer.size() - LocInfo.second);
16934 return StartTok.consume_front(
"const") &&
16936 StartTok.starts_with(
"/*") || StartTok.starts_with(
"//"));
16939 auto findBeginLoc = [&]() {
16955 diag::note_static_for_internal_linkage)
16966 if (!PossiblePrototype)
17012 if (PossiblePrototype)
17014 diag::warn_non_prototype_changes_behavior)
17021 if (
const auto *CmpndBody = dyn_cast<CompoundStmt>(Body))
17022 if (!CmpndBody->body_empty())
17023 Diag(CmpndBody->body_front()->getBeginLoc(),
17024 diag::warn_dispatch_body_ignored);
17026 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
17034 !
Context.getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
17035 Context.setNonKeyFunction(MD);
17051 "Function parsing confused");
17052 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
17064 << MD->getSelector().getAsString();
17069 bool isDesignated =
17070 MD->isDesignatedInitializerForTheInterface(&InitMethod);
17071 assert(isDesignated && InitMethod);
17072 (void)isDesignated;
17075 auto IFace = MD->getClassInterface();
17078 auto SuperD = IFace->getSuperClass();
17088 diag::warn_objc_designated_init_missing_super_call);
17090 diag::note_objc_designated_init_marked_here);
17098 diag::warn_objc_secondary_init_missing_init_call);
17113 else if (
AMDGPU().HasPotentiallyUnguardedBuiltinUsage(FD))
17118 "This should only be set for ObjC methods, which should have been "
17119 "handled in the block above.");
17134 if (!
Destructor->getParent()->isDependentType())
17152 ActivePolicy = &WP;
17155 if (!IsInstantiation && FD &&
17161 if (FD && FD->
hasAttr<NakedAttr>()) {
17165 bool RegisterVariables =
false;
17166 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
17167 for (
const auto *
Decl : DS->decls()) {
17168 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
17169 RegisterVariables =
17170 Var->hasAttr<AsmLabelAttr>() && !Var->hasInit();
17171 if (!RegisterVariables)
17176 if (RegisterVariables)
17179 Diag(S->getBeginLoc(), diag::err_non_asm_stmt_in_naked_function);
17180 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
17189 "Leftover temporaries in function");
17190 assert(!
Cleanup.exprNeedsCleanups() &&
17191 "Unaccounted cleanups in function");
17193 "Leftover expressions for odr-use checking");
17202 if (!IsInstantiation)
17205 if (!RetainFunctionScopeInfo)
17234 D = TD->getTemplatedDecl();
17246 assert(
LangOpts.implicitFunctionsAllowed() &&
17247 "Implicit function declarations aren't allowed in this language mode");
17254 Scope *BlockScope = S;
17262 Scope *ContextScope = BlockScope;
17266 ContextScope = ContextScope->
getParent();
17286 Diag(Loc, diag::ext_use_out_of_scope_declaration)
17289 return ExternCPrev;
17295 if (II.
getName().starts_with(
"__builtin_"))
17296 diag_id = diag::warn_builtin_unknown;
17299 diag_id = diag::ext_implicit_function_decl_c99;
17301 diag_id = diag::warn_implicit_function_decl;
17309 if (S && !ExternCPrev &&
17316 Diag(Loc, diag_id) << &II;
17332 return ExternCPrev;
17340 Context.getPrintingPolicy());
17342 assert(!
Error &&
"Error setting up implicit decl!");
17385 bool IsNothrow =
false;
17397 if (!IsNothrow && !FD->
hasAttr<ReturnsNonNullAttr>() &&
17415 if (!FD->
hasAttr<AllocSizeAttr>()) {
17416 FD->
addAttr(AllocSizeAttr::CreateImplicit(
17427 if (AlignmentParam && !FD->
hasAttr<AllocAlignAttr>()) {
17428 FD->
addAttr(AllocAlignAttr::CreateImplicit(
17452 unsigned FormatIdx;
17454 if (
Context.BuiltinInfo.isPrintfLike(BuiltinID, FormatIdx, HasVAListArg)) {
17455 if (!FD->
hasAttr<FormatAttr>()) {
17456 const char *fmt =
"printf";
17458 if (FormatIdx < NumParams &&
17464 HasVAListArg ? 0 : FormatIdx+2,
17468 if (
Context.BuiltinInfo.isScanfLike(BuiltinID, FormatIdx,
17470 if (!FD->
hasAttr<FormatAttr>())
17472 &
Context.Idents.get(
"scanf"),
17474 HasVAListArg ? 0 : FormatIdx+2,
17480 if (!FD->
hasAttr<CallbackAttr>() &&
17481 Context.BuiltinInfo.performsCallback(BuiltinID, Encoding))
17482 FD->
addAttr(CallbackAttr::CreateImplicit(
17488 bool NoExceptions =
17490 bool ConstWithoutErrnoAndExceptions =
17491 Context.BuiltinInfo.isConstWithoutErrnoAndExceptions(BuiltinID);
17492 bool ConstWithoutExceptions =
17493 Context.BuiltinInfo.isConstWithoutExceptions(BuiltinID);
17494 if (!FD->
hasAttr<ConstAttr>() &&
17495 (ConstWithoutErrnoAndExceptions || ConstWithoutExceptions) &&
17496 (!ConstWithoutErrnoAndExceptions ||
17498 (!ConstWithoutExceptions || NoExceptions))
17504 const llvm::Triple &Trip =
Context.getTargetInfo().getTriple();
17505 if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
17507 switch (BuiltinID) {
17508 case Builtin::BI__builtin_fma:
17509 case Builtin::BI__builtin_fmaf:
17510 case Builtin::BI__builtin_fmal:
17511 case Builtin::BIfma:
17512 case Builtin::BIfmaf:
17513 case Builtin::BIfmal:
17523 if (
Context.BuiltinInfo.isNonNull(BuiltinID, Indxs, OptMode) &&
17524 !FD->
hasAttr<NonNullAttr>()) {
17526 for (
int I : Indxs) {
17529 T =
Context.getAttributedType(attr::TypeNonNull, T, T);
17534 for (
int I : Indxs)
17535 ParamIndxs.push_back(
ParamIdx(I + 1, FD));
17536 FD->
addAttr(NonNullAttr::CreateImplicit(
Context, ParamIndxs.data(),
17537 ParamIndxs.size()));
17540 if (
Context.BuiltinInfo.isReturnsTwice(BuiltinID) &&
17541 !FD->
hasAttr<ReturnsTwiceAttr>())
17544 if (
Context.BuiltinInfo.isNoThrow(BuiltinID) && !FD->
hasAttr<NoThrowAttr>())
17546 if (
Context.BuiltinInfo.isPure(BuiltinID) && !FD->
hasAttr<PureAttr>())
17548 if (
Context.BuiltinInfo.isConst(BuiltinID) && !FD->
hasAttr<ConstAttr>())
17551 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
17556 Context.BuiltinInfo.isAuxBuiltinID(BuiltinID))
17563 switch (BuiltinID) {
17564 case Builtin::BImemalign:
17565 case Builtin::BIaligned_alloc:
17566 if (!FD->
hasAttr<AllocAlignAttr>())
17575 switch (BuiltinID) {
17576 case Builtin::BIcalloc:
17577 FD->
addAttr(AllocSizeAttr::CreateImplicit(
17580 case Builtin::BImemalign:
17581 case Builtin::BIaligned_alloc:
17582 case Builtin::BIrealloc:
17586 case Builtin::BImalloc:
17606 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
17622 if (Name->
isStr(
"asprintf") || Name->
isStr(
"vasprintf")) {
17625 if (!FD->
hasAttr<FormatAttr>())
17627 &
Context.Idents.get(
"printf"), 2,
17628 Name->
isStr(
"vasprintf") ? 0 : 3,
17632 if (Name->
isStr(
"__CFStringMakeConstantString")) {
17635 if (!FD->
hasAttr<FormatArgAttr>())
17643 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
17644 assert(!T.isNull() &&
"GetTypeForDeclarator() returned null type");
17647 assert(D.
isInvalidType() &&
"no declarator info for valid type");
17648 TInfo =
Context.getTrivialTypeSourceInfo(T);
17701 if (T->isDependentType())
17711 if (T->isAtomicType())
17712 Diag(UnderlyingLoc, diag::warn_atomic_stripped_in_enum);
17715 std::optional<unsigned> QualSelect;
17717 QualSelect = diag::CVQualList::Both;
17719 QualSelect = diag::CVQualList::Const;
17721 QualSelect = diag::CVQualList::Volatile;
17724 Diag(UnderlyingLoc, diag::warn_cv_stripped_in_enum) << *QualSelect;
17726 T = T.getAtomicUnqualifiedType();
17731 if (BT->isInteger())
17734 return Diag(UnderlyingLoc, diag::err_enum_invalid_underlying)
17735 << T << T->isBitIntType();
17739 QualType EnumUnderlyingTy,
bool IsFixed,
17741 if (IsScoped != Prev->
isScoped()) {
17742 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
17748 if (IsFixed && Prev->
isFixed()) {
17751 !
Context.hasSameUnqualifiedType(EnumUnderlyingTy,
17754 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
17760 }
else if (IsFixed != Prev->
isFixed()) {
17761 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
17783 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
17819 llvm_unreachable(
"invalid TTK");
17858 if (IsIgnoredLoc(NewTagLoc))
17861 auto IsIgnored = [&](
const TagDecl *Tag) {
17862 return IsIgnoredLoc(Tag->getLocation());
17879 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
17887 if (isDefinition) {
17895 bool previousMismatch =
false;
17897 if (I->getTagKind() !=
NewTag) {
17902 if (!previousMismatch) {
17903 previousMismatch =
true;
17904 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
17908 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
17921 if (PrevDef && IsIgnored(PrevDef))
17925 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
17932 Diag(NewTagLoc, diag::note_struct_class_suggestion)
17962 if (!Namespace || Namespace->isAnonymousNamespace())
17965 Namespaces.push_back(II);
17968 if (Lookup == Namespace)
17975 llvm::raw_svector_ostream OS(Insertion);
17978 std::reverse(Namespaces.begin(), Namespaces.end());
17979 for (
auto *II : Namespaces)
17980 OS << II->getName() <<
"::";
17993 if (OldDC->
Equals(NewDC))
18012 bool ScopedEnumUsesClassTag,
TypeResult UnderlyingType,
18013 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
18018 "Nameless record must be a definition!");
18023 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
18026 bool isMemberSpecialization =
false;
18027 bool IsInjectedClassName =
false;
18033 if (TemplateParameterLists.size() > 0 ||
18037 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
18054 !isMemberSpecialization)
18055 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
18058 if (TemplateParams) {
18060 Diag(KWLoc, diag::err_enum_template);
18064 if (TemplateParams->
size() > 0) {
18073 S, TagSpec, TUK, KWLoc, SS, Name, NameLoc, Attrs, TemplateParams,
18074 AS, ModulePrivateLoc,
18076 TemplateParameterLists.data(), isMemberSpecialization, SkipBody);
18082 isMemberSpecialization =
true;
18086 if (!TemplateParameterLists.empty() && isMemberSpecialization &&
18105 ScopedEnum ?
SourceRange(KWLoc, ScopedEnumKWLoc) : KWLoc);
18106 assert(ScopedEnum || !ScopedEnumUsesClassTag);
18107 Diag(KWLoc, diag::note_enum_friend)
18108 << (ScopedEnum + ScopedEnumUsesClassTag);
18114 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
18115 bool IsFixed = !UnderlyingType.
isUnset() || ScopedEnum;
18118 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum) ||
18122 EnumUnderlying =
Context.IntTy.getTypePtr();
18123 }
else if (UnderlyingType.
get()) {
18131 EnumUnderlying = TI;
18135 EnumUnderlying =
Context.IntTy.getTypePtr();
18139 EnumUnderlying =
Context.IntTy.getTypePtr();
18149 if (
TypeSourceInfo *TI = dyn_cast<TypeSourceInfo *>(EnumUnderlying);
18150 TI && TI->
getType()->isAtomicType())
18153 }
else if (
Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment()) {
18159 EnumUnderlying =
Context.IntTy.getTypePtr();
18165 bool isStdBadAlloc =
false;
18166 bool isStdAlignValT =
false;
18175 auto createTagFromNewDecl = [&]() ->
TagDecl * {
18185 ScopedEnum, ScopedEnumUsesClassTag, IsFixed);
18189 if (EnumUnderlying) {
18191 if (
TypeSourceInfo *TI = dyn_cast<TypeSourceInfo *>(EnumUnderlying))
18197 ?
Context.getPromotedIntegerType(EnumTy)
18218 RD->addAttr(PackedAttr::CreateImplicit(
Context));
18234 goto CreateNewDecl;
18242 IsDependent =
true;
18271 if (
Previous.wasNotFoundInCurrentInstantiation() &&
18273 IsDependent =
true;
18278 Diag(NameLoc, diag::err_not_tag_in_scope)
18279 << Kind << Name << DC << SS.
getRange();
18282 goto CreateNewDecl;
18330 bool FriendSawTagOutsideEnclosingNamespace =
false;
18337 FriendSawTagOutsideEnclosingNamespace =
true;
18346 if (
Previous.isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
18348 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
18379 Previous.getFoundDecl()->isTemplateParameter()) {
18388 if (Name->
isStr(
"bad_alloc")) {
18390 isStdBadAlloc =
true;
18397 }
else if (Name->
isStr(
"align_val_t")) {
18398 isStdAlignValT =
true;
18410 IsTemplateParamOrArg)) {
18411 if (
Invalid)
goto CreateNewDecl;
18494 if (
TagDecl *Tag = TD->getUnderlyingType()->getAsTagDecl()) {
18495 if (Tag->getDeclName() == Name &&
18496 Tag->getDeclContext()->getRedeclContext()
18497 ->Equals(TD->getDeclContext()->getRedeclContext())) {
18510 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
18511 auto *OldTag = dyn_cast<TagDecl>(PrevDecl);
18514 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
18516 *
this, OldTag->getDeclContext(), SearchDC))) {
18517 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
18518 Diag(Shadow->getTargetDecl()->getLocation(),
18519 diag::note_using_decl_target);
18520 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl)
18524 goto CreateNewDecl;
18528 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
18534 SS.
isNotEmpty() || isMemberSpecialization)) {
18536 if (
auto *RD = dyn_cast<CXXRecordDecl>(PrevDecl);
18537 RD && RD->isInjectedClassName()) {
18544 IsInjectedClassName =
true;
18552 bool SafeToContinue =
18555 if (SafeToContinue)
18556 Diag(KWLoc, diag::err_use_with_wrong_tag)
18559 PrevTagDecl->getKindName());
18561 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
18562 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
18564 if (SafeToContinue)
18565 Kind = PrevTagDecl->getTagKind();
18578 return PrevTagDecl;
18582 dyn_cast_if_present<TypeSourceInfo *>(EnumUnderlying))
18583 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
18584 else if (
const Type *T =
18585 dyn_cast_if_present<const Type *>(EnumUnderlying))
18586 EnumUnderlyingTy =
QualType(T, 0);
18592 ScopedEnum, EnumUnderlyingTy,
18593 IsFixed, PrevEnum))
18603 Diag(NameLoc, diag::ext_member_redeclared);
18604 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
18613 if (
const auto *OutermostClass = dyn_cast<CXXRecordDecl>(PrevDecl)) {
18614 while (
const auto *ParentClass =
18615 dyn_cast<CXXRecordDecl>(OutermostClass->getParent()))
18616 OutermostClass = ParentClass;
18618 if (OutermostClass->isLocalClass() &&
18620 Diag(NameLoc, diag::err_local_nested_class_invalid_scope)
18621 << Name << OutermostClass;
18622 Diag(OutermostClass->getLocation(), diag::note_defined_here)
18632 if (!Attrs.
empty()) {
18636 (PrevTagDecl->getFriendObjectKind() ==
18649 return PrevTagDecl;
18654 return PrevTagDecl;
18663 if (Def->isBeingDefined()) {
18664 Diag(NameLoc, diag::err_nested_redefinition) << Name;
18665 Diag(PrevTagDecl->getLocation(),
18666 diag::note_previous_definition);
18674 bool IsExplicitSpecializationAfterInstantiation =
false;
18675 if (isMemberSpecialization) {
18677 IsExplicitSpecializationAfterInstantiation =
18678 RD->getTemplateSpecializationKind() !=
18680 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
18681 IsExplicitSpecializationAfterInstantiation =
18682 ED->getTemplateSpecializationKind() !=
18691 bool HiddenDefVisible =
false;
18705 SkipBody->
New = createTagFromNewDecl();
18714 if (!HiddenDefVisible && Hidden)
18719 }
else if (!IsExplicitSpecializationAfterInstantiation) {
18724 Diag(NameLoc, diag::warn_redefinition_in_param_list)
18727 Diag(NameLoc, diag::err_redefinition) << Name;
18729 NameLoc.
isValid() ? NameLoc : KWLoc);
18748 IsInjectedClassName) {
18749 SearchDC = PrevTagDecl->getDeclContext();
18777 Diag(NameLoc, diag::err_tag_reference_non_tag)
18778 << PrevDecl << NTK << Kind;
18784 SS.
isNotEmpty() || isMemberSpecialization)) {
18790 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
18796 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
18799 Diag(NameLoc, diag::err_tag_definition_of_typedef)
18800 << Name << Kind << TND->getUnderlyingType();
18808 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
18840 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
18841 ScopedEnumUsesClassTag, IsFixed);
18845 KWLoc, ScopedEnumKWLoc.
isValid() ? ScopedEnumKWLoc : KWLoc));
18853 if (IsFixed && ED->
isFixed()) {
18856 }
else if (PrevDecl &&
18858 Diag(Loc, diag::ext_forward_ref_enum_def)
18862 unsigned DiagID = diag::ext_forward_ref_enum;
18864 DiagID = diag::ext_ms_forward_ref_enum;
18866 DiagID = diag::err_forward_ref_enum;
18871 if (EnumUnderlying) {
18873 if (
TypeSourceInfo *TI = dyn_cast<TypeSourceInfo *>(EnumUnderlying))
18879 ?
Context.getPromotedIntegerType(EnumTy)
18881 assert(ED->
isComplete() &&
"enum with type should be complete");
18891 cast_or_null<CXXRecordDecl>(PrevDecl));
18897 cast_or_null<RecordDecl>(PrevDecl));
18903 Diag(
New->getLocation(), diag::ext_type_defined_in_offsetof)
18909 (IsTypeSpecifier || IsTemplateParamOrArg) &&
18911 Diag(
New->getLocation(), diag::err_type_defined_in_type_specifier)
18918 Diag(
New->getLocation(), diag::err_type_defined_in_enum)
18931 isMemberSpecialization))
18935 if (TemplateParameterLists.size() > 0) {
18936 New->setTemplateParameterListsInfo(
Context, TemplateParameterLists);
18955 RD->addAttr(PackedAttr::CreateImplicit(
Context));
18961 if (ModulePrivateLoc.
isValid()) {
18962 if (isMemberSpecialization)
18963 Diag(
New->getLocation(), diag::err_module_private_specialization)
18970 New->setModulePrivate();
18990 Diag(Loc, diag::err_type_defined_in_param_type)
18996 }
else if (!PrevDecl) {
19000 Diag(Loc, diag::warn_decl_in_param_list)
19006 New->setInvalidDecl();
19028 New->startDefinition();
19030 New->setCompleteDefinition();
19031 New->demoteThisDefinitionToDeclaration();
19059 if (!
New->isInvalidDecl() &&
19060 New->getDeclContext()->getRedeclContext()->isTranslationUnit() &&
19067 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(
New)) {
19080 if (isMemberSpecialization && !
New->isInvalidDecl())
19087 if (
New->isBeingDefined())
19088 if (
auto RD = dyn_cast<RecordDecl>(
New))
19089 RD->completeDefinition();
19091 }
else if (SkipBody && SkipBody->
ShouldSkip) {
19125 bool IsFinalSpelledSealed,
19133 if (!
Record->getIdentifier())
19141 IsFinalSpelledSealed
19142 ? FinalAttr::Keyword_sealed
19143 : FinalAttr::Keyword_final));
19161 "Broken injected-class-name");
19168 Tag->setBraceRange(BraceRange);
19171 if (Tag->isBeingDefined()) {
19172 assert(Tag->isInvalidDecl() &&
"We should already have completed it");
19173 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
19174 RD->completeDefinition();
19177 if (
auto *RD = dyn_cast<CXXRecordDecl>(Tag)) {
19179 if (RD->hasAttr<SYCLSpecialClassAttr>()) {
19180 auto *Def = RD->getDefinition();
19181 assert(Def &&
"The record is expected to have a completed definition");
19182 unsigned NumInitMethods = 0;
19183 for (
auto *
Method : Def->methods()) {
19184 if (!
Method->getIdentifier())
19186 if (
Method->getName() ==
"__init")
19189 if (NumInitMethods > 1 || !Def->hasInitMethod())
19190 Diag(RD->getLocation(), diag::err_sycl_special_type_num_init_method);
19208 Tag->setTopLevelDeclInObjCContainer();
19211 if (!Tag->isInvalidDecl())
19212 Consumer.HandleTagDeclDefinition(Tag);
19216 if (
Context.getTargetInfo().getTriple().isOSAIX() &&
19222 const RecordDecl *RD = dyn_cast<RecordDecl>(Tag);
19226 if (llvm::any_of(RD->
fields(),
19227 [](
const FieldDecl *FD) { return FD->isBitField(); }))
19228 Diag(BraceRange.
getBegin(), diag::warn_pragma_align_not_xl_compatible);
19235 Tag->setInvalidDecl();
19238 if (Tag->isBeingDefined()) {
19239 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
19240 RD->completeDefinition();
19253 QualType FieldTy,
bool IsMsStruct,
19264 diag::err_field_incomplete_or_sizeless))
19267 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
19269 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
19279 llvm::APSInt
Value;
19284 BitWidth = ICE.
get();
19287 if (
Value == 0 && FieldName)
19288 return Diag(FieldLoc, diag::err_bitfield_has_zero_width)
19291 if (
Value.isSigned() &&
Value.isNegative()) {
19293 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
19295 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
19302 return Diag(FieldLoc, diag::err_bitfield_too_wide)
19307 uint64_t TypeStorageSize =
Context.getTypeSize(FieldTy);
19308 uint64_t TypeWidth =
Context.getIntWidth(FieldTy);
19309 bool BitfieldIsOverwide =
Value.ugt(TypeWidth);
19313 bool CStdConstraintViolation =
19315 bool MSBitfieldViolation =
Value.ugt(TypeStorageSize) && IsMsStruct;
19316 if (CStdConstraintViolation || MSBitfieldViolation) {
19317 unsigned DiagWidth =
19318 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
19319 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
19321 << !CStdConstraintViolation << DiagWidth;
19327 if (BitfieldIsOverwide && !FieldTy->
isBooleanType() && FieldName) {
19328 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
19371 TInfo =
Context.getTrivialTypeSourceInfo(T, Loc);
19382 diag::err_invalid_thread)
19390 switch (
Previous.getResultKind()) {
19397 PrevDecl =
Previous.getRepresentativeDecl();
19411 PrevDecl =
nullptr;
19415 PrevDecl =
nullptr;
19422 TSSL, AS, PrevDecl, &D);
19425 Record->setInvalidDecl();
19444 bool Mutable,
Expr *BitWidth,
19450 bool InvalidDecl =
false;
19455 if (T.isNull() || T->containsErrors()) {
19456 InvalidDecl =
true;
19462 bool isIncomplete =
19466 diag::err_field_incomplete_or_sizeless);
19467 if (isIncomplete) {
19469 Record->setInvalidDecl();
19470 InvalidDecl =
true;
19475 Record->setInvalidDecl();
19476 InvalidDecl =
true;
19482 if (T.hasAddressSpace() || T->isDependentAddressSpaceType() ||
19483 T->getBaseElementTypeUnsafe()->isDependentAddressSpaceType()) {
19484 Diag(Loc, diag::err_field_with_address_space);
19485 Record->setInvalidDecl();
19486 InvalidDecl =
true;
19492 if (T->isEventT() || T->isImageType() || T->isSamplerT() ||
19493 T->isBlockPointerType()) {
19494 Diag(Loc, diag::err_opencl_type_struct_or_union_field) << T;
19495 Record->setInvalidDecl();
19496 InvalidDecl =
true;
19501 "__cl_clang_bitfields",
LangOpts)) {
19502 Diag(Loc, diag::err_opencl_bitfields);
19503 InvalidDecl =
true;
19509 T.hasQualifiers()) {
19510 InvalidDecl =
true;
19511 Diag(Loc, diag::err_anon_bitfield_qualifiers);
19516 if (!InvalidDecl && T->isVariablyModifiedType()) {
19518 TInfo, T, Loc, diag::err_typecheck_field_variable_size))
19519 InvalidDecl =
true;
19524 diag::err_abstract_type_in_decl,
19526 InvalidDecl =
true;
19529 BitWidth =
nullptr;
19535 InvalidDecl =
true;
19536 BitWidth =
nullptr;
19541 if (!InvalidDecl && Mutable) {
19542 unsigned DiagID = 0;
19543 if (T->isReferenceType())
19544 DiagID =
getLangOpts().MSVCCompat ? diag::ext_mutable_reference
19545 : diag::err_mutable_reference;
19546 else if (T.isConstQualified())
19547 DiagID = diag::err_mutable_const;
19553 Diag(ErrLoc, DiagID);
19554 if (DiagID != diag::ext_mutable_reference) {
19556 InvalidDecl =
true;
19568 BitWidth, Mutable, InitStyle);
19577 Diag(Loc, diag::err_duplicate_member) << II;
19583 if (
Record->isUnion()) {
19585 RD && (RD->isBeingDefined() || RD->isCompleteDefinition())) {
19600 const bool HaveMSExt =
19605 HaveMSExt ? diag::ext_union_member_of_reference_type
19606 : diag::err_union_member_of_reference_type)
19626 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(NewFD))
19629 if (T.isObjCGCWeak())
19630 Diag(Loc, diag::warn_attribute_weak_on_field);
19633 if (
Context.getTargetInfo().getTriple().isPPC64() &&
19650 RDecl && (RDecl->isBeingDefined() || RDecl->isCompleteDefinition())) {
19661 if (RDecl->hasNonTrivialCopyConstructor())
19663 else if (!RDecl->hasTrivialDefaultConstructor())
19665 else if (RDecl->hasNonTrivialCopyAssignment())
19667 else if (RDecl->hasNonTrivialDestructor())
19672 RDecl->hasObjectMember()) {
19680 if (!FD->
hasAttr<UnavailableAttr>())
19681 FD->
addAttr(UnavailableAttr::CreateImplicit(
19682 Context,
"", UnavailableAttr::IR_ARCFieldWithOwnership, Loc));
19689 ? diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member
19690 : diag::err_illegal_union_or_anon_struct_member)
19702 if (
LangOpts.ObjCRuntime.isFragile() || AllIvarDecls.empty())
19705 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
19713 if (!CD->IsClassExtension())
19730 AllIvarDecls.push_back(Ivar);
19742 if (!
Record->hasUserDeclaredDestructor()) {
19750 if (
auto *DD = dyn_cast<CXXDestructorDecl>(
Decl)) {
19751 if (DD->isInvalidDecl())
19755 assert(DD->isIneligibleOrNotSelected() &&
"Selecting a destructor but a destructor was already selected.");
19769 Record->addedSelectedDestructor(dyn_cast<CXXDestructorDecl>(Best->Function));
19773 Msg = diag::err_ambiguous_destructor;
19778 Msg = diag::err_no_viable_destructor;
19789 Record->setInvalidDecl();
19796 Record->addedSelectedDestructor(dyn_cast<CXXDestructorDecl>(OCS.
begin()->Function));
19840 if (!Method->getTrailingRequiresClause())
19841 SatisfactionStatus.push_back(
true);
19845 SatisfactionStatus.push_back(
false);
19847 SatisfactionStatus.push_back(Satisfaction.
IsSatisfied);
19851 for (
size_t i = 0; i < Methods.size(); i++) {
19852 if (!SatisfactionStatus[i])
19860 bool AnotherMethodIsMoreConstrained =
false;
19861 for (
size_t j = 0; j < Methods.size(); j++) {
19862 if (i == j || !SatisfactionStatus[j])
19876 AnotherMethodIsMoreConstrained =
true;
19880 AnotherMethodIsMoreConstrained)) {
19883 AnotherMethodIsMoreConstrained =
true;
19885 if (AnotherMethodIsMoreConstrained)
19890 if (!AnotherMethodIsMoreConstrained) {
19891 Method->setIneligibleOrNotSelected(
false);
19892 Record->addedEligibleSpecialMemberFunction(Method,
19893 1 << llvm::to_underlying(CSM));
19907 auto *MD = dyn_cast<CXXMethodDecl>(
Decl);
19909 auto *FTD = dyn_cast<FunctionTemplateDecl>(
Decl);
19911 MD = dyn_cast<CXXMethodDecl>(FTD->getTemplatedDecl());
19915 if (
auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
19916 if (CD->isInvalidDecl())
19918 if (CD->isDefaultConstructor())
19919 DefaultConstructors.push_back(MD);
19920 else if (CD->isCopyConstructor())
19921 CopyConstructors.push_back(MD);
19922 else if (CD->isMoveConstructor())
19923 MoveConstructors.push_back(MD);
19925 CopyAssignmentOperators.push_back(MD);
19927 MoveAssignmentOperators.push_back(MD);
19945 auto IsFunctionPointerOrForwardDecl = [&](
const Decl *D) {
19946 const FieldDecl *FD = dyn_cast<FieldDecl>(D);
19959 if (
const auto *TD = dyn_cast<TagDecl>(D))
19960 return !TD->isCompleteDefinition();
19975 return llvm::all_of(
Record->decls(), IsFunctionPointerOrForwardDecl);
19982 assert(EnclosingDecl &&
"missing record or interface decl");
19991 case Decl::ObjCCategory:
19994 case Decl::ObjCImplementation:
20002 CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(EnclosingDecl);
20006 unsigned NumNamedMembers = 0;
20008 for (
const auto *I :
Record->decls()) {
20009 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
20010 if (IFD->getDeclName())
20017 const FieldDecl *PreviousField =
nullptr;
20027 RecFields.push_back(FD);
20047 bool IsLastField = (i + 1 == Fields.end());
20062 unsigned DiagID = 0;
20063 if (!
Record->isUnion() && !IsLastField) {
20066 Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
20070 }
else if (
Record->isUnion())
20072 ? diag::ext_flexible_array_union_ms
20073 : diag::ext_flexible_array_union_gnu;
20074 else if (NumNamedMembers < 1)
20076 ? diag::ext_flexible_array_empty_aggregate_ms
20077 : diag::ext_flexible_array_empty_aggregate_gnu;
20087 if (CXXRecord && CXXRecord->getNumVBases() != 0)
20101 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
20108 Record->setHasFlexibleArrayMember(
true);
20117 diag::err_incomplete_type)
20120 diag::err_field_incomplete_or_sizeless))) {
20126 if (
Record && RD->hasFlexibleArrayMember()) {
20129 Record->setHasFlexibleArrayMember(
true);
20130 if (!
Record->isUnion()) {
20147 diag::err_abstract_type_in_decl,
20152 if (
Record && RD->hasObjectMember())
20153 Record->setHasObjectMember(
true);
20154 if (
Record && RD->hasVolatileMember())
20155 Record->setHasVolatileMember(
true);
20174 FD->
addAttr(UnavailableAttr::CreateImplicit(
20175 Context,
"", UnavailableAttr::IR_ARCFieldWithOwnership,
20179 !
Record->hasObjectMember()) {
20182 Record->setHasObjectMember(
true);
20185 if (
const auto *RD = BaseType->getAsRecordDecl();
20186 RD && RD->hasObjectMember())
20187 Record->setHasObjectMember(
true);
20188 else if (BaseType->isObjCObjectPointerType() ||
20189 BaseType.isObjCGCStrong())
20190 Record->setHasObjectMember(
true);
20195 !shouldIgnoreForRecordTriviality(FD)) {
20198 Record->setNonTrivialToPrimitiveDefaultInitialize(
true);
20201 Record->setHasNonTrivialToPrimitiveDefaultInitializeCUnion(
true);
20205 Record->setNonTrivialToPrimitiveCopy(
true);
20207 Record->setHasNonTrivialToPrimitiveCopyCUnion(
true);
20209 if (FD->
hasAttr<ExplicitInitAttr>())
20210 Record->setHasUninitializedExplicitInitFields(
true);
20212 Record->setNonTrivialToPrimitiveDestroy(
true);
20213 Record->setParamDestroyedInCallee(
true);
20215 Record->setHasNonTrivialToPrimitiveDestructCUnion(
true);
20219 if (RD->getArgPassingRestrictions() ==
20221 Record->setArgPassingRestrictions(
20224 Record->setArgPassingRestrictions(
20228 Record->setArgPassingRestrictions(
20230 Record->setNonTrivialToPrimitiveCopy(
true);
20235 Record->setHasVolatileMember(
true);
20236 bool ReportMSBitfieldStoragePacking =
20237 Record && PreviousField &&
20238 !
Diags.isIgnored(diag::warn_ms_bitfield_mismatched_storage_packing,
20240 auto IsNonDependentBitField = [](
const FieldDecl *FD) {
20244 if (ReportMSBitfieldStoragePacking && IsNonDependentBitField(FD) &&
20245 IsNonDependentBitField(PreviousField)) {
20249 if (FDStorageSize != PreviousFieldStorageSize) {
20251 diag::warn_ms_bitfield_mismatched_storage_packing)
20255 diag::note_ms_bitfield_mismatched_storage_size_previous)
20256 << PreviousField << PreviousField->
getType();
20266 bool Completed =
false;
20271 Record->setInvalidDecl();
20275 if (!CXXRecord->isInvalidDecl()) {
20278 I = CXXRecord->conversion_begin(),
20279 E = CXXRecord->conversion_end(); I != E; ++I)
20280 I.setAccess((*I)->getAccess());
20286 if (!CXXRecord->isDependentType()) {
20287 if (!CXXRecord->isInvalidDecl()) {
20291 if (CXXRecord->getNumVBases()) {
20293 CXXRecord->getFinalOverriders(FinalOverriders);
20295 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
20296 MEnd = FinalOverriders.end();
20299 SOEnd = M->second.end();
20300 SO != SOEnd; ++SO) {
20301 assert(SO->second.size() > 0 &&
20302 "Virtual function without overriding functions?");
20303 if (SO->second.size() == 1)
20310 Diag(
Record->getLocation(), diag::err_multiple_final_overriders)
20312 Diag(M->first->getLocation(),
20313 diag::note_overridden_virtual_function);
20315 OM = SO->second.begin(),
20316 OMEnd = SO->second.end();
20318 Diag(OM->Method->getLocation(), diag::note_final_overrider)
20319 << (
const NamedDecl *)M->first << OM->Method->getParent();
20321 Record->setInvalidDecl();
20324 CXXRecord->completeDefinition(&FinalOverriders);
20334 Record->completeDefinition();
20343 (
Record->hasAttr<RandomizeLayoutAttr>() ||
20344 (!
Record->hasAttr<NoRandomizeLayoutAttr>() &&
20345 EntirelyFunctionPointers(
Record)))) {
20349 Record->reorderDecls(NewDeclOrdering);
20354 auto *Dtor = CXXRecord->getDestructor();
20355 if (Dtor && Dtor->isImplicit() &&
20357 CXXRecord->setImplicitDestructorIsDeleted();
20362 if (
Record->hasAttrs()) {
20365 if (
const MSInheritanceAttr *IA =
Record->getAttr<MSInheritanceAttr>())
20367 IA->getRange(), IA->getBestCase(),
20368 IA->getInheritanceModel());
20374 bool CheckForZeroSize;
20376 CheckForZeroSize =
true;
20381 CXXRecord->getLexicalDeclContext()->isExternCContext() &&
20383 CXXRecord->isCLike();
20385 if (CheckForZeroSize) {
20386 bool ZeroSize =
true;
20387 bool IsEmpty =
true;
20388 unsigned NonBitFields = 0;
20390 E =
Record->field_end();
20391 (NonBitFields == 0 || ZeroSize) && I != E; ++I) {
20393 if (I->isUnnamedBitField()) {
20394 if (!I->isZeroLengthBitField())
20398 QualType FieldType = I->getType();
20400 !
Context.getTypeSizeInChars(FieldType).isZero())
20410 diag::warn_zero_size_struct_union_in_extern_c :
20411 diag::warn_zero_size_struct_union_compat)
20412 << IsEmpty <<
Record->isUnion() << (NonBitFields > 1);
20419 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union
20420 : diag::ext_no_named_members_in_struct_union)
20428 ID->setEndOfDefinitionLoc(RBrac);
20430 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
20432 ID->addDecl(ClsFields[i]);
20436 if (ID->getSuperClass())
20439 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
20440 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
20441 for (
unsigned I = 0, N = RecFields.size(); I != N; ++I)
20447 IMPDecl->setIvarLBraceLoc(LBrac);
20448 IMPDecl->setIvarRBraceLoc(RBrac);
20450 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
20458 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
20462 Diag(ClsFields[i]->getLocation(),
20463 diag::err_duplicate_ivar_declaration);
20464 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
20470 Diag(ClsFields[i]->getLocation(),
20471 diag::err_duplicate_ivar_declaration);
20472 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
20478 CDecl->addDecl(ClsFields[i]);
20480 CDecl->setIvarLBraceLoc(LBrac);
20481 CDecl->setIvarRBraceLoc(RBrac);
20493 assert((T->isIntegralType(Context) ||
20494 T->isEnumeralType()) &&
"Integral type required!");
20495 const unsigned NumTypes = 4;
20496 QualType SignedIntegralTypes[NumTypes] = {
20497 Context.ShortTy, Context.IntTy, Context.LongTy, Context.LongLongTy
20499 QualType UnsignedIntegralTypes[NumTypes] = {
20500 Context.UnsignedShortTy, Context.UnsignedIntTy, Context.UnsignedLongTy,
20501 Context.UnsignedLongLongTy
20508 unsigned BitWidth = Context.getIntWidth(T);
20510 : UnsignedIntegralTypes;
20511 for (
unsigned I = 0; I != NumTypes; ++I)
20512 if (Context.getTypeSize(Types[I]) > BitWidth)
20523 unsigned IntWidth =
Context.getTargetInfo().getIntWidth();
20524 llvm::APSInt EnumVal(IntWidth);
20544 EltTy =
Enum->getIntegerType();
20550 Val = Converted.
get();
20557 if (
Enum->isComplete()) {
20558 EltTy =
Enum->getIntegerType();
20564 if (!
Context.isRepresentableIntegerValue(EnumVal, EltTy)) {
20567 .isWindowsMSVCEnvironment()) {
20568 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
20570 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
20593 if (!
Context.isRepresentableIntegerValue(EnumVal,
Context.IntTy)) {
20595 ? diag::warn_c17_compat_enum_value_not_int
20596 : diag::ext_c23_enum_value_not_int)
20598 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
20610 if (
Enum->isDependentType())
20612 else if (!LastEnumConst) {
20621 if (
Enum->isFixed()) {
20622 EltTy =
Enum->getIntegerType();
20631 EltTy = LastEnumConst->
getType();
20634 if (EnumVal < LastEnumConst->getInitVal()) {
20646 if (T.isNull() ||
Enum->isFixed()) {
20650 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
20652 if (
Enum->isFixed())
20654 Diag(IdLoc, diag::err_enumerator_wrapped)
20658 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
20669 EnumVal = EnumVal.zextOrTrunc(
Context.getIntWidth(EltTy));
20681 ? diag::warn_c17_compat_enum_value_not_int
20682 : diag::ext_c23_enum_value_not_int)
20683 << 1 <<
toString(EnumVal, 10) << 1;
20685 !
Context.isRepresentableIntegerValue(EnumVal, EltTy)) {
20688 : diag::ext_c23_enum_value_not_int)
20689 << 1 <<
toString(EnumVal, 10) << 1;
20697 EnumVal = EnumVal.extOrTrunc(
Context.getIntWidth(EltTy));
20716 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
20724 Skip.Previous = Hidden;
20738 cast_or_null<EnumConstantDecl>(lastEnumConst);
20755 PrevDecl =
nullptr;
20782 "Received TagDecl when not in C++!");
20785 Diag(IdLoc, diag::err_redefinition_of_enumerator) << Id;
20787 Diag(IdLoc, diag::err_redefinition) << Id;
20820 if (!BO->isAdditiveOp())
20828 InitExpr = BO->getLHS();
20832 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InitExpr);
20852 if (!
Enum->getIdentifier())
20856 if (
Enum->getNumPositiveBits() > 63 ||
Enum->getNumNegativeBits() > 64)
20865 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
20868 typedef std::unordered_map<int64_t, DeclOrVector> ValueToVectorMap;
20872 llvm::APSInt Val = D->getInitVal();
20873 return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
20876 DuplicatesVector DupVector;
20877 ValueToVectorMap EnumMap;
20881 for (
auto *Element : Elements) {
20895 EnumMap.insert({EnumConstantToKey(ECD), ECD});
20898 if (EnumMap.size() == 0)
20902 for (
auto *Element : Elements) {
20908 auto Iter = EnumMap.find(EnumConstantToKey(ECD));
20909 if (Iter == EnumMap.end())
20912 DeclOrVector& Entry = Iter->second;
20919 auto Vec = std::make_unique<ECDVector>();
20921 Vec->push_back(ECD);
20928 DupVector.emplace_back(std::move(Vec));
20934 if (*Vec->begin() == ECD)
20937 Vec->push_back(ECD);
20941 for (
const auto &Vec : DupVector) {
20942 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
20945 auto *FirstECD = Vec->front();
20946 S.
Diag(FirstECD->getLocation(), diag::warn_duplicate_enum_values)
20947 << FirstECD <<
toString(FirstECD->getInitVal(), 10)
20948 << FirstECD->getSourceRange();
20952 for (
auto *ECD : llvm::drop_begin(*Vec))
20953 S.
Diag(ECD->getLocation(), diag::note_duplicate_element)
20954 << ECD <<
toString(ECD->getInitVal(), 10)
20955 << ECD->getSourceRange();
20960 bool AllowMask)
const {
20961 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
20965 llvm::APInt &FlagBits = R.first->second;
20969 const auto &EVal = E->getInitVal();
20971 if (EVal.isPowerOf2())
20972 FlagBits = FlagBits.zext(EVal.getBitWidth()) | EVal;
20984 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
20985 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
20992 bool HasBitwiseOp =
false;
20997 for (
const auto *ECD :
Enum->enumerators()) {
20998 const Expr *InitExpr = ECD->getInitExpr();
21004 if (
const auto *BinOp = dyn_cast<BinaryOperator>(E)) {
21008 if (BinOp->isBitwiseOp() || BinOp->isShiftOp()) {
21009 HasBitwiseOp =
true;
21010 }
else if (Op == BO_LT || Op == BO_GT) {
21013 if (
const auto *IntLiteral = dyn_cast<IntegerLiteral>(LHS)) {
21015 if (IntLiteral->getValue() == 1)
21016 SuspiciousCompares.push_back(BinOp);
21024 if (HasBitwiseOp) {
21025 for (
const auto *BinOp : SuspiciousCompares) {
21026 StringRef SuggestedOp = (BinOp->getOpcode() == BO_LT)
21031 Sema.
Diag(OperatorLoc, diag::warn_comparison_in_enum_initializer)
21032 << BinOp->getOpcodeStr() << SuggestedOp;
21034 Sema.
Diag(OperatorLoc, diag::note_enum_compare_typo_suggest)
21050 if (
Enum->isDependentType()) {
21051 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
21053 cast_or_null<EnumConstantDecl>(Elements[i]);
21054 if (!ECD)
continue;
21065 unsigned NumNegativeBits = 0;
21066 unsigned NumPositiveBits = 0;
21067 bool MembersRepresentableByInt =
21068 Context.computeEnumBits(Elements, NumNegativeBits, NumPositiveBits);
21072 unsigned BestWidth;
21093 if (
Enum->isComplete()) {
21094 BestType =
Enum->getIntegerType();
21095 if (
Context.isPromotableIntegerType(BestType))
21096 BestPromotionType =
Context.getPromotedIntegerType(BestType);
21098 BestPromotionType = BestType;
21100 BestWidth =
Context.getIntWidth(BestType);
21102 bool EnumTooLarge =
Context.computeBestEnumTypes(
21103 Packed, NumNegativeBits, NumPositiveBits, BestType, BestPromotionType);
21104 BestWidth =
Context.getIntWidth(BestType);
21106 Diag(
Enum->getLocation(), diag::ext_enum_too_large);
21111 for (
auto *D : Elements) {
21112 auto *ECD = cast_or_null<EnumConstantDecl>(D);
21113 if (!ECD)
continue;
21122 llvm::APSInt InitVal = ECD->getInitVal();
21130 MembersRepresentableByInt) {
21138 NewWidth =
Context.getTargetInfo().getIntWidth();
21140 }
else if (ECD->getType() == BestType) {
21148 ECD->setType(EnumType);
21152 NewWidth = BestWidth;
21157 InitVal = InitVal.extOrTrunc(NewWidth);
21158 InitVal.setIsSigned(NewSign);
21159 ECD->setInitVal(
Context, InitVal);
21162 if (ECD->getInitExpr() &&
21163 !
Context.hasSameType(NewTy, ECD->getInitExpr()->getType()))
21165 Context, NewTy, CK_IntegralCast, ECD->getInitExpr(),
21174 ECD->setType(EnumType);
21176 ECD->setType(NewTy);
21179 Enum->completeDefinition(BestType, BestPromotionType,
21180 NumPositiveBits, NumNegativeBits);
21185 if (
Enum->isClosedFlag()) {
21186 for (
Decl *D : Elements) {
21188 if (!ECD)
continue;
21191 if (InitVal != 0 && !InitVal.isPowerOf2() &&
21199 if (
Enum->hasAttrs())
21238 AsmLabelAttr *
Attr =
21239 AsmLabelAttr::CreateImplicit(
Context, AliasName->
getName(), Info);
21249 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
21262 PrevDecl->
addAttr(WeakAttr::CreateImplicit(
Context, PragmaLoc));
21278 if (!PrevDecl->
hasAttr<AliasAttr>())
21279 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
21288 assert(FD &&
"Expected non-null FunctionDecl");
21295 FD->
hasAttr<SYCLKernelEntryPointAttr>() ||
21296 FD->
hasAttr<SYCLExternalAttr>()))
21300 auto IsEmittedForExternalSymbol = [
this, FD]() {
21312 if (
LangOpts.OpenMPIsTargetDevice) {
21315 std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
21322 if (*DevTy == OMPDeclareTargetDeclAttr::DT_Host)
21326 if (
OpenMP().isInOpenMPDeclareTargetContext() || DevTy)
21327 if (IsEmittedForExternalSymbol())
21333 }
else if (
LangOpts.OpenMP > 45) {
21337 std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
21340 if (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost)
21359 if (IsEmittedForExternalSymbol())
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.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
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.
Defines helper utilities for supporting the HLSL runtime environment.
static const Decl * getCanonicalDecl(const Decl *D)
Result
Implement __builtin_bit_cast and related operations.
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Architecture Architecture
llvm::MachO::Record Record
static bool isExternC(const NamedDecl *ND)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
@ NotForRedeclaration
The lookup is a reference to this name that is not for the purpose of redeclaring the name.
@ ForExternalRedeclaration
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
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 AMDGPU.
This file declares semantic analysis functions specific to ARM.
static bool hasAttr(const Decl *D, bool IgnoreImplicitAttr)
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 SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI, const ValueDecl *VD)
Return the location of the capture if the given lambda captures the given variable VD,...
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 CheckForComparisonInEnumInitializer(SemaBase &Sema, const EnumDecl *Enum)
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 checkModularFormatAttr(Sema &S, NamedDecl &ND)
static void checkSelectAnyAttr(Sema &S, NamedDecl &ND)
static bool isImplicitInstantiation(NamedDecl *D)
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 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 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.
@ 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>
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 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
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
const LangOptions & getLangOpts() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
const VariableArrayType * getAsVariableArrayType(QualType T) const
const TargetInfo & getTargetInfo() const
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
CanQualType getCanonicalTagType(const TagDecl *TD) const
@ GE_Missing_type
Missing a type.
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
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.
void setAttr(const Attr *A)
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condition evaluates to false; ...
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value.
A builtin binary operation expression such as "x + y" or "x <= y".
StringRef getOpcodeStr() const
static bool isCompoundAssignmentOp(Opcode Opc)
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...
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name.
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
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
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.
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.
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 hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
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
UnresolvedSetIterator conversion_iterator
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).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool isCallToStdMove() const
CastKind getCastKind() const
static CharSourceRange getCharRange(SourceRange R)
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a class template.
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...
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)
DeclListNode::iterator iterator
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.
DeclContextLookupResult lookup_result
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context,...
Decl * getNonClosureAncestor()
Find the nearest non-closure ancestor of this context, i.e.
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.
ThreadStorageClassSpecifier TSCS
void ClearStorageClassSpecs()
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
SourceRange getExplicitSpecRange() 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
void ClearConstexprSpec()
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
ExplicitSpecifier getExplicitSpecifier() const
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)
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
bool isAnyOperatorNewOrDelete() const
bool isAnyOperatorDelete() 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
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
bool isEmpty() const
Evaluates true when this declaration name is empty.
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.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
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.
Expr * getAsmLabel() const
FunctionDefinitionKind getFunctionDefinitionKind() const
const ParsedAttributes & getAttributes() const
void setRedeclaration(bool Val)
SourceLocation getIdentifierLoc() const
void SetIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
SourceLocation getEndLoc() const LLVM_READONLY
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
void takeAttributesAppending(ParsedAttributes &attrs)
takeAttributesAppending - Takes attributes from the given ParsedAttributes set and add them to this d...
void setInvalidType(bool Val=true)
TemplateParameterList * getInventedTemplateParameterList() const
The template parameter list generated from the explicit template parameters along with any invented t...
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isRedeclaration() const
const ParsedAttributesView & getDeclarationAttributes() const
const DecompositionDeclarator & getDecompositionDeclarator() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
bool isFunctionDefinition() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool hasInitializer() const
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
bool isInvalidType() const
bool isExplicitObjectMemberFunction()
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
bool isStaticMember()
Returns true if this declares a static member.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
const IdentifierInfo * getIdentifier() const
A decomposition declaration.
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, SourceLocation RSquareLoc, 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)
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.
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.
void setEnumKeyRange(SourceRange Range)
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
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.
bool isConstantInitializer(ASTContext &Ctx, bool ForRef=false, const Expr **Culprit=nullptr) const
Returns true if this expression can be emitted to IR as a constant, and thus can be used as a constan...
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()
bool isFPConstrained() const
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?
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:
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 doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
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 isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
bool isDeletedAsWritten() const
redecl_iterator redecls_end() 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.
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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.
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
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.
SmallVector< Conflict > Conflicts
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
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 isExplicitSpecialization() const
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.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
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 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...
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
llvm::iterator_range< capture_init_iterator > capture_inits()
Retrieve the initialization expressions for this lambda's captures.
@ 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...
FPExceptionModeKind getDefaultExceptionMode() const
bool requiresStrictPrototypes() const
Returns true if functions without prototypes or functions with an identifier list (aka K&R C function...
std::string getOpenCLVersionString() const
Return the OpenCL C or C++ for OpenCL language name and version as a string.
bool isCompatibleWithMSVC() const
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
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...
static std::optional< Token > findNextToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts, bool IncludeComments=false)
Finds the token that comes right after the given location.
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)
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.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
UnresolvedSetImpl::iterator iterator
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
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.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
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
Visibility getVisibility() const
Determines the visibility of this entity.
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.
bool declarationReplaces(const NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context,...
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
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const
Determine if the declaration obeys the reserved identifier rules of the given language.
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.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
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)
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
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
static OpaquePtr make(DeclGroupRef P)
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.
MapType::iterator iterator
SmallVectorImpl< UniqueVirtualMethod >::iterator overriding_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)
void setExplicitObjectParameterLoc(SourceLocation Loc)
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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
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.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
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.
field_range fields() const
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
specific_decl_iterator< FieldDecl > field_iterator
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.
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
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.
void setEntity(DeclContext *E)
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
unsigned getDepth() const
Returns the depth of this scope. The translation-unit has scope depth 0.
unsigned getNextFunctionPrototypeIndex()
Return the number of parameters declared in this function prototype, increasing it by one for the nex...
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool isTypeAliasScope() const
Determine whether this scope is a type alias scope.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
void setLookupEntity(DeclContext *E)
unsigned getMSLastManglingNumber() const
DeclContext * getEntity() const
Get the entity corresponding to this scope.
unsigned getMSCurManglingNumber() const
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
unsigned getFunctionPrototypeDepth() const
Returns the number of function prototype scopes in this scope chain.
bool isCompoundStmtScope() const
Determine whether this scope is a compound statement scope.
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred within this scope.
Scope * getTemplateParamParent()
@ 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 DiagnoseUnguardedBuiltinUsage(FunctionDecl *FD)
void CheckSMEFunctionDefAttributes(const FunctionDecl *FD)
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
Emit a compatibility diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a 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)
QualType ActOnTemplateShorthand(TemplateDecl *Template, SourceLocation NameLoc)
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)
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
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)
StmtResult BuildUnresolvedSYCLKernelCallStmt(CompoundStmt *Body, Expr *LaunchIdExpr)
Builds an UnresolvedSYCLKernelCallStmt to wrap 'Body'.
StmtResult BuildSYCLKernelCallStmt(FunctionDecl *FD, CompoundStmt *Body, Expr *LaunchIdExpr)
Builds a SYCLKernelCallStmt to wrap 'Body' and to be used as the body of 'FD'.
void CheckSYCLExternalFunctionDecl(FunctionDecl *FD)
void CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD)
ExprResult BuildSYCLKernelLaunchIdExpr(FunctionDecl *FD, QualType KernelName)
Builds an expression for the lookup of a 'sycl_kernel_launch' template with 'KernelName' as an explic...
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.
void deduceOpenCLAddressSpace(VarDecl *decl)
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...
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.
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)
Preprocessor & getPreprocessor() const
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.
bool CheckVarDeclSizeAddressSpace(const VarDecl *VD, LangAS AS)
Check whether the given variable declaration has a size that fits within the address space it is decl...
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)
PersonalityAttr * mergePersonalityAttr(Decl *D, FunctionDecl *Routine, const AttributeCommonInfo &CI)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
void ActOnCXXForRangeDecl(Decl *D, bool InExpansionStmt)
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...
AvailabilityAttr * mergeAndInferAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, const IdentifierInfo *IIEnvironment, const IdentifierInfo *InferredPlatformII)
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
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)
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
llvm::DenseMap< IdentifierInfo *, PendingPragmaInfo > PendingExportedNames
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.
bool InOverflowBehaviorAssignmentContext
Track if we're currently analyzing overflow behavior types in assignment context.
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.
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.
void mergeVisibilityType(Decl *D, SourceLocation Loc, VisibilityAttr::VisibilityType Type)
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)
void CheckAttributesOnDeducedType(Decl *D)
CheckAttributesOnDeducedType - Calls Sema functions for attributes that requires the type to be deduc...
@ 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()
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
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)
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
SourceLocation CurInitSegLoc
void inferLifetimeBoundAttribute(FunctionDecl *FD)
Add [[clang:lifetimebound]] attr for std:: functions and methods.
ModularFormatAttr * mergeModularFormatAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *ModularImplFn, StringRef ImplName, MutableArrayRef< StringRef > Aspects)
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)
bool BuildCtorClosureDefaultArgs(SourceLocation Loc, CXXConstructorDecl *Ctor, bool IsCopy=false)
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.
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
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.
llvm::MapVector< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
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.
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.