This change uses the higher level libclang library to achieve similar
results as before. It paves the way to be able to use other things
from the library such as clang_codeCompleteAt. Using CXTranslationUnits
while keeping the current ASTUnit would mean parsing the files twice
so this is why this change removes the ASTUnits.
Details
- Reviewers
- None
Diff Detail
- Build Status
Buildable 4807 Build 4807: arc lint + arc unit
Event Timeline
Just to make things clear, I'm really not sure if this is the right approach and I'm looking for opinions before going further in that direction (code completion).
It's not. the goal is to get rid of ASTUnit inside of clangd in the long term as it's a big problem for extensibility. libclang is just a wrapper for ASTUnit, with even more problems.
If you want to get completion running, just call ASTUnit::CodeComplete.
Thanks a lot. When you say the goal is to get rid of ASTUnit, what would it be replaced with? Also, why would one use libclang over ASTUnit (libclangFrontend) then? Perhaps there's some documentation listing the pros and cons?
libclang is supposed to be used for bindings to other languages (it's a pure C interface) and its stable. ASTUnit is the C++ side of libclang, libclang is just a thin wrapper around ASTUnit. ASTUnit itself suffers from lots of technical debt because clang changed since ASTUnit was created and ASTUnit was never refactored to accommodate that.
Even in the current state using ASTUnit gives you more control over clang, e.g. it lets you use the VFS which is not exposed in libclang. At some point we're going to need a cleaner replacement for ASTUnit, but currently it's the only place in clang that supports the precompiled preamble needed for speedy code completion.