    // Objective-C ARC:
    //   If an explicitly-specified template argument type is a lifetime type
    //   with no lifetime qualifier, the __strong lifetime qualifier is inferred.
-@@ -3538,8 +3568,15 @@
+@@ -3538,8 +3568,15 @@ bool Sema::CheckTemplateArgument(TemplateTypeParmDecl *Param,
  
    if (Arg->isVariablyModifiedType()) {
      return Diag(SR.getBegin(), diag::err_variably_modified_template_arg) << Arg;

--- ./tools/clang/include/clang/AST/ASTContext.h	2013-04-11 09:35:12.324974155 +0200
+++ ./tools/clang/include/clang/AST/ASTContext.h	2013-04-24 19:40:12.605511633 +0200
@@ -1028,7 +1028,8 @@
                              QualType equivalentType);
 
   QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced,

 
   llvm::FoldingSetNodeID ID;
   SubstTemplateTypeParmType::Profile(ID, Parm, Replacement);
diff --git lib/Sema/HackForDefaultTemplateArg.h lib/Sema/HackForDefaultTemplateArg.h
new file mode 100644
index 0000000..e6af62c
--- /dev/null
+++ lib/Sema/HackForDefaultTemplateArg.h
@@ -0,0 +1,52 @@
+//===------- HackForDefaultTemplateArg.h - Make template argument substitution mroe permissive -----*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//===----------------------------------------------------------------------===//
+//
+//  Enabling this hack, make the template substitution more permissive and
+//  allows for replacement with non-canonical types.  This is usefull in the
+//  case of client code emulating opaque typedefs and/or wanting to recover
+//  the template instance name as the user would have written if (s)he 
+//  expanded the default paramater explicitly.   For example the user might
+//  have type: vector<int32_t> and the client wants to see:
+//  std::vector<int32_t,std::allocator<int32_t> >
+//
+//  For convenience purposes the implementation is located in
+//  SemaTemplate.cpp
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_SEMA_HACKFORDEFAULTTEMPLATEARG_H
+#define LLVM_CLANG_SEMA_HACKFORDEFAULTTEMPLATEARG_H
+
+namespace clang {
+namespace sema {
+
+///  \brief Enabling this hack makes the template substitution more permissive
+///  and allows for replacement with non-canonical types.  This is usefull in
+///  the case of client code emulating opaque typedefs and/or wanting to recover
+///  the template instance name as the user would have written if (s)he
+///  expanded the default paramater explicitly.   For example the user might
+///  have type: \c vector<int32_t> and the client wants to see:
+///  \c std::vector<int32_t,std::allocator<int32_t> >
+   
+class HackForDefaultTemplateArg {
+  /// \brief Private RAII object that set and reset the hack state.
+
+  static bool AllowNonCanonicalSubstEnabled;
+  bool OldValue;
+public:
+
+  HackForDefaultTemplateArg();
+  ~HackForDefaultTemplateArg();
+  
+  static bool AllowNonCanonicalSubst();
+};
+  
+} // sema
+} // clang
+
+#endif // LLVM_CLANG_SEMA_HACKFORDEFAULTTEMPLATEARG_H
diff --git lib/Sema/SemaTemplate.cpp lib/Sema/SemaTemplate.cpp
index 9906261..985189b 100644
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -32,6 +32,31 @@
 using namespace clang;
 using namespace sema;
