Skip to content

Commit e80a7fc

Browse files
Michael137rorth
authored andcommitted
[lldb][test] Add test for handling conflicting Objective-C NS_OPTIONS typedefs
Add test that checks whether the expression evaluator can handle the `NS_ENUM`/`NS_OPTIONS` typedefs from Objective-C `CoreFoundation`. In the test, `module.h` mimicks the `NS_OPTIONS` typedef from `CoreFoundation`. The `ClangModulesDeclVendor` currently compiles modules as C++, so the `MyInt` Clang decl in the module will be a `TypedefType`, while the DWARF AST parser will produce an `EnumType` (since that's what the debug-info says). When the `ASTImporter` imports these decls into the scratch AST, it will fail to re-use one or the other decl because they aren't structurally equivalent (one is a typedef, the other an enum), so we end up with two conflicting `MyInt` declarations in the scratch AST and the expression fails to run due to ambiguity in name lookup. rdar://151022173
1 parent a968217 commit e80a7fc

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# REQUIRES: system-darwin
2+
3+
# Tests whether the expression evaluator can handle the `NS_ENUM`/`NS_OPTIONS`
4+
# typedefs from Objective-C `CoreFoundation`.
5+
# Here `module.h` mimicks the `NS_OPTIONS` typedef from `CoreFoundation`.
6+
#
7+
# The `ClangModulesDeclVendor` currently compiles modules as
8+
# C++, so the `MyInt` Clang decl in the module will be a `TypedefType`,
9+
# while the DWARF AST parser will produce an `EnumType` (since that's what
10+
# the debug-info says). When the `ASTImporter` imports these decls into the
11+
# scratch AST, it will fail to re-use one or the other decl because they
12+
# aren't structurally equivalent (one is a typedef, the other an enum),
13+
# so we end up with two conflicting `MyInt` declarations in the scratch AST
14+
# and the expression fails to run due to ambiguity in name lookup.
15+
16+
# RUN: split-file %s %t
17+
# RUN: %clang_host -g %t/main.m -fmodules -fcxx-modules -o %t.out
18+
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
19+
# RUN: | FileCheck %s
20+
21+
#--- main.m
22+
23+
#import "module.h"
24+
25+
int main() {
26+
MyInt i;
27+
return i;
28+
}
29+
30+
#--- module.h
31+
32+
#if (__cplusplus)
33+
typedef int MyInt;
34+
enum : MyInt { CASE };
35+
#else
36+
typedef enum MyInt : int MyInt;
37+
enum MyInt : int { CASE };
38+
#endif
39+
40+
#--- module.modulemap
41+
module Int {
42+
header "module.h"
43+
}
44+
45+
#--- commands.input
46+
47+
break set -n main
48+
run
49+
expression -l objective-c -- (MyInt)5
50+
51+
# CHECK: error: reference to 'MyInt' is ambiguous
52+
# CHECK: error: reference to 'MyInt' is ambiguous
53+
# CHECK: note: note: candidate found by name lookup is 'MyInt'
54+
# CHECK: note: note: candidate found by name lookup is 'MyInt'

0 commit comments

Comments
 (0)