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 3 // found in the LICENSE file. 4 5 #include "Config.h" 6 7 #include <cassert> 8 9 #include "clang/AST/AST.h" 10 11 using namespace clang; 12 13 // Legacy names to be removed after Blink rename: 14 namespace legacy { 15 const char kCreateName[] = "create"; 16 const char kTraceName[] = "trace"; 17 const char kTraceImplName[] = "traceImpl"; 18 const char kFinalizeName[] = "finalizeGarbageCollectedObject"; 19 const char kTraceAfterDispatchName[] = "traceAfterDispatch"; 20 const char kTraceAfterDispatchImplName[] = "traceAfterDispatchImpl"; 21 const char kRegisterWeakMembersName[] = "registerWeakMembers"; 22 const char kAdjustAndMarkName[] = "adjustAndMark"; 23 const char kIsHeapObjectAliveName[] = "isHeapObjectAlive"; 24 } // namespace legacy 25 26 const char kNewOperatorName[] = "operator new"; 27 const char* kCreateName = "Create"; 28 const char* kTraceName = "Trace"; 29 const char* kTraceImplName = "TraceImpl"; 30 const char* kFinalizeName = "FinalizeGarbageCollectedObject"; 31 const char* kTraceAfterDispatchName = "TraceAfterDispatch"; 32 const char* kTraceAfterDispatchImplName = "TraceAfterDispatchImpl"; 33 const char* kRegisterWeakMembersName = "RegisterWeakMembers"; 34 const char kHeapAllocatorName[] = "HeapAllocator"; 35 const char kTraceIfNeededName[] = "TraceIfNeeded"; 36 const char kVisitorDispatcherName[] = "VisitorDispatcher"; 37 const char kVisitorVarName[] = "visitor"; 38 const char* kAdjustAndMarkName = "AdjustAndMark"; 39 const char* kIsHeapObjectAliveName = "IsHeapObjectAlive"; 40 const char kIsEagerlyFinalizedName[] = "IsEagerlyFinalizedMarker"; 41 const char kConstIteratorName[] = "const_iterator"; 42 const char kIteratorName[] = "iterator"; 43 const char kConstReverseIteratorName[] = "const_reverse_iterator"; 44 const char kReverseIteratorName[] = "reverse_iterator"; 45 46 void Config::UseLegacyNames() { 47 kCreateName = legacy::kCreateName; 48 kTraceName = legacy::kTraceName; 49 kTraceImplName = legacy::kTraceImplName; 50 kFinalizeName = legacy::kFinalizeName; 51 kTraceAfterDispatchName = legacy::kTraceAfterDispatchName; 52 kTraceAfterDispatchImplName = legacy::kTraceAfterDispatchImplName; 53 kRegisterWeakMembersName = legacy::kRegisterWeakMembersName; 54 kAdjustAndMarkName = legacy::kAdjustAndMarkName; 55 kIsHeapObjectAliveName = legacy::kIsHeapObjectAliveName; 56 } 57 58 bool Config::IsTemplateInstantiation(CXXRecordDecl* record) { 59 ClassTemplateSpecializationDecl* spec = 60 dyn_cast<clang::ClassTemplateSpecializationDecl>(record); 61 if (!spec) 62 return false; 63 switch (spec->getTemplateSpecializationKind()) { 64 case TSK_ImplicitInstantiation: 65 case TSK_ExplicitInstantiationDefinition: 66 return true; 67 case TSK_Undeclared: 68 case TSK_ExplicitSpecialization: 69 return false; 70 // TODO: unsupported cases. 71 case TSK_ExplicitInstantiationDeclaration: 72 return false; 73 } 74 assert(false && "Unknown template specialization kind"); 75 return false; 76 } 77