Getting a DeclarationName with name "default"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting a DeclarationName with name "default"

Oleg Smolsky via cfe-dev

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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting a DeclarationName with name "default"

Oleg Smolsky via cfe-dev
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
<[hidden email]>:

>
> 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
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting a DeclarationName with name "default"

Oleg Smolsky via cfe-dev

That works as a charm. Thanks a lot Michael!

On Mon, Nov 26, 2018 at 3:59 PM Michael Kruse <[hidden email]> 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
<[hidden email]>:
>
> 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
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev