[llvm-branch-commits] [cfe-branch] r121550 - in /cfe/branches/Apple/whitney: include/clang/Basic/Attr.td include/clang/Sema/AttributeList.h lib/CodeGen/CodeGenModule.cpp lib/Sema/AttributeList.cpp lib/Sema/SemaDeclAttr.cpp test/CodeGen/no-common.c

Daniel Dunbar daniel at zuster.org
Fri Dec 10 13:37:35 PST 2010


Author: ddunbar
Date: Fri Dec 10 15:37:35 2010
New Revision: 121550

URL: http://llvm.org/viewvc/llvm-project?rev=121550&view=rev
Log:
Merge r120650:
--
Author: Eric Christopher <echristo at apple.com>
Date:   Thu Dec 2 02:45:55 2010 +0000

    Add support for the common and nocommon attributes.

    rdar://8560647

*** MANUAL MERGE ***

Modified:
    cfe/branches/Apple/whitney/include/clang/Basic/Attr.td
    cfe/branches/Apple/whitney/include/clang/Sema/AttributeList.h
    cfe/branches/Apple/whitney/lib/CodeGen/CodeGenModule.cpp
    cfe/branches/Apple/whitney/lib/Sema/AttributeList.cpp
    cfe/branches/Apple/whitney/lib/Sema/SemaDeclAttr.cpp
    cfe/branches/Apple/whitney/test/CodeGen/no-common.c

Modified: cfe/branches/Apple/whitney/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang/Basic/Attr.td?rev=121550&r1=121549&r2=121550&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang/Basic/Attr.td (original)
+++ cfe/branches/Apple/whitney/include/clang/Basic/Attr.td Fri Dec 10 15:37:35 2010
@@ -161,6 +161,10 @@
   let Args = [FunctionArgument<"FunctionDecl">];
 }
 
+def Common : Attr {
+  let Spellings = ["common"];
+}
+
 def Const : Attr {
   let Spellings = ["const"];
 }
@@ -250,6 +254,10 @@
   let Spellings = ["naked"];
 }
 
+def NoCommon : Attr {
+  let Spellings = ["nocommon"];
+}
+
 def NoDebug : Attr {
   let Spellings = ["nodebug"];
 }

Modified: cfe/branches/Apple/whitney/include/clang/Sema/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang/Sema/AttributeList.h?rev=121550&r1=121549&r2=121550&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang/Sema/AttributeList.h (original)
+++ cfe/branches/Apple/whitney/include/clang/Sema/AttributeList.h Fri Dec 10 15:37:35 2010
@@ -91,6 +91,7 @@
     AT_carries_dependency,
     AT_cdecl,
     AT_cleanup,
+    AT_common,
     AT_const,
     AT_constructor,
     AT_deprecated,
@@ -110,6 +111,7 @@
     AT_nodebug,
     AT_noinline,
     AT_no_instrument_function,
+    AT_nocommon,
     AT_nonnull,
     AT_noreturn,
     AT_nothrow,

Modified: cfe/branches/Apple/whitney/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CodeGenModule.cpp?rev=121550&r1=121549&r2=121550&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CodeGenModule.cpp Fri Dec 10 15:37:35 2010
@@ -1211,7 +1211,9 @@
     // FIXME: It seems like we can provide more specific linkage here
     // (LinkOnceODR, WeakODR).
     return llvm::GlobalVariable::WeakAnyLinkage;
