Skip to content

Commit e4cf83c

Browse files
committed
* issue #300: storage class adornments not updated after edits
* dmdserver: fixed a couple of assertions causing the server to restart * dmdserver: replaced new location storage to avoid leaking memory
1 parent fb6450c commit e4cf83c

File tree

9 files changed

+135
-43
lines changed

9 files changed

+135
-43
lines changed

CHANGES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,3 +1414,10 @@ Version history
14141414
* mago: fixed display of AA key in expanded view
14151415
* issue #291: allow overriding the default compiler executable path in the VC project settings
14161416
* issue #296: VC project integration: added support to build for ARM64 with LDC
1417+
1418+
2025-05-01 version 1.4.1-beta2
1419+
* issue #300: storage class adornments not updated after edits
1420+
* issue #301: mago: strip modifier from type before detecting arrays
1421+
* mago: improved stability when displaying arrays from invalid memory address
1422+
* dmdserver: fixed a couple of assertions causing the server to restart
1423+
* dmdserver: replaced new location storage to avoid leaking memory

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#define VERSION_MINOR 4
33
#define VERSION_REVISION 1
44
#define VERSION_BETA -beta
5-
#define VERSION_BUILD 1
5+
#define VERSION_BUILD 2

vdc/dmdserver/dmdinit.d

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ import dmd.dmodule;
2323
import dmd.dstruct;
2424
import dmd.dsymbol;
2525
import dmd.dtemplate;
26+
import dmd.escape;
2627
import dmd.expression;
2728
import dmd.func;
2829
import dmd.globals;
2930
import dmd.id;
3031
import dmd.identifier;
32+
import dmd.location;
3133
import dmd.mtype;
3234
import dmd.objc;
3335
import dmd.rootobject;
@@ -42,6 +44,8 @@ import core.stdc.string;
4244
////////////////////////////////////////////////////////////////
4345
alias countersType = uint[uint]; // actually uint[Key]
4446
alias EscapeInfer = RootObject[int];
47+
enum uint_1 : uint { initValue = 1 }
48+
4549

4650
enum string[2][] dmdStatics =
4751
[
@@ -108,6 +112,7 @@ enum string[2][] dmdStatics =
108112
["_D3dmd7arrayop7arrayOpFCQw10expression6BinExpPSQBt6dscope5ScopeZQByCQCo9dtemplate19TemplateDeclaration", "TemplateDeclaration"],
109113
["_D3dmd6errors18colorHighlightCodeFNbKSQBk6common9outbuffer9OutBufferZ6nestedi", "int"],
110114
["_D3dmd7dmodule6Module18loadCoreStdcConfigFZ16core_stdc_configCQCiQChQCc", "Module"],
115+
// EscapeState.reset not accessible in package dmd
111116
["_D3dmd6escape11EscapeState17scopeInferFailureHiCQBu10rootobject10RootObject", "EscapeInfer" ],
112117
];
113118

@@ -135,7 +140,7 @@ string genInitDmdStatics()
135140
{
136141
string s;
137142
foreach (decl; dmdStatics)
138-
s ~= cmangled(decl[0]) ~ " = " ~ decl[1] ~ ".init;\n";
143+
s ~= cmangled(decl[0]) ~ " = (" ~ decl[1] ~ ").init;\n";
139144
return s;
140145
}
141146

@@ -197,6 +202,7 @@ void dmdInit()
197202
//Token._init();
198203
Id.initialize();
199204
Expression._init();
205+
location_init();
200206

201207
target._init(global.params); // needed by Type._init
202208
Type._init();

vdc/dmdserver/dmdserver.d

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ class DMDServer : ComObject, IVDServer
840840
*types = allocBSTR("__pending__");
841841
return S_OK;
842842
}
843-
version(DebugServer) if(dbgfh) dbglog("GetIdentifierTypesResult: " ~ firstLine(mLastReferences) ~ "...");
843+
version(DebugServer) if(dbgfh) dbglog("GetIdentifierTypesResult: " ~ firstLine(mLastIdentifierTypes) ~ "...");
844844
*types = allocBSTR(mLastIdentifierTypes);
845845
return S_OK;
846846
}
@@ -855,14 +855,20 @@ class DMDServer : ComObject, IVDServer
855855
{
856856
md = findModule(fname, false);
857857
if (!md || !md.analyzedModule)
858+
{
859+
version(DebugServer) if(dbgfh) dbglog("GetParameterStorageLocs: " ~ fname ~ " not found");
858860
return S_FALSE;
861+
}
859862
}
860863

861864
auto stcLoc = findParameterStorageClass(md.analyzedModule);
862865

863866
SAFEARRAY *sa = SafeArrayCreateVector(VT_INT, 0, 3 * cast(ULONG) stcLoc.length);
864867
if(!sa)
868+
{
869+
version(DebugServer) if(dbgfh) dbglog("GetParameterStorageLocs: " ~ fname ~ " out of memory (" ~ to!string(stcLoc.length) ~ " entries)");
865870
return E_OUTOFMEMORY;
871+
}
866872

