summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-12-08 21:24:29 (GMT)
committerBrad King <brad.king@kitware.com>2014-12-08 21:24:29 (GMT)
commit875d5a6678d36102f84bb4035c12a5b51f1d2138 (patch)
tree2e0e0b4df9f3ee64c79aeb3353aa32856c73f655 /src
parenta0fe3f0824febccf8e5cd517587b455742f96c51 (diff)
downloadCastXML-875d5a6678d36102f84bb4035c12a5b51f1d2138.zip
CastXML-875d5a6678d36102f84bb4035c12a5b51f1d2138.tar.gz
CastXML-875d5a6678d36102f84bb4035c12a5b51f1d2138.tar.bz2
RunClang: Use queue to track class completion
When adding implicit members more classes may be completed. Use a queue to follow this cleanly instead of allowing a vector to be reallocated during range interation.
Diffstat (limited to 'src')
-rw-r--r--src/RunClang.cxx9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/RunClang.cxx b/src/RunClang.cxx
index 7a003d2..733f1eb 100644
--- a/src/RunClang.cxx
+++ b/src/RunClang.cxx
@@ -44,6 +44,7 @@
#include <iostream>
#include <memory>
+#include <queue>
//----------------------------------------------------------------------------
class ASTConsumer: public clang::ASTConsumer
@@ -51,7 +52,7 @@ class ASTConsumer: public clang::ASTConsumer
clang::CompilerInstance& CI;
llvm::raw_ostream& OS;
Options const& Opts;
- std::vector<clang::CXXRecordDecl*> Classes;
+ std::queue<clang::CXXRecordDecl*> Classes;
public:
ASTConsumer(clang::CompilerInstance& ci, llvm::raw_ostream& os,
Options const& opts):
@@ -76,7 +77,7 @@ public:
void HandleTagDeclDefinition(clang::TagDecl* d) {
if(clang::CXXRecordDecl* rd = clang::dyn_cast<clang::CXXRecordDecl>(d)) {
if(!rd->isDependentContext()) {
- this->Classes.push_back(rd);
+ this->Classes.push(rd);
}
}
}
@@ -92,7 +93,9 @@ public:
sema.getDiagnostics().setSuppressAllDiagnostics(true);
// Add implicit members to classes.
- for(clang::CXXRecordDecl* rd : this->Classes) {
+ while (!this->Classes.empty()) {
+ clang::CXXRecordDecl* rd = this->Classes.front();
+ this->Classes.pop();
this->AddImplicitMembers(rd);
}
}