50 const SourceManager &SM,
51 const LangOptions &LangOpts) {
52 if (Loc.isValid() && !Loc.isMacroID()) {
53 const auto LocInfo = SM.getDecomposedLoc(Loc);
55 StringRef Buffer = SM.getBufferData(LocInfo.first, &Invalid);
56 if (!Invalid && LocInfo.second > 0 && LocInfo.second + 1 < Buffer.size() &&
57 Lexer::isAsciiIdentifierContinueChar(Buffer[LocInfo.second - 1],
59 Lexer::isAsciiIdentifierContinueChar(Buffer[LocInfo.second + 1],
61 return FixItHint::CreateReplacement(SourceRange(Loc, Loc),
" ");
63 return FixItHint::CreateRemoval(Loc);
79 const auto ConstantExpr =
80 expr(anyOf(integerLiteral(), floatLiteral(), characterLiteral(),
81 cxxBoolLiteral(), stringLiteral(), cxxNullPtrLiteralExpr()));
84 const auto DecltypeOperand =
85 expr(anyOf(declRefExpr(), memberExpr(), dependentScopeDeclRefExpr(),
86 cxxDependentScopeMemberExpr(), unresolvedLookupExpr(),
87 substNonTypeTemplateParmExpr()));
88 const auto DecltypeAutoType = ignoringParens(autoType(isDecltypeAuto()));
89 const auto DecltypeAutoVar = varDecl(hasType(DecltypeAutoType));
91 const auto InDecltypeAutoContext = anyOf(
92 hasParent(DecltypeAutoVar),
94 expr(anyOf(initListExpr(), parenListExpr()),
95 anyOf(hasParent(DecltypeAutoVar),
96 hasParent(exprWithCleanups(hasParent(DecltypeAutoVar)))))),
98 returnStmt(forCallable(functionDecl(returns(DecltypeAutoType))))));
99 const auto IsDecltypeOperand = allOf(
100 subExpr(ignoringParens(DecltypeOperand)),
101 anyOf(hasParent(typeLoc(loc(decltypeType()))), InDecltypeAutoContext,
102 hasParent(exprWithCleanups(InDecltypeAutoContext))));
104 parenExpr(subExpr(anyOf(
105 parenExpr(), ConstantExpr,
106 declRefExpr(to(namedDecl(unless(
109 callExpr(unless(cxxOperatorCallExpr(
110 unless(hasAnyOperatorName(
"()",
"[]"))))),
111 arraySubscriptExpr())),
113 unless(anyOf(isInMacro(),
115 hasParent(unaryExprOrTypeTraitExpr()),
117 hasParent(typeLoc(isTypeOfExprTypeLoc())),
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.