diff options
| author | Artem Dergachev <artem.dergachev@gmail.com> | 2019-11-08 18:04:27 -0800 |
|---|---|---|
| committer | Artem Dergachev <artem.dergachev@gmail.com> | 2019-11-08 18:27:14 -0800 |
| commit | 57adc37fe57c6edabc006e6de41523319e874c65 (patch) | |
| tree | 8cf677f30a9088d66ef86ac1e7a3e46bdaabd06b | |
| parent | 60ab30ebce833c87bd4776f67cd9a82fe162ef9c (diff) | |
| download | bcm5719-llvm-57adc37fe57c6edabc006e6de41523319e874c65.tar.gz bcm5719-llvm-57adc37fe57c6edabc006e6de41523319e874c65.zip | |
[analyzer] Nullability: Don't infer nullable when passing as nullable parameter.
You can't really infer anything from that.
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp | 5 | ||||
| -rw-r--r-- | clang/test/Analysis/nullability.m | 12 |
2 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp index 4322ac20711..922048733c7 100644 --- a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp @@ -728,11 +728,6 @@ void NullabilityChecker::checkPreCall(const CallEvent &Call, } continue; } - // No tracked nullability yet. - if (ArgExprTypeLevelNullability != Nullability::Nullable) - continue; - State = State->set<NullabilityMap>( - Region, NullabilityState(ArgExprTypeLevelNullability, ArgExpr)); } if (State != OrigState) C.addTransition(State); diff --git a/clang/test/Analysis/nullability.m b/clang/test/Analysis/nullability.m new file mode 100644 index 00000000000..f777900006d --- /dev/null +++ b/clang/test/Analysis/nullability.m @@ -0,0 +1,12 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker core,nullability -w -verify %s + +// expected-no-diagnostics + +id _Nonnull conjure_nonnull(); +void use_nullable(_Nullable id x); + +id _Nonnull foo() { + void *j = conjure_nonnull(); + use_nullable(j); + return j; // no-warning +} |

