Пример #1
0
CXCursor cxcursor::MakeCursorOverloadedDeclRef(TemplateName Name,
        SourceLocation Loc,
        CXTranslationUnit TU) {
    assert(Name.getAsOverloadedTemplate() && TU && "Invalid arguments!");
    void *RawLoc = Loc.getPtrEncoding();
    OverloadedDeclRefStorage Storage(Name.getAsOverloadedTemplate());
    CXCursor C = {
        CXCursor_OverloadedDeclRef, 0,
        { Storage.getOpaqueValue(), RawLoc, TU }
    };
    return C;
}
void printTemplateName(raw_ostream &OS, const PrintingPolicy &policy, TemplateName const &name, bool qualifyNames = false)
{
    if (auto Template = name.getAsTemplateDecl())
        OS << (qualifyNames ? Template->getQualifiedNameAsString() : Template->getNameAsString());
    else if (auto QTN = name.getAsQualifiedTemplateName()) {
        OS << (qualifyNames ? QTN->getDecl()->getQualifiedNameAsString() : QTN->getDecl()->getNameAsString());
    }
    else if (auto DTN = name.getAsDependentTemplateName()) {
        if (qualifyNames && DTN->getQualifier())
            DTN->getQualifier()->print(OS, policy);
        OS << "template ";

        if (DTN->isIdentifier())
            OS << DTN->getIdentifier()->getName();
        else
            OS << "operator " << getOperatorSpelling(DTN->getOperator());
    }
    else if (auto subst = name.getAsSubstTemplateTemplateParm()) {
        subst->getReplacement().print(OS, policy, !qualifyNames);
    }
    else if (auto SubstPack = name.getAsSubstTemplateTemplateParmPack())
        OS << *SubstPack->getParameterPack();
    else {
        auto OTS = name.getAsOverloadedTemplate();
        (*OTS->begin())->printName(OS);
    }
}