summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-01-04 02:08:04 +0000
committerAnders Carlsson <andersca@mac.com>2009-01-04 02:08:04 +0000
commit762e162284e0633e3a006c589812d168189b9a2e (patch)
tree4bfc006abecfe7d3b47fb4304ae061ddb0e9404a /clang/lib/CodeGen/CodeGenModule.cpp
parentac79602005adcadfa2ff2de86320b26058f53f37 (diff)
downloadbcm5719-llvm-762e162284e0633e3a006c589812d168189b9a2e.tar.gz
bcm5719-llvm-762e162284e0633e3a006c589812d168189b9a2e.zip
Fix the bug that would cause Python to crash at startup.
When emitting the static variables we need to make sure that the order is preserved. Fix this by making StaticDecls a std::list which has O(1) random removal. llvm-svn: 61621
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index fc1b108b0d6..021e9af6765 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -361,26 +361,27 @@ void CodeGenModule::EmitStatics() {
bool Changed;
do {
Changed = false;
- for (unsigned i = 0, e = StaticDecls.size(); i != e; ++i) {
- const ValueDecl *D = StaticDecls[i];
-
+
+ for (std::list<const ValueDecl*>::iterator i = StaticDecls.begin(),
+ e = StaticDecls.end(); i != e; ) {
+ const ValueDecl *D = *i;
+
// Check if we have used a decl with the same name
// FIXME: The AST should have some sort of aggregate decls or
// global symbol map.
// FIXME: This is missing some important cases. For example, we
// need to check for uses in an alias and in a constructor.
- if (!GlobalDeclMap.count(D->getIdentifier()))
+ if (!GlobalDeclMap.count(D->getIdentifier())) {
+ i++;
continue;
-
+ }
+
// Emit the definition.
EmitGlobalDefinition(D);
// Erase the used decl from the list.
- StaticDecls[i] = StaticDecls.back();
- StaticDecls.pop_back();
- --i;
- --e;
-
+ i = StaticDecls.erase(i);
+
// Remember that we made a change.
Changed = true;
}
OpenPOWER on IntegriCloud