]> granicus.if.org Git - clang/commitdiff
MSVC ABI: Support C++11's auto on variables
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 21 Jan 2014 20:33:36 +0000 (20:33 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 21 Jan 2014 20:33:36 +0000 (20:33 +0000)
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

lib/AST/MicrosoftMangle.cpp
test/CodeGenCXX/mangle-ms-cxx11.cpp

index 30c53ed0ef1b6f30adc4640443f9125a68399eb0..ece12049e7af75d3df7685e17109d33c01dd33cc 100644 (file)
@@ -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");
index c3e7370e3792ccb1d212b4b8d05fc5915f35b91c..fd59ae6140e967d32daba2595128b7652ecebd4d 100644 (file)
@@ -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) { }