[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 12 08:03:32 PST 2025
StarOne01 wrote:
> For example, we don't suggest a correction for this:
> ```
> #define FOO1 12
> int x = FOO;
> ```
> but we do suggest a correction for this:
> ```
> int FOO1 = 12;
> int x = FOO;
> ```
Did thought of that.
> 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.
That's right, i didn't think of `#undef`.
But actually I was sceptical about a different thing.
> If i understand it right, that particular conditional statement should get executed for this:
> ```c int main(){ int var1 = 63; int out = var; }```
> and should be skipped for:
> ```c int main(){ int var1 = 63; int out = notFound; }```
> but the problem is that the conditional statement gets executed for both the cases, so when i put the new check somewhere below it, the control never reaches the new check.
> please correct me if i'm off somewhere :)
This was my actual concern, but this behaviour seems unpredictable, sometimes happens and sometimes doesn't, but in all the cases no identifiers were near to eachother.
https://github.com/llvm/llvm-project/pull/123495
More information about the cfe-commits
mailing list