diff options
author | David Chisnall <csdavec@swan.ac.uk> | 2018-08-14 10:05:25 +0000 |
---|---|---|
committer | David Chisnall <csdavec@swan.ac.uk> | 2018-08-14 10:05:25 +0000 |
commit | c66d480bce3c18d9a665875e4d87b4ad507a6a82 (patch) | |
tree | 780c5e7526788c66b442b6028845b8e1df8ca8f8 /clang/lib/CodeGen | |
parent | 060a789c844dc1f3a4a1843766bbdaafe40f87d7 (diff) | |
download | bcm5719-llvm-c66d480bce3c18d9a665875e4d87b4ad507a6a82.tar.gz bcm5719-llvm-c66d480bce3c18d9a665875e4d87b4ad507a6a82.zip |
[gnu-objc] Make selector order deterministic.
Summary:
This probably fixes PR35277, though there may be other sources of
nondeterminism (this was the only case of iterating over a DenseMap).
It's difficult to provide a test case for this, because it shows up only
on systems with ASLR enabled.
Reviewers: rjmccall
Reviewed By: rjmccall
Subscribers: bmwiedemann, mgrang, cfe-commits
Differential Revision: https://reviews.llvm.org/D50559
llvm-svn: 339668
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGObjCGNU.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 622c8bfb500..b509187b4ce 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -3541,12 +3541,16 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { ConstantInitBuilder builder(CGM); auto selectors = builder.beginArray(selStructTy); auto &table = SelectorTable; // MSVC workaround - for (auto &entry : table) { + std::vector<Selector> allSelectors; + for (auto &entry : table) + allSelectors.push_back(entry.first); + llvm::sort(allSelectors.begin(), allSelectors.end()); - std::string selNameStr = entry.first.getAsString(); + for (auto &untypedSel : allSelectors) { + std::string selNameStr = untypedSel.getAsString(); llvm::Constant *selName = ExportUniqueString(selNameStr, ".objc_sel_name"); - for (TypedSelector &sel : entry.second) { + for (TypedSelector &sel : table[untypedSel]) { llvm::Constant *selectorTypeEncoding = NULLPtr; if (!sel.first.empty()) selectorTypeEncoding = |