llvm-project/clang/test/Analysis/analyzeOneFunction.cpp
Balazs Benics ef4471edfa
[analyzer] Teach -analyze-function about USRs, extend documentation (#161666)
This flag is really convinient in most cases.
It's easy to figure out what value to pass for most cases. However, it
can sometimes match too many times, like for template functions that has
non-decuded (aka. explicitly specified) template parameters - because
they don't appear in the parameter list, thus they are not accounted for
in the current logic.

It would be nice to improve `getFunctionName` but I'd say to just settle
on using USRs. So this PR enables passing USRs to the flag, while
keeping previous behavior.
2025-10-03 16:24:03 +02:00

19 lines
811 B
C++

// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s \
// RUN: -analyze-function="Window::overloaded(int)"
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s \
// RUN: -analyze-function="c:@S@Window@F@overloaded#I#"
// RUN: %clang_extdef_map %s | FileCheck %s
// CHECK: 27:c:@S@Window@F@overloaded#I#
// CHECK-NEXT: 27:c:@S@Window@F@overloaded#C#
// CHECK-NEXT: 27:c:@S@Window@F@overloaded#d#
void clang_analyzer_warnIfReached();
struct Window {
void overloaded(double) { clang_analyzer_warnIfReached(); } // not analyzed, thus not reachable
void overloaded(char) { clang_analyzer_warnIfReached(); } // not analyzed, thus not reachable
void overloaded(int) { clang_analyzer_warnIfReached(); } // expected-warning {{REACHABLE}}
};