| OLD | NEW |
| 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 // This file defines the names used by GC infrastructure. | 5 // This file defines the names used by GC infrastructure. |
| 6 | 6 |
| 7 // TODO: Restructure the name determination to use fully qualified names (ala, | 7 // TODO: Restructure the name determination to use fully qualified names (ala, |
| 8 // blink::Foo) so that the plugin can be enabled for all of chromium. Doing so | 8 // blink::Foo) so that the plugin can be enabled for all of chromium. Doing so |
| 9 // would allow us to catch errors with structures outside of blink that might | 9 // would allow us to catch errors with structures outside of blink that might |
| 10 // have unsafe pointers to GC allocated blink structures. | 10 // have unsafe pointers to GC allocated blink structures. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 static bool IsGCFinalizedBase(const std::string& name) { | 138 static bool IsGCFinalizedBase(const std::string& name) { |
| 139 return name == "GarbageCollectedFinalized"; | 139 return name == "GarbageCollectedFinalized"; |
| 140 } | 140 } |
| 141 | 141 |
| 142 static bool IsGCBase(const std::string& name) { | 142 static bool IsGCBase(const std::string& name) { |
| 143 return name == "GarbageCollected" || | 143 return name == "GarbageCollected" || |
| 144 IsGCFinalizedBase(name) || | 144 IsGCFinalizedBase(name) || |
| 145 IsGCMixinBase(name); | 145 IsGCMixinBase(name); |
| 146 } | 146 } |
| 147 | 147 |
| 148 static bool IsScriptWrappable(const std::string& name) { |
| 149 return name == "ScriptWrappable"; |
| 150 } |
| 151 |
| 148 static bool IsIterator(const std::string& name) { | 152 static bool IsIterator(const std::string& name) { |
| 149 return name == kIteratorName || name == kConstIteratorName || | 153 return name == kIteratorName || name == kConstIteratorName || |
| 150 name == kReverseIteratorName || name == kConstReverseIteratorName; | 154 name == kReverseIteratorName || name == kConstReverseIteratorName; |
| 151 } | 155 } |
| 152 | 156 |
| 153 // Returns true of the base classes that do not need a vtable entry for trace | 157 // Returns true of the base classes that do not need a vtable entry for trace |
| 154 // because they cannot possibly initiate a GC during construction. | 158 // because they cannot possibly initiate a GC during construction. |
| 155 static bool IsSafePolymorphicBase(const std::string& name) { | 159 static bool IsSafePolymorphicBase(const std::string& name) { |
| 156 return IsGCBase(name) || IsRefCountedBase(name); | 160 return IsGCBase(name) || IsRefCountedBase(name); |
| 157 } | 161 } |
| 158 | 162 |
| 159 static bool IsAnnotated(clang::Decl* decl, const std::string& anno) { | 163 static bool IsAnnotated(clang::Decl* decl, const std::string& anno); |
| 160 clang::AnnotateAttr* attr = decl->getAttr<clang::AnnotateAttr>(); | |
| 161 return attr && (attr->getAnnotation() == anno); | |
| 162 } | |
| 163 | 164 |
| 164 static bool IsStackAnnotated(clang::Decl* decl) { | 165 static bool IsStackAnnotated(clang::Decl* decl) { |
| 165 return IsAnnotated(decl, "blink_stack_allocated"); | 166 return IsAnnotated(decl, "blink_stack_allocated"); |
| 166 } | 167 } |
| 167 | 168 |
| 169 static bool IsStaticSingleton(clang::Decl* decl) { |
| 170 return IsAnnotated(decl, "blink_gc_singleton_type"); |
| 171 } |
| 172 |
| 168 static bool IsIgnoreAnnotated(clang::Decl* decl) { | 173 static bool IsIgnoreAnnotated(clang::Decl* decl) { |
| 169 return IsAnnotated(decl, "blink_gc_plugin_ignore"); | 174 return IsAnnotated(decl, "blink_gc_plugin_ignore"); |
| 170 } | 175 } |
| 171 | 176 |
| 172 static bool IsIgnoreCycleAnnotated(clang::Decl* decl) { | 177 static bool IsIgnoreCycleAnnotated(clang::Decl* decl) { |
| 173 return IsAnnotated(decl, "blink_gc_plugin_ignore_cycle") || | 178 return IsAnnotated(decl, "blink_gc_plugin_ignore_cycle") || |
| 174 IsIgnoreAnnotated(decl); | 179 IsIgnoreAnnotated(decl); |
| 175 } | 180 } |
| 176 | 181 |
| 177 static bool IsVisitor(const std::string& name) { | 182 static bool IsVisitor(const std::string& name) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 if (suffix.size() > str.size()) | 260 if (suffix.size() > str.size()) |
| 256 return false; | 261 return false; |
| 257 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; | 262 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; |
| 258 } | 263 } |
| 259 | 264 |
| 260 // Test if a template specialization is an instantiation. | 265 // Test if a template specialization is an instantiation. |
| 261 static bool IsTemplateInstantiation(clang::CXXRecordDecl* record); | 266 static bool IsTemplateInstantiation(clang::CXXRecordDecl* record); |
| 262 }; | 267 }; |
| 263 | 268 |
| 264 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ | 269 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ |
| OLD | NEW |