Title: [93012] trunk/Source
Revision
93012
Author
[email protected]
Date
2011-08-12 19:40:51 -0700 (Fri, 12 Aug 2011)

Log Message

Use __builtin_trap() for CRASH when building with clang
https://bugs.webkit.org/show_bug.cgi?id=66152

Reviewed by Anders Carlsson.

../_javascript_Core: 

* wtf/Assertions.h:
Add Clang specific CRASH macro that calls __builtin_trap() instead
of silly techniques to crash. This allows the static analyzer to understand
that we are intentionally crashing. As a result, we need to mark some functions
as not returning.

Also adds a macros that annotates a function as never returning due to ASSERT or CRASH.

* wtf/Compiler.h:
Add COMPILIER(CLANG) and fix some formatting and spelling mistakes.

* wtf/FastMalloc.cpp:
(WTF::Internal::fastMallocMatchFailed):
Add NO_RETURN_DUE_TO_CRASH.

* yarr/YarrParser.h:
(JSC::Yarr::Parser::CharacterClassParserDelegate::assertionWordBoundary):
(JSC::Yarr::Parser::CharacterClassParserDelegate::atomBackReference):
Add NO_RETURN_DUE_TO_ASSERT.

../WebCore: 

* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneBase::fail):
* bindings/objc/WebScriptObject.mm:
* platform/mac/BlockExceptions.h:
* platform/text/cf/StringImplCF.cpp:
Add NO_RETURN_DUE_TO_ASSERT.

* bridge/IdentifierRep.h:
Don't define the destructor since it is never called,

../WebKit/mac: 

* Plugins/WebBaseNetscapePluginView.mm:
(-[WebBaseNetscapePluginView setAttributeKeys:andValues:]):
(-[WebBaseNetscapePluginView handleMouseMoved:]):
(-[WebBaseNetscapePluginView handleMouseEntered:]):
(-[WebBaseNetscapePluginView handleMouseExited:]):
(-[WebBaseNetscapePluginView focusChanged]):
(-[WebBaseNetscapePluginView windowFocusChanged:]):
(-[WebBaseNetscapePluginView createPlugin]):
(-[WebBaseNetscapePluginView loadStream]):
(-[WebBaseNetscapePluginView shouldStop]):
(-[WebBaseNetscapePluginView destroyPlugin]):
(-[WebBaseNetscapePluginView updateAndSetWindow]):
(-[WebBaseNetscapePluginView sendModifierEventWithKeyCode:character:]):
(-[WebBaseNetscapePluginView pluginLayer]):
(-[WebBaseNetscapePluginView getFormValue:]):
Remove the ASSERT_NOT_REACHED from the base class methods. They were not
adding much value and were getting in the way of making the static analyzer
work. A better way to do this would be to use a formal protocol.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (93011 => 93012)


--- trunk/Source/_javascript_Core/ChangeLog	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-08-13 02:40:51 UTC (rev 93012)
@@ -1,3 +1,30 @@
+2011-08-12  Sam Weinig  <[email protected]>
+
+        Use __builtin_trap() for CRASH when building with clang
+        https://bugs.webkit.org/show_bug.cgi?id=66152
+
+        Reviewed by Anders Carlsson.
+
+        * wtf/Assertions.h:
+        Add Clang specific CRASH macro that calls __builtin_trap() instead
+        of silly techniques to crash. This allows the static analyzer to understand
+        that we are intentionally crashing. As a result, we need to mark some functions
+        as not returning.
+
+        Also adds a macros that annotates a function as never returning due to ASSERT or CRASH.
+
+        * wtf/Compiler.h:
+        Add COMPILIER(CLANG) and fix some formatting and spelling mistakes.
+
+        * wtf/FastMalloc.cpp:
+        (WTF::Internal::fastMallocMatchFailed):
+        Add NO_RETURN_DUE_TO_CRASH.
+
+        * yarr/YarrParser.h:
+        (JSC::Yarr::Parser::CharacterClassParserDelegate::assertionWordBoundary):
+        (JSC::Yarr::Parser::CharacterClassParserDelegate::atomBackReference):
+        Add NO_RETURN_DUE_TO_ASSERT.
+
 2011-08-12  Filip Pizlo  <[email protected]>
 
         DFG JIT has inconsistent use of boxDouble and unboxDouble,

Modified: trunk/Source/_javascript_Core/wtf/Assertions.h (93011 => 93012)


