title: forcing clang to emit code for never-referenced static member function of class-template instantiation
body: <p>I can easily achieve this in <code>gcc</code> using the <code>used</code> and <code>noinline</code> <a href="http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Function-Attributes.html" rel="noreferrer">function attributes</a> (see code below), but this doesn't work in <code>clang</code> even though it's supposed to support both of these function attributes.</p>
  
  <p><strong>A simplified example:</strong></p>
  
  <pre><code>template&lt;typename T&gt;
  struct Factory {
      static __attribute__((used, noinline))
      T createFoo() { return T(); }
  };
  
  int main() {
      Factory&lt;int&gt; f; // instantiate and use Factory&lt;int&gt;
  }
  </code></pre>
  
  <p>Compile the code in <code>gcc</code> and use <code>nm</code> to confirm that gcc correctly emitted the function:</p>
  
  <pre><code>nm --demangle test | grep createFoo
  0000000000403185 W Factory&lt;int&gt;::createFoo()
  </code></pre>
  
  <p>The code compiles fine in <code>clang</code>, but it does not emit code for the static <code>createFoo()</code> function like it's supposed to.</p>
  
  <p><strong>How can I force clang to emit this static function which is never referenced?</strong></p>