2

我使用 Polyspace IHME-8.1.0.12 (R2011a) 在我的项目中查找死代码。目前,分析抓住了这种情况:

int f1() {
  int x = 1;
  if (x > 0) return 1;
  else return 0;  // dead code
}

但不是这种情况:

int f2(int x) {
  if (x > 0) return 1;
  else return 0;  // the very same dead code!
}
void call_site() {
  f2(1);
}

请注意,它x变成了一个参数,但它仍然有一个常数值,1。该f2()功能仅由call_site()调用,或者,每个调用站点都f2()使用调用x=1

在寻找无法访问的代码时,是否有我应该激活的配置选项来分析所有呼叫站点?或者这是 Polyspace 的限制?

4

1 回答 1

3

Can you tell me if there is a main in the application? If not, then Polyspace will use its main generator and so may also call f2 (it depends on how the main generator is configured). And if f2 is called also by the main generator, then x is considered to take any value. You can see the range of x that Polyspace is considering if you look at the tooltip on x or if you click on x and take a look at the check details window.

于 2015-06-26T10:38:01.087 回答