Skip to content

Commit 0e7d525

Browse files
committed
[interop] do not stop traversal when looking for clang symbols to IRGen when hitting noexcept expression
1 parent 915c5e6 commit 0e7d525

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/IRGen/GenClangDecl.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ class ClangDeclFinder
104104
// Do not traverse unevaluated expressions. Doing to might result in compile
105105
// errors if we try to instantiate an un-instantiatable template.
106106

107-
bool VisitCXXNoexceptExpr(clang::CXXNoexceptExpr *NEE) { return false; }
107+
bool TraverseCXXNoexceptExpr(clang::CXXNoexceptExpr *NEE) { return true; }
108108

109-
bool VisitCXXTypeidExpr(clang::CXXTypeidExpr *TIE) {
110-
return TIE->isPotentiallyEvaluated();
109+
bool TraverseCXXTypeidExpr(clang::CXXTypeidExpr *TIE) {
110+
if (TIE->isPotentiallyEvaluated())
111+
clang::RecursiveASTVisitor<ClangDeclFinder>::TraverseCXXTypeidExpr(TIE);
112+
return true;
111113
}
112114

113115
bool shouldVisitTemplateInstantiations() const { return true; }

test/Interop/Cxx/templates/Inputs/unevaluated-context.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ auto declval() noexcept -> decltype(__declval<_Tp>(0)) {
1616
return __declval<_Tp>(0);
1717
}
1818

19+
inline void stillCalled() {
20+
static int x = 0;
21+
}
22+
1923
template <class T>
2024
class Vec {
2125
public:
2226
void push_back(const T &__x) {
2327
if (!noexcept(declval<T *>()))
2428
;
29+
stillCalled();
2530
}
2631
};
2732

0 commit comments

Comments
 (0)