[cfe-commits] r117426 - /cfe/trunk/lib/Sema/SemaDeclAttr.cpp

John McCall rjmccall at apple.com
Tue Oct 26 17:59:00 PDT 2010


Author: rjmccall
Date: Tue Oct 26 19:59:00 2010
New Revision: 117426

URL: http://llvm.org/viewvc/llvm-project?rev=117426&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=117426&r1=117425&r2=117426&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Oct 26 19:59:00 2010
@@ -2467,14 +2467,18 @@
 /// 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;
+        }
       }
     }
   }





More information about the cfe-commits mailing list