[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

Malcolm Parsons via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 8 13:25:16 PDT 2016


malcolm.parsons added a comment.

In https://reviews.llvm.org/D25316#565378, @Prazek wrote:

> Awesome to see this patch. After this one will make it to upstream, it will be much easier for me to do same with template functions.


I was trying to match such functions:

  varDecl(hasType(type().bind("type")),
          hasInitializer(callExpr(callee(
              functionDecl(isInstantiated(),
                           hasTemplateArgument(
                               0, refersToType(type(equalsBoundNode("type")))))
                  .bind("fn")))))



================
Comment at: test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp:2
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \
+// RUN:   -- -std=c++11
----------------
Prazek wrote:
> What is the difference between this test, and next test?
> The name indicate that it removes star, but I see a lot of test that doesn't use star
> and that seem to be duplicated with the next one.
I could remove the duplicated tests, but the expected fixes are different so I'd like to test with and without star removal.


================
Comment at: test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp:25
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  ll = static_cast<long long>(l);
+  unsigned long long ull = static_cast<unsigned long long>(l);
----------------
Prazek wrote:
> Is it possible to simply fix the double spaces?
The existing modernize-use-auto tests have the same problem.
My codebase is clang-formatted regularly so it doesn't bother me.


https://reviews.llvm.org/D25316





More information about the cfe-commits mailing list