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;" 42 ForbiddenSubclassingCheck::ForbiddenSubclassingCheck(
46 ForbiddenSuperClassNames(
48 Options.get(
"ClassNames", DefaultForbiddenSuperClassNames))) {
61 std::vector<StringRef>(
62 ForbiddenSuperClassNames.begin(),
63 ForbiddenSuperClassNames.end())))
70 const MatchFinder::MatchResult &Result) {
71 const auto *SubClass = Result.Nodes.getNodeAs<ObjCInterfaceDecl>(
73 assert(SubClass !=
nullptr);
74 const auto *SuperClass = Result.Nodes.getNodeAs<ObjCInterfaceDecl>(
76 assert(SuperClass !=
nullptr);
77 diag(SubClass->getLocation(),
78 "Objective-C interface %0 subclasses %1, which is not " 79 "intended to be subclassed")
88 "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
===– 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.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.