forked from qt-creator/qt-creator
C++: Always skip unknown preprocessor "directives"
Task-number: QTCREATORBUG-7780 Change-Id: Ie93704feff17ad8229e50fb1133048f2c7598dea Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -1417,10 +1417,10 @@ void Preprocessor::handlePreprocessorDirective(PPToken *tk)
|
|||||||
handleElseDirective(tk, poundToken);
|
handleElseDirective(tk, poundToken);
|
||||||
else if (directive == ppElif)
|
else if (directive == ppElif)
|
||||||
handleElifDirective(tk, poundToken);
|
handleElifDirective(tk, poundToken);
|
||||||
|
}
|
||||||
|
|
||||||
skipPreprocesorDirective(tk);
|
skipPreprocesorDirective(tk);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Preprocessor::handleIncludeDirective(PPToken *tk)
|
void Preprocessor::handleIncludeDirective(PPToken *tk)
|
||||||
|
@@ -338,6 +338,8 @@ private slots:
|
|||||||
void multitokens_argument_data();
|
void multitokens_argument_data();
|
||||||
void multiline_strings();
|
void multiline_strings();
|
||||||
void multiline_strings_data();
|
void multiline_strings_data();
|
||||||
|
void skip_unknown_directives();
|
||||||
|
void skip_unknown_directives_data();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove all #... lines, and 'simplify' string, to allow easily comparing the result
|
// Remove all #... lines, and 'simplify' string, to allow easily comparing the result
|
||||||
@@ -1394,6 +1396,30 @@ void tst_Preprocessor::multiline_strings_data()
|
|||||||
QTest::newRow("case 1") << original << expected;
|
QTest::newRow("case 1") << original << expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_Preprocessor::skip_unknown_directives()
|
||||||
|
{
|
||||||
|
compare_input_output();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_Preprocessor::skip_unknown_directives_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QByteArray>("input");
|
||||||
|
QTest::addColumn<QByteArray>("output");
|
||||||
|
|
||||||
|
QByteArray original;
|
||||||
|
QByteArray expected;
|
||||||
|
|
||||||
|
// We should skip "weird" things when preprocessing. Particularly useful when we preprocess
|
||||||
|
// a particular expression from a document which has already been processed.
|
||||||
|
|
||||||
|
original = "# foo\n"
|
||||||
|
"# 10 \"file.cpp\"\n"
|
||||||
|
"# ()\n"
|
||||||
|
"#\n";
|
||||||
|
expected = "# 1 \"<stdin>\"\n";
|
||||||
|
QTest::newRow("case 1") << original << expected;
|
||||||
|
}
|
||||||
|
|
||||||
void tst_Preprocessor::compare_input_output(bool keepComments)
|
void tst_Preprocessor::compare_input_output(bool keepComments)
|
||||||
{
|
{
|
||||||
QFETCH(QByteArray, input);
|
QFETCH(QByteArray, input);
|
||||||
|
Reference in New Issue
Block a user