From 4fad826899f8769a21c427c693d76ae5dfb7c8dc Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 8 Nov 2022 22:04:53 +0800 Subject: [PATCH] - fix: macro defines parsed before not correctly applied in the succeeding parse. --- NEWS.md | 1 + RedPandaIDE/parser/cpppreprocessor.cpp | 14 ++++++-------- RedPandaIDE/parser/cpppreprocessor.h | 1 - 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index cfbea4f6..e4809e61 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,7 @@ Red Panda C++ Version 2.4 - enhancement: Rename filenames in todos/bookmarks/breakpoints when renaming project file - enhancement: Rename filenames in bookmarks/breakpoints after a file is save-ased. - fix: Can't goto definition of classes and namespaces displayed in the class browser on whole project mode. + - fix: macro defines parsed before not correctly applied in the succeeding parse. Red Panda C++ Version 2.3 diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index 1512a875..e5ffc535 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -159,14 +159,6 @@ PDefine CppPreprocessor::getHardDefine(const QString &name) return mHardDefines.value(name,PDefine()); } -void CppPreprocessor::resetDefines() -{ - mDefines = mHardDefines; -// mDefines.clear(); - -// mDefines.insert(mHardDefines); -} - void CppPreprocessor::setScanOptions(bool parseSystem, bool parseLocal) { mParseSystem = parseSystem; @@ -846,6 +838,7 @@ void CppPreprocessor::addDefinesInFile(const QString &fileName) return; mProcessed.insert(fileName); + qDebug()<name,define); } } + + PFileIncludes fileIncludes = getFileIncludesEntry(fileName); + foreach (const QString& file, fileIncludes->includeFiles.keys()) { + addDefinesInFile(file); + } } void CppPreprocessor::parseArgs(PDefine define) diff --git a/RedPandaIDE/parser/cpppreprocessor.h b/RedPandaIDE/parser/cpppreprocessor.h index c9a49a9c..1a5b1c65 100644 --- a/RedPandaIDE/parser/cpppreprocessor.h +++ b/RedPandaIDE/parser/cpppreprocessor.h @@ -121,7 +121,6 @@ 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);