[clang] [clang] Register all LLVM targets in AllClangUnitTest main (PR #144428)
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 17 16:28:56 PDT 2025
================
@@ -0,0 +1,24 @@
+//===- clang/unittests/AllClangUnitTests.cpp ------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/TargetSelect.h"
+#include "gtest/gtest.h"
+
+// This custom main entry point for the AllClangUnitTests binary registers all
+// tests on startup, so the tests don't become sensitive to target registration
+// within the test suite.
+int main(int argc, char **argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ llvm::cl::ParseCommandLineOptions(argc, argv);
+
+ llvm::InitializeAllTargets();
----------------
rnk wrote:
Done, sorry, I copied this from [`driver.cpp`](https://github.com/llvm/llvm-project/blob/main/clang/tools/driver/driver.cpp#L246), so I didn't get all this goop.
https://github.com/llvm/llvm-project/pull/144428
More information about the cfe-commits
mailing list