[PATCH] D154875: [MicrosoftDemangle] fix warn-trailing false positive

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 13:39:07 PDT 2023


nickdesaulniers updated this revision to Diff 538809.
nickdesaulniers edited the summary of this revision.
nickdesaulniers added a comment.

- format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154875

Files:
  llvm/lib/Demangle/MicrosoftDemangle.cpp
  llvm/test/Demangle/warn-trailing.test


Index: llvm/test/Demangle/warn-trailing.test
===================================================================
--- llvm/test/Demangle/warn-trailing.test
+++ llvm/test/Demangle/warn-trailing.test
@@ -4,3 +4,8 @@
 ; CHECK: ?x@@3HAasdf
 ; CHECK-NEXT: int x
 ; CHECK-NEXT: warning: trailing characters: asdf
+
+.?AVNet@@
+; CHECK: .?AVNet@@
+; CHECK-NEXT: class Net `RTTI Type Descriptor Name'
+; CHECK-NOT: warning: trailing characters
Index: llvm/lib/Demangle/MicrosoftDemangle.cpp
===================================================================
--- llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -2404,7 +2404,8 @@
   std::string_view Name{MangledName};
   SymbolNode *AST = D.parse(Name);
   if (!D.Error && NMangled)
-    *NMangled = Name.empty() ? 0 : &*Name.begin() - &*MangledName.begin();
+    *NMangled = Name.empty() ? MangledName.size()
+                             : &*Name.begin() - &*MangledName.begin();
 
   if (Flags & MSDF_DumpBackrefs)
     D.dumpBackReferences();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154875.538809.patch
Type: text/x-patch
Size: 1028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230710/54a87578/attachment.bin>


More information about the llvm-commits mailing list