mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 07:36:06 +00:00

In preparation of making `-Wreturn-type` default to an error (as there is virtually no situation where you’d *want* to fall off the end of a function that is supposed to return a value), this patch fixes tests that have relied on this being only a warning, of which there seem to be 3 kinds: 1. Tests which for no apparent reason have a function that triggers the warning. I suspect that a lot of these were on accident (or from before the warning was introduced), since a lot of people will open issues w/ their problematic code in the `main` function (which is the one case where you don’t need to return from a non-void function, after all...), which someone will then copy, possibly into a namespace, possibly renaming it, the end result of that being that you end up w/ something that definitely is not `main` anymore, but which still is declared as returning `int`, and which still has no return statement (another reason why I think this might apply to a lot of these is because usually the actual return type of such problematic functions is quite literally `int`). A lot of these are really old tests that don’t use `-verify`, which is why no-one noticed or had to care about the extra warning that was already being emitted by them until now. 2. Tests which test either `-Wreturn-type`, `[[noreturn]]`, or what codegen and sanitisers do whenever you do fall off the end of a function. 3. Tests where I struggle to figure out what is even being tested (usually because they’re Objective-C tests, and I don’t know Objective-C), whether falling off the end of a function matters in the first place, and tests where actually spelling out an expression to return would be rather cumbersome (e.g. matrix types currently don’t support list initialisation, so I can’t write e.g. `return {}`). For tests that fall into categories 2 and 3, I just added `-Wno-error=return-type` to the `RUN` lines and called it a day. This was especially necessary for the former since `-Wreturn-type` is an analysis-based warning, meaning that it is currently impossible to test for more than one occurrence of it in the same compilation if it defaults to an error since the analysis pass is skipped for subsequent functions as soon as an error is emitted. I’ve also added `-Werror=return-type` to a few tests that I had already updated as this patch was previously already making the warning an error by default, but we’ve decided to split that into two patches instead.
88 lines
3.9 KiB
C++
88 lines
3.9 KiB
C++
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
|
|
// Require the template function declaration refer to the correct filename.
|
|
// First, locate the function decl in metadata, and pluck out the file handle:
|
|
// CHECK: !DISubprogram(name: "extract_dwarf_data_from_header
|
|
// CHECK-SAME: file: [[FILE:![0-9]+]]
|
|
// Second: Require that filehandle refer to the correct filename:
|
|
// CHECK: [[FILE]] = !DIFile(filename: "decl_should_be_here.hpp"
|
|
typedef long unsigned int __darwin_size_t;
|
|
typedef __darwin_size_t size_t;
|
|
typedef unsigned char uint8_t;
|
|
typedef unsigned int uint32_t;
|
|
typedef unsigned long long uint64_t;
|
|
namespace std {
|
|
template<typename _Tp> class auto_ptr {
|
|
_Tp* _M_ptr;
|
|
public:
|
|
typedef _Tp element_type;
|
|
auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { }
|
|
element_type& operator*() const throw() { return *_M_ptr; }
|
|
};
|
|
}
|
|
class Pointer32 {
|
|
public:
|
|
typedef uint32_t ptr_t;
|
|
typedef uint32_t size_t;
|
|
};
|
|
class Pointer64 {
|
|
public:
|
|
typedef uint64_t ptr_t;
|
|
typedef uint64_t size_t;
|
|
};
|
|
class BigEndian {};
|
|
class LittleEndian {};
|
|
template <typename _SIZE, typename _ENDIANNESS> class SizeAndEndianness {
|
|
public:
|
|
typedef _SIZE SIZE;
|
|
};
|
|
typedef SizeAndEndianness<Pointer32, LittleEndian> ISA32Little;
|
|
typedef SizeAndEndianness<Pointer32, BigEndian> ISA32Big;
|
|
typedef SizeAndEndianness<Pointer64, LittleEndian> ISA64Little;
|
|
typedef SizeAndEndianness<Pointer64, BigEndian> ISA64Big;
|
|
template <typename SIZE> class TRange {
|
|
protected:
|
|
typename SIZE::ptr_t _location;
|
|
typename SIZE::size_t _length;
|
|
TRange(typename SIZE::ptr_t location, typename SIZE::size_t length) : _location(location), _length(length) { }
|
|
};
|
|
template <typename SIZE, typename T> class TRangeValue : public TRange<SIZE> {
|
|
T _value;
|
|
public:
|
|
TRangeValue(typename SIZE::ptr_t location, typename SIZE::size_t length, T value) : TRange<SIZE>(location, length), _value(value) {};
|
|
};
|
|
template <typename SIZE> class TAddressRelocator {};
|
|
class CSCppSymbolOwner{};
|
|
class CSCppSymbolOwnerData{};
|
|
template <typename SIZE> class TRawSymbolOwnerData
|
|
{
|
|
TRangeValue< SIZE, uint8_t* > _TEXT_text_section;
|
|
const char* _dsym_path;
|
|
uint32_t _dylib_current_version;
|
|
uint32_t _dylib_compatibility_version;
|
|
public:
|
|
TRawSymbolOwnerData() :
|
|
_TEXT_text_section(0, 0, __null), _dsym_path(__null), _dylib_current_version(0), _dylib_compatibility_version(0) {}
|
|
};
|
|
template <typename SIZE_AND_ENDIANNESS> class TExtendedMachOHeader {};
|
|
# 16 "decl_should_be_here.hpp"
|
|
template <typename SIZE_AND_ENDIANNESS> void 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) {}
|
|
struct CSCppSymbolOwnerHashFunctor {
|
|
void operator()(const CSCppSymbolOwner& symbol_owner) const {
|
|
# 97 "wrong_place_for_decl.cpp"
|
|
}
|
|
};
|
|
template <typename SIZE_AND_ENDIANNESS> void create_symbol_owner_data_arch_specific(CSCppSymbolOwner* symbol_owner, const char* dsym_path) {
|
|
typedef typename SIZE_AND_ENDIANNESS::SIZE SIZE;
|
|
std::auto_ptr< TRawSymbolOwnerData<SIZE> > data(new TRawSymbolOwnerData<SIZE>());
|
|
std::auto_ptr< TExtendedMachOHeader<SIZE_AND_ENDIANNESS> > header;
|
|
extract_dwarf_data_from_header(*header, *data, (TAddressRelocator<typename SIZE_AND_ENDIANNESS::SIZE>*)__null);
|
|
}
|
|
void create_symbol_owner_data2(CSCppSymbolOwner* symbol_owner, const char* dsym_path) {
|
|
create_symbol_owner_data_arch_specific< ISA32Little >(symbol_owner, dsym_path);
|
|
create_symbol_owner_data_arch_specific< ISA32Big >(symbol_owner, dsym_path);
|
|
create_symbol_owner_data_arch_specific< ISA64Little >(symbol_owner, dsym_path);
|
|
create_symbol_owner_data_arch_specific< ISA64Big >(symbol_owner, dsym_path);
|
|
}
|