]> granicus.if.org Git - clang/commitdiff
Revert "[Modules TS] Avoid computing the linkage of the enclosing DeclContext for...
authorEric Liu <ioeric@google.com>
Tue, 10 Oct 2017 13:00:18 +0000 (13:00 +0000)
committerEric Liu <ioeric@google.com>
Tue, 10 Oct 2017 13:00:18 +0000 (13:00 +0000)
This reverts commit r315256. See the original commit thread for reason.

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

include/clang/AST/DeclBase.h
include/clang/Sema/Sema.h
lib/AST/Decl.cpp
test/Modules/anon-linkage.cpp [deleted file]

index 47515a848a46f8273018e8237e16111eeff126db..aa278c301ed172605fe0ecadd63c562e61e4a5d3 100644 (file)
@@ -740,10 +740,7 @@ public:
 
   /// Get the module that owns this declaration for linkage purposes.
   /// There only ever is such a module under the C++ Modules TS.
-  ///
-  /// \param IgnoreLinkage Ignore the linkage of the entity; assume that
-  /// all declarations in a global module fragment are unowned.
-  Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const;
+  Module *getOwningModuleForLinkage() const;
 
   /// \brief Determine whether this declaration might be hidden from name
   /// lookup. Note that the declaration might be visible even if this returns
index 277c62f543937abf72c4cce1cbe06df1dfb24c2c..f32fafa447bf11ad8c2a6303a6d9f73628a9c33b 100644 (file)
@@ -3051,11 +3051,8 @@ public:
 
   RedeclarationKind forRedeclarationInCurContext() {
     // A declaration with an owning module for linkage can never link against
-    // anything that is not visible. We don't need to check linkage here; if
-    // the context has internal linkage, redeclaration lookup won't find things
-    // from other TUs, and we can't safely compute linkage yet in general.
-    if (cast<Decl>(CurContext)
-            ->getOwningModuleForLinkage(/*IgnoreLinkage*/true))
+    // anything that is not visible.
+    if (cast<Decl>(CurContext)->getOwningModuleForLinkage())
       return ForVisibleRedeclaration;
     return ForExternalRedeclaration;
   }
index 4a9b9bea8306bbdf02b428c744def28d1f7b1096..cdd89d20e6bc1325f7ed38830351a6787546b31d 100644 (file)
@@ -1395,7 +1395,7 @@ LinkageInfo LinkageComputer::getDeclLinkageAndVisibility(const NamedDecl *D) {
                                             : NamedDecl::VisibilityForValue));
 }
 
-Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
+Module *Decl::getOwningModuleForLinkage() const {
   Module *M = getOwningModule();
   if (!M)
     return nullptr;
@@ -1413,8 +1413,6 @@ 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.
-    if (IgnoreLinkage)
-      return nullptr;
     bool InternalLinkage;
     if (auto *ND = dyn_cast<NamedDecl>(this))
       InternalLinkage = !ND->hasExternalFormalLinkage();
diff --git a/test/Modules/anon-linkage.cpp b/test/Modules/anon-linkage.cpp
deleted file mode 100644 (file)
index 5906382..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s
-
-typedef struct {
-  int c;
-  union {
-    int n;
-    char c[4];
-  } v;
-} mbstate;
-
-export module M;
-export using ::mbstate;