[cfe-commits] r60563 - in /cfe/trunk: Driver/clang.cpp include/clang/Basic/LangOptions.h lib/Basic/Targets.cpp test/Analysis/misc-ps.m test/Parser/block-pointer-decl.c test/Rewriter/block-test.c test/Sema/block-args.c test/Sema/block-as-object.m test/Sema/block-byref-args.c test/Sema/block-call.c test/Sema/block-literal.c test/Sema/block-misc.c test/Sema/block-return.c test/Sema/block-storageclass.c test/SemaCXX/blocks.cpp test/SemaObjC/block-ivar.m test/SemaObjC/property-10.m
Chris Lattner
sabre at nondot.org
Thu Dec 4 15:20:07 PST 2008
Author: lattner
Date: Thu Dec 4 17:20:07 2008
New Revision: 60563
URL: http://llvm.org/viewvc/llvm-project?rev=60563&view=rev
Log:
instead of forcing blocks on by default, make them default to off, but let
specific targets default them to on. Default blocks to on on 10.6 and later.
Add a -fblocks option that allows the user to override the target's default.
Use -fblocks in the various testcases that use blocks.
Modified:
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Analysis/misc-ps.m
cfe/trunk/test/Parser/block-pointer-decl.c
cfe/trunk/test/Rewriter/block-test.c
cfe/trunk/test/Sema/block-args.c
cfe/trunk/test/Sema/block-as-object.m
cfe/trunk/test/Sema/block-byref-args.c
cfe/trunk/test/Sema/block-call.c
cfe/trunk/test/Sema/block-literal.c
cfe/trunk/test/Sema/block-misc.c
cfe/trunk/test/Sema/block-return.c
cfe/trunk/test/Sema/block-storageclass.c
cfe/trunk/test/SemaCXX/blocks.cpp
cfe/trunk/test/SemaObjC/block-ivar.m
cfe/trunk/test/SemaObjC/property-10.m
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Dec 4 17:20:07 2008
@@ -462,6 +462,9 @@
llvm::cl::desc("Allow implicit conversions between vectors"
" with a different number of elements or "
"different element types"));
+static llvm::cl::opt<bool>
+EnableBlocks("fblocks", llvm::cl::desc("enable the 'blocks' language feature"));
+
// FIXME: This (and all GCC -f options) really come in -f... and
// -fno-... forms, and additionally support automagic behavior when
@@ -494,7 +497,6 @@
// FIXME: add:
// -fdollars-in-identifiers
-// -fpascal-strings
static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
TargetInfo *Target) {
// Allow the target to set the default the langauge options as it sees fit.
@@ -570,11 +572,14 @@
Options.Trigraphs = LangStd < lang_gnu_START || Trigraphs ? 1 : 0;
Options.DollarIdents = 1; // FIXME: Really a target property.
- Options.PascalStrings = PascalStrings;
+ if (PascalStrings.getPosition())
+ Options.PascalStrings = PascalStrings;
Options.Microsoft = MSExtensions;
Options.WritableStrings = WritableStrings;
Options.LaxVectorConversions = LaxVectorConversions;
Options.Exceptions = Exceptions;
+ if (EnableBlocks.getPosition())
+ Options.Blocks = EnableBlocks;
// Override the default runtime if the user requested it.
if (NeXTRuntime)
Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Thu Dec 4 17:20:07 2008
@@ -69,7 +69,7 @@
// FIXME: The default should be 1.
ThreadsafeStatics = 0;
- Blocks = 1;
+ Blocks = 0;
}
GCMode getGCMode() const { return (GCMode) GC; }
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Dec 4 17:20:07 2008
@@ -86,40 +86,70 @@
Define(Defs, "__gnu_linux__");
}
+/// getDarwinNumber - Parse the 'darwin number' out of the specific targe
+/// triple. For example, if we have darwin8.5 return 8,5,4. If any entry is
+/// not defined, return 0's. Return true if we have -darwin in the string or
+/// false otherwise.
+static bool getDarwinNumber(const char *Triple, unsigned &Maj, unsigned &Min) {
+ Maj = Min = 0;
+ const char *Darwin = strstr(Triple, "-darwin");
+ if (Darwin == 0) return false;
+
+ Darwin += strlen("-darwin");
+ if (Darwin[0] < '0' || Darwin[0] > '9')
+ return true;
+
+ Maj = Darwin[0]-'0';
+ ++Darwin;
+
+ // Handle "darwin11".
+ if (Maj == 1 && Darwin[0] >= '0' && Darwin[0] <= '9') {
+ Maj = 10+Darwin[0]-'0';
+ ++Darwin;
+ }
+
+ // Handle minor version: 10.4.9 -> darwin8.9 -> "1049"
+ if (Darwin[0] == '.' && Darwin[1] >= '0' && Darwin[1] <= '9' &&
+ Darwin[2] == '\0')
+ Min = Darwin[1]-'0';
+
+ return true;
+}
+
static void getDarwinDefines(std::vector<char> &Defs, const char *Triple) {
Define(Defs, "__APPLE__");
Define(Defs, "__MACH__");
// Figure out which "darwin number" the target triple is. "darwin9" -> 10.5.
- const char *Darwin = strstr(Triple, "-darwin");
- if (Darwin) {
+ unsigned Maj, Min;
+ if (getDarwinNumber(Triple, Maj, Min)) {
char DarwinStr[] = "1000";
- Darwin += strlen("-darwin");
- if (Darwin[0] >= '0' && Darwin[0] <= '9') {
- unsigned DarwinNo = Darwin[0]-'0';
- ++Darwin;
-
- // Handle "darwin11".
- if (DarwinNo == 1 && Darwin[0] >= '0' && Darwin[0] <= '9') {
- DarwinNo = 10+Darwin[0]-'0';
- ++Darwin;
- }
-
- if (DarwinNo >= 4 && DarwinNo <= 13) { // 10.0-10.9
- // darwin7 -> 1030, darwin8 -> 1040, darwin9 -> 1050, etc.
- DarwinStr[2] = '0' + DarwinNo-4;
- }
-
- // Handle minor version: 10.4.9 -> darwin8.9 -> "1049"
- if (Darwin[0] == '.' && Darwin[1] >= '0' && Darwin[1] <= '9' &&
- Darwin[2] == '\0')
- DarwinStr[3] = Darwin[1];
-
+ if (Maj >= 4 && Maj <= 13) { // 10.0-10.9
+ // darwin7 -> 1030, darwin8 -> 1040, darwin9 -> 1050, etc.
+ DarwinStr[2] = '0' + Maj-4;
}
+
+ // Handle minor version: 10.4.9 -> darwin8.9 -> "1049"
+ DarwinStr[3] = Min+'0';
Define(Defs, "__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", DarwinStr);
}
}
+/// GetDarwinLanguageOptions - Set the default language options for darwin.
+static void GetDarwinLanguageOptions(LangOptions &Opts,
+ const char *Triple) {
+ Opts.NeXTRuntime = true;
+
+ unsigned Maj, Min;
+ if (!getDarwinNumber(Triple, Maj, Min))
+ return;
+
+ // Blocks default to on for 10.6 (darwin10) and beyond.
+ if (Maj > 9)
+ Opts.Blocks = 1;
+}
+
+
//===----------------------------------------------------------------------===//
// Defines specific to certain architectures.
//===----------------------------------------------------------------------===//
@@ -358,6 +388,7 @@
};
} // end anonymous namespace.
+
namespace {
class DarwinPPCTargetInfo : public PPC32TargetInfo {
public:
@@ -371,7 +402,7 @@
/// various language options. These may be overridden by command line
/// options.
virtual void getDefaultLangOptions(LangOptions &Opts) {
- Opts.NeXTRuntime = true;
+ GetDarwinLanguageOptions(Opts, getTargetTriple());
}
};
} // end anonymous namespace.
@@ -389,7 +420,7 @@
/// various language options. These may be overridden by command line
/// options.
virtual void getDefaultLangOptions(LangOptions &Opts) {
- Opts.NeXTRuntime = true;
+ GetDarwinLanguageOptions(Opts, getTargetTriple());
}
};
} // end anonymous namespace.
@@ -541,7 +572,7 @@
/// various language options. These may be overridden by command line
/// options.
virtual void getDefaultLangOptions(LangOptions &Opts) {
- Opts.NeXTRuntime = true;
+ GetDarwinLanguageOptions(Opts, getTargetTriple());
}
};
} // end anonymous namespace
@@ -690,7 +721,7 @@
/// various language options. These may be overridden by command line
/// options.
virtual void getDefaultLangOptions(LangOptions &Opts) {
- Opts.NeXTRuntime = true;
+ GetDarwinLanguageOptions(Opts, getTargetTriple());
}
};
} // end anonymous namespace.
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang -checker-cfref --verify %s
+// RUN: clang -checker-cfref --verify -fblocks %s
// Reduced test case from crash in <rdar://problem/6253157>
@class NSObject;
Modified: cfe/trunk/test/Parser/block-pointer-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/block-pointer-decl.c?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Parser/block-pointer-decl.c (original)
+++ cfe/trunk/test/Parser/block-pointer-decl.c Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify -parse-noop %s
+// RUN: clang -fsyntax-only -verify -parse-noop -fblocks %s
struct blockStruct {
int (^a)(float, int);
Modified: cfe/trunk/test/Rewriter/block-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/block-test.c?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/block-test.c (original)
+++ cfe/trunk/test/Rewriter/block-test.c Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang -rewrite-blocks %s -o -
+// RUN: clang -rewrite-blocks %s -fblocks -o -
static int (^block)(const void *, const void *) = (int (^)(const void *, const void *))0;
static int (*func)(int (^block)(void *, void *)) = (int (*)(int (^block)(void *, void *)))0;
Modified: cfe/trunk/test/Sema/block-args.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-args.c?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-args.c (original)
+++ cfe/trunk/test/Sema/block-args.c Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang %s -fsyntax-only -verify
+// RUN: clang %s -fsyntax-only -verify -fblocks
void take(void*);
Modified: cfe/trunk/test/Sema/block-as-object.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-as-object.m?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-as-object.m (original)
+++ cfe/trunk/test/Sema/block-as-object.m Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang %s -fsyntax-only -verify
+// RUN: clang %s -fsyntax-only -verify -fblocks
@interface Whatever
- copy;
Modified: cfe/trunk/test/Sema/block-byref-args.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-byref-args.c?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-byref-args.c (original)
+++ cfe/trunk/test/Sema/block-byref-args.c Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang %s -fsyntax-only -verify
+// RUN: clang %s -fsyntax-only -verify -fblocks
#include <stdio.h>
Modified: cfe/trunk/test/Sema/block-call.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-call.c?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-call.c (original)
+++ cfe/trunk/test/Sema/block-call.c Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify %s -fblocks
int (*FP)();
int (^IFP) ();
Modified: cfe/trunk/test/Sema/block-literal.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-literal.c?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-literal.c (original)
+++ cfe/trunk/test/Sema/block-literal.c Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only %s -verify
+// RUN: clang -fsyntax-only %s -verify -fblocks
void I( void (^)(void));
void (^noop)(void);
Modified: cfe/trunk/test/Sema/block-misc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-misc.c?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-misc.c (original)
+++ cfe/trunk/test/Sema/block-misc.c Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify %s -fblocks
void donotwarn();
int (^IFP) ();
Modified: cfe/trunk/test/Sema/block-return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-return.c (original)
+++ cfe/trunk/test/Sema/block-return.c Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only %s -verify
+// RUN: clang -fsyntax-only %s -verify -fblocks
typedef void (^CL)(void);
Modified: cfe/trunk/test/Sema/block-storageclass.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-storageclass.c?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-storageclass.c (original)
+++ cfe/trunk/test/Sema/block-storageclass.c Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang %s -fsyntax-only -verify
+// RUN: clang %s -fsyntax-only -verify -fblocks
#include <stdio.h>
void _Block_byref_release(void*src){}
Modified: cfe/trunk/test/SemaCXX/blocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/blocks.cpp?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/blocks.cpp (original)
+++ cfe/trunk/test/SemaCXX/blocks.cpp Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify %s -fblocks
void tovoid(void*);
Modified: cfe/trunk/test/SemaObjC/block-ivar.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/block-ivar.m?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/block-ivar.m (original)
+++ cfe/trunk/test/SemaObjC/block-ivar.m Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify %s -fblocks
@interface NSObject {
struct objc_object *isa;
Modified: cfe/trunk/test/SemaObjC/property-10.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-10.m?rev=60563&r1=60562&r2=60563&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-10.m (original)
+++ cfe/trunk/test/SemaObjC/property-10.m Thu Dec 4 17:20:07 2008
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify %s -fblocks
// Check property attribute consistency.
More information about the cfe-commits
mailing list