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

This reverts c7f16ab3e3f27d944db72908c9c1b1b7366f5515 / r109694 - which suggested this was done to improve consistency with the gdb test suite. Possible that at the time GCC did not canonicalize integer types, and so matching types was important for cross-compiler validity, or that it was only a case of over-constrained test cases that printed out/tested the exact names of integer types. In any case neither issue seems to exist today based on my limited testing - both gdb and lldb canonicalize integer types (in a way that happens to match Clang's preferred naming, incidentally) and so never print the original text name produced in the DWARF by GCC or Clang. This canonicalization appears to be in `integer_types_same_name_p` for GDB and in `TypeSystemClang::GetBasicTypeEnumeration` for lldb. (I tested this with one translation unit defining 3 variables - `long`, `long (*)()`, and `int (*)()`, and another translation unit that had main, and a function that took `long (*)()` as a parameter - then compiled them with mismatched compilers (either GCC+Clang, or Clang+(Clang with this patch applied)) and no matter the combination, despite the debug info for one CU naming the type "long int" and the other naming it "long", both debuggers printed out the name as "long" and were able to correctly perform overload resolution and pass the `long int (*)()` variable to the `long (*)()` function parameter) Did find one hiccup, identified by the lldb test suite - that CodeView was relying on these names to map them to builtin types in that format. So added some handling for that in LLVM. (these could be split out into separate patches, but seems small enough to not warrant it - will do that if there ends up needing any reverti/revisiting) Differential Revision: https://reviews.llvm.org/D110455
125 lines
3.9 KiB
C++
125 lines
3.9 KiB
C++
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s
|
|
|
|
enum class A { A1=1 }; // underlying type is int by default
|
|
enum class B: unsigned long { B1=1 }; // underlying type is unsigned long
|
|
enum C { C1 = 1 };
|
|
enum D : short; // enum forward declaration
|
|
enum Z : int;
|
|
A a;
|
|
B b;
|
|
C c;
|
|
D d;
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "A"
|
|
// CHECK-SAME: line: 3
|
|
// CHECK-SAME: baseType: ![[INT:[0-9]+]]
|
|
// CHECK-SAME: size: 32
|
|
// CHECK-NOT: offset:
|
|
// CHECK-SAME: flags: DIFlagEnumClass
|
|
// CHECK-SAME: ){{$}}
|
|
// CHECK: ![[INT]] = !DIBasicType(name: "int"
|
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "B"
|
|
// CHECK-SAME: line: 4
|
|
// CHECK-SAME: baseType: ![[ULONG:[0-9]+]]
|
|
// CHECK-SAME: size: 64
|
|
// CHECK-NOT: offset:
|
|
// CHECK-SAME: flags: DIFlagEnumClass
|
|
// CHECK-SAME: ){{$}}
|
|
// CHECK: ![[ULONG]] = !DIBasicType(name: "unsigned long"
|
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "C"
|
|
// CHECK-SAME: line: 5
|
|
// CHECK-SAME: baseType: ![[ULONG:[0-9]+]]
|
|
// CHECK-SAME: size: 32
|
|
// CHECK-NOT: offset:
|
|
// CHECK-NOT: flags:
|
|
// CHECK-SAME: ){{$}}
|
|
|
|
namespace PR14029 {
|
|
// Make sure this doesn't crash/assert.
|
|
template <typename T> struct Test {
|
|
enum class Tag {
|
|
test = 0
|
|
};
|
|
Test() {
|
|
auto t = Tag::test;
|
|
}
|
|
Tag tag() const { return static_cast<Tag>(1); }
|
|
};
|
|
Test<int> t;
|
|
}
|
|
|
|
namespace test2 {
|
|
// FIXME: this should just be a declaration under -fno-standalone-debug
|
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E"
|
|
// CHECK-SAME: scope: [[TEST2:![0-9]+]]
|
|
// CHECK-NOT: DIFlagEnumClass
|
|
// CHECK-SAME: elements: [[TEST_ENUMS:![0-9]+]]
|
|
// CHECK-SAME: identifier: "_ZTSN5test21EE"
|
|
// CHECK: [[TEST2]] = !DINamespace(name: "test2"
|
|
// CHECK: [[TEST_ENUMS]] = !{[[TEST_E:![0-9]*]]}
|
|
// CHECK: [[TEST_E]] = !DIEnumerator(name: "e", value: 0)
|
|
enum E : int;
|
|
void func(E *) {
|
|
}
|
|
enum E : int { e };
|
|
}
|
|
|
|
namespace test3 {
|
|
// FIXME: this should just be a declaration under -fno-standalone-debug
|
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E"
|
|
// CHECK-SAME: scope: [[TEST3:![0-9]+]]
|
|
// CHECK-NOT: DIFlagEnumClass
|
|
// CHECK-SAME: elements: [[TEST_ENUMS]]
|
|
// CHECK-SAME: identifier: "_ZTSN5test31EE"
|
|
// CHECK: [[TEST3]] = !DINamespace(name: "test3"
|
|
enum E : int { e };
|
|
void func(E *) {
|
|
}
|
|
}
|
|
|
|
namespace test4 {
|
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E"
|
|
// CHECK-SAME: scope: [[TEST4:![0-9]+]]
|
|
// CHECK-NOT: DIFlagEnumClass
|
|
// CHECK-SAME: elements: [[TEST_ENUMS]]
|
|
// CHECK-SAME: identifier: "_ZTSN5test41EE"
|
|
// CHECK: [[TEST4]] = !DINamespace(name: "test4"
|
|
enum E : int;
|
|
void f1(E *) {
|
|
}
|
|
enum E : int { e };
|
|
void f2(E) {
|
|
}
|
|
}
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "D"
|
|
// CHECK-SAME: line: 6
|
|
// CHECK-SAME: size: 16
|
|
// CHECK-NOT: offset:
|
|
// CHECK-SAME: flags: DIFlagFwdDecl
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Z"
|
|
// CHECK-NOT: scope:
|
|
// CHECK-SAME: flags: DIFlagFwdDecl
|
|
void fz() { Z z; }
|
|
|
|
namespace test5 {
|
|
// CHECK: [[TEST5:![0-9]+]] = !DINamespace(name: "test5"
|
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E"
|
|
// CHECK-SAME: scope: [[TEST5]]
|
|
// CHECK-SAME: flags: DIFlagFwdDecl
|
|
// CHECK-SAME: identifier: "_ZTSN5test51EE"
|
|
enum E : int;
|
|
void f1(E *) {
|
|
}
|
|
}
|
|
|
|
namespace test6 {
|
|
// Ensure typedef'd enums aren't manifest by debug info generation.
|
|
// This could cause "typedef changes linkage of anonymous type, but linkage was
|
|
// already computed" errors.
|
|
// CHECK-NOT: test6
|
|
typedef enum {
|
|
} E;
|
|
}
|