r205270 - MS ABI: Simplify MangleByte further

David Majnemer david.majnemer at gmail.com
Mon Mar 31 17:05:57 PDT 2014


Author: majnemer
Date: Mon Mar 31 19:05:57 2014
New Revision: 205270

URL: http://llvm.org/viewvc/llvm-project?rev=205270&view=rev
Log:
MS ABI: Simplify MangleByte further

It turns out that the ranges where the '?' <letter> manglings occur are
identical to the ranges of ASCII characters OR'd with 0x80.

Thanks to Richard Smith for the insight!

No functional change.

Modified:
    cfe/trunk/lib/AST/MicrosoftMangle.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=205270&r1=205269&r2=205270&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Mar 31 19:05:57 2014
@@ -2428,13 +2428,10 @@ void MicrosoftMangleContextImpl::mangleS
     // - ?[A-Z]: The range from \xc1 to \xda.
     // - ?[0-9]: The set of [,/\:. \n\t'-].
     // - ?$XX: A fallback which maps nibbles.
-    if ((Byte >= 'a' && Byte <= 'z') || (Byte >= 'A' && Byte <= 'Z') ||
-        (Byte >= '0' && Byte <= '9') || Byte == '_' || Byte == '$') {
+    if (isIdentifierBody(Byte, /*AllowDollar=*/true)) {
       Mangler.getStream() << Byte;
-    } else if ((Byte >= '\xe1' && Byte <= '\xfa') ||
-               (Byte >= '\xc1' && Byte <= '\xda')) {
-      // The delta between '\xe1' and '\xc1' is the same as 'a' to 'A'.
-      Mangler.getStream() << '?' << static_cast<char>('A' + (Byte - '\xc1'));
+    } else if (isLetter(Byte & 0x7f)) {
+      Mangler.getStream() << '?' << static_cast<char>(Byte & 0x7f);
     } else {
       switch (Byte) {
         case ',':





More information about the cfe-commits mailing list