Commit Graph

1 Commits

Author SHA1 Message Date
Pietro Fezzardi b092c4f505 Add ThreadSafeClangTooling library
This library provides a thin locking wrapper around clang::tooling
invocations.
It should be used instead of performing direct clang::tooling
invocations by all programs that use revng-c and may run more than one
ClangTool concurrently.

This is necessary because clang::tooling internally uses llvm's cl::opt
for parsing command line options.
cl::opt uses a global variable for the parser under the hood so parsing
two command lines concurrently is not safe.
Similarly, cl::opt typically uses global variables to hold options, so
it is not safe to execute a ClangTool concurrently to another tool
that is parsing a new set of options, because there might be race
conditions between threads reading and writing the same options at the
same time.

The new library introduces a thin locking layer so that the end-user
does not need to know or worry about these details.
2021-03-05 16:12:41 +01:00