Debian Codegraph @

llvm-project/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.h

raw
1 //===--- ConfusableIdentifierCheck.h - clang-tidy
2 //-------------------------------*- C++ -*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONFUSABLE_IDENTIFIER_CHECK_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONFUSABLE_IDENTIFIER_CHECK_H
12
13 #include "../ClangTidyCheck.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
29 private:
30 std::string skeleton(StringRef);
31 llvm::StringMap<llvm::SmallVector<const NamedDecl *>> Mapper;
32 };
33
34 } // namespace clang::tidy::misc
35
36 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONFUSABLE_IDENTIFIER_CHECK_H