]> granicus.if.org Git - clang/commitdiff
make the rewriter add a #ifndef around the #define of __attribute__.
authorChris Lattner <sabre@nondot.org>
Tue, 13 Apr 2010 17:33:56 +0000 (17:33 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 13 Apr 2010 17:33:56 +0000 (17:33 +0000)
Without it, there is no reason for a compiler that supports it to
emit the dead static globals that the rewriter labels attribute(used).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101149 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/RewriteObjC.cpp
test/Rewriter/rewrite-super-message.mm

index cba92987a3d6ce3b16f682be715db097cc33fae9..83d392aab3322922819250590b5937c3974643f1 100644 (file)
@@ -640,7 +640,9 @@ void RewriteObjC::Initialize(ASTContext &context) {
   if (LangOpts.Microsoft) {
     Preamble += "#undef __OBJC_RW_DLLIMPORT\n";
     Preamble += "#undef __OBJC_RW_STATICIMPORT\n";
+    Preamble += "#ifndef KEEP_ATTRIBUTES\n";  // We use this for clang tests.
     Preamble += "#define __attribute__(X)\n";
+    Preamble += "#endif\n";
     Preamble += "#define __weak\n";
   }
   else {
index 036aa1bb3186d0592e37414583cb37305669f8f1..be0a963c55d4a7925e2fc8e3caaa7dc045c6032e 100644 (file)
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=struct objc_object *" -D"Class=struct objc_class *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o - %t-rw.cpp | FileCheck %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -DKEEP_ATTRIBUTES -D"id=struct objc_object *" -D"Class=struct objc_class *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o - %t-rw.cpp | FileCheck %t-rw.cpp
 // radar 7738453
 
 void *sel_registerName(const char *);