Correctly classify pack expansions as NON_CANONICAL_UNLESS_DEPENDENT
Test coverage for non-dependent pack expansions doesn't demonstrate a
failure prior to this patch (a follow-up commit improving debug info
will cover this commit specifically) but covers a related hole in our
test coverage.
Reviewed by Richard Smith & Eli Friedman.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186261 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 1133d12..562243c 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -4202,8 +4202,8 @@
return None;
}
- bool isSugared() const { return false; }
- QualType desugar() const { return QualType(this, 0); }
+ bool isSugared() const { return !Pattern->isDependentType(); }
+ QualType desugar() const { return isSugared() ? Pattern : QualType(this, 0); }
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getPattern(), getNumExpansions());
diff --git a/include/clang/AST/TypeNodes.def b/include/clang/AST/TypeNodes.def
index a29ae23..3126f48 100644
--- a/include/clang/AST/TypeNodes.def
+++ b/include/clang/AST/TypeNodes.def
@@ -99,7 +99,7 @@
DEPENDENT_TYPE(InjectedClassName, Type)
DEPENDENT_TYPE(DependentName, Type)
DEPENDENT_TYPE(DependentTemplateSpecialization, Type)
-DEPENDENT_TYPE(PackExpansion, Type)
+NON_CANONICAL_UNLESS_DEPENDENT_TYPE(PackExpansion, Type)
TYPE(ObjCObject, Type)
TYPE(ObjCInterface, ObjCObjectType)
TYPE(ObjCObjectPointer, Type)
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index e5fb06a..11149f4 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -2097,6 +2097,7 @@
case Type::TypeOf:
case Type::Decltype:
case Type::UnaryTransform:
+ case Type::PackExpansion:
llvm_unreachable("type should have been unwrapped!");
case Type::Auto:
Diag = "auto";
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index bea13d4..51b86f7 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -1344,6 +1344,7 @@
case Type::UnaryTransform:
case Type::Attributed:
case Type::SubstTemplateTypeParm:
+ case Type::PackExpansion:
// Keep walking after single level desugaring.
type = type.getSingleStepDesugaredType(getContext());
break;
diff --git a/test/CXX/temp/temp.decls/temp.alias/p3.cpp b/test/CXX/temp/temp.decls/temp.alias/p3.cpp
index afd9b4b..2d46502 100644
--- a/test/CXX/temp/temp.decls/temp.alias/p3.cpp
+++ b/test/CXX/temp/temp.decls/temp.alias/p3.cpp
@@ -9,5 +9,9 @@
B<short> b;
template<typename T> using U = int;
+
+template<typename ...T> void f(U<T> ...xs);
+void g() { f<void,void,void>(1, 2, 3); }
+
// FIXME: This is illegal, but probably only because CWG1044 missed this paragraph.
template<typename T> using U = U<T>;