1 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %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:
4 // CHECK: !DISubprogram(name: "extract_dwarf_data_from_header
5 // 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"
8 typedef long unsigned int __darwin_size_t;
9 typedef __darwin_size_t size_t;
10 typedef unsigned char uint8_t;
11 typedef unsigned int uint32_t;
12 typedef unsigned long long uint64_t;
13 namespace 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()     {    }
20   };
21 }
22 class Pointer32 {
23 public:
24   typedef uint32_t ptr_t;
25   typedef uint32_t size_t;
26 };
27 class Pointer64 {
28 public:
29   typedef uint64_t ptr_t;
30   typedef uint64_t size_t;
31 };
32 class BigEndian {};
33 class LittleEndian {};
34 template <typename _SIZE, typename _ENDIANNESS> class SizeAndEndianness {
35 public:
36   typedef _SIZE SIZE;
37 };
38 typedef SizeAndEndianness<Pointer32, LittleEndian> ISA32Little;
39 typedef SizeAndEndianness<Pointer32, BigEndian> ISA32Big;
40 typedef SizeAndEndianness<Pointer64, LittleEndian> ISA64Little;
41 typedef SizeAndEndianness<Pointer64, BigEndian> ISA64Big;
42 template <typename SIZE> class TRange {
43 protected:
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 };
48 template <typename SIZE, typename T> class TRangeValue : public TRange<SIZE> {
49   T _value;
50 public:
51   TRangeValue(typename SIZE::ptr_t location, typename SIZE::size_t length, T value) : TRange<SIZE>(location, length), _value(value) {};
52 };
53 template <typename SIZE> class TAddressRelocator {};
54 class CSCppSymbolOwner{};
55 class CSCppSymbolOwnerData{};
56 template <typename SIZE> class TRawSymbolOwnerData
57 {
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;
62 public:
63   TRawSymbolOwnerData() :
64     _TEXT_text_section(0, 0, __null), _dsym_path(__null), _dylib_current_version(0), _dylib_compatibility_version(0) {}
65 };
66 template <typename SIZE_AND_ENDIANNESS> class TExtendedMachOHeader {};
67 # 16 "decl_should_be_here.hpp"
68 template <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) {}
71 struct CSCppSymbolOwnerHashFunctor {
72   size_t operator()(const CSCppSymbolOwner& symbol_owner) const {
73 # 97 "wrong_place_for_decl.cpp"
74   }
75 };
76 template <typename SIZE_AND_ENDIANNESS> CSCppSymbolOwnerData* 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 }
82 CSCppSymbolOwnerData* 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