r229950 - Add -fno-sized-deallocation option for completeness of fix in r229241 in documentation in r229818.

Larisse Voufo lvoufo at google.com
Fri Feb 20 10:17:47 PST 2015


Here is a sample test I just ran with fileA.cpp containing the following:

void foo(int* i) {
  delete i;
}

--------------------------------------------------------------------------------------------------------
With Clang 3.5:
----------------------------------------------
$ clang++ -std=c++1y -c fileA.cpp -fno-sized-deallocation
clang: error: unknown argument: '-fno-sized-deallocation'
$ clang++ -std=c++1y -c fileA.cpp -fsized-deallocation
clang: error: unknown argument: '-fsized-deallocation'

--------------------------------------------------------------------------------------------------------
With Clang 3.7 (current):
----------------------------------------------
$ clang++ -std=c++1y -c fileA.cpp -fsized-deallocation
clang: error: unknown argument: '-fsized-deallocation'
$ clang++ -std=c++1y -c fileA.cpp
$ nm fileA.o | c++filt
0000000000000000 T foo(int*)
                 U operator delete(void*, unsigned long)
$ clang++ -std=c++1y -c fileA.cpp -fno-sized-deallocation
$ nm fileA.o | c++filt
0000000000000000 T foo(int*)
                 U operator delete(void*)
--------------------------------------------------------------------------------------------------------

It actually looks like by not exposing -fsized-deallocation in the driver,
sized deallocation is
enabled by default in C++14 mode, until one uses -fno-sized-deallocation.

What's missing?
The only other issue that has come to my attention is PR22635, which is
independent of the current
designs under discussion, and is apparently fixed by r229913.

If the issue is whether to switch -fdefine-sized-deallocation by default or
not, I don't see how
that affects whether to add -fno-sized-deallocation (or to make
-fsized-deallocation visible in the driver).



On Fri, Feb 20, 2015 at 9:20 AM, Larisse Voufo <lvoufo at google.com> wrote:

