r178733 - Fix 41 of the 61 tests which fail with modules enabled: we were computing and
Richard Smith
richard-llvm at metafoo.co.uk
Wed Apr 3 18:51:12 PDT 2013
Author: rsmith
Date: Wed Apr 3 20:51:11 2013
New Revision: 178733
URL: http://llvm.org/viewvc/llvm-project?rev=178733&view=rev
Log:
Fix 41 of the 61 tests which fail with modules enabled: we were computing and
caching the linkage for a declaration before we set up its redeclaration chain,
when determining whether a declaration could be a redeclaration of something
from an unimported submodule. We actually want to look at the declaration as if
it were not a redeclaration here, so compute the linkage but don't cache it.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/PCH/chain-late-anonymous-namespace.cpp
cfe/trunk/test/PCH/cxx-constexpr.cpp
cfe/trunk/test/Sema/private-extern.c
cfe/trunk/test/SemaCXX/linkage2.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=178733&r1=178732&r2=178733&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Apr 3 20:51:11 2013
@@ -219,6 +219,10 @@ public:
return getLinkage() == ExternalLinkage;
}
+ /// \brief True if this decl has external linkage. Don't cache the linkage,
+ /// because we are not finished setting up the redecl chain for the decl.
+ bool hasExternalLinkageUncached() const;
+
/// \brief Determines the visibility of this entity.
Visibility getVisibility() const {
return getLinkageAndVisibility().getVisibility();
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=178733&r1=178732&r2=178733&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Apr 3 20:51:11 2013
@@ -866,6 +866,10 @@ bool NamedDecl::isLinkageValid() const {
Linkage(CachedLinkage);
}
+bool NamedDecl::hasExternalLinkageUncached() const {
+ return getLVForDecl(this, LVForExplicitValue).getLinkage() == ExternalLinkage;
+}
+
Linkage NamedDecl::getLinkage() const {
if (HasCachedLinkage)
return Linkage(CachedLinkage);
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=178733&r1=178732&r2=178733&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Apr 3 20:51:11 2013
@@ -1605,8 +1605,18 @@ static void filterNonConflictingPrevious
if (previous.empty())
return;
- // If this declaration has external
- bool hasExternalLinkage = decl->hasExternalLinkage();
+ // If this declaration would have external linkage if it were the first
+ // declaration of this name, then it may in fact be a redeclaration of
+ // some hidden declaration, so include those too. We don't need to worry
+ // about some previous visible declaration giving this declaration external
+ // linkage, because in that case, we'll mark this declaration as a redecl
+ // of the visible decl, and that decl will already be a redecl of the
+ // hidden declaration if that's appropriate.
+ //
+ // Don't cache this linkage computation, because it's not yet correct: we
+ // may later give this declaration a previous declaration which changes
+ // its linkage.
+ bool hasExternalLinkage = decl->hasExternalLinkageUncached();
LookupResult::Filter filter = previous.makeFilter();
while (filter.hasNext()) {
Modified: cfe/trunk/test/PCH/chain-late-anonymous-namespace.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/chain-late-anonymous-namespace.cpp?rev=178733&r1=178732&r2=178733&view=diff
==============================================================================
--- cfe/trunk/test/PCH/chain-late-anonymous-namespace.cpp (original)
+++ cfe/trunk/test/PCH/chain-late-anonymous-namespace.cpp Wed Apr 3 20:51:11 2013
@@ -2,6 +2,8 @@
// RUN: %clang_cc1 -include %s -include %s -fsyntax-only %s
// with PCH
// RUN: %clang_cc1 -chain-include %s -chain-include %s -fsyntax-only %s
+// with PCH, with modules enabled
+// RUN: %clang_cc1 -chain-include %s -chain-include %s -fsyntax-only -fmodules %s
#if !defined(PASS1)
#define PASS1
Modified: cfe/trunk/test/PCH/cxx-constexpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-constexpr.cpp?rev=178733&r1=178732&r2=178733&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx-constexpr.cpp (original)
+++ cfe/trunk/test/PCH/cxx-constexpr.cpp Wed Apr 3 20:51:11 2013
@@ -4,6 +4,9 @@
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t-cxx11
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t-cxx11 -verify %s
+// RUN: %clang_cc1 -pedantic-errors -std=c++98 -emit-pch %s -o %t -fmodules
+// RUN: %clang_cc1 -pedantic-errors -std=c++98 -include-pch %t -verify %s -fmodules
+
#ifndef HEADER_INCLUDED
#define HEADER_INCLUDED
Modified: cfe/trunk/test/Sema/private-extern.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/private-extern.c?rev=178733&r1=178732&r2=178733&view=diff
==============================================================================
--- cfe/trunk/test/Sema/private-extern.c (original)
+++ cfe/trunk/test/Sema/private-extern.c Wed Apr 3 20:51:11 2013
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern -fmodules %s
static int g0; // expected-note{{previous definition}}
int g0; // expected-error{{non-static declaration of 'g0' follows static declaration}}
Modified: cfe/trunk/test/SemaCXX/linkage2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/linkage2.cpp?rev=178733&r1=178732&r2=178733&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/linkage2.cpp (original)
+++ cfe/trunk/test/SemaCXX/linkage2.cpp Wed Apr 3 20:51:11 2013
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fmodules %s
namespace test1 {
int x; // expected-note {{previous definition is here}}
More information about the cfe-commits
mailing list