867873
for(LONG index = 0; index < stcLoc.length; index++)
868874
{
@@ -877,6 +883,7 @@ class DMDServer : ComObject, IVDServer
877883
SafeArrayPutElement(sa, &idx, &value);
878884
}
879885

886+
version(DebugServer) if(dbgfh) dbglog("GetParameterStorageLocs: " ~ fname ~ " OK (" ~ to!string(stcLoc.length) ~ " entries)");
880887
locs.vt = VT_ARRAY | VT_INT;
881888
locs.parray = sa;
882889
return S_OK;

vdc/dmdserver/dmdserver.visualdproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@
24062406
<File path="dmd\compiler\src\dmd\libmscoff.d" tool="None" />
24072407
<File path="dmd\compiler\src\dmd\libomf.d" tool="None" />
24082408
<File path="dmd\compiler\src\dmd\link.d" tool="None" />
2409-
<File path="dmd\compiler\src\dmd\location.d" />
2409+
<File path="dmd\compiler\src\dmd\location.d" tool="None" />
24102410
<File path="dmd\compiler\src\dmd\mars.d" tool="None" />
24112411
<File path="dmd\compiler\src\dmd\mtype.d" />
24122412
<File path="dmd\compiler\src\dmd\mustuse.d" />
@@ -2455,6 +2455,7 @@
24552455
<File path="dmderrors.d" />
24562456
<File path="dmdinit.d" />
24572457
<File path="dmdlib.d" />
2458+
<File path="dmdlocation.d" />
24582459
<File path="dmdrmem.d" />
24592460
<File path="dmdserver.d" />
24602461
<File customcmd="if exist &quot;$(VSINSTALLDIR)\Common7\Tools\vsvars32.bat&quot; call &quot;$(VSINSTALLDIR)\Common7\Tools\vsvars32.bat&quot;

vdc/dmdserver/semanalysis.d

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import vdc.ivdserver;
1616
import dmd.arraytypes;
1717
import dmd.cond;
1818
import dmd.dmodule;
19+
import dmd.dsymbol;
1920
import dmd.dsymbolsem;
2021
import dmd.errors;
2122
import dmd.globals;
@@ -225,6 +226,14 @@ Module analyzeModule(Module parsedModule, const ref Options opts)
225226
return Module.rootModule;
226227
}
227228

229+
debug
230+
{
231+
auto __debugOverview(Identifier id) => id ? id.toString : null;
232+
auto __debugOverview(Dsymbol s) => s && s.ident ? s.ident.toString : null;
233+
auto __debugOverview(ref const Loc loc) => loc.toChars();
234+
auto __debugExpanded(ref const Loc loc) => loc.toChars();
235+
}
236+
228237
////////////////////////////////////////////////////////////////
229238
version (traceGC) import tracegc;
230239

@@ -1944,6 +1953,19 @@ void do_unittests()
19441953
assert_equal(stcpos[1], ParameterStorageClassPos(1, 12, 11));
19451954
assert_equal(stcpos[2], ParameterStorageClassPos(2, 13, 12));
19461955
assert_equal(stcpos[3], ParameterStorageClassPos(0, 14, 11));
1956+
1957+
// extracted from regex.d, caused an assertion in dinterpret.d
1958+
// because the type must not be saved to TemplateValueParameter.specValue
1959+
source = q{
1960+
enum IR { End }
1961+
static op(int code:IR.End)() {}
1962+
1963+
void foo()
1964+
{
1965+
op!(0);
1966+
}
1967+
};
1968+
m = checkErrors(source, "");
19471969
}
19481970

19491971
unittest
@@ -2176,6 +2198,19 @@ void test_ana_dmd()
21762198
writeln(GC.stats);
21772199
}
21782200
test_leaks();
2201+
2202+
void test_std()
2203+
{
2204+
bool dump = false;
2205+
string source = q{
2206+
import std;
2207+
void main() {
2208+
auto re = regex(`([0-9]+)\.([0-9]+)(\.([0-9]+))?([-\.]?([abr])?[a-z]*[-\.]?([0-9]*))?`);
2209+
}
2210+
};
2211+
Module m = checkErrors(source, "");
2212+
}
2213+
test_std();
21792214
}
21802215

21812216
unittest

