本文整理汇总了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());
}
}
示例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;
}
示例3: useStringTable
static bool useStringTable(bool Thin, StringRef Name) {
return Thin || Name.size() >= 16 || Name.contains('/');
}
示例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;
}