[PATCH] D127811: Fix a bug introduced by the move of AddressRanges.h into ADT.

Alexey Lapshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 02:52:00 PDT 2022


avl added a comment.

Thank you for catching this!



================
Comment at: llvm/include/llvm/ADT/AddressRanges.h:30
+  void setStart(uint64_t Addr) { Start = Addr; }
+  void setEnd(uint64_t Addr) { End = Addr; }
   uint64_t size() const { return End - Start; }
----------------
I would suggest to leave AddressRange to be immutable.
It might prevent from side effects if borders of range would be changed.

If you think it is still better to have setStart/setEnd then we need to add assertions:

assert(Start <= End);


================
Comment at: llvm/lib/DebugInfo/GSYM/GsymCreator.cpp:295
             ValidTextRanges->getRangeThatContains(Funcs.back().Range.start())) {
-      Funcs.back().Range = *Range;
+      Funcs.back().Range.setEnd(Range->end());
     }
----------------
without setStart/setEnd we can reconstruct Address Range:

```
Funcs.back().Range = {Funcs.back().Range.start(), Range->end()};
```

This would allow not to introduce setters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127811



More information about the llvm-commits mailing list