[all-commits] [llvm/llvm-project] 853e0a: Don't dllexport reference temporaries

Hans via All-commits all-commits at lists.llvm.org
Fri Feb 4 07:34:55 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 853e0aa424e40b80d0bda1dd8a3471a361048e4b
      https://github.com/llvm/llvm-project/commit/853e0aa424e40b80d0bda1dd8a3471a361048e4b
  Author: Hans Wennborg <hans at chromium.org>
  Date:   2022-02-04 (Fri, 04 Feb 2022)

  Changed paths:
    M clang/lib/CodeGen/CodeGenModule.cpp
    A clang/test/CodeGenCXX/reference-temporary-ms.cpp

  Log Message:
  -----------
  Don't dllexport reference temporaries

Even if the reference itself is dllexport, the temporary should not be.
In fact, we're already giving it internal linkage, so dllexporting it
is not just wasteful, but will fail to link, as in the example below:

  $ cat /tmp/a.cc
  void _DllMainCRTStartup() {}
  const int __declspec(dllexport) &foo = 42;

  $ clang-cl -fuse-ld=lld /tmp/a.cc /Zl /link /dll /out:a.dll
  lld-link: error: <root>: undefined symbol: int const &foo::$RT1

Differential revision: https://reviews.llvm.org/D118980




More information about the All-commits mailing list