--- trunk/Source/_javascript_Core/wtf/Assertions.h	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/_javascript_Core/wtf/Assertions.h	2011-08-13 02:40:51 UTC (rev 93012)
@@ -172,22 +172,34 @@
 #define CRASH() do { \
     __DEBUGGER(); \
     User::Panic(_L("Webkit CRASH"),0); \
-    } while(false)
+} while (false)
 #elif PLATFORM(BREWMP)
 #define CRASH() do { \
     dbg_Message("WebKit CRASH", DBG_MSG_LEVEL_FATAL, __FILE__, __LINE__); \
     *(int *)(uintptr_t)0xbbadbeef = 0; \
     ((void(*)())0)(); /* More reliable, but doesn't say BBADBEEF */ \
-} while(false)
+} while (false)
+#elif COMPILER(CLANG)
+#define CRASH() do { \
+    WTFReportBacktrace(); \
+    __builtin_trap(); \
+} while (false)
 #else
 #define CRASH() do { \
     WTFReportBacktrace(); \
     *(int *)(uintptr_t)0xbbadbeef = 0; \
     ((void(*)())0)(); /* More reliable, but doesn't say BBADBEEF */ \
-} while(false)
+} while (false)
 #endif
 #endif
 
+#if COMPILER(CLANG)
+#define NO_RETURN_DUE_TO_CRASH NO_RETURN
+#else
+#define NO_RETURN_DUE_TO_CRASH
+#endif
+
+
 /* BACKTRACE
 
   Print a backtrace to the same location as ASSERT messages.
@@ -237,6 +249,7 @@
 #define ASSERT(assertion) ((void)0)
 #define ASSERT_AT(assertion, file, line, function) ((void)0)
 #define ASSERT_NOT_REACHED() ((void)0)
+#define NO_RETURN_DUE_TO_ASSERT
 
 #if COMPILER(INTEL) && !OS(WINDOWS) || COMPILER(RVCT)
 template<typename T>
@@ -269,6 +282,8 @@
 
 #define ASSERT_UNUSED(variable, assertion) ASSERT(assertion)
 
+#define NO_RETURN_DUE_TO_ASSERT NO_RETURN_DUE_TO_CRASH
+
 #endif
 
 /* ASSERT_WITH_MESSAGE */

Modified: trunk/Source/_javascript_Core/wtf/Compiler.h (93011 => 93012)


--- trunk/Source/_javascript_Core/wtf/Compiler.h	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/_javascript_Core/wtf/Compiler.h	2011-08-13 02:40:51 UTC (rev 93012)
@@ -31,9 +31,14 @@
 
 /* ==== COMPILER() - the compiler being used to build the project ==== */
 
-/* COMPILER(MSVC) Microsoft Visual C++ */
-/* COMPILER(MSVC7_OR_LOWER) Microsoft Visual C++ 2003 or lower*/
-/* COMPILER(MSVC9_OR_LOWER) Microsoft Visual C++ 2008 or lower*/
+/* COMPILER(CLANG) - Clang  */
+#if defined(__clang__)
+#define WTF_COMPILER_CLANG 1
+#endif
+
+/* COMPILER(MSVC) - Microsoft Visual C++ */
+/* COMPILER(MSVC7_OR_LOWER) - Microsoft Visual C++ 2003 or lower*/
+/* COMPILER(MSVC9_OR_LOWER) - Microsoft Visual C++ 2008 or lower*/
 #if defined(_MSC_VER)
 #define WTF_COMPILER_MSVC 1
 #if _MSC_VER < 1400
@@ -43,7 +48,7 @@
 #endif
 #endif
 
-/* COMPILER(RVCT)  - ARM RealView Compilation Tools */
+/* COMPILER(RVCT) - ARM RealView Compilation Tools */
 /* COMPILER(RVCT4_OR_GREATER) - ARM RealView Compilation Tools 4.0 or greater */
 #if defined(__CC_ARM) || defined(__ARMCC__)
 #define WTF_COMPILER_RVCT 1
@@ -100,7 +105,7 @@
 #endif
 
 
-/* ==== Comiler features ==== */
+/* ==== Compiler features ==== */
 
 
 /* ALWAYS_INLINE */

Modified: trunk/Source/_javascript_Core/wtf/FastMalloc.cpp (93011 => 93012)


