diff options
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Basic/DiagnosticDriverKinds.td | 2 | ||||
-rw-r--r-- | include/clang/Basic/LangOptions.def | 3 | ||||
-rw-r--r-- | include/clang/Basic/LangOptions.h | 3 | ||||
-rw-r--r-- | include/clang/Basic/ObjCRuntime.h | 184 | ||||
-rw-r--r-- | include/clang/Basic/VersionTuple.h | 5 | ||||
-rw-r--r-- | include/clang/Driver/CC1Options.td | 6 | ||||
-rw-r--r-- | include/clang/Driver/ObjCRuntime.h | 49 | ||||
-rw-r--r-- | include/clang/Driver/Options.td | 4 | ||||
-rw-r--r-- | include/clang/Driver/ToolChain.h | 9 | ||||
-rw-r--r-- | include/clang/Frontend/CodeGenOptions.h | 4 | ||||
-rw-r--r-- | include/clang/Serialization/ASTReader.h | 6 |
11 files changed, 205 insertions, 70 deletions
diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td index fdd3ff5881..0e548253cc 100644 --- a/include/clang/Basic/DiagnosticDriverKinds.td +++ b/include/clang/Basic/DiagnosticDriverKinds.td @@ -99,6 +99,8 @@ def err_drv_mg_requires_m_or_mm : Error< "option '-MG' requires '-M' or '-MM'">; def err_drv_asan_android_requires_pie : Error< "AddressSanitizer on Android requires '-pie'">; +def err_drv_unknown_objc_runtime : Error< + "unknown or ill-formed Objective-C runtime '%0'">; def warn_c_kext : Warning< "ignoring -fapple-kext which is valid for c++ and objective-c++ only">; diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def index 200236a133..b525e43e06 100644 --- a/include/clang/Basic/LangOptions.def +++ b/include/clang/Basic/LangOptions.def @@ -50,8 +50,6 @@ LANGOPT(CPlusPlus , 1, 0, "C++") LANGOPT(CPlusPlus0x , 1, 0, "C++0x") LANGOPT(ObjC1 , 1, 0, "Objective-C 1") LANGOPT(ObjC2 , 1, 0, "Objective-C 2") -LANGOPT(ObjCNonFragileABI , 1, 0, "Objective-C modern abi") -LANGOPT(ObjCNonFragileABI2 , 1, 0, "Objective-C enhanced modern abi") BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, "Objective-C auto-synthesized properties") BENIGN_LANGOPT(ObjCInferRelatedResultType , 1, 1, @@ -80,7 +78,6 @@ LANGOPT(SjLjExceptions , 1, 0, "setjmp-longjump exception handling") LANGOPT(TraditionalCPP , 1, 0, "traditional CPP emulation") LANGOPT(RTTI , 1, 1, "run-time type information") LANGOPT(MSBitfields , 1, 0, "Microsoft-compatible structure layout") -LANGOPT(NeXTRuntime , 1, 1, "NeXT Objective-C runtime") LANGOPT(Freestanding, 1, 0, "freestanding implementation") LANGOPT(NoBuiltin , 1, 0, "disable builtin functions") diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index ce4ff063c6..9c3b011f9c 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -16,6 +16,7 @@ #include <string> #include "clang/Basic/LLVM.h" +#include "clang/Basic/ObjCRuntime.h" #include "clang/Basic/Visibility.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" @@ -55,6 +56,8 @@ public: }; public: + clang::ObjCRuntime ObjCRuntime; + std::string ObjCConstantStringClass; /// The name of the handler function to be called when -ftrapv is specified. diff --git a/include/clang/Basic/ObjCRuntime.h b/include/clang/Basic/ObjCRuntime.h new file mode 100644 index 0000000000..b87632ff6a --- /dev/null +++ b/include/clang/Basic/ObjCRuntime.h @@ -0,0 +1,184 @@ +//===--- ObjCRuntime.h - Objective-C Runtime Configuration ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines types useful for describing an Objective-C runtime. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_OBJCRUNTIME_H +#define LLVM_CLANG_OBJCRUNTIME_H + +#include "clang/Basic/VersionTuple.h" +#include "llvm/Support/ErrorHandling.h" + +namespace clang { + +/// The basic abstraction for the target ObjC runtime. +class ObjCRuntime { +public: + /// The basic Objective-C runtimes that we know about. + enum Kind { + /// 'macosx' is the Apple-provided NeXT-derived runtime on Mac OS + /// X platforms that use the non-fragile ABI; the version is a + /// release of that OS. + MacOSX, + + /// 'macosx-fragile' is the Apple-provided NeXT-derived runtime on + /// Mac OS X platforms that use the fragile ABI; the version is a + /// release of that OS. + FragileMacOSX, + + /// 'ios' is the Apple-provided NeXT-derived runtime on iOS or the iOS + /// simulator; it is always non-fragile. The version is a release + /// version of iOS. + iOS, + + /// 'gnu' is the non-fragile GNU runtime. + GNU, + + /// 'gnu-fragile' is the fragile GNU runtime. + FragileGNU + }; + +private: + Kind TheKind; + VersionTuple Version; + +public: + /// A bogus initialization of the runtime. + ObjCRuntime() : TheKind(MacOSX) {} + + ObjCRuntime(Kind kind, const VersionTuple &version) + : TheKind(kind), Version(version) {} + + void set(Kind kind, VersionTuple version) { + TheKind = kind; + Version = version; + } + + Kind getKind() const { return TheKind; } + const VersionTuple &getVersion() const { return Version; } + + /// Does this runtime follow the set of implied behaviors for a + /// "non-fragile" ABI? + bool isNonFragile() const { + switch (getKind()) { + case FragileMacOSX: return false; + case FragileGNU: return false; + case MacOSX: return true; + case GNU: return true; + case iOS: return true; + } + llvm_unreachable("bad kind"); + } + + /// The inverse of isNonFragile(): does this runtiem follow the set of + /// implied behaviors for a "fragile" ABI? + bool isFragile() const { return !isNonFragile(); } + + /// Is this runtime basically of the GNU family of runtimes? + bool isGNUFamily() const { + switch (getKind()) { + case FragileMacOSX: + case MacOSX: + case iOS: + return false; + case FragileGNU: + case GNU: + return true; + } + llvm_unreachable("bad kind"); + } + + /// Is this runtime basically of the NeXT family of runtimes? + bool isNeXTFamily() const { + // For now, this is just the inverse of isGNUFamily(), but that's + // not inherently true. + return !isGNUFamily(); + } + + /// Does this runtime natively provide the ARC entrypoints? ARC + /// cannot be directly supported on a platform that does not provide + /// these entrypoints, although it may be supportable via a stub + /// library. + bool hasARC() const { + switch (getKind()) { + case FragileMacOSX: return false; + case MacOSX: return getVersion() >= VersionTuple(10, 7); + case iOS: return getVersion() >= VersionTuple(5); + + // This is really a lie, because some implementations and versions + // of the runtime do not support ARC. Probably -fgnu-runtime + // should imply a "maximal" runtime or something? + case FragileGNU: return true; + case GNU: return true; + } + llvm_unreachable("bad kind"); + } + + /// Does this runtime natively provide ARC-compliant 'weak' + /// entrypoints? + bool hasWeak() const { + // Right now, this is always equivalent to the ARC decision. + return hasARC(); + } + + /// Does this runtime directly support the subscripting methods? + /// This is really a property of the library, not the runtime. + bool hasSubscripting() const { + switch (getKind()) { + case FragileMacOSX: return false; + case MacOSX: return getVersion() >= VersionTuple(10, 8); + case iOS: return false; + + // This is really a lie, because some implementations and versions + // of the runtime do not support ARC. Probably -fgnu-runtime + // should imply a "maximal" runtime or something? + case FragileGNU: return true; + case GNU: return true; + } + llvm_unreachable("bad kind"); + } + + /// Does this runtime provide an objc_terminate function? This is + /// used in handlers for exceptions during the unwind process; + /// without it, abort() must be used in pure ObjC files. + bool hasTerminate() const { + switch (getKind()) { + case FragileMacOSX: return getVersion() >= VersionTuple(10, 8); + case MacOSX: return getVersion() >= VersionTuple(10, 8); + case iOS: return getVersion() >= VersionTuple(5); + case FragileGNU: return false; + case GNU: return false; + } + llvm_unreachable("bad kind"); + } + + /// Try to parse an Objective-C runtime specification from the given string. + /// + /// Return true on error. + bool tryParse(StringRef input); + + std::string getAsString() const; + + friend bool operator==(const ObjCRuntime &left, const ObjCRuntime &right) { + return left.getKind() == right.getKind() && + left.getVersion() == right.getVersion(); + } + + friend bool operator!=(const ObjCRuntime &left, const ObjCRuntime &right) { + return !(left == right); + } +}; + +raw_ostream &operator<<(raw_ostream &out, const ObjCRuntime &value); + +} // end namespace clang + +#endif diff --git a/include/clang/Basic/VersionTuple.h b/include/clang/Basic/VersionTuple.h index 30ef6641ef..814350d82d 100644 --- a/include/clang/Basic/VersionTuple.h +++ b/include/clang/Basic/VersionTuple.h @@ -114,6 +114,11 @@ public: /// \brief Retrieve a string representation of the version number/ std::string getAsString() const; + + /// \brief Try to parse the given string as a version number. + /// Returns true if the string does not match the regular expression + /// [0-9]+(\.[0-9]+(\.[0-9]+)) + bool tryParse(StringRef string); }; /// \brief Print a version number. diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 3f4c573291..da22046f36 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -386,18 +386,12 @@ def fconstant_string_class : Separate<"-fconstant-string-class">, HelpText<"Specify the class to use for constant Objective-C string objects.">; def fobjc_arc_cxxlib_EQ : Joined<"-fobjc-arc-cxxlib=">, HelpText<"Objective-C++ Automatic Reference Counting standard library kind">; -def fobjc_runtime_has_arc : Flag<"-fobjc-runtime-has-arc">, - HelpText<"The target Objective-C runtime provides ARC entrypoints">; def fobjc_runtime_has_weak : Flag<"-fobjc-runtime-has-weak">, HelpText<"The target Objective-C runtime supports ARC weak operations">; -def fobjc_runtime_has_terminate : Flag<"-fobjc-runtime-has-terminate">, - HelpText<"The target Objective-C runtime provides an objc_terminate entrypoint">; def fobjc_dispatch_method_EQ : Joined<"-fobjc-dispatch-method=">, HelpText<"Objective-C dispatch method to use">; def fobjc_default_synthesize_properties : Flag<"-fobjc-default-synthesize-properties">, HelpText<"enable the default synthesis of Objective-C properties">; -def fobjc_fragile_abi : Flag<"-fobjc-fragile-abi">, - HelpText<"Use Objective-C's fragile ABI">; def pic_level : Separate<"-pic-level">, HelpText<"Value for __PIC__">; def pie_level : Separate<"-pie-level">, diff --git a/include/clang/Driver/ObjCRuntime.h b/include/clang/Driver/ObjCRuntime.h deleted file mode 100644 index 094873a7d1..0000000000 --- a/include/clang/Driver/ObjCRuntime.h +++ /dev/null @@ -1,49 +0,0 @@ -//===--- ObjCRuntime.h - Objective C runtime features -----------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef CLANG_DRIVER_OBJCRUNTIME_H_ -#define CLANG_DRIVER_OBJCRUNTIME_H_ - -namespace clang { -namespace driver { - -class ObjCRuntime { -public: - enum Kind { GNU, NeXT }; -private: - unsigned RuntimeKind : 1; -public: - void setKind(Kind k) { RuntimeKind = k; } - Kind getKind() const { return static_cast<Kind>(RuntimeKind); } - - /// True if the runtime provides native ARC entrypoints. ARC may - /// still be usable without this if the tool-chain provides a - /// statically-linked runtime support library. - unsigned HasARC : 1; - - /// True if the runtime supports ARC zeroing __weak. - unsigned HasWeak : 1; - - /// \brief True if the runtime supports subscripting methods. - unsigned HasSubscripting : 1; - - /// True if the runtime provides the following entrypoint: - /// void objc_terminate(void); - /// If available, this will be called instead of abort() when an - /// exception is thrown out of an EH cleanup. - unsigned HasTerminate : 1; - - ObjCRuntime() : RuntimeKind(NeXT), HasARC(false), HasWeak(false), - HasSubscripting(false), HasTerminate(false) {} -}; - -} -} - -#endif diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index e0ddd707eb..2e73cc449a 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -418,7 +418,7 @@ def fgnu_keywords : Flag<"-fgnu-keywords">, Group<f_Group>, Flags<[CC1Option]>, def fgnu89_inline : Flag<"-fgnu89-inline">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Use the gnu89 inline semantics">; def fno_gnu89_inline : Flag<"-fno-gnu89-inline">, Group<f_Group>; -def fgnu_runtime : Flag<"-fgnu-runtime">, Group<f_Group>, Flags<[CC1Option]>, +def fgnu_runtime : Flag<"-fgnu-runtime">, Group<f_Group>, HelpText<"Generate output compatible with the standard GNU Objective-C runtime">; def fheinous_gnu_extensions : Flag<"-fheinous-gnu-extensions">, Flags<[CC1Option]>; def filelist : Separate<"-filelist">, Flags<[LinkerInput]>; @@ -565,6 +565,8 @@ def fno_objc_infer_related_result_type : Flag< def fobjc_link_runtime: Flag<"-fobjc-link-runtime">, Group<f_Group>; // Objective-C ABI options. +def fobjc_runtime_EQ : Joined<"-fobjc-runtime=">, Group<f_Group>, Flags<[CC1Option]>, + HelpText<"Specify the target Objective-C runtime kind and version">; def fobjc_abi_version_EQ : Joined<"-fobjc-abi-version=">, Group<f_Group>; def fobjc_nonfragile_abi_version_EQ : Joined<"-fobjc-nonfragile-abi-version=">, Group<f_Group>; def fobjc_nonfragile_abi : Flag<"-fobjc-nonfragile-abi">, Group<f_Group>; diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h index 72171af163..642d8a4274 100644 --- a/include/clang/Driver/ToolChain.h +++ b/include/clang/Driver/ToolChain.h @@ -18,6 +18,8 @@ #include <string> namespace clang { + class ObjCRuntime; + namespace driver { class ArgList; class Compilation; @@ -25,7 +27,6 @@ namespace driver { class Driver; class InputArgList; class JobAction; - class ObjCRuntime; class Tool; /// ToolChain - Access to tools for a single platform. @@ -210,11 +211,11 @@ public: virtual std::string ComputeEffectiveClangTriple(const ArgList &Args, types::ID InputType = types::TY_INVALID) const; - /// configureObjCRuntime - Configure the known properties of the - /// Objective-C runtime for this platform. + /// getDefaultObjCRuntime - Return the default Objective-C runtime + /// for this platform. /// /// FIXME: this really belongs on some sort of DeploymentTarget abstraction - virtual void configureObjCRuntime(ObjCRuntime &runtime) const; + virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const; /// hasBlocksRuntime - Given that the user is compiling with /// -fblocks, does this tool chain guarantee the existence of a diff --git a/include/clang/Frontend/CodeGenOptions.h b/include/clang/Frontend/CodeGenOptions.h index 6c77e424e7..c3ac10c982 100644 --- a/include/clang/Frontend/CodeGenOptions.h +++ b/include/clang/Frontend/CodeGenOptions.h @@ -90,8 +90,6 @@ public: unsigned NoNaNsFPMath : 1; ///< Assume FP arguments, results not NaN. unsigned NoZeroInitializedInBSS : 1; ///< -fno-zero-initialized-in-bss unsigned ObjCDispatchMethod : 2; ///< Method of Objective-C dispatch to use. - unsigned ObjCRuntimeHasARC : 1; ///< The target runtime supports ARC natively - unsigned ObjCRuntimeHasTerminate : 1; ///< The ObjC runtime has objc_terminate unsigned OmitLeafFramePointer : 1; ///< Set when -momit-leaf-frame-pointer is ///< enabled. unsigned OptimizationLevel : 3; ///< The -O[0-4] option specified. @@ -209,8 +207,6 @@ public: NumRegisterParameters = 0; ObjCAutoRefCountExceptions = 0; ObjCDispatchMethod = Legacy; - ObjCRuntimeHasARC = 0; - ObjCRuntimeHasTerminate = 0; OmitLeafFramePointer = 0; OptimizationLevel = 0; OptimizeSize = 0; diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index d084254ead..88dde868b6 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -199,6 +199,8 @@ class ASTReader public ExternalSLocEntrySource { public: + typedef SmallVector<uint64_t, 64> RecordData; + enum ASTReadResult { Success, Failure, IgnorePCH }; /// \brief Types of AST files. friend class PCHValidator; @@ -801,7 +803,7 @@ private: llvm::BitstreamCursor &SLocCursorForID(int ID); SourceLocation getImportLocation(ModuleFile *F); ASTReadResult ReadSubmoduleBlock(ModuleFile &F); - bool ParseLanguageOptions(const SmallVectorImpl<uint64_t> &Record); + bool ParseLanguageOptions(const RecordData &Record); struct RecordLocation { RecordLocation(ModuleFile *M, uint64_t O) @@ -862,8 +864,6 @@ private: ASTReader(const ASTReader&); // do not implement ASTReader &operator=(const ASTReader &); // do not implement public: - typedef SmallVector<uint64_t, 64> RecordData; - /// \brief Load the AST file and validate its contents against the given /// Preprocessor. /// |