Handle PredefinedExpr with templates and lambdas
Summary:
- lambdas, blocks or captured statements in templates were not
handled which causes codegen crashes.
Differential Revision: http://llvm-reviews.chandlerc.com/D1628
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190784 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/predefined-expr.cpp b/test/SemaCXX/predefined-expr.cpp
index e203dd4..257d44c 100644
--- a/test/SemaCXX/predefined-expr.cpp
+++ b/test/SemaCXX/predefined-expr.cpp
@@ -16,6 +16,40 @@
return 0;
}
+// Within templates.
+template <typename T>
+int baz() {
+ static_assert(sizeof(__func__) == 4, "baz");
+ static_assert(sizeof(__FUNCTION__) == 4, "baz");
+ static_assert(sizeof(__PRETTY_FUNCTION__) == 20, "int baz() [T = int]");
+
+ []() {
+ static_assert(sizeof(__func__) == 11, "operator()");
+ static_assert(sizeof(__FUNCTION__) == 11, "operator()");
+ static_assert(sizeof(__PRETTY_FUNCTION__) == 50,
+ "auto baz()::<anonymous class>::operator()() const");
+ return 0;
+ }
+ ();
+
+ ^{
+ // FIXME: This is obviously wrong.
+ static_assert(sizeof(__func__) == 1, "__baz_block_invoke");
+ static_assert(sizeof(__FUNCTION__) == 1, "__baz_block_invoke");
+ static_assert(sizeof(__PRETTY_FUNCTION__) == 1, "__baz_block_invoke");
+ }
+ ();
+
+ #pragma clang __debug captured
+ {
+ static_assert(sizeof(__func__) == 4, "baz");
+ static_assert(sizeof(__FUNCTION__) == 4, "baz");
+ static_assert(sizeof(__PRETTY_FUNCTION__) == 20, "int baz() [T = int]");
+ }
+
+ return 0;
+}
+
int main() {
static_assert(sizeof(__func__) == 5, "main");
static_assert(sizeof(__FUNCTION__) == 5, "main");
@@ -62,4 +96,8 @@
}
}
();
+
+ baz<int>();
+
+ return 0;
}