Misc cleanups to the FileSytem api.
[oota-llvm.git] / lib / Support / YAMLTraits.cpp
index 5212624f0cd3f1f6b7a86c1e836b0ea84976631b..526667fc59e7615bbb6bd7f54878a1942a658a40 100644 (file)
@@ -326,7 +326,12 @@ Input::HNode *Input::createHNodes(Node *N) {
   } else if (MappingNode *Map = dyn_cast<MappingNode>(N)) {
     MapHNode *mapHNode = new MapHNode(N);
     for (KeyValueNode &KVN : *Map) {
-      ScalarNode *KeyScalar = dyn_cast<ScalarNode>(KVN.getKey());
+      Node *KeyNode = KVN.getKey();
+      ScalarNode *KeyScalar = dyn_cast<ScalarNode>(KeyNode);
+      if (!KeyScalar) {
+        setError(KeyNode, "Map key must be a scalar");
+        break;
+      }
       StringStorage.clear();
       StringRef KeyStr = KeyScalar->getValue(StringStorage);
       if (!StringStorage.empty()) {