summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/YAMLTraits.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-01-04 03:51:36 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-01-04 03:51:36 +0000
commit87dd2ab000000a0ee6c643293caf105710327c8b (patch)
tree9206f4da51aefc9e0b81f3743cb7f61ddfede9fc /llvm/lib/Support/YAMLTraits.cpp
parent5f0793b36cfeffe17e31ccc62597034c9da2b6b8 (diff)
downloadbcm5719-llvm-87dd2ab000000a0ee6c643293caf105710327c8b.tar.gz
bcm5719-llvm-87dd2ab000000a0ee6c643293caf105710327c8b.zip
Support: Add YAML I/O support for custom mappings.
This will be used to YAMLify parts of the module summary. Differential Revision: https://reviews.llvm.org/D28014 llvm-svn: 290935
Diffstat (limited to 'llvm/lib/Support/YAMLTraits.cpp')
-rw-r--r--llvm/lib/Support/YAMLTraits.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp
index 99d2070cb6e..51c016b1d55 100644
--- a/llvm/lib/Support/YAMLTraits.cpp
+++ b/llvm/lib/Support/YAMLTraits.cpp
@@ -118,6 +118,18 @@ void Input::beginMapping() {
}
}
+std::vector<StringRef> Input::keys() {
+ MapHNode *MN = dyn_cast<MapHNode>(CurrentNode);
+ std::vector<StringRef> Ret;
+ if (!MN) {
+ setError(CurrentNode, "not a mapping");
+ return Ret;
+ }
+ for (auto &P : MN->Mapping)
+ Ret.push_back(P.first());
+ return Ret;
+}
+
bool Input::preflightKey(const char *Key, bool Required, bool, bool &UseDefault,
void *&SaveInfo) {
UseDefault = false;
@@ -374,8 +386,8 @@ std::unique_ptr<Input::HNode> Input::createHNodes(Node *N) {
}
bool Input::MapHNode::isValidKey(StringRef Key) {
- for (const char *K : ValidKeys) {
- if (Key.equals(K))
+ for (std::string &K : ValidKeys) {
+ if (Key == K)
return true;
}
return false;
@@ -451,6 +463,10 @@ void Output::endMapping() {
StateStack.pop_back();
}
+std::vector<StringRef> Output::keys() {
+ report_fatal_error("invalid call");
+}
+
bool Output::preflightKey(const char *Key, bool Required, bool SameAsDefault,
bool &UseDefault, void *&) {
UseDefault = false;
OpenPOWER on IntegriCloud