[PATCH] [ms-cxxabi] Mangle dynamic initializer stubs the same way MSVC does
Reid Kleckner
rnk at google.com
Tue Sep 10 13:40:01 PDT 2013
Committing now that D1416 landed.
================
Comment at: lib/CodeGen/CGDeclCXX.cpp:269
@@ +268,3 @@
+ llvm::raw_svector_ostream Out(FnName);
+ getCXXABI().getMangleContext().mangleDynamicInitializer(D, Out);
+ }
----------------
Timur Iskhodzhanov wrote:
> Interesting:
> I've seen a few instances of code like this:
>
> SmallString<256> FnName;
> llvm::raw_svector_ostream Out(FnName);
> getCXXABI().getMangleContext().mangleDynamicInitializer(D, Out);
> Out.flush();
>
> without the scope.
> Personally, I like your code more, but not sure what's the reason for the "old" (?) way to get the mangled symbol.
> Is it just legacy?
I like this way is better because the stream is destroyed earlier and any temporary resources are freed. I guess the old style persists because artificial scopes are weird.
================
Comment at: lib/AST/MicrosoftMangle.cpp:1975
@@ -1970,3 +1974,3 @@
MicrosoftCXXNameMangler Mangler(*this, Out);
- Mangler.getStream() << "\01??__F";
+ Mangler.getStream() << "\01??__" << CharCode;
Mangler.mangleName(D);
----------------
Timur Iskhodzhanov wrote:
> Hm, I've seen a few snippets like this:
>
> MicrosoftCXXNameMangler Mangler(*this, Out);
> ...
> Out << ...;
> ...
>
> instead of
>
> MicrosoftCXXNameMangler Mangler(*this, Out);
> ...
> Mangler.getStream() << ...;
> ...
>
> Any ideas which one is better?
I don't know which is better. FWIW Itanium standardizes on getStream(). MS::mangleThunk() is the only outlier.
http://llvm-reviews.chandlerc.com/D1477
More information about the cfe-commits
mailing list