Menu

1 / 2

AST Reconstruction: How We Manually Stitched Out-Of-Line Methods in libclang

DEV Community: cpp·Flude team·13 days ago
#z7IMzdWG
#devtocpp#devto#dev#class#libclang
Reading 0:00
15s threshold

In the previous episode, we taught our native parser based on libclang to find system headers. It stopped panicking and finally read all the code without errors.

But when we ran the documentation generation and started verifying completeness metrics, we discovered a disaster. Hundreds of methods were missing from our generated classes. The parser had simply "lost" them along the way.

The Core Problem: Out-Of-Line Methods

In C++, it is considered good practice to move the implementation of methods outside the class declaration. Usually, the implementation goes into separate .cpp files, and in the case of template classes, it remains in the header file but is written below the class itself. Both variants are called Out-Of-Line definitions:

template < class T > class MyClass { void foo (); };

template < class T > void MyClass < T >:: foo () { ...…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.