[PATCH] D90714: [clang]Fix length threshold for MicrosoftMangle md5 hash

Melanie Blower via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 7 07:44:43 PST 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc511963d5adb: [clang] Fix length threshold for MicrosoftMangle md5 hash (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90714/new/

https://reviews.llvm.org/D90714

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-ms-md5.cpp


Index: clang/test/CodeGenCXX/mangle-ms-md5.cpp
===================================================================
--- clang/test/CodeGenCXX/mangle-ms-md5.cpp
+++ clang/test/CodeGenCXX/mangle-ms-md5.cpp
@@ -49,3 +49,25 @@
 // HAVECTOR: "_CT??@c14087f0ec22b387aea7c59083f4f546@??@4ef4f8979c81f9d2224b32bf327e6bdf at 4"
 }
 #endif
+
+// Verify the threshold where md5 mangling kicks in
+// Test an ident with 4088 characters, pre-hash, MangleName.size() is 4095
+#define X4088(X)                                \
+    C2(C2(                                      \
+      C4(X,       X4(X),   X4(X),    X8(X)),    \
+      C4(X8(X),   X32(X),  X64(X),   X128(X))), \
+      C4(X256(X), X512(X), X1024(X), X2048(X)))
+#define Z4088 X4088(z)
+// Use initialization to verify mangled name association in the il
+int X4088(z) = 1515;
+// CHECK-DAG: @"?{{z+}}@@3HA" = dso_local global i32 1515, align 4
+
+// Test an ident with 4089 characters, pre-hash, MangleName.size() is 4096
+#define X4089(X)                                \
+    C2(C2(                                      \
+      C4(X2(X),   X4(X),   X4(X),    X8(X)),    \
+      C4(X8(X),   X32(X),  X64(X),   X128(X))), \
+      C4(X256(X), X512(X), X1024(X), X2048(X)))
+// Use initialization to verify mangled name association in the il
+int X4089(z) = 1717;
+// CHECK-DAG: @"??@0269945400a3474730d6880df0967d8f@" = dso_local global i32 1717, align 4
Index: clang/lib/AST/MicrosoftMangle.cpp
===================================================================
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -50,7 +50,7 @@
     bool StartsWithEscape = MangledName.startswith("\01");
     if (StartsWithEscape)
       MangledName = MangledName.drop_front(1);
-    if (MangledName.size() <= 4096) {
+    if (MangledName.size() < 4096) {
       OS << str();
       return;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90714.303641.patch
Type: text/x-patch
Size: 1862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201107/8479d9d5/attachment.bin>


More information about the cfe-commits mailing list