| Version 2 (modified by , 10 years ago) ( diff ) |
|---|
Points-to Analysis
This analysis computes the set of objects or components that a pointer can reference to. There are a lot of different categories of methods. The method described here is based on:
- flow-sensitive analysis: control-flow information is considered during analysis;
- context-sensitive analysis: when calling a function, values flow from one call through the function and return to another caller;
- heap modeling: objects named by allocation site
- aggregate modeling: elements of struct/array are distinguished
Definitions
obj(p): the set of objects thatpmay reference to;obj(e): the set of objects thatemay represent, whereehas pointer type, or composite type of pointer type (e.g., array of pointers);
Conditional Object Setof a pointerp:cobj(p)={c0->O0, c1->O1, c2->O2, ...}whereO1, O2, ...are all set of objectsc0->O0denotes that whenc0is satisfied the objects set that p could refer to isO0
Expressions
let e be an expression, let le be an left-hand-side expression, let impact(e) be the set of impact memory units of e.
letmu(e) be a function to convert an expression, of pointer type or being a left-hand-side expression, to a memory unit.
- abstract function call:
f(e0,e1, ...)
???
- address-of:
&le
obj(&le)={le}
- array literal:
{e0, e1, ...}wheree0, ..e1all have pointer types
obj({e0, e1, ...}) = obj(e0) U obj(e1) ...
- pointer addition:
e0 + e1
obj(e0 + e1) = offset(e0, e1)
- cast expression:
(T)e(whereTis pointer type)
obj((T)e)=obj(e)
- conditional expression:
e0 ? e1 : e2
obj(e0 ? e1 : e2) = e0 ? obj(e1) : obj(e2)
- dereference expression:
*ewhereehas type pointer-to-pointer ofT
obj(*e) = **???**the impact memory units of*einclude the memory unit refers to bye, and the impact memory units of the sub-expressions ofe. e.g., the impact memory units of*(p+i)is{mu(p+5), impact(i)}, becausepis of pointer type andsub(p+i)is{i}.
- dot expression:
e.kwheree.khas pointer type
obj(e.k) = {e.k}
- subscript expression:
ea[ei]
obj(ea[ei])={ea[ei]}
Sub-expressions
let e be an expression, let sub(e) be the set of sub-expressions of e.
- abstract function call:
f(e0,e1, ...)
sub(f(e0,e1, ...)) = {e0, e1, ...}
- address-of:
&le
sub(&le)={le} U sub(le)
- array literal:
{e0, e1, ...}
sub({e0, e1, ...}) = {e0, e1, ...}`
- binary expression:
e0 op e1sub(e0 op e1) = e0.type== pointer ? {e1} : {e0, e1}
- bound variable expression:
eb
sub(eb)=\empty
- cast expression:
(T)e
sub((T)e)={e}
