[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 22:53:32 PST 2025
StarOne01 wrote:
> 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.
Sorry for the confusion, I referred to this conditional statement (https://github.com/llvm/llvm-project/blob/main/clang%2Flib%2FSema%2FSemaExpr.cpp#L2525-L2526).
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.
```c
#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.
https://github.com/llvm/llvm-project/pull/123495
More information about the cfe-commits
mailing list