• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ llvm::SmallVector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中llvm::SmallVector的典型用法代码示例。如果您正苦于以下问题:C++ SmallVector类的具体用法?C++ SmallVector怎么用?C++ SmallVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setFileStream

 void MetaProcessor::setFileStream(llvm::StringRef file, bool append, int fd,
             llvm::SmallVector<llvm::SmallString<128>, 2>& prevFileStack) {
   // If we have a fileName to redirect to store it.
   if (!file.empty()) {
     prevFileStack.push_back(file);
     // pop and push a null terminating 0.
     // SmallVectorImpl<T> does not have a c_str(), thus instead of casting to
     // a SmallString<T> we null terminate the data that we have and pop the
     // 0 char back.
     prevFileStack.back().push_back(0);
     prevFileStack.back().pop_back();
     if (!append) {
       FILE * f;
       if (!(f = fopen(file.data(), "w"))) {
         llvm::errs() << "cling::MetaProcessor::setFileStream:"
                      " The file path " << file.data() << "is not valid.";
       } else {
         fclose(f);
       }
     }
   // Else unredirection, so switch to the previous file.
   } else {
     // If there is no previous file on the stack we pop the file
     if (!prevFileStack.empty()) {
       prevFileStack.pop_back();
     }
   }
 }
开发者ID:asmagina1995,项目名称:root,代码行数:28,代码来源:MetaProcessor.cpp


示例2:

void ldc::DIBuilder::AddFields(AggregateDeclaration *sd, ldc::DIFile file,
                               llvm::SmallVector<LLMetadata *, 16> &elems) {
  size_t narr = sd->fields.dim;
  elems.reserve(narr);
  for (auto vd : sd->fields) {
    elems.push_back(CreateMemberType(vd->loc.linnum, vd->type, file,
                                     vd->toChars(), vd->offset,
                                     vd->prot().kind));
  }
}
开发者ID:John-Colvin,项目名称:ldc,代码行数:10,代码来源:dibuilder.cpp


示例3:

CGFunctionInfo::CGFunctionInfo(QualType ResTy,
                               const llvm::SmallVector<QualType, 16> &ArgTys) {
    NumArgs = ArgTys.size();
    Args = new ArgInfo[1 + NumArgs];
    Args[0].type = ResTy;
    for (unsigned i = 0; i < NumArgs; ++i)
        Args[1 + i].type = ArgTys[i];
}
开发者ID:Killfrra,项目名称:llvm-kernel,代码行数:8,代码来源:CGCall.cpp


示例4: rankArgsMatch

/**
 * Check if rank arguments of send, recv pair match.
 *
 * @return is matching
 */
bool MPICheckerAST::rankArgsMatch(const MPICall &sendCall,
                                  const MPICall &recvCall,
                                  const MPIRankCase &sendCase,
                                  const MPIRankCase &recvCase) const {
    // match special case
    if (isFirstLastPair(sendCall, recvCall, sendCase, recvCase)) return true;

    // compare ranks
    const auto &rankArgSend = sendCall.arg(MPIPointToPoint::kRank);
    const auto &rankArgRecv = recvCall.arg(MPIPointToPoint::kRank);

    if (rankArgSend.valueSequence().size() !=
            rankArgRecv.valueSequence().size())
        return false;

    // build sequences without last operator(skip first element)
    const llvm::SmallVector<std::string, 4> sendValSeq{
        rankArgSend.valueSequence().begin() + 1,
        rankArgSend.valueSequence().end()},
    recvValSeq{rankArgRecv.valueSequence().begin() + 1,
               rankArgRecv.valueSequence().end()};

    bool containsSubtraction{false};
    for (size_t i = 0; i < sendValSeq.size(); ++i) {
        if (sendValSeq[i] == "-" || recvValSeq[i] == "-") {
            containsSubtraction = true;
            break;
        }
    }

    // check ordered
    if (containsSubtraction && (sendValSeq != recvValSeq)) return false;
    // check permutation
    if (!containsSubtraction &&
            (!cont::isPermutation(sendValSeq, recvValSeq))) {
        return false;
    }
    // last (value|var|function) must be identical
    if (sendValSeq.back() != recvValSeq.back()) return false;
    // last operator must be inverse
    if (!rankArgSend.isLastOperatorInverse(rankArgRecv)) return false;

    return true;
}
开发者ID:harite,项目名称:MPI-Checker,代码行数:49,代码来源:MPICheckerAST.cpp


