summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-04-04 03:27:32 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-04-04 03:27:32 +0000
commit4dc336b20fabec14568151e0634ad6501fa0e9c6 (patch)
treed7bd65943bdb85e5a8adf9cb81e78787aa9aad78
parent14aef12e244dc5ea1d315acaabb26f33988e44c3 (diff)
downloadbcm5719-llvm-4dc336b20fabec14568151e0634ad6501fa0e9c6.tar.gz
bcm5719-llvm-4dc336b20fabec14568151e0634ad6501fa0e9c6.zip
Avoid computing the linkage instead of avoiding caching it.
This mostly reverts 178733, but keeps the tests. I don't claim to understand how hidden sub modules work or when we need to see them (is that documented?), but this has the same semantics and avoids adding hasExternalLinkageUncached which has the same foot gun potential as the old hasExternalLinkage. Last but not least, not computing linkage when it is not needed is more efficient. llvm-svn: 178739
-rw-r--r--clang/include/clang/AST/Decl.h4
-rw-r--r--clang/lib/AST/Decl.cpp4
-rw-r--r--clang/lib/Sema/SemaDecl.cpp15
3 files changed, 1 insertions, 22 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 7927279ddd6..0294b9fde8a 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -219,10 +219,6 @@ 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();
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index bf807aeb1d6..9505d299ab1 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -866,10 +866,6 @@ 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 a25204d8089..0ad539ef172 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1605,19 +1605,6 @@ static void filterNonConflictingPreviousDecls(ASTContext &context,
if (previous.empty())
return;
- // 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()) {
NamedDecl *old = filter.next();
@@ -1627,7 +1614,7 @@ static void filterNonConflictingPreviousDecls(ASTContext &context,
continue;
// If either has no-external linkage, ignore the old declaration.
- if (!hasExternalLinkage || old->getLinkage() != ExternalLinkage)
+ if (old->getLinkage() != ExternalLinkage || !decl->hasExternalLinkage())
filter.erase();
}
OpenPOWER on IntegriCloud