Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: lib/CodeGen/CGException.cpp

Issue 184973004: Prep for merging 3.4: Undo changes from 3.3 branch (Closed) Base URL: http://git.chromium.org/native_client/pnacl-clang.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/Basic/Targets.cpp ('k') | lib/CodeGen/CodeGenFunction.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===--- CGException.cpp - Emit LLVM Code for C++ exceptions --------------===// 1 //===--- CGException.cpp - Emit LLVM Code for C++ exceptions --------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This contains code dealing with C++ exception related code generation. 10 // This contains code dealing with C++ exception related code generation.
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 412 }
413 413
414 llvm::Value *CodeGenFunction::getExceptionFromSlot() { 414 llvm::Value *CodeGenFunction::getExceptionFromSlot() {
415 return Builder.CreateLoad(getExceptionSlot(), "exn"); 415 return Builder.CreateLoad(getExceptionSlot(), "exn");
416 } 416 }
417 417
418 llvm::Value *CodeGenFunction::getSelectorFromSlot() { 418 llvm::Value *CodeGenFunction::getSelectorFromSlot() {
419 return Builder.CreateLoad(getEHSelectorSlot(), "sel"); 419 return Builder.CreateLoad(getEHSelectorSlot(), "sel");
420 } 420 }
421 421
422 void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E, 422 void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
423 bool KeepInsertionPoint) {
424 if (!E->getSubExpr()) { 423 if (!E->getSubExpr()) {
425 EmitNoreturnRuntimeCallOrInvoke(getReThrowFn(CGM), 424 EmitNoreturnRuntimeCallOrInvoke(getReThrowFn(CGM),
426 ArrayRef<llvm::Value*>()); 425 ArrayRef<llvm::Value*>());
427 426
428 // throw is an expression, and the expression emitters expect us 427 // throw is an expression, and the expression emitters expect us
429 // to leave ourselves at a valid insertion point. 428 // to leave ourselves at a valid insertion point.
430 if (KeepInsertionPoint) 429 EmitBlock(createBasicBlock("throw.cont"));
431 EmitBlock(createBasicBlock("throw.cont"));
432 430
433 return; 431 return;
434 } 432 }
435 433
436 QualType ThrowType = E->getSubExpr()->getType(); 434 QualType ThrowType = E->getSubExpr()->getType();
437 435
438 if (ThrowType->isObjCObjectPointerType()) { 436 if (ThrowType->isObjCObjectPointerType()) {
439 const Stmt *ThrowStmt = E->getSubExpr(); 437 const Stmt *ThrowStmt = E->getSubExpr();
440 const ObjCAtThrowStmt S(E->getExprLoc(), 438 const ObjCAtThrowStmt S(E->getExprLoc(),
441 const_cast<Stmt *>(ThrowStmt)); 439 const_cast<Stmt *>(ThrowStmt));
442 CGM.getObjCRuntime().EmitThrowStmt(*this, S, false); 440 CGM.getObjCRuntime().EmitThrowStmt(*this, S, false);
443 // This will clear insertion point which was not cleared in 441 // This will clear insertion point which was not cleared in
444 // call to EmitThrowStmt. 442 // call to EmitThrowStmt.
445 if (KeepInsertionPoint) 443 EmitBlock(createBasicBlock("throw.cont"));
446 EmitBlock(createBasicBlock("throw.cont"));
447 return; 444 return;
448 } 445 }
449 446
450 // Now allocate the exception object. 447 // Now allocate the exception object.
451 llvm::Type *SizeTy = ConvertType(getContext().getSizeType()); 448 llvm::Type *SizeTy = ConvertType(getContext().getSizeType());
452 uint64_t TypeSize = getContext().getTypeSizeInChars(ThrowType).getQuantity(); 449 uint64_t TypeSize = getContext().getTypeSizeInChars(ThrowType).getQuantity();
453 450
454 llvm::Constant *AllocExceptionFn = getAllocateExceptionFn(CGM); 451 llvm::Constant *AllocExceptionFn = getAllocateExceptionFn(CGM);
455 llvm::CallInst *ExceptionPtr = 452 llvm::CallInst *ExceptionPtr =
456 EmitNounwindRuntimeCall(AllocExceptionFn, 453 EmitNounwindRuntimeCall(AllocExceptionFn,
(...skipping 17 matching lines...) Expand all
474 Dtor = llvm::ConstantExpr::getBitCast(Dtor, Int8PtrTy); 471 Dtor = llvm::ConstantExpr::getBitCast(Dtor, Int8PtrTy);
475 } 472 }
476 } 473 }
477 if (!Dtor) Dtor = llvm::Constant::getNullValue(Int8PtrTy); 474 if (!Dtor) Dtor = llvm::Constant::getNullValue(Int8PtrTy);
478 475
479 llvm::Value *args[] = { ExceptionPtr, TypeInfo, Dtor }; 476 llvm::Value *args[] = { ExceptionPtr, TypeInfo, Dtor };
480 EmitNoreturnRuntimeCallOrInvoke(getThrowFn(CGM), args); 477 EmitNoreturnRuntimeCallOrInvoke(getThrowFn(CGM), args);
481 478
482 // throw is an expression, and the expression emitters expect us 479 // throw is an expression, and the expression emitters expect us
483 // to leave ourselves at a valid insertion point. 480 // to leave ourselves at a valid insertion point.
484 if (KeepInsertionPoint) 481 EmitBlock(createBasicBlock("throw.cont"));
485 EmitBlock(createBasicBlock("throw.cont"));
486 } 482 }
487 483
488 void CodeGenFunction::EmitStartEHSpec(const Decl *D) { 484 void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
489 if (!CGM.getLangOpts().CXXExceptions) 485 if (!CGM.getLangOpts().CXXExceptions)
490 return; 486 return;
491 487
492 const FunctionDecl* FD = dyn_cast_or_null<FunctionDecl>(D); 488 const FunctionDecl* FD = dyn_cast_or_null<FunctionDecl>(D);
493 if (FD == 0) 489 if (FD == 0)
494 return; 490 return;
495 const FunctionProtoType *Proto = FD->getType()->getAs<FunctionProtoType>(); 491 const FunctionProtoType *Proto = FD->getType()->getAs<FunctionProtoType>();
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 break; 1672 break;
1677 } 1673 }
1678 } 1674 }
1679 1675
1680 Builder.CreateUnreachable(); 1676 Builder.CreateUnreachable();
1681 1677
1682 Builder.restoreIP(SavedIP); 1678 Builder.restoreIP(SavedIP);
1683 1679
1684 return EHResumeBlock; 1680 return EHResumeBlock;
1685 } 1681 }
OLDNEW
« no previous file with comments | « lib/Basic/Targets.cpp ('k') | lib/CodeGen/CodeGenFunction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698