This revision was automatically updated to reflect the committed changes. Closed by commit rG0333dde923c4: [clang-tidy] Fix readability-identifer-naming duplicating prefix or suffix for… (authored by njames93).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D98521/new/ https://reviews.llvm.org/D98521 Files: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp +++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp @@ -148,6 +148,10 @@ int g_twice_global3 = ADD_TO_SELF(global3); // CHECK-FIXES: {{^}}int g_twice_global3 = ADD_TO_SELF(g_global3);{{$}} +int g_Global4; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'g_Global4' +// CHECK-FIXES: {{^}}int g_global4;{{$}} + enum my_enumeration { // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 'my_enumeration' // CHECK-FIXES: {{^}}enum EMyEnumeration {{{$}} @@ -544,6 +548,9 @@ // CHECK-FIXES: {{^}}unsigned const MY_CONST_GLOBAL_ARRAY[] = {1,2,3};{{$}} int * MyGlobal_Ptr;// -> ok +int * my_second_global_Ptr; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'my_second_global_Ptr' +// CHECK-FIXES: {{^}}int * MySecondGlobal_Ptr;{{$}} int * const MyConstantGlobalPointer = nullptr; // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global constant pointer 'MyConstantGlobalPointer' // CHECK-FIXES: {{^}}int * const MY_CONSTANT_GLOBAL_POINTER_Ptr = nullptr;{{$}} Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -407,6 +407,8 @@ static std::string fixupWithStyle(StringRef Name, const IdentifierNamingCheck::NamingStyle &Style) { + Name.consume_front(Style.Prefix); + Name.consume_back(Style.Suffix); const std::string Fixed = fixupWithCase( Name, Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase)); StringRef Mid = StringRef(Fixed).trim("_");
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp +++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp @@ -148,6 +148,10 @@ int g_twice_global3 = ADD_TO_SELF(global3); // CHECK-FIXES: {{^}}int g_twice_global3 = ADD_TO_SELF(g_global3);{{$}} +int g_Global4; +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'g_Global4' +// CHECK-FIXES: {{^}}int g_global4;{{$}} + enum my_enumeration { // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 'my_enumeration' // CHECK-FIXES: {{^}}enum EMyEnumeration {{{$}} @@ -544,6 +548,9 @@ // CHECK-FIXES: {{^}}unsigned const MY_CONST_GLOBAL_ARRAY[] = {1,2,3};{{$}} int * MyGlobal_Ptr;// -> ok +int * my_second_global_Ptr; +// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'my_second_global_Ptr' +// CHECK-FIXES: {{^}}int * MySecondGlobal_Ptr;{{$}} int * const MyConstantGlobalPointer = nullptr; // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global constant pointer 'MyConstantGlobalPointer' // CHECK-FIXES: {{^}}int * const MY_CONSTANT_GLOBAL_POINTER_Ptr = nullptr;{{$}} Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -407,6 +407,8 @@ static std::string fixupWithStyle(StringRef Name, const IdentifierNamingCheck::NamingStyle &Style) { + Name.consume_front(Style.Prefix); + Name.consume_back(Style.Suffix); const std::string Fixed = fixupWithCase( Name, Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase)); StringRef Mid = StringRef(Fixed).trim("_");
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits