public void WillParseCorrectly(string input, bool willConvert, DIType expectedOutput) { Assert.AreEqual(willConvert, EnumConverter.TryParse(typeof(DIType), input, out object parsed)); if (willConvert) { Assert.AreEqual(expectedOutput, (DIType)parsed); } }
private static void CreateCopyFunctionBody(BitcodeModule module , DataLayout layout , Function copyFunc , DIFile diFile , ITypeRef foo , DebugPointerType fooPtr , DIType constFooType ) { var diBuilder = module.DIBuilder; copyFunc.Parameters[0].Name = "src"; copyFunc.Parameters[1].Name = "pDst"; // create block for the function body, only need one for this simple sample var blk = copyFunc.AppendBasicBlock("entry"); // create instruction builder to build the body var instBuilder = new InstructionBuilder(blk); // create debug info locals for the arguments // NOTE: Debug parameter indices are 1 based! var paramSrc = diBuilder.CreateArgument(copyFunc.DISubProgram, "src", diFile, 11, constFooType, false, 0, 1); var paramDst = diBuilder.CreateArgument(copyFunc.DISubProgram, "pDst", diFile, 12, fooPtr.DIType, false, 0, 2); uint ptrAlign = layout.CallFrameAlignmentOf(fooPtr); // create Locals // NOTE: There's no debug location attached to these instructions. // The debug info will come from the declare intrinsic below. var dstAddr = instBuilder.Alloca(fooPtr) .RegisterName("pDst.addr") .Alignment(ptrAlign); bool param0ByVal = copyFunc.Attributes[FunctionAttributeIndex.Parameter0].Contains(AttributeKind.ByVal); if (param0ByVal) { diBuilder.InsertDeclare(copyFunc.Parameters[0] , paramSrc , new DILocation(module.Context, 11, 43, copyFunc.DISubProgram) , blk ); } instBuilder.Store(copyFunc.Parameters[1], dstAddr) .Alignment(ptrAlign); // insert declare pseudo instruction to attach debug info to the local declarations diBuilder.InsertDeclare(dstAddr, paramDst, new DILocation(module.Context, 12, 38, copyFunc.DISubProgram), blk); if (!param0ByVal) { // since the function's LLVM signature uses a pointer, which is copied locally // inform the debugger to treat it as the value by dereferencing the pointer diBuilder.InsertDeclare(copyFunc.Parameters[0] , paramSrc , diBuilder.CreateExpression(ExpressionOp.deref) , new DILocation(module.Context, 11, 43, copyFunc.DISubProgram) , blk ); } var loadedDst = instBuilder.Load(dstAddr) .Alignment(ptrAlign) .SetDebugLocation(15, 6, copyFunc.DISubProgram); var dstPtr = instBuilder.BitCast(loadedDst, module.Context.Int8Type.CreatePointerType( )) .SetDebugLocation(15, 13, copyFunc.DISubProgram); var srcPtr = instBuilder.BitCast(copyFunc.Parameters[0], module.Context.Int8Type.CreatePointerType( )) .SetDebugLocation(15, 13, copyFunc.DISubProgram); uint pointerSize = layout.IntPtrType(module.Context).IntegerBitWidth; instBuilder.MemCpy(module , dstPtr , srcPtr , module.Context.CreateConstant(pointerSize, layout.ByteSizeOf(foo), false) , ( int )layout.AbiAlignmentOf(foo) , false ).SetDebugLocation(15, 13, copyFunc.DISubProgram); instBuilder.Return( ) .SetDebugLocation(16, 1, copyFunc.DISubProgram); }
public DependencyInjectedAttribute(DIType dIType, Type implements = null) => (Type, Implements) = (dIType, implements);