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