aheejin created this revision. aheejin added a reviewer: dschuff. Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100. Herald added a project: clang.
In D80061 <https://reviews.llvm.org/D80061> we added warning for exception specifications with types (such as `throw(int)`), but it was enabled every time the target was wasm, which means it warned (and ignored) exception specifications even if wasm EH was not used. This fixes it and we only have the warning when we enable `-fwasm-exceptions`. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D80362 Files: clang/lib/CodeGen/CGException.cpp clang/test/CodeGenCXX/wasm-eh.cpp Index: clang/test/CodeGenCXX/wasm-eh.cpp =================================================================== --- clang/test/CodeGenCXX/wasm-eh.cpp +++ clang/test/CodeGenCXX/wasm-eh.cpp @@ -393,17 +393,18 @@ // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=WARNING-DEFAULT // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -Wwasm-exception-spec -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=WARNING-ON // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -Wno-wasm-exception-spec -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=WARNING-OFF +// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=NOT-WASM-EH -// Wasm ignores dynamic exception specifications with types at the moment. This -// is controlled by -Wwasm-exception-spec, which is on by default. This warning -// can be suppressed with -Wno-wasm-exception-spec. -// Checks if a warning message is correctly printed or not printed depending on -// the options. +// Wasm EH ignores dynamic exception specifications with types at the moment. +// This is controlled by -Wwasm-exception-spec, which is on by default. This +// warning can be suppressed with -Wno-wasm-exception-spec. Checks if a warning +// message is correctly printed or not printed depending on the options. void test9() throw(int) { } // WARNING-DEFAULT: warning: dynamic exception specifications with types are currently ignored in wasm // WARNING-ON: warning: dynamic exception specifications with types are currently ignored in wasm // WARNING-OFF-NOT: warning: dynamic exception specifications with types are currently ignored in wasm +// NOT-WASM-EH-NOT: warning: dynamic exception specifications with types are currently ignored in wasm // Wasm curremtly treats 'throw()' in the same way as 'noexept'. Check if the // same warning message is printed as if when a 'noexcept' function throws. Index: clang/lib/CodeGen/CGException.cpp =================================================================== --- clang/lib/CodeGen/CGException.cpp +++ clang/lib/CodeGen/CGException.cpp @@ -472,7 +472,7 @@ // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In // case of throw with types, we ignore it and print a warning for now. // TODO Correctly handle exception specification in wasm - if (getTarget().getCXXABI() == TargetCXXABI::WebAssembly) { + if (CGM.getLangOpts().WasmExceptions) { if (EST == EST_DynamicNone) EHStack.pushTerminate(); else @@ -560,7 +560,7 @@ // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In // case of throw with types, we ignore it and print a warning for now. // TODO Correctly handle exception specification in wasm - if (getTarget().getCXXABI() == TargetCXXABI::WebAssembly) { + if (CGM.getLangOpts().WasmExceptions) { if (EST == EST_DynamicNone) EHStack.popTerminate(); return;
Index: clang/test/CodeGenCXX/wasm-eh.cpp =================================================================== --- clang/test/CodeGenCXX/wasm-eh.cpp +++ clang/test/CodeGenCXX/wasm-eh.cpp @@ -393,17 +393,18 @@ // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=WARNING-DEFAULT // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -Wwasm-exception-spec -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=WARNING-ON // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -Wno-wasm-exception-spec -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=WARNING-OFF +// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=NOT-WASM-EH -// Wasm ignores dynamic exception specifications with types at the moment. This -// is controlled by -Wwasm-exception-spec, which is on by default. This warning -// can be suppressed with -Wno-wasm-exception-spec. -// Checks if a warning message is correctly printed or not printed depending on -// the options. +// Wasm EH ignores dynamic exception specifications with types at the moment. +// This is controlled by -Wwasm-exception-spec, which is on by default. This +// warning can be suppressed with -Wno-wasm-exception-spec. Checks if a warning +// message is correctly printed or not printed depending on the options. void test9() throw(int) { } // WARNING-DEFAULT: warning: dynamic exception specifications with types are currently ignored in wasm // WARNING-ON: warning: dynamic exception specifications with types are currently ignored in wasm // WARNING-OFF-NOT: warning: dynamic exception specifications with types are currently ignored in wasm +// NOT-WASM-EH-NOT: warning: dynamic exception specifications with types are currently ignored in wasm // Wasm curremtly treats 'throw()' in the same way as 'noexept'. Check if the // same warning message is printed as if when a 'noexcept' function throws. Index: clang/lib/CodeGen/CGException.cpp =================================================================== --- clang/lib/CodeGen/CGException.cpp +++ clang/lib/CodeGen/CGException.cpp @@ -472,7 +472,7 @@ // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In // case of throw with types, we ignore it and print a warning for now. // TODO Correctly handle exception specification in wasm - if (getTarget().getCXXABI() == TargetCXXABI::WebAssembly) { + if (CGM.getLangOpts().WasmExceptions) { if (EST == EST_DynamicNone) EHStack.pushTerminate(); else @@ -560,7 +560,7 @@ // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In // case of throw with types, we ignore it and print a warning for now. // TODO Correctly handle exception specification in wasm - if (getTarget().getCXXABI() == TargetCXXABI::WebAssembly) { + if (CGM.getLangOpts().WasmExceptions) { if (EST == EST_DynamicNone) EHStack.popTerminate(); return;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits