[LLVMdev] clang/g++ frontend: can __cxa_end_catch throw?

Yuri yuri at rawbw.com
Sun Jul 11 21:25:17 PDT 2010


When I compile a piece of C++ with exceptions into .ll I see that gcc 
frontend in some cases calls __cxa_end_catch with 'call' and in other 
cases with 'invoke' with termination in case of exception. clang++ 
always just calls __cxa_end_catch with 'call' instruction.

Which way is correct?

--- c.cpp ---
#include <stdio.h>
#include <stdlib.h>

struct C {
   C();
   ~C();
};

struct E {
   E();
   ~E();
};

void mythrowing1();
void mythrowing2();
void mycatching(E *e);

void myfunc() {
   try {
   C c;
     mythrowing1();
     mythrowing2();
   } catch (E *e) {
     mycatching(e);
   }
}

--- commands ---
/usr/local/llvm/2.7/bin/c++ -O3 -fexceptions -emit-llvm -S -o c-gcc.ll c.cpp
/usr/local/llvm/2.7/bin/clang++ -O3 -fexceptions -emit-llvm -S -o 
c-clang.ll c.cpp




More information about the llvm-dev mailing list