This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Exclude builtin headers from system include extraction
ClosedPublic

Authored by sammccall on Jul 22 2023, 11:46 PM.

Details

Summary

Most headers that we discover are likely to be fairly portable across at least
clang/gcc, which is why we get away with adding them to clangd's search path.

This is not the case for the compiler builtin headers, which are shipped with
the parser and rely on parser builtins/features. We're better off *not* using
the the scanned builtin headers, and hoping our own intrinsics provide the
interface the code is relying on.

Fixes https://github.com/clangd/clangd/issues/1695

Diff Detail

Event Timeline

sammccall created this revision.Jul 22 2023, 11:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2023, 11:46 PM
Herald added a subscriber: arphaman. · View Herald Transcript
sammccall requested review of this revision.Jul 22 2023, 11:46 PM

remove (broken) support for -nobuiltininc

nridge added a subscriber: nridge.Jul 23 2023, 12:17 AM
sammccall updated this revision to Diff 543291.Jul 23 2023, 8:51 AM

fix incomplete cleanup of dead option

I built latest main with this patch applied and it does fix the issues in my environment. My headers that include xmmintrin.h etc. don't throw errors in clangd. Thanks!

kadircet accepted this revision.Jul 24 2023, 12:50 AM

thanks a lot!

This revision is now accepted and ready to land.Jul 24 2023, 12:50 AM

(just a note that another way to do this check is to look for some common intrinsic file in each directory generated by the compiler driver, and remove any directory containing those files. But, if the -print-file-name=include trick works reliably that's good too).