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)
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()) {
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);
1662 bool AllowInlineNamespace)
const {
1666 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(D))
1667 return isDeclInScope(Shadow->getTargetDecl(), Ctx, S, AllowInlineNamespace);
1676 if (ScopeDC->getPrimaryContext() == TargetDC)
1688 bool ConsiderLinkage,
1689 bool AllowInlineNamespace) {
1707 if (
auto *VD = dyn_cast<VarDecl>(D))
1709 if (
auto *FD = dyn_cast<FunctionDecl>(D))
1711 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1725 if (
New->getFriendObjectKind() &&
1766 if (NewIsModuleInterface || OldIsModuleInterface) {
1770 Diag(
New->getLocation(), diag::err_mismatched_owning_module)
1772 << NewIsModuleInterface
1774 << OldIsModuleInterface
1777 New->setInvalidDecl();
1790 if (!
New->getLexicalDeclContext()
1791 ->getNonTransparentContext()
1792 ->isFileContext() ||
1798 bool IsNewExported =
New->isInExportDeclContext();
1802 if (!IsNewExported && !IsOldExported)
1814 New->getOwningModule()->isImplicitGlobalModule())
1817 assert(IsNewExported);
1825 Diag(
New->getLocation(), diag::err_redeclaration_non_exported) <<
New << S;
1843 "New and Old are not the same definition, we should diagnostic it "
1844 "immediately instead of checking it.");
1847 "We shouldn't see unreachable definitions here.");
1895 return OldM == NewM;
1932 return CD->isCopyConstructor();
1939 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1940 if (!RD->hasNameForLinkage())
1961 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1967 FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
1970 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1979 if (FD->doesThisDeclarationHaveABody() &&
1980 Context.DeclMustBeEmitted(FD))
1982 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1989 if (
Context.DeclMustBeEmitted(VD))
1992 if (VD->isStaticDataMember() &&
1995 if (VD->isStaticDataMember() &&
1997 VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
2009 return mightHaveNonExternalLinkage(D);
2016 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
2022 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2037 if (
const auto *DD = dyn_cast<DecompositionDecl>(D)) {
2041 bool IsAllIgnored =
true;
2042 for (
const auto *BD : DD->bindings()) {
2043 if (BD->isReferenced())
2045 IsAllIgnored = IsAllIgnored && (BD->isPlaceholderVar(LangOpts) ||
2046 BD->hasAttr<UnusedAttr>());
2059 if (D->
hasAttr<UnusedAttr>() || D->
hasAttr<ObjCPreciseLifetimeAttr>() ||
2069 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->
getDeclContext()))
2072 WithinFunction || (R->isLocalClass() && !R->isDependentType());
2073 if (!WithinFunction)
2084 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2087 if (
const auto *Cleanups = dyn_cast_if_present<ExprWithCleanups>(
Init))
2088 Init = Cleanups->getSubExpr();
2090 const auto *Ty = VD->getType().getTypePtr();
2095 if (TT->getDecl()->hasAttr<UnusedAttr>())
2101 if (
const auto *MTE = dyn_cast_if_present<MaterializeTemporaryExpr>(
Init);
2102 MTE && MTE->getExtendingDecl()) {
2103 Ty = VD->getType().getNonReferenceType().getTypePtr();
2104 Init = MTE->getSubExpr()->IgnoreImplicitAsWritten();
2109 if (Ty->isIncompleteType() || Ty->isDependentType())
2114 Ty = Ty->getBaseElementTypeUnsafe();
2116 if (
const TagDecl *Tag = Ty->getAsTagDecl()) {
2117 if (Tag->hasAttr<UnusedAttr>())
2120 if (
const auto *RD = dyn_cast<CXXRecordDecl>(Tag)) {
2121 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
2125 const auto *Construct =
2126 dyn_cast<CXXConstructExpr>(
Init->IgnoreImpCasts());
2127 if (Construct && !Construct->isElidable()) {
2129 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
2130 (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
2136 if (
Init->isTypeDependent()) {
2138 if (!Ctor->isTrivial())
2179 for (
auto *TmpD : D->
decls()) {
2180 if (
const auto *
T = dyn_cast<TypedefNameDecl>(TmpD))
2182 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
2196 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
2208 DiagID = diag::warn_unused_exception_param;
2210 DiagID = diag::warn_unused_label;
2212 DiagID = diag::warn_unused_variable;
2231 if (Ty->isReferenceType() || Ty->isDependentType())
2234 if (
const TagDecl *Tag = Ty->getAsTagDecl()) {
2235 if (Tag->hasAttr<UnusedAttr>())
2239 if (
const auto *RD = dyn_cast<CXXRecordDecl>(Tag);
2240 RD && !RD->hasAttr<WarnUnusedAttr>())
2252 if (VD->
hasAttr<BlocksAttr>() && Ty->isObjCObjectPointerType())
2258 if (VD->
hasAttr<ObjCPreciseLifetimeAttr>() && Ty->isObjCObjectPointerType())
2265 assert(iter->getSecond() >= 0 &&
2266 "Found a negative number of references to a VarDecl");
2267 if (
int RefCnt = iter->getSecond(); RefCnt > 0) {
2277 bool UnusedCXXCondDecl = VD->
isCXXCondDecl() && (RefCnt == 1);
2278 if (!UnusedCXXCondDecl)
2284 DiagID = diag::warn_unused_but_set_parameter;
2286 DiagID = diag::warn_unused_but_set_global;
2288 DiagID = diag::warn_unused_but_set_variable;
2298 bool Diagnose =
false;
2302 Diagnose = L->
getStmt() ==
nullptr;
2313 "Scope shouldn't contain decls!");
2320 std::optional<SourceLocation> PreviousDeclLoc;
2325 DeclDiags.push_back(LocAndDiag{Loc, std::nullopt, std::move(PD)});
2330 DeclDiags.push_back(LocAndDiag{Loc, PreviousDeclLoc, std::move(PD)});
2333 for (
auto *TmpD : S->
decls()) {
2334 assert(TmpD &&
"This decl didn't get pushed??");
2342 if (
const auto *RD = dyn_cast<RecordDecl>(D))
2345 if (
auto *VD = dyn_cast<VarDecl>(D);
2346 VD && !VD->isInternalLinkageFileVar()) {
2355 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
2366 auto ShadowI = ShadowingDecls.find(D);
2367 if (ShadowI != ShadowingDecls.end()) {
2368 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
2369 addDiagWithPrev(D->
getLocation(), FD->getLocation(),
2370 PDiag(diag::warn_ctor_parm_shadows_field)
2371 << D << FD << FD->getParent());
2373 ShadowingDecls.erase(ShadowI);
2377 llvm::sort(DeclDiags,
2378 [](
const LocAndDiag &LHS,
const LocAndDiag &RHS) ->
bool {
2383 return LHS.Loc.getRawEncoding() < RHS.Loc.getRawEncoding();
2385 for (
const LocAndDiag &D : DeclDiags) {
2387 if (D.PreviousDeclLoc)
2388 Diag(*D.PreviousDeclLoc, diag::note_previous_declaration);
2412 return "ucontext.h";
2414 llvm_unreachable(
"unhandled error kind");
2425 Parent->
addDecl(CLinkageDecl);
2426 Parent = CLinkageDecl;
2430 if (
Context.BuiltinInfo.isImmediate(ID)) {
2432 "consteval builtins should only be available in C++20 mode");
2441 New->addAttr(BuiltinAttr::CreateImplicit(
Context, ID));
2447 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2450 FT->getParamType(i),
nullptr,
SC_None,
nullptr);
2452 Params.push_back(parm);
2454 New->setParams(Params);
2462 Scope *S,
bool ForRedeclaration,
2469 if (!ForRedeclaration)
2475 Context.BuiltinInfo.allowTypeMismatch(ID))
2481 Diag(Loc, diag::warn_implicit_decl_no_jmp_buf)
2482 <<
Context.BuiltinInfo.getName(ID);
2488 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
2490 <<
Context.BuiltinInfo.getName(ID);
2494 if (!ForRedeclaration &&
2495 (
Context.BuiltinInfo.isPredefinedLibFunction(ID) ||
2496 Context.BuiltinInfo.isHeaderDependentFunction(ID))) {
2497 Diag(Loc,
LangOpts.C99 ? diag::ext_implicit_lib_function_decl_c99
2498 : diag::ext_implicit_lib_function_decl)
2499 <<
Context.BuiltinInfo.getName(ID) << R;
2500 if (
const char *Header =
Context.BuiltinInfo.getHeaderName(ID))
2501 Diag(Loc, diag::note_include_header_or_declare)
2502 << Header <<
Context.BuiltinInfo.getName(ID);
2538 while (Filter.hasNext()) {
2547 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2549 Decl->getUnderlyingType()))
2554 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2555 Decl->getAnonDeclWithTypedefName())
2567 if (
const TypedefNameDecl *OldTypedef = dyn_cast<TypedefNameDecl>(Old))
2568 OldType = OldTypedef->getUnderlyingType();
2570 OldType =
Context.getTypeDeclType(Old);
2576 Diag(
New->getLocation(), diag::err_redefinition_variably_modified_typedef)
2580 New->setInvalidDecl();
2584 if (OldType != NewType &&
2587 !
Context.hasSameType(OldType, NewType)) {
2589 Diag(
New->getLocation(), diag::err_redefinition_different_typedef)
2590 << Kind << NewType << OldType;
2593 New->setInvalidDecl();
2603 if (
New->isInvalidDecl())
return;
2609 switch (TypeID->getLength()) {
2613 if (!TypeID->isStr(
"id"))
2616 if (!
T->isPointerType())
2618 if (!
T->isVoidPointerType()) {
2623 Context.setObjCIdRedefinitionType(
T);
2625 New->setModedTypeSourceInfo(
New->getTypeSourceInfo(),
2630 if (!TypeID->isStr(
"Class"))
2632 Context.setObjCClassRedefinitionType(
New->getUnderlyingType());
2634 New->setModedTypeSourceInfo(
New->getTypeSourceInfo(),
2638 if (!TypeID->isStr(
"SEL"))
2640 Context.setObjCSelRedefinitionType(
New->getUnderlyingType());
2642 New->setModedTypeSourceInfo(
New->getTypeSourceInfo(),
2652 Diag(
New->getLocation(), diag::err_redefinition_different_kind)
2653 <<
New->getDeclName();
2659 return New->setInvalidDecl();
2664 return New->setInvalidDecl();
2666 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2667 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2668 auto *
NewTag =
New->getAnonDeclWithTypedefName();
2671 OldTag->getCanonicalDecl() !=
NewTag->getCanonicalDecl() &&
2675 if (OldTD->isModed())
2676 New->setModedTypeSourceInfo(OldTD->getTypeSourceInfo(),
2677 OldTD->getUnderlyingType());
2679 New->setTypeSourceInfo(OldTD->getTypeSourceInfo());
2692 if (
auto *NewEnum = dyn_cast<EnumDecl>(
NewTag)) {
2693 if (
auto *OldEnum = dyn_cast<EnumDecl>(OldTag)) {
2694 NewEnum->setPreviousDecl(OldEnum);
2696 for (
auto *ECD : NewEnum->enumerators())
2697 ECD->setType(EnumType);
2756 Diag(
New->getLocation(), diag::err_redefinition)
2757 <<
New->getDeclName();
2759 return New->setInvalidDecl();
2774 Context.getSourceManager().isInSystemHeader(
New->getLocation())))
2777 Diag(
New->getLocation(), diag::ext_redefinition_of_typedef)
2778 <<
New->getDeclName();
2785 if (
auto *ED = dyn_cast<EnumDecl>(
New); ED && !ED->isScoped()) {
2787 for (
auto *ECD : ED->enumerators()) {
2798 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2799 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2800 for (
const auto *i : D->
attrs())
2801 if (i->getKind() == A->
getKind()) {
2817 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2818 return VD->isThisDeclarationADefinition();
2819 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2820 return TD->isCompleteDefinition() || TD->isBeingDefined();
2831 AlignedAttr *OldAlignasAttr =
nullptr;
2832 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2833 unsigned OldAlign = 0;
2841 if (I->isAlignmentDependent())
2847 unsigned Align = I->getAlignment(S.
Context);
2848 if (Align > OldAlign) {
2850 OldStrictestAlignAttr = I;
2855 AlignedAttr *NewAlignasAttr =
nullptr;
2856 unsigned NewAlign = 0;
2857 for (
auto *I :
New->specific_attrs<AlignedAttr>()) {
2858 if (I->isAlignmentDependent())
2864 unsigned Align = I->getAlignment(S.
Context);
2865 if (Align > NewAlign)
2869 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2877 if (OldAlign == 0 || NewAlign == 0) {
2890 if (OldAlign != NewAlign) {
2891 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2894 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2907 S.
Diag(
New->getLocation(), diag::err_alignas_missing_on_definition)
2909 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2913 bool AnyAdded =
false;
2916 if (OldAlign > NewAlign) {
2917 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2918 Clone->setInherited(
true);
2919 New->addAttr(Clone);
2924 if (OldAlignasAttr && !NewAlignasAttr &&
2925 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2926 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2927 Clone->setInherited(
true);
2928 New->addAttr(Clone);
2935#define WANT_DECL_MERGE_LOGIC
2936#include "clang/Sema/AttrParsedAttrImpl.inc"
2937#undef WANT_DECL_MERGE_LOGIC
2944 if (!DiagnoseMutualExclusions(S, D,
Attr))
2955 if (
const auto *AA = dyn_cast<AvailabilityAttr>(
Attr)) {
2957 if (AvailabilityAttr *
Inf = AA->getInferredAttrAs())
2958 InferredPlatformII =
Inf->getPlatform();
2960 D, *AA, AA->getPlatform(), AA->
isImplicit(), AA->getIntroduced(),
2961 AA->getDeprecated(), AA->getObsoleted(), AA->getUnavailable(),
2962 AA->getMessage(), AA->getStrict(), AA->getReplacement(), AMK,
2963 AA->getPriority(), AA->getEnvironment(), InferredPlatformII);
2964 }
else if (
const auto *VA = dyn_cast<VisibilityAttr>(
Attr))
2966 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(
Attr))
2968 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(
Attr))
2970 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(
Attr))
2972 else if (
const auto *EA = dyn_cast<ErrorAttr>(
Attr))
2974 else if (
const auto *FA = dyn_cast<FormatAttr>(
Attr))
2975 NewAttr = S.
mergeFormatAttr(D, *FA, FA->getType(), FA->getFormatIdx(),
2977 else if (
const auto *FMA = dyn_cast<FormatMatchesAttr>(
Attr))
2979 D, *FMA, FMA->getType(), FMA->getFormatIdx(), FMA->getFormatString());
2980 else if (
const auto *MFA = dyn_cast<ModularFormatAttr>(
Attr))
2982 D, *MFA, MFA->getModularImplFn(), MFA->getImplName(),
2984 else if (
const auto *SA = dyn_cast<SectionAttr>(
Attr))
2986 else if (
const auto *CSA = dyn_cast<CodeSegAttr>(
Attr))
2988 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(
Attr))
2990 IA->getInheritanceModel());
2991 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(
Attr))
3000 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(
Attr))
3002 else if (
const auto *SNA = dyn_cast<SwiftNameAttr>(
Attr))
3004 else if (
const auto *SAA = dyn_cast<SwiftAttrAttr>(
Attr))
3006 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(
Attr))
3008 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(
Attr))
3019 else if (
const auto *UA = dyn_cast<UuidAttr>(
Attr))
3020 NewAttr = S.
mergeUuidAttr(D, *UA, UA->getGuid(), UA->getGuidDecl());
3021 else if (
const auto *IMA = dyn_cast<WebAssemblyImportModuleAttr>(
Attr))
3023 else if (
const auto *INA = dyn_cast<WebAssemblyImportNameAttr>(
Attr))
3025 else if (
const auto *ENA = dyn_cast<WebAssemblyExportNameAttr>(
Attr))
3027 else if (
const auto *TCBA = dyn_cast<EnforceTCBAttr>(
Attr))
3029 else if (
const auto *TCBLA = dyn_cast<EnforceTCBLeafAttr>(
Attr))
3031 else if (
const auto *BTFA = dyn_cast<BTFDeclTagAttr>(
Attr))
3033 else if (
const auto *NT = dyn_cast<HLSLNumThreadsAttr>(
Attr))
3036 else if (
const auto *WS = dyn_cast<HLSLWaveSizeAttr>(
Attr))
3039 WS->getSpelledArgsCount());
3040 else if (
const auto *CI = dyn_cast<HLSLVkConstantIdAttr>(
Attr))
3042 else if (
const auto *SA = dyn_cast<HLSLShaderAttr>(
Attr))
3047 else if (
const auto *RD = dyn_cast<OpenACCRoutineDeclAttr>(
Attr))
3051 else if (
const auto *PA = dyn_cast<PersonalityAttr>(
Attr))
3066 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
3067 if (
const auto *Def = TD->getDefinition(); Def && !Def->isBeingDefined())
3071 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
3077 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
3079 if (FD->isDefined(Def,
true))
3086 for (
const auto *Attribute : D->
attrs())
3087 if (Attribute->getKind() == Kind)
3095 if (!
New->hasAttrs())
3099 if (!Def || Def ==
New)
3103 for (
unsigned I = 0, E = NewAttributes.size(); I != E;) {
3104 Attr *NewAttribute = NewAttributes[I];
3113 NewAttributes.erase(NewAttributes.begin() + I);
3121 ? diag::err_alias_after_tentative
3122 : diag::err_redefinition;
3124 if (
Diag == diag::err_redefinition)
3134 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
3181 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
3182 if (AA->isAlignas()) {
3193 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
3195 NewAttributes.erase(NewAttributes.begin() + I);
3205 diag::err_loader_uninitialized_redeclaration);
3207 NewAttributes.erase(NewAttributes.begin() + I);
3230 diag::err_sycl_entry_point_after_definition)
3243 diag::warn_attribute_precede_definition);
3245 NewAttributes.erase(NewAttributes.begin() + I);
3251 const ConstInitAttr *CIAttr,
3252 bool AttrBeforeInit) {
3259 std::string SuitableSpelling;
3261 SuitableSpelling = std::string(
3263 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
3265 InsertLoc, {tok::l_square, tok::l_square,
3266 S.PP.getIdentifierInfo(
"clang"), tok::coloncolon,
3267 S.PP.getIdentifierInfo(
"require_constant_initialization"),
3268 tok::r_square, tok::r_square}));
3269 if (SuitableSpelling.empty())
3271 InsertLoc, {tok::kw___attribute, tok::l_paren, tok::r_paren,
3272 S.PP.getIdentifierInfo(
"require_constant_initialization"),
3273 tok::r_paren, tok::r_paren}));
3274 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus20)
3275 SuitableSpelling =
"constinit";
3276 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
3277 SuitableSpelling =
"[[clang::require_constant_initialization]]";
3278 if (SuitableSpelling.empty())
3279 SuitableSpelling =
"__attribute__((require_constant_initialization))";
3280 SuitableSpelling +=
" ";
3282 if (AttrBeforeInit) {
3285 assert(CIAttr->isConstinit() &&
"should not diagnose this for attribute");
3288 S.
Diag(CIAttr->getLocation(), diag::note_constinit_specified_here);
3292 S.
Diag(CIAttr->getLocation(),
3293 CIAttr->isConstinit() ? diag::err_constinit_added_too_late
3294 : diag::warn_require_const_init_added_too_late)
3297 << CIAttr->isConstinit()
3305 UsedAttr *NewAttr = OldAttr->clone(
Context);
3306 NewAttr->setInherited(
true);
3307 New->addAttr(NewAttr);
3310 RetainAttr *NewAttr = OldAttr->clone(
Context);
3311 NewAttr->setInherited(
true);
3312 New->addAttr(NewAttr);
3321 const auto *OldConstInit = Old->
getAttr<ConstInitAttr>();
3322 const auto *NewConstInit =
New->getAttr<ConstInitAttr>();
3323 if (
bool(OldConstInit) !=
bool(NewConstInit)) {
3331 (NewVD->hasInit() || NewVD->isThisDeclarationADefinition()))
3334 if (InitDecl == NewVD) {
3338 if (OldConstInit && OldConstInit->isConstinit())
3341 }
else if (NewConstInit) {
3345 if (InitDecl && InitDecl != NewVD) {
3348 NewVD->dropAttr<ConstInitAttr>();
3356 if (AsmLabelAttr *NewA =
New->getAttr<AsmLabelAttr>()) {
3357 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
3358 if (!OldA->isEquivalent(NewA)) {
3360 Diag(
New->getLocation(), diag::err_different_asm_label);
3361 Diag(OldA->getLocation(), diag::note_previous_declaration);
3363 }
else if (Old->
isUsed()) {
3366 Diag(
New->getLocation(), diag::err_late_asm_label_name)
3372 if (
const auto *NewAbiTagAttr =
New->getAttr<AbiTagAttr>()) {
3373 if (
const auto *OldAbiTagAttr = Old->
getAttr<AbiTagAttr>()) {
3374 for (
const auto &
NewTag : NewAbiTagAttr->tags()) {
3375 if (!llvm::is_contained(OldAbiTagAttr->tags(),
NewTag)) {
3376 Diag(NewAbiTagAttr->getLocation(),
3377 diag::err_new_abi_tag_on_redeclaration)
3379 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
3383 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
3389 if (
New->hasAttr<SectionAttr>() && !Old->
hasAttr<SectionAttr>()) {
3390 if (
auto *VD = dyn_cast<VarDecl>(
New)) {
3392 Diag(
New->getLocation(), diag::warn_attribute_section_on_redeclaration);
3399 const auto *NewCSA =
New->getAttr<CodeSegAttr>();
3400 if (NewCSA && !Old->
hasAttr<CodeSegAttr>() &&
3402 Diag(
New->getLocation(), diag::warn_mismatched_section)
3410 bool foundAny =
New->hasAttrs();
3443 if (
auto *FD = dyn_cast<FunctionDecl>(
New);
3456 if (!foundAny)
New->dropAttrs();
3461 checkAttrIsTypeDependent(D, A);
3472 newAttr->setInherited(
true);
3494 foundAny |= std::forward<F>(propagator)(To, From) != 0;
3520 auto NoSizeInfo = [&Ctx](
QualType Ty) {
3521 if (Ty->isIncompleteArrayType() || Ty->isPointerType())
3529 if (NoSizeInfo(Old) && NoSizeInfo(
New))
3561 if (*Oldnullability != *Newnullability) {
3562 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
3579 const auto *OldParamDT = dyn_cast<DecayedType>(OldParam->
getType());
3580 const auto *NewParamDT = dyn_cast<DecayedType>(NewParam->
getType());
3581 if (OldParamDT && NewParamDT &&
3582 OldParamDT->getPointeeType() == NewParamDT->getPointeeType()) {
3583 QualType OldParamOT = OldParamDT->getOriginalType();
3584 QualType NewParamOT = NewParamDT->getOriginalType();
3587 << NewParam << NewParamOT;
3598struct GNUCompatibleParamWarning {
3599 ParmVarDecl *OldParm;
3600 ParmVarDecl *NewParm;
3601 QualType PromotedType;
3608template <
typename T>
3609static std::pair<diag::kind, SourceLocation>
3613 if (Old->isThisDeclarationADefinition())
3614 PrevDiag = diag::note_previous_definition;
3615 else if (Old->isImplicit()) {
3616 PrevDiag = diag::note_previous_implicit_declaration;
3617 if (
const auto *FD = dyn_cast<FunctionDecl>(Old)) {
3618 if (FD->getBuiltinID())
3619 PrevDiag = diag::note_previous_builtin_declaration;
3622 OldLocation =
New->getLocation();
3624 PrevDiag = diag::note_previous_declaration;
3625 return std::make_pair(PrevDiag, OldLocation);
3633 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
3634 !LangOpts.CPlusPlus &&
3640 const AttributedType *AT =
T->getAs<AttributedType>();
3641 while (AT && !AT->isCallingConv())
3642 AT = AT->getModifiedType()->getAs<AttributedType>();
3646template <
typename T>
3660template<
typename T>
static bool isExternC(
T *D) {
return D->isExternC(); }
3667template<
typename ExpectedDecl>
3689 !Old->getDeclContext()->getRedeclContext()->Equals(
3690 New->getDeclContext()->getRedeclContext()) &&
3695 S.
Diag(
New->getLocation(), diag::err_using_decl_conflict_reverse);
3708 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
3709 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
3712 return AttrA && AttrB && AttrA->getType() == AttrB->getType() &&
3713 AttrA->isDynamic() == AttrB->isDynamic();
3739 if (NamedDC->Equals(SemaDC))
3742 assert((NamedDC->InEnclosingNamespaceSetOf(SemaDC) ||
3744 "unexpected context for redeclaration");
3755 if (
auto *FD = dyn_cast<FunctionDecl>(NewD))
3756 FixSemaDC(FD->getDescribedFunctionTemplate());
3757 else if (
auto *VD = dyn_cast<VarDecl>(NewD))
3758 FixSemaDC(VD->getDescribedVarTemplate());
3762 bool MergeTypeWithOld,
bool NewDeclIsDefn) {
3770 Diag(
New->getLocation(), diag::err_using_decl_friend);
3771 Diag(Shadow->getTargetDecl()->getLocation(),
3772 diag::note_using_decl_target);
3773 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl)
3781 New->getDescribedFunctionTemplate()) {
3793 Diag(
New->getLocation(), diag::err_redefinition_different_kind)
3794 <<
New->getDeclName();
3818 std::tie(PrevDiag, OldLocation) =
3828 !
New->getTemplateSpecializationInfo() &&
3831 Diag(
New->getLocation(), diag::ext_static_non_static) <<
New;
3832 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3834 Diag(
New->getLocation(), diag::err_static_non_static)
3836 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3841 if (
const auto *ILA =
New->getAttr<InternalLinkageAttr>())
3842 if (!Old->
hasAttr<InternalLinkageAttr>()) {
3843 Diag(
New->getLocation(), diag::err_attribute_missing_on_first_decl)
3846 New->dropAttr<InternalLinkageAttr>();
3849 if (
auto *EA =
New->getAttr<ErrorAttr>()) {
3850 if (!Old->
hasAttr<ErrorAttr>()) {
3851 Diag(EA->getLocation(), diag::err_attribute_missing_on_first_decl) << EA;
3853 New->dropAttr<ErrorAttr>();
3861 bool OldOvl = Old->
hasAttr<OverloadableAttr>();
3862 if (OldOvl !=
New->hasAttr<OverloadableAttr>() && !Old->
isImplicit()) {
3863 Diag(
New->getLocation(), diag::err_attribute_overloadable_mismatch)
3872 const Decl *DiagOld = Old;
3874 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *D) {
3875 const auto *A = D->getAttr<OverloadableAttr>();
3876 return A && !A->isImplicit();
3885 diag::note_attribute_overloadable_prev_overload)
3889 New->addAttr(OverloadableAttr::CreateImplicit(
Context));
3891 New->dropAttr<OverloadableAttr>();
3898 Diag(
New->getLocation(), diag::err_sme_attr_mismatch)
3900 Diag(OldLocation, diag::note_previous_declaration);
3923 bool RequiresAdjustment =
false;
3925 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC()) {
3931 if (!NewCCExplicit) {
3935 RequiresAdjustment =
true;
3943 Diag(
New->getLocation(), diag::warn_cconv_unsupported)
3947 RequiresAdjustment =
true;
3951 Diag(
New->getLocation(), diag::err_cconv_change)
3954 << (!FirstCCExplicit ?
"" :
3958 Diag(
First->getLocation(), diag::note_previous_declaration);
3966 RequiresAdjustment =
true;
3978 NewQType =
Context.getFunctionType(FPT2->getReturnType(),
3979 FPT2->getParamTypes(), EPI2);
3981 New->setType(NewQType);
3990 Diag(
New->getLocation(), diag::err_regparm_mismatch)
3993 Diag(OldLocation, diag::note_previous_declaration);
3998 RequiresAdjustment =
true;
4004 Diag(
New->getLocation(), diag::err_function_attribute_mismatch)
4005 <<
"'ns_returns_retained'";
4006 Diag(OldLocation, diag::note_previous_declaration);
4011 RequiresAdjustment =
true;
4017 AnyX86NoCallerSavedRegistersAttr *
Attr =
4018 New->getAttr<AnyX86NoCallerSavedRegistersAttr>();
4019 Diag(
New->getLocation(), diag::err_function_attribute_mismatch) <<
Attr;
4020 Diag(OldLocation, diag::note_previous_declaration);
4025 RequiresAdjustment =
true;
4028 if (RequiresAdjustment) {
4032 NewQType =
Context.getCanonicalType(
New->getType());
4037 if (!Old->
isInlined() &&
New->isInlined() && !
New->hasAttr<GNUInlineAttr>() &&
4045 if (
New->hasAttr<GNUInlineAttr>() &&
4054 Diag(
New->getLocation(), diag::err_different_pass_object_size_params)
4055 <<
New->getDeclName();
4056 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4060 QualType OldQTypeForComparison = OldQType;
4061 if (
Context.hasAnyFunctionEffects()) {
4063 const auto NewFX =
New->getFunctionEffects();
4064 if (OldFX != NewFX) {
4066 for (
const auto &Diff : Diffs) {
4067 if (Diff.shouldDiagnoseRedeclaration(*Old, OldFX, *
New, NewFX)) {
4069 diag::warn_mismatched_func_effect_redeclaration)
4070 << Diff.effectName();
4081 if (!MergeErrs.empty())
4088 NewFPT->getParamTypes(), EPI);
4090 New->setType(ModQT);
4091 NewQType =
New->getType();
4096 EPI = OldFPT->getExtProtoInfo();
4098 OldQTypeForComparison =
Context.getFunctionType(
4099 OldFPT->getReturnType(), OldFPT->getParamTypes(), EPI);
4101 if (OldFX.empty()) {
4112 NewQType =
Context.getCanonicalType(
New->getType());
4120 QualType NewDeclaredReturnType =
New->getDeclaredReturnType();
4121 if (!
Context.hasSameType(OldDeclaredReturnType, NewDeclaredReturnType) &&
4123 OldDeclaredReturnType)) {
4128 ResQT =
Context.mergeObjCGCQualifiers(NewQType, OldQType);
4130 if (
New->isCXXClassMember() &&
New->isOutOfLine())
4131 Diag(
New->getLocation(), diag::err_member_def_does_not_match_ret_type)
4132 <<
New <<
New->getReturnTypeSourceRange();
4134 !Old->
hasAttr<OverloadableAttr>() &&
4135 !
New->hasAttr<OverloadableAttr>())
4136 Diag(
New->getLocation(), diag::err_conflicting_types) <<
New;
4138 Diag(
New->getLocation(), diag::err_ovl_diff_return_type)
4139 <<
New->getReturnTypeSourceRange();
4140 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
4150 if (OldReturnType != NewReturnType) {
4154 if (OldAT && OldAT->isDeduced()) {
4155 QualType DT = OldAT->getDeducedType();
4166 const CXXMethodDecl *OldMethod = dyn_cast<CXXMethodDecl>(Old);
4168 if (OldMethod && NewMethod) {
4175 bool IsClassScopeExplicitSpecialization =
4181 !IsClassScopeExplicitSpecialization) {
4186 Diag(
New->getLocation(), diag::err_ovl_static_nonstatic_member);
4187 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4198 NewDiag = diag::err_constructor_redeclared;
4200 NewDiag = diag::err_destructor_redeclared;
4202 NewDiag = diag::err_conv_function_redeclared;
4204 NewDiag = diag::err_member_redeclared;
4206 Diag(
New->getLocation(), NewDiag);
4208 Diag(
New->getLocation(), diag::err_member_redeclared_in_instantiation)
4209 <<
New <<
New->getType();
4211 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4224 diag::err_definition_of_implicitly_declared_member)
4230 diag::err_definition_of_explicitly_defaulted_member)
4253 if (
const auto *NRA =
New->getAttr<CXX11NoReturnAttr>())
4254 if (!Old->
hasAttr<CXX11NoReturnAttr>()) {
4255 Diag(NRA->getLocation(), diag::err_attribute_missing_on_first_decl)
4265 const SYCLExternalAttr *SEA =
New->getAttr<SYCLExternalAttr>();
4266 if (SEA && !Old->
hasAttr<SYCLExternalAttr>()) {
4267 Diag(SEA->getLocation(), diag::warn_sycl_external_missing_on_first_decl)
4282 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
4296 Diag(
New->getLocation(), diag::ext_retained_language_linkage) <<
New;
4297 Diag(OldLocation, PrevDiag);
4299 Diag(
New->getLocation(), diag::err_different_language_linkage) <<
New;
4300 Diag(OldLocation, PrevDiag);
4307 if (
HLSL().CheckCompatibleParameterABI(
New, Old))
4315 if (
Context.hasSameFunctionTypeIgnoringParamABI(OldQTypeForComparison,
4325 if (
Context.hasSameFunctionTypeIgnoringExceptionSpec(OldQTypeForComparison,
4353 if (Old->
hasPrototype() && !
New->hasWrittenPrototype() && NewDeclIsDefn &&
4357 Diag(
New->getLocation(), diag::err_conflicting_types) <<
New;
4375 if (
New->hasWrittenPrototype()) {
4387 bool IsWithoutProtoADef =
false, IsWithProtoADef =
false;
4388 if (WithoutProto ==
New)
4389 IsWithoutProtoADef = NewDeclIsDefn;
4391 IsWithProtoADef = NewDeclIsDefn;
4393 diag::warn_non_prototype_changes_behavior)
4394 << IsWithoutProtoADef << (WithoutProto->
getNumParams() ? 0 : 1)
4395 << (WithoutProto == Old) << IsWithProtoADef;
4405 !IsWithoutProtoADef)
4411 if (
Context.typesAreCompatible(OldQType, NewQType)) {
4416 (OldProto = dyn_cast<FunctionProtoType>(OldFuncType))) {
4419 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
4420 NewQType =
Context.getFunctionType(NewFuncType->getReturnType(),
4421 OldProto->getParamTypes(),
4422 OldProto->getExtProtoInfo());
4423 New->setType(NewQType);
4424 New->setHasInheritedPrototype();
4428 for (
const auto &ParamType : OldProto->param_types()) {
4431 ParamType,
nullptr,
SC_None,
nullptr);
4432 Param->setScopeInfo(0, Params.size());
4433 Param->setImplicit();
4434 Params.push_back(Param);
4437 New->setParams(Params);
4446 if (
Context.hasSameFunctionTypeIgnoringPtrSizes(OldQType, NewQType))
4473 NewProto->getReturnType());
4474 bool LooseCompatible = !MergedReturn.isNull();
4476 LooseCompatible && Idx != End; ++Idx) {
4480 NewProto->getParamType(Idx))) {
4481 ArgTypes.push_back(NewParm->
getType());
4485 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
4486 NewProto->getParamType(Idx) };
4487 Warnings.push_back(Warn);
4488 ArgTypes.push_back(NewParm->
getType());
4490 LooseCompatible =
false;
4493 if (LooseCompatible) {
4494 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
4495 Diag(Warnings[Warn].NewParm->getLocation(),
4496 diag::ext_param_promoted_not_compatible_with_prototype)
4497 << Warnings[Warn].PromotedType
4498 << Warnings[Warn].OldParm->getType();
4499 if (Warnings[Warn].OldParm->getLocation().isValid())
4500 Diag(Warnings[Warn].OldParm->getLocation(),
4501 diag::note_previous_declaration);
4504 if (MergeTypeWithOld)
4505 New->setType(
Context.getFunctionType(MergedReturn, ArgTypes,
4522 if (
Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) {
4523 Diag(
New->getLocation(), diag::warn_redecl_library_builtin) <<
New;
4524 Diag(OldLocation, diag::note_previous_builtin_declaration)
4529 PrevDiag = diag::note_previous_builtin_declaration;
4532 Diag(
New->getLocation(), diag::err_conflicting_types) <<
New->getDeclName();
4533 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4538 Scope *S,
bool MergeTypeWithOld) {
4544 New->setIsPureVirtual();
4553 for (
unsigned i = 0, e =
New->getNumParams(); i != e; ++i) {
4567 if (!Merged.isNull() && MergeTypeWithOld)
4568 New->setType(Merged);
4592 ni != ne && oi != oe; ++ni, ++oi)
4601 S.
Diag(
New->getLocation(),
New->isThisDeclarationADefinition()
4602 ? diag::err_redefinition_different_type
4603 : diag::err_redeclaration_different_type)
4608 std::tie(PrevDiag, OldLocation)
4610 S.
Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4611 New->setInvalidDecl();
4615 bool MergeTypeWithOld) {
4621 if (
New->getType()->isUndeducedType()) {
4643 QualType PrevVDTy = PrevVD->getType();
4647 if (!
Context.hasSameType(
New->getType(), PrevVDTy))
4655 MergedT =
New->getType();
4666 else if (
New->getType()->isObjCObjectPointerType() &&
4668 MergedT =
Context.mergeObjCGCQualifiers(
New->getType(),
4683 if ((
New->getType()->isDependentType() ||
4688 if (!
New->getType()->isDependentType() && MergeTypeWithOld)
4697 if (MergeTypeWithOld)
4698 New->setType(MergedT);
4732 if (
New->isInvalidDecl())
4745 OldTemplate = dyn_cast<VarTemplateDecl>(
Previous.getFoundDecl());
4749 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4751 return New->setInvalidDecl();
4753 Old = dyn_cast<VarDecl>(
Previous.getFoundDecl());
4756 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4758 return New->setInvalidDecl();
4762 Diag(
New->getLocation(), diag::err_redefinition_different_kind)
4763 <<
New->getDeclName();
4765 New->getLocation());
4766 return New->setInvalidDecl();
4778 return New->setInvalidDecl();
4785 Diag(
New->getLocation(), diag::err_duplicate_member)
4786 <<
New->getIdentifier();
4788 New->setInvalidDecl();
4791 if (NewTemplate && OldTemplate)
4798 if (
New->hasAttr<WeakImportAttr>())
4801 Diag(
New->getLocation(), diag::warn_weak_import) <<
New->getDeclName();
4804 New->dropAttr<WeakImportAttr>();
4809 if (
const auto *ILA =
New->getAttr<InternalLinkageAttr>())
4810 if (!Old->
hasAttr<InternalLinkageAttr>()) {
4811 Diag(
New->getLocation(), diag::err_attribute_missing_on_first_decl)
4814 New->dropAttr<InternalLinkageAttr>();
4819 if (MostRecent != Old) {
4822 if (
New->isInvalidDecl())
4827 if (
New->isInvalidDecl())
4832 std::tie(PrevDiag, OldLocation) =
4837 !
New->isStaticDataMember() &&
4840 Diag(
New->getLocation(), diag::ext_static_non_static)
4841 <<
New->getDeclName();
4842 Diag(OldLocation, PrevDiag);
4847 Diag(
New->getLocation(), diag::err_static_non_static)
4848 <<
New->getDeclName()
4850 Diag(OldLocation, PrevDiag);
4851 return New->setInvalidDecl();
4867 New->hasExternalStorage() &&
Previous.isShadowed() &&
4869 Diag(
New->getLocation(), diag::err_internal_extern_mismatch)
4871 Diag(OldLocation, diag::note_previous_declaration);
4872 return New->setInvalidDecl();
4886 else if (
New->getCanonicalDecl()->getStorageClass() !=
SC_Static &&
4887 !
New->isStaticDataMember() &&
4889 Diag(
New->getLocation(), diag::err_non_static_static) <<
New->getDeclName();
4890 Diag(OldLocation, PrevDiag);
4891 return New->setInvalidDecl();
4895 if (
New->hasExternalStorage() &&
4897 Diag(
New->getLocation(), diag::err_extern_non_extern) <<
New->getDeclName();
4898 Diag(OldLocation, PrevDiag);
4899 return New->setInvalidDecl();
4902 !
New->hasExternalStorage()) {
4903 Diag(
New->getLocation(), diag::err_non_extern_extern) <<
New->getDeclName();
4904 Diag(OldLocation, PrevDiag);
4905 return New->setInvalidDecl();
4915 if (!
New->hasExternalStorage() && !
New->isFileVarDecl() &&
4918 !
New->getLexicalDeclContext()->isRecord())) {
4919 Diag(
New->getLocation(), diag::err_redefinition) <<
New->getDeclName();
4920 Diag(OldLocation, PrevDiag);
4921 return New->setInvalidDecl();
4929 Diag(
New->getLocation(), diag::err_inline_decl_follows_def) <<
New;
4930 Diag(Def->getLocation(), diag::note_previous_definition);
4944 Diag(
New->getLocation(), diag::err_thread_non_thread) <<
New->getDeclName();
4945 Diag(OldLocation, PrevDiag);
4946 }
else if (!
New->getTLSKind()) {
4947 Diag(
New->getLocation(), diag::err_non_thread_thread) <<
New->getDeclName();
4948 Diag(OldLocation, PrevDiag);
4954 Diag(
New->getLocation(), diag::err_thread_thread_different_kind)
4956 Diag(OldLocation, PrevDiag);
4966 diag::warn_deprecated_redundant_constexpr_static_def);
4972 New->setInvalidDecl();
4981 Diag(
New->getLocation(), diag::warn_cxx_compat_tentative_definition)
4988 Diag(
New->getLocation(), diag::err_different_language_linkage) <<
New;
4989 Diag(OldLocation, PrevDiag);
4990 New->setInvalidDecl();
4999 New->setPreviousDecl(Old);
5009 New->setImplicitlyInline();
5014 auto FNewDecLoc =
SrcMgr.getDecomposedLoc(
New);
5016 auto *FNew =
SrcMgr.getFileEntryForID(FNewDecLoc.first);
5017 auto FOld =
SrcMgr.getFileEntryRefForID(FOldDecLoc.first);
5018 auto &HSI =
PP.getHeaderSearchInfo();
5019 StringRef HdrFilename =
5022 auto noteFromModuleOrInclude = [&](
Module *Mod,
5028 if (IncLoc.isValid()) {
5030 Diag(IncLoc, diag::note_redefinition_modules_same_file)
5036 Diag(IncLoc, diag::note_redefinition_include_same_file)
5037 << HdrFilename.str();
5047 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
5055 if (FOld && !HSI.isFileMultipleIncludeGuarded(*FOld))
5072 New->getDescribedVarTemplate() ||
5073 !
New->getTemplateParameterLists().empty() ||
5074 New->getDeclContext()->isDependentContext() ||
5075 New->hasAttr<SelectAnyAttr>())) {
5078 New->demoteThisDefinitionToDeclaration();
5086 Diag(
New->getLocation(), diag::err_redefinition) <<
New;
5088 New->setInvalidDecl();
5114 if (!
Context.getLangOpts().CPlusPlus)
5120 if (!Tag->getName().empty() || Tag->getTypedefNameForAnonDecl())
5123 Context.getManglingNumberContext(Tag->getParent());
5132 Decl *ManglingContextDecl;
5133 std::tie(MCtx, ManglingContextDecl) =
5143struct NonCLikeKind {
5155 explicit operator bool() {
return Kind !=
None; }
5163 return {NonCLikeKind::Invalid, {}};
5170 return {NonCLikeKind::BaseClass,
5182 if (
auto *FD = dyn_cast<FieldDecl>(D)) {
5183 if (FD->hasInClassInitializer()) {
5184 auto *
Init = FD->getInClassInitializer();
5185 return {NonCLikeKind::DefaultMemberInit,
5201 auto *MemberRD = dyn_cast<CXXRecordDecl>(D);
5209 if (MemberRD->isLambda())
5210 return {NonCLikeKind::Lambda, MemberRD->getSourceRange()};
5214 if (MemberRD->isThisDeclarationADefinition()) {
5220 return {
Invalid ? NonCLikeKind::Invalid : NonCLikeKind::None, {}};
5237 Context.getCanonicalTagType(TagFromDeclSpec))) {
5239 Context.addTypedefNameForUnnamedTagDecl(TagFromDeclSpec, NewTD);
5250 const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(TagFromDeclSpec);
5254 if (NonCLike || ChangesLinkage) {
5255 if (NonCLike.Kind == NonCLikeKind::Invalid)
5258 unsigned DiagID = diag::ext_non_c_like_anon_struct_in_typedef;
5259 if (ChangesLinkage) {
5261 if (NonCLike.Kind == NonCLikeKind::None)
5262 DiagID = diag::err_typedef_changes_linkage;
5264 DiagID = diag::err_non_c_like_anon_struct_in_typedef;
5270 TextToInsert +=
' ';
5273 Diag(FixitLoc, DiagID)
5276 if (NonCLike.Kind != NonCLikeKind::None) {
5277 Diag(NonCLike.Range.
getBegin(), diag::note_non_c_like_anon_struct)
5278 << NonCLike.Kind - 1 << NonCLike.Range;
5281 << NewTD << isa<TypeAliasDecl>(NewTD);
5306 if (
const auto *ED = dyn_cast<EnumDecl>(DS.
getRepAsDecl())) {
5307 if (ED->isScopedUsingClassTag())
5314 llvm_unreachable(
"unexpected type specifier");
5322 bool IsExplicitInstantiation,
5325 Decl *TagD =
nullptr;
5343 Tag = CTD->getTemplatedDecl();
5348 Tag->setFreeStanding();
5349 if (Tag->isInvalidDecl())
5358 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
5395 "Friend ellipsis but not friend-specified?");
5398 bool DeclaresAnything =
true;
5402 if (!
Record->getDeclName() &&
Record->isCompleteDefinition() &&
5405 Record->getDeclContext()->isRecord()) {
5419 DeclaresAnything =
false;
5438 if ((Tag && Tag->getDeclName()) ||
5448 DeclaresAnything =
false;
5460 if (
Enum->enumerators().empty() && !
Enum->getIdentifier() &&
5461 !
Enum->isInvalidDecl())
5462 DeclaresAnything =
false;
5470 DeclaresAnything =
false;
5474 Tag && Tag->getDeclContext()->isFunctionOrMethod())
5476 << Tag->getTagKind()
5489 if (!DeclaresAnything) {
5492 Diag(DS.
getBeginLoc(), (IsExplicitInstantiation || !TemplateParams.empty())
5493 ? diag::err_no_declarators
5494 : diag::ext_no_declarators)
5507 unsigned DiagID = diag::warn_standalone_specifier;
5509 DiagID = diag::ext_standalone_specifier;
5550 auto EmitAttributeDiagnostic = [
this, &DS](
const ParsedAttr &AL) {
5551 unsigned DiagnosticId = diag::warn_declspec_attribute_ignored;
5553 DiagnosticId = diag::warn_attribute_ignored;
5554 else if (AL.isRegularKeywordAttribute())
5555 DiagnosticId = diag::err_declspec_keyword_has_no_effect;
5557 DiagnosticId = diag::warn_declspec_attribute_ignored;
5558 Diag(AL.getLoc(), DiagnosticId)
5562 llvm::for_each(DS.
getAttributes(), EmitAttributeDiagnostic);
5563 llvm::for_each(DeclAttrs, EmitAttributeDiagnostic);
5586 NamedDecl *PrevDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
5587 assert(PrevDecl &&
"Expected a non-null Decl");
5600 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
5602 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
5608 if (
auto *RD = dyn_cast_if_present<RecordDecl>(D))
5618 if (
Record->isAnonymousStructOrUnion())
5623 const NamedDecl *ND = dyn_cast<NamedDecl>(D);
5657 for (
auto *D : AnonRecord->
decls()) {
5680 unsigned OldChainingSize = Chaining.size();
5682 Chaining.append(IF->chain_begin(), IF->chain_end());
5684 Chaining.push_back(VD);
5686 assert(Chaining.size() >= 2);
5689 for (
unsigned i = 0; i < Chaining.size(); i++)
5690 NamedChain[i] = Chaining[i];
5694 VD->
getType(), {NamedChain, Chaining.size()});
5708 Chaining.resize(OldChainingSize);
5722 "Parser allowed 'typedef' as storage class VarDecl.");
5723 switch (StorageClassSpec) {
5737 llvm_unreachable(
"unknown storage class specifier");
5741 assert(
Record->hasInClassInitializer());
5743 for (
const auto *I :
Record->decls()) {
5744 const auto *FD = dyn_cast<FieldDecl>(I);
5745 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
5746 FD = IFD->getAnonField();
5747 if (FD && FD->hasInClassInitializer())
5748 return FD->getLocation();
5751 llvm_unreachable(
"couldn't find in-class initializer");
5759 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
5779 Diag(
Record->getLocation(), diag::ext_anonymous_union);
5781 Diag(
Record->getLocation(), diag::ext_gnu_anonymous_struct);
5783 Diag(
Record->getLocation(), diag::ext_c11_anonymous_struct);
5789 const char *PrevSpec =
nullptr;
5801 Diag(
Record->getLocation(), diag::err_anonymous_union_not_static)
5806 PrevSpec, DiagID, Policy);
5814 diag::err_anonymous_union_with_storage_spec)
5820 PrevSpec, DiagID,
Context.getPrintingPolicy());
5828 <<
Record->isUnion() <<
"const"
5832 diag::ext_anonymous_struct_union_qualified)
5833 <<
Record->isUnion() <<
"volatile"
5837 diag::ext_anonymous_struct_union_qualified)
5838 <<
Record->isUnion() <<
"restrict"
5842 diag::ext_anonymous_struct_union_qualified)
5843 <<
Record->isUnion() <<
"_Atomic"
5847 diag::ext_anonymous_struct_union_qualified)
5848 <<
Record->isUnion() <<
"__unaligned"
5858 for (
auto *Mem :
Record->decls()) {
5860 if (Mem->isInvalidDecl())
5863 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
5867 assert(FD->getAccess() !=
AS_none);
5869 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
5881 }
else if (Mem->isImplicit()) {
5888 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
5889 if (!MemRecord->isAnonymousStructOrUnion() &&
5890 MemRecord->getDeclName()) {
5893 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
5897 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
5905 Diag(MemRecord->getLocation(),
5906 diag::ext_anonymous_record_with_anonymous_type)
5916 unsigned DK = diag::err_anonymous_record_bad_member;
5918 DK = diag::err_anonymous_record_with_type;
5920 DK = diag::err_anonymous_record_with_function;
5922 DK = diag::err_anonymous_record_with_static;
5926 DK == diag::err_anonymous_record_with_type)
5927 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
5930 Diag(Mem->getLocation(), DK) <<
Record->isUnion();
5946 Diag(
Record->getLocation(), diag::err_anonymous_struct_not_member)
5967 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
5971 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
5987 Diag(
Record->getLocation(), diag::err_mutable_nonmember);
5993 Record->getLocation(),
nullptr,
6009 Record->setAnonymousStructOrUnion(
true);
6020 Chain.push_back(Anon);
6026 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
6029 Decl *ManglingContextDecl;
6030 std::tie(MCtx, ManglingContextDecl) =
6049 assert(
Record &&
"expected a record!");
6054 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
6062 nullptr, RecTy, TInfo,
6074 Chain.push_back(Anon);
6078 diag::err_field_incomplete_or_sizeless) ||
6083 ParentDecl->setInvalidDecl();
6120 diag::err_deduction_guide_name_not_class_template)
6140 NameInfo.
setName(
Context.DeclarationNames.getCXXLiteralOperatorName(
6150 NameInfo.
setName(
Context.DeclarationNames.getCXXConversionFunctionName(
6151 Context.getCanonicalType(Ty)));
6162 Context.getCanonicalType(Ty)));
6183 Context.DeclarationNames.getCXXConstructorName(CurClassType));
6195 Context.getCanonicalType(Ty)));
6203 return Context.getNameForTemplate(TName, TNameLoc);
6208 llvm_unreachable(
"Unknown name kind");
6236 for (
unsigned Idx = 0; Idx <
Declaration->param_size(); ++Idx) {
6241 if (Context.hasSameUnqualifiedType(DefParamTy, DeclParamTy))
6249 if (Context.hasSameUnqualifiedType(DeclParamBaseTy, DefParamBaseTy) ||
6250 (DeclTyName && DeclTyName == DefTyName))
6251 Params.push_back(Idx);
6278#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case DeclSpec::TST_##Trait:
6279#include "clang/Basic/BuiltinTraits.inc"
6284 if (
T.isNull() || !
T->isInstantiationDependentType())
break;
6294 if (!TSI)
return true;
6307 if (
Result.isInvalid())
return true;
6352 << D << static_cast<int>(Status);
6363 if (
OpenMP().getOMPTraitInfoForSurroundingScope()->isExtensionActive(
6364 llvm::omp::TraitProperty::
6365 implementation_extension_bind_to_declaration))
6390 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
6401 bool IsMemberSpecialization) {
6402 assert(SS.
isValid() &&
"diagnoseQualifiedDeclaration called for declaration "
6403 "without nested-name-specifier");
6419 Diag(Loc,
LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
6420 : diag::err_member_extra_qualification)
6424 Diag(Loc, diag::warn_namespace_member_extra_qualification) << Name;
6432 if (!Cur->
Encloses(DC) && !(TemplateId || IsMemberSpecialization)) {
6435 Diag(Loc, diag::err_member_qualification)
6438 Diag(Loc, diag::err_invalid_declarator_global_scope)
6441 Diag(Loc, diag::err_invalid_declarator_in_function)
6444 Diag(Loc, diag::err_invalid_declarator_in_block)
6448 Diag(Loc, diag::err_export_non_namespace_scope_name)
6455 Diag(Loc, diag::err_invalid_declarator_scope)
6465 if (IsMemberSpecialization)
6469 Diag(Loc, diag::err_member_qualification)
6496 Diag(Loc, diag::ext_template_after_declarative_nns)
6501 TL = std::exchange(NextTL,
TypeLoc())) {
6503 switch (TL.getTypeLocClass()) {
6504 case TypeLoc::TemplateSpecialization: {
6506 TemplateKeywordLoc = TST.getTemplateKeywordLoc();
6507 if (
auto *
T = TST.getTypePtr();
T->isDependentType() &&
T->isTypeAlias())
6508 Diag(Loc, diag::ext_alias_template_in_declarative_nns)
6509 << TST.getLocalSourceRange();
6512 case TypeLoc::Decltype:
6513 case TypeLoc::PackIndexing: {
6514 const Type *
T = TL.getTypePtr();
6521 Diag(Loc, diag::err_computed_type_in_declarative_nns)
6522 <<
T->isDecltypeType() << TL.getSourceRange();
6525 case TypeLoc::DependentName:
6532 if (TemplateKeywordLoc.
isValid())
6533 Diag(Loc, diag::ext_template_after_declarative_nns)
6574 diag::err_template_qualified_declarator_no_match)
6581 if (!IsDependentContext &&
6588 diag::err_member_def_undefined_record)
6611 if (EnteringContext && IsDependentContext &&
6612 TemplateParamLists.size() != 0) {
6631 bool IsLinkageLookup =
false;
6632 bool CreateBuiltins =
false;
6645 R->isFunctionType())) {
6646 IsLinkageLookup =
true;
6648 CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
6649 }
else if (
CurContext->getRedeclContext()->isTranslationUnit() &&
6651 CreateBuiltins =
true;
6653 if (IsLinkageLookup) {
6695 bool AllowForCompatibility =
false;
6698 AllowForCompatibility = DeclParent->Contains(*TemplateParamParent) &&
6699 TemplateParamParent->isDeclScope(TPD);
6702 AllowForCompatibility);
6719 (TemplateParamLists.size() == 0 || R->isFunctionType()))
6732 bool AddToScope =
true;
6734 if (TemplateParamLists.size()) {
6740 }
else if (R->isFunctionType()) {
6756 if (
New->getDeclName() && AddToScope)
6759 if (
OpenMP().isInOpenMPDeclareTargetContext())
6770 bool &SizeIsNegative,
6771 llvm::APSInt &Oversized) {
6776 SizeIsNegative =
false;
6779 if (
T->isDependentType())
6785 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
6790 if (FixedType.
isNull())
return FixedType;
6791 FixedType = Context.getPointerType(FixedType);
6792 return Qs.
apply(Context, FixedType);
6794 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
6795 QualType Inner = PTy->getInnerType();
6799 if (FixedType.
isNull())
return FixedType;
6800 FixedType = Context.getParenType(FixedType);
6801 return Qs.
apply(Context, FixedType);
6811 SizeIsNegative, Oversized);
6821 llvm::APSInt Res =
Result.Val.getInt();
6824 if (Res.isSigned() && Res.isNegative()) {
6825 SizeIsNegative =
true;
6830 unsigned ActiveSizeBits =
6834 : Res.getActiveBits();
6836 Oversized = std::move(Res);
6840 QualType FoldedArrayType = Context.getConstantArrayType(
6842 return Qs.
apply(Context, FoldedArrayType);
6867 TypeLoc DstElemTL = DstATL.getElementLoc();
6886 bool &SizeIsNegative,
6887 llvm::APSInt &Oversized) {
6890 SizeIsNegative, Oversized);
6893 TypeSourceInfo *FixedTInfo = Context.getTrivialTypeSourceInfo(FixedTy);
6901 unsigned FailedFoldDiagID) {
6902 bool SizeIsNegative;
6903 llvm::APSInt Oversized;
6905 TInfo,
Context, SizeIsNegative, Oversized);
6907 Diag(Loc, diag::ext_vla_folded_to_constant);
6914 Diag(Loc, diag::err_typecheck_negative_array_size);
6915 else if (Oversized.getBoolValue())
6917 Oversized, 10, Oversized.isSigned(),
false,
6919 else if (FailedFoldDiagID)
6920 Diag(Loc, FailedFoldDiagID);
6932 Context.getExternCContextDecl()->makeDeclVisibleInContext(ND);
6937 auto Result =
Context.getExternCContextDecl()->lookup(Name);
6946 diag::err_virtual_non_function);
6950 diag::err_explicit_non_function);
6954 diag::err_noreturn_non_function);
6975 ? diag::warn_ms_inline_non_function
6976 : diag::err_inline_non_function)
6980 << 1 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
6985 diag::err_deduction_guide_invalid_specifier)
6994 if (!NewTD)
return nullptr;
7015 if (
T->isVariablyModifiedType()) {
7019 bool SizeIsNegative;
7020 llvm::APSInt Oversized;
7031 else if (
T->isVariableArrayType())
7033 else if (Oversized.getBoolValue())
7070 switch (II->getNotableIdentifierID()) {
7071 case tok::NotableIdentifierKind::FILE:
7074 case tok::NotableIdentifierKind::jmp_buf:
7075 Context.setjmp_bufDecl(NewTD);
7077 case tok::NotableIdentifierKind::sigjmp_buf:
7078 Context.setsigjmp_bufDecl(NewTD);
7080 case tok::NotableIdentifierKind::ucontext_t:
7081 Context.setucontext_tDecl(NewTD);
7083 case tok::NotableIdentifierKind::float_t:
7084 case tok::NotableIdentifierKind::double_t:
7085 NewTD->
addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(
Context));
7122 if (Context.getLangOpts().CPlusPlus) {
7146 if (!OuterContext->
Equals(PrevOuterContext))
7155 if (!SS.
isSet())
return;
7182 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
7191 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
7192 if (VD->hasInit()) {
7193 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
7194 assert(VD->isThisDeclarationADefinition() &&
7195 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
7197 VD->dropAttr<AliasAttr>();
7206 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
7209 diag::err_attribute_selectany_non_extern_data);
7216 if (HybridPatchableAttr *
Attr = ND.
getAttr<HybridPatchableAttr>()) {
7219 diag::warn_attribute_hybrid_patchable_non_extern);
7225 auto *VD = dyn_cast<VarDecl>(&ND);
7226 bool IsAnonymousNS =
false;
7229 const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(VD->getDeclContext());
7230 while (NS && !IsAnonymousNS) {
7232 NS = dyn_cast<NamespaceDecl>(NS->
getParent());
7239 bool AnonNSInMicrosoftMode = IsAnonymousNS && IsMicrosoft;
7241 (!AnonNSInMicrosoftMode &&
7252 if (
const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
7253 FD = FD->getMostRecentDecl();
7258 for (
TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
7264 if (
const auto *A = ATL.
getAttrAs<LifetimeBoundAttr>()) {
7265 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
7266 int NoImplicitObjectError = -1;
7268 NoImplicitObjectError = 0;
7269 else if (MD->isStatic())
7270 NoImplicitObjectError = 1;
7271 else if (MD->isExplicitObjectMemberFunction())
7272 NoImplicitObjectError = 2;
7273 if (NoImplicitObjectError != -1) {
7274 S.
Diag(A->getLocation(), diag::err_lifetimebound_no_object_param)
7275 << NoImplicitObjectError << A->getRange();
7277 S.
Diag(A->getLocation(), diag::err_lifetimebound_ctor_dtor)
7279 }
else if (MD->getReturnType()->isVoidType()) {
7283 err_lifetimebound_implicit_object_parameter_void_return_type);
7288 for (
unsigned int I = 0; I < FD->getNumParams(); ++I) {
7293 if (
auto *A = P->
getAttr<LifetimeBoundAttr>()) {
7295 S.
Diag(A->getLocation(),
7296 diag::err_lifetimebound_parameter_void_return_type);
7304 if (ND.
hasAttr<ModularFormatAttr>() && !ND.
hasAttr<FormatAttr>())
7305 S.
Diag(ND.
getLocation(), diag::err_modular_format_attribute_no_format);
7324 bool IsSpecialization,
7325 bool IsDefinition) {
7329 bool IsTemplate =
false;
7330 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
7331 OldDecl = OldTD->getTemplatedDecl();
7333 if (!IsSpecialization)
7334 IsDefinition =
false;
7336 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
7337 NewDecl = NewTD->getTemplatedDecl();
7341 if (!OldDecl || !NewDecl)
7344 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
7345 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
7346 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
7347 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
7351 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
7352 (NewExportAttr && !NewExportAttr->isInherited());
7358 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
7360 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
7362 bool JustWarn =
false;
7364 auto *VD = dyn_cast<VarDecl>(OldDecl);
7365 if (VD && !VD->getDescribedVarTemplate())
7367 auto *FD = dyn_cast<FunctionDecl>(OldDecl);
7379 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
7380 : diag::err_attribute_dll_redeclaration;
7383 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
7396 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
7398 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
7401 IsStaticDataMember = VD->isStaticDataMember();
7402 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
7404 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
7405 IsInline = FD->isInlined();
7406 IsQualifiedFriend = FD->getQualifier() &&
7410 if (OldImportAttr && !HasNewAttr &&
7411 (!IsInline || (IsMicrosoftABI && IsTemplate)) && !IsStaticDataMember &&
7413 if (IsMicrosoftABI && IsDefinition) {
7414 if (IsSpecialization) {
7417 diag::err_attribute_dllimport_function_specialization_definition);
7418 S.
Diag(OldImportAttr->getLocation(), diag::note_attribute);
7419 NewDecl->
dropAttr<DLLImportAttr>();
7422 diag::warn_redeclaration_without_import_attribute)
7425 NewDecl->
dropAttr<DLLImportAttr>();
7426 NewDecl->
addAttr(DLLExportAttr::CreateImplicit(
7427 S.
Context, NewImportAttr->getRange()));
7429 }
else if (IsMicrosoftABI && IsSpecialization) {
7430 assert(!IsDefinition);
7434 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
7435 << NewDecl << OldImportAttr;
7437 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
7438 OldDecl->
dropAttr<DLLImportAttr>();
7439 NewDecl->
dropAttr<DLLImportAttr>();
7441 }
else if (IsInline && OldImportAttr && !IsMicrosoftABI) {
7444 OldDecl->
dropAttr<DLLImportAttr>();
7445 NewDecl->
dropAttr<DLLImportAttr>();
7447 diag::warn_dllimport_dropped_from_inline_function)
7448 << NewDecl << OldImportAttr;
7455 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
7457 !NewImportAttr && !NewExportAttr) {
7458 if (
const DLLExportAttr *ParentExportAttr =
7459 MD->getParent()->getAttr<DLLExportAttr>()) {
7460 DLLExportAttr *NewAttr = ParentExportAttr->clone(S.
Context);
7461 NewAttr->setInherited(
true);
7513 return D->isExternC();
7530 llvm_unreachable(
"Unexpected context");
7540 llvm_unreachable(
"Unexpected context");
7585 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
7586 return FD->isExternC();
7587 if (
const auto *VD = dyn_cast<VarDecl>(D))
7588 return VD->isExternC();
7590 llvm_unreachable(
"Unknown type of decl!");
7601 if (R->isImageType() || R->isPipeType()) {
7603 diag::err_opencl_type_can_only_be_used_as_function_parameter)
7615 if (R->isReserveIDT() || R->isClkEventT() || R->isEventT()) {
7617 diag::err_invalid_type_for_program_scope_var)
7627 QualType NR = R.getCanonicalType();
7646 Se.
Diag(NewVD->
getLocation(), diag::err_opencl_half_declaration) << R;
7655 if (R->isEventT()) {
7663 if (R->isSamplerT()) {
7678 R.isConstQualified())) {
7679 Se.
Diag(NewVD->
getLocation(), diag::err_opencl_nonconst_global_sampler);
7689template <
typename AttrTy>
7692 if (
const auto *Attribute = TND->
getAttr<AttrTy>()) {
7693 AttrTy *Clone = Attribute->clone(S.
Context);
7694 Clone->setInherited(
true);
7722 if (
const auto *ConstDecl = RD->
getAttr<ReadOnlyPlacementAttr>()) {
7724 S.
Diag(ConstDecl->getLocation(), diag::note_enforce_read_only_placement);
7731 "NewD is not a function or variable");
7740 if (IdentName ==
nullptr)
7744 auto &Label = PendingName->second;
7750 Diag(Label.NameLoc, diag::warn_pragma_not_applied) <<
"export" << NewD;
7760 (VD->
getDeclContext()->getRedeclContext()->isTranslationUnit() ||
7775 if (
R->isIncompleteType())
7781 Diag(E->
getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
7785 if (!
Context.getTargetInfo().isValidGCCRegisterName(Label) &&
7787 Diag(E->
getExprLoc(), diag::err_asm_unknown_register_name) << Label;
7797 const auto &TI =
Context.getTargetInfo();
7798 bool HasSizeMismatch;
7800 if (!TI.isValidGCCRegisterName(Label))
7801 Diag(E->
getExprLoc(), diag::err_asm_unknown_register_name) << Label;
7802 else if (!TI.validateGlobalRegisterVariable(Label,
Context.getTypeSize(R),
7804 Diag(E->
getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
7805 else if (HasSizeMismatch)
7806 Diag(E->
getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
7809 if (!
R->isIntegralType(
Context) && !
R->isPointerType()) {
7811 diag::err_asm_unsupported_register_type)
7826 bool IsPlaceholderVariable =
false;
7832 if (!Decomp.bindings().empty()) {
7833 II = Decomp.bindings()[0].Name;
7847 IsPlaceholderVariable =
true;
7855 if (IsPlaceholderVariable)
7869 bool IsLocalExternDecl = SC ==
SC_Extern &&
7888 : diag::warn_deprecated_register)
7911 const AutoType *AT = TL.getTypePtr();
7915 bool IsMemberSpecialization =
false;
7916 bool IsVariableTemplateSpecialization =
false;
7918 bool IsVariableTemplate =
false;
7926 if (R->getContainedDeducedType())
7947 false, IsMemberSpecialization,
Invalid);
7949 if (TemplateParams) {
7956 if (!TemplateParams->
size() &&
7961 diag::err_template_variable_noparams)
7965 TemplateParams =
nullptr;
7973 IsVariableTemplateSpecialization =
true;
7977 IsVariableTemplate =
true;
7985 if (!TemplateParamLists.empty() && IsMemberSpecialization &&
7990 "should have a 'template<>' for this decl");
7993 bool IsExplicitSpecialization =
8004 (IsExplicitSpecialization || IsMemberSpecialization)) {
8006 diag::ext_explicit_specialization_storage_class)
8012 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
8018 if (Ctxt->isFunctionOrMethod()) {
8019 FunctionOrMethod = Ctxt;
8022 const CXXRecordDecl *ParentDecl = dyn_cast<CXXRecordDecl>(Ctxt);
8024 AnonStruct = ParentDecl;
8028 if (FunctionOrMethod) {
8032 diag::err_static_data_member_not_allowed_in_local_class)
8033 << Name << RD->getDeclName() << RD->getTagKind();
8035 }
else if (AnonStruct) {
8040 diag::err_static_data_member_not_allowed_in_anon_struct)
8043 }
else if (RD->isUnion()) {
8047 diag_compat::static_data_member_in_union)
8065 diag::err_static_out_of_line)
8078 diag::err_storage_class_for_static_member)
8083 llvm_unreachable(
"C storage class in c++!");
8087 if (IsVariableTemplateSpecialization) {
8089 TemplateParamLists.size() > 0
8090 ? TemplateParamLists[0]->getTemplateLoc()
8093 S, D, TInfo,
Previous, TemplateKWLoc, TemplateParams, SC,
8108 if (IsVariableTemplate) {
8111 TemplateParams, NewVD);
8117 if (R->getContainedDeducedType())
8132 unsigned VDTemplateParamLists =
8133 (TemplateParams && !IsExplicitSpecialization) ? 1 : 0;
8134 if (TemplateParamLists.size() > VDTemplateParamLists)
8136 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
8143 }
else if (
CurContext->isFunctionOrMethod()) {
8146 diag::err_inline_declaration_block_scope) << Name
8151 : diag::compat_pre_cxx17_inline_variable);
8162 if (IsLocalExternDecl) {
8165 B->setLocalExternDecl();
8170 bool EmitTLSUnsupportedError =
false;
8183 diag::err_thread_non_global)
8185 else if (!
Context.getTargetInfo().isTLSSupported()) {
8190 EmitTLSUnsupportedError =
true;
8197 diag::err_thread_unsupported);
8208 diag::err_constexpr_wrong_decl_kind)
8209 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
8219 Context.getTargetInfo().getCXXABI().isMicrosoft()))
8226 diag::err_constinit_local_variable);
8230 ConstInitAttr::Keyword_constinit));
8248 diag::warn_static_local_in_extern_inline);
8254 if (IsVariableTemplateSpecialization)
8259 else if (IsMemberSpecialization)
8274 B->setModulePrivate();
8284 diag::err_opencl_unknown_type_specifier)
8294 if (
const auto *ATy = dyn_cast<ArrayType>(NewVD->
getType())) {
8295 if (ATy && ATy->getElementType().isWebAssemblyReferenceType() &&
8313 llvm::MapVector<IdentifierInfo *, AsmLabelAttr *>::iterator I =
8340 if (R->isFunctionPointerType())
8345 if (EmitTLSUnsupportedError &&
8348 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD))))
8350 diag::err_thread_unsupported);
8352 if (EmitTLSUnsupportedError &&
8359 (NewVD->
hasAttr<CUDASharedAttr>() ||
8360 NewVD->
hasAttr<CUDAConstantAttr>())) {
8368 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
8369 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
8374 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(NewVD))
8381 CheckAsmLabel(S, D.
getAsmLabel(), SC, TInfo, NewVD);
8393 IsMemberSpecialization ||
8394 IsVariableTemplateSpecialization);
8408 if (IsMemberSpecialization && !IsVariableTemplate &&
8409 !IsVariableTemplateSpecialization && !NewVD->
isInvalidDecl() &&
8426 !IsVariableTemplateSpecialization) {
8437 if (NewTemplate && IsMemberSpecialization) {
8449 if (!IsPlaceholderVariable)
8480 if (IsMemberSpecialization) {
8485 ->setMemberSpecialization();
8504 Decl *ManglingContextDecl;
8505 std::tie(MCtx, ManglingContextDecl) =
8597 return !Diags.
isIgnored(diag::warn_decl_shadow, R.getNameLoc());
8609 NamedDecl *ShadowedDecl = R.getFoundDecl();
8623 NamedDecl *ShadowedDecl = R.getFoundDecl();
8632 NamedDecl *ShadowedDecl = R.getFoundDecl();
8641 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
8643 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FnDC)) {
8646 if (MD->isStatic() || MD->isExplicitObjectMemberFunction())
8658 if (
const auto PVD = dyn_cast<ParmVarDecl>(D)) {
8661 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
8666 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
8667 if (shadowedVar->isExternC()) {
8670 for (
auto *I : shadowedVar->redecls())
8671 if (I->isFileVarDecl()) {
8679 unsigned WarningDiag = diag::warn_decl_shadow;
8682 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
8688 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
8694 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
8700 ->ShadowingDecls.push_back({D, VD});
8711 ->ShadowingDecls.push_back({D, ShadowedDecl});
8717 bool HasLocalStorage =
false;
8718 if (
const auto *VD = dyn_cast<VarDecl>(ShadowedDecl))
8719 HasLocalStorage = VD->hasLocalStorage();
8720 else if (
const auto *BD = dyn_cast<BindingDecl>(ShadowedDecl))
8724 if (HasLocalStorage) {
8729 ParentDC && !ParentDC->
Equals(OldDC);
8770 Diag(R.getNameLoc(), WarningDiag) << Name << Kind << OldDC;
8772 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
8779 const NamedDecl *ShadowedDecl = Shadow.ShadowedDecl;
8785 Diag(Shadow.VD->getLocation(),
8786 CaptureLoc.
isInvalid() ? diag::warn_decl_shadow_uncaptured_local
8787 : diag::warn_decl_shadow)
8788 << Shadow.VD->getDeclName()
8791 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
8792 << Shadow.VD->getDeclName() << 0;
8795 Diag(Shadow.VD->getLocation(),
8797 : diag::warn_decl_shadow_uncaptured_local)
8798 << Shadow.VD->getDeclName()
8824 auto *DRE = dyn_cast<DeclRefExpr>(E);
8828 auto I = ShadowingDecls.find(D);
8829 if (I == ShadowingDecls.end())
8831 const NamedDecl *ShadowedDecl = I->second;
8833 Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
8838 ShadowingDecls.erase(I);
8846 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
8905 assert(Prev &&
"should have found a previous declaration to diagnose");
8907 Prev = FD->getFirstDecl();
8911 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
8933 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
8945 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
8965 SemaRef.
Diag(VarLoc, diag::err_c23_constexpr_invalid_type) <<
T;
8975 SemaRef.
Diag(VarLoc, diag::err_c23_constexpr_invalid_type) <<
T;
8983 return CheckC23ConstexprVarType(SemaRef, VarLoc, F->getType());
9003 if (
T->isUndeducedType())
9009 if (
T->isObjCObjectType()) {
9012 T =
Context.getObjCObjectPointerType(
T);
9021 Diag(NewVD->
getLocation(), diag::err_sycl_address_space_qualified_object)
9055 if (NewVD->
hasAttr<BlocksAttr>()) {
9060 if (
T->isBlockPointerType()) {
9063 if (!
T.isConstQualified()) {
9064 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
9070 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
9079 if (!
T->isSamplerT() && !
T->isDependentType() &&
9086 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
9087 <<
Scope <<
"global or constant";
9089 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
9090 <<
Scope <<
"constant";
9104 bool AllowFunctionScopeLocalVariables =
9107 "__cl_clang_function_scope_local_variables",
getLangOpts());
9108 if (AllowFunctionScopeLocalVariables) {
9115 if (FD && !FD->
hasAttr<DeviceKernelAttr>()) {
9127 if (FD && FD->
hasAttr<DeviceKernelAttr>()) {
9152 && !NewVD->
hasAttr<BlocksAttr>()) {
9163 if (
T->isWebAssemblyTableType()) {
9174 const auto *ATy = dyn_cast<ConstantArrayType>(
T.getTypePtr());
9175 if (!ATy || ATy->getZExtSize() != 0) {
9177 diag::err_typecheck_wasm_table_must_have_zero_length);
9187 (FD->hasAttr<CUDADeviceAttr>() || FD->hasAttr<CUDAGlobalAttr>())) {
9190 ArrayT && ArrayT->isZeroSize()) {
9196 bool isVM =
T->isVariablyModifiedType();
9197 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
9203 bool SizeIsNegative;
9204 llvm::APSInt Oversized;
9209 FixedT = FixedTInfo->
getType();
9210 else if (FixedTInfo) {
9216 if ((!FixedTInfo || FixedT.
isNull()) &&
T->isVariableArrayType()) {
9249 if (
T->isVoidType()) {
9261 !
T.isWebAssemblyReferenceType() && !
T->isHLSLSpecificType()) {
9267 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
9269 << diag::NotAllowedBlockVarReason::VariablyModifiedType;
9281 !
T->isDependentType() &&
9283 diag::err_constexpr_var_non_literal)) {
9289 if (
Context.getTargetInfo().getTriple().isPPC64() &&
9299 llvm::StringMap<bool> CallerFeatureMap;
9300 Context.getFunctionFeatureMap(CallerFeatureMap, FD);
9302 CallerFeatureMap)) {
9310 llvm::StringMap<bool> CallerFeatureMap;
9311 Context.getFunctionFeatureMap(CallerFeatureMap, FD);
9316 if (
Context.getTargetInfo().hasAMDGPUTypes()) {
9323 if (
T.hasAddressSpace() &&
9357 CXXRecordDecl *BaseRecord = Specifier->getType()->getAsCXXRecordDecl();
9362 Name =
Context.DeclarationNames.getCXXDestructorName(
9363 Context.getCanonicalTagType(BaseRecord));
9368 dyn_cast<CXXMethodDecl>(BaseND->getCanonicalDecl());
9375 if (Overridden.insert(BaseMD).second) {
9392 return !Overridden.empty();
9398 struct ActOnFDArgs {
9412 DifferentNameValidatorCCC(ASTContext &Context, FunctionDecl *TypoFD,
9413 CXXRecordDecl *Parent)
9414 : Context(Context), OriginalFD(TypoFD),
9417 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
9421 SmallVector<unsigned, 1> MismatchedParams;
9423 CDeclEnd = candidate.
end();
9424 CDecl != CDeclEnd; ++CDecl) {
9425 FunctionDecl *FD = dyn_cast<FunctionDecl>(*CDecl);
9429 if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
9430 CXXRecordDecl *Parent = MD->getParent();
9433 }
else if (!ExpectedParent) {
9442 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
9443 return std::make_unique<DifferentNameValidatorCCC>(*
this);
9447 ASTContext &Context;
9448 FunctionDecl *OriginalFD;
9449 CXXRecordDecl *ExpectedParent;
9469 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *S) {
9477 IsLocalFriend ? diag::err_no_matching_local_friend :
9479 diag::err_member_decl_does_not_match;
9491 "Cannot have an ambiguity in previous-declaration lookup");
9493 DifferentNameValidatorCCC CCC(SemaRef.
Context, NewFD,
9495 if (!Prev.
empty()) {
9504 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
9505 NearMatches.push_back(std::make_pair(FD, ParamNum));
9513 IsLocalFriend ?
nullptr : NewDC))) {
9520 CDeclEnd = Correction.
end();
9521 CDecl != CDeclEnd; ++CDecl) {
9541 ExtraArgs.S, ExtraArgs.D,
9544 ExtraArgs.AddToScope);
9552 Decl *Canonical =
Result->getCanonicalDecl();
9555 if ((*I)->getCanonicalDecl() == Canonical)
9562 SemaRef.
PDiag(IsLocalFriend
9563 ? diag::err_no_matching_local_friend_suggest
9564 : diag::err_member_decl_does_not_match_suggest)
9565 << Name << NewDC << IsDefinition);
9578 << Name << NewDC << IsDefinition << NewFD->
getLocation();
9581 if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
9587 bool NewFDisConst = NewMD && NewMD->
isConst();
9590 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
9591 NearMatch != NearMatchEnd; ++NearMatch) {
9594 bool FDisConst = MD && MD->
isConst();
9595 bool IsMember = MD || !IsLocalFriend;
9598 if (
unsigned Idx = NearMatch->second) {
9602 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
9603 : diag::note_local_decl_close_param_match)
9606 }
else if (FDisConst != NewFDisConst) {
9608 diag::note_member_def_close_const_match)
9613 else if (FTI.hasMethodTypeQualifiers() &&
9614 FTI.getConstQualifierLoc().isValid())
9618 IsMember ? diag::note_member_def_close_match
9619 : diag::note_local_decl_close_match);
9627 default: llvm_unreachable(
"Unknown storage class!");
9632 diag::err_typecheck_sclass_func);
9649 diag::err_static_block_func);
9665 bool &IsVirtualOkay) {
9679 diag::err_c23_constexpr_not_variable);
9682 diag::err_constexpr_wrong_decl_kind)
9683 <<
static_cast<int>(ConstexprKind);
9704 (!R->getAsAdjusted<
FunctionType>() && R->isFunctionProtoType());
9707 "Strict prototypes are required");
9728 "Constructors can only be declared in a member context");
9734 isInline,
false, ConstexprKind,
9745 false, ConstexprKind,
9746 TrailingRequiresClause);
9749 if (
Record->isBeingDefined())
9758 IsVirtualOkay =
true;
9770 true, ConstexprKind, TrailingRequiresClause);
9776 diag::err_conv_function_not_member);
9784 IsVirtualOkay =
true;
9789 TrailingRequiresClause);
9816 IsVirtualOkay = !Ret->isStatic();
9830 true , ConstexprKind, TrailingRequiresClause);
9847 StringRef SizeTypeNames[] = {
"size_t",
"intptr_t",
"uintptr_t",
"ptrdiff_t"};
9855 if (Names.end() !=
Match)
9860 }
while (DesugaredTy != Ty);
9899 "__cl_clang_non_portable_kernel_param_types", S.
getLangOpts())) {
9901 bool IsStandardLayoutType =
true;
9907 if (!CXXRec->hasDefinition())
9908 CXXRec = CXXRec->getTemplateInstantiationPattern();
9909 if (!CXXRec || !CXXRec->hasDefinition() || !CXXRec->isStandardLayout())
9910 IsStandardLayoutType =
false;
9913 !IsStandardLayoutType)
9961 "__cl_clang_non_portable_kernel_param_types", S.
getLangOpts()) &&
9975 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
9988 S.
Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
9997 S.
Diag(Param->getLocation(), diag::err_kernel_arg_address_space);
10014 S.
Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
10022 S.
Diag(Loc, diag::note_entity_declared_at) << PT;
10023 PT = Typedef->desugar();
10045 HistoryStack.push_back(
nullptr);
10050 VisitStack.push_back(PD);
10051 assert(VisitStack.back() &&
"First decl null?");
10054 const Decl *
Next = VisitStack.pop_back_val();
10056 assert(!HistoryStack.empty());
10058 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
10059 ValidTypes.insert(Hist->getType().getTypePtr());
10068 HistoryStack.push_back(Field);
10070 QualType FieldTy = Field->getType();
10074 "Unexpected type.");
10083 VisitStack.push_back(
nullptr);
10085 for (
const auto *FD : RD->
fields()) {
10096 VisitStack.push_back(FD);
10107 S.
Diag(Param->getLocation(),
10108 diag::err_record_with_pointers_kernel_param)
10112 S.
Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
10115 S.
Diag(PD->getLocation(), diag::note_within_field_of_type)
10116 << PD->getDeclName();
10121 I = HistoryStack.begin() + 1,
10122 E = HistoryStack.end();
10135 }
while (!VisitStack.empty());
10152 (LangOpts.CPlusPlus &&
10162 unsigned BuiltinID) {
10163 switch (BuiltinID) {
10164 case Builtin::BI__GetExceptionInfo:
10168 case Builtin::BIaddressof:
10169 case Builtin::BI__addressof:
10170 case Builtin::BIforward:
10171 case Builtin::BIforward_like:
10172 case Builtin::BImove:
10173 case Builtin::BImove_if_noexcept:
10174 case Builtin::BIas_const: {
10179 return FPT->
getNumParams() == 1 && !FPT->isVariadic();
10193 switch (FT->getCallConv()) {
10194#define CC_VLS_CASE(ABI_VLEN) \
10195 case CC_RISCVVLSCall_##ABI_VLEN: \
10196 Tag = "riscv_vls_cc_" #ABI_VLEN; \
10216 AbiTagAttr *Old = Existing.empty() ?
nullptr : Existing.front();
10220 llvm::append_range(Tags, Old->tags());
10221 if (llvm::is_contained(Tags, Tag))
10223 Tags.push_back(Tag);
10225 AbiTagAttr *Merged =
10226 Old ? AbiTagAttr::Create(
Context, Tags.data(), Tags.size(), *Old)
10227 : AbiTagAttr::CreateImplicit(
Context, Tags.data(), Tags.size(),
10231 for (
size_t I = 1, E = Existing.size(); I < E; ++I)
10239 bool &AddToScope) {
10242 assert(R->isFunctionType());
10247 llvm::append_range(TemplateParamLists, TemplateParamListsRef);
10249 if (!TemplateParamLists.empty() && !TemplateParamLists.back()->empty() &&
10250 Invented->getDepth() == TemplateParamLists.back()->getDepth())
10251 TemplateParamLists.back() = Invented;
10253 TemplateParamLists.push_back(Invented);
10263 diag::err_invalid_thread)
10271 bool isFriend =
false;
10273 bool isMemberSpecialization =
false;
10274 bool isFunctionTemplateSpecialization =
false;
10276 bool HasExplicitTemplateArgs =
false;
10279 bool isVirtualOkay =
false;
10286 if (!NewFD)
return nullptr;
10296 if (IsLocalExternDecl)
10306 bool ImplicitInlineCXX20 = !
getLangOpts().CPlusPlusModules ||
10334 if (isVirtual && Parent->isUnion()) {
10338 if ((Parent->isClass() || Parent->isStruct()) &&
10339 Parent->hasAttr<SYCLSpecialClassAttr>() &&
10342 if (
auto *Def = Parent->getDefinition())
10343 Def->setInitMethod(
true);
10348 isMemberSpecialization =
false;
10349 isFunctionTemplateSpecialization =
false;
10364 isMemberSpecialization,
Invalid);
10365 if (TemplateParams) {
10370 if (TemplateParams->
size() > 0) {
10378 }
else if (TemplateId) {
10395 Name, TemplateParams,
10401 if (TemplateParamLists.size() > 1) {
10408 isFunctionTemplateSpecialization =
true;
10410 if (TemplateParamLists.size() > 0)
10430 << Name << RemoveRange
10436 HasExplicitTemplateArgs =
true;
10443 if (!TemplateParamLists.empty() && isMemberSpecialization &&
10449 if (TemplateParamLists.size() > 0)
10454 if (isFriend && TemplateId)
10455 isFunctionTemplateSpecialization =
true;
10461 if (isFunctionTemplateSpecialization && TemplateId) {
10462 HasExplicitTemplateArgs =
true;
10493 if (!isVirtualOkay) {
10495 diag::err_virtual_non_function);
10499 diag::err_virtual_out_of_class)
10505 diag::err_virtual_member_function_template)
10524 diag::err_inline_declaration_block_scope) << Name
10538 diag::err_explicit_out_of_class)
10545 diag::err_explicit_non_ctor_or_conv_function)
10563 <<
static_cast<int>(ConstexprKind);
10574 diag::err_invalid_consteval_decl_kind)
10582 if (isFunctionTemplateSpecialization) {
10585 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
10631 if (!isFriend && SC !=
SC_None) {
10639 if (isFunctionTemplateSpecialization || isMemberSpecialization) {
10641 diag::ext_explicit_specialization_storage_class)
10648 "Out-of-line member function should be a CXXMethodDecl");
10665 ? diag::ext_static_out_of_line
10666 : diag::err_static_out_of_line)
10691 PendingInlineFuncDecls.insert(NewFD);
10698 isMemberSpecialization ||
10699 isFunctionTemplateSpecialization);
10710 llvm::MapVector<IdentifierInfo *, AsmLabelAttr *>::iterator I =
10737 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
10739 assert(Param->getDeclContext() != NewFD &&
"Was set before ?");
10740 Param->setDeclContext(NewFD);
10741 Params.push_back(Param);
10743 if (Param->isInvalidDecl())
10756 auto *TD = dyn_cast<TagDecl>(NonParmDecl);
10761 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
10766 DeclContext *TagDC = TD->getLexicalDeclContext();
10770 TD->setDeclContext(NewFD);
10778 if (TagDC != PrototypeTagContext)
10779 TD->setLexicalDeclContext(TagDC);
10793 for (
const auto &AI : FT->param_types()) {
10796 Param->setScopeInfo(0, Params.size());
10797 Params.push_back(Param);
10800 assert(R->isFunctionNoProtoType() && NewFD->
getNumParams() == 0 &&
10801 "Should not need args for typedef of non-prototype fn");
10805 NewFD->setParams(Params);
10830 !NewFD->
hasAttr<SectionAttr>())
10831 NewFD->
addAttr(PragmaClangTextSectionAttr::CreateImplicit(
10837 !NewFD->
hasAttr<SectionAttr>()) {
10838 NewFD->
addAttr(SectionAttr::CreateImplicit(
10840 CodeSegStack.CurrentPragmaLocation, SectionAttr::Declspec_allocate));
10851 !NewFD->
hasAttr<StrictGuardStackCheckAttr>())
10852 NewFD->
addAttr(StrictGuardStackCheckAttr::CreateImplicit(
10857 if (!NewFD->
hasAttr<CodeSegAttr>()) {
10867 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
10868 if (
Context.getTargetInfo().getTriple().isAArch64() && NewTVA &&
10869 !NewTVA->isDefaultVersion() &&
10870 !
Context.getTargetInfo().hasFeature(
"fmv")) {
10872 AddToScope =
false;
10884 Diag(NewFD->
getLocation(), diag::err_return_value_with_address_space);
10899 isMemberSpecialization,
10906 "previous declaration set still overloaded");
10918 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
10941 diag::ext_operator_new_delete_declared_inline)
10968 if (isFunctionTemplateSpecialization || isMemberSpecialization) {
10980 Diag(TRC->getBeginLoc(), diag::err_non_temp_spec_requires_clause)
10988 diag::err_non_temp_friend_decl_with_requires_clause_must_be_def);
10992 Diag(TRC->getBeginLoc(),
10993 diag::err_constrained_non_templated_function);
11010 if (isFunctionTemplateSpecialization) {
11011 bool isDependentSpecialization =
false;
11017 isDependentSpecialization =
11020 (HasExplicitTemplateArgs &&
11021 TemplateSpecializationType::
11022 anyInstantiationDependentTemplateArguments(
11024 assert((!isDependentSpecialization ||
11025 (HasExplicitTemplateArgs == isDependentSpecialization)) &&
11026 "dependent friend function specialization without template "
11032 isDependentSpecialization =
11037 HasExplicitTemplateArgs ? &TemplateArgs :
nullptr;
11038 if (isDependentSpecialization) {
11045 NewFD, ExplicitTemplateArgs,
Previous))
11066 isMemberSpecialization,
11075 "previous declaration set still overloaded");
11116 struct ActOnFDArgs ExtraArgs = { S, D, TemplateParamLists,
11162 *
this,
Previous, NewFD, ExtraArgs,
false,
nullptr)) {
11163 AddToScope = ExtraArgs.AddToScope;
11172 *
this,
Previous, NewFD, ExtraArgs,
true, S)) {
11173 AddToScope = ExtraArgs.AddToScope;
11179 !isFriend && !isFunctionTemplateSpecialization &&
11180 !isMemberSpecialization) {
11198 if (NewFD->
hasAttr<HLSLShaderAttr>())
11202 if (
const NoInlineAttr *NoInline = NewFD->
getAttr<NoInlineAttr>()) {
11204 QualType ParamTy = PVD->getType().getNonReferenceType();
11212 Diag(PVD->getLocation(),
11213 diag::err_hlsl_resource_param_in_noinline_function)
11215 Diag(NoInline->getLocation(), diag::note_attribute);
11225 if (
unsigned BuiltinID = II->getBuiltinID()) {
11226 bool InStdNamespace =
Context.BuiltinInfo.isInStdNamespace(BuiltinID);
11227 if (!InStdNamespace &&
11232 if (
Context.BuiltinInfo.allowTypeMismatch(BuiltinID)) {
11233 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
11240 Context.hasSameFunctionTypeIgnoringExceptionSpec(
11242 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
11247 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
11263 if (NewFD->
hasAttr<OverloadableAttr>() &&
11266 diag::err_attribute_overloadable_no_prototype)
11268 NewFD->
dropAttr<OverloadableAttr>();
11301 isMemberSpecialization ||
11302 isFunctionTemplateSpecialization,
11313 Context.setcudaConfigureCallDecl(NewFD);
11315 if (II->isStr(
CUDA().getGetParameterBufferFuncName()) &&
11321 Context.setcudaGetParameterBufferDecl(NewFD);
11323 if (II->isStr(
CUDA().getLaunchDeviceFuncName()) &&
11329 Context.setcudaLaunchDeviceDecl(NewFD);
11380 diag::err_friend_decl_with_enclosing_temp_constraint_must_be_def);
11400 if (
getLangOpts().getOpenCLCompatibleVersion() >= 200) {
11402 QualType ElemTy = PipeTy->getElementType();
11404 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type);
11410 if (
Context.getTargetInfo().getTriple().isWasm()) {
11412 Diag(Param->getTypeSpecStartLoc(),
11413 diag::err_wasm_table_as_function_parameter);
11421 if (
const auto *
attr = NewFD->
getAttr<AvailabilityAttr>()) {
11422 if (NewFD->
hasAttr<ConstructorAttr>()) {
11423 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
11425 NewFD->
dropAttr<AvailabilityAttr>();
11427 if (NewFD->
hasAttr<DestructorAttr>()) {
11428 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
11430 NewFD->
dropAttr<AvailabilityAttr>();
11441 if (
const auto *NBA = NewFD->
getAttr<NoBuiltinAttr>())
11445 Diag(NBA->getLocation(),
11446 diag::err_attribute_no_builtin_on_defaulted_deleted_function)
11447 << NBA->getSpelling();
11450 Diag(NBA->getLocation(), diag::err_attribute_no_builtin_on_non_definition)
11451 << NBA->getSpelling();
11460 if (
Context.getTargetInfo().allowDebugInfoForExternalRef() &&
11484 const auto *Method = dyn_cast<CXXMethodDecl>(FD);
11488 if (
const auto *SAttr = Parent->
getAttr<CodeSegAttr>()) {
11499 while ((Parent = dyn_cast<CXXRecordDecl>(Parent->
getParent()))) {
11500 if (
const auto *SAttr = Parent->
getAttr<CodeSegAttr>()) {
11510 bool IsDefinition) {
11513 if (!FD->
hasAttr<SectionAttr>() && IsDefinition &&
11515 return SectionAttr::CreateImplicit(
11517 CodeSegStack.CurrentPragmaLocation, SectionAttr::Declspec_allocate);
11565 auto *VD = dyn_cast<ValueDecl>(D);
11566 auto *PrevVD = dyn_cast<ValueDecl>(PrevDecl);
11567 return !VD || !PrevVD ||
11569 PrevVD->getType());
11577 const auto *TA = FD->
getAttr<TargetAttr>();
11578 const auto *TVA = FD->
getAttr<TargetVersionAttr>();
11580 assert((TA || TVA) &&
"Expecting target or target_version attribute");
11593 for (
const auto &Feat : ParseInfo.
Features) {
11594 auto BareFeat = StringRef{Feat}.substr(1);
11595 if (Feat[0] ==
'-') {
11597 <<
Feature << (
"no-" + BareFeat);
11617 for (
auto &Feat : ParseInfo.
Features)
11618 Feats.push_back(StringRef{Feat}.substr(1));
11621 TVA->getFeatures(Feats);
11623 for (
const auto &Feat : Feats) {
11643 case attr::ArmLocallyStreaming:
11648 case attr::NonNull:
11649 case attr::NoThrow:
11658 const auto Diagnose = [FD, CausedFD, MVKind](
Sema &S,
const Attr *A) {
11659 S.
Diag(FD->
getLocation(), diag::err_multiversion_disallowed_other_attr)
11660 <<
static_cast<unsigned>(MVKind) << A;
11662 S.
Diag(CausedFD->
getLocation(), diag::note_multiversioning_caused_here);
11667 switch (A->getKind()) {
11668 case attr::CPUDispatch:
11669 case attr::CPUSpecific:
11672 return Diagnose(S, A);
11676 return Diagnose(S, A);
11678 case attr::TargetVersion:
11681 return Diagnose(S, A);
11683 case attr::TargetClones:
11686 return Diagnose(S, A);
11690 return Diagnose(S, A);
11703 bool ConstexprSupported,
bool CLinkageMayDiffer) {
11704 enum DoesntSupport {
11711 DefaultedFuncs = 6,
11712 ConstexprFuncs = 7,
11713 ConstevalFuncs = 8,
11725 if (NoProtoDiagID.
getDiagID() != 0 && OldFD &&
11728 Diag(NoteCausedDiagIDAt.first, NoteCausedDiagIDAt.second);
11736 if (!TemplatesSupported &&
11738 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11741 if (
const auto *NewCXXFD = dyn_cast<CXXMethodDecl>(NewFD)) {
11742 if (NewCXXFD->isVirtual())
11743 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11747 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11751 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11756 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11760 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11764 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11765 << (NewFD->
isConsteval() ? ConstevalFuncs : ConstexprFuncs);
11769 QualType NewReturnType = NewType->getReturnType();
11772 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11785 bool ArmStreamingCCMismatched =
false;
11786 if (OldFPT && NewFPT) {
11793 ArmStreamingCCMismatched =
true;
11796 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC() || ArmStreamingCCMismatched)
11799 QualType OldReturnType = OldType->getReturnType();
11801 if (OldReturnType != NewReturnType)
11802 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ReturnType;
11805 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ConstexprSpec;
11808 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << InlineSpec;
11811 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) <<
Linkage;
11834 bool IsCPUSpecificCPUDispatchMVKind =
11838 if (CausesMV && OldFD &&
11846 if (OldFD && CausesMV && OldFD->
isUsed(
false)) {
11853 OldFD, NewFD, S.
PDiag(diag::err_multiversion_noproto),
11855 S.
PDiag(diag::note_multiversioning_caused_here)),
11857 S.
PDiag(diag::err_multiversion_doesnt_support)
11858 <<
static_cast<unsigned>(MVKind)),
11860 S.
PDiag(diag::err_multiversion_diff)),
11862 !IsCPUSpecificCPUDispatchMVKind,
11875 "Function lacks multiversion attribute");
11876 const auto *TA = FD->
getAttr<TargetAttr>();
11877 const auto *TVA = FD->
getAttr<TargetVersionAttr>();
11880 if (TA && !TA->isDefaultVersion())
11917 To->
addAttr(TargetVersionAttr::CreateImplicit(
11928 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11929 const auto *OldTA = OldFD->
getAttr<TargetAttr>();
11930 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11931 const auto *OldTVA = OldFD->
getAttr<TargetVersionAttr>();
11933 assert((NewTA || NewTVA) &&
"Excpecting target or target_version attribute");
11942 if (NewTA && !NewTA->isDefaultVersion() &&
11943 (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr()))
11960 if ((NewTA && NewTA->isDefaultVersion() && !OldTA) ||
11961 (NewTVA && NewTVA->isDefaultVersion() && !OldTVA)) {
11970 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
11978 OldTA->getFeaturesStr());
11982 NewTA->getFeaturesStr());
11985 if (OldParsed == NewParsed) {
11993 for (
const auto *FD : OldFD->
redecls()) {
11994 const auto *CurTA = FD->
getAttr<TargetAttr>();
11995 const auto *CurTVA = FD->
getAttr<TargetVersionAttr>();
11999 ((NewTA && (!CurTA || CurTA->isInherited())) ||
12000 (NewTVA && (!CurTVA || CurTVA->isInherited())))) {
12002 << (NewTA ? 0 : 2);
12003 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
12050 const CPUDispatchAttr *NewCPUDisp,
const CPUSpecificAttr *NewCPUSpec,
12066 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
12067 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
12074 NewTA->getFeaturesStr());
12079 NewTVA->getFeatures(NewFeats);
12080 llvm::sort(NewFeats);
12083 bool UseMemberUsingDeclRules =
12086 bool MayNeedOverloadableChecks =
12095 if (MayNeedOverloadableChecks &&
12096 S.
IsOverload(NewFD, CurFD, UseMemberUsingDeclRules))
12099 switch (NewMVKind) {
12102 "Only target_clones can be omitted in subsequent declarations");
12105 const auto *CurTA = CurFD->
getAttr<TargetAttr>();
12106 if (CurTA->getFeaturesStr() == NewTA->getFeaturesStr()) {
12115 CurTA->getFeaturesStr());
12117 if (CurParsed == NewParsed) {
12126 if (
const auto *CurTVA = CurFD->
getAttr<TargetVersionAttr>()) {
12127 if (CurTVA->getName() == NewTVA->getName()) {
12134 CurTVA->getFeatures(CurFeats);
12135 llvm::sort(CurFeats);
12137 if (CurFeats == NewFeats) {
12143 }
else if (
const auto *CurClones = CurFD->
getAttr<TargetClonesAttr>()) {
12145 if (NewFeats.empty())
12148 for (
unsigned I = 0; I < CurClones->featuresStrs_size(); ++I) {
12150 CurClones->getFeatures(CurFeats, I);
12151 llvm::sort(CurFeats);
12153 if (CurFeats == NewFeats) {
12164 assert(NewClones &&
"MultiVersionKind does not match attribute type");
12165 if (
const auto *CurClones = CurFD->
getAttr<TargetClonesAttr>()) {
12166 if (CurClones->featuresStrs_size() != NewClones->featuresStrs_size() ||
12167 !std::equal(CurClones->featuresStrs_begin(),
12168 CurClones->featuresStrs_end(),
12169 NewClones->featuresStrs_begin())) {
12175 }
else if (
const auto *CurTVA = CurFD->
getAttr<TargetVersionAttr>()) {
12177 CurTVA->getFeatures(CurFeats);
12178 llvm::sort(CurFeats);
12181 if (CurFeats.empty())
12184 for (
unsigned I = 0; I < NewClones->featuresStrs_size(); ++I) {
12186 NewClones->getFeatures(NewFeats, I);
12187 llvm::sort(NewFeats);
12189 if (CurFeats == NewFeats) {
12205 const auto *CurCPUSpec = CurFD->
getAttr<CPUSpecificAttr>();
12206 const auto *CurCPUDisp = CurFD->
getAttr<CPUDispatchAttr>();
12211 CurFD->
hasAttr<CPUDispatchAttr>()) {
12212 if (CurCPUDisp->cpus_size() == NewCPUDisp->cpus_size() &&
12214 CurCPUDisp->cpus_begin(), CurCPUDisp->cpus_end(),
12215 NewCPUDisp->cpus_begin(),
12217 return Cur->getName() == New->getName();
12232 if (CurCPUSpec->cpus_size() == NewCPUSpec->cpus_size() &&
12234 CurCPUSpec->cpus_begin(), CurCPUSpec->cpus_end(),
12235 NewCPUSpec->cpus_begin(),
12237 return Cur->getName() == New->getName();
12248 if (CurII == NewII) {
12318 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
12319 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
12320 const auto *NewCPUDisp = NewFD->
getAttr<CPUDispatchAttr>();
12321 const auto *NewCPUSpec = NewFD->
getAttr<CPUSpecificAttr>();
12322 const auto *NewClones = NewFD->
getAttr<TargetClonesAttr>();
12332 NewTVA->isDefaultVersion())) {
12333 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_not_allowed_on_main);
12341 if (NewTA && TI.
getTriple().isAArch64())
12368 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_required_in_redecl)
12381 if (OldFD->
isUsed(
false)) {
12383 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
12405 bool IsPure = NewFD->
hasAttr<PureAttr>();
12406 bool IsConst = NewFD->
hasAttr<ConstAttr>();
12409 if (!IsPure && !IsConst)
12416 if (IsPure && IsConst) {
12426 NewFD->
dropAttrs<PureAttr, ConstAttr>();
12432 bool IsMemberSpecialization,
12435 "Variably modified return types are not handled here");
12440 bool MergeTypeWithPrevious = !
getLangOpts().CPlusPlus &&
12445 bool MayNeedOverloadableChecks =
false;
12457 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
12459 OldDecl = Candidate;
12462 MayNeedOverloadableChecks =
true;
12487 OldDecl =
Previous.getFoundDecl();
12488 MergeTypeWithPrevious =
false;
12491 if (OldDecl->
hasAttr<OverloadableAttr>() ||
12492 NewFD->
hasAttr<OverloadableAttr>()) {
12494 MayNeedOverloadableChecks =
true;
12506 if (
Context.getTargetInfo().getTriple().isPPC64() &&
12557 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
12558 if (!OldMD || !OldMD->
isStatic()) {
12593 dyn_cast<FunctionTemplateDecl>(OldDecl)) {
12594 auto *OldFD = OldTemplateDecl->getTemplatedDecl();
12597 assert(NewTemplateDecl &&
"Template/non-template mismatch");
12606 NewFD->
setAccess(OldTemplateDecl->getAccess());
12607 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
12612 if (IsMemberSpecialization &&
12615 assert(OldTemplateDecl->isMemberSpecialization());
12618 if (OldFD->isDeleted()) {
12620 assert(OldFD->getCanonicalDecl() == OldFD);
12622 OldFD->setDeletedAsWritten(
false);
12636 !NewFD->
getAttr<OverloadableAttr>()) {
12640 return ND->hasAttr<OverloadableAttr>();
12642 "Non-redecls shouldn't happen without overloadable present");
12645 const auto *FD = dyn_cast<FunctionDecl>(ND);
12646 return FD && !FD->
hasAttr<OverloadableAttr>();
12649 if (OtherUnmarkedIter !=
Previous.end()) {
12651 diag::err_attribute_overloadable_multiple_unmarked_overloads);
12652 Diag((*OtherUnmarkedIter)->getLocation(),
12653 diag::note_attribute_overloadable_prev_overload)
12663 if (NewFD->
hasAttr<SYCLKernelEntryPointAttr>())
12666 if (NewFD->
hasAttr<SYCLExternalAttr>())
12676 dyn_cast<CXXDestructorDecl>(NewFD)) {
12684 (!
Destructor->getFunctionObjectParameterType()->isDependentType() &&
12685 !
Destructor->getDeclName().isDependentName())) {
12690 Context.DeclarationNames.getCXXDestructorName(ClassType);
12697 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
12698 if (
auto *TD = Guide->getDescribedFunctionTemplate())
12704 Diag(Guide->getBeginLoc(), diag::err_deduction_guide_specialized)
12710 if (!
Method->isFunctionTemplateSpecialization() &&
12711 !
Method->getDescribedFunctionTemplate() &&
12712 Method->isCanonicalDecl()) {
12719 diag::err_constrained_virtual_method);
12754 if (R->isIncompleteType() && !R->isVoidType())
12757 else if (!R.isPODType(
Context) && !R->isVoidType() &&
12758 !R->isObjCObjectPointerType())
12759 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
12772 auto HasNoexcept = [&](
QualType T) ->
bool {
12777 T = RT->getPointeeType();
12778 else if (
T->isAnyPointerType())
12779 T =
T->getPointeeType();
12781 T = MPT->getPointeeType();
12783 if (FPT->isNothrow())
12789 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
12791 AnyNoexcept |= HasNoexcept(
T);
12794 diag::warn_cxx17_compat_exception_spec_in_signature)
12799 bool IsKernel = NewFD->
hasAttr<CUDAGlobalAttr>();
12801 if (!Parm->getType()->isDependentType() &&
12802 Parm->hasAttr<CUDAGridConstantAttr>() &&
12803 !(IsKernel && Parm->getType().isConstQualified()))
12804 Diag(Parm->getAttr<CUDAGridConstantAttr>()->getLocation(),
12805 diag::err_cuda_grid_constant_not_allowed);
12811 if (DeclIsDefn &&
Context.getTargetInfo().getTriple().isAArch64())
12821 Diag(FD->
getLocation(), diag::ext_main_invalid_linkage_specification);
12832 ? diag::err_static_main : diag::warn_static_main)
12840 Diag(NoreturnLoc, diag::ext_noreturn_main);
12841 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
12853 << FD->
hasAttr<DeviceKernelAttr>();
12858 if (FD->
hasAttr<SYCLExternalAttr>()) {
12860 << FD->
getAttr<SYCLExternalAttr>();
12871 assert(
T->isFunctionType() &&
"function decl is not of function type");
12893 Diag(RTRange.
getBegin(), diag::note_main_change_return_type)
12918 Diag(start, diag::warn_main_in_named_module)
12930 bool HasExtraParameters = (nparams > 3);
12941 if (nparams == 4 &&
Context.getTargetInfo().getTriple().isOSDarwin())
12942 HasExtraParameters =
false;
12944 if (HasExtraParameters) {
12957 for (
unsigned i = 0; i < nparams; ++i) {
12960 bool mismatch =
true;
12977 mismatch = !qs.
empty();
13006 if (
T.isOSCygMing())
13011 if (
T.isOSWindows() &&
T.getArch() == llvm::Triple::x86)
13019 assert(
T->isFunctionType() &&
"function decl is not of function type");
13028 if (FD->
getName() !=
"DllMain")
13035 FT =
Context.adjustFunctionType(
13040 FT =
Context.adjustFunctionType(FT,
13062 if (
Init->isValueDependent()) {
13063 assert(
Init->containsErrors() &&
13064 "Dependent code should only occur in error-recovery path.");
13067 const Expr *Culprit;
13068 if (
Init->isConstantInitializer(
Context,
false, &Culprit))
13092 if (
const auto *ALE = dyn_cast<ObjCArrayLiteral>(CulpritLiteral)) {
13093 for (
const Expr *Elm : ALE->elements()) {
13095 !Elm->isConstantInitializer(
Context)) {
13096 Diag(Elm->getExprLoc(),
13097 diag::err_objc_literal_nonconstant_at_file_scope)
13104 if (
const auto *DLE = dyn_cast<ObjCDictionaryLiteral>(CulpritLiteral)) {
13105 for (
size_t I = 0, N = DLE->getNumElements(); I != N; ++I) {
13112 diag::err_objc_literal_nonconstant_at_file_scope)
13121 diag::err_objc_literal_nonconstant_at_file_scope)
13129 diag::err_objc_literal_nonconstant_at_file_scope)
13141 class SelfReferenceChecker
13147 bool isReferenceType;
13148 bool isInCXXOperatorCall;
13156 SelfReferenceChecker(
Sema &S,
Decl *OrigDecl) : Inherited(S.Context),
13157 S(S), OrigDecl(OrigDecl) {
13160 isReferenceType =
false;
13161 isInCXXOperatorCall =
false;
13162 isInitList =
false;
13163 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
13164 isPODType = VD->getType().isPODType(S.
Context);
13166 isReferenceType = VD->getType()->isReferenceType();
13173 void CheckExpr(Expr *E) {
13174 InitListExpr *InitList = dyn_cast<InitListExpr>(E);
13182 InitFieldIndex.push_back(0);
13183 for (
auto *Child : InitList->
children()) {
13185 ++InitFieldIndex.back();
13187 InitFieldIndex.pop_back();
13192 bool CheckInitListMemberExpr(MemberExpr *E,
bool CheckReference) {
13193 llvm::SmallVector<FieldDecl*, 4> Fields;
13195 bool ReferenceField =
false;
13198 while (MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
13199 FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl());
13202 Fields.push_back(FD);
13204 ReferenceField =
true;
13205 Base = ME->getBase()->IgnoreParenImpCasts();
13209 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base);
13210 if (!DRE || DRE->
getDecl() != OrigDecl)
13214 if (CheckReference && !ReferenceField)
13218 llvm::SmallVector<unsigned, 4> UsedFieldIndex;
13219 for (
const FieldDecl *I : llvm::reverse(Fields))
13220 UsedFieldIndex.push_back(I->getFieldIndex());
13225 for (
auto UsedIter = UsedFieldIndex.begin(),
13226 UsedEnd = UsedFieldIndex.end(),
13227 OrigIter = InitFieldIndex.begin(),
13228 OrigEnd = InitFieldIndex.end();
13229 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
13230 if (*UsedIter < *OrigIter)
13232 if (*UsedIter > *OrigIter)
13237 HandleDeclRefExpr(DRE);
13244 void HandleValue(Expr *E) {
13246 if (DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
13247 HandleDeclRefExpr(DRE);
13251 if (ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E)) {
13252 Visit(CO->getCond());
13253 HandleValue(CO->getTrueExpr());
13254 HandleValue(CO->getFalseExpr());
13258 if (BinaryConditionalOperator *BCO =
13259 dyn_cast<BinaryConditionalOperator>(E)) {
13260 Visit(BCO->getCond());
13261 HandleValue(BCO->getFalseExpr());
13265 if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E)) {
13266 if (Expr *SE = OVE->getSourceExpr())
13271 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
13272 if (BO->getOpcode() == BO_Comma) {
13273 Visit(BO->getLHS());
13274 HandleValue(BO->getRHS());
13287 while (MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
13291 Base = ME->getBase()->IgnoreParenImpCasts();
13293 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base))
13294 HandleDeclRefExpr(DRE);
13303 void VisitDeclRefExpr(DeclRefExpr *E) {
13304 if (isReferenceType)
13305 HandleDeclRefExpr(E);
13308 void VisitImplicitCastExpr(ImplicitCastExpr *E) {
13314 Inherited::VisitImplicitCastExpr(E);
13317 void VisitMemberExpr(MemberExpr *E) {
13319 if (CheckInitListMemberExpr(E,
true ))
13328 CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(E->
getMemberDecl());
13329 bool Warn = (MD && !MD->
isStatic());
13331 while (MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
13334 Base = ME->getBase()->IgnoreParenImpCasts();
13337 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
13339 HandleDeclRefExpr(DRE);
13348 void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
13349 llvm::SaveAndRestore CxxOpCallScope(isInCXXOperatorCall,
true);
13353 return Inherited::VisitCXXOperatorCallExpr(E);
13357 HandleValue(Arg->IgnoreParenImpCasts());
13361 if (!isInCXXOperatorCall) {
13362 Inherited::VisitLambdaExpr(E);
13367 if (DeclRefExpr *DRE = dyn_cast_if_present<DeclRefExpr>(
Init))
13368 HandleDeclRefExpr(DRE);
13373 void VisitUnaryOperator(UnaryOperator *E) {
13387 Inherited::VisitUnaryOperator(E);
13390 void VisitObjCMessageExpr(ObjCMessageExpr *E) {}
13392 void VisitCXXConstructExpr(CXXConstructExpr *E) {
13394 Expr *ArgExpr = E->
getArg(0);
13395 if (InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
13396 if (ILE->getNumInits() == 1)
13397 ArgExpr = ILE->getInit(0);
13398 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(ArgExpr))
13399 if (ICE->getCastKind() == CK_NoOp)
13400 ArgExpr = ICE->getSubExpr();
13401 HandleValue(ArgExpr);
13404 Inherited::VisitCXXConstructExpr(E);
13407 void VisitCallExpr(CallExpr *E) {
13410 HandleValue(E->
getArg(0));
13414 Inherited::VisitCallExpr(E);
13417 void VisitBinaryOperator(BinaryOperator *E) {
13419 HandleValue(E->
getLHS());
13424 Inherited::VisitBinaryOperator(E);
13430 void VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
13435 void HandleDeclRefExpr(DeclRefExpr *DRE) {
13437 if (OrigDecl != ReferenceDecl)
return;
13439 if (isReferenceType) {
13440 diag = diag::warn_uninit_self_reference_in_reference_init;
13442 diag = diag::warn_static_self_reference_in_init;
13446 diag = diag::warn_uninit_self_reference_in_init;
13460 static void CheckSelfReference(Sema &S, Decl* OrigDecl, Expr *E,
13470 if (
auto *VD = dyn_cast<VarDecl>(OrigDecl);
13471 VD && VD->isConstexpr() && VD->isFileVarDecl())
13479 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
13480 if (ICE->getCastKind() == CK_LValueToRValue)
13481 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
13482 if (DRE->
getDecl() == OrigDecl)
13485 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
13492 struct VarDeclOrName {
13494 DeclarationName Name;
13496 friend const Sema::SemaDiagnosticBuilder &
13497 operator<<(
const Sema::SemaDiagnosticBuilder &
Diag, VarDeclOrName VN) {
13498 return VN.VDecl ?
Diag << VN.VDecl :
Diag << VN.Name;
13508 bool IsInitCapture = !VDecl;
13510 "init captures are expected to be deduced prior to initialization");
13512 VarDeclOrName VN{VDecl, Name};
13515 assert(
Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
13519 !isa_and_present<StringLiteral, InitListExpr>(
Init)) {
13520 Diag(Range.getBegin(), diag::err_auto_not_allowed)
13521 << (int)
Deduced->getContainedAutoType()->getKeyword()
13528 assert(VDecl &&
"no init for init capture deduction?");
13543 DeduceInits =
Init;
13545 auto *PL = dyn_cast_if_present<ParenListExpr>(
Init);
13547 DeduceInits = PL->exprs();
13550 assert(VDecl &&
"non-auto type for init capture deduction?");
13561 if (
auto *IL = dyn_cast<InitListExpr>(
Init))
13562 DeduceInits = IL->inits();
13566 if (DeduceInits.empty()) {
13569 Diag(
Init->getBeginLoc(), IsInitCapture
13570 ? diag::err_init_capture_no_expression
13571 : diag::err_auto_var_init_no_expression)
13572 << VN <<
Type << Range;
13576 if (DeduceInits.size() > 1) {
13577 Diag(DeduceInits[1]->getBeginLoc(),
13578 IsInitCapture ? diag::err_init_capture_multiple_expressions
13579 : diag::err_auto_var_init_multiple_expressions)
13580 << VN <<
Type << Range;
13584 Expr *DeduceInit = DeduceInits[0];
13586 Diag(
Init->getBeginLoc(), IsInitCapture
13587 ? diag::err_init_capture_paren_braces
13588 : diag::err_auto_var_init_paren_braces)
13594 bool DefaultedAnyToId =
false;
13596 Init->getType() ==
Context.UnknownAnyTy && !IsInitCapture) {
13598 if (
Result.isInvalid()) {
13602 DefaultedAnyToId =
true;
13612 Type.getQualifiers());
13620 if (!IsInitCapture)
13623 Diag(Range.getBegin(),
13624 diag::err_init_capture_deduction_failure_from_init_list)
13630 Diag(Range.getBegin(), diag::err_init_capture_deduction_failure)
13645 Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
13648 return DeducedType;
13653 assert(!
Init || !
Init->containsErrors());
13657 if (DeducedType.
isNull()) {
13666 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(VDecl))
13690 if (
auto *EWC = dyn_cast<ExprWithCleanups>(
Init))
13691 Init = EWC->getSubExpr();
13693 if (
auto *CE = dyn_cast<ConstantExpr>(
Init))
13694 Init = CE->getSubExpr();
13699 "shouldn't be called if type doesn't have a non-trivial C struct");
13700 if (
auto *ILE = dyn_cast<InitListExpr>(
Init)) {
13701 for (
auto *I : ILE->inits()) {
13702 if (!I->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion() &&
13703 !I->getType().hasNonTrivialToPrimitiveCopyCUnion())
13729bool shouldIgnoreForRecordTriviality(
const FieldDecl *FD) {
13735 return FD->
hasAttr<UnavailableAttr>();
13738struct DiagNonTrivalCUnionDefaultInitializeVisitor
13745 DiagNonTrivalCUnionDefaultInitializeVisitor(
13748 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13751 const FieldDecl *FD,
bool InNonTrivialUnion) {
13754 InNonTrivialUnion);
13755 return Super::visitWithKind(PDIK, QT, FD, InNonTrivialUnion);
13758 void visitARCStrong(QualType QT,
const FieldDecl *FD,
13759 bool InNonTrivialUnion) {
13760 if (InNonTrivialUnion)
13762 << 1 << 0 << QT << FD->
getName();
13765 void visitARCWeak(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13766 if (InNonTrivialUnion)
13768 << 1 << 0 << QT << FD->
getName();
13771 void visitStruct(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13773 if (RD->isUnion()) {
13774 if (OrigLoc.isValid()) {
13775 bool IsUnion =
false;
13776 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13777 IsUnion = OrigRD->isUnion();
13778 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13779 << 0 << OrigTy << IsUnion << UseContext;
13781 OrigLoc = SourceLocation();
13783 InNonTrivialUnion =
true;
13786 if (InNonTrivialUnion)
13787 S.
Diag(RD->getLocation(), diag::note_non_trivial_c_union)
13790 for (
const FieldDecl *FD : RD->fields())
13791 if (!shouldIgnoreForRecordTriviality(FD))
13792 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13795 void visitTrivial(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {}
13800 SourceLocation OrigLoc;
13805struct DiagNonTrivalCUnionDestructedTypeVisitor
13808 DestructedTypeVisitor<DiagNonTrivalCUnionDestructedTypeVisitor, void>;
13810 DiagNonTrivalCUnionDestructedTypeVisitor(QualType OrigTy,
13811 SourceLocation OrigLoc,
13814 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13817 const FieldDecl *FD,
bool InNonTrivialUnion) {
13820 InNonTrivialUnion);
13821 return Super::visitWithKind(DK, QT, FD, InNonTrivialUnion);
13824 void visitARCStrong(QualType QT,
const FieldDecl *FD,
13825 bool InNonTrivialUnion) {
13826 if (InNonTrivialUnion)
13828 << 1 << 1 << QT << FD->
getName();
13831 void visitARCWeak(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13832 if (InNonTrivialUnion)
13834 << 1 << 1 << QT << FD->
getName();
13837 void visitStruct(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13839 if (RD->isUnion()) {
13840 if (OrigLoc.isValid()) {
13841 bool IsUnion =
false;
13842 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13843 IsUnion = OrigRD->isUnion();
13844 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13845 << 1 << OrigTy << IsUnion << UseContext;
13847 OrigLoc = SourceLocation();
13849 InNonTrivialUnion =
true;
13852 if (InNonTrivialUnion)
13853 S.
Diag(RD->getLocation(), diag::note_non_trivial_c_union)
13856 for (
const FieldDecl *FD : RD->fields())
13857 if (!shouldIgnoreForRecordTriviality(FD))
13858 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13861 void visitTrivial(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {}
13862 void visitCXXDestructor(QualType QT,
const FieldDecl *FD,
13863 bool InNonTrivialUnion) {}
13868 SourceLocation OrigLoc;
13873struct DiagNonTrivalCUnionCopyVisitor
13875 using Super = CopiedTypeVisitor<DiagNonTrivalCUnionCopyVisitor, false, void>;
13877 DiagNonTrivalCUnionCopyVisitor(QualType OrigTy, SourceLocation OrigLoc,
13879 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13882 const FieldDecl *FD,
bool InNonTrivialUnion) {
13885 InNonTrivialUnion);
13886 return Super::visitWithKind(PCK, QT, FD, InNonTrivialUnion);
13889 void visitARCStrong(QualType QT,
const FieldDecl *FD,
13890 bool InNonTrivialUnion) {
13891 if (InNonTrivialUnion)
13893 << 1 << 2 << QT << FD->
getName();
13896 void visitARCWeak(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13897 if (InNonTrivialUnion)
13899 << 1 << 2 << QT << FD->
getName();
13902 void visitStruct(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13904 if (RD->isUnion()) {
13905 if (OrigLoc.isValid()) {
13906 bool IsUnion =
false;
13907 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13908 IsUnion = OrigRD->isUnion();
13909 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13910 << 2 << OrigTy << IsUnion << UseContext;
13912 OrigLoc = SourceLocation();
13914 InNonTrivialUnion =
true;
13917 if (InNonTrivialUnion)
13918 S.
Diag(RD->getLocation(), diag::note_non_trivial_c_union)
13921 for (
const FieldDecl *FD : RD->fields())
13922 if (!shouldIgnoreForRecordTriviality(FD))
13923 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13926 void visitPtrAuth(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {
13927 if (InNonTrivialUnion)
13929 << 1 << 2 << QT << FD->
getName();
13933 const FieldDecl *FD,
bool InNonTrivialUnion) {}
13934 void visitTrivial(QualType QT,
const FieldDecl *FD,
bool InNonTrivialUnion) {}
13935 void visitVolatileTrivial(QualType QT,
const FieldDecl *FD,
13936 bool InNonTrivialUnion) {}
13941 SourceLocation OrigLoc;
13950 unsigned NonTrivialKind) {
13954 "shouldn't be called if type doesn't have a non-trivial C union");
13958 DiagNonTrivalCUnionDefaultInitializeVisitor(QT, Loc, UseContext, *
this)
13959 .visit(QT,
nullptr,
false);
13962 DiagNonTrivalCUnionDestructedTypeVisitor(QT, Loc, UseContext, *
this)
13963 .visit(QT,
nullptr,
false);
13965 DiagNonTrivalCUnionCopyVisitor(QT, Loc, UseContext, *
this)
13966 .visit(QT,
nullptr,
false);
13990 bool TargetIsInline = Dcl->
isInline();
13991 bool TargetWasTemplated =
14008 TargetWasTemplated =
14018 if (!TargetIsInline || TargetWasTemplated)
14028 if (
Context.getTargetInfo().shouldDLLImportComdatSymbols()) {
14029 if (
Target->hasAttr<DLLExportAttr>() ||
Target->hasAttr<DLLImportAttr>())
14035 dyn_cast<CXXRecordDecl>(
Target->getDeclContext());
14036 if (Ctx && (Ctx->
hasAttr<DLLExportAttr>() || Ctx->
hasAttr<DLLImportAttr>()))
14058 T =
T.getNonReferenceType();
14059 if (
T->isFunctionType())
14061 if (!
T.isConstant(Ctx))
14063 if (
T->isPointerType())
14081 Diag(VD->
getLocation(), diag::warn_possible_object_duplication_mutable)
14082 << VD <<
Context.getTargetInfo().shouldDLLImportComdatSymbols();
14094 Diag(
Init->getExprLoc(), diag::warn_possible_object_duplication_init)
14095 << VD <<
Context.getTargetInfo().shouldDLLImportComdatSymbols();
14101 llvm::scope_exit ResetDeclForInitializer([
this]() {
14112 if (
auto *
Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
14113 if (!
Method->isInvalidDecl()) {
14115 Diag(
Method->getLocation(), diag::err_member_function_initialization)
14116 <<
Method->getDeclName() <<
Init->getSourceRange();
14117 Method->setInvalidDecl();
14122 VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl);
14124 assert(!
isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
14133 if (
Expr *E = Recovery.
get())
14140 Context.AMDGPUFeaturePredicateTy) {
14142 diag::err_amdgcn_predicate_type_is_not_constructible)
14149 if (!
Init->getType().isNull() &&
Init->getType()->isWebAssemblyTableType()) {
14150 Diag(
Init->getExprLoc(), diag::err_wasm_table_art) << 0;
14157 if (
Init->containsErrors()) {
14166 "decl should be invalidated when deduce fails");
14178 if (VDecl->
hasAttr<HLSLGroupSharedAddressSpaceAttr>()) {
14185 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
14205 if (
const ArrayType *Array =
Context.getAsIncompleteArrayType(BaseDeclType))
14206 BaseDeclType = Array->getElementType();
14208 diag::err_typecheck_decl_incomplete_type)) {
14215 diag::err_abstract_type_in_decl,
14233 !(VDecl->
hasAttr<SelectAnyAttr>() || VDecl->
hasAttr<WeakAttr>())) {
14242 if (Def != VDecl &&
14262 Diag(
Init->getExprLoc(), diag::err_static_data_member_reinitialization)
14265 diag::note_previous_initializer)
14290 if (VDecl->
hasAttr<LoaderUninitializedAttr>()) {
14291 Diag(VDecl->
getLocation(), diag::err_loader_uninitialized_cant_init);
14297 if (!
HLSL().handleInitialization(VDecl,
Init))
14309 if (!
Result.isUsable()) {
14317 bool InitializedFromParenListExpr =
false;
14318 bool IsParenListInit =
false;
14325 if (
auto *CXXDirectInit = dyn_cast<ParenListExpr>(
Init)) {
14327 MultiExprArg(CXXDirectInit->getExprs(), CXXDirectInit->getNumExprs());
14328 InitializedFromParenListExpr =
true;
14329 }
else if (
auto *CXXDirectInit = dyn_cast<CXXParenListInitExpr>(
Init)) {
14330 Args = CXXDirectInit->getInitExprs();
14331 InitializedFromParenListExpr =
true;
14338 if (!
Result.isUsable()) {
14358 IsParenListInit = !InitSeq.
steps().empty() &&
14362 if (!
Init->getType().isNull() && !
Init->getType()->isDependentType() &&
14364 Context.getAsIncompleteArrayType(VDeclType) &&
14365 Context.getAsIncompleteArrayType(
Init->getType())) {
14394 if (VDecl->
hasAttr<BlocksAttr>())
14407 !
Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
14408 Init->getBeginLoc()))
14409 FSI->markSafeWeakUse(
Init);
14430 if (!
Result.isUsable()) {
14470 if (
auto *E = dyn_cast<ExprWithCleanups>(
Init))
14471 if (
auto *BE = dyn_cast<BlockExpr>(E->getSubExpr()->
IgnoreParens()))
14473 BE->getBlockDecl()->setCanAvoidCopyToHeap();
14508 <<
Init->getSourceRange();
14524 diag::ext_in_class_initializer_float_type_cxx11)
14525 << DclT <<
Init->getSourceRange();
14527 diag::note_in_class_initializer_float_type_cxx11)
14530 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
14531 << DclT <<
Init->getSourceRange();
14534 Diag(
Init->getExprLoc(), diag::err_in_class_initializer_non_constant)
14535 <<
Init->getSourceRange();
14542 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
14543 << DclT <<
Init->getSourceRange()
14549 << DclT <<
Init->getSourceRange();
14562 !
Context.getBaseElementType(VDecl->
getType()).isConstQualified()) &&
14570 if (
Context.getTargetInfo().getCXXABI().isMicrosoft() &&
14583 if (!InitType.
isNull() &&
14601 if (InitializedFromParenListExpr) {
14602 assert(
DirectInit &&
"Call-style initializer must be direct init.");
14625 VarDecl *VD = dyn_cast<VarDecl>(D);
14629 if (
auto *DD = dyn_cast<DecompositionDecl>(D))
14630 for (
auto *BD : DD->bindings())
14631 BD->setInvalidDecl();
14644 Context.getBaseElementType(Ty),
14645 diag::err_typecheck_decl_incomplete_type)) {
14652 diag::err_abstract_type_in_decl,
14667 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
14671 Diag(Var->getLocation(),
14672 diag::err_amdgcn_predicate_type_is_not_constructible)
14674 Var->setInvalidDecl();
14683 dyn_cast<DecompositionDecl>(RealDecl)->getRSquareLoc();
14685 RSquareLoc,
PP.getSourceManager(),
PP.getLangOpts()))
14686 Loc =
Next->getLocation();
14687 Diag(Loc, diag::err_decomp_decl_requires_init) << Var;
14688 Var->setInvalidDecl();
14704 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
14705 !Var->isThisDeclarationADemotedDefinition()) {
14706 if (Var->isStaticDataMember()) {
14710 !
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
14711 Diag(Var->getLocation(),
14712 diag::err_constexpr_static_mem_var_requires_init)
14714 Var->setInvalidDecl();
14718 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
14719 Var->setInvalidDecl();
14726 if (!Var->isInvalidDecl() &&
14728 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
14729 bool HasConstExprDefaultConstructor =
false;
14730 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
14731 for (
auto *Ctor : RD->ctors()) {
14732 if (Ctor->isConstexpr() && Ctor->getNumParams() == 0 &&
14733 Ctor->getMethodQualifiers().getAddressSpace() ==
14735 HasConstExprDefaultConstructor =
true;
14739 if (!HasConstExprDefaultConstructor) {
14740 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
14741 Var->setInvalidDecl();
14747 if (!Var->isInvalidDecl() && Var->hasAttr<HLSLVkConstantIdAttr>()) {
14748 Diag(Var->getLocation(), diag::err_specialization_const);
14749 Var->setInvalidDecl();
14753 if (!Var->isInvalidDecl() && RealDecl->
hasAttr<LoaderUninitializedAttr>()) {
14754 if (Var->getStorageClass() ==
SC_Extern) {
14755 Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
14757 Var->setInvalidDecl();
14761 diag::err_typecheck_decl_incomplete_type)) {
14762 Var->setInvalidDecl();
14765 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
14766 if (!RD->hasTrivialDefaultConstructor()) {
14767 Diag(Var->getLocation(), diag::err_loader_uninitialized_trivial_ctor);
14768 Var->setInvalidDecl();
14778 Var->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion())
14785 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
14801 !Var->hasLinkage() && !Var->isInvalidDecl() &&
14803 diag::err_typecheck_decl_incomplete_type))
14804 Var->setInvalidDecl();
14809 diag::err_abstract_type_in_decl,
14811 Var->setInvalidDecl();
14814 Diag(Var->getLocation(), diag::warn_private_extern);
14815 Diag(Var->getLocation(), diag::note_private_extern);
14818 if (
Context.getTargetInfo().allowDebugInfoForExternalRef() &&
14819 !Var->isInvalidDecl())
14830 if (!Var->isInvalidDecl()) {
14834 Var->getLocation(), ArrayT->getElementType(),
14835 diag::err_array_incomplete_or_sizeless_type))
14836 Var->setInvalidDecl();
14838 if (Var->getStorageClass() ==
SC_Static) {
14848 if (Var->isFirstDecl())
14850 diag::ext_typecheck_decl_incomplete_type,
14856 if (!Var->isInvalidDecl())
14867 if (Var->isConstexpr())
14868 Diag(Var->getLocation(), diag::err_constexpr_var_requires_const_init)
14871 Diag(Var->getLocation(),
14872 diag::err_typecheck_incomplete_array_needs_initializer);
14873 Var->setInvalidDecl();
14880 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
14881 << Var <<
SourceRange(Var->getLocation(), Var->getLocation());
14890 if (Var->isInvalidDecl())
14893 if (!Var->hasAttr<AliasAttr>()) {
14896 diag::err_typecheck_decl_incomplete_type)) {
14897 Var->setInvalidDecl();
14906 diag::err_abstract_type_in_decl,
14908 Var->setInvalidDecl();
14915 unsigned DiagID = diag::warn_default_init_const_unsafe;
14916 if (Var->getStorageDuration() ==
SD_Static ||
14917 Var->getStorageDuration() ==
SD_Thread)
14918 DiagID = diag::warn_default_init_const;
14920 bool EmitCppCompat = !
Diags.isIgnored(
14921 diag::warn_cxx_compat_hack_fake_diagnostic_do_not_emit,
14922 Var->getLocation());
14924 Diag(Var->getLocation(), DiagID) <<
Type << EmitCppCompat;
14938 if (
const auto *CXXRecord =
14939 Context.getBaseElementType(
Type)->getAsCXXRecordDecl()) {
14943 if (!CXXRecord->isPOD())
14988 }
else if (
Init.isInvalid()) {
15006 VarDecl *VD = dyn_cast<VarDecl>(D);
15009 << InExpansionStmt;
15051 << InExpansionStmt << VD <<
Error;
15066 const char *PrevSpec;
15091 Context.getAttributedType(
Attr, MethodType, MethodType);
15102 if (var->isInvalidDecl())
return;
15109 if (var->getTypeSourceInfo()->getType()->isBlockPointerType() &&
15111 Diag(var->getLocation(), diag::err_opencl_invalid_block_declaration)
15113 var->setInvalidDecl();
15121 var->hasLocalStorage()) {
15122 switch (var->getType().getObjCLifetime()) {
15135 if (var->hasLocalStorage() &&
15144 if (var->isThisDeclarationADefinition() &&
15145 var->getDeclContext()->getRedeclContext()->isFileContext() &&
15146 var->isExternallyVisible() && var->hasLinkage() &&
15147 !var->isInline() && !var->getDescribedVarTemplate() &&
15151 !
getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
15152 var->getLocation())) {
15154 VarDecl *prev = var->getPreviousDecl();
15159 Diag(var->getLocation(), diag::warn_missing_variable_declarations) << var;
15160 Diag(var->getTypeSpecStartLoc(), diag::note_static_for_internal_linkage)
15166 std::optional<bool> CacheHasConstInit;
15167 const Expr *CacheCulprit =
nullptr;
15168 auto checkConstInit = [&]()
mutable {
15169 const Expr *
Init = var->getInit();
15170 if (
Init->isInstantiationDependent())
15173 if (!CacheHasConstInit)
15174 CacheHasConstInit = var->getInit()->isConstantInitializer(
15175 Context, var->getType()->isReferenceType(), &CacheCulprit);
15176 return *CacheHasConstInit;
15180 if (var->getType().isDestructedType()) {
15184 Diag(var->getLocation(), diag::err_thread_nontrivial_dtor);
15186 Diag(var->getLocation(), diag::note_use_thread_local);
15188 if (!checkConstInit()) {
15196 Diag(var->getLocation(), diag::note_use_thread_local);
15202 if (!var->getType()->isStructureType() && var->hasInit() &&
15205 unsigned NumInits = ILE->getNumInits();
15207 for (
unsigned I = 0; I < NumInits; ++I) {
15208 const auto *
Init = ILE->getInit(I);
15211 const auto *SL = dyn_cast<StringLiteral>(
Init->IgnoreImpCasts());
15215 unsigned NumConcat = SL->getNumConcatenated();
15219 if (NumConcat == 2 && !SL->getBeginLoc().isMacroID()) {
15220 bool OnlyOneMissingComma =
true;
15221 for (
unsigned J = I + 1; J < NumInits; ++J) {
15222 const auto *
Init = ILE->getInit(J);
15225 const auto *SLJ = dyn_cast<StringLiteral>(
Init->IgnoreImpCasts());
15226 if (!SLJ || SLJ->getNumConcatenated() > 1) {
15227 OnlyOneMissingComma =
false;
15232 if (OnlyOneMissingComma) {
15234 for (
unsigned i = 0; i < NumConcat - 1; ++i)
15236 PP.getLocForEndOfToken(SL->getStrTokenLoc(i)),
","));
15238 Diag(SL->getStrTokenLoc(1),
15239 diag::warn_concatenated_literal_array_init)
15241 Diag(SL->getBeginLoc(),
15242 diag::note_concatenated_string_literal_silence);
15253 if (var->hasAttr<BlocksAttr>())
15257 bool GlobalStorage = var->hasGlobalStorage();
15258 bool IsGlobal = GlobalStorage && !var->isStaticLocal();
15260 bool HasConstInit =
true;
15263 Diag(var->getLocation(), diag::err_constexpr_var_requires_const_init)
15268 !
type->isDependentType() &&
Init && !
Init->isValueDependent() &&
15269 (GlobalStorage || var->isConstexpr() ||
15270 var->mightBeUsableInConstantExpressions(
Context))) {
15282 HasConstInit = checkConstInit();
15286 if (HasConstInit) {
15287 if (var->isStaticDataMember() && !var->isInline() &&
15288 var->getLexicalDeclContext()->isRecord() &&
15289 type->isIntegralOrEnumerationType()) {
15294 diag::ext_in_class_initializer_non_constant)
15295 <<
Init->getSourceRange();
15298 (void)var->checkForConstantInitialization(Notes);
15300 }
else if (CacheCulprit) {
15301 Notes.emplace_back(CacheCulprit->
getExprLoc(),
15302 PDiag(diag::note_invalid_subexpr_in_const_expr));
15307 HasConstInit = var->checkForConstantInitialization(Notes);
15310 if (HasConstInit) {
15312 }
else if (var->isConstexpr()) {
15316 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
15317 diag::note_invalid_subexpr_in_const_expr) {
15318 DiagLoc = Notes[0].first;
15321 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
15322 << var <<
Init->getSourceRange();
15323 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
15324 Diag(Notes[I].first, Notes[I].second);
15325 }
else if (GlobalStorage && var->hasAttr<ConstInitAttr>()) {
15326 auto *
Attr = var->getAttr<ConstInitAttr>();
15327 Diag(var->getLocation(), diag::err_require_constant_init_failed)
15328 <<
Init->getSourceRange();
15331 for (
auto &it : Notes)
15332 Diag(it.first, it.second);
15333 }
else if (var->isStaticDataMember() && !var->isInline() &&
15334 var->getLexicalDeclContext()->isRecord()) {
15335 Diag(var->getLocation(), diag::err_in_class_initializer_non_constant)
15336 <<
Init->getSourceRange();
15337 for (
auto &it : Notes)
15338 Diag(it.first, it.second);
15339 var->setInvalidDecl();
15340 }
else if (IsGlobal &&
15342 var->getLocation())) {
15351 if (!checkConstInit())
15352 Diag(var->getLocation(), diag::warn_global_constructor)
15353 <<
Init->getSourceRange();
15359 if (GlobalStorage && var->isThisDeclarationADefinition() &&
15364 Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment();
15365 std::optional<QualType::NonConstantStorageReason> Reason;
15366 if (HasConstInit &&
15367 !(Reason = var->getType().isNonConstantStorage(
Context,
true,
false))) {
15373 if (
const SectionAttr *SA = var->getAttr<SectionAttr>()) {
15380 var->getType().isConstQualified()) {
15382 NonConstNonReferenceType) &&
15383 "This case should've already been handled elsewhere");
15384 Diag(var->getLocation(), diag::warn_section_msvc_compat)
15385 << var <<
ConstSegStack.CurrentValue << (int)(!HasConstInit
15391 var->addAttr(SectionAttr::CreateImplicit(
Context, SectionName,
15393 SectionAttr::Declspec_allocate));
15395 var->dropAttr<SectionAttr>();
15410 if (
Context.DeclMustBeEmitted(var) && !ModuleScopes.empty())
15411 Context.addModuleInitializer(ModuleScopes.back().Module, var);
15418 if (!
type->isDependentType())
15427 if (
Context.DeclMustBeEmitted(var) && !ModuleScopes.empty()) {
15429 if (ModuleScopes.back().Module->isHeaderLikeModule() ||
15432 Context.addModuleInitializer(ModuleScopes.back().Module, var);
15436 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
15447 !FD->
hasAttr<DLLExportStaticLocalAttr>() &&
15448 !FD->
hasAttr<DLLImportStaticLocalAttr>()) {
15458 NewAttr->setInherited(
true);
15460 }
else if (
Attr *A = FD->
getAttr<DLLExportStaticLocalAttr>()) {
15461 auto *NewAttr = DLLExportAttr::CreateImplicit(
getASTContext(), *A);
15462 NewAttr->setInherited(
true);
15467 if (!FD->
hasAttr<DLLExportAttr>())
15470 }
else if (
Attr *A = FD->
getAttr<DLLImportStaticLocalAttr>()) {
15471 auto *NewAttr = DLLImportAttr::CreateImplicit(
getASTContext(), *A);
15472 NewAttr->setInherited(
true);
15483 if (
unsigned MaxAlign =
Context.getTargetInfo().getMaxTLSAlign()) {
15488 if (
Context.getDeclAlign(VD) > MaxAlignChars) {
15501 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
15513 VD->
addAttr(PragmaClangBSSSectionAttr::CreateImplicit(
15517 VD->
addAttr(PragmaClangDataSectionAttr::CreateImplicit(
15521 VD->
addAttr(PragmaClangRodataSectionAttr::CreateImplicit(
15525 VD->
addAttr(PragmaClangRelroSectionAttr::CreateImplicit(
15530 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
15531 for (
auto *BD : DD->bindings()) {
15536 CheckInvalidBuiltinCountedByRef(VD->
getInit(),
15559 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
15566 bool IsClassTemplateMember =
15568 Context->getDescribedClassTemplate();
15571 IsClassTemplateMember
15572 ? diag::warn_attribute_dllimport_static_field_definition
15573 : diag::err_attribute_dllimport_static_field_definition);
15574 Diag(IA->getLocation(), diag::note_attribute);
15575 if (!IsClassTemplateMember)
15604 if (RetainAttr *
Attr = VD->
getAttr<RetainAttr>()) {
15625 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
15629 for (
const auto *I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
15631 if (!MagicValueExpr) {
15634 std::optional<llvm::APSInt> MagicValueInt;
15636 Diag(I->getRange().getBegin(),
15637 diag::err_type_tag_for_datatype_not_ice)
15641 if (MagicValueInt->getActiveBits() > 64) {
15642 Diag(I->getRange().getBegin(),
15643 diag::err_type_tag_for_datatype_too_large)
15647 uint64_t MagicValue = MagicValueInt->getZExtValue();
15650 I->getMatchingCType(),
15651 I->getLayoutCompatible(),
15652 I->getMustBeNull());
15657 auto *VD = dyn_cast<VarDecl>(DD);
15658 return VD && !VD->getType()->hasAutoForTrailingReturnType();
15670 bool DiagnosedMultipleDecomps =
false;
15672 bool DiagnosedNonDeducedAuto =
false;
15674 for (
Decl *D : Group) {
15679 if (
auto *VD = dyn_cast<VarDecl>(D);
15680 LangOpts.OpenMP && VD && VD->hasAttr<OMPDeclareTargetDeclAttr>() &&
15681 VD->hasGlobalStorage())
15685 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
15686 if (!FirstDeclaratorInGroup)
15687 FirstDeclaratorInGroup = DD;
15688 if (!FirstDecompDeclaratorInGroup)
15689 FirstDecompDeclaratorInGroup = dyn_cast<DecompositionDecl>(D);
15692 FirstNonDeducedAutoInGroup = DD;
15694 if (FirstDeclaratorInGroup != DD) {
15697 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
15699 diag::err_decomp_decl_not_alone)
15701 << DD->getSourceRange();
15702 DiagnosedMultipleDecomps =
true;
15708 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
15710 diag::err_auto_non_deduced_not_alone)
15711 << FirstNonDeducedAutoInGroup->
getType()
15714 << DD->getSourceRange();
15715 DiagnosedNonDeducedAuto =
true;
15720 Decls.push_back(D);
15726 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
15728 Context.addDeclaratorForUnnamedTagDecl(Tag, FirstDeclaratorInGroup);
15740 if (Group.size() > 1) {
15742 VarDecl *DeducedDecl =
nullptr;
15743 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
15744 VarDecl *D = dyn_cast<VarDecl>(Group[i]);
15748 if (!DT || DT->getDeducedType().isNull())
15751 Deduced = DT->getDeducedType();
15753 }
else if (!
Context.hasSameType(DT->getDeducedType(),
Deduced)) {
15754 auto *AT = dyn_cast<AutoType>(DT);
15756 diag::err_auto_different_deductions)
15758 << DeducedDecl->
getDeclName() << DT->getDeducedType()
15782 if (Group.empty() || !Group[0])
15785 if (
Diags.isIgnored(diag::warn_doc_param_not_found,
15786 Group[0]->getLocation()) &&
15787 Diags.isIgnored(diag::warn_unknown_comment_command_name,
15788 Group[0]->getLocation()))
15791 if (Group.size() >= 2) {
15799 Decl *MaybeTagDecl = Group[0];
15801 Group = Group.slice(1);
15854 const auto *VD = dyn_cast<ValueDecl>(D);
15868 unsigned Kind = TD->isEnum() ? 2 : TD->isUnion() ? 1 : 0;
15870 Diag(TD->getLocation(), diag::note_declared_at);
15876 if (!ExplicitThisLoc.
isValid())
15879 "explicit parameter in non-cplusplus mode");
15881 S.
Diag(ExplicitThisLoc, diag::err_cxx20_deducing_this)
15893 LSI->ExplicitObjectParameter = P;
15916 ? diag::ext_register_storage_class
15917 : diag::warn_deprecated_register)
15923 diag::err_invalid_storage_class_in_func_decl)
15932 diag::err_invalid_storage_class_in_func_decl);
15944 << 0 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
15965 PrevDecl =
nullptr;
15987 diag::err_hlsl_incomplete_resource_array_in_function_param);
16000 New->setInvalidDecl();
16019 Diag(
New->getLocation(), diag::err_module_private_local)
16023 if (
New->hasAttr<BlocksAttr>())
16024 Diag(
New->getLocation(), diag::err_block_not_allowed_on)
16025 << diag::NotAllowedBlockVarReason::NonlocalVariable;
16039 T,
Context.getTrivialTypeSourceInfo(
T, Loc),
16041 Param->setImplicit();
16054 !
Parameter->getIdentifier()->isPlaceholder()) {
16055 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
16063 if (
LangOpts.NumLargeByValueCopy == 0)
16069 unsigned Size =
Context.getTypeSizeInChars(ReturnTy).getQuantity();
16070 if (Size >
LangOpts.NumLargeByValueCopy)
16078 if (
T->isDependentType() || !
T.isPODType(
Context))
16080 unsigned Size =
Context.getTypeSizeInChars(
T).getQuantity();
16081 if (Size >
LangOpts.NumLargeByValueCopy)
16094 T->isObjCLifetimeType()) {
16101 if (
T->isArrayType()) {
16102 if (!
T.isConstQualified()) {
16106 NameLoc, diag::err_arc_array_param_no_ownership,
T,
false));
16108 Diag(NameLoc, diag::err_arc_array_param_no_ownership)
16113 lifetime =
T->getObjCARCImplicitLifetime();
16115 T =
Context.getLifetimeQualifiedType(
T, lifetime);
16120 if (
T->isArrayType() && !
T.hasAddressSpace()) {
16126 T =
Context.getAddrSpaceQualType(
T, ImplAS);
16133 Context.getAdjustedParameterType(
T),
16134 TSInfo, SC,
nullptr);
16139 if (
New->isParameterPack())
16141 CSI->LocalPacks.push_back(
New);
16143 if (
New->getType().hasNonTrivialToPrimitiveDestructCUnion() ||
16144 New->getType().hasNonTrivialToPrimitiveCopyCUnion())
16151 if (
T->isObjCObjectType()) {
16155 diag::err_object_cannot_be_passed_returned_by_value) << 1 <<
T
16157 T =
Context.getObjCObjectPointerType(
T);
16162 if (
T.getPointerAuth()) {
16163 Diag(NameLoc, diag::err_ptrauth_qualifier_invalid) <<
T << 1;
16164 New->setInvalidDecl();
16178 !(
T->isFunctionPointerType() &&
16184 Diag(NameLoc, diag::err_arg_with_address_space);
16185 New->setInvalidDecl();
16189 if (
Context.getTargetInfo().getTriple().isPPC64() &&
16190 PPC().CheckPPCMMAType(
New->getOriginalType(),
New->getLocation())) {
16191 New->setInvalidDecl();
16212 for (
int i = FTI.
NumParams; i != 0; ) {
16217 llvm::raw_svector_ostream(Code)
16228 const char* PrevSpec;
16231 DiagID,
Context.getPrintingPolicy());
16260 if (
LangOpts.OpenMP &&
OpenMP().isInOpenMPDeclareVariantScope())
16262 ParentScope, D, TemplateParameterLists, Bases);
16268 if (!Bases.empty())
16276 Consumer.HandleInlineFunctionDefinition(D);
16285 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
16288 PossiblePrototype = Prev;
16312 if (II->isStr(
"main") || II->isStr(
"efi_main"))
16331 if (FD->
hasAttr<DeviceKernelAttr>())
16380 bool DefinitionVisible =
false;
16383 DefinitionVisible) &&
16386 !
Definition->getTemplateParameterLists().empty())) {
16389 if (!DefinitionVisible) {
16390 if (
auto *TD =
Definition->getDescribedFunctionTemplate())
16404 Diag(
Definition->getLocation(), diag::note_previous_definition);
16413 LSI->
Lambda = LambdaClass;
16453 for (
const auto &
C : LambdaClass->
captures()) {
16454 if (
C.capturesVariable()) {
16458 const bool ByRef =
C.getCaptureKind() ==
LCK_ByRef;
16460 true,
C.getLocation(),
16461 C.isPackExpansion()
16463 I->getType(),
false);
16465 }
else if (
C.capturesThis()) {
16491 FD = FunTmpl->getTemplatedDecl();
16502 if (
const auto *
Attr = FD->
getAttr<AliasAttr>()) {
16507 if (
const auto *
Attr = FD->
getAttr<IFuncAttr>()) {
16512 if (
const auto *
Attr = FD->
getAttr<TargetVersionAttr>()) {
16513 if (
Context.getTargetInfo().getTriple().isAArch64() &&
16514 !
Context.getTargetInfo().hasFeature(
"fmv") &&
16515 !
Attr->isDefaultVersion()) {
16524 if (
auto *Ctor = dyn_cast<CXXConstructorDecl>(FD)) {
16526 Ctor->isDefaultConstructor() &&
16527 Context.getTargetInfo().getCXXABI().isMicrosoft()) {
16530 if (DLLExportAttr *
Attr = Ctor->getAttr<DLLExportAttr>())
16573 "There should be an active template instantiation on the stack "
16574 "when instantiating a generic lambda!");
16584 if (!
Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID) &&
16585 !
Context.BuiltinInfo.isPredefinedRuntimeFunction(BuiltinID)) {
16600 diag::err_func_def_incomplete_result) ||
16602 diag::err_abstract_type_in_decl,
16618 auto *NonParmDecl = dyn_cast<NamedDecl>(NPD);
16622 "parameters should not be in newly created FD yet");
16625 if (NonParmDecl->getDeclName())
16630 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
16631 for (
auto *EI : ED->enumerators())
16639 Param->setOwningFunction(FD);
16642 if (Param->getIdentifier() && FnBodyScope) {
16679 assert(!FD->
hasAttr<DLLExportAttr>());
16680 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
16710 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
16711 if (!SKEPAttr->isInvalidAttr()) {
16731 if (
auto *TD = dyn_cast<FunctionTemplateDecl>(FD))
16732 FD = TD->getTemplatedDecl();
16733 if (FD && FD->
hasAttr<OptimizeNoneAttr>()) {
16745 for (
unsigned I = 0, E =
Scope->Returns.size(); I != E; ++I) {
16746 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
16747 if (!NRVOCandidate->isNRVOVariable()) {
16748 Diag(Returns[I]->getRetValue()->getExprLoc(),
16749 diag::warn_not_eliding_copy_on_return);
16769 Outer.Fun.hasTrailingReturnType()) {
16787 if (FD->isConstexpr())
16792 if (FD->getReturnType()->getContainedDeducedType())
16795 return Consumer.shouldSkipFunctionBody(D);
16802 FD->setHasSkippedBody();
16815 S.PopExpressionEvaluationContext();
16820 bool IsLambda =
false;
16824 llvm::DenseMap<const BlockDecl *, bool> EscapeInfo;
16826 auto IsOrNestedInEscapingBlock = [&](
const BlockDecl *BD) {
16827 auto [It, Inserted] = EscapeInfo.try_emplace(BD);
16841 return It->second = R;
16846 for (
const std::pair<SourceLocation, const BlockDecl *> &P :
16848 if (IsOrNestedInEscapingBlock(P.second))
16849 S.
Diag(P.first, diag::warn_implicitly_retains_self)
16864 methodHasName(FD,
"get_return_object_on_allocation_failure");
16874 if (!FD->
hasAttr<CoroWrapperAttr>())
16879 bool RetainFunctionScopeInfo) {
16906 SYCLKernelEntryPointAttr *SKEPAttr =
16907 FD->
getAttr<SYCLKernelEntryPointAttr>();
16909 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16910 << SKEPAttr << diag::InvalidSKEPReason::DefaultedFn;
16911 SKEPAttr->setInvalidAttr();
16913 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16914 << SKEPAttr << diag::InvalidSKEPReason::DeletedFn;
16915 SKEPAttr->setInvalidAttr();
16917 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16918 << SKEPAttr << diag::InvalidSKEPReason::Coroutine;
16919 SKEPAttr->setInvalidAttr();
16921 Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
16922 << SKEPAttr << diag::InvalidSKEPReason::FunctionTryBlock;
16923 SKEPAttr->setInvalidAttr();
16931 if (Body && !SKEPAttr->isInvalidAttr()) {
16961 SYCLExternalAttr *SEAttr = FD->
getAttr<SYCLExternalAttr>();
16963 Diag(SEAttr->getLocation(),
16964 diag::err_sycl_external_invalid_deleted_function)
16994 Expr *Dummy =
nullptr;
17005 if (LSI->HasImplicitReturnType) {
17012 LSI->ReturnType.isNull() ?
Context.VoidTy : LSI->ReturnType;
17016 FD->
setType(
Context.getFunctionType(RetType, Proto->getParamTypes(),
17017 Proto->getExtProtoInfo()));
17050 dyn_cast<CXXDestructorDecl>(FD))
17070 if (PossiblePrototype) {
17074 TypeLoc TL = TI->getTypeLoc();
17077 diag::note_declaration_not_a_prototype)
17080 FTL.getRParenLoc(),
"void")
17088 if (LocInfo.first.isInvalid())
17092 StringRef Buffer = SM.getBufferData(LocInfo.first, &
Invalid);
17096 if (LocInfo.second > Buffer.size())
17099 const char *LexStart = Buffer.data() + LocInfo.second;
17100 StringRef StartTok(LexStart, Buffer.size() - LocInfo.second);
17102 return StartTok.consume_front(
"const") &&
17104 StartTok.starts_with(
"/*") || StartTok.starts_with(
"//"));
17107 auto findBeginLoc = [&]() {
17123 diag::note_static_for_internal_linkage)
17134 if (!PossiblePrototype)
17180 if (PossiblePrototype)
17182 diag::warn_non_prototype_changes_behavior)
17189 if (
const auto *CmpndBody = dyn_cast<CompoundStmt>(Body))
17190 if (!CmpndBody->body_empty())
17191 Diag(CmpndBody->body_front()->getBeginLoc(),
17192 diag::warn_dispatch_body_ignored);
17194 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
17202 !
Context.getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
17203 Context.setNonKeyFunction(MD);
17219 "Function parsing confused");
17220 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
17232 << MD->getSelector().getAsString();
17237 bool isDesignated =
17238 MD->isDesignatedInitializerForTheInterface(&InitMethod);
17239 assert(isDesignated && InitMethod);
17240 (void)isDesignated;
17243 auto IFace = MD->getClassInterface();
17246 auto SuperD = IFace->getSuperClass();
17256 diag::warn_objc_designated_init_missing_super_call);
17258 diag::note_objc_designated_init_marked_here);
17266 diag::warn_objc_secondary_init_missing_init_call);
17281 else if (
AMDGPU().HasPotentiallyUnguardedBuiltinUsage(FD))
17286 "This should only be set for ObjC methods, which should have been "
17287 "handled in the block above.");
17302 if (!
Destructor->getParent()->isDependentType())
17320 ActivePolicy = &WP;
17323 if (!IsInstantiation && FD &&
17329 if (FD && FD->
hasAttr<NakedAttr>()) {
17333 bool RegisterVariables =
false;
17334 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
17335 for (
const auto *
Decl : DS->decls()) {
17336 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
17337 RegisterVariables =
17338 Var->hasAttr<AsmLabelAttr>() && !Var->hasInit();
17339 if (!RegisterVariables)
17344 if (RegisterVariables)
17347 Diag(S->getBeginLoc(), diag::err_non_asm_stmt_in_naked_function);
17348 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
17357 "Leftover temporaries in function");
17358 assert(!
Cleanup.exprNeedsCleanups() &&
17359 "Unaccounted cleanups in function");
17361 "Leftover expressions for odr-use checking");
17370 if (!IsInstantiation)
17373 if (!RetainFunctionScopeInfo)
17402 D = TD->getTemplatedDecl();
17414 assert(
LangOpts.implicitFunctionsAllowed() &&
17415 "Implicit function declarations aren't allowed in this language mode");
17422 Scope *BlockScope = S;
17430 Scope *ContextScope = BlockScope;
17434 ContextScope = ContextScope->
getParent();
17454 Diag(Loc, diag::ext_use_out_of_scope_declaration)
17457 return ExternCPrev;
17463 if (II.
getName().starts_with(
"__builtin_"))
17464 diag_id = diag::warn_builtin_unknown;
17467 diag_id = diag::ext_implicit_function_decl_c99;
17469 diag_id = diag::warn_implicit_function_decl;
17477 if (S && !ExternCPrev &&
17484 Diag(Loc, diag_id) << &II;
17500 return ExternCPrev;
17508 Context.getPrintingPolicy());
17510 assert(!
Error &&
"Error setting up implicit decl!");
17553 bool IsNothrow =
false;
17565 if (!IsNothrow && !FD->
hasAttr<ReturnsNonNullAttr>() &&
17583 if (!FD->
hasAttr<AllocSizeAttr>()) {
17584 FD->
addAttr(AllocSizeAttr::CreateImplicit(
17595 if (AlignmentParam && !FD->
hasAttr<AllocAlignAttr>()) {
17596 FD->
addAttr(AllocAlignAttr::CreateImplicit(
17620 unsigned FormatIdx;
17622 if (
Context.BuiltinInfo.isPrintfLike(BuiltinID, FormatIdx, HasVAListArg)) {
17623 if (!FD->
hasAttr<FormatAttr>()) {
17624 const char *fmt =
"printf";
17626 if (FormatIdx < NumParams &&
17632 HasVAListArg ? 0 : FormatIdx+2,
17636 if (
Context.BuiltinInfo.isScanfLike(BuiltinID, FormatIdx,
17638 if (!FD->
hasAttr<FormatAttr>())
17640 &
Context.Idents.get(
"scanf"),
17642 HasVAListArg ? 0 : FormatIdx+2,
17648 if (!FD->
hasAttr<CallbackAttr>() &&
17649 Context.BuiltinInfo.performsCallback(BuiltinID, Encoding))
17650 FD->
addAttr(CallbackAttr::CreateImplicit(
17656 bool NoExceptions =
17658 bool ConstWithoutErrnoAndExceptions =
17659 Context.BuiltinInfo.isConstWithoutErrnoAndExceptions(BuiltinID);
17660 bool ConstWithoutExceptions =
17661 Context.BuiltinInfo.isConstWithoutExceptions(BuiltinID);
17662 if (!FD->
hasAttr<ConstAttr>() &&
17663 (ConstWithoutErrnoAndExceptions || ConstWithoutExceptions) &&
17664 (!ConstWithoutErrnoAndExceptions ||
17666 (!ConstWithoutExceptions || NoExceptions))
17672 const llvm::Triple &Trip =
Context.getTargetInfo().getTriple();
17673 if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
17675 switch (BuiltinID) {
17676 case Builtin::BI__builtin_fma:
17677 case Builtin::BI__builtin_fmaf:
17678 case Builtin::BI__builtin_fmal:
17679 case Builtin::BIfma:
17680 case Builtin::BIfmaf:
17681 case Builtin::BIfmal:
17691 if (
Context.BuiltinInfo.isNonNull(BuiltinID, Indxs, OptMode) &&
17692 !FD->
hasAttr<NonNullAttr>()) {
17694 for (
int I : Indxs) {
17697 T =
Context.getAttributedType(attr::TypeNonNull,
T,
T);
17702 for (
int I : Indxs)
17703 ParamIndxs.push_back(
ParamIdx(I + 1, FD));
17704 FD->
addAttr(NonNullAttr::CreateImplicit(
Context, ParamIndxs.data(),
17705 ParamIndxs.size()));
17708 if (
Context.BuiltinInfo.isReturnsTwice(BuiltinID) &&
17709 !FD->
hasAttr<ReturnsTwiceAttr>())
17712 if (
Context.BuiltinInfo.isNoThrow(BuiltinID) && !FD->
hasAttr<NoThrowAttr>())
17714 if (
Context.BuiltinInfo.isPure(BuiltinID) && !FD->
hasAttr<PureAttr>())
17716 if (
Context.BuiltinInfo.isConst(BuiltinID) && !FD->
hasAttr<ConstAttr>())
17719 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
17724 Context.BuiltinInfo.isAuxBuiltinID(BuiltinID))
17731 switch (BuiltinID) {
17732 case Builtin::BImemalign:
17733 case Builtin::BIaligned_alloc:
17734 if (!FD->
hasAttr<AllocAlignAttr>())
17743 switch (BuiltinID) {
17744 case Builtin::BIcalloc:
17745 FD->
addAttr(AllocSizeAttr::CreateImplicit(
17748 case Builtin::BImemalign:
17749 case Builtin::BIaligned_alloc:
17750 case Builtin::BIrealloc:
17754 case Builtin::BImalloc:
17774 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
17790 if (Name->
isStr(
"asprintf") || Name->
isStr(
"vasprintf")) {
17793 if (!FD->
hasAttr<FormatAttr>())
17795 &
Context.Idents.get(
"printf"), 2,
17796 Name->
isStr(
"vasprintf") ? 0 : 3,
17800 if (Name->
isStr(
"__CFStringMakeConstantString")) {
17803 if (!FD->
hasAttr<FormatArgAttr>())
17811 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
17812 assert(!
T.isNull() &&
"GetTypeForDeclarator() returned null type");
17815 assert(D.
isInvalidType() &&
"no declarator info for valid type");
17816 TInfo =
Context.getTrivialTypeSourceInfo(
T);
17869 if (
T->isDependentType())
17879 if (
T->isAtomicType())
17880 Diag(UnderlyingLoc, diag::warn_atomic_stripped_in_enum);
17883 std::optional<unsigned> QualSelect;
17885 QualSelect = diag::CVQualList::Both;
17887 QualSelect = diag::CVQualList::Const;
17889 QualSelect = diag::CVQualList::Volatile;
17892 Diag(UnderlyingLoc, diag::warn_cv_stripped_in_enum) << *QualSelect;
17894 T =
T.getAtomicUnqualifiedType();
17899 if (BT->isInteger())
17902 return Diag(UnderlyingLoc, diag::err_enum_invalid_underlying)
17903 <<
T <<
T->isBitIntType();
17907 QualType EnumUnderlyingTy,
bool IsFixed,
17909 if (IsScoped != Prev->
isScoped()) {
17910 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
17916 if (IsFixed && Prev->
isFixed()) {
17919 !
Context.hasSameUnqualifiedType(EnumUnderlyingTy,
17922 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
17928 }
else if (IsFixed != Prev->
isFixed()) {
17929 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
17951 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
17987 llvm_unreachable(
"invalid TTK");
18026 if (IsIgnoredLoc(NewTagLoc))
18029 auto IsIgnored = [&](
const TagDecl *Tag) {
18030 return IsIgnoredLoc(Tag->getLocation());
18047 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
18055 if (isDefinition) {
18063 bool previousMismatch =
false;
18065 if (I->getTagKind() !=
NewTag) {
18070 if (!previousMismatch) {
18071 previousMismatch =
true;
18072 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
18076 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
18089 if (PrevDef && IsIgnored(PrevDef))
18093 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
18100 Diag(NewTagLoc, diag::note_struct_class_suggestion)
18130 if (!Namespace || Namespace->isAnonymousNamespace())
18133 Namespaces.push_back(II);
18136 if (Lookup == Namespace)
18143 llvm::raw_svector_ostream OS(Insertion);
18146 std::reverse(Namespaces.begin(), Namespaces.end());
18147 for (
auto *II : Namespaces)
18148 OS << II->getName() <<
"::";
18161 if (OldDC->
Equals(NewDC))
18180 bool ScopedEnumUsesClassTag,
TypeResult UnderlyingType,
18181 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
18186 "Nameless record must be a definition!");
18191 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
18194 bool isMemberSpecialization =
false;
18195 bool IsInjectedClassName =
false;
18201 if (TemplateParameterLists.size() > 0 ||
18205 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
18222 !isMemberSpecialization)
18223 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
18226 if (TemplateParams) {
18228 Diag(KWLoc, diag::err_enum_template);
18232 if (TemplateParams->
size() > 0) {
18241 S, TagSpec, TUK, KWLoc, SS, Name, NameLoc, Attrs, TemplateParams,
18242 AS, ModulePrivateLoc,
18244 TemplateParameterLists.data(), isMemberSpecialization, SkipBody);
18250 isMemberSpecialization =
true;
18254 if (!TemplateParameterLists.empty() && isMemberSpecialization &&
18273 ScopedEnum ?
SourceRange(KWLoc, ScopedEnumKWLoc) : KWLoc);
18274 assert(ScopedEnum || !ScopedEnumUsesClassTag);
18275 Diag(KWLoc, diag::note_enum_friend)
18276 << (ScopedEnum + ScopedEnumUsesClassTag);
18282 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
18283 bool IsFixed = !UnderlyingType.
isUnset() || ScopedEnum;
18286 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum) ||
18290 EnumUnderlying =
Context.IntTy.getTypePtr();
18291 }
else if (UnderlyingType.
get()) {
18299 EnumUnderlying = TI;
18303 EnumUnderlying =
Context.IntTy.getTypePtr();
18307 EnumUnderlying =
Context.IntTy.getTypePtr();
18317 if (
TypeSourceInfo *TI = dyn_cast<TypeSourceInfo *>(EnumUnderlying);
18318 TI && TI->
getType()->isAtomicType())
18321 }
else if (
Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment()) {
18327 EnumUnderlying =
Context.IntTy.getTypePtr();
18333 bool isStdBadAlloc =
false;
18334 bool isStdAlignValT =
false;
18343 auto createTagFromNewDecl = [&]() ->
TagDecl * {
18353 ScopedEnum, ScopedEnumUsesClassTag, IsFixed);
18357 if (EnumUnderlying) {
18359 if (
TypeSourceInfo *TI = dyn_cast<TypeSourceInfo *>(EnumUnderlying))
18365 ?
Context.getPromotedIntegerType(EnumTy)
18386 RD->addAttr(PackedAttr::CreateImplicit(
Context));
18402 goto CreateNewDecl;
18410 IsDependent =
true;
18439 if (
Previous.wasNotFoundInCurrentInstantiation() &&
18441 IsDependent =
true;
18446 Diag(NameLoc, diag::err_not_tag_in_scope)
18447 << Kind << Name << DC << SS.
getRange();
18450 goto CreateNewDecl;
18498 bool FriendSawTagOutsideEnclosingNamespace =
false;
18505 FriendSawTagOutsideEnclosingNamespace =
true;
18514 if (
Previous.isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
18516 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
18547 Previous.getFoundDecl()->isTemplateParameter()) {
18556 if (Name->
isStr(
"bad_alloc")) {
18558 isStdBadAlloc =
true;
18565 }
else if (Name->
isStr(
"align_val_t")) {
18566 isStdAlignValT =
true;
18578 IsTemplateParamOrArg)) {
18579 if (
Invalid)
goto CreateNewDecl;
18662 if (
TagDecl *Tag = TD->getUnderlyingType()->getAsTagDecl()) {
18663 if (Tag->getDeclName() == Name &&
18664 Tag->getDeclContext()->getRedeclContext()
18665 ->Equals(TD->getDeclContext()->getRedeclContext())) {
18678 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
18679 auto *OldTag = dyn_cast<TagDecl>(PrevDecl);
18682 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
18684 *
this, OldTag->getDeclContext(), SearchDC))) {
18685 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
18686 Diag(Shadow->getTargetDecl()->getLocation(),
18687 diag::note_using_decl_target);
18688 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl)
18692 goto CreateNewDecl;
18696 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
18703 isMemberSpecialization)) {
18705 if (
auto *RD = dyn_cast<CXXRecordDecl>(PrevDecl);
18706 RD && RD->isInjectedClassName()) {
18713 IsInjectedClassName =
true;
18721 bool SafeToContinue =
18724 if (SafeToContinue)
18725 Diag(KWLoc, diag::err_use_with_wrong_tag)
18728 PrevTagDecl->getKindName());
18730 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
18731 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
18733 if (SafeToContinue)
18734 Kind = PrevTagDecl->getTagKind();
18747 return PrevTagDecl;
18751 dyn_cast_if_present<TypeSourceInfo *>(EnumUnderlying))
18752 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
18753 else if (
const Type *
T =
18754 dyn_cast_if_present<const Type *>(EnumUnderlying))
18761 ScopedEnum, EnumUnderlyingTy,
18762 IsFixed, PrevEnum))
18772 Diag(NameLoc, diag::ext_member_redeclared);
18773 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
18782 if (
const auto *OutermostClass = dyn_cast<CXXRecordDecl>(PrevDecl)) {
18783 while (
const auto *ParentClass =
18784 dyn_cast<CXXRecordDecl>(OutermostClass->getParent()))
18785 OutermostClass = ParentClass;
18787 if (OutermostClass->isLocalClass() &&
18789 Diag(NameLoc, diag::err_local_nested_class_invalid_scope)
18790 << Name << OutermostClass;
18791 Diag(OutermostClass->getLocation(), diag::note_defined_here)
18801 if (!Attrs.
empty()) {
18805 (PrevTagDecl->getFriendObjectKind() ==
18818 return PrevTagDecl;
18823 return PrevTagDecl;
18832 if (Def->isBeingDefined()) {
18833 Diag(NameLoc, diag::err_nested_redefinition) << Name;
18834 Diag(PrevTagDecl->getLocation(),
18835 diag::note_previous_definition);
18843 bool IsExplicitSpecializationAfterInstantiation =
false;
18844 if (isMemberSpecialization) {
18846 IsExplicitSpecializationAfterInstantiation =
18847 RD->getTemplateSpecializationKind() !=
18849 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
18850 IsExplicitSpecializationAfterInstantiation =
18851 ED->getTemplateSpecializationKind() !=
18860 bool HiddenDefVisible =
false;
18862 HiddenDefVisible) ||
18874 SkipBody->
New = createTagFromNewDecl();
18883 if (!HiddenDefVisible && Hidden)
18888 }
else if (!IsExplicitSpecializationAfterInstantiation) {
18893 Diag(NameLoc, diag::warn_redefinition_in_param_list)
18896 Diag(NameLoc, diag::err_redefinition) << Name;
18898 NameLoc.
isValid() ? NameLoc : KWLoc);
18917 IsInjectedClassName) {
18918 SearchDC = PrevTagDecl->getDeclContext();
18946 Diag(NameLoc, diag::err_tag_reference_non_tag)
18947 << PrevDecl << NTK << Kind;
18953 SS.
isNotEmpty() || isMemberSpecialization)) {
18959 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
18965 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
18968 Diag(NameLoc, diag::err_tag_definition_of_typedef)
18969 << Name << Kind << TND->getUnderlyingType();
18977 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
19009 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
19010 ScopedEnumUsesClassTag, IsFixed);
19014 KWLoc, ScopedEnumKWLoc.
isValid() ? ScopedEnumKWLoc : KWLoc));
19022 if (IsFixed && ED->
isFixed()) {
19025 }
else if (PrevDecl &&
19027 Diag(Loc, diag::ext_forward_ref_enum_def)
19031 unsigned DiagID = diag::ext_forward_ref_enum;
19033 DiagID = diag::ext_ms_forward_ref_enum;
19035 DiagID = diag::err_forward_ref_enum;
19040 if (EnumUnderlying) {
19042 if (
TypeSourceInfo *TI = dyn_cast<TypeSourceInfo *>(EnumUnderlying))
19048 ?
Context.getPromotedIntegerType(EnumTy)
19050 assert(ED->
isComplete() &&
"enum with type should be complete");
19060 cast_or_null<CXXRecordDecl>(PrevDecl));
19066 cast_or_null<RecordDecl>(PrevDecl));
19072 Diag(
New->getLocation(), diag::ext_type_defined_in_offsetof)
19078 (IsTypeSpecifier || IsTemplateParamOrArg) &&
19080 Diag(
New->getLocation(), diag::err_type_defined_in_type_specifier)
19087 Diag(
New->getLocation(), diag::err_type_defined_in_enum)
19100 isMemberSpecialization))
19104 if (TemplateParameterLists.size() > 0) {
19105 New->setTemplateParameterListsInfo(
Context, TemplateParameterLists);
19124 RD->addAttr(PackedAttr::CreateImplicit(
Context));
19130 if (ModulePrivateLoc.
isValid()) {
19131 if (isMemberSpecialization)
19132 Diag(
New->getLocation(), diag::err_module_private_specialization)
19139 New->setModulePrivate();
19159 Diag(Loc, diag::err_type_defined_in_param_type)
19165 }
else if (!PrevDecl) {
19169 Diag(Loc, diag::warn_decl_in_param_list)
19175 New->setInvalidDecl();
19202 New->startDefinition();
19204 New->setCompleteDefinition();
19205 New->demoteThisDefinitionToDeclaration();
19233 if (!
New->isInvalidDecl() &&
19234 New->getDeclContext()->getRedeclContext()->isTranslationUnit() &&
19241 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(
New)) {
19254 if (isMemberSpecialization && !
New->isInvalidDecl())
19261 if (
New->isBeingDefined())
19262 if (
auto RD = dyn_cast<RecordDecl>(
New))
19263 RD->completeDefinition();
19265 }
else if (SkipBody && SkipBody->
ShouldSkip) {
19299 bool IsFinalSpelledSealed,
19307 if (!
Record->getIdentifier())
19315 IsFinalSpelledSealed
19316 ? FinalAttr::Keyword_sealed
19317 : FinalAttr::Keyword_final));
19335 "Broken injected-class-name");
19342 Tag->setBraceRange(BraceRange);
19345 if (Tag->isBeingDefined()) {
19346 assert(Tag->isInvalidDecl() &&
"We should already have completed it");
19347 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
19348 RD->completeDefinition();
19351 if (
auto *RD = dyn_cast<CXXRecordDecl>(Tag)) {
19353 if (RD->hasAttr<SYCLSpecialClassAttr>()) {
19354 auto *Def = RD->getDefinition();
19355 assert(Def &&
"The record is expected to have a completed definition");
19356 unsigned NumInitMethods = 0;
19357 for (
auto *
Method : Def->methods()) {
19358 if (!
Method->getIdentifier())
19360 if (
Method->getName() ==
"__init")
19363 if (NumInitMethods > 1 || !Def->hasInitMethod())
19364 Diag(RD->getLocation(), diag::err_sycl_special_type_num_init_method);
19382 Tag->setTopLevelDeclInObjCContainer();
19385 if (!Tag->isInvalidDecl())
19386 Consumer.HandleTagDeclDefinition(Tag);
19390 if (
Context.getTargetInfo().getTriple().isOSAIX() &&
19396 const RecordDecl *RD = dyn_cast<RecordDecl>(Tag);
19400 if (llvm::any_of(RD->
fields(),
19401 [](
const FieldDecl *FD) { return FD->isBitField(); }))
19402 Diag(BraceRange.
getBegin(), diag::warn_pragma_align_not_xl_compatible);
19409 Tag->setInvalidDecl();
19412 if (Tag->isBeingDefined()) {
19413 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
19414 RD->completeDefinition();
19427 QualType FieldTy,
bool IsMsStruct,
19438 diag::err_field_incomplete_or_sizeless))
19441 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
19443 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
19453 llvm::APSInt
Value;
19458 BitWidth = ICE.
get();
19461 if (
Value == 0 && FieldName)
19462 return Diag(FieldLoc, diag::err_bitfield_has_zero_width)
19465 if (
Value.isSigned() &&
Value.isNegative()) {
19467 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
19469 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
19476 return Diag(FieldLoc, diag::err_bitfield_too_wide)
19481 uint64_t TypeStorageSize =
Context.getTypeSize(FieldTy);
19482 uint64_t TypeWidth =
Context.getIntWidth(FieldTy);
19483 bool BitfieldIsOverwide =
Value.ugt(TypeWidth);
19487 bool CStdConstraintViolation =
19489 bool MSBitfieldViolation =
Value.ugt(TypeStorageSize) && IsMsStruct;
19490 if (CStdConstraintViolation || MSBitfieldViolation) {
19491 unsigned DiagWidth =
19492 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
19493 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
19495 << !CStdConstraintViolation << DiagWidth;
19501 if (BitfieldIsOverwide && !FieldTy->
isBooleanType() && FieldName) {
19502 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
19545 TInfo =
Context.getTrivialTypeSourceInfo(
T, Loc);
19556 diag::err_invalid_thread)
19564 switch (
Previous.getResultKind()) {
19571 PrevDecl =
Previous.getRepresentativeDecl();
19585 PrevDecl =
nullptr;
19589 PrevDecl =
nullptr;
19596 TSSL, AS, PrevDecl, &D);
19599 Record->setInvalidDecl();
19618 bool Mutable,
Expr *BitWidth,
19624 bool InvalidDecl =
false;
19629 if (
T.isNull() ||
T->containsErrors()) {
19630 InvalidDecl =
true;
19636 bool isIncomplete =
19640 diag::err_field_incomplete_or_sizeless);
19641 if (isIncomplete) {
19643 Record->setInvalidDecl();
19644 InvalidDecl =
true;
19649 Record->setInvalidDecl();
19650 InvalidDecl =
true;
19656 if (
T.hasAddressSpace() ||
T->isDependentAddressSpaceType() ||
19657 T->getBaseElementTypeUnsafe()->isDependentAddressSpaceType()) {
19658 Diag(Loc, diag::err_field_with_address_space);
19659 Record->setInvalidDecl();
19660 InvalidDecl =
true;
19666 if (
T->isEventT() ||
T->isImageType() ||
T->isSamplerT() ||
19667 T->isBlockPointerType()) {
19668 Diag(Loc, diag::err_opencl_type_struct_or_union_field) <<
T;
19669 Record->setInvalidDecl();
19670 InvalidDecl =
true;
19675 "__cl_clang_bitfields",
LangOpts)) {
19676 Diag(Loc, diag::err_opencl_bitfields);
19677 InvalidDecl =
true;
19683 T.hasQualifiers()) {
19684 InvalidDecl =
true;
19685 Diag(Loc, diag::err_anon_bitfield_qualifiers);
19690 if (!InvalidDecl &&
T->isVariablyModifiedType()) {
19692 TInfo,
T, Loc, diag::err_typecheck_field_variable_size))
19693 InvalidDecl =
true;
19698 diag::err_abstract_type_in_decl,
19700 InvalidDecl =
true;
19703 BitWidth =
nullptr;
19709 InvalidDecl =
true;
19710 BitWidth =
nullptr;
19715 if (!InvalidDecl && Mutable) {
19716 unsigned DiagID = 0;
19717 if (
T->isReferenceType())
19718 DiagID =
getLangOpts().MSVCCompat ? diag::ext_mutable_reference
19719 : diag::err_mutable_reference;
19720 else if (
T.isConstQualified())
19721 DiagID = diag::err_mutable_const;
19727 Diag(ErrLoc, DiagID);
19728 if (DiagID != diag::ext_mutable_reference) {
19730 InvalidDecl =
true;
19742 BitWidth, Mutable, InitStyle);
19751 Diag(Loc, diag::err_duplicate_member) << II;
19757 if (
Record->isUnion()) {
19759 RD && (RD->isBeingDefined() || RD->isCompleteDefinition())) {
19774 const bool HaveMSExt =
19779 HaveMSExt ? diag::ext_union_member_of_reference_type
19780 : diag::err_union_member_of_reference_type)
19800 if (
getLangOpts().ObjCAutoRefCount &&
ObjC().inferObjCARCLifetime(NewFD))
19803 if (
T.isObjCGCWeak())
19804 Diag(Loc, diag::warn_attribute_weak_on_field);
19807 if (
Context.getTargetInfo().getTriple().isPPC64() &&
19811 if (
Context.getTargetInfo().hasAMDGPUTypes()) {
19829 RDecl && (RDecl->isBeingDefined() || RDecl->isCompleteDefinition())) {
19840 if (RDecl->hasNonTrivialCopyConstructor())
19842 else if (!RDecl->hasTrivialDefaultConstructor())
19844 else if (RDecl->hasNonTrivialCopyAssignment())
19846 else if (RDecl->hasNonTrivialDestructor())
19851 RDecl->hasObjectMember()) {
19859 if (!FD->
hasAttr<UnavailableAttr>())
19860 FD->
addAttr(UnavailableAttr::CreateImplicit(
19861 Context,
"", UnavailableAttr::IR_ARCFieldWithOwnership, Loc));
19868 ? diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member
19869 : diag::err_illegal_union_or_anon_struct_member)
19881 if (
LangOpts.ObjCRuntime.isFragile() || AllIvarDecls.empty())
19884 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
19892 if (!CD->IsClassExtension())
19909 AllIvarDecls.push_back(Ivar);
19921 if (!
Record->hasUserDeclaredDestructor()) {
19929 if (
auto *DD = dyn_cast<CXXDestructorDecl>(
Decl)) {
19930 if (DD->isInvalidDecl())
19934 assert(DD->isIneligibleOrNotSelected() &&
"Selecting a destructor but a destructor was already selected.");
19948 Record->addedSelectedDestructor(dyn_cast<CXXDestructorDecl>(Best->Function));
19952 Msg = diag::err_ambiguous_destructor;
19957 Msg = diag::err_no_viable_destructor;
19968 Record->setInvalidDecl();
19975 Record->addedSelectedDestructor(dyn_cast<CXXDestructorDecl>(OCS.
begin()->Function));
20019 if (!Method->getTrailingRequiresClause())
20020 SatisfactionStatus.push_back(
true);
20024 SatisfactionStatus.push_back(
false);
20026 SatisfactionStatus.push_back(Satisfaction.
IsSatisfied);
20030 for (
size_t i = 0; i < Methods.size(); i++) {
20031 if (!SatisfactionStatus[i])
20039 bool AnotherMethodIsMoreConstrained =
false;
20040 for (
size_t j = 0; j < Methods.size(); j++) {
20041 if (i == j || !SatisfactionStatus[j])
20055 AnotherMethodIsMoreConstrained =
true;
20059 AnotherMethodIsMoreConstrained)) {
20062 AnotherMethodIsMoreConstrained =
true;
20064 if (AnotherMethodIsMoreConstrained)
20069 if (!AnotherMethodIsMoreConstrained) {
20070 Method->setIneligibleOrNotSelected(
false);
20071 Record->addedEligibleSpecialMemberFunction(Method,
20072 1 << llvm::to_underlying(CSM));
20086 auto *MD = dyn_cast<CXXMethodDecl>(
Decl);
20088 auto *FTD = dyn_cast<FunctionTemplateDecl>(
Decl);
20090 MD = dyn_cast<CXXMethodDecl>(FTD->getTemplatedDecl());
20094 if (
auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
20095 if (CD->isInvalidDecl())
20097 if (CD->isDefaultConstructor())
20098 DefaultConstructors.push_back(MD);
20099 else if (CD->isCopyConstructor())
20100 CopyConstructors.push_back(MD);
20101 else if (CD->isMoveConstructor())
20102 MoveConstructors.push_back(MD);
20104 CopyAssignmentOperators.push_back(MD);
20106 MoveAssignmentOperators.push_back(MD);
20124 auto IsFunctionPointerOrForwardDecl = [&](
const Decl *D) {
20125 const FieldDecl *FD = dyn_cast<FieldDecl>(D);
20138 if (
const auto *TD = dyn_cast<TagDecl>(D))
20139 return !TD->isCompleteDefinition();
20154 return llvm::all_of(
Record->decls(), IsFunctionPointerOrForwardDecl);
20161 assert(EnclosingDecl &&
"missing record or interface decl");
20170 case Decl::ObjCCategory:
20173 case Decl::ObjCImplementation:
20181 CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(EnclosingDecl);
20185 unsigned NumNamedMembers = 0;
20187 for (
const auto *I :
Record->decls()) {
20188 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
20189 if (IFD->getDeclName())
20196 const FieldDecl *PreviousField =
nullptr;
20206 RecFields.push_back(FD);
20226 bool IsLastField = (i + 1 == Fields.end());
20241 unsigned DiagID = 0;
20242 if (!
Record->isUnion() && !IsLastField) {
20245 Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
20249 }
else if (
Record->isUnion())
20251 ? diag::ext_flexible_array_union_ms
20252 : diag::ext_flexible_array_union_gnu;
20253 else if (NumNamedMembers < 1)
20255 ? diag::ext_flexible_array_empty_aggregate_ms
20256 : diag::ext_flexible_array_empty_aggregate_gnu;
20266 if (CXXRecord && CXXRecord->getNumVBases() != 0)
20280 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
20287 Record->setHasFlexibleArrayMember(
true);
20296 diag::err_incomplete_type)
20299 diag::err_field_incomplete_or_sizeless))) {
20305 if (
Record && RD->hasFlexibleArrayMember()) {
20308 Record->setHasFlexibleArrayMember(
true);
20309 if (!
Record->isUnion()) {
20326 diag::err_abstract_type_in_decl,
20331 if (
Record && RD->hasObjectMember())
20332 Record->setHasObjectMember(
true);
20333 if (
Record && RD->hasVolatileMember())
20334 Record->setHasVolatileMember(
true);
20353 FD->
addAttr(UnavailableAttr::CreateImplicit(
20354 Context,
"", UnavailableAttr::IR_ARCFieldWithOwnership,
20358 !
Record->hasObjectMember()) {
20361 Record->setHasObjectMember(
true);
20364 if (
const auto *RD = BaseType->getAsRecordDecl();
20365 RD && RD->hasObjectMember())
20366 Record->setHasObjectMember(
true);
20367 else if (BaseType->isObjCObjectPointerType() ||
20368 BaseType.isObjCGCStrong())
20369 Record->setHasObjectMember(
true);
20374 !shouldIgnoreForRecordTriviality(FD)) {
20377 Record->setNonTrivialToPrimitiveDefaultInitialize(
true);
20380 Record->setHasNonTrivialToPrimitiveDefaultInitializeCUnion(
true);
20384 Record->setNonTrivialToPrimitiveCopy(
true);
20386 Record->setHasNonTrivialToPrimitiveCopyCUnion(
true);
20388 if (FD->
hasAttr<ExplicitInitAttr>())
20389 Record->setHasUninitializedExplicitInitFields(
true);
20391 Record->setNonTrivialToPrimitiveDestroy(
true);
20392 Record->setParamDestroyedInCallee(
true);
20394 Record->setHasNonTrivialToPrimitiveDestructCUnion(
true);
20398 if (RD->getArgPassingRestrictions() ==
20400 Record->setArgPassingRestrictions(
20403 Record->setArgPassingRestrictions(
20407 Record->setArgPassingRestrictions(
20409 Record->setNonTrivialToPrimitiveCopy(
true);
20414 Record->setHasVolatileMember(
true);
20415 bool ReportMSBitfieldStoragePacking =
20416 Record && PreviousField &&
20417 !
Diags.isIgnored(diag::warn_ms_bitfield_mismatched_storage_packing,
20419 auto IsNonDependentBitField = [](
const FieldDecl *FD) {
20423 if (ReportMSBitfieldStoragePacking && IsNonDependentBitField(FD) &&
20424 IsNonDependentBitField(PreviousField)) {
20428 if (FDStorageSize != PreviousFieldStorageSize) {
20430 diag::warn_ms_bitfield_mismatched_storage_packing)
20434 diag::note_ms_bitfield_mismatched_storage_size_previous)
20435 << PreviousField << PreviousField->
getType();
20445 bool Completed =
false;
20450 Record->setInvalidDecl();
20454 if (!CXXRecord->isInvalidDecl()) {
20457 I = CXXRecord->conversion_begin(),
20458 E = CXXRecord->conversion_end(); I != E; ++I)
20459 I.setAccess((*I)->getAccess());
20465 if (!CXXRecord->isDependentType()) {
20466 if (!CXXRecord->isInvalidDecl()) {
20470 if (CXXRecord->getNumVBases()) {
20472 CXXRecord->getFinalOverriders(FinalOverriders);
20474 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
20475 MEnd = FinalOverriders.end();
20478 SOEnd = M->second.end();
20479 SO != SOEnd; ++SO) {
20480 assert(SO->second.size() > 0 &&
20481 "Virtual function without overriding functions?");
20482 if (SO->second.size() == 1)
20489 Diag(
Record->getLocation(), diag::err_multiple_final_overriders)
20491 Diag(M->first->getLocation(),
20492 diag::note_overridden_virtual_function);
20494 OM = SO->second.begin(),
20495 OMEnd = SO->second.end();
20497 Diag(OM->Method->getLocation(), diag::note_final_overrider)
20498 << (
const NamedDecl *)M->first << OM->Method->getParent();
20500 Record->setInvalidDecl();
20503 CXXRecord->completeDefinition(&FinalOverriders);
20513 Record->completeDefinition();
20522 (
Record->hasAttr<RandomizeLayoutAttr>() ||
20523 (!
Record->hasAttr<NoRandomizeLayoutAttr>() &&
20524 EntirelyFunctionPointers(
Record)))) {
20528 Record->reorderDecls(NewDeclOrdering);
20533 auto *Dtor = CXXRecord->getDestructor();
20534 if (Dtor && Dtor->isImplicit() &&
20536 CXXRecord->setImplicitDestructorIsDeleted();
20541 if (
Record->hasAttrs()) {
20544 if (
const MSInheritanceAttr *IA =
Record->getAttr<MSInheritanceAttr>())
20546 IA->getRange(), IA->getBestCase(),
20547 IA->getInheritanceModel());
20553 bool CheckForZeroSize;
20555 CheckForZeroSize =
true;
20560 CXXRecord->getLexicalDeclContext()->isExternCContext() &&
20562 CXXRecord->isCLike();
20564 if (CheckForZeroSize) {
20565 bool ZeroSize =
true;
20566 bool IsEmpty =
true;
20567 unsigned NonBitFields = 0;
20569 E =
Record->field_end();
20570 (NonBitFields == 0 || ZeroSize) && I != E; ++I) {
20572 if (I->isUnnamedBitField()) {
20573 if (!I->isZeroLengthBitField())
20577 QualType FieldType = I->getType();
20579 !
Context.getTypeSizeInChars(FieldType).isZero())
20589 diag::warn_zero_size_struct_union_in_extern_c :
20590 diag::warn_zero_size_struct_union_compat)
20591 << IsEmpty <<
Record->isUnion() << (NonBitFields > 1);
20598 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union
20599 : diag::ext_no_named_members_in_struct_union)
20607 ID->setEndOfDefinitionLoc(RBrac);
20609 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
20611 ID->addDecl(ClsFields[i]);
20615 if (ID->getSuperClass())
20618 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
20619 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
20620 for (
unsigned I = 0, N = RecFields.size(); I != N; ++I)
20626 IMPDecl->setIvarLBraceLoc(LBrac);
20627 IMPDecl->setIvarRBraceLoc(RBrac);
20629 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
20637 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
20641 Diag(ClsFields[i]->getLocation(),
20642 diag::err_duplicate_ivar_declaration);
20643 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
20649 Diag(ClsFields[i]->getLocation(),
20650 diag::err_duplicate_ivar_declaration);
20651 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
20657 CDecl->addDecl(ClsFields[i]);
20659 CDecl->setIvarLBraceLoc(LBrac);
20660 CDecl->setIvarRBraceLoc(RBrac);
20676 assert((
T->isIntegralType(Context) ||
20677 T->isEnumeralType()) &&
"Integral type required!");
20678 const unsigned NumTypes = 4;
20679 QualType SignedIntegralTypes[NumTypes] = {
20680 Context.ShortTy, Context.IntTy, Context.LongTy, Context.LongLongTy
20682 QualType UnsignedIntegralTypes[NumTypes] = {
20683 Context.UnsignedShortTy, Context.UnsignedIntTy, Context.UnsignedLongTy,
20684 Context.UnsignedLongLongTy
20691 unsigned BitWidth = Context.getIntWidth(
T);
20692 QualType *Types =
T->isSignedIntegerOrEnumerationType()? SignedIntegralTypes
20693 : UnsignedIntegralTypes;
20694 for (
unsigned I = 0; I != NumTypes; ++I)
20695 if (Context.getTypeSize(Types[I]) > BitWidth)
20706 unsigned IntWidth =
Context.getTargetInfo().getIntWidth();
20707 llvm::APSInt EnumVal(IntWidth);
20727 EltTy =
Enum->getIntegerType();
20733 Val = Converted.
get();
20740 if (
Enum->isComplete()) {
20741 EltTy =
Enum->getIntegerType();
20747 if (!
Context.isRepresentableIntegerValue(EnumVal, EltTy)) {
20750 .isWindowsMSVCEnvironment()) {
20751 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
20753 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
20776 if (!
Context.isRepresentableIntegerValue(EnumVal,
Context.IntTy)) {
20778 ? diag::warn_c17_compat_enum_value_not_int
20779 : diag::ext_c23_enum_value_not_int)
20781 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
20793 if (
Enum->isDependentType())
20795 else if (!LastEnumConst) {
20804 if (
Enum->isFixed()) {
20805 EltTy =
Enum->getIntegerType();
20814 EltTy = LastEnumConst->
getType();
20817 if (EnumVal < LastEnumConst->getInitVal()) {
20829 if (
T.isNull() ||
Enum->isFixed()) {
20833 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
20835 if (
Enum->isFixed())
20837 Diag(IdLoc, diag::err_enumerator_wrapped)
20841 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
20852 EnumVal = EnumVal.zextOrTrunc(
Context.getIntWidth(EltTy));
20864 ? diag::warn_c17_compat_enum_value_not_int
20865 : diag::ext_c23_enum_value_not_int)
20866 << 1 <<
toString(EnumVal, 10) << 1;
20868 !
Context.isRepresentableIntegerValue(EnumVal, EltTy)) {
20871 : diag::ext_c23_enum_value_not_int)
20872 << 1 <<
toString(EnumVal, 10) << 1;
20880 EnumVal = EnumVal.extOrTrunc(
Context.getIntWidth(EltTy));
20899 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
20907 Skip.Previous = Hidden;
20921 cast_or_null<EnumConstantDecl>(lastEnumConst);
20938 PrevDecl =
nullptr;
20965 "Received TagDecl when not in C++!");
20968 Diag(IdLoc, diag::err_redefinition_of_enumerator) << Id;
20970 Diag(IdLoc, diag::err_redefinition) << Id;
21003 if (!BO->isAdditiveOp())
21011 InitExpr = BO->getLHS();
21015 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InitExpr);
21035 if (!
Enum->getIdentifier())
21039 if (
Enum->getNumPositiveBits() > 63 ||
Enum->getNumNegativeBits() > 64)
21048 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
21051 typedef std::unordered_map<int64_t, DeclOrVector> ValueToVectorMap;
21055 llvm::APSInt Val = D->getInitVal();
21056 return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
21059 DuplicatesVector DupVector;
21060 ValueToVectorMap EnumMap;
21064 for (
auto *Element : Elements) {
21078 EnumMap.insert({EnumConstantToKey(ECD), ECD});
21081 if (EnumMap.size() == 0)
21085 for (
auto *Element : Elements) {
21091 auto Iter = EnumMap.find(EnumConstantToKey(ECD));
21092 if (Iter == EnumMap.end())
21095 DeclOrVector& Entry = Iter->second;
21102 auto Vec = std::make_unique<ECDVector>();
21104 Vec->push_back(ECD);
21111 DupVector.emplace_back(std::move(Vec));
21117 if (*Vec->begin() == ECD)
21120 Vec->push_back(ECD);
21124 for (
const auto &Vec : DupVector) {
21125 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
21128 auto *FirstECD = Vec->front();
21129 S.
Diag(FirstECD->getLocation(), diag::warn_duplicate_enum_values)
21130 << FirstECD <<
toString(FirstECD->getInitVal(), 10)
21131 << FirstECD->getSourceRange();
21135 for (
auto *ECD : llvm::drop_begin(*Vec))
21136 S.
Diag(ECD->getLocation(), diag::note_duplicate_element)
21137 << ECD <<
toString(ECD->getInitVal(), 10)
21138 << ECD->getSourceRange();
21143 bool AllowMask)
const {
21144 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
21148 llvm::APInt &FlagBits = R.first->second;
21152 const auto &EVal = E->getInitVal();
21154 if (EVal.isPowerOf2())
21155 FlagBits = FlagBits.zext(EVal.getBitWidth()) | EVal;
21167 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
21168 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
21175 bool HasBitwiseOp =
false;
21180 for (
const auto *ECD :
Enum->enumerators()) {
21181 const Expr *InitExpr = ECD->getInitExpr();
21187 if (
const auto *BinOp = dyn_cast<BinaryOperator>(E)) {
21191 if (BinOp->isBitwiseOp() || BinOp->isShiftOp()) {
21192 HasBitwiseOp =
true;
21193 }
else if (Op == BO_LT || Op == BO_GT) {
21196 if (
const auto *IntLiteral = dyn_cast<IntegerLiteral>(LHS)) {
21198 if (IntLiteral->getValue() == 1)
21199 SuspiciousCompares.push_back(BinOp);
21207 if (HasBitwiseOp) {
21208 for (
const auto *BinOp : SuspiciousCompares) {
21209 StringRef SuggestedOp = (BinOp->getOpcode() == BO_LT)
21214 Sema.
Diag(OperatorLoc, diag::warn_comparison_in_enum_initializer)
21215 << BinOp->getOpcodeStr() << SuggestedOp;
21217 Sema.
Diag(OperatorLoc, diag::note_enum_compare_typo_suggest)
21233 if (
Enum->isDependentType()) {
21234 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
21236 cast_or_null<EnumConstantDecl>(Elements[i]);
21237 if (!ECD)
continue;
21248 unsigned NumNegativeBits = 0;
21249 unsigned NumPositiveBits = 0;
21250 bool MembersRepresentableByInt =
21251 Context.computeEnumBits(Elements, NumNegativeBits, NumPositiveBits);
21255 unsigned BestWidth;
21276 if (
Enum->isComplete()) {
21277 BestType =
Enum->getIntegerType();
21278 if (
Context.isPromotableIntegerType(BestType))
21279 BestPromotionType =
Context.getPromotedIntegerType(BestType);
21281 BestPromotionType = BestType;
21283 BestWidth =
Context.getIntWidth(BestType);
21285 bool EnumTooLarge =
Context.computeBestEnumTypes(
21286 Packed, NumNegativeBits, NumPositiveBits, BestType, BestPromotionType);
21287 BestWidth =
Context.getIntWidth(BestType);
21289 Diag(
Enum->getLocation(), diag::ext_enum_too_large);
21294 for (
auto *D : Elements) {
21295 auto *ECD = cast_or_null<EnumConstantDecl>(D);
21296 if (!ECD)
continue;
21305 llvm::APSInt InitVal = ECD->getInitVal();
21313 MembersRepresentableByInt) {
21321 NewWidth =
Context.getTargetInfo().getIntWidth();
21323 }
else if (ECD->getType() == BestType) {
21331 ECD->setType(EnumType);
21335 NewWidth = BestWidth;
21340 InitVal = InitVal.extOrTrunc(NewWidth);
21341 InitVal.setIsSigned(NewSign);
21342 ECD->setInitVal(
Context, InitVal);
21345 if (ECD->getInitExpr() &&
21346 !
Context.hasSameType(NewTy, ECD->getInitExpr()->getType()))
21348 Context, NewTy, CK_IntegralCast, ECD->getInitExpr(),
21357 ECD->setType(EnumType);
21359 ECD->setType(NewTy);
21362 Enum->completeDefinition(BestType, BestPromotionType,
21363 NumPositiveBits, NumNegativeBits);
21368 if (
Enum->isClosedFlag()) {
21369 for (
Decl *D : Elements) {
21371 if (!ECD)
continue;
21374 if (InitVal != 0 && !InitVal.isPowerOf2() &&
21382 if (
Enum->hasAttrs())
21421 AsmLabelAttr *
Attr =
21422 AsmLabelAttr::CreateImplicit(
Context, AliasName->
getName(), Info);
21432 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
21445 PrevDecl->
addAttr(WeakAttr::CreateImplicit(
Context, PragmaLoc));
21461 if (!PrevDecl->
hasAttr<AliasAttr>())
21462 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
21471 assert(FD &&
"Expected non-null FunctionDecl");
21478 FD->
hasAttr<SYCLKernelEntryPointAttr>() ||
21479 FD->
hasAttr<SYCLExternalAttr>()))
21483 auto IsEmittedForExternalSymbol = [
this, FD]() {
21495 if (
LangOpts.OpenMPIsTargetDevice) {
21498 std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
21505 if (*DevTy == OMPDeclareTargetDeclAttr::DT_Host)
21509 if (
OpenMP().isInOpenMPDeclareTargetContext() || DevTy)
21510 if (IsEmittedForExternalSymbol())
21516 }
else if (
LangOpts.OpenMP > 45) {
21520 std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
21523 if (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost)
21542 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.
#define CC_VLS_CASE(ABI_VLEN)
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 bool isSYCLAddressSpace(LangAS AS)
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
bool isImplicit() const
Returns true if the attribute has been implicitly created instead of explicitly written by the user.
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)
CXXSpecialMemberKind getSpecialMemberKind() const
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)
This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
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
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
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()
DeclContext * getEnclosingNonExpansionStatementContext()
Retrieve the innermost enclosing context that doesn't belong to an expansion statement.
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, bool AllowRelaxedEval=false) 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.
bool isGlobalModule() const
Does this Module scope describe a fragment of the global module within some C++ module.
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.
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
static std::string getAddrSpaceAsString(LangAS AS)
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 checkNamedBarrierWrapper(RecordDecl *R)
Called in ActOnFields - whenever a C/C++ Record is being finalized.
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)
SwiftAttrAttr * mergeAttrAttr(Decl *D, const SwiftAttrAttr &SAA)
WebAssemblyExportNameAttr * mergeExportNameAttr(Decl *D, const WebAssemblyExportNameAttr &AL)
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)
bool isFromSameSingleIncludeHeader(const Decl *PrevD, SourceLocation NewLoc)
Determine if a definition at NewLoc coincides with PrevD.
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)
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)
void addImplicitCallingConvAbiTag(FunctionDecl *FD)
Attach the ABI tag a standard calling convention variant requires, as an implicit abi_tag attribute.
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.
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
void CleanupMergedEnum(Scope *S, Decl *New)
CleanupMergedEnum - We have just merged the decl 'New' by making another definition visible.
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD, QualType NewT, QualType OldT)
Determines if we can perform a correct type check for D as a redeclaration of PrevDecl.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_enum attribute.
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible.
void diagnoseFunctionEffectMergeConflicts(const FunctionEffectSet::Conflicts &Errs, SourceLocation NewLoc, SourceLocation OldLoc)
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
bool areMultiversionVariantFunctionsCompatible(const FunctionDecl *OldFD, const FunctionDecl *NewFD, const PartialDiagnostic &NoProtoDiagID, const PartialDiagnosticAt &NoteCausedDiagIDAt, const PartialDiagnosticAt &NoSupportDiagIDAt, const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported, bool ConstexprSupported, bool CLinkageMayDiffer)
Checks if the variant/multiversion functions are compatible.
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e....
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
PragmaClangSection PragmaClangTextSection
FormatMatchesAttr * mergeFormatMatchesAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Format, int FormatIdx, StringLiteral *FormatStr)
PragmaClangSection PragmaClangDataSection
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true)
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaRedefineExtname - Called on well formed #pragma redefine_extname oldname newname.
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
MaybeODRUseExprSet MaybeODRUseExprs
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
CheckParmsForFunctionDef - Check that the parameters of the given function are appropriate for the de...
TopLevelStmtDecl * ActOnStartTopLevelStmtDecl(Scope *S)
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc, ImplicitTypenameContext IsImplicitTypename=ImplicitTypenameContext::No)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
void ProcessPragmaExport(DeclaratorDecl *newDecl)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
void CheckCompleteVariableDeclaration(VarDecl *VD)
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
void setFunctionHasBranchProtectedScope()
RedeclarationKind forRedeclarationInCurContext() const
void MergeVarDecl(VarDecl *New, LookupResult &Previous)
MergeVarDecl - We just parsed a variable 'New' which has the same name and scope as a previous declar...
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool IsTemplateTypeArg)
Attempt to behave like MSVC in situations where lookup of an unqualified type name has failed in a de...
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
bool isRedefinitionAllowedFor(NamedDecl *D, SourceLocation NewDefinitionLoc, NamedDecl **Suggested, bool &Visible)
Determine if D has a definition which allows we redefine it in current TU.
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *TSI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID=diag::err_init_element_not_constant)
type checking declaration initializers (C99 6.7.8)
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
SmallVector< ExprWithCleanups::CleanupObject, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
@ FirstDecl
Parsing the first decl in a TU.
void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc)
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, const ParsedAttributesView &DeclAttrs, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e....
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD)
Only called on function definitions; if there is a MSVC pragma optimize in scope, consider changing t...
bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl)
Checks if the new declaration declared in dependent context must be put in the same redeclaration cha...
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
void DiscardCleanupsInEvaluationContext()
llvm::SmallPtrSet< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
void warnOnCTypeHiddenInCPlusPlus(const NamedDecl *D)
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location.
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AvailabilityMergeKind::Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc, StringLiteral *Message=nullptr)
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure.
static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD)
DiagnosticsEngine & Diags
OpenCLOptions & getOpenCLOptions()
static bool CanBeGetReturnObject(const FunctionDecl *FD)
NamespaceDecl * getStdNamespace() const
bool IsAtLeastAsConstrained(const NamedDecl *D1, MutableArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, MutableArrayRef< AssociatedConstraint > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
void addLifetimeBoundToImplicitThis(CXXMethodDecl *MD)
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
void LoadExternalExtnameUndeclaredIdentifiers()
Load pragma redefine_extname'd undeclared identifiers from the external source.
PragmaStack< StringLiteral * > DataSegStack
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
@ TPC_FriendFunctionTemplate
@ TPC_ClassTemplateMember
@ TPC_FriendFunctionTemplateDefinition
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name,...
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
friend class InitializationSequence
bool GloballyUniqueObjectMightBeAccidentallyDuplicated(const VarDecl *Dcl)
Certain globally-unique variables might be accidentally duplicated if built into multiple shared libr...
bool isMainFileLoc(SourceLocation Loc) const
Determines whether the given source location is in the main file and we're in a context where we shou...
void DiagnoseUnusedDecl(const NamedDecl *ND)
void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init)
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
QualType SubstAutoTypeDependent(QualType TypeWithAuto)
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope.
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it,...
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool AllowTypoCorrection=true)
void ActOnUninitializedDecl(Decl *dcl)
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool isTagRedeclarationInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
Determine whether a tag-like declaration found by lookup can be redeclared in the given scope.
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec.
Decl * ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth)
ActOnField - Each field of a C struct/union is passed into this in order to create a FieldDecl object...
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, bool IsMemberSpecialization, SkipBodyInfo *SkipBody=nullptr)
PragmaClangSection PragmaClangBSSSection
Decl * ActOnDeclarator(Scope *S, Declarator &D)
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
void CheckAlignasUnderalignment(Decl *D)
bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old)
A wrapper function for checking the semantic restrictions of a redeclaration within a module.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
ExprResult ActOnNameClassifiedAsDependentNonType(const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, bool IsAddressOfOperand)
Act on the result of classifying a name as an undeclared member of a dependent base class.
void adjustMemberFunctionCC(QualType &T, bool HasThisPointer, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly.
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
void CheckVariableDeclarationType(VarDecl *NewVD)
OpaquePtr< TemplateName > TemplateTy
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New)
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
llvm::SmallPtrSet< const NamedDecl *, 4 > TypoCorrectedFunctionDefinitions
The function definitions which were renamed as part of typo-correction to match their respective decl...
void AddSectionMSAllocText(FunctionDecl *FD)
Only called on function definitions; if there is a #pragma alloc_text that decides which code section...
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
void checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Format, int FormatIdx, int FirstArg)
IdentifierResolver IdResolver
bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, bool AllowMask) const
IsValueInFlagEnum - Determine if a value is allowed as part of a flag enum.
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
void DiagnoseSizeOfParametersAndReturnValue(ArrayRef< ParmVarDecl * > Parameters, QualType ReturnTy, NamedDecl *D)
Diagnose whether the size of parameters or return value of a function or obj-c method definition is p...
void checkTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK, TypeDecl *TD, SourceLocation NameLoc)
Returns the TypeDeclType for the given type declaration, as ASTContext::getTypeDeclType would,...
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where 'self' is implicitly retained inside a block.
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
void warnOnReservedIdentifier(const NamedDecl *D)
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
void inferNullableClassAttribute(CXXRecordDecl *CRD)
Add _Nullable attributes for std:: types.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
SourceLocation getStrTokenLoc(unsigned TokNum) const
Get one of the string literal token.
StringRef getString() const
Represents the declaration of a struct/union/class/enum.
static TagDecl * castFromDeclContext(const DeclContext *DC)
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
SourceLocation getInnerLocStart() const
Return SourceLocation representing start of source range ignoring outer template declarations.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
TagKind getTagKind() const
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
void setElaboratedKeywordLoc(SourceLocation Loc)
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Exposes information about the current target.
virtual bool validateCpuIs(StringRef Name) const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual llvm::APInt getFMVPriority(ArrayRef< StringRef > Features) const
virtual bool validateCpuSupports(StringRef Name) const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const
bool supportsMultiVersioning() const
Identify whether this target supports multiversioning of functions, which requires support for cpu_su...
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getRAngleLoc() const
SourceLocation getTemplateLoc() const
Token - This structure provides full information about a lexed token.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
bool isOneOf(Ts... Ks) const
bool isNot(tok::TokenKind K) const
A declaration that models statements at global scope.
static TopLevelStmtDecl * Create(ASTContext &C, Stmt *Statement)
Represents a declaration of a type.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
SourceLocation getEndLoc() const
Get the end source location.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
bool isStructureType() const
bool isDependentSizedArrayType() const
bool isBooleanType() const
bool isFunctionReferenceType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isIncompleteArrayType() const
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isFunctionPointerType() const
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isHLSLIntangibleType() const
bool isScalarType() const
bool isVariableArrayType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isOpenCLSpecificType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
RecordDecl * castAsRecordDecl() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
bool containsErrors() const
Whether this type is an error type.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isAtomicType() const
bool isFunctionProtoType() const
bool isObjCIdType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isObjCObjectType() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isPointerOrReferenceType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isMemberFunctionPointerType() const
bool isFloatingType() const
bool isAnyPointerType() const
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
bool isRecordType() const
bool isHLSLResourceRecordArray() const
bool isReserveIDT() const
NullabilityKindOrNone getNullability() const
Determine the nullability of the given type.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
QualType getUnderlyingType() const
void setTypeSourceInfo(TypeSourceInfo *newType)
Wrapper for source info for typedefs.
TypedefNameDecl * getDecl() const
Simple class containing the result of Sema::CorrectTypo.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
SmallVectorImpl< NamedDecl * >::const_iterator const_decl_iterator
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
NestedNameSpecifier getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
Expr * getSubExpr() const
static bool isIncrementDecrementOp(Opcode Op)
Represents a C++ unqualified-id that has been parsed.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
UnionParsedType ConstructorName
When Kind == IK_ConstructorName, the class-name of the type whose constructor is being referenced.
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
const IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId,...
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Wrapper for source info for unresolved typename using decls.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Wrapper for source info for types used via transparent aliases.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
void setCXXForRangeDecl(bool FRD)
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
TLSKind getTLSKind() const
void setInitStyle(InitializationStyle Style)
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool isCXXCondDecl() const
@ ListInit
Direct list-initialization (C++11)
@ ParenListInit
Parenthesized list-initialization (C++20)
@ CallInit
Call-style initialization (C++98)
void setStorageClass(StorageClass SC)
void setPreviousDeclInSameBlockScope(bool Same)
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
void assignAddressSpace(const ASTContext &Ctxt, LangAS AS)
Apply a deduced address space, if one isn't already set.
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
void setInlineSpecified()
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
void setTSCSpec(ThreadStorageClassSpecifier TSC)
bool isInline() const
Whether this variable is (C++1z) inline.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
VarDecl * getInitializingDeclaration()
Get the initializing declaration of this variable, if any.
void setConstexpr(bool IC)
@ TLS_Static
TLS with a known-constant initializer.
@ TLS_Dynamic
TLS with a dynamic initializer.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
@ TentativeDefinition
This declaration is a tentative definition.
@ DeclarationOnly
This declaration is only a declaration.
@ Definition
This declaration is definitely a definition.
void setDescribedVarTemplate(VarTemplateDecl *Template)
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setImplicitlyInline()
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
VarDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
bool hasDependentAlignment() const
Determines if this variable's alignment is dependent.
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
Declaration of a variable template.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Captures information about a #pragma weak directive.
void disableCheckFallThrough()
ValueDecl * getVariable() const
bool isVariableCapture() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
void addVLATypeCapture(SourceLocation Loc, const VariableArrayType *VLAType, QualType CaptureType)
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
SmallVector< Capture, 4 > Captures
Captures - The captures.
ImplicitCaptureStyle ImpCaptureStyle
bool isCXXThisCaptured() const
Determine whether the C++ 'this' is captured.
void addThisCapture(bool isNested, SourceLocation Loc, QualType CaptureType, bool ByCopy)
void addCapture(ValueDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
Retains information about a function, method, or block that is currently being parsed.
bool UsesFPIntrin
Whether this function uses constrained floating point intrinsics.
void addByrefBlockVar(VarDecl *VD)
bool NeedsScopeChecking() const
bool ObjCShouldCallSuper
A flag that is set when parsing a method that must call super's implementation, such as -dealloc,...
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
bool HasPotentialAvailabilityViolations
Whether we make reference to a declaration that could be unavailable.
Expr * SYCLKernelLaunchIdExpr
An unresolved identifier lookup expression for an implicit call to a SYCL kernel launch function in a...
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
bool BeforeCompoundStatement
TemplateParameterList * GLTemplateParameterList
If this is a generic lambda, and the template parameter list has been created (from the TemplateParam...
ParmVarDecl * ExplicitObjectParameter
llvm::SmallVector< ShadowedOuterDecl, 4 > ShadowingDecls
CXXRecordDecl * Lambda
The class that describes the lambda.
bool AfterParameterList
Indicate that we parsed the parameter list at which point the mutability of the lambda is known.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
bool Mutable
Whether this is a mutable lambda.
Provides information about an attempted template argument deduction, whose success or failure was des...
Defines the clang::TargetInfo interface.
Public enums and private classes that are part of the SourceManager implementation.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
constexpr bool isInitializedByPipeline(LangAS AS)
bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
bool randomizeStructureLayout(const ASTContext &Context, RecordDecl *RD, llvm::SmallVectorImpl< Decl * > &FinalOrdering)
Top level wrappers for InstallAPI frontend operations.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
@ NonFunction
This is not an overload because the lookup results contain a non-function.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
GVALinkage
A more specific kind of linkage than enum Linkage.
@ GVA_AvailableExternally
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
int hasAttribute(AttributeCommonInfo::Syntax Syntax, llvm::StringRef ScopeName, llvm::StringRef AttrName, const TargetInfo &Target, const LangOptions &LangOpts, bool CheckPlugins)
Return the version number associated with the attribute if we recognize and implement the attribute s...
ConstexprSpecKind
Define the kind of constexpr specifier.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ Found
Name lookup found a single declaration that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
InClassInitStyle
In-class initialization styles for non-static data members.
@ ICIS_NoInit
No in-class initializer.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
OverloadCandidateDisplayKind
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
std::pair< FileID, unsigned > FileIDAndOffset
@ LCK_ByRef
Capturing by reference.
@ LCK_StarThis
Capturing the *this object by copy.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
@ TemplateTemplateArgument
@ DefaultInitializedObject
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
@ None
Don't merge availability attributes at all.
@ Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
@ OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
@ Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
@ ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
@ IK_DeductionGuideName
A deduction-guide name (a template-name)
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_ConstructorTemplateId
A constructor named via a template-id.
@ IK_ConstructorName
A constructor name.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ IK_ConversionFunctionId
A conversion function name, e.g., operator int.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
ActionResult< Decl * > DeclResult
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
@ AmbiguousTagHiding
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.
StorageClass
Storage classes.
@ TSCS_thread_local
C++11 thread_local.
@ TSCS__Thread_local
C11 _Thread_local.
@ TSCS___thread
GNU __thread.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
MutableArrayRef< Expr * > MultiExprArg
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
llvm::Expected< Decl * > ExpectedDecl
@ SD_Thread
Thread storage duration.
@ SD_Static
Static storage duration.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
@ Template
We are parsing a template declaration.
TagTypeKind
The kind of a tag type.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...
bool isDiscardableGVALinkage(GVALinkage L)
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ CanNeverPassInRegs
The argument of this type cannot be passed directly in registers.
MutableArrayRef< ParsedTemplateArgument > ASTTemplateArgsPtr
@ Deduced
The normal deduced case.
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
CXXSpecialMemberKind
Kinds of C++ special members.
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
bool isExternalFormalLinkage(Linkage L)
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TemplateDeductionResult
Describes the result of template argument deduction.
@ Success
Template argument deduction was successful.
@ AlreadyDiagnosed
Some error which was already diagnosed.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
@ None
The alignment was not explicit in code.
@ Enumerator
Enumerator value with fixed underlying type.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ None
No keyword precedes the qualified type name.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
ActionResult< Expr * > ExprResult
@ Other
Other implicit parameter.
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
@ HiddenVisibility
Objects with "hidden" visibility are not seen by the dynamic linker.
ActionResult< Stmt * > StmtResult
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
const Expr * ConstraintExpr
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword).
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword).
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
const IdentifierInfo * Ident
One instance of this struct is used for each type in a declarator that is parsed.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
MemberPointerTypeInfo Mem
enum clang::DeclaratorChunk::@340323374315200305336204205154073066142310370142 Kind
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
EvalResult is a struct with detailed info about an evaluated expression.
Extra information about a function prototype.
FunctionEffectsRef FunctionEffects
unsigned CFIUncheckedCallee
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &ESI)
static StringRef getTagTypeKindName(TagTypeKind Kind)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
An element in an Objective-C dictionary literal.
Expr * Value
The value of the dictionary element.
Expr * Key
The key for the dictionary element.
Contains information gathered from parsing the contents of TargetAttr.
std::vector< std::string > Features
Describes how types, statements, expressions, and declarations should be printed.
SourceLocation CurrentPragmaLocation
Information about a template-id annotation token.
const IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
unsigned NumArgs
NumArgs - The number of template arguments.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
OpaquePtr< T > get() const
SourceLocation SymbolLocations[3]
The source locations of the individual tokens that name the operator, e.g., the "new",...
OverloadedOperatorKind Operator
The kind of overloaded operator.