summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppmodelmanager.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2010-03-18 15:21:07 +0100
committerRoberto Raggi <roberto.raggi@nokia.com>2010-03-18 15:23:13 +0100
commit61a504c4273d01aecf1a149f5d9d8a3ab5e354c3 (patch)
tree4417d9e1e2f67acd3c56ec351055072e21cb6a27 /src/plugins/cpptools/cppmodelmanager.cpp
parent1e2af0a77dcddd84de43879609733cd55302756f (diff)
downloadqt-creator-61a504c4273d01aecf1a149f5d9d8a3ab5e354c3.tar.gz
Ensure that the memory pool can be reused after a rewind and get rid of the segmented array.
Diffstat (limited to 'src/plugins/cpptools/cppmodelmanager.cpp')
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index 977b0677ef..58c358378b 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -74,6 +74,8 @@
#include <ASTVisitor.h>
#include <Lexer.h>
#include <Token.h>
+#include <Parser.h>
+#include <Control.h>
#include <cplusplus/LookupContext.h>
@@ -261,18 +263,49 @@ public:
if (_workingCopy.contains(doc->fileName()))
mode = Document::FullCheck;
- doc->parse();
- doc->check(mode);
+ if (doc->isParsed() && mode == Document::FastCheck) {
+ TranslationUnit *unit = doc->translationUnit();
+ MemoryPool *pool = unit->memoryPool();
- if (mode == Document::FullCheck) {
- // run the binding pass
- NamespaceBindingPtr ns = bind(doc, _snapshot);
+ Parser parser(unit);
+ Semantic semantic(unit);
- // check for undefined symbols.
- CheckUndefinedSymbols checkUndefinedSymbols(doc);
- checkUndefinedSymbols.setGlobalNamespaceBinding(ns);
+ Namespace *globalNamespace = doc->control()->newNamespace(0);
+ doc->setGlobalNamespace(globalNamespace);
- checkUndefinedSymbols(doc->translationUnit()->ast()); // ### FIXME
+ Scope *globals = globalNamespace->members();
+
+ while (parser.LA()) {
+ unsigned start_declaration = parser.cursor();
+ DeclarationAST *declaration = 0;
+
+ if (parser.parseDeclaration(declaration)) {
+ semantic.check(declaration, globals);
+
+ } else {
+ doc->translationUnit()->error(start_declaration, "expected a declaration");
+ parser.rewind(start_declaration + 1);
+ parser.skipUntilDeclaration();
+ }
+
+ parser.clearTemplateArgumentList();
+ pool->reset();
+ }
+
+ } else {
+ doc->parse();
+ doc->check(mode);
+
+ if (mode == Document::FullCheck) {
+ // run the binding pass
+ NamespaceBindingPtr ns = bind(doc, _snapshot);
+
+ // check for undefined symbols.
+ CheckUndefinedSymbols checkUndefinedSymbols(doc);
+ checkUndefinedSymbols.setGlobalNamespaceBinding(ns);
+
+ checkUndefinedSymbols(doc->translationUnit()->ast()); // ### FIXME
+ }
}
doc->releaseTranslationUnit();