<div dir="ltr"><div>Hi,<br><br><br></div><div>I'm using the Clang Static Analyzer from Clang 3.3. I want to check object's state when they die. I tried using checkDeadSymbols, but according to the SymbolReaper, the objects of interest never die. This is my test code:<br>
<br></div><div>struct Foo<br>{<br></div><div> int* x;<br></div><div> Foo() { x = new int(10); }<br></div><div>};<br><br></div><div>int main(int argc, const char** argv)<br>{<br></div><div> Foo f;<br></div><div>
return 0;<br></div><div>}<br><br></div><div>The int* does die, but f does not. (I cannot check this directly: I just made the SymbolReaper print all symbols are regions that died, using the dead_begin(), etc. and region_begin() etc. methods). Why is this, and how can I work around it?<br>
<br></div><div>Even when there is a user-made destructor, which I can get using checkEndFunction, I'm unable to get back the symbol that represents 'f'. I spent like an hour digging through clang::ento's reference, and this was my best tip:<br>
<br>const CXXThisRegion* thisRegion = context.getStoreManager().getRegionManager().getCXXThisRegion(<br> dtor->getThisType(context.getASTContext()),<br> context.getLocationContext());<br><br></div>
<div>Unfortunately, this gives something that doesn't seem to have anything to do with 'f'. How can I get the symbol representing 'f', using only the CheckerContext and the const CXXDestructorDecl* I can obtain from the LocationContext?<br>
<br></div><div>I'm really stuck, and any help would be greatly appreciated. Thank you!<br><br>Gabor<br></div></div>