- 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
|
Version 0.8.5 For Dev-C++ 7 Beta
|
||||||
- enhancement: use lighter color to draw menu seperators
|
- enhancement: use lighter color to draw menu seperators
|
||||||
- enhancement: differentiate selected and unselected tab bars
|
- enhancement: differentiate selected and unselected tab bars
|
||||||
|
|
|
@ -91,7 +91,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
ui->toolbarCompilerSet->addWidget(mCompilerSet);
|
ui->toolbarCompilerSet->addWidget(mCompilerSet);
|
||||||
connect(mCompilerSet,QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(mCompilerSet,QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &MainWindow::onCompilerSetChanged);
|
this, &MainWindow::onCompilerSetChanged);
|
||||||
updateCompilerSet();
|
//updateCompilerSet();
|
||||||
|
|
||||||
mCompilerManager = new CompilerManager(this);
|
mCompilerManager = new CompilerManager(this);
|
||||||
mDebugger = new Debugger(this);
|
mDebugger = new Debugger(this);
|
||||||
|
@ -399,7 +399,7 @@ void MainWindow::updateEditorActions()
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCompileActions();
|
updateCompileActions();
|
||||||
|
updateCompilerSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateProjectActions()
|
void MainWindow::updateProjectActions()
|
||||||
|
|
|
@ -61,9 +61,9 @@ void CppParser::addHardDefineByLine(const QString &line)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mMutex);
|
QMutexLocker locker(&mMutex);
|
||||||
if (line.startsWith('#')) {
|
if (line.startsWith('#')) {
|
||||||
mPreprocessor.addDefineByLine(line.mid(1).trimmed(), true);
|
mPreprocessor.addHardDefineByLine(line.mid(1).trimmed());
|
||||||
} else {
|
} else {
|
||||||
mPreprocessor.addDefineByLine(line, true);
|
mPreprocessor.addHardDefineByLine(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3127,9 +3127,16 @@ void CppParser::internalParse(const QString &fileName)
|
||||||
mPreprocessor.setScanOptions(mParseGlobalHeaders, mParseLocalHeaders);
|
mPreprocessor.setScanOptions(mParseGlobalHeaders, mParseLocalHeaders);
|
||||||
mPreprocessor.preprocess(fileName, buffer);
|
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
|
// Tokenize the preprocessed buffer file
|
||||||
mTokenizer.tokenize(mPreprocessor.result());
|
mTokenizer.tokenize(prerocessResult);
|
||||||
if (mTokenizer.tokenCount() == 0)
|
if (mTokenizer.tokenCount() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -3147,13 +3154,11 @@ void CppParser::internalParse(const QString &fileName)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef QT_DEBUG
|
#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");
|
// mTokenizer.dumpTokens("f:\\tokens.txt");
|
||||||
|
// mStatementList.dump("f:\\stats.txt");
|
||||||
// mStatementList.dumpAll("f:\\all-stats.txt");
|
// mStatementList.dumpAll("f:\\all-stats.txt");
|
||||||
#endif
|
#endif
|
||||||
|
mTokenizer.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,18 @@ void CppPreprocessor::clear()
|
||||||
mCurrentIncludes.reset();
|
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)
|
void CppPreprocessor::addDefineByParts(const QString &name, const QString &args, const QString &value, bool hardCoded)
|
||||||
{
|
{
|
||||||
// Check for duplicates
|
// Check for duplicates
|
||||||
|
@ -91,6 +103,11 @@ void CppPreprocessor::getDefineParts(const QString &input, QString &name, QStrin
|
||||||
value = removeGCCAttributes(s.mid(i+1).trimmed());
|
value = removeGCCAttributes(s.mid(i+1).trimmed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CppPreprocessor::addHardDefineByLine(const QString &line)
|
||||||
|
{
|
||||||
|
addDefineByLine(line,true);
|
||||||
|
}
|
||||||
|
|
||||||
void CppPreprocessor::addDefineByLine(const QString &line, bool hardCoded)
|
void CppPreprocessor::addDefineByLine(const QString &line, bool hardCoded)
|
||||||
{
|
{
|
||||||
// Remove define
|
// Remove define
|
||||||
|
|
|
@ -46,17 +46,12 @@ public:
|
||||||
|
|
||||||
explicit CppPreprocessor();
|
explicit CppPreprocessor();
|
||||||
void clear();
|
void clear();
|
||||||
void addDefineByParts(const QString& name, const QString& args,
|
void clearResult();
|
||||||
const QString& value, bool hardCoded);
|
|
||||||
void getDefineParts(const QString& input, QString &name, QString &args, QString &value);
|
void getDefineParts(const QString& input, QString &name, QString &args, QString &value);
|
||||||
void addDefineByLine(const QString& line, bool hardCoded);
|
void addHardDefineByLine(const QString& line);
|
||||||
PDefine getDefine(const QString& name);
|
|
||||||
PDefine getHardDefine(const QString& name);
|
|
||||||
void reset(); //reset but don't clear generated defines
|
void reset(); //reset but don't clear generated defines
|
||||||
void resetDefines();
|
|
||||||
void setScanOptions(bool parseSystem, bool parseLocal);
|
void setScanOptions(bool parseSystem, bool parseLocal);
|
||||||
void preprocess(const QString& fileName, QStringList buffer = QStringList());
|
void preprocess(const QString& fileName, QStringList buffer = QStringList());
|
||||||
void invalidDefinesInFile(const QString& fileName);
|
|
||||||
|
|
||||||
void dumpDefinesTo(const QString& fileName) const;
|
void dumpDefinesTo(const QString& fileName) const;
|
||||||
void dumpIncludesListTo(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);
|
void expandMacro(const QString& line, QString& newLine, QString& word, int& i, int depth);
|
||||||
QString removeGCCAttributes(const QString& line);
|
QString removeGCCAttributes(const QString& line);
|
||||||
void removeGCCAttribute(const QString&line, QString& newLine, int &i, const QString& word);
|
void removeGCCAttribute(const QString&line, QString& newLine, int &i, const QString& word);
|
||||||
|
PDefine getDefine(const QString& name);
|
||||||
// current file stuff
|
// current file stuff
|
||||||
PParsedFile getInclude(int index);
|
PParsedFile getInclude(int index);
|
||||||
void openInclude(const QString& fileName, QStringList bufferedText=QStringList());
|
void openInclude(const QString& fileName, QStringList bufferedText=QStringList());
|
||||||
|
@ -110,6 +105,12 @@ private:
|
||||||
// include stuff
|
// include stuff
|
||||||
PFileIncludes getFileIncludesEntry(const QString& FileName);
|
PFileIncludes getFileIncludesEntry(const QString& FileName);
|
||||||
void addDefinesInFile(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);
|
void parseArgs(PDefine define);
|
||||||
QList<PDefineArgToken> tokenizeValue(const QString& value);
|
QList<PDefineArgToken> tokenizeValue(const QString& value);
|
||||||
|
@ -181,24 +182,26 @@ private:
|
||||||
QStringList mResult;
|
QStringList mResult;
|
||||||
PFileIncludes mCurrentIncludes;
|
PFileIncludes mCurrentIncludes;
|
||||||
int mPreProcIndex;
|
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<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
|
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}
|
DefineMap mDefines; // working set, editable
|
||||||
QSet<QString> mIncludePaths;
|
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 }
|
//{ List of current project's include path }
|
||||||
QSet<QString> mProjectIncludePaths;
|
QSet<QString> mProjectIncludePaths;
|
||||||
//we also need include paths in order (for #include_next)
|
//we also need include paths in order (for #include_next)
|
||||||
QList<QString> mIncludePathList;
|
QList<QString> mIncludePathList;
|
||||||
QList<QString> mProjectIncludePathList;
|
QList<QString> mProjectIncludePathList;
|
||||||
|
//{ List of current compiler set's include path}
|
||||||
|
QSet<QString> mIncludePaths;
|
||||||
|
|
||||||
bool mParseSystem;
|
bool mParseSystem;
|
||||||
bool mParseLocal;
|
bool mParseLocal;
|
||||||
QSet<QString> mScannedFiles;
|
QSet<QString> mScannedFiles;
|
||||||
QSet<QString> mProcessed; // dictionary to save filename already processed
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CPPPREPROCESSOR_H
|
#endif // CPPPREPROCESSOR_H
|
||||||
|
|
Loading…
Reference in New Issue