summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangExpressionDeclMap.cpp
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2012-03-06 21:56:33 +0000
committerSean Callanan <scallanan@apple.com>2012-03-06 21:56:33 +0000
commit75383bf34dc8069f260e8639783c481224b90dc6 (patch)
tree4de2afd635784126f3d25d36980cf818d27731b7 /lldb/source/Expression/ClangExpressionDeclMap.cpp
parent773642d3d8aa8b1a6052a79f5a64b722b9d4556f (diff)
downloadbcm5719-llvm-75383bf34dc8069f260e8639783c481224b90dc6.tar.gz
bcm5719-llvm-75383bf34dc8069f260e8639783c481224b90dc6.zip
Added support for calling blocks from expressions,
but gated by an #ifdef until we roll LLVM/Clang to bring in the necessary parser support. llvm-svn: 152149
Diffstat (limited to 'lldb/source/Expression/ClangExpressionDeclMap.cpp')
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 6b82c7dbd23..c9f08ebdc9a 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -2731,6 +2731,44 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
}
}
+static clang_type_t
+MaybePromoteToBlockPointerType
+(
+ ASTContext *ast_context,
+ clang_type_t candidate_type
+)
+{
+ if (!candidate_type)
+ return candidate_type;
+
+ QualType candidate_qual_type = QualType::getFromOpaquePtr(candidate_type);
+
+ const PointerType *candidate_pointer_type = dyn_cast<PointerType>(candidate_qual_type);
+
+ if (!candidate_pointer_type)
+ return candidate_type;
+
+ QualType pointee_qual_type = candidate_pointer_type->getPointeeType();
+
+ const RecordType *pointee_record_type = dyn_cast<RecordType>(pointee_qual_type);
+
+ if (!pointee_record_type)
+ return candidate_type;
+
+ RecordDecl *pointee_record_decl = pointee_record_type->getDecl();
+
+ if (!pointee_record_decl->isRecord())
+ return candidate_type;
+
+ if (!pointee_record_decl->getName().startswith(llvm::StringRef("__block_literal_")))
+ return candidate_type;
+
+ QualType generic_function_type = ast_context->getFunctionNoProtoType(ast_context->UnknownAnyTy);
+ QualType block_pointer_type = ast_context->getBlockPointerType(generic_function_type);
+
+ return block_pointer_type.getAsOpaquePtr();
+}
+
Value *
ClangExpressionDeclMap::GetVariableValue
(
@@ -2768,6 +2806,10 @@ ClangExpressionDeclMap::GetVariableValue
log->PutCString("There is no AST context for the current execution context");
return NULL;
}
+
+#ifdef EXPRESSION_PARSER_SUPPORTS_BLOCKS
+ var_opaque_type = MaybePromoteToBlockPointerType (ast, var_opaque_type);
+#endif
DWARFExpression &var_location_expr = var->LocationExpression();
OpenPOWER on IntegriCloud