diff options
| author | John McCall <rjmccall@apple.com> | 2010-10-27 00:59:00 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-10-27 00:59:00 +0000 |
| commit | 6fe024052b1e024135fe9bb3b3c5e0f73b247f78 (patch) | |
| tree | 2e5da07630ad05f333085db50853bcb7c2260f0f /clang/lib/Sema/SemaDeclAttr.cpp | |
| parent | 79e1407c11106432af54040764782421f7933c86 (diff) | |
| download | bcm5719-llvm-6fe024052b1e024135fe9bb3b3c5e0f73b247f78.tar.gz bcm5719-llvm-6fe024052b1e024135fe9bb3b3c5e0f73b247f78.zip | |
Don't compute linkage for a declaration as part of the #pragma weak
forward-declaration support unless there's really a mapping for that
name.
llvm-svn: 117426
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index f30a6ff78f9..8b7863107b4 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2467,14 +2467,18 @@ void Sema::DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W) { /// it, apply them to D. This is a bit tricky because PD can have attributes /// specified in many different places, and we need to find and apply them all. void Sema::ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD) { - // Handle #pragma weak - if (NamedDecl *ND = dyn_cast<NamedDecl>(D)) { - if (ND->hasLinkage()) { - WeakInfo W = WeakUndeclaredIdentifiers.lookup(ND->getIdentifier()); - if (W != WeakInfo()) { - // Identifier referenced by #pragma weak before it was declared - DeclApplyPragmaWeak(S, ND, W); - WeakUndeclaredIdentifiers[ND->getIdentifier()] = W; + // It's valid to "forward-declare" #pragma weak, in which case we + // have to do this. + if (!WeakUndeclaredIdentifiers.empty()) { + if (NamedDecl *ND = dyn_cast<NamedDecl>(D)) { + if (IdentifierInfo *Id = ND->getIdentifier()) { + llvm::DenseMap<IdentifierInfo*,WeakInfo>::iterator I + = WeakUndeclaredIdentifiers.find(Id); + if (I != WeakUndeclaredIdentifiers.end() && ND->hasLinkage()) { + WeakInfo W = I->second; + DeclApplyPragmaWeak(S, ND, W); + WeakUndeclaredIdentifiers[Id] = W; + } } } } |

