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


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

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


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

示例1: 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

示例2: 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

示例3: _objc_getClass

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

示例4: displayCounts

void displayCounts() {
    vector<pair<int, string> > counts;
    llvm::StringMap<int>::iterator cmi = countsMap.begin();
    while (cmi != countsMap.end()) {
        counts.push_back(make_pair(cmi->getValue(), cmi->getKey()));
        ++cmi;
    }
    sort(counts.begin(), counts.end());
    for (unsigned i = 0; i < counts.size(); ++i) {
        llvm::outs() << counts[i].second << " - " << counts[i].first << '\n';
    }
}
开发者ID:Blei,项目名称:clay,代码行数:12,代码来源:profiler.cpp

示例5: callHandler

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

示例6: 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

示例7: 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

示例8: hide

static void hide(llvm::StringMap<cl::Option *> &map, const char *name) {
  // Check if option exists first for resilience against LLVM changes
  // between versions.
  if (map.count(name)) {
    map[name]->setHiddenFlag(cl::Hidden);
  }
}
开发者ID:digideskio,项目名称:Calypso,代码行数:7,代码来源:main.cpp

示例9: 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

示例10: assert_existing_variable

 void assert_existing_variable(llvm::StringMapIterator<ast::Variable> ptr, std::string identifier, int id = -1) {
     if(ptr == variables.end()) {
         std::cout << "Unknown variable "
                   << identifier;
         print_id(id);
         std::cout << std::endl;
     }
 }
开发者ID:scoiatael,项目名称:Czero,代码行数:8,代码来源:checker.cpp

示例11: check

void DeprecatedIosBaseAliasesCheck::check(
    const MatchFinder::MatchResult &Result) {
  SourceManager &SM = *Result.SourceManager;

  const auto *Typedef = Result.Nodes.getNodeAs<TypedefDecl>("TypeDecl");
  StringRef TypeName = Typedef->getName();
  bool HasReplacement = ReplacementTypes.count(TypeName);

  const auto *TL = Result.Nodes.getNodeAs<TypeLoc>("TypeLoc");
  SourceLocation IoStateLoc = TL->getBeginLoc();

  // Do not generate fixits for matches depending on template arguments and
  // macro expansions.
  bool Fix = HasReplacement && !TL->getType()->isDependentType();
  if (IoStateLoc.isMacroID()) {
    IoStateLoc = SM.getSpellingLoc(IoStateLoc);
    Fix = false;
  }

  SourceLocation EndLoc = IoStateLoc.getLocWithOffset(TypeName.size() - 1);

  if (HasReplacement) {
    auto FixName = ReplacementTypes.lookup(TypeName);
    auto Builder = diag(IoStateLoc, "'std::ios_base::%0' is deprecated; use "
                                    "'std::ios_base::%1' instead")
                   << TypeName << FixName;

    if (Fix)
      Builder << FixItHint::CreateReplacement(SourceRange(IoStateLoc, EndLoc),
                                              FixName);
  } else
    diag(IoStateLoc, "'std::ios_base::%0' is deprecated") << TypeName;
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:33,代码来源:DeprecatedIosBaseAliasesCheck.cpp

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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