clang-tools
18.0.0git
llvm-project
clang-tools-extra
clang-tidy
misc
UnusedUsingDeclsCheck.h
Go to the documentation of this file.
1
//===--- UnusedUsingDeclsCheck.h - clang-tidy--------------------*- C++ -*-===//
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_UNUSED_USING_DECLS_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
11
12
#include "../ClangTidyCheck.h"
13
#include "../utils/FileExtensionsUtils.h"
14
#include "llvm/ADT/SmallPtrSet.h"
15
#include <vector>
16
17
namespace
clang::tidy::misc
{
18
19
/// Finds unused using declarations.
20
///
21
/// For the user-facing documentation see:
22
/// http://clang.llvm.org/extra/clang-tidy/checks/misc/unused-using-decls.html
23
class
UnusedUsingDeclsCheck
:
public
ClangTidyCheck
{
24
public
:
25
UnusedUsingDeclsCheck
(StringRef
Name
,
ClangTidyContext
*Context);
26
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
27
void
check
(
const
ast_matchers::MatchFinder::MatchResult &Result)
override
;
28
void
onEndOfTranslationUnit
()
override
;
29
30
private
:
31
void
removeFromFoundDecls(
const
Decl
*D);
32
33
struct
UsingDeclContext {
34
explicit
UsingDeclContext(
const
UsingDecl *FoundUsingDecl)
35
: FoundUsingDecl(FoundUsingDecl) {}
36
// A set saves all UsingShadowDecls introduced by a UsingDecl. A UsingDecl
37
// can introduce multiple UsingShadowDecls in some cases (such as
38
// overloaded functions).
39
llvm::SmallPtrSet<const Decl *, 4> UsingTargetDecls;
40
// The original UsingDecl.
41
const
UsingDecl *FoundUsingDecl;
42
// The source range of the UsingDecl.
43
CharSourceRange UsingDeclRange;
44
// Whether the UsingDecl is used.
45
bool
IsUsed
=
false
;
46
};
47
48
std::vector<UsingDeclContext> Contexts;
49
50
StringRef RawStringHeaderFileExtensions;
51
FileExtensionsSet
HeaderFileExtensions;
52
};
53
54
}
// namespace clang::tidy::misc
55
56
#endif
// LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
IsUsed
bool IsUsed
Definition:
AvoidBindCheck.cpp:83
Decl
const FunctionDecl * Decl
Definition:
AvoidBindCheck.cpp:98
Name
llvm::StringRef Name
Definition:
HeaderIncludeCycleCheck.cpp:30
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidyCheck.h:53
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:69
clang::tidy::misc::UnusedUsingDeclsCheck
Finds unused using declarations.
Definition:
UnusedUsingDeclsCheck.h:23
clang::tidy::misc::UnusedUsingDeclsCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
UnusedUsingDeclsCheck.cpp:58
clang::tidy::misc::UnusedUsingDeclsCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
UnusedUsingDeclsCheck.cpp:87
clang::tidy::misc::UnusedUsingDeclsCheck::onEndOfTranslationUnit
void onEndOfTranslationUnit() override
Definition:
UnusedUsingDeclsCheck.cpp:215
clang::tidy::misc
Definition:
ConfusableIdentifierCheck.cpp:25
clang::tidy::FileExtensionsSet
llvm::SmallSet< llvm::StringRef, 5 > FileExtensionsSet
Definition:
FileExtensionsSet.h:16
Generated on Tue Nov 28 2023 13:40:22 for clang-tools by
1.9.6