| OLD | NEW |
| 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 "BlinkGCPluginConsumer.h" | 5 #include "BlinkGCPluginConsumer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "CheckDispatchVisitor.h" | 10 #include "CheckDispatchVisitor.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 | 172 |
| 173 CheckClass(info); | 173 CheckClass(info); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void BlinkGCPluginConsumer::CheckClass(RecordInfo* info) { | 176 void BlinkGCPluginConsumer::CheckClass(RecordInfo* info) { |
| 177 if (!info) | 177 if (!info) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 // Check consistency of stack-allocated hierarchies. | |
| 181 if (info->IsStackAllocated()) { | |
| 182 for (auto& base : info->GetBases()) | |
| 183 if (!base.second.info()->IsStackAllocated()) | |
| 184 reporter_.DerivesNonStackAllocated(info, &base.second); | |
| 185 } | |
| 186 | |
| 187 if (CXXMethodDecl* trace = info->GetTraceMethod()) { | 180 if (CXXMethodDecl* trace = info->GetTraceMethod()) { |
| 188 if (trace->isPure()) | 181 if (trace->isPure()) |
| 189 reporter_.ClassDeclaresPureVirtualTrace(info, trace); | 182 reporter_.ClassDeclaresPureVirtualTrace(info, trace); |
| 190 } else if (info->RequiresTraceMethod()) { | 183 } else if (info->RequiresTraceMethod()) { |
| 191 reporter_.ClassRequiresTraceMethod(info); | 184 reporter_.ClassRequiresTraceMethod(info); |
| 192 } | 185 } |
| 193 | 186 |
| 194 // Check polymorphic classes that are GC-derived or have a trace method. | 187 // Check polymorphic classes that are GC-derived or have a trace method. |
| 195 if (info->record()->hasDefinition() && info->record()->isPolymorphic()) { | 188 if (info->record()->hasDefinition() && info->record()->isPolymorphic()) { |
| 196 // TODO: Check classes that inherit a trace method. | 189 // TODO: Check classes that inherit a trace method. |
| 197 CXXMethodDecl* trace = info->GetTraceMethod(); | 190 CXXMethodDecl* trace = info->GetTraceMethod(); |
| 198 if (trace || info->IsGCDerived()) | 191 if (trace || info->IsGCDerived()) |
| 199 CheckPolymorphicClass(info, trace); | 192 CheckPolymorphicClass(info, trace); |
| 200 } | 193 } |
| 201 | 194 |
| 202 { | 195 { |
| 203 CheckFieldsVisitor visitor; | 196 CheckFieldsVisitor visitor; |
| 204 if (visitor.ContainsInvalidFields(info)) | 197 if (visitor.ContainsInvalidFields(info)) |
| 205 reporter_.ClassContainsInvalidFields(info, visitor.invalid_fields()); | 198 reporter_.ClassContainsInvalidFields(info, visitor.invalid_fields()); |
| 206 } | 199 } |
| 207 | 200 |
| 208 if (info->IsGCDerived()) { | 201 if (info->IsGCDerived()) { |
| 202 // It is illegal for a class to be both stack allocated and garbage |
| 203 // collected. |
| 204 if (info->IsStackAllocated()) { |
| 205 for (auto& base : info->GetBases()) { |
| 206 RecordInfo* base_info = base.second.info(); |
| 207 if (Config::IsGCBase(base_info->name()) || base_info->IsGCDerived()) { |
| 208 reporter_.StackAllocatedDerivesGarbageCollected(info, &base.second); |
| 209 } |
| 210 } |
| 211 } |
| 212 |
| 209 if (!info->IsGCMixin()) { | 213 if (!info->IsGCMixin()) { |
| 210 CheckLeftMostDerived(info); | 214 CheckLeftMostDerived(info); |
| 211 CheckDispatch(info); | 215 CheckDispatch(info); |
| 212 if (CXXMethodDecl* newop = info->DeclaresNewOperator()) | 216 if (CXXMethodDecl* newop = info->DeclaresNewOperator()) |
| 213 if (!Config::IsIgnoreAnnotated(newop)) | 217 if (!Config::IsIgnoreAnnotated(newop)) |
| 214 reporter_.ClassOverridesNew(info, newop); | 218 reporter_.ClassOverridesNew(info, newop); |
| 215 } | 219 } |
| 216 | 220 |
| 217 { | 221 { |
| 218 CheckGCRootsVisitor visitor; | 222 CheckGCRootsVisitor visitor; |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 SourceLocation spelling_location = source_manager.getSpellingLoc(loc); | 719 SourceLocation spelling_location = source_manager.getSpellingLoc(loc); |
| 716 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); | 720 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); |
| 717 if (ploc.isInvalid()) { | 721 if (ploc.isInvalid()) { |
| 718 // If we're in an invalid location, we're looking at things that aren't | 722 // If we're in an invalid location, we're looking at things that aren't |
| 719 // actually stated in the source. | 723 // actually stated in the source. |
| 720 return false; | 724 return false; |
| 721 } | 725 } |
| 722 *filename = ploc.getFilename(); | 726 *filename = ploc.getFilename(); |
| 723 return true; | 727 return true; |
| 724 } | 728 } |
| OLD | NEW |