Improve compilation database handling (#142)

Co-authored-by: star9029 <hengxings783@gmail.com>
This commit is contained in:
ykiko
2025-06-23 16:49:35 +08:00
committed by GitHub
parent a3075f86c0
commit d4c943d803
15 changed files with 229 additions and 154 deletions

View File

@@ -10,9 +10,17 @@ PCMInfo buildPCM(llvm::StringRef file, llvm::StringRef code) {
llvm::SmallString<128> outPath;
fs::createUniquePath(llvm::Twine(file) + "%%%%%%.pcm", outPath, true);
std::string path = file.str();
std::vector<const char*> arguments = {
"clang++",
"-std=c++20",
"-xc++",
path.c_str(),
};
CompilationParams params;
params.outPath = outPath;
params.command = "clang++ -std=c++20 -x c++ " + file.str();
params.arguments = arguments;
params.add_remapped_file(file, code);
params.add_remapped_file("./test.h", "export int foo2();");
@@ -26,8 +34,15 @@ PCMInfo buildPCM(llvm::StringRef file, llvm::StringRef code) {
}
ModuleInfo scan(llvm::StringRef content) {
std::vector<const char*> arguments = {
"clang++",
"-std=c++20",
"-xc++",
"main.ixx",
};
CompilationParams params;
params.command = "clang++ -std=c++20 -x c++ main.ixx";
params.arguments = arguments;
params.add_remapped_file("main.ixx", content);
params.add_remapped_file("./test.h", "export module A");
auto info = scanModule(params);