aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/test/clang-tidy/checkers/readability
diff options
context:
space:
mode:
authorPiotr Zegar <me@piotrzegar.pl>2023-09-20 21:29:54 +0200
committerGitHub <noreply@github.com>2023-09-20 21:29:54 +0200
commit5d95d27e50c1f5ce4803039d942ff3c25401c77f (patch)
tree7b80c7996e5d61924886d34299f853caaf0c0ac3 /clang-tools-extra/test/clang-tidy/checkers/readability
parent33aa095a8b7741b3f24504c44634dba70c55d6ed (diff)
downloadllvm-5d95d27e50c1f5ce4803039d942ff3c25401c77f.zip
llvm-5d95d27e50c1f5ce4803039d942ff3c25401c77f.tar.gz
llvm-5d95d27e50c1f5ce4803039d942ff3c25401c77f.tar.bz2
[clang-tidy] Fix support for typedefs in readability-identifier-naming (#66835)
Typedef rename were not properly handled when typedef were used behind pointer, or as a part of function type. Additionally because entire function were passed as an source-range, when function started with macro, such change were not marked for a fix. Removed workaround and used proper TypedefTypeLoc instead. Fixes #55156, #54699
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/checkers/readability')
-rw-r--r--clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp26
1 files changed, 26 insertions, 0 deletions
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 3445a21..84bf776 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
@@ -729,3 +729,29 @@ struct forward_declared_as_struct;
class forward_declared_as_struct {
};
+namespace pr55156 {
+
+template<typename> struct Wrap;
+
+typedef enum {
+ VALUE0,
+ VALUE1,
+} ValueType;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: invalid case style for typedef 'ValueType' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}} value_type_t;
+
+typedef ValueType (*MyFunPtr)(const ValueType&, Wrap<ValueType>*);
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for typedef 'MyFunPtr' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}typedef value_type_t (*my_fun_ptr_t)(const value_type_t&, Wrap<value_type_t>*);
+
+#define STATIC_MACRO static
+STATIC_MACRO void someFunc(ValueType a_v1, const ValueType& a_v2) {}
+// CHECK-FIXES: {{^}}STATIC_MACRO void someFunc(value_type_t a_v1, const value_type_t& a_v2) {}
+STATIC_MACRO void someFunc(const ValueType** p_a_v1, ValueType (*p_a_v2)()) {}
+// CHECK-FIXES: {{^}}STATIC_MACRO void someFunc(const value_type_t** p_a_v1, value_type_t (*p_a_v2)()) {}
+STATIC_MACRO ValueType someFunc() {}
+// CHECK-FIXES: {{^}}STATIC_MACRO value_type_t someFunc() {}
+STATIC_MACRO void someFunc(MyFunPtr, const MyFunPtr****) {}
+// CHECK-FIXES: {{^}}STATIC_MACRO void someFunc(my_fun_ptr_t, const my_fun_ptr_t****) {}
+#undef STATIC_MACRO
+}