CLion opens 2019.1 EAP: ClangFormat, Disassembly View for LLDB, and support for injected languages


Today we are thrilled to begin the CLion 2019.1 Early Access Program! The first build is already available for download. As usual, you can download build 191.4212.38. from our site, using Toolbox App, or through a snap package (if you are using Ubuntu).

Download CLion 2019.1 EAP

The main highlights (as you probably already got from the title) include:

CLion 2019.1 EAP

ClangFormat support

CLion’s own formatter works as you type and it provides you with several predefined code styles like LLVM, Google, or Qt. There are also dozens of other flexible options that you can use to configure your code to your personal preferences. However, in the C and C++ world, there is a widely used tool for formatting the code, which some call the standard. It’s called ClangFormat. And it’s now supported in CLion! Let’s take a look at how you can use it.

Open a project in CLion with .clang-format file in it

If your whole team is using ClangFormat it’s natural that you should use it as well, especially since the config file is likely already present in the project repository. Besides this, many open source projects nowadays include a .clang-format config with the project source code. In cases where ClangFormat is used, when you open the project for the first time in CLion (and open any C/C++/Objective-C file in the editor), the IDE detect it and it will suggest that you switch to ClangFormat:
ClangFormat notification

Another possibility is that you manually invoke Enable ClangFormat for project from the code formatting switch at the bottom of the editor at any time:
ClangFormat in action

Another option is to turn it on in Settings/Preferences | Editor | Code Style (this will affect all the projects you are working on in CLion):
ClangFormat global setting

Review the ClangFormat options applied to a particular file

It’s possible to have several different ClangFormat settings inside one project: for example, a library used in the project, uses one style, while a user’s code is done in a different style. If this is the case, then there can be several .clang-format configs in the project. To better understand which style affects the file, CLion provides a quick and easy way to review all the ClangFormat settings applied in particular file – simply call the “View ClangFormat options for <file name>” action from the toolbar switcher when the necessary file is opened in the editor:
ClangFormat settings

Tip: If you don’t have a .clang-format configuration file yet, you still can switch to ClangFormat in CLion using the toolbar switch or the IDE settings. LLVM style will be used in this case and you can review ClangFormat settings in the IDE.

These settings are currently read-only. We’ll add the ability to change and export them later (CPP-15184).

When is ClangFormat used?

Naturally everywhere in the IDE where you have code to format:

  • While typing in the editor or pasting the code
  • When calling the Reformat Code action for a selected piece of code (Ctrl+Alt+L on Windows/Linux, ⌥⌘L on macOS):

Format with ClangFormat

  • When reformatting the code before a commit (pre-commit hook), if a commit is done via the Commit action (Ctrl+K on Windows/Linux, ⌘K on macOS)
  • When calling Generate actions
  • When Refactoring
  • When applying quick-fixes and intention actions

Known limitations:

  • It’s not possible right now to import/export settings between CLion’s own formatter and ClangFormat (CPP-4805).
  • ClangFormat only works for C, C++, and Objective-C.
  • A few other issues linked to the parent ticket CPP-4809.

Debugger: Disassembly View

LLDB users will be happy to learn that bundled LLDB (on macOS and Linux platforms) was updated to 7.0.1 in this build. And more importantly, Disassembly View now works for LLDB as well!

Disassembly View was updated for both backends: GDB and LLDB, and now it shows information per function:
Disasm for LLDB

Please note, CLion still doesn’t provide Disassembly View on demand (CPP-9091), which means that it only works after you force the step into functions with no source code. As a workaround, feel free to use a nice 3rd party plugin known as Compiler Explorer (hopefully, it will soon be updated to work with 2019.1 EAP).

Injected languages

When coding in C and C++, there can sometimes be pieces of code inside string literals. Wouldn’t it be nice if an IDE could treat them as code, and not as text? For example, SQL strings, HTML code, or Regular Expressions. Well, it’s now possible in CLion! To temporarily inject a language, press Alt+Enter and apply the intention “Inject language or reference”, select the appropriate language, and you are done!
Injected SQL

CLion provides accurate code highlighting based on the language chosen, it also has language-specific intentions, actions, and it can edit a code fragment in the dedicated editor section functionality. For example, for regular expressions you can check if a string matches the RegExp right in the IDE:
Injected regular expression

