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

Michael Kruse via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 26 12:59:01 PST 2018


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



More information about the cfe-dev mailing list