[cfe-dev] Getting a DeclarationName with name "default"

Lingda Li via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 26 13:28:05 PST 2018


That works as a charm. Thanks a lot Michael!

On Mon, Nov 26, 2018 at 3:59 PM Michael Kruse <llvm at meinersbur.de> wrote:

> Hi,
>
> you should be able to get an IndentifierInfo for "default" using
> IdentifierTable::get(StringRef). You get an IdentifierTable object
> from ASTContext::Idents (public field).
>
> Michael
>
>
>
>
>
>
>
>
>
> Am Mo., 26. Nov. 2018 um 10:04 Uhr schrieb Lingda Li via cfe-dev
> <cfe-dev at lists.llvm.org>:
> >
> > Hi!
> >
> >
> > I just encountered this problem when implementing a new feature in
> OpenMP 5.0, which is called user defined mapper (the details of this
> feature are irrelevant to this question).
> >
> >
> > I need to build a NamedDecl. In some cases, programs will provide a
> name. In these cases, I will use the token of the name to get the
> corresponding DeclarationName from ASTContect::DeclarationNames, which will
> be used to initiate the NamedDecl I want.
> >
> > The code is like:
> >
> > DeclarationName ID =
> Actions.getASTContext().DeclarationNames.getIdentifier(Tok.getIdentifierInfo());
> >
> >
> > In other cases, programs do not provide a name, and the name should be
> the keyword "default" in these cases. No "default" token is available from
> the preprocessor in these cases so the previous method does not work.
> >
> >
> > My question is, in the later cases, how do I create a DeclarationName
> with the name "default", so that I can create the NamedDecl later? Any
> feedback will be much appreciated!
> >
> >
> > Thanks a lot,
> >
> >
> > Lingda Li
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181126/ceb44d82/attachment.html>


More information about the cfe-dev mailing list