digitalmars.D - how to instrument dmd compiler to dump all references to a given
- Timothee Cour (19/19) Jan 13 2018 eg:
- Adam D. Ruppe (25/27) Jan 13 2018 you can actually do it with your own code. behold:
- Shachar Shemesh (12/20) Jan 13 2018 It wouldn't catch this use:
- Seb (5/25) Jan 13 2018 I don't know what you are trying to achieve, but `deprecated`
eg: how to instrument dmd compiler to dump all references to a given symbol? eg: for `A.a` it should output the locations marked with HERE any help/starting points would be appreciated! ``` Struct A{ int a; void fun(){ a++; // HERE alias b=a; b++; // HERE } } void fun(){ int a; // NOT HERE A b; b.a ++ ; // HERE } ```
Jan 13 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.
Jan 13 2018
On 14/01/18 04:42, Adam D. Ruppe wrote:On Sunday, 14 January 2018 at 02:36:02 UTC, Timothee Cour wrote:It wouldn't catch this use: auto hiddenUser(T)(T t) { static if( __traits(hasMember, T, "a") ) { return T.a; } else { return 17; } } ... A var; hiddenUser(var);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...
Jan 13 2018
On Sunday, 14 January 2018 at 02:36:02 UTC, Timothee Cour wrote:eg: how to instrument dmd compiler to dump all references to a given symbol? eg: for `A.a` it should output the locations marked with HERE any help/starting points would be appreciated! ``` Struct A{ int a; void fun(){ a++; // HERE alias b=a; b++; // HERE } } void fun(){ int a; // NOT HERE A b; b.a ++ ; // HERE } ```I don't know what you are trying to achieve, but `deprecated` could work for you. At least it's an easy way to get all locations using a symbol: https://run.dlang.io/is/ICv9lH
Jan 13 2018