File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
test/Interop/Cxx/templates Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,10 @@ class ClangDeclFinder
112
112
return true ;
113
113
}
114
114
115
+ // Do not traverse type locs, as they might contain expressions that reference
116
+ // code that should not be instantiated and/or emitted.
117
+ bool TraverseTypeLoc (clang::TypeLoc TL) { return true ; }
118
+
115
119
bool shouldVisitTemplateInstantiations () const { return true ; }
116
120
bool shouldVisitImplicitCode () const { return true ; }
117
121
};
Original file line number Diff line number Diff line change @@ -35,4 +35,27 @@ inline void initVector() {
35
35
vv.push_back (0 );
36
36
}
37
37
38
+ template <class T >
39
+ class UseDeclVal {
40
+ public:
41
+ UseDeclVal () {}
42
+
43
+ auto declTypeRet () const noexcept -> decltype(declval<T>().method()) {
44
+ return T ().method ();
45
+ }
46
+
47
+ inline int callMethod () const {
48
+ int x = declTypeRet ();
49
+ return x;
50
+ }
51
+ };
52
+
53
+ struct StructWithMethod {
54
+ inline int method () {
55
+ return 42 ;
56
+ }
57
+ };
58
+
59
+ using UseDeclValStruct = UseDeclVal<StructWithMethod>;
60
+
38
61
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_UNEVALUATED_CONTEXT_H
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ var UnevaluatedTestSuite = TestSuite("UnevaluatedContext")
9
9
10
10
UnevaluatedTestSuite . test ( " declval " ) {
11
11
initVector ( )
12
+ let _ = UseDeclValStruct ( ) . callMethod ( )
12
13
}
13
14
14
15
runAllTests ( )
You can’t perform that action at this time.
0 commit comments