[clang] [clang][CrossTU] Indicate weak link attribute in ExternalDefMap. (PR #204188)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 24 08:46:08 PDT 2026


================
@@ -279,6 +306,8 @@ CrossTranslationUnitContext::~CrossTranslationUnitContext() {}
 std::optional<std::string>
 CrossTranslationUnitContext::getLookupName(const Decl *D) {
   SmallString<128> DeclUSR;
+  if (D->hasAttr<WeakAttr>())
+    DeclUSR.push_back('-');
----------------
balazske wrote:

It is a difficult question if it is correct to have a different USR for weak and non-weak version of the "same" declaration. One program should have theoretically not multiple versions of a declaration but with the "weak" attribute this is possible, so it may have a different USR. This needs more discussion because changes in the USR generation can affect other areas and use cases. If the weak attribute was not a problem before (except this CTU use case) probably it is not worth such a big change.

https://github.com/llvm/llvm-project/pull/204188


More information about the cfe-commits mailing list