[cfe-dev] Generating C++ with Sourcemaps

Timothy Baldridge via cfe-dev cfe-dev at lists.llvm.org
Thu Apr 6 10:17:44 PDT 2017


Um....wow....thats perfect. Learn something new every day.

On Thu, Apr 6, 2017 at 10:55 AM, Jonathan Roelofs <jonathan at codesourcery.com
> wrote:

>
>
> On 4/6/17 10:48 AM, Timothy Baldridge via cfe-dev wrote:
>
>> Apologies if this is the wrong mailing list.
>>
>> I'm looking to generate some C++ from another set of input files. Now in
>> a perfect world I'd love to get line numbers and source references that
>> link back to my input files, and not to the C++ files. Think of
>> something like Cython in Python. It translates Python to C, but all the
>> error messages point back to Python.
>>
>> I can think of two main ways to do this via libclang, and perhaps both
>> of them are bad ideas, so I'm open to more options:
>>
>> A) I could parse my input files and build up libclang ASTs, I could then
>> compile these ASTs via clang and then run those ASTs through the normal
>> optimization/code emission passes.
>>
>> B) I could compile my own version of clang that accepted an external
>> "sourcemap" file. This file would be used to replace the data held in
>> the SourceManager code with other filenames/offsets.
>>
>> C) Some other option I haven't thought of?
>>
>
> Have you considered emitting your C with #line directives that correspond
> to the python?
>
> https://gcc.gnu.org/onlinedocs/cpp/Line-Control.html
>
>
> Jon
>
>
>> So any thoughts as to the best way to go about this?
>>
>> Thanks,
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>>
> --
> Jon Roelofs
> jonathan at codesourcery.com
> CodeSourcery / Mentor Embedded / Siemens
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170406/7c246ad9/attachment.html>


More information about the cfe-dev mailing list