diff options
author | Gabor Horvath <xazax.hun@gmail.com> | 2015-03-11 17:25:22 +0000 |
---|---|---|
committer | Gabor Horvath <xazax.hun@gmail.com> | 2015-03-11 17:25:22 +0000 |
commit | 343832181b853eaf703dfc929a3eb1acc35fa7bf (patch) | |
tree | 225ff0ef542df3153eb88211022e98c9d038d1ab /clang-tools-extra/test | |
parent | 29f342c6b5085d8d4221a346f59e58198ce6dd33 (diff) | |
download | bcm5719-llvm-343832181b853eaf703dfc929a3eb1acc35fa7bf.tar.gz bcm5719-llvm-343832181b853eaf703dfc929a3eb1acc35fa7bf.zip |
[clang-tidy] Static Analyzer checker configuration options pass-through.
Reviewed by: Alexander Kornienko
Differential Revision: http://reviews.llvm.org/D8164
llvm-svn: 231941
Diffstat (limited to 'clang-tools-extra/test')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/static-analyzer-config.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/static-analyzer-config.cpp b/clang-tools-extra/test/clang-tidy/static-analyzer-config.cpp new file mode 100644 index 00000000000..1af7cfb4d22 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/static-analyzer-config.cpp @@ -0,0 +1,19 @@ +// RUN: clang-tidy %s -checks='-*,clang-analyzer-unix.Malloc' -config='{CheckOptions: [{ key: "clang-analyzer-unix.Malloc:Optimistic", value: true}]}' -- | FileCheck %s +typedef __typeof(sizeof(int)) size_t; +void *malloc(size_t); +void free(void *); +void __attribute((ownership_returns(malloc))) *my_malloc(size_t); +void __attribute((ownership_takes(malloc, 1))) my_free(void *); + +void f1() { + void *p = malloc(12); + return; + // CHECK: warning: Potential leak of memory pointed to by 'p' [clang-analyzer-unix.Malloc] +} + +void af2() { + void *p = my_malloc(12); + my_free(p); + free(p); + // CHECK: warning: Attempt to free released memory [clang-analyzer-unix.Malloc] +} |