[cfe-users] Compile from source code string

0dminnimda via cfe-users cfe-users at lists.llvm.org
Wed Jan 19 12:15:41 PST 2022


Right now I'm in process of trying this approach:
Copy the code from cc1_main, write my own SourceManager and set it to
CompilerInstance with setSourceManager().


On Wed, Jan 19, 2022, 7:45 PM Matthew Fernandez <matthew.fernandez at gmail.com>
wrote:

>
> > On Jan 17, 2022, at 21:59, 0dminnimda <0dminnimda at gmail.com> wrote:
> >
> > > The phrase “clang api” is a bit vague (libclang?)
> >
> > If it's possible, then of course LibClang as it's backward compatible,
> but I know that it's restricted in functionality, so if LibClang don't give
> such freedom, then LibTooling.
> >
> > > $ echo 'int main(void) { return 0; }' | clang -x c -
> >
> > Thanks for the advice! This should work on unix, but what's about other
> systems? That's why I wanted to go with code, because I target at least
> Linux, Macos and Windows, and with code solution it'll be no different to
> support all of them as well as it'll be bit more secure, I think.
>
> I can’t see anything promising in libclang, but maybe runToolOnCode in
> libtooling might achieve what you’re after.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20220119/44480880/attachment.html>


More information about the cfe-users mailing list