c++ - llvm 属性::NoUnwind

标签 c++ exception-handling llvm

我在里面跑 http://llvm.org/demo以下片段:

class X { public: ~X() __attribute((nothrow)); };
void a(X* p);
void nothr() throw();
void b() { try { X x; a(&x); } catch (X* foo) { nothr(); } }

我看到一些调用(例如,对 func_llvm_eh_typeid_for)设置了 Attribute::NoUnwind:

CallInst* int32_71 = CallInst::Create(func_llvm_eh_typeid_for, const_ptr_43, "", label_49);
  int32_71->setCallingConv(CallingConv::C);
  int32_71->setTailCall(false);
  AttrListPtr int32_71_PAL;
  {
   SmallVector<AttributeWithIndex, 4> Attrs;
   AttributeWithIndex PAWI;
   PAWI.Index = 4294967295U; PAWI.Attrs = 0  | Attribute::NoUnwind;
   Attrs.push_back(PAWI);
   int32_71_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());

  }
  int32_71->setAttributes(int32_71_PAL);

由于此调用是使用 CallInst 而不是 InvokeInst 创建的,我认为调用本身不会抛出,因此我想知道在此上下文中 Unwind 属性的用途是什么?

最佳答案

这意味着您不必担心生成异常处理代码或优化,就好像异常可以通过该代码部分传播一样,因为您已经说过它不会。如果一个碰巧通过那里,那么它应该正确传播到程序中的下一个堆栈帧。

关于c++ - llvm 属性::NoUnwind,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7573535/

相关文章:

c++ - #include 的问题,C++

java - 如何在没有 throws 子句的情况下实现在接口(interface)中定义的方法时添加 throws Exception 子句?

objective-c - 使用 LLVM 5 在 Objective-C 的结构中声明枚举

c++ - 在 Windows 上运行紧贴

c++ - 如何从 C++ 代码获取 linux 上的线程 pid?

c++ - 使用其他成员初始化结构体的成员?

C++算法模数

ruby-on-rails - 是否有可以跟踪独特错误的 Rails 库?

python - 如何使用调试信息记录 Python 错误?

xcode - Clang Pragma 综合列表