10 #include "clang/AST/ASTContext.h" 11 #include "clang/ASTMatchers/ASTMatchFinder.h" 12 #include "llvm/ADT/Hashing.h" 13 #include "llvm/ADT/SmallVector.h" 14 #include "../utils/OptionsUtils.h" 24 constexpr
char DefaultForbiddenSuperClassNames[] =
25 "ABNewPersonViewController;" 26 "ABPeoplePickerNavigationController;" 27 "ABPersonViewController;" 28 "ABUnknownPersonViewController;" 36 "UIImagePickerController;" 56 ast_matchers::internal::Matcher<ObjCInterfaceDecl>,
Base) {
57 for (
const auto *SuperClass = Node.getSuperClass();
58 SuperClass !=
nullptr;
59 SuperClass = SuperClass->getSuperClass()) {
69 ForbiddenSubclassingCheck::ForbiddenSubclassingCheck(
73 ForbiddenSuperClassNames(
75 Options.get(
"ClassNames", DefaultForbiddenSuperClassNames))) {
88 std::vector<StringRef>(
89 ForbiddenSuperClassNames.begin(),
90 ForbiddenSuperClassNames.end())))
97 const MatchFinder::MatchResult &
Result) {
98 const auto *SubClass = Result.Nodes.getNodeAs<ObjCInterfaceDecl>(
100 assert(SubClass !=
nullptr);
101 const auto *SuperClass = Result.Nodes.getNodeAs<ObjCInterfaceDecl>(
103 assert(SuperClass !=
nullptr);
104 diag(SubClass->getLocation(),
105 "Objective-C interface %0 subclasses %1, which is not " 106 "intended to be subclassed")
115 "ForbiddenSuperClassNames",
std::string serializeStringList(ArrayRef< std::string > Strings)
Serialize a sequence of names that can be parsed by parseStringList.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Base class for all clang-tidy checks.
void storeOptions(ClangTidyOptions::OptionMap &Options) override
Should store all options supported by this check with their current values or default values for opti...
const LangOptions & getLangOpts() const
Returns the language options from the context.
std::vector< std::string > parseStringList(StringRef Option)
Parse a semicolon separated list of strings.
void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, StringRef Value) const
Stores an option with the check-local name LocalName with string value Value to Options.
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
CodeCompletionBuilder Builder
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
std::unique_ptr< GlobalCompilationDatabase > Base
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
AST_MATCHER_P(CXXMethodDecl, hasCanonicalDecl, ast_matchers::internal::Matcher< CXXMethodDecl >, InnerMatcher)