[PATCH] D124726: Suggest typoed directives in preprocessor conditionals

Aaron Ballman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 16 10:17:18 PDT 2022


aaron.ballman added a comment.

In D124726#3516346 <https://reviews.llvm.org/D124726#3516346>, @nathanchance wrote:

> I see an instance of this warning in the Linux kernel due to the "Now, for unknown directives inside a skipped conditional block, we diagnose the unknown directive as a warning if it is sufficiently similar to a directive specific to preprocessor conditional blocks" part of this change:
>
>   arch/x86/crypto/aesni-intel_asm.S:532:8: warning: invalid preprocessing directive, did you mean '#if'? [-Wunknown-directives]
>                                           # in in order to perform
>                                             ^
>   arch/x86/crypto/aesni-intel_asm.S:547:8: warning: invalid preprocessing directive, did you mean '#if'? [-Wunknown-directives]
>                                           # in in order to perform
>                                             ^
>   2 warnings generated.

Oh wow, that's a really neat one!

> This is a comment within an assembler file that will be preprocessed (this is a 32-bit x86 build and the block is guarded by `#ifdef __x86_64__` on line 500):
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/crypto/aesni-intel_asm.S?h=v5.18-rc7#n532
>
> Is there anything that can be done to improve this heuristic for this case? I can try to push a patch to change the comment style for this one instance but I always worry that a warning of this nature will appear in the future and result in the kernel disabling this warning entirely.

Ah, and we don't get an error for those because of special logic: https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/PPDirectives.cpp#L1243 and it looks like we may need similar logic before issuing the warnings as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124726/new/

https://reviews.llvm.org/D124726



More information about the llvm-commits mailing list