2015-01-29 00:35:59 +08: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 21:31:14 +08:00
|
|
|
int llvm_add_named_metadata_operand(void) {
|
2015-01-29 00:35:59 +08: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-29 02:32:31 +08:00
|
|
|
LLVMDisposeModule(m);
|
|
|
|
|
2015-01-29 00:35:59 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-05 21:31:14 +08:00
|
|
|
int llvm_set_metadata(void) {
|
2015-01-29 00:35:59 +08: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-29 02:32:31 +08:00
|
|
|
LLVMDisposeBuilder(b);
|
|
|
|
|
2015-01-29 00:35:59 +08:00
|
|
|
return 0;
|
|
|
|
}
|