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:
Родитель
776233f9a3
Коммит
835316e4fe
|
@ -96,7 +96,7 @@ AST_MATCHER_P(QualType, isSugarFor, internal::Matcher<QualType>, SugarMatcher) {
|
||||||
///
|
///
|
||||||
/// \c namedDecl(hasStdIteratorName()) matches \c I and \c CI.
|
/// \c namedDecl(hasStdIteratorName()) matches \c I and \c CI.
|
||||||
AST_MATCHER(NamedDecl, hasStdIteratorName) {
|
AST_MATCHER(NamedDecl, hasStdIteratorName) {
|
||||||
static const char *IteratorNames[] = {
|
static const char *const IteratorNames[] = {
|
||||||
"iterator",
|
"iterator",
|
||||||
"reverse_iterator",
|
"reverse_iterator",
|
||||||
"const_iterator",
|
"const_iterator",
|
||||||
|
@ -125,7 +125,7 @@ AST_MATCHER(NamedDecl, hasStdIteratorName) {
|
||||||
/// \c recordDecl(hasStdContainerName()) matches \c vector and \c forward_list
|
/// \c recordDecl(hasStdContainerName()) matches \c vector and \c forward_list
|
||||||
/// but not \c my_vec.
|
/// but not \c my_vec.
|
||||||
AST_MATCHER(NamedDecl, hasStdContainerName) {
|
AST_MATCHER(NamedDecl, hasStdContainerName) {
|
||||||
static const char *ContainerNames[] = {
|
static const char *const ContainerNames[] = {
|
||||||
"array",
|
"array",
|
||||||
"deque",
|
"deque",
|
||||||
"forward_list",
|
"forward_list",
|
||||||
|
|
|
@ -45,7 +45,7 @@ static cl::OptionCategory FormattingCategory("Formatting Options");
|
||||||
static cl::OptionCategory IncludeExcludeCategory("Inclusion/Exclusion Options");
|
static cl::OptionCategory IncludeExcludeCategory("Inclusion/Exclusion Options");
|
||||||
static cl::OptionCategory SerializeCategory("Serialization Options");
|
static cl::OptionCategory SerializeCategory("Serialization Options");
|
||||||
|
|
||||||
static const cl::OptionCategory *VisibleCategories[] = {
|
static const cl::OptionCategory *const VisibleCategories[] = {
|
||||||
&GeneralCategory, &FormattingCategory, &IncludeExcludeCategory,
|
&GeneralCategory, &FormattingCategory, &IncludeExcludeCategory,
|
||||||
&SerializeCategory, &TransformCategory, &TransformsOptionsCategory,
|
&SerializeCategory, &TransformCategory, &TransformsOptionsCategory,
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace tidy {
|
||||||
namespace {
|
namespace {
|
||||||
static const char *AnalyzerCheckNamePrefix = "clang-analyzer-";
|
static const char *AnalyzerCheckNamePrefix = "clang-analyzer-";
|
||||||
|
|
||||||
static StringRef StaticAnalyzerChecks[] = {
|
static const StringRef StaticAnalyzerChecks[] = {
|
||||||
#define GET_CHECKERS
|
#define GET_CHECKERS
|
||||||
#define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN) \
|
#define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN) \
|
||||||
FULLNAME,
|
FULLNAME,
|
||||||
|
|
|
@ -61,7 +61,7 @@ void AssignOperatorSignatureCheck::check(
|
||||||
const auto* Method = Result.Nodes.getNodeAs<CXXMethodDecl>("method");
|
const auto* Method = Result.Nodes.getNodeAs<CXXMethodDecl>("method");
|
||||||
std::string Name = Method->getParent()->getName();
|
std::string Name = Method->getParent()->getName();
|
||||||
|
|
||||||
static const char *Messages[][2] = {
|
static const char *const Messages[][2] = {
|
||||||
{"ReturnType", "operator=() should return '%0&'"},
|
{"ReturnType", "operator=() should return '%0&'"},
|
||||||
{"ArgumentType", "operator=() should take '%0 const&', '%0&&' or '%0'"},
|
{"ArgumentType", "operator=() should take '%0 const&', '%0&&' or '%0'"},
|
||||||
{"cv", "operator=() should not be marked '%1'"}
|
{"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
|
// 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.
|
// extra thought since POSIX types and FILE types are usable in different ways.
|
||||||
bool isPOSIXTypeName(StringRef ClassName) {
|
bool isPOSIXTypeName(StringRef ClassName) {
|
||||||
static const char *TypeNames[] = {
|
static const char *const TypeNames[] = {
|
||||||
"::pthread_cond_t",
|
"::pthread_cond_t",
|
||||||
"::pthread_mutex_t",
|
"::pthread_mutex_t",
|
||||||
"pthread_cond_t",
|
"pthread_cond_t",
|
||||||
|
@ -31,7 +31,7 @@ bool isPOSIXTypeName(StringRef ClassName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFILETypeName(StringRef ClassName) {
|
bool isFILETypeName(StringRef ClassName) {
|
||||||
static const char *TypeNames[] = {
|
static const char *const TypeNames[] = {
|
||||||
"::FILE",
|
"::FILE",
|
||||||
"FILE",
|
"FILE",
|
||||||
"std::FILE"
|
"std::FILE"
|
||||||
|
|
|
@ -18,7 +18,7 @@ using namespace clang::ast_matchers;
|
||||||
namespace clang {
|
namespace clang {
|
||||||
namespace {
|
namespace {
|
||||||
bool isShrinkableContainer(llvm::StringRef ClassName) {
|
bool isShrinkableContainer(llvm::StringRef ClassName) {
|
||||||
static const char *Shrinkables[] = {
|
static const char *const Shrinkables[] = {
|
||||||
"std::basic_string",
|
"std::basic_string",
|
||||||
"std::deque",
|
"std::deque",
|
||||||
"std::vector"
|
"std::vector"
|
||||||
|
|
|
@ -87,9 +87,9 @@ AST_MATCHER_P(QualType, isSugarFor, Matcher<QualType>, SugarMatcher) {
|
||||||
///
|
///
|
||||||
/// namedDecl(hasStdIteratorName()) matches \c I and \c CI.
|
/// namedDecl(hasStdIteratorName()) matches \c I and \c CI.
|
||||||
AST_MATCHER(NamedDecl, hasStdIteratorName) {
|
AST_MATCHER(NamedDecl, hasStdIteratorName) {
|
||||||
static const char *IteratorNames[] = {"iterator", "reverse_iterator",
|
static const char *const IteratorNames[] = {"iterator", "reverse_iterator",
|
||||||
"const_iterator",
|
"const_iterator",
|
||||||
"const_reverse_iterator"};
|
"const_reverse_iterator"};
|
||||||
|
|
||||||
for (const char *Name : IteratorNames) {
|
for (const char *Name : IteratorNames) {
|
||||||
if (hasName(Name).matches(Node, Finder, Builder))
|
if (hasName(Name).matches(Node, Finder, Builder))
|
||||||
|
@ -111,18 +111,20 @@ AST_MATCHER(NamedDecl, hasStdIteratorName) {
|
||||||
/// recordDecl(hasStdContainerName()) matches \c vector and \c forward_list
|
/// recordDecl(hasStdContainerName()) matches \c vector and \c forward_list
|
||||||
/// but not \c my_vec.
|
/// but not \c my_vec.
|
||||||
AST_MATCHER(NamedDecl, hasStdContainerName) {
|
AST_MATCHER(NamedDecl, hasStdContainerName) {
|
||||||
static const char *ContainerNames[] = {"array", "deque",
|
static const char *const ContainerNames[] = {"array", "deque",
|
||||||
"forward_list", "list",
|
"forward_list", "list",
|
||||||
"vector",
|
"vector",
|
||||||
|
|
||||||
"map", "multimap",
|
"map", "multimap",
|
||||||
"set", "multiset",
|
"set", "multiset",
|
||||||
|
|
||||||
"unordered_map", "unordered_multimap",
|
"unordered_map",
|
||||||
"unordered_set", "unordered_multiset",
|
"unordered_multimap",
|
||||||
|
"unordered_set",
|
||||||
|
"unordered_multiset",
|
||||||
|
|
||||||
"queue", "priority_queue",
|
"queue", "priority_queue",
|
||||||
"stack"};
|
"stack"};
|
||||||
|
|
||||||
for (const char *Name : ContainerNames) {
|
for (const char *Name : ContainerNames) {
|
||||||
if (hasName(Name).matches(Node, Finder, Builder))
|
if (hasName(Name).matches(Node, Finder, Builder))
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
using namespace clang::ast_matchers;
|
using namespace clang::ast_matchers;
|
||||||
|
|
||||||
static bool isContainer(llvm::StringRef ClassName) {
|
static bool isContainer(llvm::StringRef ClassName) {
|
||||||
static const char *ContainerNames[] = {
|
static const char *const ContainerNames[] = {
|
||||||
"std::array",
|
"std::array",
|
||||||
"std::deque",
|
"std::deque",
|
||||||
"std::forward_list",
|
"std::forward_list",
|
||||||
|
|
|
@ -137,7 +137,7 @@ Module *Module::findSubModule(llvm::StringRef SubName) {
|
||||||
// Reserved keywords in module.modulemap syntax.
|
// Reserved keywords in module.modulemap syntax.
|
||||||
// Keep in sync with keywords in module map parser in Lex/ModuleMap.cpp,
|
// Keep in sync with keywords in module map parser in Lex/ModuleMap.cpp,
|
||||||
// such as in ModuleMapParser::consumeToken().
|
// such as in ModuleMapParser::consumeToken().
|
||||||
static const char *ReservedNames[] = {
|
static const char *const ReservedNames[] = {
|
||||||
"config_macros", "export", "module", "conflict", "framework",
|
"config_macros", "export", "module", "conflict", "framework",
|
||||||
"requires", "exclude", "header", "private", "explicit",
|
"requires", "exclude", "header", "private", "explicit",
|
||||||
"link", "umbrella", "extern", "use", nullptr // Flag end.
|
"link", "umbrella", "extern", "use", nullptr // Flag end.
|
||||||
|
|
|
@ -56,35 +56,38 @@ static std::string getSourceLocationString(clang::Preprocessor &PP,
|
||||||
// Enum string tables.
|
// Enum string tables.
|
||||||
|
|
||||||
// FileChangeReason strings.
|
// FileChangeReason strings.
|
||||||
static const char *FileChangeReasonStrings[] = {
|
static const char *const FileChangeReasonStrings[] = {
|
||||||
"EnterFile", "ExitFile", "SystemHeaderPragma", "RenameFile"
|
"EnterFile", "ExitFile", "SystemHeaderPragma", "RenameFile"
|
||||||
};
|
};
|
||||||
|
|
||||||
// CharacteristicKind strings.
|
// CharacteristicKind strings.
|
||||||
static const char *CharacteristicKindStrings[] = { "C_User", "C_System",
|
static const char *const CharacteristicKindStrings[] = { "C_User", "C_System",
|
||||||
"C_ExternCSystem" };
|
"C_ExternCSystem" };
|
||||||
|
|
||||||
// MacroDirective::Kind strings.
|
// MacroDirective::Kind strings.
|
||||||
static const char *MacroDirectiveKindStrings[] = { "MD_Define", "MD_Undefine",
|
static const char *const MacroDirectiveKindStrings[] = {
|
||||||
"MD_Visibility" };
|
"MD_Define","MD_Undefine", "MD_Visibility"
|
||||||
|
};
|
||||||
|
|
||||||
// PragmaIntroducerKind strings.
|
// PragmaIntroducerKind strings.
|
||||||
static const char *PragmaIntroducerKindStrings[] = { "PIK_HashPragma",
|
static const char *const PragmaIntroducerKindStrings[] = { "PIK_HashPragma",
|
||||||
"PIK__Pragma",
|
"PIK__Pragma",
|
||||||
"PIK___pragma" };
|
"PIK___pragma" };
|
||||||
|
|
||||||
// PragmaMessageKind strings.
|
// PragmaMessageKind strings.
|
||||||
static const char *PragmaMessageKindStrings[] = { "PMK_Message", "PMK_Warning",
|
static const char *const PragmaMessageKindStrings[] = {
|
||||||
"PMK_Error" };
|
"PMK_Message", "PMK_Warning", "PMK_Error"
|
||||||
|
};
|
||||||
|
|
||||||
// ConditionValueKind strings.
|
// ConditionValueKind strings.
|
||||||
static const char *ConditionValueKindStrings[] = {"CVK_NotEvaluated",
|
static const char *const ConditionValueKindStrings[] = {
|
||||||
"CVK_False", "CVK_True"};
|
"CVK_NotEvaluated", "CVK_False", "CVK_True"
|
||||||
|
};
|
||||||
|
|
||||||
// Mapping strings.
|
// Mapping strings.
|
||||||
static const char *MappingStrings[] = { "0", "MAP_IGNORE",
|
static const char *const MappingStrings[] = { "0", "MAP_IGNORE",
|
||||||
"MAP_REMARK", "MAP_WARNING",
|
"MAP_REMARK", "MAP_WARNING",
|
||||||
"MAP_ERROR", "MAP_FATAL" };
|
"MAP_ERROR", "MAP_FATAL" };
|
||||||
|
|
||||||
// PPCallbacksTracker functions.
|
// PPCallbacksTracker functions.
|
||||||
|
|
||||||
|
@ -453,7 +456,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
|
||||||
|
|
||||||
// Append an enum argument to the top trace item.
|
// Append an enum argument to the top trace item.
|
||||||
void PPCallbacksTracker::appendArgument(const char *Name, int Value,
|
void PPCallbacksTracker::appendArgument(const char *Name, int Value,
|
||||||
const char *Strings[]) {
|
const char *const Strings[]) {
|
||||||
appendArgument(Name, Strings[Value]);
|
appendArgument(Name, Strings[Value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ public:
|
||||||
void appendArgument(const char *Name, const clang::Token &Value);
|
void appendArgument(const char *Name, const clang::Token &Value);
|
||||||
|
|
||||||
/// \brief Append an enum argument to the top trace item.
|
/// \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.
|
/// \brief Append a FileID argument to the top trace item.
|
||||||
void appendArgument(const char *Name, clang::FileID Value);
|
void appendArgument(const char *Name, clang::FileID Value);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче