From dc86de6b6e3f34c669296f4b4fbc87075c41cc8e Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 23 Mar 2018 18:05:19 +0000 Subject: [PATCH] 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! llvm-svn: 328345 --- llvm/include/llvm/Support/YAMLParser.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/include/llvm/Support/YAMLParser.h b/llvm/include/llvm/Support/YAMLParser.h index c907a99..5b681a5 100644 --- a/llvm/include/llvm/Support/YAMLParser.h +++ b/llvm/include/llvm/Support/YAMLParser.h @@ -125,6 +125,11 @@ public: Node(unsigned int Type, std::unique_ptr &, 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); -- 2.7.4