[cfe-commits] r167997 - in /cfe/trunk: include/clang/Basic/LangOptions.def include/clang/Driver/Options.td lib/AST/ASTContext.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGenObjC/extended-block-signature-encode.m
Fariborz Jahanian
fjahanian at apple.com
Wed Nov 14 15:11:38 PST 2012
Author: fjahanian
Date: Wed Nov 14 17:11:38 2012
New Revision: 167997
URL: http://llvm.org/viewvc/llvm-project?rev=167997&view=rev
Log:
objective-C blocks: under cc1 flag -encode-extended-block-signature,
generate expanded signature encoding to include types as we
already do this for protocol method lists.
// rdar://12109031
Added:
cfe/trunk/test/CodeGenObjC/extended-block-signature-encode.m
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=167997&r1=167996&r2=167997&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Wed Nov 14 17:11:38 2012
@@ -104,6 +104,7 @@
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, 0, "Do extended encoding of block type signature")
BENIGN_LANGOPT(AccessControl , 1, 1, "C++ access control")
LANGOPT(CharIsSigned , 1, 1, "signed char")
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=167997&r1=167996&r2=167997&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Nov 14 17:11:38 2012
@@ -929,6 +929,8 @@
HelpText<"Print the full library path of <file>">, MetaVarName<"<file>">;
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">;
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=167997&r1=167996&r2=167997&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Nov 14 17:11:38 2012
@@ -4511,7 +4511,13 @@
QualType BlockTy =
Expr->getType()->getAs<BlockPointerType>()->getPointeeType();
// Encode result type.
- getObjCEncodingForType(BlockTy->getAs<FunctionType>()->getResultType(), S);
+ if (getLangOpts().ObjCExtendedBlockEncode)
+ getObjCEncodingForMethodParameter(Decl::OBJC_TQ_None,
+ BlockTy->getAs<FunctionType>()->getResultType(),
+ S, true /*Extended*/);
+ else
+ getObjCEncodingForType(BlockTy->getAs<FunctionType>()->getResultType(),
+ S);
// Compute size of all parameters.
// Start with computing size of a pointer in number of bytes.
// FIXME: There might(should) be a better way of doing this computation!
@@ -4546,7 +4552,11 @@
PType = PVDecl->getType();
} else if (PType->isFunctionType())
PType = PVDecl->getType();
- getObjCEncodingForType(PType, S);
+ if (getLangOpts().ObjCExtendedBlockEncode)
+ getObjCEncodingForMethodParameter(Decl::OBJC_TQ_None, PType,
+ S, true /*Extended*/);
+ else
+ getObjCEncodingForType(PType, S);
S += charUnitsToString(ParmOffset);
ParmOffset += getObjCEncodingTypeSize(PType);
}
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=167997&r1=167996&r2=167997&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Nov 14 17:11:38 2012
@@ -1113,6 +1113,8 @@
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;
Added: cfe/trunk/test/CodeGenObjC/extended-block-signature-encode.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/extended-block-signature-encode.m?rev=167997&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/extended-block-signature-encode.m (added)
+++ cfe/trunk/test/CodeGenObjC/extended-block-signature-encode.m Wed Nov 14 17:11:38 2012
@@ -0,0 +1,15 @@
+// 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=BRIEF
+// rdar://12109031
+
+ at class NSString, NSArray;
+
+typedef NSString*(^BBB)(NSArray*);
+
+int main ()
+{
+ BBB b1;
+ ^(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-BRIEF: @{{.*}} = private unnamed_addr constant [14 x i8] c"@?24@?0@?8d16\00"
More information about the cfe-commits
mailing list