понедельник, 13 января 2014 г.

CppCat

CppCat -- extension for Microsoft Visual Studio. We have only linux-based projects, but we ususally build it in MS Visual Studio just for checking compability and search for possible bugs. With this tool it became much easier. We have a lot of legacy code, so it helps us to fix it. We've found a LOT of hidden issues.

The only problem for me is that cppcat isn't always expand macro in correct way. For example, in legacy code we have switch/case statement divided in macros.

#define BEGIN_DECLARATION() switch (id) {
#define caseatr(n, at, extif) case n: /*removed code*/

#define END_DECLARATION() default: /*removed code*/ }

With following use:
BEGIN_DECLARATION();
caseatr(0, vendor_id, omccver >= G984_4_2004 );
caseatr(1, version, omccver >= G984_4_2004 );
END_DECLARATION();

Cppcat understand that first macro is begining of switch, but do not understand that all following macros is cases.

Of course, it's nothing to compare with all threats we've found thanks to it.

Update
As Andrey pointed out analyzer warns that there is "extra" semicolon. It's still correct code, but it might be wrong. So, warning is correct and macro expanding either correct.

Комментариев нет:

Отправить комментарий