mirror of https://github.com/microsoft/clang.git
[modules] When reading / writing a typedef that is a name for linkage for
another declaration, ensure we actually serialize / deserialize that declaration. Before this patch, if another copy of the typedef were merged with the parsed version, we would emit type information referring to the merged version and consequently emit nothing about the parsed anonymous struct. This resulted in us losing information, particularly the visible merged module set for the parsed definition. Force that information to be emitted and to be loaded when the typedef is used. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293219 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c8c23fa4f5
commit
b388a34bdd
|
@ -592,6 +592,11 @@ ASTDeclReader::VisitTypedefNameDecl(TypedefNameDecl *TD) {
|
|||
TD->setModedTypeSourceInfo(TInfo, modedT);
|
||||
} else
|
||||
TD->setTypeSourceInfo(TInfo);
|
||||
// Read and discard the declaration for which this is a typedef name for
|
||||
// linkage, if it exists. We cannot rely on our type to pull in this decl,
|
||||
// because it might have been merged with a type from another module and
|
||||
// thus might not refer to our version of the declaration.
|
||||
ReadDecl();
|
||||
return Redecl;
|
||||
}
|
||||
|
||||
|
|
|
@ -368,6 +368,7 @@ void ASTDeclWriter::VisitTypedefNameDecl(TypedefNameDecl *D) {
|
|||
Record.push_back(D->isModed());
|
||||
if (D->isModed())
|
||||
Record.AddTypeRef(D->getUnderlyingType());
|
||||
Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
|
||||
}
|
||||
|
||||
void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) {
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
typedef union {} pthread_mutex_t;
|
||||
|
||||
// Define then merge with another definition.
|
||||
typedef struct {} merged_after_definition;
|
||||
#include "c1.h"
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
module a { header "a.h" export * }
|
||||
module b { header "b.h" export * }
|
||||
module c { module c1 { header "c1.h" export * } module c2 { header "c2.h" export * } }
|
||||
|
|
|
@ -7,3 +7,4 @@ typedef pthread_mutex_t pthread_mutex_t;
|
|||
pthread_mutex_t x;
|
||||
#include "b.h"
|
||||
pthread_mutex_t y;
|
||||
merged_after_definition z;
|
||||
|
|
Loading…
Reference in New Issue