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

Side by Side Diff: tools/clang/blink_gc_plugin/Config.h

Issue 207913002: Global cycle detection analysis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 // This file defines the names used by GC infrastructure. 5 // This file defines the names used by GC infrastructure.
6 6
7 #ifndef TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ 7 #ifndef TOOLS_BLINK_GC_PLUGIN_CONFIG_H_
8 #define TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ 8 #define TOOLS_BLINK_GC_PLUGIN_CONFIG_H_
9 9
10 #include "clang/AST/AST.h" 10 #include "clang/AST/AST.h"
11 #include "clang/AST/Attr.h"
11 12
12 const char kNewOperatorName[] = "operator new"; 13 const char kNewOperatorName[] = "operator new";
13 const char kCreateName[] = "create"; 14 const char kCreateName[] = "create";
14 const char kTraceName[] = "trace"; 15 const char kTraceName[] = "trace";
15 const char kFinalizeName[] = "finalizeGarbageCollectedObject"; 16 const char kFinalizeName[] = "finalizeGarbageCollectedObject";
16 const char kTraceAfterDispatchName[] = "traceAfterDispatch"; 17 const char kTraceAfterDispatchName[] = "traceAfterDispatch";
17 const char kRegisterWeakMembersName[] = "registerWeakMembers"; 18 const char kRegisterWeakMembersName[] = "registerWeakMembers";
18 const char kHeapAllocatorName[] = "HeapAllocator"; 19 const char kHeapAllocatorName[] = "HeapAllocator";
19 20
20 class Config { 21 class Config {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return name == "GarbageCollectedFinalized" || 95 return name == "GarbageCollectedFinalized" ||
95 name == "RefCountedGarbageCollected"; 96 name == "RefCountedGarbageCollected";
96 } 97 }
97 98
98 static bool IsGCBase(const std::string& name) { 99 static bool IsGCBase(const std::string& name) {
99 return name == "GarbageCollected" || 100 return name == "GarbageCollected" ||
100 IsGCFinalizedBase(name) || 101 IsGCFinalizedBase(name) ||
101 IsGCMixinBase(name); 102 IsGCMixinBase(name);
102 } 103 }
103 104
105 static bool IsAnnotated(clang::Decl* decl, const std::string& anno) {
106 clang::AnnotateAttr* attr = decl->getAttr<clang::AnnotateAttr>();
107 return attr && (attr->getAnnotation() == anno);
108 }
109
110 static bool IsStackAnnotated(clang::Decl* decl) {
111 return IsAnnotated(decl, "blink_stack_allocated");
112 }
113
114 static bool IsIgnoreAnnotated(clang::Decl* decl) {
115 return IsAnnotated(decl, "blink_gc_plugin_ignore");
116 }
117
118 static bool IsIgnoreCycleAnnotated(clang::Decl* decl) {
119 return IsAnnotated(decl, "blink_gc_plugin_ignore_cycle") ||
120 IsIgnoreAnnotated(decl);
121 }
122
104 static bool IsVisitor(const std::string& name) { return name == "Visitor"; } 123 static bool IsVisitor(const std::string& name) { return name == "Visitor"; }
105 124
106 static bool IsTraceMethod(clang::CXXMethodDecl* method, 125 static bool IsTraceMethod(clang::CXXMethodDecl* method,
107 bool* isTraceAfterDispatch = 0) { 126 bool* isTraceAfterDispatch = 0) {
108 if (method->getNumParams() != 1) 127 if (method->getNumParams() != 1)
109 return false; 128 return false;
110 129
111 const std::string& name = method->getNameAsString(); 130 const std::string& name = method->getNameAsString();
112 if (name != kTraceName && name != kTraceAfterDispatchName) 131 if (name != kTraceName && name != kTraceAfterDispatchName)
113 return false; 132 return false;
(...skipping 22 matching lines...) Expand all
136 } 155 }
137 156
138 static bool EndsWith(const std::string& str, const std::string& suffix) { 157 static bool EndsWith(const std::string& str, const std::string& suffix) {
139 if (suffix.size() > str.size()) 158 if (suffix.size() > str.size())
140 return false; 159 return false;
141 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; 160 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
142 } 161 }
143 }; 162 };
144 163
145 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ 164 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698