================ @@ -0,0 +1,198 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify=expected,default %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config legacy-inlining-prevention=false -verify=expected,disabled %s + +int getNum(void); // Get an opaque number. + +void clang_analyzer_numTimesReached(void); +void clang_analyzer_dump(int arg); + +//----------------------------------------------------------------------------- +// Simple case: inlined function never reaches `analyzer-max-loop`. + +int inner_simple(void) { + clang_analyzer_numTimesReached(); // expected-warning {{2}} + return 42; +} + +int outer_simple(void) { + int x = inner_simple(); + int y = inner_simple(); + return 53 / (x - y); // expected-warning {{Division by zero}} +} + +//----------------------------------------------------------------------------- +// Inlined function always reaches `analyzer-max-loop`. + +int inner_fixed_loop_1(void) { + int i; + clang_analyzer_numTimesReached(); // expected-warning {{1}} ---------------- balazs-benics-sonarsource wrote:
You could pass a `const char*` from a string literal to differentiate which is inlined when observing its value using a `clang_analyzer_dump()` at the beginning of this inlined function. That should make it clear that for the first time its inlined, but for the second time it's not. https://github.com/llvm/llvm-project/pull/136720 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits