CLion 2018.2 EAP: clangd as an additional C++ language engine

Hi,

A new CLion 2018.2 EAP (build 182.3458.13) is now available! As usual, a patch-update will be available shortly for those using the previous EAP build, and you can also use Toolbox app or snap packages (in the case of Ubuntu) to get this build.

No license is required and the build is free to use, but it will expire within 30 days of the build date.

Download CLion 2018.2 EAP

In brief, in this build clangd is available as an additional C++ language engine in CLion. It’s turned on by default on all platforms (on Linux and macOS – in v2018.2, on Windows – in v2018.2.1) and is used for showing code errors and warnings in the CLion editor. This feature is experimental, which means we can not guarantee it will make it to the official CLion 2018.2 release.

And now let’s talk about it in details.

Intro

CLion provides rich code insight abilities for C and C++ code. All these refactorings, code completion, code generation, code analysis, and other features are working on the language engine which CLion provides. We constantly work on making the language support in CLion more accurate and knowledgeable about modern C++ language features. As part of this goal, we now would like to give clangd, a popular Clang-based language engine, a try as an additional C++ language engine.

Two is better than one

llvm Nowadays Clang is definitely the most accurate solution in terms of correct C++ code parsing and resolve. However in its current state it can’t support all the code insight features we’d like to provide in CLion. So we’ve decided to keep both language engines working at the same time.

How my IDE is affected?

Let’s talk about how the change affects CLion:

  • When enabled, clangd is used to show code errors and warnings in the CLion editor. CLion’s own code errors are turned off in this case (some warnings are still there).
  • Default configuration includes many compiler warnings, unless you turned them off manually in settings.
  • Quick-fixes are provided by the CLion’s own engine.
  • The rest of the code insight features are not affected (i.e. code highlighting, refactorings, completion, navigation is still working on top of the CLion’s own language engine).

Available settings

Clangd settings are available in Settings/Preferences | Languages & Frameworks | C/C++ | Clangd:
clangd_settings
Here you can turn on/off the clangd as errors/warnings provider and configure the Clang warnings set.

Known issues and limitations

Here is the list of the issues and current limitations known to us. If you notice anything else disturbing you, please report to our issue tracker.

  • In some cases the quick-fixes might be provided by CLion with a noticable delay after the error shown by clangd.
  • Code | Inspect Code… action uses CLion C++ language engine. So the result may be different from what you see in the editor (as it works via clangd).
  • Complete Statement for incomplete code doesn’t work in most cases when errors from clangd are enabled (CPP-13412).
  • Some other issues: CPP-13312, CPP-13482, CPP-13484.

Full release notes are available by the link.

Your CLion Team
JetBrains
The Drive to Develop

This entry was posted in Early Access Preview and tagged , , , . Bookmark the permalink.

16 Responses to CLion 2018.2 EAP: clangd as an additional C++ language engine

  1. Roman says:

    Do you plan to extend integration to support all clangd features? Including completion and navigation?

    • Anastasia Kazakova says:

      We’ll see if we can integrate it into the IDE with both acceptable performance and working accurately on the project. If it works, then yes.

  2. Tano says:

    Hi Anastasia, the clangd implementation sounds really great, but I have some questions:

    1. What is the difference between using clang-tidy from CLion directly (like before) and via clangd?
    2. Exactly what are the CLion’s disabled inspections, if one uses clangd errors? I see that CLion’s inspection for “unused include directive” is disabled while using clangd errors, and that inspection is really great, I love it, I don’t want it disabled.
    3 Is there a difference between adding the clang warnings in that editbox and adding them as CMake warning flags and show then during compilation?

    Thanks.

    • Anastasia Kazakova says:

      1. Ideally there shouldn’t be any differences. Actually clang-tidy via clangd is turned on by default for a couple of EAP builds already and we don’t see any complains.
      2. “unused include directive” is turned off some time ago already, it’s not because of the clangd, but because of the inaccuracy of it in its current state. We hope to put it back when possible.
      With clangd we turn off only Type checks inspections from CLion (but we hope to put them back soon as well).
      3. Compiler flags from CMakeLists.txt are also reflected in the annotation. So shouldn’t be any differences.

      • Tano says:

        2. I have checked “unused include directive” for a long time and I am very satisfied with it, I had no problems.:)

  3. Sebastian Raaphorst says:

    CLion is the one C++ IDE that I find pleasant to use, but there are some fundamental issues with it: for example, six times today, I began to to type “for (const auto” when the IDE reported a fatal crash, and additionally, I’ve had to restart it another five times due to it freezing up and becoming unresponsive.

    I’ve searched around online and heard people from 2016 complaining about some of these issues, and yet they’ve persisted.

    Can we get some focus on making CLion more usable on a fundamental level, because I really do not want to have to switch IDEs, and I never imagined myself paying for an IDE until I came across CLion?

    • Anastasia Kazakova says:

      Do you know the link to the report in our issue tracker about the crash? Have you ever reported any IDE logs from the crash to us? We always try to keep an eye on such critical issues, but quite often we are unaware of the details and thus can’t reproduce and fix.

  4. Andrew Smith says:

    This is unrelated to clangd. But I was wondering — will any remote development features in the 2018.2 roadmap (or ssh debugging in the 2018.1 roadmap) make it into 2018.2?

    • Anastasia Kazakova says:

      The work is in progress, but I doubt it will be ready on time for 2018.2. Then it’ll land in 2018.3.

  5. Roman says:

    Do you plan to fix CPP-7361 anytime soon? This bug was there from the very beginning of Clion. Extremely annoying, encountering it dozen times every day.

  6. NBlizz says:

    If I turn on clangd, does it affect to CLion’s own code refactoring?

    • petr.kudriavtsev@jetbrains.com says:

      No, it does not. However, if your system is Windows, I wouldn’t recommend to turn clangd on until CPP-13502 is fixed

  7. Marcus says:

    This is really great news and something that I’ve been wishing for in CLion for quite some time.

    When you get it finished (eg. supporting completion and navigation) please contact me as I’ll gladly return to being a CLion user.

    In the mean time I’m using VSCode with CQuery (which is like clangd) – it has very good C++ support but lacks the ergonomics that make CLion great to use.

    Marcus.

  8. Alexander says:

    Qt’s QStringLiteral() seems to be broken with clangd. It’s highlighted in red with “Use of undeclared identifier QStringLiteral”.

Leave a Reply

Your email address will not be published. Required fields are marked *