[cfe-dev] Looking up names after parsing
Chandler Carruth
chandlerc at google.com
Sun Nov 6 13:15:03 PST 2011
On Sun, Nov 6, 2011 at 8:35 AM, Abramo Bagnara <abramo.bagnara at gmail.com>wrote:
> b) NamedDecl* from string "ns::v" (or NULL if this is not parsable)
>
> What's the Right(TM) way to do that using clang library?
>
At least for this last case, there is a DeclContext for the translation
unit, and all DeclContext's have a 'lookup' method. For the more complex
cases, I would look at how Sema and other parts of Clang use the lookup
method and their surrounding code.
However, I suspect the real challenge here is parsing "ns::v". That isn't a
single name lookup, that as two, with the parser for nested-name-specifiers
building on the first to issue the second. Doing each name lookup will be
easy, but the rules for parsing a NNS are moderately complex. How far do
you want to go? ;]
I do think it would be very handy to have a well defined set of routines to
build a Clang parser for you that assumes a particular parse context
(relative to an AST), and parses a string of text into a new AST-fragment.
Tools like LLDB clearly need this so some form of it may already exist.
Getting it into Clang's Parser library would be very useful I think.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111106/c4ae7e6a/attachment.html>
More information about the cfe-dev
mailing list