- 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

@ -2319,9 +2319,16 @@ QStringList Editor::getExpressionAtPosition(
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,6 +485,7 @@ QString CppTokenizer::getWord()
skipToNextToken(); skipToNextToken();
} }
} else if (*mCurrent == '[') { } else if (*mCurrent == '[') {
if (*(mCurrent+1)!='[') {
// Append array stuff // Append array stuff
while(true) { while(true) {
offset = mCurrent; offset = mCurrent;
@ -496,6 +497,7 @@ QString CppTokenizer::getWord()
break; break;
} }
} }
}
// Keep parent/child operators // Keep parent/child operators
// if (*mCurrent == '.') { // if (*mCurrent == '.') {

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 += \