39 const MatchFinder::MatchResult &Result) {
40 const SourceManager &SM = *Result.SourceManager;
42 const auto *Typedef = Result.Nodes.getNodeAs<TypedefDecl>(
"TypeDecl");
43 const StringRef TypeName = Typedef->getName();
46 TypeLoc TL = *Result.Nodes.getNodeAs<TypeLoc>(
"TypeLoc");
47 if (
const auto QTL = TL.getAs<QualifiedTypeLoc>())
48 TL = QTL.getUnqualifiedLoc();
50 SourceLocation IoStateLoc = TL.castAs<TypedefTypeLoc>().getNameLoc();
53 bool Fix = Replacement && !TL.getType()->isDependentType();
54 if (IoStateLoc.isMacroID()) {
55 IoStateLoc = SM.getSpellingLoc(IoStateLoc);
59 const SourceLocation EndLoc =
60 IoStateLoc.getLocWithOffset(TypeName.size() - 1);
63 const char *FixName = *Replacement;
65 diag(IoStateLoc,
"'std::ios_base::%0' is deprecated; use "
66 "'std::ios_base::%1' instead")
67 << TypeName << FixName;
70 Builder << FixItHint::CreateReplacement(SourceRange(IoStateLoc, EndLoc),
73 diag(IoStateLoc,
"'std::ios_base::%0' is deprecated") << TypeName;
static cl::opt< bool > Fix("fix", desc(R"(
Apply suggested fixes. Without -fix-errors
clang-tidy will bail out if any compilation
errors were found.
)"), cl::init(false), cl::cat(ClangTidyCategory))