r190809 - Emit an error when attempting to generate IR for SEH __try

Reid Kleckner reid at kleckner.net
Mon Sep 16 14:46:31 PDT 2013


Author: rnk
Date: Mon Sep 16 16:46:30 2013
New Revision: 190809

URL: http://llvm.org/viewvc/llvm-project?rev=190809&view=rev
Log:
Emit an error when attempting to generate IR for SEH __try

Currently we silently omit the code in the try and finally bodies, which
is pretty bad.  This way we fail loudly.

Added:
    cfe/trunk/test/CodeGen/exceptions-seh.c
Modified:
    cfe/trunk/lib/CodeGen/CGException.cpp
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=190809&r1=190808&r2=190809&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Mon Sep 16 16:46:30 2013
@@ -1697,3 +1697,7 @@ llvm::BasicBlock *CodeGenFunction::getEH
 
   return EHResumeBlock;
 }
+
+void CodeGenFunction::EmitSEHTryStmt(const SEHTryStmt &S) {
+  CGM.ErrorUnsupported(&S, "SEH __try");
+}

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=190809&r1=190808&r2=190809&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Mon Sep 16 16:46:30 2013
@@ -168,8 +168,9 @@ void CodeGenFunction::EmitStmt(const Stm
     break;
   case Stmt::CXXForRangeStmtClass:
     EmitCXXForRangeStmt(cast<CXXForRangeStmt>(*S));
+    break;
   case Stmt::SEHTryStmtClass:
-    // FIXME Not yet implemented
+    EmitSEHTryStmt(cast<SEHTryStmt>(*S));
     break;
   }
 }

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=190809&r1=190808&r2=190809&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Sep 16 16:46:30 2013
@@ -1838,6 +1838,7 @@ public:
   void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);
 
   void EmitCXXTryStmt(const CXXTryStmt &S);
+  void EmitSEHTryStmt(const SEHTryStmt &S);
   void EmitCXXForRangeStmt(const CXXForRangeStmt &S);
 
   llvm::Function *EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K);

Added: cfe/trunk/test/CodeGen/exceptions-seh.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh.c?rev=190809&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/exceptions-seh.c (added)
+++ cfe/trunk/test/CodeGen/exceptions-seh.c Mon Sep 16 16:46:30 2013
@@ -0,0 +1,18 @@
+// RUN: not %clang_cc1 -triple i686-pc-win32 -fexceptions -fms-extensions -emit-llvm -o - %s 2>&1 | FileCheck %s
+
+// This is a codegen test because we only emit the diagnostic when we start
+// generating code.
+
+int SaveDiv(int numerator, int denominator, int *res) {
+  int myres = 0;
+  __try {
+    myres = numerator / denominator;
+  } __except (1) {
+    return 0;
+  }
+  *res = myres;
+  return 1;
+}
+// CHECK-NOT error
+// CHECK: error: cannot compile this SEH __try yet
+// CHECK-NOT error





More information about the cfe-commits mailing list