summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp21
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h4
2 files changed, 14 insertions, 11 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;
}
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 3f604dd048b..0bd0e2c724f 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -21,6 +21,8 @@
#include "CGCall.h"
+#include <list>
+
namespace llvm {
class Module;
class Constant;
@@ -97,7 +99,7 @@ class CodeGenModule {
/// will lazily emit definitions for only the decls that were
/// actually used. This should contain only Function and Var decls,
/// and only those which actually define something.
- std::vector<const ValueDecl*> StaticDecls;
+ std::list<const ValueDecl*> StaticDecls;
/// GlobalCtors - Store the list of global constructors and their
/// respective priorities to be emitted when the translation unit is
OpenPOWER on IntegriCloud