Piotr Caban : msvcp90: Don't use throw_exception helper for out_of_range exception.

Alexandre Julliard julliard at winehq.org
Fri Aug 27 15:03:34 CDT 2021


Module: wine
Branch: master
Commit: 503f3462c64565488b0687fcaece989cb987bfca
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=503f3462c64565488b0687fcaece989cb987bfca

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Aug 27 13:48:24 2021 +0200

msvcp90: Don't use throw_exception helper for out_of_range exception.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcp60/msvcp.h     |  1 +
 dlls/msvcp60/string.c    |  4 +---
 dlls/msvcp90/cxx.h       |  1 -
 dlls/msvcp90/details.c   | 17 ++++++-----------
 dlls/msvcp90/exception.c | 14 +++++++-------
 dlls/msvcp90/locale.c    |  2 +-
 dlls/msvcp90/msvcp90.h   |  1 +
 dlls/msvcp90/string.c    |  4 +---
 8 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/dlls/msvcp60/msvcp.h b/dlls/msvcp60/msvcp.h
index 0c4f4f32280..bae75855c3a 100644
--- a/dlls/msvcp60/msvcp.h
+++ b/dlls/msvcp60/msvcp.h
@@ -487,3 +487,4 @@ typedef struct {
 void WINAPI DECLSPEC_NORETURN _CxxThrowException(void*,const cxx_exception_type*);
 void __cdecl DECLSPEC_NORETURN _Xlength_error(const char*);
 void __cdecl DECLSPEC_NORETURN _Xmem(void);
+void __cdecl DECLSPEC_NORETURN _Xout_of_range(const char*);
diff --git a/dlls/msvcp60/string.c b/dlls/msvcp60/string.c
index 22cdcd49891..45b7a57f961 100644
--- a/dlls/msvcp60/string.c
+++ b/dlls/msvcp60/string.c
@@ -46,10 +46,8 @@ typedef struct {
 /* ?_Xran at std@@YAXXZ */
 void __cdecl _Xran(void)
 {
-    static const char msg[] = "invalid string position";
-
     TRACE("\n");
-    throw_exception(EXCEPTION_OUT_OF_RANGE, msg);
+    _Xout_of_range("invalid string position");
 }
 
 /* ?_Xlen at std@@YAXXZ */
diff --git a/dlls/msvcp90/cxx.h b/dlls/msvcp90/cxx.h
index 0b14806d95c..9d79ca80e21 100644
--- a/dlls/msvcp90/cxx.h
+++ b/dlls/msvcp90/cxx.h
@@ -319,7 +319,6 @@ typedef enum __exception_type {
     EXCEPTION,
     EXCEPTION_BAD_CAST,
     EXCEPTION_LOGIC_ERROR,
-    EXCEPTION_OUT_OF_RANGE,
     EXCEPTION_FAILURE,
     EXCEPTION_RANGE_ERROR,
 } exception_type;
diff --git a/dlls/msvcp90/details.c b/dlls/msvcp90/details.c
index d2c51b7ff0a..b7de12e6e90 100644
--- a/dlls/msvcp90/details.c
+++ b/dlls/msvcp90/details.c
@@ -470,19 +470,14 @@ size_t __cdecl _vector_base_v4__Segment_index_of(size_t x)
 DEFINE_THISCALL_WRAPPER(_vector_base_v4__Internal_throw_exception, 8)
 void __thiscall _vector_base_v4__Internal_throw_exception(void/*_vector_base_v4*/ *this, size_t idx)
 {
-    static const struct {
-        exception_type type;
-        const char *msg;
-    } exceptions[] = {
-        { EXCEPTION_OUT_OF_RANGE, "Index out of range" },
-        { EXCEPTION_OUT_OF_RANGE, "Index out of segments table range" },
-        { EXCEPTION_RANGE_ERROR,  "Index is inside segment which failed to be allocated" },
-    };
-
     TRACE("(%p %Iu)\n", this, idx);
 
-    if(idx < ARRAY_SIZE(exceptions))
-        throw_exception(exceptions[idx].type, exceptions[idx].msg);
+    switch(idx) {
+    case 0: _Xout_of_range("Index out of range");
+    case 1: _Xout_of_range("Index out of segments table range");
+    case 2: throw_exception(EXCEPTION_RANGE_ERROR,
+                    "Index is inside segment which failed to be allocated");
+    }
 }
 
 #ifdef _WIN64
diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c
index 7b92b80d393..f6a15ecc8d6 100644
--- a/dlls/msvcp90/exception.c
+++ b/dlls/msvcp90/exception.c
@@ -916,10 +916,15 @@ void __cdecl DECLSPEC_NORETURN _Xlength_error(const char *str)
 
 /* ?_Xout_of_range at std@@YAXPBD at Z */
 /* ?_Xout_of_range at std@@YAXPEBD at Z */
-void __cdecl _Xout_of_range(const char *str)
+void __cdecl DECLSPEC_NORETURN _Xout_of_range(const char *str)
 {
+    exception_name name = EXCEPTION_NAME(str);
+    out_of_range e;
+
     TRACE("(%s)\n", debugstr_a(str));
-    throw_exception(EXCEPTION_OUT_OF_RANGE, str);
+
+    MSVCP_out_of_range_ctor(&e, name);
+    _CxxThrowException(&e, &out_of_range_cxx_type);
 }
 
 /* ?_Xruntime_error at std@@YAXPBD at Z */
@@ -1081,11 +1086,6 @@ void throw_exception(exception_type et, const char *str)
         MSVCP_logic_error_ctor(&e, name);
         _CxxThrowException(&e, &logic_error_cxx_type);
     }
-    case EXCEPTION_OUT_OF_RANGE: {
-        out_of_range e;
-        MSVCP_out_of_range_ctor(&e, name);
-        _CxxThrowException(&e, &out_of_range_cxx_type);
-    }
     case EXCEPTION_FAILURE: {
         failure e;
         MSVCP_failure_ctor(&e, name);
diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c
index 0afe394ad2d..116f3c75e5d 100644
--- a/dlls/msvcp90/locale.c
+++ b/dlls/msvcp90/locale.c
@@ -1613,7 +1613,7 @@ ctype_base* __thiscall ctype_base_vector_dtor(ctype_base *this, unsigned int fla
 /* ?_Xran at ctype_base@std@@KAXXZ */
 void __cdecl ctype_base__Xran(void)
 {
-    throw_exception(EXCEPTION_OUT_OF_RANGE, "out of range in ctype<T>");
+    _Xout_of_range("out of range in ctype<T>");
 }
 
 /* ?id@?$ctype at D@std@@2V0locale at 2@A */
diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h
index 3f862f1b2c1..7452a7f6a99 100644
--- a/dlls/msvcp90/msvcp90.h
+++ b/dlls/msvcp90/msvcp90.h
@@ -667,4 +667,5 @@ void WINAPI DECLSPEC_NORETURN _CxxThrowException(void*,const cxx_exception_type*
 void __cdecl DECLSPEC_NORETURN _Xinvalid_argument(const char*);
 void __cdecl DECLSPEC_NORETURN _Xlength_error(const char*);
 void __cdecl DECLSPEC_NORETURN _Xmem(void);
+void __cdecl DECLSPEC_NORETURN _Xout_of_range(const char*);
 void __cdecl DECLSPEC_NORETURN _Xruntime_error(const char*);
diff --git a/dlls/msvcp90/string.c b/dlls/msvcp90/string.c
index 7609f913093..3384069bd03 100644
--- a/dlls/msvcp90/string.c
+++ b/dlls/msvcp90/string.c
@@ -468,10 +468,8 @@ void __thiscall _String_base__Xlen(const void/*_String_base*/ *this)
 /* ?_Xran at _String_base@std@@SAXXZ */
 void CDECL MSVCP__String_base_Xran(void)
 {
-    static const char msg[] = "invalid string position";
-
     TRACE("\n");
-    throw_exception(EXCEPTION_OUT_OF_RANGE, msg);
+    _Xout_of_range("invalid string position");
 }
 
 /* ?_Xran at _String_base@std@@QBEXXZ */




More information about the wine-cvs mailing list