[cfe-dev] [clang-tidy] Some possible contributions

Richard via cfe-dev cfe-dev at lists.llvm.org
Wed Dec 16 13:42:39 PST 2015


[Please reply *only* to the list and do not include my email directly
in the To: or Cc: of your reply; otherwise I will not see your reply.
Thanks.]

In article <CAC8rT1_WHgg4wE0Tn2s-GqWSZ_tA5UJYF=sSpBh0c+QoGu93zw at mail.gmail.com>,
    Firat Kasmis via cfe-dev <cfe-dev at lists.llvm.org> writes:

> I just improved and simplified the code. Now auto, decltype
> and initializer_list work too. As you can see in the example, auto is
> automatically transformed into its deduced type (there is a way to keep the
> auto keyword) and long int will get long. An additional if-statement would
> change both behavior if you like.
> 
> Now, you only need the DeclarationTransformer: http://pastebin.com/Luu1i9s3
> Example before and after: http://pastebin.com/KnrzNWnM ->
> http://pastebin.com/rLmPZRxP
> 
> There is always a simple solution! :-)

Awesome!

A couple other things to try:

- C++11 brace initialization

    std::vector<std::string> s{"foo"s, "bar"s}, t{"foo"s}, u;
=>
    std::vector<std::string> s{"foo"s, "bar"s};
    std::vector<std::string> t{"foo"s};
    std::vector<std::string> u;

- function declarations

    void f(int), g(int, float);
=>
    void f(int);
    void g(int, float);

- pointers to functions

    void gg(int, float);
    void (*f)(int), (*g)(int, float) = gg;
=>
    void gg(int, float);
    void (*f)(int);
    void (*g)(int, float) = gg;

- pointers to member data

    struct S { int a; const int b; };
	int S::*p = &S::a, S::* const q = &S::a;
	const int S::*r = &S::b, S::*t;
=>
    struct S { int a; const int b; };
	int S::*p = &S::a;
	int S::* const q = &S::a;
	const int S::*r = &S::b;
	const int S::*t;

- pointers to member functions

    struct S { int f(); };
	int (S::*p)() = &S::f, (S::*q)();
=>
    struct S { int f(); };
	int (S::*p)() = &S::f;
	int (S::*q)();

I haven't looked at your implementation to specifically see if any of
these are a problem, but in my experience these more "exotic" types
are often a weak spot in refactoring tools.  clang tooling
infrastructure tends to do a little better here because it's a real
parser.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>



More information about the cfe-dev mailing list