[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 13 09:23:26 PDT 2018


JonasToth added a comment.

Please add a test for the same usecase as in Sema.

  template <typename T>
  struct SizeIndicator {
    constexpr int value = 8;
  };
  template <>
  struct SizeIndicator<int> {
    constexpr int value = 4;
  };
  template <typename Foo>
  void fooFunction() {
    char Characters[SizeIndicator<Foo>::value];
    void ArrayToPointerDecay(Characters);
  }
  
  template <>
  void fooFunction<int>() {
    char Character[SizeIndicator<int>::value];
    void ArrayToPointerDecay(Characters);
  }

In both cases the mutation must be detected. I assume the function specialization is diagnosed correctly, because everything is resolved.



================
Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:454
+
+  AST =
+      tooling::buildASTFromCode("template <class T> void f() { T x; x.y.z; }");
----------------
Is there already a test for a method from a templated type?

E.g.
```
template <typename T>
struct Foo {
  T x;
  Foo() { int local_int; x(local_int); }
};
```
One can not say that `local_int` could be const or not.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50619





More information about the cfe-commits mailing list