| Index: tools/clang/blink_gc_plugin/RecordInfo.cpp
|
| diff --git a/tools/clang/blink_gc_plugin/RecordInfo.cpp b/tools/clang/blink_gc_plugin/RecordInfo.cpp
|
| index 419ed7ae764ce261f18e8986ac26d7aff52a98be..2bce77147605fdd0ad16dfc66399f998a508f6d1 100644
|
| --- a/tools/clang/blink_gc_plugin/RecordInfo.cpp
|
| +++ b/tools/clang/blink_gc_plugin/RecordInfo.cpp
|
| @@ -107,6 +107,27 @@ CXXRecordDecl* RecordInfo::GetDependentTemplatedDecl(const Type& type) {
|
| return dyn_cast_or_null<CXXRecordDecl>(tmpl_decl->getTemplatedDecl());
|
| }
|
|
|
| +const Type* RecordInfo::GetPersistentArgumentType(bool& has_persistent_name) {
|
| + has_persistent_name =
|
| + Config::IsPersistent(name()) || Config::IsCrossThreadPersistent(name());
|
| + if (!has_persistent_name)
|
| + return nullptr;
|
| +
|
| + // "Persistent" could refer to v8::Persistent, check the name space.
|
| + if (!IsInBlinkNamespace())
|
| + return nullptr;
|
| +
|
| + TemplateArgs args;
|
| + if (!GetTemplateArgs(1, &args))
|
| + return nullptr;
|
| + return args[0];
|
| +}
|
| +
|
| +bool RecordInfo::IsInBlinkNamespace() {
|
| + NamespaceDecl* ns = dyn_cast<NamespaceDecl>(record()->getDeclContext());
|
| + return ns && ns->getName() == "blink";
|
| +}
|
| +
|
| void RecordInfo::walkBases() {
|
| // This traversal is akin to CXXRecordDecl::forallBases()'s,
|
| // but without stepping over dependent bases -- these might also
|
| @@ -514,20 +535,23 @@ bool RecordInfo::NeedsFinalization() {
|
| return does_need_finalization_;
|
|
|
| CXXDestructorDecl* dtor = record_->getDestructor();
|
| - if (dtor && dtor->isUserProvided())
|
| + if (dtor && dtor->isUserProvided()) {
|
| return does_need_finalization_;
|
| + }
|
| for (Fields::iterator it = GetFields().begin();
|
| it != GetFields().end();
|
| ++it) {
|
| - if (it->second.edge()->NeedsFinalization())
|
| + if (it->second.edge()->NeedsFinalization()) {
|
| return does_need_finalization_;
|
| + }
|
| }
|
|
|
| for (Bases::iterator it = GetBases().begin();
|
| it != GetBases().end();
|
| ++it) {
|
| - if (it->second.info()->NeedsFinalization())
|
| + if (it->second.info()->NeedsFinalization()) {
|
| return does_need_finalization_;
|
| + }
|
| }
|
| // Destructor was non-trivial due to bases with destructors that
|
| // can be safely ignored. Hence, no need for finalization.
|
| @@ -655,23 +679,19 @@ Edge* RecordInfo::CreateEdge(const Type* type) {
|
| return 0;
|
| }
|
|
|
| - bool is_persistent = Config::IsPersistent(info->name());
|
| - if (is_persistent || Config::IsCrossThreadPersistent(info->name())) {
|
| - // Persistent might refer to v8::Persistent, so check the name space.
|
| - // TODO: Consider using a more canonical identification than names.
|
| - NamespaceDecl* ns =
|
| - dyn_cast<NamespaceDecl>(info->record()->getDeclContext());
|
| - if (!ns || ns->getName() != "blink")
|
| - return 0;
|
| - if (!info->GetTemplateArgs(1, &args))
|
| - return 0;
|
| - if (Edge* ptr = CreateEdge(args[0])) {
|
| - if (is_persistent)
|
| + bool has_persistent_name = false;
|
| + if (const Type* arg_type =
|
| + info->GetPersistentArgumentType(has_persistent_name)) {
|
| + if (Edge* ptr = CreateEdge(arg_type)) {
|
| + if (Config::IsPersistent(info->name()))
|
| return new Persistent(ptr);
|
| else
|
| return new CrossThreadPersistent(ptr);
|
| }
|
| - return 0;
|
| + return nullptr;
|
| + } else if (has_persistent_name) {
|
| + // Other Persistent type names are not relevant, like v8::Persistent<>.
|
| + return nullptr;
|
| }
|
|
|
| if (Config::IsGCCollection(info->name()) ||
|
|
|