- enhancement: greatly reduces memory usage for symbol parsing ( memory needed for bits/stdc++.h reduced from 150m+ to 50m+)
- fix: currect compiler set not correctly updated when switch between normal file and project file
This commit is contained in:
parent
17dd73149c
commit
b3e5ddc94c
4
NEWS.md
4
NEWS.md
|
@ -1,3 +1,7 @@
|
|||
Version 0.8.6 For Dev-C++ 7 Beta
|
||||
- enhancement: greatly reduces memory usage for symbol parsing ( memory needed for bits/stdc++.h reduced from 150m+ to 50m+)
|
||||
- fix: currect compiler set not correctly updated when switch between normal file and project file
|
||||
|
||||
Version 0.8.5 For Dev-C++ 7 Beta
|
||||
- enhancement: use lighter color to draw menu seperators
|
||||
- enhancement: differentiate selected and unselected tab bars
|
||||
|
|
|
@ -91,7 +91,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->toolbarCompilerSet->addWidget(mCompilerSet);
|
||||
connect(mCompilerSet,QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &MainWindow::onCompilerSetChanged);
|
||||
updateCompilerSet();
|
||||
//updateCompilerSet();
|
||||
|
||||
mCompilerManager = new CompilerManager(this);
|
||||
mDebugger = new Debugger(this);
|
||||
|
@ -399,7 +399,7 @@ void MainWindow::updateEditorActions()
|
|||
}
|
||||
|
||||
updateCompileActions();
|
||||
|
||||
updateCompilerSet();
|
||||
}
|
||||
|
||||
void MainWindow::updateProjectActions()
|
||||
|
|
|
@ -61,9 +61,9 @@ void CppParser::addHardDefineByLine(const QString &line)
|
|||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (line.startsWith('#')) {
|
||||
mPreprocessor.addDefineByLine(line.mid(1).trimmed(), true);
|
||||
mPreprocessor.addHardDefineByLine(line.mid(1).trimmed());
|
||||
} else {
|
||||
mPreprocessor.addDefineByLine(line, true);
|
||||
mPreprocessor.addHardDefineByLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3127,9 +3127,16 @@ void CppParser::internalParse(const QString &fileName)
|
|||
mPreprocessor.setScanOptions(mParseGlobalHeaders, mParseLocalHeaders);
|
||||
mPreprocessor.preprocess(fileName, buffer);
|
||||
|
||||
QStringList prerocessResult = mPreprocessor.result();
|
||||
mPreprocessor.clearResult();
|
||||
#ifdef QT_DEBUG
|
||||
// StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt");
|
||||
// mPreprocessor.dumpDefinesTo("f:\\defines.txt");
|
||||
// mPreprocessor.dumpIncludesListTo("f:\\includes.txt");
|
||||
#endif
|
||||
|
||||
// Tokenize the preprocessed buffer file
|
||||
mTokenizer.tokenize(mPreprocessor.result());
|
||||
mTokenizer.tokenize(prerocessResult);
|
||||
if (mTokenizer.tokenCount() == 0)
|
||||
return;
|
||||
|
||||
|
@ -3147,13 +3154,11 @@ void CppParser::internalParse(const QString &fileName)
|
|||
break;
|
||||
}
|
||||
#ifdef QT_DEBUG
|
||||
// StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt");
|
||||
// mPreprocessor.dumpDefinesTo("f:\\defines.txt");
|
||||
// mPreprocessor.dumpIncludesListTo("f:\\includes.txt");
|
||||
// mStatementList.dump("f:\\stats.txt");
|
||||
// mTokenizer.dumpTokens("f:\\tokens.txt");
|
||||
// mStatementList.dump("f:\\stats.txt");
|
||||
// mStatementList.dumpAll("f:\\all-stats.txt");
|
||||
#endif
|
||||
mTokenizer.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,18 @@ void CppPreprocessor::clear()
|
|||
mCurrentIncludes.reset();
|
||||
}
|
||||
|
||||
void CppPreprocessor::clearResult()
|
||||
{
|
||||
mFileName.clear();
|
||||
mBuffer.clear();
|
||||
mResult.clear();
|
||||
mCurrentIncludes = nullptr;
|
||||
mIncludes.clear(); // stack of files we've stepped into. last one is current file, first one is source file
|
||||
mBranchResults.clear();// stack of branch results (boolean). last one is current branch, first one is outermost branch
|
||||
mDefines.clear(); // working set, editable
|
||||
mProcessed.clear(); // dictionary to save filename already processed
|
||||
}
|
||||
|
||||
void CppPreprocessor::addDefineByParts(const QString &name, const QString &args, const QString &value, bool hardCoded)
|
||||
{
|
||||
// Check for duplicates
|
||||
|
@ -91,6 +103,11 @@ void CppPreprocessor::getDefineParts(const QString &input, QString &name, QStrin
|
|||
value = removeGCCAttributes(s.mid(i+1).trimmed());
|
||||
}
|
||||
|
||||
void CppPreprocessor::addHardDefineByLine(const QString &line)
|
||||
{
|
||||
addDefineByLine(line,true);
|
||||
}
|
||||
|
||||
void CppPreprocessor::addDefineByLine(const QString &line, bool hardCoded)
|
||||
{
|
||||
// Remove define
|
||||
|
|
|
@ -46,17 +46,12 @@ public:
|
|||
|
||||
explicit CppPreprocessor();
|
||||
void clear();
|
||||
void addDefineByParts(const QString& name, const QString& args,
|
||||
const QString& value, bool hardCoded);
|
||||
void clearResult();
|
||||
void getDefineParts(const QString& input, QString &name, QString &args, QString &value);
|
||||
void addDefineByLine(const QString& line, bool hardCoded);
|
||||
PDefine getDefine(const QString& name);
|
||||
PDefine getHardDefine(const QString& name);
|
||||
void addHardDefineByLine(const QString& line);
|
||||
void reset(); //reset but don't clear generated defines
|
||||
void resetDefines();
|
||||
void setScanOptions(bool parseSystem, bool parseLocal);
|
||||
void preprocess(const QString& fileName, QStringList buffer = QStringList());
|
||||
void invalidDefinesInFile(const QString& fileName);
|
||||
|
||||
void dumpDefinesTo(const QString& fileName) const;
|
||||
void dumpIncludesListTo(const QString& fileName) const;
|
||||
|
@ -97,7 +92,7 @@ private:
|
|||
void expandMacro(const QString& line, QString& newLine, QString& word, int& i, int depth);
|
||||
QString removeGCCAttributes(const QString& line);
|
||||
void removeGCCAttribute(const QString&line, QString& newLine, int &i, const QString& word);
|
||||
|
||||
PDefine getDefine(const QString& name);
|
||||
// current file stuff
|
||||
PParsedFile getInclude(int index);
|
||||
void openInclude(const QString& fileName, QStringList bufferedText=QStringList());
|
||||
|
@ -110,6 +105,12 @@ private:
|
|||
// include stuff
|
||||
PFileIncludes getFileIncludesEntry(const QString& FileName);
|
||||
void addDefinesInFile(const QString& fileName);
|
||||
void resetDefines();
|
||||
void addDefineByParts(const QString& name, const QString& args,
|
||||
const QString& value, bool hardCoded);
|
||||
void addDefineByLine(const QString& line, bool hardCoded);
|
||||
PDefine getHardDefine(const QString& name);
|
||||
void invalidDefinesInFile(const QString& fileName);
|
||||
|
||||
void parseArgs(PDefine define);
|
||||
QList<PDefineArgToken> tokenizeValue(const QString& value);
|
||||
|
@ -181,24 +182,26 @@ private:
|
|||
QStringList mResult;
|
||||
PFileIncludes mCurrentIncludes;
|
||||
int mPreProcIndex;
|
||||
QHash<QString,PFileIncludes> mIncludesList;
|
||||
DefineMap mHardDefines; // set by "cpp -dM -E -xc NUL"
|
||||
DefineMap mDefines; // working set, editable
|
||||
QHash<QString, PDefineMap> mFileDefines; //dictionary to save defines for each headerfile;
|
||||
QList<PParsedFile> mIncludes; // stack of files we've stepped into. last one is current file, first one is source file
|
||||
QList<bool> mBranchResults;// stack of branch results (boolean). last one is current branch, first one is outermost branch
|
||||
//{ List of current compiler set's include path}
|
||||
QSet<QString> mIncludePaths;
|
||||
DefineMap mDefines; // working set, editable
|
||||
QSet<QString> mProcessed; // dictionary to save filename already processed
|
||||
|
||||
//used by parser even preprocess finished
|
||||
DefineMap mHardDefines; // set by "cpp -dM -E -xc NUL"
|
||||
QHash<QString,PFileIncludes> mIncludesList;
|
||||
QHash<QString, PDefineMap> mFileDefines; //dictionary to save defines for each headerfile;
|
||||
//{ List of current project's include path }
|
||||
QSet<QString> mProjectIncludePaths;
|
||||
//we also need include paths in order (for #include_next)
|
||||
QList<QString> mIncludePathList;
|
||||
QList<QString> mProjectIncludePathList;
|
||||
//{ List of current compiler set's include path}
|
||||
QSet<QString> mIncludePaths;
|
||||
|
||||
bool mParseSystem;
|
||||
bool mParseLocal;
|
||||
QSet<QString> mScannedFiles;
|
||||
QSet<QString> mProcessed; // dictionary to save filename already processed
|
||||
};
|
||||
|
||||
#endif // CPPPREPROCESSOR_H
|
||||
|
|
Loading…
Reference in New Issue