[PATCH] D44317: Delete the copy constructor for llvm::yaml::Node

Jordan Rose via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 9 10:31:07 PST 2018


jordan_rose created this revision.
jordan_rose added a reviewer: arphaman.

The nodes keep a reference back to the original document, but the document is streamed, not read all into memory at once, and the position is part of the state. If nodes are ever copied, the document position can end up being advanced more than once.

      

This did not reveal any problems in LLVM or Clang but caught a handful over in Swift!


Repository:
  rL LLVM

https://reviews.llvm.org/D44317

Files:
  include/llvm/Support/YAMLParser.h


Index: include/llvm/Support/YAMLParser.h
===================================================================
--- include/llvm/Support/YAMLParser.h
+++ include/llvm/Support/YAMLParser.h
@@ -125,6 +125,11 @@
   Node(unsigned int Type, std::unique_ptr<Document> &, StringRef Anchor,
        StringRef Tag);
 
+  // It's not safe to copy YAML nodes; the document is streamed and the position
+  // is part of the state.
+  Node(const Node &) = delete;
+  void operator=(const Node &) = delete;
+
   void *operator new(size_t Size, BumpPtrAllocator &Alloc,
                      size_t Alignment = 16) noexcept {
     return Alloc.Allocate(Size, Alignment);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44317.137791.patch
Type: text/x-patch
Size: 653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180309/c2957d09/attachment.bin>


More information about the llvm-commits mailing list