[llvm-branch-commits] [cfe-branch] r296762 - Merging r296656:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Mar 2 08:47:48 PST 2017
Author: hans
Date: Thu Mar 2 10:47:48 2017
New Revision: 296762
URL: http://llvm.org/viewvc/llvm-project?rev=296762&view=rev
Log:
Merging r296656:
------------------------------------------------------------------------
r296656 | bruno | 2017-03-01 11:18:42 -0800 (Wed, 01 Mar 2017) | 34 lines
[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
------------------------------------------------------------------------
Added:
cfe/branches/release_40/test/PCH/empty-def-fwd-struct.h
- copied unchanged from r296656, cfe/trunk/test/PCH/empty-def-fwd-struct.h
Modified:
cfe/branches/release_40/ (props changed)
cfe/branches/release_40/lib/Serialization/ASTReaderDecl.cpp
Propchange: cfe/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar 2 10:47:48 2017
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:291850,291853,291865,291871,291877,291879,291881,291907,291955,291963-291964,292032,292052,292183,292194,292247,292265,292497,292555,292558-292559,292561,292590,292800,292847,292874,292991,293043,293134,293360,293369,293596,293604,293678,293787,294008,294800,294855,294954,295149-295150,295224,295313,295473-295474,295592,295610,295843,296063
+/cfe/trunk:291850,291853,291865,291871,291877,291879,291881,291907,291955,291963-291964,292032,292052,292183,292194,292247,292265,292497,292555,292558-292559,292561,292590,292800,292847,292874,292991,293043,293134,293360,293369,293596,293604,293678,293787,294008,294800,294855,294954,295149-295150,295224,295313,295473-295474,295592,295610,295843,296063,296656
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_40/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/lib/Serialization/ASTReaderDecl.cpp?rev=296762&r1=296761&r2=296762&view=diff
==============================================================================
--- cfe/branches/release_40/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/branches/release_40/lib/Serialization/ASTReaderDecl.cpp Thu Mar 2 10:47:48 2017
@@ -2513,8 +2513,8 @@ static bool isConsumerInterestedIn(ASTCo
// An ImportDecl or VarDecl imported from a module will get emitted when
// we import the relevant module.
- if ((isa<ImportDecl>(D) || isa<VarDecl>(D)) && Ctx.DeclMustBeEmitted(D) &&
- D->getImportedOwningModule())
+ if ((isa<ImportDecl>(D) || isa<VarDecl>(D)) && D->getImportedOwningModule() &&
+ Ctx.DeclMustBeEmitted(D))
return false;
if (isa<FileScopeAsmDecl>(D) ||
More information about the llvm-branch-commits
mailing list