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.
[pulse] preserve restricted variables across function calls
Summary: When a variable (an `AbstractValue.t`) denotes a non-negative value, nothing is recorded in the Pulse formula, we just represent that variable with a *restricted* variable. We were losing information about which variables are restricted when applying function calls as the substitution would not take them into account and map them to *unrestricted* variables. Reviewed By: ezgicicek Differential Revision: D32465508 fbshipit-source-id: e5bf5266c
- Loading branch information
1 parent
4b73086
commit b60d5ff
Showing
5 changed files
with
58 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include <assert.h> | ||
#include <stdlib.h> | ||
|
||
int return_non_negative() { | ||
int x = random(); | ||
if (x < 0) { | ||
exit(1); | ||
} | ||
return x; | ||
} | ||
|
||
void return_non_negative_is_non_negative_ok() { | ||
if (return_non_negative() < 0) { | ||
int* p = NULL; | ||
*p = 42; | ||
} | ||
} | ||
|
||
void assume_non_negative(int x) { | ||
if (x < 0) { | ||
exit(1); | ||
} | ||
} | ||
|
||
void assume_non_negative_is_non_negative_ok() { | ||
int x = random(); | ||
assume_non_negative(x); | ||
if (x < 0) { | ||
int* p = NULL; | ||
*p = 42; | ||
} | ||
} |