@@ -50,7 +50,7 @@ private struct Demangle(Hooks = NoHooks)
50
50
// allocation during the course of a parsing run, this is still
51
51
// faster than assembling the result piecemeal.
52
52
53
- pure :
53
+ pure @safe :
54
54
enum AddType { no, yes }
55
55
56
56
98
98
}
99
99
100
100
101
- static void error ( string msg = " Invalid symbol" )
101
+ static void error ( string msg = " Invalid symbol" ) @trusted /* exception only used in module */
102
102
{
103
103
// throw new ParseException( msg );
104
104
debug (info) printf( " error: %.*s\n " , cast (int ) msg.length, msg.ptr );
@@ -108,7 +108,7 @@ pure:
108
108
}
109
109
110
110
111
- static void overflow ( string msg = " Buffer overflow" )
111
+ static void overflow ( string msg = " Buffer overflow" ) @trusted /* exception only used in module */
112
112
{
113
113
// throw new OverflowException( msg );
114
114
debug (info) printf( " overflow: %.*s\n " , cast (int ) msg.length, msg.ptr );
@@ -161,7 +161,7 @@ pure:
161
161
// ////////////////////////////////////////////////////////////////////////
162
162
163
163
164
- static bool contains ( const (char )[] a, const (char )[] b )
164
+ static bool contains ( const (char )[] a, const (char )[] b ) @trusted
165
165
{
166
166
if (a.length && b.length)
167
167
{
@@ -183,7 +183,7 @@ pure:
183
183
184
184
if (len + val.length > dst.length)
185
185
overflow();
186
- size_t v = val.ptr - dst.ptr ;
186
+ size_t v = & val[ 0 ] - & dst[ 0 ] ;
187
187
dst[len .. len + val.length] = val[];
188
188
for (size_t p = v; p < len; p++ )
189
189
dst[p] = dst[p + val.length];
@@ -201,7 +201,7 @@ pure:
201
201
assert ( contains( dst[0 .. len], val ) );
202
202
debug (info) printf( " removing (%.*s)\n " , cast (int ) val.length, val.ptr );
203
203
204
- size_t v = val.ptr - dst.ptr ;
204
+ size_t v = & val[ 0 ] - & dst[ 0 ] ;
205
205
for (size_t p = v; p < len; p++ )
206
206
dst[p] = dst[p + val.length];
207
207
len -= val.length;
@@ -217,7 +217,7 @@ pure:
217
217
assert ( ! contains( dst[0 .. len], val ) );
218
218
debug (info) printf( " appending (%.*s)\n " , cast (int ) val.length, val.ptr );
219
219
220
- if ( dst.ptr + len == val.ptr &&
220
+ if ( & dst[ len] == & val[ 0 ] &&
221
221
dst.length - len >= val.length )
222
222
{
223
223
// data is already in place
@@ -532,7 +532,7 @@ pure:
532
532
533
533
tbuf[tlen] = 0 ;
534
534
debug (info) printf( " got (%s)\n " , tbuf.ptr );
535
- pureReprintReal( tbuf.ptr, tbuf.length );
535
+ pureReprintReal( tbuf[] );
536
536
debug (info) printf( " converted (%.*s)\n " , cast (int ) tlen, tbuf.ptr );
537
537
put( tbuf[0 .. tlen] );
538
538
}
@@ -813,7 +813,7 @@ pure:
813
813
auto beg = len;
814
814
auto t = front;
815
815
816
- char [] parseBackrefType (scope char [] delegate () pure parseDg) pure
816
+ char [] parseBackrefType (scope char [] delegate () pure @safe parseDg) pure @safe
817
817
{
818
818
if (pos == brp)
819
819
error(" recursive back reference" );
@@ -1977,15 +1977,19 @@ pure:
1977
1977
dst[0 .. buf.length] = buf[];
1978
1978
return dst[0 .. buf.length];
1979
1979
}
1980
+ catch ( Exception e )
1981
+ {
1982
+ assert ( false ); // no other exceptions thrown
1983
+ }
1980
1984
}
1981
1985
}
1982
1986
1983
- char [] demangleName ()
1987
+ char [] demangleName () nothrow
1984
1988
{
1985
1989
return doDemangle! parseMangledName();
1986
1990
}
1987
1991
1988
- char [] demangleType ()
1992
+ char [] demangleType () nothrow
1989
1993
{
1990
1994
return doDemangle! parseType();
1991
1995
}
@@ -2004,7 +2008,7 @@ pure:
2004
2008
* The demangled name or the original string if the name is not a mangled D
2005
2009
* name.
2006
2010
*/
2007
- char [] demangle ( const (char )[] buf, char [] dst = null )
2011
+ char [] demangle ( const (char )[] buf, char [] dst = null ) nothrow pure @safe
2008
2012
{
2009
2013
// return Demangle(buf, dst)();
2010
2014
auto d = Demangle! ()(buf, dst);
@@ -2023,7 +2027,7 @@ char[] demangle( const(char)[] buf, char[] dst = null )
2023
2027
* The demangled type name or the original string if the name is not a
2024
2028
* mangled D type.
2025
2029
*/
2026
- char [] demangleType ( const (char )[] buf, char [] dst = null )
2030
+ char [] demangleType ( const (char )[] buf, char [] dst = null ) nothrow pure @safe
2027
2031
{
2028
2032
auto d = Demangle! ()(buf, dst);
2029
2033
return d.demangleType();
@@ -2055,7 +2059,7 @@ char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
2055
2059
}
2056
2060
Replacement [] replacements;
2057
2061
2058
- pure :
2062
+ pure @safe :
2059
2063
size_t positionInResult (size_t pos)
2060
2064
{
2061
2065
foreach_reverse (r; replacements)
@@ -2186,7 +2190,7 @@ char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
2186
2190
d.mute = true ; // no demangled output
2187
2191
try
2188
2192
{
2189
- () @trusted { d.parseMangledName(); } ();
2193
+ d.parseMangledName();
2190
2194
if (d.hooks.lastpos < d.pos)
2191
2195
d.hooks.result ~= d.buf[d.hooks.lastpos .. d.pos];
2192
2196
return d.hooks.result;
@@ -2267,14 +2271,14 @@ char[] mangle(T)(const(char)[] fqn, char[] dst = null) @safe pure nothrow
2267
2271
2268
2272
2269
2273
// /
2270
- unittest
2274
+ @safe pure nothrow unittest
2271
2275
{
2272
2276
assert (mangle! int (" a.b" ) == " _D1a1bi" );
2273
2277
assert (mangle! (char [])(" test.foo" ) == " _D4test3fooAa" );
2274
2278
assert (mangle! (int function (int ))(" a.b" ) == " _D1a1bPFiZi" );
2275
2279
}
2276
2280
2277
- unittest
2281
+ @safe pure nothrow unittest
2278
2282
{
2279
2283
static assert (mangle! int (" a.b" ) == " _D1a1bi" );
2280
2284
@@ -2325,7 +2329,7 @@ char[] mangleFunc(T:FT*, FT)(const(char)[] fqn, char[] dst = null) @safe pure no
2325
2329
private enum hasTypeBackRef = (int function (void ** ,void ** )).mangleof[$- 4 .. $] == " QdZi" ;
2326
2330
2327
2331
// /
2328
- unittest
2332
+ @safe pure nothrow unittest
2329
2333
{
2330
2334
assert (mangleFunc! (int function (int ))(" a.b" ) == " _D1a1bFiZi" );
2331
2335
static if (hasTypeBackRef)
@@ -2344,7 +2348,7 @@ unittest
2344
2348
assert (reencodeMangled(" _D3std4conv4conv7__T3std4convi" ) == " _D3std4convQf7__T3stdQpi" );
2345
2349
}
2346
2350
2347
- unittest
2351
+ @safe pure nothrow unittest
2348
2352
{
2349
2353
int function (lazy int [], ... ) fp;
2350
2354
assert (mangle! (typeof (fp))(" demangle.test" ) == " _D8demangle4testPFLAiYi" );
@@ -2368,7 +2372,7 @@ private template hasPlainMangling(FT) if (is(FT == function))
2368
2372
enum hasPlainMangling = c == ' U' || c == ' V' || c == ' W' ;
2369
2373
}
2370
2374
2371
- unittest
2375
+ @safe pure nothrow unittest
2372
2376
{
2373
2377
static extern (D) void fooD();
2374
2378
static extern (C) void fooC();
@@ -2533,7 +2537,7 @@ version(unittest)
2533
2537
alias Seq! (staticIota! (x - 1 ), x - 1 ) staticIota;
2534
2538
}
2535
2539
}
2536
- unittest
2540
+ @safe pure nothrow unittest
2537
2541
{
2538
2542
foreach ( i, name; table )
2539
2543
{
@@ -2553,7 +2557,7 @@ unittest
2553
2557
/*
2554
2558
*
2555
2559
*/
2556
- string decodeDmdString ( const (char )[] ln, ref size_t p )
2560
+ string decodeDmdString ( const (char )[] ln, ref size_t p ) nothrow pure @safe
2557
2561
{
2558
2562
string s;
2559
2563
uint zlen, zpos;
@@ -2598,19 +2602,17 @@ string decodeDmdString( const(char)[] ln, ref size_t p )
2598
2602
// locally purified for internal use here only
2599
2603
extern (C ) private
2600
2604
{
2601
- pure @trusted @nogc nothrow pragma (mangle, " fakePureReprintReal" ) real pureReprintReal(char * nptr, size_t len );
2605
+ pure @trusted @nogc nothrow pragma (mangle, " fakePureReprintReal" ) void pureReprintReal(char [] nptr);
2602
2606
2603
- char * fakePureReprintReal (char * nptr, size_t len )
2607
+ void fakePureReprintReal (char [] nptr)
2604
2608
{
2605
2609
import core.stdc.stdlib : strtold;
2606
2610
import core.stdc.stdio : snprintf;
2607
2611
import core.stdc.errno : errno;
2608
2612
2609
2613
const err = errno;
2610
- real val = strtold(nptr, null );
2611
- len = snprintf(nptr, len , " %#Lg" , val);
2614
+ real val = strtold(nptr.ptr , null );
2615
+ snprintf(nptr.ptr, nptr.length , " %#Lg" , val);
2612
2616
errno = err;
2613
-
2614
- return nptr;
2615
2617
}
2616
2618
}
0 commit comments