LTP GCOV extension - code coverage report
Current view: directory - usr/include/c++/4.3 - typeinfo
Test: lcov.info
Date: 2008-08-14 Instrumented lines: 4
Code covered: 50.0 % Executed lines: 2

       1                 : // RTTI support for -*- C++ -*-
       2                 : // Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
       3                 : // 2003, 2004, 2005, 2006, 2007
       4                 : // Free Software Foundation
       5                 : //
       6                 : // This file is part of GCC.
       7                 : //
       8                 : // GCC is free software; you can redistribute it and/or modify
       9                 : // it under the terms of the GNU General Public License as published by
      10                 : // the Free Software Foundation; either version 2, or (at your option)
      11                 : // any later version.
      12                 : // 
      13                 : // GCC is distributed in the hope that it will be useful,
      14                 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16                 : // GNU General Public License for more details.
      17                 : // 
      18                 : // You should have received a copy of the GNU General Public License
      19                 : // along with GCC; see the file COPYING.  If not, write to
      20                 : // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
      21                 : // Boston, MA 02110-1301, USA.
      22                 : 
      23                 : // As a special exception, you may use this file as part of a free software
      24                 : // library without restriction.  Specifically, if other files instantiate
      25                 : // templates or use macros or inline functions from this file, or you compile
      26                 : // this file and link it with other files to produce an executable, this
      27                 : // file does not by itself cause the resulting executable to be covered by
      28                 : // the GNU General Public License.  This exception does not however
      29                 : // invalidate any other reasons why the executable file might be covered by
      30                 : // the GNU General Public License.
      31                 : 
      32                 : /** @file typeinfo
      33                 :  *  This is a Standard C++ Library header.
      34                 :  */
      35                 : 
      36                 : #ifndef _TYPEINFO
      37                 : #define _TYPEINFO
      38                 : 
      39                 : #include <exception>
      40                 : 
      41                 : #pragma GCC visibility push(default)
      42                 : 
      43                 : extern "C++" {
      44                 : 
      45                 : namespace __cxxabiv1
      46                 : {
      47                 :   class __class_type_info;
      48                 : } // namespace __cxxabiv1
      49                 : 
      50                 : // Determine whether typeinfo names for the same type are merged (in which
      51                 : // case comparison can just compare pointers) or not (in which case
      52                 : // strings must be compared and g++.dg/abi/local1.C will fail), and
      53                 : // whether comparison is to be implemented inline or not.  By default we
      54                 : // use inline pointer comparison if weak symbols are available, and
      55                 : // out-of-line strcmp if not.  Out-of-line pointer comparison is used
      56                 : // where the object files are to be portable to multiple systems, some of
      57                 : // which may not be able to use pointer comparison, but the particular
      58                 : // system for which libstdc++ is being built can use pointer comparison;
      59                 : // in particular for most ARM EABI systems, where the ABI specifies
      60                 : // out-of-line comparison.  Inline strcmp is not currently supported.  The
      61                 : // compiler's target configuration can override the defaults by defining
      62                 : // __GXX_TYPEINFO_EQUALITY_INLINE to 1 or 0 to indicate whether or not
      63                 : // comparison is inline, and __GXX_MERGED_TYPEINFO_NAMES to 1 or 0 to
      64                 : // indicate whether or not pointer comparison can be used.
      65                 : 
      66                 : #ifndef __GXX_MERGED_TYPEINFO_NAMES
      67                 :   #if !__GXX_WEAK__
      68                 :     // If weak symbols are not supported, typeinfo names are not merged.
      69                 :     #define __GXX_MERGED_TYPEINFO_NAMES 0
      70                 :   #else
      71                 :     // On platforms that support weak symbols, typeinfo names are merged.
      72                 :     #define __GXX_MERGED_TYPEINFO_NAMES 1
      73                 :   #endif
      74                 : #endif
      75                 : 
      76                 : // By default follow the same rules as for __GXX_MERGED_TYPEINFO_NAMES.
      77                 : #ifndef __GXX_TYPEINFO_EQUALITY_INLINE
      78                 :   #if !__GXX_WEAK__
      79                 :     #define __GXX_TYPEINFO_EQUALITY_INLINE 0
      80                 :   #else
      81                 :     #define __GXX_TYPEINFO_EQUALITY_INLINE 1
      82                 :   #endif
      83                 : #endif
      84                 : 
      85                 : namespace std 
      86                 : {
      87                 :   /**
      88                 :    *  @brief  Part of RTTI.
      89                 :    *
      90                 :    *  The @c type_info class describes type information generated by
      91                 :    *  an implementation.
      92                 :   */
      93                 :   class type_info 
      94                 :   {
      95                 :   public:
      96                 :     /** Destructor first. Being the first non-inline virtual function, this
      97                 :      *  controls in which translation unit the vtable is emitted. The
      98                 :      *  compiler makes use of that information to know where to emit
      99                 :      *  the runtime-mandated type_info structures in the new-abi.  */
     100                 :     virtual ~type_info();
     101                 : 
     102                 :     /** Returns an @e implementation-defined byte string; this is not
     103                 :      *  portable between compilers!  */
     104               2 :     const char* name() const
     105               2 :     { return __name; }
     106                 : 
     107                 : #if !__GXX_TYPEINFO_EQUALITY_INLINE
     108                 :     bool before(const type_info& __arg) const;
     109                 : 
     110                 :     // In old abi, or when weak symbols are not supported, there can
     111                 :     // be multiple instances of a type_info object for one
     112                 :     // type. Uniqueness must use the _name value, not object address.
     113                 :     bool operator==(const type_info& __arg) const;
     114                 : #else
     115                 :   #if !__GXX_MERGED_TYPEINFO_NAMES
     116                 :     #error "Inline implementation of type_info comparision requires merging of type_info objects"
     117                 :   #endif
     118                 :     /** Returns true if @c *this precedes @c __arg in the implementation's
     119                 :      *  collation order.  */
     120                 :     // In new abi we can rely on type_info's NTBS being unique,
     121                 :     // and therefore address comparisons are sufficient.
     122               0 :     bool before(const type_info& __arg) const
     123               0 :     { return __name < __arg.__name; }
     124                 : 
     125                 :     bool operator==(const type_info& __arg) const
     126                 :     { return __name == __arg.__name; }
     127                 : #endif
     128                 :     bool operator!=(const type_info& __arg) const
     129                 :     { return !operator==(__arg); }
     130                 : 
     131                 :     // Return true if this is a pointer type of some kind
     132                 :     virtual bool __is_pointer_p() const;
     133                 : 
     134                 :     // Return true if this is a function type
     135                 :     virtual bool __is_function_p() const;
     136                 : 
     137                 :     // Try and catch a thrown type. Store an adjusted pointer to the
     138                 :     // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then
     139                 :     // THR_OBJ points to the thrown object. If THR_TYPE is a pointer
     140                 :     // type, then THR_OBJ is the pointer itself. OUTER indicates the
     141                 :     // number of outer pointers, and whether they were const
     142                 :     // qualified.
     143                 :     virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
     144                 :                             unsigned __outer) const;
     145                 : 
     146                 :     // Internally used during catch matching
     147                 :     virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
     148                 :                              void **__obj_ptr) const;
     149                 : 
     150                 :   protected:
     151                 :     const char *__name;
     152                 :     
     153                 :     explicit type_info(const char *__n): __name(__n) { }
     154                 :     
     155                 :   private:
     156                 :     /// Assigning type_info is not supported.
     157                 :     type_info& operator=(const type_info&);
     158                 :     type_info(const type_info&);
     159                 :   };
     160                 : 
     161                 :   /**
     162                 :    *  @brief  Thrown during incorrect typecasting.
     163                 :    *
     164                 :    *  If you attempt an invalid @c dynamic_cast expression, an instance of
     165                 :    *  this class (or something derived from this class) is thrown.  */
     166                 :   class bad_cast : public exception 
     167                 :   {
     168                 :   public:
     169                 :     bad_cast() throw() { }
     170                 : 
     171                 :     // This declaration is not useless:
     172                 :     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
     173                 :     virtual ~bad_cast() throw();
     174                 : 
     175                 :     // See comment in eh_exception.cc.
     176                 :     virtual const char* what() const throw();
     177                 :   };
     178                 :   
     179                 :   /** If you use a NULL pointer in a @c typeid expression, this is thrown.  */
     180                 :   class bad_typeid : public exception 
     181                 :   {
     182                 :   public:
     183                 :     bad_typeid () throw() { }
     184                 : 
     185                 :     // This declaration is not useless:
     186                 :     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
     187                 :     virtual ~bad_typeid() throw();
     188                 : 
     189                 :     // See comment in eh_exception.cc.
     190                 :     virtual const char* what() const throw();
     191                 :   };
     192                 : } // namespace std
     193                 : 
     194                 : #pragma GCC visibility pop
     195                 : 
     196                 : } // extern "C++"
     197                 : #endif

Generated by: LTP GCOV extension version 1.6