mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 11:35:51 -04:00

Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296895
28 lines
741 B
C++
28 lines
741 B
C++
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.ReturnPtrRange -verify %s
|
|
|
|
int arr[10];
|
|
int *ptr;
|
|
|
|
int conjure_index();
|
|
|
|
int *test_element_index_lifetime() {
|
|
do {
|
|
int x = conjure_index();
|
|
ptr = arr + x;
|
|
if (x != 20)
|
|
return arr; // no-warning
|
|
} while (0);
|
|
return ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow)}}
|
|
}
|
|
|
|
int *test_element_index_lifetime_with_local_ptr() {
|
|
int *local_ptr;
|
|
do {
|
|
int x = conjure_index();
|
|
local_ptr = arr + x;
|
|
if (x != 20)
|
|
return arr; // no-warning
|
|
} while (0);
|
|
return local_ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow)}}
|
|
}
|