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


C++ StringMap::find方法代码示例

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


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

示例1: check_variable

    int check_variable(ast::Variable* var) {
        assert(var != nullptr);

        auto ptr = variables.find(var->identifier);
        assert_existing_variable(ptr, var->identifier, var->id);
        auto expected = ptr->getValue().type;
        return check_coercion(var->type, expected, var->identifier, var->id);
    }
开发者ID:scoiatael,项目名称:Czero,代码行数:8,代码来源:checker.cpp

示例2: check_assignment

 int check_assignment(ast::Assignment* assignment) {
     assert(assignment != nullptr);
     auto ptr = variables.find(assignment->identifier);
     assert_existing_variable(ptr, assignment->identifier, assignment->id);
     auto val = assignment->value.get();
     check_operation(val);
     return check_coercion(val->type, ptr->getValue().type, "assignment", assignment->id);
 }
开发者ID:scoiatael,项目名称:Czero,代码行数:8,代码来源:checker.cpp

示例3: operator

 bool operator()(const Multilib &M) const override {
   for (StringRef Flag : M.flags()) {
     llvm::StringMap<bool>::const_iterator SI = FlagSet.find(Flag.substr(1));
     if (SI != FlagSet.end())
       if (SI->getValue() != isFlagEnabled(Flag))
         return true;
   }
   return false;
 }
开发者ID:ADonut,项目名称:LLVM-GPGPU,代码行数:9,代码来源:Multilib.cpp

示例4: addDirective

 // Register a directive at the specified marker.
 void addDirective(StringRef MarkerName, const UnattachedDirective &UD) {
   auto MarkerIt = Markers.find(MarkerName);
   if (MarkerIt != Markers.end()) {
     Marker &M = MarkerIt->second;
     if (M.UseLoc.isInvalid())
       M.UseLoc = UD.DirectivePos;
     return attachDirective(Diags, UD, M.DefLoc);
   }
   DeferredDirectives[MarkerName].push_back(UD);
 }
开发者ID:jvesely,项目名称:clang,代码行数:11,代码来源:VerifyDiagnosticConsumer.cpp

示例5: rename

static void rename(llvm::StringMap<cl::Option *> &map, const char *from,
                   const char *to) {
  auto i = map.find(from);
  if (i != map.end()) {
    cl::Option *opt = i->getValue();
    map.erase(i);
    opt->setArgStr(to);
    map[to] = opt;
  }
}
开发者ID:digideskio,项目名称:Calypso,代码行数:10,代码来源:main.cpp

示例6: declare_variable

 int declare_variable(ast::Variable& it) {
     if(variables.find(it.identifier) != variables.end()) {
         std::cout << "Variable shadowing of "
                   << it.identifier;
         print_id(it.id);
         std::cout << std::endl;
     }
     variables.insert(std::pair<llvm::StringRef, ast::Variable>(it.identifier,
                      it));
     return EXIT_SUCCESS;
 }
开发者ID:scoiatael,项目名称:Czero,代码行数:11,代码来源:checker.cpp

示例7: GenerateClass

void CGObjCJit::GenerateClass(const ObjCImplementationDecl *ClassDecl) {
  if (isUsable) {
    const char* ClassName = ClassDecl->getIdentifier()->getNameStart();

    void* Superclass = 0;
    ObjCInterfaceDecl *superClassDecl =
      ClassDecl->getClassInterface()->getSuperClass();

    if (superClassDecl) {
      const char* superClassName =
          superClassDecl->getIdentifier()->getNameStart();
      Superclass = _objc_getClass(superClassName);
    }

    void *theClass =
      _objc_allocateClassPair(Superclass, ClassName, 0); // TODO: always zero?

    // Add methods
    AddMethodsToClass(theClass);

    // Add interface ivars
    const ObjCInterfaceDecl *classInterfaceDecl = ClassDecl->getClassInterface();
    AddIvarsToClass(theClass,
                    classInterfaceDecl->ivar_begin(),
                    classInterfaceDecl->ivar_end());

    // Add implementation ivars
    AddIvarsToClass(theClass,
                    ClassDecl->ivar_begin(),
                    ClassDecl->ivar_end());

    // Add protocols
    ObjCInterfaceDecl::protocol_iterator protocol =
      classInterfaceDecl->protocol_begin();
    const ObjCInterfaceDecl::protocol_iterator protocol_end =
      classInterfaceDecl->protocol_end();
    while (protocol != protocol_end) {
      void *theProtocol = 0;
      // Search "locally" first, then from runtime
      llvm::StringMap<void*>::iterator proto_local =
        DefinedProtocols.find((*protocol)->getName());
      if (proto_local != DefinedProtocols.end()) {
        theProtocol = proto_local->second;
      } else {
        theProtocol = _objc_getProtocol((*protocol)->getNameAsString().c_str());
      }
      _class_addProtocol(theClass, theProtocol);
      protocol++;
    }

    // Finalize class (adding methods later, at runtime, in init function)
    _objc_registerClassPair(theClass);
  }
}
开发者ID:eerolanguage,项目名称:clang-interpreter-runtime,代码行数:54,代码来源:CGObjCJit.cpp