--- trunk/Source/_javascript_Core/wtf/FastMalloc.cpp	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/_javascript_Core/wtf/FastMalloc.cpp	2011-08-13 02:40:51 UTC (rev 93012)
@@ -199,7 +199,8 @@
 #else
 COMPILE_ASSERT(((sizeof(ValidationHeader) % sizeof(AllocAlignmentInteger)) == 0), ValidationHeader_must_produce_correct_alignment);
 #endif
-void fastMallocMatchFailed(void*)
+
+NO_RETURN_DUE_TO_CRASH void fastMallocMatchFailed(void*)
 {
     CRASH();
 }

Modified: trunk/Source/_javascript_Core/yarr/YarrParser.h (93011 => 93012)


--- trunk/Source/_javascript_Core/yarr/YarrParser.h	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/_javascript_Core/yarr/YarrParser.h	2011-08-13 02:40:51 UTC (rev 93012)
@@ -211,8 +211,8 @@
 
         // parseEscape() should never call these delegate methods when
         // invoked with inCharacterClass set.
-        void assertionWordBoundary(bool) { ASSERT_NOT_REACHED(); }
-        void atomBackReference(unsigned) { ASSERT_NOT_REACHED(); }
+        NO_RETURN_DUE_TO_ASSERT void assertionWordBoundary(bool) { ASSERT_NOT_REACHED(); }
+        NO_RETURN_DUE_TO_ASSERT void atomBackReference(unsigned) { ASSERT_NOT_REACHED(); }
 
     private:
         Delegate& m_delegate;

Modified: trunk/Source/WebCore/ChangeLog (93011 => 93012)


--- trunk/Source/WebCore/ChangeLog	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/WebCore/ChangeLog	2011-08-13 02:40:51 UTC (rev 93012)
@@ -1,3 +1,20 @@
+2011-08-12  Sam Weinig  <[email protected]>
+
+        Use __builtin_trap() for CRASH when building with clang
+        https://bugs.webkit.org/show_bug.cgi?id=66152
+
+        Reviewed by Anders Carlsson.
+
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::CloneBase::fail):
+        * bindings/objc/WebScriptObject.mm:
+        * platform/mac/BlockExceptions.h:
+        * platform/text/cf/StringImplCF.cpp:
+        Add NO_RETURN_DUE_TO_ASSERT.
+
+        * bridge/IdentifierRep.h:
+        Don't define the destructor since it is never called,
+
 2011-08-12  Joseph Pecoraro  <[email protected]>
 
         Abandoned Memory: Temporary CSS Fonts May Never Be Purged

Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (93011 => 93012)


--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2011-08-13 02:40:51 UTC (rev 93012)
@@ -197,6 +197,7 @@
         throwError(m_exec, createInterruptedExecutionException(&m_exec->globalData()));
     }
 
+    NO_RETURN_DUE_TO_ASSERT
     void fail()
     {
         ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/bindings/objc/WebScriptObject.mm (93011 => 93012)


--- trunk/Source/WebCore/bindings/objc/WebScriptObject.mm	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/WebCore/bindings/objc/WebScriptObject.mm	2011-08-13 02:40:51 UTC (rev 93012)
@@ -603,6 +603,11 @@
 
 @end
 
+
+@interface WebUndefined (Overrides)
+- (void)dealloc NO_RETURN_DUE_TO_ASSERT;
+@end
+
 @implementation WebUndefined
 
 + (id)allocWithZone:(NSZone *)unusedZone
@@ -660,7 +665,7 @@
 
 - (void)dealloc
 {
-    ASSERT(false);
+    ASSERT_NOT_REACHED();
     return;
     [super dealloc]; // make -Wdealloc-check happy
 }

Modified: trunk/Source/WebCore/bridge/IdentifierRep.h (93011 => 93012)


--- trunk/Source/WebCore/bridge/IdentifierRep.h	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/WebCore/bridge/IdentifierRep.h	2011-08-13 02:40:51 UTC (rev 93012)
@@ -59,11 +59,7 @@
         m_value.m_string = fastStrDup(name);
     }
     
