#include #include #include #include using namespace clice; TEST(clice_test, index) { std::vector compileArgs = { "clang++", "-std=c++20", "main.cpp", "-resource-dir", "/home/ykiko/C++/clice2/build/lib/clang/20", }; const char* code = R"( template struct X {}; template struct X {}; void f() { X y; X x; } )"; auto invocation = createInvocation("main.cpp", code, compileArgs); auto instance = createInstance(std::move(invocation)); SymbolSlab slab; auto indexConsumer = std::make_shared(slab); clang::index::IndexingOptions indexOptions; auto action = clang::index::createIndexingAction(indexConsumer, indexOptions); if(!action->BeginSourceFile(*instance, instance->getFrontendOpts().Inputs[0])) { return; } auto consumer = clang::index::createIndexingASTConsumer(indexConsumer, indexOptions, instance->getPreprocessorPtr()); instance->setASTConsumer(std::move(consumer)); if(auto err = action->Execute()) { llvm::errs() << "Error while indexing: " << err << "\n"; std::terminate(); } // instance->getASTContext().getTranslationUnitDecl()->dump(); action->EndSourceFile(); }