Libclang Integrati
KDevelop IDE
Kevin Funk ([email protected])
April 14, 2015 | London | EuroLLVM 2
ion in the
2015
About KDevelop
● A free, open-source, plugin ex
● Started in 1998 – GPL
● Cross-platform – written in C+
● Supports many languages
● C++
● Python, PHP, Ruby, QML/JS
● Debugger integration
● GDB, Xdebug (PHP) – no LL
● Known for its powerful code n
xtensible IDE
++/Qt
S, …
LDB yet! :'(
navigation/completion support
History of C++ Language
● Issues with current C++ Sup
● Custom parser living inside
● Over 50 000 LOC
● Hard to maintain, even har
– Hint: C++11, C++14, …
● Lots of issues with non-trivia
– (designated initializers, ...)
● Not possible to disambiguat
C vs. C++, or separate C++
● ...
Kevin Funk Clang Integratio
e Support
pport
e KDevelop code base
rder to extend
al C/C++ code
)
te between
+ standard versions
on in KDevelop 3
Clang to the Rescue!
● C/C++/ObjC language fronten
● Features
● Expressive diagnostics
● Allows tight integration with I
● BSD-licensed
● Highly active community
● Stable API via libclang
Kevin Funk Clang Integratio
nd for LLVM
IDEs
on in KDevelop 4
Implementati
Kevin Funk Clang Integratio
ion overview
on in KDevelop 5
Language Support Archi
12
10
8
6
4
2
0
Row 1 new pluRgowin2
Kevin Funk Clang Integratio
itecture
Column 1
Column 2
Column 3
Row 3 Row 4
on in KDevelop 6
Libclang Features Used
● C++ AST introspection
● Extract definitions, uses, thei
● Diagnostic reporting
● Spell-checking, fixits
● Macro definitions/expansions
● PCH generation
● Unsaved files for editor buffer
● Code completion
Kevin Funk Clang Integratio
ir attributes 7
s
rs
on in KDevelop
Impres
Kevin Funk Clang Integratio
ssions 8
on in KDevelop
Clang Assistants
● Providing diagnostics/fixits fro
Kevin Funk Clang Integratio
om Clang
on in KDevelop 9
Clang Code Completion
● Show viable expressions for c
Kevin Funk Clang Integratio
current context
on in KDevelop 10
Clang Code Completion
● Special completion: Enum-ca
Kevin Funk Clang Integratio
cont'd
ase labels
on in KDevelop 11
Clang Macro Navigation
● Show definition text and uses
Kevin Funk Clang Integratio
s of Macro definitions
on in KDevelop 12
Clang Objective-C Suppo
● A little bit of Objective-C supp
Kevin Funk Clang Integratio
ort
port
on in KDevelop 13
Clang Helpers
● Clang parsing Doxygen-style
Kevin Funk Clang Integratio
comments
on in KDevelop 14
What's u
Kevin Funk Clang Integratio
up next?
on in KDevelop 15
TODO in our C++ suppor
● Libclang
● Fix C++11-auto type deductio
● Get preprocessed contents in
● “Identifiable” diagnostics
Introduce: int clang_getD
● KDevelop Clang support plug
● Backport of our custom parse
– Example: Auto-transform of
string* s = …; s.<cursor>
● Make it work on Windows (M
No constexpr support yet! :(
Kevin Funk Clang Integratio
rt
on
n macro expansions
tDiagnosticId(…)?
gin
er's capabilities
f . to -> in
>
MSVC):
on in KDevelop 16
Join Us!
● kdev-clang is manageable (
● Clean, C++11-aware code ba
● Fully unit-tested
● KDevelop provides powerful
saves precious manpower
● Easy to implement new assis
Kevin Funk Clang Integratio
(below 10 KLOC)
ase
language-agnostic interfaces,
stants/warnings, …
on in KDevelop 17
Tha
Kevin Funk Clang Integratio
anks!
on in KDevelop 18
References
● Contact
● IRC: #kdevelop on Freenode
● Mailing list: kdevelop-devel@
● GSoC: Clang Integration in
http://kfunk.org/2014/04/28/gsoc-2014
lop/
(+ follow-up posts)
● Try it out yourself:
http://milianw.de/blog/katekdevelop-sp
Take my Code]
Kevin Funk Clang Integratio
e
@kde.org
KDevelop:
4-improving-the-clang-integration-in-kdeve
print-2014-let-there-be-clang [Section:
on in KDevelop 19