AaronBallman wrote:

> > Also, i see the typo correction is unpredictable as I addressed above, is 
> > that a expected behaviour?
> 
> @AaronBallman could you help me with this? I do understand the delayed typo 
> thing but how is that being decided? also, I couldn't find that documented.

For this:
```
#define FOO1() 
void f() {
    int FOO;
    int x = FOO1; // Typo correction to 'FOO' instead of note about 'FOO1()'.
}
```
I believe the issue is because the `CorrectionCandidateCallback` used is 
unaware of macro identifiers (because macros are not declarations and are 
replaced entirely by the time we get to the parser or sema). For example, we 
don't suggest a correction for this:
```
#define FOO1 12
int x = FOO;
```
https://godbolt.org/z/99s8P3vzc
but we do suggest a correction for this:
```
int FOO1 = 12;
int x = FOO;
```
https://godbolt.org/z/v94rjhxY4

I think it will be challenging to support macros in general because we'd have 
to be able to handle `#undef` removing macros that were previously defined, 
etc. I think for right now, it's fine to not have a typo correction.

https://github.com/llvm/llvm-project/pull/123495
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to