Skip to content

Commit f0bc0d9

Browse files
committed
Merge commit '162a5fb'
2 parents 15c780f + 162a5fb commit f0bc0d9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/analysis/run.d

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,21 @@ const(Module) parseModule(string fileName, ubyte[] code, RollbackAllocator* p,
199199
MessageSet analyze(string fileName, const Module m, const StaticAnalysisConfig analysisConfig,
200200
ref ModuleCache moduleCache, const(Token)[] tokens, bool staticAnalyze = true)
201201
{
202+
import dsymbol.symbol : DSymbol;
203+
202204
if (!staticAnalyze)
203205
return null;
204206

205-
auto symbolAllocator = new ASTAllocator;
207+
auto symbolAllocator = scoped!ASTAllocator();
206208
auto first = scoped!FirstPass(m, internString(fileName), symbolAllocator,
207209
symbolAllocator, true, &moduleCache, null);
208210
first.run();
209211

210212
secondPass(first.rootSymbol, first.moduleScope, moduleCache);
211-
typeid(SemanticSymbol).destroy(first.rootSymbol);
212-
const(Scope)* moduleScope = first.moduleScope;
213-
213+
auto moduleScope = first.moduleScope;
214+
scope(exit) typeid(DSymbol).destroy(first.rootSymbol.acSymbol);
215+
scope(exit) typeid(SemanticSymbol).destroy(first.rootSymbol);
216+
scope(exit) typeid(Scope).destroy(first.moduleScope);
214217
BaseAnalyzer[] checks;
215218

216219
if (analysisConfig.asm_style_check)

src/main.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import std.path;
1414
import std.stdio;
1515
import std.range;
1616
import std.experimental.lexer;
17+
import std.typecons : scoped;
1718
import dparse.lexer;
1819
import dparse.parser;
1920
import dparse.rollback_allocator;
@@ -138,7 +139,8 @@ else
138139
const(string[]) absImportPaths = importPaths.map!(a => a.absolutePath()
139140
.buildNormalizedPath()).array();
140141

141-
auto moduleCache = ModuleCache(new dsymbol.modulecache.ASTAllocator);
142+
auto alloc = scoped!(dsymbol.modulecache.ASTAllocator)();
143+
auto moduleCache = ModuleCache(alloc);
142144

143145
if (absImportPaths.length)
144146
moduleCache.addImportPaths(absImportPaths);

0 commit comments

Comments
 (0)