CLion starts 2017.2 EAP with Clang-Tidy integration

Hi everyone,

CLion_20172EAP@2x_splash
Great news – CLion 2017.2 EAP starts now!
We had a lot of work planned for this iteration, and especially one thing that was nearly ready for 2017.1 but got postponed in the end as it required more thoughtful development and testing. Today as a part of the 2017.2 EAP (build 172.1572.3), we give you Clang-Tidy integration!


Download CLion 2017.2 EAP

As usual, you can install it side by side with your current stable CLion version, with no active subscription required.

Please note that EAP builds have been moved to the site for easier search. The confluence page is now obsolete.

Clang-Tidy

Why Clang-Tidy?

As you may know, CLion has its own code analysis tool on board. It runs on the fly, showing warnings as you type and suggesting quick-fixes for detected issues. Built-in code inspections provide checks for unused code, the order of declarations, incompatible types, redundant casts, and many other issues. So why do we need Clang-Tidy? Here are some important reasons:

  • Clang-Tidy is a great tool that provides dozens of valuable checks. Some of them overlap with the CLion’s inspections, while other are unique. The tool also provides quick-fixes in addition to checks.
  • Clang-Tidy is easily extendable, with a convenient API for writing new checks.
  • The list of Clang-Tidy checks now includes checks for the C++ Core Guidelines, which we want CLion users to benefit from.

How it works

Clang-Tidy is now seamlessly integrated into CLion, meaning it simply works as you type in the CLion editor. Clang-Tidy warnings are shown the same way as CLion’s own built-in code inspections. Similarly you can use Alt+Enter to apply Clang-Tidy quick-fixes where available:
ct_modernize

CLion uses its own Clang-Tidy fork, which we are going to make public later. We’ve improved the output format and implemented support for response files passed through the command line. These changes are subject to backporting to Clang-Tidy master (the patches will be prepared soon). When either of the above is done, users will be able to create their own custom Clang-Tidy-based checks in CLion.

Clang-Tidy integration works on all platforms including Linux, Windows and macOS. As for compilers, currently it works for GCC and Clang; MSVC, which is supported in experimental mode for now, has not yet been tested with Clang-Tidy.

ct_google

Settings

Clang-Tidy checks are enabled by default in this EAP build, and are shown as warnings in the editor. Not all the checks are enabled, however; find the default configuration description here. You can customize them in Settings/Preferences | Editor | Inspections | C/C++ | General | Clang-Tidy:

  • Switch on/off Clang-Tidy checks as a whole.
  • Set a severity level (Warning by default) for all the checks at once.
  • Configure the list of checks to enable / disable in text form, by using the Clang-Tidy command line format.

For example, let’s run only C++ Core Guidelines checks on the project. Pass the following line in the settings: -*,cppcoreguidelines-*:
ct-settings

This will result in only C++ Core Guidelines checks running on the project:
ct_cppcoreguide

For Clang Static Analyzer checks, use: -*,clang-analyzer-*. For modernize checks, use: -*,modernize-*. And so on.

The full list of Clang-Tidy checks can be found on their site. CLion’s default configuration is described at our confluence page.

Future plans, known issues and your feedback

There are many things that are not yet there for Clang-Tidy integration:

  • A UI for configuring Clang-Tidy checks is still up for discussion.
  • There is a noticeable delay after a quick-fix is applied and before the warning disappears (CPP-9204).
  • Because the current .clang-tidy formats and options are not supported, the checks that use them are turned off by default.
  • There may be possible bugs in Clang-Tidy itself.

We hope to address the biggest problems in time for the 2017.2 release. Your feedback, typical usage scenarios and probable issues with Clang-Tidy integration would be very helpful! Please share them in our tracker or in the comment section below.

Upd. CLion 2017.2 with Clang-Tidy integration was released. Check the blog post for more details.

And more

