9

I am an old school C++ developer and even today I have no professional C++11 experience. I trust the C++ committee that the language is moving in the right direction, but it seems that in the projects I work the scepticism is dominant and a lot of the C++11 features are banned even before they are understood and explored.

Anyways, I am having a chance now to work on a new code base and I would like to apply all C++11 power, but I do not want to shoot myself in the foot.

In the past, I found some of the static code analysis tools to be extremely powerful teaching instrument to show me all these subtle aspects of the language.

For my project, I use clang, and portable libraries as STL and Boost that build on Windows, Linux, Mac and more.
I hoped clang-tidy, clang-modernize, etc. will be good tools to let me tune my behavior to the C++11 feature, but they seem to provide very limited help - it literally took me like 2-3 days to adapt to all the suggestions they do... and I am sure that there are a lot of possibilities that I am missing based on rvalue references for example.

Some features that I would like it to have:

  • When copy elision is not sufficient and forwarding interface will provide optimization.

  • When some of the class members are not movable and auto-generated move constructor and move assignment operator is not possible.

  • When local variable could be moved if this is the last reference in its scope.

  • When const auto& is better over auto.

I have no price limits.

9
  • Welcome to Software Recommendations! It's quite unclear what you're asking for. Please take a look at What is required for a question to contain "enough information"? Then please edit your question and see if you can incorporate some of these improvements.
    – Izzy
    Jan 1, 2016 at 21:21
  • @lzzy I am looking for: "static code analysis tool with good coverage of c++11 features"
    – gsf
    Jan 1, 2016 at 21:23
  • That's a bit "too broad" I'm afraid. Have you checked with the link of my last comment? There are many details missing in your question, e.g. which OS it should run on, what your budget is. Possibly more, but when it comes to features I must pass, as that's not my area of expertise.
    – Izzy
    Jan 1, 2016 at 21:27
  • 1
    @mguassa I use clang, and portable libraries as stl and boost that build on windows, linux, mac and more.
    – gsf
    Jan 1, 2016 at 23:16
  • 2
    Please, can anyone vote to reopen the question? I think it's clear enough for people to provide some answers.
    – mguassa
    Jan 3, 2016 at 10:55

2 Answers 2

2

In the past, for old-school C/C++ code, I used PC-lint, a commercial software developed by Gimpel Software.

The company actually develops a couple of static analysis tools: PC-lint and FlexeLint.
Pc-lint is for Windows systems, while FlexeLint runs on almost all systems that support C including VMS, OS-9, and pretty much all Unix systems.

PC-lint and FlexeLint are powerful static analysis tools that will check your C/C++ source code and find bugs, glitches, inconsistencies, non-portable constructs, redundant code, and much more. It looks across multiple modules, and so, enjoys a perspective your compiler does not have.

Regarding the C++11 support, they have a dedicated page for it:
PC-lint / FlexeLint Support for C++ 11

Full support for C++11 and C++1y is our primary focus and while we cannot provide a date for full support we anticipate a quicker release cycle as we roll-out support for the remaining features.

So, at this time of writing, they don't support all the C++11 features, but most of them seem to be there. What I like is that the development status of the features is clearly and transparently reported on that page, along with a priority (for other tools, such information doesn't seem to be that clear or easily available).
For example, in your question you mentioned rvalue, which appears to be supported:

  • Language feature: Rvalue references
  • C++11 Proposal: N2118
  • Available n PC-Lint/FlexeLint?: Lint 9.00c

Based on the information you can find on the website and on that page, the cost involved and your project, you can evaluate if it's a tool that can fit your needs. Others might know other tools, this is the one I suggest you to have a look at.

Finally, a list of other tools for C/C++ static code analysis can be found on Wikipedia. They do not all support C++11.

2
  • Thanks, this seem more like a "we do not have compile issues with these features", than "we have a good set of advices for these issues". Do you have personal observation in this aspect?
    – gsf
    Jan 10, 2016 at 17:37
  • @gsf Honestly, I've never used any of the C++11 features, I only used that product in the past for old-school C/C++ code and I feel I can recommend it. As far as I know, for what I've seen lately and for the specific request you have, there doesn't seem to be much around. Having used the product before, and looking at the effort they seem to put on the C++11 support now, what I've suggested looks like one of the best options available. Note that I have no relationship with that company.
    – mguassa
    Jan 26, 2016 at 11:21
2

You can try CppDepend, a pretty complete static analysis tool which integrates a wide range of features, and 100% integrated to Visual Studio.

1
  • 2
    It looks like that CppDepend uses clang-modernize, which is something that the OP already tried. See CppDepend modernizer.
    – mguassa
    Jan 13, 2016 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.