[Lldb-commits] [PATCH] D145547: When setting load addresses on darwin kernel kexts, handle case where in-memory load commands are not updated

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 8 17:30:09 PST 2023


bulbazord added inline comments.


================
Comment at: lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:816-819
+      ObjectFileMachO *ondisk_objfile_macho =
+          llvm::dyn_cast_or_null<ObjectFileMachO>(
+              m_module_sp ? m_module_sp->GetObjectFile() : nullptr);
+      if (ondisk_objfile_macho) {
----------------
I have a suggestion that may make this easier to read. You already know that m_module_sp is valid because you have that as a condition to even enter this block. So you can do something like
```
ObjectFileMachO *ondisk_objfile_macho = m_module_sp->GetObjectFile();
```

But right below you only act on this if the object is valid, so you could stick it in the if condition itself:
```
if (auto *ondisk_objfile_macho = m_module_sp->GetObjectFile()) {
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145547



More information about the lldb-commits mailing list