| 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, |
| 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 |
| 10 // have unsafe pointers to GC allocated blink structures. |
| 11 |
| 7 #ifndef TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ | 12 #ifndef TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ |
| 8 #define TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ | 13 #define TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ |
| 9 | 14 |
| 10 #include "clang/AST/AST.h" | 15 #include "clang/AST/AST.h" |
| 11 #include "clang/AST/Attr.h" | 16 #include "clang/AST/Attr.h" |
| 12 | 17 |
| 13 const char kNewOperatorName[] = "operator new"; | 18 const char kNewOperatorName[] = "operator new"; |
| 14 const char kCreateName[] = "create"; | 19 const char kCreateName[] = "create"; |
| 15 const char kTraceName[] = "trace"; | 20 const char kTraceName[] = "trace"; |
| 16 const char kFinalizeName[] = "finalizeGarbageCollectedObject"; | 21 const char kFinalizeName[] = "finalizeGarbageCollectedObject"; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 92 } |
| 88 | 93 |
| 89 static bool IsHashMap(const std::string& name) { | 94 static bool IsHashMap(const std::string& name) { |
| 90 return name == "HashMap" || | 95 return name == "HashMap" || |
| 91 name == "HeapHashMap" || | 96 name == "HeapHashMap" || |
| 92 name == "PersistentHeapHashMap"; | 97 name == "PersistentHeapHashMap"; |
| 93 } | 98 } |
| 94 | 99 |
| 95 // Following http://crrev.com/369633033 (Blink r177436), | 100 // Following http://crrev.com/369633033 (Blink r177436), |
| 96 // ignore blink::ScriptWrappable's destructor. | 101 // ignore blink::ScriptWrappable's destructor. |
| 97 // FIXME: remove when its non-Oilpan destructor is removed. | 102 // TODO: remove when its non-Oilpan destructor is removed. |
| 98 static bool HasIgnorableDestructor(const std::string& ns, | 103 static bool HasIgnorableDestructor(const std::string& ns, |
| 99 const std::string& name) { | 104 const std::string& name) { |
| 100 return ns == "blink" && name == "ScriptWrappable"; | 105 return ns == "blink" && name == "ScriptWrappable"; |
| 101 } | 106 } |
| 102 | 107 |
| 103 // Assumes name is a valid collection name. | 108 // Assumes name is a valid collection name. |
| 104 static size_t CollectionDimension(const std::string& name) { | 109 static size_t CollectionDimension(const std::string& name) { |
| 105 return (IsHashMap(name) || name == "pair") ? 2 : 1; | 110 return (IsHashMap(name) || name == "pair") ? 2 : 1; |
| 106 } | 111 } |
| 107 | 112 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 194 } |
| 190 | 195 |
| 191 static bool EndsWith(const std::string& str, const std::string& suffix) { | 196 static bool EndsWith(const std::string& str, const std::string& suffix) { |
| 192 if (suffix.size() > str.size()) | 197 if (suffix.size() > str.size()) |
| 193 return false; | 198 return false; |
| 194 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; | 199 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; |
| 195 } | 200 } |
| 196 }; | 201 }; |
| 197 | 202 |
| 198 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ | 203 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ |
| OLD | NEW |