[PATCH] D53052: [AST] Use -fvisibility value when ignoring -fv-i-h* inline static locals

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 10 01:09:39 PDT 2018


hans accepted this revision.
hans added a comment.

> Most codebases probably only use either -fvisibility=hidden or
>  -fvisibility-inlines-hidden, since marking inlines hidden should be a
>  no-op if everything was already going to be hidden, but it looks like
>  Chromium uses both.

I think using both flags is useful in code bases that want hidden visibility by default, but mark some classes visible explicitly, and then still want the inline functions hidden as an optimization:

  struct __attribute__((visibility("default"))) S {
    int foo() {
      static int x;
      return x++;
    }
    int bar();
  };
  
  int S::bar() { return 45; }
  void use(S *s) { s->foo(); }

With both -fvisibility=hidden and -fvisibility-inlines-hidden, S::bar() will be visible, but S::foo() will be hidden. S::foo()'s static local should be visible though. If the class didn't have the attribute, everything including the static local should be hidden.

The patch looks good to me, but perhaps we should add the above as a test case?


https://reviews.llvm.org/D53052





More information about the llvm-commits mailing list