Files
clice/tests/Index/Index.cpp
2024-10-17 21:51:20 +08:00

34 lines
746 B
C++

#include <gtest/gtest.h>
#include <Index/SymbolSlab.h>
#include <Support/JSON.h>
#include <Compiler/Compiler.h>
using namespace clice;
TEST(clice, Index) {
std::vector<const char*> compileArgs = {
"clang++",
"-std=c++20",
"main.cpp",
"-resource-dir",
"/home/ykiko/C++/clice2/build/lib/clang/20",
};
const char* code = R"(
template<typename T, typename U> struct X {};
template<typename T> struct X<T, T> {};
void f() {
X<char, int> y;
X<int, int> x;
}
)";
Compiler compiler("main.cpp", code, compileArgs);
compiler.buildAST();
SymbolSlab slab;
auto csif = slab.index(compiler.context());
auto value = json::serialize(csif);
llvm::outs() << value << "\n";
}