>
>
> On Thu, Feb 19, 2015 at 7:03 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
>
>> On Thu, Feb 19, 2015 at 6:07 PM, Larisse Voufo <lvoufo at google.com> wrote:
>>
>>> Author: lvoufo
>>> Date: Thu Feb 19 20:07:22 2015
>>> New Revision: 229950
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=229950&view=rev
>>> Log:
>>> Add -fno-sized-deallocation option for completeness of fix in r229241 in
>>> documentation in r229818.
>>>
>>
>> This seems really strange; the driver now has a -fno-sized-deallocation
>> but no -fsized-deallocation,
>>
>
> -fsized-deallocation was never exposed in the driver. I didn't want to
> mess with its design too much at all, except for using it as a reference to
> add -fdefine-sized-deallocation and -fno-sized-deallocation. I could expose
> it if you want.
>
>
>> and the frontend now has both but they don't override each other in the
>> usual way.
>>
>
> They should. I specifically set Opts.SizedDeallocation to turn itself off
> if -fno-sized-deallocation is set.
> If this doesn't work (which would be surprising), then there must be
> something else going on.
>
>
>> I don't think this is the right design. Can you revert this for now until
>> we finish discussing what command-line interface we want here?
>>
>
> Well, aside from flag naming, we currently have all the pieces of the
> designs in place, except for turning off sized deallocation.
> With this, switching over to whatever design we end up with, will be no
> beig deal.
>
> Besides, reverting this means that I have to update the cxx_status page to
> remove the -fno-sized-deallocation option.
> I really don't see why we should hold up when we have something that works
> for now.
>
>
>>
>>> Modified:
>>>     cfe/trunk/include/clang/Driver/Options.td
>>>     cfe/trunk/lib/Driver/Tools.cpp
>>>     cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>>     cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
>>>     cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp
>>>     cfe/trunk/test/CodeGenCXX/pr21754.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Driver/Options.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=229950&r1=229949&r2=229950&view=diff
>>>
>>> ==============================================================================
>>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>>> +++ cfe/trunk/include/clang/Driver/Options.td Thu Feb 19 20:07:22 2015
>>> @@ -394,8 +394,10 @@ def fasm_blocks : Flag<["-"], "fasm-bloc
>>>  def fno_asm_blocks : Flag<["-"], "fno-asm-blocks">, Group<f_Group>;
>>>
>>>  def fassume_sane_operator_new : Flag<["-"],
>>> "fassume-sane-operator-new">, Group<f_Group>;
>>> +def fno_sized_deallocation: Flag<["-"], "fno-sized-deallocation">,
>>> Group<f_Group>,
>>> +  HelpText<"Disable sized deallocation functions">, Flags<[CC1Option]>;
>>>  def fdefine_sized_deallocation: Flag<["-"],
>>> "fdefine-sized-deallocation">, Group<f_Group>,
>>> -  HelpText<"Allow compiler-generated definition of sized deallocation
>>> function">, Flags<[CC1Option]>;
>>> +  HelpText<"Allow compiler-generated definition of sized deallocation
>>> functions">, Flags<[CC1Option]>;
>>>  def fastcp : Flag<["-"], "fastcp">, Group<f_Group>;
>>>  def fastf : Flag<["-"], "fastf">, Group<f_Group>;
>>>  def fast : Flag<["-"], "fast">, Group<f_Group>;
>>>
>>> Modified: cfe/trunk/lib/Driver/Tools.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=229950&r1=229949&r2=229950&view=diff
>>>
>>> ==============================================================================
>>> --- cfe/trunk/lib/Driver/Tools.cpp (original)
>>> +++ cfe/trunk/lib/Driver/Tools.cpp Thu Feb 19 20:07:22 2015
>>> @@ -4213,6 +4213,10 @@ void Clang::ConstructJob(Compilation &C,
>>>                      options::OPT_fno_assume_sane_operator_new))
>>>      CmdArgs.push_back("-fno-assume-sane-operator-new");
>>>
>>> +  // -fno-sized-deallocation: disable sized delete.
>>> +  if (Args.hasArg(options::OPT_fno_sized_deallocation))
>>> +    CmdArgs.push_back("-fno-sized-deallocation");
>>> +
>>>    // -fdefine-sized-deallocation: default implementation of sized
>>> delete as a
>>>    // weak definition.
>>>    if (Args.hasArg(options::OPT_fdefine_sized_deallocation))
>>>
>>> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=229950&r1=229949&r2=229950&view=diff
>>>
>>> ==============================================================================
>>> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>>> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Feb 19 20:07:22
>>> 2015
>>> @@ -1522,6 +1522,7 @@ static void ParseLangArgs(LangOptions &O
>>>    Opts.NoMathBuiltin = Args.hasArg(OPT_fno_math_builtin);
>>>    Opts.AssumeSaneOperatorNew =
>>> !Args.hasArg(OPT_fno_assume_sane_operator_new);
>>>    Opts.SizedDeallocation |= Args.hasArg(OPT_fsized_deallocation);
>>> +  Opts.SizedDeallocation &= !Args.hasArg(OPT_fno_sized_deallocation);
>>>    Opts.DefineSizedDeallocation = Opts.SizedDeallocation &&
>>>        Args.hasArg(OPT_fdefine_sized_deallocation);
>>>    Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
>>>
>>> Modified: cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp?rev=229950&r1=229949&r2=229950&view=diff
>>>
>>> ==============================================================================
>>> --- cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp (original)
>>> +++ cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp Thu Feb 19
>>> 20:07:22 2015
>>> @@ -3,6 +3,7 @@
>>>  // RUN: %clang_cc1 -std=c++11 -fsized-deallocation %s -emit-llvm
>>> -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK
>>> --check-prefix=CHECKUND
>>>  // RUN: %clang_cc1 -std=c++11 -fsized-deallocation
>>> -fdefine-sized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - |
>>> FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDEF
>>>  // RUN: %clang_cc1 -std=c++11 %s -emit-llvm -triple x86_64-linux-gnu -o
>>> - | FileCheck %s --check-prefix=CHECK-UNSIZED
>>> +// RUN: %clang_cc1 -std=c++1y %s -emit-llvm -triple x86_64-linux-gnu
>>> -fno-sized-deallocation -o - | FileCheck %s --check-prefix=CHECK-UNSIZED
>>>
>>>  // CHECK-UNSIZED-NOT: _ZdlPvm
>>>  // CHECK-UNSIZED-NOT: _ZdaPvm
>>>
>>> Modified: cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp?rev=229950&r1=229949&r2=229950&view=diff
>>>
>>> ==============================================================================
>>> --- cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp
>>> (original)
>>> +++ cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp Thu Feb
>>> 19 20:07:22 2015
>>> @@ -1,5 +1,6 @@
>>>  // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o -
>>> -std=c++11 %s 2>&1 | FileCheck %s -check-prefix=CHECKDEF
>>> -check-prefix=CHECK11
>>>  // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o -
>>> -std=c++11 -fvisibility hidden %s 2>&1 | FileCheck %s
>>> -check-prefix=CHECKHID -check-prefix=CHECK11
>>> +// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o -
>>> -std=c++14 -fno-sized-deallocation %s 2>&1 | FileCheck %s
>>> -check-prefix=CHECKDEF -check-prefix=CHECK11
>>>  // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o -
>>> -std=c++14 %s 2>&1 | FileCheck %s -check-prefix=CHECKDEF
>>> -check-prefix=CHECK14 -check-prefix=CHECK14UND
>>>  // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o -
>>> -std=c++14 -fvisibility hidden %s 2>&1 | FileCheck %s
>>> -check-prefix=CHECKHID -check-prefix=CHECK14 -check-prefix=CHECK14UND
>>>  // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o -
>>> -std=c++14 -fdefine-sized-deallocation %s 2>&1 | FileCheck %s
>>> -check-prefix=CHECKDEF -check-prefix=CHECK14 -check-prefix=CHECK14DEFCOMDAT
>>>
>>> Modified: cfe/trunk/test/CodeGenCXX/pr21754.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr21754.cpp?rev=229950&r1=229949&r2=229950&view=diff
>>>
>>> ==============================================================================
>>> --- cfe/trunk/test/CodeGenCXX/pr21754.cpp (original)
>>> +++ cfe/trunk/test/CodeGenCXX/pr21754.cpp Thu Feb 19 20:07:22 2015
>>> @@ -1,12 +1,10 @@
>>>  // RUN: %clang -cc1 -emit-llvm -triple x86_64-unknown-unknown
>>> -std=c++1y -o - %s 2>&1 | FileCheck %s
>>>  // RUN: %clang -cc1 -emit-llvm -triple x86_64-unknown-unknown
>>> -std=c++1y -fdefine-sized-deallocation -o - %s 2>&1 | FileCheck %s
>>> +// RUN: %clang -cc1 -emit-llvm -triple x86_64-unknown-unknown
>>> -std=c++1y -fno-sized-deallocation -o - %s 2>&1 | FileCheck %s
>>>  // RUN: %clang -cc1 -emit-llvm -triple x86_64-unknown-unknown
>>> -std=c++11 -fsized-deallocation -o - %s 2>&1 | FileCheck %s
>>>  // RUN: %clang -cc1 -emit-llvm -triple x86_64-unknown-unknown
>>> -std=c++11 -fsized-deallocation -fdefine-sized-deallocation -o - %s 2>&1 |
>>> FileCheck %s
>>>  // RUN: %clang -cc1 -emit-llvm -triple x86_64-unknown-unknown
>>> -std=c++11 -o - %s 2>&1 | FileCheck %s
>>>
>>> -// CHECK-UNSIZED-NOT: _ZdlPvm
>>> -// CHECK-UNSIZED-NOT: _ZdaPvm
>>> -
>>>  void operator delete(void*, unsigned long) throw()
>>> __attribute__((alias("foo")));
>>>  extern "C" void foo(void*, unsigned long) {}
>>>
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150220/421a808b/attachment.html>


More information about the cfe-commits mailing list