[cfe-dev] RefactoringTool - set output file path?

Gabor Kozar kozargabor at gmail.com
Tue Mar 31 17:15:46 PDT 2015


Thank you very much for your help, that's indeed what I was looking for!

---
Best regards,

Gábor 'ShdNx' Kozár http://gaborkozar.me



On Sun, Mar 29, 2015, at 03:36, Manuel Klimek wrote:
> On Sat, Mar 28, 2015 at 10:19 AM Gabor Kozar
> <kozargabor at gmail.com> wrote:
>>> Otherwise, you can write out the modified files in whatever way
>>> you want.
>>
>> I
 cannot find any way to do that, nor the RefactoringTool, nor the
 Rewriter classes seem to expose any functionality at all to write the
 modified files anywhere else. How should I go about this (without
 modifying clang itself)?
>
> Look at
> http://reviews.llvm.org/diffusion/L/browse/clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp;233488$143
> The Rewriter basically does everything in-memory. In the end, you can
> take the buffer, and write it to whereever you like (in clang-rename's
> example it writes optionally to stdout)
>
>>
>>
>>> Usually what people want to do is to write the diffs / changes out,
>>> instead of the modified files, in that case...
>>
>> I need to specifically write out the modified files.
>>
>>> Do you need to instrument the /source code/ in particular?
>>
>> Unfortunately, I do, because I work in an environment where we cannot
>> compile using clang, only GCC. The reasons for this are...
>> interesting, at best, but unfortunately this is what I have to work.
>> I agree with you though, IR-level instrumentation is obviously a much
>> better idea... one that's not feasible in my situation.
>>
>> ---
>> Best regards,
>>
>> Gábor 'ShdNx' Kozár http://gaborkozar.me
>>
>>
>>
>> On Mon, Mar 16, 2015, at 15:59, David Blaikie wrote:
>>>
>>>
>>> On Sat, Mar 14, 2015 at 4:52 AM, Gabor Kozar <kozargabor at gmail.com>
>>> wrote:
>>>> __
>>>> I'm working on a clang tool that instruments source code.
>>>
>>> Do you need to instrument the /source code/ in particular? The usual
>>> approach with other instrumentation (sanitizers, code coverage, etc)
>>> is just to instrument the resulting binary (by instrumenting the
>>> LLVM IR generated by the frontend - usually during IR generation in
>>> the frontend (Clang, most often)) rather than mutating the source
>>> (or generating a mutated copy of the source) & then compiling that.
>>>
>>> The refactoring tools are really focussed on the scenario of
>>> refactoring - where you actually want to modify the original source.
>>> (not that they can't be used for other things, just that they might
>>> not be the best tool for the job)
>>>
>>>> However, I can't seem to find any option to set the output file
>>>> path, i.e. my tool will always modify the original file, which is
>>>> not what I want.
>>>>
>>>> Was this a deliberate decision, or am I just missing something?
>>>>
>>>> ---
>>>> Best regards,
>>>>
>>>> Gábor 'ShdNx' Kozár http://gaborkozar.me
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> cfe-dev mailing list cfe-dev at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>>>
>>>
>>
>> _________________________________________________
>>
cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/__mailman/listinfo/cfe-dev

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


More information about the cfe-dev mailing list