[cfe-commits] [PATCH] Type safety attributes (was: Compile-time MPI_Datatype checking)
Dmitri Gribenko
gribozavr at gmail.com
Sun May 27 10:48:19 PDT 2012
Hi Hal,
Thank you for the review. Comments inline.
Updated version of the patch attached. Changes include addressing the
review comments and proper handling of 128-bit integer constants in
attribute arguments and type tags (ensures we don't crash in these
cases).
On Thu, May 24, 2012 at 5:27 AM, Hal Finkel <hfinkel at anl.gov> wrote:
> layout_compatible - The documentation on this needs to be expanded.
> I recommend an example or two (at least).
Added an example. Is that enough or more explanations are needed?
> Do we need a new has_feature check so that we can properly guard the
> new attributes in public headers?
__has_attribute already works with these attributes.
> Are C++ objects that are implicitly convertible to pointers of the
> correct type handled correctly [this is not obvious to me from reading
> the patch, but I'm not an expert here]?
Classes with conversion operators, like this:
class OperatorIntStar
{
public:
operator int*();
};
These classes are supported. I've added a test for that to make sure
we don't regress.
>> + bool IsMPI = ArgumentKind->isStr("mpi");
>> +
>> + if (SpecifiedType->isVoidType()) {
>> + // Type tag with matching void type requires a null pointer.
>> + if (!ArgumentExpr->isNullPointerConstant(Context,
>> +
>> Expr::NPC_ValueDependentIsNotNull)) {
>> + Diag(ArgumentExpr->getExprLoc(),
>> + IsMPI ? diag::warn_mpi_datatype_null_but_buffer_not_null
>> + : diag::warn_type_safety_null_pointer_required)
>> + << ArgumentExpr->getSourceRange()
>> + << TypeTagExpr->getSourceRange();
>> + }
>> + return;
>> + }
>
> Can we generalize this as well? Maybe we should call this
> void_must_be_null, and make it like layout_compatible (an optional
> parameter)? [As far as I can tell, this is the only MPI-specific logic
> left, is there anything else?]
Done.
Yes, that was the only piece of MPI-specific logic.
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: type-safety-attrs-v4.patch
Type: application/octet-stream
Size: 71303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120527/6e67455c/attachment.obj>
More information about the cfe-commits
mailing list