本文整理汇总了C++中llvm::StringMap::end方法的典型用法代码示例。如果您正苦于以下问题:C++ StringMap::end方法的具体用法?C++ StringMap::end怎么用?C++ StringMap::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::StringMap
的用法示例。
在下文中一共展示了StringMap::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: 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;
}
示例3: 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);
}
示例4: 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;
}
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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;
}
示例8: 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';
}
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例15: getScaleForDurationInverse
llvm::Optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name) {
static const llvm::StringMap<DurationScale> ScaleMap(
{{"ToDoubleHours", DurationScale::Hours},
{"ToInt64Hours", DurationScale::Hours},
{"ToDoubleMinutes", DurationScale::Minutes},
{"ToInt64Minutes", DurationScale::Minutes},
{"ToDoubleSeconds", DurationScale::Seconds},
{"ToInt64Seconds", DurationScale::Seconds},
{"ToDoubleMilliseconds", DurationScale::Milliseconds},
{"ToInt64Milliseconds", DurationScale::Milliseconds},
{"ToDoubleMicroseconds", DurationScale::Microseconds},
{"ToInt64Microseconds", DurationScale::Microseconds},
{"ToDoubleNanoseconds", DurationScale::Nanoseconds},
{"ToInt64Nanoseconds", DurationScale::Nanoseconds}});
auto ScaleIter = ScaleMap.find(std::string(Name));
if (ScaleIter == ScaleMap.end())
return llvm::None;
return ScaleIter->second;
}