From 969ccf42820e9aa0c69d57bab7c4263629b970c7 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 24 Oct 2014 23:19:08 -0700 Subject: [PATCH] Remove compiler feature detection for = delete All supported compilers have this feature. Also remove unused macros for OVERRIDE now that override are broadly supported. R=esprehn@chromium.org, eseidel@chromium.org Review URL: https://codereview.chromium.org/673403002 --- engine/core/dom/Attr.h | 2 +- engine/core/dom/CharacterData.h | 4 ++-- engine/core/dom/ContainerNode.h | 4 ++-- engine/core/dom/Document.h | 8 ++++---- engine/core/dom/DocumentFragment.h | 2 +- engine/core/dom/Element.h | 6 +++--- engine/core/dom/Text.h | 2 +- engine/core/dom/shadow/InsertionPoint.h | 2 +- engine/core/editing/PlainTextRange.h | 2 +- engine/core/html/HTMLElement.h | 4 ++-- engine/core/rendering/RenderBlock.h | 4 ++-- engine/core/rendering/RenderBox.h | 2 +- engine/core/rendering/RenderInline.h | 4 ++-- engine/core/rendering/RenderMedia.h | 4 ++-- engine/core/rendering/RenderText.h | 2 +- engine/platform/heap/Heap.h | 23 --------------------- engine/wtf/Compiler.h | 27 +------------------------ engine/wtf/Noncopyable.h | 15 ++++---------- engine/wtf/NullPtr.h | 9 --------- 19 files changed, 31 insertions(+), 95 deletions(-) diff --git a/engine/core/dom/Attr.h b/engine/core/dom/Attr.h index 786ff3597..b2eb4b5ce 100644 --- a/engine/core/dom/Attr.h +++ b/engine/core/dom/Attr.h @@ -52,7 +52,7 @@ public: private: Attr(Element&, const QualifiedName&); - bool isElementNode() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isElementNode() const = delete; // This will catch anyone doing an unnecessary check. virtual String nodeName() const override { return name(); } virtual NodeType nodeType() const override { return ATTRIBUTE_NODE; } diff --git a/engine/core/dom/CharacterData.h b/engine/core/dom/CharacterData.h index 93163f9ef..5898d078f 100644 --- a/engine/core/dom/CharacterData.h +++ b/engine/core/dom/CharacterData.h @@ -77,8 +77,8 @@ private: virtual bool offsetInCharacters() const override final; void setDataAndUpdate(const String&, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength, RecalcStyleBehavior = DoNotRecalcStyle); - bool isContainerNode() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. - bool isElementNode() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isContainerNode() const = delete; // This will catch anyone doing an unnecessary check. + bool isElementNode() const = delete; // This will catch anyone doing an unnecessary check. }; DEFINE_NODE_TYPE_CASTS(CharacterData, isCharacterDataNode()); diff --git a/engine/core/dom/ContainerNode.h b/engine/core/dom/ContainerNode.h index c625f986e..b82c47059 100644 --- a/engine/core/dom/ContainerNode.h +++ b/engine/core/dom/ContainerNode.h @@ -142,8 +142,8 @@ protected: void setLastChild(Node* child) { m_lastChild = child; } private: - bool isContainerNode() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. - bool isTextNode() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isContainerNode() const = delete; // This will catch anyone doing an unnecessary check. + bool isTextNode() const = delete; // This will catch anyone doing an unnecessary check. void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild); void insertBeforeCommon(Node& nextChild, Node& oldChild); diff --git a/engine/core/dom/Document.h b/engine/core/dom/Document.h index 6dd5c690e..f8f42e820 100644 --- a/engine/core/dom/Document.h +++ b/engine/core/dom/Document.h @@ -322,7 +322,7 @@ public: void prepareForDestruction(); // If you have a Document, use renderView() instead which is faster. - void renderer() const WTF_DELETED_FUNCTION; + void renderer() const = delete; RenderView* renderView() const { return m_renderView; } @@ -680,9 +680,9 @@ protected: private: friend class Node; - bool isDocumentFragment() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. - bool isDocumentNode() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. - bool isElementNode() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isDocumentFragment() const = delete; // This will catch anyone doing an unnecessary check. + bool isDocumentNode() const = delete; // This will catch anyone doing an unnecessary check. + bool isElementNode() const = delete; // This will catch anyone doing an unnecessary check. ScriptedAnimationController& ensureScriptedAnimationController(); virtual EventQueue* eventQueue() const override final; diff --git a/engine/core/dom/DocumentFragment.h b/engine/core/dom/DocumentFragment.h index 1ca87bbef..31408beee 100644 --- a/engine/core/dom/DocumentFragment.h +++ b/engine/core/dom/DocumentFragment.h @@ -45,7 +45,7 @@ private: virtual PassRefPtrWillBeRawPtr cloneNode(bool deep = true) override; virtual bool childTypeAllowed(NodeType) const override; - bool isDocumentFragment() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isDocumentFragment() const = delete; // This will catch anyone doing an unnecessary check. }; DEFINE_NODE_TYPE_CASTS(DocumentFragment, isDocumentFragment()); diff --git a/engine/core/dom/Element.h b/engine/core/dom/Element.h index e733706d8..126abaa03 100644 --- a/engine/core/dom/Element.h +++ b/engine/core/dom/Element.h @@ -425,9 +425,9 @@ private: void clearElementFlag(ElementFlags); bool hasElementFlagInternal(ElementFlags) const; - bool isElementNode() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. - bool isDocumentFragment() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. - bool isDocumentNode() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isElementNode() const = delete; // This will catch anyone doing an unnecessary check. + bool isDocumentFragment() const = delete; // This will catch anyone doing an unnecessary check. + bool isDocumentNode() const = delete; // This will catch anyone doing an unnecessary check. void styleAttributeChanged(const AtomicString& newStyleString); diff --git a/engine/core/dom/Text.h b/engine/core/dom/Text.h index 589250d59..4371cd6bd 100644 --- a/engine/core/dom/Text.h +++ b/engine/core/dom/Text.h @@ -71,7 +71,7 @@ private: virtual String nodeName() const override; virtual PassRefPtrWillBeRawPtr cloneNode(bool deep = true) override final; - bool isTextNode() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isTextNode() const = delete; // This will catch anyone doing an unnecessary check. bool needsWhitespaceRenderer(); diff --git a/engine/core/dom/shadow/InsertionPoint.h b/engine/core/dom/shadow/InsertionPoint.h index 8fc2f2da3..612cf8668 100644 --- a/engine/core/dom/shadow/InsertionPoint.h +++ b/engine/core/dom/shadow/InsertionPoint.h @@ -78,7 +78,7 @@ protected: virtual void willRecalcStyle(StyleRecalcChange) override; private: - bool isInsertionPoint() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isInsertionPoint() const = delete; // This will catch anyone doing an unnecessary check. ContentDistribution m_distribution; bool m_registeredWithShadowRoot; diff --git a/engine/core/editing/PlainTextRange.h b/engine/core/editing/PlainTextRange.h index e9ad645c7..8c8c97792 100644 --- a/engine/core/editing/PlainTextRange.h +++ b/engine/core/editing/PlainTextRange.h @@ -54,7 +54,7 @@ public: static PlainTextRange create(const ContainerNode& scope, const Range&); private: - PlainTextRange& operator=(const PlainTextRange&) WTF_DELETED_FUNCTION; + PlainTextRange& operator=(const PlainTextRange&) = delete; enum GetRangeFor { ForGeneric, ForSelection }; PassRefPtrWillBeRawPtr createRangeFor(const ContainerNode& scope, GetRangeFor) const; diff --git a/engine/core/html/HTMLElement.h b/engine/core/html/HTMLElement.h index fb0ef43d7..65a0c85b0 100644 --- a/engine/core/html/HTMLElement.h +++ b/engine/core/html/HTMLElement.h @@ -67,8 +67,8 @@ protected: HTMLElement(const QualifiedName& tagName, Document&, ConstructionType); private: - bool isHTMLElement() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. - bool isStyledElement() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isHTMLElement() const = delete; // This will catch anyone doing an unnecessary check. + bool isStyledElement() const = delete; // This will catch anyone doing an unnecessary check. }; DEFINE_ELEMENT_TYPE_CASTS(HTMLElement, isHTMLElement()); diff --git a/engine/core/rendering/RenderBlock.h b/engine/core/rendering/RenderBlock.h index dd64bd5d1..d8c4b5040 100644 --- a/engine/core/rendering/RenderBlock.h +++ b/engine/core/rendering/RenderBlock.h @@ -66,8 +66,8 @@ public: RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); } // If you have a RenderBlock, use firstChild or lastChild instead. - void slowFirstChild() const WTF_DELETED_FUNCTION; - void slowLastChild() const WTF_DELETED_FUNCTION; + void slowFirstChild() const = delete; + void slowLastChild() const = delete; const RenderObjectChildList* children() const { return &m_children; } RenderObjectChildList* children() { return &m_children; } diff --git a/engine/core/rendering/RenderBox.h b/engine/core/rendering/RenderBox.h index f304e4478..9f50453f4 100644 --- a/engine/core/rendering/RenderBox.h +++ b/engine/core/rendering/RenderBox.h @@ -718,7 +718,7 @@ private: virtual InvalidationReason invalidatePaintIfNeeded(const PaintInvalidationState&, const RenderLayerModelObject& newPaintInvalidationContainer) override final; - bool isBox() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isBox() const = delete; // This will catch anyone doing an unnecessary check. // The width/height of the contents + borders + padding. The x/y location is relative to our container (which is not always our parent). LayoutRect m_frameRect; diff --git a/engine/core/rendering/RenderInline.h b/engine/core/rendering/RenderInline.h index b62f7a2ef..6696c1dd4 100644 --- a/engine/core/rendering/RenderInline.h +++ b/engine/core/rendering/RenderInline.h @@ -41,8 +41,8 @@ public: RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); } // If you have a RenderInline, use firstChild or lastChild instead. - void slowFirstChild() const WTF_DELETED_FUNCTION; - void slowLastChild() const WTF_DELETED_FUNCTION; + void slowFirstChild() const = delete; + void slowLastChild() const = delete; virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) override; diff --git a/engine/core/rendering/RenderMedia.h b/engine/core/rendering/RenderMedia.h index bf4ff2d4e..7abf503b5 100644 --- a/engine/core/rendering/RenderMedia.h +++ b/engine/core/rendering/RenderMedia.h @@ -42,8 +42,8 @@ public: RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); } // If you have a RenderMedia, use firstChild or lastChild instead. - void slowFirstChild() const WTF_DELETED_FUNCTION; - void slowLastChild() const WTF_DELETED_FUNCTION; + void slowFirstChild() const = delete; + void slowLastChild() const = delete; const RenderObjectChildList* children() const { return &m_children; } RenderObjectChildList* children() { return &m_children; } diff --git a/engine/core/rendering/RenderText.h b/engine/core/rendering/RenderText.h index 1524fd7f0..adb8db964 100644 --- a/engine/core/rendering/RenderText.h +++ b/engine/core/rendering/RenderText.h @@ -169,7 +169,7 @@ private: float widthFromCache(const Font&, int start, int len, float xPos, TextDirection, HashSet* fallbackFonts, GlyphOverflow*) const; bool isAllASCII() const { return m_isAllASCII; } - bool isText() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. + bool isText() const = delete; // This will catch anyone doing an unnecessary check. // We put the bitfield first to minimize padding on 64-bit. bool m_hasBreakableChar : 1; // Whether or not we can be broken into multiple lines. diff --git a/engine/platform/heap/Heap.h b/engine/platform/heap/Heap.h index b155c86fc..e1f071cef 100644 --- a/engine/platform/heap/Heap.h +++ b/engine/platform/heap/Heap.h @@ -1401,7 +1401,6 @@ T* adoptRefCountedGarbageCollected(T* ptr) // need to have a trace method. That trace method will be called // automatically by the Heap collections. // -#if COMPILER_SUPPORTS(CXX_DELETED_FUNCTIONS) #define DISALLOW_ALLOCATION() \ private: \ void* operator new(size_t) = delete; \ @@ -1419,28 +1418,6 @@ T* adoptRefCountedGarbageCollected(T* ptr) private: \ Type() = delete; -#else - -#define DISALLOW_ALLOCATION() \ - private: \ - void* operator new(size_t); \ - void* operator new(size_t, NotNullTag, void*); \ - void* operator new(size_t, void*) - -#define ALLOW_ONLY_INLINE_ALLOCATION() \ - public: \ - void* operator new(size_t, NotNullTag, void* location) { return location; } \ - void* operator new(size_t, void* location) { return location; } \ - private: \ - void* operator new(size_t); - -#define STATIC_ONLY(Type) \ - private: \ - Type(); - -#endif - - // These macros insert annotations that the Blink GC plugin for clang uses for // verification. STACK_ALLOCATED is used to declare that objects of this type // are always stack allocated. GC_PLUGIN_IGNORE is used to make the plugin diff --git a/engine/wtf/Compiler.h b/engine/wtf/Compiler.h index 403d0385b..ff35d1008 100644 --- a/engine/wtf/Compiler.h +++ b/engine/wtf/Compiler.h @@ -51,13 +51,11 @@ check for both cxx_rvalue_references as well as the unrelated cxx_nonstatic_member_init feature which we know was added in 4.3 */ #define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES __has_extension(cxx_rvalue_references) && __has_extension(cxx_nonstatic_member_init) -#define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS __has_extension(cxx_deleted_functions) #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR __has_feature(cxx_nullptr) #define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS __has_feature(cxx_explicit_conversions) #define WTF_COMPILER_SUPPORTS_BLOCKS __has_feature(blocks) #define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT __has_extension(c_static_assert) #define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT __has_extension(cxx_static_assert) -#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL __has_extension(cxx_override_control) #define WTF_COMPILER_SUPPORTS_HAS_TRIVIAL_DESTRUCTOR __has_extension(has_trivial_destructor) #define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS __has_extension(cxx_strong_enums) @@ -79,8 +77,6 @@ #if COMPILER(CLANG) /* Keep strong enums turned off when building with clang-cl: We cannot yet build all of Blink without fallback to cl.exe, and strong enums are exposed at ABI boundaries. */ #undef WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS -#else -#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL 1 #endif #endif @@ -108,9 +104,6 @@ #define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT 1 #define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES 1 #endif -#if GCC_VERSION_AT_LEAST(4, 4, 0) -#define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS 1 -#endif #if GCC_VERSION_AT_LEAST(4, 5, 0) #define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS 1 #endif @@ -119,9 +112,6 @@ /* Strong enums should work from gcc 4.4, but doesn't seem to support some operators */ #define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS 1 #endif -#if GCC_VERSION_AT_LEAST(4, 7, 0) -#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL 1 -#endif #endif /* defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus >= 201103L) */ #endif /* COMPILER(GCC) */ @@ -206,23 +196,8 @@ #define ALLOW_UNUSED #endif -/* override and FINAL */ - -#if COMPILER_SUPPORTS(CXX_OVERRIDE_CONTROL) -#define override override +/* FIXME: Convert all instance of FINAL to final */ #define FINAL final -#else -#define override -#define FINAL -#endif - -/* WTF_DELETED_FUNCTION */ - -#if COMPILER_SUPPORTS(CXX_DELETED_FUNCTIONS) -#define WTF_DELETED_FUNCTION = delete -#else -#define WTF_DELETED_FUNCTION -#endif /* REFERENCED_FROM_ASM */ diff --git a/engine/wtf/Noncopyable.h b/engine/wtf/Noncopyable.h index 4be30c427..f3321e883 100644 --- a/engine/wtf/Noncopyable.h +++ b/engine/wtf/Noncopyable.h @@ -23,16 +23,9 @@ #include "wtf/Compiler.h" -#if COMPILER_SUPPORTS(CXX_DELETED_FUNCTIONS) - #define WTF_MAKE_NONCOPYABLE(ClassName) \ - private: \ - ClassName(const ClassName&) = delete; \ - ClassName& operator=(const ClassName&) = delete; -#else - #define WTF_MAKE_NONCOPYABLE(ClassName) \ - private: \ - ClassName(const ClassName&); \ - ClassName& operator=(const ClassName&) -#endif +#define WTF_MAKE_NONCOPYABLE(ClassName) \ + private: \ + ClassName(const ClassName&) = delete; \ + ClassName& operator=(const ClassName&) = delete; #endif // WTF_Noncopyable_h diff --git a/engine/wtf/NullPtr.h b/engine/wtf/NullPtr.h index 1aa558498..9614104e9 100644 --- a/engine/wtf/NullPtr.h +++ b/engine/wtf/NullPtr.h @@ -66,20 +66,11 @@ WTF_EXPORT extern const std::nullptr_t nullptr; #endif -#if COMPILER_SUPPORTS(CXX_DELETED_FUNCTIONS) #define WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(ClassName) \ private: \ ClassName(int) = delete #define WTF_DISALLOW_ZERO_ASSIGNMENT(ClassName) \ private: \ ClassName& operator=(int) = delete -#else -#define WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(ClassName) \ - private: \ - ClassName(int) -#define WTF_DISALLOW_ZERO_ASSIGNMENT(ClassName) \ - private: \ - ClassName& operator=(int) -#endif #endif -- GitLab