Commit 57f9ef9
committed
Avoid undefined behavior in shift operators during constant folding of DIExpressions.
Bit shift operations with a shift operand greater than or equal to the bit width
of the (promoted) value type result in undefined behavior according to C++
[expr.shift]p1. This change adds checking for this situation and avoids attempts
to constant fold DIExpressions that would otherwise provoke such behavior.
An existing test that presumably intended to exercise shifts at the UB boundary
has been updated; it now checks for shifts of 64 bits instead of 65. This issue
was reported by a static analysis tool; no actual cases of shift operations that
would result in undefined behavior in practice have been identified.1 parent 4b50ec4 commit 57f9ef9
File tree
2 files changed
+10
-8
lines changed- llvm
- lib/IR
- unittests/IR
2 files changed
+10
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | | - | |
| 68 | + | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3541 | 3541 | | |
3542 | 3542 | | |
3543 | 3543 | | |
3544 | | - | |
| 3544 | + | |
3545 | 3545 | | |
3546 | 3546 | | |
3547 | 3547 | | |
3548 | 3548 | | |
3549 | | - | |
| 3549 | + | |
3550 | 3550 | | |
3551 | 3551 | | |
3552 | 3552 | | |
3553 | 3553 | | |
3554 | 3554 | | |
3555 | 3555 | | |
3556 | 3556 | | |
3557 | | - | |
| 3557 | + | |
3558 | 3558 | | |
3559 | 3559 | | |
3560 | 3560 | | |
3561 | 3561 | | |
3562 | | - | |
| 3562 | + | |
3563 | 3563 | | |
3564 | 3564 | | |
3565 | 3565 | | |
3566 | 3566 | | |
3567 | | - | |
| 3567 | + | |
3568 | 3568 | | |
3569 | 3569 | | |
3570 | 3570 | | |
3571 | 3571 | | |
3572 | 3572 | | |
3573 | 3573 | | |
3574 | 3574 | | |
3575 | | - | |
| 3575 | + | |
3576 | 3576 | | |
3577 | 3577 | | |
3578 | 3578 | | |
| |||
0 commit comments