[dllexport] odr-use constexpr default args for constructor closures
authorHans Wennborg <hans@chromium.org>
Fri, 8 Apr 2022 13:54:09 +0000 (15:54 +0200)
committerHans Wennborg <hans@chromium.org>
Mon, 11 Apr 2022 14:23:01 +0000 (16:23 +0200)
commit40ad6670138ab8130a426432b0e94544b5e03642
tree1529ba5ab47c22bb383431e60171ac21c90d3a2a
parentf018a5f6e0d1ac20d9cb499be5c3a8990b272d7d
[dllexport] odr-use constexpr default args for constructor closures

InstantiateDefaultCtorDefaultArgs() is supposed to mark default
constructor args as odr-used, since those args will be used when
emitting the constructor closure.

However, constexpr vars were not getting odr-used since
DoMarkVarDeclReferenced() defers them in MaybeODRUseExprs, and the code
was calling CleanupVarDeclMarking() which discarded those uses instead
of processing them.

(This came up in Chromium, crbug.com/1312086)

Differential revision: https://reviews.llvm.org/D123405
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGenCXX/dllexport-ctor-closure.cpp