how to instrument dmd compiler to dump all references to a given symbol?
Adam D. Ruppe
destructionator at gmail.com
Sun Jan 14 02:42:09 UTC 2018
On Sunday, 14 January 2018 at 02:36:02 UTC, Timothee Cour wrote:
> how to instrument dmd compiler to dump all references to a
> given symbol?
you can actually do it with your own code. behold:
struct A{
//int a; // comment this line
int _a; // make the actual var renamed...
// then add a ref property with template file/line params
@property ref int a(string file = __FILE__, size_t line =
__LINE__)() {
pragma(msg, file); // and print those out
pragma(msg, line);
return _a;
}
void fun(){
a++; // HERE
alias b=a;
b++; // HERE
}
}
void fun(){
int a; // NOT HERE
A b;
b.a ++ ; // HERE
}
Can be a bit trickier in other cases but there's a compile time
list of uses.
More information about the Digitalmars-d
mailing list