[cfe-commits] r102112 - in /cfe/trunk: include/clang/Basic/LangOptions.h include/clang/Driver/CC1Options.td lib/CodeGen/CGObjCMac.cpp lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h lib/Frontend/CompilerInvocation.cpp

Daniel Dunbar daniel at zuster.org
Tue Apr 27 08:23:30 PDT 2010


Hi Fariborz,

On Thu, Apr 22, 2010 at 1:26 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
> Author: fjahanian
> Date: Thu Apr 22 15:26:39 2010
> New Revision: 102112
>
> URL: http://llvm.org/viewvc/llvm-project?rev=102112&view=rev
> Log:
> Support for -fno-constant-cfstrings option - wip.

This is missing one piece, Clang needs to generate the reference to
the "NSConstantString" class (this is done via the module level
assembly hack, in CGObjCMac.cpp).

 - Daniel

>
>
> Modified:
>    cfe/trunk/include/clang/Basic/LangOptions.h
>    cfe/trunk/include/clang/Driver/CC1Options.td
>    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
>    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>    cfe/trunk/lib/CodeGen/CodeGenModule.h
>    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=102112&r1=102111&r2=102112&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.h Thu Apr 22 15:26:39 2010
> @@ -101,6 +101,7 @@
>   unsigned CatchUndefined    : 1; // Generate code to check for undefined ops.
>   unsigned DumpRecordLayouts : 1; /// Dump the layout of IRgen'd records.
>   unsigned DumpVTableLayouts : 1; /// Dump the layouts of emitted vtables.
> +  unsigned NoConstantCFStrings : 1;  // Do not do CF strings
>
>   // FIXME: This is just a temporary option, for testing purposes.
>   unsigned NoBitFieldTypeAlign : 1;
> @@ -134,6 +135,7 @@
>     GNUMode = GNUKeywords = ImplicitInt = Digraphs = 0;
>     HexFloats = 0;
>     GC = ObjC1 = ObjC2 = ObjCNonFragileABI = ObjCNonFragileABI2 = 0;
> +    NoConstantCFStrings = 0;
>     C99 = Microsoft = CPlusPlus = CPlusPlus0x = 0;
>     CXXOperatorNames = PascalStrings = WritableStrings = ConstStrings = 0;
>     Exceptions = SjLjExceptions = Freestanding = NoBuiltin = 0;
>
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=102112&r1=102111&r2=102112&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Apr 22 15:26:39 2010
> @@ -385,6 +385,8 @@
>  def fconstant_string_class : Separate<"-fconstant-string-class">,
>   MetaVarName<"<class name>">,
>   HelpText<"Specify the class to use for constant Objective-C string objects.">;
> +def fno_constant_cfstrings : Flag<"-fno-constant-cfstrings">,
> +  HelpText<"Enable creation of CodeFoundation-type constant strings">;
>  def fobjc_gc : Flag<"-fobjc-gc">,
>   HelpText<"Enable Objective-C garbage collection">;
>  def fobjc_gc_only : Flag<"-fobjc-gc-only">,
>
> Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=102112&r1=102111&r2=102112&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Apr 22 15:26:39 2010
> @@ -1493,9 +1493,20 @@
>   };
>  */
>
> +/// or Generate a constant NSString object.
> +/*
> +   struct __builtin_NSString {
> +     const int *isa; // point to __NSConstantStringClassReference
> +     const char *str;
> +     unsigned int length;
> +   };
> +*/
> +
>  llvm::Constant *CGObjCCommonMac::GenerateConstantString(
>   const StringLiteral *SL) {
> -  return CGM.GetAddrOfConstantCFString(SL);
> +  return (CGM.getLangOptions().NoConstantCFStrings == 0 ?
> +          CGM.GetAddrOfConstantCFString(SL) :
> +          CGM.GetAddrOfConstantNSString(SL));
>  }
>
>  /// Generates a message send where the super is the receiver.  This is
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=102112&r1=102111&r2=102112&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Apr 22 15:26:39 2010
> @@ -1593,6 +1593,12 @@
>   return GV;
>  }
>
> +llvm::Constant *
> +CodeGenModule::GetAddrOfConstantNSString(const StringLiteral *Literal) {
> +  // FIXME. This is temporary so -fno-constant-cfstrings same as old.
> +  return GetAddrOfConstantCFString(Literal);
> +}
> +
>  /// GetStringForStringLiteral - Return the appropriate bytes for a
>  /// string literal, properly padded to match the literal type.
>  std::string CodeGenModule::GetStringForStringLiteral(const StringLiteral *E) {
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=102112&r1=102111&r2=102112&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Apr 22 15:26:39 2010
> @@ -250,6 +250,10 @@
>   /// GetAddrOfConstantCFString - Return a pointer to a constant CFString object
>   /// for the given string.
>   llvm::Constant *GetAddrOfConstantCFString(const StringLiteral *Literal);
> +
> +  /// GetAddrOfConstantNSString - Return a pointer to a constant NSString object
> +  /// for the given string.
> +  llvm::Constant *GetAddrOfConstantNSString(const StringLiteral *Literal);
>
>   /// GetAddrOfConstantStringFromLiteral - Return a pointer to a constant array
>   /// for the given string literal.
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=102112&r1=102111&r2=102112&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Apr 22 15:26:39 2010
> @@ -549,6 +549,8 @@
>   }
>   if (Opts.ObjCGCBitmapPrint)
>     Res.push_back("-print-ivar-layout");
> +  if (Opts.NoConstantCFStrings)
> +    Res.push_back("-fno-constant-cfstrings");
>   if (!Opts.AccessControl)
>     Res.push_back("-fno-access-control");
>   if (!Opts.CharIsSigned)
> @@ -1180,6 +1182,8 @@
>
>   if (Args.hasArg(OPT_print_ivar_layout))
>     Opts.ObjCGCBitmapPrint = 1;
> +  if (Args.hasArg(OPT_fno_constant_cfstrings))
> +    Opts.NoConstantCFStrings = 1;
>
>   if (Args.hasArg(OPT_faltivec))
>     Opts.AltiVec = 1;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list