blob: 59c2f6a737d9900a912f328ad7c48776a94fa0a5 [file] [log] [blame]
Greg Claytona2721472011-06-25 00:44:06 +00001//===-- ClangASTImporter.cpp ------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "clang/AST/Decl.h"
Sean Callanancbbe3ac2012-01-13 22:55:55 +000011#include "clang/AST/DeclCXX.h"
Sean Callanancc427fa2011-07-30 02:42:06 +000012#include "clang/AST/DeclObjC.h"
13#include "lldb/Core/Log.h"
Greg Clayton7c6d7b82011-10-21 23:04:20 +000014#include "lldb/Core/Module.h"
Greg Claytona2721472011-06-25 00:44:06 +000015#include "lldb/Symbol/ClangASTContext.h"
16#include "lldb/Symbol/ClangASTImporter.h"
Sean Callananb2269162011-10-21 22:18:07 +000017#include "lldb/Symbol/ClangNamespaceDecl.h"
Greg Claytona2721472011-06-25 00:44:06 +000018
19using namespace lldb_private;
20using namespace clang;
21
22clang::QualType
Sean Callanan686b2312011-11-16 18:20:47 +000023ClangASTImporter::CopyType (clang::ASTContext *dst_ast,
24 clang::ASTContext *src_ast,
Greg Claytona2721472011-06-25 00:44:06 +000025 clang::QualType type)
26{
Sean Callanan686b2312011-11-16 18:20:47 +000027 MinionSP minion_sp (GetMinion(dst_ast, src_ast));
Sean Callanancc427fa2011-07-30 02:42:06 +000028
Greg Claytondd0649b2011-07-06 18:55:08 +000029 if (minion_sp)
30 return minion_sp->Import(type);
Sean Callanancc427fa2011-07-30 02:42:06 +000031
Greg Claytondd0649b2011-07-06 18:55:08 +000032 return QualType();
Greg Claytona2721472011-06-25 00:44:06 +000033}
34
Sean Callanan80f78672011-11-16 19:07:39 +000035lldb::clang_type_t
36ClangASTImporter::CopyType (clang::ASTContext *dst_ast,
37 clang::ASTContext *src_ast,
38 lldb::clang_type_t type)
39{
40 return CopyType (dst_ast, src_ast, QualType::getFromOpaquePtr(type)).getAsOpaquePtr();
41}
42
Greg Claytona2721472011-06-25 00:44:06 +000043clang::Decl *
Sean Callanan686b2312011-11-16 18:20:47 +000044ClangASTImporter::CopyDecl (clang::ASTContext *dst_ast,
45 clang::ASTContext *src_ast,
Greg Claytona2721472011-06-25 00:44:06 +000046 clang::Decl *decl)
47{
Greg Claytondd0649b2011-07-06 18:55:08 +000048 MinionSP minion_sp;
Greg Claytona2721472011-06-25 00:44:06 +000049
Sean Callanan686b2312011-11-16 18:20:47 +000050 minion_sp = GetMinion(dst_ast, src_ast);
Greg Claytona2721472011-06-25 00:44:06 +000051
Greg Claytondd0649b2011-07-06 18:55:08 +000052 if (minion_sp)
Sean Callananbfb237bc2011-11-04 22:46:46 +000053 {
54 clang::Decl *result = minion_sp->Import(decl);
55
56 if (!result)
57 {
58 lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
59
Sean Callanand5145b32011-11-05 00:08:12 +000060 if (log)
61 {
62 if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
63 log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s '%s'", decl->getDeclKindName(), named_decl->getNameAsString().c_str());
64 else
65 log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s", decl->getDeclKindName());
66 }
Sean Callananbfb237bc2011-11-04 22:46:46 +000067 }
68
69 return result;
70 }
Sean Callanancc427fa2011-07-30 02:42:06 +000071
Greg Claytondd0649b2011-07-06 18:55:08 +000072 return NULL;
Greg Claytona2721472011-06-25 00:44:06 +000073}
74
Sean Callananbb120042011-12-16 21:06:35 +000075lldb::clang_type_t
76ClangASTImporter::DeportType (clang::ASTContext *dst_ctx,
77 clang::ASTContext *src_ctx,
78 lldb::clang_type_t type)
79{
80 lldb::clang_type_t result = CopyType(dst_ctx, src_ctx, type);
81
82 if (!result)
83 return NULL;
84
85 QualType qual_type = QualType::getFromOpaquePtr(type);
86
87 if (const TagType *tag_type = qual_type->getAs<TagType>())
88 {
89 TagDecl *tag_decl = tag_type->getDecl();
90 const TagType *result_tag_type = QualType::getFromOpaquePtr(result)->getAs<TagType>();
91 TagDecl *result_tag_decl = result_tag_type->getDecl();
92
93 if (tag_decl)
94 {
95 MinionSP minion_sp (GetMinion (dst_ctx, src_ctx));
96
Sean Callanancbbe3ac2012-01-13 22:55:55 +000097 minion_sp->ImportDefinitionTo(result_tag_decl, tag_decl);
Sean Callananbb120042011-12-16 21:06:35 +000098
99 ASTContextMetadataSP to_context_md = GetContextMetadata(dst_ctx);
100
Sean Callanancbbe3ac2012-01-13 22:55:55 +0000101 OriginMap::iterator oi = to_context_md->m_origins.find(result_tag_decl);
102
103 if (oi != to_context_md->m_origins.end() &&
104 oi->second.ctx == src_ctx)
105 to_context_md->m_origins.erase(oi);
Sean Callananbb120042011-12-16 21:06:35 +0000106 }
107 }
108
109 return result;
110}
111
Sean Callanan0eed0d42011-12-06 03:41:14 +0000112clang::Decl *
113ClangASTImporter::DeportDecl (clang::ASTContext *dst_ctx,
114 clang::ASTContext *src_ctx,
115 clang::Decl *decl)
116{
117 clang::Decl *result = CopyDecl(dst_ctx, src_ctx, decl);
118
119 if (!result)
120 return NULL;
121
122 ClangASTContext::GetCompleteDecl (src_ctx, decl);
123
124 MinionSP minion_sp (GetMinion (dst_ctx, src_ctx));
125
126 if (minion_sp && isa<TagDecl>(decl))
Sean Callanancbbe3ac2012-01-13 22:55:55 +0000127 minion_sp->ImportDefinitionTo(result, decl);
Sean Callanan0eed0d42011-12-06 03:41:14 +0000128
129 ASTContextMetadataSP to_context_md = GetContextMetadata(dst_ctx);
130
Sean Callanancbbe3ac2012-01-13 22:55:55 +0000131 OriginMap::iterator oi = to_context_md->m_origins.find(decl);
132
133 if (oi != to_context_md->m_origins.end() &&
134 oi->second.ctx == src_ctx)
135 to_context_md->m_origins.erase(oi);
Sean Callanan0eed0d42011-12-06 03:41:14 +0000136
137 return result;
138}
139
Sean Callanan12014a02011-12-08 23:45:45 +0000140bool
Sean Callanancc427fa2011-07-30 02:42:06 +0000141ClangASTImporter::CompleteTagDecl (clang::TagDecl *decl)
Sean Callanan12014a02011-12-08 23:45:45 +0000142{
Sean Callanancc427fa2011-07-30 02:42:06 +0000143 DeclOrigin decl_origin = GetDeclOrigin(decl);
Greg Claytona2721472011-06-25 00:44:06 +0000144
Sean Callanancc427fa2011-07-30 02:42:06 +0000145 if (!decl_origin.Valid())
Sean Callanan12014a02011-12-08 23:45:45 +0000146 return false;
Greg Claytona2721472011-06-25 00:44:06 +0000147
Sean Callanancc427fa2011-07-30 02:42:06 +0000148 if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
Sean Callanan12014a02011-12-08 23:45:45 +0000149 return false;
Greg Claytona2721472011-06-25 00:44:06 +0000150
Sean Callanan686b2312011-11-16 18:20:47 +0000151 MinionSP minion_sp (GetMinion(&decl->getASTContext(), decl_origin.ctx));
Greg Claytona2721472011-06-25 00:44:06 +0000152
Greg Claytondd0649b2011-07-06 18:55:08 +0000153 if (minion_sp)
Sean Callanancbbe3ac2012-01-13 22:55:55 +0000154 minion_sp->ImportDefinitionTo(decl, decl_origin.decl);
155
Sean Callanan12014a02011-12-08 23:45:45 +0000156 return true;
Greg Claytona2721472011-06-25 00:44:06 +0000157}
Sean Callanancc427fa2011-07-30 02:42:06 +0000158
Sean Callanan12014a02011-12-08 23:45:45 +0000159bool
160ClangASTImporter::CompleteTagDeclWithOrigin(clang::TagDecl *decl, clang::TagDecl *origin_decl)
161{
162 clang::ASTContext *origin_ast_ctx = &origin_decl->getASTContext();
163
164 if (!ClangASTContext::GetCompleteDecl(origin_ast_ctx, origin_decl))
165 return false;
166
167 MinionSP minion_sp (GetMinion(&decl->getASTContext(), origin_ast_ctx));
168
169 if (minion_sp)
Sean Callanancbbe3ac2012-01-13 22:55:55 +0000170 minion_sp->ImportDefinitionTo(decl, origin_decl);
171
Sean Callanan12014a02011-12-08 23:45:45 +0000172 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
173
174 OriginMap &origins = context_md->m_origins;
175
176 origins[decl] = DeclOrigin(origin_ast_ctx, origin_decl);
177
178 return true;
179}
180
181bool
Sean Callanancc427fa2011-07-30 02:42:06 +0000182ClangASTImporter::CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl)
183{
184 lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
185
Sean Callanancc427fa2011-07-30 02:42:06 +0000186 DeclOrigin decl_origin = GetDeclOrigin(interface_decl);
187
188 if (!decl_origin.Valid())
Sean Callanan12014a02011-12-08 23:45:45 +0000189 return false;
Sean Callanancc427fa2011-07-30 02:42:06 +0000190
191 if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
Sean Callanan12014a02011-12-08 23:45:45 +0000192 return false;
Sean Callanancc427fa2011-07-30 02:42:06 +0000193
Sean Callanan686b2312011-11-16 18:20:47 +0000194 MinionSP minion_sp (GetMinion(&interface_decl->getASTContext(), decl_origin.ctx));
Sean Callanancc427fa2011-07-30 02:42:06 +0000195
196 if (minion_sp)
Sean Callanancbbe3ac2012-01-13 22:55:55 +0000197 minion_sp->ImportDefinitionTo(interface_decl, decl_origin.decl);
198
Sean Callanan12014a02011-12-08 23:45:45 +0000199 return true;
Sean Callanancc427fa2011-07-30 02:42:06 +0000200}
201
Sean Callananf487bd82011-11-16 21:40:57 +0000202ClangASTImporter::DeclOrigin
203ClangASTImporter::GetDeclOrigin(const clang::Decl *decl)
204{
205 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
206
207 OriginMap &origins = context_md->m_origins;
208
209 OriginMap::iterator iter = origins.find(decl);
210
211 if (iter != origins.end())
212 return iter->second;
213 else
214 return DeclOrigin();
215}
216
Sean Callanan503aa522011-10-12 00:12:34 +0000217void
218ClangASTImporter::RegisterNamespaceMap(const clang::NamespaceDecl *decl,
219 NamespaceMapSP &namespace_map)
220{
Sean Callananf487bd82011-11-16 21:40:57 +0000221 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
222
223 context_md->m_namespace_maps[decl] = namespace_map;
Sean Callanan503aa522011-10-12 00:12:34 +0000224}
225
226ClangASTImporter::NamespaceMapSP
227ClangASTImporter::GetNamespaceMap(const clang::NamespaceDecl *decl)
228{
Sean Callananf487bd82011-11-16 21:40:57 +0000229 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
230
231 NamespaceMetaMap &namespace_maps = context_md->m_namespace_maps;
Sean Callanan503aa522011-10-12 00:12:34 +0000232
Sean Callananf487bd82011-11-16 21:40:57 +0000233 NamespaceMetaMap::iterator iter = namespace_maps.find(decl);
234
235 if (iter != namespace_maps.end())
Sean Callanan503aa522011-10-12 00:12:34 +0000236 return iter->second;
237 else
238 return NamespaceMapSP();
239}
240
Sean Callananb2269162011-10-21 22:18:07 +0000241void
242ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl)
243{
Sean Callananf487bd82011-11-16 21:40:57 +0000244 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
245
Sean Callananb2269162011-10-21 22:18:07 +0000246 const DeclContext *parent_context = decl->getDeclContext();
247 const NamespaceDecl *parent_namespace = dyn_cast<NamespaceDecl>(parent_context);
248 NamespaceMapSP parent_map;
249
250 if (parent_namespace)
251 parent_map = GetNamespaceMap(parent_namespace);
252
253 NamespaceMapSP new_map;
254
255 new_map.reset(new NamespaceMap);
256
Sean Callananf487bd82011-11-16 21:40:57 +0000257 if (context_md->m_map_completer)
Sean Callananb2269162011-10-21 22:18:07 +0000258 {
259 std::string namespace_string = decl->getDeclName().getAsString();
260
Sean Callananf487bd82011-11-16 21:40:57 +0000261 context_md->m_map_completer->CompleteNamespaceMap (new_map, ConstString(namespace_string.c_str()), parent_map);
Sean Callananb2269162011-10-21 22:18:07 +0000262 }
263
Sean Callanan0eed0d42011-12-06 03:41:14 +0000264 context_md->m_namespace_maps[decl] = new_map;
Sean Callananb2269162011-10-21 22:18:07 +0000265}
266
Sean Callanan686b2312011-11-16 18:20:47 +0000267void
Sean Callanan99732312011-11-29 00:42:02 +0000268ClangASTImporter::ForgetDestination (clang::ASTContext *dst_ast)
Sean Callanan686b2312011-11-16 18:20:47 +0000269{
Sean Callanancbbe3ac2012-01-13 22:55:55 +0000270 lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
271
272 if (log)
273 log->Printf(" [ClangASTImporter] Forgetting destination (ASTContext*)%p", dst_ast);
274
Sean Callananf487bd82011-11-16 21:40:57 +0000275 m_metadata_map.erase(dst_ast);
Sean Callanan686b2312011-11-16 18:20:47 +0000276}
277
Sean Callanan99732312011-11-29 00:42:02 +0000278void
279ClangASTImporter::ForgetSource (clang::ASTContext *dst_ast, clang::ASTContext *src_ast)
280{
281 ASTContextMetadataSP md = MaybeGetContextMetadata (dst_ast);
282
Sean Callanancbbe3ac2012-01-13 22:55:55 +0000283 lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
284
285 if (log)
286 log->Printf(" [ClangASTImporter] Forgetting source->dest (ASTContext*)%p->(ASTContext*)%p", src_ast, dst_ast);
287
Sean Callanan99732312011-11-29 00:42:02 +0000288 if (!md)
289 return;
290
291 md->m_minions.erase(src_ast);
292
293 for (OriginMap::iterator iter = md->m_origins.begin();
294 iter != md->m_origins.end();
295 )
296 {
297 if (iter->second.ctx == src_ast)
298 md->m_origins.erase(iter++);
299 else
300 ++iter;
301 }
302}
303
Sean Callanan0eed0d42011-12-06 03:41:14 +0000304ClangASTImporter::MapCompleter::~MapCompleter ()
Sean Callananb2269162011-10-21 22:18:07 +0000305{
306 return;
307}
308
Sean Callanan0eed0d42011-12-06 03:41:14 +0000309ClangASTImporter::ObjCInterfaceMapSP
310ClangASTImporter::GetObjCInterfaceMap (const clang::ObjCInterfaceDecl *decl)
311{
312 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
313
314 ObjCInterfaceMetaMap &objc_interface_maps = context_md->m_objc_interface_maps;
315
316 ObjCInterfaceMetaMap::iterator iter = objc_interface_maps.find(decl);
317
318 if (iter != objc_interface_maps.end())
319 return iter->second;
320 else
321 return ObjCInterfaceMapSP();
322}
323
324void
325ClangASTImporter::BuildObjCInterfaceMap (const clang::ObjCInterfaceDecl *decl)
326{
327 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
328
329 ObjCInterfaceMapSP new_map(new ObjCInterfaceMap);
330
331 if (context_md->m_map_completer)
332 {
333 std::string namespace_string = decl->getDeclName().getAsString();
334
335 context_md->m_map_completer->CompleteObjCInterfaceMap(new_map, ConstString(namespace_string.c_str()));
336 }
337
338 context_md->m_objc_interface_maps[decl] = new_map;
339}
340
Sean Callanancbbe3ac2012-01-13 22:55:55 +0000341void
342ClangASTImporter::Minion::ImportDefinitionTo (clang::Decl *to, clang::Decl *from)
343{
344 ASTImporter::Imported(from, to);
345
346 ImportDefinition(from);
347}
348
Sean Callanancc427fa2011-07-30 02:42:06 +0000349clang::Decl
350*ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to)
351{
352 lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Sean Callanan00f43622011-11-18 03:28:09 +0000353
354 if (log)
355 {
356 if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from))
357 {
358 log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p, named %s (from (Decl*)%p)",
359 from->getDeclKindName(),
360 to,
361 from_named_decl->getName().str().c_str(),
362 from);
363 }
364 else
365 {
366 log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p (from (Decl*)%p)",
367 from->getDeclKindName(),
368 to,
369 from);
370 }
371 }
372
Sean Callananb0b87a52011-11-16 22:23:28 +0000373 ASTContextMetadataSP to_context_md = m_master.GetContextMetadata(&to->getASTContext());
374 ASTContextMetadataSP from_context_md = m_master.MaybeGetContextMetadata(m_source_ctx);
Sean Callananf487bd82011-11-16 21:40:57 +0000375
Sean Callananb0b87a52011-11-16 22:23:28 +0000376 if (from_context_md)
377 {
378 OriginMap &origins = from_context_md->m_origins;
379
380 OriginMap::iterator origin_iter = origins.find(from);
381
382 if (origin_iter != origins.end())
Sean Callanan00f43622011-11-18 03:28:09 +0000383 {
Sean Callananb0b87a52011-11-16 22:23:28 +0000384 to_context_md->m_origins[to] = origin_iter->second;
Sean Callanan00f43622011-11-18 03:28:09 +0000385
Sean Callanan5bc5a762011-12-20 23:55:47 +0000386 MinionSP direct_completer = m_master.GetMinion(&to->getASTContext(), origin_iter->second.ctx);
387
388 if (direct_completer.get() != this)
389 direct_completer->ASTImporter::Imported(origin_iter->second.decl, to);
390
Sean Callanan00f43622011-11-18 03:28:09 +0000391 if (log)
392 log->Printf(" [ClangASTImporter] Propagated origin (Decl*)%p/(ASTContext*)%p from (ASTContext*)%p to (ASTContext*)%p",
393 origin_iter->second.decl,
394 origin_iter->second.ctx,
395 &from->getASTContext(),
396 &to->getASTContext());
397 }
398 else
399 {
Sean Callanan0eed0d42011-12-06 03:41:14 +0000400 to_context_md->m_origins[to] = DeclOrigin(m_source_ctx, from);
401
Sean Callanan00f43622011-11-18 03:28:09 +0000402 if (log)
403 log->Printf(" [ClangASTImporter] Decl has no origin information in (ASTContext*)%p",
404 &from->getASTContext());
405 }
Sean Callananb0b87a52011-11-16 22:23:28 +0000406
407 if (clang::NamespaceDecl *to_namespace = dyn_cast<clang::NamespaceDecl>(to))
408 {
409 clang::NamespaceDecl *from_namespace = dyn_cast<clang::NamespaceDecl>(from);
410
411 NamespaceMetaMap &namespace_maps = from_context_md->m_namespace_maps;
412
413 NamespaceMetaMap::iterator namespace_map_iter = namespace_maps.find(from_namespace);
414
415 if (namespace_map_iter != namespace_maps.end())
416 to_context_md->m_namespace_maps[to_namespace] = namespace_map_iter->second;
417 }
418 }
419 else
420 {
421 to_context_md->m_origins[to] = DeclOrigin (m_source_ctx, from);
Sean Callanan00f43622011-11-18 03:28:09 +0000422
423 if (log)
424 log->Printf(" [ClangASTImporter] Sourced origin (Decl*)%p/(ASTContext*)%p into (ASTContext*)%p",
425 from,
426 m_source_ctx,
427 &to->getASTContext());
Sean Callananb0b87a52011-11-16 22:23:28 +0000428 }
429
Sean Callanancc427fa2011-07-30 02:42:06 +0000430 if (TagDecl *from_tag_decl = dyn_cast<TagDecl>(from))
431 {
432 TagDecl *to_tag_decl = dyn_cast<TagDecl>(to);
433
434 to_tag_decl->setHasExternalLexicalStorage();
Sean Callanan0730e9c2011-11-09 19:33:21 +0000435
Sean Callanancc427fa2011-07-30 02:42:06 +0000436 if (log)
Sean Callanan00f43622011-11-18 03:28:09 +0000437 log->Printf(" [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]",
Sean Callanancc427fa2011-07-30 02:42:06 +0000438 (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
Sean Callanan0730e9c2011-11-09 19:33:21 +0000439 (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""),
440 (from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"),
441 (to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"));
Sean Callanan00f43622011-11-18 03:28:09 +0000442
443 to_tag_decl = NULL;
Sean Callanancc427fa2011-07-30 02:42:06 +0000444 }
445
Sean Callananb2269162011-10-21 22:18:07 +0000446 if (isa<NamespaceDecl>(from))
447 {
448 NamespaceDecl *to_namespace_decl = dyn_cast<NamespaceDecl>(to);
449
450 m_master.BuildNamespaceMap(to_namespace_decl);
451
452 to_namespace_decl->setHasExternalVisibleStorage();
453 }
454
Sean Callanan00f43622011-11-18 03:28:09 +0000455 if (isa<ObjCInterfaceDecl>(from))
Sean Callanancc427fa2011-07-30 02:42:06 +0000456 {
457 ObjCInterfaceDecl *to_interface_decl = dyn_cast<ObjCInterfaceDecl>(to);
458
Sean Callanan0eed0d42011-12-06 03:41:14 +0000459 m_master.BuildObjCInterfaceMap(to_interface_decl);
460
Sean Callanand5c17ed2011-11-15 02:11:17 +0000461 to_interface_decl->setHasExternalLexicalStorage();
Sean Callanan0730e9c2011-11-09 19:33:21 +0000462 to_interface_decl->setHasExternalVisibleStorage();
463
Sean Callanand5c17ed2011-11-15 02:11:17 +0000464 if (to_interface_decl->isForwardDecl())
465 to_interface_decl->completedForwardDecl();
Sean Callananbb120042011-12-16 21:06:35 +0000466
Sean Callanand5c17ed2011-11-15 02:11:17 +0000467 to_interface_decl->setExternallyCompleted();
Sean Callanan0eed0d42011-12-06 03:41:14 +0000468
Sean Callanand5c17ed2011-11-15 02:11:17 +0000469 if (log)
Sean Callanan00f43622011-11-18 03:28:09 +0000470 log->Printf(" [ClangASTImporter] To is an ObjCInterfaceDecl - attributes %s%s%s",
Sean Callanand5c17ed2011-11-15 02:11:17 +0000471 (to_interface_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
472 (to_interface_decl->hasExternalVisibleStorage() ? " Visible" : ""),
473 (to_interface_decl->isForwardDecl() ? " Forward" : ""));
Sean Callanancc427fa2011-07-30 02:42:06 +0000474 }
475
476 return clang::ASTImporter::Imported(from, to);
Greg Clayton3418c852011-08-10 02:10:13 +0000477}