[PATCH] Mangling of anonymous unions

Richard Smith richard at metafoo.co.uk
Tue Nov 25 14:28:31 PST 2014


================
Comment at: lib/AST/ItaniumMangle.cpp:3913-3925
@@ +3912,15 @@
+unsigned ItaniumMangleContextImpl::uniquifyNamedDecl(const NamedDecl *ND) {
+  IdentifierInfo *Identifier = ND->getIdentifier();
+  if (!Identifier) {
+    if (const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
+      if (const RecordType *RT = VD->getType()->getAs<RecordType>()) {
+        const RecordDecl *RD = RT->getDecl();
+        if (RD->isUnion()) {
+          if (const FieldDecl *FD = RD->findFirstNamedDataMember()) {
+            Identifier = FD->getIdentifier();
+          }
+        }
+      }
+    }
+  }
+  unsigned &Discriminator = Uniquifier[ND];
----------------
Why do you need to do this? Since this code is only reached for non-externally-visible entities, a single counter for the context (like we used to use) seems like it should be sufficient.

http://reviews.llvm.org/D6295






More information about the cfe-commits mailing list