[PATCH] D13925: Implement __attribute__((internal_linkage))

Evgeniy Stepanov via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 3 16:59:35 PST 2015


eugenis added inline comments.

================
Comment at: lib/AST/Decl.cpp:635-641
@@ -634,2 +634,9 @@
   assert(!isa<FieldDecl>(D) && "Didn't expect a FieldDecl!");
 
+  for (const DeclContext *DC = D->getDeclContext();
+       !isa<TranslationUnitDecl>(DC); DC = DC->getParent()) {
+    const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC);
+    if (ND && ND->getAttr<InternalLinkageAttr>())
+      return LinkageInfo::internal();
+  }
+
----------------
rsmith wrote:
> Dead code?
Right. Removed.

================
Comment at: lib/AST/Decl.cpp:1362-1367
@@ -1346,4 +1361,8 @@
     }
-    assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage());
+    // Linkages may also differ if one of the declarations has
+    // InternalLinkageAttr.
+    assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage() ||
+           (Old->hasAttr<InternalLinkageAttr>() !=
+            D->hasAttr<InternalLinkageAttr>()));
 #endif
 
----------------
rsmith wrote:
> We should not introduce another case where the linkage of an entity can change after its first declaration. It seems reasonable to require this attribute to be on the first declaration of the function.
This is strange, I can no longer trigger this code path.
I wonder if the change that added an attribute check to isExternallyVisible made this special case unnecessary?
Reverting this chunk.


Repository:
  rL LLVM

http://reviews.llvm.org/D13925





More information about the cfe-commits mailing list