summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-05-20 17:20:42 +0000
committerChris Bieneman <beanz@apple.com>2016-05-20 17:20:42 +0000
commit54530096e514cbeb78782dc8111dbf356b8e6aff (patch)
tree23343d255fc60443692dbb999f05ddeb1af96064 /include
parent2c98ad1c24791aa0f95744f9cb006dc8d4dbe4ad (diff)
[obj2yaml][yaml2obj] Adding enumFallback for MachO load commands
This adds support for handling unknown load commands, and a bogus_load_command tests. Unknown or unsupported load commands can be specified in YAML by their hex value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270239 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ObjectYAML/MachOYAML.h1
-rw-r--r--include/llvm/Support/YAMLTraits.h7
2 files changed, 5 insertions, 3 deletions
diff --git a/include/llvm/ObjectYAML/MachOYAML.h b/include/llvm/ObjectYAML/MachOYAML.h
index cb29c6dcd62..c9eb48a24c5 100644
--- a/include/llvm/ObjectYAML/MachOYAML.h
+++ b/include/llvm/ObjectYAML/MachOYAML.h
@@ -95,6 +95,7 @@ template <> struct MappingTraits<MachOYAML::Section> {
template <> struct ScalarEnumerationTraits<MachO::LoadCommandType> {
static void enumeration(IO &io, MachO::LoadCommandType &value) {
#include "llvm/Support/MachO.def"
+ io.enumFallback<Hex32>(value);
}
};
diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h
index b332bdde83a..6f38a94d91b 100644
--- a/include/llvm/Support/YAMLTraits.h
+++ b/include/llvm/Support/YAMLTraits.h
@@ -510,11 +510,11 @@ public:
template <typename FBT, typename T>
void enumFallback(T &Val) {
- if ( matchEnumFallback() ) {
+ if (matchEnumFallback()) {
// FIXME: Force integral conversion to allow strong typedefs to convert.
- FBT Res = (uint64_t)Val;
+ FBT Res = static_cast<typename FBT::BaseType>(Val);
yamlize(*this, Res, true);
- Val = (uint64_t)Res;
+ Val = static_cast<T>(static_cast<typename FBT::BaseType>(Res));
}
}
@@ -1168,6 +1168,7 @@ private:
bool operator==(const _base &rhs) const { return value == rhs; } \
bool operator<(const _type &rhs) const { return value < rhs.value; } \
_base value; \
+ typedef _base BaseType; \
};
///