Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352537

Summary: Indexer does not recognize gcc builtin functions
Product: [Tools] CDT Reporter: Gunther Piez <gpiez>
Component: cdt-indexerAssignee: Project Inbox <cdt-indexer-inbox>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, jensen.j.brian, malaperle, yevshif, zeratul976
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Gunther Piez CLA 2011-07-20 03:48:32 EDT
Build Identifier: 20110615-0604

I get an error `Function __builtin_ia32_vec_ext_v8hi could not be resolved`	in a line using the SSE intrinsic function `_mm_extract_epi16(a,b)`.

The `_mm_extract_epi16(a,b)` is defined in the SSE2 header `emmintrin.h`, which is in the path, gets parsed and for which the relevant macros are defined ('__SSE__' and '__SSE2__' needs to defined, and it is).

The function is expanded with a macro to the gcc builtin function '__builtin_ia32_vec_ext_v8hi', which is defined nowhere (AFAIK), since it is built in.

Maybe all functions starting with "__builtin" when using gcc should be treated as "defined"?

This happens using gcc-4.5.3

Reproducible: Always
Comment 1 Marc-André Laperle CLA 2011-07-21 02:59:42 EDT
There is GCCBuiltinSymbolProvider that defines "other" built-ins from GCC, like __builtin_abs, etc. Maybe it would possible to have a GCCX86BuiltinSymbolProvider? I'm not sure how the types would map though.
Comment 2 Markus Schorn CLA 2011-07-21 03:48:35 EDT
(In reply to comment #1)
> There is GCCBuiltinSymbolProvider that defines "other" built-ins from GCC, like
> __builtin_abs, etc. Maybe it would possible to have a
> GCCX86BuiltinSymbolProvider? I'm not sure how the types would map though.

I would not mind adding target-specific builtins to GCCBuiltinSymbolProvider, they won't hurt on other platforms. However, there are lots of them and the gcc-manual does not even list all of them.
The data type is 'short __attribute__ ((vector_size (16)))', which will be treated as a short by our parser.

-> For the purpose of parsing it'd be sufficient to add 
int __builtin_ia32_vec_ext_v8hi(short, int) to GCCBuiltinSymbolProvider.
Comment 3 Nathan Ridge CLA 2014-10-26 03:02:27 EDT
As of April 2013, CDT no longer gives an error for uses of symbols that begin with '__builtin_'. [1]

They are still not syntax-colored as function calls; this could be accomplished by adding them to GCCBuiltinSymbolProvider as described in comment 2.

However, since the undocumented ones are not meant to be used directly [2], but rather through their wrapper macros, and since there are so many of them, I don't think there's a point in doing that.

I think this bug can be closed.

[1] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=fa881229
[2] https://www.mail-archive.com/gcc@gcc.gnu.org/msg03310.html
Comment 4 Nathan Ridge CLA 2016-12-22 18:55:04 EST
Closing per comment 3.