Add managed accessors for types, values, constants, and globals - #261
Merged
tannergooding merged 1 commit intoJul 15, 2026
Merged
Conversation
Fill in the high-level C++-mirroring managed API (sources/LLVMSharp) with the self-contained accessors that need no libLLVMSharp native support, deferring the instruction, module, and context surface to follow-up PRs. Mirror ClangSharp's ownership model so wrapper-returning accessors can reach their owning context: LLVMContext keeps a static weak registry keyed by LLVMContextRef, and Value/Type recover their managed context from their own handle rather than threading it through every constructor. Also surface the existing Aliasee, GlobalIFuncResolver, UnnamedAddress, and block-address getters on LLVMValueRef, which the managed accessors consume. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fills in the high-level C++-mirroring managed API (
sources/LLVMSharp) with the self-contained accessors that need nolibLLVMSharpnative support. This is the first of three slices: the instruction, module, and context/target surface follows in later PRs, and the native-dependent accessors come after thelibLLVMSharphelpers land.To let wrapper-returning accessors reach their owning context without threading it through every constructor, this mirrors ClangSharp's ownership model:
LLVMContextkeeps a static weak registry keyed byLLVMContextRef, andValue/Typerecover their managed context from their own handle (Handle.Context).Added managed surface:
Typepredicates,Context,ScalarType,Dump/PrintToString;IntegerType.BitWidth;SequentialType.ElementType;ArrayType/VectorType.NumElements;PointerType.AddressSpace;FunctionTypereturn/params/vararg;StructTypename/packed/opaque/elements/SetBody.Context,Kind,Name,Type,Dump,PrintToString;NumOperands,GetOperand,SetOperand.IsNullValue,GetAggregateElement;ConstantIntSExt/ZExtValue;ConstantFPValueAsDouble/GetDouble;ConstantDataSequentialIsString/AsString;ConstantExpr.Opcode;BlockAddress.Function/BasicBlock.GlobalValuelinkage/visibility/DLL-storage/unnamed-addr/section/value-type;GlobalVariableinitializer/constant/thread-local/erase;Functiontype/return/params/basic-blocks/GC/personality/verify;GlobalAlias.Aliasee;GlobalIFunc.Resolver.Also surfaces the existing
LLVMAliasGetAliasee/SetAliasee,LLVMGet/SetGlobalIFuncResolver,LLVMGet/SetUnnamedAddress, andLLVMGetBlockAddressFunction/BasicBlockC-API onLLVMValueRef, which the managed accessors consume.Function.ReturnTypedeliberately routes throughFunctionType.ReturnType(pure LLVM-C) rather than the nativeFunction_getReturnTypehelper, keeping it in this no-native slice.Builds with 0 warnings; adds
ManagedApi.cs(9 tests) exercising the new surface.net10.0, 2606 tests pass.