[llvm] r328345 - Delete the copy constructor for llvm::yaml::Node

Jordan Rose via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 23 11:05:20 PDT 2018


Author: jrose
Date: Fri Mar 23 11:05:19 2018
New Revision: 328345

URL: http://llvm.org/viewvc/llvm-project?rev=328345&view=rev
Log:
Delete the copy constructor for llvm::yaml::Node

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!

Modified:
    llvm/trunk/include/llvm/Support/YAMLParser.h

Modified: llvm/trunk/include/llvm/Support/YAMLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/YAMLParser.h?rev=328345&r1=328344&r2=328345&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/YAMLParser.h (original)
+++ llvm/trunk/include/llvm/Support/YAMLParser.h Fri Mar 23 11:05:19 2018
@@ -125,6 +125,11 @@ public:
   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);




More information about the llvm-commits mailing list