Category : abstract-syntax-tree

Given these ASTs: // using foo = const char*; TypeAliasDecl 0x26c72e0 <dread.cc:2:1, col:23> col:7 foo ‘const char *’ `-PointerType 0x26c6fc0 ‘const char *’ `-QualType 0x26c6961 ‘const char’ const `-BuiltinType 0x26c6960 ‘char’ //< What I want // using foo = std::unique_ptr<int>; TypeAliasDecl 0x2570928 <dread.cc:32:1, col:32> col:7 foo ‘std::unique_ptr<int>’:’std::unique_ptr<int>’ `-ElaboratedType 0x25708b0 ‘std::unique_ptr<int>’ sugar //< What I want ..

Read more

I am in the following code: struct Test { void fn(int a) const; }; int main() { Test a; a.fn(1); } The a.fn(1) expression is parsed by clang in the following ast: CXXMemberCallExpr 0x1ea95a99ba0 <C:/…/test.cpp:33:5, col:11> ‘void’ |-MemberExpr 0x1ea95a99b70 <col:5, col:7> ‘<bound member function type>’ .fn 0x1ea95a8b628 | `-ImplicitCastExpr 0x1ea95a99bc8 <col:5> ‘const Test’ lvalue <NoOp> ..

Read more

I am currently trying to traverse clang AST but I am not sure where I should start, I have read the documentation about RecursiveASTVisitor, but I don’t know how to implement it. Can you please share the complete guides which can help me to start from scratch? I am using C++ as the main language. ..

Read more

Given the following test.cpp- #include <vector> using namespace std; class MyData {}; class MoreData {}; class MyClass { public: void Method2(vector<int> vec){} void Method3(const vector<int>& vec){} void Method4(vector<MoreData> vec){} void Method5(const vector<MoreData>& vec){} void Method7(vector<MyData> vec){} // Match works for this void Method8(const vector<MyData>& vec){} // How to match by reference? }; I can create ..

Read more