[clang] 234f51a - Don't crash if we deserialize a pack expansion type whose pattern
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 31 17:19:53 PDT 2020
Author: Richard Smith
Date: 2020-07-31T17:19:44-07:00
New Revision: 234f51a65a45b79402996ac6f0abcbb5793814bf
URL: https://github.com/llvm/llvm-project/commit/234f51a65a45b79402996ac6f0abcbb5793814bf
DIFF: https://github.com/llvm/llvm-project/commit/234f51a65a45b79402996ac6f0abcbb5793814bf.diff
LOG: Don't crash if we deserialize a pack expansion type whose pattern
contains no packs.
Fixes a regression from 740a164dec483225cbd02ab6c82199e2747ffacb.
Added:
Modified:
clang/include/clang/AST/TypeProperties.td
clang/lib/AST/ASTImporter.cpp
clang/test/PCH/cxx-variadic-templates.cpp
clang/test/PCH/cxx-variadic-templates.h
clang/test/PCH/cxx1y-lambdas.mm
clang/test/PCH/cxx2a-constraints.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td
index 4540ea0e1952..ed91670829b8 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -722,7 +722,8 @@ let Class = PackExpansionType in {
}
def : Creator<[{
- return ctx.getPackExpansionType(pattern, numExpansions);
+ return ctx.getPackExpansionType(pattern, numExpansions,
+ /*ExpectPackInType*/false);
}]>;
}
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 12dcd14c06bf..ee6daf45b7c3 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1498,7 +1498,8 @@ ASTNodeImporter::VisitPackExpansionType(const PackExpansionType *T) {
return ToPatternOrErr.takeError();
return Importer.getToContext().getPackExpansionType(*ToPatternOrErr,
- T->getNumExpansions());
+ T->getNumExpansions(),
+ /*ExpactPack=*/false);
}
ExpectedType ASTNodeImporter::VisitDependentTemplateSpecializationType(
diff --git a/clang/test/PCH/cxx-variadic-templates.cpp b/clang/test/PCH/cxx-variadic-templates.cpp
index 87b101d73c14..b1eed5adb647 100644
--- a/clang/test/PCH/cxx-variadic-templates.cpp
+++ b/clang/test/PCH/cxx-variadic-templates.cpp
@@ -19,3 +19,8 @@ shared_ptr<int> spi = shared_ptr<int>::allocate_shared(1, 2);
template<int> struct A {};
template<int> struct B {};
outer<int, int>::inner<1, 2, A, B> i(A<1>{}, B<2>{});
+
+void test_nondependent_pack() {
+ take_nondependent_pack<int, int>(nullptr, nullptr);
+ take_nondependent_pack_2<int, int>({});
+}
diff --git a/clang/test/PCH/cxx-variadic-templates.h b/clang/test/PCH/cxx-variadic-templates.h
index 50596cdf5dbf..45395e9ae84a 100644
--- a/clang/test/PCH/cxx-variadic-templates.h
+++ b/clang/test/PCH/cxx-variadic-templates.h
@@ -23,3 +23,8 @@ template<typename...Ts> struct outer {
};
};
template struct outer<int, int>;
+
+template<typename ...T> void take_nondependent_pack(int (...arr)[sizeof(sizeof(T))]);
+
+template<typename T> using hide = int;
+template<typename ...T> void take_nondependent_pack_2(outer<hide<T>...>);
diff --git a/clang/test/PCH/cxx1y-lambdas.mm b/clang/test/PCH/cxx1y-lambdas.mm
index f140a15215b8..9c4c11970473 100644
--- a/clang/test/PCH/cxx1y-lambdas.mm
+++ b/clang/test/PCH/cxx1y-lambdas.mm
@@ -39,6 +39,8 @@ int init_capture(T t) {
return [&, x(t)] { return sizeof(x); };
}
+auto with_pack = [](auto ...xs){};
+
#else
// CHECK-PRINT: T add_slowly
@@ -55,4 +57,6 @@ int add(int x, int y) {
// CHECK-PRINT: init_capture
// CHECK-PRINT: [&, x(t)]
+void use_with_pack() { with_pack(1, 2, 3); }
+
#endif
diff --git a/clang/test/PCH/cxx2a-constraints.cpp b/clang/test/PCH/cxx2a-constraints.cpp
index d8b79337c8f1..3f3b5e536cc9 100644
--- a/clang/test/PCH/cxx2a-constraints.cpp
+++ b/clang/test/PCH/cxx2a-constraints.cpp
@@ -24,6 +24,8 @@ template <SizedLike<char> T> void h(T) {}
template <SizedLike<int> T> void i(T) {}
template <SizedLike T> void i(T) {}
+void j(SizedLike<int> auto ...ints) {}
+
#else /*included pch*/
int main() {
@@ -35,6 +37,7 @@ int main() {
(void)h(1);
(void)i('1');
(void)i(1);
+ (void)j(1, 2, 3);
}
-#endif // HEADER
\ No newline at end of file
+#endif // HEADER
More information about the cfe-commits
mailing list