1 //===- unittests/MC/TargetRegistry.cpp ------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // The target registry code lives in Support, but it relies on linking in all
10 // LLVM targets. We keep this test with the MC tests, which already do that, to
11 // keep the SupportTests target small.
13 #include "llvm/Support/TargetRegistry.h"
14 #include "llvm/Support/TargetSelect.h"
15 #include "gtest/gtest.h"
21 TEST(TargetRegistry
, TargetHasArchType
) {
22 // Presence of at least one target will be asserted when done with the loop,
23 // else this would pass by accident if InitializeAllTargetInfos were omitted.
26 llvm::InitializeAllTargetInfos();
28 for (const Target
&T
: TargetRegistry::targets()) {
29 StringRef Name
= T
.getName();
30 // There is really no way (at present) to ask a Target whether it targets
31 // a specific architecture, because the logic for that is buried in a
33 // We can't ask the predicate "Are you a function that always returns
35 // So given that the cpp backend truly has no target arch, it is skipped.
37 Triple::ArchType Arch
= Triple::getArchTypeForLLVMName(Name
);
38 EXPECT_NE(Arch
, Triple::UnknownArch
);