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


C++ StringRef::equals方法代码示例

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


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

示例1: isEmscriptenJSArgsFunc

static bool isEmscriptenJSArgsFunc(Module *M, StringRef Name) {
  // TODO(jfb) Make these intrinsics in clang and remove the assert: these
  //           intrinsics should only exist for Emscripten.
  bool isEmscriptenSpecial = Name.equals("emscripten_asm_const_int") ||
                             Name.equals("emscripten_asm_const_double") ||
                             Name.equals("emscripten_landingpad") ||
                             Name.equals("emscripten_resume");
  assert(isEmscriptenSpecial ? Triple(M->getTargetTriple()).isOSEmscripten()
                             : true);
  return isEmscriptenSpecial;
}
开发者ID:Maher4Ever,项目名称:emscripten-fastcomp,代码行数:11,代码来源:ExpandVarArgs.cpp

示例2: isSmallDataSection

// Returns true if the section name is such that the symbol will be put
// in a small data section.
// For instance, global variables with section attributes such as ".sdata"
// ".sdata.*", ".sbss", and ".sbss.*" will go into small data.
static bool isSmallDataSection(StringRef Sec) {
  // sectionName is either ".sdata" or ".sbss". Looking for an exact match
  // obviates the need for checks for section names such as ".sdatafoo".
  if (Sec.equals(".sdata") || Sec.equals(".sbss") || Sec.equals(".scommon"))
    return true;
  // If either ".sdata." or ".sbss." is a substring of the section name
  // then put the symbol in small data.
  return Sec.find(".sdata.") != StringRef::npos ||
         Sec.find(".sbss.") != StringRef::npos ||
         Sec.find(".scommon.") != StringRef::npos;
}
开发者ID:AnachroNia,项目名称:llvm,代码行数:15,代码来源:HexagonTargetObjectFile.cpp

示例3: parseBPFArch

static Triple::ArchType parseBPFArch(StringRef ArchName) {
  if (ArchName.equals("bpf")) {
    if (sys::IsLittleEndianHost)
      return Triple::bpfel;
    else
      return Triple::bpfeb;
  } else if (ArchName.equals("bpf_be") || ArchName.equals("bpfeb")) {
    return Triple::bpfeb;
  } else if (ArchName.equals("bpf_le") || ArchName.equals("bpfel")) {
    return Triple::bpfel;
  } else {
    return Triple::UnknownArch;
  }
}
开发者ID:RichardsonAlex,项目名称:llvm-1,代码行数:14,代码来源:Triple.cpp

示例4: postSocket

