isuckatcs wrote:

@PiotrZSL 

> What about 'false' ?

In both cases if `false` is a keyword or an undefined macro, it evaluates to 
`false`, so I don't find that misleading or the source of a hard-to debug 
issue, so I don't see a reason to emit a warning for that.

> This issue is detected by -Wundef compiler warning in both clang and gcc.

This is a nice catch, I didn't know about it 😅. IIUC, `-Wundef` warns every 
time an undefined macro is expanded, but I don't see the warning and this check 
being mutually exclusive. 

I can imagine cases when the macro is expected to be defined in a compiler 
argument, e.g.: `-DLOG_LEVEL=2`. In such cases the program might contain code 
like `#if LOG_LEVEL == 1`, `#if LOG_LEVEL == 2`, etc. In this case using 
`-Wundef` might be undesireable, because it would emit multiple warnings that 
the developers are aware of.

> 2. Create check that forbids usage of true/false in processor as an 
> non-portable thing (could be in portability category)
> 3. Extracting 'true' case from -Wundef into separate warning like -Wundef-true

I like both of these approaches, though I prefer the 2. one because even if we 
extract `-Wundef-true`, `gcc` won't have the same option. How about doing 
option 2. and moving the check to `portability` then?

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

Reply via email to