Author: adrian Date: Tue Jan 15 13:04:19 2019 New Revision: 351244 URL: http://llvm.org/viewvc/llvm-project?rev=351244&view=rev Log: Simplify code
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=351244&r1=351243&r2=351244&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Jan 15 13:04:19 2019 @@ -4506,7 +4506,7 @@ ClangASTContext::GetArrayElementType(lld // TODO: the real stride will be >= this value.. find the real one! if (stride) - if (llvm::Optional<uint64_t> size = element_type.GetByteSize(nullptr)) + if (Optional<uint64_t> size = element_type.GetByteSize(nullptr)) *stride = *size; return element_type; @@ -5529,7 +5529,7 @@ static bool ObjCDeclHasIVars(clang::ObjC return false; } -static llvm::Optional<SymbolFile::ArrayInfo> +static Optional<SymbolFile::ArrayInfo> GetDynamicArrayInfo(ClangASTContext &ast, SymbolFile *sym_file, clang::QualType qual_type, const ExecutionContext *exe_ctx) { @@ -6596,6 +6596,10 @@ CompilerType ClangASTContext::GetChildCo if (!type) return CompilerType(); + auto get_exe_scope = [&exe_ctx]() { + return exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr; + }; + clang::QualType parent_qual_type(GetCanonicalQualType(type)); const clang::Type::TypeClass parent_type_class = parent_qual_type->getTypeClass(); @@ -6684,8 +6688,8 @@ CompilerType ClangASTContext::GetChildCo CompilerType base_class_clang_type(getASTContext(), base_class->getType()); child_name = base_class_clang_type.GetTypeName().AsCString(""); - llvm::Optional<uint64_t> size = base_class_clang_type.GetBitSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL); + Optional<uint64_t> size = + base_class_clang_type.GetBitSize(get_exe_scope()); if (!size) return {}; uint64_t base_class_clang_type_bit_size = *size; @@ -6716,8 +6720,8 @@ CompilerType ClangASTContext::GetChildCo // alignment (field_type_info.second) from the AST context. CompilerType field_clang_type(getASTContext(), field->getType()); assert(field_idx < record_layout.getFieldCount()); - llvm::Optional<uint64_t> size = field_clang_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL); + Optional<uint64_t> size = + field_clang_type.GetByteSize(get_exe_scope()); if (!size) return {}; child_byte_size = *size; @@ -6891,8 +6895,8 @@ CompilerType ClangASTContext::GetChildCo // We have a pointer to an simple type if (idx == 0 && pointee_clang_type.GetCompleteType()) { - if (llvm::Optional<uint64_t> size = pointee_clang_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) { + if (Optional<uint64_t> size = + pointee_clang_type.GetByteSize(get_exe_scope())) { child_byte_size = *size; child_byte_offset = 0; return pointee_clang_type; @@ -6914,8 +6918,8 @@ CompilerType ClangASTContext::GetChildCo ::snprintf(element_name, sizeof(element_name), "[%" PRIu64 "]", static_cast<uint64_t>(idx)); child_name.assign(element_name); - if (llvm::Optional<uint64_t> size = element_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) { + if (Optional<uint64_t> size = + element_type.GetByteSize(get_exe_scope())) { child_byte_size = *size; child_byte_offset = (int32_t)idx * (int32_t)child_byte_size; return element_type; @@ -6933,8 +6937,8 @@ CompilerType ClangASTContext::GetChildCo CompilerType element_type(getASTContext(), array->getElementType()); if (element_type.GetCompleteType()) { child_name = llvm::formatv("[{0}]", idx); - if (llvm::Optional<uint64_t> size = element_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) { + if (Optional<uint64_t> size = + element_type.GetByteSize(get_exe_scope())) { child_byte_size = *size; child_byte_offset = (int32_t)idx * (int32_t)child_byte_size; return element_type; @@ -6972,8 +6976,8 @@ CompilerType ClangASTContext::GetChildCo // We have a pointer to an simple type if (idx == 0) { - if (llvm::Optional<uint64_t> size = pointee_clang_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) { + if (Optional<uint64_t> size = + pointee_clang_type.GetByteSize(get_exe_scope())) { child_byte_size = *size; child_byte_offset = 0; return pointee_clang_type; @@ -7009,8 +7013,8 @@ CompilerType ClangASTContext::GetChildCo // We have a pointer to an simple type if (idx == 0) { - if (llvm::Optional<uint64_t> size = pointee_clang_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) { + if (Optional<uint64_t> size = + pointee_clang_type.GetByteSize(get_exe_scope())) { child_byte_size = *size; child_byte_offset = 0; return pointee_clang_type; @@ -7803,7 +7807,7 @@ ClangASTContext::GetTypeTemplateArgument return CompilerType(getASTContext(), template_arg.getAsType()); } -llvm::Optional<CompilerType::IntegralTemplateArgument> +Optional<CompilerType::IntegralTemplateArgument> ClangASTContext::GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx) { const clang::ClassTemplateSpecializationDecl *template_decl = _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits