summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Expression')
-rw-r--r--lldb/source/Expression/ClangASTSource.cpp6
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp75
-rw-r--r--lldb/source/Expression/ClangExpressionParser.cpp12
3 files changed, 83 insertions, 10 deletions
diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp
index f3526a70f7b..d91f2f1069e 100644
--- a/lldb/source/Expression/ClangASTSource.cpp
+++ b/lldb/source/Expression/ClangASTSource.cpp
@@ -232,9 +232,9 @@ NameSearchContext::AddGenericFunDecl()
proto_info.Variadic = true;
- QualType generic_function_type(m_ast_source.m_ast_context.getFunctionType (m_ast_source.m_ast_context.getSizeType(), // result
- NULL, // argument types
- 0, // number of arguments
+ QualType generic_function_type(m_ast_source.m_ast_context.getFunctionType (m_ast_source.m_ast_context.UnknownAnyTy, // result
+ NULL, // argument types
+ 0, // number of arguments
proto_info));
return AddFunDecl(generic_function_type.getAsOpaquePtr());
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 6c7b2a87dff..b2fe2da3e66 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -1295,8 +1295,15 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
}
if (log)
- log->Printf("%s %s with type %p", (dematerialize ? "Dematerializing" : "Materializing"), name.GetCString(), type.GetOpaqueQualType());
-
+ {
+ StreamString my_stream_string;
+
+ ClangASTType::DumpTypeDescription (type.GetASTContext(),
+ type.GetOpaqueQualType(),
+ &my_stream_string);
+
+ log->Printf("%s %s with type %s", (dematerialize ? "Dematerializing" : "Materializing"), name.GetCString(), my_stream_string.GetString().c_str());
+ }
if (!location_value.get())
{
@@ -2095,13 +2102,13 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
clang::ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext();
- TypeFromUser user_type (ClangASTContext::GetVoidPtrType(scratch_ast_context, false),
+ TypeFromUser user_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(scratch_ast_context, true)),
scratch_ast_context);
- TypeFromParser parser_type (ClangASTContext::GetVoidPtrType(context.GetASTContext(), false),
+ TypeFromParser parser_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(context.GetASTContext(), true)),
context.GetASTContext());
- NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(parser_type.GetASTContext(), parser_type.GetOpaqueQualType()));
+ NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType());
std::string decl_name(context.m_decl_name.getAsString());
ConstString entity_name(decl_name.c_str());
@@ -2111,7 +2118,6 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
m_parser_vars->m_exe_ctx->process->GetByteOrder(),
m_parser_vars->m_exe_ctx->process->GetAddressByteSize()));
assert (entity.get());
- entity->EnableParserVars();
std::auto_ptr<Value> symbol_location(new Value);
@@ -2123,11 +2129,13 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
symbol_location->GetScalar() = symbol_load_addr;
symbol_location->SetValueType(Value::eValueTypeLoadAddress);
+ entity->EnableParserVars();
entity->m_parser_vars->m_parser_type = parser_type;
entity->m_parser_vars->m_named_decl = var_decl;
entity->m_parser_vars->m_llvm_value = NULL;
entity->m_parser_vars->m_lldb_value = symbol_location.release();
entity->m_parser_vars->m_lldb_sym = &symbol;
+ //entity->m_flags |= ClangExpressionVariable::EVUnknownType;
if (log)
{
@@ -2147,6 +2155,61 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
}
}
+bool
+ClangExpressionDeclMap::ResolveUnknownTypes()
+{
+ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ clang::ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext();
+
+ for (size_t index = 0, num_entities = m_found_entities.GetSize();
+ index < num_entities;
+ ++index)
+ {
+ ClangExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
+
+ if (entity->m_flags & ClangExpressionVariable::EVUnknownType)
+ {
+ const NamedDecl *named_decl = entity->m_parser_vars->m_named_decl;
+ const VarDecl *var_decl = dyn_cast<VarDecl>(named_decl);
+
+ if (!var_decl)
+ {
+ if (log)
+ log->Printf("Entity of unknown type does not have a VarDecl");
+ return false;
+ }
+
+ if (log)
+ {
+ std::string var_decl_print_string;
+ llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string);
+ var_decl->print(var_decl_print_stream);
+ var_decl_print_stream.flush();
+
+ log->Printf("Variable of unknown type now has Decl %s", var_decl_print_string.c_str());
+ }
+
+ QualType var_type = var_decl->getType();
+ TypeFromParser parser_type(var_type.getAsOpaquePtr(), &var_decl->getASTContext());
+
+ lldb::clang_type_t copied_type = ClangASTContext::CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr());
+
+ TypeFromUser user_type(copied_type, scratch_ast_context);
+
+ entity->m_parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
+ entity->m_parser_vars->m_parser_type = parser_type;
+
+ entity->SetClangAST(user_type.GetASTContext());
+ entity->SetClangType(user_type.GetOpaqueQualType());
+
+ entity->m_flags &= ~(ClangExpressionVariable::EVUnknownType);
+ }
+ }
+
+ return true;
+}
+
void
ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context,
const RegisterInfo *reg_info)
diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp
index 51654626fcd..028f99ab7e2 100644
--- a/lldb/source/Expression/ClangExpressionParser.cpp
+++ b/lldb/source/Expression/ClangExpressionParser.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Expression/ClangASTSource.h"
#include "lldb/Expression/ClangExpression.h"
+#include "lldb/Expression/ClangExpressionDeclMap.h"
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Expression/IRForTarget.h"
#include "lldb/Expression/IRToDWARF.h"
@@ -352,7 +353,7 @@ ClangExpressionParser::Parse (Stream &stream)
ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(), m_compiler->getASTContext());
diag_buf->EndSourceFile();
-
+
TextDiagnosticBuffer::const_iterator diag_iterator;
int num_errors = 0;
@@ -377,6 +378,15 @@ ClangExpressionParser::Parse (Stream &stream)
++diag_iterator)
stream.Printf("note: %s\n", (*diag_iterator).second.c_str());
+ if (!num_errors)
+ {
+ if (m_expr.DeclMap() && !m_expr.DeclMap()->ResolveUnknownTypes())
+ {
+ stream.Printf("error: Couldn't infer the type of a variable\n");
+ num_errors++;
+ }
+ }
+
return num_errors;
}
OpenPOWER on IntegriCloud