Category : abstract-syntax-tree

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

I’m trying to write a clang-tidy rule that will change the name of a function and modify a string literal parameter. The goal is to auto-port from tinyFormat to libfmt. I’ve got what I think is a good matcher here: finder->addMatcher( callExpr( callee(functionDecl(hasName("::tiny::Format"))), optionally(hasArgument( 0, ignoringImpCasts( declRefExpr( to(varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration( cxxRecordDecl(isDerivedFrom( "::std::basic_ostream"))))))))) .bind("streamArg")))), anyOf(hasArgument(0, stringLiteral().bind("fmtLiteral")), hasArgument(1, ..

Read more