Search code examples
clangclang++libtooling

How to remove error limit in Clang Libtooling?


I made C/C++ source code modification tool using Clang Libtooling. I ran into the following error while executing my tool on test programs.

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

But I would like for the tool to ignore this limit, print all the errors, and execute AST modification as normal. Is there a way to fix this problem using Clang Libtooling?


Solution

  • Thanks to @dratenik, I solved the problem by adding an ArgumentAdjuster which passes Clang the option -ferror-limit=0.

    clang::tooling::ClangTool tool(compileDb, filename);
    tool.appendArgumentsAdjuster(clang::tooling::getInsertArgumentAdjuster(
        "-ferror-limit=0"));
    tool.run(...);