Commit f448a60
committed
Allow use-after-scope front-end argument to take effect with -fsanitize=kernel-address
Lifetime intrinsics required for detection of use-after-scope are not emitted
under kernel-address sanitizer (`-fsanitize=kernel-address`) when paired with
`-O0` & `-fsanitize-address-use-after-scope`.
This is because with `-fsanitize=kernel-address -O0` under
`shouldEmitLifetimeMarkers` in `clang\lib\CodeGen\CodeGenFunction.cpp`,
`CGOpts.SanitizeAddressUseAfterScope` is set to `false`. Therefore, the
following check, `CGOpts.OptimizationLevel != 0`, is run which evaluates to
`false` thus preventing the emission of lifetime markers.
The reason `CGOpts.SanitizeAddressUseAfterScope` is false stems from the fact
that this variable is normally set via the frontend flag
`-fsanitize-address-use-after-scope`, however, this flag only takes effect
under normal address sanitizer due to the gated logic in
`clang\lib\Driver\SanitizerArgs.cpp`, specifically,
`if (AllAddedKinds & SanitizerKind::Address)`. This check excludes
`SanitizerKind::KernelAddress` from consideration, so even if
`-fsanitize-address-use-after-scope` is supplied as a front-end argument, it
won't be passed to `cc1` thus preventing `use-after-scope` checks from
being emitted under `-fsanitize-kernel-address -O0`. Higher optimization levels
will allow emission of lifetime markers regardless thanks to the logic in
`shouldEmitLifetimeMarkers`.
This PR allows `-fsanitize-address-use-after-scope` to take effect under
kernel-address sanitizer.1 parent 2e389cb commit f448a60
File tree
3 files changed
+13
-1
lines changed- clang
- lib/Driver
- test
- CodeGenCXX
- CodeGen
3 files changed
+13
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1099 | 1099 | | |
1100 | 1100 | | |
1101 | 1101 | | |
1102 | | - | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
1103 | 1109 | | |
1104 | 1110 | | |
1105 | 1111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
0 commit comments