summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/YAMLParser.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-09-11 22:40:40 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-09-11 22:40:40 +0000
commit23d8306d13e441c5afad5dfa48d344ad5865fde8 (patch)
treeb2234d3368a380b25fc61e61528f0b580cf2c0d6 /llvm/lib/Support/YAMLParser.cpp
parent3013ea1b63f6f214ec814a16dd65d93e899c376a (diff)
downloadbcm5719-llvm-23d8306d13e441c5afad5dfa48d344ad5865fde8.tar.gz
bcm5719-llvm-23d8306d13e441c5afad5dfa48d344ad5865fde8.zip
ADT: Add AllocatorList, and use it for yaml::Token
- Add AllocatorList, a non-intrusive list that owns an LLVM-style allocator and provides a std::list-like interface (trivially built on top of simple_ilist), - add a typedef (and unit tests) for BumpPtrList, and - use BumpPtrList for the list of llvm::yaml::Token (i.e., TokenQueueT). TokenQueueT has no need for the complexity of an intrusive list. The only reason to inherit from ilist was to customize the allocator. TokenQueueT was the only example in-tree of using ilist<> in a truly non-intrusive way. Moreover, this removes the final use of the non-intrusive ilist_traits<>::createNode (after r280573, r281177, and r281181). I have a WIP patch that removes this customization point (and the API that relies on it) that I plan to commit soon. Note: AllocatorList owns the allocator, which limits the viable API (e.g., splicing must be on the same list). For now I've left out any problematic API. It wouldn't be hard to split AllocatorList into two layers: an Impl class that calls DerivedT::getAlloc (via CRTP), and derived classes that handle Allocator ownership/reference/etc semantics; and then implement splice with appropriate assertions; but TBH we should probably just customize the std::list allocators at that point. llvm-svn: 281182
Diffstat (limited to 'llvm/lib/Support/YAMLParser.cpp')
-rw-r--r--llvm/lib/Support/YAMLParser.cpp23
1 files changed, 5 insertions, 18 deletions
diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp
index c083e1f1ebd..0d169af26be 100644
--- a/llvm/lib/Support/YAMLParser.cpp
+++ b/llvm/lib/Support/YAMLParser.cpp
@@ -17,8 +17,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
-#include "llvm/ADT/ilist.h"
-#include "llvm/ADT/ilist_node.h"
+#include "llvm/ADT/AllocatorList.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
@@ -109,7 +108,7 @@ void SequenceNode::anchor() {}
void AliasNode::anchor() {}
/// Token - A single YAML token.
-struct Token : ilist_node<Token> {
+struct Token {
enum TokenKind {
TK_Error, // Uninitialized token.
TK_StreamStart,
@@ -148,18 +147,7 @@ struct Token : ilist_node<Token> {
}
}
-namespace llvm {
-template <> struct ilist_alloc_traits<Token> {
- Token *createNode(const Token &V) {
- return new (Alloc.Allocate<Token>()) Token(V);
- }
- static void deleteNode(Token *V) { V->~Token(); }
-
- BumpPtrAllocator Alloc;
-};
-} // end namespace llvm
-
-typedef ilist<Token> TokenQueueT;
+typedef llvm::BumpPtrList<Token> TokenQueueT;
namespace {
/// @brief This struct is used to track simple keys.
@@ -797,9 +785,8 @@ Token Scanner::getNext() {
// There cannot be any referenced Token's if the TokenQueue is empty. So do a
// quick deallocation of them all.
- if (TokenQueue.empty()) {
- TokenQueue.Alloc.Reset();
- }
+ if (TokenQueue.empty())
+ TokenQueue.resetAlloc();
return Ret;
}
OpenPOWER on IntegriCloud