aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/InitPreprocessor.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2024-05-20 18:43:13 -0700
committerGitHub <noreply@github.com>2024-05-20 18:43:13 -0700
commitd1aca0ae2e0c52298966e35e4312e21045d4c6e4 (patch)
tree717da6bb2c88baefaac78b461b2efbaba2141b4a /clang/lib/Frontend/InitPreprocessor.cpp
parent45968da95d8959a7c4ca7d56f501bb12de413fcc (diff)
downloadllvm-d1aca0ae2e0c52298966e35e4312e21045d4c6e4.zip
llvm-d1aca0ae2e0c52298966e35e4312e21045d4c6e4.tar.gz
llvm-d1aca0ae2e0c52298966e35e4312e21045d4c6e4.tar.bz2
[WebAssembly] Define __WASM_EXCEPTIONS__ for -fwasm-exceptions (#92604)
When using other specific exception options in Clang, such as `-fseh-exceptions` or `-fsjlj-exceptions`, Clang defines a corresponding preprocessor such as `-D__USING_SJLJ_EXCEPTIONS__`. Emscripten does that in our own build system: https://github.com/emscripten-core/emscripten/blob/7dcd7f40749918e141dc33397d2f4311dd80637a/tools/system_libs.py#L1577-L1578 But to make Wasm EH usable in non-Emscripten toolchain, this has to be defined somewhere else. This PR makes Wasm EH consistent with other exception scheme by letting it defined by Clang depending on the exception option. We have been using `__USING_WASM_EXCEPTIONS__` in our current library code, but this changes it to `__WASM_EXCEPTIONS__` for its conciseness, and I will update other parts of LLVM as follow-ups. This does not break anything currently working, because we have not been defining anything in Clang so far.
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
-rw-r--r--clang/lib/Frontend/InitPreprocessor.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index c1d2094..68760e0 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -1006,6 +1006,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
else if (LangOpts.hasDWARFExceptions() &&
(TI.getTriple().isThumb() || TI.getTriple().isARM()))
Builder.defineMacro("__ARM_DWARF_EH__");
+ else if (LangOpts.hasWasmExceptions() && TI.getTriple().isWasm())
+ Builder.defineMacro("__WASM_EXCEPTIONS__");
if (LangOpts.Deprecated)
Builder.defineMacro("__DEPRECATED");