[PATCH] [-cxx-abi microsoft] Mangle local TagDecls appropriately

Reid Kleckner rnk at google.com
Wed Aug 28 11:44:02 PDT 2013


  My two cents, but I'd also defer to others for changes to core AST nodes like TagDecl.


================
Comment at: test/CodeGenCXX/mangle-ms.cpp:252
@@ +251,3 @@
+    int a_field;
+  } static_variable_in_inline_function = { 20 };
+  // CHECK: @"\01?static_variable_in_inline_function@?1??inline_function_with_local_type@@YAHXZ at 4U<unnamed-type-static_variable_in_inline_function>@?1??1 at YAHXZ@A"
----------------
You can improve on this with:
  inline int inline_function_with_local_type() {
    static struct {
      int a_field;
    } static_variable_in_inline_function = { 20 }, second_static = { 40 };
    return static_variable_in_inline_function.a_field + second_static.a_field;
  }

I verified that cl.exe uses the first variable name in the type.

================
Comment at: include/clang/AST/Decl.h:2672
@@ -2668,1 +2671,3 @@
 
+  bool hasDeclaratorForAnonDecl() const {
+    return dyn_cast_or_null<DeclaratorDecl>(
----------------
Charles Davis wrote:
> This is ugly. It seems to me that it should be possible to just say:
> 
>   lang=c++
>   NamedDeclOrQualifier.dyn_cast<DeclaratorDecl *>()
> 
> instead of having to explicitly grab the `NamedDecl` pointer, then `dyn_cast_or_null` it to `DeclaratorDecl`. But this is a limitation of `llvm::PointerUnion` anyway; nothing we can do about it here.
> 
Can we avoid talking about typedefs vs declarator decls at all here?  It seems like this field should point to whatever NamedDecl the first identifier in the declarator group created, whether it's a TypedefDecl or a DeclaratorDecl.  We don't need these helpers, we can just let the caller dyn_cast to see if it's a typedef or not.

This would simplifiy the serialization code as well.


http://llvm-reviews.chandlerc.com/D1540



More information about the cfe-commits mailing list