[cfe-dev] [Patch] Add MallocAttr to new operator
Tom Jablin
tom at liberty-research.org
Thu Aug 12 13:29:36 PDT 2010
Hi,
Starting with revision 110175, there was a regression in clang where the
return type of the new operator was not marked with noalias when there was
an explicit declaration of the new operator. This is a problem since the
<new> header explicitly declares the new operator. The <new> header is
indirectly including through many other headers including <string> and
<iostream>. I have enclosed a patch to add the MallocAttr to the new
operator as long as -fassume-sane-operator-new is set.
Here is a simple test case:
$ echo -e "#include <string>\nvoid foo(void) { delete[] new int[10]; }" |
clang -x c++ - -emit-llvm -S -o - | grep declare.*Znam
declare i8* @_Znam(i64)
after the patch:
$ echo -e "#include <string>\nvoid foo(void) { delete[] new int[10]; }" |
clang -x c++ - -emit-llvm -S -o - | grep declare.*Znam
declare noalias i8* @_Znam(i64)
Thanks your help.
Sincerely yours,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100812/91abd63d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MallocAttr.patch
Type: text/x-diff
Size: 703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100812/91abd63d/attachment.patch>
More information about the cfe-dev
mailing list