当前位置: 首页>>代码示例>>C++>>正文


C++ TemplateArgument::getAsExpr方法代码示例

本文整理汇总了C++中TemplateArgument::getAsExpr方法的典型用法代码示例。如果您正苦于以下问题:C++ TemplateArgument::getAsExpr方法的具体用法?C++ TemplateArgument::getAsExpr怎么用?C++ TemplateArgument::getAsExpr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TemplateArgument的用法示例。


在下文中一共展示了TemplateArgument::getAsExpr方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: VisitTemplateArgument

void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
  // Mostly repetitive with TemplateArgument::Profile!
  ID.AddInteger(Arg.getKind());
  switch (Arg.getKind()) {
  case TemplateArgument::Null:
    break;

  case TemplateArgument::Type:
    VisitType(Arg.getAsType());
    break;

  case TemplateArgument::Template:
  case TemplateArgument::TemplateExpansion:
    VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
    break;
      
  case TemplateArgument::Declaration:
    VisitDecl(Arg.getAsDecl());
    break;

  case TemplateArgument::NullPtr:
    VisitType(Arg.getNullPtrType());
    break;

  case TemplateArgument::Integral:
    Arg.getAsIntegral().Profile(ID);
    VisitType(Arg.getIntegralType());
    break;

  case TemplateArgument::Expression:
    Visit(Arg.getAsExpr());
    break;

  case TemplateArgument::Pack:
    for (const auto &P : Arg.pack_elements())
      VisitTemplateArgument(P);
    break;
  }
}
开发者ID:AntonBikineev,项目名称:clang,代码行数:39,代码来源:StmtProfile.cpp

示例2: PrintTemplateArgument

static void PrintTemplateArgument(std::string &Buffer,
                                  const TemplateArgument &Arg,
                                  const PrintingPolicy &Policy) {
  switch (Arg.getKind()) {
    case TemplateArgument::Null:
      assert(false && "Null template argument");
      break;
      
    case TemplateArgument::Type:
      Arg.getAsType().getAsStringInternal(Buffer, Policy);
      break;
      
    case TemplateArgument::Declaration:
      Buffer = cast<NamedDecl>(Arg.getAsDecl())->getNameAsString();
      break;
      
    case TemplateArgument::Template: {
      llvm::raw_string_ostream s(Buffer);
      Arg.getAsTemplate().print(s, Policy);
      break;
    }
      
    case TemplateArgument::Integral:
      Buffer = Arg.getAsIntegral()->toString(10, true);
      break;
      
    case TemplateArgument::Expression: {
      llvm::raw_string_ostream s(Buffer);
      Arg.getAsExpr()->printPretty(s, 0, Policy);
      break;
    }
      
    case TemplateArgument::Pack:
      assert(0 && "FIXME: Implement!");
      break;
  }
}
开发者ID:lgerbarg,项目名称:clang,代码行数:37,代码来源:TypePrinter.cpp

示例3: VisitTemplateArgument

void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
  // Mostly repetitive with TemplateArgument::Profile!
  ID.AddInteger(Arg.getKind());
  switch (Arg.getKind()) {
  case TemplateArgument::Null:
    break;

  case TemplateArgument::Type:
    VisitType(Arg.getAsType());
    break;

  case TemplateArgument::Template:
  case TemplateArgument::TemplateExpansion:
    VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
    break;
      
  case TemplateArgument::Declaration:
    VisitDecl(Arg.getAsDecl());
    break;

  case TemplateArgument::Integral:
    Arg.getAsIntegral()->Profile(ID);
    VisitType(Arg.getIntegralType());
    break;

  case TemplateArgument::Expression:
    Visit(Arg.getAsExpr());
    break;

  case TemplateArgument::Pack:
    const TemplateArgument *Pack = Arg.pack_begin();
    for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i)
      VisitTemplateArgument(Pack[i]);
    break;
  }
}
开发者ID:syoyo,项目名称:clang,代码行数:36,代码来源:StmtProfile.cpp

示例4: getTemplateArgumentName

string getTemplateArgumentName(const TemplateArgument & argument)
{
	string qualifiedName;

	switch(argument.getKind()) {
		case TemplateArgument::Null:
			qualifiedName = "NULL";
			break;

		case TemplateArgument::Type:
			qualifiedName = CppType(argument.getAsType()).getQualifiedName();
			break;

		case TemplateArgument::Declaration:
			qualifiedName = dyn_cast<NamedDecl>(argument.getAsDecl())->getQualifiedNameAsString();
			break;

		case TemplateArgument::Integral:
		case TemplateArgument::Expression:
			qualifiedName = exprToText(argument.getAsExpr());
			break;

		case TemplateArgument::Template:
			qualifiedName = argument.getAsTemplate().getAsTemplateDecl()->getQualifiedNameAsString();
			break;

		case TemplateArgument::TemplateExpansion:
			break;

		case TemplateArgument::Pack:
			break;

	}

	return qualifiedName;
}
开发者ID:Remscar,项目名称:cpgf,代码行数:36,代码来源:cpputil.cpp

示例5: printTemplateArgument

// Adapted from tools\clang\lib\AST\TemplateBase.cpp TemplateArgument::print
void printTemplateArgument(raw_ostream &out, const PrintingPolicy &policy, TemplateArgument const &arg, bool qualifyNames)
{
    switch (arg.getKind()) {
    case TemplateArgument::Null:
        out << "(no value)";
        break;

    case TemplateArgument::Type: {
        PrintingPolicy SubPolicy(policy);
        SubPolicy.SuppressStrongLifetime = true;
        arg.getAsType().print(out, SubPolicy);
        break;
    }

    case TemplateArgument::Declaration: {
        NamedDecl *ND = cast<NamedDecl>(arg.getAsDecl());
        out << '&';
        if (ND->getDeclName()) {
            // FIXME: distinguish between pointer and reference args?
            ND->printQualifiedName(out);
        }
        else {
            out << "(anonymous)";
        }
        break;
    }

    case TemplateArgument::NullPtr:
        out << "nullptr";
        break;

    case TemplateArgument::Template:
        // Orig: arg.getAsTemplate().print(out, policy);
    {
        auto templateName = arg.getAsTemplate();
        printTemplateName(out, policy, templateName, qualifyNames);
        break;
    }

    case TemplateArgument::TemplateExpansion:
        arg.getAsTemplateOrTemplatePattern().print(out, policy);
        out << "...";
        break;

    case TemplateArgument::Integral: {
        printIntegral(arg, out, policy);
        break;
    }

    case TemplateArgument::Expression:
        arg.getAsExpr()->printPretty(out, nullptr, policy);
        break;

    case TemplateArgument::Pack:
        out << "<";
        bool First = true;
        for (const auto &P : arg.pack_elements()) {
            if (First)
                First = false;
            else
                out << ", ";

            P.print(policy, out);
        }
        out << ">";
        break;
    }
}
开发者ID:CAST-projects,项目名称:Clang-ast-viewer,代码行数:69,代码来源:TemplateUtilities.cpp


注:本文中的TemplateArgument::getAsExpr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。