Skip to content

Commit

Permalink
Rename 'const value' stuff to 'expr result'.
Browse files Browse the repository at this point in the history
Closes issue #47.
  • Loading branch information
katzdm committed Jun 7, 2024
1 parent 43bf5b8 commit b9b286b
Show file tree
Hide file tree
Showing 16 changed files with 113 additions and 113 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/AST/APValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ class APValue {
return const_cast<APValue*>(this)->getReflection();
}
QualType getReflectedType() const;
ConstantExpr *getReflectedConstValueExpr() const;
ConstantExpr *getReflectedExprResult() const;
ValueDecl *getReflectedDecl() const;
const TemplateName getReflectedTemplate() const;
Decl *getReflectedNamespace() const;
Expand Down
6 changes: 3 additions & 3 deletions clang/include/clang/AST/PropertiesBase.td
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ let Class = PropertyTypeCase<ReflectionValue, "RK_type"> in {
value.getAsOpaquePtr());
}]>;
}
let Class = PropertyTypeCase<ReflectionValue, "RK_const_value"> in {
let Class = PropertyTypeCase<ReflectionValue, "RK_expr_result"> in {
def : Property<"value", StmtRef> {
let Read = [{ node.getAsConstValueExpr() }];
let Read = [{ node.getAsExprResult() }];
}
def : Creator<[{
return ReflectionValue(ReflectionValue::RK_const_value, value);
return ReflectionValue(ReflectionValue::RK_expr_result, value);
}]>;
}
let Class = PropertyTypeCase<ReflectionValue, "RK_declaration"> in {
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2954,8 +2954,8 @@ DEF_TRAVERSE_STMT(CXXReflectExpr, {
TRY_TO(TraverseType(Op.getAsType()));
break;
}
case ReflectionValue::RK_const_value: {
TRY_TO(TraverseStmt(Op.getAsConstValueExpr()));
case ReflectionValue::RK_expr_result: {
TRY_TO(TraverseStmt(Op.getAsExprResult()));
break;
}
case ReflectionValue::RK_declaration: {
Expand Down
10 changes: 5 additions & 5 deletions clang/include/clang/AST/Reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class ReflectionValue {
/// QualType.
RK_type = 1,

/// \brief A reflection of an expression that constant evaluates to a
/// prvalue. Corresponds to an object of type ConstantExpr.
RK_const_value = 2,
/// \brief A reflection of the result of an expression. Corresponds to an
/// object of type ConstantExpr.
RK_expr_result = 2,

/// \brief A reflection of an expression referencing an entity (e.g.,
/// variable, function, member function, etc). Corresponds to an object of
Expand Down Expand Up @@ -102,8 +102,8 @@ class ReflectionValue {
QualType getAsType() const;

/// Returns this as an expression.
ConstantExpr *getAsConstValueExpr() const {
assert(getKind() == RK_const_value && "not a constant value");
ConstantExpr *getAsExprResult() const {
assert(getKind() == RK_expr_result && "not an expression result");
return reinterpret_cast<ConstantExpr *>(Entity);
}

Expand Down
10 changes: 5 additions & 5 deletions clang/lib/AST/APValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,10 @@ QualType APValue::getReflectedType() const {
return Refl.getAsType();
}

ConstantExpr *APValue::getReflectedConstValueExpr() const {
ConstantExpr *APValue::getReflectedExprResult() const {
const ReflectionValue &Refl = getReflection();
assert(Refl.getKind() == ReflectionValue::RK_const_value);
return Refl.getAsConstValueExpr();
assert(Refl.getKind() == ReflectionValue::RK_expr_result);
return Refl.getAsExprResult();
}

ValueDecl *APValue::getReflectedDecl() const {
Expand Down Expand Up @@ -999,8 +999,8 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
case ReflectionValue::RK_type:
Repr = "type";
break;
case ReflectionValue::RK_const_value:
Repr = "constant-value";
case ReflectionValue::RK_expr_result:
Repr = "expression-result";
break;
case ReflectionValue::RK_declaration:
Repr = "declaration";
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ComputeDependence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@ ExprDependence clang::computeDependence(CXXReflectExpr *E,
D |= ExprDependence::UnexpandedPack;
return D;
}
case ReflectionValue::RK_const_value:
return Operand.getAsConstValueExpr()->getDependence();
case ReflectionValue::RK_expr_result:
return Operand.getAsExprResult()->getDependence();
case ReflectionValue::RK_declaration: {
ValueDecl *VD = Operand.getAsDecl();
if (VD->getType()->isDependentType())
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ CXXReflectExpr::CXXReflectExpr(const ASTContext &C, QualType T,
CXXReflectExpr::CXXReflectExpr(const ASTContext &C, QualType T,
Expr *Operand)
: Expr(CXXReflectExprClass, T, VK_PRValue, OK_Ordinary),
Ref(ReflectionValue::RK_const_value, Operand) {
Ref(ReflectionValue::RK_expr_result, Operand) {
setDependence(computeDependence(this, C));
}

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15790,8 +15790,8 @@ bool ReflectionEvaluator::VisitCXXReflectExpr(const CXXReflectExpr *E) {
APValue Result(ReflectionValue::RK_type, Ref.getAsType().getAsOpaquePtr());
return Success(Result, E);
}
case ReflectionValue::RK_const_value: {
APValue Result(ReflectionValue::RK_const_value, Ref.getAsConstValueExpr());
case ReflectionValue::RK_expr_result: {
APValue Result(ReflectionValue::RK_expr_result, Ref.getAsExprResult());
return Success(Result, E);
}
case ReflectionValue::RK_declaration: {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4684,9 +4684,9 @@ void CXXNameMangler::mangleReflection(const ReflectionValue &R) {
Context.mangleCanonicalTypeName(QT, Out, false);
break;
}
case ReflectionValue::RK_const_value:
case ReflectionValue::RK_expr_result:
Out << 'e';
mangleExpression(R.getAsConstValueExpr());
mangleExpression(R.getAsExprResult());
break;
case ReflectionValue::RK_declaration: {
Out << 'd';
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/MicrosoftMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,7 @@ void MicrosoftCXXNameMangler::mangleReflection(const ReflectionValue &R) {
Context.mangleCanonicalTypeName(QT, Out, false);
break;
}
case ReflectionValue::RK_const_value:
case ReflectionValue::RK_expr_result:
case ReflectionValue::RK_declaration:
case ReflectionValue::RK_template:
case ReflectionValue::RK_namespace:
Expand Down
16 changes: 8 additions & 8 deletions clang/lib/AST/Reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ void ReflectionValue::Profile(llvm::FoldingSetNodeID &ID) const {
QT.Profile(ID);
break;
}
case RK_const_value:
if (auto *RD = getAsConstValueExpr()->getType()->getAsRecordDecl();
case RK_expr_result:
if (auto *RD = getAsExprResult()->getType()->getAsRecordDecl();
RD && RD->isLambda()) {
QualType(RD->getTypeForDecl(), 0).Profile(ID);
}
getAsConstValueExpr()->getAPValueResult().Profile(ID);
getAsExprResult()->getAPValueResult().Profile(ID);
break;
case RK_declaration:
ID.AddPointer(getAsDecl());
Expand Down Expand Up @@ -136,15 +136,15 @@ bool ReflectionValue::operator==(ReflectionValue const& Rhs) const {

return LQT.getCanonicalType() == RQT.getCanonicalType();
}
case RK_const_value: {
APValue LV = getAsConstValueExpr()->getAPValueResult();
APValue RV = Rhs.getAsConstValueExpr()->getAPValueResult();
case RK_expr_result: {
APValue LV = getAsExprResult()->getAPValueResult();
APValue RV = Rhs.getAsExprResult()->getAPValueResult();

llvm::FoldingSetNodeID LID, RID;
getAsConstValueExpr()->getType()
getAsExprResult()->getType()
.getCanonicalType().getUnqualifiedType().Profile(LID);
LV.Profile(LID);
Rhs.getAsConstValueExpr()->getType()
Rhs.getAsExprResult()->getType()
.getCanonicalType().getUnqualifiedType().Profile(RID);
RV.Profile(RID);

Expand Down
Loading

0 comments on commit b9b286b

Please sign in to comment.