示例5: Parse

  void IncrementalParser::Parse(llvm::StringRef input, 
                                llvm::SmallVector<DeclGroupRef, 4>& DGRs) {

    Parse(input);
    for (llvm::SmallVector<ChainedConsumer::DGRInfo, 64>::iterator 
           I = m_Consumer->DeclsQueue.begin(), E = m_Consumer->DeclsQueue.end();
         I != E; ++I) {
      DGRs.push_back((*I).D);
    }
  }
开发者ID:krafczyk,项目名称:root-5.34.09-ams,代码行数:10,代码来源:IncrementalParser.cpp


示例6: populateParentNamespaces

static void
populateParentNamespaces(llvm::SmallVector<Reference, 4> &Namespaces,
                         const T *D) {
  const auto *DC = dyn_cast<DeclContext>(D);
  while ((DC = DC->getParent())) {
    if (const auto *N = dyn_cast<NamespaceDecl>(DC))
      Namespaces.emplace_back(getUSRForDecl(N), N->getNameAsString(),
                              InfoType::IT_namespace);
    else if (const auto *N = dyn_cast<RecordDecl>(DC))
      Namespaces.emplace_back(getUSRForDecl(N), N->getNameAsString(),
                              InfoType::IT_record);
    else if (const auto *N = dyn_cast<FunctionDecl>(DC))
      Namespaces.emplace_back(getUSRForDecl(N), N->getNameAsString(),
                              InfoType::IT_function);
    else if (const auto *N = dyn_cast<EnumDecl>(DC))
      Namespaces.emplace_back(getUSRForDecl(N), N->getNameAsString(),
                              InfoType::IT_enum);
  }
}
开发者ID:vmiklos,项目名称:clang-tools-extra,代码行数:19,代码来源:Serialize.cpp


示例7: parse_float

std::string clang_c_convertert::parse_float(
  llvm::SmallVector<char, 32> &src,
  mp_integer &significand,
  mp_integer &exponent)
{
  // {digit}{dot}{31 digits}[+-]{exponent}

  unsigned p = 0;

  // get whole number
  std::string str_whole_number = "";
  str_whole_number += src[p++];

  // skip dot
  assert(src[p] == '.');
  p++;

  // get fraction part
  std::string str_fraction_part = "";
  while (src[p] != 'E')
    str_fraction_part += src[p++];

  // skip E
  assert(src[p] == 'E');
  p++;

  // get exponent
  assert(src[p] == '+' || src[p] == '-');

  // skip +
  if(src[p] == '+')
    p++;

  std::string str_exponent = "";
  str_exponent += src[p++];

  while (p < src.size())
    str_exponent += src[p++];

  std::string str_number = str_whole_number + str_fraction_part;

  if (str_number.empty())
    significand = 0;
  else
    significand = string2integer(str_number);

  if (str_exponent.empty())
    exponent = 0;
  else
    exponent = string2integer(str_exponent);

  exponent -= str_fraction_part.size();

  return str_whole_number;
}
开发者ID:ericksonalves,项目名称:esbmc,代码行数:55,代码来源:clang_c_convert_literals.cpp


示例8: createAllocas

