Fixed some bugs.
[llvm/zpu.git] / test / FrontendC++ / 2010-07-23-DeclLoc.cpp
blobc72de3b336239ed40980f5399de21a3aefc75378
1 // RUN: %llvmgxx -emit-llvm -S -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:
4 // CHECK: {{extract_dwarf_data_from_header.*extract_dwarf_data_from_header.*extract_dwarf_data_from_header.*[^ ]+", metadata !}}[[filehandle:[0-9]+]],
5 // Second: Require that filehandle refer to the correct filename:
6 // CHECK: {{^!}}[[filehandle]] = metadata {{![{].*}} metadata !"decl_should_be_here.hpp",
7 typedef long unsigned int __darwin_size_t;
8 typedef __darwin_size_t size_t;
9 typedef unsigned char uint8_t;
10 typedef unsigned int uint32_t;
11 typedef unsigned long long uint64_t;
12 namespace 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() { }
21 class Pointer32 {
22 public:
23 typedef uint32_t ptr_t;
24 typedef uint32_t size_t;
26 class Pointer64 {
27 public:
28 typedef uint64_t ptr_t;
29 typedef uint64_t size_t;
31 class BigEndian {};
32 class LittleEndian {};
33 template <typename _SIZE, typename _ENDIANNESS> class SizeAndEndianness {
34 public:
35 typedef _SIZE SIZE;
37 typedef SizeAndEndianness<Pointer32, LittleEndian> ISA32Little;
38 typedef SizeAndEndianness<Pointer32, BigEndian> ISA32Big;
39 typedef SizeAndEndianness<Pointer64, LittleEndian> ISA64Little;
40 typedef SizeAndEndianness<Pointer64, BigEndian> ISA64Big;
41 template <typename SIZE> class TRange {
42 protected:
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) { }
47 template <typename SIZE, typename T> class TRangeValue : public TRange<SIZE> {
48 T _value;
49 public:
50 TRangeValue(typename SIZE::ptr_t location, typename SIZE::size_t length, T value) : TRange<SIZE>(location, length), _value(value) {};
52 template <typename SIZE> class TAddressRelocator {};
53 class CSCppSymbolOwner{};
54 class CSCppSymbolOwnerData{};
55 template <typename SIZE> class TRawSymbolOwnerData
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;
61 public:
62 TRawSymbolOwnerData() :
63 _TEXT_text_section(0, 0, __null), _dsym_path(__null), _dylib_current_version(0), _dylib_compatibility_version(0) {}
65 template <typename SIZE_AND_ENDIANNESS> class TExtendedMachOHeader {};
66 # 16 "decl_should_be_here.hpp"
67 template <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) {}
70 struct CSCppSymbolOwnerHashFunctor {
71 size_t operator()(const CSCppSymbolOwner& symbol_owner) const {
72 # 97 "wrong_place_for_decl.cpp"
75 template <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);
81 CSCppSymbolOwnerData* 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);