m varDecl(hasType(classTemplateSpecializationDecl(
hasAnyTemplateArgument(templateArgument(
# TODO: match type with the name 'char'
).bind("template_param"))
).bind("var")))
Я пытаюсь сопоставить vardecl () , который является специализацией шаблона с типами определенного имени. Например: < /p> [code]template class C { };
C var; [/code] Я хотел бы сопоставить var , когда аргумент шаблона - char . Сопоставщик, который я использую до сих пор: < /p> [code]m varDecl(hasType(classTemplateSpecializationDecl( hasAnyTemplateArgument(templateArgument( # TODO: match type with the name 'char' ).bind("template_param")) ).bind("var"))) [/code] Вывод из Clang-Query : [code]Binding for "template_param": TemplateArgument type 'char' `-BuiltinType 0x13203c6b0 'char'
Binding for "var": ClassTemplateSpecializationDecl 0x1538906f0 col:7 class C definition implicit_instantiation |-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr | |-CopyConstructor simple trivial has_const_param implicit_has_const_param | |-MoveConstructor exists simple trivial | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param | |-MoveAssignment exists simple trivial needs_implicit | `-Destructor simple irrelevant trivial needs_implicit |-TemplateArgument type 'A' | `-RecordType 0x15386ca80 'A' | `-CXXRecord 0x15386c9f0 'A' |-CXXRecordDecl 0x1538909c8 col:7 implicit class C |-CXXConstructorDecl 0x153890a88 col:7 implicit used constexpr C 'void () noexcept' inline default trivial | `-CompoundStmt 0x153891030 |-CXXConstructorDecl 0x153890c40 col:7 implicit constexpr C 'void (const C &)' inline default trivial noexcept-unevaluated 0x153890c40 | `-ParmVarDecl 0x153890d70 col:7 'const C &' `-CXXConstructorDecl 0x153890e50 col:7 implicit constexpr C 'void (C &&)' inline default trivial noexcept-unevaluated 0x153890e50 `-ParmVarDecl 0x153890f80 col:7 'C &&' < /code> Вещи, которые я пробовал: < /p> refersToType(builtinType(hasName("char"))) < /code> не работает: < /p> 3:22: Error building matcher builtinType. 3:34: Incorrect type for arg 1. (Expected = Matcher) != (Actual = Matcher) < /code> refersToDeclaration(decl())[/code] также, похоже, ничего не соответствует.