Go to file
Bruno Cardoso Lopes 84df6e99b8 [PCH] Avoid VarDecl emission attempt if no owning module avaiable
This is a stopgap fix for PR31863, a regression introduced in r276159.

Consider this snippet:

struct FVector;
struct FVector {};
struct FBox {
  FVector Min;
  FBox(int);
};
namespace {
FBox InvalidBoundingBox(0);
}

While parsing the DECL_VAR for 'struct FBox', clang recursively read all the
dep decls until it finds the DECL_CXX_RECORD forward declaration for 'struct
FVector'. Then, it resumes all the way up back to DECL_VAR handling in
`ReadDeclRecord`, where it checks if `isConsumerInterestedIn` for the decl.

One of the condition for `isConsumerInterestedIn` to return false is if the
VarDecl is imported from a module `D->getImportedOwningModule()`, because it
will get emitted when we import the relevant module. However, before checking
if it comes from a module, clang checks if `Ctx.DeclMustBeEmitted(D)`, which
triggers the emission of 'struct FBox'. Since one of its fields is still
incomplete, it crashes.

Instead, check if `D->getImportedOwningModule()` is true before calling
`Ctx.DeclMustBeEmitted(D)`.

Differential Revision: https://reviews.llvm.org/D29753

rdar://problem/30173654

llvm-svn: 296656
2017-03-01 19:18:42 +00:00
clang [PCH] Avoid VarDecl emission attempt if no owning module avaiable 2017-03-01 19:18:42 +00:00
clang-tools-extra [clangd] Unbreak the shared build. 2017-03-01 16:23:40 +00:00
compiler-rt Reapply r296419: [asan] Print a "PC is at a non-executable memory region" message if that's the case 2017-03-01 18:52:11 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc math: Implement sinh function 2017-02-25 02:46:53 +00:00
libcxx [libcxx] Support threads on Fuchsia 2017-03-01 03:09:18 +00:00
libcxxabi [libcxxabi] Clean up macro usage. 2017-03-01 11:42:01 +00:00
libunwind Fix the project name in the license file. 2017-02-27 17:47:58 +00:00
lld Add a reference to a Ulrich Drepper's paper. 2017-03-01 18:09:09 +00:00
lldb Mark TestYMMRegister as no_debug_info_test 2017-03-01 11:18:59 +00:00
llgo [llgo] Remove support for LLVM attributes 2016-12-06 19:22:04 +00:00
llvm Alphabetize some cases (NFC) 2017-03-01 19:01:47 +00:00
openmp Removing couple unnecessary architecture guards. 2017-02-28 21:43:28 +00:00
parallel-libs [Axccel] Remove -Wno-missing-braces in build 2016-12-19 21:34:07 +00:00
polly Fix namespaces after clang-format update 2017-03-01 15:54:27 +00:00