[PATCH] D146386: [MS ABI] Fix mangling references to declarations.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 28 14:26:36 PDT 2023


efriedma added inline comments.


================
Comment at: clang/lib/AST/MicrosoftMangle.cpp:1250
+      for (unsigned I = 1, IE = ID->getChainingSize(); I < IE; ++I)
+        mangleSourceName("<unnamed-tag>");
+
----------------
bolshakov-a wrote:
> bolshakov-a wrote:
> > efriedma wrote:
> > > bolshakov-a wrote:
> > > > efriedma wrote:
> > > > > bolshakov-a wrote:
> > > > > > efriedma wrote:
> > > > > > > Weird indentation
> > > > > > I agree. Don't know why clang-format does so. Should I put `clang-format off` here?
> > > > > If clang-format won't cooperate, you can probably make it figure out what you're doing with something like
> > > > > 
> > > > >   if (const auto *ID = dyn_cast<IndirectFieldDecl>(ND)) {
> > > > >     for (unsigned I = 1, IE = ID->getChainingSize(); I < IE; ++I)
> > > > >       mangleSourceName("<unnamed-tag>");
> > > > >   }
> > > > It doesn't help. Moreover, clang-format corrupts formatting in this function even without my changes. You can check it by yourself.
> > > I just tried "clang-format -i" on the file with your patch, and it seems to compute the correct indentation here.  This with a source tree and clang-format binary from feb 28 because that's what I had handy... but I don't think anything relevant has changed here?
> > Running clang-format on the whole file really seems to produce correct formatting... But it is a lot of unrelated changes. Running clang-format only on the `mangleNestedName` function (`--lines=1185:1287` without my changes, `--lines=1242:1349` with my changes) produces bad formatting.
> I could make a separate PR with formatting this file and fix this PR after landing that one.
If `clang-format --lines` is broken, just fix the formatting by hand (and file a bug against clang-format).


================
Comment at: clang/lib/AST/MicrosoftMangle.cpp:1816
 
-      QualType T = Base.getType();
+      std::stack<char> EntryTypeStack;
+      SmallVector<std::function<void()>, 2> EntryManglers;
----------------
bolshakov-a wrote:
> efriedma wrote:
> > Please just use SmallVector instead of std::stack.
> `std::stack` can be parameterized with container type (`std::stack<char, SmallVector<char, 2>>`). Or it should not be used for some other reason?
Using std::stack as a wrapper around SmallVector is sort of pointless; you can just explicitly push_back/pop_back.


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

https://reviews.llvm.org/D146386



More information about the cfe-commits mailing list