| OLD | NEW | 
|    1 // Copyright 2014 The Chromium Authors. All rights reserved. |    1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "Config.h" |    5 #include "Config.h" | 
|    6 #include "RecordInfo.h" |    6 #include "RecordInfo.h" | 
|    7 #include "clang/Sema/Sema.h" |  | 
|    8  |    7  | 
|    9 using namespace clang; |    8 using namespace clang; | 
|   10 using std::string; |    9 using std::string; | 
|   11  |   10  | 
|   12 RecordInfo::RecordInfo(CXXRecordDecl* record, RecordCache* cache) |   11 RecordInfo::RecordInfo(CXXRecordDecl* record, RecordCache* cache) | 
|   13     : cache_(cache), |   12     : cache_(cache), | 
|   14       record_(record), |   13       record_(record), | 
|   15       name_(record->getName()), |   14       name_(record->getName()), | 
|   16       fields_need_tracing_(TracingStatus::Unknown()), |   15       fields_need_tracing_(TracingStatus::Unknown()), | 
|   17       bases_(0), |   16       bases_(0), | 
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  582       return new RefPtr(ptr); |  581       return new RefPtr(ptr); | 
|  583     return 0; |  582     return 0; | 
|  584   } |  583   } | 
|  585  |  584  | 
|  586   if (Config::IsOwnPtr(info->name()) && info->GetTemplateArgs(1, &args)) { |  585   if (Config::IsOwnPtr(info->name()) && info->GetTemplateArgs(1, &args)) { | 
|  587     if (Edge* ptr = CreateEdge(args[0])) |  586     if (Edge* ptr = CreateEdge(args[0])) | 
|  588       return new OwnPtr(ptr); |  587       return new OwnPtr(ptr); | 
|  589     return 0; |  588     return 0; | 
|  590   } |  589   } | 
|  591  |  590  | 
|  592   if (Config::IsUniquePtr(info->name()) && info->GetTemplateArgs(1, &args)) { |  | 
|  593     // Check that this is std::unique_ptr |  | 
|  594     NamespaceDecl* ns = |  | 
|  595         dyn_cast<NamespaceDecl>(info->record()->getDeclContext()); |  | 
|  596     if (!ns) |  | 
|  597       return 0; |  | 
|  598  |  | 
|  599     clang::Sema& sema = cache_->instance().getSema(); |  | 
|  600     if (ns != sema.getStdNamespace()) |  | 
|  601       return 0; |  | 
|  602     if (Edge* ptr = CreateEdge(args[0])) |  | 
|  603       return new UniquePtr(ptr); |  | 
|  604     return 0; |  | 
|  605   } |  | 
|  606  |  | 
|  607   if (Config::IsMember(info->name()) && info->GetTemplateArgs(1, &args)) { |  591   if (Config::IsMember(info->name()) && info->GetTemplateArgs(1, &args)) { | 
|  608     if (Edge* ptr = CreateEdge(args[0])) |  592     if (Edge* ptr = CreateEdge(args[0])) | 
|  609       return new Member(ptr); |  593       return new Member(ptr); | 
|  610     return 0; |  594     return 0; | 
|  611   } |  595   } | 
|  612  |  596  | 
|  613   if (Config::IsWeakMember(info->name()) && info->GetTemplateArgs(1, &args)) { |  597   if (Config::IsWeakMember(info->name()) && info->GetTemplateArgs(1, &args)) { | 
|  614     if (Edge* ptr = CreateEdge(args[0])) |  598     if (Edge* ptr = CreateEdge(args[0])) | 
|  615       return new WeakMember(ptr); |  599       return new WeakMember(ptr); | 
|  616     return 0; |  600     return 0; | 
|  617   } |  601   } | 
|  618  |  602  | 
|  619   bool is_persistent = Config::IsPersistent(info->name()); |  603   if (Config::IsPersistent(info->name())) { | 
|  620   if (is_persistent || Config::IsCrossThreadPersistent(info->name())) { |  | 
|  621     // Persistent might refer to v8::Persistent, so check the name space. |  604     // Persistent might refer to v8::Persistent, so check the name space. | 
|  622     // TODO: Consider using a more canonical identification than names. |  605     // TODO: Consider using a more canonical identification than names. | 
|  623     NamespaceDecl* ns = |  606     NamespaceDecl* ns = | 
|  624         dyn_cast<NamespaceDecl>(info->record()->getDeclContext()); |  607         dyn_cast<NamespaceDecl>(info->record()->getDeclContext()); | 
|  625     if (!ns || ns->getName() != "blink") |  608     if (!ns || ns->getName() != "blink") | 
|  626       return 0; |  609       return 0; | 
|  627     if (!info->GetTemplateArgs(1, &args)) |  610     if (!info->GetTemplateArgs(1, &args)) | 
|  628       return 0; |  611       return 0; | 
|  629     if (Edge* ptr = CreateEdge(args[0])) { |  612     if (Edge* ptr = CreateEdge(args[0])) | 
|  630       if (is_persistent) |  613       return new Persistent(ptr); | 
|  631         return new Persistent(ptr); |  | 
|  632       else |  | 
|  633         return new CrossThreadPersistent(ptr); |  | 
|  634     } |  | 
|  635     return 0; |  614     return 0; | 
|  636   } |  615   } | 
|  637  |  616  | 
|  638   if (Config::IsGCCollection(info->name()) || |  617   if (Config::IsGCCollection(info->name()) || | 
|  639       Config::IsWTFCollection(info->name())) { |  618       Config::IsWTFCollection(info->name())) { | 
|  640     bool is_root = Config::IsPersistentGCCollection(info->name()); |  619     bool is_root = Config::IsPersistentGCCollection(info->name()); | 
|  641     bool on_heap = is_root || info->IsHeapAllocatedCollection(); |  620     bool on_heap = is_root || info->IsHeapAllocatedCollection(); | 
|  642     size_t count = Config::CollectionDimension(info->name()); |  621     size_t count = Config::CollectionDimension(info->name()); | 
|  643     if (!info->GetTemplateArgs(count, &args)) |  622     if (!info->GetTemplateArgs(count, &args)) | 
|  644       return 0; |  623       return 0; | 
|  645     Collection* edge = new Collection(info, on_heap, is_root); |  624     Collection* edge = new Collection(info, on_heap, is_root); | 
|  646     for (TemplateArgs::iterator it = args.begin(); it != args.end(); ++it) { |  625     for (TemplateArgs::iterator it = args.begin(); it != args.end(); ++it) { | 
|  647       if (Edge* member = CreateEdge(*it)) { |  626       if (Edge* member = CreateEdge(*it)) { | 
|  648         edge->members().push_back(member); |  627         edge->members().push_back(member); | 
|  649       } |  628       } | 
|  650       // TODO: Handle the case where we fail to create an edge (eg, if the |  629       // TODO: Handle the case where we fail to create an edge (eg, if the | 
|  651       // argument is a primitive type or just not fully known yet). |  630       // argument is a primitive type or just not fully known yet). | 
|  652     } |  631     } | 
|  653     return edge; |  632     return edge; | 
|  654   } |  633   } | 
|  655  |  634  | 
|  656   return new Value(info); |  635   return new Value(info); | 
|  657 } |  636 } | 
| OLD | NEW |