[LLVMdev] Can I use Clang to parse snippets of C++ code?
Chris Lattner
clattner at apple.com
Mon Feb 21 20:35:55 PST 2011
On Feb 21, 2011, at 6:31 PM, FĂ©lix Cloutier wrote:
> 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?
It depends on exactly what you're trying to achieve. LLDB uses clang to parse individual expressions, and does this by hooking into various name lookup routines to dynamically/lazily populate symbol tables from debug info.
This is all possible, but it's a nontrivial amount of work.
-Chris
More information about the llvm-dev
mailing list