PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - usr/include/c++/4.4.7 - typeinfo (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 4 7 57.1 %
Date: 2014-07-21 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // RTTI support for -*- C++ -*-
       2             : // Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
       3             : // 2003, 2004, 2005, 2006, 2007, 2009
       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 3, 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             : // Under Section 7 of GPL version 3, you are granted additional
      19             : // permissions described in the GCC Runtime Library Exception, version
      20             : // 3.1, as published by the Free Software Foundation.
      21             : 
      22             : // You should have received a copy of the GNU General Public License and
      23             : // a copy of the GCC Runtime Library Exception along with this program;
      24             : // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      25             : // <http://www.gnu.org/licenses/>.
      26             : 
      27             : /** @file typeinfo
      28             :  *  This is a Standard C++ Library header.
      29             :  */
      30             : 
      31             : #ifndef _TYPEINFO
      32             : #define _TYPEINFO
      33             : 
      34             : #include <exception>
      35             : 
      36             : #pragma GCC visibility push(default)
      37             : 
      38             : extern "C++" {
      39             : 
      40             : namespace __cxxabiv1
      41             : {
      42             :   class __class_type_info;
      43             : } // namespace __cxxabiv1
      44             : 
      45             : // Determine whether typeinfo names for the same type are merged (in which
      46             : // case comparison can just compare pointers) or not (in which case strings
      47             : // must be compared), and whether comparison is to be implemented inline or
      48             : // not.  We used to do inline pointer comparison by default if weak symbols
      49             : // are available, but even with weak symbols sometimes names are not merged
      50             : // when objects are loaded with RTLD_LOCAL, so now we always use strcmp by
      51             : // default.  For ABI compatibility, we do the strcmp inline if weak symbols
      52             : // are available, and out-of-line if not.  Out-of-line pointer comparison
      53             : // is used where the object files are to be portable to multiple systems,
      54             : // some of which may not be able to use pointer comparison, but the
      55             : // particular system for which libstdc++ is being built can use pointer
      56             : // comparison; in particular for most ARM EABI systems, where the ABI
      57             : // specifies out-of-line comparison.  The compiler's target configuration
      58             : // can override the defaults by defining __GXX_TYPEINFO_EQUALITY_INLINE to
      59             : // 1 or 0 to indicate whether or not comparison is inline, and
      60             : // __GXX_MERGED_TYPEINFO_NAMES to 1 or 0 to indicate whether or not pointer
      61             : // comparison can be used.
      62             : 
      63             : #ifndef __GXX_MERGED_TYPEINFO_NAMES
      64             : // By default, typeinfo names are not merged.
      65             : #define __GXX_MERGED_TYPEINFO_NAMES 0
      66             : #endif
      67             : 
      68             : // By default follow the old inline rules to avoid ABI changes.
      69             : #ifndef __GXX_TYPEINFO_EQUALITY_INLINE
      70             :   #if !__GXX_WEAK__
      71             :     #define __GXX_TYPEINFO_EQUALITY_INLINE 0
      72             :   #else
      73             :     #define __GXX_TYPEINFO_EQUALITY_INLINE 1
      74             :   #endif
      75             : #endif
      76             : 
      77             : namespace std 
      78             : {
      79             :   /**
      80             :    *  @brief  Part of RTTI.
      81             :    *
      82             :    *  The @c type_info class describes type information generated by
      83             :    *  an implementation.
      84             :   */
      85             :   class type_info 
      86             :   {
      87             :   public:
      88             :     /** Destructor first. Being the first non-inline virtual function, this
      89             :      *  controls in which translation unit the vtable is emitted. The
      90             :      *  compiler makes use of that information to know where to emit
      91             :      *  the runtime-mandated type_info structures in the new-abi.  */
      92             :     virtual ~type_info();
      93             : 
      94             :     /** Returns an @e implementation-defined byte string; this is not
      95             :      *  portable between compilers!  */
      96           0 :     const char* name() const
      97           0 :     { return __name[0] == '*' ? __name + 1 : __name; }
      98             : 
      99             : #if !__GXX_TYPEINFO_EQUALITY_INLINE
     100             :     // In old abi, or when weak symbols are not supported, there can
     101             :     // be multiple instances of a type_info object for one
     102             :     // type. Uniqueness must use the _name value, not object address.
     103             :     bool before(const type_info& __arg) const;
     104             :     bool operator==(const type_info& __arg) const;
     105             : #else
     106             :   #if !__GXX_MERGED_TYPEINFO_NAMES
     107             :     /** Returns true if @c *this precedes @c __arg in the implementation's
     108             :      *  collation order.  */
     109             :     // Even with the new abi, on systems that support dlopen
     110             :     // we can run into cases where type_info names aren't merged,
     111             :     // so we still need to do string comparison.
     112             :     bool before(const type_info& __arg) const
     113             :     { return (__name[0] == '*' && __arg.__name[0] == '*')
     114             :         ? __name < __arg.__name
     115             :         : __builtin_strcmp (__name, __arg.__name) < 0; }
     116             : 
     117           3 :     bool operator==(const type_info& __arg) const
     118             :     {
     119             :       return ((__name == __arg.__name)
     120           0 :               || (__name[0] != '*' &&
     121           3 :                   __builtin_strcmp (__name, __arg.__name) == 0));
     122             :     }
     123             :   #else
     124             :     // On some targets we can rely on type_info's NTBS being unique,
     125             :     // and therefore address comparisons are sufficient.
     126             :     bool before(const type_info& __arg) const
     127             :     { return __name < __arg.__name; }
     128             : 
     129             :     bool operator==(const type_info& __arg) const
     130             :     { return __name == __arg.__name; }
     131             :   #endif
     132             : #endif
     133           3 :     bool operator!=(const type_info& __arg) const
     134           3 :     { return !operator==(__arg); }
     135             : 
     136             :     // Return true if this is a pointer type of some kind
     137             :     virtual bool __is_pointer_p() const;
     138             : 
     139             :     // Return true if this is a function type
     140             :     virtual bool __is_function_p() const;
     141             : 
     142             :     // Try and catch a thrown type. Store an adjusted pointer to the
     143             :     // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then
     144             :     // THR_OBJ points to the thrown object. If THR_TYPE is a pointer
     145             :     // type, then THR_OBJ is the pointer itself. OUTER indicates the
     146             :     // number of outer pointers, and whether they were const
     147             :     // qualified.
     148             :     virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
     149             :                             unsigned __outer) const;
     150             : 
     151             :     // Internally used during catch matching
     152             :     virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
     153             :                              void **__obj_ptr) const;
     154             : 
     155             :   protected:
     156             :     const char *__name;
     157             :     
     158             :     explicit type_info(const char *__n): __name(__n) { }
     159             :     
     160             :   private:
     161             :     /// Assigning type_info is not supported.
     162             :     type_info& operator=(const type_info&);
     163             :     type_info(const type_info&);
     164             :   };
     165             : 
     166             :   /**
     167             :    *  @brief  Thrown during incorrect typecasting.
     168             :    *  @ingroup exceptions
     169             :    *
     170             :    *  If you attempt an invalid @c dynamic_cast expression, an instance of
     171             :    *  this class (or something derived from this class) is thrown.  */
     172             :   class bad_cast : public exception 
     173             :   {
     174             :   public:
     175             :     bad_cast() throw() { }
     176             : 
     177             :     // This declaration is not useless:
     178             :     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
     179             :     virtual ~bad_cast() throw();
     180             : 
     181             :     // See comment in eh_exception.cc.
     182             :     virtual const char* what() const throw();
     183             :   };
     184             :   
     185             :   /** 
     186             :    *  @brief Thrown when a NULL pointer in a @c typeid expression is used.
     187             :    *  @ingroup exceptions
     188             :    */
     189             :   class bad_typeid : public exception 
     190             :   {
     191             :   public:
     192             :     bad_typeid () throw() { }
     193             : 
     194             :     // This declaration is not useless:
     195             :     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
     196             :     virtual ~bad_typeid() throw();
     197             : 
     198             :     // See comment in eh_exception.cc.
     199             :     virtual const char* what() const throw();
     200             :   };
     201             : } // namespace std
     202             : 
     203             : #pragma GCC visibility pop
     204             : 
     205             : } // extern "C++"
     206             : #endif

Generated by: LCOV version 1.10

Generated at Tue, 22 Jul 2014 01:33:03 +0000 (4 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.