@@ -57,7 +57,7 @@ ClangExpressionDeclMap::ClangExpressionDeclMap (ExecutionContext *exe_ctx) :
57
57
m_materialized_location (0 ),
58
58
m_result_name (),
59
59
m_object_pointer_type (),
60
- m_lookedup_types ( )
60
+ m_ignore_lookups ( false )
61
61
{
62
62
if (exe_ctx)
63
63
{
@@ -990,6 +990,13 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
990
990
// Back out in all cases where we're not fully initialized
991
991
if (m_exe_ctx.frame == NULL )
992
992
return ;
993
+
994
+ if (m_ignore_lookups)
995
+ {
996
+ if (log)
997
+ log->Printf (" Ignoring a query during an import" );
998
+ return ;
999
+ }
993
1000
994
1001
SymbolContextList sc_list;
995
1002
@@ -1117,36 +1124,22 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
1117
1124
AddOneVariable (context, pvar);
1118
1125
}
1119
1126
1120
-
1121
- // See information on gating of this operation next to the definition for
1122
- // m_lookedup_types.
1123
-
1124
- if (m_lookedup_types.find (name_unique_cstr) == m_lookedup_types.end ())
1125
- {
1126
- // 1 The name is added to m_lookedup_types.
1127
- m_lookedup_types.insert (std::pair<const char *, bool >(name_unique_cstr, true ));
1128
-
1129
- // 2 The type is looked up and added, potentially causing more type loookups.
1130
- lldb::TypeSP type_sp (m_sym_ctx.FindTypeByName (name));
1127
+ lldb::TypeSP type_sp (m_sym_ctx.FindTypeByName (name));
1131
1128
1132
- if (type_sp)
1129
+ if (type_sp)
1130
+ {
1131
+ if (log)
1133
1132
{
1134
- if (log)
1135
- {
1136
- log->Printf (" Matching type found for \" %s\" : " , name.GetCString ());
1137
- StreamString strm;
1138
- type_sp->Dump (&strm, true );
1139
- log->PutCString (strm.GetData ());
1140
- }
1133
+ log->Printf (" Matching type found for \" %s\" : " , name.GetCString ());
1134
+ StreamString strm;
1135
+ type_sp->Dump (&strm, true );
1136
+ log->PutCString (strm.GetData ());
1137
+ }
1141
1138
1142
- TypeFromUser user_type (type_sp->GetClangType (),
1139
+ TypeFromUser user_type (type_sp->GetClangType (),
1143
1140
type_sp->GetClangAST ());
1144
1141
1145
- AddOneType (context, user_type, false );
1146
- }
1147
-
1148
- // 3 The name is removed from m_lookedup_types.
1149
- m_lookedup_types.erase (name_unique_cstr);
1142
+ AddOneType (context, user_type, false );
1150
1143
}
1151
1144
}
1152
1145
@@ -1225,7 +1218,7 @@ ClangExpressionDeclMap::GetVariableValue
1225
1218
1226
1219
if (parser_ast_context)
1227
1220
{
1228
- type_to_use = ClangASTContext::CopyType (parser_ast_context, var_ast_context, var_opaque_type);
1221
+ type_to_use = GuardedCopyType (parser_ast_context, var_ast_context, var_opaque_type);
1229
1222
1230
1223
if (parser_type)
1231
1224
*parser_type = TypeFromParser (type_to_use, parser_ast_context);
@@ -1310,9 +1303,9 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
1310
1303
1311
1304
TypeFromUser user_type = pvar->m_user_type ;
1312
1305
1313
- TypeFromParser parser_type (ClangASTContext::CopyType (context.GetASTContext (),
1314
- user_type.GetASTContext (),
1315
- user_type.GetOpaqueQualType ()),
1306
+ TypeFromParser parser_type (GuardedCopyType (context.GetASTContext (),
1307
+ user_type.GetASTContext (),
1308
+ user_type.GetOpaqueQualType ()),
1316
1309
context.GetASTContext ());
1317
1310
1318
1311
NamedDecl *var_decl = context.AddVarDecl (parser_type.GetOpaqueQualType ());
@@ -1386,7 +1379,7 @@ ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
1386
1379
1387
1380
TypeList *type_list = fun_type->GetTypeList ();
1388
1381
fun_ast_context = type_list->GetClangASTContext ().getASTContext ();
1389
- void *copied_type = ClangASTContext::CopyType (context.GetASTContext (), fun_ast_context, fun_opaque_type);
1382
+ void *copied_type = GuardedCopyType (context.GetASTContext (), fun_ast_context, fun_opaque_type);
1390
1383
1391
1384
fun_decl = context.AddFunDecl (copied_type);
1392
1385
}
@@ -1436,7 +1429,7 @@ ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
1436
1429
clang::ASTContext *parser_ast_context = context.GetASTContext ();
1437
1430
clang::ASTContext *user_ast_context = ut.GetASTContext ();
1438
1431
1439
- void *copied_type = ClangASTContext::CopyType (parser_ast_context, user_ast_context, ut.GetOpaqueQualType ());
1432
+ void *copied_type = GuardedCopyType (parser_ast_context, user_ast_context, ut.GetOpaqueQualType ());
1440
1433
1441
1434
TypeFromParser parser_type (copied_type, parser_ast_context);
1442
1435
@@ -1471,3 +1464,19 @@ ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
1471
1464
1472
1465
context.AddTypeDecl (copied_type);
1473
1466
}
1467
+
1468
+ void *
1469
+ ClangExpressionDeclMap::GuardedCopyType (ASTContext *dest_context,
1470
+ ASTContext *source_context,
1471
+ void *clang_type)
1472
+ {
1473
+ m_ignore_lookups = true ;
1474
+
1475
+ void *ret = ClangASTContext::CopyType (dest_context,
1476
+ source_context,
1477
+ clang_type);
1478
+
1479
+ m_ignore_lookups = false ;
1480
+
1481
+ return ret;
1482
+ }
0 commit comments