[C++] Always output a #line as first line of the pp output.

Change-Id: I60d25109ae8fe3628b1899078a21010263787c33
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Erik Verbruggen
2012-03-30 13:01:32 +02:00
parent 5001982e50
commit ff0a465403
15 changed files with 48 additions and 25 deletions

View File

@@ -1,3 +1,4 @@
# 1 "data/empty-macro.2.cpp"
# 6 "data/empty-macro.2.cpp"
class Test {
private:

View File

@@ -1,3 +1,4 @@
# 1 "data/empty-macro.cpp"
class Foo {

View File

@@ -1,3 +1,4 @@
# 1 "data/identifier-expansion.1.cpp"
#gen true
# 1 "data/identifier-expansion.1.cpp"
test test

View File

@@ -1,3 +1,4 @@
# 1 "data/identifier-expansion.2.cpp"
#gen true
# 1 "data/identifier-expansion.2.cpp"
test test

View File

@@ -1,3 +1,4 @@
# 1 "data/identifier-expansion.3.cpp"
# 8 "data/identifier-expansion.3.cpp"
enum op_code {
#gen true

View File

@@ -1,3 +1,4 @@
# 1 "data/identifier-expansion.4.cpp"

View File

@@ -1 +1,2 @@
# 1 "data/identifier-expansion.5.cpp"
# 9 "data/identifier-expansion.5.cpp"

View File

@@ -1,3 +1,4 @@
# 1 "data/macro-test.cpp"
# 7 "data/macro-test.cpp"
void thisFunctionIsEnabled();
# 21 "data/macro-test.cpp"

View File

@@ -1,3 +1,4 @@
# 1 "data/macro_expand.c"

View File

@@ -1,3 +1,4 @@
# 1 "data/recursive.1.cpp"
#gen true
# 1 "data/recursive.1.cpp"
b

View File

@@ -1,3 +1,4 @@
# 1 "data/reserved.1.cpp"
# 5 "data/reserved.1.cpp"
int f() {
foreach (QString &s, QStringList()) {

View File

@@ -192,12 +192,12 @@ public:
}
}
void sourceNeeded(const QString &fileName)
void sourceNeeded(const QString &fileName, bool nolines)
{
QByteArray src = loadSource(fileName);
QVERIFY(!src.isEmpty());
m_pp.preprocess(fileName, src, m_output, false, true, false);
m_pp.preprocess(fileName, src, m_output, nolines, true, false);
}
QList<Block> skippedBlocks() const
@@ -223,12 +223,12 @@ class tst_Preprocessor: public QObject
Q_OBJECT
protected:
QByteArray preprocess(const QString &fileName, QByteArray * /*errors*/) {
QByteArray preprocess(const QString &fileName, QByteArray * /*errors*/, bool nolines) {
//### TODO: hook up errors
QByteArray output;
Environment env;
MockClient client(&env, &output);
client.sourceNeeded("data/" + fileName);
client.sourceNeeded("data/" + fileName, nolines);
return output;
}
@@ -371,7 +371,8 @@ void tst_Preprocessor::unfinished_function_like_macro_call()
QByteArray preprocessed = preprocess(QLatin1String("<stdin>"),
QByteArray("\n#define foo(a,b) a + b"
"\nfoo(1, 2\n"));
QByteArray expected__("\n\n 1\n#gen true\n# 2 \"<stdin>\"\n+\n#gen false\n# 3 \"<stdin>\"\n 2\n");
QByteArray expected__("# 1 \"<stdin>\"\n\n\n 1\n#gen true\n# 2 \"<stdin>\"\n+\n#gen false\n# 3 \"<stdin>\"\n 2\n");
// DUMP_OUTPUT(preprocessed);
QCOMPARE(preprocessed, expected__);
}
@@ -441,7 +442,7 @@ void tst_Preprocessor::tstst()
"namespace std _GLIBCXX_VISIBILITY(default) {\n"
"}\n"
));
const QByteArray result____ ="\n\n"
const QByteArray result____ ="# 1 \"<stdin>\"\n\n\n"
"namespace std\n"
"#gen true\n"
"# 2 \"<stdin>\"\n"
@@ -454,6 +455,7 @@ void tst_Preprocessor::tstst()
" {\n"
"}\n";
// DUMP_OUTPUT(preprocessed);
QCOMPARE(preprocessed, result____);
}
@@ -468,6 +470,7 @@ void tst_Preprocessor::test_file_builtin()
QByteArray("const char *f = __FILE__\n"
));
const QByteArray result____ =
"# 1 \"some-file.c\"\n"
"const char *f =\n"
"#gen true\n"
"# 1 \"some-file.c\"\n"
@@ -506,7 +509,7 @@ void tst_Preprocessor::comparisons()
QFETCH(QString, errorfile);
QByteArray errors;
QByteArray preprocessed = preprocess(infile, &errors);
QByteArray preprocessed = preprocess(infile, &errors, infile == outfile);
// DUMP_OUTPUT(preprocessed);