20 return Node.isIntegerType() && !Node.isAnyCharacterType() &&
21 !Node.isBooleanType();
25 void UseToStringCheck::registerMatchers(MatchFinder *Finder) {
26 if (!getLangOpts().CPlusPlus)
31 hasDeclaration(functionDecl(
32 returns(hasDeclaration(classTemplateSpecializationDecl(
33 hasName(
"std::basic_string"),
34 hasTemplateArgument(0,
35 templateArgument().bind(
"char_type"))))),
36 hasName(
"boost::lexical_cast"),
37 hasParameter(0, hasType(qualType(has(substTemplateTypeParmType(
38 isStrictlyInteger()))))))),
39 argumentCountIs(1), unless(isInTemplateInstantiation()))
44 void UseToStringCheck::check(
const MatchFinder::MatchResult &
Result) {
45 const auto *Call = Result.Nodes.getNodeAs<CallExpr>(
"to_string");
47 Result.Nodes.getNodeAs<TemplateArgument>(
"char_type")->getAsType();
50 if (CharType->isSpecificBuiltinType(BuiltinType::Char_S) ||
51 CharType->isSpecificBuiltinType(BuiltinType::Char_U))
52 StringType =
"string";
53 else if (CharType->isSpecificBuiltinType(BuiltinType::WChar_S) ||
54 CharType->isSpecificBuiltinType(BuiltinType::WChar_U))
55 StringType =
"wstring";
59 auto Loc = Call->getBeginLoc();
61 diag(
Loc,
"use std::to_%0 instead of boost::lexical_cast<std::%0>")
67 Diag << FixItHint::CreateReplacement(
68 CharSourceRange::getCharRange(Call->getBeginLoc(),
69 Call->getArg(0)->getBeginLoc()),
70 (llvm::Twine(
"std::to_") + StringType +
"(").str());
SourceLocation Loc
'#' location in the include directive
AST_MATCHER(BinaryOperator, isAssignmentOperator)
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//