diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2015-03-26 08:32:49 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2015-03-26 08:32:49 +0000 |
commit | f85d98285e8eb6bcf42c2821e3b03abfc22ffac9 (patch) | |
tree | 611357433af1c908392bcd691daa41a33b1bfc9b /clang/lib/Serialization | |
parent | 23536d92c75dfebd65afa5ce1e588470e908b594 (diff) | |
download | bcm5719-llvm-f85d98285e8eb6bcf42c2821e3b03abfc22ffac9.tar.gz bcm5719-llvm-f85d98285e8eb6bcf42c2821e3b03abfc22ffac9.zip |
[Modules] Make "#pragma weak" undeclared identifiers be tracked
deterministically.
This fixes a latent issue where even Clang's Sema (and diagnostics) were
non-deterministic in the face of this pragma. The fix is super simple --
just use a MapVector so we track the order in which these are parsed (or
imported). Especially considering how rare they are, this seems like the
perfect tradeoff. I've also simplified the client code with judicious
use of auto and range based for loops.
I've added some pretty hilarious code to my stress test which now
survives the binary diff without issue.
llvm-svn: 233261
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 9f0626f060c..7227a97e7b9 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -4359,15 +4359,13 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, // entire table, since later PCH files in a PCH chain are only interested in // the results at the end of the chain. RecordData WeakUndeclaredIdentifiers; - if (!SemaRef.WeakUndeclaredIdentifiers.empty()) { - for (llvm::DenseMap<IdentifierInfo*,WeakInfo>::iterator - I = SemaRef.WeakUndeclaredIdentifiers.begin(), - E = SemaRef.WeakUndeclaredIdentifiers.end(); I != E; ++I) { - AddIdentifierRef(I->first, WeakUndeclaredIdentifiers); - AddIdentifierRef(I->second.getAlias(), WeakUndeclaredIdentifiers); - AddSourceLocation(I->second.getLocation(), WeakUndeclaredIdentifiers); - WeakUndeclaredIdentifiers.push_back(I->second.getUsed()); - } + for (auto &WeakUndeclaredIdentifier : SemaRef.WeakUndeclaredIdentifiers) { + IdentifierInfo *II = WeakUndeclaredIdentifier.first; + WeakInfo &WI = WeakUndeclaredIdentifier.second; + AddIdentifierRef(II, WeakUndeclaredIdentifiers); + AddIdentifierRef(WI.getAlias(), WeakUndeclaredIdentifiers); + AddSourceLocation(WI.getLocation(), WeakUndeclaredIdentifiers); + WeakUndeclaredIdentifiers.push_back(WI.getUsed()); } // Build a record containing all of the ext_vector declarations. |