]> granicus.if.org Git - clang/commit
[analyzer] Add support for testing the presence of weak functions.
authorJordan Rose <jordan_rose@apple.com>
Wed, 28 Aug 2013 17:07:04 +0000 (17:07 +0000)
committerJordan Rose <jordan_rose@apple.com>
Wed, 28 Aug 2013 17:07:04 +0000 (17:07 +0000)
commit3aa6f431897edf5fec32cbede8fcddbfb8fa16f7
treeae2749ffab803aaec5bc94f043f174c255c5a328
parentf54617858a0df936746b7f521a8ffb032289d02f
[analyzer] Add support for testing the presence of weak functions.

When casting the address of a FunctionTextRegion to bool, or when adding
constraints to such an address, use a stand-in symbol to represent the
presence or absence of the function if the function is weakly linked.
This is groundwork for possible simple availability testing checks, and
can already catch mistakes involving inverted null checks for
weakly-linked functions.

Currently, the implementation reuses the "extent" symbols, originally created
for tracking the size of a malloc region. Since FunctionTextRegions cannot
be dereferenced, the extent symbol will never be used for anything else.
Still, this probably deserves a refactoring in the future.

This patch does not attempt to support testing the presence of weak
/variables/ (global variables), which would likely require much more of
a change and a generalization of "region structure metadata", like the
current "extents", vs. "region contents metadata", like CStringChecker's
"string length".

Patch by Richard <tarka.t.otter@googlemail.com>!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189492 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/SValBuilder.cpp
lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
lib/StaticAnalyzer/Core/SimpleConstraintManager.h
lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
lib/StaticAnalyzer/Core/SymbolManager.cpp
test/Analysis/weak-functions.c [new file with mode: 0644]