mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 01:36:38 +00:00

When debugging CSA issues, sometimes it would be useful to have a dedicated note for the analysis entry point, aka. the function name you would need to pass as "-analyze-function=XYZ" to reproduce a specific issue. One way we use (or will use) this downstream is to provide tooling on top of creduce to enhance to supercharge productivity by automatically reduce cases on crashes for example. This will be added only if the "-analyzer-note-analysis-entry-points" is set or the "analyzer-display-progress" is on. This additional entry point marker will be the first "note" if enabled, with the following message: "[debug] analyzing from XYZ". They are prefixed by "[debug]" to remind the CSA developer that this is only meant to be visible for them, for debugging purposes. CPP-5012
55 lines
2.4 KiB
C++
55 lines
2.4 KiB
C++
// RUN: %clang_analyze_cc1 -verify %s 2>&1 \
|
|
// RUN: -analyzer-display-progress \
|
|
// RUN: -analyzer-checker=debug.ExprInspection \
|
|
// RUN: -analyzer-output=text \
|
|
// RUN: | FileCheck %s
|
|
|
|
void clang_analyzer_warnIfReached();
|
|
|
|
// expected-note@+2 {{[debug] analyzing from f()}}
|
|
// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
|
|
void f() { clang_analyzer_warnIfReached(); }
|
|
|
|
// expected-note@+2 {{[debug] analyzing from g()}}
|
|
// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
|
|
void g() { clang_analyzer_warnIfReached(); }
|
|
|
|
// expected-note@+2 {{[debug] analyzing from h()}}
|
|
// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
|
|
void h() { clang_analyzer_warnIfReached(); }
|
|
|
|
struct SomeStruct {
|
|
// expected-note@+2 {{[debug] analyzing from SomeStruct::f()}}
|
|
// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
|
|
void f() { clang_analyzer_warnIfReached(); }
|
|
};
|
|
|
|
struct SomeOtherStruct {
|
|
// expected-note@+2 {{[debug] analyzing from SomeOtherStruct::f()}}
|
|
// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
|
|
void f() { clang_analyzer_warnIfReached(); }
|
|
};
|
|
|
|
namespace ns {
|
|
struct SomeStruct {
|
|
// expected-note@+2 {{[debug] analyzing from ns::SomeStruct::f(int)}}
|
|
// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
|
|
void f(int) { clang_analyzer_warnIfReached(); }
|
|
// expected-note@+2 {{[debug] analyzing from ns::SomeStruct::f(float, ::SomeStruct)}}
|
|
// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
|
|
void f(float, ::SomeStruct) { clang_analyzer_warnIfReached(); }
|
|
// expected-note@+2 {{[debug] analyzing from ns::SomeStruct::f(float, SomeStruct)}}
|
|
// expected-warning@+1 {{REACHABLE}} expected-note@+1 {{REACHABLE}}
|
|
void f(float, SomeStruct) { clang_analyzer_warnIfReached(); }
|
|
};
|
|
}
|
|
|
|
// CHECK: analyzer-display-progress.cpp f() : {{[0-9]+}}
|
|
// CHECK: analyzer-display-progress.cpp g() : {{[0-9]+}}
|
|
// CHECK: analyzer-display-progress.cpp h() : {{[0-9]+}}
|
|
// CHECK: analyzer-display-progress.cpp SomeStruct::f() : {{[0-9]+}}
|
|
// CHECK: analyzer-display-progress.cpp SomeOtherStruct::f() : {{[0-9]+}}
|
|
// CHECK: analyzer-display-progress.cpp ns::SomeStruct::f(int) : {{[0-9]+}}
|
|
// CHECK: analyzer-display-progress.cpp ns::SomeStruct::f(float, ::SomeStruct) : {{[0-9]+}}
|
|
// CHECK: analyzer-display-progress.cpp ns::SomeStruct::f(float, SomeStruct) : {{[0-9]+}}
|