示例8: declare_extern

 int declare_extern(ast::Extern* extrn) {
     assert(extrn != nullptr);
     if(functions.find(extrn->identifier) != functions.end()) {
         std::cout << "Double declaration of "
                   << extrn->identifier;
         print_id(extrn->id);
         std::cout << std::endl;
     }
     functions.insert(std::pair<llvm::StringRef, ast::Extern>(extrn->identifier,
                      *extrn));
     return EXIT_SUCCESS;
 }
开发者ID:scoiatael,项目名称:Czero,代码行数:12,代码来源:checker.cpp

示例9:

static void
callHandler(const llvm::StringMap<std::unique_ptr<Handler>> &Handlers,
            llvm::yaml::ScalarNode *Method, llvm::yaml::ScalarNode *Id,
            llvm::yaml::MappingNode *Params, Handler *UnknownHandler) {
  llvm::SmallString<10> MethodStorage;
  auto I = Handlers.find(Method->getValue(MethodStorage));
  auto *Handler = I != Handlers.end() ? I->second.get() : UnknownHandler;
  if (Id)
    Handler->handleMethod(Params, Id->getRawValue());
  else
    Handler->handleNotification(Params);
}
开发者ID:efcs,项目名称:clang-tools-extra,代码行数:12,代码来源:JSONRPCDispatcher.cpp

示例10: incrementCount

void incrementCount(ObjectPtr obj) {
    string buf;
    llvm::raw_string_ostream sout(buf);
    sout << obj;
    string s = sout.str();
    llvm::StringMap<int>::iterator i = countsMap.find(s);
    if (i == countsMap.end()) {
        countsMap[s] = 1;
    }
    else {
        i->second += 1;
    }
}
开发者ID:Blei,项目名称:clay,代码行数:13,代码来源:profiler.cpp

示例11: check_call

    int check_call(ast::Call* call) {
        assert(call != nullptr);

        auto func = functions.find(call->function_name);
        if(func == functions.end()) {
            std::cout << "Unknown function "
                      << call->function_name
                      << " at "
                      << call->id
                      << std::endl;
            return EXIT_FAILURE;
        }
        auto fun = func->getValue();
        auto actual_argument_size = call->arguments.size();
        auto prototype_argument_size = fun.arguments.size();
        if(actual_argument_size < prototype_argument_size) {
            std::cout << "Not enough arguments to "
                      << fun.identifier
                      << " (expected "
                      << prototype_argument_size
                      << ", got "
                      << actual_argument_size
                      << ")"
                      << std::endl;
            return EXIT_FAILURE;
        }
        if(actual_argument_size > prototype_argument_size && !fun.variadic) {
            std::cout << "Too many arguments to "
                      << fun.identifier
                      << " (expected "
                      << prototype_argument_size
                      << ", got "
                      << actual_argument_size
                      << ")"
                      << std::endl;
            return EXIT_FAILURE;
        }
        check_coercion(call->type, fun.return_value, fun.identifier, call->id);
        for (auto it = call->arguments.begin(); it != call->arguments.end(); ++it) {
            auto op = it->get();
            auto index = std::distance(call->arguments.begin(), it);
            auto prototype_op = std::next(fun.arguments.begin(), index);
            check_operation(op);
            // Variadic functions.. don't check type.
            if(prototype_op != fun.arguments.end()) {
                check_coercion(op->type, prototype_op->type, "function argument", op->id);
            }
        }
        return EXIT_SUCCESS;
    }
开发者ID:scoiatael,项目名称:Czero,代码行数:50,代码来源:checker.cpp

