46 #include "llvm/ADT/SmallString.h" 47 #include "llvm/ADT/Triple.h" 52 using namespace clang;
57 Decl *Group[2] = { OwnedType, Ptr };
68 TypeNameValidatorCCC(
bool AllowInvalid,
bool WantClass =
false,
69 bool AllowTemplates =
false,
70 bool AllowNonTemplates =
true)
71 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
72 AllowTemplates(AllowTemplates), AllowNonTemplates(AllowNonTemplates) {
73 WantExpressionKeywords =
false;
74 WantCXXNamedCasts =
false;
75 WantRemainingKeywords =
false;
80 if (!AllowInvalidDecl && ND->isInvalidDecl())
84 return AllowTemplates;
86 bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
90 if (AllowNonTemplates)
97 if (!RD || !RD->isInjectedClassName())
99 RD = cast<CXXRecordDecl>(RD->getDeclContext());
101 isa<ClassTemplateSpecializationDecl>(RD);
107 return !WantClassName && candidate.
isKeyword();
110 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
111 return std::make_unique<TypeNameValidatorCCC>(*this);
115 bool AllowInvalidDecl;
118 bool AllowNonTemplates;
130 case tok::kw___int64:
131 case tok::kw___int128:
133 case tok::kw_unsigned:
140 case tok::kw__Float16:
141 case tok::kw___float128:
142 case tok::kw_wchar_t:
144 case tok::kw___underlying_type:
145 case tok::kw___auto_type:
148 case tok::annot_typename:
149 case tok::kw_char16_t:
150 case tok::kw_char32_t:
152 case tok::annot_decltype:
153 case tok::kw_decltype:
154 return getLangOpts().CPlusPlus;
156 case tok::kw_char8_t:
157 return getLangOpts().Char8;
183 return UnqualifiedTypeNameLookupResult::NotFound;
186 UnqualifiedTypeNameLookupResult::NotFound;
189 if (
auto *BaseTT =
Base.getType()->getAs<
TagType>())
190 BaseRD = BaseTT->getAsCXXRecordDecl();
194 if (!TST || !TST->isDependentType())
196 auto *TD = TST->getTemplateName().getAsTemplateDecl();
199 if (
auto *BasePrimaryTemplate =
200 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
202 BaseRD = BasePrimaryTemplate;
203 else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
205 CTD->findPartialSpecialization(
Base.getType()))
213 if (!isa<TypeDecl>(ND))
214 return UnqualifiedTypeNameLookupResult::FoundNonType;
215 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
217 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
219 case UnqualifiedTypeNameLookupResult::FoundNonType:
220 return UnqualifiedTypeNameLookupResult::FoundNonType;
221 case UnqualifiedTypeNameLookupResult::FoundType:
222 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
224 case UnqualifiedTypeNameLookupResult::NotFound:
231 return FoundTypeDecl;
240 UnqualifiedTypeNameLookupResult::NotFound;
242 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
243 DC = DC->getParent()) {
250 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
256 S.
Diag(NameLoc, diag::ext_found_via_dependent_bases_lookup) << &II;
284 bool isClassName,
bool HasTrailingDot,
286 bool IsCtorOrDtorName,
287 bool WantNontrivialTypeSourceInfo,
288 bool IsClassTemplateDeductionContext,
291 bool AllowDeducedTemplate = IsClassTemplateDeductionContext &&
292 getLangOpts().CPlusPlus17 && !IsCtorOrDtorName &&
293 !isClassName && !HasTrailingDot;
300 LookupCtx = computeDeclContext(ObjectType);
302 LookupCtx = computeDeclContext(*SS,
false);
305 if (isDependentScopeSpecifier(*SS)) {
315 if (!isClassName && !IsCtorOrDtorName)
320 if (WantNontrivialTypeSourceInfo)
321 return ActOnTypenameType(S,
SourceLocation(), *SS, II, NameLoc).get();
333 RequireCompleteDeclContext(*SS, LookupCtx))
347 LookupQualifiedName(Result, LookupCtx);
349 if (ObjectTypePtr && Result.
empty()) {
356 LookupName(Result, S);
360 LookupName(Result, S);
364 if (Result.
empty() && getLangOpts().MSVCCompat && (!SS || SS->
isEmpty())) {
376 TypeNameValidatorCCC CCC(
true, isClassName,
377 AllowDeducedTemplate);
379 S, SS, CCC, CTK_ErrorRecovery);
382 bool MemberOfUnknownSpecialization;
391 if (Correction && (NNS || NewII != &II) &&
396 isTemplateName(S, *NewSSPtr,
false, TemplateName,
nullptr,
false,
397 Template, MemberOfUnknownSpecialization))) {
399 isClassName, HasTrailingDot, ObjectTypePtr,
401 WantNontrivialTypeSourceInfo,
402 IsClassTemplateDeductionContext);
404 diagnoseTypo(Correction,
405 PDiag(diag::err_unknown_type_or_class_name_suggest)
408 SS->MakeTrivial(Context, NNS,
SourceRange(NameLoc));
409 *CorrectedII = NewII;
434 Res != ResEnd; ++Res) {
435 if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res) ||
466 assert(IIDecl &&
"Didn't find decl");
469 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
473 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
475 if (!isClassName && !IsCtorOrDtorName && LookupRD && FoundRD &&
476 FoundRD->isInjectedClassName() &&
478 Diag(NameLoc, diag::err_out_of_line_qualified_id_type_names_constructor)
481 DiagnoseUseOfDecl(IIDecl, NameLoc);
484 MarkAnyDeclReferenced(TD->getLocation(), TD,
false);
486 (void)DiagnoseUseOfDecl(IDecl, NameLoc);
489 }
else if (AllowDeducedTemplate) {
504 if (SS && SS->
isNotEmpty() && !IsCtorOrDtorName &&
505 !isa<ObjCInterfaceDecl>(IIDecl)) {
506 if (WantNontrivialTypeSourceInfo) {
511 T = getElaboratedType(
ETK_None, *SS, T);
517 T = getElaboratedType(
ETK_None, *SS, T);
530 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
532 else if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
534 RD->getTypeForDecl());
535 else if (isa<TranslationUnitDecl>(DC))
538 llvm_unreachable(
"something isn't in TU scope?");
549 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
550 if (MD->getParent()->hasAnyDependentBases())
558 bool IsTemplateTypeArg) {
559 assert(getLangOpts().MSVCCompat &&
"shouldn't be called in non-MSVC mode");
562 if (IsTemplateTypeArg && getCurScope()->isTemplateParamScope()) {
571 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
577 RD->getTypeForDecl());
581 Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
612 LookupName(R, S,
false);
616 switch (TD->getTagKind()) {
643 if (CurContext->isRecord()) {
663 bool IsTemplateName) {
668 SuggestedType =
nullptr;
672 TypeNameValidatorCCC CCC(
false,
false,
677 CCC, CTK_ErrorRecovery)) {
679 bool CanRecover = !IsTemplateName;
680 if (Corrected.isKeyword()) {
682 diagnoseTypo(Corrected,
683 PDiag(IsTemplateName ? diag::err_no_template_suggest
684 : diag::err_unknown_typename_suggest)
686 II = Corrected.getCorrectionAsIdentifierInfo();
689 if (!SS || !SS->
isSet()) {
690 diagnoseTypo(Corrected,
691 PDiag(IsTemplateName ? diag::err_no_template_suggest
692 : diag::err_unknown_typename_suggest)
694 }
else if (
DeclContext *DC = computeDeclContext(*SS,
false)) {
695 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
696 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
697 II->
getName().equals(CorrectedStr);
698 diagnoseTypo(Corrected,
700 ? diag::err_no_member_template_suggest
701 : diag::err_unknown_nested_typename_suggest)
702 << II << DC << DroppedSpecifier << SS->
getRange(),
705 llvm_unreachable(
"could not have corrected a typo here");
712 if (Corrected.getCorrectionSpecifier())
713 tmpSS.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
717 getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc, S,
718 tmpSS.
isSet() ? &tmpSS : SS,
false,
false,
nullptr,
725 if (getLangOpts().CPlusPlus && !IsTemplateName) {
731 bool MemberOfUnknownSpecialization;
732 if (isTemplateName(S, SS ? *SS : EmptySS,
false,
733 Name,
nullptr,
true, TemplateResult,
735 diagnoseMissingTemplateArguments(TemplateResult.
get(), IILoc);
744 Diag(IILoc, IsTemplateName ? diag::err_no_template
745 : diag::err_unknown_typename)
747 else if (
DeclContext *DC = computeDeclContext(*SS,
false))
748 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
749 : diag::err_typename_nested_not_found)
751 else if (isDependentScopeSpecifier(*SS)) {
752 unsigned DiagID = diag::err_typename_missing;
753 if (getLangOpts().MSVCCompat && isMicrosoftMissingTypename(SS, S))
754 DiagID = diag::ext_typename_missing;
761 *SS, *II, IILoc).
get();
764 "Invalid scope specifier has already been diagnosed");
772 NextToken.
is(tok::less);
775 if (isa<TypeDecl>(*I) || isa<ObjCInterfaceDecl>(*I))
778 if (CheckTemplate && isa<TemplateDecl>(*I))
792 StringRef FixItTagName;
793 switch (Tag->getTagKind()) {
795 FixItTagName =
"class ";
799 FixItTagName =
"enum ";
803 FixItTagName =
"struct ";
807 FixItTagName =
"__interface ";
811 FixItTagName =
"union ";
815 StringRef TagName = FixItTagName.drop_back();
816 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
817 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
822 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
852 const Token &NextToken,
857 assert(NextToken.
isNot(tok::coloncolon) &&
858 "parse nested name specifiers before calling ClassifyName");
859 if (getLangOpts().CPlusPlus && SS.
isSet() &&
860 isCurrentClassName(*Name, S, &SS)) {
868 LookupResult Result(*
this, Name, NameLoc, LookupOrdinaryName);
869 LookupParsedName(Result, S, &SS, !CurMethod);
876 if (Result.
empty() && SS.
isEmpty() && getLangOpts().MSVCCompat) {
887 DeclResult Ivar = LookupIvarInObjCMethod(Result, S, Name);
891 return NameClassification::NonType(cast<NamedDecl>(Ivar.
get()));
895 LookupBuiltin(Result);
898 bool SecondTry =
false;
899 bool IsFilteredTemplateName =
false;
906 if (SS.
isEmpty() && NextToken.
is(tok::l_paren)) {
909 if (getLangOpts().CPlusPlus)
910 return NameClassification::UndeclaredNonType();
924 if (
NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *Name, S))
925 return NameClassification::NonType(D);
928 if (getLangOpts().CPlusPlus2a && SS.
isEmpty() && NextToken.
is(tok::less)) {
935 return NameClassification::UndeclaredTemplate(Template);
941 if (!getLangOpts().
CPlusPlus && !SecondTry &&
948 if (!SecondTry && CCC) {
952 &SS, *CCC, CTK_ErrorRecovery)) {
953 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
954 unsigned QualifiedDiag = diag::err_no_member_suggest;
956 NamedDecl *FirstDecl = Corrected.getFoundDecl();
957 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
958 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
959 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
960 UnqualifiedDiag = diag::err_no_template_suggest;
961 QualifiedDiag = diag::err_no_member_template_suggest;
962 }
else if (UnderlyingFirstDecl &&
963 (isa<TypeDecl>(UnderlyingFirstDecl) ||
964 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
965 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
966 UnqualifiedDiag = diag::err_unknown_typename_suggest;
967 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
971 diagnoseTypo(Corrected, PDiag(UnqualifiedDiag) << Name);
973 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
974 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
975 Name->
getName().equals(CorrectedStr);
976 diagnoseTypo(Corrected, PDiag(QualifiedDiag)
977 << Name << computeDeclContext(SS,
false)
978 << DroppedSpecifier << SS.getRange());
982 Name = Corrected.getCorrectionAsIdentifierInfo();
985 if (Corrected.isKeyword())
1001 LookupIvarInObjCMethod(Result, S, Ivar->getIdentifier());
1005 return NameClassification::NonType(Ivar);
1031 return NameClassification::DependentNonType();
1040 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
1041 hasAnyAcceptableTemplateNames(Result,
true,
1054 FilterAcceptableTemplateNames(Result);
1056 IsFilteredTemplateName =
true;
1065 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
1066 (IsFilteredTemplateName ||
1067 hasAnyAcceptableTemplateNames(
1071 getLangOpts().CPlusPlus2a))) {
1082 if (!IsFilteredTemplateName)
1083 FilterAcceptableTemplateNames(Result);
1085 bool IsFunctionTemplate;
1088 if (Result.
end() - Result.
begin() > 1) {
1089 IsFunctionTemplate =
true;
1092 }
else if (!Result.
empty()) {
1093 auto *TD = cast<TemplateDecl>(getAsTemplateNameDecl(
1094 *Result.
begin(),
true,
1096 IsFunctionTemplate = isa<FunctionTemplateDecl>(TD);
1097 IsVarTemplate = isa<VarTemplateDecl>(TD);
1108 IsFunctionTemplate =
true;
1112 if (IsFunctionTemplate) {
1118 return NameClassification::FunctionTemplate(Template);
1121 return IsVarTemplate ? NameClassification::VarTemplate(Template)
1122 : NameClassification::TypeTemplate(Template);
1127 DiagnoseUseOfDecl(
Type, NameLoc);
1128 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
1139 dyn_cast<ObjCCompatibleAliasDecl>(FirstDecl))
1140 Class = Alias->getClassInterface();
1144 DiagnoseUseOfDecl(Class, NameLoc);
1146 if (NextToken.
is(tok::period)) {
1157 if (isa<ConceptDecl>(FirstDecl))
1158 return NameClassification::Concept(
1162 if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl) &&
1163 !isa<VarTemplateDecl>(FirstDecl))
1164 return NameClassification::TypeTemplate(
1169 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1170 if ((NextToken.
is(tok::identifier) ||
1175 DiagnoseUseOfDecl(Type, NameLoc);
1185 return NameClassification::ContextIndependentExpr(
1186 BuildPossibleImplicitMemberExpr(SS,
SourceLocation(), Result,
nullptr,
1191 bool ADL = UseArgumentDependentLookup(SS, Result, NextToken.
is(tok::l_paren));
1197 return NameClassification::ContextIndependentExpr(
1198 BuildDeclarationNameExpr(SS, Result, ADL));
1204 assert(getLangOpts().
CPlusPlus &&
"ADL-only call in C?");
1206 LookupResult Result(*
this, Name, NameLoc, LookupOrdinaryName);
1207 return BuildDeclarationNameExpr(SS, Result,
true);
1214 bool IsAddressOfOperand) {
1217 NameInfo, IsAddressOfOperand,
1224 const Token &NextToken) {
1225 if (getCurMethodDecl() && SS.
isEmpty())
1227 return BuildIvarRefExpr(S, NameLoc, Ivar);
1231 Result.addDecl(Found);
1232 Result.resolveKind();
1234 bool ADL = UseArgumentDependentLookup(SS, Result, NextToken.
is(tok::l_paren));
1235 return BuildDeclarationNameExpr(SS, Result, ADL);
1242 return TemplateNameKindForDiagnostics::DependentTemplate;
1243 if (isa<ClassTemplateDecl>(TD))
1244 return TemplateNameKindForDiagnostics::ClassTemplate;
1245 if (isa<FunctionTemplateDecl>(TD))
1246 return TemplateNameKindForDiagnostics::FunctionTemplate;
1247 if (isa<VarTemplateDecl>(TD))
1248 return TemplateNameKindForDiagnostics::VarTemplate;
1249 if (isa<TypeAliasTemplateDecl>(TD))
1250 return TemplateNameKindForDiagnostics::AliasTemplate;
1251 if (isa<TemplateTemplateParmDecl>(TD))
1252 return TemplateNameKindForDiagnostics::TemplateTemplateParam;
1253 if (isa<ConceptDecl>(TD))
1254 return TemplateNameKindForDiagnostics::Concept;
1255 return TemplateNameKindForDiagnostics::DependentTemplate;
1280 if (!isa<CXXRecordDecl>(DC))
1298 assert(getContainingDC(DC) == CurContext &&
1299 "The next DeclContext should be lexically contained in the current one.");
1305 assert(CurContext &&
"DeclContext imbalance!");
1307 CurContext = getContainingDC(CurContext);
1308 assert(CurContext &&
"Popped translation unit!");
1318 assert(CurContext &&
"skipping definition of undefined tag");
1321 S->
setEntity(CurContext->getLookupParent());
1326 CurContext =
static_cast<decltype(CurContext)
>(Context);
1349 assert(!S->
getEntity() &&
"scope already has entity");
1353 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1354 assert(Ancestor->getEntity() == CurContext &&
"ancestor context mismatch");
1362 assert(S->
getEntity() == CurContext &&
"Context imbalance!");
1367 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1384 "The next DeclContext should be lexically contained in the current one.");
1388 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1393 IdResolver.AddDecl(Param);
1401 assert(CurContext &&
"DeclContext imbalance!");
1402 CurContext = CurContext->getLexicalParent();
1403 assert(CurContext &&
"Popped translation unit!");
1426 New->
hasAttr<OverloadableAttr>());
1441 CurContext->addDecl(D);
1452 if (isa<FunctionDecl>(D) &&
1453 cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
1458 IEnd = IdResolver.end();
1459 for (; I != IEnd; ++I) {
1462 IdResolver.RemoveDecl(*I);
1471 if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) {
1475 for (I = IdResolver.begin(D->
getDeclName()); I != IEnd; ++I) {
1477 if (IDC == CurContext) {
1480 }
else if (IDC->
Encloses(CurContext))
1484 IdResolver.InsertDeclAfter(I, D);
1486 IdResolver.AddDecl(D);
1491 bool AllowInlineNamespace) {
1492 return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace);
1499 if (ScopeDC->getPrimaryContext() == TargetDC)
1513 bool ConsiderLinkage,
1514 bool AllowInlineNamespace) {
1519 if (isDeclInScope(D, Ctx, S, AllowInlineNamespace))
1541 makeMergedDefinitionVisible(New);
1558 if (NewIsModuleInterface || OldIsModuleInterface) {
1564 << NewIsModuleInterface
1566 << OldIsModuleInterface
1577 return isa<UsingShadowDecl>(D) ||
1578 isa<UnresolvedUsingTypenameDecl>(D) ||
1579 isa<UnresolvedUsingValueDecl>(D);
1606 return CD->isCopyConstructor();
1622 bool Sema::mightHaveNonExternalLinkage(
const DeclaratorDecl *D) {
1625 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1626 if (!RD->hasNameForLinkage())
1655 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1661 FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
1664 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1669 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1673 if (FD->doesThisDeclarationHaveABody() &&
1676 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1686 if (VD->isStaticDataMember() &&
1689 if (VD->isStaticDataMember() &&
1691 VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
1694 if (VD->isInline() && !
isMainFileLoc(*
this, VD->getLocation()))
1703 return mightHaveNonExternalLinkage(D);
1710 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1712 if (FD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1716 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1718 if (VD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1722 if (ShouldWarnIfUnusedFileScopedDecl(D))
1723 UnusedFileScopedDecls.push_back(D);
1730 bool Referenced =
false;
1731 if (
auto *DD = dyn_cast<DecompositionDecl>(D)) {
1735 for (
auto *BD : DD->bindings()) {
1736 if (BD->isReferenced()) {
1747 if (Referenced || D->
hasAttr<UnusedAttr>() ||
1748 D->
hasAttr<ObjCPreciseLifetimeAttr>())
1751 if (isa<LabelDecl>(D))
1757 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->
getDeclContext()))
1760 WithinFunction || (R->isLocalClass() && !R->isDependentType());
1761 if (!WithinFunction)
1764 if (isa<TypedefNameDecl>(D))
1768 if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D))
1772 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1775 const auto *Ty = VD->getType().getTypePtr();
1779 if (TT->getDecl()->hasAttr<UnusedAttr>())
1785 if (Ty->isIncompleteType() || Ty->isDependentType())
1790 Ty = Ty->getBaseElementTypeUnsafe();
1793 const TagDecl *Tag = TT->getDecl();
1794 if (Tag->
hasAttr<UnusedAttr>())
1797 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) {
1798 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
1801 if (
const Expr *Init = VD->getInit()) {
1803 dyn_cast<ExprWithCleanups>(Init))
1804 Init = Cleanups->getSubExpr();
1809 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
1810 (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
1816 if (Init->isTypeDependent())
1818 if (!Ctor->isTrivial())
1832 if (isa<LabelDecl>(D)) {
1847 for (
auto *TmpD : D->
decls()) {
1848 if (
const auto *T = dyn_cast<TypedefNameDecl>(TmpD))
1849 DiagnoseUnusedDecl(T);
1850 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
1851 DiagnoseUnusedNestedTypedefs(R);
1861 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1864 UnusedLocalTypedefNameCandidates.insert(TD);
1872 if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
1873 DiagID = diag::warn_unused_exception_param;
1874 else if (isa<LabelDecl>(D))
1875 DiagID = diag::warn_unused_label;
1877 DiagID = diag::warn_unused_variable;
1887 bool Diagnose =
false;
1891 Diagnose = L->
getStmt() ==
nullptr;
1901 "Scope shouldn't contain decls!");
1903 for (
auto *TmpD : S->
decls()) {
1904 assert(TmpD &&
"This decl didn't get pushed??");
1906 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
1911 DiagnoseUnusedDecl(D);
1912 if (
const auto *RD = dyn_cast<RecordDecl>(D))
1913 DiagnoseUnusedNestedTypedefs(RD);
1919 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
1924 IdResolver.RemoveDecl(D);
1925 auto ShadowI = ShadowingDecls.find(D);
1926 if (ShadowI != ShadowingDecls.end()) {
1927 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
1929 << D << FD << FD->getParent();
1930 Diag(FD->getLocation(), diag::note_previous_declaration);
1932 ShadowingDecls.erase(ShadowI);
1952 bool DoTypoCorrection) {
1955 NamedDecl *IDecl = LookupSingleName(TUScope, Id, IdLoc, LookupOrdinaryName);
1957 if (!IDecl && DoTypoCorrection) {
1963 TUScope,
nullptr, CCC, CTK_ErrorRecovery)) {
1964 diagnoseTypo(C, PDiag(diag::err_undef_interface_suggest) << Id);
2013 if (!II->
isStr(
"objc_msgSendSuper"))
2037 return "ucontext.h";
2039 llvm_unreachable(
"unhandled error kind");
2047 Scope *S,
bool ForRedeclaration,
2054 if (!ForRedeclaration)
2065 Diag(Loc, diag::warn_implicit_decl_no_jmp_buf)
2072 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
2078 if (!ForRedeclaration &&
2081 Diag(Loc, diag::ext_implicit_lib_function_decl)
2084 !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc))
2085 Diag(Loc, diag::note_include_header_or_declare)
2099 Parent->
addDecl(CLinkageDecl);
2100 Parent = CLinkageDecl;
2105 Loc, Loc, II, R,
nullptr,
2115 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2118 nullptr, FT->getParamType(i),
nullptr,
2121 Params.push_back(parm);
2123 New->setParams(Params);
2126 AddKnownFunctionAttributes(New);
2127 RegisterLocallyScopedExternCDecl(New, S);
2135 PushOnScopeChains(New, TUScope);
2136 CurContext = SavedContext;
2152 if (Previous.
empty())
2165 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2172 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2186 OldType = OldTypedef->getUnderlyingType();
2193 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2194 Diag(New->
getLocation(), diag::err_redefinition_variably_modified_typedef)
2202 if (OldType != NewType &&
2206 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2208 << Kind << NewType << OldType;
2230 if (getLangOpts().ObjC) {
2236 if (!TypeID->
isStr(
"id"))
2252 if (!TypeID->
isStr(
"Class"))
2259 if (!TypeID->
isStr(
"SEL"))
2286 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2287 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2290 if (OldTag && NewTag &&
2291 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
2292 !hasVisibleDefinition(OldTag, &Hidden)) {
2296 if (OldTD->isModed())
2298 OldTD->getUnderlyingType());
2303 makeMergedDefinitionVisible(Hidden);
2307 if (isa<EnumDecl>(NewTag)) {
2308 Scope *EnumScope = getNonFieldDeclScope(S);
2309 for (
auto *D : NewTag->decls()) {
2310 auto *ED = cast<EnumConstantDecl>(D);
2313 IdResolver.RemoveDecl(ED);
2314 ED->getLexicalDeclContext()->removeDecl(ED);
2322 if (isIncompatibleTypedef(Old, New))
2329 mergeDeclAttributes(New, Old);
2332 if (getLangOpts().MicrosoftExt)
2340 if (!isa<CXXRecordDecl>(CurContext))
2364 if (!isa<TypedefNameDecl>(Old))
2374 if (getLangOpts().Modules || getLangOpts().
C11)
2381 if (getDiagnostics().getSuppressSystemWarnings() &&
2396 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2397 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2398 for (
const auto *i : D->
attrs())
2399 if (i->getKind() == A->
getKind()) {
2401 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2406 if (OA && isa<OwnershipAttr>(i))
2407 return OA->getOwnKind() == cast<OwnershipAttr>(i)->getOwnKind();
2415 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2416 return VD->isThisDeclarationADefinition();
2417 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2418 return TD->isCompleteDefinition() || TD->isBeingDefined();
2429 AlignedAttr *OldAlignasAttr =
nullptr;
2430 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2431 unsigned OldAlign = 0;
2439 if (I->isAlignmentDependent())
2445 unsigned Align = I->getAlignment(S.
Context);
2446 if (Align > OldAlign) {
2448 OldStrictestAlignAttr = I;
2453 AlignedAttr *NewAlignasAttr =
nullptr;
2454 unsigned NewAlign = 0;
2456 if (I->isAlignmentDependent())
2462 unsigned Align = I->getAlignment(S.
Context);
2463 if (Align > NewAlign)
2467 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2475 if (OldAlign == 0 || NewAlign == 0) {
2477 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2488 if (OldAlign != NewAlign) {
2489 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2492 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2507 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2511 bool AnyAdded =
false;
2514 if (OldAlign > NewAlign) {
2515 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2516 Clone->setInherited(
true);
2522 if (OldAlignasAttr && !NewAlignasAttr &&
2523 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2524 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2525 Clone->setInherited(
true);
2544 if (
const auto *AA = dyn_cast<AvailabilityAttr>(Attr))
2546 D, *AA, AA->getPlatform(), AA->
isImplicit(), AA->getIntroduced(),
2547 AA->getDeprecated(), AA->getObsoleted(), AA->getUnavailable(),
2548 AA->getMessage(), AA->getStrict(), AA->getReplacement(), AMK,
2550 else if (
const auto *VA = dyn_cast<VisibilityAttr>(Attr))
2552 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(Attr))
2554 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(Attr))
2556 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(Attr))
2558 else if (
const auto *FA = dyn_cast<FormatAttr>(Attr))
2559 NewAttr = S.
mergeFormatAttr(D, *FA, FA->getType(), FA->getFormatIdx(),
2561 else if (
const auto *SA = dyn_cast<SectionAttr>(Attr))
2563 else if (
const auto *CSA = dyn_cast<CodeSegAttr>(Attr))
2565 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(Attr))
2567 IA->getInheritanceModel());
2568 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(Attr))
2571 else if (S.
getLangOpts().CUDA && isa<FunctionDecl>(D) &&
2572 (isa<CUDAHostAttr>(Attr) || isa<CUDADeviceAttr>(Attr) ||
2573 isa<CUDAGlobalAttr>(Attr))) {
2577 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(Attr))
2579 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(Attr))
2581 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(Attr))
2583 else if (
const auto *CommonA = dyn_cast<CommonAttr>(Attr))
2585 else if (isa<AlignedAttr>(Attr))
2589 else if ((isa<DeprecatedAttr>(Attr) || isa<UnavailableAttr>(Attr)) &&
2593 else if (
const auto *UA = dyn_cast<UuidAttr>(Attr))
2595 else if (
const auto *SLHA = dyn_cast<SpeculativeLoadHardeningAttr>(Attr))
2597 else if (
const auto *SLHA = dyn_cast<NoSpeculativeLoadHardeningAttr>(Attr))
2600 NewAttr = cast<InheritableAttr>(Attr->
clone(S.
Context));
2605 if (isa<MSInheritanceAttr>(NewAttr))
2614 if (
const TagDecl *TD = dyn_cast<TagDecl>(D))
2615 return TD->getDefinition();
2616 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2622 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
2628 for (
const auto *Attribute : D->
attrs())
2629 if (Attribute->getKind() ==
Kind)
2641 if (!Def || Def == New)
2645 for (
unsigned I = 0, E = NewAttributes.size(); I != E;) {
2646 const Attr *NewAttribute = NewAttributes[I];
2648 if (isa<AliasAttr>(NewAttribute) || isa<IFuncAttr>(NewAttribute)) {
2655 NewAttributes.erase(NewAttributes.begin() + I);
2660 VarDecl *VD = cast<VarDecl>(New);
2661 unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
2663 ? diag::err_alias_after_tentative
2664 : diag::err_redefinition;
2666 if (Diag == diag::err_redefinition)
2676 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
2689 if (isa<C11NoReturnAttr>(NewAttribute)) {
2693 }
else if (isa<UuidAttr>(NewAttribute)) {
2697 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
2698 if (AA->isAlignas()) {
2709 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
2711 NewAttributes.erase(NewAttributes.begin() + I);
2715 }
else if (isa<SelectAnyAttr>(NewAttribute) &&
2716 cast<VarDecl>(New)->isInline() &&
2717 !cast<VarDecl>(New)->isInlineSpecified()) {
2727 diag::warn_attribute_precede_definition);
2729 NewAttributes.erase(NewAttributes.begin() + I);
2735 const ConstInitAttr *CIAttr,
2736 bool AttrBeforeInit) {
2743 std::string SuitableSpelling;
2747 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
2750 {tok::l_square, tok::l_square, S.PP.getIdentifierInfo(
"clang"),
2752 S.PP.getIdentifierInfo(
"require_constant_initialization"),
2753 tok::r_square, tok::r_square});
2754 if (SuitableSpelling.empty())
2757 {tok::kw___attribute, tok::l_paren, tok::r_paren,
2758 S.PP.getIdentifierInfo(
"require_constant_initialization"),
2759 tok::r_paren, tok::r_paren});
2760 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus2a)
2761 SuitableSpelling =
"constinit";
2762 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
2763 SuitableSpelling =
"[[clang::require_constant_initialization]]";
2764 if (SuitableSpelling.empty())
2765 SuitableSpelling =
"__attribute__((require_constant_initialization))";
2766 SuitableSpelling +=
" ";
2768 if (AttrBeforeInit) {
2771 assert(CIAttr->isConstinit() &&
"should not diagnose this for attribute");
2774 S.
Diag(CIAttr->getLocation(), diag::note_constinit_specified_here);
2778 S.
Diag(CIAttr->getLocation(),
2779 CIAttr->isConstinit() ? diag::err_constinit_added_too_late
2780 : diag::warn_require_const_init_added_too_late)
2783 << CIAttr->isConstinit()
2792 UsedAttr *NewAttr = OldAttr->clone(Context);
2793 NewAttr->setInherited(
true);
2803 const auto *OldConstInit = Old->
getAttr<ConstInitAttr>();
2804 const auto *NewConstInit = New->
getAttr<ConstInitAttr>();
2805 if (
bool(OldConstInit) !=
bool(NewConstInit)) {
2806 const auto *OldVD = cast<VarDecl>(Old);
2807 auto *NewVD = cast<VarDecl>(New);
2813 (NewVD->hasInit() || NewVD->isThisDeclarationADefinition()))
2816 if (InitDecl == NewVD) {
2820 if (OldConstInit && OldConstInit->isConstinit())
2823 }
else if (NewConstInit) {
2827 if (InitDecl && InitDecl != NewVD) {
2830 NewVD->dropAttr<ConstInitAttr>();
2838 if (AsmLabelAttr *NewA = New->
getAttr<AsmLabelAttr>()) {
2839 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
2840 if (!OldA->isEquivalent(NewA)) {
2843 Diag(OldA->getLocation(), diag::note_previous_declaration);
2845 }
else if (Old->
isUsed()) {
2849 << isa<FunctionDecl>(Old) << New->
getAttr<AsmLabelAttr>()->getRange();
2854 if (
const auto *NewAbiTagAttr = New->
getAttr<AbiTagAttr>()) {
2855 if (
const auto *OldAbiTagAttr = Old->
getAttr<AbiTagAttr>()) {
2856 for (
const auto &NewTag : NewAbiTagAttr->tags()) {
2857 if (std::find(OldAbiTagAttr->tags_begin(), OldAbiTagAttr->tags_end(),
2858 NewTag) == OldAbiTagAttr->tags_end()) {
2859 Diag(NewAbiTagAttr->getLocation(),
2860 diag::err_new_abi_tag_on_redeclaration)
2862 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
2866 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
2872 if (New->
hasAttr<SectionAttr>() && !Old->
hasAttr<SectionAttr>()) {
2873 if (
auto *VD = dyn_cast<VarDecl>(New)) {
2875 Diag(New->
getLocation(), diag::warn_attribute_section_on_redeclaration);
2882 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
2883 if (NewCSA && !Old->
hasAttr<CodeSegAttr>() &&
2884 !NewCSA->isImplicit() && isa<CXXMethodDecl>(New)) {
2902 if (isa<DeprecatedAttr>(I) ||
2903 isa<UnavailableAttr>(I) ||
2904 isa<AvailabilityAttr>(I)) {
2909 case AMK_Redeclaration:
2911 case AMK_ProtocolImplementation:
2918 if (isa<UsedAttr>(I))
2940 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
2941 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
2942 S.
Diag(CDA->getLocation(),
2943 diag::err_carries_dependency_missing_on_first_decl) << 1;
2951 diag::note_carries_dependency_missing_first_decl) << 1;
2957 bool foundAny = newDecl->
hasAttrs();
2966 cast<InheritableParamAttr>(I->clone(S.
Context));
2981 if (*Oldnullability != *Newnullability) {
2982 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
3007 struct GNUCompatibleParamWarning {
3017 template <
typename T>
3018 static std::pair<diag::kind, SourceLocation>
3022 if (Old->isThisDeclarationADefinition())
3023 PrevDiag = diag::note_previous_definition;
3024 else if (Old->isImplicit()) {
3025 PrevDiag = diag::note_previous_implicit_declaration;
3027 OldLocation = New->getLocation();
3029 PrevDiag = diag::note_previous_declaration;
3030 return std::make_pair(PrevDiag, OldLocation);
3038 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
3039 !LangOpts.CPlusPlus &&
3051 template <
typename T>
3065 template<
typename T>
static bool isExternC(T *D) {
return D->isExternC(); }
3071 template<
typename ExpectedDecl>
3093 !Old->getDeclContext()->getRedeclContext()->Equals(
3094 New->getDeclContext()->getRedeclContext()) &&
3099 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
3112 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
3113 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
3116 return AttrA && AttrB && AttrA->getType() == AttrB->getType() &&
3117 AttrA->isDynamic() == AttrB->isDynamic();
3120 return std::equal(A->param_begin(), A->param_end(), B->
param_begin(), AttrEq);
3143 if (NamedDC->Equals(SemaDC))
3146 assert((NamedDC->InEnclosingNamespaceSetOf(SemaDC) ||
3148 "unexpected context for redeclaration");
3159 if (
auto *FD = dyn_cast<FunctionDecl>(NewD))
3160 FixSemaDC(FD->getDescribedFunctionTemplate());
3161 else if (
auto *VD = dyn_cast<VarDecl>(NewD))
3162 FixSemaDC(VD->getDescribedVarTemplate());
3177 Scope *S,
bool MergeTypeWithOld) {
3184 Diag(Shadow->getTargetDecl()->getLocation(),
3185 diag::note_using_decl_target);
3186 Diag(Shadow->getUsingDecl()->getLocation(),
3187 diag::note_using_decl) << 0;
3192 if (checkUsingShadowRedecl<FunctionDecl>(*
this, Shadow, New))
3194 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
3208 if (!getASTContext().canBuiltinBeRedeclared(Old)) {
3217 std::tie(PrevDiag, OldLocation) =
3224 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
3229 if (getLangOpts().MicrosoftExt) {
3231 Diag(OldLocation, PrevDiag);
3234 Diag(OldLocation, PrevDiag);
3239 if (New->
hasAttr<InternalLinkageAttr>() &&
3240 !Old->
hasAttr<InternalLinkageAttr>()) {
3244 New->
dropAttr<InternalLinkageAttr>();
3247 if (CheckRedeclarationModuleOwnership(New, Old))
3250 if (!getLangOpts().CPlusPlus) {
3251 bool OldOvl = Old->
hasAttr<OverloadableAttr>();
3262 const Decl *DiagOld = Old;
3264 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *D) {
3265 const auto *A = D->
getAttr<OverloadableAttr>();
3266 return A && !A->isImplicit();
3270 DiagOld = OldIter == Old->
redecls_end() ? nullptr : *OldIter;
3274 Diag(DiagOld->getLocation(),
3275 diag::note_attribute_overloadable_prev_overload)
3279 New->
addAttr(OverloadableAttr::CreateImplicit(Context));
3300 const FunctionType *OldType = cast<FunctionType>(OldQType);
3301 const FunctionType *NewType = cast<FunctionType>(NewQType);
3304 bool RequiresAdjustment =
false;
3306 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC()) {
3311 bool NewCCExplicit = getCallingConvAttributedType(New->
getType());
3312 if (!NewCCExplicit) {
3316 RequiresAdjustment =
true;
3323 << (
int)CallingConventionIgnoredReason::BuiltinFunction;
3325 RequiresAdjustment =
true;
3328 bool FirstCCExplicit = getCallingConvAttributedType(First->
getType());
3332 << (!FirstCCExplicit ?
"" :
3342 if (OldTypeInfo.getNoReturn() && !NewTypeInfo.
getNoReturn()) {
3344 RequiresAdjustment =
true;
3348 if (OldTypeInfo.getHasRegParm() != NewTypeInfo.
getHasRegParm() ||
3349 OldTypeInfo.getRegParm() != NewTypeInfo.
getRegParm()) {
3352 << NewType->getRegParmType()
3354 Diag(OldLocation, diag::note_previous_declaration);
3358 NewTypeInfo = NewTypeInfo.
withRegParm(OldTypeInfo.getRegParm());
3359 RequiresAdjustment =
true;
3366 <<
"'ns_returns_retained'";
3367 Diag(OldLocation, diag::note_previous_declaration);
3372 RequiresAdjustment =
true;
3375 if (OldTypeInfo.getNoCallerSavedRegs() !=
3378 AnyX86NoCallerSavedRegistersAttr *
Attr =
3379 New->
getAttr<AnyX86NoCallerSavedRegistersAttr>();
3380 Diag(New->
getLocation(), diag::err_function_attribute_mismatch) << Attr;
3381 Diag(OldLocation, diag::note_previous_declaration);
3386 RequiresAdjustment =
true;
3389 if (RequiresAdjustment) {
3399 !New->
hasAttr<GNUInlineAttr>() &&
3400 !getLangOpts().GNUInline &&
3408 if (New->
hasAttr<GNUInlineAttr>() &&
3419 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3434 if (CheckEquivalentExceptionSpec(Old, New))
3446 if (!Context.
hasSameType(OldDeclaredReturnType, NewDeclaredReturnType) &&
3447 canFullyTypeCheckRedeclaration(New, Old, NewDeclaredReturnType,
3448 OldDeclaredReturnType)) {
3456 Diag(New->
getLocation(), diag::err_member_def_does_not_match_ret_type)
3461 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
3470 QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType();
3471 if (OldReturnType != NewReturnType) {
3481 SubstAutoType(NewQType,
3489 if (OldMethod && NewMethod) {
3496 bool IsClassScopeExplicitSpecialization =
3498 NewMethod->isFunctionTemplateSpecialization();
3499 bool isFriend = NewMethod->getFriendObjectKind();
3501 if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() &&
3502 !IsClassScopeExplicitSpecialization) {
3506 if (OldMethod->
isStatic() != NewMethod->isStatic()) {
3508 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3516 if (!inTemplateInstantiation()) {
3518 if (isa<CXXConstructorDecl>(OldMethod))
3519 NewDiag = diag::err_constructor_redeclared;
3520 else if (isa<CXXDestructorDecl>(NewMethod))
3521 NewDiag = diag::err_destructor_redeclared;
3522 else if (isa<CXXConversionDecl>(NewMethod))
3523 NewDiag = diag::err_conv_function_redeclared;
3525 NewDiag = diag::err_member_redeclared;
3529 Diag(New->
getLocation(), diag::err_member_redeclared_in_instantiation)
3532 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3542 NewMethod->setImplicit();
3544 Diag(NewMethod->getLocation(),
3545 diag::err_definition_of_implicitly_declared_member)
3546 << New << getSpecialMember(OldMethod);
3550 Diag(NewMethod->getLocation(),
3551 diag::err_definition_of_explicitly_defaulted_member)
3552 << getSpecialMember(OldMethod);
3561 const CXX11NoReturnAttr *NRA = New->
getAttr<CXX11NoReturnAttr>();
3562 if (NRA && !Old->
hasAttr<CXX11NoReturnAttr>()) {
3563 Diag(NRA->getLocation(), diag::err_noreturn_missing_on_first_decl);
3565 diag::note_noreturn_missing_first_decl);
3572 const CarriesDependencyAttr *CDA = New->
getAttr<CarriesDependencyAttr>();
3573 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
3574 Diag(CDA->getLocation(),
3575 diag::err_carries_dependency_missing_on_first_decl) << 0;
3577 diag::note_carries_dependency_missing_first_decl) << 0;
3586 QualType OldQTypeForComparison = OldQType;
3587 if (!OldTypeInfo.getNoReturn() && NewTypeInfo.
getNoReturn()) {
3591 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
3592 assert(OldQTypeForComparison.isCanonical());
3606 Diag(OldLocation, PrevDiag);
3608 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3609 Diag(OldLocation, PrevDiag);
3620 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3625 if (!canFullyTypeCheckRedeclaration(New, Old, NewQType, OldQType))
3633 if (!getLangOpts().CPlusPlus &&
3638 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
3642 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
3646 OldProto->getExtProtoInfo());
3652 for (
const auto &ParamType : OldProto->param_types()) {
3659 Params.push_back(Param);
3662 New->setParams(Params);
3665 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3684 if (!getLangOpts().CPlusPlus &&
3697 NewProto->getReturnType());
3698 bool LooseCompatible = !MergedReturn.
isNull();
3700 LooseCompatible && Idx !=
End; ++Idx) {
3704 NewProto->getParamType(Idx))) {
3705 ArgTypes.push_back(NewParm->
getType());
3709 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
3710 NewProto->getParamType(Idx) };
3711 Warnings.push_back(Warn);
3712 ArgTypes.push_back(NewParm->
getType());
3714 LooseCompatible =
false;
3717 if (LooseCompatible) {
3718 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
3719 Diag(Warnings[Warn].NewParm->getLocation(),
3720 diag::ext_param_promoted_not_compatible_with_prototype)
3721 << Warnings[Warn].PromotedType
3722 << Warnings[Warn].OldParm->getType();
3723 if (Warnings[Warn].OldParm->getLocation().isValid())
3724 Diag(Warnings[Warn].OldParm->getLocation(),
3725 diag::note_previous_declaration);
3728 if (MergeTypeWithOld)
3731 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3748 Diag(OldLocation, diag::note_previous_builtin_declaration)
3765 PrevDiag = diag::note_previous_builtin_declaration;
3769 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3783 Scope *S,
bool MergeTypeWithOld) {
3785 mergeDeclAttributes(New, Old);
3798 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
3806 return MergeCXXFunctionDecl(New, Old, S);
3812 if (!Merged.
isNull() && MergeTypeWithOld)
3823 ? AMK_ProtocolImplementation
3824 : isa<ObjCImplDecl>(newMethod->
getDeclContext()) ? AMK_Redeclaration
3827 mergeDeclAttributes(newMethod, oldMethod, MergeKind);
3834 ni != ne && oi != oe; ++ni, ++oi)
3837 CheckObjCMethodOverride(newMethod, oldMethod);
3844 ? diag::err_redefinition_different_type
3845 : diag::err_redeclaration_different_type)
3850 std::tie(PrevDiag, OldLocation)
3852 S.
Diag(OldLocation, PrevDiag);
3864 bool MergeTypeWithOld) {
3869 if (getLangOpts().CPlusPlus) {
3875 return MergeVarDeclExceptionSpecs(New, Old);
3946 if (MergeTypeWithOld)
3992 if (!shouldLinkPossiblyHiddenDecl(Previous, New))
4007 if (checkUsingShadowRedecl<VarTemplateDecl>(*
this, Shadow, NewTemplate))
4014 if (checkUsingShadowRedecl<VarDecl>(*
this, Shadow, New))
4030 true, TPL_TemplateMatch))
4044 mergeDeclAttributes(New, Old);
4047 if (New->
hasAttr<WeakImportAttr>() &&
4049 !Old->
hasAttr<WeakImportAttr>()) {
4056 if (New->
hasAttr<InternalLinkageAttr>() &&
4057 !Old->
hasAttr<InternalLinkageAttr>()) {
4061 New->
dropAttr<InternalLinkageAttr>();
4066 if (MostRecent != Old) {
4067 MergeVarDeclTypes(New, MostRecent,
4079 std::tie(PrevDiag, OldLocation) =
4086 if (getLangOpts().MicrosoftExt) {
4089 Diag(OldLocation, PrevDiag);
4093 Diag(OldLocation, PrevDiag);
4112 Diag(OldLocation, PrevDiag);
4120 Diag(OldLocation, PrevDiag);
4126 Diag(OldLocation, PrevDiag);
4130 if (CheckRedeclarationModuleOwnership(New, Old))
4142 Diag(OldLocation, PrevDiag);
4152 Diag(Def->getLocation(), diag::note_previous_definition);
4166 Diag(OldLocation, PrevDiag);
4169 Diag(OldLocation, PrevDiag);
4177 Diag(OldLocation, PrevDiag);
4188 diag::warn_deprecated_redundant_constexpr_static_def);
4190 if (checkVarDeclRedefinition(Def, New))
4196 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
4197 Diag(OldLocation, PrevDiag);
4227 auto &HSI = PP.getHeaderSearchInfo();
4228 StringRef HdrFilename =
4231 auto noteFromModuleOrInclude = [&](
Module *Mod,
4237 if (IncLoc.isValid()) {
4239 Diag(IncLoc, diag::note_redefinition_modules_same_file)
4245 Diag(IncLoc, diag::note_redefinition_include_same_file)
4246 << HdrFilename.str();
4256 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
4261 EmittedDiag |= noteFromModuleOrInclude(getCurrentModule(), NewIncLoc);
4264 if (FOld && !HSI.isFileMultipleIncludeGuarded(FOld))
4279 if (!hasVisibleDefinition(Old) &&
4291 makeMergedDefinitionVisible(OldTD);
4292 makeMergedDefinitionVisible(Old);
4327 if (isa<CXXRecordDecl>(Tag->
getParent())) {
4342 Decl *ManglingContextDecl;
4343 std::tie(MCtx, ManglingContextDecl) =
4367 if (getLangOpts().CPlusPlus)
4382 tagLoc = getLocForEndOfToken(tagLoc);
4385 textToInsert +=
' ';
4387 Diag(tagLoc, diag::note_typedef_changes_linkage)
4409 llvm_unreachable(
"unexpected type specifier");
4419 bool IsExplicitInstantiation,
4421 Decl *TagD =
nullptr;
4436 if (isa<TagDecl>(TagD))
4437 Tag = cast<TagDecl>(TagD);
4439 Tag = CTD->getTemplatedDecl();
4443 handleTagNumbering(Tag, S);
4454 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
4460 << getLangOpts().CPlusPlus17;
4478 DiagnoseFunctionSpecifiers(DS);
4485 return ActOnFriendTypeDecl(S, DS, TemplateParams);
4489 bool IsExplicitSpecialization =
4490 !TemplateParams.empty() && TemplateParams.back()->size() == 0;
4492 !IsExplicitInstantiation && !IsExplicitSpecialization &&
4493 !isa<ClassTemplatePartialSpecializationDecl>(Tag)) {
4502 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
4508 bool DeclaresAnything =
true;
4511 if (
RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
4512 if (!Record->getDeclName() && Record->isCompleteDefinition() &&
4514 if (getLangOpts().CPlusPlus ||
4515 Record->getDeclContext()->isRecord()) {
4523 if (CurContext->isFunctionOrMethod())
4524 AnonRecord = Record;
4525 return BuildAnonymousStructOrUnion(S, DS, AS, Record,
4529 DeclaresAnything =
false;
4539 if (!getLangOpts().CPlusPlus && CurContext->isRecord() &&
4555 Record = RT->getDecl();
4557 Record = UT->getDecl();
4559 if (Record && getLangOpts().MicrosoftExt) {
4562 return BuildMicrosoftCAnonymousStruct(S, DS, Record);
4565 DeclaresAnything =
false;
4574 if (getLangOpts().CPlusPlus &&
4576 if (
EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Tag))
4577 if (Enum->enumerator_begin() == Enum->enumerator_end() &&
4578 !Enum->getIdentifier() && !Enum->isInvalidDecl())
4579 DeclaresAnything =
false;
4587 DeclaresAnything =
false;
4596 ActOnDocumentableDecl(TagD);
4606 if (!DeclaresAnything) {
4621 unsigned DiagID = diag::warn_standalone_specifier;
4623 DiagID = diag::ext_standalone_specifier;
4664 Diag(AL.getLoc(), diag::warn_declspec_attribute_ignored)
4688 assert(PrevDecl &&
"Expected a non-null Decl");
4693 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
4695 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
4720 bool Invalid =
false;
4723 for (
auto *D : AnonRecord->
decls()) {
4724 if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
4725 cast<NamedDecl>(D)->getDeclName()) {
4741 unsigned OldChainingSize = Chaining.size();
4743 Chaining.append(IF->chain_begin(), IF->chain_end());
4745 Chaining.push_back(VD);
4747 assert(Chaining.size() >= 2);
4750 for (
unsigned i = 0; i < Chaining.size(); i++)
4751 NamedChain[i] = Chaining[i];
4755 VD->
getType(), {NamedChain, Chaining.size()});
4767 Chaining.resize(OldChainingSize);
4782 "Parser allowed 'typedef' as storage class VarDecl.");
4783 switch (StorageClassSpec) {
4797 llvm_unreachable(
"unknown storage class specifier");
4803 for (
const auto *I : Record->
decls()) {
4804 const auto *FD = dyn_cast<
FieldDecl>(I);
4805 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
4806 FD = IFD->getAnonField();
4807 if (FD && FD->hasInClassInitializer())
4811 llvm_unreachable(
"couldn't find in-class initializer");
4819 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
4842 if (Record->
isUnion() && !getLangOpts().CPlusPlus && !getLangOpts().C11)
4844 else if (!Record->
isUnion() && getLangOpts().CPlusPlus)
4846 else if (!Record->
isUnion() && !getLangOpts().C11)
4851 bool Invalid =
false;
4852 if (getLangOpts().CPlusPlus) {
4853 const char *PrevSpec =
nullptr;
4864 !cast<NamespaceDecl>(OwnerScope)->isAnonymousNamespace()))) {
4870 PrevSpec, DiagID, Policy);
4876 isa<RecordDecl>(Owner)) {
4878 diag::err_anonymous_union_with_storage_spec)
4892 << Record->
isUnion() <<
"const" 4896 diag::ext_anonymous_struct_union_qualified)
4897 << Record->
isUnion() <<
"volatile" 4901 diag::ext_anonymous_struct_union_qualified)
4902 << Record->
isUnion() <<
"restrict" 4906 diag::ext_anonymous_struct_union_qualified)
4907 << Record->
isUnion() <<
"_Atomic" 4911 diag::ext_anonymous_struct_union_qualified)
4912 << Record->
isUnion() <<
"__unaligned" 4922 for (
auto *Mem : Record->
decls()) {
4923 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
4927 assert(FD->getAccess() !=
AS_none);
4929 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
4939 if (CheckNontrivialField(FD))
4941 }
else if (Mem->isImplicit()) {
4943 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
4948 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
4949 if (!MemRecord->isAnonymousStructOrUnion() &&
4950 MemRecord->getDeclName()) {
4952 if (getLangOpts().MicrosoftExt)
4953 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
4957 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
4965 Diag(MemRecord->getLocation(),
4966 diag::ext_anonymous_record_with_anonymous_type)
4969 }
else if (isa<AccessSpecDecl>(Mem)) {
4971 }
else if (isa<StaticAssertDecl>(Mem)) {
4976 unsigned DK = diag::err_anonymous_record_bad_member;
4977 if (isa<TypeDecl>(Mem))
4978 DK = diag::err_anonymous_record_with_type;
4979 else if (isa<FunctionDecl>(Mem))
4980 DK = diag::err_anonymous_record_with_function;
4981 else if (isa<VarDecl>(Mem))
4982 DK = diag::err_anonymous_record_with_static;
4985 if (getLangOpts().MicrosoftExt &&
4986 DK == diag::err_anonymous_record_with_type)
4987 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
4990 Diag(Mem->getLocation(), DK) << Record->
isUnion();
4999 if (cast<CXXRecordDecl>(Record)->hasInClassInitializer() &&
5002 cast<CXXRecordDecl>(Record));
5007 << getLangOpts().CPlusPlus;
5020 if (getLangOpts().CPlusPlus && Record->
field_empty())
5026 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
5030 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
5037 ProcessDeclAttributes(S, Anon, Dc);
5040 FieldCollector->Add(cast<FieldDecl>(Anon));
5061 ActOnUninitializedDecl(Anon);
5077 Chain.push_back(Anon);
5082 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
5083 if (getLangOpts().
CPlusPlus && NewVD->isStaticLocal()) {
5085 Decl *ManglingContextDecl;
5086 std::tie(MCtx, ManglingContextDecl) =
5087 getCurrentMangleNumberContext(NewVD->getDeclContext());
5118 assert(Record &&
"expected a record!");
5123 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
5125 auto *ParentDecl = cast<RecordDecl>(CurContext);
5131 nullptr, RecTy, TInfo,
5137 CurContext->addDecl(Anon);
5143 Chain.push_back(Anon);
5146 if (RequireCompleteType(Anon->
getLocation(), RecTy,
5147 diag::err_field_incomplete) ||
5151 ParentDecl->setInvalidDecl();
5160 return GetNameFromUnqualifiedId(D.
getName());
5189 if (!Template || !isa<ClassTemplateDecl>(Template)) {
5191 diag::err_deduction_guide_name_not_class_template)
5192 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
5194 Diag(Template->getLocation(), diag::note_template_decl_here);
5281 llvm_unreachable(
"Unknown name kind");
5309 for (
unsigned Idx = 0; Idx < Declaration->
param_size(); ++Idx) {
5323 (DeclTyName && DeclTyName == DefTyName))
5324 Params.push_back(Idx);
5365 if (!TSI)
return true;
5410 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer() &&
5414 if (getLangOpts().
OpenCL)
5415 setCurrentOpenCLExtensionForDecl(Dcl);
5433 Record = dyn_cast<CXXRecordDecl>(Record->
getParent());
5435 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
5462 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
5476 Diag(Loc, LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
5477 : diag::err_member_extra_qualification)
5481 Diag(Loc, diag::warn_namespace_member_extra_qualification) << Name;
5489 if (!Cur->
Encloses(DC) && !IsTemplateId) {
5491 Diag(Loc, diag::err_member_qualification)
5493 else if (isa<TranslationUnitDecl>(DC))
5494 Diag(Loc, diag::err_invalid_declarator_global_scope)
5496 else if (isa<FunctionDecl>(Cur))
5497 Diag(Loc, diag::err_invalid_declarator_in_function)
5499 else if (isa<BlockDecl>(Cur))
5500 Diag(Loc, diag::err_invalid_declarator_in_block)
5503 Diag(Loc, diag::err_invalid_declarator_scope)
5504 << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.
getRange();
5511 Diag(Loc, diag::err_member_qualification)
5531 while (SpecLoc.getPrefix())
5533 if (dyn_cast_or_null<DecltypeType>(
5534 SpecLoc.getNestedNameSpecifier()->getAsType()))
5535 Diag(Loc, diag::err_decltype_in_declarator)
5536 << SpecLoc.getTypeLoc().getSourceRange();
5550 return ActOnDecompositionDeclarator(S, D, TemplateParamLists);
5556 }
else if (DiagnoseUnexpandedParameterPack(NameInfo, UPPC_DeclarationType))
5570 UPPC_DeclarationQualifier))
5575 if (!DC || isa<EnumDecl>(DC)) {
5581 diag::err_template_qualified_declarator_no_match)
5588 if (!IsDependentContext &&
5593 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
5595 diag::err_member_def_undefined_record)
5600 if (diagnoseQualifiedDeclaration(
5612 if (EnteringContext && IsDependentContext &&
5613 TemplateParamLists.size() != 0) {
5624 UPPC_DeclarationType))
5628 forRedeclarationInCurContext());
5632 bool IsLinkageLookup =
false;
5633 bool CreateBuiltins =
false;
5644 else if (CurContext->isFunctionOrMethod() &&
5647 IsLinkageLookup =
true;
5649 CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
5650 }
else if (CurContext->getRedeclContext()->isTranslationUnit() &&
5652 CreateBuiltins =
true;
5654 if (IsLinkageLookup) {
5655 Previous.
clear(LookupRedeclarationWithLinkage);
5659 LookupName(Previous, S, CreateBuiltins);
5661 LookupQualifiedName(Previous, DC);
5703 if (!R->
isFunctionType() && DiagnoseClassNameShadow(DC, NameInfo))
5719 CheckExtraCXXDefaultArguments(D);
5723 bool AddToScope =
true;
5725 if (TemplateParamLists.size()) {
5730 New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous);
5732 New = ActOnFunctionDeclarator(S, D, DC, TInfo, Previous,
5736 New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists,
5746 PushOnScopeChains(New, S);
5748 if (isInOpenMPDeclareTargetContext())
5749 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
5759 bool &SizeIsNegative,
5765 SizeIsNegative =
false;
5774 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
5779 if (FixedType.
isNull())
return FixedType;
5781 return Qs.
apply(Context, FixedType);
5783 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
5784 QualType Inner = PTy->getInnerType();
5788 if (FixedType.
isNull())
return FixedType;
5790 return Qs.
apply(Context, FixedType);
5808 if (Res.isSigned() && Res.isNegative()) {
5809 SizeIsNegative =
true;
5814 unsigned ActiveSizeBits
5848 TypeLoc DstElemTL = DstATL.getElementLoc();
5861 bool &SizeIsNegative,
5865 SizeIsNegative, Oversized);
5892 return Result.empty() ? nullptr : *Result.begin();
5902 diag::err_virtual_non_function);
5906 diag::err_explicit_non_function);
5910 diag::err_noreturn_non_function);
5930 << getLangOpts().CPlusPlus17;
5938 diag::err_deduction_guide_invalid_specifier)
5947 if (!NewTD)
return nullptr;
5950 ProcessDeclAttributes(S, NewTD, D);
5952 CheckTypedefForVariablyModifiedType(S, NewTD);
5955 NamedDecl *ND = ActOnTypedefNameDecl(S, DC, NewTD, Previous, Redeclaration);
5969 setFunctionHasBranchProtectedScope();
5972 bool SizeIsNegative;
5986 else if (Oversized.getBoolValue())
5988 << Oversized.toString(10);
6005 NamedDecl *ShadowedDecl = getShadowedDeclaration(NewTD, Previous);
6009 FilterLookupForScope(Previous, DC, S,
false,
6012 if (!Previous.
empty()) {
6013 Redeclaration =
true;
6014 MergeTypedefNameDecl(S, NewTD, Previous);
6016 inferGslPointerAttribute(NewTD);
6019 if (ShadowedDecl && !Redeclaration)
6020 CheckShadow(NewTD, ShadowedDecl, Previous);
6026 if (II->isStr(
"FILE"))
6028 else if (II->isStr(
"jmp_buf"))
6030 else if (II->isStr(
"sigjmp_buf"))
6032 else if (II->isStr(
"ucontext_t"))
6090 if (!OuterContext->
Equals(PrevOuterContext))
6099 if (!SS.
isSet())
return;
6108 unsigned kind = -1U;
6109 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
6110 if (var->hasAttr<BlocksAttr>())
6112 else if (!var->hasLocalStorage())
6114 }
else if (isa<ObjCIvarDecl>(decl)) {
6116 }
else if (isa<FieldDecl>(decl)) {
6134 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
6137 var->getTLSKind()) {
6138 Diag(var->getLocation(), diag::err_arc_thread_ownership)
6150 if (
VarDecl *Var = dyn_cast<VarDecl>(Decl)) {
6155 if ((getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) &&
6156 Var->hasGlobalStorage())
6160 if (
auto DT = dyn_cast<DecayedType>(Type)) {
6161 auto OrigTy = DT->getOriginalType();
6162 if (!OrigTy.hasAddressSpace() && OrigTy->isArrayType()) {
6194 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
6202 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
6203 if (VD->hasInit()) {
6204 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
6205 assert(VD->isThisDeclarationADefinition() &&
6206 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
6208 VD->dropAttr<AliasAttr>();
6215 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
6218 diag::err_attribute_selectany_non_extern_data);
6224 auto *VD = dyn_cast<
VarDecl>(&ND);
6225 bool IsAnonymousNS =
false;
6229 while (NS && !IsAnonymousNS) {
6238 bool AnonNSInMicrosoftMode = IsAnonymousNS && IsMicrosoft;
6240 (!AnonNSInMicrosoftMode &&
6250 if (
auto *MD = dyn_cast<CXXMethodDecl>(&ND))
6251 if (MD->isVirtual()) {
6253 diag::err_invalid_attribute_on_virtual_function)
6259 if (
const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
6264 for (
TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
6270 if (
const auto *A = ATL.
getAttrAs<LifetimeBoundAttr>()) {
6272 if (!MD || MD->isStatic()) {
6273 S.
Diag(A->getLocation(), diag::err_lifetimebound_no_object_param)
6274 << !MD << A->getRange();
6275 }
else if (isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD)) {
6276 S.
Diag(A->getLocation(), diag::err_lifetimebound_ctor_dtor)
6277 << isa<CXXDestructorDecl>(MD) << A->getRange();
6286 bool IsSpecialization,
6287 bool IsDefinition) {
6291 bool IsTemplate =
false;
6292 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
6293 OldDecl = OldTD->getTemplatedDecl();
6295 if (!IsSpecialization)
6296 IsDefinition =
false;
6298 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
6299 NewDecl = NewTD->getTemplatedDecl();
6303 if (!OldDecl || !NewDecl)
6306 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
6307 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
6308 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
6309 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
6313 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
6314 (NewExportAttr && !NewExportAttr->isInherited());
6320 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
6322 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
6324 bool JustWarn =
false;
6326 auto *VD = dyn_cast<
VarDecl>(OldDecl);
6327 if (VD && !VD->getDescribedVarTemplate())
6338 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
6341 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
6342 : diag::err_attribute_dll_redeclaration;
6345 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
6358 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
6360 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
6363 IsStaticDataMember = VD->isStaticDataMember();
6364 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
6366 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
6367 IsInline = FD->isInlined();
6368 IsQualifiedFriend = FD->getQualifier() &&
6372 if (OldImportAttr && !HasNewAttr &&
6373 (!IsInline || (IsMicrosoft && IsTemplate)) && !IsStaticDataMember &&
6375 if (IsMicrosoft && IsDefinition) {
6377 diag::warn_redeclaration_without_import_attribute)
6380 NewDecl->
dropAttr<DLLImportAttr>();
6382 DLLExportAttr::CreateImplicit(S.
Context, NewImportAttr->getRange()));
6385 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
6386 << NewDecl << OldImportAttr;
6388 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
6389 OldDecl->
dropAttr<DLLImportAttr>();
6390 NewDecl->
dropAttr<DLLImportAttr>();
6392 }
else if (IsInline && OldImportAttr && !IsMicrosoft) {
6395 OldDecl->
dropAttr<DLLImportAttr>();
6396 NewDecl->
dropAttr<DLLImportAttr>();
6398 diag::warn_dllimport_dropped_from_inline_function)
6399 << NewDecl << OldImportAttr;
6406 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
6408 !NewImportAttr && !NewExportAttr) {
6409 if (
const DLLExportAttr *ParentExportAttr =
6410 MD->getParent()->getAttr<DLLExportAttr>()) {
6411 DLLExportAttr *NewAttr = ParentExportAttr->clone(S.
Context);
6412 NewAttr->setInherited(
true);
6452 template<
typename T>
6456 if (!D->isInExternCContext() || D->template hasAttr<OverloadableAttr>())
6460 if (S.
getLangOpts().CUDA && (D->template hasAttr<CUDADeviceAttr>() ||
6461 D->template hasAttr<CUDAHostAttr>()))
6464 return D->isExternC();
6470 isa<OMPDeclareMapperDecl>(DC))
6476 if (isa<RequiresExprBodyDecl>(DC))
6478 llvm_unreachable(
"Unexpected context");
6484 isa<OMPDeclareReductionDecl>(DC) || isa<OMPDeclareMapperDecl>(DC))
6488 llvm_unreachable(
"Unexpected context");
6534 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
6535 return FD->isExternC();
6536 if (
const auto *VD = dyn_cast<VarDecl>(D))
6537 return VD->isExternC();
6539 llvm_unreachable(
"Unknown type of decl!");
6549 diag::err_opencl_type_can_only_be_used_as_function_parameter)
6563 diag::err_invalid_type_for_program_scope_var)
6609 diag::err_opencl_unknown_type_specifier)
6654 if (!Decomp.bindings().empty()) {
6655 II = Decomp.bindings()[0].Name;
6675 bool IsLocalExternDecl = SC ==
SC_Extern &&
6676 adjustContextForLocalExternDecl(DC);
6687 !D.
getAsmLabel() && !getSourceManager().isInSystemMacro(
6693 getLangOpts().CPlusPlus17 ? diag::ext_register_storage_class
6694 : diag::warn_deprecated_register)
6710 bool IsMemberSpecialization =
false;
6711 bool IsVariableTemplateSpecialization =
false;
6713 bool IsVariableTemplate =
false;
6721 if (R->getContainedDeducedType())
6722 ParsingInitForAutoVars.insert(NewVD);
6730 NTCUC_AutoVar, NTCUK_Destruct);
6732 bool Invalid =
false;
6734 if (DC->
isRecord() && !CurContext->isRecord()) {
6741 diag::err_static_out_of_line)
6753 diag::err_storage_class_for_static_member)
6757 llvm_unreachable(
"C storage class in c++!");
6761 if (SC ==
SC_Static && CurContext->isRecord()) {
6762 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
6763 if (RD->isLocalClass())
6765 diag::err_static_data_member_not_allowed_in_local_class)
6766 << Name << RD->getDeclName();
6772 getLangOpts().CPlusPlus11
6773 ? diag::warn_cxx98_compat_static_data_member_in_union
6774 : diag::ext_static_data_member_in_union) << Name;
6776 else if (!RD->getDeclName())
6778 diag::err_static_data_member_not_allowed_in_anon_struct)
6779 << Name << RD->isUnion();
6785 TemplateParams = MatchTemplateParametersToScopeSpecifier(
6792 false, IsMemberSpecialization, Invalid);
6794 if (TemplateParams) {
6795 if (!TemplateParams->
size() &&
6800 diag::err_template_variable_noparams)
6804 TemplateParams =
nullptr;
6809 IsVariableTemplateSpecialization =
true;
6810 IsPartialSpecialization = TemplateParams->
size() > 0;
6813 IsVariableTemplate =
true;
6816 if (CheckTemplateDeclScope(S, TemplateParams))
6821 getLangOpts().CPlusPlus14
6822 ? diag::warn_cxx11_compat_variable_template
6823 : diag::ext_variable_template);
6829 "should have a 'template<>' for this decl");
6832 if (IsVariableTemplateSpecialization) {
6834 TemplateParamLists.size() > 0
6835 ? TemplateParamLists[0]->getTemplateLoc()
6837 DeclResult Res = ActOnVarTemplateSpecialization(
6838 S, D, TInfo, TemplateKWLoc, TemplateParams, SC,
6839 IsPartialSpecialization);
6842 NewVD = cast<VarDecl>(Res.
get());
6853 if (IsVariableTemplate) {
6856 TemplateParams, NewVD);
6857 NewVD->setDescribedVarTemplate(NewTemplate);
6862 if (R->getContainedDeducedType())
6863 ParsingInitForAutoVars.insert(NewVD);
6875 unsigned VDTemplateParamLists = TemplateParams ? 1 : 0;
6876 if (TemplateParamLists.size() > VDTemplateParamLists)
6877 NewVD->setTemplateParameterListsInfo(
6878 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
6882 if (!getLangOpts().CPlusPlus) {
6885 }
else if (CurContext->isFunctionOrMethod()) {
6888 diag::err_inline_declaration_block_scope) << Name
6892 getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_inline_variable
6893 : diag::ext_inline_variable);
6904 if (IsLocalExternDecl) {
6906 for (
auto *B : Bindings)
6907 B->setLocalExternDecl();
6912 bool EmitTLSUnsupportedError =
false;
6925 diag::err_thread_non_global)
6928 if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
6932 EmitTLSUnsupportedError =
true;
6939 diag::err_thread_unsupported);
6950 diag::err_constexpr_wrong_decl_kind)
6960 (getLangOpts().CPlusPlus17 ||
6968 diag::err_constinit_local_variable);
6990 diag::warn_static_local_in_extern_inline);
6991 MaybeSuggestAddingStaticToDecl(CurFD);
6996 if (IsVariableTemplateSpecialization)
6998 << (IsPartialSpecialization ? 1 : 0)
7001 else if (IsMemberSpecialization)
7014 for (
auto *B : Bindings)
7015 B->setModulePrivate();
7019 if (getLangOpts().
OpenCL) {
7021 deduceOpenCLAddressSpace(NewVD);
7027 ProcessDeclAttributes(S, NewVD, D);
7029 if (getLangOpts().
CUDA || getLangOpts().OpenMPIsDevice) {
7030 if (EmitTLSUnsupportedError &&
7032 (getLangOpts().OpenMPIsDevice &&
7033 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD))))
7035 diag::err_thread_unsupported);
7039 (NewVD->
hasAttr<CUDASharedAttr>() ||
7040 NewVD->
hasAttr<CUDAConstantAttr>())) {
7048 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
7049 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
7054 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewVD))
7066 Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
7072 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
7083 bool HasSizeMismatch;
7085 if (!TI.isValidGCCRegisterName(Label))
7086 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
7087 else if (!TI.validateGlobalRegisterVariable(Label,
7090 Diag(E->getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
7091 else if (HasSizeMismatch)
7092 Diag(E->getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
7104 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
7105 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
7107 if (I != ExtnameUndeclaredIdentifiers.end()) {
7110 ExtnameUndeclaredIdentifiers.erase(I);
7119 ? getShadowedDeclaration(NewVD, Previous)
7127 IsMemberSpecialization ||
7128 IsVariableTemplateSpecialization);
7132 if (getLangOpts().CPlusPlus &&
7136 isDeclInScope(Previous.
getFoundDecl(), OriginalDC, S,
false));
7138 if (!getLangOpts().CPlusPlus) {
7143 CheckMemberSpecialization(NewVD, Previous))
7147 if (!Previous.
empty()) {
7166 if (!IsVariableTemplateSpecialization)
7178 if (CheckTemplateParameterList(
7184 ? TPC_ClassTemplateMember
7190 if (PrevVarTemplate &&
7198 CheckShadow(NewVD, ShadowedDecl, Previous);
7200 ProcessPragmaWeak(S, NewVD);
7206 RegisterLocallyScopedExternCDecl(NewVD, S);
7210 Decl *ManglingContextDecl;
7211 std::tie(MCtx, ManglingContextDecl) =
7228 if (getLangOpts().CPlusPlus)
7246 ActOnDocumentableDecl(NewTemplate);
7251 CompleteMemberSpecialization(NewVD, Previous);
7269 if (isa<TypeAliasDecl>(ShadowedDecl))
7271 else if (isa<TypedefDecl>(ShadowedDecl))
7273 else if (isa<RecordDecl>(OldDC))
7312 return isa<VarDecl>(ShadowedDecl) || isa<FieldDecl>(ShadowedDecl)
7329 return isa<TypedefNameDecl>(ShadowedDecl) ? ShadowedDecl :
nullptr;
7345 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
7353 if (isa<CXXConstructorDecl>(NewDC))
7354 if (
const auto PVD = dyn_cast<ParmVarDecl>(D)) {
7357 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
7362 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
7363 if (shadowedVar->isExternC()) {
7366 for (
auto I : shadowedVar->redecls())
7367 if (I->isFileVarDecl()) {
7375 unsigned WarningDiag = diag::warn_decl_shadow;
7377 if (isa<VarDecl>(D) && isa<VarDecl>(ShadowedDecl) && NewDC &&
7378 isa<CXXMethodDecl>(NewDC)) {
7379 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
7381 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
7383 const auto *LSI = cast<LambdaScopeInfo>(getCurFunction());
7386 if (CaptureLoc.isInvalid())
7387 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
7391 cast<LambdaScopeInfo>(getCurFunction())
7392 ->ShadowingDecls.push_back(
7393 {cast<VarDecl>(D), cast<VarDecl>(ShadowedDecl)});
7398 if (cast<VarDecl>(ShadowedDecl)->hasLocalStorage()) {
7402 ParentDC && !ParentDC->
Equals(OldDC);
7406 if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) &&
7433 if (getSourceManager().isInSystemMacro(R.
getNameLoc()))
7438 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7447 const VarDecl *ShadowedDecl = Shadow.ShadowedDecl;
7452 ? diag::warn_decl_shadow_uncaptured_local
7453 : diag::warn_decl_shadow)
7454 << Shadow.VD->getDeclName()
7457 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7458 << Shadow.VD->getDeclName() << 0;
7465 if (Diags.isIgnored(diag::warn_decl_shadow, D->
getLocation()))
7471 if (
NamedDecl *ShadowedDecl = getShadowedDeclaration(D, R))
7472 CheckShadow(D, ShadowedDecl, R);
7479 if (!getLangOpts().
CPlusPlus || ShadowingDecls.empty())
7485 const NamedDecl *D = cast<NamedDecl>(DRE->getDecl()->getCanonicalDecl());
7486 auto I = ShadowingDecls.find(D);
7487 if (I == ShadowingDecls.end())
7489 const NamedDecl *ShadowedDecl = I->second;
7491 Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
7496 ShadowingDecls.erase(I);
7501 template<
typename T>
7504 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
7525 if (!isa<VarDecl>(ND))
7535 if (isa<VarDecl>(*I)) {
7545 if (isa<VarDecl>(*I)) {
7563 assert(Prev &&
"should have found a previous declaration to diagnose");
7565 Prev = FD->getFirstDecl();
7567 Prev = cast<VarDecl>(Prev)->getFirstDecl();
7569 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
7571 S.
Diag(Prev->getLocation(), diag::note_extern_c_global_conflict)
7584 template<
typename T>
7591 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
7603 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
7628 CheckAlignasUnderalignment(NewVD);
7650 if (getLangOpts().OpenCLVersion == 120 &&
7651 !getOpenCLOptions().
isEnabled(
"cl_clang_storage_class_specifiers") &&
7658 if (getLangOpts().
OpenCL) {
7660 if (NewVD->
hasAttr<BlocksAttr>()) {
7669 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
7675 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
7692 (getLangOpts().OpenCLVersion == 200 ||
7693 getLangOpts().OpenCLCPlusPlus)))) {
7695 if (getLangOpts().OpenCLVersion == 200 || getLangOpts().OpenCLCPlusPlus)
7696 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7697 << Scope <<
"global or constant";
7699 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7700 << Scope <<
"constant";
7716 if (FD && !FD->
hasAttr<OpenCLKernelAttr>()) {
7728 if (FD && FD->
hasAttr<OpenCLKernelAttr>()) {
7729 if (!getCurScope()->isFunctionScope()) {
7753 && !NewVD->
hasAttr<BlocksAttr>()) {
7757 assert(!getLangOpts().ObjCAutoRefCount);
7763 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
7765 setFunctionHasBranchProtectedScope();
7769 bool SizeIsNegative;
7775 FixedT = FixedTInfo->
getType();
7776 else if (FixedTInfo) {
7832 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
7840 diag::err_constexpr_var_non_literal)) {
7859 CheckVariableDeclarationType(NewVD);
7867 if (Previous.
empty() &&
7871 if (!Previous.
empty()) {
7872 MergeVarDecl(NewVD, Previous);
7879 struct FindOverriddenMethod {
7905 if (MD->isVirtual() &&
7936 if ((OEK == OEK_All) ||
7937 (OEK == OEK_NonDeleted && !O->isDeleted()) ||
7938 (OEK == OEK_Deleted && O->isDeleted()))
7939 S.
Diag(O->getLocation(), diag::note_overridden_virtual_function);
7948 FindOverriddenMethod FOM;
7951 bool hasDeletedOverridenMethods =
false;
7952 bool hasNonDeletedOverridenMethods =
false;
7953 bool AddedAny =
false;
7958 if (!CheckOverridingFunctionReturnType(MD, OldMD) &&
7959 !CheckOverridingFunctionAttributes(MD, OldMD) &&
7960 !CheckOverridingFunctionExceptionSpec(MD, OldMD) &&
7961 !CheckIfOverriddenFunctionIsMarkedFinal(MD, OldMD)) {
7962 hasDeletedOverridenMethods |= OldMD->isDeleted();
7963 hasNonDeletedOverridenMethods |= !OldMD->isDeleted();
7970 if (hasDeletedOverridenMethods && !MD->
isDeleted()) {
7971 ReportOverrides(*
this, diag::err_non_deleted_override, MD, OEK_Deleted);
7973 if (hasNonDeletedOverridenMethods && MD->
isDeleted()) {
7974 ReportOverrides(*
this, diag::err_deleted_override, MD, OEK_NonDeleted);
7983 struct ActOnFDArgs {
7999 : Context(Context), OriginalFD(TypoFD),
8002 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
8008 CDeclEnd = candidate.
end();
8009 CDecl != CDeclEnd; ++CDecl) {
8018 }
else if (!ExpectedParent) {
8027 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
8028 return std::make_unique<DifferentNameValidatorCCC>(*this);
8040 TypoCorrectedFunctionDefinitions.insert(F);
8054 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *S) {
8060 bool IsDefinition = ExtraArgs.D.isFunctionDefinition();
8062 IsLocalFriend ? diag::err_no_matching_local_friend :
8064 diag::err_member_decl_does_not_match;
8075 assert(!Prev.isAmbiguous() &&
8076 "Cannot have an ambiguity in previous-declaration lookup");
8078 DifferentNameValidatorCCC CCC(SemaRef.
Context, NewFD,
8080 if (!Prev.empty()) {
8082 Func != FuncEnd; ++Func) {
8089 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
8090 NearMatches.push_back(std::make_pair(FD, ParamNum));
8095 Prev.getLookupNameInfo(), Prev.getLookupKind(), S,
8097 IsLocalFriend ? nullptr : NewDC))) {
8100 ExtraArgs.D.getIdentifierLoc());
8104 CDeclEnd = Correction.
end();
8105 CDecl != CDeclEnd; ++CDecl) {
8112 bool wasRedeclaration = ExtraArgs.D.isRedeclaration();
8125 ExtraArgs.S, ExtraArgs.D,
8128 ExtraArgs.AddToScope);
8139 if ((*I)->getCanonicalDecl() == Canonical)
8146 SemaRef.
PDiag(IsLocalFriend
8147 ? diag::err_no_matching_local_friend_suggest
8148 : diag::err_member_decl_does_not_match_suggest)
8149 << Name << NewDC << IsDefinition);
8155 ExtraArgs.D.getIdentifierLoc());
8156 ExtraArgs.D.setRedeclaration(wasRedeclaration);
8162 << Name << NewDC << IsDefinition << NewFD->
getLocation();
8164 bool NewFDisConst =
false;
8166 NewFDisConst = NewMD->isConst();
8169 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
8170 NearMatch != NearMatchEnd; ++NearMatch) {
8173 bool FDisConst = MD && MD->
isConst();
8174 bool IsMember = MD || !IsLocalFriend;
8177 if (
unsigned Idx = NearMatch->second) {
8181 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
8182 : diag::note_local_decl_close_param_match)
8185 }
else if (FDisConst != NewFDisConst) {
8186 SemaRef.
Diag(FD->
getLocation(), diag::note_member_def_close_const_match)
8190 IsMember ? diag::note_member_def_close_match
8191 : diag::note_local_decl_close_match);
8198 default: llvm_unreachable(
"Unknown storage class!");
8203 diag::err_typecheck_sclass_func);
8220 diag::err_static_block_func);
8236 bool &IsVirtualOkay) {
8255 R, TInfo, SC, isInline, HasPrototype,
8269 diag::err_constexpr_wrong_decl_kind)
8288 "Constructors can only be declared in a member context");
8293 TInfo, ExplicitSpecifier, isInline,
8295 TrailingRequiresClause);
8304 isInline,
false, ConstexprKind,
8305 TrailingRequiresClause);
8313 IsVirtualOkay =
true;
8325 true, ConstexprKind,
8326 TrailingRequiresClause);
8332 diag::err_conv_function_not_member);
8340 IsVirtualOkay =
true;
8343 TInfo, isInline, ExplicitSpecifier, ConstexprKind,
SourceLocation(),
8344 TrailingRequiresClause);
8347 if (TrailingRequiresClause)
8349 diag::err_trailing_requires_clause_on_deduction_guide)
8354 ExplicitSpecifier, NameInfo, R, TInfo,
8373 TrailingRequiresClause);
8386 R, TInfo, SC, isInline,
true ,
8387 ConstexprKind, TrailingRequiresClause);
8404 StringRef SizeTypeNames[] = {
"size_t",
"intptr_t",
"uintptr_t",
"ptrdiff_t"};
8412 if (Names.end() != Match)
8417 }
while (DesugaredTy != Ty);
8473 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
8520 S.
Diag(Loc, diag::note_entity_declared_at) << PT;
8543 HistoryStack.push_back(
nullptr);
8552 VisitStack.push_back(RecTy->
getDecl());
8553 assert(VisitStack.back() &&
"First decl null?");
8556 const Decl *Next = VisitStack.pop_back_val();
8558 assert(!HistoryStack.empty());
8560 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
8561 ValidTypes.insert(Hist->getType().getTypePtr());
8569 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(Next)) {
8570 HistoryStack.push_back(Field);
8572 QualType FieldTy = Field->getType();
8576 "Unexpected type.");
8581 RD = cast<RecordDecl>(Next);
8585 VisitStack.push_back(
nullptr);
8587 for (
const auto *FD : RD->
fields()) {
8598 VisitStack.push_back(FD);
8609 diag::err_record_with_pointers_kernel_param)
8616 S.
Diag(OrigRecDecl->getLocation(), diag::note_within_field_of_type)
8617 << OrigRecDecl->getDeclName();
8622 I = HistoryStack.begin() + 1,
8623 E = HistoryStack.end();
8630 S.
Diag(FD->getLocation(), diag::note_illegal_field_declared_here)
8636 }
while (!VisitStack.empty());
8653 (LangOpts.CPlusPlus &&
8671 TemplateParamLists.push_back(TPL);
8673 if (!TemplateParamLists.empty() &&
8674 Invented->getDepth() == TemplateParamLists.back()->getDepth())
8675 TemplateParamLists.back() = Invented;
8677 TemplateParamLists.push_back(Invented);
8687 diag::err_invalid_thread)
8694 bool isFriend =
false;
8696 bool isMemberSpecialization =
false;
8697 bool isFunctionTemplateSpecialization =
false;
8699 bool isDependentClassScopeExplicitSpecialization =
false;
8700 bool HasExplicitTemplateArgs =
false;
8703 bool isVirtualOkay =
false;
8706 bool IsLocalExternDecl = adjustContextForLocalExternDecl(DC);
8710 if (!NewFD)
return nullptr;
8712 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer())
8720 if (IsLocalExternDecl)
8740 if (
Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
8745 if (isVirtual &&
Parent->isUnion())
8750 isMemberSpecialization =
false;
8751 isFunctionTemplateSpecialization =
false;
8757 bool Invalid =
false;
8759 MatchTemplateParametersToScopeSpecifier(
8765 TemplateParamLists, isFriend, isMemberSpecialization,
8767 if (TemplateParams) {
8768 if (TemplateParams->
size() > 0) {
8772 if (CheckTemplateDeclScope(S, TemplateParams))
8786 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
8792 Name, TemplateParams,
8798 if (TemplateParamLists.size() > 1) {
8805 isFunctionTemplateSpecialization =
true;
8807 if (TemplateParamLists.size() > 0)
8823 InsertLoc = getLocForEndOfToken(InsertLoc);
8827 << Name << RemoveRange
8835 if (TemplateParamLists.size() > 0)
8842 if (FunctionTemplate)
8852 if (!isVirtualOkay) {
8854 diag::err_virtual_non_function);
8855 }
else if (!CurContext->isRecord()) {
8858 diag::err_virtual_out_of_class)
8864 diag::err_virtual_member_function_template)
8876 if (getLangOpts().CPlusPlus14 &&
8878 (isFriend && CurContext->isDependentContext())) &&
8898 if (CurContext->isFunctionOrMethod()) {
8901 diag::err_inline_declaration_block_scope) << Name
8911 !isa<CXXDeductionGuideDecl>(NewFD)) {
8912 if (!CurContext->isRecord()) {
8915 diag::err_explicit_out_of_class)
8917 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
8918 !isa<CXXConversionDecl>(NewFD)) {
8922 diag::err_explicit_non_ctor_or_conv_function)
8936 if (isa<CXXDestructorDecl>(NewFD) && !getLangOpts().
CPlusPlus2a) {
8944 if (isFunctionTemplateSpecialization) {
8947 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
8952 if (FunctionTemplate)
8958 if (FunctionTemplate) {
8983 if (isa<CXXMethodDecl>(NewFD) && DC == CurContext &&
8991 if (SC ==
SC_Static && isa<CXXMethodDecl>(NewFD) &&
8992 !CurContext->isRecord()) {
9006 cast<CXXRecordDecl>(DC)->getDescribedClassTemplate()) ||
9008 ? diag::ext_static_out_of_line : diag::err_static_out_of_line)
9018 getLangOpts().CPlusPlus11 && FPT && !FPT->hasExceptionSpec())
9020 FPT->getReturnType(), FPT->getParamTypes(),
9027 isMemberSpecialization ||
9028 isFunctionTemplateSpecialization);
9037 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
9038 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
9040 if (I != ExtnameUndeclaredIdentifiers.end()) {
9043 ExtnameUndeclaredIdentifiers.erase(I);
9063 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
9067 Params.push_back(Param);
9082 auto *TD = dyn_cast<
TagDecl>(NonParmDecl);
9087 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
9088 TD = cast<EnumDecl>(ECD->getDeclContext());
9096 TD->setDeclContext(NewFD);
9104 if (TagDC != PrototypeTagContext)
9105 TD->setLexicalDeclContext(TagDC);
9119 for (
const auto &AI : FT->param_types()) {
9123 Params.push_back(Param);
9127 "Should not need args for typedef of non-prototype fn");
9131 NewFD->setParams(Params);
9148 !NewFD->
hasAttr<SectionAttr>())
9149 NewFD->
addAttr(PragmaClangTextSectionAttr::CreateImplicit(
9150 Context, PragmaClangTextSection.SectionName,
9155 !NewFD->
hasAttr<SectionAttr>()) {
9156 NewFD->
addAttr(SectionAttr::CreateImplicit(
9157 Context, CodeSegStack.CurrentValue->getString(),
9159 SectionAttr::Declspec_allocate));
9160 if (UnifySection(CodeSegStack.CurrentValue->getString(),
9169 if (!NewFD->
hasAttr<CodeSegAttr>()) {
9170 if (
Attr *SAttr = getImplicitCodeSegOrSectionAttrForFunction(NewFD,
9177 ProcessDeclAttributes(S, NewFD, D);
9179 if (getLangOpts().
OpenCL) {
9185 diag::err_opencl_return_value_with_address_space);
9196 CheckMSVCRTEntryPoint(NewFD);
9200 isMemberSpecialization));
9201 else if (!Previous.
empty())
9206 "previous declaration set still overloaded");
9218 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
9228 NTCUC_FunctionReturn, NTCUK_Destruct|NTCUK_Copy);
9241 diag::ext_operator_new_delete_declared_inline)
9252 translateTemplateArguments(TemplateArgsPtr,
9255 HasExplicitTemplateArgs =
true;
9258 HasExplicitTemplateArgs =
false;
9259 }
else if (FunctionTemplate) {
9264 HasExplicitTemplateArgs =
false;
9266 assert((isFunctionTemplateSpecialization ||
9268 "should have a 'template<>' for this decl");
9270 isFunctionTemplateSpecialization =
true;
9272 }
else if (isFriend && isFunctionTemplateSpecialization) {
9279 HasExplicitTemplateArgs =
true;
9290 if (getLangOpts().CUDA && !isFunctionTemplateSpecialization)
9291 maybeAddCUDAHostDeviceAttrs(NewFD, Previous);
9297 bool InstantiationDependent =
false;
9298 if (isFunctionTemplateSpecialization && isFriend &&
9302 InstantiationDependent))) {
9303 assert(HasExplicitTemplateArgs &&
9304 "friend function specialization without template args");
9305 if (CheckDependentFunctionTemplateSpecialization(NewFD, TemplateArgs,
9308 }
else if (isFunctionTemplateSpecialization) {
9309 if (CurContext->isDependentContext() && CurContext->isRecord()
9311 isDependentClassScopeExplicitSpecialization =
true;
9313 CheckFunctionTemplateSpecialization(
9314 NewFD, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr),
9326 diag::err_explicit_specialization_inconsistent_storage_class)
9333 diag::ext_explicit_specialization_storage_class)
9337 }
else if (isMemberSpecialization && isa<CXXMethodDecl>(NewFD)) {
9338 if (CheckMemberSpecialization(NewFD, Previous))
9343 if (!isDependentClassScopeExplicitSpecialization) {
9348 CheckMSVCRTEntryPoint(NewFD);
9352 isMemberSpecialization));
9353 else if (!Previous.
empty())
9360 "previous declaration set still overloaded");
9362 NamedDecl *PrincipalDecl = (FunctionTemplate
9363 ? cast<NamedDecl>(FunctionTemplate)
9372 if (FunctionTemplate) FunctionTemplate->
setAccess(Access);
9381 if (FunctionTemplate) {
9389 ? TPC_FriendFunctionTemplateDefinition
9390 : TPC_FriendFunctionTemplate)
9394 ? TPC_ClassTemplateMember
9395 : TPC_FunctionTemplate);
9401 struct ActOnFDArgs ExtraArgs = { S, D, TemplateParamLists,
9424 (!Previous.
empty() && CurContext->isDependentContext()))) {
9443 *
this, Previous, NewFD, ExtraArgs,
false,
nullptr)) {
9444 AddToScope = ExtraArgs.AddToScope;
9451 }
else if (isFriend && cast<CXXRecordDecl>(CurContext)->isLocalClass()) {
9453 *
this, Previous, NewFD, ExtraArgs,
true, S)) {
9454 AddToScope = ExtraArgs.AddToScope;
9459 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
9460 !isFriend && !isFunctionTemplateSpecialization &&
9461 !isMemberSpecialization) {
9474 ProcessPragmaWeak(S, NewFD);
9477 AddKnownFunctionAttributes(NewFD);
9479 if (NewFD->
hasAttr<OverloadableAttr>() &&
9482 diag::err_attribute_overloadable_no_prototype)
9490 EPI.ExtInfo = FT->getExtInfo();
9499 AddPushedVisibilityAttribute(NewFD);
9503 AddCFAuditedAttribute(NewFD);
9508 AddRangeBasedOptnone(NewFD);
9514 RegisterLocallyScopedExternCDecl(NewFD, S);
9522 isMemberSpecialization ||
9523 isFunctionTemplateSpecialization,
9527 if (getLangOpts().CUDA) {
9529 if (II && II->
isStr(getCudaConfigureFuncName()) &&
9534 << getCudaConfigureFuncName();
9541 if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->
isVariadic() &&
9542 (NewFD->
hasAttr<CUDADeviceAttr>() ||
9543 NewFD->
hasAttr<CUDAGlobalAttr>()) &&
9550 MarkUnusedFileScopedDecl(NewFD);
9554 if (getLangOpts().
OpenCL && NewFD->
hasAttr<OpenCLKernelAttr>()) {
9556 if ((getLangOpts().OpenCLVersion >= 120)
9571 llvm::SmallPtrSet<const Type *, 16> ValidTypes;
9575 if (getLangOpts().OpenCLCPlusPlus) {
9580 if (FunctionTemplate) {
9588 if (FunctionTemplate) {
9591 return FunctionTemplate;
9595 CompleteMemberSpecialization(NewFD, Previous);
9603 if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
9605 QualType ElemTy = PipeTy->getElementType();
9607 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type );
9617 if (isDependentClassScopeExplicitSpecialization) {
9621 cast<CXXMethodDecl>(NewFD),
9622 HasExplicitTemplateArgs, TemplateArgs);
9623 CurContext->addDecl(NewSpec);
9629 if (
const auto *attr = NewFD->
getAttr<AvailabilityAttr>()) {
9630 if (NewFD->
hasAttr<ConstructorAttr>()) {
9631 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer)
9633 NewFD->
dropAttr<AvailabilityAttr>();
9635 if (NewFD->
hasAttr<DestructorAttr>()) {
9636 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer)
9638 NewFD->
dropAttr<AvailabilityAttr>();
9649 if (
const auto *NBA = NewFD->
getAttr<NoBuiltinAttr>())
9653 Diag(NBA->getLocation(),
9654 diag::err_attribute_no_builtin_on_defaulted_deleted_function)
9655 << NBA->getSpelling();
9658 Diag(NBA->getLocation(), diag::err_attribute_no_builtin_on_non_definition)
9659 << NBA->getSpelling();
9683 if (
const auto *SAttr = Parent->
getAttr<CodeSegAttr>()) {
9694 while ((Parent = dyn_cast<CXXRecordDecl>(Parent->
getParent()))) {
9695 if (
const auto *SAttr = Parent->
getAttr<CodeSegAttr>()) {
9714 bool IsDefinition) {
9717 if (!FD->
hasAttr<SectionAttr>() && IsDefinition &&
9718 CodeSegStack.CurrentValue)
9719 return SectionAttr::CreateImplicit(
9720 getASTContext(), CodeSegStack.CurrentValue->getString(),
9722 SectionAttr::Declspec_allocate);
9788 auto *PrevVD = dyn_cast<
ValueDecl>(PrevDecl);
9789 return !VD || !PrevVD ||
9790 canFullyTypeCheckRedeclaration(VD, PrevVD, VD->getType(),
9799 const auto *TA = FD->
getAttr<TargetAttr>();
9800 assert(TA &&
"MultiVersion Candidate requires a target attribute");
9803 enum ErrType { Feature = 0, Architecture = 1 };
9812 for (
const auto &Feat : ParseInfo.
Features) {
9813 auto BareFeat = StringRef{Feat}.substr(1);
9814 if (Feat[0] ==
'-') {
9816 << Feature << (
"no-" + BareFeat).str();
9823 << Feature << BareFeat;
9833 switch (A->getKind()) {
9834 case attr::CPUDispatch:
9835 case attr::CPUSpecific:
9857 bool ConstexprSupported,
bool CLinkageMayDiffer) {
9858 enum DoesntSupport {
9878 if (NoProtoDiagID.
getDiagID() != 0 && OldFD &&
9881 Diag(NoteCausedDiagIDAt.first, NoteCausedDiagIDAt.second);
9889 if (!TemplatesSupported &&
9891 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
9894 if (
const auto *NewCXXFD = dyn_cast<CXXMethodDecl>(NewFD)) {
9895 if (NewCXXFD->isVirtual())
9896 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
9899 if (isa<CXXConstructorDecl>(NewCXXFD))
9900 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
9903 if (isa<CXXDestructorDecl>(NewCXXFD))
9904 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
9909 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
9913 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
9917 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
9918 << (NewFD->
isConsteval() ? ConstevalFuncs : ConstexprFuncs);
9921 const auto *NewType = cast<FunctionType>(NewQType);
9922 QualType NewReturnType = NewType->getReturnType();
9924 if (NewReturnType->isUndeducedType())
9925 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
9931 const auto *OldType = cast<FunctionType>(OldQType);
9935 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC())
9938 QualType OldReturnType = OldType->getReturnType();
9940 if (OldReturnType != NewReturnType)
9941 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ReturnType;
9944 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ConstexprSpec;
9947 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << InlineSpec;
9953 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) <<
Linkage;
9955 if (CheckEquivalentExceptionSpec(
9974 bool IsCPUSpecificCPUDispatchMVType =
9982 << IsCPUSpecificCPUDispatchMVType;
9988 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_no_other_attrs)
9989 << IsCPUSpecificCPUDispatchMVType;
9992 if (OldFD && CausesMV && OldFD->
isUsed(
false))
9993 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
9996 OldFD, NewFD, S.
PDiag(diag::err_multiversion_noproto),
9998 S.
PDiag(diag::note_multiversioning_caused_here)),
10000 S.
PDiag(diag::err_multiversion_doesnt_support)
10001 << IsCPUSpecificCPUDispatchMVType),
10003 S.
PDiag(diag::err_multiversion_diff)),
10005 !IsCPUSpecificCPUDispatchMVType,
10017 const TargetAttr *TA) {
10019 "Function lacks multiversion attribute");
10051 bool &Redeclaration,
NamedDecl *&OldDecl,
bool &MergeTypeWithPrevious,
10053 const auto *OldTA = OldFD->
getAttr<TargetAttr>();
10056 llvm::sort(NewParsed.Features);
10060 if (!NewTA->isDefaultVersion() &&
10061 (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr()))
10084 if (!OldFD->
isMultiVersion() && !OldTA && NewTA->isDefaultVersion()) {
10085 Redeclaration =
true;
10093 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
10100 if (OldParsed == NewParsed) {
10107 for (
const auto *FD : OldFD->
redecls()) {
10108 const auto *CurTA = FD->getAttr<TargetAttr>();
10112 (!CurTA || CurTA->isInherited())) {
10113 S.
Diag(FD->getLocation(), diag::err_multiversion_required_in_redecl)
10115 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
10123 Redeclaration =
false;
10124 MergeTypeWithPrevious =
false;
10135 const CPUDispatchAttr *NewCPUDisp,
const CPUSpecificAttr *NewCPUSpec,
10136 bool &Redeclaration,
NamedDecl *&OldDecl,
bool &MergeTypeWithPrevious,
10153 NewParsed = NewTA->parse();
10157 bool UseMemberUsingDeclRules =
10166 if (S.
IsOverload(NewFD, CurFD, UseMemberUsingDeclRules))
10170 const auto *CurTA = CurFD->
getAttr<TargetAttr>();
10171 if (CurTA->getFeaturesStr() == NewTA->getFeaturesStr()) {
10173 Redeclaration =
true;
10179 if (CurParsed == NewParsed) {
10186 const auto *CurCPUSpec = CurFD->
getAttr<CPUSpecificAttr>();
10187 const auto *CurCPUDisp = CurFD->
getAttr<CPUDispatchAttr>();
10192 CurFD->
hasAttr<CPUDispatchAttr>()) {
10193 if (CurCPUDisp->cpus_size() == NewCPUDisp->cpus_size() &&
10195 CurCPUDisp->cpus_begin(), CurCPUDisp->cpus_end(),
10196 NewCPUDisp->cpus_begin(),
10198 return Cur->
getName() == New->getName();
10201 Redeclaration =
true;
10214 if (CurCPUSpec->cpus_size() == NewCPUSpec->cpus_size() &&
10216 CurCPUSpec->cpus_begin(), CurCPUSpec->cpus_end(),
10217 NewCPUSpec->cpus_begin(),
10219 return Cur->
getName() == New->getName();
10222 Redeclaration =
true;
10230 if (CurII == NewII) {
10264 Redeclaration =
true;
10270 Redeclaration =
false;
10271 MergeTypeWithPrevious =
false;
10285 bool &Redeclaration,
NamedDecl *&OldDecl,
10286 bool &MergeTypeWithPrevious,
10288 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
10289 const auto *NewCPUDisp = NewFD->
getAttr<CPUDispatchAttr>();
10290 const auto *NewCPUSpec = NewFD->
getAttr<CPUSpecificAttr>();
10293 if ((NewTA && NewCPUDisp) || (NewTA && NewCPUSpec) ||
10294 (NewCPUDisp && NewCPUSpec)) {
10308 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_not_allowed_on_main);
10331 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_required_in_redecl)
10340 Redeclaration, OldDecl,
10341 MergeTypeWithPrevious, Previous);
10347 S, OldFD, NewFD, MVType, NewTA, NewCPUDisp, NewCPUSpec, Redeclaration,
10348 OldDecl, MergeTypeWithPrevious, Previous);
10370 bool IsMemberSpecialization) {
10372 "Variably modified return types are not handled here");
10377 bool MergeTypeWithPrevious = !getLangOpts().CPlusPlus &&
10380 bool Redeclaration =
false;
10382 bool MayNeedOverloadableChecks =
false;
10386 if (!Previous.
empty()) {
10393 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
10394 Redeclaration =
true;
10395 OldDecl = Candidate;
10398 MayNeedOverloadableChecks =
true;
10399 switch (CheckOverload(S, NewFD, Previous, OldDecl,
10402 Redeclaration =
true;
10405 case Ovl_NonFunction:
10406 Redeclaration =
true;
10410 Redeclaration =
false;
10417 if (!Redeclaration &&
10419 if (!Previous.
empty()) {
10422 Redeclaration =
true;
10424 MergeTypeWithPrevious =
false;
10427 if (OldDecl->
hasAttr<OverloadableAttr>() ||
10428 NewFD->
hasAttr<OverloadableAttr>()) {
10429 if (IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
10430 MayNeedOverloadableChecks =
true;
10431 Redeclaration =
false;
10439 MergeTypeWithPrevious, Previous))
10440 return Redeclaration;
10452 if (!getLangOpts().CPlusPlus14 && MD && MD->
isConstexpr() &&
10453 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
10457 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
10458 if (!OldMD || !OldMD->
isStatic()) {
10468 if (!inTemplateInstantiation()) {
10472 AddConstLoc = getLocForEndOfToken(FTL.getRParenLoc());
10480 if (Redeclaration) {
10483 if (MergeFunctionDecl(NewFD, OldDecl, S, MergeTypeWithPrevious)) {
10485 return Redeclaration;
10492 dyn_cast<FunctionTemplateDecl>(OldDecl)) {
10493 auto *OldFD = OldTemplateDecl->getTemplatedDecl();
10496 assert(NewTemplateDecl &&
"Template/non-template mismatch");
10506 NewFD->
setAccess(OldTemplateDecl->getAccess());
10507 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
10512 if (IsMemberSpecialization &&
10515 assert(OldTemplateDecl->isMemberSpecialization());
10518 if (OldFD->isDeleted()) {
10520 assert(OldFD->getCanonicalDecl() == OldFD);
10522 OldFD->setDeletedAsWritten(
false);
10527 if (shouldLinkDependentDeclWithPrevious(NewFD, OldDecl)) {
10528 auto *OldFD = cast<FunctionDecl>(OldDecl);
10536 }
else if (!getLangOpts().CPlusPlus && MayNeedOverloadableChecks &&
10537 !NewFD->
getAttr<OverloadableAttr>()) {
10538 assert((Previous.
empty() ||
10539 llvm::any_of(Previous,
10541 return ND->
hasAttr<OverloadableAttr>();
10543 "Non-redecls shouldn't happen without overloadable present");
10545 auto OtherUnmarkedIter = llvm::find_if(Previous, [](
const NamedDecl *ND) {
10547 return FD && !FD->
hasAttr<OverloadableAttr>();
10550 if (OtherUnmarkedIter != Previous.
end()) {
10552 diag::err_attribute_overloadable_multiple_unmarked_overloads);
10553 Diag((*OtherUnmarkedIter)->getLocation(),
10554 diag::note_attribute_overloadable_prev_overload)
10557 NewFD->
addAttr(OverloadableAttr::CreateImplicit(Context));
10566 CheckConstructor(Constructor);
10568 dyn_cast<CXXDestructorDecl>(NewFD)) {
10581 return Redeclaration;
10585 = dyn_cast<CXXConversionDecl>(NewFD)) {
10586 ActOnConversionDeclarator(Conversion);
10587 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
10588 if (
auto *TD = Guide->getDescribedFunctionTemplate())
10589 CheckDeductionGuideTemplate(TD);
10594 Diag(Guide->getBeginLoc(), diag::err_deduction_guide_specialized)
10599 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
10600 if (!Method->isFunctionTemplateSpecialization() &&
10601 !Method->getDescribedFunctionTemplate() &&
10602 Method->isCanonicalDecl()) {
10603 if (AddOverriddenMethods(Method->getParent(), Method)) {
10614 diag::err_constrained_virtual_method);
10616 if (Method->isStatic())
10617 checkThisInStaticMemberFunctionType(Method);
10622 CheckOverloadedOperatorDeclaration(NewFD)) {
10624 return Redeclaration;
10629 CheckLiteralOperatorDeclaration(NewFD)) {
10631 return Redeclaration;
10637 if (!CurContext->isRecord())
10638 CheckCXXDefaultArguments(NewFD);
10669 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
10682 auto HasNoexcept = [&](
QualType T) ->
bool {
10688 else if (T->isAnyPointerType())
10693 if (FPT->isNothrow())
10699 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
10700 for (
QualType T : FPT->param_types())
10701 AnyNoexcept |= HasNoexcept(T);
10704 diag::warn_cxx17_compat_exception_spec_in_signature)
10708 if (!Redeclaration && LangOpts.CUDA)
10709 checkCUDATargetOverload(NewFD, Previous);
10711 return Redeclaration;
10724 ? diag::err_static_main : diag::warn_static_main)
10731 SourceRange NoreturnRange(NoreturnLoc, getLocForEndOfToken(NoreturnLoc));
10732 Diag(NoreturnLoc, diag::ext_noreturn_main);
10733 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
10743 if (getLangOpts().
OpenCL) {
10745 << FD->
hasAttr<OpenCLKernelAttr>();
10751 assert(T->
isFunctionType() &&
"function decl is not of function type");
10755 if (FT->getCallConv() !=
CC_C) {
10761 if (getLangOpts().GNUMode && !getLangOpts().CPlusPlus) {
10772 if (RTRange.isValid())
10773 Diag(RTRange.getBegin(), diag::note_main_change_return_type)
10795 if (isa<FunctionNoProtoType>(FT))
return;
10801 bool HasExtraParameters = (nparams > 3);
10813 HasExtraParameters =
false;
10815 if (HasExtraParameters) {
10828 for (
unsigned i = 0; i < nparams; ++i) {
10831 bool mismatch =
true;
10835 else if (Expected[i] == CharPP) {
10848 mismatch = !qs.
empty();
10853 Diag(FD->
getLocation(), diag::err_main_arg_wrong) << i << Expected[i];
10871 assert(T->
isFunctionType() &&
"function decl is not of function type");
10876 if (FT->getReturnType()->isIntegralOrEnumerationType() ||
10877 FT->getReturnType()->isAnyPointerType() ||
10878 FT->getReturnType()->isNullPtrType())
10880 if (FD->
getName() !=
"DllMain")
10898 const Expr *Culprit;
10901 Diag(Culprit->
getExprLoc(), diag::err_init_element_not_constant)
10909 class SelfReferenceChecker
10915 bool isReferenceType;
10923 SelfReferenceChecker(
Sema &S,
Decl *OrigDecl) : Inherited(S.
Context),
10924 S(S), OrigDecl(OrigDecl) {
10926 isRecordType =
false;
10927 isReferenceType =
false;
10928 isInitList =
false;
10929 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
10930 isPODType = VD->getType().isPODType(S.
Context);
10931 isRecordType = VD->getType()->isRecordType();
10932 isReferenceType = VD->getType()->isReferenceType();
10939 void CheckExpr(
Expr *E) {
10948 InitFieldIndex.push_back(0);
10949 for (
auto Child : InitList->
children()) {
10950 CheckExpr(cast<Expr>(Child));
10951 ++InitFieldIndex.back();
10953 InitFieldIndex.pop_back();
10958 bool CheckInitListMemberExpr(
MemberExpr *E,
bool CheckReference) {
10961 bool ReferenceField =
false;
10964 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
10968 Fields.push_back(FD);
10970 ReferenceField =
true;
10976 if (!DRE || DRE->
getDecl() != OrigDecl)
10980 if (CheckReference && !ReferenceField)
10985 for (
const FieldDecl *I : llvm::reverse(Fields))
10986 UsedFieldIndex.push_back(I->getFieldIndex());
10991 for (
auto UsedIter = UsedFieldIndex.begin(),
10992 UsedEnd = UsedFieldIndex.end(),
10993 OrigIter = InitFieldIndex.begin(),
10994 OrigEnd = InitFieldIndex.end();
10995 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
10996 if (*UsedIter < *OrigIter)
10998 if (*UsedIter > *OrigIter)
11003 HandleDeclRefExpr(DRE);
11010 void HandleValue(
Expr *E) {
11012 if (
DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
11013 HandleDeclRefExpr(DRE);
11018 Visit(CO->getCond());
11019 HandleValue(CO->getTrueExpr());
11020 HandleValue(CO->getFalseExpr());
11025 dyn_cast<BinaryConditionalOperator>(E)) {
11026 Visit(BCO->getCond());
11027 HandleValue(BCO->getFalseExpr());
11032 HandleValue(OVE->getSourceExpr());
11037 if (BO->getOpcode() == BO_Comma) {
11038 Visit(BO->getLHS());
11039 HandleValue(BO->getRHS());
11044 if (isa<MemberExpr>(E)) {
11046 if (CheckInitListMemberExpr(cast<MemberExpr>(E),
11052 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
11054 if (!isa<FieldDecl>(ME->getMemberDecl()))
11058 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base))
11059 HandleDeclRefExpr(DRE);
11069 if (isReferenceType)
11070 HandleDeclRefExpr(E);
11079 Inherited::VisitImplicitCastExpr(E);
11084 if (CheckInitListMemberExpr(E,
true ))
11094 bool Warn = (MD && !MD->
isStatic());
11096 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
11097 if (!isa<FieldDecl>(ME->getMemberDecl()))
11102 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
11104 HandleDeclRefExpr(DRE);
11116 if (isa<UnresolvedLookupExpr>(Callee))
11117 return Inherited::VisitCXXOperatorCallExpr(E);
11121 HandleValue(Arg->IgnoreParenImpCasts());
11126 if (E->
getOpcode() == UO_AddrOf && isRecordType &&
11138 Inherited::VisitUnaryOperator(E);
11146 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
11147 if (ILE->getNumInits() == 1)
11148 ArgExpr = ILE->getInit(0);
11150 if (ICE->getCastKind() == CK_NoOp)
11151 ArgExpr = ICE->getSubExpr();
11152 HandleValue(ArgExpr);
11155 Inherited::VisitCXXConstructExpr(E);
11161 HandleValue(E->
getArg(0));
11165 Inherited::VisitCallExpr(E);
11170 HandleValue(E->
getLHS());
11175 Inherited::VisitBinaryOperator(E);
11188 if (OrigDecl != ReferenceDecl)
return;
11190 if (isReferenceType) {
11191 diag = diag::warn_uninit_self_reference_in_reference_init;
11192 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
11193 diag = diag::warn_static_self_reference_in_init;
11194 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
11197 diag = diag::warn_uninit_self_reference_in_init;
11211 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *E,
11215 if (isa<ParmVarDecl>(OrigDecl))
11222 if (!DirectInit && !cast<VarDecl>(OrigDecl)->getType()->
isRecordType())
11224 if (ICE->getCastKind() == CK_LValueToRValue)
11225 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
11226 if (DRE->getDecl() == OrigDecl)
11229 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
11236 struct VarDeclOrName {
11242 return VN.VDecl ? Diag << VN.VDecl : Diag << VN.Name;
11252 bool IsInitCapture = !VDecl;
11254 "init captures are expected to be deduced prior to initialization");
11256 VarDeclOrName VN{VDecl, Name};
11259 assert(Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
11263 assert(VDecl &&
"no init for init capture deduction?");
11267 if (!isa<DeducedTemplateSpecializationType>(Deduced) ||
11278 DeduceInits = Init;
11281 if (
auto *PL = dyn_cast_or_null<ParenListExpr>(Init))
11282 DeduceInits = PL->exprs();
11285 if (isa<DeducedTemplateSpecializationType>(Deduced)) {
11286 assert(VDecl &&
"non-auto type for init capture deduction?");
11292 return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind,
11297 if (
auto *IL = dyn_cast<InitListExpr>(Init))
11298 DeduceInits = IL->inits();
11302 if (DeduceInits.empty()) {
11306 ? diag::err_init_capture_no_expression
11307 : diag::err_auto_var_init_no_expression)
11308 << VN << Type << Range;
11312 if (DeduceInits.size() > 1) {
11313 Diag(DeduceInits[1]->getBeginLoc(),
11314 IsInitCapture ? diag::err_init_capture_multiple_expressions
11315 : diag::err_auto_var_init_multiple_expressions)
11316 << VN << Type << Range;
11320 Expr *DeduceInit = DeduceInits[0];
11321 if (DirectInit && isa<InitListExpr>(DeduceInit)) {
11323 ? diag::err_init_capture_paren_braces
11324 : diag::err_auto_var_init_paren_braces)
11325 << isa<InitListExpr>(Init) << VN << Type << Range;
11330 bool DefaultedAnyToId =
false;
11331 if (getLangOpts().DebuggerCastResultToId &&
11337 Init = Result.
get();
11338 DefaultedAnyToId =
true;
11344 if (VDecl && isa<DecompositionDecl>(VDecl) &&
11351 if (DeduceAutoType(TSI, DeduceInit, DeducedType) == DAR_Failed) {
11352 if (!IsInitCapture)
11353 DiagnoseAutoDeductionFailure(VDecl, DeduceInit);
11354 else if (isa<InitListExpr>(Init))
11356 diag::err_init_capture_deduction_failure_from_init_list)
11362 Diag(Range.
getBegin(), diag::err_init_capture_deduction_failure)
11374 if (!inTemplateInstantiation() && !DefaultedAnyToId && !IsInitCapture &&
11377 Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
11380 return DeducedType;
11388 if (DeducedType.
isNull()) {
11397 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(VDecl))
11400 if (getLangOpts().
OpenCL)
11401 deduceOpenCLAddressSpace(VDecl);
11408 MergeVarDeclTypes(VDecl, Old,
false);
11412 CheckVariableDeclarationType(VDecl);
11418 if (
auto *CE = dyn_cast<ConstantExpr>(Init))
11419 Init = CE->getSubExpr();
11424 "shouldn't be called if type doesn't have a non-trivial C struct");
11425 if (
auto *ILE = dyn_cast<InitListExpr>(Init)) {
11426 for (
auto I : ILE->inits()) {
11427 if (!I->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion() &&
11428 !I->getType().hasNonTrivialToPrimitiveCopyCUnion())
11431 checkNonTrivialCUnionInInitializer(I, SL.
isValid() ? SL : Loc);
11436 if (isa<ImplicitValueInitExpr>(Init)) {
11438 checkNonTrivialCUnion(InitType, Loc, NTCUC_DefaultInitializedObject,
11446 checkNonTrivialCUnion(InitType, Loc, NTCUC_CopyInit, NTCUK_Copy);
11452 bool shouldIgnoreForRecordTriviality(
const FieldDecl *FD) {
11458 return FD->
hasAttr<UnavailableAttr>();
11461 struct DiagNonTrivalCUnionDefaultInitializeVisitor
11468 DiagNonTrivalCUnionDefaultInitializeVisitor(
11471 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
11474 const FieldDecl *FD,
bool InNonTrivialUnion) {
11477 InNonTrivialUnion);
11478 return Super::visitWithKind(PDIK, QT, FD, InNonTrivialUnion);
11482 bool InNonTrivialUnion) {
11483 if (InNonTrivialUnion)
11485 << 1 << 0 << QT << FD->
getName();
11489 if (InNonTrivialUnion)
11491 << 1 << 0 << QT << FD->
getName();
11498 bool IsUnion =
false;
11500 IsUnion = OrigRD->isUnion();
11501 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
11502 << 0 << OrigTy << IsUnion << UseContext;
11506 InNonTrivialUnion =
true;
11509 if (InNonTrivialUnion)
11514 if (!shouldIgnoreForRecordTriviality(FD))
11515 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
11528 struct DiagNonTrivalCUnionDestructedTypeVisitor
11533 DiagNonTrivalCUnionDestructedTypeVisitor(
11536 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
11539 const FieldDecl *FD,
bool InNonTrivialUnion) {
11542 InNonTrivialUnion);
11543 return Super::visitWithKind(DK, QT, FD, InNonTrivialUnion);
11547 bool InNonTrivialUnion) {
11548 if (InNonTrivialUnion)
11550 << 1 << 1 << QT << FD->
getName();
11554 if (InNonTrivialUnion)
11556 << 1 << 1 << QT << FD->
getName();
11563 bool IsUnion =
false;
11565 IsUnion = OrigRD->isUnion();
11566 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
11567 << 1 << OrigTy << IsUnion << UseContext;
11571 InNonTrivialUnion =
true;
11574 if (InNonTrivialUnion)
11579 if (!shouldIgnoreForRecordTriviality(FD))
11580 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
11585 bool InNonTrivialUnion) {}
11595 struct DiagNonTrivalCUnionCopyVisitor
11602 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
11605 const FieldDecl *FD,
bool InNonTrivialUnion) {
11608 InNonTrivialUnion);
11609 return Super::visitWithKind(PCK, QT, FD, InNonTrivialUnion);
11613 bool InNonTrivialUnion) {
11614 if (InNonTrivialUnion)
11616 << 1 << 2 << QT << FD->
getName();
11620 if (InNonTrivialUnion)
11622 << 1 << 2 << QT << FD->
getName();
11629 bool IsUnion =
false;
11631 IsUnion = OrigRD->isUnion();
11632 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
11633 << 2 << OrigTy << IsUnion << UseContext;
11637 InNonTrivialUnion =
true;
11640 if (InNonTrivialUnion)
11645 if (!shouldIgnoreForRecordTriviality(FD))
11646 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
11650 const FieldDecl *FD,
bool InNonTrivialUnion) {}
11653 bool InNonTrivialUnion) {}
11667 unsigned NonTrivialKind) {
11671 "shouldn't be called if type doesn't have a non-trivial C union");
11673 if ((NonTrivialKind & NTCUK_Init) &&
11675 DiagNonTrivalCUnionDefaultInitializeVisitor(QT, Loc, UseContext, *
this)
11676 .visit(QT,
nullptr,
false);
11677 if ((NonTrivialKind & NTCUK_Destruct) &&
11679 DiagNonTrivalCUnionDestructedTypeVisitor(QT, Loc, UseContext, *
this)
11680 .visit(QT,
nullptr,
false);
11682 DiagNonTrivalCUnionCopyVisitor(QT, Loc, UseContext, *
this)
11683 .visit(QT,
nullptr,
false);
11693 CorrectDelayedTyposInExpr(Init, dyn_cast_or_null<VarDecl>(RealDecl));
11697 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
11699 Diag(Method->getLocation(), diag::err_member_function_initialization)
11701 Method->setInvalidDecl();
11707 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
11718 ExprResult Res = CorrectDelayedTyposInExpr(Init, VDecl);
11725 if (DeduceVariableDeclarationType(VDecl, DirectInit, Init))
11731 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
11749 BaseDeclType = Array->getElementType();
11750 if (RequireCompleteType(VDecl->
getLocation(), BaseDeclType,
11751 diag::err_typecheck_decl_incomplete_type)) {
11758 diag::err_abstract_type_in_decl,
11759 AbstractVariableType))
11770 checkVarDeclRedefinition(Def, VDecl))
11773 if (getLangOpts().CPlusPlus) {
11787 Diag(Init->
getExprLoc(), diag::err_static_data_member_reinitialization)
11790 diag::note_previous_initializer)
11796 setFunctionHasBranchProtectedScope();
11798 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer)) {
11825 Init = Result.
get();
11841 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
11843 Args[Idx], VDecl, [
this, Entity, Kind](
Expr *E) {
11849 }
else if (Res.
get() != Args[Idx]) {
11850 Args[Idx] = Res.
get();
11872 if (getLangOpts().CPlusPlus) {
11875 CheckSelfReference(*
this, RealDecl, Init, DirectInit);
11889 if (VDecl->
hasAttr<BlocksAttr>())
11890 checkRetainCycles(VDecl, Init);
11902 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
11904 FSI->markSafeWeakUse(Init);
11925 Init = Result.
get();
11938 CheckForConstantInitializer(Init, DclT);
11947 CheckForConstantInitializer(Init, DclT);
11954 isa<InitListExpr>(Init)) {
11955 const Expr *Culprit;
11958 diag::ext_aggregate_init_not_constant)
11963 if (
auto *E = dyn_cast<ExprWithCleanups>(Init))
11964 if (
auto *BE = dyn_cast<BlockExpr>(E->getSubExpr()->IgnoreParens()))
11966 BE->getBlockDecl()->setCanAvoidCopyToHeap();
12022 Diag(Loc, diag::ext_in_class_initializer_non_constant)
12027 Diag(Loc, diag::err_in_class_initializer_non_constant)
12036 if (getLangOpts().CPlusPlus11) {
12038 diag::ext_in_class_initializer_float_type_cxx11)
12041 diag::note_in_class_initializer_float_type_cxx11)
12044 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
12048 Diag(Init->
getExprLoc(), diag::err_in_class_initializer_non_constant)
12056 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
12075 ((!getLangOpts().CPlusPlus && !VDecl->
hasAttr<SelectAnyAttr>()) ||
12077 !(getLangOpts().CPlusPlus && VDecl->
isExternC()) &&
12091 CheckForConstantInitializer(Init, DclT);
12095 if (!InitType.
isNull() &&
12098 checkNonTrivialCUnionInInitializer(Init, Init->
getExprLoc());
12114 if (CXXDirectInit) {
12115 assert(DirectInit &&
"Call-style initializer must be direct init.");
12117 }
else if (DirectInit) {
12122 CheckCompleteVariableDeclaration(VDecl);
12137 if (
auto *DD = dyn_cast<DecompositionDecl>(D))
12138 for (
auto *BD : DD->bindings())
12142 if (ParsingInitForAutoVars.count(D)) {
12153 diag::err_typecheck_decl_incomplete_type)) {
12159 if (RequireNonAbstractType(VD->
getLocation(), Ty,
12160 diag::err_abstract_type_in_decl,
12161 AbstractVariableType)) {
12175 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
12179 if (isa<DecompositionDecl>(RealDecl)) {
12180 Diag(Var->getLocation(), diag::err_decomp_decl_requires_init) << Var;
12181 Var->setInvalidDecl();
12186 DeduceVariableDeclarationType(Var,
false,
nullptr))
12195 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
12196 !Var->isThisDeclarationADemotedDefinition()) {
12197 if (Var->isStaticDataMember()) {
12200 if (!getLangOpts().CPlusPlus17 &&
12202 Diag(Var->getLocation(),
12203 diag::err_constexpr_static_mem_var_requires_init)
12204 << Var->getDeclName();
12205 Var->setInvalidDecl();
12209 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
12210 Var->setInvalidDecl();
12217 if (!Var->isInvalidDecl() &&
12219 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
12220 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
12221 Var->setInvalidDecl();
12227 Var->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion())
12228 checkNonTrivialCUnion(Var->getType(), Var->getLocation(),
12229 NTCUC_DefaultInitializedObject, NTCUK_Init);
12234 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
12250 !Var->hasLinkage() && !Var->isInvalidDecl() &&
12251 RequireCompleteType(Var->getLocation(), Type,
12252 diag::err_typecheck_decl_incomplete_type))
12253 Var->setInvalidDecl();
12257 RequireNonAbstractType(Var->getLocation(), Type,
12258 diag::err_abstract_type_in_decl,
12259 AbstractVariableType))
12260 Var->setInvalidDecl();
12263 Diag(Var->getLocation(), diag::warn_private_extern);
12264 Diag(Var->getLocation(), diag::note_private_extern);
12268 !Var->isInvalidDecl() && !getLangOpts().CPlusPlus)
12269 ExternalDeclarations.push_back(Var);
12279 if (!Var->isInvalidDecl()) {
12282 if (RequireCompleteType(Var->getLocation(),
12283 ArrayT->getElementType(),
12284 diag::err_illegal_decl_array_incomplete_type))
12285 Var->setInvalidDecl();
12286 }
else if (Var->getStorageClass() ==
SC_Static) {
12296 if (Var->isFirstDecl())
12297 RequireCompleteType(Var->getLocation(), Type,
12298 diag::ext_typecheck_decl_incomplete_type);
12303 if (!Var->isInvalidDecl())
12304 TentativeDefinitions.push_back(Var);
12311 Diag(Var->getLocation(),
12312 diag::err_typecheck_incomplete_array_needs_initializer);
12313 Var->setInvalidDecl();
12320 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
12321 << Var->getDeclName()
12322 <<
SourceRange(Var->getLocation(), Var->getLocation());
12323 Var->setInvalidDecl();
12332 if (Var->isInvalidDecl())
12335 if (!Var->hasAttr<AliasAttr>()) {
12336 if (RequireCompleteType(Var->getLocation(),
12338 diag::err_typecheck_decl_incomplete_type)) {
12339 Var->setInvalidDecl();
12347 if (RequireNonAbstractType(Var->getLocation(), Type,
12348 diag::err_abstract_type_in_decl,
12349 AbstractVariableType)) {
12350 Var->setInvalidDecl();
12364 if (getLangOpts().
CPlusPlus && Var->hasLocalStorage()) {
12367 CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl());
12371 if (!CXXRecord->
isPOD())
12372 setFunctionHasBranchProtectedScope();
12377 if (getLangOpts().OpenCL &&
12399 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, None);
12401 Var->setInvalidDecl();
12402 else if (Init.
get()) {
12403 Var->setInit(MaybeCreateExprWithCleanups(Init.
get()));
12408 CheckCompleteVariableDeclaration(Var);
12466 const char *PrevSpec;
12469 getPrintingPolicy());
12477 Decl *Var = ActOnDeclarator(S, D);
12478 cast<VarDecl>(Var)->setCXXForRangeDecl(
true);
12479 FinalizeDeclaration(Var);
12480 return ActOnDeclStmt(FinalizeDeclaratorGroup(S, DS, Var), IdentLoc,
12481 AttrEnd.
isValid() ? AttrEnd : IdentLoc);
12487 if (getLangOpts().OpenCL) {
12501 if (getLangOpts().ObjC &&
12511 setFunctionHasBranchProtectedScope();
12518 setFunctionHasBranchProtectedScope();
12529 !isa<VarTemplatePartialSpecializationDecl>(var) &&
12531 !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
12539 Diag(var->
getLocation(), diag::warn_missing_variable_declarations) << var;
12547 const Expr *CacheCulprit =
nullptr;
12548 auto checkConstInit = [&]()
mutable {
12549 if (!CacheHasConstInit)
12552 return *CacheHasConstInit;
12561 if (getLangOpts().CPlusPlus11)
12563 }
else if (getLangOpts().CPlusPlus && var->
hasInit()) {
12564 if (!checkConstInit()) {
12580 !inTemplateInstantiation()) {
12584 Stack = &ConstSegStack;
12586 Stack = &BSSSegStack;
12589 Stack = &DataSegStack;
12593 var->
addAttr(SectionAttr::CreateImplicit(
12596 SectionAttr::Declspec_allocate));
12597 if (
const SectionAttr *SA = var->
getAttr<SectionAttr>())
12598 if (UnifySection(SA->getName(), SectionFlags, var))
12604 if (CurInitSeg && var->
getInit())
12605 var->
addAttr(InitSegAttr::CreateImplicit(Context, CurInitSeg->getString(),
12611 if (!getLangOpts().CPlusPlus) {
12619 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
12620 CheckCompleteDecompositionDeclaration(DD);
12625 if (var->
hasAttr<BlocksAttr>())
12626 getCurFunction()->addByrefBlockVar(var);
12639 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
12640 diag::note_invalid_subexpr_in_const_expr) {
12641 DiagLoc = Notes[0].first;
12644 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
12646 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
12647 Diag(Notes[I].first, Notes[I].second);
12660 bool DiagErr = getLangOpts().CPlusPlus11
12667 diag::note_declared_required_constant_init_here)
12673 for (
auto &it : Notes)
12674 Diag(it.first, it.second);
12677 diag::note_invalid_subexpr_in_const_expr)
12683 !getDiagnostics().isIgnored(diag::warn_global_constructor,
12690 if (!checkConstInit())
12712 if (I->isAlignmentDependent())
12726 !FD->hasAttr<DLLExportStaticLocalAttr>() &&
12727 !FD->hasAttr<DLLImportStaticLocalAttr>()) {
12728 FD = dyn_cast_or_null<FunctionDecl>(FD->getParentFunctionOrMethod());
12736 auto *NewAttr = cast<InheritableAttr>(A->clone(getASTContext()));
12737 NewAttr->setInherited(
true);
12739 }
else if (
Attr *A = FD->getAttr<DLLExportStaticLocalAttr>()) {
12740 auto *NewAttr = DLLExportAttr::CreateImplicit(getASTContext(), *A);
12741 NewAttr->setInherited(
true);
12746 if (!FD->hasAttr<DLLExportAttr>())
12747 FD->addAttr(NewAttr);
12749 }
else if (
Attr *A = FD->getAttr<DLLImportStaticLocalAttr>()) {
12750 auto *NewAttr = DLLImportAttr::CreateImplicit(getASTContext(), *A);
12751 NewAttr->setInherited(
true);
12760 ParsingInitForAutoVars.erase(ThisDecl);
12762 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
12768 !inTemplateInstantiation() && !VD->
hasAttr<SectionAttr>()) {
12769 if (PragmaClangBSSSection.Valid)
12770 VD->
addAttr(PragmaClangBSSSectionAttr::CreateImplicit(
12771 Context, PragmaClangBSSSection.SectionName,
12772 PragmaClangBSSSection.PragmaLocation,
12774 if (PragmaClangDataSection.Valid)
12775 VD->
addAttr(PragmaClangDataSectionAttr::CreateImplicit(
12776 Context, PragmaClangDataSection.SectionName,
12777 PragmaClangDataSection.PragmaLocation,
12779 if (PragmaClangRodataSection.Valid)
12780 VD->
addAttr(PragmaClangRodataSectionAttr::CreateImplicit(
12781 Context, PragmaClangRodataSection.SectionName,
12782 PragmaClangRodataSection.PragmaLocation,
12784 if (PragmaClangRelroSection.Valid)
12785 VD->
addAttr(PragmaClangRelroSectionAttr::CreateImplicit(
12786 Context, PragmaClangRelroSection.SectionName,
12787 PragmaClangRelroSection.PragmaLocation,
12791 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
12792 for (
auto *BD : DD->bindings()) {
12793 FinalizeDeclaration(BD);
12817 CheckStaticLocalForDllExport(VD);
12827 if (!getLangOpts().CUDA)
12829 if (VD->
hasAttr<CUDASharedAttr>())
12832 !(VD->
hasAttr<CUDADeviceAttr>() || VD->
hasAttr<CUDAConstantAttr>()))
12835 diag::err_device_static_local_var)
12836 << CurrentCUDATarget())
12847 if (getLangOpts().CUDA)
12848 checkAllowedCUDAInitializer(VD);
12854 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
12861 bool IsClassTemplateMember =
12862 isa<ClassTemplatePartialSpecializationDecl>(Context) ||
12866 IsClassTemplateMember
12867 ? diag::warn_attribute_dllimport_static_field_definition
12868 : diag::err_attribute_dllimport_static_field_definition);
12869 Diag(IA->getLocation(), diag::note_attribute);
12870 if (!IsClassTemplateMember)
12902 AddPushedVisibilityAttribute(VD);
12905 if (VD->
isFileVarDecl() && !isa<VarTemplatePartialSpecializationDecl>(VD))
12906 MarkUnusedFileScopedDecl(VD);
12910 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
12914 for (
const auto *I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
12916 if (!MagicValueExpr) {
12921 Diag(I->getRange().getBegin(),
12922 diag::err_type_tag_for_datatype_not_ice)
12926 if (MagicValueInt.getActiveBits() > 64) {
12927 Diag(I->getRange().getBegin(),
12928 diag::err_type_tag_for_datatype_too_large)
12932 uint64_t MagicValue = MagicValueInt.getZExtValue();
12933 RegisterTypeTagForDatatype(I->getArgumentKind(),
12935 I->getMatchingCType(),
12936 I->getLayoutCompatible(),
12937 I->getMustBeNull());
12942 auto *VD = dyn_cast<
VarDecl>(DD);
12955 bool DiagnosedMultipleDecomps =
false;
12957 bool DiagnosedNonDeducedAuto =
false;
12959 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
12960 if (
Decl *D = Group[i]) {
12963 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
12964 if (!FirstDeclaratorInGroup)
12965 FirstDeclaratorInGroup = DD;
12966 if (!FirstDecompDeclaratorInGroup)
12970 FirstNonDeducedAutoInGroup = DD;
12972 if (FirstDeclaratorInGroup != DD) {
12975 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
12977 diag::err_decomp_decl_not_alone)
12979 << DD->getSourceRange();
12980 DiagnosedMultipleDecomps =
true;
12986 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
12988 diag::err_auto_non_deduced_not_alone)
12989 << FirstNonDeducedAutoInGroup->
getType()
12992 << DD->getSourceRange();
12993 DiagnosedNonDeducedAuto =
true;
12998 Decls.push_back(D);
13004 handleTagNumbering(Tag, S);
13005 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
13006 getLangOpts().CPlusPlus)
13011 return BuildDeclaratorGroup(Decls);
13021 if (Group.size() > 1) {
13023 VarDecl *DeducedDecl =
nullptr;
13024 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
13035 auto *AT = dyn_cast<
AutoType>(DT);
13037 diag::err_auto_different_deductions)
13038 << (AT ? (
unsigned)AT->getKeyword() : 3)
13049 ActOnDocumentableDecls(Group);
13051 return DeclGroupPtrTy::make(
13056 ActOnDocumentableDecls(D);
13061 if (Group.empty() || !Group[0])
13064 if (Diags.isIgnored(diag::warn_doc_param_not_found,
13065 Group[0]->getLocation()) &&
13066 Diags.isIgnored(diag::warn_unknown_comment_command_name,
13067 Group[0]->getLocation()))
13070 if (Group.size() >= 2) {
13078 Decl *MaybeTagDecl = Group[0];
13079 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
13080 Group = Group.slice(1);
13096 CheckExtraCXXDefaultArguments(D);
13118 << GetNameForDeclarator(D).getName();
13142 if (getLangOpts().CPlusPlus11) {
13144 getLangOpts().CPlusPlus17 ? diag::ext_register_storage_class
13145 : diag::warn_deprecated_register)
13148 }
else if (getLangOpts().CPlusPlus &&
13153 diag::err_invalid_storage_class_in_func_decl);
13162 << getLangOpts().CPlusPlus17;
13167 DiagnoseFunctionSpecifiers(DS);
13169 CheckFunctionOrTemplateParamDeclarator(S, D);
13178 ForVisibleRedeclaration);
13180 if (R.isSingleResult()) {
13181 NamedDecl *PrevDecl = R.getFoundDecl();
13186 PrevDecl =
nullptr;
13217 IdResolver.AddDecl(New);
13219 ProcessDeclAttributes(S, New, D);
13227 if (New->
hasAttr<BlocksAttr>()) {
13231 if (getLangOpts().OpenCL)
13232 deduceOpenCLAddressSpace(New);
13255 if (inTemplateInstantiation())
13261 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
13269 if (LangOpts.NumLargeByValueCopy == 0)
13276 if (Size > LangOpts.NumLargeByValueCopy)
13288 if (Size > LangOpts.NumLargeByValueCopy)
13299 if (getLangOpts().ObjCAutoRefCount &&
13313 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
13315 Diag(NameLoc, diag::err_arc_array_param_no_ownership)
13327 TSInfo, SC,
nullptr);
13333 if (
auto *LSI = getEnclosingLambda())
13334 LSI->LocalPacks.push_back(New);
13339 NTCUC_FunctionParam, NTCUK_Destruct|NTCUK_Copy);
13344 if (!CurContext->isRecord() &&
13345 RequireNonAbstractType(NameLoc, T, diag::err_abstract_type_in_decl,
13346 AbstractParamType))
13355 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
13368 !(getLangOpts().OpenCL &&
13370 Diag(NameLoc, diag::err_arg_with_address_space);
13384 for (
int i = FTI.
NumParams; i != 0; ) {
13388 llvm::raw_svector_ostream(Code)
13398 const char* PrevSpec;
13407 FTI.
Params[i].
Param = ActOnParamDeclarator(S, ParamD);
13417 assert(getCurFunctionDecl() ==
nullptr &&
"Function parsing confused");
13422 Decl *DP = HandleDeclarator(ParentScope, D, TemplateParameterLists);
13423 return ActOnStartOfFunctionDef(FnBodyScope, DP, SkipBody);
13427 Consumer.HandleInlineFunctionDefinition(D);
13442 if (isa<CXXMethodDecl>(FD))
13448 if (II->isStr(
"main"))
13464 if (FD->
hasAttr<OpenCLKernelAttr>())
13475 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
13478 PossiblePrototype = Prev;
13506 for (
auto I : FD->
redecls()) {
13519 if (Original->isThisDeclarationADefinition()) {
13533 for (
auto I : FTD->redecls()) {
13534 auto D = cast<FunctionTemplateDecl>(I);
13536 assert(!D->isThisDeclarationADefinition() &&
13537 "More than one definition in redeclaration chain");
13540 D->getInstantiatedFromMemberTemplate()) {
13541 if (FT->isThisDeclarationADefinition()) {
13542 Definition = D->getTemplatedDecl();
13558 if (TypoCorrectedFunctionDefinitions.count(Definition))
13563 if (SkipBody && !hasVisibleDefinition(Definition) &&
13571 makeMergedDefinitionVisible(TD);
13572 makeMergedDefinitionVisible(const_cast<FunctionDecl*>(Definition));
13593 LSI->
Lambda = LambdaClass;
13611 for (
const auto &C : LambdaClass->
captures()) {
13612 if (C.capturesVariable()) {
13613 VarDecl *VD = C.getCapturedVar();
13617 const bool ByRef = C.getCaptureKind() ==
LCK_ByRef;
13619 true, C.getLocation(),
13620 C.isPackExpansion()
13622 CaptureType,
false);
13624 }
else if (C.capturesThis()) {
13640 PushFunctionScope();
13641 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
13648 FD = FunTmpl->getTemplatedDecl();
13650 FD = cast<FunctionDecl>(D);
13655 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
13658 if (
const auto *
Attr = FD->
getAttr<AliasAttr>()) {
13663 if (
const auto *
Attr = FD->
getAttr<IFuncAttr>()) {
13672 CheckForFunctionRedefinition(FD,
nullptr, SkipBody);
13694 assert(inTemplateInstantiation() &&
13695 "There should be an active template instantiation on the stack " 13696 "when instantiating a generic lambda!");
13700 PushFunctionScope();
13717 RequireCompleteType(FD->
getLocation(), ResultType,
13718 diag::err_func_def_incomplete_result))
13722 PushDeclContext(FnBodyScope, FD);
13732 auto *NonParmDecl = dyn_cast<
NamedDecl>(NPD);
13735 assert(!isa<ParmVarDecl>(NonParmDecl) &&
13736 "parameters should not be in newly created FD yet");
13739 if (NonParmDecl->getDeclName())
13740 PushOnScopeChains(NonParmDecl, FnBodyScope,
false);
13744 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
13745 for (
auto *EI : ED->enumerators())
13746 PushOnScopeChains(EI, FnBodyScope,
false);
13753 Param->setOwningFunction(FD);
13756 if (Param->getIdentifier() && FnBodyScope) {
13757 CheckShadow(FnBodyScope, Param);
13759 PushOnScopeChains(Param, FnBodyScope);
13770 assert(!FD->
hasAttr<DLLExportAttr>());
13771 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
13777 ActOnDocumentableDecl(D);
13778 if (getCurLexicalContext()->isObjCContainer() &&
13779 getCurLexicalContext()->getDeclKind() != Decl::ObjCCategoryImpl &&
13780 getCurLexicalContext()->getDeclKind() != Decl::ObjCImplementation)
13801 for (
unsigned I = 0, E = Scope->
Returns.size(); I != E; ++I) {
13802 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
13803 if (!NRVOCandidate->isNRVOVariable())
13804 Returns[I]->setNRVOCandidate(
nullptr);
13822 Outer.Fun.hasTrailingReturnType()) {
13823 QualType Ty = GetTypeFromParser(Outer.Fun.getTrailingReturnType());
13840 if (FD->isConstexpr())
13845 if (FD->getReturnType()->getContainedDeducedType())
13848 return Consumer.shouldSkipFunctionBody(D);
13855 FD->setHasSkippedBody();
13857 MD->setHasSkippedBody();
13862 return ActOnFinishFunctionBody(D, BodyArg,
false);
13877 bool IsLambda =
false;
13881 llvm::DenseMap<const BlockDecl *, bool> EscapeInfo;
13883 auto IsOrNestedInEscapingBlock = [&](
const BlockDecl *BD) {
13884 if (EscapeInfo.count(BD))
13885 return EscapeInfo[BD];
13897 return EscapeInfo[BD] = R;
13902 for (
const std::pair<SourceLocation, const BlockDecl *> &
P :
13904 if (IsOrNestedInEscapingBlock(P.second))
13905 S.
Diag(P.first, diag::warn_implicitly_retains_self)
13910 bool IsInstantiation) {
13916 if (getLangOpts().Coroutines && getCurFunction()->isCoroutine())
13917 CheckCompletedCoroutineBody(FD, Body);
13940 TypeLoc ResultType = getReturnTypeLoc(FD);
13948 auto *LSI = getCurLambda();
13949 if (LSI->HasImplicitReturnType) {
13950 deduceClosureReturnType(*LSI);
13956 LSI->ReturnType.isNull() ? Context.
VoidTy : LSI->ReturnType;
13961 Proto->getExtProtoInfo()));
13979 DiagnoseSizeOfParametersAndReturnValue(FD->
parameters(),
13984 MarkVTableUsed(FD->
getLocation(), Constructor->getParent());
13986 MarkVTableUsed(FD->
getLocation(), Destructor->getParent());
13993 computeNRVO(Body, getCurFunction());
14005 if (PossiblePrototype) {
14009 TypeLoc TL = TI->getTypeLoc();
14012 diag::note_declaration_not_a_prototype)
14035 !LangOpts.CPlusPlus) {
14045 if (
const auto *CmpndBody = dyn_cast<CompoundStmt>(Body))
14046 if (!CmpndBody->body_empty())
14047 Diag(CmpndBody->body_front()->getBeginLoc(),
14048 diag::warn_dispatch_body_ignored);
14050 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
14052 if (MD->isOutOfLine() && (MD = MD->getCanonicalDecl()) &&
14065 if (KeyFunction && KeyFunction->
isDefined(Definition))
14066 MarkVTableUsed(Definition->
getLocation(), MD->getParent(),
true);
14069 MarkVTableUsed(FD->
getLocation(), MD->getParent(),
true);
14074 assert((FD == getCurFunctionDecl() || getCurLambda()->CallOperator == FD) &&
14075 "Function parsing confused");
14076 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
14077 assert(MD == getCurMethodDecl() &&
"Method parsing confused");
14079 if (!MD->isInvalidDecl()) {
14080 DiagnoseSizeOfParametersAndReturnValue(MD->parameters(),
14081 MD->getReturnType(), MD);
14084 computeNRVO(Body, getCurFunction());
14086 if (getCurFunction()->ObjCShouldCallSuper) {
14087 Diag(MD->getEndLoc(), diag::warn_objc_missing_super_call)
14088 << MD->getSelector().getAsString();
14089 getCurFunction()->ObjCShouldCallSuper =
false;
14091 if (getCurFunction()->ObjCWarnForNoDesignatedInitChain) {
14093 bool isDesignated =
14095 assert(isDesignated && InitMethod);
14096 (void)isDesignated;
14099 auto IFace = MD->getClassInterface();
14102 auto SuperD = IFace->getSuperClass();
14105 return SuperD->getIdentifier() ==
14110 if (!MD->isUnavailable() && !superIsNSObject(MD)) {
14111 Diag(MD->getLocation(),
14112 diag::warn_objc_designated_init_missing_super_call);
14114 diag::note_objc_designated_init_marked_here);
14116 getCurFunction()->ObjCWarnForNoDesignatedInitChain =
false;
14118 if (getCurFunction()->ObjCWarnForNoInitDelegation) {
14120 if (!MD->isUnavailable())
14121 Diag(MD->getLocation(),
14122 diag::warn_objc_secondary_init_missing_init_call);
14123 getCurFunction()->ObjCWarnForNoInitDelegation =
false;
14130 PopFunctionScopeInfo(ActivePolicy, dcl);
14134 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
14135 DiagnoseUnguardedAvailabilityViolations(dcl);
14137 assert(!getCurFunction()->ObjCShouldCallSuper &&
14138 "This should only be set for ObjC methods, which should have been " 14139 "handled in the block above.");
14146 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
14147 DiagnoseReturnInConstructorExceptionHandler(cast<CXXTryStmt>(Body));
14150 if (getCurFunction()->NeedsScopeChecking() &&
14151 !PP.isCodeCompletionEnabled())
14152 DiagnoseInvalidJumps(Body);
14155 if (!Destructor->getParent()->isDependentType())
14156 CheckDestructor(Destructor);
14158 MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(),
14159 Destructor->getParent());
14165 if (getDiagnostics().hasErrorOccurred() ||
14166 getDiagnostics().getSuppressAllDiagnostics()) {
14167 DiscardCleanupsInEvaluationContext();
14169 if (!getDiagnostics().hasUncompilableErrorOccurred() &&
14170 !isa<FunctionTemplateDecl>(dcl)) {
14173 ActivePolicy = &WP;
14177 !CheckConstexprFunctionDefinition(FD, CheckConstexprKind::Diagnose))
14180 if (FD && FD->
hasAttr<NakedAttr>()) {
14184 bool RegisterVariables =
false;
14185 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
14186 for (
const auto *
Decl : DS->decls()) {
14187 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
14188 RegisterVariables =
14189 Var->hasAttr<AsmLabelAttr>() && !Var->hasInit();
14190 if (!RegisterVariables)
14195 if (RegisterVariables)
14197 if (!isa<AsmStmt>(S) && !isa<NullStmt>(S)) {
14198 Diag(S->getBeginLoc(), diag::err_non_asm_stmt_in_naked_function);
14199 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
14206 assert(ExprCleanupObjects.size() ==
14207 ExprEvalContexts.back().NumCleanupObjects &&
14208 "Leftover temporaries in function");
14209 assert(!Cleanup.exprNeedsCleanups() &&
"Unaccounted cleanups in function");
14210 assert(MaybeODRUseExprs.empty() &&
14211 "Leftover expressions for odr-use checking");
14214 if (!IsInstantiation)
14217 PopFunctionScopeInfo(ActivePolicy, dcl);
14221 if (getDiagnostics().hasErrorOccurred()) {
14222 DiscardCleanupsInEvaluationContext();
14234 D = TD->getTemplatedDecl();
14235 ProcessDeclAttributeList(S, D, Attrs);
14237 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D))
14238 if (Method->isStatic())
14239 checkThisInStaticMemberFunctionAttributes(Method);
14251 Scope *BlockScope = S;
14255 Scope *ContextScope = BlockScope;
14257 ContextScope = ContextScope->
getParent();
14264 NamedDecl *ExternCPrev = findLocallyScopedExternCDecl(&II);
14268 PushOnScopeChains(ExternCPrev, BlockScope,
false);
14273 if (!isa<FunctionDecl>(ExternCPrev) ||
14275 cast<FunctionDecl>(ExternCPrev)->getType(),
14277 Diag(Loc, diag::ext_use_out_of_scope_declaration)
14278 << ExternCPrev << !getLangOpts().C99;
14279 Diag(ExternCPrev->getLocation(), diag::note_previous_declaration);
14280 return ExternCPrev;
14286 if (II.
getName().startswith(
"__builtin_"))
14287 diag_id = diag::warn_builtin_unknown;
14289 else if (getLangOpts().OpenCL)
14290 diag_id = diag::err_opencl_implicit_function_decl;
14291 else if (getLangOpts().C99)
14292 diag_id = diag::ext_implicit_function_decl;
14294 diag_id = diag::warn_implicit_function_decl;
14295 Diag(Loc, diag_id) << &II;
14301 return ExternCPrev;
14308 if (S && (Corrected =
14310 S,
nullptr, CCC, CTK_NonError)))
14311 diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion),
14323 assert(!Error &&
"Error setting up implicit decl!");
14348 FunctionDecl *FD = cast<FunctionDecl>(ActOnDeclarator(BlockScope, D));
14351 AddKnownFunctionAttributes(FD);
14373 unsigned FormatIdx;
14376 if (!FD->
hasAttr<FormatAttr>()) {
14377 const char *fmt =
"printf";
14379 if (FormatIdx < NumParams &&
14382 FD->
addAttr(FormatAttr::CreateImplicit(Context,
14385 HasVAListArg ? 0 : FormatIdx+2,
14391 if (!FD->
hasAttr<FormatAttr>())
14392 FD->
addAttr(FormatAttr::CreateImplicit(Context,
14395 HasVAListArg ? 0 : FormatIdx+2,
14401 if (!FD->
hasAttr<CallbackAttr>() &&
14403 FD->
addAttr(CallbackAttr::CreateImplicit(
14404 Context, Encoding.data(), Encoding.size(), FD->
getLocation()));
14409 if (!getLangOpts().MathErrno && !FD->
hasAttr<ConstAttr>() &&
14417 if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
14419 switch (BuiltinID) {
14420 case Builtin::BI__builtin_fma:
14421 case Builtin::BI__builtin_fmaf:
14422 case Builtin::BI__builtin_fmal:
14423 case Builtin::BIfma:
14424 case Builtin::BIfmaf:
14425 case Builtin::BIfmal:
14434 !FD->
hasAttr<ReturnsTwiceAttr>())
14435 FD->
addAttr(ReturnsTwiceAttr::CreateImplicit(Context,
14444 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
14448 if (getLangOpts().CUDAIsDevice !=
14459 if (getLangOpts().CXXExceptions && getLangOpts().ExternCNoUnwind &&
14462 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
14479 if (Name->
isStr(
"asprintf") || Name->
isStr(
"vasprintf")) {
14482 if (!FD->
hasAttr<FormatAttr>())
14483 FD->
addAttr(FormatAttr::CreateImplicit(Context,
14485 Name->
isStr(
"vasprintf") ? 0 : 3,
14489 if (Name->
isStr(
"__CFStringMakeConstantString")) {
14492 if (!FD->
hasAttr<FormatArgAttr>())
14500 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
14501 assert(!T.
isNull() &&
"GetTypeForDeclarator() returned null type");
14504 assert(D.
isInvalidType() &&
"no declarator info for valid type");
14520 if (CurContext->isFunctionOrMethod())
14542 setTagNameForLinkagePurposes(tagFromDeclSpec, NewTD);
14562 if (BT->isInteger())
14565 Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T;
14572 QualType EnumUnderlyingTy,
bool IsFixed,
14574 if (IsScoped != Prev->
isScoped()) {
14575 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
14581 if (IsFixed && Prev->
isFixed()) {
14587 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
14593 }
else if (IsFixed != Prev->
isFixed()) {
14594 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
14613 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
14628 if (isa<TypedefDecl>(PrevDecl))
14629 return NTK_Typedef;
14630 else if (isa<TypeAliasDecl>(PrevDecl))
14631 return NTK_TypeAlias;
14632 else if (isa<ClassTemplateDecl>(PrevDecl))
14633 return NTK_Template;
14634 else if (isa<TypeAliasTemplateDecl>(PrevDecl))
14635 return NTK_TypeAliasTemplate;
14636 else if (isa<TemplateTemplateParmDecl>(PrevDecl))
14637 return NTK_TemplateTemplateArgument;
14642 return getLangOpts().CPlusPlus ? NTK_NonClass : NTK_NonStruct;
14644 return NTK_NonUnion;
14646 return NTK_NonEnum;
14648 llvm_unreachable(
"invalid TTK");
14673 if (OldTag != NewTag &&
14688 return getDiagnostics().isIgnored(diag::warn_struct_class_tag_mismatch,
14691 if (IsIgnoredLoc(NewTagLoc))
14694 auto IsIgnored = [&](
const TagDecl *Tag) {
14695 return IsIgnoredLoc(Tag->getLocation());
14697 while (IsIgnored(Previous)) {
14705 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Previous))
14706 isTemplate = Record->getDescribedClassTemplate();
14708 if (inTemplateInstantiation()) {
14709 if (OldTag != NewTag) {
14712 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
14720 if (isDefinition) {
14728 bool previousMismatch =
false;
14730 if (I->getTagKind() != NewTag) {
14735 if (!previousMismatch) {
14736 previousMismatch =
true;
14737 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
14741 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
14754 if (PrevDef && IsIgnored(PrevDef))
14758 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
14765 Diag(NewTagLoc, diag::note_struct_class_suggestion)
14798 Namespaces.push_back(II);
14801 if (Lookup == Namespace)
14808 llvm::raw_svector_ostream OS(Insertion);
14811 std::reverse(Namespaces.begin(), Namespaces.end());
14812 for (
auto *II : Namespaces)
14813 OS << II->getName() <<
"::";
14826 if (OldDC->
Equals(NewDC))
14854 bool &OwnedDecl,
bool &IsDependent,
14856 bool ScopedEnumUsesClassTag,
TypeResult UnderlyingType,
14857 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
14861 assert((Name !=
nullptr || TUK == TUK_Definition) &&
14862 "Nameless record must be a definition!");
14863 assert(TemplateParameterLists.size() == 0 || TUK != TUK_Reference);
14867 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
14870 bool isMemberSpecialization =
false;
14871 bool Invalid =
false;
14876 if (TemplateParameterLists.size() > 0 ||
14877 (SS.
isNotEmpty() && TUK != TUK_Reference)) {
14879 MatchTemplateParametersToScopeSpecifier(
14880 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
14881 TUK == TUK_Friend, isMemberSpecialization, Invalid)) {
14883 Diag(KWLoc, diag::err_enum_template);
14887 if (TemplateParams->size() > 0) {
14896 S, TagSpec, TUK, KWLoc, SS, Name, NameLoc, Attrs, TemplateParams,
14897 AS, ModulePrivateLoc,
14899 TemplateParameterLists.data(), SkipBody);
14900 return Result.
get();
14903 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
14905 isMemberSpecialization =
true;
14913 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
14914 bool IsFixed = !UnderlyingType.
isUnset() || ScopedEnum;
14917 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum)) {
14921 }
else if (UnderlyingType.
get()) {
14925 GetTypeFromParser(UnderlyingType.
get(), &TI);
14926 EnumUnderlying = TI;
14928 if (CheckEnumUnderlyingType(TI))
14933 UPPC_FixedUnderlyingType))
14941 if (TUK == TUK_Definition || getLangOpts().MSVCCompat)
14948 bool isStdBadAlloc =
false;
14949 bool isStdAlignValT =
false;
14952 if (TUK == TUK_Friend || TUK == TUK_Reference)
14953 Redecl = NotForRedeclaration;
14958 auto createTagFromNewDecl = [&]() ->
TagDecl * {
14959 assert(!getLangOpts().
CPlusPlus &&
"not meant for C++ usage");
14968 ScopedEnum, ScopedEnumUsesClassTag, IsFixed);
14970 if (TUK != TUK_Definition && !Invalid)
14972 if (EnumUnderlying) {
14973 EnumDecl *ED = cast<EnumDecl>(New);
14985 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
14995 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip)) {
14996 AddAlignmentAttributesForRecord(RD);
14997 AddMsStructLayoutForRecord(RD);
15011 goto CreateNewDecl;
15016 if (TUK == TUK_Friend || TUK == TUK_Reference) {
15017 DC = computeDeclContext(SS,
false);
15019 IsDependent =
true;
15023 DC = computeDeclContext(SS,
true);
15031 if (RequireCompleteDeclContext(SS, DC))
15036 LookupQualifiedName(Previous, DC);
15041 if (Previous.
empty()) {
15049 (TUK == TUK_Reference || TUK == TUK_Friend)) {
15050 IsDependent =
true;
15055 Diag(NameLoc, diag::err_not_tag_in_scope)
15056 << Kind << Name << DC << SS.
getRange();
15059 goto CreateNewDecl;
15066 if (TUK != TUK_Reference && TUK != TUK_Friend &&
15075 LookupName(Previous, S);
15080 (TUK == TUK_Definition || TUK == TUK_Declaration)) {
15104 if (!Previous.
empty() && TUK == TUK_Friend) {
15107 bool FriendSawTagOutsideEnclosingNamespace =
false;
15113 if (getLangOpts().MSVCCompat)
15114 FriendSawTagOutsideEnclosingNamespace =
true;
15123 if (Previous.
isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
15125 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
15134 if (!getLangOpts().CPlusPlus && TUK != TUK_Reference) {
15139 while (isa<RecordDecl>(SearchDC) || isa<EnumDecl>(SearchDC))
15147 DiagnoseTemplateParameterShadow(NameLoc, Previous.
getFoundDecl());
15152 if (getLangOpts().
CPlusPlus && Name && DC && StdNamespace &&
15153 DC->
Equals(getStdNamespace())) {
15154 if (Name->
isStr(
"bad_alloc")) {
15156 isStdBadAlloc =
true;
15161 if (Previous.
empty() && StdBadAlloc)
15162 Previous.
addDecl(getStdBadAlloc());
15163 }
else if (Name->
isStr(
"align_val_t")) {
15164 isStdAlignValT =
true;
15165 if (Previous.
empty() && StdAlignValT)
15166 Previous.
addDecl(getStdAlignValT());
15174 if (Name && Previous.
empty() &&
15175 (TUK == TUK_Reference || TUK == TUK_Friend || IsTemplateParamOrArg)) {
15176 if (Invalid)
goto CreateNewDecl;
15179 if (TUK == TUK_Reference || IsTemplateParamOrArg) {
15213 assert(TUK == TUK_Friend);
15229 LookupQualifiedName(Previous, SearchDC);
15232 LookupName(Previous, S);
15240 if (!Previous.
empty()) {
15256 TagDecl *Tag = TT->getDecl();
15259 ->
Equals(TD->getDeclContext()->getRedeclContext())) {
15272 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
15273 auto *OldTag = dyn_cast<
TagDecl>(PrevDecl);
15274 if (SS.
isEmpty() && TUK != TUK_Reference && TUK != TUK_Friend &&
15275 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
15277 *
this, OldTag->getDeclContext(), SearchDC))) {
15278 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
15279 Diag(Shadow->getTargetDecl()->getLocation(),
15280 diag::note_using_decl_target);
15281 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl)
15285 goto CreateNewDecl;
15289 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
15293 if (TUK == TUK_Reference || TUK == TUK_Friend ||
15294 isDeclInScope(DirectPrevDecl, SearchDC, S,
15295 SS.
isNotEmpty() || isMemberSpecialization)) {
15298 if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind,
15299 TUK == TUK_Definition, KWLoc,
15301 bool SafeToContinue
15302 = (PrevTagDecl->getTagKind() !=
TTK_Enum &&
15304 if (SafeToContinue)
15305 Diag(KWLoc, diag::err_use_with_wrong_tag)
15308 PrevTagDecl->getKindName());
15310 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
15311 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
15313 if (SafeToContinue)
15314 Kind = PrevTagDecl->getTagKind();
15324 const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
15328 if (TUK == TUK_Reference || TUK == TUK_Friend) {
15330 Diag(ScopedEnumKWLoc, diag::err_enum_class_reference)
15333 return PrevTagDecl;
15338 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
15339 else if (
const Type *T = EnumUnderlying.dyn_cast<
const Type*>())
15340 EnumUnderlyingTy =
QualType(T, 0);
15345 if (CheckEnumRedeclaration(NameLoc.
isValid() ? NameLoc : KWLoc,
15346 ScopedEnum, EnumUnderlyingTy,
15347 IsFixed, PrevEnum))
15348 return TUK == TUK_Declaration ? PrevTagDecl :
nullptr;
15357 Diag(NameLoc, diag::ext_member_redeclared);
15358 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
15364 if (TUK == TUK_Reference || TUK == TUK_Friend) {
15365 if (!Attrs.
empty()) {
15368 }
else if (TUK == TUK_Reference &&
15369 (PrevTagDecl->getFriendObjectKind() ==
15382 return PrevTagDecl;
15387 return PrevTagDecl;
15392 if (TUK == TUK_Definition) {
15393 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
15397 bool IsExplicitSpecializationAfterInstantiation =
false;
15398 if (isMemberSpecialization) {
15400 IsExplicitSpecializationAfterInstantiation =
15401 RD->getTemplateSpecializationKind() !=
15403 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
15404 IsExplicitSpecializationAfterInstantiation =
15405 ED->getTemplateSpecializationKind() !=
15414 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
15425 SkipBody->
New = createTagFromNewDecl();
15431 makeMergedDefinitionVisible(Hidden);
15435 }
else if (!IsExplicitSpecializationAfterInstantiation) {
15439 Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name;
15441 Diag(NameLoc, diag::err_redefinition) << Name;
15442 notePreviousDefinition(Def,
15443 NameLoc.
isValid() ? NameLoc : KWLoc);
15455 if (TD->isBeingDefined()) {
15456 Diag(NameLoc, diag::err_nested_redefinition) << Name;
15457 Diag(PrevTagDecl->getLocation(),
15458 diag::note_previous_definition);
15472 if (TUK == TUK_Friend || TUK == TUK_Reference) {
15473 SearchDC = PrevTagDecl->getDeclContext();
15498 if ((TUK == TUK_Reference || TUK == TUK_Friend) &&
15500 NonTagKind NTK = getNonTagTypeDeclKind(PrevDecl, Kind);
15501 Diag(NameLoc, diag::err_tag_reference_non_tag) << PrevDecl << NTK
15507 }
else if (!isDeclInScope(DirectPrevDecl, SearchDC, S,
15508 SS.
isNotEmpty() || isMemberSpecialization)) {
15512 }
else if (TUK == TUK_Reference || TUK == TUK_Friend) {
15513 NonTagKind NTK = getNonTagTypeDeclKind(PrevDecl, Kind);
15514 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
15520 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
15522 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
15523 Diag(NameLoc, diag::err_tag_definition_of_typedef)
15524 << Name << Kind << TND->getUnderlyingType();
15532 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
15533 notePreviousDefinition(PrevDecl, NameLoc);
15564 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
15565 ScopedEnumUsesClassTag, IsFixed);
15567 if (isStdAlignValT && (!StdAlignValT || getStdAlignValT()->isImplicit()))
15568 StdAlignValT = cast<EnumDecl>(New);
15571 if (TUK != TUK_Definition && !Invalid) {
15573 if (IsFixed && cast<EnumDecl>(New)->isFixed()) {
15577 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
15578 Diag(Loc, diag::ext_forward_ref_enum_def)
15582 unsigned DiagID = diag::ext_forward_ref_enum;
15583 if (getLangOpts().MSVCCompat)
15584 DiagID = diag::ext_ms_forward_ref_enum;
15585 else if (getLangOpts().CPlusPlus)
15586 DiagID = diag::err_forward_ref_enum;
15591 if (EnumUnderlying) {
15592 EnumDecl *ED = cast<EnumDecl>(New);
15598 assert(ED->
isComplete() &&
"enum with type should be complete");
15605 if (getLangOpts().CPlusPlus) {
15608 cast_or_null<CXXRecordDecl>(PrevDecl));
15610 if (isStdBadAlloc && (!StdBadAlloc || getStdBadAlloc()->isImplicit()))
15611 StdBadAlloc = cast<CXXRecordDecl>(New);
15614 cast_or_null<RecordDecl>(PrevDecl));
15619 if (getLangOpts().
CPlusPlus && (IsTypeSpecifier || IsTemplateParamOrArg) &&
15620 TUK == TUK_Definition) {
15626 if (!Invalid && getLangOpts().
CPlusPlus && TUK == TUK_Definition &&
15638 if ((TUK == TUK_Definition || TUK == TUK_Declaration) &&
15639 diagnoseQualifiedDeclaration(SS, DC, OrigName, Loc,
15640 isMemberSpecialization))
15644 if (TemplateParameterLists.size() > 0) {
15652 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
15662 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip)) {
15663 AddAlignmentAttributesForRecord(RD);
15664 AddMsStructLayoutForRecord(RD);
15668 if (ModulePrivateLoc.
isValid()) {
15669 if (isMemberSpecialization)
15682 if (isMemberSpecialization && CheckMemberSpecialization(New, Previous))
15689 getNonFieldDeclScope(S)->isFunctionPrototypeScope()) {
15693 if (TUK == TUK_Definition && !IsTypeSpecifier) {
15694 Diag(Loc, diag::err_type_defined_in_param_type)
15698 }
else if (!PrevDecl) {
15714 if (TUK == TUK_Friend)
15718 if (!Invalid && SearchDC->
isRecord())
15719 SetMemberAccessSpecifier(New, PrevDecl, AS);
15722 CheckRedeclarationModuleOwnership(New, PrevDecl);
15724 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip))
15727 ProcessDeclAttributeList(S, New, Attrs);
15728 AddPragmaAttributes(S, New);
15731 if (TUK == TUK_Friend) {
15740 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
15741 PushOnScopeChains(New, EnclosingScope,
false);
15743 S = getNonFieldDeclScope(S);
15744 PushOnScopeChains(New, S,
true);
15746 CurContext->addDecl(New);
15757 mergeDeclAttributes(New, PrevDecl);
15759 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(New))
15760 inferGslOwnerPointerAttribute(CXXRD);
15764 AddPushedVisibilityAttribute(New);
15767 CompleteMemberSpecialization(New, Previous);
15772 if (Invalid && getLangOpts().CPlusPlus) {
15774 if (
auto RD = dyn_cast<RecordDecl>(New))
15775 RD->completeDefinition();
15777 }
else if (SkipBody && SkipBody->
ShouldSkip) {
15785 AdjustDeclIfTemplate(TagD);
15786 TagDecl *Tag = cast<TagDecl>(TagD);
15789 PushDeclContext(S, Tag);
15791 ActOnDocumentableDecl(TagD);
15795 AddPushedVisibilityAttribute(Tag);
15800 if (!hasStructuralCompatLayout(Prev, SkipBody.
New))
15804 makeMergedDefinitionVisible(SkipBody.
Previous);
15809 assert(isa<ObjCContainerDecl>(IDecl) &&
15810 "ActOnObjCContainerStartDefinition - Not ObjCContainerDecl");
15812 assert(getContainingDC(OCD) == CurContext &&
15813 "The next DeclContext should be lexically contained in the current one.");
15820 bool IsFinalSpelledSealed,
15822 AdjustDeclIfTemplate(TagD);
15825 FieldCollector->StartClass();
15833 static_cast<FinalAttr::Spelling>(IsFinalSpelledSealed)));
15850 PushOnScopeChains(InjectedClassName, S);
15852 "Broken injected-class-name");
15857 AdjustDeclIfTemplate(TagD);
15858 TagDecl *Tag = cast<TagDecl>(TagD);
15863 assert(Tag->
isInvalidDecl() &&
"We should already have completed it");
15864 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
15865 RD->completeDefinition();
15868 if (isa<CXXRecordDecl>(Tag)) {
15869 FieldCollector->FinishClass();
15875 if (getCurLexicalContext()->isObjCContainer() &&
15881 Consumer.HandleTagDeclDefinition(Tag);
15890 assert(DC == CurContext &&
"Mismatch of container contexts");
15891 OriginalLexicalContext = DC;
15892 ActOnObjCContainerFinishDefinition();
15896 ActOnObjCContainerStartDefinition(cast<Decl>(DC));
15897 OriginalLexicalContext =
nullptr;
15901 AdjustDeclIfTemplate(TagD);
15902 TagDecl *Tag = cast<TagDecl>(TagD);
15907 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
15908 RD->completeDefinition();
15921 QualType FieldTy,
bool IsMsStruct,
15922 Expr *BitWidth,
bool *ZeroWidth) {
15931 if (RequireCompleteType(FieldLoc, FieldTy, diag::err_field_incomplete))
15934 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
15936 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
15938 }
else if (DiagnoseUnexpandedParameterPack(const_cast<Expr *>(BitWidth),
15939 UPPC_BitFieldWidth))
15948 ExprResult ICE = VerifyIntegerConstantExpression(BitWidth, &Value);
15951 BitWidth = ICE.
get();
15953 if (Value != 0 && ZeroWidth)
15954 *ZeroWidth =
false;
15957 if (Value == 0 && FieldName)
15958 return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
15960 if (Value.isSigned() && Value.isNegative()) {
15962 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
15963 << FieldName << Value.toString(10);
15964 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
15965 << Value.toString(10);
15969 uint64_t TypeStorageSize = Context.
getTypeSize(FieldTy);
15970 uint64_t TypeWidth = Context.
getIntWidth(FieldTy);
15971 bool BitfieldIsOverwide = Value.ugt(TypeWidth);
15975 bool CStdConstraintViolation =
15976 BitfieldIsOverwide && !getLangOpts().CPlusPlus;
15977 bool MSBitfieldViolation =
15978 Value.ugt(TypeStorageSize) &&
15980 if (CStdConstraintViolation || MSBitfieldViolation) {
15981 unsigned DiagWidth =
15982 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
15984 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
15985 << FieldName << (unsigned)Value.getZExtValue()
15986 << !CStdConstraintViolation << DiagWidth;
15988 return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width)
15989 << (unsigned)Value.getZExtValue() << !CStdConstraintViolation
15998 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
15999 << FieldName << (unsigned)Value.getZExtValue()
16000 << (unsigned)TypeWidth;
16002 Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_width)
16003 << (unsigned)Value.getZExtValue() << (unsigned)TypeWidth;
16014 FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD),
16015 DeclStart, D, static_cast<Expr*>(BitfieldWidth),
16041 CheckExtraCXXDefaultArguments(D);
16044 UPPC_DataMemberType)) {
16055 << getLangOpts().CPlusPlus17;
16058 diag::err_invalid_thread)
16064 ForVisibleRedeclaration);
16065 LookupName(Previous, S);
16087 PrevDecl =
nullptr;
16090 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
16091 PrevDecl =
nullptr;
16097 = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
16098 TSSL, AS, PrevDecl, &D);
16110 PushOnScopeChains(NewFD, S);
16130 bool Mutable,
Expr *BitWidth,
16136 bool InvalidDecl =
false;
16142 InvalidDecl =
true;
16148 if (RequireCompleteType(Loc, EltTy, diag::err_field_incomplete)) {
16151 InvalidDecl =
true;
16157 InvalidDecl =
true;
16165 Diag(Loc, diag::err_field_with_address_space);
16167 InvalidDecl =
true;
16170 if (LangOpts.OpenCL) {
16175 Diag(Loc, diag::err_opencl_type_struct_or_union_field) << T;
16177 InvalidDecl =
true;
16181 Diag(Loc, diag::err_opencl_bitfields);
16182 InvalidDecl =
true;
16187 if (!InvalidDecl && getLangOpts().
CPlusPlus && !II && BitWidth &&
16189 InvalidDecl =
true;
16190 Diag(Loc, diag::err_anon_bitfield_qualifiers);
16196 bool SizeIsNegative;
16204 Diag(Loc, diag::warn_illegal_constant_array_size);
16205 TInfo = FixedTInfo;
16208 if (SizeIsNegative)
16209 Diag(Loc, diag::err_typecheck_negative_array_size);
16210 else if (Oversized.getBoolValue())
16211 Diag(Loc, diag::err_array_too_large)
16212 << Oversized.toString(10);
16214 Diag(Loc, diag::err_typecheck_field_variable_size);
16215 InvalidDecl =
true;
16220 if (!InvalidDecl && RequireNonAbstractType(Loc, T,
16221 diag::err_abstract_type_in_decl,
16222 AbstractFieldType))
16223 InvalidDecl =
true;
16225 bool ZeroWidth =
false;
16227 BitWidth =
nullptr;
16230 BitWidth = VerifyBitField(Loc, II, T, Record->
isMsStruct(Context), BitWidth,
16233 InvalidDecl =
true;
16234 BitWidth =
nullptr;
16240 if (!InvalidDecl && Mutable) {
16241 unsigned DiagID = 0;
16243 DiagID = getLangOpts().MSVCCompat ? diag::ext_mutable_reference
16244 : diag::err_mutable_reference;
16246 DiagID = diag::err_mutable_const;
16252 Diag(ErrLoc, DiagID);
16253 if (DiagID != diag::ext_mutable_reference) {
16255 InvalidDecl =
true;
16267 BitWidth, Mutable, InitStyle);
16271 if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
16272 Diag(Loc, diag::err_duplicate_member) << II;
16277 if (!InvalidDecl && getLangOpts().
CPlusPlus) {
16287 if (CheckNontrivialField(NewFD))
16297 diag::ext_union_member_of_reference_type :
16298 diag::err_union_member_of_reference_type)
16300 if (!getLangOpts().MicrosoftExt)
16310 ProcessDeclAttributes(getCurScope(), NewFD, *D);
16313 CheckAlignasUnderalignment(NewFD);
16318 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewFD))
16322 Diag(Loc, diag::warn_attribute_weak_on_field);
16330 assert(getLangOpts().
CPlusPlus &&
"valid check only for C++");
16350 member = CXXCopyConstructor;
16352 member = CXXDefaultConstructor;
16354 member = CXXCopyAssignment;
16356 member = CXXDestructor;
16358 if (member != CXXInvalid) {
16359 if (!getLangOpts().CPlusPlus11 &&
16367 if (getSourceManager().isInSystemHeader(Loc)) {
16368 if (!FD->
hasAttr<UnavailableAttr>())
16369 FD->
addAttr(UnavailableAttr::CreateImplicit(Context,
"",
16370 UnavailableAttr::IR_ARCFieldWithOwnership, Loc));
16376 diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member :
16377 diag::err_illegal_union_or_anon_struct_member)
16379 DiagnoseNontrivial(RDecl, member);
16380 return !getLangOpts().CPlusPlus11;
16392 switch (ivarVisibility) {
16393 default: llvm_unreachable(
"Unknown visitibility kind");
16409 Expr *BitWidth = (
Expr*)BitfieldWidth;
16421 BitWidth = VerifyBitField(Loc, II, T,
false, BitWidth).get();
16431 Diag(Loc, diag::err_ivar_reference_type);
16437 Diag(Loc, diag::err_typecheck_ivar_variable_size);
16451 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
16452 if (LangOpts.ObjCRuntime.isFragile()) {
16454 EnclosingContext = IMPDecl->getClassInterface();
16455 assert(EnclosingContext &&
"Implementation has no class interface!");
16458 EnclosingContext = EnclosingDecl;
16461 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
16462 if (LangOpts.ObjCRuntime.isFragile() || !CDecl->IsClassExtension()) {
16463 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
16467 EnclosingContext = EnclosingDecl;
16472 DeclStart, Loc, II, T,
16473 TInfo, ac, (
Expr *)BitfieldWidth);
16476 NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
16477 ForVisibleRedeclaration);
16478 if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S)
16479 && !isa<TagDecl>(PrevDecl)) {
16480 Diag(Loc, diag::err_duplicate_member) << II;
16487 ProcessDeclAttributes(S, NewID, D);
16493 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewID))
16503 IdResolver.AddDecl(NewID);
16506 if (LangOpts.ObjCRuntime.isNonFragile() &&
16507 !NewID->
isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
16508 Diag(Loc, diag::warn_ivars_in_interface);
16519 if (LangOpts.ObjCRuntime.isFragile() || AllIvarDecls.empty())
16522 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
16530 if (!CD->IsClassExtension())
16542 DeclLoc, DeclLoc,
nullptr,
16548 AllIvarDecls.push_back(Ivar);
16555 assert(EnclosingDecl &&
"missing record or interface decl");
16560 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
16564 case Decl::ObjCCategory:
16565 Context.
ResetObjCLayout(cast<ObjCCategoryDecl>(DC)->getClassInterface());
16567 case Decl::ObjCImplementation:
16569 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
16579 unsigned NumNamedMembers = 0;
16581 for (
const auto *I : Record->
decls()) {
16582 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
16583 if (IFD->getDeclName())
16600 RecFields.push_back(FD);
16620 bool IsLastField = (i + 1 == Fields.end());
16629 (Record || isa<ObjCContainerDecl>(EnclosingDecl))) {
16635 unsigned DiagID = 0;
16636 if (!Record->
isUnion() && !IsLastField) {
16639 Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
16643 }
else if (Record->
isUnion())
16644 DiagID = getLangOpts().MicrosoftExt
16645 ? diag::ext_flexible_array_union_ms
16646 : getLangOpts().CPlusPlus
16647 ? diag::ext_flexible_array_union_gnu
16648 : diag::err_flexible_array_union;
16649 else if (NumNamedMembers < 1)
16650 DiagID = getLangOpts().MicrosoftExt
16651 ? diag::ext_flexible_array_empty_aggregate_ms
16652 : getLangOpts().CPlusPlus
16653 ? diag::ext_flexible_array_empty_aggregate_gnu
16654 : diag::err_flexible_array_empty_aggregate;
16664 if (CXXRecord && CXXRecord->getNumVBases() != 0)
16667 if (!getLangOpts().
C99)
16678 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
16693 diag::err_field_incomplete)) {
16718 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
16720 diag::err_abstract_type_in_decl,
16721 AbstractIvarType)) {
16735 }
else if (Record && Record->
isUnion() &&
16737 getSourceManager().isInSystemHeader(FD->
getLocation()) &&
16738 !getLangOpts().CPlusPlus && !FD->
hasAttr<UnavailableAttr>() &&
16747 FD->
addAttr(UnavailableAttr::CreateImplicit(
16748 Context,
"", UnavailableAttr::IR_ARCFieldWithOwnership,
16750 }
else if (getLangOpts().ObjC &&
16767 if (Record && !getLangOpts().
CPlusPlus &&
16768 !shouldIgnoreForRecordTriviality(FD)) {
16790 if (RT->getDecl()->getArgPassingRestrictions() ==
16806 bool Completed =
false;
16808 if (!CXXRecord->isInvalidDecl()) {
16811 I = CXXRecord->conversion_begin(),
16812 E = CXXRecord->conversion_end(); I != E; ++I)
16813 I.setAccess((*I)->getAccess());
16816 if (!CXXRecord->isDependentType()) {
16818 AddImplicitlyDeclaredMembersToClass(CXXRecord);
16820 if (!CXXRecord->isInvalidDecl()) {
16824 if (CXXRecord->getNumVBases()) {
16826 CXXRecord->getFinalOverriders(FinalOverriders);
16828 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
16829 MEnd = FinalOverriders.end();
16832 SOEnd = M->second.end();
16833 SO != SOEnd; ++SO) {
16834 assert(SO->second.size() > 0 &&
16835 "Virtual function without overriding functions?");
16836 if (SO->second.size() == 1)
16844 << (
const NamedDecl *)M->first << Record;
16845 Diag(M->first->getLocation(),
16846 diag::note_overridden_virtual_function);
16848 OM = SO->second.begin(),
16849 OMEnd = SO->second.end();
16851 Diag(OM->Method->getLocation(), diag::note_final_overrider)
16852 << (
const NamedDecl *)M->first << OM->Method->getParent();
16857 CXXRecord->completeDefinition(&FinalOverriders);
16868 ProcessDeclAttributeList(S, Record, Attrs);
16872 auto *Dtor = CXXRecord->getDestructor();
16873 if (Dtor && Dtor->isImplicit() &&
16874 ShouldDeleteSpecialMember(Dtor, CXXDestructor)) {
16875 CXXRecord->setImplicitDestructorIsDeleted();
16876 SetDeclDeleted(Dtor, CXXRecord->getLocation());
16881 CheckAlignasUnderalignment(Record);
16883 if (
const MSInheritanceAttr *IA = Record->
getAttr<MSInheritanceAttr>())
16884 checkMSInheritanceAttrOnDefinition(cast<CXXRecordDecl>(Record),
16885 IA->getRange(), IA->getBestCase(),
16886 IA->getInheritanceModel());
16892 bool CheckForZeroSize;
16893 if (!getLangOpts().CPlusPlus) {
16894 CheckForZeroSize =
true;
16903 if (CheckForZeroSize) {
16904 bool ZeroSize =
true;
16905 bool IsEmpty =
true;
16906 unsigned NonBitFields = 0;
16909 (NonBitFields == 0 || ZeroSize) && I != E; ++I) {
16911 if (I->isUnnamedBitfield()) {
16912 if (!I->isZeroLengthBitField(Context))
16916 QualType FieldType = I->getType();
16928 diag::warn_zero_size_struct_union_in_extern_c :
16929 diag::warn_zero_size_struct_union_compat)
16930 << IsEmpty << Record->
isUnion() << (NonBitFields > 1);
16935 if (NonBitFields == 0 && !getLangOpts().CPlusPlus) {
16936 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union :
16937 diag::ext_no_named_members_in_struct_union)
16945 ID->setEndOfDefinitionLoc(RBrac);
16947 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
16949 ID->addDecl(ClsFields[i]);
16953 if (
ID->getSuperClass())
16954 DiagnoseDuplicateIvars(
ID,
ID->getSuperClass());
16956 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
16957 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
16958 for (
unsigned I = 0, N = RecFields.size(); I != N; ++I)
16961 ClsFields[I]->setLexicalDeclContext(IMPDecl);
16962 CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
16963 IMPDecl->setIvarLBraceLoc(LBrac);
16964 IMPDecl->setIvarRBraceLoc(RBrac);
16966 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
16974 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
16978 Diag(ClsFields[i]->getLocation(),
16979 diag::err_duplicate_ivar_declaration);
16980 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
16986 Diag(ClsFields[i]->getLocation(),
16987 diag::err_duplicate_ivar_declaration);
16988 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
16994 CDecl->addDecl(ClsFields[i]);
16996 CDecl->setIvarLBraceLoc(LBrac);
16997 CDecl->setIvarRBraceLoc(RBrac);
17008 "Integral type required!");
17011 if (Value.isUnsigned() || Value.isNonNegative()) {
17014 return Value.getActiveBits() <= BitWidth;
17016 return Value.getMinSignedBits() <= BitWidth;
17026 const unsigned NumTypes = 4;
17027 QualType SignedIntegralTypes[NumTypes] = {
17030 QualType UnsignedIntegralTypes[NumTypes] = {
17037 : UnsignedIntegralTypes;
17038 for (
unsigned I = 0; I != NumTypes; ++I)
17054 if (Val && DiagnoseUnexpandedParameterPack(Val, UPPC_EnumeratorValue))
17058 Val = DefaultLvalueConversion(Val).get();
17064 if (getLangOpts().CPlusPlus11 && Enum->
isFixed()) {
17075 Val = Converted.
get();
17077 !(Val = VerifyIntegerConstantExpression(Val,
17078 &EnumVal).get())) {
17091 .isWindowsMSVCEnvironment()) {
17092 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
17094 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
17099 Val = ImpCastExprToType(Val, EltTy,
17118 Diag(IdLoc, diag::ext_enum_value_not_int)
17120 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
17123 Val = ImpCastExprToType(Val, Context.
IntTy, CK_IntegralCast).get();
17132 if (Enum->isDependentType())
17134 else if (!LastEnumConst) {
17143 if (Enum->isFixed()) {
17144 EltTy = Enum->getIntegerType();
17147 EltTy = Context.
IntTy;
17151 EnumVal = LastEnumConst->getInitVal();
17153 EltTy = LastEnumConst->getType();
17156 if (EnumVal < LastEnumConst->getInitVal()) {
17168 if (T.
isNull() || Enum->isFixed()) {
17171 EnumVal = LastEnumConst->getInitVal();
17172 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
17174 if (Enum->isFixed())
17176 Diag(IdLoc, diag::err_enumerator_wrapped)
17177 << EnumVal.toString(10)
17180 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
17181 << EnumVal.toString(10);
17189 EnumVal = LastEnumConst->getInitVal();
17190 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
17191 EnumVal = EnumVal.zextOrTrunc(Context.
getIntWidth(EltTy));
17199 if (!getLangOpts().CPlusPlus && !T.
isNull())
17200 Diag(IdLoc, diag::warn_enum_value_overflow);
17201 }
else if (!getLangOpts().CPlusPlus &&
17204 Diag(IdLoc, diag::ext_enum_value_not_int)
17205 << EnumVal.toString(10) << 1;
17210 if (!EltTy->isDependentType()) {
17213 EnumVal = EnumVal.extOrTrunc(Context.
getIntWidth(EltTy));
17214 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
17223 if (!(getLangOpts().Modules || getLangOpts().ModulesLocalVisibility) ||
17230 NamedDecl *PrevDecl = LookupSingleName(S, II, IILoc, LookupOrdinaryName,
17231 forRedeclarationInCurContext());
17232 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
17236 EnumDecl *PrevED = cast<EnumDecl>(PrevECD->getDeclContext());
17238 if (!PrevED->
getDeclName() && !hasVisibleDefinition(PrevED, &Hidden)) {
17251 EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl);
17253 cast_or_null<EnumConstantDecl>(lastEnumConst);
17257 S = getNonFieldDeclScope(S);
17261 LookupResult R(*
this, Id, IdLoc, LookupOrdinaryName, ForVisibleRedeclaration);
17267 DiagnoseTemplateParameterShadow(IdLoc, PrevDecl);
17269 PrevDecl =
nullptr;
17282 CheckEnumConstant(TheEnumDecl, LastEnumConst, IdLoc, Id, Val);
17287 if (!TheEnumDecl->
isScoped() && isa<ValueDecl>(PrevDecl)) {
17289 CheckShadow(New, PrevDecl, R);
17294 assert((getLangOpts().
CPlusPlus || !isa<TagDecl>(PrevDecl)) &&
17295 "Received TagDecl when not in C++!");
17296 if (!isa<TagDecl>(PrevDecl) && isDeclInScope(PrevDecl, CurContext, S)) {
17297 if (isa<EnumConstantDecl>(PrevDecl))
17298 Diag(IdLoc, diag::err_redefinition_of_enumerator) <<
Id;
17300 Diag(IdLoc, diag::err_redefinition) <<
Id;
17301 notePreviousDefinition(PrevDecl, IdLoc);
17307 ProcessDeclAttributeList(S, New, Attrs);
17308 AddPragmaAttributes(S, New);
17312 PushOnScopeChains(New, S);
17314 ActOnDocumentableDecl(New);
17332 if (!BO->isAdditiveOp())
17340 InitExpr = BO->getLHS();
17377 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
17378 typedef std::unordered_map<int64_t, DeclOrVector> ValueToVectorMap;
17383 return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
17386 DuplicatesVector DupVector;
17387 ValueToVectorMap EnumMap;
17391 for (
auto *Element : Elements) {
17405 EnumMap.insert({EnumConstantToKey(ECD), ECD});
17408 if (EnumMap.size() == 0)
17412 for (
auto *Element : Elements) {
17418 auto Iter = EnumMap.find(EnumConstantToKey(ECD));
17419 if (Iter == EnumMap.end())
17422 DeclOrVector& Entry = Iter->second;
17429 auto Vec = std::make_unique<ECDVector>();
17431 Vec->push_back(ECD);
17438 DupVector.emplace_back(std::move(Vec));
17442 ECDVector *Vec = Entry.get<ECDVector*>();
17444 if (*Vec->begin() == ECD)
17447 Vec->push_back(ECD);
17451 for (
const auto &Vec : DupVector) {
17452 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
17455 auto *FirstECD = Vec->front();
17456 S.
Diag(FirstECD->getLocation(), diag::warn_duplicate_enum_values)
17457 << FirstECD << FirstECD->getInitVal().toString(10)
17458 << FirstECD->getSourceRange();
17462 for (
auto *ECD : llvm::make_range(Vec->begin() + 1, Vec->end()))
17463 S.
Diag(ECD->getLocation(), diag::note_duplicate_element)
17464 << ECD << ECD->getInitVal().toString(10)
17465 << ECD->getSourceRange();
17470 bool AllowMask)
const {
17471 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
17474 auto R = FlagBitsCache.insert(std::make_pair(ED,
llvm::APInt()));
17479 const auto &EVal = E->getInitVal();
17481 if (EVal.isPowerOf2())
17482 FlagBits = FlagBits.zextOrSelf(EVal.getBitWidth()) | EVal;
17494 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
17495 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
17501 EnumDecl *Enum = cast<EnumDecl>(EnumDeclX);
17504 ProcessDeclAttributeList(S, Enum, Attrs);
17507 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
17509 cast_or_null<EnumConstantDecl>(Elements[i]);
17510 if (!ECD)
continue;
17528 unsigned NumNegativeBits = 0;
17529 unsigned NumPositiveBits = 0;
17532 bool AllElementsInt =
true;
17534 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
17536 cast_or_null<EnumConstantDecl>(Elements[i]);
17537 if (!ECD)
continue;
17542 if (InitVal.isUnsigned() || InitVal.isNonNegative())
17543 NumPositiveBits =
std::max(NumPositiveBits,
17544 (
unsigned)InitVal.getActiveBits());
17546 NumNegativeBits =
std::max(NumNegativeBits,
17547 (
unsigned)InitVal.getMinSignedBits());
17550 if (AllElementsInt)
17556 unsigned BestWidth;
17569 bool Packed = Enum->
hasAttr<PackedAttr>();
17572 if (LangOpts.ShortEnums)
17582 BestPromotionType = BestType;
17586 else if (NumNegativeBits) {
17590 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
17592 BestWidth = CharWidth;
17593 }
else if (Packed && NumNegativeBits <= ShortWidth &&
17594 NumPositiveBits < ShortWidth) {
17596 BestWidth = ShortWidth;
17597 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
17598 BestType = Context.
IntTy;
17599 BestWidth = IntWidth;
17603 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
17604 BestType = Context.
LongTy;
17608 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
17613 BestPromotionType = (BestWidth <= IntWidth ? Context.
IntTy : BestType);
17618 if (Packed && NumPositiveBits <= CharWidth) {
17620 BestPromotionType = Context.
IntTy;
17621 BestWidth = CharWidth;
17622 }
else if (Packed && NumPositiveBits <= ShortWidth) {
17624 BestPromotionType = Context.
IntTy;
17625 BestWidth = ShortWidth;
17626 }
else if (NumPositiveBits <= IntWidth) {
17628 BestWidth = IntWidth;
17630 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
17632 }
else if (NumPositiveBits <=
17636 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
17640 assert(NumPositiveBits <= BestWidth &&
17641 "How could an initializer get larger than ULL?");
17644 = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus)
17651 for (
auto *D : Elements) {
17652 auto *ECD = cast_or_null<EnumConstantDecl>(D);
17653 if (!ECD)
continue;
17672 NewTy = Context.
IntTy;
17673 NewWidth = IntWidth;
17675 }
else if (ECD->getType() == BestType) {
17677 if (getLangOpts().CPlusPlus)
17681 ECD->setType(EnumType);
17685 NewWidth = BestWidth;
17690 InitVal = InitVal.extOrTrunc(NewWidth);
17691 InitVal.setIsSigned(NewSign);
17692 ECD->setInitVal(InitVal);
17695 if (ECD->getInitExpr() &&
17696 !Context.
hasSameType(NewTy, ECD->getInitExpr()->getType()))
17699 ECD->getInitExpr(),
17702 if (getLangOpts().CPlusPlus)
17706 ECD->setType(EnumType);
17708 ECD->setType(NewTy);
17712 NumPositiveBits, NumNegativeBits);
17717 for (
Decl *D : Elements) {
17719 if (!ECD)
continue;
17722 if (InitVal != 0 && !InitVal.isPowerOf2() &&
17723 !IsValueInFlagEnum(Enum, InitVal,
true))
17731 CheckAlignasUnderalignment(Enum);
17740 AsmString, StartLoc,
17742 CurContext->addDecl(New);
17751 NamedDecl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc,
17752 LookupOrdinaryName);
17755 AsmLabelAttr *
Attr = AsmLabelAttr::CreateImplicit(
17756 Context, AliasName->
getName(),
true, Info);
17762 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
17766 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
17767 << (isa<FunctionDecl>(PrevDecl) ? 0 : 1) << PrevDecl;
17770 (
void)ExtnameUndeclaredIdentifiers.insert(std::make_pair(Name, Attr));
17776 Decl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName);
17781 (void)WeakUndeclaredIdentifiers.insert(
17782 std::pair<IdentifierInfo*,WeakInfo>
17792 Decl *PrevDecl = LookupSingleName(TUScope, AliasName, AliasNameLoc,
17793 LookupOrdinaryName);
17796 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
17797 if (!PrevDecl->
hasAttr<AliasAttr>())
17798 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
17799 DeclApplyPragmaWeak(TUScope, ND, W);
17801 (void)WeakUndeclaredIdentifiers.insert(
17802 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W));
17807 return (dyn_cast_or_null<ObjCContainerDecl>(CurContext));
17813 return FunctionEmissionStatus::TemplateDiscarded;
17816 if (LangOpts.OpenMPIsDevice) {
17819 if (DevTy.hasValue()) {
17820 if (*DevTy == OMPDeclareTargetDeclAttr::DT_Host)
17821 OMPES = FunctionEmissionStatus::OMPDiscarded;
17822 else if (DeviceKnownEmittedFns.count(FD) > 0)
17823 OMPES = FunctionEmissionStatus::Emitted;
17825 }
else if (LangOpts.OpenMP) {
17827 if (LangOpts.OpenMP <= 45) {
17828 OMPES = FunctionEmissionStatus::Emitted;
17836 if (DevTy.hasValue()) {
17837 if (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost) {
17838 OMPES = FunctionEmissionStatus::OMPDiscarded;
17839 }
else if (DeviceKnownEmittedFns.count(FD) > 0) {
17840 OMPES = FunctionEmissionStatus::Emitted;
17845 if (OMPES == FunctionEmissionStatus::OMPDiscarded ||
17846 (OMPES == FunctionEmissionStatus::Emitted && !LangOpts.CUDA))
17849 if (LangOpts.CUDA) {
17856 return FunctionEmissionStatus::CUDADiscarded;
17857 if (!LangOpts.CUDAIsDevice &&
17859 return FunctionEmissionStatus::CUDADiscarded;
17871 && (!LangOpts.OpenMP || OMPES == FunctionEmissionStatus::Emitted))
17872 return FunctionEmissionStatus::Emitted;
17877 return (DeviceKnownEmittedFns.count(FD) > 0)
17878 ? FunctionEmissionStatus::Emitted
17890 return LangOpts.CUDA && !LangOpts.CUDAIsDevice &&
17891 IdentifyCUDATarget(Callee) == CFT_Global;
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
A call to an overloaded operator written using operator syntax.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
std::vector< std::string > Features
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
FunctionDecl * getDefinition()
Get the definition for this declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCallToStdMove() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
PragmaStack< StringLiteral * > CodeSegStack
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
bool mightBeUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
static StringRef getHeaderName(Builtin::Context &BuiltinInfo, unsigned ID, ASTContext::GetBuiltinTypeError Error)
void setImplicit(bool I=true)
Represents a function declaration or definition.
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Name lookup found a set of overloaded functions that met the criteria.
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Decl * 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, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
bool isPure(unsigned ID) const
Return true if this function has no side effects.
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
void setNonTrivialToPrimitiveDestroy(bool V)
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
static void CheckForDuplicateEnumValues(Sema &S, ArrayRef< Decl *> Elements, EnumDecl *Enum, QualType EnumType)
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
bool CheckNontrivialField(FieldDecl *FD)
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
no exception specification
QualType getObjCIdType() const
Represents the Objective-CC id type.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void setAnonymousStructOrUnion(bool Anon)
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
A (possibly-)qualified type.
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, tok::ObjCKeywordKind visibility)
ActOnIvar - Each ivar field of an objective-c class is passed into this in order to create an IvarDec...
bool isBlockPointerType() const
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
Simple class containing the result of Sema::CorrectTypo.
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
void InstantiatedLocal(const Decl *D, Decl *Inst)
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...
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc, bool IsTemplateId)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
NoSpeculativeLoadHardeningAttr * mergeNoSpeculativeLoadHardeningAttr(Decl *D, const NoSpeculativeLoadHardeningAttr &AL)
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword)...
const DeclarationNameLoc & getInfo() const
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Ident)
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
static void adjustDeclContextForDeclaratorDecl(DeclaratorDecl *NewD, DeclaratorDecl *OldD)
If necessary, adjust the semantic declaration context for a qualified declaration to name the correct...
SpeculativeLoadHardeningAttr * mergeSpeculativeLoadHardeningAttr(Decl *D, const SpeculativeLoadHardeningAttr &AL)
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
A class which encapsulates the logic for delaying diagnostics during parsing and other processing...
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
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...
ExtInfo withNoCallerSavedRegs(bool noCallerSavedRegs) const
static ShadowedDeclKind computeShadowedDeclKind(const NamedDecl *ShadowedDecl, const DeclContext *OldDC)
Determine what kind of declaration we're shadowing.
void setAttrs(const AttrVec &Attrs)
FunctionEmissionStatus getEmissionStatus(FunctionDecl *Decl)
void CheckCompleteVariableDeclaration(VarDecl *VD)
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
void setNonTrivialToPrimitiveDefaultInitialize(bool V)
AmbiguityKind getAmbiguityKind() const
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl *> CH)
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
void setStarLoc(SourceLocation Loc)
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
Filter makeFilter()
Create a filter for this result set.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
An instance of this object exists for each enum constant that is defined.
bool EvaluateAsInitializer(APValue &Result, const ASTContext &Ctx, const VarDecl *VD, SmallVectorImpl< PartialDiagnosticAt > &Notes) const
EvaluateAsInitializer - Evaluate an expression as if it were the initializer of the given declaration...
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
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)) {...
RAII object that pops an ExpressionEvaluationContext when exiting a function body.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Defines the SourceManager interface.
static void diagnoseImplicitlyRetainedSelf(Sema &S)
void setObjCClassRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
static const Builtin::Info BuiltinInfo[]
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
bool hasVolatileMember() const
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
bool isRecordType() const
bool isEmpty() const
No scope specifier.
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
void erase()
Erase the last element returned from this iterator.
static const TST TST_typeofExpr
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
bool isVariadic() const
Whether this function prototype is variadic.
SourceLocation getBeginLoc() const LLVM_READONLY
void forgetBuiltin(unsigned ID, IdentifierTable &Table)
Completely forget that the given ID was ever considered a builtin, e.g., because the user provided a ...
bool isDiscardableGVALinkage(GVALinkage L)
const RecordType * getAsStructureType() const
CommonAttr * mergeCommonAttr(Decl *D, const ParsedAttr &AL)
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
void setArgPassingRestrictions(ArgPassingKind Kind)
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function...
bool isPrintfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like printf in its formatting rules and, if so, set the index to th...
SmallVectorImpl< NamedDecl * >::const_iterator const_decl_iterator
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
bool isPOD() const
Whether this class is a POD-type (C++ [class]p4)
Defines the C++ template declaration subclasses.
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
static bool canRedefineFunction(const FunctionDecl *FD, const LangOptions &LangOpts)
canRedefineFunction - checks if a function can be redefined.
void setPure(bool P=true)
void setPreviousDeclaration(FunctionDecl *PrevDecl)
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
bool hasWrittenPrototype() const
Whether this function has a written prototype.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD, bool &Redeclaration, NamedDecl *&OldDecl, bool &MergeTypeWithPrevious, LookupResult &Previous)
Check the validity of a mulitversion function declaration.
A constructor named via a template-id.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
The base class of the type hierarchy.
static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New)
static void checkDuplicateDefaultInit(Sema &S, CXXRecordDecl *Parent, SourceLocation DefaultInitLoc)
SourceLocation getBeginLoc() const LLVM_READONLY
One instance of this struct is used for each type in a declarator that is parsed. ...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
Represent a C++ namespace.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
Represents a call to a C++ constructor.
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getEndLoc() const LLVM_READONLY
virtual void completeDefinition()
Note that the definition of this type is now complete.
bool isZero() const
isZero - Test whether the quantity equals zero.
SourceLocation getEndLoc() const LLVM_READONLY
const TargetInfo & getTargetInfo() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
void ActOnExitFunctionContext()
const NestedNameSpecifier * Specifier
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...
A container of type source information.
Store information needed for an explicit specifier.
static Attr * getImplicitCodeSegAttrFromClass(Sema &S, const FunctionDecl *FD)
Return a CodeSegAttr from a containing class.
Wrapper for void* pointer.
capture_const_range captures() const
Look up of a name that precedes the '::' scope resolution operator in C++.
static NestedNameSpecifier * synthesizeCurrentNestedNameSpecifier(ASTContext &Context, DeclContext *DC)
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=CSK_unspecified, Expr *TrailingRequiresClause=nullptr)
bool hasExplicitSpecifier() const
SourceRange getIntegerTypeRange() const LLVM_READONLY
Retrieve the source range that covers the underlying type if specified.
An overloaded operator name, e.g., operator+.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
static unsigned GetDiagnosticTypeSpecifierID(DeclSpec::TST T)
TSCS getThreadStorageClassSpec() const
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
void setInitStyle(InitializationStyle Style)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
unsigned getCharWidth() const
param_const_iterator param_end() const
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext...
size_t param_size() const
SourceLocation getEndLoc() const
Get the end source location.
const ParsedAttributes & getAttributes() const
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
bool hasAttribute(ParsedAttr::Kind K) const
QualType getElementType() const
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
***static FixItHint createFriendTagNNSFixIt(Sema &SemaRef, NamedDecl *ND, Scope *S, SourceLocation NameLoc)
The type would be trivial except that it is volatile-qualified.
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
Retains information about a function, method, or block that is currently being parsed.
This file provides some common utility functions for processing Lambda related AST Constructs...
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class, then each of the following shall have a name different from T:
void setRAngleLoc(SourceLocation Loc)
void ActOnObjCReenterContainerContext(DeclContext *DC)
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
enumerator_range enumerators() const
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.
Represents a variable declaration or definition.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool isStructureType() const
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
static const TST TST_underlyingType
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
DeclarationName getLookupName() const
Gets the name to look up.
Information about one declarator, including the parsed type information and the identifier.
QualType getReturnType() const
DiagnosticsEngine & Diags
unsigned getNumParams() const
bool isEnumeralType() const
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
const T * getAs() const
Member-template getAs<specific type>'.
static void SetNestedNameSpecifier(Sema &S, DeclaratorDecl *DD, Declarator &D)
Extra information about a function prototype.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
TypeSpecifierType
Specifies the kind of type.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
The "__interface" keyword.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
ExtInfo withProducesResult(bool producesResult) const
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
void ActOnObjCTemporaryExitContainerContext(DeclContext *DC)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
static const TST TST_interface
bool isZeroLengthBitField(const ASTContext &Ctx) const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
unsigned getDiagID() const
bool isInvalidDecl() const
bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD)
AddOverriddenMethods - See if a method overrides any in the base classes, and if so, check that it's a valid override and remember it.
QualType getObjCClassType() const
Represents the Objective-C Class type.
Stores a list of template parameters for a TemplateDecl and its derived classes.
static StringRef getTagTypeKindName(TagTypeKind Kind)
bool isCallingConv() const
Describes how types, statements, expressions, and declarations should be printed. ...
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Decl * ActOnParamDeclarator(Scope *S, Declarator &D)
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
llvm::SmallVector< ShadowedOuterDecl, 4 > ShadowingDecls
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
bool hasDefinition() const
static QualType getCoreType(QualType Ty)
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
static const NamedDecl * getDefinition(const Decl *D)
Represents a parameter to a function.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
void removeDecl(Decl *D)
Removes a declaration from this context.
void addVLATypeCapture(SourceLocation Loc, const VariableArrayType *VLAType, QualType CaptureType)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
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...
bool isVariableArrayType() const
Information about a template-id annotation token.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
ModuleKind Kind
The kind of this module.
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.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
void ActOnUninitializedDecl(Decl *dcl)
Base wrapper for a particular "section" of type source info.
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
bool isRedeclaration() const
Represents a struct/union/class.
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...
This is the private module fragment within some C++ module.
Description of a constructor that was inherited from a base class.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
static bool CheckTargetCausesMultiVersioning(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, const TargetAttr *NewTA, bool &Redeclaration, NamedDecl *&OldDecl, bool &MergeTypeWithPrevious, LookupResult &Previous)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
bool isComplete() const
Returns true if this can be considered a complete type.
One of these records is kept for each identifier that is lexed.
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
void setIntegerType(QualType T)
Set the underlying integer type.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations. ...
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
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...
virtual unsigned getStaticLocalNumber(const VarDecl *VD)=0
Static locals are numbered by source order.
bool doesNotEscape() const
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S)
Register the given locally-scoped extern "C" declaration so that it can be found later for redeclarat...
static bool isDeclExternC(const Decl *D)
Returns true if given declaration has external C language linkage.
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld)
MergeVarDeclTypes - We parsed a variable 'New' which has the same name and scope as a previous declar...
static bool hasDeducedAuto(DeclaratorDecl *DD)
unsigned getRegParm() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
void setManglingNumber(const NamedDecl *ND, unsigned Number)
static void mergeParamDeclTypes(ParmVarDecl *NewParam, const ParmVarDecl *OldParam, Sema &S)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
ArrayRef< QualType > getParamTypes() const
The results of name lookup within a DeclContext.
SourceLocation getTypeSpecTypeLoc() const
const ParmVarDecl *const * param_const_iterator
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
TypeLoc getInnerLoc() const
ConstexprSpecKind getConstexprKind() const
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e...
Missing a type from <ucontext.h>
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
unsigned getFunctionPrototypeDepth() const
Returns the number of function prototype scopes in this scope chain.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
field_range fields() const
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
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...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
SourceLocation getBeginLoc() const LLVM_READONLY
static const TST TST_class
NameKind getNameKind() const
Determine what kind of name this is.
bool isObjCIdType() const
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl *> Bindings)
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
Represents a member of a struct/union/class.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
const llvm::APSInt & getInitVal() const
bool supportsMultiVersioning() const
Identify whether this target supports multiversioning of functions, which requires support for cpu_su...
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
OverloadedOperatorKind Operator
The kind of overloaded operator.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
static bool isIncrementDecrementOp(Opcode Op)
bool Zero(InterpState &S, CodePtr OpPC)
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
bool isFunctionDefinition() const
void startDefinition()
Starts the definition of this tag declaration.
Attr * getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, bool IsDefinition)
Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a containing class...
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
bool hasAutoTypeSpec() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
bool isReferenceType() const
void setElaboratedKeywordLoc(SourceLocation Loc)
The iterator over UnresolvedSets.
static const TST TST_error
Token - This structure provides full information about a lexed token.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
bool isInIdentifierNamespace(unsigned NS) const
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT)
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool isLinkageValid() const
True if the computed linkage is valid.
This declaration is definitely a definition.
static const TST TST_enum
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
ExplicitSpecifier getExplicitSpecifier() const
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
LookupResultKind getResultKind() const
bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S)
isMicrosoftMissingTypename - In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal...
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
__DEVICE__ int max(int __a, int __b)
void ClearStorageClassSpecs()
SourceLocation getBeginLoc() const LLVM_READONLY
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Declaration of a function specialization at template class scope.
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
SourceLocation getTemplateLoc() const
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
void PopExpressionEvaluationContext()
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
A user-defined literal name, e.g., operator "" _i.
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Describes a module or submodule.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
ArrayRef< ParmVarDecl * > parameters() const
bool canKeyFunctionBeInline() const
Can an out-of-line inline function serve as a key function?
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool getProducesResult() const
DeclClass * getAsSingle() const
static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, DeclContext *Owner, RecordDecl *AnonRecord, AccessSpecifier AS, SmallVectorImpl< NamedDecl *> &Chaining)
InjectAnonymousStructOrUnionMembers - Inject the members of the anonymous struct or union AnonRecord ...
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
bool isReplaceableGlobalAllocationFunction(bool *IsAligned=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
Describes an C or C++ initializer list.
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
Represents a C++ unqualified-id that has been parsed.
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
bool isBitField() const
Determines whether this field is a bitfield.
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, const TemplateArgumentListInfo &TemplateArgs)
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
void setNameLoc(SourceLocation Loc)
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation)
Represents the results of name lookup.
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn)
We've just determined that Old and New both appear to be definitions of the same variable.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl *> Bindings=None)
bool isElidable() const
Whether this construction is elidable.
ObjCContainerDecl - Represents a container for method declarations.
static void filterNonConflictingPreviousTypedefDecls(Sema &S, TypedefNameDecl *Decl, LookupResult &Previous)
Typedef declarations don't have linkage, but they still denote the same entity if their types are the...
TagKind getTagKind() const
bool isReferenced() const
Whether any declaration of this entity was referenced.
CharUnits - This is an opaque type for sizes expressed in character units.
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
void setcudaConfigureCallDecl(FunctionDecl *FD)
void setParamDestroyedInCallee(bool V)
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
bool ActOnDuplicateDefinition(DeclSpec &DS, Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old)
Merge alignment attributes from Old to New, taking into account the special semantics of C11's _Align...
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes, if any.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
Wrapper for source info for functions.
static void RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator, Sema &S)
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
SCS
storage-class-specifier
static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl *> Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Decl * getObjCDeclContext() const
Visibility
Describes the different kinds of visibility that a declaration may have.
Decl * ActOnObjCContainerStartDefinition(Decl *IDecl)
static ParsedType recoverFromTypeInKnownDependentBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc)
A friend of a previously-undeclared entity.
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
SourceLocation getBeginLoc() const LLVM_READONLY
Concrete class used by the front-end to report problems and issues.
__ptr16, alignas(...), etc.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
bool isConstWithoutErrno(unsigned ID) const
Return true if this function has no side effects and doesn't read memory, except for possibly errno...
const clang::PrintingPolicy & getPrintingPolicy() const
static bool isRecordType(QualType T)
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
void setRedeclaration(bool Val)
void setHasObjectMember(bool val)
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isShadowed() const
Determine whether the lookup result was shadowed by some other declaration that lookup ignored...
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
static void checkIsValidOpenCLKernelParameter(Sema &S, Declarator &D, ParmVarDecl *Param, llvm::SmallPtrSetImpl< const Type *> &ValidTypes)
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...
static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization, bool IsDefinition)
SourceLocation getLParenLoc() const
static SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI, const VarDecl *VD)
Return the location of the capture if the given lambda captures the given variable VD...
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
void setHasImplicitReturnZero(bool IRZ)
State that falling off this function implicitly returns null/zero.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
Module * Parent
The parent of this module.
static bool isAcceptableTagRedeclContext(Sema &S, DeclContext *OldDC, DeclContext *NewDC)
Determine whether a tag originally declared in context OldDC can be redeclared with an unqualified na...
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
unsigned getMSLastManglingNumber() const
The argument of this type cannot be passed directly in registers.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
void attachCommentsToJustParsedDecls(ArrayRef< Decl *> Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
DeclContextLookupResult slice(size_t N) const
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
Expr * getSizeExpr() const
Scope - A scope is a transient data structure that is used while parsing the program.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
field_iterator field_begin() const
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl *> &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions...
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
void DiagnoseUnusedDecl(const NamedDecl *ND)
DiagnoseUnusedDecl - Emit warnings about declarations that are not used unless they are marked attr(u...
const Expr * getInitExpr() const
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Represents a C++ nested-name-specifier or a global scope specifier.
const T * getAsAdjusted() const
Member-template getAsAdjusted<specific type>.
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
bool 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 isNoreturnSpecified() const
void setRedeclarationKind(Sema::RedeclarationKind RK)
Change this lookup's redeclaration kind.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
static bool mergeDeclAttribute(Sema &S, NamedDecl *D, const InheritableAttr *Attr, Sema::AvailabilityMergeKind AMK)
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...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
void UpdateExprRep(Expr *Rep)
void CheckVariableDeclarationType(VarDecl *NewVD)
bool performsCallback(unsigned ID, llvm::SmallVectorImpl< int > &Encoding) const
Determine whether this builtin has callback behavior (see llvm::AbstractCallSites for details)...
virtual bool allowDebugInfoForExternalVar() const
Whether target allows debuginfo types for decl only variables.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
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'.
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
SourceLocation getConstSpecLoc() const
void setLocalOwningModule(Module *M)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool isScalarType() const
SourceLocation getLSquareLoc() const
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Represents an ObjC class declaration.
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
void revertBuiltin()
Revert the identifier to a non-builtin identifier.
Represents a linkage specification.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
Member name lookup, which finds the names of class/struct/union members.
SourceLocation getTypeSpecStartLoc() const
SourceRange getSourceRange() const LLVM_READONLY
PrimitiveDefaultInitializeKind
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
The type does not fall into any of the following categories.
IdentifierInfo * getIdentifier() const
static bool isUsingDecl(NamedDecl *D)
CanQualType UnsignedCharTy
unsigned getLength() const
Efficiently return the length of this identifier info.
bool getNoCallerSavedRegs() const
UnionParsedType ConstructorName
When Kind == IK_ConstructorName, the class-name of the type whose constructor is being referenced...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
This object can be modified without requiring retains or releases.
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
param_iterator param_begin()
void setHasInheritedPrototype(bool P=true)
State that this function inherited its prototype from a previous declaration.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
ExtInfo withCallingConv(CallingConv cc) const
ImplicitCaptureStyle ImpCaptureStyle
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
bool isExternInLinkageSpec() const
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), Expr *TrailingRequiresClause=nullptr)
CXXSpecialMember
Kinds of C++ special members.
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
void completeDefinition(QualType NewType, QualType PromotionType, unsigned NumPositiveBits, unsigned NumNegativeBits)
When created, the EnumDecl corresponds to a forward-declared enum.
ConditionalOperator - The ?: ternary operator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
Sema - This implements semantic analysis and AST building for C.
StringRef getString() const
Merge availability attributes for an implementation of a protocol requirement.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
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(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true, bool ConsiderRequiresClauses=true)
Contains information gathered from parsing the contents of TargetAttr.
bool Mutable
Whether this is a mutable lambda.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
SmallVector< ReturnStmt *, 4 > Returns
The list of return statements that occur within the function or block, if there is any chance of appl...
SourceLocation getUnalignedSpecLoc() const
Represents a prototype with parameter type info, e.g.
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool hasConstexprSpecifier() const
void ClearConstexprSpec()
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration...
static void mergeParamDeclAttributes(ParmVarDecl *newDecl, const ParmVarDecl *oldDecl, Sema &S)
mergeParamDeclAttributes - Copy attributes from the old parameter to the new one. ...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S)
isTagName() - This method is called for error recovery purposes only to determine if the specified na...
bool inferObjCARCLifetime(ValueDecl *decl)
Represents a ValueDecl that came out of a declarator.
void SetRangeStart(SourceLocation Loc)
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclarationNameTable DeclarationNames
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S, bool MergeTypeWithOld)
MergeFunctionDecl - We just parsed a function 'New' from declarator D which has the same name and sco...
const char * getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl)
Checks if the new declaration declared in dependent context must be put in the same redeclaration cha...
bool isEnabled(llvm::StringRef Ext) const
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl *> Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
A conversion function name, e.g., operator int.
SourceRange getRange() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Captures information about a #pragma weak directive.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
TypeSourceInfo * getTypeSourceInfo() const
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
TST getTypeSpecType() const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
static NamedDecl * DiagnoseInvalidRedeclaration(Sema &SemaRef, LookupResult &Previous, FunctionDecl *NewFD, ActOnFDArgs &ExtraArgs, bool IsLocalFriend, Scope *S)
Generate diagnostics for an invalid function redeclaration.
static bool isDeclRep(TST T)
bool isVariableCapture() const
Exposes information about the current target.
bool isCLike() const
True if this class is C-like, without C++-specific features, e.g.
bool isMsStruct(const ASTContext &C) const
Get whether or not this is an ms_struct which can be turned on with an attribute, pragma...
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.
SourceLocation getBeginLoc() const
Get the begin source location.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Type source information for an attributed type.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
bool isObjCGCStrong() const
true when Type is objc's strong.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
LookupNameKind
Describes the kind of name lookup to perform.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e...
static bool isResultTypeOrTemplate(LookupResult &R, const Token &NextToken)
Determine whether the given result set contains either a type name or.
known_extensions_range known_extensions() const
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
bool isFunctionNoProtoType() const
bool isVariadic() const
Whether this function is variadic.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
void ResetObjCLayout(const ObjCContainerDecl *CD)
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
void deduceOpenCLAddressSpace(ValueDecl *decl)
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
static bool checkForConflictWithNonVisibleExternC(Sema &S, const T *ND, LookupResult &Previous)
Apply special rules for handling extern "C" declarations.
DeclContext * getEntity() const
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...
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
unsigned SymbolLocations[3]
The source locations of the individual tokens that name the operator, e.g., the "new", "[", and "]" tokens in operator new [].
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
bool getHasRegParm() const
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee)
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI)
Diagnose shadowing for variables shadowed in the lambda record LambdaRD when these variables are capt...
static bool ValidDuplicateEnum(EnumConstantDecl *ECD, EnumDecl *Enum)
OpaquePtr< T > get() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
QualType getParenType(QualType NamedType) const
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
SourceLocation getVolatileSpecLoc() const
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
SourceLocation getThreadStorageClassSpecLoc() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure...
Defines the clang::Preprocessor interface.
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
bool isPredefinedRuntimeFunction(unsigned ID) const
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache"...
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
static void CheckPoppedLabel(LabelDecl *L, Sema &S)
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
field_iterator field_end() const
overridden_method_range overridden_methods() const
ObjCLifetime getObjCLifetime() const
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
bool isFileContext() const
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
SourceLocation getBeginLoc() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
This declaration is a tentative definition.
static bool PreviousDeclsHaveMultiVersionAttribute(const FunctionDecl *FD)
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
void setObjCIdRedefinitionType(QualType RedefType)
Set the user-written type that redefines id.
TLSKind getTLSKind() const
AttributeFactory & getFactory() const
static QualType getNextLargerIntegralType(ASTContext &Context, QualType T)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
void setMemberSpecialization()
Note that this member template is a specialization.
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
Represents a C++ template name within the type system.
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name...
SourceLocation getStorageClassSpecLoc() const
ParmVarDecl *const * param_iterator
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...
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
unsigned short getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
void UpdateTypeRep(ParsedType Rep)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
bool shouldInheritEvenIfAlreadyPresent() const
Should this attribute be inherited from a prior declaration even if it's explicitly provided in the c...
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
void setConstexpr(bool IC)
FieldDecl * CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitfieldWidth, InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D=nullptr)
Build a new FieldDecl and check its well-formedness.
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old)
checkNewAttributesAfterDef - If we already have a definition, check that there are no new attributes ...
bool isFunctionOrMethod() const
static StorageClass getFunctionStorageClass(Sema &SemaRef, Declarator &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.
static bool hasSimilarParameters(ASTContext &Context, FunctionDecl *Declaration, FunctionDecl *Definition, SmallVectorImpl< unsigned > &Params)
hasSimilarParameters - Determine whether the C++ functions Declaration and Definition have "nearly" m...
StorageClass
Storage classes.
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
virtual bool validateCpuSupports(StringRef Name) const
static bool HasNonMultiVersionAttributes(const FunctionDecl *FD, MultiVersionKind MVType)
Direct list-initialization (C++11)
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
static bool hasParsedAttr(Scope *S, const Declarator &PD, ParsedAttr::Kind Kind)
InClassInitStyle
In-class initialization styles for non-static data members.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
An expression that sends a message to the given Objective-C object or class.
QualType getRecordType(const RecordDecl *Decl) const
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
SourceLocation getEnd() const
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
struct CXXOpName CXXOperatorName
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getContainingDC(DeclContext *DC)
bool isFriendSpecified() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
bool isCompoundStmtScope() const
Determine whether this scope is a compound statement scope.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
void setStorageClass(StorageClass SC)
Represents a C++ conversion function within a class.
sema::LambdaScopeInfo * PushLambdaScope()
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
This template specialization was implicitly instantiated from a template.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
QualType withoutLocalFastQualifiers() const
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static bool shouldConsiderLinkage(const VarDecl *VD)
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
static StringRef getIdentifier(const Token &Tok)
static void ReportOverrides(Sema &S, unsigned DiagID, const CXXMethodDecl *MD, OverrideErrorKind OEK=OEK_All)
Report an error regarding overriding, along with any relevant overridden methods. ...
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList *> TPLists)
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
static CharSourceRange getCharRange(SourceRange R)
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
ExtInfo withNoReturn(bool noReturn) const
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isVoidPointerType() const
static bool checkGlobalOrExternCConflict(Sema &S, const T *ND, bool IsGlobal, LookupResult &Previous)
Check for conflict between this global or extern "C" declaration and previous global or extern "C" de...
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
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.
RecordDecl * getDecl() const
ConstexprSpecKind getConstexprSpecifier() const
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...
static bool CheckMultiVersionValue(Sema &S, const FunctionDecl *FD)
Check the target attribute of the function for MultiVersion validity.
SourceLocation getNoreturnSpecLoc() const
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Decl * ActOnSkippedFunctionBody(Decl *Decl)
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
UnqualifiedTypeNameLookupResult
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
static bool isIncompleteDeclExternC(Sema &S, const T *D)
Determine whether a variable is extern "C" prior to attaching an initializer.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
void setTypeForDecl(const Type *TD)
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
char * location_data() const
Retrieve the data associated with the source-location information.
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
bool isAuxBuiltinID(unsigned ID) const
Return true if builtin ID belongs to AuxTarget.
Wrapper for source info for arrays.
static unsigned getMSManglingNumber(const LangOptions &LO, Scope *S)
There is no lifetime qualification on this type.
Decl::Kind getDeclKind() const
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
TypeLoc IgnoreParens() const
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
VarDecl * getVariable() const
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
ExtProtoInfo getExtProtoInfo() const
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SCS getStorageClassSpec() const
ASTContext & getASTContext() const
Expr * getAsmLabel() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
unsigned getMSCurManglingNumber() const
unsigned getNumExprs() const
Return the number of expressions in this paren list.
static bool AllowOverloadingOfFunction(LookupResult &Previous, ASTContext &Context, const FunctionDecl *New)
Determine whether we allow overloading of the function PrevDecl with another declaration.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
bool isTypeSpecOwned() const
Sugar for parentheses used when specifying types.
static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, Declarator &D, DeclContext *DC, QualType R)
Returns true if there hasn't been any invalid type diagnosed.
void setTopLevelDeclInObjCContainer(bool V=true)
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
bool isPure() const
Whether this virtual function is pure, i.e.
bool CheckForConstantInitializer(Expr *e, QualType t)
type checking declaration initializers (C99 6.7.8)
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
void ActOnDocumentableDecls(ArrayRef< Decl *> Group)
SourceLocation CurrentPragmaLocation
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
LangAS getAddressSpace() const
Return the address space of this type.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
Expr * getSubExpr() const
FunctionDefinitionKind getFunctionDefinitionKind() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
CXXRecordDecl * Lambda
The class that describes the lambda.
void setBraceRange(SourceRange R)
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
Attr * clone(ASTContext &C) const
enum clang::DeclaratorChunk::@219 Kind
static bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
CastKind getCastKind() const
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function...
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority)
Attribute merging methods. Return true if a new attribute was added.
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
void setFreeStanding(bool isFreeStanding=true)
True if this tag is free standing, e.g. "struct foo;".
void disableCheckFallThrough()
DeclarationName getName() const
getName - Returns the embedded declaration name.
void ExitDeclaratorContext(Scope *S)
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
MutableArrayRef< Expr * > MultiExprArg
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
bool isModulePrivateSpecified() const
static const TST TST_union
CallingConv getCC() const
bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context, will replace the declaration OldD if introduced into scope.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
ExitFunctionBodyRAII(Sema &S, bool IsLambda)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList *> TPLists)
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
Represents the declaration of a label.
ParsedAttr - Represents a syntactic attribute.
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...
const DecompositionDeclarator & getDecompositionDeclarator() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
void setDefaulted(bool D=true)
void setHasFlexibleArrayMember(bool V)
SourceLocation getStrTokenLoc(unsigned TokNum) const
Get one of the string literal token.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used...
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
bool isConst(unsigned ID) const
Return true if this function has no side effects and doesn't read memory.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void addOverriddenMethod(const CXXMethodDecl *MD)
static ParsedType buildNestedType(Sema &S, CXXScopeSpec &SS, QualType T, SourceLocation NameLoc)
Build a ParsedType for a simple-type-specifier with a nested-name-specifier.
void setEntity(DeclContext *E)
const ParmVarDecl * getParamDecl(unsigned i) const
void demoteThisDefinitionToDeclaration()
This is a definition which should be demoted to a declaration.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
SourceLocation getLocation() const
A friend of a previously-declared entity.
Name lookup found an unresolvable value declaration and cannot yet complete.
MemberPointerTypeInfo Mem
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
static bool CheckMultiVersionAdditionalRules(Sema &S, const FunctionDecl *OldFD, const FunctionDecl *NewFD, bool CausesMV, MultiVersionKind MVType)
ObjCCategoryDecl - Represents a category declaration.
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible. ...
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
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 isObjCObjectPointerType() const
Decl * getRepAsDecl() const
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
A class for iterating through a result set and possibly filtering out results.
This declaration is only a declaration.
SmallVector< Capture, 4 > Captures
Captures - The captures.
bool isMSAsmLabel() const
bool isSimpleTypeSpecifier(tok::TokenKind Kind) const
Determine whether the token kind starts a simple-type-specifier.
SourceRange getRange() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
uint32_t TypeID
An ID number that refers to a type in an AST file.
bool isFunctionProtoType() const
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
static const TST TST_typeofType
bool hasLinkageBeenComputed() const
True if something has required us to compute the linkage of this declaration.
No entity found met the criteria.
bool isHeaderDependentFunction(unsigned ID) const
Returns true if this builtin requires appropriate header in other compilers.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
SourceLocation getRAngleLoc() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
DeclarationNameInfo getNameInfo() const
bool isStaticMember()
Returns true if this declares a static member.
virtual bool validateCpuIs(StringRef Name) const
SourceLocation getInlineSpecLoc() const
static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl *Old)
Assigning into this object requires a lifetime extension.
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
static bool isExternC(T *D)
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
bool isScanfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like scanf in its formatting rules and, if so, set the index to the...
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
void setObjCSuperType(QualType ST)
bool hasFlexibleArrayMember() const
void setLAngleLoc(SourceLocation Loc)
bool isInvalid() const
An error occurred during parsing of the scope specifier.
static bool isRepresentableIntegerValue(ASTContext &Context, llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T...
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag)
static void LookupPredefedObjCSuperType(Sema &ThisSema, Scope *S, IdentifierInfo *II)
Looks up the declaration of "struct objc_super" and saves it for later use in building builtin declar...
static unsigned getRedeclDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for redeclaration diagnostic message.
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface...
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
MultiVersionKind getMultiVersionKind() const
Gets the kind of multiversioning attribute this declaration has.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
TypeLoc getElementLoc() const
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
SourceLocation getModulePrivateSpecLoc() const
ObjCDeclQualifier getObjCDeclQualifier() const
StringRef getName() const
Return the actual identifier string.
static bool isOutOfScopePreviousDeclaration(NamedDecl *, DeclContext *, ASTContext &)
Determines whether the given declaration is an out-of-scope previous declaration. ...
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
NamedDecl * getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R)
Return the declaration shadowed by the given typedef D, or null if it doesn't shadow any declaration ...
CanQualType UnsignedShortTy
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
bool isObjCGCWeak() const
true when Type is objc's weak.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Base class for declarations which introduce a typedef-name.
bool isNot(tok::TokenKind K) const
TLS with a dynamic initializer.
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
VarDecl * getInitializingDeclaration()
Get the initializing declaration of this variable, if any.
LabelStmt * getStmt() const
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
TagTypeKind
The kind of a tag type.
bool hasSameFunctionTypeIgnoringPtrSizes(QualType T, QualType U)
Determine whether two function types are the same, ignoring pointer sizes in the return type and para...
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Dataflow Directional Tag Classes.
ConstexprSpecKind
Define the kind of constexpr specifier.
static void FixInvalidVariablyModifiedTypeLoc(TypeLoc SrcTL, TypeLoc DstTL)
bool isValid() const
Return true if this is a valid SourceLocation object.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
ExtInfo getExtInfo() const
void setHasVolatileMember(bool val)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
A qualifier set is used to build a set of qualifiers.
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false)
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
static const CXXRecordDecl * findRecordWithDependentBasesOfEnclosingMethod(const DeclContext *DC)
Find the parent class with dependent bases of the innermost enclosing method context.
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
The base class of all kinds of template declarations (e.g., class, function, etc.).
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
static const TST TST_decltype
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where 'self' is implicitly retained inside a block.
static const TST TST_auto
const Scope * getParent() const
getParent - Return the scope that this is nested in.
static bool CheckAnonMemberRedeclaration(Sema &SemaRef, Scope *S, DeclContext *Owner, DeclarationName Name, SourceLocation NameLoc, bool IsUnion)
We are trying to inject an anonymous member into the given scope; check if there's an existing declar...
QualType getType() const
Get the type for which this source info wrapper provides information.
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
Qualifiers getMethodQualifiers() const
Represents a field injected from an anonymous union/struct into the parent scope. ...
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
bool isDependentAddressSpaceType() const
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
QualType getUnderlyingType() const
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
unsigned getNextFunctionPrototypeIndex()
Return the number of parameters declared in this function prototype, increasing it by one for the nex...
CanQualType UnsignedLongLongTy
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
SourceLocation getIncludeLoc(FileID FID) const
Returns the include location if FID is a #include'd file otherwise it returns an invalid location...
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
const Expr * getInit() const
AccessSpecifier getAccess() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Uuid)
A decomposition declaration.
MapType::iterator iterator
This is a scope that corresponds to the template parameters of a C++ template.
void setShadowed()
Note that we found and ignored a declaration while performing lookup.
void setWillHaveBody(bool V=true)
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
The name of a declaration.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
static ObjCIvarDecl::AccessControl TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility)
TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
static FunctionDecl * CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, DeclContext *DC, QualType &R, TypeSourceInfo *TInfo, StorageClass SC, bool &IsVirtualOkay)
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
A mapping from each virtual member function to its set of final overriders.
unsigned getNumTemplateParameterLists() const
redecl_iterator redecls_end() const
void setInlineSpecified()
void mergeNRVOIntoParent()
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack...
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
static bool isTagTypeWithMissingTag(Sema &SemaRef, LookupResult &Result, Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc)
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D)
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
void setPreviousDeclInSameBlockScope(bool Same)
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
The name refers to a template whose specialization produces a type.
SourceLocation getBeginLoc() const LLVM_READONLY
static const TST TST_unspecified
static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, const FunctionDecl *&PossiblePrototype)
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
IdentifierInfo * getCorrectionAsIdentifierInfo() const
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
static std::pair< diag::kind, SourceLocation > getNoteDiagForInvalidRedeclaration(const T *Old, const T *New)
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
llvm::APInt getValue() const
QualType getModifiedType() const
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
void setNameLoc(SourceLocation Loc)
SourceLocation getRBracketLoc() const
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated", "unavailable", and "availability").
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation DefinitionLoc
The location of the module definition.
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
Name lookup found a single declaration that met the criteria.
void setImplicitlyInline()
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
TypeLoc getPointeeLoc() const
unsigned getIntWidth(QualType T) const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
bool isIncompleteArrayType() const
bool isClosedFlag() const
Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(ope...
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...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
bool isModulePurview() const
Does this Module scope describe part of the purview of a named C++ module?
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl *> Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void addThisCapture(bool isNested, SourceLocation Loc, QualType CaptureType, bool ByCopy)
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx, FixItHint &Hint)
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
SourceLocation getVirtualSpecLoc() const
bool isReserveIDT() const
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant...
CanQualType UnsignedLongTy
bool hasNonTrivialObjCLifetime() const
void setConstexprKind(ConstexprSpecKind CSK)
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl *> Elements, Scope *S, const ParsedAttributesView &Attr)
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false)
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S'...
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value...
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope...
bool isFunctionType() const
void setTypeSourceInfo(TypeSourceInfo *TI)
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
TypeSourceInfo * getTypeSourceInfo() const
static const TST TST_typename
Expr * getSizeExpr() const
Expr * getArg(unsigned Arg)
Return the specified argument.
param_const_iterator param_begin() const
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
SourceLocation getLBracketLoc() const
void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaRedefineExtname - Called on well formed #pragma redefine_extname oldname newname...
void setHasNonTrivialToPrimitiveDestructCUnion(bool V)
void setCXXForRangeDecl(bool FRD)
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
void ActOnCXXForRangeDecl(Decl *D)
static bool isOpenCLSizeDependentType(ASTContext &C, QualType Ty)
Decl * BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy)
BuildAnonymousStructOrUnion - Handle the declaration of an anonymous structure or union...
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.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
void addDecl(Decl *D)
Add the declaration D into this context.
static SourceLocation findDefaultInitializer(const CXXRecordDecl *Record)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
void setInherited(bool I)
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, ParsedAttributes &Attrs, SourceLocation AttrEnd)
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
bool isConstantArrayType() const
bool hasAddressSpace() const
Check if this type has any address space qualifier.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Represents a base class of a C++ class.
CXXScopeSpec & getTypeSpecScope()
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
This is a scope that can contain a declaration.
SourceManager & getSourceManager()
void * SkippedDefinitionContext
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any...
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setPromotionType(QualType T)
Set the promotion type.
ObjCInterfaceDecl * getObjCInterfaceDecl(IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
bool isSet() const
Deprecated.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
SourceRange getSourceRange() const
bool isNoThrow(unsigned ID) const
Return true if we know this builtin never throws an exception.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
TypedefNameDecl * getDecl() const
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
void setInvalidType(bool Val=true)
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Reading or writing from this object requires a barrier call.
ExternCContextDecl * getExternCContextDecl() const
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
static bool isClassCompatTagKind(TagTypeKind Tag)
Determine if tag kind is a class-key compatible with class for redeclaration (class, struct, or __interface).
static bool isMainFileLoc(const Sema &S, SourceLocation Loc)
bool isResolvedMSAsmLabel() const
An attributed type is a type to which a type attribute has been applied.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
Call-style initialization (C++98)
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 typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI, bool BestCase, MSInheritanceModel Model)
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
bool Failed() const
Determine whether the initialization sequence is invalid.
TranslationUnitDecl * getTranslationUnitDecl() const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
Describes the sequence of initializations required to initialize a given object or reference with a s...
static QualType TryToFixInvalidVariablyModifiedType(QualType T, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
Helper method to turn variable array types into constant array types in certain situations which woul...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
static DeclContext * getTagInjectionContext(DeclContext *DC)
Find the DeclContext in which a tag is implicitly declared if we see an elaborated type specifier in ...
Captures information about "declaration specifiers".
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
SourceLocation getRestrictSpecLoc() const
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization)
Perform semantic checking of a new function declaration.
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl *> Group)
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
ShadowedDeclKind
Enum describing the select options in diag::warn_decl_shadow.
Represents a C++ struct/union/class.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
static bool isCompoundAssignmentOp(Opcode Opc)
static const TSCS TSCS_thread_local
TemplateParameterList * getInventedTemplateParameterList() const
The template parameter list generated from the explicit template parameters along with any invented t...
void setTSCSpec(ThreadStorageClassSpecifier TSC)
static void RemoveUsingDecls(LookupResult &R)
Removes using shadow declarations from the lookup results.
void MergeVarDecl(VarDecl *New, LookupResult &Previous)
MergeVarDecl - We just parsed a variable 'New' which has the same name and scope as a previous declar...
SmallVectorImpl< UniqueVirtualMethod >::iterator overriding_iterator
Represents a C array with an unspecified size.
static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, DeclarationName Name)
NeedsRebuildingInCurrentInstantiation - Checks whether the given declarator needs to be rebuilt in th...
ExprResult VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth, bool *ZeroWidth=nullptr)
VerifyBitField - verifies that a bit field expression is an ICE and has the correct width...
Missing a type from <stdio.h>
Look up a friend of a local class.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
static bool hasIdenticalPassObjectSizeAttrs(const FunctionDecl *A, const FunctionDecl *B)
bool isTLSSupported() const
Whether the target supports thread-local storage.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
The parameter type of a method or function.
ObjCIvarDecl - Represents an ObjC instance variable.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
LambdaCaptureDefault getLambdaCaptureDefault() const
void setLParenLoc(SourceLocation Loc)
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
void setHasNonTrivialToPrimitiveCopyCUnion(bool V)
Builtin::Context & BuiltinInfo
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void ActOnPopScope(SourceLocation Loc, Scope *S)
Scope actions.
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Declaration of a class template.
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool isVirtualSpecified() const
static StorageClass StorageClassSpecToVarDeclStorageClass(const DeclSpec &DS)
StorageClassSpecToVarDeclStorageClass - Maps a DeclSpec::SCS to a VarDecl::StorageClass.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
This class is used for builtin types like 'int'.
unsigned getRegParmType() const
A template-id, e.g., f<int>.
AttributePool & getPool() const
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
ParsedType getRepAsType() const
TranslationUnitKind TUKind
The kind of translation unit we are processing.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U)
Determine whether two function types are the same, ignoring exception specifications in cases where t...
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
bool isInlineSpecified() const
TLS with a known-constant initializer.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
SourceLocation getAtomicSpecLoc() const
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
The translation unit is a complete translation unit.
static bool CheckMultiVersionAdditionalDecl(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, MultiVersionKind NewMVType, const TargetAttr *NewTA, const CPUDispatchAttr *NewCPUDisp, const CPUSpecificAttr *NewCPUSpec, bool &Redeclaration, NamedDecl *&OldDecl, bool &MergeTypeWithPrevious, LookupResult &Previous)
Check the validity of a new function declaration being added to an existing multiversioned declaratio...
static TagDecl * castFromDeclContext(const DeclContext *DC)
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.
void setObjCSelRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
const VariableArrayType * getAsVariableArrayType(QualType T) const
static bool DeclHasAttr(const Decl *D, const Attr *A)
DeclhasAttr - returns true if decl Declaration already has the target attribute.
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
static OpaquePtr make(QualType P)
static bool checkUsingShadowRedecl(Sema &S, UsingShadowDecl *OldS, ExpectedDecl *New)
Check whether a redeclaration of an entity introduced by a using-declaration is valid, given that we know it's not an overload (nor a hidden tag declaration).
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
SourceLocation getExplicitSpecLoc() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
SourceLocation getConstexprSpecLoc() const
bool isEvaluatable(const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-e...
static void diagnoseMissingConstinit(Sema &S, const VarDecl *InitDecl, const ConstInitAttr *CIAttr, bool AttrBeforeInit)
A reference to a declared variable, function, enum, etc.
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Represents a type template specialization; the template must be a class template, a type alias templa...
Visibility getVisibility() const
Determines the visibility of this entity.
static const TST TST_atomic
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
bool hasObjectMember() const
NamedDecl * findLocallyScopedExternCDecl(DeclarationName Name)
Look for a locally scoped extern "C" declaration by the given name.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
void ActOnObjCContainerFinishDefinition()
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
SourceManager & SourceMgr
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
static const TST TST_struct
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
bool isStaticDataMember() const
Determines whether this is a static data member.
SourceLocation getInnerLocStart() const
Return SourceLocation representing start of source range ignoring outer template declarations.
static bool hasDependentAlignment(VarDecl *VD)
Determines if a variable's alignment is dependent.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
static bool CheckMultiVersionFirstFunction(Sema &S, FunctionDecl *FD, MultiVersionKind MVType, const TargetAttr *TA)
Check the validity of a multiversion function declaration that is the first of its kind...
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
static StringRef getNameForCallConv(CallingConv CC)
bool empty() const
Return true if no decls were found.
void setRParenLoc(SourceLocation Loc)
bool isFloatingType() const
A trivial tuple used to represent a source range.
bool hasUnrecoverableErrorOccurred() const
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
void setLexicalDeclContext(DeclContext *DC)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void setHasNonTrivialToPrimitiveDefaultInitializeCUnion(bool V)
This represents a decl that may have a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool isTranslationUnit() const
Expr * getRepAsExpr() const
void setTypeSourceInfo(TypeSourceInfo *newType)
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
Represents a C array with a specified size that is not an integer-constant-expression.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
static bool shouldWarnIfShadowedDecl(const DiagnosticsEngine &Diags, const LookupResult &R)
No keyword precedes the qualified type name.
bool isInline() const
Whether this variable is (C++1z) inline.
static bool IsDisallowedCopyOrAssign(const CXXMethodDecl *D)
Check for this common pattern:
static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND)
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool IsTemplateTypeArg)
Attempt to behave like MSVC in situations where lookup of an unqualified type name has failed in a de...
static bool mergeTypeWithPrevious(Sema &S, VarDecl *NewVD, VarDecl *OldVD, LookupResult &Previous)
SourceLocation getNameLoc() const
Gets the location of the identifier.
Describes an entity that is being initialized.
bool isFunctionPointerType() const
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
attr::Kind getKind() const
unsigned NumArgs
NumArgs - The number of template arguments.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
bool isReturnsTwice(unsigned ID) const
Return true if we know this builtin can return twice.
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
void SetRangeEnd(SourceLocation Loc)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Missing a type from <setjmp.h>
void setType(QualType newType)
Wrapper for source info for pointers.
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
const LangOptions & getLangOpts() const
const BlockDecl * getInnermostBlockDecl() const
Return this DeclContext if it is a BlockDecl.
void setNonTrivialToPrimitiveCopy(bool V)
void setDeletedAsWritten(bool D=true)
static bool isAttributeTargetADefinition(Decl *D)
An implicit 'self' parameter.
SourceRange getExplicitSpecRange() const
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
This class handles loading and caching of source files into memory.
bool isGlobal() const
Determines whether this is a global function.
Defines enum values for all the target-independent builtin functions.
A deduction-guide name (a template-name)
Declaration of a template function.
iterator - Iterate over the decls of a specified declaration name.
ExtInfo withRegParm(unsigned RegParm) const
A class which abstracts out some details necessary for making a call.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
bool hasLinkage() const
Determine whether this declaration has linkage.
void setElaboratedKeywordLoc(SourceLocation Loc)
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result=nullptr, SourceLocation *Loc=nullptr) const
isCXX11ConstantExpr - Return true if this expression is a constant expression in C++11.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool isExternallyVisible() const
QualType getType() const
Return the type wrapped by this type source info.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
bool isBeingDefined() const
Return true if this decl is currently being defined.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
ObjCCompatibleAliasDecl - Represents alias of a class.
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
Decl * ActOnDeclarator(Scope *S, Declarator &D)
CanQualType UnsignedIntTy
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, const ParsedAttributesView &Attrs, SourceLocation EqualLoc, Expr *Val)
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...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
QualType getType() const
Retrieves the type of the base class.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.