[PATCH] D89212: PR47663: Warn if an entity becomes weak after its first use.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 14 16:52:41 PDT 2020


rsmith added a comment.

In D89212#2326771 <https://reviews.llvm.org/D89212#2326771>, @rjmccall wrote:

> Patch looks good to me.  I think we're running some internal tests; do you want to wait for those?

More testing and validation would be nice; I don't think this patch is urgent so I'm happy to wait.

In my internal testing, I found one more false positive: the protocol buffer compiler's support for weak imports results in code like this:

  // generated .h file
  extern T foo;
  inline T *get() { return &foo; }



  // generated .cc file
  __attribute__((weak)) extern T foo;
  // more uses of foo

This is intentional: the idea is that if someone includes the `.h` file and invokes the inline function, they get a strong link-time dependency on the symbol `foo` and need to link against that proto library. But if not, then there is no such dependency, and the library is optional. However, this functionality of the protocol buffer compiler is deprecated and being phased out (and suppressing the warning in this one case should be straightforward) so I'm not worried about it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89212



More information about the cfe-commits mailing list