示例12: getScaleForTimeInverse

llvm::Optional<DurationScale> getScaleForTimeInverse(llvm::StringRef Name) {
  static const llvm::StringMap<DurationScale> ScaleMap(
      {{"ToUnixHours", DurationScale::Hours},
       {"ToUnixMinutes", DurationScale::Minutes},
       {"ToUnixSeconds", DurationScale::Seconds},
       {"ToUnixMillis", DurationScale::Milliseconds},
       {"ToUnixMicros", DurationScale::Microseconds},
       {"ToUnixNanos", DurationScale::Nanoseconds}});

  auto ScaleIter = ScaleMap.find(std::string(Name));
  if (ScaleIter == ScaleMap.end())
    return llvm::None;

  return ScaleIter->second;
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:15,代码来源:DurationRewriter.cpp

示例13: isTypedefTypeMatching

/// Check if a fixed size width buffer type matches the MPI datatype.
///
/// \param Typedef buffer type
/// \param BufferTypeName buffer type name, gets assigned
/// \param MPIDatatype name of the MPI datatype
///
/// \returns true if the type matches or the buffer type is unknown
static bool isTypedefTypeMatching(const TypedefType *const Typedef,
                                  std::string &BufferTypeName,
                                  const std::string &MPIDatatype) {
  static llvm::StringMap<std::string> FixedWidthMatches = {
      {"int8_t", "MPI_INT8_T"},     {"int16_t", "MPI_INT16_T"},
      {"int32_t", "MPI_INT32_T"},   {"int64_t", "MPI_INT64_T"},
      {"uint8_t", "MPI_UINT8_T"},   {"uint16_t", "MPI_UINT16_T"},
      {"uint32_t", "MPI_UINT32_T"}, {"uint64_t", "MPI_UINT64_T"}};

  const auto it = FixedWidthMatches.find(Typedef->getDecl()->getName());
  // Check if the typedef is known and not matching the MPI datatype.
  if (it != FixedWidthMatches.end() && it->getValue() != MPIDatatype) {
    BufferTypeName = Typedef->getDecl()->getName();
    return false;
  }
  return true;
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:24,代码来源:TypeMismatchCheck.cpp

示例14:

llvm::Value *CGObjCJit::GenerateProtocolRef(CodeGenFunction &CGF,
                                            const ObjCProtocolDecl *PD) {
  if (isUsable) {
    llvm::Value *theProtocol;  
    // If not locally defined, retrieve from runtime
    llvm::StringMap<void*>::iterator it =
      DefinedProtocols.find(PD->getIdentifier()->getNameStart());
    if (it != DefinedProtocols.end()) {
      theProtocol =
          llvm::Constant::getIntegerValue(ObjCTypes.ProtocolPtrTy,
                                          llvm::APInt(sizeof(void*) * 8,
                                                      (uint64_t)it->second));
    } else {
      llvm::Value *ProtocolName =
          CGF.Builder.CreateGlobalStringPtr(PD->getNameAsString());
      theProtocol = CGF.Builder.CreateCall(fn_objc_getProtocol, ProtocolName);
    }
    return CGF.Builder.CreateBitCast(theProtocol, ObjCTypes.getExternalProtocolPtrTy());
  }
  return 0;
}
开发者ID:eerolanguage,项目名称:clang-interpreter-runtime,代码行数:21,代码来源:CGObjCJit.cpp

示例15: addMarker

  // Register a marker.
  void addMarker(StringRef MarkerName, SourceLocation Pos) {
    auto InsertResult = Markers.insert(
        {MarkerName, Marker{Pos, SourceLocation(), SourceLocation()}});

    Marker &M = InsertResult.first->second;
    if (!InsertResult.second) {
      // Marker was redefined.
      M.RedefLoc = Pos;
    } else {
      // First definition: build any deferred directives.
      auto Deferred = DeferredDirectives.find(MarkerName);
      if (Deferred != DeferredDirectives.end()) {
        for (auto &UD : Deferred->second) {
          if (M.UseLoc.isInvalid())
            M.UseLoc = UD.DirectivePos;
          attachDirective(Diags, UD, Pos);
        }
        DeferredDirectives.erase(Deferred);
      }
    }
  }
开发者ID:jvesely,项目名称:clang,代码行数:22,代码来源:VerifyDiagnosticConsumer.cpp


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