void
SROAMemoryUseAnalyzer::
createAllocas(llvm::SmallVector<AllocStackInst *, 4> &NewAllocations) {
  SILBuilderWithScope B(AI);
  SILType Type = AI->getType().getObjectType();

  if (TT) {
    for (unsigned EltNo : indices(TT->getElementTypes())) {
      SILType EltTy = Type.getTupleElementType(EltNo);
      NewAllocations.push_back(B.createAllocStack(AI->getLoc(), EltTy));
    }
  } else {
    assert(SD && "SD should not be null since either it or TT must be set at "
           "this point.");
    SILModule &M = AI->getModule();
    for (auto *D : SD->getStoredProperties())
      NewAllocations.push_back(B.createAllocStack(AI->getLoc(),
                                                  Type.getFieldType(D, M)));
  }
}
开发者ID:frsoares,项目名称:swift,代码行数:20,代码来源:SILSROA.cpp


示例9: allRegionsUsedByWait

void MPIChecker::allRegionsUsedByWait(
    llvm::SmallVector<const MemRegion *, 2> &ReqRegions,
    const MemRegion *const MR, const CallEvent &CE, CheckerContext &Ctx) const {

  MemRegionManager *const RegionManager = MR->getMemRegionManager();

  if (FuncClassifier->isMPI_Waitall(CE.getCalleeIdentifier())) {
    const MemRegion *SuperRegion{nullptr};
    if (const ElementRegion *const ER = MR->getAs<ElementRegion>()) {
      SuperRegion = ER->getSuperRegion();
    }

    // A single request is passed to MPI_Waitall.
    if (!SuperRegion) {
      ReqRegions.push_back(MR);
      return;
    }

    const auto &Size = Ctx.getStoreManager().getSizeInElements(
        Ctx.getState(), SuperRegion,
        CE.getArgExpr(1)->getType()->getPointeeType());
    const llvm::APSInt &ArrSize = Size.getAs<nonloc::ConcreteInt>()->getValue();

    for (size_t i = 0; i < ArrSize; ++i) {
      const NonLoc Idx = Ctx.getSValBuilder().makeArrayIndex(i);

      const ElementRegion *const ER = RegionManager->getElementRegion(
          CE.getArgExpr(1)->getType()->getPointeeType(), Idx, SuperRegion,
          Ctx.getASTContext());

      ReqRegions.push_back(ER->getAs<MemRegion>());
    }
  } else if (FuncClassifier->isMPI_Wait(CE.getCalleeIdentifier())) {
    ReqRegions.push_back(MR);
  }
}
开发者ID:AntonBikineev,项目名称:clang,代码行数:36,代码来源:MPIChecker.cpp


示例10: GenOpenCLArgMetadata

// OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument
// information in the program executable. The argument information stored
// includes the argument name, its type, the address and access qualifiers used.
// FIXME: Add type, address, and access qualifiers.
static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn,
                                 CodeGenModule &CGM,llvm::LLVMContext &Context,
                                 llvm::SmallVector <llvm::Value*, 5> &kernelMDArgs) {
  
  // Create MDNodes that represents the kernel arg metadata.
  // Each MDNode is a list in the form of "key", N number of values which is
  // the same number of values as their are kernel arguments.
  
  // MDNode for the kernel argument names.
  SmallVector<llvm::Value*, 8> argNames;
  argNames.push_back(llvm::MDString::get(Context, "kernel_arg_name"));
  
  for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) {
    const ParmVarDecl *parm = FD->getParamDecl(i);
    
    // Get argument name.
    argNames.push_back(llvm::MDString::get(Context, parm->getName()));
    
  }
  // Add MDNode to the list of all metadata.
  kernelMDArgs.push_back(llvm::MDNode::get(Context, argNames));
}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:26,代码来源:CodeGenFunction.cpp


示例11: CreateSet

