- fix: C++ compiler atrribute '[[xxx]]' are not correctly handled.

This commit is contained in:
Roy Qu 2023-10-25 17:01:42 +08:00
parent 85ef5986bf
commit 3a78819fb8
6 changed files with 30 additions and 19 deletions

View File

@ -17,6 +17,8 @@ Red Panda C++ Version 2.26
- enhancement: Basic support for parsing variadic macros(macros that use __VA_ARGS__). - enhancement: Basic support for parsing variadic macros(macros that use __VA_ARGS__).
- enhancement: Better support for expanding macros with complex parameters. - enhancement: Better support for expanding macros with complex parameters.
- fix: Macros that defined by the compiler are not correctly syntax-colored and tooltiped. - fix: Macros that defined by the compiler are not correctly syntax-colored and tooltiped.
- fix: Code suggestion for identifiers after '*' (eg. 3 * item->price) can't correct.
- fix: C++ compiler atrribute '[[xxx]]' are not correctly handled.
Red Panda C++ Version 2.25 Red Panda C++ Version 2.25

View File

@ -15,7 +15,7 @@ APP_NAME = RedPandaCPP
APP_VERSION = 2.26 APP_VERSION = 2.26
TEST_VERSION = alpha4 TEST_VERSION = alpha5
contains(QMAKE_HOST.arch, x86_64):{ contains(QMAKE_HOST.arch, x86_64):{
DEFINES += ARCH_X86_64=1 DEFINES += ARCH_X86_64=1

View File

@ -2318,10 +2318,17 @@ QStringList Editor::getExpressionAtPosition(
return result; return result;
break; break;
case LastSymbolType::AsteriskSign: // before '*': case LastSymbolType::AsteriskSign: // before '*':
if (token == '*') { if (token == '*') {
} else {
} else QChar ch=token.front();
if (isIdentChar(ch)
|| ch.isDigit()
|| ch == '.'
|| ch == ')' ) {
result.pop_front();
}
return result; return result;
}
break; break;
case LastSymbolType::AmpersandSign: // before '&': case LastSymbolType::AmpersandSign: // before '&':
return result; return result;

View File

@ -4397,8 +4397,8 @@ void CppParser::internalParse(const QString &fileName)
QStringList preprocessResult = mPreprocessor.result(); QStringList preprocessResult = mPreprocessor.result();
#ifdef QT_DEBUG #ifdef QT_DEBUG
// stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName)));
// mPreprocessor.dumpDefinesTo("r:\\defines.txt"); mPreprocessor.dumpDefinesTo("r:\\defines.txt");
// mPreprocessor.dumpIncludesListTo("r:\\includes.txt"); // mPreprocessor.dumpIncludesListTo("r:\\includes.txt");
#endif #endif
//qDebug()<<"preprocess"<<timer.elapsed(); //qDebug()<<"preprocess"<<timer.elapsed();
@ -4416,7 +4416,7 @@ void CppParser::internalParse(const QString &fileName)
if (mTokenizer.tokenCount() == 0) if (mTokenizer.tokenCount() == 0)
return; return;
#ifdef QT_DEBUG #ifdef QT_DEBUG
// mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName)));
#endif #endif
#ifdef QT_DEBUG #ifdef QT_DEBUG
mLastIndex = -1; mLastIndex = -1;
@ -4429,8 +4429,8 @@ void CppParser::internalParse(const QString &fileName)
} }
// qDebug()<<"parse"<<timer.elapsed(); // qDebug()<<"parse"<<timer.elapsed();
#ifdef QT_DEBUG #ifdef QT_DEBUG
// mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName))); mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName)));
// mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName))); mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
#endif #endif
//reduce memory usage //reduce memory usage
internalClear(); internalClear();

View File

@ -485,15 +485,17 @@ QString CppTokenizer::getWord()
skipToNextToken(); skipToNextToken();
} }
} else if (*mCurrent == '[') { } else if (*mCurrent == '[') {
// Append array stuff if (*(mCurrent+1)!='[') {
while(true) { // Append array stuff
offset = mCurrent; while(true) {
skipPair('[', ']'); offset = mCurrent;
result += QString(offset,mCurrent-offset); skipPair('[', ']');
simplifyArgs(result); result += QString(offset,mCurrent-offset);
skipToNextToken(); simplifyArgs(result);
if (*mCurrent!='[') //maybe multi-dimension array skipToNextToken();
break; if (*mCurrent!='[') //maybe multi-dimension array
break;
}
} }
} }

View File

@ -21,7 +21,7 @@ APP_NAME = RedPandaCPP
APP_VERSION = 2.26 APP_VERSION = 2.26
TEST_VERSION = alpha1 TEST_VERSION = alpha5
win32: { win32: {
SUBDIRS += \ SUBDIRS += \