38 const MatchFinder::MatchResult &Result) {
39 SourceManager &SM = *Result.SourceManager;
41 const auto *Typedef = Result.Nodes.getNodeAs<TypedefDecl>(
"TypeDecl");
42 StringRef TypeName = Typedef->getName();
45 TypeLoc TL = *Result.Nodes.getNodeAs<TypeLoc>(
"TypeLoc");
46 if (
auto QTL = TL.getAs<QualifiedTypeLoc>())
47 TL = QTL.getUnqualifiedLoc();
49 SourceLocation IoStateLoc = TL.castAs<TypedefTypeLoc>().getNameLoc();
52 bool Fix = Replacement && !TL.getType()->isDependentType();
53 if (IoStateLoc.isMacroID()) {
54 IoStateLoc = SM.getSpellingLoc(IoStateLoc);
58 SourceLocation EndLoc = IoStateLoc.getLocWithOffset(TypeName.size() - 1);
61 const char *FixName = *Replacement;
62 auto Builder = diag(IoStateLoc,
"'std::ios_base::%0' is deprecated; use "
63 "'std::ios_base::%1' instead")
64 << TypeName << FixName;
67 Builder << FixItHint::CreateReplacement(SourceRange(IoStateLoc, EndLoc),
70 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))