From 6bbe311027780821d6f83b00aa730e434648b691 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 10 Oct 2017 22:33:17 +0000 Subject: [Modules TS] Module ownership semantics for redeclarations. When declaring an entity in the "purview" of a module, it's never a redeclaration of an entity in the purview of a default module or in no module ("in the global module"). Don't consider those other declarations as possible redeclaration targets if they're not visible, and reject any cases where we pick a prior visible declaration that violates this rule. This reinstates r315251 and r315256, reverted in r315309 and r315308 respectively, tweaked to avoid triggering a linkage calculation when declaring implicit special members (this exposed our pre-existing issue with typedef names for linkage changing the linkage of types whose linkage has already been computed and cached in more cases). A testcase for that regression has been added in r315366. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315379 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/DeclBase.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/AST/DeclBase.cpp') diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 42f0ba0bd7..1e15ee98bb 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -315,12 +315,11 @@ bool Decl::isLexicallyWithinFunctionOrMethod() const { } bool Decl::isInAnonymousNamespace() const { - const DeclContext *DC = getDeclContext(); - do { + for (const DeclContext *DC = getDeclContext(); DC; DC = DC->getParent()) { if (const NamespaceDecl *ND = dyn_cast(DC)) if (ND->isAnonymousNamespace()) return true; - } while ((DC = DC->getParent())); + } return false; } -- cgit v1.2.1