Author: Thorsten Date: 2020-11-16T14:10:19-05:00 New Revision: 41b65f166b51760f77d0f9e465b3858f46e101f0
URL: https://github.com/llvm/llvm-project/commit/41b65f166b51760f77d0f9e465b3858f46e101f0 DIFF: https://github.com/llvm/llvm-project/commit/41b65f166b51760f77d0f9e465b3858f46e101f0.diff LOG: Convert ConstexprKind from Specifiers.h to a scoped enum; NFC Added: Modified: clang/include/clang/AST/Decl.h clang/include/clang/AST/DeclCXX.h clang/include/clang/Basic/Specifiers.h clang/include/clang/Sema/DeclSpec.h clang/lib/AST/Decl.cpp clang/lib/AST/DeclCXX.cpp clang/lib/Parse/ParseDecl.cpp clang/lib/Parse/ParseExprCXX.cpp clang/lib/Sema/DeclSpec.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaLambda.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/SemaType.cpp clang/lib/Serialization/ASTWriterDecl.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 71896c0db086..7f6f143aa866 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -1978,7 +1978,7 @@ class FunctionDecl : public DeclaratorDecl, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified = false, bool hasWrittenPrototype = true, - ConstexprSpecKind ConstexprKind = CSK_unspecified, + ConstexprSpecKind ConstexprKind = ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause = nullptr) { DeclarationNameInfo NameInfo(N, NLoc); return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, SC, @@ -2230,19 +2230,19 @@ class FunctionDecl : public DeclaratorDecl, /// Whether this is a (C++11) constexpr function or constexpr constructor. bool isConstexpr() const { - return FunctionDeclBits.ConstexprKind != CSK_unspecified; + return getConstexprKind() != ConstexprSpecKind::Unspecified; } void setConstexprKind(ConstexprSpecKind CSK) { - FunctionDeclBits.ConstexprKind = CSK; + FunctionDeclBits.ConstexprKind = static_cast<uint64_t>(CSK); } ConstexprSpecKind getConstexprKind() const { return static_cast<ConstexprSpecKind>(FunctionDeclBits.ConstexprKind); } bool isConstexprSpecified() const { - return FunctionDeclBits.ConstexprKind == CSK_constexpr; + return getConstexprKind() == ConstexprSpecKind::Constexpr; } bool isConsteval() const { - return FunctionDeclBits.ConstexprKind == CSK_consteval; + return getConstexprKind() == ConstexprSpecKind::Consteval; } /// Whether the instantiation of this function is pending. diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 496caf871a91..36f42c06a300 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -1887,7 +1887,7 @@ class CXXDeductionGuideDecl : public FunctionDecl { const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation) : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo, - SC_None, false, CSK_unspecified), + SC_None, false, ConstexprSpecKind::Unspecified), ExplicitSpec(ES) { if (EndLocation.isValid()) setRangeEnd(EndLocation); diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h index 41537672283d..03de6ea6a434 100644 --- a/clang/include/clang/Basic/Specifiers.h +++ b/clang/include/clang/Basic/Specifiers.h @@ -29,12 +29,7 @@ namespace clang { }; /// Define the kind of constexpr specifier. - enum ConstexprSpecKind { - CSK_unspecified, - CSK_constexpr, - CSK_consteval, - CSK_constinit - }; + enum class ConstexprSpecKind { Unspecified, Constexpr, Consteval, Constinit }; /// Specifies the width of a type, e.g., short, long, or long long. enum class TypeSpecifierWidth { Unspecified, Short, Long, LongLong }; diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index 6a961bc026b0..d2acafc2e4b3 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -431,8 +431,10 @@ class DeclSpec { TypeQualifiers(TQ_unspecified), FS_inline_specified(false), FS_forceinline_specified(false), FS_virtual_specified(false), FS_noreturn_specified(false), Friend_specified(false), - ConstexprSpecifier(CSK_unspecified), FS_explicit_specifier(), - Attrs(attrFactory), writtenBS(), ObjCQualifiers(nullptr) {} + ConstexprSpecifier( + static_cast<unsigned>(ConstexprSpecKind::Unspecified)), + FS_explicit_specifier(), Attrs(attrFactory), writtenBS(), + ObjCQualifiers(nullptr) {} // storage-class-specifier SCS getStorageClassSpec() const { return (SCS)StorageClassSpec; } @@ -755,11 +757,11 @@ class DeclSpec { SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; } bool hasConstexprSpecifier() const { - return ConstexprSpecifier != CSK_unspecified; + return getConstexprSpecifier() != ConstexprSpecKind::Unspecified; } void ClearConstexprSpec() { - ConstexprSpecifier = CSK_unspecified; + ConstexprSpecifier = static_cast<unsigned>(ConstexprSpecKind::Unspecified); ConstexprLoc = SourceLocation(); } diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 8960d924d3fa..f0c925f9cdf9 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2834,7 +2834,7 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, FunctionDeclBits.HasDefaultedFunctionInfo = false; FunctionDeclBits.HasImplicitReturnZero = false; FunctionDeclBits.IsLateTemplateParsed = false; - FunctionDeclBits.ConstexprKind = ConstexprKind; + FunctionDeclBits.ConstexprKind = static_cast<uint64_t>(ConstexprKind); FunctionDeclBits.InstantiationIsPending = false; FunctionDeclBits.UsesSEHTry = false; FunctionDeclBits.UsesFPIntrin = false; @@ -4827,9 +4827,9 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, } FunctionDecl *FunctionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) FunctionDecl(Function, C, nullptr, SourceLocation(), - DeclarationNameInfo(), QualType(), nullptr, - SC_None, false, CSK_unspecified, nullptr); + return new (C, ID) FunctionDecl( + Function, C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), + nullptr, SC_None, false, ConstexprSpecKind::Unspecified, nullptr); } BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 9f8248722002..16eb8206dba2 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -2187,10 +2187,10 @@ CXXMethodDecl *CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD, } CXXMethodDecl *CXXMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) CXXMethodDecl( - CXXMethod, C, nullptr, SourceLocation(), DeclarationNameInfo(), - QualType(), nullptr, SC_None, false, CSK_unspecified, SourceLocation(), - nullptr); + return new (C, ID) + CXXMethodDecl(CXXMethod, C, nullptr, SourceLocation(), + DeclarationNameInfo(), QualType(), nullptr, SC_None, false, + ConstexprSpecKind::Unspecified, SourceLocation(), nullptr); } CXXMethodDecl *CXXMethodDecl::getDevirtualizedMethod(const Expr *Base, @@ -2589,10 +2589,10 @@ CXXConstructorDecl *CXXConstructorDecl::CreateDeserialized(ASTContext &C, unsigned Extra = additionalSizeToAlloc<InheritedConstructor, ExplicitSpecifier>( isInheritingConstructor, hasTraillingExplicit); - auto *Result = new (C, ID, Extra) - CXXConstructorDecl(C, nullptr, SourceLocation(), DeclarationNameInfo(), - QualType(), nullptr, ExplicitSpecifier(), false, false, - CSK_unspecified, InheritedConstructor(), nullptr); + auto *Result = new (C, ID, Extra) CXXConstructorDecl( + C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr, + ExplicitSpecifier(), false, false, ConstexprSpecKind::Unspecified, + InheritedConstructor(), nullptr); Result->setInheritingConstructor(isInheritingConstructor); Result->CXXConstructorDeclBits.HasTrailingExplicitSpecifier = hasTraillingExplicit; @@ -2730,10 +2730,9 @@ void CXXDestructorDecl::anchor() {} CXXDestructorDecl * CXXDestructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) - CXXDestructorDecl(C, nullptr, SourceLocation(), DeclarationNameInfo(), - QualType(), nullptr, false, false, CSK_unspecified, - nullptr); + return new (C, ID) CXXDestructorDecl( + C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr, + false, false, ConstexprSpecKind::Unspecified, nullptr); } CXXDestructorDecl *CXXDestructorDecl::Create( @@ -2766,7 +2765,8 @@ CXXConversionDecl * CXXConversionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { return new (C, ID) CXXConversionDecl( C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr, - false, ExplicitSpecifier(), CSK_unspecified, SourceLocation(), nullptr); + false, ExplicitSpecifier(), ConstexprSpecKind::Unspecified, + SourceLocation(), nullptr); } CXXConversionDecl *CXXConversionDecl::Create( diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 79392f6bdb48..277a67f3513f 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -2438,7 +2438,7 @@ void Parser::ParseSpecifierQualifierList(DeclSpec &DS, AccessSpecifier AS, // Issue diagnostic and remove constexpr specifier if present. if (DS.hasConstexprSpecifier() && DSC != DeclSpecContext::DSC_condition) { Diag(DS.getConstexprSpecLoc(), diag::err_typename_invalid_constexpr) - << DS.getConstexprSpecifier(); + << static_cast<int>(DS.getConstexprSpecifier()); DS.ClearConstexprSpec(); } } @@ -3679,13 +3679,16 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, // constexpr, consteval, constinit specifiers case tok::kw_constexpr: - isInvalid = DS.SetConstexprSpec(CSK_constexpr, Loc, PrevSpec, DiagID); + isInvalid = DS.SetConstexprSpec(ConstexprSpecKind::Constexpr, Loc, + PrevSpec, DiagID); break; case tok::kw_consteval: - isInvalid = DS.SetConstexprSpec(CSK_consteval, Loc, PrevSpec, DiagID); + isInvalid = DS.SetConstexprSpec(ConstexprSpecKind::Consteval, Loc, + PrevSpec, DiagID); break; case tok::kw_constinit: - isInvalid = DS.SetConstexprSpec(CSK_constinit, Loc, PrevSpec, DiagID); + isInvalid = DS.SetConstexprSpec(ConstexprSpecKind::Constinit, Loc, + PrevSpec, DiagID); break; // type-specifier diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 19c226a21bc1..96df2c932bea 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -1206,7 +1206,8 @@ addConstexprToLambdaDeclSpecifier(Parser &P, SourceLocation ConstexprLoc, : diag::warn_cxx14_compat_constexpr_on_lambda); const char *PrevSpec = nullptr; unsigned DiagID = 0; - DS.SetConstexprSpec(CSK_constexpr, ConstexprLoc, PrevSpec, DiagID); + DS.SetConstexprSpec(ConstexprSpecKind::Constexpr, ConstexprLoc, PrevSpec, + DiagID); assert(PrevSpec == nullptr && DiagID == 0 && "Constexpr cannot have been set previously!"); } @@ -1219,7 +1220,8 @@ static void addConstevalToLambdaDeclSpecifier(Parser &P, P.Diag(ConstevalLoc, diag::warn_cxx20_compat_consteval); const char *PrevSpec = nullptr; unsigned DiagID = 0; - DS.SetConstexprSpec(CSK_consteval, ConstevalLoc, PrevSpec, DiagID); + DS.SetConstexprSpec(ConstexprSpecKind::Consteval, ConstevalLoc, PrevSpec, + DiagID); if (DiagID != 0) P.Diag(ConstevalLoc, DiagID) << PrevSpec; } diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 7cef6553237e..93685172b2b6 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -588,10 +588,14 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T, const char *DeclSpec::getSpecifierName(ConstexprSpecKind C) { switch (C) { - case CSK_unspecified: return "unspecified"; - case CSK_constexpr: return "constexpr"; - case CSK_consteval: return "consteval"; - case CSK_constinit: return "constinit"; + case ConstexprSpecKind::Unspecified: + return "unspecified"; + case ConstexprSpecKind::Constexpr: + return "constexpr"; + case ConstexprSpecKind::Consteval: + return "consteval"; + case ConstexprSpecKind::Constinit: + return "constinit"; } llvm_unreachable("Unknown ConstexprSpecKind"); } @@ -1085,10 +1089,10 @@ bool DeclSpec::setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, bool DeclSpec::SetConstexprSpec(ConstexprSpecKind ConstexprKind, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID) { - if (getConstexprSpecifier() != CSK_unspecified) + if (getConstexprSpecifier() != ConstexprSpecKind::Unspecified) return BadSpecifier(ConstexprKind, getConstexprSpecifier(), PrevSpec, DiagID); - ConstexprSpecifier = ConstexprKind; + ConstexprSpecifier = static_cast<unsigned>(ConstexprKind); ConstexprLoc = Loc; return false; } @@ -1354,11 +1358,11 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) { else if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32) S.Diag(TSTLoc, diag::warn_cxx98_compat_unicode_type) << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t"); - if (getConstexprSpecifier() == CSK_constexpr) + if (getConstexprSpecifier() == ConstexprSpecKind::Constexpr) S.Diag(ConstexprLoc, diag::warn_cxx98_compat_constexpr); - else if (getConstexprSpecifier() == CSK_consteval) + else if (getConstexprSpecifier() == ConstexprSpecKind::Consteval) S.Diag(ConstexprLoc, diag::warn_cxx20_compat_consteval); - else if (getConstexprSpecifier() == CSK_constinit) + else if (getConstexprSpecifier() == ConstexprSpecKind::Constinit) S.Diag(ConstexprLoc, diag::warn_cxx20_compat_constinit); // C++ [class.friend]p6: // No storage-class-specifier shall appear in the decl-specifier-seq diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 3b940a017a02..19501f7f0d52 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4599,10 +4599,10 @@ Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, if (Tag) Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_tag) << GetDiagnosticTypeSpecifierID(DS.getTypeSpecType()) - << DS.getConstexprSpecifier(); + << static_cast<int>(DS.getConstexprSpecifier()); else Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_wrong_decl_kind) - << DS.getConstexprSpecifier(); + << static_cast<int>(DS.getConstexprSpecifier()); // Don't emit warnings after this error. return TagD; } @@ -6082,7 +6082,7 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, << getLangOpts().CPlusPlus17; if (D.getDeclSpec().hasConstexprSpecifier()) Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr) - << 1 << D.getDeclSpec().getConstexprSpecifier(); + << 1 << static_cast<int>(D.getDeclSpec().getConstexprSpecifier()); if (D.getName().Kind != UnqualifiedIdKind::IK_Identifier) { if (D.getName().Kind == UnqualifiedIdKind::IK_DeductionGuideName) @@ -7124,16 +7124,16 @@ NamedDecl *Sema::ActOnVariableDeclarator( } switch (D.getDeclSpec().getConstexprSpecifier()) { - case CSK_unspecified: + case ConstexprSpecKind::Unspecified: break; - case CSK_consteval: + case ConstexprSpecKind::Consteval: Diag(D.getDeclSpec().getConstexprSpecLoc(), - diag::err_constexpr_wrong_decl_kind) - << D.getDeclSpec().getConstexprSpecifier(); + diag::err_constexpr_wrong_decl_kind) + << static_cast<int>(D.getDeclSpec().getConstexprSpecifier()); LLVM_FALLTHROUGH; - case CSK_constexpr: + case ConstexprSpecKind::Constexpr: NewVD->setConstexpr(true); MaybeAddCUDAConstantAttr(NewVD); // C++1z [dcl.spec.constexpr]p1: @@ -7145,7 +7145,7 @@ NamedDecl *Sema::ActOnVariableDeclarator( NewVD->setImplicitlyInline(); break; - case CSK_constinit: + case ConstexprSpecKind::Constinit: if (!NewVD->hasGlobalStorage()) Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_constinit_local_variable); @@ -8424,7 +8424,7 @@ static FunctionDecl *CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, NewFD = FunctionDecl::Create(SemaRef.Context, DC, D.getBeginLoc(), NameInfo, R, TInfo, SC, isInline, HasPrototype, - CSK_unspecified, + ConstexprSpecKind::Unspecified, /*TrailingRequiresClause=*/nullptr); if (D.isInvalidType()) NewFD->setInvalidDecl(); @@ -8435,11 +8435,11 @@ static FunctionDecl *CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, ExplicitSpecifier ExplicitSpecifier = D.getDeclSpec().getExplicitSpecifier(); ConstexprSpecKind ConstexprKind = D.getDeclSpec().getConstexprSpecifier(); - if (ConstexprKind == CSK_constinit) { + if (ConstexprKind == ConstexprSpecKind::Constinit) { SemaRef.Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_constexpr_wrong_decl_kind) - << ConstexprKind; - ConstexprKind = CSK_unspecified; + << static_cast<int>(ConstexprKind); + ConstexprKind = ConstexprSpecKind::Unspecified; D.getMutableDeclSpec().ClearConstexprSpec(); } Expr *TrailingRequiresClause = D.getTrailingRequiresClause(); @@ -9103,8 +9103,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, } } - if (ConstexprSpecKind ConstexprKind = - D.getDeclSpec().getConstexprSpecifier()) { + ConstexprSpecKind ConstexprKind = D.getDeclSpec().getConstexprSpecifier(); + if (ConstexprKind != ConstexprSpecKind::Unspecified) { // C++11 [dcl.constexpr]p2: constexpr functions and constexpr constructors // are implicitly inline. NewFD->setImplicitlyInline(); @@ -9113,15 +9113,18 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // be either constructors or to return a literal type. Therefore, // destructors cannot be declared constexpr. if (isa<CXXDestructorDecl>(NewFD) && - (!getLangOpts().CPlusPlus20 || ConstexprKind == CSK_consteval)) { + (!getLangOpts().CPlusPlus20 || + ConstexprKind == ConstexprSpecKind::Consteval)) { Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_constexpr_dtor) - << ConstexprKind; - NewFD->setConstexprKind(getLangOpts().CPlusPlus20 ? CSK_unspecified : CSK_constexpr); + << static_cast<int>(ConstexprKind); + NewFD->setConstexprKind(getLangOpts().CPlusPlus20 + ? ConstexprSpecKind::Unspecified + : ConstexprSpecKind::Constexpr); } // C++20 [dcl.constexpr]p2: An allocation function, or a // deallocation function shall not be declared with the consteval // specifier. - if (ConstexprKind == CSK_consteval && + if (ConstexprKind == ConstexprSpecKind::Consteval && (NewFD->getOverloadedOperator() == OO_New || NewFD->getOverloadedOperator() == OO_Array_New || NewFD->getOverloadedOperator() == OO_Delete || @@ -9129,7 +9132,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_consteval_decl_kind) << NewFD; - NewFD->setConstexprKind(CSK_constexpr); + NewFD->setConstexprKind(ConstexprSpecKind::Constexpr); } } @@ -10988,7 +10991,7 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) { Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_main) << FD->isConsteval() << FixItHint::CreateRemoval(DS.getConstexprSpecLoc()); - FD->setConstexprKind(CSK_unspecified); + FD->setConstexprKind(ConstexprSpecKind::Unspecified); } if (getLangOpts().OpenCL) { @@ -13514,7 +13517,7 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { << getLangOpts().CPlusPlus17; if (DS.hasConstexprSpecifier()) Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr) - << 0 << D.getDeclSpec().getConstexprSpecifier(); + << 0 << static_cast<int>(D.getDeclSpec().getConstexprSpecifier()); DiagnoseFunctionSpecifiers(DS); diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index a2b7e8dbf57c..6a414e257447 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -8176,8 +8176,8 @@ NamedDecl * Sema::DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II, NewFD = FunctionDecl::Create( FD->getASTContext(), FD->getDeclContext(), Loc, Loc, DeclarationName(II), FD->getType(), FD->getTypeSourceInfo(), SC_None, - false /*isInlineSpecified*/, FD->hasPrototype(), CSK_unspecified, - FD->getTrailingRequiresClause()); + false /*isInlineSpecified*/, FD->hasPrototype(), + ConstexprSpecKind::Unspecified, FD->getTrailingRequiresClause()); NewD = NewFD; if (FD->getQualifier()) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c90a71626ea7..d31d2e32547a 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -655,7 +655,8 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, // contain the constexpr specifier. if (New->getConstexprKind() != Old->getConstexprKind()) { Diag(New->getLocation(), diag::err_constexpr_redecl_mismatch) - << New << New->getConstexprKind() << Old->getConstexprKind(); + << New << static_cast<int>(New->getConstexprKind()) + << static_cast<int>(Old->getConstexprKind()); Diag(Old->getLocation(), diag::note_previous_declaration); Invalid = true; } else if (!Old->getMostRecentDecl()->isInlined() && New->isInlined() && @@ -1642,7 +1643,7 @@ static bool CheckConstexprDestructorSubobjects(Sema &SemaRef, if (Kind == Sema::CheckConstexprKind::Diagnose) { SemaRef.Diag(DD->getLocation(), diag::err_constexpr_dtor_subobject) - << DD->getConstexprKind() << !FD + << static_cast<int>(DD->getConstexprKind()) << !FD << (FD ? FD->getDeclName() : DeclarationName()) << T; SemaRef.Diag(Loc, diag::note_constexpr_dtor_subobject) << !FD << (FD ? FD->getDeclName() : DeclarationName()) << T; @@ -7368,9 +7369,10 @@ bool Sema::CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD, // If a function is explicitly defaulted on its first declaration, it is // implicitly considered to be constexpr if the implicit declaration // would be. - MD->setConstexprKind( - Constexpr ? (MD->isConsteval() ? CSK_consteval : CSK_constexpr) - : CSK_unspecified); + MD->setConstexprKind(Constexpr ? (MD->isConsteval() + ? ConstexprSpecKind::Consteval + : ConstexprSpecKind::Constexpr) + : ConstexprSpecKind::Unspecified); if (!Type->hasExceptionSpec()) { // C++2a [except.spec]p3: @@ -8462,7 +8464,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *FD, // FIXME: Only applying this to the first declaration seems problematic, as // simple reorderings can affect the meaning of the program. if (First && !FD->isConstexpr() && Info.Constexpr) - FD->setConstexprKind(CSK_constexpr); + FD->setConstexprKind(ConstexprSpecKind::Constexpr); // C++2a [except.spec]p3: // If a declaration of a function does not have a noexcept-specifier @@ -12974,7 +12976,8 @@ CXXConstructorDecl *Sema::DeclareImplicitDefaultConstructor( Context, ClassDecl, ClassLoc, NameInfo, /*Type*/ QualType(), /*TInfo=*/nullptr, ExplicitSpecifier(), /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr ? CSK_constexpr : CSK_unspecified); + Constexpr ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified); DefaultCon->setAccess(AS_public); DefaultCon->setDefaulted(); @@ -13095,7 +13098,7 @@ Sema::findInheritingConstructor(SourceLocation Loc, Context, Derived, UsingLoc, NameInfo, TInfo->getType(), TInfo, BaseCtor->getExplicitSpecifier(), /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr ? BaseCtor->getConstexprKind() : CSK_unspecified, + Constexpr ? BaseCtor->getConstexprKind() : ConstexprSpecKind::Unspecified, InheritedConstructor(Shadow, BaseCtor), BaseCtor->getTrailingRequiresClause()); if (Shadow->isInvalidDecl()) @@ -13252,7 +13255,8 @@ CXXDestructorDecl *Sema::DeclareImplicitDestructor(CXXRecordDecl *ClassDecl) { CXXDestructorDecl::Create(Context, ClassDecl, ClassLoc, NameInfo, QualType(), nullptr, /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr ? CSK_constexpr : CSK_unspecified); + Constexpr ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified); Destructor->setAccess(AS_public); Destructor->setDefaulted(); @@ -13887,7 +13891,8 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) { CXXMethodDecl *CopyAssignment = CXXMethodDecl::Create( Context, ClassDecl, ClassLoc, NameInfo, QualType(), /*TInfo=*/nullptr, /*StorageClass=*/SC_None, - /*isInline=*/true, Constexpr ? CSK_constexpr : CSK_unspecified, + /*isInline=*/true, + Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified, SourceLocation()); CopyAssignment->setAccess(AS_public); CopyAssignment->setDefaulted(); @@ -14212,7 +14217,8 @@ CXXMethodDecl *Sema::DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl) { CXXMethodDecl *MoveAssignment = CXXMethodDecl::Create( Context, ClassDecl, ClassLoc, NameInfo, QualType(), /*TInfo=*/nullptr, /*StorageClass=*/SC_None, - /*isInline=*/true, Constexpr ? CSK_constexpr : CSK_unspecified, + /*isInline=*/true, + Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified, SourceLocation()); MoveAssignment->setAccess(AS_public); MoveAssignment->setDefaulted(); @@ -14596,7 +14602,8 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor( ExplicitSpecifier(), /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr ? CSK_constexpr : CSK_unspecified); + Constexpr ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified); CopyConstructor->setAccess(AS_public); CopyConstructor->setDefaulted(); @@ -14729,7 +14736,8 @@ CXXConstructorDecl *Sema::DeclareImplicitMoveConstructor( ExplicitSpecifier(), /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr ? CSK_constexpr : CSK_unspecified); + Constexpr ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified); MoveConstructor->setAccess(AS_public); MoveConstructor->setDefaulted(); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3dedb3eb0c06..0a25720c0f7b 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -18973,7 +18973,7 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) { S.Context, FD->getDeclContext(), Loc, Loc, FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(), SC_None, false /*isInlineSpecified*/, FD->hasPrototype(), - /*ConstexprKind*/ CSK_unspecified); + /*ConstexprKind*/ ConstexprSpecKind::Unspecified); if (FD->getQualifier()) NewFD->setQualifierInfo(FD->getQualifierLoc()); diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index 9e45709551c6..c2eb663147c2 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -1439,7 +1439,8 @@ static void addFunctionPointerConversion(Sema &S, SourceRange IntroducerRange, S.Context, Class, Loc, DeclarationNameInfo(ConversionName, Loc, ConvNameLoc), ConvTy, ConvTSI, /*isInline=*/true, ExplicitSpecifier(), - S.getLangOpts().CPlusPlus17 ? CSK_constexpr : CSK_unspecified, + S.getLangOpts().CPlusPlus17 ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified, CallOperator->getBody()->getEndLoc()); Conversion->setAccess(AS_public); Conversion->setImplicit(true); @@ -1478,7 +1479,8 @@ static void addFunctionPointerConversion(Sema &S, SourceRange IntroducerRange, CXXMethodDecl *Invoke = CXXMethodDecl::Create( S.Context, Class, Loc, DeclarationNameInfo(InvokerName, Loc), InvokerFunctionTy, CallOperator->getTypeSourceInfo(), SC_Static, - /*isInline=*/true, CSK_unspecified, CallOperator->getBody()->getEndLoc()); + /*isInline=*/true, ConstexprSpecKind::Unspecified, + CallOperator->getBody()->getEndLoc()); for (unsigned I = 0, N = CallOperator->getNumParams(); I != N; ++I) InvokerParams[I]->setOwningFunction(Invoke); Invoke->setParams(InvokerParams); @@ -1545,7 +1547,7 @@ static void addBlockPointerConversion(Sema &S, CXXConversionDecl *Conversion = CXXConversionDecl::Create( S.Context, Class, Loc, DeclarationNameInfo(Name, Loc, NameLoc), ConvTy, S.Context.getTrivialTypeSourceInfo(ConvTy, Loc), - /*isInline=*/true, ExplicitSpecifier(), CSK_unspecified, + /*isInline=*/true, ExplicitSpecifier(), ConstexprSpecKind::Unspecified, CallOperator->getBody()->getEndLoc()); Conversion->setAccess(AS_public); Conversion->setImplicit(true); @@ -1909,8 +1911,8 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, CallOperator->setConstexprKind( CheckConstexprFunctionDefinition(CallOperator, CheckConstexprKind::CheckValid) - ? CSK_constexpr - : CSK_unspecified); + ? ConstexprSpecKind::Constexpr + : ConstexprSpecKind::Unspecified); } // Emit delayed shadowing warnings now that the full capture list is known. diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index a8352c1e7f20..6bb63fc4f1fe 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -5902,8 +5902,10 @@ void Sema::ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope( TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType FType = TInfo->getType(); - bool IsConstexpr = D.getDeclSpec().getConstexprSpecifier() == CSK_constexpr; - bool IsConsteval = D.getDeclSpec().getConstexprSpecifier() == CSK_consteval; + bool IsConstexpr = + D.getDeclSpec().getConstexprSpecifier() == ConstexprSpecKind::Constexpr; + bool IsConsteval = + D.getDeclSpec().getConstexprSpecifier() == ConstexprSpecKind::Consteval; for (auto *Candidate : Lookup) { auto *CandidateDecl = Candidate->getUnderlyingDecl(); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 6c4475f6a624..3fb2e654ea85 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -5549,7 +5549,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // C++0x [dcl.constexpr]p9: // A constexpr specifier used in an object declaration declares the object // as const. - if (D.getDeclSpec().getConstexprSpecifier() == CSK_constexpr && + if (D.getDeclSpec().getConstexprSpecifier() == ConstexprSpecKind::Constexpr && T->isObjectType()) T.addConst(); diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 47ed44898f49..2cb44bf9038b 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -557,7 +557,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) { Record.push_back(D->isDefaulted()); Record.push_back(D->isExplicitlyDefaulted()); Record.push_back(D->hasImplicitReturnZero()); - Record.push_back(D->getConstexprKind()); + Record.push_back(static_cast<uint64_t>(D->getConstexprKind())); Record.push_back(D->usesSEHTry()); Record.push_back(D->hasSkippedBody()); Record.push_back(D->isMultiVersion()); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits