https://bugs.llvm.org/show_bug.cgi?id=40101
Bug ID: 40101
Summary: __assume not handled correctly by clang-cl static
analyzer
Product: clang
Version: 7.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Static Analyzer
Assignee: dcough...@apple.com
Reporter: steve...@gmail.com
CC: dcough...@apple.com, llvm-bugs@lists.llvm.org
Using this file:
#if _MSC_VER
#define ASSUME(COND) __assume((COND))
#else
#define ASSUME(COND) do { if (!(COND)) __builtin_unreachable(); } while (0)
#endif
struct A
{
int someApi();
};
int testAssert(A* a) {
ASSUME(a != nullptr);
return a->someApi();
}
int testAssert2(int* a) {
ASSUME(a != nullptr);
return *a;
}
int testAssert3(A* a) {
ASSUME(a);
return a->someApi();
}
int testAssert4(int* a) {
ASSUME(a);
return *a;
}
on linux, I get no output:
$ clang++ --analyze ../tmp/assert.cpp
$
On windows I get false positives:
$ "c:\Program Files\LLVM\bin\clang-cl.exe" --analyze assert.cpp
assert.cpp(16,12): warning: Called C++ object pointer is null
return a->someApi();
^~~~~~~~~~~~
assert.cpp(21,12): warning: Dereference of null pointer (loaded from variable
'a')
return *a;
^~
2 warnings generated.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs