[PATCH] D100019: [lld-macho][nfc] Minor refactoring + clang-tidy fixes

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 7 09:53:15 PDT 2021


oontvoo added a comment.

In D100019#2674137 <https://reviews.llvm.org/D100019#2674137>, @int3 wrote:

> I actually snuck in a clang-format cleanup yesterday :) https://github.com/llvm/llvm-project/commit/174deb0539ee4af7d20bfead9f73055782e878e3 (so just update the commit title I guess)

These are `clang-tidy`'s suggested fixes (the `size()` vs `empty()`) - not clang-format :)



================
Comment at: lld/MachO/Driver.cpp:1064-1067
+      std::vector<StringRef> extensions = {".tbd"};
+      for (const Arg *arg : args.filtered(OPT_sub_umbrella)) {
+        reexportHandler(arg, extensions);
+      }
----------------
int3 wrote:
> int3 wrote:
> > 1. no need for braces
> > 2. I'm pretty sure the compiler can hoist out the construction of the vector
> > I'm pretty sure the compiler can hoist out the construction of the vector
> 
> well, I'm wrong: https://godbolt.org/z/szKbeojrd
> > I'm pretty sure the compiler can hoist out the construction of the vector
> well, I'm wrong: https://godbolt.org/z/szKbeojrd

Probably because it can't know what `foo` does with the reference - hoisting it out could change the logic entirely:

```
void foo(const std::vector<int>& v) {
  static auto* last_vector = &v;
  static bool first = true;
  if (first) first = false;
  else  assert (&v != last_vector);  
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100019



More information about the llvm-commits mailing list