ConcatNestedNamespacesCheck.h 1.5 KB

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