From 3f95477f28ef3baaf79001a5654785c8b2075710 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 5 Aug 2010 09:47:59 +0000 Subject: [PATCH] Make sure C++ variable definitions are actually passed to the consumer when loaded from PCH. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110322 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/PCHReaderDecl.cpp | 3 ++- test/PCH/cxx-required-decls.cpp | 1 + test/PCH/cxx-required-decls.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index 7557950e66..a6a68d9425 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -1350,7 +1350,8 @@ static bool isConsumerInterestedIn(Decl *D) { if (isa(D)) return true; if (VarDecl *Var = dyn_cast(D)) - return Var->isFileVarDecl() && Var->getInit(); + return Var->isFileVarDecl() && + Var->isThisDeclarationADefinition() == VarDecl::Definition; if (FunctionDecl *Func = dyn_cast(D)) return Func->isThisDeclarationADefinition(); return isa(D); diff --git a/test/PCH/cxx-required-decls.cpp b/test/PCH/cxx-required-decls.cpp index 818958ea1e..8c4b11cd84 100644 --- a/test/PCH/cxx-required-decls.cpp +++ b/test/PCH/cxx-required-decls.cpp @@ -7,3 +7,4 @@ // CHECK: @_ZL5globS = internal global %struct.S zeroinitializer // CHECK: @_ZL3bar = internal global i32 0, align 4 +// CHECK: @glob_var = global i32 0 diff --git a/test/PCH/cxx-required-decls.h b/test/PCH/cxx-required-decls.h index df28ad6c2f..099d2da56c 100644 --- a/test/PCH/cxx-required-decls.h +++ b/test/PCH/cxx-required-decls.h @@ -8,3 +8,5 @@ static S globS; extern int ext_foo; static int bar = ++ext_foo; + +int glob_var;