From: Argyrios Kyrtzidis Date: Thu, 29 Jul 2010 20:07:52 +0000 (+0000) Subject: Weak references and variables that are not definitions are not required for early... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab411c8c2efed8f2403bf8596e780c0f2f905a19;p=clang Weak references and variables that are not definitions are not required for early codegen/deserialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109796 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index af19e89fd9..633538f312 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -5550,6 +5550,10 @@ bool ASTContext::DeclIsRequiredFunctionOrFileScopedVar(const Decl *D) { } else if (!isa(D)) return false; + // Weak references don't produce any output by themselves. + if (D->hasAttr()) + return false; + // Aliases and used decls are required. if (D->hasAttr() || D->hasAttr()) return true; @@ -5587,6 +5591,9 @@ bool ASTContext::DeclIsRequiredFunctionOrFileScopedVar(const Decl *D) { const VarDecl *VD = cast(D); assert(VD->isFileVarDecl() && "Expected file scoped var"); + if (VD->isThisDeclarationADefinition() == VarDecl::DeclarationOnly) + return false; + // Structs that have non-trivial constructors or destructors are required. // FIXME: Handle references. diff --git a/test/PCH/cxx-templates.h b/test/PCH/cxx-templates.h index 47fa11eb08..92932199fa 100644 --- a/test/PCH/cxx-templates.h +++ b/test/PCH/cxx-templates.h @@ -109,3 +109,10 @@ template struct S_PR7660 { void g(void (*)(T)); }; template class C_PR7670; template<> class C_PR7670; template<> class C_PR7670; + +template +struct S2 { + static bool V; +}; + +extern template class S2;