blob: 1b1a23154032a936203edc1a99fd80c1c3fc0c29 [file] [log] [blame]
Alexander Kornienkobef51cd2014-05-19 16:39:08 +00001//===--- NamespaceCommentCheck.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 Kornienko33fc3db2014-09-22 10:41:39 +000010#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_NAMESPACECOMMENTCHECK_H
11#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_NAMESPACECOMMENTCHECK_H
Alexander Kornienkobef51cd2014-05-19 16:39:08 +000012
13#include "../ClangTidy.h"
14#include "llvm/Support/Regex.h"
15
16namespace clang {
17namespace tidy {
Alexander Kornienko33fc3db2014-09-22 10:41:39 +000018namespace readability {
Alexander Kornienkobef51cd2014-05-19 16:39:08 +000019
Alexander Kornienkof8ed0a82015-08-27 18:01:58 +000020/// Checks that long namespaces have a closing comment.
Alexander Kornienkobef51cd2014-05-19 16:39:08 +000021///
Alexander Kornienko33fc3db2014-09-22 10:41:39 +000022/// http://llvm.org/docs/CodingStandards.html#namespace-indentation
Alexander Kornienkof8ed0a82015-08-27 18:01:58 +000023///
Haojian Wubd639722016-02-25 14:31:10 +000024/// https://google.github.io/styleguide/cppguide.html#Namespaces
Alexander Kornienkobef51cd2014-05-19 16:39:08 +000025class NamespaceCommentCheck : public ClangTidyCheck {
26public:
Alexander Kornienko6e0cbc82014-09-12 08:53:36 +000027 NamespaceCommentCheck(StringRef Name, ClangTidyContext *Context);
Alexander Kornienkobef51cd2014-05-19 16:39:08 +000028 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
29 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
30
31private:
Alexander Kornienko6e0cbc82014-09-12 08:53:36 +000032 void storeOptions(ClangTidyOptions::OptionMap &Options) override;
33
Alexander Kornienkobef51cd2014-05-19 16:39:08 +000034 llvm::Regex NamespaceCommentPattern;
35 const unsigned ShortNamespaceLines;
Alexander Kornienko6e0cbc82014-09-12 08:53:36 +000036 const unsigned SpacesBeforeComments;
Alexander Kornienko5a65e672018-01-11 13:00:28 +000037 llvm::SmallVector<SourceLocation, 4> Ends;
Alexander Kornienkobef51cd2014-05-19 16:39:08 +000038};
39
Alexander Kornienko33fc3db2014-09-22 10:41:39 +000040} // namespace readability
Alexander Kornienkobef51cd2014-05-19 16:39:08 +000041} // namespace tidy
42} // namespace clang
43
Alexander Kornienko33fc3db2014-09-22 10:41:39 +000044#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_NAMESPACECOMMENTCHECK_H