brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · ef589e0 Raw
88 lines · cpp
1// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s2// Require the template function declaration refer to the correct filename.3// First, locate the function decl in metadata, and pluck out the file handle:4// CHECK: !DISubprogram(name: "extract_dwarf_data_from_header5// CHECK-SAME:          file: [[FILE:![0-9]+]]6// Second: Require that filehandle refer to the correct filename:7// CHECK: [[FILE]] = !DIFile(filename: "decl_should_be_here.hpp"8typedef long unsigned int __darwin_size_t;9typedef __darwin_size_t size_t;10typedef unsigned char uint8_t;11typedef unsigned int uint32_t;12typedef unsigned long long uint64_t;13namespace std {14  template<typename _Tp>   class auto_ptr   {15    _Tp* _M_ptr;16  public:17    typedef _Tp element_type;18    auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) {    }19    element_type&     operator*() const throw()     { return *_M_ptr; }20  };21}22class Pointer32 {23public:24  typedef uint32_t ptr_t;25  typedef uint32_t size_t;26};27class Pointer64 {28public:29  typedef uint64_t ptr_t;30  typedef uint64_t size_t;31};32class BigEndian {};33class LittleEndian {};34template <typename _SIZE, typename _ENDIANNESS> class SizeAndEndianness {35public:36  typedef _SIZE SIZE;37};38typedef SizeAndEndianness<Pointer32, LittleEndian> ISA32Little;39typedef SizeAndEndianness<Pointer32, BigEndian> ISA32Big;40typedef SizeAndEndianness<Pointer64, LittleEndian> ISA64Little;41typedef SizeAndEndianness<Pointer64, BigEndian> ISA64Big;42template <typename SIZE> class TRange {43protected:44  typename SIZE::ptr_t _location;45  typename SIZE::size_t _length;46  TRange(typename SIZE::ptr_t location, typename SIZE::size_t length) : _location(location), _length(length) {  }47};48template <typename SIZE, typename T> class TRangeValue : public TRange<SIZE> {49  T _value;50public:51  TRangeValue(typename SIZE::ptr_t location, typename SIZE::size_t length, T value) : TRange<SIZE>(location, length), _value(value) {};52};53template <typename SIZE> class TAddressRelocator {};54class CSCppSymbolOwner{};55class CSCppSymbolOwnerData{};56template <typename SIZE> class TRawSymbolOwnerData57{58  TRangeValue< SIZE, uint8_t* > _TEXT_text_section;59  const char* _dsym_path;60  uint32_t _dylib_current_version;61  uint32_t _dylib_compatibility_version;62public:63  TRawSymbolOwnerData() :64    _TEXT_text_section(0, 0, __null), _dsym_path(__null), _dylib_current_version(0), _dylib_compatibility_version(0) {}65};66template <typename SIZE_AND_ENDIANNESS> class TExtendedMachOHeader {};67# 16 "decl_should_be_here.hpp"68template <typename SIZE_AND_ENDIANNESS> void extract_dwarf_data_from_header(TExtendedMachOHeader<SIZE_AND_ENDIANNESS>& header,69                                                                            TRawSymbolOwnerData<typename SIZE_AND_ENDIANNESS::SIZE>& symbol_owner_data,70                                                                            TAddressRelocator<typename SIZE_AND_ENDIANNESS::SIZE>* address_relocator) {}71struct CSCppSymbolOwnerHashFunctor {72  void operator()(const CSCppSymbolOwner& symbol_owner) const {73# 97 "wrong_place_for_decl.cpp"74  }75};76template <typename SIZE_AND_ENDIANNESS> void create_symbol_owner_data_arch_specific(CSCppSymbolOwner* symbol_owner, const char* dsym_path) {77  typedef typename SIZE_AND_ENDIANNESS::SIZE SIZE;78  std::auto_ptr< TRawSymbolOwnerData<SIZE> > data(new TRawSymbolOwnerData<SIZE>());79  std::auto_ptr< TExtendedMachOHeader<SIZE_AND_ENDIANNESS> > header;80  extract_dwarf_data_from_header(*header, *data, (TAddressRelocator<typename SIZE_AND_ENDIANNESS::SIZE>*)__null);81}82void create_symbol_owner_data2(CSCppSymbolOwner* symbol_owner, const char* dsym_path) {83  create_symbol_owner_data_arch_specific< ISA32Little >(symbol_owner, dsym_path);84  create_symbol_owner_data_arch_specific< ISA32Big >(symbol_owner, dsym_path);85  create_symbol_owner_data_arch_specific< ISA64Little >(symbol_owner, dsym_path);86  create_symbol_owner_data_arch_specific< ISA64Big >(symbol_owner, dsym_path);87}88