DWARFExpression lldb_private::npdb::MakeConstantLocationExpression( TypeIndex underlying_ti, TpiStream &tpi, const llvm::APSInt &constant, ModuleSP module) { const ArchSpec &architecture = module->GetArchitecture(); uint32_t address_size = architecture.GetAddressByteSize(); size_t size = 0; bool is_signed = false; std::tie(size, is_signed) = GetIntegralTypeInfo(underlying_ti, tpi); union { llvm::support::little64_t I; llvm::support::ulittle64_t U; } Value; std::shared_ptr<DataBufferHeap> buffer = std::make_shared<DataBufferHeap>(); buffer->SetByteSize(size); llvm::ArrayRef<uint8_t> bytes; if (is_signed) { Value.I = constant.getSExtValue(); } else { Value.U = constant.getZExtValue(); } bytes = llvm::makeArrayRef(reinterpret_cast<const uint8_t *>(&Value), 8) .take_front(size); buffer->CopyData(bytes.data(), size); DataExtractor extractor(buffer, lldb::eByteOrderLittle, address_size); DWARFExpression result(nullptr, extractor, nullptr, 0, size); return result; }
TemplateArgument::TemplateArgument(ASTContext &Ctx, const llvm::APSInt &Value, QualType Type) { Integer.Kind = Integral; // Copy the APSInt value into our decomposed form. Integer.BitWidth = Value.getBitWidth(); Integer.IsUnsigned = Value.isUnsigned(); // If the value is large, we have to get additional memory from the ASTContext unsigned NumWords = Value.getNumWords(); if (NumWords > 1) { void *Mem = Ctx.Allocate(NumWords * sizeof(uint64_t)); std::memcpy(Mem, Value.getRawData(), NumWords * sizeof(uint64_t)); Integer.pVal = static_cast<uint64_t *>(Mem); } else { Integer.VAL = Value.getZExtValue(); } Integer.Type = Type.getAsOpaquePtr(); }