[clang] [analyzer] Compute length of string literal initializers (#66990) (PR #68368)

via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 9 18:09:20 PDT 2023


================
@@ -97,6 +97,17 @@ void strlen_constant2(char x) {
   clang_analyzer_eval(strlen(a) == 3); // expected-warning{{UNKNOWN}}
 }
 
+const char *const global_str_ptr = "abcd";
----------------
luamfb wrote:

I've added a new test to cover this too. Since non-const pointers can be changed to point to strings of different length, I've assumed the correct behavior for the comparison is to be UNKNOWN. Please let me know if this is wrong.

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


More information about the cfe-commits mailing list