本文整理汇总了C++中CompilerType类的典型用法代码示例。如果您正苦于以下问题:C++ CompilerType类的具体用法?C++ CompilerType怎么用?C++ CompilerType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CompilerType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTypeBitSize
bool ObjCLanguageRuntime::GetTypeBitSize(const CompilerType &compiler_type,
uint64_t &size) {
void *opaque_ptr = compiler_type.GetOpaqueQualType();
size = m_type_size_cache.Lookup(opaque_ptr);
// an ObjC object will at least have an ISA, so 0 is definitely not OK
if (size > 0)
return true;
ClassDescriptorSP class_descriptor_sp =
GetClassDescriptorFromClassName(compiler_type.GetTypeName());
if (!class_descriptor_sp)
return false;
int32_t max_offset = INT32_MIN;
uint64_t sizeof_max = 0;
bool found = false;
for (size_t idx = 0; idx < class_descriptor_sp->GetNumIVars(); idx++) {
const auto &ivar = class_descriptor_sp->GetIVarAtIndex(idx);
int32_t cur_offset = ivar.m_offset;
if (cur_offset > max_offset) {
max_offset = cur_offset;
sizeof_max = ivar.m_size;
found = true;
}
}
size = 8 * (max_offset + sizeof_max);
if (found)
m_type_size_cache.Insert(opaque_ptr, size);
return found;
}
示例2: IsClangType
bool ClangUtil::IsClangType(const CompilerType &ct) {
if (llvm::dyn_cast_or_null<ClangASTContext>(ct.GetTypeSystem()) == nullptr)
return false;
if (!ct.GetOpaqueQualType())
return false;
return true;
}
示例3: LookupType
CompilerType
GoUserExpression::GoInterpreter::EvaluateType(const GoASTExpr *e)
{
TargetSP target = m_exe_ctx.GetTargetSP();
if (auto *id = llvm::dyn_cast<GoASTIdent>(e))
{
CompilerType result = LookupType(target, ConstString(id->GetName().m_value));
if (result.IsValid())
return result;
std::string fullname = (m_package + "." + id->GetName().m_value).str();
result = LookupType(target, ConstString(fullname));
if (!result)
m_error.SetErrorStringWithFormat("Unknown type %s", fullname.c_str());
return result;
}
if (auto *sel = llvm::dyn_cast<GoASTSelectorExpr>(e))
{
std::string package;
if (auto *pkg_node = llvm::dyn_cast<GoASTIdent>(sel->GetX()))
{
package = pkg_node->GetName().m_value.str();
}
else if (auto *str_node = llvm::dyn_cast<GoASTBasicLit>(sel->GetX()))
{
if (str_node->GetValue().m_type == GoLexer::LIT_STRING)
{
package = str_node->GetValue().m_value.substr(1).str();
package.resize(package.length() - 1);
}
}
if (package.empty())
{
m_error.SetErrorStringWithFormat("Invalid %s in type expression", sel->GetX()->GetKindName());
return CompilerType();
}
std::string fullname = (package + "." + sel->GetSel()->GetName().m_value).str();
CompilerType result = LookupType(target, ConstString(fullname));
if (!result)
m_error.SetErrorStringWithFormat("Unknown type %s", fullname.c_str());
return result;
}
if (auto *star = llvm::dyn_cast<GoASTStarExpr>(e))
{
CompilerType elem = EvaluateType(star->GetX());
return elem.GetPointerType();
}
if (auto *paren = llvm::dyn_cast<GoASTParenExpr>(e))
return EvaluateType(paren->GetX());
if (auto *array = llvm::dyn_cast<GoASTArrayType>(e))
{
CompilerType elem = EvaluateType(array->GetElt());
}
m_error.SetErrorStringWithFormat("Invalid %s in type expression", e->GetKindName());
return CompilerType();
}
示例4: CalculateDynamicTypeId
uint64_t JavaASTContext::CalculateDynamicTypeId(ExecutionContext *exe_ctx,
const CompilerType &type,
ValueObject &in_value) {
if (JavaObjectType *obj = llvm::dyn_cast<JavaObjectType>(
static_cast<JavaType *>(type.GetOpaqueQualType())))
return obj->CalculateDynamicTypeId(exe_ctx, in_value);
if (JavaArrayType *arr = llvm::dyn_cast<JavaArrayType>(
static_cast<JavaType *>(type.GetOpaqueQualType())))
return arr->CalculateDynamicTypeId(exe_ctx, in_value);
return UINT64_MAX;
}
示例5: WouldEvenConsiderFormatting
bool lldb_private::formatters::swift::SwiftOptionSetSummaryProvider::
WouldEvenConsiderFormatting(CompilerType clang_type) {
SwiftASTContext *swift_ast_ctx =
llvm::dyn_cast_or_null<SwiftASTContext>(clang_type.GetTypeSystem());
if (!swift_ast_ctx)
return false;
return clang_type.IsValid() &&
swift_ast_ctx->IsTrivialOptionSetType(clang_type) &&
swift_ast_ctx->IsImportedType(clang_type, nullptr);
}
示例6:
void Materializer::Entity::SetSizeAndAlignmentFromType(CompilerType &type) {
m_size = type.GetByteSize(nullptr);
uint32_t bit_alignment = type.GetTypeBitAlign();
if (bit_alignment % 8) {
bit_alignment += 8;
bit_alignment &= ~((uint32_t)0x111u);
}
m_alignment = bit_alignment / 8;
}
示例7: GetItemFormatForFormat
static lldb::Format
GetItemFormatForFormat (lldb::Format format,
CompilerType element_type)
{
switch (format)
{
case lldb::eFormatVectorOfChar:
return lldb::eFormatChar;
case lldb::eFormatVectorOfFloat32:
case lldb::eFormatVectorOfFloat64:
return lldb::eFormatFloat;
case lldb::eFormatVectorOfSInt16:
case lldb::eFormatVectorOfSInt32:
case lldb::eFormatVectorOfSInt64:
case lldb::eFormatVectorOfSInt8:
return lldb::eFormatDecimal;
case lldb::eFormatVectorOfUInt128:
case lldb::eFormatVectorOfUInt16:
case lldb::eFormatVectorOfUInt32:
case lldb::eFormatVectorOfUInt64:
case lldb::eFormatVectorOfUInt8:
return lldb::eFormatUnsigned;
case lldb::eFormatBinary:
case lldb::eFormatComplexInteger:
case lldb::eFormatDecimal:
case lldb::eFormatEnum:
case lldb::eFormatInstruction:
case lldb::eFormatOSType:
case lldb::eFormatVoid:
return eFormatHex;
case lldb::eFormatDefault:
{
// special case the (default, char) combination to actually display as an integer value
// most often, you won't want to see the ASCII characters... (and if you do, eFormatChar is a keystroke away)
bool is_char = element_type.IsCharType();
bool is_signed = false;
element_type.IsIntegerType(is_signed);
return is_char ? (is_signed ? lldb::eFormatDecimal : eFormatHex) : format;
}
break;
default:
return format;
}
}
示例8: GetQualType
QualType ClangUtil::GetQualType(const CompilerType &ct) {
// Make sure we have a clang type before making a clang::QualType
if (!IsClangType(ct))
return QualType();
return QualType::getFromOpaquePtr(ct.GetOpaqueQualType());
}
示例9: exe_ctx
ValueObjectSP ABISysV_s390x::GetReturnValueObjectImpl(
Thread &thread, CompilerType &return_compiler_type) const {
ValueObjectSP return_valobj_sp;
if (!return_compiler_type)
return return_valobj_sp;
ExecutionContext exe_ctx(thread.shared_from_this());
return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type);
if (return_valobj_sp)
return return_valobj_sp;
RegisterContextSP reg_ctx_sp = thread.GetRegisterContext();
if (!reg_ctx_sp)
return return_valobj_sp;
if (return_compiler_type.IsAggregateType()) {
// FIXME: This is just taking a guess, r2 may very well no longer hold the
// return storage location.
// If we are going to do this right, when we make a new frame we should
// check to see if it uses a memory return, and if we are at the first
// instruction and if so stash away the return location. Then we would
// only return the memory return value if we know it is valid.
unsigned r2_id =
reg_ctx_sp->GetRegisterInfoByName("r2", 0)->kinds[eRegisterKindLLDB];
lldb::addr_t storage_addr =
(uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_id, 0);
return_valobj_sp = ValueObjectMemory::Create(
&thread, "", Address(storage_addr, nullptr), return_compiler_type);
}
return return_valobj_sp;
}
示例10: CompleteObjectType
void JavaASTContext::CompleteObjectType(const CompilerType &object_type) {
JavaObjectType *obj = llvm::dyn_cast<JavaObjectType>(
static_cast<JavaType *>(object_type.GetOpaqueQualType()));
assert(obj &&
"JavaASTContext::CompleteObjectType called with not a JavaObjectType");
obj->SetCompleteType(true);
}
示例11: CalculateArraySize
uint32_t JavaASTContext::CalculateArraySize(const CompilerType &type,
ValueObject &in_value) {
if (JavaArrayType *arr = llvm::dyn_cast<JavaArrayType>(
static_cast<JavaType *>(type.GetOpaqueQualType())))
return arr->GetNumElements(&in_value);
return UINT32_MAX;
}
示例12: exe_ctx
ValueObjectSP
ABISysV_i386::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_clang_type) const
{
ValueObjectSP return_valobj_sp;
if (!return_clang_type)
return return_valobj_sp;
ExecutionContext exe_ctx (thread.shared_from_this());
return_valobj_sp = GetReturnValueObjectSimple(thread, return_clang_type);
if (return_valobj_sp)
return return_valobj_sp;
RegisterContextSP reg_ctx_sp = thread.GetRegisterContext();
if (!reg_ctx_sp)
return return_valobj_sp;
if (return_clang_type.IsAggregateType())
{
unsigned eax_id = reg_ctx_sp->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
lldb::addr_t storage_addr = (uint32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff);
return_valobj_sp = ValueObjectMemory::Create (&thread,
"",
Address (storage_addr, nullptr),
return_clang_type);
}
return return_valobj_sp;
}
示例13: CalculateArrayElementOffset
uint64_t JavaASTContext::CalculateArrayElementOffset(const CompilerType &type,
size_t index) {
if (JavaArrayType *arr = llvm::dyn_cast<JavaArrayType>(
static_cast<JavaType *>(type.GetOpaqueQualType())))
return arr->GetElementOffset(index);
return UINT64_MAX;
}
示例14: compile_multiple
void compile_multiple(CompilerType& compiler, std::function<std::pair<std::string, ValueType>(std::string)> parser,
std::vector<std::string>& inputs)
{
boost::iostreams::filtering_istream input_stream;
std::string line;
for (auto input_as_string : inputs) {
auto input = boost::filesystem::path(input_as_string);
if(boost::filesystem::is_directory(input)) {
int files_added = 0;
for(auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(input), {})) {
if (entry.path().extension() == ".gz") {
input_stream.push(boost::iostreams::gzip_decompressor());
}
boost::iostreams::file_source file(entry.path().string(), std::ios_base::in | std::ios_base::binary);
input_stream.push(file);
++files_added;
while (std::getline(input_stream, line)) {
auto parse_result = parser(line);
if (parse_result.first.size() == 0) {
continue;
}
compiler.Add(parse_result.first, parse_result.second);
}
input_stream.reset();
}
} else {
if (input.extension() == ".gz"){
input_stream.push(boost::iostreams::gzip_decompressor());
}
boost::iostreams::file_source file(input.string(), std::ios_base::in | std::ios_base::binary);
input_stream.push(file);
while (std::getline(input_stream, line)) {
auto parse_result = parser(line);
compiler.Add(parse_result.first, parse_result.second);
}
input_stream.reset();
}
}
}
示例15: CalculateNumChildren
static size_t
CalculateNumChildren (CompilerType container_type,
CompilerType element_type,
lldb_private::ExecutionContextScope *exe_scope = nullptr // does not matter here because all we trade in are basic types
)
{
auto container_size = container_type.GetByteSize(exe_scope);
auto element_size = element_type.GetByteSize(exe_scope);
if (element_size)
{
if (container_size % element_size)
return 0;
return container_size / element_size;
}
return 0;
}