Make a bunch of static arrays const.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250641 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2015-10-18 05:14:41 +00:00
Родитель 776233f9a3
Коммит 835316e4fe
11 изменённых файлов: 44 добавлений и 39 удалений

Просмотреть файл

@ -96,7 +96,7 @@ AST_MATCHER_P(QualType, isSugarFor, internal::Matcher<QualType>, SugarMatcher) {
///
/// \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, hasStdIteratorName) {
/// \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",

Просмотреть файл

@ -45,7 +45,7 @@ static cl::OptionCategory FormattingCategory("Formatting Options");
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,
};

Просмотреть файл

@ -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,

Просмотреть файл

@ -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'"}

Просмотреть файл

@ -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"

Просмотреть файл

@ -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"

Просмотреть файл

@ -87,9 +87,9 @@ AST_MATCHER_P(QualType, isSugarFor, Matcher<QualType>, SugarMatcher) {
///
/// 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, hasStdIteratorName) {
/// 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",
"map", "multimap",
"set", "multiset",
"unordered_map", "unordered_multimap",
"unordered_set", "unordered_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))

Просмотреть файл

@ -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",

Просмотреть файл

@ -137,7 +137,7 @@ Module *Module::findSubModule(llvm::StringRef SubName) {
// 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.

Просмотреть файл

@ -56,35 +56,38 @@ static std::string getSourceLocationString(clang::Preprocessor &PP,
// 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(const char *Name,
// 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]);
}

Просмотреть файл

@ -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);