gnu.cfg: Add more __builtin_* functions and some tests

Most of them were detected by daca@home
This commit is contained in:
versat 2019-08-02 12:27:46 +02:00
parent c1773225e7
commit 2519a1aed5
2 changed files with 66 additions and 0 deletions

View File

@ -39,6 +39,63 @@
<define name="__bswap_64(x)" value="bswap_64(x)"/>
<!-- https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html -->
<define name="__builtin_alloca(size)" value="alloca(size)"/>
<define name="__builtin_memcpy(dest, source, size)" value="memcpy(dest, source, size)"/>
<define name="__builtin_signbit(value)" value="signbit(value)"/>
<define name="__builtin_offsetof(st, m)" value="offsetof(st, m)"/>
<define name="__builtin_nan(str)" value="nan(str)"/>
<define name="__builtin_nanf(str)" value="nanf(str)"/>
<define name="__builtin_nanl(str)" value="nanl(str)"/>
<define name="__builtin_signbit(value)" value="signbit(value)"/>
<!-- void *__builtin_alloca (size_t size) -->
<!-- alloca() is often defined as __builtin_alloca() so the define above does not work always -->
<!-- void *alloca(size_t size); -->
<function name="__builtin_alloca">
<use-retval/>
<returnValue type="void *"/>
<noreturn>false</noreturn>
<arg nr="1" direction="in">
<not-uninit/>
<valid>0:</valid>
</arg>
</function>
<!-- void __builtin_prefetch (const void *addr, ...) -->
<function name="__builtin_prefetch">
<noreturn>false</noreturn>
<returnValue type="void"/>
<leak-ignore/>
<arg nr="1" direction="in"/>
<arg nr="variadic" direction="in">
<not-uninit/>
</arg>
</function>
<!-- int __builtin_types_compatible_p (type1, type2) -->
<function name="__builtin_types_compatible_p">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
<leak-ignore/>
<arg nr="1"/>
<arg nr="2"/>
</function>
<!-- void __builtin_trap (void) -->
<function name="__builtin_trap">
<noreturn>true</noreturn>
</function>
<!-- int __builtin_popcount (unsigned int x) -->
<!-- int __builtin_parity (unsigned int x) -->
<!-- int __builtin_ffs (int x) -->
<!-- int __builtin_ffsl (long) -->
<!-- int __builtin_ffsll (long long) -->
<!-- int __builtin_clz (unsigned int x) -->
<function name="__builtin_popcount,__builtin_parity,__builtin_ffs,__builtin_ffsl,__builtin_ffsll,__builtin_clz">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- void xexit(int status); -->
<function name="xexit">
<noreturn>true</noreturn>

View File

@ -90,6 +90,15 @@ void valid_code(int argInt1)
free(p);
p = (char *)xmalloc(5);
xfree(p);
// cppcheck-suppress allocaCalled
p = __builtin_alloca(5);
p[0] = 1;
// TODO cppcheck-suppress arrayIndexOutOfBounds
p[5] = 1;
__builtin_prefetch(p, 0, 1);
if (__builtin_types_compatible_p(int, char)) {}
}
void ignoreleak(void)