[clang-tools-extra] r308605 - [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 20 05:02:03 PDT 2017
Author: alexfh
Date: Thu Jul 20 05:02:03 2017
New Revision: 308605
URL: http://llvm.org/viewvc/llvm-project?rev=308605&view=rev
Log:
[clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.cpp
clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.h
clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/HeaderFileExtensionsUtils.h
clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.h
Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp Thu Jul 20 05:02:03 2017
@@ -23,7 +23,7 @@ ProBoundsConstantArrayIndexCheck::ProBou
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context), GslHeader(Options.get("GslHeader", "")),
IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
- Options.get("IncludeStyle", "llvm"))) {}
+ Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
void ProBoundsConstantArrayIndexCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
Modified: clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp Thu Jul 20 05:02:03 2017
@@ -23,8 +23,8 @@ namespace readability {
GlobalNamesInHeadersCheck::GlobalNamesInHeadersCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
- RawStringHeaderFileExtensions(
- Options.getLocalOrGlobal("HeaderFileExtensions", "h")) {
+ RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
+ "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
if (!utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,
HeaderFileExtensions, ',')) {
llvm::errs() << "Invalid header file extension: "
Modified: clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp Thu Jul 20 05:02:03 2017
@@ -22,8 +22,8 @@ namespace build {
UnnamedNamespaceInHeaderCheck::UnnamedNamespaceInHeaderCheck(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
- RawStringHeaderFileExtensions(
- Options.getLocalOrGlobal("HeaderFileExtensions", "h,hh,hpp,hxx")) {
+ RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
+ "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
if (!utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,
HeaderFileExtensions, ',')) {
llvm::errs() << "Invalid header file extension: "
Modified: clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.cpp Thu Jul 20 05:02:03 2017
@@ -15,20 +15,7 @@ namespace llvm {
LLVMHeaderGuardCheck::LLVMHeaderGuardCheck(StringRef Name,
ClangTidyContext *Context)
- : HeaderGuardCheck(Name, Context),
- RawStringHeaderFileExtensions(
- Options.getLocalOrGlobal("HeaderFileExtensions", ",h,hh,hpp,hxx")) {
- utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,
- HeaderFileExtensions, ',');
-}
-
-void LLVMHeaderGuardCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
- Options.store(Opts, "HeaderFileExtensions", RawStringHeaderFileExtensions);
-}
-
-bool LLVMHeaderGuardCheck::shouldFixHeaderGuard(StringRef FileName) {
- return utils::isHeaderFileExtension(FileName, HeaderFileExtensions);
-}
+ : HeaderGuardCheck(Name, Context) {}
std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef Filename,
StringRef OldGuard) {
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=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.h Thu Jul 20 05:02:03 2017
@@ -29,14 +29,8 @@ class LLVMHeaderGuardCheck : public util
public:
LLVMHeaderGuardCheck(StringRef Name, ClangTidyContext *Context);
- void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
bool shouldSuggestEndifComment(StringRef Filename) override { return false; }
- bool shouldFixHeaderGuard(StringRef Filename) override;
std::string getHeaderGuard(StringRef Filename, StringRef OldGuard) override;
-
-private:
- std::string RawStringHeaderFileExtensions;
- utils::HeaderFileExtensionsSet HeaderFileExtensions;
};
} // namespace llvm
Modified: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp Thu Jul 20 05:02:03 2017
@@ -32,8 +32,8 @@ DefinitionsInHeadersCheck::DefinitionsIn
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
UseHeaderFileExtension(Options.get("UseHeaderFileExtension", true)),
- RawStringHeaderFileExtensions(
- Options.getLocalOrGlobal("HeaderFileExtensions", ",h,hh,hpp,hxx")) {
+ RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
+ "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
if (!utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,
HeaderFileExtensions, ',')) {
// FIXME: Find a more suitable way to handle invalid configuration
Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp Thu Jul 20 05:02:03 2017
@@ -25,7 +25,7 @@ MoveConstructorInitCheck::MoveConstructo
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
- Options.get("IncludeStyle", "llvm"))) {}
+ Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) {
// Only register the matchers for C++11; the functionality currently does not
Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Thu Jul 20 05:02:03 2017
@@ -46,7 +46,7 @@ MakeSmartPtrCheck::MakeSmartPtrCheck(Str
StringRef MakeSmartPtrFunctionName)
: ClangTidyCheck(Name, Context),
IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
- Options.get("IncludeStyle", "llvm"))),
+ Options.getLocalOrGlobal("IncludeStyle", "llvm"))),
MakeSmartPtrFunctionHeader(
Options.get("MakeSmartPtrFunctionHeader", StdMemoryHeader)),
MakeSmartPtrFunctionName(
Modified: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp Thu Jul 20 05:02:03 2017
@@ -119,7 +119,7 @@ collectParamDecls(const CXXConstructorDe
PassByValueCheck::PassByValueCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
- Options.get("IncludeStyle", "llvm"))),
+ Options.getLocalOrGlobal("IncludeStyle", "llvm"))),
ValuesOnly(Options.get("ValuesOnly", 0) != 0) {}
void PassByValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Modified: clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp Thu Jul 20 05:02:03 2017
@@ -73,7 +73,7 @@ ReplaceAutoPtrCheck::ReplaceAutoPtrCheck
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
- Options.get("IncludeStyle", "llvm"))) {}
+ Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
void ReplaceAutoPtrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "IncludeStyle",
Modified: clang-tools-extra/trunk/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp Thu Jul 20 05:02:03 2017
@@ -25,7 +25,7 @@ ReplaceRandomShuffleCheck::ReplaceRandom
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
- Options.get("IncludeStyle", "llvm"))) {}
+ Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
void ReplaceRandomShuffleCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus11)
Modified: clang-tools-extra/trunk/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/TypePromotionInMathFnCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/performance/TypePromotionInMathFnCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/performance/TypePromotionInMathFnCheck.cpp Thu Jul 20 05:02:03 2017
@@ -33,7 +33,7 @@ TypePromotionInMathFnCheck::TypePromotio
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
- Options.get("IncludeStyle", "llvm"))) {}
+ Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
void TypePromotionInMathFnCheck::registerPPCallbacks(
CompilerInstance &Compiler) {
Modified: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp Thu Jul 20 05:02:03 2017
@@ -64,7 +64,7 @@ UnnecessaryValueParamCheck::UnnecessaryV
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
- Options.get("IncludeStyle", "llvm"))) {}
+ Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) {
const auto ExpensiveValueParamDecl =
Modified: clang-tools-extra/trunk/clang-tidy/utils/HeaderFileExtensionsUtils.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/HeaderFileExtensionsUtils.h?rev=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/HeaderFileExtensionsUtils.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/HeaderFileExtensionsUtils.h Thu Jul 20 05:02:03 2017
@@ -36,6 +36,10 @@ bool isSpellingLocInHeaderFile(
SourceLocation Loc, SourceManager &SM,
const HeaderFileExtensionsSet &HeaderFileExtensions);
+/// \brief Returns recommended default value for the list of header file
+/// extensions.
+inline StringRef defaultHeaderFileExtensions() { return ",h,hh,hpp,hxx"; }
+
/// \brief Parses header file extensions from a semicolon-separated list.
bool parseHeaderFileExtensions(StringRef AllHeaderFileExtensions,
HeaderFileExtensionsSet &HeaderFileExtensions,
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=308605&r1=308604&r2=308605&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.h Thu Jul 20 05:02:03 2017
@@ -28,8 +28,8 @@ class HeaderGuardCheck : public ClangTid
public:
HeaderGuardCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
- RawStringHeaderFileExtensions(
- Options.getLocalOrGlobal("HeaderFileExtensions", ",h,hh,hpp,hxx")) {
+ RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
+ "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,
HeaderFileExtensions, ',');
}
More information about the cfe-commits
mailing list