I'm trying to understand some of CIL's behavior wrt renamings.
According to the doc, variables seem to be renamed to be unique.  This
is AWESOME in terms of simplifying analyses.  However, there seem to
be cases where it doesn't do this (and having assumed it did, lead to
bugs in my own tool).

For example:
// -------------------------------------
int global_param_1 = 5;
int f1(int global_param_1) {
        return global_param_1;
}

int f2(int global_param_2) {
        return global_param_2;
}
int global_param_2 = 5;
// ---------------
int global_local_1 = 5;
int g1() {
        int global_local_1 = 7;
        return global_local_1;
}

int g2() {
        int global_local_2 = 7;
        return global_local_2;
}
int global_local_2 = 5;
// ---------------
int main(void) {
        [...]
}
// -------------------------------------

I expected the four variables global_param_1, global_param_2,
global_local_1, and global_local_2 to end up with unique names after
compilation.  In fact, only the first and third do:

// shortened output from cilly
int global_param_1  =    5;
int f1(int global_param_1___0 ) {
  return (global_param_1___0);
}

int f2(int global_param_2 ) {
  return (global_param_2);
}
int global_param_2  =    5;
// ---------------
int global_local_1  =    5;
int g1(void) {
  int global_local_1___0 ;
  global_local_1___0 = 7;
  return (global_local_1___0);
}

int g2(void) {
  int global_local_2 ;
  global_local_2 = 7;
  return (global_local_2);
}
int global_local_2  =    5;
// -------------------------------------

Granted, in the second and forth case the two variables do not share
any visibility, but having the names conflict means we have to handle
scoping in our own tools.  Unique names effectively means we don't
need to handle scope at all, and it doesn't seem difficult from the
point of view of CIL to provide this.

Can anyone confirm?  Is it already known about?  Is this a bug, or has
it been decided this is desirable already?

-Chucky
University of Illinois

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to