GlobalValue: Automatically reset visibility when setting local linkage
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 20 May 2014 19:00:58 +0000 (19:00 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 20 May 2014 19:00:58 +0000 (19:00 +0000)
r208264 started asserting in `setLinkage()` and `setVisibility()` that
visibility and linkage are compatible.  There are a few places in clang
where visibility is set first, and then linkage later, so the assert
fires.  In `setLinkage()`, it's clear what the visibility *should* be,
so rather than updating all the call sites just automatically fix the
visibility.

The testcase for this is for *clang*, so it'll follow separately in cfe.

PR19760

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209227 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/GlobalValue.h

index 0ed302cdb4b8c43925f699d514fb837feca5d0b3..10df372945a98b113a5742c00e631343b7435f3c 100644 (file)
@@ -222,8 +222,8 @@ public:
   bool hasCommonLinkage() const { return isCommonLinkage(Linkage); }
 
   void setLinkage(LinkageTypes LT) {
-    assert((!isLocalLinkage(LT) || hasDefaultVisibility()) &&
-           "local linkage requires default visibility");
+    if (isLocalLinkage(LT))
+      Visibility = DefaultVisibility;
     Linkage = LT;
   }
   LinkageTypes getLinkage() const { return Linkage; }