2020-03-18 18:54:27 +00:00
|
|
|
#include "coverage.h"
|
2019-12-18 10:43:40 +00:00
|
|
|
|
|
|
|
#if WITH_COVERAGE
|
|
|
|
|
2020-03-18 18:54:27 +00:00
|
|
|
# include <mutex>
|
|
|
|
# include <unistd.h>
|
|
|
|
|
|
|
|
|
|
|
|
# if defined(__clang__)
|
2020-09-17 14:44:46 +00:00
|
|
|
extern "C" void __llvm_profile_dump(); // NOLINT
|
2020-03-18 18:54:27 +00:00
|
|
|
# elif defined(__GNUC__) || defined(__GNUG__)
|
2019-12-18 10:43:40 +00:00
|
|
|
extern "C" void __gcov_exit();
|
2020-03-18 18:54:27 +00:00
|
|
|
# endif
|
2019-12-18 10:43:40 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
void dumpCoverageReportIfPossible()
|
|
|
|
{
|
|
|
|
#if WITH_COVERAGE
|
|
|
|
static std::mutex mutex;
|
|
|
|
std::lock_guard lock(mutex);
|
|
|
|
|
2020-03-18 18:54:27 +00:00
|
|
|
# if defined(__clang__)
|
2020-09-17 14:44:46 +00:00
|
|
|
__llvm_profile_dump(); // NOLINT
|
2020-03-18 18:54:27 +00:00
|
|
|
# elif defined(__GNUC__) || defined(__GNUG__)
|
2019-12-18 10:43:40 +00:00
|
|
|
__gcov_exit();
|
2020-03-18 18:54:27 +00:00
|
|
|
# endif
|
2019-12-18 10:43:40 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|