From: David Majnemer Date: Tue, 29 Dec 2015 11:46:00 +0000 (+0000) Subject: [MS ABI] Implement a mangling for _Atomic types X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b91542bfcc08d2732650e387f7861f6aebc83b7;p=clang [MS ABI] Implement a mangling for _Atomic types MSVC doesn't implement a mangling for C11's _Atomic so we must invent our own. For now, treating it like a class type called _Atomic in the __clang namespace. This means that 'void f(__Atomic(int))' will demangle as: 'void f(struct __clang::_Atomic)' git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256557 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index e4b043939f..1f3ba15a5b 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -2391,11 +2391,16 @@ void MicrosoftCXXNameMangler::mangleType(const AutoType *T, Qualifiers, void MicrosoftCXXNameMangler::mangleType(const AtomicType *T, Qualifiers, SourceRange Range) { - DiagnosticsEngine &Diags = Context.getDiags(); - unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, - "cannot mangle this C11 atomic type yet"); - Diags.Report(Range.getBegin(), DiagID) - << Range; + QualType ValueType = T->getValueType(); + + llvm::SmallString<64> TemplateMangling; + llvm::raw_svector_ostream Stream(TemplateMangling); + MicrosoftCXXNameMangler Extra(Context, Stream); + Stream << "?$"; + Extra.mangleSourceName("_Atomic"); + Extra.mangleType(ValueType, Range, QMM_Escape); + + mangleArtificalTagType(TTK_Struct, TemplateMangling, {"__clang"}); } void MicrosoftMangleContextImpl::mangleCXXName(const NamedDecl *D, diff --git a/test/CodeGenCXX/mangle-ms.cpp b/test/CodeGenCXX/mangle-ms.cpp index 98277dc9a3..5fe0974c87 100644 --- a/test/CodeGenCXX/mangle-ms.cpp +++ b/test/CodeGenCXX/mangle-ms.cpp @@ -437,3 +437,8 @@ int foo(int *const i __attribute__((pass_object_size(0)))) { return 0; } // CHECK-DAG: define i32 @"\01?bar@PassObjectSize@@YAHQAHW4__pass_object_size1@__clang@@@Z" int bar(int *const i __attribute__((pass_object_size(1)))) { return 0; } } + +namespace Atomic { +// CHECK-DAG: define void @"\01?f@Atomic@@YAXU?$_Atomic@H@__clang@@@Z"( +void f(_Atomic(int)) {} +}