aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-04 17:21:36 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-04 17:21:36 +0000
commit4791fa2c3c16c51c8435706682ec0fec8647335a (patch)
tree630f50b7a1ad3a726dfc099978a626125fdaa811 /lib
parent7076281fcaab2a01e6226b05c822dd3142167636 (diff)
Implement declaration merging for variables in disjoint modules.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp
index c34243f601..84f7545e6a 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -880,8 +880,12 @@ void ASTDeclReader::VisitIndirectFieldDecl(IndirectFieldDecl *FD) {
}
void ASTDeclReader::VisitVarDecl(VarDecl *VD) {
- VisitRedeclarable(VD);
+ // Record the declaration -> global ID mapping.
+ Reader.DeclToID[VD] = ThisDeclID;
+
+ RedeclarableResult Redecl = VisitRedeclarable(VD);
VisitDeclaratorDecl(VD);
+
VD->VarDeclBits.SClass = (StorageClass)Record[Idx++];
VD->VarDeclBits.SClassAsWritten = (StorageClass)Record[Idx++];
VD->VarDeclBits.ThreadSpecified = Record[Idx++];
@@ -890,6 +894,9 @@ void ASTDeclReader::VisitVarDecl(VarDecl *VD) {
VD->VarDeclBits.NRVOVariable = Record[Idx++];
VD->VarDeclBits.CXXForRangeDecl = Record[Idx++];
VD->VarDeclBits.ARCPseudoStrong = Record[Idx++];
+
+ mergeRedeclarable(VD, Redecl);
+
if (uint64_t Val = Record[Idx++]) {
VD->setInit(Reader.ReadExpr(F));
if (Val > 1) {
@@ -1707,12 +1714,20 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
}
// Functions with the same type and linkage match.
+ // FIXME: This needs to cope with function templates, merging of
+ //prototyped/non-prototyped functions, etc.
if (FunctionDecl *FuncX = dyn_cast<FunctionDecl>(X)) {
FunctionDecl *FuncY = cast<FunctionDecl>(Y);
return (FuncX->getLinkage() == FuncY->getLinkage()) &&
FuncX->getASTContext().hasSameType(FuncX->getType(), FuncY->getType());
}
+ // Variables with the same type and linkage match.
+ if (VarDecl *VarX = dyn_cast<VarDecl>(X)) {
+ VarDecl *VarY = cast<VarDecl>(Y);
+ return (VarX->getLinkage() == VarY->getLinkage()) &&
+ VarX->getASTContext().hasSameType(VarX->getType(), VarY->getType());
+ }
// FIXME: Many other cases to implement.
return false;