[PATCH] C++11: noexcept should check whether the expression is a constant expression

Richard Smith richard at metafoo.co.uk
Wed Mar 13 13:38:21 PDT 2013


  Generally speaking, I'd prefer for us to implement the resolution of core issue 1351 rather than patching up our implementation of the broken C++11 rules. However, even the core issue 1351 rules are broken when the callee is a function pointer...


================
Comment at: lib/Sema/SemaExceptionSpec.cpp:864-867
@@ -857,2 +863,6 @@
+  //   expression (5.19),
+  if (isa<CallExpr>(E) && E->isCXX11ConstantExpr(S.getASTContext()))
+    return CT_Cannot;
+
   return FT->isNothrow(S.Context) ? CT_Cannot : CT_Can;
 }
----------------
Please reverse the order of these checks; FT->isNothrow will typically be a much cheaper test.

================
Comment at: lib/Sema/SemaExceptionSpec.cpp:825-831
@@ -824,9 +824,9 @@
                                            bool NullThrows = true) {
   if (!D)
     return NullThrows ? CT_Can : CT_Cannot;
 
   // See if we can get a function type from the decl somehow.
   const ValueDecl *VD = dyn_cast<ValueDecl>(D);
   if (!VD) // If we have no clue what we're calling, assume the worst.
     return CT_Can;
 
----------------
This is not right. We should try to evaluate the call even if we can't resolve it to a particular declaration.

================
Comment at: lib/Sema/SemaExceptionSpec.cpp:850-851
@@ -849,4 +849,4 @@
 
   if (!FT)
     return CT_Can;
 
----------------
Likewise, this should attempt evaluation (although it's not clear to me how this could happen...).


http://llvm-reviews.chandlerc.com/D538



More information about the cfe-commits mailing list