[cfe-dev] A ClangTool question

Frank Redeker via cfe-dev cfe-dev at lists.llvm.org
Sun Apr 15 22:07:12 PDT 2018


Hello List,

I am developing a tool to analyze source code that is written for target
compilers (e.g. IAR, Cosmic, Greenhills). Because some of these
compilers use their own data types and keywords (e.g. special function
registers, bit data types, and type modifier huge, far, near) and comes
with own headers, my workflow is as follows.

I use the preprocessor of the target compiler to preprocess the sources.
The preprocessed source is then processed by a lexer to remove or
rewrite constructs that lead to a syntax errors.
Then I use CLangTool.buildATSs to create ASTUnits and processe them with
my ASTVisitor.

That's worked so far. Now I have switched to 64 bit and I am facing the
problem that sources written for 32 bit cannot be compiled anymore.

My question now is, is there a command line option to teach CLangTool
that it has 32 bit source code in front of it? Or do I have to create a
32 and 64 version of my tool first?

Here is an example of code that compiles with 32 bit without errors, but
generates an error with the 64 bit version.

typedef unsigned int size_t;
void* operator new(std::size_t);

error: 'operator new' takes type size_t ('unsigned long long') as first
parameter


Frank

P.S.:
I'm on Windows using MSYS2/MinGW to compile my tool. I have compiled
Clang/LLVM 6.0 with MinGW gcc 7.2.



More information about the cfe-dev mailing list