diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp index 85c9b65a90d..c85062982ec 100644 --- a/src/plugins/clangcodemodel/clangutils.cpp +++ b/src/plugins/clangcodemodel/clangutils.cpp @@ -105,9 +105,16 @@ FilePath currentCppEditorDocumentFilePath() DiagnosticTextInfo::DiagnosticTextInfo(const QString &text) : m_text(text) - , m_squareBracketStartIndex(text.lastIndexOf('[')) {} +int DiagnosticTextInfo::getSquareBracketStartIndex() const +{ + const int offset = m_text.lastIndexOf('['); + if (offset < m_text.length() - 1 && m_text.at(offset + 1) == ']') + return -1; + return offset; +} + QString DiagnosticTextInfo::textWithoutOption() const { if (m_squareBracketStartIndex == -1) diff --git a/src/plugins/clangcodemodel/clangutils.h b/src/plugins/clangcodemodel/clangutils.h index 93be75dfe23..6c64671ad0e 100644 --- a/src/plugins/clangcodemodel/clangutils.h +++ b/src/plugins/clangcodemodel/clangutils.h @@ -65,8 +65,10 @@ public: static QString clazyCheckName(const QString &option); private: + int getSquareBracketStartIndex() const; + const QString m_text; - const int m_squareBracketStartIndex; + const int m_squareBracketStartIndex = getSquareBracketStartIndex(); }; class ClangSourceRange