2015-01-28 17:35:59 +01:00
|
|
|
/*===-- object.c - tool for testing libLLVM and llvm-c API ----------------===*\
|
|
|
|
|* *|
|
|
|
|
|* The LLVM Compiler Infrastructure *|
|
|
|
|
|* *|
|
|
|
|
|* This file is distributed under the University of Illinois Open Source *|
|
|
|
|
|* License. See LICENSE.TXT for details. *|
|
|
|
|
|* *|
|
|
|
|
|*===----------------------------------------------------------------------===*|
|
|
|
|
|* *|
|
|
|
|
|* This file implements the --add-named-metadata-operand and --set-metadata *|
|
|
|
|
|* commands in llvm-c-test. *|
|
|
|
|
|* *|
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
|
|
|
#include "llvm-c-test.h"
|
|
|
|
|
2016-02-05 14:31:14 +01:00
|
|
|
int llvm_add_named_metadata_operand(void) {
|
2015-01-28 17:35:59 +01:00
|
|
|
LLVMModuleRef m = LLVMModuleCreateWithName("Mod");
|
|
|
|
LLVMValueRef values[] = { LLVMConstInt(LLVMInt32Type(), 0, 0) };
|
|
|
|
|
|
|
|
// This used to trigger an assertion
|
|
|
|
LLVMAddNamedMetadataOperand(m, "name", LLVMMDNode(values, 1));
|
|
|
|
|
2015-01-28 19:32:31 +01:00
|
|
|
LLVMDisposeModule(m);
|
|
|
|
|
2015-01-28 17:35:59 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-05 14:31:14 +01:00
|
|
|
int llvm_set_metadata(void) {
|
2015-01-28 17:35:59 +01:00
|
|
|
LLVMBuilderRef b = LLVMCreateBuilder();
|
|
|
|
LLVMValueRef values[] = { LLVMConstInt(LLVMInt32Type(), 0, 0) };
|
|
|
|
|
|
|
|
// This used to trigger an assertion
|
|
|
|
LLVMSetMetadata(
|
|
|
|
LLVMBuildRetVoid(b),
|
|
|
|
LLVMGetMDKindID("kind", 4),
|
|
|
|
LLVMMDNode(values, 1));
|
|
|
|
|
2015-01-28 19:32:31 +01:00
|
|
|
LLVMDisposeBuilder(b);
|
|
|
|
|
2015-01-28 17:35:59 +01:00
|
|
|
return 0;
|
|
|
|
}
|