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

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

Issue 1645763004: blink_gc_plugin: Make RecordInfo::Get{Fields,Bases} return deterministic order (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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 "CheckTraceVisitor.h" 5 #include "CheckTraceVisitor.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "Config.h" 9 #include "Config.h"
10 10
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 353 }
354 } 354 }
355 } 355 }
356 return true; 356 return true;
357 } 357 }
358 358
359 bool CheckTraceVisitor::IsWeakCallback() const { 359 bool CheckTraceVisitor::IsWeakCallback() const {
360 return !trace_; 360 return !trace_;
361 } 361 }
362 362
363 void CheckTraceVisitor::MarkTraced(RecordInfo::Fields::iterator it) { 363 void CheckTraceVisitor::MarkTraced(RecordInfo::Field& field) {
364 // In a weak callback we can't mark strong fields as traced. 364 // In a weak callback we can't mark strong fields as traced.
365 if (IsWeakCallback() && !it->second.edge()->IsWeakMember()) 365 if (IsWeakCallback() && !field.second.edge()->IsWeakMember())
366 return; 366 return;
367 it->second.MarkTraced(); 367 field.second.MarkTraced();
368 } 368 }
369 369
370 void CheckTraceVisitor::FoundField(FieldDecl* field) { 370 void CheckTraceVisitor::FoundField(FieldDecl* field) {
371 if (Config::IsTemplateInstantiation(info_->record())) { 371 if (Config::IsTemplateInstantiation(info_->record())) {
372 // Pointer equality on fields does not work for template instantiations. 372 // Pointer equality on fields does not work for template instantiations.
373 // The trace method refers to fields of the template definition which 373 // The trace method refers to fields of the template definition which
374 // are different from the instantiated fields that need to be traced. 374 // are different from the instantiated fields that need to be traced.
375 const std::string& name = field->getNameAsString(); 375 const std::string& name = field->getNameAsString();
376 for (RecordInfo::Fields::iterator it = info_->GetFields().begin(); 376 for (RecordInfo::Fields::iterator it = info_->GetFields().begin();
377 it != info_->GetFields().end(); 377 it != info_->GetFields().end();
378 ++it) { 378 ++it) {
379 if (it->first->getNameAsString() == name) { 379 if (it->first->getNameAsString() == name) {
380 MarkTraced(it); 380 MarkTraced(*it);
381 break; 381 break;
382 } 382 }
383 } 383 }
384 } else { 384 } else {
385 RecordInfo::Fields::iterator it = info_->GetFields().find(field); 385 if (info_->HasField(field))
386 if (it != info_->GetFields().end()) 386 MarkTraced(info_->GetField(field));
387 MarkTraced(it);
388 } 387 }
389 } 388 }
390 389
391 void CheckTraceVisitor::MarkAllWeakMembersTraced() { 390 void CheckTraceVisitor::MarkAllWeakMembersTraced() {
392 // If we find a call to registerWeakMembers which is unresolved we 391 // If we find a call to registerWeakMembers which is unresolved we
393 // unsoundly consider all weak members as traced. 392 // unsoundly consider all weak members as traced.
394 // TODO: Find out how to validate weak member tracing for unresolved call. 393 // TODO: Find out how to validate weak member tracing for unresolved call.
395 for (auto& field : info_->GetFields()) { 394 for (auto& field : info_->GetFields()) {
396 if (field.second.edge()->IsWeakMember()) 395 if (field.second.edge()->IsWeakMember())
397 field.second.MarkTraced(); 396 field.second.MarkTraced();
398 } 397 }
399 } 398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698