diff --git a/ClazySources.cmake b/ClazySources.cmake --- a/ClazySources.cmake +++ b/ClazySources.cmake @@ -24,8 +24,9 @@ set(CLAZY_SHARED_SRCS # sources shared between clazy-standalone and clazy plugin ${CLAZY_CHECKS_SRCS} - ${CMAKE_CURRENT_LIST_DIR}/src/ClazyContext.cpp ${CMAKE_CURRENT_LIST_DIR}/src/Clazy.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ClazyContext.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ClazyOptions.cpp ${CLAZY_LIB_SRC} ) diff --git a/src/Clazy.h b/src/Clazy.h --- a/src/Clazy.h +++ b/src/Clazy.h @@ -27,6 +27,7 @@ #include "checkmanager.h" #include "ClazyContext.h" +#include "ClazyOptions.h" #include "checkbase.h" #include @@ -51,7 +52,7 @@ } /** - * This is the FrontendAction that is run with clazy is used as a plugin. + * This is the FrontendAction that is run when clazy is used as a clang plugin. */ class ClazyASTAction : public clang::PluginASTAction @@ -70,32 +71,23 @@ private: void printRequestedChecks() const; RegisteredCheck::List m_checks; - ClazyContext::ClazyOptions m_options = 0; CheckManager *const m_checkManager; ClazyContext *m_context = nullptr; }; /** - * This is the FrontendAction that is run with clazy is used standalone instead of as a plugin. - * i.e: when you run clazy-standalone, this is the invoked FrontendAction + * This is the FrontendAction that is run when clazy is invoked via clazy-standalone. */ class ClazyStandaloneASTAction : public clang::ASTFrontendAction { public: - explicit ClazyStandaloneASTAction(const std::string &checkList, - const std::string &headerFilter, - const std::string &ignoreDirs, - const std::string &exportFixesFilename, - ClazyContext::ClazyOptions = ClazyContext::ClazyOption_None); + explicit ClazyStandaloneASTAction(const ClazyOptions &options, const std::string &exportFixesFilename); protected: std::unique_ptr CreateASTConsumer(clang::CompilerInstance &ci, llvm::StringRef) override; private: - const std::string m_checkList; - const std::string m_headerFilter; - const std::string m_ignoreDirs; - const std::string m_exportFixesFilename; - const ClazyContext::ClazyOptions m_options; + ClazyOptions m_options; + std::string m_exportFixesFilename; }; /** diff --git a/src/Clazy.cpp b/src/Clazy.cpp --- a/src/Clazy.cpp +++ b/src/Clazy.cpp @@ -172,7 +172,7 @@ if (m_context->exporter) m_context->exporter->BeginSourceFile(clang::LangOptions()); - if ((m_context->options & ClazyContext::ClazyOption_OnlyQt) && !m_context->isQt()) + if ((m_context->isOnlyQt()) && !m_context->isQt()) return; // Run our RecursiveAstVisitor based checks: @@ -217,53 +217,41 @@ return std::unique_ptr(astConsumer.release()); } -static std::string getEnvVariable(const char *name) -{ - const char *result = getenv(name); - if (result) - return result; - else return std::string(); -} - bool ClazyASTAction::ParseArgs(const CompilerInstance &ci, const std::vector &args_) { // NOTE: This method needs to be kept reentrant (but not necessarily thread-safe) // Might be called from multiple threads via libclang, each thread operates on a different instance though std::vector args = args_; - - const string headerFilter = getEnvVariable("CLAZY_HEADER_FILTER"); - const string ignoreDirs = getEnvVariable("CLAZY_IGNORE_DIRS"); std::string exportFixes; + auto options = ClazyOptions::defaultOptions(); + options = options.mergedWith(ClazyOptions::fromEnvironment()); if (parseArgument("help", args)) { - m_context = new ClazyContext(ci, headerFilter, ignoreDirs, exportFixes, ClazyContext::ClazyOption_None); + m_context = new ClazyContext(ci, options, exportFixes); PrintHelp(llvm::errs()); return true; } - if (parseArgument("export-fixes", args) || getenv("CLAZY_EXPORT_FIXES")) - m_options |= ClazyContext::ClazyOption_ExportFixes; + if (parseArgument("export-fixes", args)) + options.exportFixes = args.at(0); if (parseArgument("qt4-compat", args)) - m_options |= ClazyContext::ClazyOption_Qt4Compat; + options.qt4Compatibility = true; if (parseArgument("only-qt", args)) - m_options |= ClazyContext::ClazyOption_OnlyQt; + options.onlyQt = true; if (parseArgument("qt-developer", args)) - m_options |= ClazyContext::ClazyOption_QtDeveloper; + options.qtDeveloper = true; if (parseArgument("visit-implicit-code", args)) - m_options |= ClazyContext::ClazyOption_VisitImplicitCode; + options.visitImplicitCode = true; if (parseArgument("ignore-included-files", args)) - m_options |= ClazyContext::ClazyOption_IgnoreIncludedFiles; + options.ignoreIncludedFiles = true; - if (parseArgument("export-fixes", args)) - exportFixes = args.at(0); - - m_context = new ClazyContext(ci, headerFilter, ignoreDirs, exportFixes, m_options); + m_context = new ClazyContext(ci, options, exportFixes); // This argument is for debugging purposes const bool dbgPrintRequestedChecks = parseArgument("print-requested-checks", args); @@ -362,34 +350,24 @@ ros << " export CLAZY_CHECKS=\"reserve-candidates\"\n\n"; ros << "or pass as compiler arguments, for example:\n"; ros << " -Xclang -plugin-arg-clazy -Xclang reserve-candidates,qstring-allocations\n"; - ros << "\n"; - ros << "To enable FixIts for a check, also set the env variable CLAZY_FIXIT, for example:\n"; - ros << " export CLAZY_FIXIT=\"fix-qlatin1string-allocations\"\n\n"; - ros << "FixIts are experimental and rewrite your code therefore only one FixIt is allowed per build.\nSpecifying a list of different FixIts is not supported.\nBackup your code before running them.\n"; } -ClazyStandaloneASTAction::ClazyStandaloneASTAction(const string &checkList, - const string &headerFilter, - const string &ignoreDirs, - const string &exportFixesFilename, - ClazyContext::ClazyOptions options) +ClazyStandaloneASTAction::ClazyStandaloneASTAction(const ClazyOptions &options, const string &exportFixesFilename) : clang::ASTFrontendAction() - , m_checkList(checkList.empty() ? "level1" : checkList) - , m_headerFilter(headerFilter.empty() ? getEnvVariable("CLAZY_HEADER_FILTER") : headerFilter) - , m_ignoreDirs(ignoreDirs.empty() ? getEnvVariable("CLAZY_IGNORE_DIRS") : ignoreDirs) - , m_exportFixesFilename(exportFixesFilename) , m_options(options) + , m_exportFixesFilename(exportFixesFilename) { } unique_ptr ClazyStandaloneASTAction::CreateASTConsumer(CompilerInstance &ci, llvm::StringRef) { - auto context = new ClazyContext(ci, m_headerFilter, m_ignoreDirs, m_exportFixesFilename, m_options); + auto context = new ClazyContext(ci, m_options, m_exportFixesFilename); auto astConsumer = new ClazyASTConsumer(context); auto cm = CheckManager::instance(); - vector checks; checks.push_back(m_checkList); + vector checks; + checks.push_back(m_options.checks.getValue()); const RegisteredCheck::List requestedChecks = cm->requestedChecks(context, checks); if (requestedChecks.size() == 0) { diff --git a/src/ClazyContext.h b/src/ClazyContext.h --- a/src/ClazyContext.h +++ b/src/ClazyContext.h @@ -24,6 +24,7 @@ #include "SuppressionManager.h" #include "clazy_stl.h" +#include "ClazyOptions.h" #include #include @@ -56,22 +57,9 @@ class ClazyContext { public: - enum ClazyOption { - ClazyOption_None = 0, - ClazyOption_ExportFixes = 1, - ClazyOption_Qt4Compat = 2, - ClazyOption_OnlyQt = 4, // Ignore non-Qt files. This is done by bailing out if QT_CORE_LIB is not set. - ClazyOption_QtDeveloper = 8, // For running clazy on Qt itself, optional, but honours specific guidelines - ClazyOption_VisitImplicitCode = 16, // Inspect compiler generated code aswell, useful for custom checks, if they need it - ClazyOption_IgnoreIncludedFiles = 32 // Only warn for the current file being compiled, not on includes (useful for performance reasons) - }; - typedef int ClazyOptions; - explicit ClazyContext(const clang::CompilerInstance &ci, - const std::string &headerFilter, - const std::string &ignoreDirs, - std::string exportFixesFilename, - ClazyOptions = ClazyOption_None); + const ClazyOptions & options, + std::string exportFixesFilename); ~ClazyContext(); bool usingPreCompiledHeaders() const @@ -81,27 +69,37 @@ bool userDisabledWError() const { - return m_noWerror; + return options.noWarningAsError.getValue(); } bool exportFixesEnabled() const { - return options & ClazyOption_ExportFixes; + return options.exportFixes.hasValue(); } bool isQtDeveloper() const { - return options & ClazyOption_QtDeveloper; + return options.qtDeveloper.getValue(); + } + + bool isOnlyQt() const + { + return options.onlyQt.getValue(); + } + + bool isQt4Compatible() const + { + return options.qt4Compatibility.getValue(); } bool ignoresIncludedFiles() const { - return options & ClazyOption_IgnoreIncludedFiles; + return options.ignoreIncludedFiles.getValue(); } bool isVisitImplicitCode() const { - return options & ClazyContext::ClazyOption_VisitImplicitCode; + return options.visitImplicitCode.getValue(); } bool isOptionSet(const std::string &optionName) const @@ -169,14 +167,15 @@ AccessSpecifierManager *accessSpecifierManager = nullptr; PreProcessorVisitor *preprocessorVisitor = nullptr; SuppressionManager suppressionManager; - const bool m_noWerror; clang::ParentMap *parentMap = nullptr; - const ClazyOptions options; - const std::vector extraOptions; FixItExporter *exporter = nullptr; clang::CXXMethodDecl *lastMethodDecl = nullptr; clang::FunctionDecl *lastFunctionDecl = nullptr; clang::Decl *lastDecl = nullptr; + +private: + ClazyOptions options; + std::vector extraOptions; std::unique_ptr headerFilterRegex; std::unique_ptr ignoreDirsRegex; }; diff --git a/src/ClazyContext.cpp b/src/ClazyContext.cpp --- a/src/ClazyContext.cpp +++ b/src/ClazyContext.cpp @@ -62,20 +62,21 @@ }; ClazyContext::ClazyContext(const clang::CompilerInstance &compiler, - const string &headerFilter, const string &ignoreDirs, - string exportFixesFilename, ClazyOptions opts) + const ClazyOptions &options, + string exportFixesFilename) : ci(compiler) , astContext(ci.getASTContext()) , sm(ci.getSourceManager()) - , m_noWerror(getenv("CLAZY_NO_WERROR") != nullptr) // Allows user to make clazy ignore -Werror - , options(opts) - , extraOptions(clazy::splitString(getenv("CLAZY_EXTRA_OPTIONS"), ',')) + , options(options) { - if (!headerFilter.empty()) - headerFilterRegex = std::unique_ptr(new llvm::Regex(headerFilter)); + if (options.extraOptions.hasValue()) + extraOptions = clazy::splitString(options.extraOptions.getValue(), ','); - if (!ignoreDirs.empty()) - ignoreDirsRegex = std::unique_ptr(new llvm::Regex(ignoreDirs)); + if (options.headerFilterRegExp.hasValue()) + headerFilterRegex = std::unique_ptr(new llvm::Regex(options.headerFilterRegExp.getValue())); + + if (!options.ignoreDirs.hasValue()) + ignoreDirsRegex = std::unique_ptr(new llvm::Regex(options.ignoreDirs.getValue())); if (exportFixesEnabled()) { if (exportFixesFilename.empty()) { diff --git a/src/ClazyOptions.h b/src/ClazyOptions.h new file mode 100644 --- /dev/null +++ b/src/ClazyOptions.h @@ -0,0 +1,104 @@ +/* + This file is part of the clazy static checker. + + Copyright (C) 2019 Christian Gagneraud + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef CLAZY_OPTIONS_H +#define CLAZY_OPTIONS_H + +#include "llvm/ADT/Optional.h" +#include "llvm/Support/ErrorOr.h" + +#include +#include + +struct ClazyOptions +{ + using optional_string = llvm::Optional; + using optional_bool = llvm::Optional; + + ClazyOptions mergedWith(const ClazyOptions &other) const; + + static ClazyOptions defaultOptions(); + static ClazyOptions fromEnvironment(); + static llvm::ErrorOr fromText(const std::string &text); + static ClazyOptions fromArguments(std::vector &arguments); + static ClazyOptions fromOptionParser(); + static std::string toText(const ClazyOptions& options); + + /* + * Clang-tidy compatible + */ + // Check filters (can use glob ('*' ) and negation ('-')) + llvm::Optional checks; + // Warning-as-error filters + optional_string warningsAsErrors; + // Regular expression matching the names of the headers to output diagnostics from + optional_string headerFilterRegExp; + + /* + * To be converted to clang-tidy CheckOptions and extraArgs/extraArgsBefore + * CheckOptions: + * - key: qstring-allocations.no-msvc-compat + * value: '1' + */ + // Clang-tidy: Additional argument to append to the compiler command line + optional_string extraArgs; + // Clang-tidy: Additional argument to prepend to the compiler command line + optional_string extraArgsBefore; + // Clazy: ? + optional_string extraOptions; + + // TBD: see warningAsErrors above + optional_bool noWarningAsError; + + /* + * Clazy extra filters + */ + // Regular expression matching the names of the directories for which diagnostics should never be emitted + optional_string ignoreDirs; + // Only warn for the current file being compiled, not on includes (useful for performance reasons) + optional_bool ignoreIncludedFiles; + + /* + * Qt specific + */ + // Turns off checks not compatible with Qt 4 + optional_bool qt4Compatibility; + // Ignore non-Qt files. This is done by bailing out if QT_CORE_LIB is not set. + optional_bool onlyQt; + // For running clazy on Qt itself, optional, but honours specific guidelines + optional_bool qtDeveloper; + + /* + * Clazy specific, doesn't belong here? + */ + // Inspect compiler generated code aswell, useful for custom checks, if they need it + optional_bool visitImplicitCode; + // If not empty, use export fixes to sourcefile with added prefix + optional_string fixitSuffix; + + /* + * Doesn't belong here + */ + // Export fixes to this file, if empty .... + optional_string exportFixes; +}; + +#endif // CLAZY_OPTIONS_H diff --git a/src/ClazyOptions.cpp b/src/ClazyOptions.cpp new file mode 100644 --- /dev/null +++ b/src/ClazyOptions.cpp @@ -0,0 +1,197 @@ +/* + This file is part of the clazy static checker. + + Copyright (C) 2019 Christian Gagneraud + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +// Heavily based on ClangTidyOptions.cpp from "The LLVM Compiler Infrastructure" +// A file distributed under the University of Illinois Open Source License + +#include "ClazyOptions.h" + +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/YAMLTraits.h" +#include "llvm/Support/raw_ostream.h" + +namespace llvm { +namespace yaml { + +template <> +struct MappingTraits +{ + static void mapping(IO &io, ClazyOptions &options) + { + // Clang-tidy compatible + io.mapOptional("Checks", options.checks); + io.mapOptional("WarningsAsErrors", options.warningsAsErrors); + io.mapOptional("HeaderFilterRegex", options.headerFilterRegExp); + + // To be converted to clang-tidy style + io.mapOptional("ExtraArgs", options.extraArgs); + io.mapOptional("ExtraArgsBefore", options.extraArgsBefore); + // io.mapOptional("CheckOptions", NOpts->Options); + io.mapOptional("ExtraOptions", options.extraOptions); + + // Clazy extra filters + io.mapOptional("IgnoreDirs", options.ignoreDirs); + io.mapOptional("IgnoreIncludedFiles", options.ignoreIncludedFiles); + + // Qt specific + io.mapOptional("Qt4Compatibility", options.qt4Compatibility); + io.mapOptional("OnlyQt", options.onlyQt); + io.mapOptional("QtDeveloperMode", options.qtDeveloper); + + // Clazy specific (FIXME: doesn't belong here?) + // - visitImplicitCode + // - fixesPrefix + + // FIXME: Doesn't belong here + // - exportFixes + } +}; + +}} // namespace llvm::yaml + +template +static llvm::Optional getEnvVariable(const char *name) +{ + const char *result = getenv(name); + if (result) + return T(result); + return llvm::Optional(); +} + +template +static void mergeVectors(llvm::Optional &dst, + const llvm::Optional &src) +{ + if (src) { + if (dst) + dst->insert(dst->end(), src->begin(), src->end()); + else + dst = src; + } +} + +static void mergeCsv(llvm::Optional &dst, + const llvm::Optional &src) +{ + if (src) + dst = (dst && !dst->empty() ? *dst + "," : "") + *src; +} + +template +static void overrideValue(llvm::Optional &dst, + const llvm::Optional &src) +{ + if (src) + dst = src; +} + +ClazyOptions ClazyOptions::mergedWith(const ClazyOptions &other) const +{ + ClazyOptions result = *this; + + // Clang-tidy compatible + mergeCsv(result.checks, other.checks); + mergeCsv(result.warningsAsErrors, other.warningsAsErrors); + overrideValue(result.headerFilterRegExp, other.headerFilterRegExp); + + // To be converted to clang-tidy style + mergeVectors(result.extraArgs, other.extraArgs); + mergeVectors(result.extraArgsBefore, other.extraArgsBefore); + mergeVectors(result.extraOptions, other.extraOptions); + overrideValue(result.noWarningAsError, other.noWarningAsError); + + // Clazy extra filters + overrideValue(result.ignoreDirs, other.ignoreDirs); + overrideValue(result.ignoreIncludedFiles, other.ignoreIncludedFiles); + + // Qt specific + overrideValue(result.qt4Compatibility, other.qt4Compatibility); + overrideValue(result.onlyQt, other.onlyQt); + overrideValue(result.qtDeveloper, other.qtDeveloper); + + // Clazy specific, doesn't belong here? + overrideValue(result.fixitSuffix, other.fixitSuffix); + overrideValue(result.visitImplicitCode, other.visitImplicitCode); + + // Doesn't belong here + overrideValue(result.exportFixes, other.exportFixes); + + return result; +} + +std::string ClazyOptions::toText(const ClazyOptions &options) +{ + std::string result; + llvm::raw_string_ostream stream(result); + llvm::yaml::Output output(stream); + ClazyOptions tmp = options; // No 'const traits' avail. + output << tmp; + return stream.str(); +} + +ClazyOptions ClazyOptions::defaultOptions() +{ + ClazyOptions options; + options.checks = "level1"; + options.warningsAsErrors = std::string(); + options.headerFilterRegExp = std::string(); + options.extraArgs = std::string(); + options.extraArgsBefore = std::string(); + options.extraOptions = std::string(); + options.noWarningAsError = false; + options.ignoreDirs = std::string(); + options.ignoreIncludedFiles = false; + options.qt4Compatibility = false; + options.onlyQt = false; + options.qtDeveloper = false; + options.visitImplicitCode = false; + options.fixitSuffix = ".clazy.yaml"; + options.exportFixes = std::string(); + return options; +} + +ClazyOptions ClazyOptions::fromEnvironment() +{ + ClazyOptions options; + + options.checks = getEnvVariable("CLAZY_CHECKS"); + options.exportFixes = getEnvVariable("CLAZY_EXPORT_FIXES"); + options.noWarningAsError = getEnvVariable("CLAZY_NO_WERROR"); + options.fixitSuffix = getEnvVariable("CLAZY_FIXIT_SUFFIX"); + options.headerFilterRegExp = getEnvVariable("CLAZY_HEADER_FILTER"); + options.ignoreDirs = getEnvVariable("CLAZY_IGNORE_DIRS"); + + // FIXME: CLAZY_UNUSED_NON_TRIVIAL_VARIABLE_BLACKLIST + // FIXME: CLAZY_UNUSED_NON_TRIVIAL_VARIABLE_WHITELIST + + return options; +} + +llvm::ErrorOr ClazyOptions::fromText(const std::string &text) +{ + llvm::yaml::Input input(text); + ClazyOptions options; + input >> options; + if (input.error()) + return input.error(); + return options; +} diff --git a/src/ClazyStandaloneMain.cpp b/src/ClazyStandaloneMain.cpp --- a/src/ClazyStandaloneMain.cpp +++ b/src/ClazyStandaloneMain.cpp @@ -23,6 +23,7 @@ #include "Clazy.h" #include "ClazyContext.h" +#include "ClazyOptions.h" #include #include @@ -42,7 +43,7 @@ static llvm::cl::OptionCategory s_clazyCategory("clazy options"); static cl::opt s_checks("checks", cl::desc("Comma-separated list of clazy checks. Default is level1"), - cl::init(""), cl::cat(s_clazyCategory)); + cl::init("level1"), cl::cat(s_clazyCategory)); static cl::opt s_exportFixes("export-fixes", cl::desc("YAML file to store suggested fixes in. The stored fixes can be applied to the input source code with clang-apply-replacements."), cl::init(""), cl::cat(s_clazyCategory)); @@ -83,30 +84,36 @@ FrontendAction *create() override { - ClazyContext::ClazyOptions options = ClazyContext::ClazyOption_None; + ClazyOptions options; - if (!s_exportFixes.getValue().empty()) - options |= ClazyContext::ClazyOption_ExportFixes; + options.checks = s_checks; - if (s_qt4Compat.getValue()) - options |= ClazyContext::ClazyOption_Qt4Compat; + if (s_headerFilter.getNumOccurrences() > 0) + options.headerFilterRegExp = s_headerFilter; - if (s_qtDeveloper.getValue()) - options |= ClazyContext::ClazyOption_QtDeveloper; + if (s_exportFixes.getNumOccurrences() >0) + options.exportFixes = s_exportFixes; - if (s_onlyQt.getValue()) - options |= ClazyContext::ClazyOption_OnlyQt; + if (s_qt4Compat.getNumOccurrences() > 0) + options.qt4Compatibility = s_qt4Compat; - if (s_visitImplicitCode.getValue()) - options |= ClazyContext::ClazyOption_VisitImplicitCode; + if (s_qtDeveloper.getNumOccurrences() > 0) + options.qtDeveloper = s_qtDeveloper; - if (s_ignoreIncludedFiles.getValue()) - options |= ClazyContext::ClazyOption_IgnoreIncludedFiles; + if (s_onlyQt.getNumOccurrences() > 0) + options.onlyQt = s_onlyQt; + + if (s_visitImplicitCode.getNumOccurrences() > 0) + options.visitImplicitCode = s_visitImplicitCode; + + if (s_ignoreIncludedFiles.getNumOccurrences() > 0) + options.ignoreIncludedFiles = s_ignoreIncludedFiles; + + options = ClazyOptions::defaultOptions().mergedWith(options); + // options = options.mergedWith(/* from config file */); // TODO: We need to agregate the fixes with previous run - return new ClazyStandaloneASTAction(s_checks.getValue(), s_headerFilter.getValue(), - s_ignoreDirs.getValue(), s_exportFixes.getValue(), - options); + return new ClazyStandaloneASTAction(options, s_exportFixes); } }; diff --git a/src/checkmanager.cpp b/src/checkmanager.cpp --- a/src/checkmanager.cpp +++ b/src/checkmanager.cpp @@ -171,6 +171,8 @@ return false; } +// TODO: handle glog and negation, eg "-*,foo-bar" +// TODO: requestedChecksThroughEnv, CLAZY_CHECKS and ClazyOptions::fromEnvironment RegisteredCheck::List CheckManager::requestedChecks(const ClazyContext *context, std::vector &args) { RegisteredCheck::List result; @@ -213,7 +215,7 @@ clazy::sort_and_remove_dups(result, checkLessThan); CheckManager::removeChecksFromList(result, userDisabledChecks); - if (context->options & ClazyContext::ClazyOption_Qt4Compat) { + if (context->isQt4Compatible()) { // #5 Remove Qt4 incompatible checks result.erase(remove_if(result.begin(), result.end(), [](const RegisteredCheck &c){ return c.options & RegisteredCheck::Option_Qt4Incompatible;