forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
------------------------------------------------------------------------ r227319 | bsteinbr | 2015-01-28 08:35:59 -0800 (Wed, 28 Jan 2015) | 10 lines Fix LLVMSetMetadata and LLVMAddNamedMetadataOperand for single value MDNodes Summary: MetadataAsValue uses a canonical format that strips the MDNode if it contains only a single constant value. This triggers an assertion when trying to cast the value to a MDNode. Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7165 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@227475 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
7 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
; RUN: llvm-c-test --add-named-metadata-operand < /dev/null | ||
; This used to trigger an assertion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
; RUN: llvm-c-test --set-metadata < /dev/null | ||
; This used to trigger an assertion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ add_llvm_tool(llvm-c-test | |
include-all.c | ||
main.c | ||
module.c | ||
metadata.c | ||
object.c | ||
targets.c | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*===-- 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" | ||
#include "llvm-c/Core.h" | ||
|
||
int add_named_metadata_operand(void) { | ||
LLVMModuleRef m = LLVMModuleCreateWithName("Mod"); | ||
LLVMValueRef values[] = { LLVMConstInt(LLVMInt32Type(), 0, 0) }; | ||
|
||
// This used to trigger an assertion | ||
LLVMAddNamedMetadataOperand(m, "name", LLVMMDNode(values, 1)); | ||
|
||
return 0; | ||
} | ||
|
||
int set_metadata(void) { | ||
LLVMBuilderRef b = LLVMCreateBuilder(); | ||
LLVMValueRef values[] = { LLVMConstInt(LLVMInt32Type(), 0, 0) }; | ||
|
||
// This used to trigger an assertion | ||
LLVMSetMetadata( | ||
LLVMBuildRetVoid(b), | ||
LLVMGetMDKindID("kind", 4), | ||
LLVMMDNode(values, 1)); | ||
|
||
return 0; | ||
} |