Benjamin Kramer | 2252cbf | 2014-07-16 14:16:56 +0000 | [diff] [blame] | 1 | //===--- UsingNamespaceDirectiveCheck.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 | |
Alexander Kornienko | 6658055 | 2015-03-09 16:52:33 +0000 | [diff] [blame] | 10 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_USINGNAMESPACEDIRECTIVECHECK_H |
| 11 | #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_USINGNAMESPACEDIRECTIVECHECK_H |
Benjamin Kramer | 2252cbf | 2014-07-16 14:16:56 +0000 | [diff] [blame] | 12 | |
| 13 | #include "../ClangTidy.h" |
| 14 | |
| 15 | namespace clang { |
| 16 | namespace tidy { |
Alexander Kornienko | ed824e0 | 2015-03-05 13:46:14 +0000 | [diff] [blame] | 17 | namespace google { |
Benjamin Kramer | 2252cbf | 2014-07-16 14:16:56 +0000 | [diff] [blame] | 18 | namespace build { |
| 19 | |
Alexander Kornienko | f8ed0a8 | 2015-08-27 18:01:58 +0000 | [diff] [blame] | 20 | /// Finds using namespace directives. |
Benjamin Kramer | 2252cbf | 2014-07-16 14:16:56 +0000 | [diff] [blame] | 21 | /// |
Haojian Wu | bd63972 | 2016-02-25 14:31:10 +0000 | [diff] [blame] | 22 | /// https://google.github.io/styleguide/cppguide.html#Namespaces |
Alexander Kornienko | f8ed0a8 | 2015-08-27 18:01:58 +0000 | [diff] [blame] | 23 | /// |
| 24 | /// The check implements the following rule of the Google C++ Style Guide: |
| 25 | /// |
| 26 | /// You may not use a using-directive to make all names from a namespace |
| 27 | /// available. |
| 28 | /// |
| 29 | /// \code |
| 30 | /// // Forbidden -- This pollutes the namespace. |
| 31 | /// using namespace foo; |
| 32 | /// \endcode |
| 33 | /// |
| 34 | /// Corresponding cpplint.py check name: `build/namespaces`. |
Benjamin Kramer | 2252cbf | 2014-07-16 14:16:56 +0000 | [diff] [blame] | 35 | class UsingNamespaceDirectiveCheck : public ClangTidyCheck { |
| 36 | public: |
Alexander Kornienko | 6e0cbc8 | 2014-09-12 08:53:36 +0000 | [diff] [blame] | 37 | UsingNamespaceDirectiveCheck(StringRef Name, ClangTidyContext *Context) |
| 38 | : ClangTidyCheck(Name, Context) {} |
Benjamin Kramer | 2252cbf | 2014-07-16 14:16:56 +0000 | [diff] [blame] | 39 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; |
| 40 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; |
| 41 | }; |
| 42 | |
| 43 | } // namespace build |
Alexander Kornienko | ed824e0 | 2015-03-05 13:46:14 +0000 | [diff] [blame] | 44 | } // namespace google |
Benjamin Kramer | 2252cbf | 2014-07-16 14:16:56 +0000 | [diff] [blame] | 45 | } // namespace tidy |
| 46 | } // namespace clang |
| 47 | |
Alexander Kornienko | 6658055 | 2015-03-09 16:52:33 +0000 | [diff] [blame] | 48 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_USINGNAMESPACEDIRECTIVECHECK_H |