aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
diff options
context:
space:
mode:
authoryronglin <yronglin777@gmail.com>2025-08-18 14:17:35 +0800
committerGitHub <noreply@github.com>2025-08-18 14:17:35 +0800
commite6e874ce8f055f5b8c5d7f8c7fb0afe764d1d350 (patch)
tree361966507919833b34cfd68c418e76c48fcf1a02 /llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
parent145e8aadcaf189a75c6d1648d7e043eb313852a0 (diff)
downloadllvm-e6e874ce8f055f5b8c5d7f8c7fb0afe764d1d350.zip
llvm-e6e874ce8f055f5b8c5d7f8c7fb0afe764d1d350.tar.gz
llvm-e6e874ce8f055f5b8c5d7f8c7fb0afe764d1d350.tar.bz2
[clang] Allow trivial pp-directives before C++ module directive (#153641)
Consider the following code: ```cpp # 1 __FILE__ 1 3 export module a; ``` According to the wording in [P1857R3](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1857r3.html): ``` A module directive may only appear as the first preprocessing tokens in a file (excluding the global module fragment.) ``` and the wording in [[cpp.pre]](https://eel.is/c++draft/cpp.pre#nt:module-file) ``` module-file: pp-global-module-fragment[opt] pp-module group[opt] pp-private-module-fragment[opt] ``` `#` is the first pp-token in the translation unit, and it was rejected by clang, but they really should be exempted from this rule. The goal is to not allow any preprocessor conditionals or most state changes, but these don't fit that. State change would mean most semantically observable preprocessor state, particularly anything that is order dependent. Global flags like being a system header/module shouldn't matter. We should exempt a brunch of directives, even though it violates the current standard wording. In this patch, we introduce a `TrivialDirectiveTracer` to trace the **State change** that described above and propose to exempt the following kind of directive: `#line`, GNU line marker, `#ident`, `#pragma comment`, `#pragma mark`, `#pragma detect_mismatch`, `#pragma clang __debug`, `#pragma message`, `#pragma GCC warning`, `#pragma GCC error`, `#pragma gcc diagnostic`, `#pragma OPENCL EXTENSION`, `#pragma warning`, `#pragma execution_character_set`, `#pragma clang assume_nonnull` and builtin macro expansion. Fixes https://github.com/llvm/llvm-project/issues/145274 --------- Signed-off-by: yronglin <yronglin777@gmail.com>
Diffstat (limited to 'llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp')
0 files changed, 0 insertions, 0 deletions