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 | d4aff0e2b77879e27e7e4eac8c972aaaa293fa12 (patch) | |
tree | 3c1c06caacc35f579365256047b18a7270720fee /lib/Sema/SemaDeclAttr.cpp | |
parent | c37b736150db77ddfcfc0e5f1171c258a32d6ef7 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index f30a6ff78f..8b7863107b 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/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; + } } } } |