[PATCH] D47875: [MS ABI] Mangle unnamed empty enums (PR37723)

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 7 08:02:45 PDT 2018


hans added a comment.

Thanks!



================
Comment at: lib/AST/MicrosoftMangle.cpp:888-891
         auto EnumeratorI = ED->enumerator_begin();
-        assert(EnumeratorI != ED->enumerator_end());
-        Name += "<unnamed-enum-";
-        Name += EnumeratorI->getName();
+        if (EnumeratorI == ED->enumerator_end()) {
+          Name += "<unnamed-tag";
+        } else {
----------------
majnemer wrote:
> Thinking about it some more, it'd be better if we handled this like the else case:
>   Name += "<unnamed-type-$S";
>   Name += llvm::utostr(Context.getAnonymousStructId(TD) + 1);
> 
> Reason being that something like:
>   struct S {
>     enum {};
>     enum {};
>   };
> 
> Would otherwise end up with two identical mangles.
> 
> This would also make us more consistent with other mangles, for example:
>   enum {} x;
>   struct {} y;
> 
> These are mangled as: <unnamed-type-x> and <unnamed-type-y>.
Okay, yeah that makes sense.

I just checked

struct S {
  enum {};
  enum {};
};

with MSVC, and they seem to give them identical mangling.

I have to head out, but will update the patch tomorrow morning unless you're keen to do it :-)


https://reviews.llvm.org/D47875





More information about the cfe-commits mailing list