]> granicus.if.org Git - clang/commit
[analyzer] Treat more const variables and fields as known contants.
authorArtem Dergachev <artem.dergachev@gmail.com>
Fri, 4 May 2018 20:52:39 +0000 (20:52 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Fri, 4 May 2018 20:52:39 +0000 (20:52 +0000)
commit8ae2126a3f455c3726c6ba93838d50f285fd1eba
tree71f26f642669fe3dc5d1a91fba1ea1ce73099f54
parent2e9c64acdd7c73ed179a6b13fc38fc74f10deebb
[analyzer] Treat more const variables and fields as known contants.

When loading from a variable or a field that is declared as constant,
the analyzer will try to inspect its initializer and constant-fold it.
Upon success, the analyzer would skip normal load and return the respective
constant.

The new behavior also applies to fields/elements of brace-initialized structures
and arrays.

Patch by Rafael Stahl!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331556 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/RegionStore.cpp
lib/StaticAnalyzer/Core/SValBuilder.cpp
test/Analysis/globals.cpp [new file with mode: 0644]