Problem with USR generation

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

Problem with USR generation

Eric Fiselier via cfe-dev
Hi all,

We're having some problems with the name generation for ParamVarDecls in our tool, can anyone give us some help?

A bit of context:

We use libTooling to generate the AST of a given program that we later convert to our format and do a number of analyses. 

We also define a bunch of functions in every TU, so we don't get 'implicit  function declaration' warnings/errors [0] by adding them to the preprocessor's predefines [1].

We want to use clang to generate the name of every declaration (VarDecl, ParmVar, FunctionDecl and maybe FieldDecl as well), and it seems to work fine for everything except the code we just added to the preprocessor, i.e.:

FunctionDecl 0x3ad9620 <esbmc_intrinsics.h:3:1, col:61> col:6 __ESBMC_assert 'void (_Bool, const char *)'
|-ParmVarDecl 0x3a84c48 <col:21, col:27> col:27 assertion '_Bool'
`-ParmVarDecl 0x3a84cc0 <col:38, col:50> col:50 description 'const char *'

Name: c:@F@__ESBMC_assert

~

ParmVarDecl 0x3a84c48 <esbmc_intrinsics.h:3:21, col:27> col:27 assertion '_Bool'
Name: c:

~

ParmVarDecl 0x3a84cc0 <esbmc_intrinsics.h:3:38, col:50> col:50 description 'const char *'
Name: c:

~

We do: 

clang::SmallString<128> declUSR;
bool ret = clang::index::generateUSRForDecl(&d, declUSR); (void)ret;

and ret is false, meaning it actually failed. 

At first, we thought it was because of the missing filename, so we added to our predefines: 

    "# 1 \"esbmc_intrinsics.h\" 1\n"

But it's still not working.

~

I had a look at the code maybe it's related to the printLoc function [2]? It fails if it can't find the fileEntry in the SourceManager.

Any clue how to make it work? I'm currently trying to add a file named esbmc_intrinsics.h to the VFS and see if it fixes the issue.

Thank you,


_______________________________________________
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: Problem with USR generation

Eric Fiselier via cfe-dev
Hi all,

Apparently the problem was that USRGen couldn't handle line directives.

I submitted a patch to fix it [0] but changes the format of the generated USR. 

Any feedback is welcome.


Thank you,


2017-12-08 17:18 GMT+00:00 Mikhail Ramalho <[hidden email]>:
Hi all,

We're having some problems with the name generation for ParamVarDecls in our tool, can anyone give us some help?

A bit of context:

We use libTooling to generate the AST of a given program that we later convert to our format and do a number of analyses. 

We also define a bunch of functions in every TU, so we don't get 'implicit  function declaration' warnings/errors [0] by adding them to the preprocessor's predefines [1].

We want to use clang to generate the name of every declaration (VarDecl, ParmVar, FunctionDecl and maybe FieldDecl as well), and it seems to work fine for everything except the code we just added to the preprocessor, i.e.:

FunctionDecl 0x3ad9620 <esbmc_intrinsics.h:3:1, col:61> col:6 __ESBMC_assert 'void (_Bool, const char *)'
|-ParmVarDecl 0x3a84c48 <col:21, col:27> col:27 assertion '_Bool'
`-ParmVarDecl 0x3a84cc0 <col:38, col:50> col:50 description 'const char *'

Name: c:@F@__ESBMC_assert

~

ParmVarDecl 0x3a84c48 <esbmc_intrinsics.h:3:21, col:27> col:27 assertion '_Bool'
Name: c:

~

ParmVarDecl 0x3a84cc0 <esbmc_intrinsics.h:3:38, col:50> col:50 description 'const char *'
Name: c:

~

We do: 

clang::SmallString<128> declUSR;
bool ret = clang::index::generateUSRForDecl(&d, declUSR); (void)ret;

and ret is false, meaning it actually failed. 

At first, we thought it was because of the missing filename, so we added to our predefines: 

    "# 1 \"esbmc_intrinsics.h\" 1\n"

But it's still not working.

~

I had a look at the code maybe it's related to the printLoc function [2]? It fails if it can't find the fileEntry in the SourceManager.

Any clue how to make it work? I'm currently trying to add a file named esbmc_intrinsics.h to the VFS and see if it fixes the issue.

Thank you,




--

Mikhail Ramalho.

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