Work around bug in clang coverage with a helper function

Clang code coverage asserts on the following code pattern when
targetting Android:

  #define LOAD_FUNCTION(lib, func)                             \
    do {                                                       \
      func##Fn = reinterpret_cast<p##func>(dlsym(lib, #func)); \
      if (!func##Fn) {                                         \
        supported = false;                                     \
        LOG(ERROR) << "Unable to load function " << #func;     \
      }                                                        \
    } while (0)

The important thing in this snippet is the use of the base/logging.h
macros inside another macro. Clang code coverage expects source
locations to appear in ascending order, and somehow with these multiple
levels of macro expansion, that invariant is broken. The upstream bug is
https://llvm.org/pr39942. However, it's not making progress, so as a
workaround, wrap the logging in a plain function.

Test: Compile libchrome with use_clang_coverage=true for Android, build
succeeds.

R=backer@chromium.org, liaoyuke@chromium.org, rmcilroy@chromium.org

Bug: 843356
Change-Id: I6a729adec482fd8a2903c80d919b7e0c5e6dd267
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1490740
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Jonathan Backer <backer@chromium.org>
Reviewed-by: Yuke Liao <liaoyuke@chromium.org>
Commit-Queue: Reid Kleckner <rnk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#639124}
2 files changed