[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 Feb 12 08:49:05 PST 2025


AaronBallman wrote:

> But actually I was sceptical about a different thing.

Thanks for clarifying!

> > 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 either cases no identifiers were near to eachother.

If you're talking about https://github.com/llvm/llvm-project/blob/cb3498c6704daefc6e5221beb757126765737aa7/clang/lib/Sema/SemaExpr.cpp#L2527, I would expect that condition to be true for both code examples because there is a scope (the body of `main`) and there is a `TypoExpr **` passed in from the caller. Am I looking at the right condition? If so, I'm not certain I understand what's unpredictable yet.


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


More information about the cfe-commits mailing list