about summary refs log tree commit diff
path: root/src/rustllvm/ExecutionEngineWrapper.cpp
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-05-14 14:39:16 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-05-15 13:50:33 -0700
commit912a9675c0b7f9e8c836983e525b180c48693925 (patch)
tree3543072ddff4c87068ed5b191db6b57660662fb7 /src/rustllvm/ExecutionEngineWrapper.cpp
parentd547de998d33e5b688533f4159ea997c940d9431 (diff)
downloadrust-912a9675c0b7f9e8c836983e525b180c48693925.tar.gz
rust-912a9675c0b7f9e8c836983e525b180c48693925.zip
Make `from_bits` in `bitflags!` safe; add `from_bits_truncate`
Previously, the `from_bits` function in the `std::bitflags::bitflags`
macro was marked as unsafe, as it did not check that the bits being
converted actually corresponded to flags.

This patch changes the function to check against the full set of
possible flags and return an `Option` which is `None` if a non-flag bit
is set. It also adds a `from_bits_truncate` function which simply zeros
any bits not corresponding to a flag.

This addresses the concern raised in https://github.com/mozilla/rust/pull/13897
Diffstat (limited to 'src/rustllvm/ExecutionEngineWrapper.cpp')
0 files changed, 0 insertions, 0 deletions