[PATCH] [ms-cxxabi] Implement guard variables for static initialization

Reid Kleckner rnk at google.com
Wed Sep 4 10:10:20 PDT 2013


On Fri, Aug 30, 2013 at 10:45 AM, Reid Kleckner <rnk at google.com> wrote:

>
>
> ================
> Comment at: lib/Sema/SemaLambda.cpp:101
> @@ -98,1 +100,3 @@
> +        (isa<FunctionDecl>(CurContext) &&
> +         Context.getTargetInfo().getCXXABI().isMicrosoft())) {
>        ManglingContextDecl = 0;
> ----------------
> Eli Friedman wrote:
> > Why do you need to number anything in a function which isn't inline?
>  CodeGen can mangle static variables etc.  however it wants because they
> aren't externally visible.
> I'm using these to number bits in a bitfield, not to mangle.  I have to
> use this mechanism to number the bits of inline functions, so it makes
> sense to use it to number bits of non inline functions too.  Otherwise I
> have to add back the CXXABIFunctionState code I had in the first version of
> this patch.
>
> I'm having a very hard time extracting this function from Sema and moving
> it over to AST/ItaniumCXXABI.cpp as John suggested.  It accesses a bunch of
> Sema fields.  Do you have any thoughts on how this should look in the long
> run?
>

Any thoughts on this?  This is needed to avoid double initialization of
llvm::outs/errs(), and factoring this one check out will require a massive
migration of Eli's Itanium logic from Sema to AST.

OK to commit with a FIXME?  Or without one, since I generally find comments
like "FIXME: refactor" to be useless.


> I expect I will also need to number other things like scopes to handle
> your example of:
>   int bar();
>   inline void foo() {
>     static int f = bar();
>     { static int f = bar(); }
>   }
>
> These are differentiated by mangling in the current scope depth.  The
> first f is at level 2 (global 0?, param, local) and the second f is at
> level 3 (+1 local scope).  MicrosoftCXXNameMangler::mangleLocalName()
> attempts to implement this, but it is wrong.
>
>
> http://llvm-reviews.chandlerc.com/D1416
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130904/6d636ae5/attachment.html>


More information about the cfe-commits mailing list