Skip to content

Instantly share code, notes, and snippets.

Created October 3, 2014 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/dc0000d3b801a7bedff0 to your computer and use it in GitHub Desktop.
Save anonymous/dc0000d3b801a7bedff0 to your computer and use it in GitHub Desktop.
GC warnings processing script for DMD.
import std.stdio, std.string, std.regex, std.algorithm, std.range;
struct Result{
string file, line, reason;
}
void main(){
auto re = regex(`(.*\\\w+)\.d\((\d+)\):\s*vgc:\s*(.*)`);
//writeln(`std\variant.d(236): vgc: 'new' causes GC allocation`.match(re));
Result[] results;
foreach(line; stdin.byLine){
auto m = line.idup.matchFirst(re);
if(m){
results ~= Result(m[1].replace("\\", "/"), m[2], m[3]);
}
}
sort!((a,b) => a.file < b.file && a.line < b.line)(results);
results = uniq(results).array;
string linkTempalte =
`[%s:L%s](https://github.com/D-Programming-Language/phobos/blob/master/%s.d#L%s)`;
writeln("|module| function |reason|action|");
writeln("|------|----------|------|------|");
foreach(r; results){
//writeln(r.file, ",", r.line, ",", r.reason);
auto mod = r.file.replace("/", ".");
auto link = format(linkTempalte, mod, r.line, r.file, r.line);
writefln("| %s | | %s | |", link, r.reason,);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment