Commit 089723d
committed
[clang] Implement -fstrict-bool
``bool`` values are stored as i8 in memory, and it is undefined
behavior for a ``bool`` value to be any value other than 0 or 1. Clang
exploits this with range metadata: ``bool`` load instructions at any
optimization level above -O0 are assumed to only have their lowest bit
set. This can create memory safety problems when other bits are set,
for instance through ``memcpy``.
This change adds a ``-f[no-]strict-bool`` option that controls this
behavior. It is enabled by default in order to not upset the status quo,
except in the Darwin driver when passing -mkernel.
Radar-ID: 1393972121 parent da032a6 commit 089723d
File tree
6 files changed
+44
-4
lines changed- clang
- docs
- include/clang
- Basic
- Driver
- lib
- CodeGen
- Driver/ToolChains
- test/CodeGen
6 files changed
+44
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2179 | 2179 | | |
2180 | 2180 | | |
2181 | 2181 | | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
2182 | 2187 | | |
2183 | 2188 | | |
2184 | 2189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| 314 | + | |
314 | 315 | | |
315 | 316 | | |
316 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3970 | 3970 | | |
3971 | 3971 | | |
3972 | 3972 | | |
| 3973 | + | |
| 3974 | + | |
| 3975 | + | |
| 3976 | + | |
| 3977 | + | |
| 3978 | + | |
3973 | 3979 | | |
3974 | 3980 | | |
3975 | 3981 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1896 | 1896 | | |
1897 | 1897 | | |
1898 | 1898 | | |
1899 | | - | |
1900 | | - | |
1901 | | - | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
1902 | 1902 | | |
1903 | 1903 | | |
1904 | 1904 | | |
1905 | 1905 | | |
1906 | 1906 | | |
1907 | 1907 | | |
1908 | 1908 | | |
| 1909 | + | |
| 1910 | + | |
1909 | 1911 | | |
1910 | 1912 | | |
1911 | 1913 | | |
| |||
1918 | 1920 | | |
1919 | 1921 | | |
1920 | 1922 | | |
| 1923 | + | |
1921 | 1924 | | |
1922 | 1925 | | |
1923 | 1926 | | |
| |||
1951 | 1954 | | |
1952 | 1955 | | |
1953 | 1956 | | |
1954 | | - | |
| 1957 | + | |
| 1958 | + | |
1955 | 1959 | | |
1956 | 1960 | | |
1957 | 1961 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5938 | 5938 | | |
5939 | 5939 | | |
5940 | 5940 | | |
| 5941 | + | |
| 5942 | + | |
5941 | 5943 | | |
5942 | 5944 | | |
5943 | 5945 | | |
| |||
6052 | 6054 | | |
6053 | 6055 | | |
6054 | 6056 | | |
| 6057 | + | |
| 6058 | + | |
| 6059 | + | |
| 6060 | + | |
6055 | 6061 | | |
6056 | 6062 | | |
6057 | 6063 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
0 commit comments