[PATCH] Prevent errors of omission when adding backend names.
Douglas Katzman
dougk at google.com
Fri May 1 12:46:36 PDT 2015
Hi rnk, chandlerc,
Add test that getArchTypeForLLVMName() returns something other than Unknown for all but 1 special case.
http://reviews.llvm.org/D9441
Files:
unittests/MC/CMakeLists.txt
unittests/MC/TargetRegistry.cpp
Index: unittests/MC/CMakeLists.txt
===================================================================
--- unittests/MC/CMakeLists.txt
+++ unittests/MC/CMakeLists.txt
@@ -3,10 +3,12 @@
MC
MCDisassembler
Support
+ AllTargetsInfos
)
add_llvm_unittest(MCTests
Disassembler.cpp
StringTableBuilderTest.cpp
+ TargetRegistry.cpp
YAMLTest.cpp
)
Index: unittests/MC/TargetRegistry.cpp
===================================================================
--- /dev/null
+++ unittests/MC/TargetRegistry.cpp
@@ -0,0 +1,37 @@
+//===- unittests/MC/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, PrintAll) {
+ llvm::InitializeAllTargetInfos();
+ int i = 0;
+ for (auto it = llvm::TargetRegistry::begin() ; it != llvm::TargetRegistry::end() ;
+ ++it) {
+ StringRef s = it->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, we have to skip it.
+ if (s != "cpp") {
+ Triple::ArchType arch = Triple::getArchTypeForLLVMName(s);
+ ASSERT_NE(arch, Triple::UnknownArch);
+ ++i;
+ }
+ }
+ ASSERT_NE(i, 0);
+}
+
+} // end namespace
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9441.24825.patch
Type: text/x-patch
Size: 1797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150501/2d671dc6/attachment.bin>
More information about the llvm-commits
mailing list