Hi all, I want to use GCC to categorise "functional purity" in C++. My definition will differ from classic functional purity. In particular:
A function is considered pure if it makes no changes to existing memory or program state. There may be a few exceptions to this rule such as for new/malloc in that they change program state (allocating new memory) but will be manually marked as pure. However free/delete should be marked as impure (modifying function parameter, but not global state). This means that a function which is pure can create new objects/memory and make changes to those new objects, but the existing memory must remain unchanged. When categorising a functions purity i also would like to identify the cause of the impurity. In particular for a function that is impure i want to categorise the impurity cause as: * modifies global state * modifies a function parameter * modifies the object state (this is an extension of the function parameter on the "this" parameter) The reason for posting this is to ask. Is there code in GCC that already does something "similar" in say one of the optimisation passes so i can get a look at how to get started on this? Thanks, Brendon.