clang-tools 22.0.0git
clang::tidy::bugprone::ForwardDeclarationNamespaceCheck Class Reference

Checks if an unused forward declaration is in a wrong namespace. More...

#include <ForwardDeclarationNamespaceCheck.h>

Inheritance diagram for clang::tidy::bugprone::ForwardDeclarationNamespaceCheck:
[legend]

Public Member Functions

 ForwardDeclarationNamespaceCheck (StringRef Name, ClangTidyContext *Context)
void registerMatchers (ast_matchers::MatchFinder *Finder) override
void check (const ast_matchers::MatchFinder::MatchResult &Result) override
void onEndOfTranslationUnit () override

Detailed Description

Checks if an unused forward declaration is in a wrong namespace.

The check inspects all unused forward declarations and checks if there is any declaration/definition with the same name, which could indicate that the forward declaration is potentially in a wrong namespace.

namespace na { struct A; }
namespace nb { struct A {} };
nb::A a;
// warning : no definition found for 'A', but a definition with the same
name 'A' found in another namespace 'nb::'

This check can only generate warnings, but it can't suggest fixes at this point.

For the user-facing documentation see: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/forward-declaration-namespace.html

Definition at line 38 of file ForwardDeclarationNamespaceCheck.h.

Constructor & Destructor Documentation

◆ ForwardDeclarationNamespaceCheck()

clang::tidy::bugprone::ForwardDeclarationNamespaceCheck::ForwardDeclarationNamespaceCheck ( StringRef Name,
ClangTidyContext * Context )
inline

Definition at line 40 of file ForwardDeclarationNamespaceCheck.h.

Member Function Documentation

◆ check()

void clang::tidy::bugprone::ForwardDeclarationNamespaceCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
override

Definition at line 45 of file ForwardDeclarationNamespaceCheck.cpp.

◆ onEndOfTranslationUnit()

void clang::tidy::bugprone::ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit ( )
override

◆ registerMatchers()

void clang::tidy::bugprone::ForwardDeclarationNamespaceCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

Definition at line 20 of file ForwardDeclarationNamespaceCheck.cpp.


The documentation for this class was generated from the following files: