diff options
author | Anna Zaks <ganna@apple.com> | 2017-03-09 00:01:10 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2017-03-09 00:01:10 +0000 |
commit | 5a343ec2914569b31f8c092a2469a7392e3dd251 (patch) | |
tree | 8f027e90a9ea4680a678a354cf4b983d85880db2 /docs/analyzer | |
parent | ab6b808769f3e72b370c416b611d1499a4e68554 (diff) |
[analyzer] Improve usability of ExprInspectionChecker
Some of the magic functions take arguments of arbitrary type. However,
for semantic correctness, the compiler still requires a declaration
of these functions with the correct type. Since C does not have
argument-type-overloaded function, this made those functions hard to
use in C code. Improve this situation by allowing arbitrary suffixes
in the affected magic functions' names, thus allowing the user to
create different declarations for different types.
A patch by Keno Fischer!
Differential Revision: https://reviews.llvm.org/D30589
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297325 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/analyzer')
-rw-r--r-- | docs/analyzer/DebugChecks.rst | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/docs/analyzer/DebugChecks.rst b/docs/analyzer/DebugChecks.rst index ecf11ca0f1..880dcfc960 100644 --- a/docs/analyzer/DebugChecks.rst +++ b/docs/analyzer/DebugChecks.rst @@ -178,15 +178,21 @@ ExprInspection checks This function explains the value of its argument in a human-readable manner in the warning message. You can make as many overrides of its prototype in the test code as necessary to explain various integral, pointer, - or even record-type values. + or even record-type values. To simplify usage in C code (where overloading + the function declaration is not allowed), you may append an arbitrary suffix + to the function name, without affecting functionality. Example usage:: void clang_analyzer_explain(int); void clang_analyzer_explain(void *); + // Useful in C code + void clang_analyzer_explain_int(int); + void foo(int param, void *ptr) { clang_analyzer_explain(param); // expected-warning{{argument 'param'}} + clang_analyzer_explain_int(param); // expected-warning{{argument 'param'}} if (!ptr) clang_analyzer_explain(ptr); // expected-warning{{memory address '0'}} } |