[PATCH] D110577: [llvm-cxxfilt] Enable support for D programming language demangling

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 30 13:27:46 PDT 2021


dblaikie added inline comments.


================
Comment at: llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp:79-99
   if (Types ||
       ((DecoratedLength >= 2 && strncmp(DecoratedStr, "_Z", 2) == 0) ||
        (DecoratedLength >= 4 && strncmp(DecoratedStr, "___Z", 4) == 0)))
     Undecorated = itaniumDemangle(DecoratedStr, nullptr, nullptr, &Status);
 
   if (!Undecorated &&
       (DecoratedLength > 6 && strncmp(DecoratedStr, "__imp_", 6) == 0)) {
----------------
Perhaps this code could be refactored to be shared with llvm-symbolizer? (eg: the code being updated in D110664 here: `llvm/lib/DebugInfo/Symbolize/Symbolize.cpp`)


================
Comment at: llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp:21
 #include <cstdlib>
+#include <cstring>
 #include <iostream>
----------------
jhenderson wrote:
> ljmf00 wrote:
> > jhenderson wrote:
> > > I don't think you need to include this header - `strncmp` is already used in this file, so it's clearly being included through the existing include hierarchy. See also https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible.
> > Yeah, my editor LSP plugin probably added it automatically by mistake, and no apparent duplication was detected. I'm going to remove it!
> No problem!
Generally we should include anything we depend on - not rely on indirect inclusions. (the style guide gives some allowance for this - like if some other header just has to have provided a definition/inclusion of a thing, that's fine - but in this case there's no strong connection between whatever header includes something for strncmp so it's suitable to include it here, so if that other header is refactored to remove the need/use of the header it doesn't break this code)

So this #include is probably good/proper here.

The advice in the style guide is about not including unused headers and not including headers when a forward declaration would suffice.


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

https://reviews.llvm.org/D110577



More information about the llvm-commits mailing list