Category : abstract-syntax-tree

I want to write a matcher, which excludes classes containing incomplete types like: std::unique_ptr<ForwardDeclared>, but it is not identified as one, because it is a template type (I think so). Does anyone know how to circumvent this? Minimal code: // … class MoveDefaultToDecl: public MatchFinder::MatchCallback { // … public: void run(const MatchFinder::MatchResult& r) override { ..

Read more

I am a newcomer who is beginning to learn the principles of compilation. I am trying to implement a simple C-like scripting language interpreter using C++17. I have completed lexical analysis and parser, and can convert code text into AST representation.The next step is to execute the code by traversing the AST. I understand the ..

Read more

Consider the following struct definition in foo.cc: struct Foo { int &bar; }; Because bar has reference type, the implicit trivial default constructor Foo::Foo() is implicitly deleted. However, this fact does not seem to be reflected in the AST generated by clang. E.g. running clang -Xclang -ast-dump foo.cc results in: `-CXXRecordDecl 0x5612ba4c03b8 <test.cc:1:1, col:24> col:8 ..

Read more

I have a big project, and a slew of C++ class member functions of the form: Return CClass::MemberFunction( Arg1 arg1, //… std::weak_ptr<IMemberFunctionListenerInterface> listener) { //… } I’m trying to write a matcher that finds functions like these, which have arguments whose types have the string "Listener" in their name. I can find functions with arguments ..

Read more

I want to analyze a specific file located here (https://github.com/larmillo/GIZMO-CMZ/blob/master/gravity/forcetree.c) I am trying to parse it using Clang as a frontend that can generate an AST for me. Specifically the operation I am interested in doing is something like this: clang -Xclang -ast-dump ./gravity/forcetree.c -I /usr/include/hdf5/serial -I /usr/include/mpi -I /home/esmerald/Documents/uci/Research/C2Bluespec/GIZMO-CMZ-master/grackle/src/clib This produces the error: /usr/bin/ld: ..

Read more

I have a function like this to get the the AST from a file. antlr4::tree::ParseTree *get_ast(std::string &filename) { std::ifstream stream; stream.open(filename); antlr4::ANTLRInputStream input(stream); Lexer lexer(&input); antlr4::CommonTokenStream tokens(&lexer); Parser parser(&tokens); antlr4::tree::ParseTree *tree = parser.program(); return tree; } But when using the return value, it seems that what tree is pointing to is already cleared (on the ..

Read more