summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2014-10-13 19:38:02 +0000
committerJordan Rose <jordan_rose@apple.com>2014-10-13 19:38:02 +0000
commit679659f58c865cb18c69e1c789e944b4aa72a66d (patch)
tree008565f5df0e46251097dcb7bc3cbe961f1af569 /clang/lib/StaticAnalyzer
parent193d87fd8cdb746f1050d274cac096ba318e2f2b (diff)
downloadbcm5719-llvm-679659f58c865cb18c69e1c789e944b4aa72a66d.tar.gz
bcm5719-llvm-679659f58c865cb18c69e1c789e944b4aa72a66d.zip
[analyzer] Check all 'nonnull' attributes, not just the first one.
Patch by Daniel Fahlgren! llvm-svn: 219625
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
index 650aa8b8758..cb2d46b5831 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -49,16 +49,27 @@ void NonNullParamChecker::checkPreCall(const CallEvent &Call,
if (!FD)
return;
- // FIXME: This is wrong; there can be multiple attributes with different sets
- // of non-null parameter indices.
- const NonNullAttr *Att = FD->getAttr<NonNullAttr>();
+ // Merge all non-null attributes
+ unsigned NumArgs = Call.getNumArgs();
+ llvm::SmallBitVector AttrNonNull(NumArgs);
+ for (const auto *NonNull : FD->specific_attrs<NonNullAttr>()) {
+ if (!NonNull->args_size()) {
+ AttrNonNull.set(0, NumArgs);
+ break;
+ }
+ for (unsigned Val : NonNull->args()) {
+ if (Val >= NumArgs)
+ continue;
+ AttrNonNull.set(Val);
+ }
+ }
ProgramStateRef state = C.getState();
CallEvent::param_type_iterator TyI = Call.param_type_begin(),
TyE = Call.param_type_end();
- for (unsigned idx = 0, count = Call.getNumArgs(); idx != count; ++idx){
+ for (unsigned idx = 0; idx < NumArgs; ++idx) {
// Check if the parameter is a reference. We want to report when reference
// to a null pointer is passed as a paramter.
@@ -68,7 +79,7 @@ void NonNullParamChecker::checkPreCall(const CallEvent &Call,
TyI++;
}
- bool haveAttrNonNull = Att && Att->isNonNull(idx);
+ bool haveAttrNonNull = AttrNonNull[idx];
if (!haveAttrNonNull) {
// Check if the parameter is also marked 'nonnull'.
ArrayRef<ParmVarDecl*> parms = Call.parameters();
OpenPOWER on IntegriCloud