diff options
author | Pavel Skripkin <paskripkin@gmail.com> | 2024-09-09 19:12:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-09 18:12:38 +0200 |
commit | db6051dae085c35020c1273ae8d38508c9958bc7 (patch) | |
tree | b9fa7b9daacaa733cfe91aeccf539174d31983d2 /clang/test | |
parent | 3cdb30ebbc18fa894d3bd67aebcff76ce7c741ac (diff) | |
download | llvm-db6051dae085c35020c1273ae8d38508c9958bc7.zip llvm-db6051dae085c35020c1273ae8d38508c9958bc7.tar.gz llvm-db6051dae085c35020c1273ae8d38508c9958bc7.tar.bz2 |
[analyzer] fix crash on binding to symbolic region with `void *` type (#107572)
As reported in
https://github.com/llvm/llvm-project/pull/103714#issuecomment-2295769193.
CSA crashes on trying to bind value to symbolic region with `void *`.
This happens when such region gets passed as inline asm input and engine
tries to bind `UnknownVal` to that region.
Fix it by changing type from void to char before calling
`GetElementZeroRegion`
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Analysis/asm.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/Analysis/asm.cpp b/clang/test/Analysis/asm.cpp index b17ab04..e0691dc 100644 --- a/clang/test/Analysis/asm.cpp +++ b/clang/test/Analysis/asm.cpp @@ -2,6 +2,8 @@ // RUN: -analyzer-checker debug.ExprInspection,core -Wno-error=invalid-gnu-asm-cast -w %s -verify int clang_analyzer_eval(int); +void clang_analyzer_dump(int); +void clang_analyzer_dump_ptr(void *); int global; void testRValueOutput() { @@ -40,3 +42,13 @@ void testInlineAsmMemcpyUninit(void) MyMemcpy(&a[1], &b[1], sizeof(b) - sizeof(b[1])); c = a[0]; // expected-warning{{Assigned value is garbage or undefined}} } + +void testAsmWithVoidPtrArgument() +{ + extern void *globalVoidPtr; + clang_analyzer_dump(*(int *)globalVoidPtr); // expected-warning-re {{reg_${{[0-9]+}}<int Element{SymRegion{reg_${{[0-9]+}}<void * globalVoidPtr>},0 S64b,int}>}} + clang_analyzer_dump_ptr(globalVoidPtr); // expected-warning-re {{&SymRegion{reg_${{[0-9]+}}<void * globalVoidPtr>}}} + asm ("" : : "a"(globalVoidPtr)); // no crash + clang_analyzer_dump(*(int *)globalVoidPtr); // expected-warning {{Unknown}} + clang_analyzer_dump_ptr(globalVoidPtr); // expected-warning-re {{&SymRegion{reg_${{[0-9]+}}<void * globalVoidPtr>}}} +} |