[PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 28 12:51:16 PDT 2016


rsmith added a comment.

Thank you! I'm happy with this implementation (other than some data structure improvements), and cxx-abi-dev discussion seems to be settling on this approach (mangling the return type / variable type to extract attributes) being the right one.

(Minor nit: please make sure that your comments start with a capital letter and end in a period.)


================
Comment at: lib/AST/ItaniumMangle.cpp:352-355
@@ +351,6 @@
+          UsedAbiTags.insert(Tag);
+          if (std::find(TagList.begin(), TagList.end(), Tag) == TagList.end()) {
+            // don't insert duplicates
+            TagList.push_back(Tag);
+          }
+        }
----------------
You're going to sort the result list anyway, so how about adding the tag here without checking if it's already present, then using `std::unique` to weed out duplicates after you sort?

================
Comment at: lib/AST/ItaniumMangle.cpp:679-683
@@ +678,7 @@
+  // Get tags from return type that are not present in function name or encoding
+  AbiTagList AdditionalAbiTags;
+  for (const auto &Tag : ReturnTypeAbiTags) {
+    if (!FunctionEncodingMangler.AbiTagsRoot.getUsedAbiTags().count(Tag))
+      AdditionalAbiTags.push_back(Tag);
+  }
+
----------------
Instead of keeping the `UsedAbiTags` as a `SmallSetVector`, you can just keep a `SmallVector` of them, and sort/unique it here. Since you keep the list of emitted ABI tags sorted, you can then use `std::set_difference` to extract the additional tags in linear time.


http://reviews.llvm.org/D18035





More information about the cfe-commits mailing list