diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index ab157e56bf..61555ad19d 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -20,6 +20,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" +#include "clang/AST/ExprCXX.h" #include "clang/Basic/SourceManager.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" @@ -971,7 +972,26 @@ void CXXNameMangler::mangleExpression(const Expr *E) { } } + + break; } + + case Expr::UnresolvedDeclRefExprClass: { + const UnresolvedDeclRefExpr *DRE = cast(E); + const Type *QTy = DRE->getQualifier()->getAsType(); + assert(QTy && "Qualifier was not type!"); + + // ::= sr # dependent name + Out << "sr"; + mangleType(QualType(QTy, 0)); + + assert(DRE->getDeclName().getNameKind() == DeclarationName::Identifier && + "Unhandled decl name kind!"); + mangleSourceName(DRE->getDeclName().getAsIdentifierInfo()); + + break; + } + } } diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index a55f5b97fe..86f5fb0d5b 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -180,3 +180,21 @@ template typename T::U ft6(const T&) { return 0; } // CHECK: @_Z3ft6I1SENT_1UERKS1_ template int ft6(const S&); + +template struct __is_scalar { + enum { __value = 1 }; +}; + +template struct __enable_if { }; + +template struct __enable_if { + typedef T __type; +}; + +// PR5063 +template typename __enable_if<__is_scalar::__value, void>::__type ft7() { } + +// CHECK: @_Z3ft7IiEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv +template void ft7(); +// CHECK: @_Z3ft7IPvEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv +template void ft7();