aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/MC
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-07-21 00:45:20 -0700
committerStephen Hines <srhines@google.com>2014-07-21 00:45:20 -0700
commitc6a4f5e819217e1e12c458aed8e7b122e23a3a58 (patch)
tree81b7dd2bb4370a392f31d332a566c903b5744764 /unittests/MC
parent19c6fbb3e8aaf74093afa08013134b61fa08f245 (diff)
downloadexternal_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.zip
external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.tar.gz
external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.tar.bz2
Update LLVM for rebase to r212749.
Includes a cherry-pick of: r212948 - fixes a small issue with atomic calls Change-Id: Ib97bd980b59f18142a69506400911a6009d9df18
Diffstat (limited to 'unittests/MC')
-rw-r--r--unittests/MC/CMakeLists.txt10
-rw-r--r--unittests/MC/MCAtomTest.cpp4
-rw-r--r--unittests/MC/Makefile2
-rw-r--r--unittests/MC/StringTableBuilderTest.cpp40
-rw-r--r--unittests/MC/YAMLTest.cpp38
5 files changed, 85 insertions, 9 deletions
diff --git a/unittests/MC/CMakeLists.txt b/unittests/MC/CMakeLists.txt
index 0e4782c..e2beab2 100644
--- a/unittests/MC/CMakeLists.txt
+++ b/unittests/MC/CMakeLists.txt
@@ -1,11 +1,9 @@
set(LLVM_LINK_COMPONENTS
- MC
- )
-
-set(MCSources
- MCAtomTest.cpp
+ MCAnalysis
)
add_llvm_unittest(MCTests
- ${MCSources}
+ MCAtomTest.cpp
+ StringTableBuilderTest.cpp
+ YAMLTest.cpp
)
diff --git a/unittests/MC/MCAtomTest.cpp b/unittests/MC/MCAtomTest.cpp
index 17b056c..16228b5 100644
--- a/unittests/MC/MCAtomTest.cpp
+++ b/unittests/MC/MCAtomTest.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/MC/MCAtom.h"
-#include "llvm/MC/MCModule.h"
+#include "llvm/MC/MCAnalysis/MCAtom.h"
+#include "llvm/MC/MCAnalysis/MCModule.h"
#include "gtest/gtest.h"
namespace llvm {
diff --git a/unittests/MC/Makefile b/unittests/MC/Makefile
index 4c25697..07a608e 100644
--- a/unittests/MC/Makefile
+++ b/unittests/MC/Makefile
@@ -9,7 +9,7 @@
LEVEL = ../..
TESTNAME = MC
-LINK_COMPONENTS := MC
+LINK_COMPONENTS := MCAnalysis
include $(LEVEL)/Makefile.config
include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/unittests/MC/StringTableBuilderTest.cpp b/unittests/MC/StringTableBuilderTest.cpp
new file mode 100644
index 0000000..d30dc62
--- /dev/null
+++ b/unittests/MC/StringTableBuilderTest.cpp
@@ -0,0 +1,40 @@
+//===----------- StringTableBuilderTest.cpp -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/MC/StringTableBuilder.h"
+#include "gtest/gtest.h"
+#include <string>
+
+using namespace llvm;
+
+namespace {
+
+TEST(StringTableBuilderTest, Basic) {
+ StringTableBuilder B;
+
+ B.add("foo");
+ B.add("bar");
+ B.add("foobar");
+
+ B.finalize();
+
+ std::string Expected;
+ Expected += '\x00';
+ Expected += "foobar";
+ Expected += '\x00';
+ Expected += "foo";
+ Expected += '\x00';
+
+ EXPECT_EQ(Expected, B.data());
+ EXPECT_EQ(1U, B.getOffset("foobar"));
+ EXPECT_EQ(4U, B.getOffset("bar"));
+ EXPECT_EQ(8U, B.getOffset("foo"));
+}
+
+}
diff --git a/unittests/MC/YAMLTest.cpp b/unittests/MC/YAMLTest.cpp
new file mode 100644
index 0000000..09709ad
--- /dev/null
+++ b/unittests/MC/YAMLTest.cpp
@@ -0,0 +1,38 @@
+//===- llvm/unittest/Object/YAMLTest.cpp - Tests for Object YAML ----------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/MC/YAML.h"
+#include "llvm/Support/YAMLTraits.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+struct BinaryHolder {
+ yaml::BinaryRef Binary;
+};
+
+namespace llvm {
+namespace yaml {
+template <>
+struct MappingTraits<BinaryHolder> {
+ static void mapping(IO &IO, BinaryHolder &BH) {
+ IO.mapRequired("Binary", BH.Binary);
+ }
+};
+} // end namespace yaml
+} // end namespace llvm
+
+TEST(ObjectYAML, BinaryRef) {
+ BinaryHolder BH;
+ SmallVector<char, 32> Buf;
+ llvm::raw_svector_ostream OS(Buf);
+ yaml::Output YOut(OS);
+ YOut << BH;
+ EXPECT_NE(OS.str().find("''"), StringRef::npos);
+}