Forgot to reply all... ---------- Forwarded message ---------- From: Brendon Costa <[EMAIL PROTECTED]> Date: 2008/11/30 Subject: Re: Functional Purity To: David Fang <[EMAIL PROTECTED]>
> Sounds like you want to (at least): > > 1) automatically qualify every declaration (including parameters, member > declarations, and member function declarations) with 'const'. > > 2) forbid the use of the '=' operator family (including +=, etc...) > (might be redundant with #1) > > Does this accurately summarize your proposed analysis? As a crude start, > maybe you could alter the syntax trees, and let the rest of compilation > catch any resulting violations? You are right in that what i am trying to achieve is very similar to the analysis of constness already performed by the compiler. Constness and purity as i have defined them are very similar. Except there is no syntatic const definition that can represent "global purity" (I.e. Markup a given function to indicate that it does not modify any global variables), and constness can be easily (and un-intentionally) cast away. Part of the reason for this analysis is to identify parameters and methods that could be declared const but are not and notify the user, so as a result it can not rely on the users const definitions. Not being able to rely on protoype definitions will make the task much more difficult, as i will need to do my analysis at link time. Though i am already doing this sort of thing for my static analysis program (EDoc++). The purpose of this analysis is to be a part of a larger analysis to automate classifying the exception safety guarantee of functions. I am looking at the feasibility of automating something similar to the process described at: http://www.ddj.com/cpp/184401728 Starting with the classification of a functions purity. I will also look at the other suggestions in ipa-pure-const.c and gimple_has_side_effects() and see if they can help me out somehow. Thanks, Brendon.