auxhelper.cc revision 350400
176264Sgreen/* 276264Sgreen * Copyright 2010-2011 PathScale, Inc. All rights reserved. 3255460Sdes * 4255460Sdes * Redistribution and use in source and binary forms, with or without 576264Sgreen * modification, are permitted provided that the following conditions are met: 6197679Sdes * 7158519Sdes * 1. Redistributions of source code must retain the above copyright notice, 876264Sgreen * this list of conditions and the following disclaimer. 9255460Sdes * 10255460Sdes * 2. Redistributions in binary form must reproduce the above copyright notice, 11255386Sdes * this list of conditions and the following disclaimer in the documentation 1276264Sgreen * and/or other materials provided with the distribution. 13255460Sdes * 14255460Sdes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS 15255460Sdes * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16255460Sdes * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17255460Sdes * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18255460Sdes * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19255460Sdes * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20255460Sdes * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21255460Sdes * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22255460Sdes * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 2376264Sgreen * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 2476264Sgreen * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2576264Sgreen */ 26158529Sdes 27158529Sdes/** 28 * aux.cc - Compiler helper functions. 29 * 30 * The functions declared in this file are intended to be called only by code 31 * that is automatically generated by C++ compilers for some common cases. 32 */ 33 34#include <stdlib.h> 35#include "stdexcept.h" 36 37/** 38 * Called to generate a bad cast exception. This function is intended to allow 39 * compilers to insert code generating this exception without needing to 40 * duplicate the code for throwing the exception in every call site. 41 */ 42extern "C" void __cxa_bad_cast() 43{ 44 throw std::bad_cast(); 45} 46 47/** 48 * Called to generate a bad typeid exception. This function is intended to 49 * allow compilers to insert code generating this exception without needing to 50 * duplicate the code for throwing the exception in every call site. 51 */ 52extern "C" void __cxa_bad_typeid() 53{ 54 throw std::bad_typeid(); 55} 56 57/** 58 * Compilers may (but are not required to) set any pure-virtual function's 59 * vtable entry to this function. This makes debugging slightly easier, as 60 * users can add a breakpoint on this function to tell if they've accidentally 61 * called a pure-virtual function. 62 */ 63extern "C" void __cxa_pure_virtual() 64{ 65 abort(); 66} 67 68/** 69 * Compilers may (but are not required to) set any deleted-virtual function's 70 * vtable entry to this function. This makes debugging slightly easier, as 71 * users can add a breakpoint on this function to tell if they've accidentally 72 * called a deleted-virtual function. 73 */ 74extern "C" void __cxa_deleted_virtual() 75{ 76 abort(); 77} 78 79extern "C" void __cxa_throw_bad_array_new_length() 80{ 81 throw std::bad_array_new_length(); 82} 83