From 56fc53e4b073dedcf406595433d24c06b99988f1 Mon Sep 17 00:00:00 2001 From: zebullon Date: Sun, 6 Oct 2024 16:39:22 +0900 Subject: [PATCH] Stash Stash Stash Stash --- clang/include/clang/AST/Reflection.h | 4 +- clang/include/clang/Sema/Sema.h | 148 ++++++++++++++++----------- clang/lib/AST/ComputeDependence.cpp | 22 ++-- 3 files changed, 102 insertions(+), 72 deletions(-) diff --git a/clang/include/clang/AST/Reflection.h b/clang/include/clang/AST/Reflection.h index e31df466ddeeb2..fde146b47d4240 100644 --- a/clang/include/clang/AST/Reflection.h +++ b/clang/include/clang/AST/Reflection.h @@ -118,8 +118,8 @@ struct TagDataMemberSpec { std::optional BitWidth; bool NoUniqueAddress; - bool operator==(TagDataMemberSpec const &Rhs) const; - bool operator!=(TagDataMemberSpec const &Rhs) const; + bool operator==(TagDataMemberSpec const& Rhs) const; + bool operator!=(TagDataMemberSpec const& Rhs) const; }; } // namespace clang diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 828da165022cbf..79124386f7fd33 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4888,9 +4888,12 @@ class Sema final : public SemaBase { SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident); - Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, - SourceLocation AliasLoc, IdentifierInfo *Alias, - CXXScopeSpec &SS, SourceLocation IdentLoc, + Decl *ActOnNamespaceAliasDef(Scope *CurScope, + SourceLocation NamespaceLoc, + SourceLocation AliasLoc, + IdentifierInfo *Alias, + CXXScopeSpec &SS, + SourceLocation IdentLoc, NamedDecl *ND); /// Remove decls we can't actually see from a lookup being used to declare @@ -8567,11 +8570,12 @@ class Sema final : public SemaBase { Scope *BodyScope); void ActOnFinishRequiresExpr(); concepts::Requirement *ActOnSimpleRequirement(Expr *E); - concepts::Requirement * - ActOnTypeRequirement(SourceLocation TypenameKWLoc, CXXScopeSpec &SS, - SourceLocation NameLoc, const IdentifierInfo *TypeName, - TemplateIdAnnotation *TemplateId, - CXXSpliceSpecifierExpr *SpliceExpr); + concepts::Requirement *ActOnTypeRequirement(SourceLocation TypenameKWLoc, + CXXScopeSpec &SS, + SourceLocation NameLoc, + const IdentifierInfo *TypeName, + TemplateIdAnnotation *TemplateId, + CXXSpliceSpecifierExpr *SpliceExpr); concepts::Requirement *ActOnCompoundRequirement(Expr *E, SourceLocation NoexceptLoc); concepts::Requirement *ActOnCompoundRequirement( @@ -15160,12 +15164,12 @@ class Sema final : public SemaBase { bool suppressDiagnostics() const { return SuppressDiagnostics; } ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, - SourceLocation TemplateKWLoc, CXXScopeSpec &SS, - UnqualifiedId &Id); + SourceLocation TemplateKWLoc, + CXXScopeSpec &SS, UnqualifiedId &Id); ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, TypeResult T); - ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, SourceLocation ArgLoc, - Decl *D); + ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, + SourceLocation ArgLoc, Decl *D); ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, ParsedTemplateArgument Template); ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, CXXSpliceExpr *E); @@ -15179,10 +15183,13 @@ class Sema final : public SemaBase { SourceLocation LSpliceLoc, Expr *Operand, SourceLocation RSpliceLoc); - TypeResult ActOnCXXSpliceExpectingType(SourceLocation LSplice, Expr *Operand, - SourceLocation RSplice, bool Complain); + TypeResult ActOnCXXSpliceExpectingType(SourceLocation LSplice, + Expr *Operand, + SourceLocation RSplice, + bool Complain); ExprResult ActOnCXXSpliceExpectingExpr(SourceLocation TemplateKWLoc, - SourceLocation LSplice, Expr *Operand, + SourceLocation LSplice, + Expr *Operand, SourceLocation RSplice, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, @@ -15198,13 +15205,14 @@ class Sema final : public SemaBase { ParsedTemplateArgument ActOnTemplateSpliceSpecifierArgument(CXXSpliceSpecifierExpr *Splice); - bool - ActOnCXXNestedNameSpecifierReflectionSplice(CXXScopeSpec &SS, - CXXSpliceSpecifierExpr *Splice, - SourceLocation ColonColonLoc); + bool ActOnCXXNestedNameSpecifierReflectionSplice( + CXXScopeSpec &SS, CXXSpliceSpecifierExpr *Splice, + SourceLocation ColonColonLoc); - ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, - tok::TokenKind OpKind, CXXSpliceExpr *RHS, + ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, + SourceLocation OpLoc, + tok::TokenKind OpKind, + CXXSpliceExpr *RHS, SourceLocation TemplateKWLoc); // Reflection of non-expression operands. @@ -15215,6 +15223,7 @@ class Sema final : public SemaBase { ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc, SourceLocation OperandLoc, TemplateName Template); + ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc, ParsedAttr *A); // Reflection of expression operands. ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc, Expr *E); @@ -15222,8 +15231,8 @@ class Sema final : public SemaBase { UnresolvedLookupExpr *E); ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc, SubstNonTypeTemplateParmExpr *E); - ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc, CXXSpliceExpr *E); - ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc, ParsedAttr *A); + ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc, + CXXSpliceExpr *E); ExprResult BuildCXXMetafunctionExpr(SourceLocation KwLoc, SourceLocation LParenLoc, @@ -15236,11 +15245,13 @@ class Sema final : public SemaBase { SourceLocation LSpliceLoc, Expr *Operand, SourceLocation RSpliceLoc); - QualType BuildReflectionSpliceType(SourceLocation LSplice, Expr *Operand, - SourceLocation RSplice, bool Complain); + QualType BuildReflectionSpliceType(SourceLocation LSplice, + Expr *Operand, + SourceLocation RSplice, + bool Complain); QualType BuildReflectionSpliceTypeLoc(TypeLocBuilder &TLB, - SourceLocation LSpliceLoc, Expr *E, - SourceLocation RSpliceLoc, + SourceLocation LSpliceLoc, + Expr *E, SourceLocation RSpliceLoc, bool Complain); ExprResult BuildReflectionSpliceExpr(SourceLocation TemplateKWLoc, SourceLocation LSplice, Expr *Operand, @@ -15257,7 +15268,8 @@ class Sema final : public SemaBase { ExprResult BuildMemberReferenceExpr(Scope *S, Expr *Base, SourceLocation OpLoc, - tok::TokenKind OpKind, CXXSpliceExpr *RHS, + tok::TokenKind OpKind, + CXXSpliceExpr *RHS, SourceLocation TemplateKWLoc); ExprResult BuildDependentMemberSpliceExpr(Expr *Base, SourceLocation OpLoc, bool IsArrow, CXXSpliceExpr *RHS); @@ -15270,10 +15282,10 @@ class Sema final : public SemaBase { // Lambdas having bound references to this Sema object, used to evaluate // metafunction (C++26, P2996) at constant evaluation time. llvm::SmallDenseMap> - MetafunctionImplCbs; + MetafunctionImplCbs; // Whether to elide access control when checking access to class members. - bool EllideAccessControl{false}; + bool EllideAccessControl {false}; // Used to check whether a template substitution is valid without producing // a diagnostic. @@ -15281,16 +15293,16 @@ class Sema final : public SemaBase { class AccessControlScopeGuard final { public: - AccessControlScopeGuard(const AccessControlScopeGuard &) = delete; - AccessControlScopeGuard(AccessControlScopeGuard &&) = delete; - AccessControlScopeGuard & - operator=(const AccessControlScopeGuard &) = delete; - AccessControlScopeGuard &operator=(AccessControlScopeGuard &&) = delete; + AccessControlScopeGuard(const AccessControlScopeGuard&) = delete; + AccessControlScopeGuard(AccessControlScopeGuard&&) = delete; + AccessControlScopeGuard& operator=(const AccessControlScopeGuard&) = delete; + AccessControlScopeGuard& operator=(AccessControlScopeGuard&&) = delete; // Sets EllideAccessControl to the new override value & keeps the // previous one, so we can revert when the scope guard exits explicit AccessControlScopeGuard(Sema &S, bool ellideAccessControlOverride) - : S_{S}, previousEllideAccessControl_{S_.EllideAccessControl} { + : S_{S} + , previousEllideAccessControl_{S_.EllideAccessControl} { S_.EllideAccessControl = ellideAccessControlOverride; } @@ -15300,7 +15312,7 @@ class Sema final : public SemaBase { private: Sema &S_; - bool previousEllideAccessControl_{false}; + bool previousEllideAccessControl_ {false}; }; ///@} @@ -15324,17 +15336,26 @@ class Sema final : public SemaBase { SourceLocation RParenLoc, BuildForRangeKind Kind); - StmtResult ActOnCXXInitListExpansionStmt( - SourceLocation TemplateKWLoc, SourceLocation ForLoc, - SourceLocation LParenLoc, Stmt *Init, Stmt *ExpansionVarStmt, - SourceLocation ColonLoc, CXXExpansionInitListExpr *Range, - SourceLocation RParenLoc, Expr *TParmRef, BuildForRangeKind Kind); - - StmtResult ActOnCXXDestructurableExpansionStmt( - SourceLocation TemplateKWLoc, SourceLocation ForLoc, - SourceLocation LParenLoc, Stmt *Init, Stmt *ExpansionVarStmt, - SourceLocation ColonLoc, Expr *Range, SourceLocation RParenLoc, - Expr *TParmRef, BuildForRangeKind Kind); + StmtResult ActOnCXXInitListExpansionStmt(SourceLocation TemplateKWLoc, + SourceLocation ForLoc, + SourceLocation LParenLoc, Stmt *Init, + Stmt *ExpansionVarStmt, + SourceLocation ColonLoc, + CXXExpansionInitListExpr *Range, + SourceLocation RParenLoc, + Expr *TParmRef, + BuildForRangeKind Kind); + + StmtResult ActOnCXXDestructurableExpansionStmt(SourceLocation TemplateKWLoc, + SourceLocation ForLoc, + SourceLocation LParenLoc, + Stmt *Init, + Stmt *ExpansionVarStmt, + SourceLocation ColonLoc, + Expr *Range, + SourceLocation RParenLoc, + Expr *TParmRef, + BuildForRangeKind Kind); bool ComputeDecompositionExpansionArity(Expr *Range, unsigned &Result); @@ -15350,17 +15371,26 @@ class Sema final : public SemaBase { ExprResult ActOnCXXDestructurableExpansionSelectExpr(Expr *Range, Expr *Idx, bool Constexpr); - StmtResult BuildCXXInitListExpansionStmt( - SourceLocation TemplateKWLoc, SourceLocation ForLoc, - SourceLocation LParenLoc, Stmt *Init, Stmt *ExpansionVarStmt, - SourceLocation ColonLoc, CXXExpansionInitListExpr *Range, - SourceLocation RParenLoc, unsigned TemplateDepth, BuildForRangeKind Kind); - - StmtResult BuildCXXDestructurableExpansionStmt( - SourceLocation TemplateKWLoc, SourceLocation ForLoc, - SourceLocation LParenLoc, Stmt *Init, Stmt *ExpansionVarStmt, - SourceLocation ColonLoc, Expr *Range, SourceLocation RParenLoc, - unsigned TemplateDepth, BuildForRangeKind Kind); + StmtResult BuildCXXInitListExpansionStmt(SourceLocation TemplateKWLoc, + SourceLocation ForLoc, + SourceLocation LParenLoc, Stmt *Init, + Stmt *ExpansionVarStmt, + SourceLocation ColonLoc, + CXXExpansionInitListExpr *Range, + SourceLocation RParenLoc, + unsigned TemplateDepth, + BuildForRangeKind Kind); + + StmtResult BuildCXXDestructurableExpansionStmt(SourceLocation TemplateKWLoc, + SourceLocation ForLoc, + SourceLocation LParenLoc, + Stmt *Init, + Stmt *ExpansionVarStmt, + SourceLocation ColonLoc, + Expr *Range, + SourceLocation RParenLoc, + unsigned TemplateDepth, + BuildForRangeKind Kind); ExprResult BuildCXXExpansionInitList(SourceLocation LBraceLoc, MultiExprArg SubExprs, diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp index e8f59fc272a69d..73327c39b6e741 100644 --- a/clang/lib/AST/ComputeDependence.cpp +++ b/clang/lib/AST/ComputeDependence.cpp @@ -18,7 +18,6 @@ #include "clang/AST/ExprConcepts.h" #include "clang/AST/ExprObjC.h" #include "clang/AST/ExprOpenMP.h" -#include "clang/AST/Reflection.h" #include "clang/Basic/ExceptionSpecificationType.h" #include "llvm/ADT/ArrayRef.h" @@ -471,7 +470,7 @@ ExprDependence clang::computeDependence(ArraySectionExpr *E) { ExprDependence clang::computeDependence(OMPArrayShapingExpr *E) { auto D = E->getBase()->getDependence(); - for (Expr *Dim : E->getDimensions()) + for (Expr *Dim: E->getDimensions()) if (Dim) D |= turnValueToTypeDependence(Dim->getDependence()); return D; @@ -936,7 +935,7 @@ ExprDependence clang::computeDependence(ConceptSpecializationExpr *E, ExprDependence D = ValueDependent ? ExprDependence::Value : ExprDependence::None; auto Res = D | toExprDependence(TA); - if (!ValueDependent && E->getSatisfaction().ContainsErrors) + if(!ValueDependent && E->getSatisfaction().ContainsErrors) Res |= ExprDependence::Error; return Res; } @@ -994,14 +993,15 @@ ExprDependence clang::computeDependence(CXXReflectExpr *E, } ExprDependence clang::computeDependence(CXXMetafunctionExpr *E) { - auto D = ExprDependence::None; - for (unsigned I = 0; I < E->getNumArgs(); ++I) { - Expr *Arg = E->getArg(I); - D |= Arg->getDependence(); - } - return D & ~ExprDependence::UnexpandedPack; + auto D = ExprDependence::None; + for (unsigned I = 0; I < E->getNumArgs(); ++I) { + Expr *Arg = E->getArg(I); + D |= Arg->getDependence(); + } + return D & ~ExprDependence::UnexpandedPack; } + ExprDependence clang::computeDependence(CXXSpliceSpecifierExpr *E) { return E->getOperand()->getDependence(); } @@ -1047,8 +1047,8 @@ ExprDependence clang::computeDependence(CXXExpansionInitListSelectExpr *E) { return D; } -ExprDependence -clang::computeDependence(CXXDestructurableExpansionSelectExpr *E) { +ExprDependence clang::computeDependence( + CXXDestructurableExpansionSelectExpr *E) { auto D = E->getRange()->getDependence() | E->getIdx()->getDependence(); if (D & ExprDependence::Value) D |= ExprDependence::Type;