[cfe-dev] Using clang::tooling::RefactoringTool on cross-compiled code with different /usr/include
Kenneth MacKenzie via cfe-dev
cfe-dev at lists.llvm.org
Fri Mar 23 14:16:41 PDT 2018
On 23/03/18 09:21, Иванов Игорь via cfe-dev wrote:
> I am writing a tool using clang's tooling::RefactoringTool and want
> to apply it to ARM targeted sources. Those rely on their own sysroot
> to compile, which is incomplete and basically contains only lib and
> usr directories with proprietary stuff. Its /usr/include headers
> also differ from my system ones - so when parsing my sources with
> clang tool I get a lot of parsing errors related to header ordering,
> etc. And of course, with vendor-provided gcc4.8 everything is fine,
> which led me to a conclusion there's something wrong with how I use
> clang.
Hi,
I've been working on a project that involves writing clang refactoring
and analysis tools and we had similar problems. It's possible to ignore
the compilation database and pass arguments directly to the clang front
end like this:
your-tool <tool arguments> -- -std=c++14 -DDEBUG
-I/home/someone/include -I/some/other/directory
Everything after the -- is used by the clang front end when it's parsing
your source files; I think you may be able to use this to solve your
problem.
When you use -- I think it ignores the compilation database and just
uses whatever you supply on the command line. We've found this to be
considerably more convenient than using compilation databases.
Unfortunately this feature doesn't seem to be very well publicised: I
think we only discovered it by looking at the Clang sources...
Best wishes,
Kenneth MacKenzie
More information about the cfe-dev
mailing list