[PATCH] D128223: [clang] Linkage computation of static locals may require forcing visibility computation

David Tenty via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 28 16:48:08 PDT 2022


daltenty accepted this revision.
daltenty added a comment.
This revision is now accepted and ready to land.

LGTM. Doing the inner computation while observing visibility seems like the right thing to do in this case.



================
Comment at: clang/lib/AST/Decl.cpp:1355
+        !Context.getLangOpts().VisibilityInlinesHiddenStaticLocalVar;
+    LVComputationKind nestedComputation =
+        mayBeVisible
----------------
Just adding my own note  of explanation, since this stuff can be a little hard to follow.

This inner linkage query needs to observe visibility in order to get a consistent result, even if the calling query (i.e. `getLinkageInternal` in this case) has passed in a LVComputationKind indicating we don't need to for the LocalDecl. If we don't, we may get results inconsistent with the cached value for the enclosing FunctionDecl, hence the assert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128223



More information about the cfe-commits mailing list