diff --git a/Dockerfile b/Dockerfile index e9eecad..0a9d4ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ cmake -G Ninja \\ -DCMAKE_CXX_COMPILER=clang++ \\ -DCMAKE_CXX_STANDARD=17 \\ -DCMAKE_INSTALL_PREFIX=\$2 \\ - -DCMAKE_PREFIX_PATH="$(/usr/lib/llvm-17/bin/llvm-config --cmakedir)" \\ + -DCMAKE_PREFIX_PATH="$(llvm-config --cmakedir)" \\ -DCPACK_SOURCE_IGNORE_FILES=".git/;tester/third_party/" \\ -S \$1 \\ -B \$2/build @@ -35,7 +35,7 @@ apt-get update -y apt-get upgrade -y apt-get install -y --no-install-recommends \ libantlr4-runtime-dev default-jre-headless pkg-config uuid-dev flex bison \ - clang llvm-17-dev zlib1g-dev libzstd-dev lld python3 cmake ninja-build git + clang llvm-dev zlib1g-dev libzstd-dev lld python3 cmake ninja-build git apt-get autoremove -y apt-get clean -y rm -rf /var/lib/apt/lists/* diff --git a/generator/main.cc b/generator/main.cc index 762fa7d..f7924c2 100644 --- a/generator/main.cc +++ b/generator/main.cc @@ -8,10 +8,10 @@ #include namespace { -llvm::LLVMContext TheContext; -llvm::Module TheModule("-", TheContext); -llvm::Function *buildFunctionDecl(const llvm::json::Object *O) { +llvm::Function *buildFunctionDecl(llvm::LLVMContext &TheContext, + llvm::Module &TheModule, + const llvm::json::Object *O) { // First, check for an existing function from a previous declaration. auto TheName = O->get("name")->getAsString()->str(); llvm::Function *TheFunction = TheModule.getFunction(TheName); @@ -44,7 +44,9 @@ llvm::Function *buildFunctionDecl(const llvm::json::Object *O) { return nullptr; } -void buildTranslationUnitDecl(const llvm::json::Object *O) { +void buildTranslationUnitDecl(llvm::LLVMContext &TheContext, + llvm::Module &TheModule, + const llvm::json::Object *O) { if (O == nullptr) return; if (auto kind = O->get("kind")->getAsString()) { @@ -57,14 +59,16 @@ void buildTranslationUnitDecl(const llvm::json::Object *O) { if (auto P = it.getAsObject()) if (auto kind = P->get("kind")->getAsString()) { if (*kind == "FunctionDecl") - buildFunctionDecl(P); + buildFunctionDecl(TheContext, TheModule, P); } } } // namespace int main() { + llvm::LLVMContext TheContext; + llvm::Module TheModule("-", TheContext); auto llvmin = llvm::MemoryBuffer::getFileOrSTDIN("-"); auto json = llvm::json::parse(llvmin.get()->getBuffer()); - buildTranslationUnitDecl(json->getAsObject()); + buildTranslationUnitDecl(TheContext, TheModule, json->getAsObject()); TheModule.print(llvm::outs(), nullptr); } \ No newline at end of file