This injection is temporary, which means it will be removed when you restart the IDE restart or reopen the project. And of course, you can un-inject manually using the Alt+Enter context menu.

An update for plugin writers

When you are missing any functionality in CLion you may create a feature request or consider implementing a plugin using IntelliJ Platform API. In our plugin repository, there are more than 1.2K plugins for CLion (check this selection of valuable non-bundled plugins). We have simplified the process of building CLion’s plugins by publishing CLion as a Maven dependency to be used by gradle-intellij-plugin (since version 0.4.2). In simple terms, this Gradle plugin adds the specific IntelliJ-based IDE dependencies, helps with preparing plugin.xml files and preparing the proper structure for the plugin, executes the IDE instance with the plugin you are developing, and finally, it also helps with uploading the plugin to the plugin repository. And starting with 2019.1 it’s aware of the CLion SDK.
We do hope to make some help articles on the CLion specifics, which will be available here shortly, and we welcome anyone who wants to create a plugin for CLion to check it out!

Other enhancements

Since 2018.2 CLion uses an additional Clangd-based C++ language engine for showing code errors and warnings in the editor and some navigation and search actions. In this EAP we’ve improved the errors messages and take more details from Clang:
Detailed clang errors
These details, for example, might be very useful when you debug failed overload resolution in your C++ code.

This EAP brings new inspection which reports the member functions that can be marked as static:
Member function can be static

If you are using compilation database project model in CLion, you’ll be interested to learn that CLion now allows you to build/clean such projects. Just configure external tools and provide them in the settings as build/clean commands:

And finally, there are also notable VCS improvements coming from the IntelliJ Platform. Thanks team!

That’s it. Full release notes are here. Download and try the EAP build right now and let us know what you think!

Download CLion 2019.1 EAP

Your CLion Team
The Drive to Develop

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