// If argument 0(protocol domain) is network, the return value should get taint.
ProgramStateRef GenericTaintChecker::postSocket(const CallExpr *CE,
                                                CheckerContext &C) const {
  ProgramStateRef State = C.getState();
  if (CE->getNumArgs() < 3)
    return State;

  SourceLocation DomLoc = CE->getArg(0)->getExprLoc();
  StringRef DomName = C.getMacroNameOrSpelling(DomLoc);
  // White list the internal communication protocols.
  if (DomName.equals("AF_SYSTEM") || DomName.equals("AF_LOCAL") ||
      DomName.equals("AF_UNIX") || DomName.equals("AF_RESERVED_36"))
    return State;
  State = State->addTaint(CE, C.getLocationContext());
  return State;
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:16,代码来源:GenericTaintChecker.cpp

示例5: switch

AMDGPUAsmParser::OperandMatchResultTy
AMDGPUAsmParser::parseIntWithPrefix(const char *Prefix, int64_t &Int,
                                    int64_t Default) {

  // We are at the end of the statement, and this is a default argument, so
  // use a default value.
  if (getLexer().is(AsmToken::EndOfStatement)) {
    Int = Default;
    return MatchOperand_Success;
  }

  switch(getLexer().getKind()) {
    default: return MatchOperand_NoMatch;
    case AsmToken::Identifier: {
      StringRef OffsetName = Parser.getTok().getString();
      if (!OffsetName.equals(Prefix))
        return MatchOperand_NoMatch;

      Parser.Lex();
      if (getLexer().isNot(AsmToken::Colon))
        return MatchOperand_ParseFail;

      Parser.Lex();
      if (getLexer().isNot(AsmToken::Integer))
        return MatchOperand_ParseFail;

      if (getParser().parseAbsoluteExpression(Int))
        return MatchOperand_ParseFail;
      break;
    }
  }
  return MatchOperand_Success;
}
开发者ID:cephdon,项目名称:llvm,代码行数:33,代码来源:AMDGPUAsmParser.cpp

示例6: isCLibraryFunction

bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD,
                                        StringRef Name, ASTContext &Context) {
  // To avoid false positives (Ex: finding user defined functions with
  // similar names), only perform fuzzy name matching when it's a builtin.
  // Using a string compare is slow, we might want to switch on BuiltinID here.
  unsigned BId = FD->getBuiltinID();
  if (BId != 0) {
    StringRef BName = Context.BuiltinInfo.GetName(BId);
    if (BName.find(Name) != StringRef::npos)
      return true;
  }

  const IdentifierInfo *II = FD->getIdentifier();
  // If this is a special C++ name without IdentifierInfo, it can't be a
  // C library function.
  if (!II)
    return false;

  StringRef FName = II->getName();
  if (FName.equals(Name))
    return true;

  if (FName.startswith("__inline") && (FName.find(Name) != StringRef::npos))
    return true;

  if (FName.startswith("__") && FName.endswith("_chk") &&
      FName.find(Name) != StringRef::npos)
    return true;

  return false;
}
开发者ID:2014-class,项目名称:freerouter,代码行数:31,代码来源:CheckerContext.cpp

示例7: parse

bool CodeGenCoverage::parse(MemoryBuffer &Buffer, StringRef BackendName) {
  const char *CurPtr = Buffer.getBufferStart();

  while (CurPtr != Buffer.getBufferEnd()) {
    // Read the backend name from the input.
    const char *LexedBackendName = CurPtr;
    while (*CurPtr++ != 0)
      ;
    if (CurPtr == Buffer.getBufferEnd())
      return false; // Data is invalid, expected rule id's to follow.

    bool IsForThisBackend = BackendName.equals(LexedBackendName);
    while (CurPtr != Buffer.getBufferEnd()) {
      if (std::distance(CurPtr, Buffer.getBufferEnd()) < 8)
        return false; // Data is invalid. Not enough bytes for another rule id.

      uint64_t RuleID = support::endian::read64(CurPtr, support::native);
      CurPtr += 8;

      // ~0ull terminates the rule id list.
      if (RuleID == ~0ull)
        break;

      // Anything else, is recorded or ignored depending on whether it's
      // intended for the backend we're interested in.
      if (IsForThisBackend)
        setCovered(RuleID);
    }
  }

  return true;
}
开发者ID:bkaradzic,项目名称:SwiftShader,代码行数:32,代码来源:CodeGenCoverage.cpp

示例8: assert

/// \brief Find string metadata for loop
///
/// If it has a value (e.g. {"llvm.distribute", 1} return the value as an
/// operand or null otherwise.  If the string metadata is not found return
/// Optional's not-a-value.
Optional<const MDOperand *> llvm::findStringMetadataForLoop(Loop *TheLoop,
                                                            StringRef Name) {
  MDNode *LoopID = TheLoop->getLoopID();
  // Return none if LoopID is false.
  if (!LoopID)
    return None;

  // First operand should refer to the loop id itself.
  assert(LoopID->getNumOperands() > 0 && "requires at least one operand");
  assert(LoopID->getOperand(0) == LoopID && "invalid loop id");

  // Iterate over LoopID operands and look for MDString Metadata
  for (unsigned i = 1, e = LoopID->getNumOperands(); i < e; ++i) {
    MDNode *MD = dyn_cast<MDNode>(LoopID->getOperand(i));
    if (!MD)
      continue;
    MDString *S = dyn_cast<MDString>(MD->getOperand(0));
    if (!S)
      continue;
    // Return true if MDString holds expected MetaData.
    if (Name.equals(S->getString()))
      switch (MD->getNumOperands()) {
      case 1:
        return nullptr;
      case 2:
        return &MD->getOperand(1);
      default:
        llvm_unreachable("loop metadata has 0 or 1 operand");
      }
  }
  return None;
}
开发者ID:theryee,项目名称:llvm,代码行数:37,代码来源:LoopUtils.cpp

