[PATCH] D75763: [ELF] Postpone evaluation of ORIGIN/LENGTH in a MEMORY command

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 7 08:04:14 PST 2020


MaskRay added inline comments.


================
Comment at: lld/ELF/ScriptParser.cpp:1526
     setError("expected one of: " + s1 + ", " + s2 + ", or " + s3);
     return 0;
   }
----------------
grimar wrote:
> It calls `std::function(nullptr_t)` constructor.
> Such `Expr` will fail during evaluation (exception: std::bad_function_call).
> 
> You should probably use `return [] { return 0; };`
Thanks for this tip!

`return 0` does not crash (not testable) because:

```
createFiles(args);  // parse linker scripts
if (errorCount())
  return;
```

Anyway, `return [] { return 0; };` removes dependency on `errorCount()` check.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75763/new/

https://reviews.llvm.org/D75763





More information about the llvm-commits mailing list