loladiro 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; +} + ---------------- majnemer wrote: > 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. So you're concerned about this case: ``` template < typename T > auto foo( T x ) { class inner { T y; public: virtual ~inner() {} inner(T y) : y(y) {} T getY() { return y; } }; return inner{x}.getY(); }
extern template __attribute__((unique_instantiation)) auto foo<int>(int); template __attribute__((unique_instantiation)) auto foo<int>(int); ``` Right now the inner class's vtable and method is linkonce_odr. If you think it should be strong I'll look into it. http://reviews.llvm.org/D13330 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits