[PATCH] D81003: [clang] SequenceChecker: Also visit default arguments.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 16 17:33:35 PDT 2020


rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Seems reasonable. I think we need similar handling for `CXXDefaultInitExpr`, for cases like this:

  int a;
  struct X { int b = ++a; };
  int c = X{} + a;



================
Comment at: clang/test/SemaCXX/warn-unsequenced.cpp:282-283
+  void test() {
+    // TODO: Consider adding a remark indicating the function call where
+    // the default argument was used.
+    int b;
----------------
I think it's important that we handle this in the near future (though I don't mind if you'd like to submit this patch as-is and deal with this as a follow-on). For a case like:

```
void f(int, int = a++);
// ... some time later ...
f(a);
```

... a warning that only gives the location of the default argument is not useful. We need to show both locations (and potentially a path through multiple default arguments, I suppose; yuck).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81003





More information about the cfe-commits mailing list