-  else if (!getLangOptions().CPlusPlus && !CodeGenOpts.NoCommon &&
+  else if (!getLangOptions().CPlusPlus && 
+           ((!CodeGenOpts.NoCommon && !D->getAttr<NoCommonAttr>()) ||
+             D->getAttr<CommonAttr>()) &&
            !D->hasExternalStorage() && !D->getInit() &&
            !D->getAttr<SectionAttr>() && !D->isThreadSpecified()) {
     // Thread local vars aren't considered common linkage.

Modified: cfe/branches/Apple/whitney/lib/Sema/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/AttributeList.cpp?rev=121550&r1=121549&r2=121550&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/AttributeList.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/AttributeList.cpp Fri Dec 10 15:37:35 2010
@@ -118,6 +118,8 @@
     .Case("no_instrument_function", AT_no_instrument_function)
     .Case("thiscall", AT_thiscall)
     .Case("pascal", AT_pascal)
+    .Case("common", AT_common)
+    .Case("nocommon", AT_nocommon)
     .Case("__cdecl", AT_cdecl)
     .Case("__stdcall", AT_stdcall)
     .Case("__fastcall", AT_fastcall)

Modified: cfe/branches/Apple/whitney/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaDeclAttr.cpp?rev=121550&r1=121549&r2=121550&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaDeclAttr.cpp Fri Dec 10 15:37:35 2010
@@ -731,6 +731,16 @@
   S.Diag(Attr.getLoc(), diag::warn_attribute_malloc_pointer_only);
 }
 
+static void HandleNoCommonAttr(Decl *d, const AttributeList &Attr, Sema &S) {
+  assert(Attr.isInvalid() == false);
+  d->addAttr(::new (S.Context) NoCommonAttr(Attr.getLoc(), S.Context));
+}
+
+static void HandleCommonAttr(Decl *d, const AttributeList &Attr, Sema &S) {
+  assert(Attr.isInvalid() == false);
+  d->addAttr(::new (S.Context) CommonAttr(Attr.getLoc(), S.Context));
+}
+
 static void HandleNoReturnAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   /* Diagnostics (if any) was emitted by Sema::ProcessFnAttr(). */
   assert(Attr.isInvalid() == false);
@@ -2346,6 +2356,7 @@
   case AttributeList::AT_base_check:  HandleBaseCheckAttr   (D, Attr, S); break;
   case AttributeList::AT_carries_dependency:
                                       HandleDependencyAttr  (D, Attr, S); break;
+  case AttributeList::AT_common:      HandleCommonAttr      (D, Attr, S); break;
   case AttributeList::AT_constructor: HandleConstructorAttr (D, Attr, S); break;
   case AttributeList::AT_deprecated:  HandleDeprecatedAttr  (D, Attr, S); break;
   case AttributeList::AT_destructor:  HandleDestructorAttr  (D, Attr, S); break;
@@ -2359,6 +2370,7 @@
   case AttributeList::AT_hiding:      HandleHidingAttr      (D, Attr, S); break;
   case AttributeList::AT_mode:        HandleModeAttr        (D, Attr, S); break;
   case AttributeList::AT_malloc:      HandleMallocAttr      (D, Attr, S); break;
+  case AttributeList::AT_nocommon:    HandleNoCommonAttr    (D, Attr, S); break;
   case AttributeList::AT_nonnull:     HandleNonNullAttr     (D, Attr, S); break;
   case AttributeList::AT_ownership_returns:
   case AttributeList::AT_ownership_takes:

Modified: cfe/branches/Apple/whitney/test/CodeGen/no-common.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/CodeGen/no-common.c?rev=121550&r1=121549&r2=121550&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/CodeGen/no-common.c (original)
+++ cfe/branches/Apple/whitney/test/CodeGen/no-common.c Fri Dec 10 15:37:35 2010
@@ -4,3 +4,12 @@
 // RUN: grep '@x = global' %t
 
 int x;
+
+// CHECK-DEFAULT: @ABC = global
+// CHECK-NOCOMMON: @ABC = global
+typedef void* (*fn_t)(long a, long b, char *f, int c);
+fn_t ABC __attribute__ ((nocommon));
+
+// CHECK-DEFAULT: @y = common global
+// CHECK-NOCOMMON: @y = common global
+int y __attribute__((common));
\ No newline at end of file





More information about the llvm-branch-commits mailing list