[PATCH] D67740: [Consumed] Refactor and improve diagnostics

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 19 12:54:26 PDT 2019


dblaikie added a comment.

Looks like this might benefit from being split into independent changes - the work related to templates (I haven't looked closely, but I assume that's fairly indivisible) and the work related to other diagnostics seems fairly separable - and maybe there's other pieces too.



================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:3234
+  "consumed analysis attribute is attached to a "
+  "%select{static method|constructor}0 of class '%1'">,
+  InGroup<Consumed>, DefaultIgnore;
----------------
"member function" would be more correct than "method" here (the diagnostics in this file using the word "method" are mostly for Objective C things)

Are there other diagnostics that are similar? (like maybe function "const" - which can't be on non-member, static member, or ctors - wouldn't that be the same here? Where's the failure path for a non-member (free) function? Could it be unified with the static member/ctor case you're adding?)

Ah, looks like in Attr.td these attributes could be flagged "NonStaticCXXMethod" rather than "CXXMethod" - perhaps that narrower classification wasn't available when this was originally implemented. (then, I think, the attribute parsing logic will do the job of warning about the misuse and ignoring the attribute entirely)


================
Comment at: lib/Sema/SemaDeclAttr.cpp:1237-1240
+    else if (auto *CX = dyn_cast<CXXConstructorDecl>(X))
+      return CX->getThisType()->getPointeeType();
+    else
+      return cast<FunctionDecl>(X)->getCallResultType();
----------------
Drop the else-after-return https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return


Repository:
  rC Clang

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

https://reviews.llvm.org/D67740





More information about the cfe-commits mailing list