1

My production code is compiled on a proprietary compiler with some language extensions, for example:

__even_in_range(TA2IV, TA2IV_TAIFG);

But I am using clang as code analysis tool, and getting this error error: use of undeclared identifier '__even_in_range'. There are few more language extensions that produce similar behavior. Is there any way to ask clang to ignore certain identifiers?

EDIT: Both of the comments guided me towards define solution, so I added these compiler options to the code analysis package ( I use https://github.com/lvzixun/Clang-Complete package).

  1. -D __even_in_range(y,x)=y
  2. -D __interrupt=

This way none of my sources are influenced by the static analysis tool

Thanks...

user1135541
  • 1,781
  • 3
  • 19
  • 41
  • 2
    You could add a fake header, #defining these extension without expanding to anything (#define __even_in_range(x,y)). You don't even need to modify the original source, you can specify this header on the command line: http://stackoverflow.com/questions/9945473/include-one-header-file-in-each-source-file – Lukas Rieger Apr 24 '15 at 19:36

1 Answers1

1

You can use the predefined macro __clang_analyzer__ to identify that the analyzer is being run, and just #define out those extensions in that case:

#ifdef __clang_analyzer__
#define __even_in_range(...)
...
#endif

Details here, along with other ideas to get rid of false positives.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469