clang-tools
3.9.0
Main Page
Namespaces
Classes
Files
File List
File Members
llvm.src
tools
clang
tools
extra
clang-tidy
misc
ForwardDeclarationNamespaceCheck.h
Go to the documentation of this file.
1
//===--- ForwardDeclarationNamespaceCheck.h - clang-tidy --------*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FORWARDDECLARATIONNAMESPACECHECK_H
11
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FORWARDDECLARATIONNAMESPACECHECK_H
12
13
#include <set>
14
#include <vector>
15
#include "llvm/ADT/SmallPtrSet.h"
16
#include "../ClangTidy.h"
17
18
namespace
clang {
19
namespace
tidy {
20
namespace
misc {
21
22
/// Checks if an unused forward declaration is in a wrong namespace.
23
///
24
/// The check inspects all unused forward declarations and checks if there is
25
/// any declaration/definition with the same name, which could indicate
26
/// that the forward declaration is potentially in a wrong namespace.
27
///
28
/// \code
29
/// namespace na { struct A; }
30
/// namespace nb { struct A {} };
31
/// nb::A a;
32
/// // warning : no definition found for 'A', but a definition with the same
33
/// name 'A' found in another namespace 'nb::'
34
/// \endcode
35
///
36
/// This check can only generate warnings, but it can't suggest fixes at this
37
/// point.
38
///
39
/// For the user-facing documentation see:
40
/// http://clang.llvm.org/extra/clang-tidy/checks/misc-forward-declaration-namespace.html
41
class
ForwardDeclarationNamespaceCheck
:
public
ClangTidyCheck
{
42
public
:
43
ForwardDeclarationNamespaceCheck
(StringRef
Name
,
ClangTidyContext
*Context)
44
:
ClangTidyCheck
(Name, Context) {}
45
void
registerMatchers
(ast_matchers::MatchFinder *
Finder
)
override
;
46
void
check
(
const
ast_matchers::MatchFinder::MatchResult &
Result
)
override
;
47
void
onEndOfTranslationUnit
()
override
;
48
49
private
:
50
llvm::StringMap<std::vector<const CXXRecordDecl *>> DeclNameToDefinitions;
51
llvm::StringMap<std::vector<const CXXRecordDecl *>> DeclNameToDeclarations;
52
llvm::SmallPtrSet<const Type *, 16> FriendTypes;
53
};
54
55
}
// namespace misc
56
}
// namespace tidy
57
}
// namespace clang
58
59
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FORWARDDECLARATIONNAMESPACECHECK_H
Name
const std::string Name
Definition:
USRFinder.cpp:140
Finder
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition:
ClangTidy.cpp:210
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidy.h:110
clang::tidy::misc::ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit
void onEndOfTranslationUnit() override
Definition:
ForwardDeclarationNamespaceCheck.cpp:117
clang::tidy::misc::ForwardDeclarationNamespaceCheck::ForwardDeclarationNamespaceCheck
ForwardDeclarationNamespaceCheck(StringRef Name, ClangTidyContext *Context)
Definition:
ForwardDeclarationNamespaceCheck.h:43
clang::tidy::misc::ForwardDeclarationNamespaceCheck
Checks if an unused forward declaration is in a wrong namespace.
Definition:
ForwardDeclarationNamespaceCheck.h:41
clang::tidy::misc::ForwardDeclarationNamespaceCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
ForwardDeclarationNamespaceCheck.cpp:24
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:135
Result
const NamedDecl * Result
Definition:
USRFinder.cpp:137
clang::tidy::misc::ForwardDeclarationNamespaceCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
ForwardDeclarationNamespaceCheck.cpp:49
Generated on Wed Aug 31 2016 16:57:10 for clang-tools by
1.8.6