================
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -x c -std=c2y %s
+// expected-no-diagnostics
+
+// Ensure that VLA types are correctly handled by unary type traits in the
+// expression engine. Previously, __datasizeof and _Countof both caused failed
+// assertions.
+void gh151711(int i) {
+ (void)sizeof(int[i++]);
+
+#ifdef __cplusplus
+ // __datasizeof is only available in C++.
+ (void)__datasizeof(int[i++]);
+#else
+ // _Countof is only available in C.
+ (void)_Countof(int[i++]);
+#endif
+}
----------------
steakhal wrote:
Could you dump the result of these expressions? I'm not convinced we do the
right thing in terms of semantics.
Be sure to patch the RUN lines by replacing `core` with
`core,debug.ExprInspection`.
Please report back what you get. My bet is that it's handled the same way as
sizeof before, hence we get "unknown" - which is the correct result in this
case.
If that would be the case, feel free to asset it with an expected warning.
```suggestion
void clang_analyzer_dump(int);
// Ensure that VLA types are correctly handled by unary type traits in the
// expression engine. Previously, __datasizeof and _Countof both caused failed
// assertions.
void gh151711(int i) {
clang_analyzer_dump(sizeof(int[i++])); // expected-warning {{Unknown}}
#ifdef __cplusplus
// __datasizeof is only available in C++.
clang_analyzer_dump(__datasizeof(int[i++]));
#else
// _Countof is only available in C.
clang_analyzer_dump(_Countof(int[i++]));
#endif
}
```
https://github.com/llvm/llvm-project/pull/151719
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits