[lld] [LLD] Improve linker script handing in LLD (PR #106334)
Daniel Thornburgh via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 11:13:47 PDT 2024
================
@@ -131,6 +131,156 @@ uint64_t ExprValue::getSectionOffset() const {
return getValue() - getSecAddr();
}
+std::function<ExprValue()> ScriptExpr::getExpr() const {
+ switch (kind_) {
+ case ExprKind::Constant:
+ return static_cast<const ConstantExpr *>(this)->getConstantExpr();
+ case ExprKind::Dynamic: {
+ auto expr = static_cast<const DynamicExpr *>(this);
+ return expr->getImpl();
+ }
+ case ExprKind::Binary: {
+ auto expr = static_cast<const BinaryExpr *>(this);
+ return [=] { return expr->evaluateBinaryOperands(); };
+ }
+ default:
+ return [] { return ExprValue(0); };
+ };
+}
+
+ExprValue ScriptExpr::getExprValue() const {
+ switch (kind_) {
+ case ExprKind::Constant:
----------------
mysterymath wrote:
Each of the functions called on the derived classes should be named `getExprValue()`. This minimizes the amount of information about the implementations of the various expression subclasses present in the base class.
https://github.com/llvm/llvm-project/pull/106334
More information about the llvm-commits
mailing list