| 1 |
//===--- ConcatNestedNamespacesCheck.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_MODERNIZE_CONCATNESTEDNAMESPACESCHECK_H |
| 10 |
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_CONCATNESTEDNAMESPACESCHECK_H |
| 11 |
|
| 12 |
#include "../ClangTidyCheck.h" |
| 13 |
#include "llvm/ADT/SmallString.h" |
| 14 |
#include "llvm/ADT/SmallVector.h" |
| 15 |
|
| 16 |
namespace clang::tidy::modernize { |
| 17 |
|
| 18 |
class ConcatNestedNamespacesCheck : public ClangTidyCheck { |
| 19 |
public: |
| 20 |
ConcatNestedNamespacesCheck(StringRef Name, ClangTidyContext *Context) |
| 21 |
: ClangTidyCheck(Name, Context) {} |
| 22 |
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { |
| 23 |
return LangOpts.CPlusPlus17; |
| 24 |
} |
| 25 |
void registerMatchers(ast_matchers::MatchFinder *Finder) override; |
| 26 |
void check(const ast_matchers::MatchFinder::MatchResult &Result) override; |
| 27 |
|
| 28 |
private: |
| 29 |
using NamespaceContextVec = llvm::SmallVector<const NamespaceDecl *, 6>; |
| 30 |
using NamespaceString = llvm::SmallString<40>; |
| 31 |
|
| 32 |
void reportDiagnostic(const SourceRange &FrontReplacement, |
| 33 |
const SourceRange &BackReplacement); |
| 34 |
NamespaceString concatNamespaces(); |
| 35 |
NamespaceContextVec Namespaces; |
| 36 |
}; |
| 37 |
} // namespace clang::tidy::modernize |
| 38 |
|
| 39 |
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_CONCATNESTEDNAMESPACESCHECK_H |