File indexing completed on 2026-05-10 08:36:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONFUSABLE_IDENTIFIER_CHECK_H
0011 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONFUSABLE_IDENTIFIER_CHECK_H
0012
0013 #include "../ClangTidyCheck.h"
0014 #include <unordered_map>
0015
0016 namespace clang::tidy::misc {
0017
0018
0019
0020
0021
0022 class ConfusableIdentifierCheck : public ClangTidyCheck {
0023 public:
0024 ConfusableIdentifierCheck(StringRef Name, ClangTidyContext *Context);
0025 ~ConfusableIdentifierCheck();
0026
0027 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0028 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0029 void onEndOfTranslationUnit() override;
0030 std::optional<TraversalKind> getCheckTraversalKind() const override {
0031 return TK_IgnoreUnlessSpelledInSource;
0032 }
0033
0034 struct ContextInfo {
0035 const DeclContext *PrimaryContext;
0036 const DeclContext *NonTransparentContext;
0037 llvm::SmallVector<const DeclContext *> PrimaryContexts;
0038 llvm::SmallVector<const CXXRecordDecl *> Bases;
0039 };
0040
0041 private:
0042 struct Entry {
0043 const NamedDecl *Declaration;
0044 const ContextInfo *Info;
0045 };
0046
0047 const ContextInfo *getContextInfo(const DeclContext *DC);
0048
0049 llvm::StringMap<llvm::SmallVector<Entry>> Mapper;
0050 std::unordered_map<const DeclContext *, ContextInfo> ContextInfos;
0051 };
0052
0053 }
0054
0055 #endif