summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-04-15 12:49:13 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-04-15 12:49:13 +0000
commit5bddd6a92a0e8f1f72c658529e808c24ae864e23 (patch)
treece0623aa9ce71a3d5c1731b02a400cbfe4c8c271 /clang/lib/Sema/SemaDecl.cpp
parent7332acac4cfb7959b8d9848ba8bc74331abd2f7a (diff)
downloadbcm5719-llvm-5bddd6a92a0e8f1f72c658529e808c24ae864e23.tar.gz
bcm5719-llvm-5bddd6a92a0e8f1f72c658529e808c24ae864e23.zip
Remove hasExternalLinkageUncached.
It was being used correctly, but it is a very dangerous API to have around. Instead, move the logic from the filtering to when we are deciding if we should link two decls. llvm-svn: 179523
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9b3083a4ecb..a17e9d0cdaf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1613,20 +1613,7 @@ static void filterNonConflictingPreviousDecls(ASTContext &context,
if (!old->isHidden())
continue;
- // If either has no-external linkage, ignore the old declaration.
- // 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())
+ if (old->getLinkage() != ExternalLinkage)
filter.erase();
}
@@ -2881,6 +2868,9 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous,
return New->setInvalidDecl();
}
+ if (!shouldLinkPossiblyHiddenDecl(Old, New))
+ return;
+
// C++ [class.mem]p1:
// A member shall not be declared twice in the member-specification [...]
//
@@ -6687,8 +6677,11 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
// there's no more work to do here; we'll just add the new
// function to the scope.
if (!AllowOverloadingOfFunction(Previous, Context)) {
- Redeclaration = true;
- OldDecl = Previous.getFoundDecl();
+ NamedDecl *Candidate = Previous.getFoundDecl();
+ if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
+ Redeclaration = true;
+ OldDecl = Candidate;
+ }
} else {
switch (CheckOverload(S, NewFD, Previous, OldDecl,
/*NewIsUsingDecl*/ false)) {
OpenPOWER on IntegriCloud