clang-tools
22.0.0git
llvm-project
clang-tools-extra
clang-tidy
misc
ConfusableIdentifierCheck.h
Go to the documentation of this file.
1
//===----------------------------------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONFUSABLE_IDENTIFIER_CHECK_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONFUSABLE_IDENTIFIER_CHECK_H
11
12
#include "
../ClangTidyCheck.h
"
13
#include "llvm/ADT/DenseMap.h"
14
15
namespace
clang::tidy::misc
{
16
17
/// Finds symbol which have confusable identifiers, i.e. identifiers that look
18
/// the same visually but have a different Unicode representation.
19
/// If symbols are confusable but don't live in conflicting namespaces, they are
20
/// not reported.
21
class
ConfusableIdentifierCheck
:
public
ClangTidyCheck
{
22
public
:
23
ConfusableIdentifierCheck
(StringRef Name,
ClangTidyContext
*Context);
24
~ConfusableIdentifierCheck
();
25
26
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
27
void
check
(
const
ast_matchers::MatchFinder::MatchResult &Result)
override
;
28
void
onEndOfTranslationUnit
()
override
;
29
std::optional<TraversalKind>
getCheckTraversalKind
()
const override
{
30
return
TK_IgnoreUnlessSpelledInSource;
31
}
32
33
private
:
34
void
addDeclToCheck(
const
NamedDecl *ND,
const
Decl *Parent);
35
36
llvm::DenseMap<
37
const
IdentifierInfo *,
38
llvm::SmallVector<std::pair<const NamedDecl *, const Decl *>, 1>>
39
NameToDecls;
40
};
41
42
}
// namespace clang::tidy::misc
43
44
#endif
// LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONFUSABLE_IDENTIFIER_CHECK_H
ClangTidyCheck.h
ClangTidyCheck
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition
ClangTidyDiagnosticConsumer.h:70
clang::tidy::misc::ConfusableIdentifierCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
Definition
ConfusableIdentifierCheck.cpp:155
clang::tidy::misc::ConfusableIdentifierCheck::~ConfusableIdentifierCheck
~ConfusableIdentifierCheck()
clang::tidy::misc::ConfusableIdentifierCheck::onEndOfTranslationUnit
void onEndOfTranslationUnit() override
Definition
ConfusableIdentifierCheck.cpp:193
clang::tidy::misc::ConfusableIdentifierCheck::ConfusableIdentifierCheck
ConfusableIdentifierCheck(StringRef Name, ClangTidyContext *Context)
Definition
ConfusableIdentifierCheck.cpp:26
clang::tidy::misc::ConfusableIdentifierCheck::getCheckTraversalKind
std::optional< TraversalKind > getCheckTraversalKind() const override
Definition
ConfusableIdentifierCheck.h:29
clang::tidy::misc::ConfusableIdentifierCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Definition
ConfusableIdentifierCheck.cpp:250
clang::tidy::misc
Definition
ConfusableIdentifierCheck.cpp:24
Generated on
for clang-tools by
1.14.0