Skip to content

Commit 1f0f569

Browse files
committed
[llvm-c] Add getters for LLVMContextRef for various types
1 parent b132dd4 commit 1f0f569

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

llvm/include/llvm-c/Core.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,6 +1918,13 @@ void LLVMDumpValue(LLVMValueRef Val);
19181918
*/
19191919
char *LLVMPrintValueToString(LLVMValueRef Val);
19201920

1921+
/**
1922+
* Obtain the context to which this value is associated.
1923+
*
1924+
* @see llvm::Value::getContext()
1925+
*/
1926+
LLVMContextRef LLVMGetValueContext(LLVMValueRef Val);
1927+
19211928
/**
19221929
* Return a string representation of the DbgRecord. Use
19231930
* LLVMDisposeMessage to free the string.
@@ -3434,6 +3441,13 @@ void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
34343441
*/
34353442
void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
34363443

3444+
/**
3445+
* Obtain the context to which this basic block is associated.
3446+
*
3447+
* @see llvm::Module::getContext()
3448+
*/
3449+
LLVMContextRef LLVMGetBasicBlockContext(LLVMBasicBlockRef BB);
3450+
34373451
/**
34383452
* Obtain the first instruction in a basic block.
34393453
*
@@ -4070,6 +4084,13 @@ LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);
40704084
void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
40714085
LLVMMetadataRef FPMathTag);
40724086

4087+
/**
4088+
* Obtain the context to which this builder is associated.
4089+
*
4090+
* @see llvm::IRBuilder::getContext()
4091+
*/
4092+
LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder);
4093+
40734094
/**
40744095
* Deprecated: Passing the NULL location will crash.
40754096
* Use LLVMGetCurrentDebugLocation2 instead.

llvm/lib/IR/Core.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,10 @@ char* LLVMPrintValueToString(LLVMValueRef Val) {
10361036
return strdup(buf.c_str());
10371037
}
10381038

1039+
LLVMContextRef LLVMGetValueContext(LLVMValueRef Val) {
1040+
return wrap(&unwrap(Val)->getContext());
1041+
}
1042+
10391043
char *LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record) {
10401044
std::string buf;
10411045
raw_string_ostream os(buf);
@@ -2823,6 +2827,10 @@ void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos) {
28232827
unwrap(BB)->moveAfter(unwrap(MovePos));
28242828
}
28252829

2830+
LLVMContextRef LLVMGetBasicBlockContext(LLVMBasicBlockRef BB) {
2831+
return wrap(&unwrap(BB)->getContext());
2832+
}
2833+
28262834
/*--.. Operations on instructions ..........................................--*/
28272835

28282836
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst) {
@@ -3256,6 +3264,10 @@ void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
32563264
: nullptr);
32573265
}
32583266

3267+
LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder) {
3268+
return wrap(&unwrap(Builder)->getContext());
3269+
}
3270+
32593271
LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder) {
32603272
return wrap(unwrap(Builder)->getDefaultFPMathTag());
32613273
}

0 commit comments

Comments
 (0)