From: Fariborz Jahanian Date: Thu, 15 Nov 2012 19:02:45 +0000 (+0000) Subject: block extended signatur option. Change previous option X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d145f660a23d5bdabdd1ead83c51f3df1489b09;p=clang block extended signatur option. Change previous option to a cc1 -fencode-extended-block-signature and pass it to cc1 and recognize this option to produce extended block type signature. // rdar://12109031 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168063 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def index 8e90bf2a56..fc78e929a9 100644 --- a/include/clang/Basic/LangOptions.def +++ b/include/clang/Basic/LangOptions.def @@ -53,6 +53,8 @@ LANGOPT(ObjC1 , 1, 0, "Objective-C 1") LANGOPT(ObjC2 , 1, 0, "Objective-C 2") BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, "Objective-C auto-synthesized properties") +BENIGN_LANGOPT(EncodeExtendedBlockSig , 1, 0, + "Encoding extended block type signature") BENIGN_LANGOPT(ObjCInferRelatedResultType , 1, 1, "Objective-C related result type inference") LANGOPT(Trigraphs , 1, 0,"trigraphs") @@ -104,7 +106,6 @@ LANGOPT(FastMath , 1, 0, "__FAST_MATH__ predefined macro") LANGOPT(FiniteMathOnly , 1, 0, "__FINITE_MATH_ONLY__ predefined macro") BENIGN_LANGOPT(ObjCGCBitmapPrint , 1, 0, "printing of GC's bitmap layout for __weak/__strong ivars") -BENIGN_LANGOPT(ObjCExtendedBlockEncode , 1, 1, "Do extended encoding of block type signature") BENIGN_LANGOPT(AccessControl , 1, 1, "C++ access control") LANGOPT(CharIsSigned , 1, 1, "signed char") diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index be0653cb9c..5761d2e17a 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -406,6 +406,8 @@ 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 fencode_extended_block_signature : Flag<["-"], "fencode-extended-block-signature">, + HelpText<"enable extended encoding of block type signature">; def pic_level : Separate<["-"], "pic-level">, HelpText<"Value for __PIC__">; def pie_level : Separate<["-"], "pie-level">, diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 7d437a6f31..77ba17a2b4 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -929,8 +929,6 @@ def print_file_name_EQ : Joined<["-", "--"], "print-file-name=">, HelpText<"Print the full library path of ">, MetaVarName<"">; def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>, HelpText<"Enable Objective-C Ivar layout bitmap print trace">; -def encode_extended_block_sig : Flag<["-"], "encode-extended-block-signature">, Flags<[CC1Option]>, - HelpText<"Enable encoding of the extended block type signature">; def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">, HelpText<"Print the library path for \"libgcc.a\"">; def print_multi_directory : Flag<["-", "--"], "print-multi-directory">; diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h index 71736d666e..89f2697747 100644 --- a/include/clang/Driver/ToolChain.h +++ b/include/clang/Driver/ToolChain.h @@ -148,6 +148,10 @@ public: /// IsObjCDefaultSynthPropertiesDefault - Does this tool chain enable /// -fobjc-default-synthesize-properties by default. virtual bool IsObjCDefaultSynthPropertiesDefault() const { return false; } + + /// IsEncodeExtendedBlockSignatureDefault - Does this tool chain enable + /// -fencode-extended-block-signature by default. + virtual bool IsEncodeExtendedBlockSignatureDefault() const { return false; } /// IsObjCNonFragileABIDefault - Does this tool chain set /// -fobjc-nonfragile-abi by default. diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index c192d28860..5a9225000a 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -4511,7 +4511,7 @@ std::string ASTContext::getObjCEncodingForBlock(const BlockExpr *Expr) const { QualType BlockTy = Expr->getType()->getAs()->getPointeeType(); // Encode result type. - if (getLangOpts().ObjCExtendedBlockEncode) + if (getLangOpts().EncodeExtendedBlockSig) getObjCEncodingForMethodParameter(Decl::OBJC_TQ_None, BlockTy->getAs()->getResultType(), S, true /*Extended*/); @@ -4552,7 +4552,7 @@ std::string ASTContext::getObjCEncodingForBlock(const BlockExpr *Expr) const { PType = PVDecl->getType(); } else if (PType->isFunctionType()) PType = PVDecl->getType(); - if (getLangOpts().ObjCExtendedBlockEncode) + if (getLangOpts().EncodeExtendedBlockSig) getObjCEncodingForMethodParameter(Decl::OBJC_TQ_None, PType, S, true /*Extended*/); else diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 8ea466af77..2005d9654c 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -318,6 +318,10 @@ public: return true; } + virtual bool IsEncodeExtendedBlockSignatureDefault() const { + return true; + } + virtual bool IsObjCNonFragileABIDefault() const { // Non-fragile ABI is default for everything but i386. return getTriple().getArch() != llvm::Triple::x86; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index b1e450d21c..4dea717f98 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2727,6 +2727,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-fobjc-default-synthesize-properties"); } + // -fencode-extended-block-signature=1 is default. + if (getToolChain().IsEncodeExtendedBlockSignatureDefault()) { + CmdArgs.push_back("-fencode-extended-block-signature"); + } + // Allow -fno-objc-arr to trump -fobjc-arr/-fobjc-arc. // NOTE: This logic is duplicated in ToolChains.cpp. bool ARC = isObjCAutoRefCount(Args); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index df4c88389c..2e8ae63831 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1126,8 +1126,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, if (Args.hasArg(OPT_print_ivar_layout)) Opts.ObjCGCBitmapPrint = 1; - if (Args.hasArg(OPT_encode_extended_block_sig)) - Opts.ObjCExtendedBlockEncode = 1; if (Args.hasArg(OPT_fno_constant_cfstrings)) Opts.NoConstantCFStrings = 1; @@ -1216,6 +1214,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Args.getLastArgValue(OPT_fconstant_string_class); Opts.ObjCDefaultSynthProperties = Args.hasArg(OPT_fobjc_default_synthesize_properties); + Opts.EncodeExtendedBlockSig = + Args.hasArg(OPT_fencode_extended_block_signature); Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls); Opts.PackStruct = Args.getLastArgIntValue(OPT_fpack_struct_EQ, 0, Diags); Opts.PICLevel = Args.getLastArgIntValue(OPT_pic_level, 0, Diags); diff --git a/test/CodeGenObjC/extended-block-signature-encode.m b/test/CodeGenObjC/extended-block-signature-encode.m index 0db41edf9a..a380856da5 100644 --- a/test/CodeGenObjC/extended-block-signature-encode.m +++ b/test/CodeGenObjC/extended-block-signature-encode.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -encode-extended-block-signature -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s -check-prefix=EXPANDED +// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fencode-extended-block-signature -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s -check-prefix=BRIEF // rdar://12109031 @class NSString, NSArray; @@ -12,4 +12,4 @@ int main () ^(BBB arg1, double arg2){ return b1; }(0, 3.14); } // CHECK: @{{.*}} = private unnamed_addr constant [64 x i8] c"@?<@\22NSString\22@?@\22NSArray\22>24@?0@?<@\22NSString\22@?@\22NSArray\22>8d16\00" -// CHECK-EXPANDED: @{{.*}} = private unnamed_addr constant [64 x i8] c"@?<@\22NSString\22@?@\22NSArray\22>24@?0@?<@\22NSString\22@?@\22NSArray\22>8d16\00" +// CHECK-BRIEF: @{{.*}} = private unnamed_addr constant [14 x i8] c"@?24@?0@?8d16\00" diff --git a/test/Driver/rewrite-legacy-objc.m b/test/Driver/rewrite-legacy-objc.m index a76175f68a..2e3f4218ef 100644 --- a/test/Driver/rewrite-legacy-objc.m +++ b/test/Driver/rewrite-legacy-objc.m @@ -3,5 +3,5 @@ // TEST0: clang{{.*}}" "-cc1" // TEST0: "-rewrite-objc" // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. -// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" +// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-default-synthesize-properties" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" // TEST0: rewrite-legacy-objc.m" diff --git a/test/Driver/rewrite-objc.m b/test/Driver/rewrite-objc.m index ca578cf40e..fa159a6258 100644 --- a/test/Driver/rewrite-objc.m +++ b/test/Driver/rewrite-objc.m @@ -3,4 +3,4 @@ // TEST0: clang{{.*}}" "-cc1" // TEST0: "-rewrite-objc" // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. -// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" +// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"