diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/IdentifierResolver.cpp | 8 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 26 |
2 files changed, 31 insertions, 3 deletions
diff --git a/lib/Sema/IdentifierResolver.cpp b/lib/Sema/IdentifierResolver.cpp index 6f5ddca20b..d44c1fb926 100644 --- a/lib/Sema/IdentifierResolver.cpp +++ b/lib/Sema/IdentifierResolver.cpp @@ -302,6 +302,14 @@ static DeclMatchKind compareDeclarations(NamedDecl *Existing, NamedDecl *New) { // If the declarations are redeclarations of each other, keep the newest one. if (Existing->getCanonicalDecl() == New->getCanonicalDecl()) { + // If either of these is the most recent declaration, use it. + Decl *MostRecent = Existing->getMostRecentDecl(); + if (Existing == MostRecent) + return DMK_Ignore; + + if (New == MostRecent) + return DMK_Replace; + // If the existing declaration is somewhere in the previous declaration // chain of the new declaration, then prefer the new declaration. for (Decl::redecl_iterator RD = New->redecls_begin(), diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index a00d40659f..53fa21f9aa 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -457,6 +457,16 @@ ASTIdentifierLookupTraitBase::ReadKey(const unsigned char* d, unsigned n) { return StringRef((const char*) d, n-1); } +/// \brief Whether the given identifier is "interesting". +static bool isInterestingIdentifier(IdentifierInfo &II) { + return II.isPoisoned() || + II.isExtensionToken() || + II.getObjCOrBuiltinID() || + II.hasRevertedTokenIDToIdentifier() || + II.hadMacroDefinition() || + II.getFETokenInfo<void>(); +} + IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k, const unsigned char* d, unsigned DataLen) { @@ -477,8 +487,13 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k, KnownII = II; } Reader.SetIdentifierInfo(ID, II); - II->setIsFromAST(); - Reader.markIdentifierUpToDate(II); + if (!II->isFromAST()) { + bool WasInteresting = isInterestingIdentifier(*II); + II->setIsFromAST(); + if (WasInteresting) + II->setChangedSinceDeserialization(); + } + Reader.markIdentifierUpToDate(II); return II; } @@ -506,7 +521,12 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k, KnownII = II; } Reader.markIdentifierUpToDate(II); - II->setIsFromAST(); + if (!II->isFromAST()) { + bool WasInteresting = isInterestingIdentifier(*II); + II->setIsFromAST(); + if (WasInteresting) + II->setChangedSinceDeserialization(); + } // Set or check the various bits in the IdentifierInfo structure. // Token IDs are read-only. |