Docsity

Interprocedural CFG & Variable Range Analysis for C/C++ Pseudo Code - Prof. Qing Yi, Assignments of Computer Science

Toggle sidebar
bg1
Exercise 6
Apr 10/15, 2008
Given the following C/C++ pseudo code.
struct List { int val; struct List* next; };
int count (struct List* head)
{
if (head == NULL) return 0;
t = count(head->next);
return 1 + t;
}
int main() {
struct List* mylist;
mylist = new struct List();
mylist->next = new struct List();
mylist->val = mylist->next->val = 0;
int len = count(mylist);
printf("len = %d", len);
}
1. Draw an interprocedural control flow graph for the above code.
2. Give the steps of performing interprocedural variable range analysis on
the above code.o Your context need to remember only a single caller when
analyzing function definitions.
1

Partial preview of the text

Download Interprocedural CFG & Variable Range Analysis for C/C++ Pseudo Code - Prof. Qing Yi and more Assignments Computer Science in PDF only on Docsity!

Exercise 6

Apr 10/15, 2008

Given the following C/C++ pseudo code.

struct List { int val; struct List* next; }; int count (struct List* head) { if (head == NULL) return 0; t = count(head->next); return 1 + t; }

int main() { struct List* mylist; mylist = new struct List(); mylist->next = new struct List(); mylist->val = mylist->next->val = 0; int len = count(mylist); printf("len = %d", len); }

  1. Draw an interprocedural control flow graph for the above code.
  2. Give the steps of performing interprocedural variable range analysis on the above code.o Your context need to remember only a single caller when analyzing function definitions.