зеркало из https://github.com/microsoft/clang.git
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60563 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
06de37bade
Коммит
ae0ee03fd9
|
@ -462,6 +462,9 @@ LaxVectorConversions("flax-vector-conversions",
|
|||
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 @@ Ansi("ansi", llvm::cl::desc("Equivalent to specifying -std=c89."));
|
|||
|
||||
// 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 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
|
|||
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)
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
// FIXME: The default should be 1.
|
||||
ThreadsafeStatics = 0;
|
||||
Blocks = 1;
|
||||
Blocks = 0;
|
||||
}
|
||||
|
||||
GCMode getGCMode() const { return (GCMode) GC; }
|
||||
|
|
|
@ -86,40 +86,70 @@ static void getLinuxDefines(std::vector<char> &Defs) {
|
|||
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 @@ public:
|
|||
};
|
||||
} // end anonymous namespace.
|
||||
|
||||
|
||||
namespace {
|
||||
class DarwinPPCTargetInfo : public PPC32TargetInfo {
|
||||
public:
|
||||
|
@ -371,7 +402,7 @@ public:
|
|||
/// 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 @@ public:
|
|||
/// 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 @@ public:
|
|||
/// 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 @@ public:
|
|||
/// 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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang %s -fsyntax-only -verify
|
||||
// RUN: clang %s -fsyntax-only -verify -fblocks
|
||||
|
||||
void take(void*);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang %s -fsyntax-only -verify
|
||||
// RUN: clang %s -fsyntax-only -verify -fblocks
|
||||
|
||||
@interface Whatever
|
||||
- copy;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang %s -fsyntax-only -verify
|
||||
// RUN: clang %s -fsyntax-only -verify -fblocks
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang -fsyntax-only -verify %s
|
||||
// RUN: clang -fsyntax-only -verify %s -fblocks
|
||||
|
||||
int (*FP)();
|
||||
int (^IFP) ();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang -fsyntax-only %s -verify
|
||||
// RUN: clang -fsyntax-only %s -verify -fblocks
|
||||
|
||||
void I( void (^)(void));
|
||||
void (^noop)(void);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang -fsyntax-only -verify %s
|
||||
// RUN: clang -fsyntax-only -verify %s -fblocks
|
||||
void donotwarn();
|
||||
|
||||
int (^IFP) ();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang -fsyntax-only %s -verify
|
||||
// RUN: clang -fsyntax-only %s -verify -fblocks
|
||||
|
||||
typedef void (^CL)(void);
|
||||
|
||||
|
|
|
@ -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){}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang -fsyntax-only -verify %s
|
||||
// RUN: clang -fsyntax-only -verify %s -fblocks
|
||||
|
||||
void tovoid(void*);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang -fsyntax-only -verify %s
|
||||
// RUN: clang -fsyntax-only -verify %s -fblocks
|
||||
|
||||
@interface NSObject {
|
||||
struct objc_object *isa;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang -fsyntax-only -verify %s
|
||||
// RUN: clang -fsyntax-only -verify %s -fblocks
|
||||
|
||||
// Check property attribute consistency.
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче