This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Support new/delete in Sema
ClosedPublic

Authored by svenvh on May 9 2018, 10:49 AM.

Details

Summary

Reject uses of the default new/delete operators with a diagnostic
instead of a crash in OpenCL C++ mode and accept user-defined forms.

Diff Detail

Repository
rC Clang

Event Timeline

svenvh created this revision.May 9 2018, 10:49 AM
rjmccall added inline comments.May 9 2018, 11:40 AM
lib/Sema/SemaExprCXX.cpp
2030

I think a better interpretation of this rule would be to just error on attempts to use the standard non-placement operator new/delete instead of trying to outlaw the operator declarations. For example, I don't know why a user-defined non-global operator new would be problematic.

svenvh added inline comments.May 11 2018, 10:41 AM
lib/Sema/SemaExprCXX.cpp
2030

Good point, I have raised this with Khronos, so I will hold this off until we have clarification.

Anastasia requested changes to this revision.Jun 8 2018, 7:36 AM
Anastasia added inline comments.
lib/Sema/SemaExprCXX.cpp
2030

The decision by Khronos is to allow all user defined new/delete operators (even global). I have submitted the change to the spec. The next publishing date is however in July.

This revision now requires changes to proceed.Jun 8 2018, 7:36 AM
svenvh updated this revision to Diff 150535.Jun 8 2018, 10:18 AM
svenvh retitled this revision from [OpenCL] Support placement new/delete in Sema to [OpenCL] Support new/delete in Sema.
svenvh edited the summary of this revision. (Show Details)

Relaxed the new/delete restrictions following the Khronos advice.

rjmccall added inline comments.Jun 9 2018, 7:28 PM
lib/Sema/SemaDeclCXX.cpp
13034

getTypePtr() is done automatically by operator-> on QualType. This can be fixed in multiple places in this patch.

lib/Sema/SemaExprCXX.cpp
2030

Okay. I agree with your decision in this patch to treat this as a defect in the spec and thus to go ahead and do the right thing now.

svenvh updated this revision to Diff 150788.Jun 11 2018, 10:31 AM

Dropped 2 redundant uses of getTypePtr(); minor formatting changes.

svenvh added inline comments.Jun 11 2018, 10:35 AM
lib/Sema/SemaExprCXX.cpp
2030

I can postpone committing this until the revised spec has been published, if that's more desirable?

rjmccall accepted this revision.Jun 11 2018, 11:41 AM

LGTM.

lib/Sema/SemaExprCXX.cpp
2030

No, if that's the directive I see no reason to wait for formal publication. As precedent, we update C++ rules long before ISO officially blesses the current draft into a standard.

Anastasia accepted this revision.Jun 14 2018, 2:24 AM

LGTM! Thanks!

This revision is now accepted and ready to land.Jun 14 2018, 2:24 AM
This revision was automatically updated to reflect the committed changes.