From: David Majnemer Date: Tue, 21 Jan 2014 20:33:36 +0000 (+0000) Subject: MSVC ABI: Support C++11's auto on variables X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e2aa2004e7b93bad2d3e0aa1d2f25a75c31e8ec;p=clang MSVC ABI: Support C++11's auto on variables The MSVC C++ ABI always uses the deduced type in place of auto when generating external names for variables. N.B. MSVC doesn't support C++1y's 'operator auto' and this patch will not give us said functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199764 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 30c53ed0ef..ece12049e7 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -345,7 +345,7 @@ void MicrosoftCXXNameMangler::mangleVariableEncoding(const VarDecl *VD) { // Pointers and references are odd. The type of 'int * const foo;' gets // mangled as 'QAHA' instead of 'PAHB', for example. TypeLoc TL = VD->getTypeSourceInfo()->getTypeLoc(); - QualType Ty = TL.getType(); + QualType Ty = VD->getType(); if (Ty->isPointerType() || Ty->isReferenceType() || Ty->isMemberPointerType()) { mangleType(Ty, TL.getSourceRange(), QMM_Drop); @@ -1803,6 +1803,8 @@ void MicrosoftCXXNameMangler::mangleType(const UnaryTransformType *T, } void MicrosoftCXXNameMangler::mangleType(const AutoType *T, SourceRange Range) { + assert(T->getDeducedType().isNull() && "expecting a dependent type!"); + DiagnosticsEngine &Diags = Context.getDiags(); unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, "cannot mangle this 'auto' type yet"); diff --git a/test/CodeGenCXX/mangle-ms-cxx11.cpp b/test/CodeGenCXX/mangle-ms-cxx11.cpp index c3e7370e37..fd59ae6140 100644 --- a/test/CodeGenCXX/mangle-ms-cxx11.cpp +++ b/test/CodeGenCXX/mangle-ms-cxx11.cpp @@ -1,5 +1,8 @@ // RUN: %clang_cc1 -std=c++11 -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s +// CHECK: "\01?DeducedType@@3HA" +auto DeducedType = 30; + // CHECK: "\01?LRef@@YAXAAH@Z" void LRef(int& a) { }