r186261 - Correctly classify pack expansions as NON_CANONICAL_UNLESS_DEPENDENT

David Blaikie dblaikie at gmail.com
Sat Jul 13 14:08:08 PDT 2013


Author: dblaikie
Date: Sat Jul 13 16:08:08 2013
New Revision: 186261

URL: http://llvm.org/viewvc/llvm-project?rev=186261&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/include/clang/AST/TypeNodes.def
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/test/CXX/temp/temp.decls/temp.alias/p3.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=186261&r1=186260&r2=186261&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sat Jul 13 16:08:08 2013
@@ -4202,8 +4202,8 @@ public:
     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());

Modified: cfe/trunk/include/clang/AST/TypeNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeNodes.def?rev=186261&r1=186260&r2=186261&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TypeNodes.def (original)
+++ cfe/trunk/include/clang/AST/TypeNodes.def Sat Jul 13 16:08:08 2013
@@ -99,7 +99,7 @@ TYPE(Auto, Type)
 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)

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=186261&r1=186260&r2=186261&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sat Jul 13 16:08:08 2013
@@ -2097,6 +2097,7 @@ llvm::DIType CGDebugInfo::CreateTypeNode
   case Type::TypeOf:
   case Type::Decltype:
   case Type::UnaryTransform:
+  case Type::PackExpansion:
     llvm_unreachable("type should have been unwrapped!");
   case Type::Auto:
     Diag = "auto";

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=186261&r1=186260&r2=186261&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Sat Jul 13 16:08:08 2013
@@ -1344,6 +1344,7 @@ void CodeGenFunction::EmitVariablyModifi
     case Type::UnaryTransform:
     case Type::Attributed:
     case Type::SubstTemplateTypeParm:
+    case Type::PackExpansion:
       // Keep walking after single level desugaring.
       type = type.getSingleStepDesugaredType(getContext());
       break;

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.alias/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.alias/p3.cpp?rev=186261&r1=186260&r2=186261&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.alias/p3.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.alias/p3.cpp Sat Jul 13 16:08:08 2013
@@ -9,5 +9,9 @@ template<class T> struct A {
 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>;





More information about the cfe-commits mailing list