[clang-tools-extra] r250641 - Make a bunch of static arrays const.
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 17 22:14:42 PDT 2015
Author: ctopper
Date: Sun Oct 18 00:14:41 2015
New Revision: 250641
URL: http://llvm.org/viewvc/llvm-project?rev=250641&view=rev
Log:
Make a bunch of static arrays const.
Modified:
clang-tools-extra/trunk/clang-modernize/UseAuto/UseAutoMatchers.cpp
clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/NonCopyableObjects.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/trunk/modularize/ModuleAssistant.cpp
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h
Modified: clang-tools-extra/trunk/clang-modernize/UseAuto/UseAutoMatchers.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/UseAuto/UseAutoMatchers.cpp?rev=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/UseAuto/UseAutoMatchers.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/UseAuto/UseAutoMatchers.cpp Sun Oct 18 00:14:41 2015
@@ -96,7 +96,7 @@ AST_MATCHER_P(QualType, isSugarFor, inte
///
/// \c namedDecl(hasStdIteratorName()) matches \c I and \c CI.
AST_MATCHER(NamedDecl, hasStdIteratorName) {
- static const char *IteratorNames[] = {
+ static const char *const IteratorNames[] = {
"iterator",
"reverse_iterator",
"const_iterator",
@@ -125,7 +125,7 @@ AST_MATCHER(NamedDecl, hasStdIteratorNam
/// \c recordDecl(hasStdContainerName()) matches \c vector and \c forward_list
/// but not \c my_vec.
AST_MATCHER(NamedDecl, hasStdContainerName) {
- static const char *ContainerNames[] = {
+ static const char *const ContainerNames[] = {
"array",
"deque",
"forward_list",
Modified: clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp?rev=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp Sun Oct 18 00:14:41 2015
@@ -45,7 +45,7 @@ static cl::OptionCategory FormattingCate
static cl::OptionCategory IncludeExcludeCategory("Inclusion/Exclusion Options");
static cl::OptionCategory SerializeCategory("Serialization Options");
-static const cl::OptionCategory *VisibleCategories[] = {
+static const cl::OptionCategory *const VisibleCategories[] = {
&GeneralCategory, &FormattingCategory, &IncludeExcludeCategory,
&SerializeCategory, &TransformCategory, &TransformsOptionsCategory,
};
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=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Sun Oct 18 00:14:41 2015
@@ -55,7 +55,7 @@ namespace tidy {
namespace {
static const char *AnalyzerCheckNamePrefix = "clang-analyzer-";
-static StringRef StaticAnalyzerChecks[] = {
+static const StringRef StaticAnalyzerChecks[] = {
#define GET_CHECKERS
#define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN) \
FULLNAME,
Modified: clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp?rev=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp Sun Oct 18 00:14:41 2015
@@ -61,7 +61,7 @@ void AssignOperatorSignatureCheck::check
const auto* Method = Result.Nodes.getNodeAs<CXXMethodDecl>("method");
std::string Name = Method->getParent()->getName();
- static const char *Messages[][2] = {
+ static const char *const Messages[][2] = {
{"ReturnType", "operator=() should return '%0&'"},
{"ArgumentType", "operator=() should take '%0 const&', '%0&&' or '%0'"},
{"cv", "operator=() should not be marked '%1'"}
Modified: clang-tools-extra/trunk/clang-tidy/misc/NonCopyableObjects.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NonCopyableObjects.cpp?rev=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NonCopyableObjects.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NonCopyableObjects.cpp Sun Oct 18 00:14:41 2015
@@ -20,7 +20,7 @@ namespace {
// users can add their own elements to the list. However, it may require some
// extra thought since POSIX types and FILE types are usable in different ways.
bool isPOSIXTypeName(StringRef ClassName) {
- static const char *TypeNames[] = {
+ static const char *const TypeNames[] = {
"::pthread_cond_t",
"::pthread_mutex_t",
"pthread_cond_t",
@@ -31,7 +31,7 @@ bool isPOSIXTypeName(StringRef ClassName
}
bool isFILETypeName(StringRef ClassName) {
- static const char *TypeNames[] = {
+ static const char *const TypeNames[] = {
"::FILE",
"FILE",
"std::FILE"
Modified: clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp?rev=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp Sun Oct 18 00:14:41 2015
@@ -18,7 +18,7 @@ using namespace clang::ast_matchers;
namespace clang {
namespace {
bool isShrinkableContainer(llvm::StringRef ClassName) {
- static const char *Shrinkables[] = {
+ static const char *const Shrinkables[] = {
"std::basic_string",
"std::deque",
"std::vector"
Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp?rev=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Sun Oct 18 00:14:41 2015
@@ -87,9 +87,9 @@ AST_MATCHER_P(QualType, isSugarFor, Matc
///
/// namedDecl(hasStdIteratorName()) matches \c I and \c CI.
AST_MATCHER(NamedDecl, hasStdIteratorName) {
- static const char *IteratorNames[] = {"iterator", "reverse_iterator",
- "const_iterator",
- "const_reverse_iterator"};
+ static const char *const IteratorNames[] = {"iterator", "reverse_iterator",
+ "const_iterator",
+ "const_reverse_iterator"};
for (const char *Name : IteratorNames) {
if (hasName(Name).matches(Node, Finder, Builder))
@@ -111,18 +111,20 @@ AST_MATCHER(NamedDecl, hasStdIteratorNam
/// recordDecl(hasStdContainerName()) matches \c vector and \c forward_list
/// but not \c my_vec.
AST_MATCHER(NamedDecl, hasStdContainerName) {
- static const char *ContainerNames[] = {"array", "deque",
- "forward_list", "list",
- "vector",
+ static const char *const ContainerNames[] = {"array", "deque",
+ "forward_list", "list",
+ "vector",
+
+ "map", "multimap",
+ "set", "multiset",
+
+ "unordered_map",
+ "unordered_multimap",
+ "unordered_set",
+ "unordered_multiset",
- "map", "multimap",
- "set", "multiset",
-
- "unordered_map", "unordered_multimap",
- "unordered_set", "unordered_multiset",
-
- "queue", "priority_queue",
- "stack"};
+ "queue", "priority_queue",
+ "stack"};
for (const char *Name : ContainerNames) {
if (hasName(Name).matches(Node, Finder, Builder))
Modified: clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp?rev=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp Sun Oct 18 00:14:41 2015
@@ -15,7 +15,7 @@
using namespace clang::ast_matchers;
static bool isContainer(llvm::StringRef ClassName) {
- static const char *ContainerNames[] = {
+ static const char *const ContainerNames[] = {
"std::array",
"std::deque",
"std::forward_list",
Modified: clang-tools-extra/trunk/modularize/ModuleAssistant.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModuleAssistant.cpp?rev=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/ModuleAssistant.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModuleAssistant.cpp Sun Oct 18 00:14:41 2015
@@ -137,7 +137,7 @@ Module *Module::findSubModule(llvm::Stri
// Reserved keywords in module.modulemap syntax.
// Keep in sync with keywords in module map parser in Lex/ModuleMap.cpp,
// such as in ModuleMapParser::consumeToken().
-static const char *ReservedNames[] = {
+static const char *const ReservedNames[] = {
"config_macros", "export", "module", "conflict", "framework",
"requires", "exclude", "header", "private", "explicit",
"link", "umbrella", "extern", "use", nullptr // Flag end.
Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp?rev=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp Sun Oct 18 00:14:41 2015
@@ -56,35 +56,38 @@ static std::string getSourceLocationStri
// Enum string tables.
// FileChangeReason strings.
-static const char *FileChangeReasonStrings[] = {
+static const char *const FileChangeReasonStrings[] = {
"EnterFile", "ExitFile", "SystemHeaderPragma", "RenameFile"
};
// CharacteristicKind strings.
-static const char *CharacteristicKindStrings[] = { "C_User", "C_System",
- "C_ExternCSystem" };
+static const char *const CharacteristicKindStrings[] = { "C_User", "C_System",
+ "C_ExternCSystem" };
// MacroDirective::Kind strings.
-static const char *MacroDirectiveKindStrings[] = { "MD_Define", "MD_Undefine",
- "MD_Visibility" };
+static const char *const MacroDirectiveKindStrings[] = {
+ "MD_Define","MD_Undefine", "MD_Visibility"
+};
// PragmaIntroducerKind strings.
-static const char *PragmaIntroducerKindStrings[] = { "PIK_HashPragma",
- "PIK__Pragma",
- "PIK___pragma" };
+static const char *const PragmaIntroducerKindStrings[] = { "PIK_HashPragma",
+ "PIK__Pragma",
+ "PIK___pragma" };
// PragmaMessageKind strings.
-static const char *PragmaMessageKindStrings[] = { "PMK_Message", "PMK_Warning",
- "PMK_Error" };
+static const char *const PragmaMessageKindStrings[] = {
+ "PMK_Message", "PMK_Warning", "PMK_Error"
+};
// ConditionValueKind strings.
-static const char *ConditionValueKindStrings[] = {"CVK_NotEvaluated",
- "CVK_False", "CVK_True"};
+static const char *const ConditionValueKindStrings[] = {
+ "CVK_NotEvaluated", "CVK_False", "CVK_True"
+};
// Mapping strings.
-static const char *MappingStrings[] = { "0", "MAP_IGNORE",
- "MAP_REMARK", "MAP_WARNING",
- "MAP_ERROR", "MAP_FATAL" };
+static const char *const MappingStrings[] = { "0", "MAP_IGNORE",
+ "MAP_REMARK", "MAP_WARNING",
+ "MAP_ERROR", "MAP_FATAL" };
// PPCallbacksTracker functions.
@@ -453,7 +456,7 @@ void PPCallbacksTracker::appendArgument(
// Append an enum argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name, int Value,
- const char *Strings[]) {
+ const char *const Strings[]) {
appendArgument(Name, Strings[Value]);
}
Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h?rev=250641&r1=250640&r2=250641&view=diff
==============================================================================
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h Sun Oct 18 00:14:41 2015
@@ -179,7 +179,7 @@ public:
void appendArgument(const char *Name, const clang::Token &Value);
/// \brief Append an enum argument to the top trace item.
- void appendArgument(const char *Name, int Value, const char *Strings[]);
+ void appendArgument(const char *Name, int Value, const char *const Strings[]);
/// \brief Append a FileID argument to the top trace item.
void appendArgument(const char *Name, clang::FileID Value);
More information about the cfe-commits
mailing list