[clang-tools-extra] r217661 - Implemented clang-tidy-check-specific options.
Alexander Kornienko
alexfh at google.com
Fri Sep 12 01:53:38 PDT 2014
Author: alexfh
Date: Fri Sep 12 03:53:36 2014
New Revision: 217661
URL: http://llvm.org/viewvc/llvm-project?rev=217661&view=rev
Log:
Implemented clang-tidy-check-specific options.
Summary:
Each check can implement readOptions and storeOptions methods to read
and store custom options. Each check's options are stored in a local namespace
to avoid name collisions and provide some sort of context to the user.
Reviewers: bkramer, klimek
Reviewed By: klimek
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D5296
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyModule.h
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h
clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h
clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.h
clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.h
clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.h
clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.h
clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h
clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.h
clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h
clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.h
clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.h
clang-tools-extra/trunk/clang-tidy/llvm/NamespaceCommentCheck.cpp
clang-tools-extra/trunk/clang-tidy/llvm/NamespaceCommentCheck.h
clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h
clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.h
clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversion.h
clang-tools-extra/trunk/clang-tidy/misc/RedundantSmartptrGet.h
clang-tools-extra/trunk/clang-tidy/misc/SwappedArgumentsCheck.h
clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.h
clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.h
clang-tools-extra/trunk/clang-tidy/misc/UseOverride.h
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.h
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Sep 12 03:53:36 2014
@@ -214,13 +214,11 @@ ClangTidyASTConsumerFactory::CreateASTCo
Context.setASTContext(&Compiler.getASTContext());
std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
- GlobList &Filter = Context.getChecksFilter();
- CheckFactories->createChecks(Filter, Checks);
+ CheckFactories->createChecks(&Context, Checks);
std::unique_ptr<ast_matchers::MatchFinder> Finder(
new ast_matchers::MatchFinder);
for (auto &Check : Checks) {
- Check->setContext(&Context);
Check->registerMatchers(&*Finder);
Check->registerPPCallbacks(Compiler);
}
@@ -235,6 +233,7 @@ ClangTidyASTConsumerFactory::CreateASTCo
AnalyzerOptions->Config["cfg-temporary-dtors"] =
Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";
+ GlobList &Filter = Context.getChecksFilter();
AnalyzerOptions->CheckersControlList = getCheckersControlList(Filter);
if (!AnalyzerOptions->CheckersControlList.empty()) {
AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
@@ -251,9 +250,9 @@ ClangTidyASTConsumerFactory::CreateASTCo
std::move(Consumers), std::move(Finder), std::move(Checks));
}
-std::vector<std::string>
-ClangTidyASTConsumerFactory::getCheckNames(GlobList &Filter) {
+std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
std::vector<std::string> CheckNames;
+ GlobList &Filter = Context.getChecksFilter();
for (const auto &CheckFactory : *CheckFactories) {
if (Filter.contains(CheckFactory.first))
CheckNames.push_back(CheckFactory.first);
@@ -266,6 +265,15 @@ ClangTidyASTConsumerFactory::getCheckNam
return CheckNames;
}
+ClangTidyOptions::OptionMap ClangTidyASTConsumerFactory::getCheckOptions() {
+ ClangTidyOptions::OptionMap Options;
+ std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
+ CheckFactories->createChecks(&Context, Checks);
+ for (const auto &Check : Checks)
+ Check->storeOptions(Options);
+ return Options;
+}
+
ClangTidyASTConsumerFactory::CheckersList
ClangTidyASTConsumerFactory::getCheckersControlList(GlobList &Filter) {
CheckersList List;
@@ -307,9 +315,25 @@ void ClangTidyCheck::run(const ast_match
check(Result);
}
-void ClangTidyCheck::setName(StringRef Name) {
- assert(CheckName.empty());
- CheckName = Name.str();
+OptionsView::OptionsView(StringRef CheckName,
+ const ClangTidyOptions::OptionMap &CheckOptions)
+ : NamePrefix(CheckName.str() + "."), CheckOptions(CheckOptions) {}
+
+std::string OptionsView::get(StringRef LocalName, std::string Default) const {
+ const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
+ if (Iter != CheckOptions.end())
+ return Iter->second;
+ return Default;
+}
+
+void OptionsView::store(ClangTidyOptions::OptionMap &Options,
+ StringRef LocalName, StringRef Value) const {
+ Options[NamePrefix + LocalName.str()] = Value;
+}
+
+void OptionsView::store(ClangTidyOptions::OptionMap &Options,
+ StringRef LocalName, int64_t Value) const {
+ store(Options, LocalName, llvm::itostr(Value));
}
std::vector<std::string> getCheckNames(const ClangTidyOptions &Options) {
@@ -317,7 +341,15 @@ std::vector<std::string> getCheckNames(c
llvm::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
Options));
ClangTidyASTConsumerFactory Factory(Context);
- return Factory.getCheckNames(Context.getChecksFilter());
+ return Factory.getCheckNames();
+}
+
+ClangTidyOptions::OptionMap getCheckOptions(const ClangTidyOptions &Options) {
+ clang::tidy::ClangTidyContext Context(
+ llvm::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
+ Options));
+ ClangTidyASTConsumerFactory Factory(Context);
+ return Factory.getCheckOptions();
}
ClangTidyStats
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Fri Sep 12 03:53:36 2014
@@ -16,7 +16,10 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Tooling/Refactoring.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/raw_ostream.h"
#include <memory>
+#include <type_traits>
#include <vector>
namespace clang {
@@ -28,6 +31,55 @@ class CompilationDatabase;
namespace tidy {
+/// \brief Provides access to the \c ClangTidyCheck options via check-local
+/// names.
+///
+/// Methods of this class prepend <tt>CheckName + "."</tt> to translate
+/// check-local option names to global option names.
+class OptionsView {
+public:
+ /// \brief Initializes the instance using \p CheckName + "." as a prefix.
+ OptionsView(StringRef CheckName,
+ const ClangTidyOptions::OptionMap &CheckOptions);
+
+ /// \brief Read a named option from the \c Context.
+ ///
+ /// Reads the option with the check-local name \p LocalName from the
+ /// \c CheckOptions. If the corresponding key is not present, returns
+ /// \p Default.
+ std::string get(StringRef LocalName, std::string Default) const;
+
+ /// \brief Read a named option from the \c Context and parse it as an integral
+ /// type \c T.
+ ///
+ /// Reads the option with the check-local name \p LocalName from the
+ /// \c CheckOptions. If the corresponding key is not present, returns
+ /// \p Default.
+ template <typename T>
+ typename std::enable_if<std::is_integral<T>::value, T>::type
+ get(StringRef LocalName, T Default) const {
+ std::string Value = get(LocalName, "");
+ T Result = Default;
+ if (!Value.empty())
+ StringRef(Value).getAsInteger(10, Result);
+ return Result;
+ }
+
+ /// \brief Stores an option with the check-local name \p LocalName with string
+ /// value \p Value to \p Options.
+ void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
+ StringRef Value) const;
+
+ /// \brief Stores an option with the check-local name \p LocalName with
+ /// \c int64_t value \p Value to \p Options.
+ void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
+ int64_t Value) const;
+
+private:
+ std::string NamePrefix;
+ const ClangTidyOptions::OptionMap &CheckOptions;
+};
+
/// \brief Base class for all clang-tidy checks.
///
/// To implement a \c ClangTidyCheck, write a subclass and overwrite some of the
@@ -49,6 +101,18 @@ namespace tidy {
/// useful/necessary.
class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
public:
+ /// \brief Initializes the check with \p CheckName and \p Context.
+ ///
+ /// Derived classes must implement the constructor with this signature or
+ /// delegate it. If a check needs to read options, it can do this in the
+ /// constructor using the Options.get() methods below.
+ ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context)
+ : CheckName(CheckName), Context(Context),
+ Options(CheckName, Context->getOptions().CheckOptions) {
+ assert(Context != nullptr);
+ assert(!CheckName.empty());
+ }
+
virtual ~ClangTidyCheck() {}
/// \brief Overwrite this to register \c PPCallbacks with \c Compiler.
@@ -75,21 +139,24 @@ public:
/// work in here.
virtual void check(const ast_matchers::MatchFinder::MatchResult &Result) {}
- /// \brief The infrastructure sets the context to \p Ctx with this function.
- void setContext(ClangTidyContext *Ctx) { Context = Ctx; }
-
/// \brief Add a diagnostic with the check's name.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
- /// \brief Sets the check name. Intended to be used by the clang-tidy
- /// framework. Can be called only once.
- void setName(StringRef Name);
+ /// \brief Should store all options supported by this check with their
+ /// current values or default values for options that haven't been overridden.
+ ///
+ /// The check should use \c Options.store() to store each option it supports
+ /// whether it has the default value or it has been overridden.
+ virtual void storeOptions(ClangTidyOptions::OptionMap &Options) {}
private:
void run(const ast_matchers::MatchFinder::MatchResult &Result) override;
- ClangTidyContext *Context;
std::string CheckName;
+ ClangTidyContext *Context;
+
+protected:
+ OptionsView Options;
};
class ClangTidyCheckFactories;
@@ -103,10 +170,13 @@ public:
CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef File);
/// \brief Get the list of enabled checks.
- std::vector<std::string> getCheckNames(GlobList &Filter);
+ std::vector<std::string> getCheckNames();
+
+ /// \brief Get the union of options from all checks.
+ ClangTidyOptions::OptionMap getCheckOptions();
private:
- typedef std::vector<std::pair<std::string, bool> > CheckersList;
+ typedef std::vector<std::pair<std::string, bool>> CheckersList;
CheckersList getCheckersControlList(GlobList &Filter);
ClangTidyContext &Context;
@@ -117,6 +187,14 @@ private:
/// filters are applied.
std::vector<std::string> getCheckNames(const ClangTidyOptions &Options);
+/// \brief Returns the effective check-specific options.
+///
+/// The method configures ClangTidy with the specified \p Options and collects
+/// effective options from all created checks. The returned set of options
+/// includes default check-specific options for all keys not overridden by \p
+/// Options.
+ClangTidyOptions::OptionMap getCheckOptions(const ClangTidyOptions &Options);
+
/// \brief Run a set of clang-tidy checks on a set of files.
ClangTidyStats
runClangTidy(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp Fri Sep 12 03:53:36 2014
@@ -16,19 +16,18 @@
namespace clang {
namespace tidy {
-void ClangTidyCheckFactories::registerCheckFactory(
- StringRef Name, std::function<ClangTidyCheck *()> Factory) {
+void ClangTidyCheckFactories::registerCheckFactory(StringRef Name,
+ CheckFactory Factory) {
Factories[Name] = Factory;
}
void ClangTidyCheckFactories::createChecks(
- GlobList &Filter, std::vector<std::unique_ptr<ClangTidyCheck>> &Checks) {
+ ClangTidyContext *Context,
+ std::vector<std::unique_ptr<ClangTidyCheck>> &Checks) {
+ GlobList &Filter = Context->getChecksFilter();
for (const auto &Factory : Factories) {
- if (Filter.contains(Factory.first)) {
- ClangTidyCheck *Check = Factory.second();
- Check->setName(Factory.first);
- Checks.emplace_back(Check);
- }
+ if (Filter.contains(Factory.first))
+ Checks.emplace_back(Factory.second(Factory.first, Context));
}
}
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyModule.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyModule.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyModule.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyModule.h Fri Sep 12 03:53:36 2014
@@ -26,11 +26,13 @@ namespace tidy {
/// this object.
class ClangTidyCheckFactories {
public:
+ typedef std::function<ClangTidyCheck *(
+ StringRef Name, ClangTidyContext *Context)> CheckFactory;
+
/// \brief Registers check \p Factory with name \p Name.
///
/// For all checks that have default constructors, use \c registerCheck.
- void registerCheckFactory(StringRef Name,
- std::function<ClangTidyCheck *()> Factory);
+ void registerCheckFactory(StringRef Name, CheckFactory Factory);
/// \brief Registers the \c CheckType with the name \p Name.
///
@@ -53,19 +55,21 @@ public:
/// }
/// };
/// \endcode
- template<typename CheckType>
- void registerCheck(StringRef Name) {
- registerCheckFactory(Name, []() { return new CheckType(); });
+ template <typename CheckType> void registerCheck(StringRef CheckName) {
+ registerCheckFactory(CheckName,
+ [](StringRef Name, ClangTidyContext *Context) {
+ return new CheckType(Name, Context);
+ });
}
/// \brief Create instances of all checks matching \p CheckRegexString and
/// store them in \p Checks.
///
/// The caller takes ownership of the return \c ClangTidyChecks.
- void createChecks(GlobList &Filter,
+ void createChecks(ClangTidyContext *Context,
std::vector<std::unique_ptr<ClangTidyCheck>> &Checks);
- typedef std::map<std::string, std::function<ClangTidyCheck *()>> FactoryMap;
+ typedef std::map<std::string, CheckFactory> FactoryMap;
FactoryMap::const_iterator begin() const { return Factories.begin(); }
FactoryMap::const_iterator end() const { return Factories.end(); }
bool empty() const { return Factories.empty(); }
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp Fri Sep 12 03:53:36 2014
@@ -25,6 +25,7 @@ using clang::tidy::FileFilter;
LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter)
LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter::LineRange)
+LLVM_YAML_IS_SEQUENCE_VECTOR(ClangTidyOptions::StringPair);
namespace llvm {
namespace yaml {
@@ -57,11 +58,34 @@ template <> struct MappingTraits<FileFil
}
};
+template <> struct MappingTraits<ClangTidyOptions::StringPair> {
+ static void mapping(IO &IO, ClangTidyOptions::StringPair &KeyValue) {
+ IO.mapRequired("key", KeyValue.first);
+ IO.mapRequired("value", KeyValue.second);
+ }
+};
+
+struct NOptionMap {
+ NOptionMap(IO &) {}
+ NOptionMap(IO &, const ClangTidyOptions::OptionMap &OptionMap)
+ : Options(OptionMap.begin(), OptionMap.end()) {}
+ ClangTidyOptions::OptionMap denormalize(IO &) {
+ ClangTidyOptions::OptionMap Map;
+ for (const auto &KeyValue : Options)
+ Map[KeyValue.first] = KeyValue.second;
+ return Map;
+ }
+ std::vector<ClangTidyOptions::StringPair> Options;
+};
+
template <> struct MappingTraits<ClangTidyOptions> {
static void mapping(IO &IO, ClangTidyOptions &Options) {
+ MappingNormalization<NOptionMap, ClangTidyOptions::OptionMap> NOpts(
+ IO, Options.CheckOptions);
IO.mapOptional("Checks", Options.Checks);
IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors);
+ IO.mapOptional("CheckOptions", NOpts->Options);
}
};
@@ -85,6 +109,10 @@ ClangTidyOptions::mergeWith(const ClangT
Result.HeaderFilterRegex = Other.HeaderFilterRegex;
if (Other.AnalyzeTemporaryDtors)
Result.AnalyzeTemporaryDtors = Other.AnalyzeTemporaryDtors;
+
+ for (const auto &KeyValue : Other.CheckOptions)
+ Result.CheckOptions[KeyValue.first] = KeyValue.second;
+
return Result;
}
@@ -169,6 +197,10 @@ FileOptionsProvider::TryReadConfigFile(S
llvm::MemoryBuffer::getFile(ConfigFile.c_str());
if (std::error_code EC = Text.getError())
return EC;
+ // Skip empty files, e.g. files opened for writing via shell output
+ // redirection.
+ if ((*Text)->getBuffer().empty())
+ return make_error_code(llvm::errc::no_such_file_or_directory);
if (std::error_code EC = parseConfiguration((*Text)->getBuffer(), Options))
return EC;
return Options.mergeWith(OverrideOptions);
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h Fri Sep 12 03:53:36 2014
@@ -14,6 +14,7 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorOr.h"
+#include <map>
#include <string>
#include <system_error>
#include <utility>
@@ -70,6 +71,12 @@ struct ClangTidyOptions {
/// \brief Turns on temporary destructor-based analysis.
llvm::Optional<bool> AnalyzeTemporaryDtors;
+
+ typedef std::pair<std::string, std::string> StringPair;
+ typedef std::map<std::string, std::string> OptionMap;
+
+ /// \brief Key-value mapping used to store check-specific options.
+ OptionMap CheckOptions;
};
/// \brief Abstract interface for retrieving various ClangTidy options.
Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h Fri Sep 12 03:53:36 2014
@@ -26,6 +26,8 @@ namespace readability {
/// ones generated by -Wold-style-cast.
class AvoidCStyleCastsCheck : public ClangTidyCheck {
public:
+ AvoidCStyleCastsCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h Fri Sep 12 03:53:36 2014
@@ -21,6 +21,8 @@ namespace tidy {
/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Explicit_Constructors
class ExplicitConstructorCheck : public ClangTidyCheck {
public:
+ ExplicitConstructorCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.h Fri Sep 12 03:53:36 2014
@@ -24,6 +24,8 @@ namespace build {
/// Corresponding cpplint.py check name: 'build/explicit_make_pair'.
class ExplicitMakePairCheck : public ClangTidyCheck {
public:
+ ExplicitMakePairCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.h Fri Sep 12 03:53:36 2014
@@ -21,9 +21,9 @@ namespace runtime {
/// Correspondig cpplint.py check: runtime/int.
class IntegerTypesCheck : public ClangTidyCheck {
public:
- IntegerTypesCheck()
- : UnsignedTypePrefix("uint"), SignedTypePrefix("int"),
- AddUnderscoreT(false) {}
+ IntegerTypesCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context), UnsignedTypePrefix("uint"),
+ SignedTypePrefix("int"), AddUnderscoreT(false) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
Modified: clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.h Fri Sep 12 03:53:36 2014
@@ -24,6 +24,8 @@ namespace runtime {
/// Corresponding cpplint.py check name: 'runtime/memset'.
class MemsetZeroLengthCheck : public ClangTidyCheck {
public:
+ MemsetZeroLengthCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.h Fri Sep 12 03:53:36 2014
@@ -22,6 +22,8 @@ namespace readability {
/// Corresponding cpplint.py check name: 'readability/function'.
class NamedParameterCheck : public ClangTidyCheck {
public:
+ NamedParameterCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h Fri Sep 12 03:53:36 2014
@@ -22,6 +22,8 @@ namespace runtime {
/// Corresponding cpplint.py check name: 'runtime/operator'.
class OverloadedUnaryAndCheck : public ClangTidyCheck {
public:
+ OverloadedUnaryAndCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.h Fri Sep 12 03:53:36 2014
@@ -39,6 +39,8 @@ namespace runtime {
/// Corresponding cpplint.py check name: 'runtime/member_string_reference'.
class StringReferenceMemberCheck : public ClangTidyCheck {
public:
+ StringReferenceMemberCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h Fri Sep 12 03:53:36 2014
@@ -22,6 +22,8 @@ namespace build {
/// Corresponding cpplint.py check name: 'build/namespaces'.
class UnnamedNamespaceInHeaderCheck : public ClangTidyCheck {
public:
+ UnnamedNamespaceInHeaderCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h Fri Sep 12 03:53:36 2014
@@ -22,6 +22,8 @@ namespace build {
/// Corresponding cpplint.py check name: 'build/namespaces'.
class UsingNamespaceDirectiveCheck : public ClangTidyCheck {
public:
+ UsingNamespaceDirectiveCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.h Fri Sep 12 03:53:36 2014
@@ -18,6 +18,8 @@ namespace tidy {
/// Finds and fixes header guards that do not adhere to LLVM style.
class LLVMHeaderGuardCheck : public HeaderGuardCheck {
public:
+ LLVMHeaderGuardCheck(StringRef Name, ClangTidyContext *Context)
+ : HeaderGuardCheck(Name, Context) {}
bool shouldSuggestEndifComment(StringRef Filename) override { return false; }
bool shouldFixHeaderGuard(StringRef Filename) override;
std::string getHeaderGuard(StringRef Filename, StringRef OldGuard) override;
Modified: clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.h Fri Sep 12 03:53:36 2014
@@ -20,6 +20,8 @@ namespace tidy {
/// see: http://llvm.org/docs/CodingStandards.html#include-style
class IncludeOrderCheck : public ClangTidyCheck {
public:
+ IncludeOrderCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerPPCallbacks(CompilerInstance &Compiler) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/llvm/NamespaceCommentCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/NamespaceCommentCheck.cpp?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/llvm/NamespaceCommentCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/NamespaceCommentCheck.cpp Fri Sep 12 03:53:36 2014
@@ -11,20 +11,26 @@
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Lex/Lexer.h"
-
-
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/ADT/StringExtras.h"
using namespace clang::ast_matchers;
namespace clang {
namespace tidy {
-NamespaceCommentCheck::NamespaceCommentCheck()
- : NamespaceCommentPattern("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
+NamespaceCommentCheck::NamespaceCommentCheck(StringRef Name,
+ ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context),
+ NamespaceCommentPattern("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
"namespace( +([a-zA-Z0-9_]+))? *(\\*/)?$",
llvm::Regex::IgnoreCase),
- ShortNamespaceLines(1) {}
+ ShortNamespaceLines(Options.get("ShortNamespaceLines", 1u)),
+ SpacesBeforeComments(Options.get("SpacesBeforeComments", 1u)) {}
+
+void NamespaceCommentCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+ Options.store(Opts, "ShortNamespaceLines", ShortNamespaceLines);
+ Options.store(Opts, "SpacesBeforeComments", SpacesBeforeComments);
+}
void NamespaceCommentCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(namespaceDecl().bind("namespace"), this);
@@ -36,10 +42,12 @@ bool locationsInSameFile(const SourceMan
Sources.getFileID(Loc1) == Sources.getFileID(Loc2);
}
-std::string getNamespaceComment(const NamespaceDecl *ND, bool InsertLineBreak) {
+std::string getNamespaceComment(const NamespaceDecl *ND, bool InsertLineBreak,
+ unsigned SpacesBeforeComments) {
std::string Fix = "// namespace";
if (!ND->isAnonymousNamespace())
- Fix.append(" ").append(ND->getNameAsString());
+ Fix.append(std::string(SpacesBeforeComments, ' '))
+ .append(ND->getNameAsString());
if (InsertLineBreak)
Fix.append("\n");
return Fix;
@@ -97,7 +105,8 @@ void NamespaceCommentCheck::check(const
diag(Loc, "namespace closing comment refers to a wrong namespace '%0'")
<< NamespaceNameInComment
<< FixItHint::CreateReplacement(
- OldCommentRange, getNamespaceComment(ND, NeedLineBreak));
+ OldCommentRange,
+ getNamespaceComment(ND, NeedLineBreak, SpacesBeforeComments));
return;
}
@@ -110,7 +119,8 @@ void NamespaceCommentCheck::check(const
diag(ND->getLocation(), "namespace not terminated with a closing comment")
<< FixItHint::CreateInsertion(
- AfterRBrace, " " + getNamespaceComment(ND, NeedLineBreak));
+ AfterRBrace,
+ " " + getNamespaceComment(ND, NeedLineBreak, SpacesBeforeComments));
}
} // namespace tidy
Modified: clang-tools-extra/trunk/clang-tidy/llvm/NamespaceCommentCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/NamespaceCommentCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/llvm/NamespaceCommentCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/NamespaceCommentCheck.h Fri Sep 12 03:53:36 2014
@@ -21,13 +21,16 @@ namespace tidy {
/// see: http://llvm.org/docs/CodingStandards.html#namespace-indentation
class NamespaceCommentCheck : public ClangTidyCheck {
public:
- NamespaceCommentCheck();
+ NamespaceCommentCheck(StringRef Name, ClangTidyContext *Context);
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
+ void storeOptions(ClangTidyOptions::OptionMap &Options) override;
+
llvm::Regex NamespaceCommentPattern;
const unsigned ShortNamespaceLines;
+ const unsigned SpacesBeforeComments;
};
} // namespace tidy
Modified: clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp Fri Sep 12 03:53:36 2014
@@ -17,8 +17,6 @@ using namespace clang::ast_matchers;
namespace clang {
namespace tidy {
-TwineLocalCheck::TwineLocalCheck() {}
-
void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
auto TwineType =
qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine"))));
Modified: clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h Fri Sep 12 03:53:36 2014
@@ -19,7 +19,8 @@ namespace tidy {
/// and should be generally avoided.
class TwineLocalCheck : public ClangTidyCheck {
public:
- TwineLocalCheck();
+ TwineLocalCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp Fri Sep 12 03:53:36 2014
@@ -18,8 +18,10 @@ using namespace clang::ast_matchers;
namespace clang {
namespace tidy {
-ArgumentCommentCheck::ArgumentCommentCheck()
- : IdentRE("^(/\\* *)([_A-Za-z][_A-Za-z0-9]*)( *= *\\*/)$") {}
+ArgumentCommentCheck::ArgumentCommentCheck(StringRef Name,
+ ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context),
+ IdentRE("^(/\\* *)([_A-Za-z][_A-Za-z0-9]*)( *= *\\*/)$") {}
void ArgumentCommentCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
Modified: clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.h Fri Sep 12 03:53:36 2014
@@ -19,7 +19,7 @@ namespace tidy {
/// \brief Checks that argument comments match parameter names.
class ArgumentCommentCheck : public ClangTidyCheck {
public:
- ArgumentCommentCheck();
+ ArgumentCommentCheck(StringRef Name, ClangTidyContext *Context);
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
Modified: clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversion.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversion.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversion.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversion.h Fri Sep 12 03:53:36 2014
@@ -23,6 +23,8 @@ namespace tidy {
/// }
class BoolPointerImplicitConversion : public ClangTidyCheck {
public:
+ BoolPointerImplicitConversion(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantSmartptrGet.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/RedundantSmartptrGet.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/RedundantSmartptrGet.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/RedundantSmartptrGet.h Fri Sep 12 03:53:36 2014
@@ -23,6 +23,8 @@ namespace tidy {
/// *ptr->get() ==> **ptr
class RedundantSmartptrGet : public ClangTidyCheck {
public:
+ RedundantSmartptrGet(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/misc/SwappedArgumentsCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SwappedArgumentsCheck.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/SwappedArgumentsCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/SwappedArgumentsCheck.h Fri Sep 12 03:53:36 2014
@@ -19,6 +19,8 @@ namespace tidy {
/// conversions.
class SwappedArgumentsCheck : public ClangTidyCheck {
public:
+ SwappedArgumentsCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.h Fri Sep 12 03:53:36 2014
@@ -20,6 +20,8 @@ namespace tidy {
/// meant to use a delegating constructor or base class initializer.
class UndelegatedConstructorCheck : public ClangTidyCheck {
public:
+ UndelegatedConstructorCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.h Fri Sep 12 03:53:36 2014
@@ -37,6 +37,8 @@ namespace tidy {
/// - Ignore objects returned from a call.
class UnusedRAIICheck : public ClangTidyCheck {
public:
+ UnusedRAIICheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/misc/UseOverride.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseOverride.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverride.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverride.h Fri Sep 12 03:53:36 2014
@@ -18,6 +18,8 @@ namespace tidy {
/// \brief Use C++11's 'override' and remove 'virtual' where applicable.
class UseOverride : public ClangTidyCheck {
public:
+ UseOverride(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Fri Sep 12 03:53:36 2014
@@ -173,6 +173,7 @@ int clangTidyMain(int argc, const char *
}
if (DumpConfig) {
+ EffectiveOptions.CheckOptions = getCheckOptions(EffectiveOptions);
llvm::outs() << configurationAsText(ClangTidyOptions::getDefaults()
.mergeWith(EffectiveOptions))
<< "\n";
Modified: clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.h Fri Sep 12 03:53:36 2014
@@ -18,6 +18,8 @@ namespace tidy {
/// \brief Finds and fixes header guards.
class HeaderGuardCheck : public ClangTidyCheck {
public:
+ HeaderGuardCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerPPCallbacks(CompilerInstance &Compiler) override;
/// \brief Returns true if the checker should suggest inserting a trailing
Modified: clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp Fri Sep 12 03:53:36 2014
@@ -8,6 +8,8 @@ namespace test {
class TestCheck : public ClangTidyCheck {
public:
+ TestCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override {
Finder->addMatcher(ast_matchers::varDecl().bind("var"), this);
}
@@ -23,9 +25,8 @@ TEST(ClangTidyDiagnosticConsumer, SortsE
std::vector<ClangTidyError> Errors;
runCheckOnCode<TestCheck>("int a;", &Errors);
EXPECT_EQ(2ul, Errors.size());
- // FIXME: Remove " []" once the check name is removed from the message text.
- EXPECT_EQ("type specifier []", Errors[0].Message.Message);
- EXPECT_EQ("variable []", Errors[1].Message.Message);
+ EXPECT_EQ("type specifier", Errors[0].Message.Message);
+ EXPECT_EQ("variable", Errors[1].Message.Message);
}
TEST(GlobList, Empty) {
Modified: clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h Fri Sep 12 03:53:36 2014
@@ -44,13 +44,12 @@ std::string runCheckOnCode(StringRef Cod
std::vector<ClangTidyError> *Errors = nullptr,
const Twine &Filename = "input.cc",
ArrayRef<std::string> ExtraArgs = None) {
- T Check;
ClangTidyOptions Options;
Options.Checks = "*";
ClangTidyContext Context(llvm::make_unique<DefaultOptionsProvider>(
ClangTidyGlobalOptions(), Options));
ClangTidyDiagnosticConsumer DiagConsumer(Context);
- Check.setContext(&Context);
+ T Check("test-check", &Context);
std::vector<std::string> ArgCXX11(1, "-std=c++11");
ArgCXX11.insert(ArgCXX11.end(), ExtraArgs.begin(), ExtraArgs.end());
Modified: clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp?rev=217661&r1=217660&r2=217661&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp Fri Sep 12 03:53:36 2014
@@ -95,6 +95,8 @@ static std::string runHeaderGuardCheck(S
namespace {
struct WithEndifComment : public LLVMHeaderGuardCheck {
+ WithEndifComment(StringRef Name, ClangTidyContext *Context)
+ : LLVMHeaderGuardCheck(Name, Context) {}
bool shouldSuggestEndifComment(StringRef Filename) override { return true; }
};
} // namespace
More information about the cfe-commits
mailing list