[cfe-commits] r113642 - in /cfe/trunk: lib/Parse/ParseExpr.cpp lib/Sema/SemaExprCXX.cpp test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Fri Sep 10 14:57:27 PDT 2010


Author: cornedbee
Date: Fri Sep 10 16:57:27 2010
New Revision: 113642

URL: http://llvm.org/viewvc/llvm-project?rev=113642&view=rev
Log:
Eli helped me understand how evaluation contexts work.

Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=113642&r1=113641&r2=113642&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Sep 10 16:57:27 2010
@@ -898,6 +898,10 @@
     if (ExpectAndConsume(tok::l_paren,
                          diag::err_expected_lparen_after, "noexcept"))
       return ExprError();
+    // C++ [expr.unary.noexcept]p1:
+    //   The noexcept operator determines whether the evaluation of its operand,
+    //   which is an unevaluated operand, can throw an exception.
+    EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated);
     ExprResult Result = ParseExpression();
     SourceLocation RParen = MatchRHSPunctuation(tok::r_paren, LParen);
     if (!Result.isInvalid())

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=113642&r1=113641&r2=113642&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Sep 10 16:57:27 2010
@@ -3116,11 +3116,6 @@
 
 ExprResult Sema::BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand,
                                       SourceLocation RParen) {
-  // C++ [expr.unary.noexcept]p1:
-  //   The noexcept operator determines whether the evaluation of its operand,
-  //   which is an unevaluated operand, can throw an exception.
-  ExprEvalContexts.back().Context = Unevaluated;
-
   return Owned(new (Context) CXXNoexceptExpr(Context.BoolTy, Operand,
                                              Operand->CanThrow(Context),
                                              KeyLoc, RParen));

Modified: cfe/trunk/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp?rev=113642&r1=113641&r2=113642&view=diff
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp (original)
+++ cfe/trunk/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp Fri Sep 10 16:57:27 2010
@@ -2,14 +2,25 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-pch -o %t-ser.pch -std=c++0x -x c++ %S/ser.h
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S -emit-llvm -std=c++0x -include-pch %t-ser.pch %s -o - | FileCheck %s
 
+struct D {
+  ~D() throw();
+};
+struct E {
+  ~E() throw();
+};
+
 void test() {
   bool b;
   // CHECK: store i8 1, i8* %b, align 1
   b = noexcept(0);
   // CHECK: store i8 0, i8* %b, align 1
   b = noexcept(throw 0);
-  // CHECK: ret i1 true
   b = f1();
-  // CHECK: ret i1 false
   b = f2();
+
+  // CHECK-NOT: call void @_ZN1ED1Ev
+  // CHECK: call void @_ZN1DD1Ev
+  D(), noexcept(E());
 }
+// CHECK: ret i1 true
+// CHECK: ret i1 false





More information about the cfe-commits mailing list