[cfe-dev] MemRegions - how to (re)use them right?

Olaf Krzikalla Olaf.Krzikalla at tu-dresden.de
Tue Sep 29 07:50:37 PDT 2009


Hi @clang,

I need to analyze some (rather simple) data flow at AST level. While I 
could do it by my own I have the strange feeling that the 
MemRegionManager already provides a lot of the means I need. However I 
couldn't figure out how to use it. At the moment it seems to be used for 
diagnostics only.
Here is a code example:

struct A { int a, b };

void foo(int* sink)
{
  A temp;
  A* ptr = &temp;

  temp.a = /*expr*/;
  temp.b = /* another_expr */;
  *sink = temp.a;   // (1)
  *sink = ptr->b;   // (2)
}

I want to know that at (1) actually the result of expr is written to 
sink and that at (2) the result of another_expr is written to sink. Can 
I somehow compute this using clang's static analyzer?


Best regards
Olaf Krzikalla




More information about the cfe-dev mailing list