vdc/dmdserver/semvisitor.d

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ RootObject _findAST(Dsymbol sym, const(char*) filename, int startLine, int start
10911091

10921092
RootObject findAST(Module mod, int startLine, int startIndex, int endLine, int endIndex)
10931093
{
1094-
auto filename = mod.srcfile.toChars();
1094+
auto filename = mod.srcfile.toString().toLocFilename.ptr;
10951095
return _findAST(mod, filename, startLine, startIndex, endLine, endIndex);
10961096
}
10971097

@@ -1524,7 +1524,7 @@ string findTip(Module mod, int startLine, int startIndex, int endLine, int endIn
15241524
showSizeAndAlignment = addsize;
15251525
scope(exit) showSizeAndAlignment = false; // tips also used by findExpansions
15261526

1527-
auto filename = mod.srcfile.toChars();
1527+
auto filename = mod.srcfile.toString().toLocFilename.ptr;
15281528
scope FindTipVisitor ftv = new FindTipVisitor(filename, startLine, startIndex, endLine, endIndex);
15291529
mod.accept(ftv);
15301530

@@ -1606,7 +1606,7 @@ extern(C++) class FindDefinitionVisitor : FindASTVisitor
16061606

16071607
string findDefinition(Module mod, ref int line, ref int index)
16081608
{
1609-
auto filename = mod.srcfile.toChars();
1609+
auto filename = mod.srcfile.toString().toLocFilename.ptr;
16101610
scope FindDefinitionVisitor fdv = new FindDefinitionVisitor(filename, line, index, line, index + 1);
16111611
mod.accept(fdv);
16121612

@@ -1647,7 +1647,7 @@ Loc[] findBinaryIsInLocations(Module mod)
16471647
}
16481648

16491649
scope BinaryIsInVisitor biiv = new BinaryIsInVisitor;
1650-
biiv.filename = mod.srcfile.toChars();
1650+
biiv.filename = mod.srcfile.toString().toLocFilename.ptr;
16511651
biiv.unconditional = true;
16521652
mod.accept(biiv);
16531653

@@ -1676,6 +1676,8 @@ FindIdentifierTypesResult findIdentifierTypes(Module mod)
16761676
extern(D)
16771677
final void addTypePos(const(char)[] ident, int type, int line, int col)
16781678
{
1679+
if (line <= 0)
1680+
return; // not visible
16791681
if (auto pid = ident in idTypes)
16801682
{
16811683
// merge sorted
@@ -2003,7 +2005,7 @@ FindIdentifierTypesResult findIdentifierTypes(Module mod)
20032005
}
20042006

20052007
scope IdentifierTypesVisitor itv = new IdentifierTypesVisitor;
2006-
itv.filename = mod.srcfile.toChars();
2008+
itv.filename = mod.srcfile.toString().toLocFilename.ptr;
20072009
mod.accept(itv);
20082010

20092011
return itv.idTypes;
@@ -2085,7 +2087,7 @@ ParameterStorageClassPos[] findParameterStorageClass(Module mod)
20852087
}
20862088

20872089
scope psv = new ParameterStorageClassVisitor;
2088-
psv.filename = mod.srcfile.toChars();
2090+
psv.filename = mod.srcfile.toString().toLocFilename.ptr;
20892091
mod.accept(psv);
20902092

20912093
return psv.stcPos;
@@ -2100,7 +2102,7 @@ struct Reference
21002102

21012103
Reference[] findReferencesInModule(Module mod, int line, int index)
21022104
{
2103-
auto filename = mod.srcfile.toChars();
2105+
auto filename = mod.srcfile.toString().toLocFilename.ptr;
21042106
scope FindDefinitionVisitor fdv = new FindDefinitionVisitor(filename, line, index, line, index + 1);
21052107
mod.accept(fdv);
21062108

@@ -2118,7 +2120,7 @@ Reference[] findReferencesInModule(Module mod, int line, int index)
21182120
extern(D)
21192121
void addReference(ref const Loc loc, Identifier ident)
21202122
{
2121-
if (loc.filename is filename && ident)
2123+
if (loc.filename is filename && ident && loc.linnum > 0)
21222124
if (!references.contains(Reference(loc, ident)))
21232125
references ~= Reference(loc, ident);
21242126
}
@@ -2510,15 +2512,8 @@ extern(C++) class FindExpansionsVisitor : FindASTVisitor
25102512
override void visit(DotIdExp de)
25112513
{
25122514
if (!found && de.ident)
2513-
{
25142515
if (matchDotIdentifier(de.dotloc, de.identloc, de.ident))
2515-
{
2516-
if (!de.type && de.resolvedTo && !de.resolvedTo.isErrorExp())
2517-
foundResolved(de.resolvedTo);
2518-
else
2519-
foundNode(de);
2520-
}
2521-
}
2516+
foundNode(de);
25222517
}
25232518

25242519
override void checkScope(ScopeDsymbol sc)
@@ -2542,7 +2537,7 @@ extern(C++) class FindExpansionsVisitor : FindASTVisitor
25422537

25432538
string[] findExpansions(Module mod, int line, int index, string tok)
25442539
{
2545-
auto filename = mod.srcfile.toChars();
2540+
auto filename = mod.srcfile.toString().toLocFilename.ptr;
25462541
scope FindExpansionsVisitor fdv = new FindExpansionsVisitor(filename, line, index, line, index + 1);
25472542
mod.accept(fdv);
25482543

@@ -2584,6 +2579,13 @@ string[] findExpansions(Module mod, int line, int index, string tok)
25842579
if (auto t = getType(e, false))
25852580
type = t;
25862581
}
2582+
if (!type)
2583+
if (auto sym = fdv.found ? fdv.found.isDsymbol() : null)
2584+
if (auto em = sym.isEnumMember())
2585+
type = em.ed.type;
2586+
2587+
if (type && type.isTypeEnum())
2588+
flags |= SearchOpt.localsOnly;
25872589

25882590
auto sds = fdv.foundScope;
25892591
if (type)

0 commit comments

Comments
 (0)