diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-02-11 18:16:18 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-02-11 18:16:18 +0000 |
commit | dcf25087917305dec7fc0d7ff7d438882a6cb727 (patch) | |
tree | eb8a305bb272cb6d5472dca02f3c6712a4325936 /clang/lib/Serialization/ASTReader.cpp | |
parent | c92c8f06ec0dcee0bf6cc035bcd3eba34d15cb44 (diff) | |
download | bcm5719-llvm-dcf25087917305dec7fc0d7ff7d438882a6cb727.tar.gz bcm5719-llvm-dcf25087917305dec7fc0d7ff7d438882a6cb727.zip |
[Modules] Cope better with top-level declarations loaded after being declared in the current translation unit <rdar://problem/13189985>.
These two related tweaks to keep the information associated with a
given identifier correct when the identifier has been given some
top-level information (say, a top-level declaration) and more
information is then loaded from a module. The first ensures that an
identifier that was "interesting" before being loaded from an AST is
considered to be different from its on-disk counterpart. Otherwise, we
lose such changes when writing the current translation unit as a
module.
Second, teach the code that injects AST-loaded names into the
identifier chain for name lookup to keep the most recent declaration,
so that we don't end up confusing our declaration chains by having a
different declaration in there.
llvm-svn: 174895
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index a00d40659f3..53fa21f9aaa 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/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. |