Chromium Code Reviews| Index: tools/clang/blink_gc_plugin/Config.h |
| diff --git a/tools/clang/blink_gc_plugin/Config.h b/tools/clang/blink_gc_plugin/Config.h |
| index 37cecd0df992115833730fdc32a5ff56afae230b..02bb557a81bdaf104261c06cff7fe8ad67a83703 100644 |
| --- a/tools/clang/blink_gc_plugin/Config.h |
| +++ b/tools/clang/blink_gc_plugin/Config.h |
| @@ -18,11 +18,13 @@ |
| const char kNewOperatorName[] = "operator new"; |
| const char kCreateName[] = "create"; |
| const char kTraceName[] = "trace"; |
| +const char kTraceImplName[] = "traceImpl"; |
| const char kFinalizeName[] = "finalizeGarbageCollectedObject"; |
| const char kTraceAfterDispatchName[] = "traceAfterDispatch"; |
| const char kRegisterWeakMembersName[] = "registerWeakMembers"; |
| const char kHeapAllocatorName[] = "HeapAllocator"; |
| const char kTraceIfNeededName[] = "TraceIfNeeded"; |
| +const char kVisitorDispatcherName[] = "VisitorDispatcher"; |
| class Config { |
| public: |
| @@ -163,16 +165,7 @@ class Config { |
| return name == "Visitor" || name == "VisitorHelper"; |
| } |
| - static bool IsTraceMethod(clang::FunctionDecl* method, |
| - bool* isTraceAfterDispatch = 0) { |
| - if (method->getNumParams() != 1) |
| - return false; |
| - |
| - const std::string& name = method->getNameAsString(); |
| - if (name != kTraceName && name != kTraceAfterDispatchName) |
| - return false; |
| - |
| - const clang::QualType& formal_type = method->getParamDecl(0)->getType(); |
| + static bool IsVisitorPtrType(const clang::QualType& formal_type) { |
| if (!formal_type->isPointerType()) |
| return false; |
| @@ -184,8 +177,51 @@ class Config { |
| if (!IsVisitor(pointee_type->getName())) |
| return false; |
| + return true; |
| + } |
| + |
| + static bool IsVisitorDispatcherType(const clang::QualType& formal_type) { |
| + if (const clang::SubstTemplateTypeParmType* subst_type = |
| + clang::dyn_cast<clang::SubstTemplateTypeParmType>( |
| + formal_type.getTypePtr())) { |
| + if (IsVisitorPtrType(subst_type->getReplacementType())) { |
| + // VisitorDispatcher template parameter substituted to Visitor*. |
| + return true; |
| + } |
| + } else if (const clang::TemplateTypeParmType* parm_type = |
| + clang::dyn_cast<clang::TemplateTypeParmType>( |
| + formal_type.getTypePtr())) { |
| + if (parm_type->getDecl()->getName() == kVisitorDispatcherName) { |
| + // Unresolved, but its parameter name is VisitorDispatcher. |
| + return false; |
| + } |
| + } |
| + |
| + return IsVisitorPtrType(formal_type); |
| + } |
| + |
| + static bool IsTraceMethod(clang::FunctionDecl* method, |
| + bool* isTraceAfterDispatch = 0) { |
|
Yuta Kitamura
2014/12/24 06:31:18
I know this is not from you, but...
Google style
kouhei (in TOK)
2014/12/24 09:03:04
Will fix this on separate CL.
|
| + using namespace clang; |
| + using namespace llvm; |
|
kouhei (in TOK)
2014/12/24 05:53:19
FIXME: remove these.
kouhei (in TOK)
2014/12/24 09:03:04
Done.
|
| + if (method->getNumParams() != 1) |
| + return false; |
| + |
| + const std::string& name = method->getNameAsString(); |
| + if (name != kTraceName && name != kTraceAfterDispatchName && |
| + name != kTraceImplName) |
| + return false; |
| + |
| + const clang::QualType& formal_type = method->getParamDecl(0)->getType(); |
| + if (name == kTraceImplName) { |
| + if (!IsVisitorDispatcherType(formal_type)) |
| + return false; |
| + } else if (!IsVisitorPtrType(formal_type)) |
|
Yuta Kitamura
2014/12/24 06:31:18
If you put braces to "if", you need to do so in
co
kouhei (in TOK)
2014/12/24 09:03:04
Done.
|
| + return false; |
| + |
| if (isTraceAfterDispatch) |
| *isTraceAfterDispatch = (name == kTraceAfterDispatchName); |
| + |
| return true; |
| } |