X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=lib%2FSupport%2FYAMLTraits.cpp;h=526667fc59e7615bbb6bd7f54878a1942a658a40;hb=12af22e8cc217827cf4f118b0f5e4ebbda9925ae;hp=66af33693d67545745bc8d5e71b91a69dde727b7;hpb=9ac3cc8a251a67e155c55bb2550f0fb5e5f07018;p=oota-llvm.git diff --git a/lib/Support/YAMLTraits.cpp b/lib/Support/YAMLTraits.cpp index 66af33693d6..526667fc59e 100644 --- a/lib/Support/YAMLTraits.cpp +++ b/lib/Support/YAMLTraits.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Support/Errc.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Casting.h" @@ -56,9 +57,7 @@ Input::Input(StringRef InputContent, Input::~Input() { } -error_code Input::error() { - return EC; -} +std::error_code Input::error() { return EC; } // Pin the vtables to this file. void Input::HNode::anchor() {} @@ -74,7 +73,7 @@ bool Input::setCurrentDocument() { Node *N = DocIterator->getRoot(); if (!N) { assert(Strm->failed() && "Root is NULL iff parsing failed"); - EC = std::make_error_code(std::errc::invalid_argument); + EC = make_error_code(errc::invalid_argument); return false; } @@ -124,7 +123,7 @@ bool Input::preflightKey(const char *Key, bool Required, bool, bool &UseDefault, // nodes are present. if (!CurrentNode) { if (Required) - EC = std::make_error_code(std::errc::invalid_argument); + EC = make_error_code(errc::invalid_argument); return false; } @@ -300,7 +299,7 @@ void Input::setError(HNode *hnode, const Twine &message) { void Input::setError(Node *node, const Twine &message) { Strm->printError(node, message); - EC = std::make_error_code(std::errc::invalid_argument); + EC = make_error_code(errc::invalid_argument); } Input::HNode *Input::createHNodes(Node *N) { @@ -327,7 +326,12 @@ Input::HNode *Input::createHNodes(Node *N) { } else if (MappingNode *Map = dyn_cast(N)) { MapHNode *mapHNode = new MapHNode(N); for (KeyValueNode &KVN : *Map) { - ScalarNode *KeyScalar = dyn_cast(KVN.getKey()); + Node *KeyNode = KVN.getKey(); + ScalarNode *KeyScalar = dyn_cast(KeyNode); + if (!KeyScalar) { + setError(KeyNode, "Map key must be a scalar"); + break; + } StringStorage.clear(); StringRef KeyStr = KeyScalar->getValue(StringStorage); if (!StringStorage.empty()) {