[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed May 14 06:04:13 PDT 2025


AaronBallman wrote:

Oof, sorry for this falling off my radar!

> To demonstrate the uncertain behaviour, let's take a testcase which @shafik suggested.
> 
> When we track the value of *out pointer though the code, we could see that.
> ```
> #define F() 66
> int x = F;  // This 'F' seems make the `*out` non-null
> 
> void g(int);
> 
> void f() {
>     F + 1; // but this 'F' seems to have `*out` ptr null
>     g(F);  // this one makes  the `*out` ptr non-null 
> }
> ```
> 
> Even though F shouldn't have a typocorrection, given the context.

Unfortunately, I'm not certain why you get that behavior. I think we'd have to get into a debugger and really dig around to find out. I would have expected all three uses of `F` there to make `*out` ptr non-null. The only distinction I can think of is that the odd-man-out is a discarded value expression. But why that should matter for typo correction is a mystery to me currently.

https://github.com/llvm/llvm-project/pull/123495


More information about the cfe-commits mailing list