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


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

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


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

示例1: getThinLTOObjectFileName

/// Given the original \p Path to an output file, replace any filename
/// suffix matching \p OldSuffix with \p NewSuffix.
static std::string getThinLTOObjectFileName(const std::string Path,
                                            const std::string &OldSuffix,
                                            const std::string &NewSuffix) {
  if (OldSuffix.empty() && NewSuffix.empty())
    return Path;
  StringRef NewPath = Path;
  NewPath.consume_back(OldSuffix);
  std::string NewNewPath = NewPath.str() + NewSuffix;
  return NewPath.str() + NewSuffix;
}
开发者ID:mikaoP,项目名称:llvm,代码行数:12,代码来源:gold-plugin.cpp

示例2: check

void UseUncaughtExceptionsCheck::check(const MatchFinder::MatchResult &Result) {
  SourceLocation BeginLoc;
  SourceLocation EndLoc;
  const CallExpr *C = Result.Nodes.getNodeAs<CallExpr>("init_call_expr");
  bool WarnOnly = false;

  if (C) {
    BeginLoc = C->getLocStart();
    EndLoc = C->getLocEnd();
  } else if (const auto *E = Result.Nodes.getNodeAs<CallExpr>("call_expr")) {
    BeginLoc = E->getLocStart();
    EndLoc = E->getLocEnd();
  } else if (const auto *D =
                 Result.Nodes.getNodeAs<DeclRefExpr>("decl_ref_expr")) {
    BeginLoc = D->getLocStart();
    EndLoc = D->getLocEnd();
    WarnOnly = true;
  } else {
    const auto *U = Result.Nodes.getNodeAs<UsingDecl>("using_decl");
    assert(U && "Null pointer, no node provided");
    BeginLoc = U->getNameInfo().getBeginLoc();
    EndLoc = U->getNameInfo().getEndLoc();
  }

  auto Diag = diag(BeginLoc, "'std::uncaught_exception' is deprecated, use "
                             "'std::uncaught_exceptions' instead");

  if (!BeginLoc.isMacroID()) {
    StringRef Text =
        Lexer::getSourceText(CharSourceRange::getTokenRange(BeginLoc, EndLoc),
                             *Result.SourceManager, getLangOpts());

    Text.consume_back("()");
    int TextLength = Text.size();

    if (WarnOnly) {
      return;
    }

    if (!C) {
      Diag << FixItHint::CreateInsertion(BeginLoc.getLocWithOffset(TextLength),
                                         "s");
    } else {
      Diag << FixItHint::CreateReplacement(C->getSourceRange(),
                                           "std::uncaught_exceptions() > 0");
    }
  }
}
开发者ID:staronj,项目名称:clang-tools-extra,代码行数:48,代码来源:UseUncaughtExceptionsCheck.cpp


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