Current completion fix-its approach does not provide OtherOpBase for C code. But we can easily proceed in this case taking the original Base type.
Details
Diff Detail
- Repository
- rC Clang
Event Timeline
It's the responsibility of the caller to provide a corrected expression, this keeps the completion function simpler. I suggest we stick to this contract.
We do something in getLangOpts().CPlusPlus case to create a corrected expression, let's just implement a similar fallback for C at the single callsite that we have (ParsePostfixExpressionSuffix).
I tried that first but did not I find a way just to copy an expression (we basically need the same expr for such case). Do you know how to properly generate a copy of expression or some other way to get the same expression?
It seems Sema::ActOnStartCXXMemberReference only changes expression when overloading for C++'s operator -> is required, otherwise it keeps the same expression. Since C does not have that, we can just leave the expression as is.
So setting CorrectedLHS = LHS for C should do the trick (no need to copy the expression IIUC, it's fine to use the same pointer for both CorrectedLHS and LHS).