diff options
| author | Tim Besard <tim.besard@gmail.com> | 2024-08-28 11:30:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-28 11:30:49 +0200 |
| commit | 0bd513082540b2b00bfad1540812e3ea282e70ed (patch) | |
| tree | 1631a2a2f2c202a3a5bec781ffd553ac4ccbb6e3 /llvm/lib/IR/Core.cpp | |
| parent | 82e314e3664d2c8768212e74f751187d51950b87 (diff) | |
[LLVM][C API] Clearing initializer and personality by passing NULL (#105521)
This is similar to how the C++ API supports passing `nullptr` to
`setPersonalityFn` or `setInitializer`.
Diffstat (limited to 'llvm/lib/IR/Core.cpp')
| -rw-r--r-- | llvm/lib/IR/Core.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 7665385025bd..28f603b2c38c 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -2261,8 +2261,8 @@ LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar) { } void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) { - unwrap<GlobalVariable>(GlobalVar) - ->setInitializer(unwrap<Constant>(ConstantVal)); + unwrap<GlobalVariable>(GlobalVar)->setInitializer( + ConstantVal ? unwrap<Constant>(ConstantVal) : nullptr); } LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar) { @@ -2445,7 +2445,8 @@ LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn) { } void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn) { - unwrap<Function>(Fn)->setPersonalityFn(unwrap<Constant>(PersonalityFn)); + unwrap<Function>(Fn)->setPersonalityFn( + PersonalityFn ? unwrap<Constant>(PersonalityFn) : nullptr); } unsigned LLVMGetIntrinsicID(LLVMValueRef Fn) { |
