Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: tools/clang/blink_gc_plugin/RecordInfo.cpp

Issue 2060553002: GC plugin: improve error reporting when tracing illegal fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/clang/blink_gc_plugin/RecordInfo.h ('k') | tools/clang/blink_gc_plugin/TracingStatus.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 using namespace clang; 8 using namespace clang;
9 using std::string; 9 using std::string;
10 10
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 return new RefPtr(ptr); 592 return new RefPtr(ptr);
593 return 0; 593 return 0;
594 } 594 }
595 595
596 if (Config::IsOwnPtr(info->name()) && info->GetTemplateArgs(1, &args)) { 596 if (Config::IsOwnPtr(info->name()) && info->GetTemplateArgs(1, &args)) {
597 if (Edge* ptr = CreateEdge(args[0])) 597 if (Edge* ptr = CreateEdge(args[0]))
598 return new OwnPtr(ptr); 598 return new OwnPtr(ptr);
599 return 0; 599 return 0;
600 } 600 }
601 601
602 if (Config::IsUniquePtr(info->name()) && info->GetTemplateArgs(1, &args)) {
603 // Check that this is std::unique_ptr
604 NamespaceDecl* ns =
605 dyn_cast<NamespaceDecl>(info->record()->getDeclContext());
606 if (!ns || ns->getName() != "std")
Nico 2016/06/14 11:35:15 (this isn't new in this patch, but in general i th
sof 2016/06/14 21:01:22 Thanks for the Sema tip, adjusted to use instead.
607 return 0;
608 if (!info->GetTemplateArgs(1, &args))
609 return 0;
610 if (Edge* ptr = CreateEdge(args[0]))
611 return new UniquePtr(ptr);
612 return 0;
613 }
614
602 if (Config::IsMember(info->name()) && info->GetTemplateArgs(1, &args)) { 615 if (Config::IsMember(info->name()) && info->GetTemplateArgs(1, &args)) {
603 if (Edge* ptr = CreateEdge(args[0])) 616 if (Edge* ptr = CreateEdge(args[0]))
604 return new Member(ptr); 617 return new Member(ptr);
605 return 0; 618 return 0;
606 } 619 }
607 620
608 if (Config::IsWeakMember(info->name()) && info->GetTemplateArgs(1, &args)) { 621 if (Config::IsWeakMember(info->name()) && info->GetTemplateArgs(1, &args)) {
609 if (Edge* ptr = CreateEdge(args[0])) 622 if (Edge* ptr = CreateEdge(args[0]))
610 return new WeakMember(ptr); 623 return new WeakMember(ptr);
611 return 0; 624 return 0;
612 } 625 }
613 626
614 if (Config::IsPersistent(info->name())) { 627 bool is_persistent = Config::IsPersistent(info->name());
628 if (is_persistent || Config::IsCrossThreadPersistent(info->name())) {
615 // Persistent might refer to v8::Persistent, so check the name space. 629 // Persistent might refer to v8::Persistent, so check the name space.
616 // TODO: Consider using a more canonical identification than names. 630 // TODO: Consider using a more canonical identification than names.
617 NamespaceDecl* ns = 631 NamespaceDecl* ns =
618 dyn_cast<NamespaceDecl>(info->record()->getDeclContext()); 632 dyn_cast<NamespaceDecl>(info->record()->getDeclContext());
619 if (!ns || ns->getName() != "blink") 633 if (!ns || ns->getName() != "blink")
620 return 0; 634 return 0;
621 if (!info->GetTemplateArgs(1, &args)) 635 if (!info->GetTemplateArgs(1, &args))
622 return 0; 636 return 0;
623 if (Edge* ptr = CreateEdge(args[0])) 637 if (Edge* ptr = CreateEdge(args[0])) {
624 return new Persistent(ptr); 638 if (is_persistent)
639 return new Persistent(ptr);
640 else
641 return new CrossThreadPersistent(ptr);
642 }
625 return 0; 643 return 0;
626 } 644 }
627 645
628 if (Config::IsGCCollection(info->name()) || 646 if (Config::IsGCCollection(info->name()) ||
629 Config::IsWTFCollection(info->name())) { 647 Config::IsWTFCollection(info->name())) {
630 bool is_root = Config::IsPersistentGCCollection(info->name()); 648 bool is_root = Config::IsPersistentGCCollection(info->name());
631 bool on_heap = is_root || info->IsHeapAllocatedCollection(); 649 bool on_heap = is_root || info->IsHeapAllocatedCollection();
632 size_t count = Config::CollectionDimension(info->name()); 650 size_t count = Config::CollectionDimension(info->name());
633 if (!info->GetTemplateArgs(count, &args)) 651 if (!info->GetTemplateArgs(count, &args))
634 return 0; 652 return 0;
635 Collection* edge = new Collection(info, on_heap, is_root); 653 Collection* edge = new Collection(info, on_heap, is_root);
636 for (TemplateArgs::iterator it = args.begin(); it != args.end(); ++it) { 654 for (TemplateArgs::iterator it = args.begin(); it != args.end(); ++it) {
637 if (Edge* member = CreateEdge(*it)) { 655 if (Edge* member = CreateEdge(*it)) {
638 edge->members().push_back(member); 656 edge->members().push_back(member);
639 } 657 }
640 // TODO: Handle the case where we fail to create an edge (eg, if the 658 // TODO: Handle the case where we fail to create an edge (eg, if the
641 // argument is a primitive type or just not fully known yet). 659 // argument is a primitive type or just not fully known yet).
642 } 660 }
643 return edge; 661 return edge;
644 } 662 }
645 663
646 return new Value(info); 664 return new Value(info);
647 } 665 }
OLDNEW
« no previous file with comments | « tools/clang/blink_gc_plugin/RecordInfo.h ('k') | tools/clang/blink_gc_plugin/TracingStatus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698