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

Charles Davis cdavis5x at gmail.com
Wed Aug 28 10:33:59 PDT 2013


  LGTM, but you should really wait for John, Reid, and Richard to weigh in.


================
Comment at: include/clang/AST/Decl.h:2672-2688
@@ -2668,6 +2671,19 @@
 
+  bool hasDeclaratorForAnonDecl() const {
+    return dyn_cast_or_null<DeclaratorDecl>(
+        NamedDeclOrQualifier.get<NamedDecl *>());
+  }
+  const DeclaratorDecl *getDeclaratorForAnonDecl() const {
+    return hasExtInfo() ? 0 : dyn_cast_or_null<DeclaratorDecl>(
+                                  NamedDeclOrQualifier.get<NamedDecl *>());
+  }
+  DeclaratorDecl *getDeclaratorForAnonDecl() {
+    return hasExtInfo() ? 0 : dyn_cast_or_null<DeclaratorDecl>(
+                                  NamedDeclOrQualifier.get<NamedDecl *>());
+  }
+
   TypedefNameDecl *getTypedefNameForAnonDecl() const {
-    return hasExtInfo() ? 0 :
-           TypedefNameDeclOrQualifier.get<TypedefNameDecl*>();
+    return hasExtInfo() ? 0 : dyn_cast_or_null<TypedefNameDecl>(
+                                  NamedDeclOrQualifier.get<NamedDecl *>());
   }
 
----------------
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.



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



More information about the cfe-commits mailing list