[cfe-dev] getting visit methods right
Rajendra
rks at cse.iitb.ac.in
Tue Nov 27 01:24:37 PST 2012
Any suggestion on this topic, please?
- Rajendra
On 26-11-2012 03:21 PM, Rajendra wrote:
> Hi,
>
> I have overridden VisitIfStmt(Stmt* s) and some visit methods for
> binary operators:
> - VisitBinAssign(),
> - VisitBinAdd() and other arithmetic operators,
> - VisitBinGT() and other relational operators
>
> My dilemma is how do I return from different visit methods (or call
> them explicitly)
> so that I can perform some analysis on binary operators and use them
> in condition part,
> then clause and else clause for IfStmt? e.g. I want to analyze
> following C program:
> int main() {
> int x, y;
> x = 10;
> if (x > 0)
> y = 1;
> else if (x == 0)
> y = 0;
> else
> y = -1;
> return 0;
> }
>
> Basic block contains:
> 1: int x;
> 2: int y;
> 3: x = 10
> 4: x > 0
> T: if [B6.4]
>
> Now, for condition x > 0 (line 3:) due to VisitBinGT() can get
> following info:
> Relational Op >
> LHS identifier = x
> type: int
> RHS value: 0
> From VisitIfStmt() I can get pointer to condition part, then and else
> clauses.
> so, how should I combine IfStmt and information I have due to visit
> to other methods?
>
> Please advise.
>
> - Rajendra
More information about the cfe-dev
mailing list