[llvm] [SandboxIR] Boilerplate code (PR #95814)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 16:33:15 PDT 2024
================
@@ -0,0 +1,43 @@
+//===- SandboxIRTest.cpp --------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/SandboxIR/SandboxIR.h"
+#include "llvm/AsmParser/Parser.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instruction.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/SourceMgr.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+struct SandboxIRTest : public testing::Test {
+ LLVMContext C;
+ std::unique_ptr<Module> M;
+
+ void parseIR(LLVMContext &C, const char *IR) {
+ SMDiagnostic Err;
+ M = parseAssemblyString(IR, Err, C);
+ if (!M)
+ Err.print("SandboxIRTest", errs());
+ }
+};
+
+TEST_F(SandboxIRTest, UserInstantiation) {
+ parseIR(C, R"IR(
+define void @foo(i32 %v1) {
+ ret void
+}
+)IR");
+ Function &F = *M->getFunction("foo");
+ auto *Ret = F.begin()->getTerminator();
+ sandboxir::Context Ctxt(C);
+ sandboxir::User U(sandboxir::Value::ClassID::User, Ret, Ctxt);
----------------
aeubanks wrote:
`[[maybe_unused]] sandboxir::User U...` instead of `(void) U`
https://github.com/llvm/llvm-project/pull/95814
More information about the llvm-commits
mailing list