forked from facebook/infer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[prover] do destructive normalization to prove more
Summary: In some cases we normalize expressions to check some facts about them. In these cases, trying to keep as much information as possible in the expression, such as the fact it comes from a `sizeof()` expression, is not needed. Doing destructive normalization allows us to replace `sizeof()` by its statically-known value. closes facebook#706 Reviewed By: mbouaziz Differential Revision: D5536685 fbshipit-source-id: cc3d731
- Loading branch information
1 parent
91d5189
commit b2ee115
Showing
6 changed files
with
66 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2017 - present Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
int sizeof_eval_good(void) { | ||
int a = 4; | ||
int b = sizeof(a); | ||
char c[2]; | ||
|
||
if (a % 4) { | ||
return a / 0; | ||
} | ||
if (b % sizeof(a)) { | ||
return a / 0; | ||
} | ||
if (sizeof(c) > 2) { | ||
return a / 0; | ||
} | ||
if ((sizeof(c) / sizeof(c[0])) != 2) { | ||
return a / 0; | ||
} | ||
return 0; | ||
} | ||
|
||
void sentinel_bad(void) { return 1 / 0; } |