[cfe-commits] r72433 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiate.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp test/CodeGenCXX/explicit-instantiation.cpp
Douglas Gregor
dgregor at apple.com
Tue May 26 13:50:52 PDT 2009
Author: dgregor
Date: Tue May 26 15:50:29 2009
New Revision: 72433
URL: http://llvm.org/viewvc/llvm-project?rev=72433&view=rev
Log:
Make sure that CodeGen sees template instantiations.
Added:
cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=72433&r1=72432&r2=72433&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Tue May 26 15:50:29 2009
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===/
#include "Sema.h"
+#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Expr.h"
#include "clang/AST/DeclTemplate.h"
@@ -779,6 +780,9 @@
// Exit the scope of this instantiation.
CurContext = PreviousContext;
+ if (!Invalid)
+ Consumer.HandleTagDeclDefinition(Instantiation);
+
// If this is an explicit instantiation, instantiate our members, too.
if (!Invalid && ExplicitInstantiation) {
Inst.Clear();
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=72433&r1=72432&r2=72433&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue May 26 15:50:29 2009
@@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===/
#include "Sema.h"
+#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/DeclVisitor.h"
@@ -622,6 +623,9 @@
/*IsInstantiation=*/true);
CurContext = PreviousContext;
+
+ DeclGroupRef DG(Function);
+ Consumer.HandleTopLevelDecl(DG);
}
/// \brief Instantiate the definition of the given variable from its
Added: cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp?rev=72433&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp Tue May 26 15:50:29 2009
@@ -0,0 +1,11 @@
+// RUN: clang-cc -emit-llvm -femit-all-decls -o %t %s &&
+// RUN: grep "_ZNK4plusIillEclERKiRKl" %t | count 1
+
+template<typename T, typename U, typename Result>
+struct plus {
+ Result operator()(const T& t, const U& u) const {
+ return t + u;
+ }
+};
+
+template struct plus<int, long, long>;
More information about the cfe-commits
mailing list