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


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

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


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

示例1: check

void DurationConversionCastCheck::check(
    const MatchFinder::MatchResult &Result) {
  const auto *MatchedCast =
      Result.Nodes.getNodeAs<ExplicitCastExpr>("cast_expr");

  if (isInMacro(Result, MatchedCast))
    return;

  const auto *FuncDecl = Result.Nodes.getNodeAs<FunctionDecl>("func_decl");
  const auto *Arg = Result.Nodes.getNodeAs<Expr>("arg");
  StringRef ConversionFuncName = FuncDecl->getName();

  llvm::Optional<DurationScale> Scale =
      getScaleForDurationInverse(ConversionFuncName);
  if (!Scale)
    return;

  // Casting a double to an integer.
  if (MatchedCast->getTypeAsWritten()->isIntegerType() &&
      ConversionFuncName.contains("Double")) {
    llvm::StringRef NewFuncName = getDurationInverseForScale(*Scale).second;

    diag(MatchedCast->getBeginLoc(),
         "duration should be converted directly to an integer rather than "
         "through a type cast")
        << FixItHint::CreateReplacement(
               MatchedCast->getSourceRange(),
               (llvm::Twine(NewFuncName.substr(2)) + "(" +
                tooling::fixit::getText(*Arg, *Result.Context) + ")")
                   .str());
  }

  // Casting an integer to a double.
  if (MatchedCast->getTypeAsWritten()->isRealFloatingType() &&
      ConversionFuncName.contains("Int64")) {
    llvm::StringRef NewFuncName = getDurationInverseForScale(*Scale).first;

    diag(MatchedCast->getBeginLoc(), "duration should be converted directly to "
                                     "a floating-piont number rather than "
                                     "through a type cast")
        << FixItHint::CreateReplacement(
               MatchedCast->getSourceRange(),
               (llvm::Twine(NewFuncName.substr(2)) + "(" +
                tooling::fixit::getText(*Arg, *Result.Context) + ")")
                   .str());
  }
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:47,代码来源:DurationConversionCastCheck.cpp

示例2: compareVersion

// Using .symver foo,[email protected]@VER unfortunately creates two symbols: foo and
// [email protected]@VER. We want to effectively ignore foo, so give precedence to
// [email protected]@VER.
// FIXME: If users can transition to using
// .symver foo,[email protected]@@VER
// we can delete this hack.
static int compareVersion(Symbol *S, StringRef Name) {
  bool A = Name.contains("@@");
  bool B = S->getName().contains("@@");
  if (A && !B)
    return 1;
  if (!A && B)
    return -1;
  return 0;
}
开发者ID:llvm-mirror,项目名称:lld,代码行数:15,代码来源:SymbolTable.cpp

示例3: useStringTable

static bool useStringTable(bool Thin, StringRef Name) {
  return Thin || Name.size() >= 16 || Name.contains('/');
}
开发者ID:jamboree,项目名称:llvm,代码行数:3,代码来源:ArchiveWriter.cpp

示例4: quote

// Quote a given string if it contains a space character.
std::string lld::quote(StringRef S) {
  if (S.contains(' '))
    return ("\"" + S + "\"").str();
  return S;
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:6,代码来源:Reproduce.cpp


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