This revision was automatically updated to reflect the committed changes. Closed by commit rGb3dae59b9dfb: [clang] Fix CodeGenAction for LLVM IR MemBuffers (authored by RSenApps, committed by dcastagna).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121259/new/ https://reviews.llvm.org/D121259 Files: clang/lib/CodeGen/CodeGenAction.cpp clang/unittests/Frontend/CodeGenActionTest.cpp Index: clang/unittests/Frontend/CodeGenActionTest.cpp =================================================================== --- clang/unittests/Frontend/CodeGenActionTest.cpp +++ clang/unittests/Frontend/CodeGenActionTest.cpp @@ -59,4 +59,21 @@ EXPECT_TRUE(Success); } +TEST(CodeGenTest, CodeGenFromIRMemBuffer) { + auto Invocation = std::make_shared<CompilerInvocation>(); + std::unique_ptr<MemoryBuffer> MemBuffer = + MemoryBuffer::getMemBuffer("", "test.ll"); + Invocation->getFrontendOpts().Inputs.push_back( + FrontendInputFile(*MemBuffer, Language::LLVM_IR)); + Invocation->getFrontendOpts().ProgramAction = frontend::EmitLLVMOnly; + Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu"; + CompilerInstance Compiler; + Compiler.setInvocation(std::move(Invocation)); + Compiler.createDiagnostics(); + EXPECT_TRUE(Compiler.hasDiagnostics()); + + EmitLLVMOnlyAction Action; + bool Success = Compiler.ExecuteAction(Action); + EXPECT_TRUE(Success); +} } Index: clang/lib/CodeGen/CodeGenAction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenAction.cpp +++ clang/lib/CodeGen/CodeGenAction.cpp @@ -1113,7 +1113,7 @@ auto &CodeGenOpts = CI.getCodeGenOpts(); auto &Diagnostics = CI.getDiagnostics(); std::unique_ptr<raw_pwrite_stream> OS = - GetOutputStream(CI, getCurrentFile(), BA); + GetOutputStream(CI, getCurrentFileOrBufferName(), BA); if (BA != Backend_EmitNothing && !OS) return;
Index: clang/unittests/Frontend/CodeGenActionTest.cpp =================================================================== --- clang/unittests/Frontend/CodeGenActionTest.cpp +++ clang/unittests/Frontend/CodeGenActionTest.cpp @@ -59,4 +59,21 @@ EXPECT_TRUE(Success); } +TEST(CodeGenTest, CodeGenFromIRMemBuffer) { + auto Invocation = std::make_shared<CompilerInvocation>(); + std::unique_ptr<MemoryBuffer> MemBuffer = + MemoryBuffer::getMemBuffer("", "test.ll"); + Invocation->getFrontendOpts().Inputs.push_back( + FrontendInputFile(*MemBuffer, Language::LLVM_IR)); + Invocation->getFrontendOpts().ProgramAction = frontend::EmitLLVMOnly; + Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu"; + CompilerInstance Compiler; + Compiler.setInvocation(std::move(Invocation)); + Compiler.createDiagnostics(); + EXPECT_TRUE(Compiler.hasDiagnostics()); + + EmitLLVMOnlyAction Action; + bool Success = Compiler.ExecuteAction(Action); + EXPECT_TRUE(Success); +} } Index: clang/lib/CodeGen/CodeGenAction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenAction.cpp +++ clang/lib/CodeGen/CodeGenAction.cpp @@ -1113,7 +1113,7 @@ auto &CodeGenOpts = CI.getCodeGenOpts(); auto &Diagnostics = CI.getDiagnostics(); std::unique_ptr<raw_pwrite_stream> OS = - GetOutputStream(CI, getCurrentFile(), BA); + GetOutputStream(CI, getCurrentFileOrBufferName(), BA); if (BA != Backend_EmitNothing && !OS) return;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits