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