[snapshot] Suppress function type mismatch UB

UBSan is detecting a function type mismatch in this test. This is
because TestModule_GetCrashpadInfo returns a TestCrashpadInfo* but the
function expectes to return a CrashpadInfo*. Structurally, the
TestCrashpadInfo struct is meant to replicate a CrashpadInfo
byte-for-byte, but there's no relationship between the types.

Bug: fxbug.dev/128274
Change-Id: I7b02ca802e55274116d46513b3aa6dc998f6d292
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4599482
Reviewed-by: Mark Mentovai <mark@chromium.org>
diff --git a/snapshot/crashpad_info_client_options_test.cc b/snapshot/crashpad_info_client_options_test.cc
index bc09790..005dfd5 100644
--- a/snapshot/crashpad_info_client_options_test.cc
+++ b/snapshot/crashpad_info_client_options_test.cc
@@ -241,6 +241,22 @@
 class CrashpadInfoSizes_ClientOptions
     : public testing::TestWithParam<base::FilePath::StringType> {};
 
+// UBSan detects a function type mismatch when calling
+// TestModule_GetCrashpadInfo since the expected function signature should
+// return a CrashpadInfo* but the actual TestModule_GetCrashpadInfo defined for
+// the test returns a TestCrashpadInfo*. CrashpadInfo is a struct with its
+// members set as private and TestCrashpadInfo is a POD meant to replicate the
+// layout of CrashpadInfo byte-for-byte. Note this is intentional since the
+// whole point of the test is to exercise the snapshot reader’s ability to
+// handle CrashpadInfo.
+#if defined(__clang__)
+[[clang::no_sanitize("function")]]
+#endif
+inline CrashpadInfo*
+CallGetCrashpadInfo(CrashpadInfo* (*func)()) {
+  return func();
+}
+
 TEST_P(CrashpadInfoSizes_ClientOptions, DifferentlySizedStruct) {
   base::FilePath::StringType artifact(FILE_PATH_LITERAL("module_"));
   artifact += GetParam();
@@ -279,7 +295,8 @@
   EXPECT_EQ(options.gather_indirectly_referenced_memory, TriState::kUnset);
 
   // Get the remote CrashpadInfo structure.
-  CrashpadInfo* remote_crashpad_info = TestModule_GetCrashpadInfo();
+  CrashpadInfo* remote_crashpad_info =
+      CallGetCrashpadInfo(TestModule_GetCrashpadInfo);
   ASSERT_TRUE(remote_crashpad_info);
 
   {