[lld] [LLD] Improve linker script handing in LLD (PR #106334)
Hongyu Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 11:38:34 PDT 2024
================
@@ -74,6 +75,111 @@ struct ExprValue {
// Later, we evaluate the expression by calling the function.
using Expr = std::function<ExprValue()>;
+class ScriptExpr {
+public:
+ enum class ExprKind : uint8_t { Constant, Dynamic, Unary, Binary };
+
+private:
+ ExprKind kind_;
+
+protected:
+ explicit ScriptExpr(ExprKind kind) : kind_(kind) {}
+
+public:
+ ExprKind getKind() const { return kind_; }
+ std::function<ExprValue()> getExpr() const;
+ ExprValue getExprValue() const;
+};
+
+class ConstantExpr : public ScriptExpr {
+public:
+ // ConstantExpr(ExprValue val) : ScriptExpr(ExprKind::Constant), val_(val) {}
+ ConstantExpr(uint64_t val) : ScriptExpr(ExprKind::Constant), val_(val) {}
+ std::function<ExprValue()> getConstantExpr() const {
+ return [=] { return val_; };
+ }
+ ExprValue getConstantExprValue() const { return ExprValue(val_); }
----------------
yugier wrote:
Fixed!
https://github.com/llvm/llvm-project/pull/106334
More information about the llvm-commits
mailing list