some update.

This commit is contained in:
ykiko
2024-09-15 13:50:49 +08:00
parent cfcb3f488b
commit b2fc464d86
14 changed files with 450 additions and 313 deletions

View File

@@ -1,10 +1,17 @@
#include <gtest/gtest.h>
#include <AST/ParsedAST.h>
#include <Feature/SemanticTokens.h>
namespace {
using namespace clang;
template <typename T>
auto f() {
using type = typename T::type;
return T::value;
}
TEST(test, test) {
std::vector<const char*> compileArgs = {
"clang++",
@@ -14,19 +21,23 @@ TEST(test, test) {
};
const char* code = R"(
int x [[maybe_unused]] = 0;
template<typename T>
struct X {
using type = T;
static constexpr bool value = true;
};
template <typename T>
auto f() {
using type = typename X<T>::type::type;
return T::value;
}
)";
auto AST = clice::ParsedAST::build("main.cpp", code, compileArgs);
auto fileID = AST->getFileID("main.cpp");
auto tokens = AST->spelledTokens(fileID);
// ClassVisitor visitor(&AST->context);
// visitor.TraverseDecl(AST->context.getTranslationUnitDecl());
for(auto& token: tokens) {
llvm::outs() << clang::tok::getTokenName(token.kind()) << ": " << token.text(AST->sourceManager) << "\n";
}
AST->context.getTranslationUnitDecl()->dump();
auto semanticTokens = clice::feature::semanticTokens(*AST, "main.cpp");
}
} // namespace