llvm-project/clang/lib/Serialization
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
..
ASTCommon.cpp Add an explicit derived class of FunctionDecl to model deduction guides rather 2017-02-17 20:05:37 +00:00
ASTCommon.h PR29097: add an update record when we instantiate the default member 2016-08-24 21:25:37 +00:00
ASTReader.cpp [ODRHash] Add basic support for CXXRecordDecl 2017-02-28 21:24:38 +00:00
ASTReaderDecl.cpp [PCH] Avoid VarDecl emission attempt if no owning module avaiable 2017-03-01 19:18:42 +00:00
ASTReaderInternals.h Remove move constructors that are identical to the generated default move ctor. 2016-10-21 18:55:07 +00:00
ASTReaderStmt.cpp [OpenMP] Prepare Sema for initial implementation for pragma 'distribute parallel for' 2017-02-17 21:29:13 +00:00
ASTWriter.cpp C++ DR1611, 1658, 2180: implement "potentially constructed subobject" rules for special member functions. 2017-02-25 23:53:05 +00:00
ASTWriterDecl.cpp Add an explicit derived class of FunctionDecl to model deduction guides rather 2017-02-17 20:05:37 +00:00
ASTWriterStmt.cpp [OpenMP] Prepare Sema for initial implementation for pragma 'distribute parallel for' 2017-02-17 21:29:13 +00:00
CMakeLists.txt Introduce module file extensions to piggy-back data onto module files. 2015-11-03 18:33:07 +00:00
GeneratePCH.cpp Use shared_ptr instead of IntrusiveRefCntPtr for ModuleFileExtension 2017-01-05 18:23:18 +00:00
GlobalModuleIndex.cpp Fix for LLVM Bitcode API change (to use std::shared_ptr) 2017-01-04 22:36:43 +00:00
Module.cpp Modules: Simplify the ModuleFile constructor; likely NFC 2017-01-29 00:39:09 +00:00
ModuleFileExtension.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
ModuleManager.cpp [modules] Load the ModuleOffsetMap from the module header lazily. 2017-02-18 00:32:02 +00:00
MultiOnDiskHashTable.h [NFC] Header cleanup 2016-07-18 19:02:11 +00:00