forked from qt-creator/qt-creator
CPlusPlus: Do not handle extremely long function-like macros
Qt Creator almost hangs and consumes a lot of memory if that happens. Just ignore such cases in preprocessor. Task-number: QTCREATORBUG-18995 Change-Id: Ib81cc18738696b02f98e5064d06c719a44ebdaa3 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -76,6 +76,7 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
enum {
|
enum {
|
||||||
|
MAX_FUNCTION_LIKE_ARGUMENTS_COUNT = 100,
|
||||||
MAX_TOKEN_EXPANSION_COUNT = 5000,
|
MAX_TOKEN_EXPANSION_COUNT = 5000,
|
||||||
MAX_TOKEN_BUFFER_DEPTH = 16000 // for when macros are using some kind of right-folding, this is the list of "delayed" buffers waiting to be expanded after the current one.
|
MAX_TOKEN_BUFFER_DEPTH = 16000 // for when macros are using some kind of right-folding, this is the list of "delayed" buffers waiting to be expanded after the current one.
|
||||||
};
|
};
|
||||||
@@ -1058,6 +1059,9 @@ bool Preprocessor::handleIdentifier(PPToken *tk)
|
|||||||
argRefs);
|
argRefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (allArgTks.size() > MAX_FUNCTION_LIKE_ARGUMENTS_COUNT)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!handleFunctionLikeMacro(macro, body, allArgTks, baseLine)) {
|
if (!handleFunctionLikeMacro(macro, body, allArgTks, baseLine)) {
|
||||||
if (m_client && !idTk.expanded())
|
if (m_client && !idTk.expanded())
|
||||||
m_client->stopExpandingMacro(idTk.byteOffset, *macro);
|
m_client->stopExpandingMacro(idTk.byteOffset, *macro);
|
||||||
|
|||||||
Reference in New Issue
Block a user