Is it possible to getBody() of basic_string::_M_construct() in libstdc++ 8.3.0?

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

Is it possible to getBody() of basic_string::_M_construct() in libstdc++ 8.3.0?

David Blaikie via cfe-dev
Hi all!

I would like to know if it's possible to get the method body of std::__cxx11::basic_string::_M_construct(size_type, _CharT) ?

The question arises when StaticAnalyzer's ExprEnging::defaultEvalCall()
tries to inline this method but the CXXMethodDecl node for '_M_construct'
(and a few other similar members) from the AST has no body attached to it.

The body (templated?) should be in the AST but is hidden somewhere else,
otherwise the TU would be incomplete.

Any hint would be appreciated, thanks!

--
Best Regards
 
Ding Fei
E-mail: [hidden email]

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to getBody() of basic_string::_M_construct() in libstdc++ 8.3.0?

David Blaikie via cfe-dev
If it's not in the AST, it's not in the translation unit. Try searching the AST dump, maybe you're looking in the wrong place.

Static analyzer is intended to work more or less correctly regardless of whether the method is present. Like, it doesn't even have to be libc++ to begin with. But i'd be pretty surprised if the body is there but the static analyzer can't find it. Most likely something else is going on.

You should be looking for the fully instantiated body, not the original template, because that's what the static analyzer works with. Clang duplicates the AST for each template instantiation so it should be there if it's at all available.

On 11/10/20 12:28 AM, Ding Fei via cfe-dev wrote:
Hi all!

I would like to know if it's possible to get the method body of std::__cxx11::basic_string::_M_construct(size_type, _CharT) ?

The question arises when StaticAnalyzer's ExprEnging::defaultEvalCall()
tries to inline this method but the CXXMethodDecl node for '_M_construct'
(and a few other similar members) from the AST has no body attached to it.

The body (templated?) should be in the AST but is hidden somewhere else,
otherwise the TU would be incomplete.

Any hint would be appreciated, thanks!

--
Best Regards
 
Ding Fei
E-mail: [hidden email]

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


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to getBody() of basic_string::_M_construct() in libstdc++ 8.3.0?

David Blaikie via cfe-dev
I've not looked into the libstdc++ code for this, but my guess would be that implicit instantiation of that function's definition is being suppressed by an explicit instantiation declaration -- so the definition of the template might be in the AST, but we're not allowed to instantiate it even though it was used.

On Thu, 12 Nov 2020 at 16:52, Artem Dergachev via cfe-dev <[hidden email]> wrote:
If it's not in the AST, it's not in the translation unit. Try searching the AST dump, maybe you're looking in the wrong place.

Static analyzer is intended to work more or less correctly regardless of whether the method is present. Like, it doesn't even have to be libc++ to begin with. But i'd be pretty surprised if the body is there but the static analyzer can't find it. Most likely something else is going on.

You should be looking for the fully instantiated body, not the original template, because that's what the static analyzer works with. Clang duplicates the AST for each template instantiation so it should be there if it's at all available.

On 11/10/20 12:28 AM, Ding Fei via cfe-dev wrote:
Hi all!

I would like to know if it's possible to get the method body of std::__cxx11::basic_string::_M_construct(size_type, _CharT) ?

The question arises when StaticAnalyzer's ExprEnging::defaultEvalCall()
tries to inline this method but the CXXMethodDecl node for '_M_construct'
(and a few other similar members) from the AST has no body attached to it.

The body (templated?) should be in the AST but is hidden somewhere else,
otherwise the TU would be incomplete.

Any hint would be appreciated, thanks!

--
Best Regards
 
Ding Fei
E-mail: [hidden email]

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

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

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