bool SetCreator::CreateSet(ASTContext &C) {
  SmallVector<EquivalenceSet::Object, 16> Objects;
  const EquivalenceScope::InfluenceObject *Obj = nullptr;
  for(size_t I = 0; I < Connections.size(); ++I) {
    if(Visited[I]) continue;
    Obj = Connections[I].A.Obj;
  }
  if(!Obj) return false;

  Result.clear();
  FindConnections(Obj);
  llvm::SmallPtrSet<VarDecl*, 16> ProcessedObjects;
  for(auto I : Result) {
    if(ProcessedObjects.insert(I.Obj->Var).second)
      Objects.push_back(EquivalenceSet::Object(I.Obj->Var, I.E));
  }

  auto Set = EquivalenceSet::Create(C, Objects);
  for(auto I : Objects)
    I.Var->setStorageSet(Set);
  return true;
}
开发者ID:carlobertolli,项目名称:flang,代码行数:22,代码来源:SemaEquivalence.cpp


示例12: CheckForClashingNames

  ///\brief Checks for clashing names when trying to extract a declaration.
  ///
  ///\returns true if there is another declaration with the same name
  bool DeclExtractor::CheckForClashingNames(
                                  const llvm::SmallVector<NamedDecl*, 4>& Decls,
                                            DeclContext* DC, Scope* S) {
    for (size_t i = 0; i < Decls.size(); ++i) {
      NamedDecl* ND = Decls[i];

      if (TagDecl* TD = dyn_cast<TagDecl>(ND)) {
        LookupResult Previous(*m_Sema, ND->getDeclName(), ND->getLocation(),
                              Sema::LookupTagName, Sema::ForRedeclaration
                              );

        m_Sema->LookupName(Previous, S);

        // There is no function diagnosing the redeclaration of tags (eg. enums).
        // So either we have to do it by hand or we can call the top-most
        // function that does the check. Currently the top-most clang function
        // doing the checks creates an AST node, which we don't want.
        if (!CheckTagDeclaration(TD, Previous))
          return true;
      }
      else if (VarDecl* VD = dyn_cast<VarDecl>(ND)) {
        LookupResult Previous(*m_Sema, ND->getDeclName(), ND->getLocation(),
                              Sema::LookupOrdinaryName, Sema::ForRedeclaration
                              );

        m_Sema->LookupName(Previous, S);
        m_Sema->CheckVariableDeclaration(VD, Previous);
        if (VD->isInvalidDecl())
          return true;
        // This var decl will likely get referenced later; claim that it's used.
        VD->setIsUsed();
      }
    }

    return false;
  }
开发者ID:aamedina,项目名称:cling,代码行数:39,代码来源:DeclExtractor.cpp


示例13: getDataBytes

void NativeRawSymbol::getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes) const {
  bytes.clear();
}
开发者ID:davidlt,项目名称:root,代码行数:3,代码来源:NativeRawSymbol.cpp


示例14: alloc

 void* alloc() {
     if (free_chunks.empty()) {
         int protection = PROT_READ | PROT_WRITE | PROT_EXEC;
         int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT;
         char* addr = (char*)mmap(NULL, region_size, protection, flags, -1, 0);
         for (int i = 0; i < region_size / chunk_size; ++i) {
             free_chunks.push_back(&addr[i * chunk_size]);
         }
     }
     return free_chunks.pop_back_val();
 }
开发者ID:Daetalus,项目名称:pyston,代码行数:11,代码来源:ics.cpp


示例15: FindConnections

void SetCreator::FindConnections(const EquivalenceScope::InfluenceObject *Obj) {
  for(size_t I = 0; I < Connections.size(); ++I) {
    if(Visited[I]) continue;

    if(Connections[I].A.Obj == Obj ||
       Connections[I].B.Obj == Obj) {
      Visited[I] = true;
      Result.push_back(Connections[I].A);
      Result.push_back(Connections[I].B);

      if(Connections[I].A.Obj == Obj)
        FindConnections(Connections[I].B.Obj);
      else
        FindConnections(Connections[I].A.Obj);
    }
  }
}
开发者ID:carlobertolli,项目名称:flang,代码行数:17,代码来源:SemaEquivalence.cpp


