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


C++ QualType::getAsStringInternal方法代码示例

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


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

示例1: makeLocalAsGlobalVar

bool LToGASTVisitor::makeLocalAsGlobalVar(FunctionDecl *FD,
                                          VarDecl *LV)
{
  std::string GlobalVarStr;
  std::string NewName = ConsumerInstance->getNewName();

  QualType T = LV->getType();
  T.getAsStringInternal(NewName, 
                        ConsumerInstance->Context->getPrintingPolicy());

  GlobalVarStr = NewName;

  if (LV->hasInit()) {
    const Expr *InitExpr = LV->getInit();
    std::string InitStr("");
    ConsumerInstance->RewriteHelper->getExprString(InitExpr, 
                                                   InitStr);
    GlobalVarStr += " = ";
    GlobalVarStr += InitStr; 
  }

  GlobalVarStr += ";\n";

  return ConsumerInstance->RewriteHelper->
           insertStringBeforeFunc(FD, GlobalVarStr);
}
开发者ID:BlastarIndia,项目名称:creduce,代码行数:26,代码来源:LocalToGlobal.cpp

示例2: replaceCallExpr

void CallExprToValue::replaceCallExpr(void)
{
  std::string CommaStr = "";

  QualType RVQualType = TheCallExpr->getType();
  const Type *RVType = RVQualType.getTypePtr();
  if (RVType->isVoidType()) {
    // Nothing to do
  }
  else if (RVType->isUnionType() || RVType->isStructureType()) {
    std::string RVStr("");
    RewriteHelper->getTmpTransName(NamePostfix, RVStr);
    NamePostfix++;

    CommaStr = RVStr;
    RVQualType.getAsStringInternal(RVStr, Context->getPrintingPolicy());
    RVStr += ";\n";
    RewriteHelper->insertStringBeforeFunc(CurrentFD, RVStr);
  }
  else {
    CommaStr = "0";
  }

  RewriteHelper->replaceExpr(TheCallExpr, CommaStr);
}
开发者ID:AWeggerl,项目名称:creduce,代码行数:25,代码来源:CallExprToValue.cpp

示例3: getTypeString

bool InstantiateTemplateParam::getTypeString(
       const QualType &QT, std::string &Str, std::string &ForwardStr)
{
  const Type *Ty = QT.getTypePtr();
  Type::TypeClass TC = Ty->getTypeClass();

  switch (TC) {
  case Type::Elaborated: {
    const ElaboratedType *ETy = dyn_cast<ElaboratedType>(Ty);
    return getTypeString(ETy->getNamedType(), Str, ForwardStr);
  }

  case Type::Typedef: {
    const TypedefType *TdefTy = dyn_cast<TypedefType>(Ty);
    const TypedefNameDecl *TdefD = TdefTy->getDecl();
    return getTypeString(TdefD->getUnderlyingType(), Str, ForwardStr);
  }

  case Type::Record: {
    RecordDeclSet TempAvailableRecordDecls;
    getForwardDeclStr(Ty, ForwardStr, TempAvailableRecordDecls);
    QT.getAsStringInternal(Str, Context->getPrintingPolicy());
    return true;
  }

  case Type::Builtin: {
    QT.getAsStringInternal(Str, Context->getPrintingPolicy());
    return true;
  }

  default:
    return false;
  }

  TransAssert(0 && "Unreachable code!");
  return false;
}
开发者ID:csmith-project,项目名称:creduce,代码行数:37,代码来源:InstantiateTemplateParam.cpp

示例4: addNewTmpVariable

bool BinOpSimplification::addNewTmpVariable(void)
{
  QualType QT = TheBinOp->getType();
  std::string VarStr;
  std::stringstream SS;
  unsigned int NamePostfix = NameQueryWrap->getMaxNamePostfix();

  SS << RewriteHelper->getTmpVarNamePrefix() << (NamePostfix + 1);
  VarStr = SS.str();
  setTmpVarName(VarStr);

  QT.getAsStringInternal(VarStr,
                         Context->getPrintingPolicy());

  VarStr += ";";
  return RewriteHelper->addLocalVarToFunc(VarStr, TheFuncDecl);
}
开发者ID:AWeggerl,项目名称:creduce,代码行数:17,代码来源:BinOpSimplification.cpp

示例5: replaceCallExpr

void SimplifyCallExpr::replaceCallExpr(void)
{
  std::string CommaStr("");
  unsigned int NumArg = TheCallExpr->getNumArgs();
  if (NumArg == 0) {
    RewriteHelper->replaceExpr(TheCallExpr, CommaStr);
    return;
  }

  const Expr *Arg = TheCallExpr->getArg(0);
  std::string ArgStr;
  handleOneArgStr(Arg, ArgStr);
  CommaStr += ("(" + ArgStr);

  for (unsigned int I = 1; I < NumArg; ++I) {
    Arg = TheCallExpr->getArg(I);
    handleOneArgStr(Arg, ArgStr);
    CommaStr += ("," + ArgStr);
  }

  QualType RVQualType = TheCallExpr->getType();
  const Type *RVType = RVQualType.getTypePtr();
  if (RVType->isVoidType()) {
    // Nothing to do
  }
  else if (RVType->isUnionType() || RVType->isStructureType()) {
    std::string RVStr("");
    RewriteHelper->getTmpTransName(NamePostfix, RVStr);
    NamePostfix++;

    CommaStr += ("," + RVStr);
    RVQualType.getAsStringInternal(RVStr, Context->getPrintingPolicy());
    RVStr += ";\n";
    RewriteHelper->insertStringBeforeFunc(CurrentFD, RVStr);
  }
  else {
    CommaStr += ",0";
  }

  CommaStr += ")";
  RewriteHelper->replaceExpr(TheCallExpr, CommaStr);
}
开发者ID:chubbymaggie,项目名称:creduce,代码行数:42,代码来源:SimplifyCallExpr.cpp

