[cfe-dev] How to rewrite a header file?

Miklos Vajna via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 8 00:11:32 PDT 2017


Hi Marcel,

On Thu, Sep 07, 2017 at 03:03:12PM +0200, Marcel Schaible <marcel at schaible-consulting.de> wrote:
> thanks for your hint. What do you mean by "Rewriting in header files
> happens out of the box..."?
> 
> When I rewrite with my tools some definition in a header file I'll get
> an error message from the rewriter:
> 
> <<<INVALID SOURCE LOCATION >>>

My guess is this has little to do with header files. Invalid location
can be also a result of something else. Try to print out the
filename/line/col values for the locations and offsets, hopefully
that'll lead to the place where you first get an invalid location.

Also, as a first iteration try to avoid macros. :-) Rewriting inside
macros is tricky, but your intention is to just rewrite inside header
files AIUI. In general, it might be a good idea to read the source of
e.g. clang-rename (or some other clang-provided rewriting tool) to see
how rewriting (in header files) works.

Regards,

Miklos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170908/886d608e/attachment.sig>


More information about the cfe-dev mailing list