aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-04-04 01:51:11 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-04-04 01:51:11 +0000
commitd613ac9c57936d219d9eecba1d061a45ff7a3ae8 (patch)
treea00e5f5d40b301e5e58a3c16b453994301bace9e /lib
parentb846381fc3099b2340ba8c74d16178203a60d9a0 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/Decl.cpp4
-rw-r--r--lib/Sema/SemaDecl.cpp14
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 9505d299ab..bf807aeb1d 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -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);
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 1288568401..42d7d2bdf5 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1605,8 +1605,18 @@ static void filterNonConflictingPreviousDecls(ASTContext &context,
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()) {