[PATCH] D13330: Implement __attribute__((unique_instantiation))

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 7 14:03:02 PST 2015


majnemer added inline comments.

================
Comment at: lib/AST/ASTContext.cpp:8257-8266
@@ -8256,1 +8256,12 @@
 
+bool ASTContext::containedInUniqueInstantiation(const Decl *D) {
+  const RecordDecl *RD;
+  while ((RD = dyn_cast<RecordDecl>(D->getDeclContext()))) {
+    auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD);
+    if (CTSD && CTSD->hasAttr<UniqueInstantiationAttr>())
+      return true;
+    D = RD;
+  }
+  return false;
+}
+
----------------
Function templates can contain class templates which contain functions.  I think this code will return false if the outermost function template is the only one annotated with UniqueInstantiationAttr.


http://reviews.llvm.org/D13330





More information about the cfe-commits mailing list