[analyzer] assume bitwise arithmetic axioms
authorGeorge Karpenkov <ekarpenkov@apple.com>
Thu, 9 Nov 2017 19:06:22 +0000 (19:06 +0000)
committerGeorge Karpenkov <ekarpenkov@apple.com>
Thu, 9 Nov 2017 19:06:22 +0000 (19:06 +0000)
commitbbb66ad7b2daba4b6f7ccfb8d15fa656c99ef00b
tree2260c5f08a00ea03b45c8a1e9f76db52b549fe8c
parentc019c39f4f75320aefb4142fffc2f3c3cea44e9e
[analyzer] assume bitwise arithmetic axioms

Patches the solver to assume that bitwise OR of an unsigned value with a
constant always produces a value larger-or-equal than the constant, and
bitwise AND with a constant always produces a value less-or-equal than
the constant.

This patch is especially useful in the context of using bitwise
arithmetic for error code encoding: the analyzer would be able to state
that the error code produced using a bitwise OR is non-zero.

Differential Revision: https://reviews.llvm.org/D39707

llvm-svn: 317820
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/test/Analysis/constant-folding.c