[Patch] Add MallocAttr to new operator

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 header explicitly declares the new operator. The header is indirectly including through many other headers including and . 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 \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 \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

MallocAttr.patch (703 Bytes)

Thanks, committed as r111363 along with a version of the test above. In the future, it would help if you could include a test case in the patch that can go directly into the Clang test-suite.

  - Doug