catch(…)正在吞噬xcode llvm 3.0中的所有其他捕获 我试图让GoogleTest运行在我的C++项目上,其中的一部分涉及使用 EXPREFION(语句,ExpEdEdION异常);代码>。我正在使用选择了“Apple LLVM编译器3.0”的XCode。所有这些都在雪豹10.6.8,XCode 4.2上

catch(…)正在吞噬xcode llvm 3.0中的所有其他捕获 我试图让GoogleTest运行在我的C++项目上,其中的一部分涉及使用 EXPREFION(语句,ExpEdEdION异常);代码>。我正在使用选择了“Apple LLVM编译器3.0”的XCode。所有这些都在雪豹10.6.8,XCode 4.2上,c++,xcode,unit-testing,llvm,clang++,C++,Xcode,Unit Testing,Llvm,Clang++,即使使用显式的伪caseEXPECT\u-THROW(THROW std::runtime\u error(),std::runtime\u error),我也无法通过这些测试 将宏(从gtest/internal/gtest internal.h:1114 gtest_TEST_THROW_)扩展到我自己之后 bool gtest_caught_expected = false; try { // GTEST_SUPPRESS_UNREACHABLE_CODE_

即使使用显式的伪case
EXPECT\u-THROW(THROW std::runtime\u error(),std::runtime\u error),我也无法通过这些测试

将宏(从gtest/internal/gtest internal.h:1114 gtest_TEST_THROW_)扩展到我自己之后

    bool gtest_caught_expected = false;
    try {
        // GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement);
        throw std::runtime_error("sigh");
    }
    // catch (expected_exception const&) {
    catch (std::runtime_error const& e){
        std::cout << "const ref caught" << std::endl;
        gtest_caught_expected = true;
    }
    // added by me to check it wasn't a const& issue
    catch (std::runtime_error e){
        std::cout << "type caught" << std::endl;
        gtest_caught_expected = true;
    }
    catch (...) {
        //gtest_msg.value =
        // "Expected: " #statement " throws an exception of type "
        //#expected_exception ".\n  Actual: it throws a different type.";
        //goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__);
        std::cout << "unknown caught" << std::endl;         
    }
bool gtest\u capture\u expected=false;
试一试{
//GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_lower_(声明);
抛出std::运行时_错误(“叹息”);
}
//捕获(应为异常常量&){
捕获(标准::运行时错误常量&e){
std::cout等待一段时间后,似乎没有已知的修复方法,因此我将按上面的方式发布我的答案。它可能在Xcode 4.3中修复

因此,我还链接了libprofile_rt.dylib,以及编译器标志-fprofile arcs-fprofile coverage。删除编译器标志-fprofile arcs可消除此问题。进行注释是因为它会破坏我的覆盖率报告

(与librpofile_rt.a的链接存在相同的问题)


当然,我不是唯一一个看到这一点的人,因为LLVM应该在他们的测试用例中使用googletest?!

不是答案,但您通常应该通过非常量引用,而不是常量引用或值来捕获。您可能想尝试更新版本的clang;自从Apple LLVM compiler 3.0以来,已经有一些重要的异常处理修复程序。是的,走自建之路很有诱惑力,但如果每个人都准备好了,那么融入团队就不太好了。。。