[PATCH] D69779: -fmodules-codegen should not emit extern templates

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 13 14:58:19 PST 2020


dblaikie added inline comments.


================
Comment at: clang/test/PCH/codegen-extern-template.cpp:1-9
+// Build the PCH with extern template.
+// RUN: %clang -x c++-header %S/codegen-extern-template.h -o %t.pch -Xclang -building-pch-with-obj -Xclang -fmodules-codegen
+// Build the PCH's object file.
+// RUN: %clang -c %s -include-pch %t.pch -Xclang -building-pch-with-obj -Xclang -fmodules-codegen -o %t.1.o
+// Build source with explicit template instantiation.
+// RUN: %clang -c %s -DMAIN -include-pch %t.pch -o %t.2.o
+// There should be no unresolved symbol.
----------------
Please reduce the test to not rely on linking - it should check for the IR output of clang (not object output) for the symbols that should/shouldn't be present.

Specifically the main function is probably unneeded - and only the explicit template specialization definition is needed. The test would then verify that the required function definition is present in the IR output.

Also - to simplify this, could you change this to use an inline function template - rather than a member function? It'd make it more clear that it's the function template with 'inline' (rather than relying on the implicit inline from member functions).


================
Comment at: clang/test/PCH/codegen-extern-template.h:1-16
+// header for codegen-extern-template.cpp
+#pragma once
+
+template< typename T >
+struct A
+{
+   T foo() { return 10;}
----------------
Please run this (& the .cpp file) through clang-format, and change the #pragma once to standard header include guards (#define/etc).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69779/new/

https://reviews.llvm.org/D69779





More information about the cfe-commits mailing list