[PATCH] D40929: Unblock Swift Calling Convention Mangling on Windows

2017-12-15 Thread Thomas Roughton via Phabricator via cfe-commits
troughton marked an inline comment as done.
troughton added a comment.

> Which, I think is just adding something wacky like `@swiftcc@__Swift@@` which 
> would demangle as `__Swift::swiftcc` if the demangler expected an NNS there. 
> Of course, it doesn't, so it won't demangle, but at least you can overload 
> between cdecl and swiftcc then.

Could we do a combination of these? Use the `A` prefix for the CC slot but then 
append the `@swiftcc@__Swift@@` at the end of the qualified name? That way you 
could still distinguish a SwiftCC function and have it correctly demangle with 
existing tools.

As for emitting a proper diagnostic: we definitely can do something better 
here. I wasn't sure what to base it off so went with the simplest option, but 
given that `CodeGenModule::ErrorUnsupported` example I'll take a look and try 
to implement something similar.




Comment at: lib/AST/MicrosoftMangle.cpp:2133
+  llvm::errs() << "Unsupported CC for mangling: " << CC << ".\n";
 case CC_Win64:
 case CC_X86_64SysV:

smeenai wrote:
> You still need the default label, right?
Oops, yes. Thanks. I've added it back.


Repository:
  rC Clang

https://reviews.llvm.org/D40929



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40929: Unblock Swift Calling Convention Mangling on Windows

2017-12-06 Thread Thomas Roughton via Phabricator via cfe-commits
troughton created this revision.
troughton added a project: clang.
Herald added a subscriber: cfe-commits.

Following discussion on the [[ 
https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20171204/006123.html | 
swift-dev mailing list] and on a pull request for swift-clang 
, unblock support for the Swift 
calling convention on targets using Microsoft mangling by mangling the name as 
per the __cdecl calling convention.

Also in this PR, replace llvm_unreachable with an error diagnostic since this 
code path can be hit.


Repository:
  rC Clang

https://reviews.llvm.org/D40929

Files:
  lib/AST/MicrosoftMangle.cpp


Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -2130,10 +2130,12 @@
   // them.)

   switch (CC) {
-default:
-  llvm_unreachable("Unsupported CC for mangling");
+  llvm::errs() << "Unsupported CC for mangling: " << CC << ".\n";
 case CC_Win64:
 case CC_X86_64SysV:
+// NOTE: SwiftCC should have its own mangling specifier.
+// For now, don't do anything special and treat SwiftCC like __cdecl.
+case CC_Swift:
 case CC_C: Out << 'A'; break;
 case CC_X86Pascal: Out << 'C'; break;
 case CC_X86ThisCall: Out << 'E'; break;


Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -2130,10 +2130,12 @@
   // them.)

   switch (CC) {
-default:
-  llvm_unreachable("Unsupported CC for mangling");
+  llvm::errs() << "Unsupported CC for mangling: " << CC << ".\n";
 case CC_Win64:
 case CC_X86_64SysV:
+// NOTE: SwiftCC should have its own mangling specifier.
+// For now, don't do anything special and treat SwiftCC like __cdecl.
+case CC_Swift:
 case CC_C: Out << 'A'; break;
 case CC_X86Pascal: Out << 'C'; break;
 case CC_X86ThisCall: Out << 'E'; break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40929: Unblock Swift Calling Convention Mangling on Windows

2017-12-06 Thread Thomas Roughton via Phabricator via cfe-commits
troughton updated this revision to Diff 125847.
troughton added a comment.

Add back a mistakenly removed default case.


Repository:
  rC Clang

https://reviews.llvm.org/D40929

Files:
  lib/AST/MicrosoftMangle.cpp


Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -2131,9 +2131,12 @@

   switch (CC) {
 default:
-  llvm_unreachable("Unsupported CC for mangling");
+  llvm::errs() << "Unsupported CC for mangling" << CC << ".\n";
 case CC_Win64:
 case CC_X86_64SysV:
+// NOTE: SwiftCC should have its own mangling specifier.
+// For now, don't do anything special and treat SwiftCC like __cdecl.
+case CC_Swift:
 case CC_C: Out << 'A'; break;
 case CC_X86Pascal: Out << 'C'; break;
 case CC_X86ThisCall: Out << 'E'; break;


Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -2131,9 +2131,12 @@

   switch (CC) {
 default:
-  llvm_unreachable("Unsupported CC for mangling");
+  llvm::errs() << "Unsupported CC for mangling" << CC << ".\n";
 case CC_Win64:
 case CC_X86_64SysV:
+// NOTE: SwiftCC should have its own mangling specifier.
+// For now, don't do anything special and treat SwiftCC like __cdecl.
+case CC_Swift:
 case CC_C: Out << 'A'; break;
 case CC_X86Pascal: Out << 'C'; break;
 case CC_X86ThisCall: Out << 'E'; break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits