[PATCH] D113490: [NFC] Let Microsoft mangler accept GlobalDecl

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 9 12:39:52 PST 2021

rnk added inline comments.

Comment at: clang/lib/AST/MicrosoftMangle.cpp:47
+  if (auto *CD = dyn_cast<CXXConstructorDecl>(DC))
+    GD = GlobalDecl(CD, Ctor_Complete);
+  else if (auto *DD = dyn_cast<CXXDestructorDecl>(DC))
I would prefer if you passed Ctor_Base and Dtor_Base here. I believe MSVC models the variants as separate compiler-generated functions. I believe the user code is always emitted into the "base" variant. That's consistent with what the user can observe in `__FUNCDNAME__`, see here:

Comment at: clang/lib/AST/MicrosoftMangle.cpp:345
   MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_,
                           const CXXConstructorDecl *D, CXXCtorType Type)
I would like to remove these constructor overloads, but I don't feel like I can ask you to do it.

Comment at: clang/lib/AST/MicrosoftMangle.cpp:1250
       if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
-        mangle(FD, "?");
+        mangle(getGlobalDeclAsDeclContext(FD), "?");
So, nested calls to `mangle` seem like they mostly come up when you have entities inside function scopes. I think when we have things inside structors, we want to mangle using the base ctor/dtor variant.



More information about the cfe-commits mailing list