[clang] 945ad14 - Revert "[WebAssembly] Handle exception specifications"

Heejin Ahn via cfe-commits cfe-commits at lists.llvm.org
Fri May 15 21:35:30 PDT 2020


Author: Heejin Ahn
Date: 2020-05-15T21:33:44-07:00
New Revision: 945ad141ce63c94b5822d52ad76c49aba906a4b8

URL: https://github.com/llvm/llvm-project/commit/945ad141ce63c94b5822d52ad76c49aba906a4b8
DIFF: https://github.com/llvm/llvm-project/commit/945ad141ce63c94b5822d52ad76c49aba906a4b8.diff

LOG: Revert "[WebAssembly] Handle exception specifications"

This reverts commit bca347508c86647f9d44992275c9a364fbd9fb0d.

This broke clang/test/Misc/warning-flags.c, because the newly added
warning option in this commit didn't have a matching flag.

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticSemaKinds.td
    clang/lib/CodeGen/CGException.cpp
    clang/test/CodeGenCXX/wasm-eh.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c559e3e2dcf3..0fe8b1e6abfc 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1590,8 +1590,6 @@ def err_exception_spec_cycle : Error<
   "exception specification of %0 uses itself">;
 def err_exception_spec_incomplete_type : Error<
   "exception specification needed for member of incomplete class %0">;
-def warn_wasm_dynamic_exception_spec_ignored : Warning<
-  "dynamic exception specifications with types are currently ignored in wasm">;
 
 // C++ access checking
 def err_class_redeclared_with_
diff erent_access : Error<

diff  --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index d821eb2d5595..a5dae1b32e69 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -20,7 +20,6 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtVisitor.h"
-#include "clang/Basic/DiagnosticSema.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Intrinsics.h"
@@ -469,18 +468,6 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
     // encode these in an object file but MSVC doesn't do anything with it.
     if (getTarget().getCXXABI().isMicrosoft())
       return;
-    // 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 (EST == EST_DynamicNone)
-        EHStack.pushTerminate();
-      else
-        CGM.getDiags().Report(D->getLocation(),
-                              diag::warn_wasm_dynamic_exception_spec_ignored)
-            << FD->getExceptionSpecSourceRange();
-      return;
-    }
     unsigned NumExceptions = Proto->getNumExceptions();
     EHFilterScope *Filter = EHStack.pushFilter(NumExceptions);
 
@@ -557,14 +544,6 @@ void CodeGenFunction::EmitEndEHSpec(const Decl *D) {
     // encode these in an object file but MSVC doesn't do anything with it.
     if (getTarget().getCXXABI().isMicrosoft())
       return;
-    // 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 (EST == EST_DynamicNone)
-        EHStack.popTerminate();
-      return;
-    }
     EHFilterScope &filterScope = cast<EHFilterScope>(*EHStack.begin());
     emitFilterDispatchBlock(*this, filterScope);
     EHStack.popFilter();

diff  --git a/clang/test/CodeGenCXX/wasm-eh.cpp b/clang/test/CodeGenCXX/wasm-eh.cpp
index 9bfc41516743..2d56c6bd0cb7 100644
--- a/clang/test/CodeGenCXX/wasm-eh.cpp
+++ b/clang/test/CodeGenCXX/wasm-eh.cpp
@@ -1,6 +1,7 @@
 // REQUIRES: webassembly-registered-target
 // 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 | FileCheck %s
 // RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -S -o - -std=c++11 | FileCheck %s --check-prefix=ASSEMBLY
 
 void may_throw();
 void dont_throw() noexcept;
@@ -384,27 +385,9 @@ void test8() {
 
 // CHECK:   unreachable
 
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -emit-llvm -std=c++11 2>&1 | FileCheck %s --check-prefix=WARNING
-
-// Wasm ignores dynamic exception specifications with types at the moment.
-// Checks if a warning message is printed.
-void test9() throw(int) {
-}
-// WARNING: 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.
-void test10() throw() {
-  throw 3;
-}
-// WARNING: warning: 'test10' has a non-throwing exception specification but can still throw
-// WARNING: function declared non-throwing here
-
 // Here we only check if the command enables wasm exception handling in the
 // backend so that exception handling instructions can be generated in .s file.
 
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -S -o - -std=c++11 | FileCheck %s --check-prefix=ASSEMBLY
-
 // ASSEMBLY: try
 // ASSEMBLY: catch
 // ASSEMBLY: rethrow


        


More information about the cfe-commits mailing list