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

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

Issue 273873002: Blink GC plugin: require a trace method if a class derives multiple bases that need tracing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 | Annotate | Revision Log
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 CXXMethodDecl* RecordInfo::DeclaresNewOperator() { 233 CXXMethodDecl* RecordInfo::DeclaresNewOperator() {
234 for (CXXRecordDecl::method_iterator it = record_->method_begin(); 234 for (CXXRecordDecl::method_iterator it = record_->method_begin();
235 it != record_->method_end(); 235 it != record_->method_end();
236 ++it) { 236 ++it) {
237 if (it->getNameAsString() == kNewOperatorName && it->getNumParams() == 1) 237 if (it->getNameAsString() == kNewOperatorName && it->getNumParams() == 1)
238 return *it; 238 return *it;
239 } 239 }
240 return 0; 240 return 0;
241 } 241 }
242 242
243 // An object requires a tracing method if it has any fields that need tracing. 243 // An object requires a tracing method if it has any fields that need tracing
244 // or if it inherits from multiple bases that need tracing.
244 bool RecordInfo::RequiresTraceMethod() { 245 bool RecordInfo::RequiresTraceMethod() {
245 if (IsStackAllocated()) 246 if (IsStackAllocated())
246 return false; 247 return false;
248 unsigned bases_with_trace = 0;
249 for (Bases::iterator it = GetBases().begin(); it != GetBases().end(); ++it) {
250 if (it->second.NeedsTracing().IsNeeded())
251 ++bases_with_trace;
252 }
253 if (bases_with_trace > 1)
254 return true;
247 GetFields(); 255 GetFields();
248 return fields_need_tracing_.IsNeeded(); 256 return fields_need_tracing_.IsNeeded();
249 } 257 }
250 258
251 // Get the actual tracing method (ie, can be traceAfterDispatch if there is a 259 // Get the actual tracing method (ie, can be traceAfterDispatch if there is a
252 // dispatch method). 260 // dispatch method).
253 CXXMethodDecl* RecordInfo::GetTraceMethod() { 261 CXXMethodDecl* RecordInfo::GetTraceMethod() {
254 DetermineTracingMethods(); 262 DetermineTracingMethods();
255 return trace_method_; 263 return trace_method_;
256 } 264 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 edge->members().push_back(member); 524 edge->members().push_back(member);
517 } 525 }
518 // TODO: Handle the case where we fail to create an edge (eg, if the 526 // TODO: Handle the case where we fail to create an edge (eg, if the
519 // argument is a primitive type or just not fully known yet). 527 // argument is a primitive type or just not fully known yet).
520 } 528 }
521 return edge; 529 return edge;
522 } 530 }
523 531
524 return new Value(info); 532 return new Value(info);
525 } 533 }
OLDNEW
« no previous file with comments | « tools/clang/blink_gc_plugin/RecordInfo.h ('k') | tools/clang/blink_gc_plugin/tests/class_multiple_trace_bases.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698