[clang] [analyzer] Fix "sprintf" parameter modeling in CStringChecker (PR #74345)

via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 07:04:00 PST 2023


================
@@ -1,13 +1,15 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -verify %s
-
-// expected-no-diagnostics
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection -verify %s
 
 // Test functions that are called "memcpy" but aren't the memcpy
 // we're looking for. Unfortunately, this test cannot be put into
 // a namespace. The out-of-class weird memcpy needs to be recognized
 // as a normal C function for the test to make sense.
 typedef __typeof(sizeof(int)) size_t;
 void *memcpy(void *, const void *, size_t);
+int sprintf(char *str, const char *format, ...);
----------------
DonatNagyE wrote:

Bikeshedding: add a blank line above this to emphasize that they're independent from the comment block that's above them.

Personally I slightly prefer the style when the mock library declarations appear directly above the testcase that's using them when there's just one testcase that's using them (and the test file is not brutally large); but this "declare everything at the top" style is also OK and has its own advantages.

https://github.com/llvm/llvm-project/pull/74345


More information about the cfe-commits mailing list