summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2019-01-15 21:04:19 +0000
committerAdrian Prantl <aprantl@apple.com>2019-01-15 21:04:19 +0000
commit03e3065f240dd72aa8c57d970802ec57cc374bdb (patch)
tree38ba2295f1e4ebdec152991144b7fec50b594449
parent27c6ec393292f51984265865e502eb5cc62d2048 (diff)
Simplify code
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 7386edef11a..85436b630b7 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -4506,7 +4506,7 @@ ClangASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type,
// 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::ObjCInterfaceDecl *class_interface_decl,
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::GetChildCompilerTypeAtIndex(
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::GetChildCompilerTypeAtIndex(
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::GetChildCompilerTypeAtIndex(
// 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::GetChildCompilerTypeAtIndex(
// 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::GetChildCompilerTypeAtIndex(
::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::GetChildCompilerTypeAtIndex(
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::GetChildCompilerTypeAtIndex(
// 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::GetChildCompilerTypeAtIndex(
// 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(lldb::opaque_compiler_type_t type,
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 =