llvm-project/clang/unittests/AllClangUnitTests.cpp
Reid Kleckner dbb3e7d116
[clang] Register all LLVM targets in AllClangUnitTest main (#144428)
Addresses feedback in
https://github.com/llvm/llvm-project/pull/134196#issuecomment-2970715875

Makes the tests less sensitive to target registration from unrelated
test fixtures by registering everything up front.
2025-06-24 18:40:13 -07:00

29 lines
1.1 KiB
C++

//===- 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/TargetSelect.h"
namespace {
struct RegisterAllLLVMTargets {
RegisterAllLLVMTargets();
} gv;
} // namespace
// This dynamic initializer initializes all layers (TargetInfo, MC, CodeGen,
// AsmPrinter, etc) of all LLVM targets. This matches what cc1_main does on
// startup, and prevents tests from initializing some of the Target layers,
// which can interfere with tests that assume that lower target layers are
// registered if the TargetInfo is registered.
RegisterAllLLVMTargets::RegisterAllLLVMTargets() {
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmPrinters();
llvm::InitializeAllAsmParsers();
}