[PATCH] D52791: [Diagnostics] Check for misleading pointer declarations

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 3 17:27:10 PDT 2018


rsmith added a comment.

In https://reviews.llvm.org/D52791#1254559, @rsmith wrote:

>   int *ptr, (a), b, c;
>   


Another possible heuristic for suppressing the check: only warn if there is whitespace before the identifier. So:

  int* a, b; // warning
  int *a, b; // no warning



================
Comment at: lib/Sema/SemaStmt.cpp:82-95
+  for (auto *DI : DS->decls()) {
+    VarDecl *VD = dyn_cast<VarDecl>(DI);
+    if (!VD)
+      continue;
+
+    if (!FirstVarDecl) {
+      if (!VD->getType()->isPointerType())
----------------
This is an inappropriate way of performing the check. Instead, you should look at the syntactic form of the declarator while parsing it.


https://reviews.llvm.org/D52791





More information about the cfe-commits mailing list