From 0d2ed35d3ea8a6625142d677dd71ee44ee0ec1b1 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 12 Aug 2016 15:00:55 +0000 Subject: ADT: Share code for embedded sentinel traits, NFC Share code for the (mostly problematic) embedded sentinel traits. - Move the LLVM_NO_SANITIZE("object-size") attribute to ilist_half_embedded_sentinel_traits and ilist_embedded_sentinel_traits (previously it spread throughout the code duplication). - Add an ilist_full_embedded_sentinel_traits which has no UB (but has the downside of storing the complete node). - Replace all the custom sentinel traits in LLVM with a declaration of ilist_sentinel_traits that inherits from one of the embedded sentinel traits classes. There are still custom sentinel traits in other LLVM subprojects. I'll remove those in a follow-up. Nothing at all should be changing here, this is just rearranging code. Note that the final goal here is to remove the sentinel traits altogether, settling on the memory layout of ilist_half_embedded_sentinel_traits without the UB. This intermediate step moves the logic into ilist.h. llvm-svn: 278513 --- llvm/lib/Support/YAMLParser.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'llvm/lib/Support/YAMLParser.cpp') diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp index 2b71c596cc4..4d5b750e266 100644 --- a/llvm/lib/Support/YAMLParser.cpp +++ b/llvm/lib/Support/YAMLParser.cpp @@ -149,20 +149,9 @@ struct Token : ilist_node { } namespace llvm { -template<> -struct ilist_sentinel_traits { - Token *createSentinel() const { - return &Sentinel; - } - static void destroySentinel(Token*) {} - - Token *provideInitialHead() const { return createSentinel(); } - Token *ensureHead(Token*) const { return createSentinel(); } - static void noteHead(Token*, Token*) {} - -private: - mutable Token Sentinel; -}; +template <> +struct ilist_sentinel_traits + : public ilist_full_embedded_sentinel_traits {}; template<> struct ilist_node_traits { -- cgit v1.2.3