File indexing completed on 2026-05-10 08:36:20
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
0011
0012 #include "../ClangTidyCheck.h"
0013 #include "../utils/FileExtensionsUtils.h"
0014 #include "llvm/ADT/SmallPtrSet.h"
0015 #include <vector>
0016
0017 namespace clang::tidy::misc {
0018
0019
0020
0021
0022
0023 class UnusedUsingDeclsCheck : public ClangTidyCheck {
0024 public:
0025 UnusedUsingDeclsCheck(StringRef Name, ClangTidyContext *Context);
0026 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0027 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0028 void onEndOfTranslationUnit() override;
0029 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
0030 return LangOpts.CPlusPlus;
0031 }
0032
0033 private:
0034 void removeFromFoundDecls(const Decl *D);
0035
0036 struct UsingDeclContext {
0037 explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
0038 : FoundUsingDecl(FoundUsingDecl) {}
0039
0040
0041
0042 llvm::SmallPtrSet<const Decl *, 4> UsingTargetDecls;
0043
0044 const UsingDecl *FoundUsingDecl;
0045
0046 CharSourceRange UsingDeclRange;
0047
0048 bool IsUsed = false;
0049 };
0050
0051 std::vector<UsingDeclContext> Contexts;
0052 llvm::SmallPtrSet<const Decl *, 32> UsingTargetDeclsCache;
0053
0054 FileExtensionsSet HeaderFileExtensions;
0055 };
0056
0057 }
0058
0059 #endif