diff options
author | Vedant Kumar <vsk@apple.com> | 2017-06-23 21:32:38 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-06-23 21:32:38 +0000 |
commit | c34d343f15373dde087897d33fe3173726dd4cf1 (patch) | |
tree | 36ede4fd471c6f0cc0e76502eb6671951292d07f /clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp | |
parent | 77a2e6b198550e2e4bccf8b724bc1b7f8fa819ec (diff) | |
download | bcm5719-llvm-c34d343f15373dde087897d33fe3173726dd4cf1.tar.gz bcm5719-llvm-c34d343f15373dde087897d33fe3173726dd4cf1.zip |
[ubsan] Improve diagnostics for return value checks (clang)
This patch makes ubsan's nonnull return value diagnostics more precise,
which makes the diagnostics more useful when there are multiple return
statements in a function. Example:
1 |__attribute__((returns_nonnull)) char *foo() {
2 | if (...) {
3 | return expr_which_might_evaluate_to_null();
4 | } else {
5 | return another_expr_which_might_evaluate_to_null();
6 | }
7 |} // <- The current diagnostic always points here!
runtime error: Null returned from Line 7, Column 2!
With this patch, the diagnostic would point to either Line 3, Column 5
or Line 5, Column 5.
This is done by emitting source location metadata for each return
statement in a sanitized function. The runtime is passed a pointer to
the appropriate metadata so that it can prepare and deduplicate reports.
Compiler-rt patch (with more tests): https://reviews.llvm.org/D34298
Differential Revision: https://reviews.llvm.org/D34299
llvm-svn: 306163
Diffstat (limited to 'clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp')
0 files changed, 0 insertions, 0 deletions