-    ~IdentifierRep()
-    {
-        // IdentifierReps should never be deleted.
-        ASSERT_NOT_REACHED();
-    }
+    ~IdentifierRep(); // Not implemented
     
     union {
         const char* m_string;

Modified: trunk/Source/WebCore/platform/mac/BlockExceptions.h (93011 => 93012)


--- trunk/Source/WebCore/platform/mac/BlockExceptions.h	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/WebCore/platform/mac/BlockExceptions.h	2011-08-13 02:40:51 UTC (rev 93012)
@@ -25,7 +25,7 @@
 
 #import <Foundation/NSException.h>
 
-void ReportBlockedObjCException(NSException *);
+NO_RETURN_DUE_TO_ASSERT void ReportBlockedObjCException(NSException *);
 
 #define BEGIN_BLOCK_OBJC_EXCEPTIONS @try {
 #define END_BLOCK_OBJC_EXCEPTIONS } @catch(NSException *localException) { ReportBlockedObjCException(localException); }

Modified: trunk/Source/WebCore/platform/text/cf/StringImplCF.cpp (93011 => 93012)


--- trunk/Source/WebCore/platform/text/cf/StringImplCF.cpp	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/WebCore/platform/text/cf/StringImplCF.cpp	2011-08-13 02:40:51 UTC (rev 93012)
@@ -43,6 +43,7 @@
         return info;
     }
 
+    NO_RETURN_DUE_TO_ASSERT
     static void release(const void*)
     {
         ASSERT_NOT_REACHED();

Modified: trunk/Source/WebKit/mac/ChangeLog (93011 => 93012)


--- trunk/Source/WebKit/mac/ChangeLog	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/WebKit/mac/ChangeLog	2011-08-13 02:40:51 UTC (rev 93012)
@@ -1,3 +1,29 @@
+2011-08-12  Sam Weinig  <[email protected]>
+
+        Use __builtin_trap() for CRASH when building with clang
+        https://bugs.webkit.org/show_bug.cgi?id=66152
+
+        Reviewed by Anders Carlsson.
+
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (-[WebBaseNetscapePluginView setAttributeKeys:andValues:]):
+        (-[WebBaseNetscapePluginView handleMouseMoved:]):
+        (-[WebBaseNetscapePluginView handleMouseEntered:]):
+        (-[WebBaseNetscapePluginView handleMouseExited:]):
+        (-[WebBaseNetscapePluginView focusChanged]):
+        (-[WebBaseNetscapePluginView windowFocusChanged:]):
+        (-[WebBaseNetscapePluginView createPlugin]):
+        (-[WebBaseNetscapePluginView loadStream]):
+        (-[WebBaseNetscapePluginView shouldStop]):
+        (-[WebBaseNetscapePluginView destroyPlugin]):
+        (-[WebBaseNetscapePluginView updateAndSetWindow]):
+        (-[WebBaseNetscapePluginView sendModifierEventWithKeyCode:character:]):
+        (-[WebBaseNetscapePluginView pluginLayer]):
+        (-[WebBaseNetscapePluginView getFormValue:]):
+        Remove the ASSERT_NOT_REACHED from the base class methods. They were not
+        adding much value and were getting in the way of making the static analyzer
+        work. A better way to do this would be to use a formal protocol.
+
 2011-08-12  Mark Rowe  <[email protected]>
 
         Be more forward-looking in the choice of compiler.

Modified: trunk/Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm (93011 => 93012)


--- trunk/Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm	2011-08-13 01:44:01 UTC (rev 93011)
+++ trunk/Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm	2011-08-13 02:40:51 UTC (rev 93012)
@@ -182,64 +182,64 @@
 // Methods that subclasses must override
 - (void)setAttributeKeys:(NSArray *)keys andValues:(NSArray *)values
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
 }
 
 - (void)handleMouseMoved:(NSEvent *)event
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overriden by subclasses.
 }
 
 - (void)handleMouseEntered:(NSEvent *)event
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
 }
 
 - (void)handleMouseExited:(NSEvent *)event
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
 }
 
 - (void)focusChanged
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
 }
 
 - (void)windowFocusChanged:(BOOL)hasFocus
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
 }
 
 - (BOOL)createPlugin
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
     return NO;
 }
 
 - (void)loadStream
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
 }
 
 - (BOOL)shouldStop
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
     return YES;
 }
 
 - (void)destroyPlugin
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
 }
 
 - (void)updateAndSetWindow
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
 }
 
 - (void)sendModifierEventWithKeyCode:(int)keyCode character:(char)character
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
 }
 
 - (void)privateBrowsingModeDidChange
@@ -875,13 +875,13 @@
 
 - (CALayer *)pluginLayer
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
     return nil;
 }
 
 - (BOOL)getFormValue:(NSString **)value
 {
-    ASSERT_NOT_REACHED();
+    // This needs to be overridden by subclasses.
     return false;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to