Libclang Integration in the KDevelop IDE Kevin Funk (kfunk@kde.org) - - PowerPoint PPT Presentation

libclang integration in the kdevelop ide
SMART_READER_LITE
LIVE PREVIEW

Libclang Integration in the KDevelop IDE Kevin Funk (kfunk@kde.org) - - PowerPoint PPT Presentation

Libclang Integration in the KDevelop IDE Kevin Funk (kfunk@kde.org) April 14, 2015 | London | EuroLLVM 2015 About KDevelop A free, open-source, plugin extensible IDE Started in 1998 GPL Cross-platform written in C++/Qt


slide-1
SLIDE 1

Libclang Integration in the KDevelop IDE

Kevin Funk (kfunk@kde.org)

April 14, 2015 | London | EuroLLVM 2015

slide-2
SLIDE 2

About KDevelop

  • A free, open-source, plugin extensible IDE
  • Started in 1998 – GPL
  • Cross-platform – written in C++/Qt
  • Supports many languages
  • C++
  • Python, PHP, Ruby, QML/JS, …
  • Debugger integration
  • GDB, Xdebug (PHP) – no LLDB yet! :'(
  • Known for its powerful code navigation/completion support
slide-3
SLIDE 3

Kevin Funk Clang Integration in KDevelop 3

History of C++ Language Support

  • Issues with current C++ Support
  • Custom parser living inside KDevelop code base
  • Over 50 000 LOC
  • Hard to maintain, even harder to extend

– Hint: C++11, C++14, …

  • Lots of issues with non-trivial C/C++ code

– (designated initializers, ...)

  • Not possible to disambiguate between

C vs. C++, or separate C++ standard versions

  • ...
slide-4
SLIDE 4

Kevin Funk Clang Integration in KDevelop 4

Clang to the Rescue!

  • C/C++/ObjC language frontend for LLVM
  • Features
  • Expressive diagnostics
  • Allows tight integration with IDEs
  • BSD-licensed
  • Highly active community
  • Stable API via libclang
slide-5
SLIDE 5

Kevin Funk Clang Integration in KDevelop 5

Implementation overview

slide-6
SLIDE 6

Kevin Funk Clang Integration in KDevelop 6

Language Support Architecture

Row 1 Row 2 Row 3 Row 4 2 4 6 8 10 12 Column 1 Column 2 Column 3

new plugin

slide-7
SLIDE 7

Kevin Funk Clang Integration in KDevelop 7

Libclang Features Used

  • C++ AST introspection
  • Extract definitions, uses, their attributes
  • Diagnostic reporting
  • Spell-checking, fixits
  • Macro definitions/expansions
  • PCH generation
  • Unsaved files for editor buffers
  • Code completion
slide-8
SLIDE 8

Kevin Funk Clang Integration in KDevelop 8

Impressions

slide-9
SLIDE 9

Kevin Funk Clang Integration in KDevelop 9

Clang Assistants

  • Providing diagnostics/fixits from Clang
slide-10
SLIDE 10

Kevin Funk Clang Integration in KDevelop 10

Clang Code Completion

  • Show viable expressions for current context
slide-11
SLIDE 11

Kevin Funk Clang Integration in KDevelop 11

Clang Code Completion cont'd

  • Special completion: Enum-case labels
slide-12
SLIDE 12

Kevin Funk Clang Integration in KDevelop 12

Clang Macro Navigation

  • Show definition text and uses of Macro definitions
slide-13
SLIDE 13

Kevin Funk Clang Integration in KDevelop 13

Clang Objective-C Support

  • A little bit of Objective-C support
slide-14
SLIDE 14

Kevin Funk Clang Integration in KDevelop 14

Clang Helpers

  • Clang parsing Doxygen-style comments
slide-15
SLIDE 15

Kevin Funk Clang Integration in KDevelop 15

What's up next?

slide-16
SLIDE 16

Kevin Funk Clang Integration in KDevelop 16

TODO in our C++ support

  • Libclang
  • Fix C++11-auto type deduction
  • Get preprocessed contents in macro expansions
  • “Identifiable” diagnostics

Introduce: int clang_getDiagnosticId(…)?

  • KDevelop Clang support plugin
  • Backport of our custom parser's capabilities

– Example: Auto-transform of . to -> in

string* s = …; s.<cursor>

  • Make it work on Windows (MSVC):

No constexpr support yet! :(

slide-17
SLIDE 17

Kevin Funk Clang Integration in KDevelop 17

Join Us!

  • kdev-clang is manageable (below 10 KLOC)
  • Clean, C++11-aware code base
  • Fully unit-tested
  • KDevelop provides powerful language-agnostic interfaces,

saves precious manpower

  • Easy to implement new assistants/warnings, …
slide-18
SLIDE 18

Kevin Funk Clang Integration in KDevelop 18

Thanks!

slide-19
SLIDE 19

Kevin Funk Clang Integration in KDevelop 19

References

  • Contact
  • IRC: #kdevelop on Freenode
  • Mailing list: kdevelop-devel@kde.org
  • GSoC: Clang Integration in KDevelop:

http://kfunk.org/2014/04/28/gsoc-2014-improving-the-clang-integration-in-kdeve lop/ (+ follow-up posts)

  • Try it out yourself:

http://milianw.de/blog/katekdevelop-sprint-2014-let-there-be-clang [Section: Take my Code]