This repository was archived by the owner on Apr 23, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +68
-1
lines changed Expand file tree Collapse file tree 6 files changed +68
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ void BinaryRef::writeAsBinary(raw_ostream &OS) const {
49
49
}
50
50
51
51
void BinaryRef::writeAsHex (raw_ostream &OS) const {
52
+ if (binary_size () == 0 ) {
53
+ OS << " \"\" " ;
54
+ return ;
55
+ }
52
56
if (DataIsHexString) {
53
57
OS.write ((const char *)Data.data (), Data.size ());
54
58
return ;
Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ add_subdirectory(Support)
14
14
add_subdirectory (Transforms)
15
15
add_subdirectory (IR)
16
16
add_subdirectory (DebugInfo)
17
+ add_subdirectory (Object)
Original file line number Diff line number Diff line change 10
10
LEVEL = ..
11
11
12
12
PARALLEL_DIRS = ADT ExecutionEngine Support Transforms IR Analysis Bitcode \
13
- DebugInfo
13
+ DebugInfo Object
14
14
15
15
include $(LEVEL ) /Makefile.common
16
16
Original file line number Diff line number Diff line change
1
+ set (LLVM_LINK_COMPONENTS
2
+ object
3
+ )
4
+
5
+ add_llvm_unittest(ObjectTests
6
+ YAMLTest.cpp
7
+ )
Original file line number Diff line number Diff line change
1
+ # #===- unittests/IR/Makefile -------------------------------*- Makefile -*-===##
2
+ #
3
+ # The LLVM Compiler Infrastructure
4
+ #
5
+ # This file is distributed under the University of Illinois Open Source
6
+ # License. See LICENSE.TXT for details.
7
+ #
8
+ # #===----------------------------------------------------------------------===##
9
+
10
+ LEVEL = ../..
11
+ TESTNAME = Object
12
+ LINK_COMPONENTS := object
13
+
14
+ include $(LEVEL ) /Makefile.config
15
+ include $(LLVM_SRC_ROOT ) /unittests/Makefile.unittest
Original file line number Diff line number Diff line change
1
+ // ===- llvm/unittest/Object/YAMLTest.cpp - Tests for Object YAML ----------===//
2
+ //
3
+ // The LLVM Compiler Infrastructure
4
+ //
5
+ // This file is distributed under the University of Illinois Open Source
6
+ // License. See LICENSE.TXT for details.
7
+ //
8
+ // ===----------------------------------------------------------------------===//
9
+
10
+ #include " llvm/Object/YAML.h"
11
+ #include " llvm/Support/YAMLTraits.h"
12
+ #include " gtest/gtest.h"
13
+
14
+ using namespace llvm ;
15
+
16
+ namespace {
17
+ struct BinaryHolder {
18
+ object::yaml::BinaryRef Binary;
19
+ };
20
+ } // end anonymous namespace
21
+
22
+ namespace llvm {
23
+ namespace yaml {
24
+ template <>
25
+ struct MappingTraits <BinaryHolder> {
26
+ static void mapping (IO &IO, BinaryHolder &BH) {
27
+ IO.mapRequired (" Binary" , BH.Binary );
28
+ }
29
+ };
30
+ } // end namespace yaml
31
+ } // end namespace llvm
32
+
33
+ TEST (ObjectYAML, BinaryRef) {
34
+ BinaryHolder BH;
35
+ SmallVector<char , 32 > Buf;
36
+ llvm::raw_svector_ostream OS (Buf);
37
+ yaml::Output YOut (OS);
38
+ YOut << BH;
39
+ EXPECT_NE (OS.str ().find (" \"\" " ), StringRef::npos);
40
+ }
You can’t perform that action at this time.
0 commit comments