Bug 426335

Summary: kdevelop symantic analysis opencl only partially working
Product: [Applications] kdevelop Reporter: jpsollie <janpieter.sollie>
Component: Language Support: CPP (Clang-based)Assignee: kdevelop-bugs-null
Status: CONFIRMED ---    
Severity: normal CC: aaronpuchert, kossebau, mail
Priority: NOR    
Version First Reported In: 5.6.0   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: image of error
cl code described in bug (mimal)

Description jpsollie 2020-09-09 09:25:41 UTC
Created attachment 131507 [details]
image of error

SUMMARY
the opencl semantic analysis of kdevelop is only partially working:
while it "warns" about a #pragma OPENCL EXTENSION all : enable statement (which is not allowed) it errors on uchar and int4 with "undefined type"
view attachment as example

STEPS TO REPRODUCE
1. create opencl file
2. write code
3. 

OBSERVED RESULT
Opencl semantic analysis errors

EXPECTED RESULT
no errors

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Gentoo Linux 5.6
(available in About System)
KDE Plasma Version: 5.19.4
KDE Frameworks Version: 5.72.0
Qt Version: 5.15

ADDITIONAL INFORMATION
view attachment image
Comment 1 jpsollie 2020-09-09 09:32:04 UTC
Created attachment 131508 [details]
cl code described in bug (mimal)
Comment 2 Francis Herne 2020-09-09 14:06:57 UTC
The same errors are reported when calling `clang -cl-std=CL1.2 file.cl`.


Adding `-include /usr/lib/clang/10.0.1/include/opencl-c.h` to the command resolves them, and jpsollie reports that adding this same header to 'Custom Defines/Includes' makes KDevelop work.

We should probably include this automatically when parsing CL files in KDevelop.
Comment 3 Aaron Puchert 2020-09-26 22:00:49 UTC
Or we use -fdeclare-opencl-builtins. (https://reviews.llvm.org/D60763)

Supposedly the header takes very long to parse and this flag uses builtin declarations instead. Apparently one still has to include opencl-c-base.h though.
Comment 4 Aaron Puchert 2020-09-26 22:08:04 UTC
(In reply to Aaron Puchert from comment #3)
> Or we use -fdeclare-opencl-builtins. (https://reviews.llvm.org/D60763)
Maybe not for now though, the flag is still considered experimental (you have to prefix it with -Xclang). It worked for me, but maybe it's not production-ready.

There was a proposal to include the builtin header by default, but it got stalled because of this apparently. (https://reviews.llvm.org/D78979)