[cfe-dev] Implementing __builtin_LINE(x) using a clang plugin

Blaise Tine via cfe-dev cfe-dev at lists.llvm.org
Sun Dec 22 00:17:23 PST 2019

Hi all,
I have  C++ DSL that defines its own primitive types and operators and I want to provide some debugging facilities during compilation to display the source location (filename, line number) for uninitialized DSL objects.To capture the source line information for a given DSL object, I'm using __builtin_LINE(x) inside the class constructor, where 'x' is the function nesting depth (see below).I would like to implement this functionality using a clang plugging such that the feature is automatically used during compilation.I don't know if this is feasible with the current Clang plugin API.I was wondering someone has some experience with the plugin and how this can be done.Thank you so much.
eg: DSLObject  myobj;

class DSLObject {public:    DSLObject() {        lineno_ = __builtin_LINE(1);
    }private:    int lineno_;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191222/82efac15/attachment.html>

More information about the cfe-dev mailing list