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

Side by Side Diff: tools/clang/blink_gc_plugin/CheckFieldsVisitor.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: robustify namespace equality checking instead 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/CheckFieldsVisitor.h ('k') | tools/clang/blink_gc_plugin/Config.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "CheckFieldsVisitor.h" 5 #include "CheckFieldsVisitor.h"
6 6
7 #include <cassert> 7 #include <cassert>
8 8
9 #include "BlinkGCPluginOptions.h" 9 #include "BlinkGCPluginOptions.h"
10 #include "RecordInfo.h" 10 #include "RecordInfo.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 invalid_fields_.push_back(std::make_pair(current_, 79 invalid_fields_.push_back(std::make_pair(current_,
80 kMemberToGCUnmanaged)); 80 kMemberToGCUnmanaged));
81 return; 81 return;
82 } 82 }
83 83
84 if (!Parent() || !edge->value()->IsGCAllocated()) 84 if (!Parent() || !edge->value()->IsGCAllocated())
85 return; 85 return;
86 86
87 // Disallow OwnPtr<T>, RefPtr<T> and T* to stack-allocated types. 87 // Disallow OwnPtr<T>, RefPtr<T> and T* to stack-allocated types.
88 if (Parent()->IsOwnPtr() || 88 if (Parent()->IsOwnPtr() ||
89 Parent()->IsUniquePtr() ||
89 Parent()->IsRefPtr() || 90 Parent()->IsRefPtr() ||
90 (stack_allocated_host_ && Parent()->IsRawPtr())) { 91 (stack_allocated_host_ && Parent()->IsRawPtr())) {
91 invalid_fields_.push_back(std::make_pair( 92 invalid_fields_.push_back(std::make_pair(
92 current_, InvalidSmartPtr(Parent()))); 93 current_, InvalidSmartPtr(Parent())));
93 return; 94 return;
94 } 95 }
95 if (Parent()->IsRawPtr()) { 96 if (Parent()->IsRawPtr()) {
96 RawPtr* rawPtr = static_cast<RawPtr*>(Parent()); 97 RawPtr* rawPtr = static_cast<RawPtr*>(Parent());
97 Error error = rawPtr->HasReferenceType() ? 98 Error error = rawPtr->HasReferenceType() ?
98 kReferencePtrToGCManaged : kRawPtrToGCManaged; 99 kReferencePtrToGCManaged : kRawPtrToGCManaged;
99 invalid_fields_.push_back(std::make_pair(current_, error)); 100 invalid_fields_.push_back(std::make_pair(current_, error));
100 } 101 }
101 } 102 }
102 103
103 void CheckFieldsVisitor::AtCollection(Collection* edge) { 104 void CheckFieldsVisitor::AtCollection(Collection* edge) {
104 if (edge->on_heap() && Parent() && Parent()->IsOwnPtr()) 105 if (edge->on_heap() && Parent() && Parent()->IsOwnPtr())
105 invalid_fields_.push_back(std::make_pair(current_, kOwnPtrToGCManaged)); 106 invalid_fields_.push_back(std::make_pair(current_, kOwnPtrToGCManaged));
107 if (edge->on_heap() && Parent() && Parent()->IsUniquePtr())
108 invalid_fields_.push_back(std::make_pair(current_, kUniquePtrToGCManaged));
106 } 109 }
107 110
108 CheckFieldsVisitor::Error CheckFieldsVisitor::InvalidSmartPtr(Edge* ptr) { 111 CheckFieldsVisitor::Error CheckFieldsVisitor::InvalidSmartPtr(Edge* ptr) {
109 if (ptr->IsRawPtr()) { 112 if (ptr->IsRawPtr()) {
110 if (static_cast<RawPtr*>(ptr)->HasReferenceType()) 113 if (static_cast<RawPtr*>(ptr)->HasReferenceType())
111 return kReferencePtrToGCManaged; 114 return kReferencePtrToGCManaged;
112 else 115 else
113 return kRawPtrToGCManaged; 116 return kRawPtrToGCManaged;
114 } 117 }
115 if (ptr->IsRefPtr()) 118 if (ptr->IsRefPtr())
116 return kRefPtrToGCManaged; 119 return kRefPtrToGCManaged;
117 if (ptr->IsOwnPtr()) 120 if (ptr->IsOwnPtr())
118 return kOwnPtrToGCManaged; 121 return kOwnPtrToGCManaged;
122 if (ptr->IsUniquePtr())
123 return kUniquePtrToGCManaged;
119 assert(false && "Unknown smart pointer kind"); 124 assert(false && "Unknown smart pointer kind");
120 } 125 }
OLDNEW
« no previous file with comments | « tools/clang/blink_gc_plugin/CheckFieldsVisitor.h ('k') | tools/clang/blink_gc_plugin/Config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698