diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-04 04:40:17 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-04 04:40:17 +0000 |
commit | 7b51ae8e0e09816737d3bcd471666d5f6a5695c0 (patch) | |
tree | d63723718545d5b5ab5e260dd84705b8f8003c50 /clang/lib | |
parent | 5dacbec4aa1e37b153dfa41bdc188885219ae7db (diff) | |
download | bcm5719-llvm-7b51ae8e0e09816737d3bcd471666d5f6a5695c0.tar.gz bcm5719-llvm-7b51ae8e0e09816737d3bcd471666d5f6a5695c0.zip |
Add hasExternalLinkageUncached back with the test that Richard provided, but
keep the call at the current location.
llvm-svn: 178741
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 14 |
2 files changed, 17 insertions, 1 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 9505d299ab1..bf807aeb1d6 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/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/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 0ad539ef172..436fca35cbc 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1614,7 +1614,19 @@ static void filterNonConflictingPreviousDecls(ASTContext &context, continue; // If either has no-external linkage, ignore the old declaration. - if (old->getLinkage() != ExternalLinkage || !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. + if (old->getLinkage() != ExternalLinkage || + !decl->hasExternalLinkageUncached()) filter.erase(); } |