Author: Nathan Sidwell
Date: 2022-02-02T05:14:26-08:00
New Revision: ccf02cdf17d68a7dd4411daa74b81fa5b48d0a0c

URL: 
https://github.com/llvm/llvm-project/commit/ccf02cdf17d68a7dd4411daa74b81fa5b48d0a0c
DIFF: 
https://github.com/llvm/llvm-project/commit/ccf02cdf17d68a7dd4411daa74b81fa5b48d0a0c.diff

LOG: [clang][NFC] Remove unreachable code

NamespaceDecls are NamedDecls, so NSD can never be non-null in the
else branch.  Add a comment about this whole ModuleInternal linkage
concept going away when p1815 is implemented.

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D118704

Added: 
    

Modified: 
    clang/lib/AST/Decl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index b2ee34f20cf73..060a6d1ad5ed5 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1557,16 +1557,16 @@ Module *Decl::getOwningModuleForLinkage(bool 
IgnoreLinkage) const {
     // for linkage purposes. But internal linkage declarations in the global
     // module fragment of a particular module are owned by that module for
     // linkage purposes.
+    // FIXME: p1815 removes the need for this distinction -- there are no
+    // internal linkage declarations that need to be referred to from outside
+    // this TU.
     if (IgnoreLinkage)
       return nullptr;
     bool InternalLinkage;
     if (auto *ND = dyn_cast<NamedDecl>(this))
       InternalLinkage = !ND->hasExternalFormalLinkage();
-    else {
-      auto *NSD = dyn_cast<NamespaceDecl>(this);
-      InternalLinkage = (NSD && NSD->isAnonymousNamespace()) ||
-                        isInAnonymousNamespace();
-    }
+    else
+      InternalLinkage = isInAnonymousNamespace();
     return InternalLinkage ? M->Parent : nullptr;
   }
 


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to