1 //===- unittests/Support/TargetRegistry.cpp - -----------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Support/TargetRegistry.h"
11 #include "llvm/Support/TargetSelect.h"
12 #include "gtest/gtest.h"
18 TEST(TargetRegistry, TargetHasArchType) {
19 // Presence of at least one target will be asserted when done with the loop,
20 // else this would pass by accident if InitializeAllTargetInfos were omitted.
23 llvm::InitializeAllTargetInfos();
25 llvm::TargetRegistry RegistryRoot;
26 for (auto &I = TargetRegistry::begin(), &E = TargetRegistry::end();
28 StringRef Name = I->getName();
29 // There is really no way (at present) to ask a Target whether it targets
30 // a specific architecture, because the logic for that is buried in a
32 // We can't ask the predicate "Are you a function that always returns
34 // So given that the cpp backend truly has no target arch, it is skipped.
36 Triple::ArchType Arch = Triple::getArchTypeForLLVMName(Name);
37 EXPECT_NE(Arch, Triple::UnknownArch);