示例6: addTmpVar

bool AggregateToScalar::addTmpVar(const Expr *RefE,
                                  const std::string &VarName,
                                  const std::string *InitStr)
{
  std::string VarStr(VarName);
  QualType QT = RefE->getType();
  QT.getAsStringInternal(VarStr, Context->getPrintingPolicy());

  if (InitStr) {
    VarStr += " = ";
    VarStr += (*InitStr);
  }
  VarStr += ";";
   
  if (TheVarDecl->getStorageClass() == SC_Static)
    VarStr = "static " + VarStr; 

  TransAssert(!dyn_cast<ParmVarDecl>(TheVarDecl) && 
              "We don't handle ParmVarDecl!");
  if (TheVarDecl->isLocalVarDecl()) {
    DeclStmt *TheDeclStmt = VarDeclToDeclStmtMap[TheVarDecl];
    TransAssert(TheDeclStmt && "NULL TheDeclStmt");
    return RewriteHelper->addStringAfterStmt(TheDeclStmt, VarStr);
  }
  else {
    llvm::DenseMap<const VarDecl *, DeclGroupRef>::iterator DI =
      VarDeclToDeclGroupMap.find(TheVarDecl);
    TransAssert((DI != VarDeclToDeclGroupMap.end()) && 
                 "Cannot find VarDeclGroup!");
    VarDecl *LastVD = NULL;
    DeclGroupRef DR = (*DI).second;
    for (DeclGroupRef::iterator I = DR.begin(), E = DR.end(); I != E; ++I) {
      LastVD = dyn_cast<VarDecl>(*I);
    }
    TransAssert(LastVD && "Bad LastVD!");
    return RewriteHelper->addStringAfterVarDecl(LastVD, VarStr);
  }
}
开发者ID:sylvestre,项目名称:creduce,代码行数:38,代码来源:AggregateToScalar.cpp

示例7: getNewTmpVariableStr


//.........这里部分代码省略.........
      QT = FD->getReturnType();
      return getNewTmpVariable(QT, VarStr);
    }

    // handle other cases where lookupDeclContext is different from
    // the current CXXRecord, e.g.,
    const Type *Ty = ME->getBaseType().getTypePtr();
    if (const DeclContext *Ctx = getBaseDeclFromType(Ty)) {
      DeclContextSet VisitedCtxs;
      const FunctionDecl *FD = lookupFunctionDecl(DName, Ctx, VisitedCtxs);
      if (!FD) {
        return getNewTmpVariable(QT, VarStr);
      }
      QT = FD->getReturnType();
      const Type *RVTy = QT.getTypePtr();
      if (RVTy->getAs<InjectedClassNameType>()) {
        // handle cases like:
        // template <typename> struct D {
        //   D f();
        // };
        // template <typename T> void foo(D<T>);
        // template <typename T > void bar () {
        //   D<T> G;
        //   foo(G.f());
        // }
        // in this case, seems it's hard to retrieve the instantiated type
        // of f's return type, because `D<T> G' is dependent. I tried
        // findSpecialization from ClassTemplateDecl, but it didn't work.
        // So use a really ugly way, i.e., manipulating strings...
        const TemplateSpecializationType *TST =
          Ty->getAs<TemplateSpecializationType>();
        TransAssert(TST && "Invalid TemplateSpecialization Type!");

        QT.getAsStringInternal(VarStr,
                               Context->getPrintingPolicy());
        return getVarStrForTemplateSpecialization(VarStr, TST);
      }
      else {
        // other cases:
        // template <typename> struct D {
        //   int f();
        // };
        // void foo(int);
        // template <typename T > void bar () {
        //   D<T> G;
        //   foo(G.f());
        // }
        return getNewTmpVariable(QT, VarStr);
      }
    }
    else {
      // template <typename> struct D {
      // D f();
      // D operator[] (int);
      // };
      // template <typename T> void foo(D<T>);
      // template <typename T > void bar () {
      //   D<T> G;
      //   foo(G[0].f());
      // }
      // In this case, G[0] is of BuiltinType.
      // But why does clang represent a dependent type as BuiltinType here?

      TransAssert((Ty->getAs<BuiltinType>() ||
                   Ty->getAs<TemplateTypeParmType>() ||
                   Ty->getAs<TypedefType>() ||
开发者ID:hassahma,项目名称:creduce,代码行数:67,代码来源:RemoveNestedFunction.cpp

示例8: getNewTmpVariable

void RemoveNestedFunction::getNewTmpVariable(const QualType &QT,
                                             std::string &VarStr)
{
  QT.getAsStringInternal(VarStr, Context->getPrintingPolicy());
}
开发者ID:hassahma,项目名称:creduce,代码行数:5,代码来源:RemoveNestedFunction.cpp


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