Other important changes include:

  • Previously only targets linked with gtest were automatically producing Google Test Run/Debug configurations in CLion. Now gmock is working in the same way as well (CPP-6146).
  • In case there is an unused variable, CLion will suggest you to remove it. In addition, starting from this build new quick-fix was added to preserve non-trivial constructor call on unused variable:
    unused_constr_quick_fix
  • A bug with Rename refactoring renaming another variable with the same name is fixed now (CPP-7251). This also covers the case when name stays in generalized lambda capture (CPP-9286).

Full release notes are available here.


Download CLion 2017.2 EAP

Your CLion Team
The Drive to Develop

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

70 Responses to CLion starts 2017.2 EAP with Clang-Tidy integration

  1. Kai says:

    Will the integration of clang-tidy be basically the same as setting the CMAKE_CXX_CLANG_TIDYvariable in CMake?

    • Anastasia Kazakova says:

      No, our integration assumes all the warning are shown on the fly in the editor and quick-fixes can be applied the same way as the quick fixes for the built-in CLion’s inspections – via Alt+Enter. Variable in CMake doesn’t affect it in any way.

  2. Roman says:

    Download link is broken

  3. Olof says:

    It would be neat if it would be easy to somehow file a bug report with enough context on each parser issue where clang tidy and the built-in parser disagrees.

    I can’t file such bug reports due to IP reasons, but people working on for instance open source projects could file extremely useful reports left and right with enough information that they can be replicated and understood quickly.

    PS.
    Download link doesn’t work.

    • Anastasia Kazakova says:

      Link is fixed already. Sorry for the inconvenience.

      I’m afraid without some big and non-trivial localization job this might end in simply submitting a full project, which doesn’t make sense. You can simply submit a bug with a link to the OS project in that case.

  4. Victor Sergienko says:

    Thanks for the release and the great product!

    A little whining: I’m not happy at all with the new “Commit”, “Update project” and “Diff” icons. While “Update project” can be interpreted as getting something from remote tree, the other two give zero idea what they do.
    Old “Diff” icon was so much more understandable.

    Let me also remind you about indistinguishable application icons, IDEA-159933.

    • Phil Nash says:

      Thanks for the feedback, Victor.
      I agree the diff icon is a little more abstract than the old one – but it’s also cleaner and looks less cluttered IMO. I think it’s easy enough to get used to. I hope you do, too.
      Commit is a tougher one – not least because of how most VCSs have separate “commit” and “push” stages these days. It can be hard enough explaining that to new users of DVCSs, let along representing them unambiguously in graphics! I think the old one was actually a little more misleading in that respect. Certainly room for improvement, and perhaps it will be iterated further (that’s my speculation, I don’t have any inside knowledge there).
      But I haven’t been involved in the icon design process. I don’t know what the rationale actually was. There are usually additional constraints that are not immediately obvious – for example these icons cannot be taken in isolation but must be seen as part of a set.

      • Victor Sergienko says:

        Humans can get used to anything. Yeah, I’ll get used to it and cope. Though I keep changing the IDE app icons to https://github.com/synthagency/icons-flat-osx with each EAP build, despite the process being troublesome on OS X.

        But basically, you’re just giving justifications to “why doesn’t the icon carry out its main purpose: clearly describe what a button does”. I don’t care about design, consistence and such as long as it just doesn’t do its main thing.

        The arguments are on a level of “git pull is not always an update from central repo. It’s a DVCS and in general you must speak about network…” … seriously? Use the Pareto rule. 99% of the time git repo network is a star, and the old icon described EXACTLY what the button did; the remaining 1% users know VERY well what they are doing.

    • Anastasia Kazakova says:

      Thanks for the comment. We’ll take it into account.

    • Kai says:

      Yes, this is interesting, as I couldn’t find any info/didn’t figure out by now what *Update project* actually does?

  5. John says:

    Just to be clear, CLion now bundles a custom version of clang-tidy for each platform release? (Windows, Linux, macOS)

    This sounds really great because on some platforms (CentOS for example) it’s non-trivial to get the extra clang tools installed.

    Have you considered doing anything similar with clang-format? Sometimes it’s easier to check in a clang-format config than trying to keep everyone’s CLion formatting settings in sync.

    • Olof says:

      I have clang-format set up as an external tool and mapped to the same short cut as for format.

      However it has some quirks. For instance, it formats the file on disk and that means that sometimes the IDE is asking me if I want to reload the file because it is newer on disk than in the editor.

      It would be better if the CLion formatting could be replaced with the clang-format, and it being integrated with CLion.

      There’s another reason for that as well. Right now my CLion formatting and clang-format are at war, formatting things differently.

      At this point I’d actually want a single button to completely turn off the CLion formatting.

    • Anastasia Kazakova says:

      Yes, there is a bundled version in each distribution package.

      Clang-format is a different story. CLion’s own formatter is powerful enough and what makes more sense to us here is a way to convert clang-format rules into CLion (and maybe vice versa).

      • Olof says:

        If that conversion, or compatibility mode, works then that would be fantastic.

        Even a stand-alone tool that lets me do it by hand would be great. Or like a web page where I could paste in clang-rules and get the CLion rules back.

      • Manuel Klimek says:

        Given that clang format doesn’t use a rule based model, but an optimization algorithm, I doubt it’s possible to integrate a compatible mode into a different formatter.

      • Kai says:

        I’d suggest adding a dedicated option in the settings menu to import the formatting rules from a .clang-format file. You do provide some pre-defined settings such as Google, LLVM etc. but adjusting all formatting rules from a given .clang-format would be perfect in my view.

        I also use the same setting as described by Olof, so that Cmd-Alt-L is calling clang-format as an external tool instead of your own internal formatter. This has definitely some drawbacks tough: For instance, the option reformat my code before committing always uses your internal formatter instead of my configured clang-format one. By the way, it would help a lot if I would be able to run a tool **before commit**. Clion only provides an option to run a tool afterwards which is not helping here.

        Another question: Is the *optimize imports* functionality internally also using clang-tidy now or does it still use your internal one?

        • Anastasia Kazakova says:

          Optimize imports uses internal optimizations.

          In commit dialog there is an option Reformat Code in the section Before commit. Is it what you are looking for?

  6. Alex says:

    Please please please allow us to toggle to disassembly mode even for our own code.

  7. Roman says:

    Does not work on Windows 10 win MSVC15 installed to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community, got “Visual Studio not found”

    • Anastasia Kazakova says:

      You mean the MSVC in settings? Have you tried passing manually the path in settings?

      • Roman says:

        Hm, I’ve managed to fix it: 1) Push “reset” 2) then enter a path MSVC path again 3) then “Apply” 4) and finally got “Visual studio 15” found

        • Anastasia Kazakova says:

          Good to know!

          • mrAnderen says:

            I am having just the same issue. But Roman’s solution not working (

            CLion 2017.2.2
            Build #CL-172.3968.17, built on August 22, 2017
            Expiration date: October 8, 2017
            JRE: 1.8.0_152-release-915-b11 amd64
            JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
            Windows 10 10.0

          • Anton Makeev says:

            mrAnderen, could you please send the log (Help | Show Log in Explorer) to clion-supportatjetbrainsdotcom?

  8. Roman says:

    Looks like there is some performance problem with this EAP, constantly having freezes even on midsized project.

    • Anastasia Kazakova says:

      Could you pls share:
      – which JDK (bundled or not) you are using?
      – platform
      – in the Help | Show logs there should be thread dumps generated automatically for the freezes – could you pls share?

      • Not OP, but I am also having problems with this.

        I am using the bundled JDK on OS X.

        In my case, the IDE is freezing when reindexing after a launch and even after waiting for 30 minutes I cannot get it unfreeze. The funny thing is it was working fine yesterday on the same project.

        It seems memory usage is skyrocketing… I had a 10GB heap for CLion and it managed to consume 100% of that. CPU usage is also stuck at max on all cores.

        Additionally, since I have reverted to the latest release for the time being, it seems indexing is way slower on the EAP.

        Here’s the thread dumps for the last session: http://wikisend.com/download/574090/threadDumps-freeze-20170426-110857-CL-172.1572.3.zip

        • Anastasia Kazakova says:

          Could you please try changing the bundled JDK to the one taken from 2017.1 for example (also bundled) or Oracle one? Does it help?

        • Anastasia Kazakova says:

          Seems you can some code on a remote machine. Is it the case? We see some issues with VFS on the log.

          • In one of the projects, yes. But the freezing was happening in either. The project in with the VFS issues is probably FreeBSD (which is HUGE), I managed to hack a CMake file that allows CLion to at least give me autocomplete features. Then changes are uploaded to my server where I recompile the system. The problems were probably related to my network being very flaky at the time: my WiFi was dropping out all the time. I think that might be the problem there.

            Just tested Oracle’s JDK and it seems to fix the hanging problem and UI text looks crisper too! Thank you!

            Btw, also noticed the update did not ask to migrate settings from previous version. Lost some configuration I had, nothing huge though.

          • Anastasia Kazakova says:

            Ok, good to know.
            Still, while Oracle JDK solved the problem for you, I would recommend checking some updates to the bundled JDK in the upcoming builds. We can’t guarantee any stable performance and stability with Oracle JDK used as it has lots of issues, which are fixed in our bundled version.

      • Roman says:

        Budlned JDK on Ubuntu 14.04. The problem was already reported:
        https://youtrack.jetbrains.com/issue/CPP-7168

        Sometimes “Navigate related” (switch header/source) shortcut completeley freezes IDE for 1-2 minutes. So it is faster to kill it and restart, then to wait. Codebase is https://github.com/BVLC/caffe

        • Anastasia Kazakova says:

          Could you please try changing bundled JDK from 2017.2 to the bundled one from 2017.1? Does it help?

          • Roman says:

            Actually it turned out 2017.1 has same performance issues on this project. Can’t say what is the reason, just avoiding “Navigate related” as a workaround.

          • Anastasia Kazakova says:

            We’ve checked the logs attached and seems this is not jdk but other issue and we are currently doing some investigations around that place. So hopefully we’ll get a fix soon. Follow the updates in the issue. Sorry for the inconvenience.

          • Roman says:

            Good to know it is solvable!

  9. lenfien says:

    Will you add remote development(remote edit/run/debut and remote autocomplete) in next release?

    • Anastasia Kazakova says:

      Remote GDB debug is already available. Remote edit and run is not planned for 2017.2

  10. John says:

    Any chance the “unused import” false positives will be addressed in 2017.2.2?
    https://youtrack.jetbrains.com/issue/CPP-1492
    https://youtrack.jetbrains.com/issue/CPP-6891

    It’s currently the issue that produces the majority of false positives on all of the C++ projects I’ve used CLion on.

    • Anastasia Kazakova says:

      We do plan to work on auto import functionality. We’ll check the issues listed. Thanks!

  11. Ervin Bosenbacher says:

    The ONLY thing that would be really really nice is remote development. In that case we would not need to do nasty hacks and workarounds to perform the development on our VMs

    • Anastasia Kazakova says:

      And by remote development do you mean remote edit/run? Could you describe your configuration and share some details?

      • Ivan says:

        I am not sure what Ervin means exactly but I would say it boils down to putting the compilation/running/debugging into a remote machine while keeping all the IDE stuff running locally.
        For an interface I would give the IDE information to start an SSH session which allows you to read, write, watch and send any relevant commands using the remote’s environment. This would be particularly useful if for legal reasons I can view/edit files from a local machine but I would not necessarily want to store them there.
        It would also be very useful when it comes to reducing the memory load on the compiling machine which would make the biggest difference. My current solution is to forward X11 over ssh to access the remote machine and launch Clion but I often swap while compiling.

        • Anastasia Kazakova says:

          I see, thanks. That is somehow in our plans for the future.
          Current workaround could be as follows: use Remote Host Access plugin to sync remote files with the local machine over ftp/sftp, run build command remotely via terminal. And the remote debug is already there.
          I understand that’s not exactly what you want. But seems now the best we can suggest.

  12. Sergey says:

    Does not work on Windows 10 win MSVC14 installed to C:\Program Files (x86)\Microsoft Visual Studio\2017\shared, got “Visual Studio not found”

    i’m using 2017 vs but have to use 2015 to build old projects.
    is there any way to manually choose nmake & cl executables?

    • Anastasia Kazakova says:

      Pls, check that the path is set correctly in Settings | Build, Execution, Deployment | Toolchains. Also make sure the C++ package is installed.
      If all is correct, get the log from Help | Show Log and share with us.

      Mind that currently the setting is global (not per-project). However, we do plan to make it per project in future.

  13. Nicolay says:

    UI scaling seems to be broken in this build on Windows 10. I have a 4K display configured to 150% UI scaling in Windows. This was working perfectly in 2017.1, but does not work in EAP 2017.2. Basically no scaling is applied to the UI text or icons, making it very hard to use. It’s working as expected in OsX, though.

    • Anastasia Kazakova says:

      Thanks for the feedback. We’ll check. Also next week hopefully a new EAP build will be available, where you can check if any improvements.

  14. xpirad says:

    Hello,I want to ask when will MSBuild Tools be supported?

    I’ve installed MSbuild tools 2015 ,but clion can’t recognize it.

    I really don’t want to install the whole visual studio.
    Please fix this! Thank you!!!

    • Anastasia Kazakova says:

      I can’t provide you any estimation now. MSVC support is still experimental, so we consider various options. MSBuild is one of them.

      • xpirad says:

        Thank you for the quick reply!

        One more question, now that i’ve installed bash in windows 10.
        can i use the gcc installed in it to compile (and gdb to debug)?

        • Anastasia Kazakova says:

          Where are these gcc/gdb are from? If they are from Cygwin or MinGW / MinGW-w64, then yes.

  15. Maksim says:

    I like the feature!
    Thank you very much!

  16. HGH says:

    Do you have a roadmap of C++17 features for this release? As now all platforms I care for support C++17 I intend to jump right into it but I certainly hope for avoiding the confusing presence of squiggly lines. I hope the most requested ones to be implemented in this EAP soon.

    • Anastasia Kazakova says:

      You can check what’s already supported here: https://www.jetbrains.com/help/clion/cpp_support.html
      And for the roadmap for C++17, unfortunately, no clear plan for 2017.2 release. As we are mostly busy with fixing issues in the currently implemented features. We’ll share when we have more clear vision.

      • HGH says:

        Thank you for the always prompt response! I hope​ that you prioritize adding the new syntax as this should be easier to implement anyway and will promote the use of modern​ C++.
        And the second most important feature for me – the performance, especially on lower end laptops.

        • Anastasia Kazakova says:

          Agree. However, this is a bit contradictory. It’s hard to add new features and work on fixing old bug as they often intersect. So we prefer to do it step by step. But we’ll do our best. Thanks for support!

  17. Tomasz says:

    Wow, excellent update. Running it on mac OS Sierra and so far so good.
    Loving clang-tidy integration. Till now I’ve been using it as a separate target in cmake for all the cpp files.

    Thanks!

  18. HGH says:

    The Clang Tidy options need a better UI that what is seen on the screenshot above.

    • Anastasia Kazakova says:

      Thanks! First UI is very basic, we plan more profound UI where you can visually select which checks to enable. However, we wanted our EAP users to try the feature as soon as possible, so decided to start with that simple UI.

  19. Anders says:

    Am I the only one experiencing minute-long CPU consumption by clang-tidy, even after the simplest code changes in a source file (e.g. inserting a new empty line)?

    A similar thing happens when switching tabs between source files.

    I’m using 2017.2 on Ubuntu 17.04.

    • Anastasia Kazakova says:

      Could you please check if CLion has enough memory (especially with switching tabs issue)? Settings | Appearance & Behavior | Appearance | Windows options | Show memory indicator

  20. Hannes says:

    Is it possible to define custom clang tidy checks?
    Like a clang-tidy file.

    CheckOptions:
    – key: readability-identifier-naming.AbstractClassCase
    value: CamelCase

    I’ve tried several possibilities in the inspection settings but nothing worked.

Leave a Reply

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