[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D72373#1834591 , @AlexanderLanin 
wrote:

> Updated misc-misplaced-const.c to reflect new output and fixed one wrong col 
> in misc-misplaced-const.cpp - I really do not understand how that happened.
>  Rebased and verified with check-clang-tools.


Thanks! I've committed on your behalf in 
84c5f196370065388779cd96d033c84d31031543 



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-22 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin updated this revision to Diff 239665.
AlexanderLanin added a comment.

Updated misc-misplaced-const.c to reflect new output and fixed one wrong col in 
misc-misplaced-const.cpp - I really do not understand how that happened.
Rebased and verified with check-clang-tools.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373

Files:
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.c
  clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp
@@ -1,20 +1,40 @@
-// RUN: %check_clang_tidy %s misc-misplaced-const %t
-
-typedef int plain_i;
-typedef int *ip;
-typedef const int *cip;
-
-void func() {
-  if (const int *i = 0)
-;
-  if (const plain_i *i = 0)
-;
-  if (const cip i = 0)
-;
-
-  // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: 'i' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
-  if (const ip i = 0)
-;
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DUSING
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DTYPEDEF
+
+#ifdef TYPEDEF
+typedef int int_;
+typedef int *ptr_to_int;
+typedef const int *ptr_to_const_int;
+#endif
+#ifdef USING
+using int_ = int;
+using ptr_to_int = int *;
+using ptr_to_const_int = const int *;
+#endif
+
+void const_pointers() {
+  if (const int *i = 0) {
+i = 0;
+// *i = 0;
+  }
+
+  if (const int_ *i = 0) {
+i = 0;
+// *i = 0;
+  }
+
+  if (const ptr_to_const_int i = 0) {
+// i = 0;
+// *i = 0;
+  }
+
+  // Potentially quite unexpectedly the int can be modified here
+  // CHECK-MESSAGES: :[[@LINE+1]]:24: warning: 'i' declared with a const-qualified {{.*}}; results in the type being 'int *const' instead of 'const int *'
+  if (const ptr_to_int i = 0) {
+//i = 0;
+
+*i = 0;
+  }
 }
 
 template 
@@ -24,8 +44,8 @@
 };
 
 template struct S;
-template struct S; // ok
-template struct S;
+template struct S; // ok
+template struct S;
 
 template 
 struct U {
Index: clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.c
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.c
+++ clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.c
@@ -14,13 +14,13 @@
 
   // Not ok
   const ip i3 = 0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i3' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i3' declared with a const-qualified typedef; results in the type being 'int *const' instead of 'const int *'
 
   ip const i4 = 0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i4' declared with a const-qualified
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i4' declared with a const-qualified typedef; results in the type being 'int *const' instead of 'const int *'
 
   const volatile ip i5 = 0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i5' declared with a const-qualified typedef type; results in the type being 'int *const volatile' instead of 'const int *volatile'
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i5' declared with a const-qualified typedef; results in the type being 'int *const volatile' instead of 'const int *volatile'
 }
 
 void func2(const plain_i *i1,
Index: clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
+++ clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
@@ -3,10 +3,10 @@
 misc-misplaced-const
 
 
-This check diagnoses when a ``const`` qualifier is applied to a ``typedef`` to a
-pointer type rather than to the pointee, because such constructs are often
-misleading to developers because the ``const`` applies to the pointer rather
-than the pointee.
+This check diagnoses when a ``const`` qualifier is applied to a ``typedef``/
+``using`` to a pointer type rather than to the pointee, because such constructs
+are often misleading to developers because the ``const`` applies to the pointer
+rather than the pointee.
 
 For instance, in the following code, the resulting type is ``int *`` ``const``
 rather than ``const int *``:
@@ -14,9 +14,12 @@
 .. code-block:: c++
 
   typedef int *int_ptr;
-  void f(const int_ptr ptr);
+  void f(const int_ptr ptr) {
+*ptr = 0; // potentially quite unexpectedly the int can be modified here
+ptr = 0; // does not 

[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D72373#1833569 , @thakis wrote:

> Looks like this breaks tests: http://45.33.8.238/linux/8102/step_8.txt


I reverted in e3b15ed376f3753d2a4e16281f8230e4ffed41ba 
. 
@AlexanderLanin, do you mind taking a look?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-22 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests: http://45.33.8.238/linux/8102/step_8.txt


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit on your behalf in ecc7dae50c41bc8a129a158ecf0ae0270126505c 
. Sorry 
about the delay in committing and thank you for the patch!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-22 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin added a comment.

ping

> Could someone commit this? As I can not.
>  Alexander Lanin 




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-16 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin added a comment.

Thanks for the review!

Could someone commit this? As I can not.
Alexander Lanin 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!

In D72373#1809080 , @AlexanderLanin 
wrote:

> FIX-IT isn't quite that obvious. Some options:
>
> - look for other typedef which contains the same as const
> - create new typedef/using
> - remove "*" from typedef and adjust all usage accordingly. Implies removing 
> "Ptr" suffix.


I think we can punt on the fixit for now as this is a good incremental 
improvement. Another possible option is to remove the `const` from the 
declaration using the typedef (there may be situations where you cannot add a 
new typedef or modify the existing one because the typedef is in a system 
header).




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp:2
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DUSING
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DTYPEDEF
+

AlexanderLanin wrote:
> is this good practice? I didn't want to duplicate everything here.
Yes, this is a good way to reduce duplication.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp:32
+  // Potentially quite unexpectedly the int can be modified here
+  // CHECK-MESSAGES: :[[@LINE+1]]:23: warning: 'i' declared with a 
const-qualified {{.*}}; results in the type being 'int *const' instead of 
'const int *'
+  if (const ptr_to_int i = 0) {

AlexanderLanin wrote:
> not sure how to remove the regex here without duplicating everything
I think the regex is reasonable enough.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-12 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin updated this revision to Diff 237558.
AlexanderLanin marked an inline comment as done.
AlexanderLanin added a comment.

Updated revision with llvm_unreachable


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373

Files:
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp
@@ -1,20 +1,40 @@
-// RUN: %check_clang_tidy %s misc-misplaced-const %t
-
-typedef int plain_i;
-typedef int *ip;
-typedef const int *cip;
-
-void func() {
-  if (const int *i = 0)
-;
-  if (const plain_i *i = 0)
-;
-  if (const cip i = 0)
-;
-
-  // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: 'i' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
-  if (const ip i = 0)
-;
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DUSING
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DTYPEDEF
+
+#ifdef TYPEDEF
+typedef int int_;
+typedef int *ptr_to_int;
+typedef const int *ptr_to_const_int;
+#endif
+#ifdef USING
+using int_ = int;
+using ptr_to_int = int *;
+using ptr_to_const_int = const int *;
+#endif
+
+void const_pointers() {
+  if (const int *i = 0) {
+i = 0;
+// *i = 0;
+  }
+
+  if (const int_ *i = 0) {
+i = 0;
+// *i = 0;
+  }
+
+  if (const ptr_to_const_int i = 0) {
+// i = 0;
+// *i = 0;
+  }
+
+  // Potentially quite unexpectedly the int can be modified here
+  // CHECK-MESSAGES: :[[@LINE+1]]:23: warning: 'i' declared with a const-qualified {{.*}}; results in the type being 'int *const' instead of 'const int *'
+  if (const ptr_to_int i = 0) {
+//i = 0;
+
+*i = 0;
+  }
 }
 
 template 
@@ -24,8 +44,8 @@
 };
 
 template struct S;
-template struct S; // ok
-template struct S;
+template struct S; // ok
+template struct S;
 
 template 
 struct U {
Index: clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
+++ clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
@@ -3,10 +3,10 @@
 misc-misplaced-const
 
 
-This check diagnoses when a ``const`` qualifier is applied to a ``typedef`` to a
-pointer type rather than to the pointee, because such constructs are often
-misleading to developers because the ``const`` applies to the pointer rather
-than the pointee.
+This check diagnoses when a ``const`` qualifier is applied to a ``typedef``/
+``using`` to a pointer type rather than to the pointee, because such constructs
+are often misleading to developers because the ``const`` applies to the pointer
+rather than the pointee.
 
 For instance, in the following code, the resulting type is ``int *`` ``const``
 rather than ``const int *``:
@@ -14,9 +14,12 @@
 .. code-block:: c++
 
   typedef int *int_ptr;
-  void f(const int_ptr ptr);
+  void f(const int_ptr ptr) {
+*ptr = 0; // potentially quite unexpectedly the int can be modified here
+ptr = 0; // does not compile
+  }
 
-The check does not diagnose when the underlying ``typedef`` type is a pointer to
-a ``const`` type or a function pointer type. This is because the ``const``
-qualifier is less likely to be mistaken because it would be redundant (or
-disallowed) on the underlying pointee type.
+The check does not diagnose when the underlying ``typedef``/``using`` type is a
+pointer to a ``const`` type or a function pointer type. This is because the
+``const`` qualifier is less likely to be mistaken because it would be redundant
+(or disallowed) on the underlying pointee type.
Index: clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
@@ -17,13 +17,16 @@
 namespace misc {
 
 void MisplacedConstCheck::registerMatchers(MatchFinder *Finder) {
+  auto NonConstAndNonFunctionPointerType = hasType(pointerType(unless(
+  pointee(anyOf(isConstQualified(), ignoringParens(functionType()));
+
   Finder->addMatcher(
-  valueDecl(hasType(isConstQualified()),
-hasType(typedefType(hasDeclaration(
-typedefDecl(hasType(pointerType(unless(pointee(
-anyOf(isConstQualified(),
-  ignoringParens(functionType(
-.bind("typedef")
+  valueDecl(
+  hasType(isConstQu

[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-07 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp:64
+  } else {
+assert(0 && "This should not be reachable");
+  }

llvm_unreachable


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-07 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin added a comment.

looking at this at least many are indeed valid results: F11183407: 
partial-misc-misplaced-const-llvm-output.zip 

I guess false positives could be reduced by eliminating those cases where the 
variables are (intentionally) modified.

FIX-IT isn't quite that obvious. Some options:

- look for other typedef which contains the same as const
- create new typedef/using
- remove "*" from typedef and adjust all usage accordingly. Implies removing 
"Ptr" suffix.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp:2
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DUSING
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DTYPEDEF
+

is this good practice? I didn't want to duplicate everything here.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp:32
+  // Potentially quite unexpectedly the int can be modified here
+  // CHECK-MESSAGES: :[[@LINE+1]]:23: warning: 'i' declared with a 
const-qualified {{.*}}; results in the type being 'int *const' instead of 
'const int *'
+  if (const ptr_to_int i = 0) {

not sure how to remove the regex here without duplicating everything


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72373/new/

https://reviews.llvm.org/D72373



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-07 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin created this revision.
AlexanderLanin added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72373

Files:
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp
@@ -1,20 +1,40 @@
-// RUN: %check_clang_tidy %s misc-misplaced-const %t
-
-typedef int plain_i;
-typedef int *ip;
-typedef const int *cip;
-
-void func() {
-  if (const int *i = 0)
-;
-  if (const plain_i *i = 0)
-;
-  if (const cip i = 0)
-;
-
-  // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: 'i' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
-  if (const ip i = 0)
-;
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DUSING
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DTYPEDEF
+
+#ifdef TYPEDEF
+typedef int int_;
+typedef int *ptr_to_int;
+typedef const int *ptr_to_const_int;
+#endif
+#ifdef USING
+using int_ = int;
+using ptr_to_int = int *;
+using ptr_to_const_int = const int *;
+#endif
+
+void const_pointers() {
+  if (const int *i = 0) {
+i = 0;
+// *i = 0;
+  }
+
+  if (const int_ *i = 0) {
+i = 0;
+// *i = 0;
+  }
+
+  if (const ptr_to_const_int i = 0) {
+// i = 0;
+// *i = 0;
+  }
+
+  // Potentially quite unexpectedly the int can be modified here
+  // CHECK-MESSAGES: :[[@LINE+1]]:23: warning: 'i' declared with a const-qualified {{.*}}; results in the type being 'int *const' instead of 'const int *'
+  if (const ptr_to_int i = 0) {
+//i = 0;
+
+*i = 0;
+  }
 }
 
 template 
@@ -24,8 +44,8 @@
 };
 
 template struct S;
-template struct S; // ok
-template struct S;
+template struct S; // ok
+template struct S;
 
 template 
 struct U {
Index: clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
+++ clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
@@ -3,10 +3,10 @@
 misc-misplaced-const
 
 
-This check diagnoses when a ``const`` qualifier is applied to a ``typedef`` to a
-pointer type rather than to the pointee, because such constructs are often
-misleading to developers because the ``const`` applies to the pointer rather
-than the pointee.
+This check diagnoses when a ``const`` qualifier is applied to a ``typedef``/
+``using`` to a pointer type rather than to the pointee, because such constructs
+are often misleading to developers because the ``const`` applies to the pointer
+rather than the pointee.
 
 For instance, in the following code, the resulting type is ``int *`` ``const``
 rather than ``const int *``:
@@ -14,9 +14,12 @@
 .. code-block:: c++
 
   typedef int *int_ptr;
-  void f(const int_ptr ptr);
+  void f(const int_ptr ptr) {
+*ptr = 0; // potentially quite unexpectedly the int can be modified here
+ptr = 0; // does not compile
+  }
 
-The check does not diagnose when the underlying ``typedef`` type is a pointer to
-a ``const`` type or a function pointer type. This is because the ``const``
-qualifier is less likely to be mistaken because it would be redundant (or
-disallowed) on the underlying pointee type.
+The check does not diagnose when the underlying ``typedef``/``using`` type is a
+pointer to a ``const`` type or a function pointer type. This is because the
+``const`` qualifier is less likely to be mistaken because it would be redundant
+(or disallowed) on the underlying pointee type.
Index: clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
@@ -17,13 +17,16 @@
 namespace misc {
 
 void MisplacedConstCheck::registerMatchers(MatchFinder *Finder) {
+  auto NonConstAndNonFunctionPointerType = hasType(pointerType(unless(
+  pointee(anyOf(isConstQualified(), ignoringParens(functionType()));
+
   Finder->addMatcher(
-  valueDecl(hasType(isConstQualified()),
-hasType(typedefType(hasDeclaration(
-typedefDecl(hasType(pointerType(unless(pointee(
-anyOf(isConstQualified(),
-  ignoringParens(functionType(
-.bind("typedef")
+  valueDecl(
+  hasType(isConstQualified()),
+  hasType(type