[LLVMdev] Can I use Clang to parse snippets of C++ code?

Reid Kleckner reid.kleckner at gmail.com
Mon Feb 21 18:45:33 PST 2011


The semantics of C++ depend heavily on what comes before the given
fragment.  How do you plan to address this?  For example, if you know
all the headers you think these snippets will include, you can do
something similar to PCH to parse the fragment in context of all of
the headers.

I don't know much about feeding clang buffers instead of files, but I
believe it can be done with some of the "virtual" file suport that has
been added recently.

Reid

2011/2/21 Félix Cloutier <felixcca at yahoo.ca>:
> Hello guys,
>
> I'd like to use Clang to parse snippets of (and emit bytecode for) C++ code that come from larger files that don't contain only C++, but looking at the clang interpreter example, either I didn't get it, or it looks like the driver expects only files, and not strings or char buffers.
>
> Is there a simple way to achieve this? Do I have to split my input into small files and pass them to clang, or is there a better way?
>
> Félix
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list