示例9:

bool Input::MapHNode::isValidKey(StringRef Key) {
  for (const char *K : ValidKeys) {
    if (Key.equals(K))
      return true;
  }
  return false;
}
开发者ID:AntiMoron,项目名称:llvm,代码行数:7,代码来源:YAMLTraits.cpp

示例10:

bool Input::MapHNode::isValidKey(StringRef Key) {
  for (SmallVectorImpl<const char *>::iterator i = ValidKeys.begin(),
       End = ValidKeys.end(); i != End; ++i) {
    if (Key.equals(*i))
      return true;
  }
  return false;
}
开发者ID:TristanSchmelcher,项目名称:llvm-andersen,代码行数:8,代码来源:YAMLTraits.cpp

示例11: get_io_code

IOCode cdfg::get_io_code(CallInst &C)
{
  llvm::Function *f = C.getCalledFunction();
  assert(f && "function pointers are not currently supported");
  
  if (!f->isDeclaration())
    return NOT_IO;

  StringRef name = f->getName();
  IOCode ioc = (name.equals("read_uint32") ? READ_UINT32
                : (name.equals("write_uint32") ? WRITE_UINT32
                   : (name.equals("read_float32") ? READ_FLOAT32
                      : (name.equals("write_float32") ? WRITE_FLOAT32
                         : NOT_IO))));
  
  return ioc;
}
开发者ID:ahirOrg,项目名称:ahir,代码行数:17,代码来源:Utils.cpp

示例12: get_loop_pipelining_info

bool Aa::get_loop_pipelining_info(llvm::BasicBlock& BB,int& pipelining_depth, int& buffering, bool& full_rate_flag)
{
	bool opt_fn_found = false;

	for(llvm::BasicBlock::iterator iiter = BB.begin(),fiter = BB.end(); 
			iiter != fiter;  ++iiter)
	{
		if(isa<CallInst>(*iiter))
		{
			llvm::CallInst& C = static_cast<CallInst&>(*iiter);
			llvm::Function* f  = C.getCalledFunction();

			if(f == NULL)
				return(false);

			if(f->isDeclaration())
			{
				StringRef name = f->getName();
				if(name.equals("__loop_pipelining_on__"))
				{
					opt_fn_found = true;
					if(C.getNumArgOperands() > 0)
					{
						llvm::Value* v = C.getArgOperand(0);	
						if(isa<Constant>(v))
						{
							int pd = get_uint32(dyn_cast<Constant>(v));
							if(pd > 0)
								pipelining_depth = pd;
						}	
						if(C.getNumArgOperands() > 1)
						{
							v = C.getArgOperand(1);	
							if(isa<Constant>(v))
							{
								int bd = get_uint32(dyn_cast<Constant>(v));
								if(bd > 0)
									buffering = bd;
							}
						}
						if(C.getNumArgOperands() > 2)
						{
							v = C.getArgOperand(2);	
							if(isa<Constant>(v))
							{
								int bd = get_uint32(dyn_cast<Constant>(v));
								if(bd > 0)
									full_rate_flag = true;
							}
						}
					}
					break;
				}
			}
		}
	}
	return(opt_fn_found);
}
开发者ID:madhavPdesai,项目名称:ahir,代码行数:58,代码来源:Utils.cpp

示例13: mapTag

