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

Reid Kleckner rnk at google.com
Fri Aug 30 10:45:53 PDT 2013



================
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?

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



More information about the cfe-commits mailing list