summaryrefslogtreecommitdiffstats
path: root/qmake/generators/makefiledeps.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/generators/makefiledeps.cpp')
-rw-r--r--qmake/generators/makefiledeps.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp
index 0646d232ce..8e8d42cc96 100644
--- a/qmake/generators/makefiledeps.cpp
+++ b/qmake/generators/makefiledeps.cpp
@@ -164,7 +164,7 @@ void QMakeSourceFileInfo::setDependencyPaths(const QList<QMakeLocalFileName> &l)
{
// Ensure that depdirs does not contain the same paths several times, to minimize the stats
QList<QMakeLocalFileName> ll;
- for (int i = 0; i < l.count(); ++i) {
+ for (int i = 0; i < l.size(); ++i) {
if (!ll.contains(l.at(i)))
ll.append(l.at(i));
}
@@ -365,13 +365,21 @@ static bool matchWhileUnsplitting(const char *buffer, int buffer_len, int start,
return true;
}
-/* Advance from an opening quote at buffer[offset] to the matching close quote. */
+/* Advance from an opening quote at buffer[offset] to the matching close quote.
+ If an apostrophe turns out to be a digit-separator in a numeric literal,
+ rather than the start of a character literal, treat it as both the open and
+ the close quote of the "string" that isn't there.
+*/
static int scanPastString(char *buffer, int buffer_len, int offset, int *lines)
{
// http://en.cppreference.com/w/cpp/language/string_literal
// It might be a C++11 raw string.
bool israw = false;
- if (buffer[offset] == '"' && offset > 0) {
+
+ Q_ASSERT(offset < buffer_len);
+ if (offset <= 0) {
+ // skip, neither of these special cases applies here
+ } else if (buffer[offset] == '"') {
int explore = offset - 1;
bool prefix = false; // One of L, U, u or u8 may appear before R
bool saw8 = false; // Partial scan of u8
@@ -415,6 +423,19 @@ static int scanPastString(char *buffer, int buffer_len, int offset, int *lines)
&& (isalnum(buffer[explore]) || buffer[explore] == '_')) {
israw = false;
}
+
+ } else {
+ // Is this apostrophe a digit separator rather than the start of a
+ // character literal ? If so, there was no string to scan past, so
+ // treat the apostrophe as both open and close.
+ Q_ASSERT(buffer[offset] == '\'' && offset > 0);
+ // Wrap std::isdigit() to package the casting to unsigned char.
+ const auto isDigit = [](unsigned char c) { return std::isdigit(c); };
+ if (isDigit(buffer[offset - 1]) && offset + 1 < buffer_len && isDigit(buffer[offset + 1])) {
+ // One exception: u8'0' is a perfectly good character literal.
+ if (offset < 2 || buffer[offset - 1] != '8' || buffer[offset - 2] != 'u')
+ return offset;
+ }
}
if (israw) {
@@ -788,7 +809,7 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
}
}
if(!exists) { //path lookup
- for (const QMakeLocalFileName &depdir : qAsConst(depdirs)) {
+ for (const QMakeLocalFileName &depdir : std::as_const(depdirs)) {
QMakeLocalFileName f(depdir.real() + Option::dir_sep + lfn.real());
QFileInfo fi(findFileInfo(f));
if(fi.exists() && !fi.isDir()) {