qqiangwu / cppsafe

Cpp lifetime safety profile static analyzer
MIT License
45 stars 1 forks source link

x86intrin.h woe #4

Closed adah1972 closed 5 months ago

adah1972 commented 7 months ago

For a simple test case:

#include <x86intrin.h>
int main() {}

cppsafe gives the following error messages on Ventura:

In file included from test.cpp:1:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/include/x86intrin.h:15:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/include/immintrin.h:26:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/include/xmmintrin.h:3009:
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/include/emmintrin.h:2228:19: error: use of undeclared identifier '__builtin_ia32_paddsb128'; did you mean '__builtin_ia32_phaddsw128'?
 2228 |   return (__m128i)__builtin_ia32_paddsb128((__v16qi)__a, (__v16qi)__b);
      |                   ^
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/include/emmintrin.h:2228:19: note: '__builtin_ia32_phaddsw128' declared here
adah1972 commented 7 months ago

Workaround: manually add the LLVM17 include directories, like:

cppsafe test.cpp -- -isystem /usr/local/opt/llvm@17/bin/../include/c++/v1 -isystem /usr/local/Cellar/llvm/17.0.6_1/lib/clang/17/include -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks

So it seems colocating with LLVM installation is more reliable ...

qqiangwu commented 4 months ago

see https://github.com/llvm/llvm-project/issues/69566 for more detail