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