diff options
author | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2015-11-25 11:57:36 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2015-12-08 08:13:32 +0000 |
commit | 64ab4de4b0abb19fad18e009dfd094f1ae6a78c1 (patch) | |
tree | da76ba735f4895dcb4612cba32072604369f4baf /qmake | |
parent | cbb2ce0f918c471a7306a2e6a91730aad6a01f7b (diff) |
Teach qmake's #include parser to recognize C++11 Raw strings.
Can't sensibly test unless the compiler does support raw strings,
since any test that would catch qmake's (prior) inability to parse raw
strings would necessarily confuse the C++ compiler in the same way.
This even applies (in test app code) to any #if-ery around the raw
string, since tokenization happens before preprocessor directives are
resolved. So the #if-ery on Q_COMPILER_RAW_STRINGS has to be in
tst_qmake.cpp, not the test app it builds.
Change-Id: I4a461f515adff288b54fb273fd9996f9b906d11c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/generators/makefiledeps.cpp | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp index 0f11745f4c..b939a9c9d4 100644 --- a/qmake/generators/makefiledeps.cpp +++ b/qmake/generators/makefiledeps.cpp @@ -555,15 +555,44 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file) // quoted strings if (buffer[x] == '\'' || buffer[x] == '"') { - const char term = buffer[x]; - while (++x < buffer_len) { - if (buffer[x] == term) { - ++x; - break; - } else if (buffer[x] == '\\') { - ++x; - } else if (qmake_endOfLine(buffer[x])) { - ++line_count; + // It might be a C++11 raw string. + bool israw = false; + if (buffer[x] == '"' && x > 0) { + int y = x; + while (--y > 0 && (buffer[y] == '8' || buffer[y] == 'u' || buffer[y] == 'U')) {} // skip + israw = (buffer[y] == 'R'); + } + if (israw) { + x++; + const char *const delim = buffer + x; + while (x < buffer_len && buffer[x] != '(') + x++; + /* + Not checking correctness (trust real compiler to do that): + - no controls, spaces, '(', ')', '\\' or (presumably) '"' in delim; + - at most 16 bytes in delim + */ + + const int delimlen = buffer + x - delim; + while (++x < buffer_len + && (buffer[x] != ')' + || (delimlen > 0 && + strncmp(buffer + x + 1, delim, delimlen)) + || buffer[x + 1 + delimlen] != '"')) {} // skip + // buffer[x] is ')' + x += 1 + delimlen; // 1 for ')', then delim + // buffer[x] is '"' + } else { + const char term = buffer[x]; + while (++x < buffer_len) { + if (buffer[x] == term) { + ++x; + break; + } else if (buffer[x] == '\\') { + ++x; + } else if (qmake_endOfLine(buffer[x])) { + ++line_count; + } } } } |