[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-python-plugin
Subject:    Associating run-time and compile-time type information
From:       dmalcolm () redhat ! com (David Malcolm)
Date:       2011-11-23 23:07:02
Message-ID: 1322089623.2189.10.camel () surprise
[Download RAW message or body]

I added a new custom compiler attribute to the cpychecker, which allows
you to associate a PyTypeObject instance with a C typedef:

This means that the cpychecker can now tie together run-time type
information with C's compile-time type information:

/* Define some PyObject subclass, as both a struct and a typedef */
struct OurObjectStruct {
    PyObject_HEAD
    /* other fields */
};
typedef struct OurObjectStruct OurExtensionObject;

/*
  Declare the PyTypeObject (run-time type info), using the custom
  attribute to associate it with the typedef above:
*/
extern PyTypeObject UserDefinedExtension_Type
  CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF("OurExtensionObject");

The checker uses this so far in just one specific place, but it could be
used for various other verifications (e.g. to check that casts are
sane).

This is in
http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=commit;h=ff3eb4ac1f666b7b3a23da2d529659356098a5db


See:
http://gcc-python-plugin.readthedocs.org/en/latest/cpychecker.html#associating-pytypeobject-instances-with-compile-time-types


Naturally the plugin itself now uses this attribute, for the case where
the checker is verifying the plugin; doing so fixes some false
positives.  This is in git in 223bccfc32603be851e0d9b62aee8fd999c329eb.

Dave


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic