work save: clean up CppPreprocessor clear & reset
This commit is contained in:
parent
6ba6030af7
commit
dbf34548d8
|
@ -976,7 +976,7 @@ void CppParser::resetParser()
|
||||||
mInlineNamespaces.clear();
|
mInlineNamespaces.clear();
|
||||||
|
|
||||||
mPreprocessor.clear();
|
mPreprocessor.clear();
|
||||||
mTokenizer.reset();
|
mTokenizer.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3260,8 +3260,7 @@ void CppParser::internalParse(const QString &fileName)
|
||||||
// Preprocess the file...
|
// Preprocess the file...
|
||||||
{
|
{
|
||||||
auto action = finally([this]{
|
auto action = finally([this]{
|
||||||
mPreprocessor.reset();
|
mTokenizer.clear();
|
||||||
mTokenizer.reset();
|
|
||||||
});
|
});
|
||||||
// Let the preprocessor augment the include records
|
// Let the preprocessor augment the include records
|
||||||
// mPreprocessor.setIncludesList(mIncludesList);
|
// mPreprocessor.setIncludesList(mIncludesList);
|
||||||
|
@ -3273,7 +3272,7 @@ void CppParser::internalParse(const QString &fileName)
|
||||||
|
|
||||||
QStringList preprocessResult = mPreprocessor.result();
|
QStringList preprocessResult = mPreprocessor.result();
|
||||||
//reduce memory usage
|
//reduce memory usage
|
||||||
mPreprocessor.clearResult();
|
mPreprocessor.clearTempResults();
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
// stringsToFile(mPreprocessor.result(),"r:\\preprocess.txt");
|
// stringsToFile(mPreprocessor.result(),"r:\\preprocess.txt");
|
||||||
// mPreprocessor.dumpDefinesTo("r:\\defines.txt");
|
// mPreprocessor.dumpDefinesTo("r:\\defines.txt");
|
||||||
|
@ -3301,7 +3300,7 @@ void CppParser::internalParse(const QString &fileName)
|
||||||
// mStatementList.dumpAll("r:\\all-stats.txt");
|
// mStatementList.dumpAll("r:\\all-stats.txt");
|
||||||
#endif
|
#endif
|
||||||
//reduce memory usage
|
//reduce memory usage
|
||||||
mTokenizer.reset();
|
mTokenizer.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ CppPreprocessor::CppPreprocessor()
|
||||||
void CppPreprocessor::clear()
|
void CppPreprocessor::clear()
|
||||||
{
|
{
|
||||||
//don't use reset(), it will reset(add) defines.
|
//don't use reset(), it will reset(add) defines.
|
||||||
clearResult();
|
clearTempResults();
|
||||||
|
|
||||||
//Result across processings.
|
//Result across processings.
|
||||||
//used by parser even preprocess finished
|
//used by parser even preprocess finished
|
||||||
|
@ -48,7 +48,7 @@ void CppPreprocessor::clear()
|
||||||
mIncludePaths.clear();
|
mIncludePaths.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::clearResult()
|
void CppPreprocessor::clearTempResults()
|
||||||
{
|
{
|
||||||
//temporary data when preprocessing single file
|
//temporary data when preprocessing single file
|
||||||
mFileName="";
|
mFileName="";
|
||||||
|
@ -159,13 +159,6 @@ PDefine CppPreprocessor::getHardDefine(const QString &name)
|
||||||
return mHardDefines.value(name,PDefine());
|
return mHardDefines.value(name,PDefine());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::reset()
|
|
||||||
{
|
|
||||||
clearResult();
|
|
||||||
// Clear extracted data
|
|
||||||
resetDefines(); // do not throw away hardcoded
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppPreprocessor::resetDefines()
|
void CppPreprocessor::resetDefines()
|
||||||
{
|
{
|
||||||
mDefines = mHardDefines;
|
mDefines = mHardDefines;
|
||||||
|
@ -182,8 +175,9 @@ void CppPreprocessor::setScanOptions(bool parseSystem, bool parseLocal)
|
||||||
|
|
||||||
void CppPreprocessor::preprocess(const QString &fileName, QStringList buffer)
|
void CppPreprocessor::preprocess(const QString &fileName, QStringList buffer)
|
||||||
{
|
{
|
||||||
|
clearTempResults();
|
||||||
mFileName = fileName;
|
mFileName = fileName;
|
||||||
reset();
|
mDefines = mHardDefines;
|
||||||
openInclude(fileName, buffer);
|
openInclude(fileName, buffer);
|
||||||
// StringsToFile(mBuffer,"f:\\buffer.txt");
|
// StringsToFile(mBuffer,"f:\\buffer.txt");
|
||||||
preprocessBuffer();
|
preprocessBuffer();
|
||||||
|
@ -340,14 +334,11 @@ void CppPreprocessor::clearProjectIncludePaths()
|
||||||
mProjectIncludePathList.clear();
|
mProjectIncludePathList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::clearScannedFiles()
|
void CppPreprocessor::removeScannedFile(const QString &filename)
|
||||||
{
|
{
|
||||||
mScannedFiles.clear();
|
mScannedFiles.remove(filename);
|
||||||
}
|
mIncludesList.remove(filename);
|
||||||
|
mFileDefines.remove(filename);
|
||||||
void CppPreprocessor::clearIncludeList()
|
|
||||||
{
|
|
||||||
mIncludesList.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CppPreprocessor::getNextPreprocessor()
|
QString CppPreprocessor::getNextPreprocessor()
|
||||||
|
|
|
@ -62,10 +62,10 @@ public:
|
||||||
|
|
||||||
explicit CppPreprocessor();
|
explicit CppPreprocessor();
|
||||||
void clear();
|
void clear();
|
||||||
void clearResult();
|
|
||||||
|
void clearTempResults();
|
||||||
void getDefineParts(const QString& input, QString &name, QString &args, QString &value);
|
void getDefineParts(const QString& input, QString &name, QString &args, QString &value);
|
||||||
void addHardDefineByLine(const QString& line);
|
void addHardDefineByLine(const QString& line);
|
||||||
void reset(); //reset but don't clear generated defines
|
|
||||||
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());
|
||||||
|
|
||||||
|
@ -75,8 +75,7 @@ public:
|
||||||
void addProjectIncludePath(const QString& fileName);
|
void addProjectIncludePath(const QString& fileName);
|
||||||
void clearIncludePaths();
|
void clearIncludePaths();
|
||||||
void clearProjectIncludePaths();
|
void clearProjectIncludePaths();
|
||||||
void clearScannedFiles();
|
|
||||||
void clearIncludeList();
|
|
||||||
QStringList result() const;
|
QStringList result() const;
|
||||||
|
|
||||||
QHash<QString, PFileIncludes> &includesList();
|
QHash<QString, PFileIncludes> &includesList();
|
||||||
|
|
|
@ -24,7 +24,7 @@ CppTokenizer::CppTokenizer()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppTokenizer::reset()
|
void CppTokenizer::clear()
|
||||||
{
|
{
|
||||||
mTokenList.clear();
|
mTokenList.clear();
|
||||||
mBuffer.clear();
|
mBuffer.clear();
|
||||||
|
@ -34,7 +34,7 @@ void CppTokenizer::reset()
|
||||||
|
|
||||||
void CppTokenizer::tokenize(const QStringList &buffer)
|
void CppTokenizer::tokenize(const QStringList &buffer)
|
||||||
{
|
{
|
||||||
reset();
|
clear();
|
||||||
|
|
||||||
mBuffer = buffer;
|
mBuffer = buffer;
|
||||||
if (mBuffer.isEmpty())
|
if (mBuffer.isEmpty())
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
using TokenList = QVector<PToken>;
|
using TokenList = QVector<PToken>;
|
||||||
explicit CppTokenizer();
|
explicit CppTokenizer();
|
||||||
|
|
||||||
void reset();
|
void clear();
|
||||||
void tokenize(const QStringList& buffer);
|
void tokenize(const QStringList& buffer);
|
||||||
void dumpTokens(const QString& fileName);
|
void dumpTokens(const QString& fileName);
|
||||||
const TokenList& tokens();
|
const TokenList& tokens();
|
||||||
|
|
|
@ -585,7 +585,7 @@ void Project::resetParserProjectFiles()
|
||||||
mParser->clearProjectFiles();
|
mParser->clearProjectFiles();
|
||||||
mParser->clearProjectIncludePaths();
|
mParser->clearProjectIncludePaths();
|
||||||
foreach (const PProjectUnit& unit, mUnits) {
|
foreach (const PProjectUnit& unit, mUnits) {
|
||||||
mParser->addFileToScan(unit->fileName());
|
mParser->addFileToScan(unit->fileName(),true);
|
||||||
}
|
}
|
||||||
foreach (const QString& s, mOptions.includeDirs) {
|
foreach (const QString& s, mOptions.includeDirs) {
|
||||||
mParser->addProjectIncludePath(s);
|
mParser->addProjectIncludePath(s);
|
||||||
|
|
Loading…
Reference in New Issue