示例16: insert

 /// Insert a block into the worklist and set its stack depth.
 void insert(SILBasicBlock *BB, int StackDepth) {
   auto Iter = Block2StackDepth.find(BB);
   if (Iter != Block2StackDepth.end()) {
     // We already handled the block.
     assert(StackDepth >= 0);
     if (Iter->second < 0) {
       // Update the stack depth if we didn't set it yet for the block.
       Iter->second = StackDepth;
     } else {
       assert(Iter->second == StackDepth &&
                "inconsistent stack depth at a CFG merge point");
     }
   } else {
     Block2StackDepth[BB] = StackDepth;
     ToHandle.push_back(BB);
   }
 }
开发者ID:Ben-G,项目名称:swift,代码行数:18,代码来源:StackPromotion.cpp


示例17:

 SILBasicBlock *pop_back_val() { return ToHandle.pop_back_val(); }
开发者ID:Ben-G,项目名称:swift,代码行数:1,代码来源:StackPromotion.cpp


示例18: empty

 bool empty() const { return ToHandle.empty(); }
开发者ID:Ben-G,项目名称:swift,代码行数:1,代码来源:StackPromotion.cpp


示例19: VisitCallExpr

    // Deal with all the call expr in the transaction.
    bool VisitCallExpr(CallExpr* TheCall) {
      if (FunctionDecl* FDecl = TheCall->getDirectCallee()) {
        std::bitset<32> ArgIndexs;
        for (FunctionDecl::redecl_iterator RI = FDecl->redecls_begin(),
             RE = FDecl->redecls_end(); RI != RE; ++RI) {
          for (specific_attr_iterator<NonNullAttr>
               I = RI->specific_attr_begin<NonNullAttr>(),
               E = RI->specific_attr_end<NonNullAttr>(); I != E; ++I) {
            NonNullAttr *NonNull = *I;

            // Store all the null attr argument's index into "ArgIndexs".
            for (NonNullAttr::args_iterator i = NonNull->args_begin(),
                 e = NonNull->args_end(); i != e; ++i) {

              // Get the argument with the nonnull attribute.
              const Expr* Arg = TheCall->getArg(*i);

              // Check whether we can get the argument'value. If the argument is
              // not null, then ignore this argument and continue to deal with the
              // next argument with the nonnull attribute.ArgIndexs.set(*i);
              bool Result;
              ASTContext& Context = m_Sema->getASTContext();
              if (Arg->EvaluateAsBooleanCondition(Result, Context) && Result) {
                continue;
              }
              ArgIndexs.set(*i);
            }
            break;
          }
        }

        if (ArgIndexs.any()) {

          // Get the function decl's name.
          std::string FName = getMangledName(FDecl);

          // Store the function decl's name into the vector.
          m_NonNullDeclNames.push_back(FName);

          // Store the function decl's name with its null attr args' indexes
          // into the map.
          m_NonNullArgIndexs.insert(std::make_pair(FName, ArgIndexs));
        }

        // FIXME: For now we will only work/check on declarations that are not
        // deserialized. We want to avoid our null deref transaformer to 
        // deserialize all the contents of a PCH/PCM.
        // We have to think of a better way to find the annotated 
        // declarations, without that to cause too much deserialization.
        Stmt* S = (FDecl->isFromASTFile()) ? 0 : FDecl->getBody();
        if (S) {
          for (Stmt::child_iterator II = S->child_begin(), EE = S->child_end();
               II != EE; ++II) {
            CallExpr* child = dyn_cast<CallExpr>(*II);
            if (child && child->getDirectCallee() != FDecl)
              VisitCallExpr(child);
          }
        }
      }
      return true; // returning false will abort the in-depth traversal.
    }
开发者ID:agheorghiu,项目名称:root,代码行数:62,代码来源:NullDerefProtectionTransformer.cpp


示例20: dealloc

 void dealloc(void* ptr) {
     free_chunks.push_back(ptr); // TODO: we should probably delete some regions if this list gets to large
 }
开发者ID:Daetalus,项目名称:pyston,代码行数:3,代码来源:ics.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ llvm::SmallVectorImpl类代码示例发布时间:2022-05-31
下一篇:
C++ llvm::SmallPtrSetImpl类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap