<div dir="ltr">Hi All,<div><br></div><div>I would like to perform for simulation experiments on a C codebase where based on the type of the variable, an assignment to a pointer of this type is followed by some additional instruction (lets say an external counter increment --- just to create a simple scenario). I have implemented a RecuriveASTVisitor that visits BinaryOps (after checking they are assignments) and rewrites the source by replacement. </div><div><br></div><div>However, there are issues with multiple assignments within the same source line (such as ptr1 = ptr2 = NULL), as well as some macro expansions. I would like a robust way of doing so without breaking the code.</div><div><br></div><div>Could someone kindly answer the following: </div><div>1. Is there some existing libTool to do so? </div><div><br></div><div>if not, then: </div><div>2. My wrapper function is of the form: (listing a simplified version)</div><div> void * wrapAssgnmt (void **ptrToLhsPtr, void *rhsPtr){</div><div> *ptrToLhsPtr = rhsPtr;</div><div> // do other things for simulation</div><div> return *ptrToLhsPtr; // so that NULL based checks work. </div><div> }</div><div> compilation gives me: "warning: comparison between pointer and integer" for cases of pattern: </div><div> type *ptr; // original code is if( (ptr = malloc ( ... )) = NULL) ... </div><div> if((wrapAssgnmt( &ptr , malloc( ... ) ) = NULL) </div><div> </div><div> I understand the warning, but I am not sure about the cause/reason. Could someone please suggest the correction? </div><div><br></div><div>Thanks!</div><div><div><div class="gmail_signature" data-smartmail="gmail_signature"></div></div>
</div></div>