[clang] [clang][analyzer] Fix #embed crash (PR #107764)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 9 02:11:57 PDT 2024


================
@@ -0,0 +1,9 @@
+// RUN: %clang_analyze_cc1 -std=c23 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// expected-no-diagnostics
+
+int main() {
+    const unsigned char SelfBytes[] = {
+        #embed "embed.c"
+    };
+}
----------------
steakhal wrote:

```suggestion
// RUN: %clang_analyze_cc1 -std=c23 -analyzer-checker=core,debug.ExprInspection -verify %s

void clang_analyzer_dump_ptr(const unsigned char *ptr);
void clang_analyzer_dump(unsigned char val);

int main() {
    const unsigned char SelfBytes[] = {
        #embed "embed.c"
    };
    clang_analyzer_dump_ptr(SelfBytes); // expected-warning {{&Element{SelfBytes,0 S64b,unsigned char}}}
    clang_analyzer_dump(SelfBytes[0]); // expected-warning {{Unknown}} FIXME: This should be the `/` character.
}
```

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


More information about the cfe-commits mailing list