bool Input::mapTag(StringRef Tag, bool Default) {
  std::string foundTag = CurrentNode->_node->getVerbatimTag();
  if (foundTag.empty()) {
    // If no tag found and 'Tag' is the default, say it was found.
    return Default;
  }
  // Return true iff found tag matches supplied tag.
  return Tag.equals(foundTag);
}
开发者ID:AntiMoron,项目名称:llvm,代码行数:9,代码来源:YAMLTraits.cpp

示例14: setProperty

void ExecutionContext::setProperty(const StringRef name, const ValueRef value)
{
    Scope scope(this);
    for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
        if (ctx->type == Type_WithContext) {
            ScopedObject w(scope, static_cast<WithContext *>(ctx)->withObject);
            if (w->__hasProperty__(name)) {
                w->put(name, value);
                return;
            }
        } else if (ctx->type == Type_CatchContext && static_cast<CatchContext *>(ctx)->exceptionVarName->isEqualTo(name)) {
            static_cast<CatchContext *>(ctx)->exceptionValue = *value;
            return;
        } else {
            ScopedObject activation(scope, (Object *)0);
            if (ctx->type >= Type_CallContext) {
                CallContext *c = static_cast<CallContext *>(ctx);
                if (c->function->function) {
                    uint index = c->function->function->internalClass->find(name);
                    if (index < UINT_MAX) {
                        if (index < c->function->formalParameterCount) {
                            c->callData->args[c->function->formalParameterCount - index - 1] = *value;
                        } else {
                            index -= c->function->formalParameterCount;
                            c->locals[index] = *value;
                        }
                        return;
                    }
                }
                activation = c->activation;
            } else if (ctx->type == Type_GlobalContext) {
                activation = static_cast<GlobalContext *>(ctx)->global;
            }

            if (activation) {
                if (ctx->type == Type_QmlContext) {
                    activation->put(name, value);
                    return;
                } else {
                    PropertyAttributes attrs;
                    Property *p = activation->__getOwnProperty__(name, &attrs);
                    if (p) {
                        activation->putValue(p, attrs, value);
                        return;
                    }
                }
            }
        }
    }
    if (strictMode || name->equals(engine->id_this)) {
        ScopedValue n(scope, name.asReturnedValue());
        throwReferenceError(n);
        return;
    }
    engine->globalObject->put(name, value);
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:56,代码来源:qv4context.cpp

示例15: handleIns

void StatsComputer::handleIns(FunInfo &funInfo, const Instruction &ins) {
  if (const CallInst *CI = dyn_cast<const CallInst>(&ins)) {
    if (CI->isInlineAsm()) {
#ifdef DEBUG_ASM
      errs() << "ASM: in " << ins.getParent()->getParent()->getName() << " ";
      CI->print(errs());
      CI->getParent()->print(errs());
      errs() << "\n";
#endif
      funInfo.setHasAsm();
    } else {
      Function *called = CI->getCalledFunction();
      if (called) {
        StringRef calledName = called->getName();
        if (calledName.startswith("llvm.") ||
            calledName.equals("__assert_fail") ||
            calledName.equals("__kmalloc") || calledName.equals("kfree") ||
            isLockingFun(calledName))
          return;
        if (called->isDeclaration()) {
#ifdef DEBUG_EXT
          errs() << "EXT1 " << ins.getParent()->getParent()->getName() << " to "
                 << called->getName() << "\n";
#endif
          funInfo.setHasExternalCall();
        }
      } else {
#ifdef DEBUG_EXT
        errs() << "EXT2 " << ins.getParent()->getParent()->getName() << " to ";
        ins.print(errs());
        errs() << '\n';
#endif
        funInfo.setHasExternalCall();
      }
      funInfo.setHasCall();
    }
  } else if (const StoreInst *SI = dyn_cast<const StoreInst>(&ins)) {
    const Value *LHS = SI->getPointerOperand();
    if (LHS->hasName() && LHS->getName().startswith("__ai_state"))
      funInfo.setHasLock();
  }
}
开发者ID:Justme0,项目名称:LLVMSlicer,代码行数:42,代码来源:ModStats.cpp


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