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