summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/PseudoConstantAnalysis.cpp
diff options
context:
space:
mode:
authorJF Bastien <jfbastien@apple.com>2018-05-25 23:43:53 +0000
committerJF Bastien <jfbastien@apple.com>2018-05-25 23:43:53 +0000
commit1be7517aa9d860461cd986a85ef659d43d1d74b6 (patch)
treee2d0bee423a0dc389a69c5f7b3f571c2f24dc5b2 /clang/lib/Analysis/PseudoConstantAnalysis.cpp
parent3514bace279c8f47673e8e6df86cd3beb1879fb9 (diff)
downloadbcm5719-llvm-1be7517aa9d860461cd986a85ef659d43d1d74b6.tar.gz
bcm5719-llvm-1be7517aa9d860461cd986a85ef659d43d1d74b6.zip
Add nonnull; use it for atomics
Summary: The atomic non-member functions accept pointers to std::atomic / std::atomic_flag as well as to the non-atomic value. These are all dereferenced unconditionally when lowered, and therefore will fault if null. It's a tiny gotcha for new users, especially when they pass in NULL as expected value (instead of passing a pointer to a NULL value). We can therefore use the nonnull attribute to denote that: - A warning should be generated if the argument is null - It is undefined behavior if the argument is null (because a dereference will segfault) This patch adds support for this attribute for clang and GCC, and sticks to the subset of the syntax both supports. In particular, work around this GCC oddity: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60625 The attributes are documented: - https://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html - https://clang.llvm.org/docs/AttributeReference.html#nullability-attributes I'm authoring a companion clang patch for the __c11_* and __atomic_* builtins, which currently only warn on a subset of the pointer parameters. In all cases the check needs to be explicit and not use the empty nonnull list, because some of the overloads are for atomic<T*> and the values themselves are allowed to be null. <rdar://problem/18473124> Reviewers: arphaman, EricWF Subscribers: aheejin, christof, cfe-commits Differential Revision: https://reviews.llvm.org/D47225 llvm-svn: 333325
Diffstat (limited to 'clang/lib/Analysis/PseudoConstantAnalysis.cpp')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud