================
@@ -13518,8 +13518,29 @@ bool
Sema::GloballyUniqueObjectMightBeAccidentallyDuplicated(
// If the object isn't hidden, the dynamic linker will prevent duplication.
clang::LinkageInfo Lnk = Target->getLinkageAndVisibility();
- if (Lnk.getVisibility() != HiddenVisibility)
+
+ // The target is "hidden" (from the dynamic linker) if:
+ // 1. On posix, it has hidden visibility, or
+ // 2. On windows, it has no import/export annotation
+ if (Context.getTargetInfo().shouldDLLImportComdatSymbols()) {
+ if (Target->hasAttr<DLLExportAttr>() || Target->hasAttr<DLLImportAttr>())
+ return false;
+
+ // If the variable isn't directly annotated, check to see if it's a member
+ // of an annotated class.
+ const VarDecl *VD = dyn_cast_if_present<VarDecl>(Target);
----------------
DKLoehr wrote:
Huh, you're right. Played with it locally a bit; I also see the "Inherited"
attribute in the AST, but the warning still fires. Is there a better way to
check for it than I'm currently doing? Perhaps `hasAttr` doesn't pick up
inherited attributes?
https://github.com/llvm/llvm-project/pull/143537
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits