-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C++: Measure bounds for Enum constants and reduce getBoundsLimit
#21313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MathiasVP
wants to merge
4
commits into
github:main
Choose a base branch
from
MathiasVP:range-analysis-lower-bound-and-measure-enums
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+627
−2
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b14ece7
C++: Add range analysis test demonstrating missing measuring bounds.
MathiasVP a4dd4f9
C++: Also compute type bounds for accesses of an enum type.
MathiasVP 6dd6bdd
C++: Add more terms to make range analysis test timeout.
MathiasVP 2dc91a5
C++: Lower the treshold for max number of bounds to 2^29.
MathiasVP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -513,7 +513,7 @@ private module BoundsEstimate { | |||||
| float getBoundsLimit() { | ||||||
| // This limit is arbitrary, but low enough that it prevents timeouts on | ||||||
| // specific observed customer databases (and the in the tests). | ||||||
|
||||||
| // specific observed customer databases (and the in the tests). | |
| // specific observed customer databases (and in the tests). |
This file contains hidden or 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
73 changes: 73 additions & 0 deletions
73
cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/missing_bounds.cpp
This file contains hidden or 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,73 @@ | ||
| enum MY_ENUM { | ||
| A = 0x1, | ||
| B = 0x2, | ||
| C = 0x4, | ||
| D = 0x8, | ||
| E = 0x10, | ||
| F = 0x20, | ||
| G = 0x40, | ||
| H = 0x80, | ||
| I = 0x100, | ||
| J = 0x200, | ||
| L = 0x400, | ||
| M = 0x800, | ||
| N = 0x1000, | ||
| O = 0x2000, | ||
| P = 0x4000, | ||
| Q = 0x8000, | ||
| R = 0x10000, | ||
| S = 0x20000, | ||
| T = 0x40000, | ||
| U = 0x80000, | ||
| V = 0x100000, | ||
| W = 0x200000, | ||
| X = 0x400000, | ||
| Y = 0x800000, | ||
| Z = 0x1000000, | ||
| AA = 0x2000000, | ||
| AB = 0x4000000, | ||
| AC = 0x8000000, | ||
| AD = 0x10000000, | ||
| AE = 0x20000000 | ||
| }; | ||
|
|
||
| typedef unsigned int MY_ENUM_FLAGS; | ||
|
|
||
| MY_ENUM_FLAGS check_and_subs(MY_ENUM_FLAGS x) | ||
| { | ||
|
|
||
| #define CHECK_AND_SUB(flag) if ((x & flag) == flag) { x -= flag; } | ||
| CHECK_AND_SUB(A); | ||
| CHECK_AND_SUB(B); | ||
| CHECK_AND_SUB(C); | ||
| CHECK_AND_SUB(D); | ||
| CHECK_AND_SUB(E); | ||
| CHECK_AND_SUB(F); | ||
| CHECK_AND_SUB(G); | ||
| CHECK_AND_SUB(H); | ||
| CHECK_AND_SUB(I); | ||
| CHECK_AND_SUB(J); | ||
| CHECK_AND_SUB(L); | ||
| CHECK_AND_SUB(M); | ||
| CHECK_AND_SUB(N); | ||
| CHECK_AND_SUB(O); | ||
| CHECK_AND_SUB(P); | ||
| CHECK_AND_SUB(Q); | ||
| CHECK_AND_SUB(R); | ||
| CHECK_AND_SUB(S); | ||
| CHECK_AND_SUB(T); | ||
| CHECK_AND_SUB(U); | ||
| CHECK_AND_SUB(V); | ||
| CHECK_AND_SUB(W); | ||
| CHECK_AND_SUB(X); | ||
| CHECK_AND_SUB(Y); | ||
| CHECK_AND_SUB(Z); | ||
| CHECK_AND_SUB(AA); | ||
| CHECK_AND_SUB(AB); | ||
| CHECK_AND_SUB(AC); | ||
| CHECK_AND_SUB(AD); | ||
| CHECK_AND_SUB(AE); | ||
| #undef CHECK_AND_SUB | ||
|
|
||
MathiasVP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return x; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.