diff options
author | Douglas Katzman <dougk@google.com> | 2015-05-08 15:34:12 +0000 |
---|---|---|
committer | Douglas Katzman <dougk@google.com> | 2015-05-08 15:34:12 +0000 |
commit | ec1fc97e5da00a4bfbb16ac74449b2e042dc37cb (patch) | |
tree | 08dcf40afa265c0118d3fa1b86e4256e5df00f64 /llvm/unittests/Support/TargetRegistry.cpp | |
parent | 84e22b90967d8f1b36d4254cc500493c7d0d7e41 (diff) | |
download | bcm5719-llvm-ec1fc97e5da00a4bfbb16ac74449b2e042dc37cb.tar.gz bcm5719-llvm-ec1fc97e5da00a4bfbb16ac74449b2e042dc37cb.zip |
Prevent further errors of omission when adding backend names.
Differential Revision: http://reviews.llvm.org/D9441
llvm-svn: 236865
Diffstat (limited to 'llvm/unittests/Support/TargetRegistry.cpp')
-rw-r--r-- | llvm/unittests/Support/TargetRegistry.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/unittests/Support/TargetRegistry.cpp b/llvm/unittests/Support/TargetRegistry.cpp new file mode 100644 index 00000000000..dd5ef431ae0 --- /dev/null +++ b/llvm/unittests/Support/TargetRegistry.cpp @@ -0,0 +1,43 @@ +//===- unittests/Support/TargetRegistry.cpp - -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/TargetSelect.h" +#include "gtest/gtest.h" + +using namespace llvm; + +namespace { + +TEST(TargetRegistry, TargetHasArchType) { + // Presence of at least one target will be asserted when done with the loop, + // else this would pass by accident if InitializeAllTargetInfos were omitted. + int Count = 0; + + llvm::InitializeAllTargetInfos(); + + llvm::TargetRegistry RegistryRoot; + for (const auto &Target : RegistryRoot) { + StringRef Name = Target.getName(); + // There is really no way (at present) to ask a Target whether it targets + // a specific architecture, because the logic for that is buried in a + // predicate. + // We can't ask the predicate "Are you a function that always returns + // false?" + // So given that the cpp backend truly has no target arch, it is skipped. + if (Name != "cpp") { + Triple::ArchType Arch = Triple::getArchTypeForLLVMName(Name); + EXPECT_NE(Arch, Triple::UnknownArch); + ++Count; + } + } + ASSERT_NE(Count, 0); +} + +} // end namespace |