firolino added a comment.

In https://reviews.llvm.org/D27621#619649, @malcolm.parsons wrote:

> The fixit construction looks overly complicated.
>  All you need to do is change a `,` to a `;` and insert a copy of the type:
>
>   << FixItHint::CreateReplacement(CommaRange, ";")
>   << FixItHint::CreateInsertionFromRange(VarLocation, TypeRange)
>
>
> and insert some whitespace where needed.


I could do CommaRange = findToken(tok:comma) an do a in-place replacment and 
thus, get rid of the workaround part as well. But for the TypeRange, I didn't 
find a proper way to get only the type part. For example, 
getTypeSourceInfo()->getTypeLoc().getSourceRange() for

  const int a(1), b(2);
  int const c(3), d(4);

will be

  const int
  int

I am not able to get the qualifier as well. I even saw something in the source 
like "we do not provide SourceRange for Qualifiers...". I would like to get rid 
of getUserWrittenType, but didn't find a way. It gets also dirty for 
MemberFunctionPointers:

  int S::*p = &S::a, S::* const q = &S::a;
  const int S::*r = &S::b, S::*t;
  int const CS :: * pp = &CS::a, CS::* const qq = &CS::a;

TypeRange will be

  int S
  int S
  int const CS


https://reviews.llvm.org/D27621



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to