[cfe-dev] [Analyzer] Get CXX "This" in a top-level instance call

scott constable via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 16 08:17:46 PDT 2015


Hi All,

Suppose I am analyzing the following code:

class MyClass {
public:
int foo(int, int);
private:
int x;
int y;
};

int MyClass::foo(int a, int b) {
x = a;
return a;
}

and I would like to examine or modify the state of both x and y during a
call to MyClass::foo(), even though MyClass::foo() only touches x. If
another function in this translation unit is calling MyClass::foo(), then I
can simply grab the CallEvent during a PreCall, cast it to a
CXXInstanceCall, and use CXXInstanceCall::getCXXThisVal() to obtain the
SVal corresponding to the calling instance. But if the analyzer is
executing MyClass::foo() from the top level, I don't see a way of doing
this.

~Scott Constable
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151016/c46b69c6/attachment.html>


More information about the cfe-dev mailing list