Author: Zeyi Xu
Date: 2026-09-04T21:29:45+08:00
New Revision: c8391ec76e50dbb353acf1649142ef8f35e174d5

URL: 
https://github.com/llvm/llvm-project/commit/c8391ec76e50dbb353acf1649142ef8f35e174d5
DIFF: 
https://github.com/llvm/llvm-project/commit/c8391ec76e50dbb353acf1649142ef8f35e174d5.diff

LOG: [clang-tidy] Fix renaming parameter packs in `sizeof...` expressions 
(#219155)

Record parameter pack usages held by `SizeOfPackExpr` in the common
renamer visitor. This ensures that declarations and `sizeof...`
references are renamed together.

Closes #219154

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
    clang-tools-extra/docs/ReleaseNotes.md
    clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index 943c21a14c6d9..7b984891803e5 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -276,6 +276,11 @@ class RenamerClangTidyVisitor
     return true;
   }
 
+  bool VisitSizeOfPackExpr(SizeOfPackExpr *SizeOfPack) {
+    Check->addUsage(SizeOfPack->getPack(), SizeOfPack->getPackLoc(), SM);
+    return true;
+  }
+
   bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc Loc) {
     if (const NestedNameSpecifier Spec = Loc.getNestedNameSpecifier();
         Spec.getKind() == NestedNameSpecifier::Kind::Namespace) {

diff  --git a/clang-tools-extra/docs/ReleaseNotes.md 
b/clang-tools-extra/docs/ReleaseNotes.md
index bb3fe614f3564..70dd45eb3297c 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -216,6 +216,9 @@ infrastructure are described first, followed by 
tool-specific sections.
   - Fixed {option}`DefaultHungarianPrefix` being incorrectly diagnosed as an
     invalid option.
 
+  - Fixed invalid fixes when renaming parameter packs used in `sizeof...`
+    expressions.
+
   - Added the {option}`TypedefInheritAnonTagConfig`, which checks a
     typedef or type alias that provides the only name of an otherwise unnamed
     tag, such as `typedef enum {} MyEnum;`, against the style configured for

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
index f0a72ee31bc21..d00235aa6f28f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
@@ -512,6 +512,8 @@ void Global_Fun(TYPE_parameters... PARAMETER_PACK) {
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global 
function 'Global_Fun'
 // CHECK-MESSAGES: :[[@LINE-2]]:36: warning: invalid case style for parameter 
pack 'PARAMETER_PACK'
 // CHECK-FIXES: void GlobalFun(typeParameters_t... parameterPack) {
+    (void)sizeof...(PARAMETER_PACK);
+// CHECK-FIXES: (void)sizeof...(parameterPack);
     global_function(1, 2);
 // CHECK-FIXES: GlobalFunction(1, 2);
     FOO_bar = Global_variable;


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to