Skip to content

Commit

Permalink
Stash
Browse files Browse the repository at this point in the history
Stash

Stash

Stash
  • Loading branch information
zebullon committed Oct 6, 2024
1 parent a2f0785 commit 56fc53e
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 72 deletions.
4 changes: 2 additions & 2 deletions clang/include/clang/AST/Reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ struct TagDataMemberSpec {
std::optional<size_t> 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

Expand Down
148 changes: 89 additions & 59 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -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.
Expand All @@ -15215,15 +15223,16 @@ 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);
ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc,
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,
Expand All @@ -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,
Expand All @@ -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);
Expand All @@ -15270,27 +15282,27 @@ 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<unsigned, std::unique_ptr<CXXMetafunctionExpr::ImplFn>>
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.
bool SuppressDiagnostics = false;

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;
}

Expand All @@ -15300,7 +15312,7 @@ class Sema final : public SemaBase {

private:
Sema &S_;
bool previousEllideAccessControl_{false};
bool previousEllideAccessControl_ {false};
};

///@}
Expand All @@ -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);

Expand All @@ -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,
Expand Down
22 changes: 11 additions & 11 deletions clang/lib/AST/ComputeDependence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 56fc53e

Please sign in to comment.