D12331: Always use the clang builtin headers for the libclang version we use

Milian Wolff noreply at phabricator.kde.org
Wed Apr 18 21:33:40 UTC 2018


mwolff created this revision.
Restricted Application added a subscriber: kdevelop-devel.
mwolff requested review of this revision.

REVISION SUMMARY
  When we try to parse GCC builtin headers, or headers from other clang
  versions, we can easily end up with dozens of parse errors that
  eventually reach the error limit. In such cases, kdev-clang becomes
  completely unusable.
  
  To prevent this from happening, we filter out the compiler include
  path for the builtin headers. This is done using a simple heuristic
  by looking for the varargs.h header. For my system, this is only
  available in these three folders:
  
  /usr/lib/clang/6.0.0/include/varargs.h
  /usr/lib/gcc/arm-none-eabi/7.3.0/include/varargs.h
  /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include/varargs.h
  
  All of them are folders for the compiler builtin headers. So now
  we always exclude these folders, and instead find the include path
  for the folder containing the builtin headers matching the libclang
  version we link against. This is required, since libclang does not
  find any builtin headers on its own, cf. [1].
  
  [1]: https://clang.llvm.org/docs/LibTooling.html#libtooling-builtin-includes
  
  In the end, this gives us a seemingly well working GCC emulation layer
  without the previous pitfalls. The macro compatibility header kept
  breaking, and we never had any support for different clang versions.
  
  BUG: 387005

REPOSITORY
  R32 KDevelop

BRANCH
  master

REVISION DETAIL
  https://phabricator.kde.org/D12331

AFFECTED FILES
  plugins/clang/CMakeLists.txt
  plugins/clang/duchain/gcc_compat.h
  plugins/clang/duchain/parsesession.cpp
  plugins/clang/libclang_include_path.h.cmake
  plugins/custom-definesandincludes/compilerprovider/gcclikecompiler.cpp

To: mwolff
Cc: kdevelop-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20180418/2cc4bf22/attachment.html>


More information about the KDevelop-devel mailing list