From 68fdb35d57013eb76ad113991f82d0ab97c304f7 Mon Sep 17 00:00:00 2001 From: ykiko Date: Sun, 13 Oct 2024 15:46:43 +0800 Subject: [PATCH] Some update. --- .vscode/launch.json | 4 ++++ deps/llvm | 2 +- include/Compiler/Resolver.h | 2 ++ src/Compiler/Preamble.cpp | 4 +++- tests/Source/ModuleScanner/A.cppm | 5 +++++ tests/Source/ModuleScanner/B.cppm | 3 +++ tests/Source/ModuleScanner/C.cppm | 3 +++ tests/Source/ModuleScanner/D.cppm | 7 +++++++ 8 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/Source/ModuleScanner/A.cppm create mode 100644 tests/Source/ModuleScanner/B.cppm create mode 100644 tests/Source/ModuleScanner/C.cppm create mode 100644 tests/Source/ModuleScanner/D.cppm diff --git a/.vscode/launch.json b/.vscode/launch.json index f62389b5..51da5601 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -21,6 +21,10 @@ "request": "launch", "name": "clice_test", "program": "${workspaceFolder}/build/bin/clice_test", + "args": [ + "--test-dir=/home/ykiko/C++/clice2/tests/Source", + "--gtest_filter=clice.Compiler" + ], "cwd": "${workspaceFolder}" } ] diff --git a/deps/llvm b/deps/llvm index 74b7c749..68cd2926 160000 --- a/deps/llvm +++ b/deps/llvm @@ -1 +1 @@ -Subproject commit 74b7c749705a62380a58746ead5f7a4cbff74fae +Subproject commit 68cd2926c6c0333dd8ee1fc9ac35ab492eedd59c diff --git a/include/Compiler/Resolver.h b/include/Compiler/Resolver.h index 4d31d8e8..dcc79489 100644 --- a/include/Compiler/Resolver.h +++ b/include/Compiler/Resolver.h @@ -19,6 +19,8 @@ public: clang::QualType resolve(clang::QualType type); + // TODO: + // use a relative clear way to resolve `UnresolvedLookupExpr`. private: clang::Sema& sema; }; diff --git a/src/Compiler/Preamble.cpp b/src/Compiler/Preamble.cpp index 7d7f413b..f9ec7c0c 100644 --- a/src/Compiler/Preamble.cpp +++ b/src/Compiler/Preamble.cpp @@ -7,7 +7,9 @@ public: std::optional collector; public: - void BeforeExecute(clang::CompilerInstance& CI) override { collector.emplace(CI.getPreprocessor()); } + void BeforeExecute(clang::CompilerInstance& CI) override { + collector.emplace(CI.getPreprocessor()); + } void AfterExecute(clang::CompilerInstance& CI) override { auto tokens = std::move(collector.value()).consume(); diff --git a/tests/Source/ModuleScanner/A.cppm b/tests/Source/ModuleScanner/A.cppm new file mode 100644 index 00000000..0db46de1 --- /dev/null +++ b/tests/Source/ModuleScanner/A.cppm @@ -0,0 +1,5 @@ +export module A; + +export int f() { + return 42; +} diff --git a/tests/Source/ModuleScanner/B.cppm b/tests/Source/ModuleScanner/B.cppm new file mode 100644 index 00000000..8866f49d --- /dev/null +++ b/tests/Source/ModuleScanner/B.cppm @@ -0,0 +1,3 @@ +export module B; + +import A; \ No newline at end of file diff --git a/tests/Source/ModuleScanner/C.cppm b/tests/Source/ModuleScanner/C.cppm new file mode 100644 index 00000000..652cbd44 --- /dev/null +++ b/tests/Source/ModuleScanner/C.cppm @@ -0,0 +1,3 @@ +export module C; + +import A; \ No newline at end of file diff --git a/tests/Source/ModuleScanner/D.cppm b/tests/Source/ModuleScanner/D.cppm new file mode 100644 index 00000000..080d121a --- /dev/null +++ b/tests/Source/ModuleScanner/D.cppm @@ -0,0 +1,7 @@ +import B; +import C; + +int main() { + int x = 42; + return 42; +}