46 Responses to CLion opens 2019.1 EAP: ClangFormat, Disassembly View for LLDB, and support for injected languages

  1. Taw says:

    This is great news, too bad that clang-format has a lot of bugs, it works correctly only if you use some of the default settings (google, llvm) without many modifications. If you try to customize it a lot (like I do), it behaves very strange. I use uncrustify.

    • Anastasia Kazakova says:

      You can configure uncrustify as an external tool in CLion and call it when you need to reformat the code. Not that convenient as a built-in formatter, but still works.

      • Taw says:

        Yep, that’s what I did, the external command is really nice.
        Btw, am I missing something or clang-format is not in the package? I searched in the clang folder, which includes already clangd and clang-tidy.

        • Anastasia Kazakova says:

          It’s part of the clangd. So there is no separate executable

          • Danylo says:

            So I cannot specify my own clang-format executable?
            What version of clangformat is used in CLion?

          • Anastasia Kazakova says:

            No, currently you can’t, as we take ClagnFormat from the bundled Clangd-based engine.
            In the release version, we bundle clang 8.0, merged from trunk at the beginning of February 2019.

  2. Roman says:

    Can you give any estimate when Ninja builds and MSVC debugging will be supported on Windows? Tired of waiting when I can finally switch from Visual Studio.

    • Anastasia Kazakova says:

      Debugger is under development, we have to reimplement it from scratch, so not sure it will be ready for 2019.1, but some 2019.x is very likely.
      Ninja will likely come with CMake server support, but we currently don’t have clear estimation for that, but it’s in our short list.

  3. Taw says:

    Also, it was nice to finally implement an “X” to close the lower menus like Event Log, CMake, etc..The only possibility is to click on the round-icon settings then “Remove from toolbar” (or smth), so 2 clicks.

    • Anastasia Kazakova says:

      Why can’t you just hide all the toolbars?

      • Taw says:

        Because some of them are very useful, like the Build Output or CMake, but some other I really hate (like Event Log) and they should be forever closed with only one click. Someone told me that it will be a redesign of those items and there will be a nice solution for this problem.

        • Anastasia Kazakova says:

          Any known ticket in tracker?

          • Taw says:


            “Vassiliy Kudryashov commented 26 Apr 2018 21:26
            Taw Moto We are in progress with tool windows redesign and it’s not just an X. But an X too, you’re right!”

            Almost 1 year of redesigning :)

          • Anastasia Kazakova says:

            There is still some ongoing activity. I’ll check with the team and ask to update the state

  4. Vadim P says:

    Thanks so much for the clang-format support!

  5. Taw says:

    Regarding the clang-format, it reformats the code during typing? Can it be used only when pressing “Reformat code”? Because I would like to keep my own formatting in some places. Sorry I cannot test myself, I don’t have a PC for several days.

    • Anastasia Kazakova says:

      You can preserve formatting in particular places, ClangFormat comment for that:

      • Tano says:

        No no, I know about that solution but I don’t like polluting my code with their comments, I preffer to manually run it from time to time and accept only some changes (double spaces, missing spaces, etc)

        Because at the moment it seems that you only support full-formatting or none. And from my experience, clang-format fails in a lot of cases, especially with long functions that must be separated on multiple lines with parameters alignment.

        I just want to disable clang-format in CLion during code typing..Is this possible?

        • Anastasia Kazakova says:

          You can disable ClangFormat and then call it via External tool when you actually need it.

          • Taw says:

            Ok, but in this case clang-format integration will be useless.
            Perhaps you can add an option in the future, because now seems to intrusive, some of us want to run it from time to time: CPP-15246
            Thanks for the help, Anastasia.

          • Anastasia Kazakova says:

            I don’t think it’s a correct approach. You either use the formatter everywhere, and turn off some particular places if you really need that. Moreover, ClangFormat is capable of using different sets of settings for different folders.

            If you need to run some tool just from time to time, you can do this through the External Tools. The integration is for the first case.

      • Alexey says:

        For me it not works well during typing.
        Small snippet I typed:

        for (int i=0;i<10;++i){printf(“hello”);}

        With clang-format switched off became:

        for (int i=0;i<10;++i)

        (that is expected)

        With clang-format switched 'on' I take:

        for (int i=0;i<10;++i)

        That is not expected; I don't want indend of { under 'for'.

        But after 'code reformat' it became:

        for ( int i = 0; i < 10; ++i )
        printf ( "hello" );

        Yes, finally I achieve the goal. But it is NOT during the typing, and moreover, it became even worse without explicit reformat call.

        (I thing, it expects that C++ syntax underneath is always correct, but this is not always true during typing, and so, in that moment it has a kind of wrong AST and perform wrong action then)

  6. Michal says:

    You mentioned that performance (indexing, freezes, memory consumption) is one of the major targets for 2019. Has this release any updates related to performance ?

    • Anastasia Kazakova says:

      There are some improvements constantly, including this build. Nothing too big, but still overall improvement.

  7. Michal says:

    How about “Performance improvements and elimination of freezes: here we plan to focus on memory and CPU usage, investigate deeper first project indexing times and completion performance.” mentioned in the plan for 2019.1 ?(

  8. Noam Dori says:

    Great to see language injection is now available. When can we expect automatic language injection to std::regex (and potentially boost::regex) strings (CPP-6789)?

    • Anastasia Kazakova says:

      I can’t provide any estimation to this now, unfortuantely. Please upvote the ticket if that’s important for you

  9. Helge Penne says:

    It seems like the issue with automatic selection of the resolve context has been successfully fixed. The resolve context now seems to be correctly set based on the current build settings (target and toolchain). Thanks. This issue caused us a lot of hassle, and it is great to see this working now.

    Another big annoyance that I hope you can fix is the handling of includes (automatic includes and “” vs , there are lots of bugs filed for this). Those issues are really annoying and makes the tool look silly. I hope you can get around to fixing these soon.

  10. Tosh says:

    Very cool that it is now possible to specify an external build tool for compilation database projects!! Any reason why creation of run/debug configurations is not possible?

  11. Jakub says:

    The language injection is great. Any plans for configuring automatic injection based on, let’s say, the raw string terminator sequence?

    SELECT x
    FROM y
    WHERE a = b)sql”;

    Also good to hear clang-format is there.

  12. Nikita says:

    A lot of new stuff, but still no Qt support in the debugger.

    • Anastasia Kazakova says:

      If you mean Qt pretty printers, you can simply load them via .gdbinit/.lldbinit. CLion will use them then. Unfortunately, we can’t bundled them because of the licensing restrictions.

Leave a Reply

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