Commit 57602f92 authored by Sergio Martins's avatar Sergio Martins

Merge remote-tracking branch 'WaveAccessEgorGabov:master' into 1.7

Fixes compilation with llvm-11.
parents 9abf7675 25aa102c
...@@ -68,7 +68,7 @@ void FixItExporter::BeginSourceFile(const LangOptions &LangOpts, const Preproces ...@@ -68,7 +68,7 @@ void FixItExporter::BeginSourceFile(const LangOptions &LangOpts, const Preproces
const auto id = SourceMgr.getMainFileID(); const auto id = SourceMgr.getMainFileID();
const auto entry = SourceMgr.getFileEntryForID(id); const auto entry = SourceMgr.getFileEntryForID(id);
getTuDiag().MainSourceFile = entry->getName(); getTuDiag().MainSourceFile = static_cast<std::string>(entry->getName());
} }
bool FixItExporter::IncludeInDiagnosticCounts() const bool FixItExporter::IncludeInDiagnosticCounts() const
...@@ -89,7 +89,8 @@ tooling::Diagnostic FixItExporter::ConvertDiagnostic(const Diagnostic &Info) ...@@ -89,7 +89,8 @@ tooling::Diagnostic FixItExporter::ConvertDiagnostic(const Diagnostic &Info)
// TODO: This returns an empty string: DiagEngine->getDiagnosticIDs()->getWarningOptionForDiag(Info.getID()); // TODO: This returns an empty string: DiagEngine->getDiagnosticIDs()->getWarningOptionForDiag(Info.getID());
// HACK: capture it at the end of the message: Message text [check-name] // HACK: capture it at the end of the message: Message text [check-name]
std::string checkName = DiagEngine.getDiagnosticIDs()->getWarningOptionForDiag(Info.getID()); std::string checkName =
static_cast<std::string>(DiagEngine.getDiagnosticIDs()->getWarningOptionForDiag(Info.getID()));
std::string messageText; std::string messageText;
if (checkName.empty()) { if (checkName.empty()) {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <clang/Frontend/CompilerInstance.h> #include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/FrontendPluginRegistry.h> #include <clang/Frontend/FrontendPluginRegistry.h>
#include <clang/Basic/FileManager.h>
using namespace clang; using namespace clang;
using namespace std; using namespace std;
......
...@@ -922,7 +922,7 @@ string Utils::filenameForLoc(SourceLocation loc, const clang::SourceManager &sm) ...@@ -922,7 +922,7 @@ string Utils::filenameForLoc(SourceLocation loc, const clang::SourceManager &sm)
if (loc.isMacroID()) if (loc.isMacroID())
loc = sm.getExpansionLoc(loc); loc = sm.getExpansionLoc(loc);
const string filename = sm.getFilename(loc); const string filename = static_cast<string>(sm.getFilename(loc));
auto splitted = clazy::splitString(filename, '/'); auto splitted = clazy::splitString(filename, '/');
if (splitted.empty()) if (splitted.empty())
return {}; return {};
......
...@@ -188,7 +188,7 @@ bool CheckBase::shouldIgnoreFile(SourceLocation loc) const ...@@ -188,7 +188,7 @@ bool CheckBase::shouldIgnoreFile(SourceLocation loc) const
if (!loc.isValid()) if (!loc.isValid())
return true; return true;
string filename = sm().getFilename(loc); string filename = static_cast<string>(sm().getFilename(loc));
return clazy::any_of(m_filesToIgnore, [filename](const std::string &ignored) { return clazy::any_of(m_filesToIgnore, [filename](const std::string &ignored) {
return clazy::contains(filename, ignored); return clazy::contains(filename, ignored);
......
...@@ -57,7 +57,7 @@ bool DetachingBase::isDetachingMethod(CXXMethodDecl *method, DetachingMethodType ...@@ -57,7 +57,7 @@ bool DetachingBase::isDetachingMethod(CXXMethodDecl *method, DetachingMethodType
const std::unordered_map<string, std::vector<StringRef>> &methodsByType = detachingMethodType == DetachingMethod ? clazy::detachingMethods() const std::unordered_map<string, std::vector<StringRef>> &methodsByType = detachingMethodType == DetachingMethod ? clazy::detachingMethods()
: clazy::detachingMethodsWithConstCounterParts(); : clazy::detachingMethodsWithConstCounterParts();
auto it = methodsByType.find(className); auto it = methodsByType.find(static_cast<std::string>(className));
if (it != methodsByType.cend()) { if (it != methodsByType.cend()) {
const auto &methods = it->second; const auto &methods = it->second;
if (clazy::contains(methods, clazy::name(method))) if (clazy::contains(methods, clazy::name(method)))
......
...@@ -59,7 +59,7 @@ void QEnums::VisitMacroExpands(const Token &MacroNameTok, const SourceRange &ran ...@@ -59,7 +59,7 @@ void QEnums::VisitMacroExpands(const Token &MacroNameTok, const SourceRange &ran
// We simply check if :: is present because it's very cumbersome to to check for different classes when dealing with the pre-processor // We simply check if :: is present because it's very cumbersome to to check for different classes when dealing with the pre-processor
CharSourceRange crange = Lexer::getAsCharRange(range, sm(), lo()); CharSourceRange crange = Lexer::getAsCharRange(range, sm(), lo());
string text = Lexer::getSourceText(crange, sm(), lo()); string text = static_cast<string>(Lexer::getSourceText(crange, sm(), lo()));
if (clazy::contains(text, "::")) if (clazy::contains(text, "::"))
return; return;
} }
......
...@@ -44,7 +44,7 @@ void QtMacros::VisitMacroDefined(const Token &MacroNameTok) ...@@ -44,7 +44,7 @@ void QtMacros::VisitMacroDefined(const Token &MacroNameTok)
return; return;
IdentifierInfo *ii = MacroNameTok.getIdentifierInfo(); IdentifierInfo *ii = MacroNameTok.getIdentifierInfo();
if (ii && clazy::startsWith(ii->getName(), "Q_OS_")) if (ii && clazy::startsWith(static_cast<std::string>(ii->getName()), "Q_OS_"))
m_OSMacroExists = true; m_OSMacroExists = true;
} }
...@@ -58,7 +58,7 @@ void QtMacros::checkIfDef(const Token &macroNameTok, SourceLocation Loc) ...@@ -58,7 +58,7 @@ void QtMacros::checkIfDef(const Token &macroNameTok, SourceLocation Loc)
if (preProcessorVisitor && preProcessorVisitor->qtVersion() < 51204 && ii->getName() == "Q_OS_WINDOWS") { if (preProcessorVisitor && preProcessorVisitor->qtVersion() < 51204 && ii->getName() == "Q_OS_WINDOWS") {
// Q_OS_WINDOWS was introduced in 5.12.4 // Q_OS_WINDOWS was introduced in 5.12.4
emitWarning(Loc, "Q_OS_WINDOWS was only introduced in Qt 5.12.4, use Q_OS_WIN instead"); emitWarning(Loc, "Q_OS_WINDOWS was only introduced in Qt 5.12.4, use Q_OS_WIN instead");
} else if (!m_OSMacroExists && clazy::startsWith(ii->getName(), "Q_OS_")) { } else if (!m_OSMacroExists && clazy::startsWith(static_cast<std::string>(ii->getName()), "Q_OS_")) {
emitWarning(Loc, "Include qglobal.h before testing Q_OS_ macros"); emitWarning(Loc, "Include qglobal.h before testing Q_OS_ macros");
} }
} }
......
...@@ -91,7 +91,7 @@ bool UnusedNonTrivialVariable::isUninterestingType(const CXXRecordDecl *record) ...@@ -91,7 +91,7 @@ bool UnusedNonTrivialVariable::isUninterestingType(const CXXRecordDecl *record)
static const vector<StringRef> blacklistedTemplates = { "QScopedPointer", "QSetValueOnDestroy", "QScopedValueRollback" }; static const vector<StringRef> blacklistedTemplates = { "QScopedPointer", "QSetValueOnDestroy", "QScopedValueRollback" };
StringRef className = clazy::name(record); StringRef className = clazy::name(record);
for (StringRef templateName : blacklistedTemplates) { for (StringRef templateName : blacklistedTemplates) {
if (clazy::startsWith(className, templateName)) if (clazy::startsWith(static_cast<std::string>(className), static_cast<std::string>(templateName)))
return true; return true;
} }
......
...@@ -140,7 +140,7 @@ void DetachingTemporary::VisitStmt(clang::Stmt *stm) ...@@ -140,7 +140,7 @@ void DetachingTemporary::VisitStmt(clang::Stmt *stm)
StringRef className = clazy::name(classDecl); StringRef className = clazy::name(classDecl);
const std::unordered_map<string, std::vector<StringRef>> &methodsByType = clazy::detachingMethods(); const std::unordered_map<string, std::vector<StringRef>> &methodsByType = clazy::detachingMethods();
auto it = methodsByType.find(className); auto it = methodsByType.find(static_cast<std::string>(className));
auto it2 = m_writeMethodsByType.find(className); auto it2 = m_writeMethodsByType.find(className);
std::vector<StringRef> allowedFunctions; std::vector<StringRef> allowedFunctions;
......
...@@ -74,7 +74,7 @@ void NonPodGlobalStatic::VisitStmt(clang::Stmt *stm) ...@@ -74,7 +74,7 @@ void NonPodGlobalStatic::VisitStmt(clang::Stmt *stm)
const SourceLocation declStart = clazy::getLocStart(varDecl); const SourceLocation declStart = clazy::getLocStart(varDecl);
if (declStart.isMacroID()) { if (declStart.isMacroID()) {
auto macroName = Lexer::getImmediateMacroName(declStart, sm(), lo()); auto macroName = static_cast<std::string>(Lexer::getImmediateMacroName(declStart, sm(), lo()));
if (clazy::startsWithAny(macroName, { "Q_IMPORT_PLUGIN", "Q_CONSTRUCTOR_FUNCTION", "Q_DESTRUCTOR_FUNCTION"})) // Don't warn on these if (clazy::startsWithAny(macroName, { "Q_IMPORT_PLUGIN", "Q_CONSTRUCTOR_FUNCTION", "Q_DESTRUCTOR_FUNCTION"})) // Don't warn on these
return; return;
} }
......
...@@ -69,7 +69,7 @@ void QPropertyWithoutNotify::VisitMacroExpands(const clang::Token &MacroNameTok, ...@@ -69,7 +69,7 @@ void QPropertyWithoutNotify::VisitMacroExpands(const clang::Token &MacroNameTok,
return; return;
CharSourceRange crange = Lexer::getAsCharRange(range, sm(), lo()); CharSourceRange crange = Lexer::getAsCharRange(range, sm(), lo());
string text = Lexer::getSourceText(crange, sm(), lo()); string text = static_cast<std::string>(Lexer::getSourceText(crange, sm(), lo()));
if (text.back() == ')') if (text.back() == ')')
text.pop_back(); text.pop_back();
......
...@@ -74,7 +74,7 @@ void MissingTypeInfo::VisitDecl(clang::Decl *decl) ...@@ -74,7 +74,7 @@ void MissingTypeInfo::VisitDecl(clang::Decl *decl)
if (sm().isInSystemHeader(clazy::getLocStart(record))) if (sm().isInSystemHeader(clazy::getLocStart(record)))
return; return;
std::string typeName = clazy::name(record); std::string typeName = static_cast<std::string>(clazy::name(record));
if (typeName == "QPair") // QPair doesn't use Q_DECLARE_TYPEINFO, but rather a explicit QTypeInfo. if (typeName == "QPair") // QPair doesn't use Q_DECLARE_TYPEINFO, but rather a explicit QTypeInfo.
return; return;
......
...@@ -272,7 +272,7 @@ void OldStyleConnect::VisitMacroExpands(const Token &macroNameTok, const SourceR ...@@ -272,7 +272,7 @@ void OldStyleConnect::VisitMacroExpands(const Token &macroNameTok, const SourceR
return; return;
auto charRange = Lexer::getAsCharRange(range, sm(), lo()); auto charRange = Lexer::getAsCharRange(range, sm(), lo());
const string text = Lexer::getSourceText(charRange, sm(), lo()); const string text = static_cast<string>(Lexer::getSourceText(charRange, sm(), lo()));
static regex rx(R"(Q_PRIVATE_SLOT\s*\((.*)\s*,\s*.*\s+(.*)\(.*)"); static regex rx(R"(Q_PRIVATE_SLOT\s*\((.*)\s*,\s*.*\s+(.*)\(.*)");
smatch match; smatch match;
...@@ -291,7 +291,7 @@ string OldStyleConnect::signalOrSlotNameFromMacro(SourceLocation macroLoc) ...@@ -291,7 +291,7 @@ string OldStyleConnect::signalOrSlotNameFromMacro(SourceLocation macroLoc)
CharSourceRange expansionRange = clazy::getImmediateExpansionRange(macroLoc, sm()); CharSourceRange expansionRange = clazy::getImmediateExpansionRange(macroLoc, sm());
SourceRange range = SourceRange(expansionRange.getBegin(), expansionRange.getEnd()); SourceRange range = SourceRange(expansionRange.getBegin(), expansionRange.getEnd());
auto charRange = Lexer::getAsCharRange(range, sm(), lo()); auto charRange = Lexer::getAsCharRange(range, sm(), lo());
const string text = Lexer::getSourceText(charRange, sm(), lo()); const string text = static_cast<string>(Lexer::getSourceText(charRange, sm(), lo()));
static regex rx(R"(\s*(SIGNAL|SLOT)\s*\(\s*(.+)\s*\(.*)"); static regex rx(R"(\s*(SIGNAL|SLOT)\s*\(\s*(.+)\s*\(.*)");
...@@ -313,7 +313,7 @@ bool OldStyleConnect::isSignalOrSlot(SourceLocation loc, string &macroName) cons ...@@ -313,7 +313,7 @@ bool OldStyleConnect::isSignalOrSlot(SourceLocation loc, string &macroName) cons
if (!loc.isMacroID() || loc.isInvalid()) if (!loc.isMacroID() || loc.isInvalid())
return false; return false;
macroName = Lexer::getImmediateMacroName(loc, sm(), lo()); macroName = static_cast<string>(Lexer::getImmediateMacroName(loc, sm(), lo()));
return macroName == "SIGNAL" || macroName == "SLOT"; return macroName == "SIGNAL" || macroName == "SLOT";
} }
......
...@@ -140,7 +140,7 @@ void RuleOfThree::VisitDecl(clang::Decl *decl) ...@@ -140,7 +140,7 @@ void RuleOfThree::VisitDecl(clang::Decl *decl)
const string className = record->getNameAsString(); const string className = record->getNameAsString();
const string classQualifiedName = record->getQualifiedNameAsString(); const string classQualifiedName = record->getQualifiedNameAsString();
const string filename = sm().getFilename(recordStart); const string filename = static_cast<string>(sm().getFilename(recordStart));
if (clazy::endsWith(className, "Private") && clazy::endsWithAny(filename, { ".cpp", ".cxx", "_p.h" })) if (clazy::endsWith(className, "Private") && clazy::endsWithAny(filename, { ".cpp", ".cxx", "_p.h" }))
return; // Lots of RAII classes fall into this category. And even Private (d-pointer) classes, warning in that case would just be noise return; // Lots of RAII classes fall into this category. And even Private (d-pointer) classes, warning in that case would just be noise
......
...@@ -44,7 +44,7 @@ void IfndefDefineTypo::VisitMacroDefined(const Token &macroNameTok) ...@@ -44,7 +44,7 @@ void IfndefDefineTypo::VisitMacroDefined(const Token &macroNameTok)
{ {
if (!m_lastIfndef.empty()) { if (!m_lastIfndef.empty()) {
if (IdentifierInfo *ii = macroNameTok.getIdentifierInfo()) { if (IdentifierInfo *ii = macroNameTok.getIdentifierInfo()) {
maybeWarn(ii->getName(), macroNameTok.getLocation()); maybeWarn(static_cast<std::string>(ii->getName()), macroNameTok.getLocation());
} }
} }
} }
...@@ -53,7 +53,7 @@ void IfndefDefineTypo::VisitDefined(const Token &macroNameTok, const SourceRange ...@@ -53,7 +53,7 @@ void IfndefDefineTypo::VisitDefined(const Token &macroNameTok, const SourceRange
{ {
if (!m_lastIfndef.empty()) { if (!m_lastIfndef.empty()) {
if (IdentifierInfo *ii = macroNameTok.getIdentifierInfo()) { if (IdentifierInfo *ii = macroNameTok.getIdentifierInfo()) {
maybeWarn(ii->getName(), macroNameTok.getLocation()); maybeWarn(static_cast<std::string>(ii->getName()), macroNameTok.getLocation());
} }
} }
} }
...@@ -66,7 +66,7 @@ void IfndefDefineTypo::VisitIfdef(SourceLocation, const Token &) ...@@ -66,7 +66,7 @@ void IfndefDefineTypo::VisitIfdef(SourceLocation, const Token &)
void IfndefDefineTypo::VisitIfndef(SourceLocation, const Token &macroNameTok) void IfndefDefineTypo::VisitIfndef(SourceLocation, const Token &macroNameTok)
{ {
if (IdentifierInfo *ii = macroNameTok.getIdentifierInfo()) if (IdentifierInfo *ii = macroNameTok.getIdentifierInfo())
m_lastIfndef = ii->getName(); m_lastIfndef = static_cast<std::string>(ii->getName());
} }
void IfndefDefineTypo::VisitIf(SourceLocation, SourceRange, PPCallbacks::ConditionValueKind) void IfndefDefineTypo::VisitIf(SourceLocation, SourceRange, PPCallbacks::ConditionValueKind)
......
...@@ -103,7 +103,7 @@ void JniSignatures::checkFunctionCall(Stmt *stm) ...@@ -103,7 +103,7 @@ void JniSignatures::checkFunctionCall(Stmt *stm)
return; return;
} }
const std::string name = clazy::name(funDecl); const std::string name = static_cast<std::string>(clazy::name(funDecl));
if (name == "callObjectMethod" || name == "callMethod") { if (name == "callObjectMethod" || name == "callMethod") {
checkArgAt(callExpr, 0, methodNameRegex, "Invalid method name"); checkArgAt(callExpr, 0, methodNameRegex, "Invalid method name");
......
...@@ -237,7 +237,7 @@ void QPropertyTypeMismatch::VisitMacroExpands(const clang::Token &MacroNameTok, ...@@ -237,7 +237,7 @@ void QPropertyTypeMismatch::VisitMacroExpands(const clang::Token &MacroNameTok,
CharSourceRange crange = Lexer::getAsCharRange(range, sm(), lo()); CharSourceRange crange = Lexer::getAsCharRange(range, sm(), lo());
string text = Lexer::getSourceText(crange, sm(), lo()); string text = static_cast<string>(Lexer::getSourceText(crange, sm(), lo()));
if (!text.empty() && text.back() == ')') if (!text.empty() && text.back() == ')')
text.pop_back(); text.pop_back();
......
...@@ -65,7 +65,7 @@ void QRequiredResultCandidates::VisitDecl(clang::Decl *decl) ...@@ -65,7 +65,7 @@ void QRequiredResultCandidates::VisitDecl(clang::Decl *decl)
if (returnClass == classDecl) { if (returnClass == classDecl) {
const std::string methodName = clazy::name(method); const std::string methodName = static_cast<std::string>(clazy::name(method));
if (methodName.empty()) // fixes assert if (methodName.empty()) // fixes assert
return; return;
......
...@@ -59,12 +59,12 @@ void QtKeywords::VisitMacroExpands(const Token &macroNameTok, const SourceRange ...@@ -59,12 +59,12 @@ void QtKeywords::VisitMacroExpands(const Token &macroNameTok, const SourceRange
} }
static const vector<StringRef> keywords = { "foreach", "signals", "slots", "emit" }; static const vector<StringRef> keywords = { "foreach", "signals", "slots", "emit" };
std::string name = ii->getName(); std::string name = static_cast<std::string>(ii->getName());
if (!clazy::contains(keywords, name)) if (!clazy::contains(keywords, name))
return; return;
// Make sure the macro is Qt's. It must be defined in Qt's headers, not 3rdparty // Make sure the macro is Qt's. It must be defined in Qt's headers, not 3rdparty
std::string qtheader = sm().getFilename(sm().getSpellingLoc(minfo->getDefinitionLoc())); std::string qtheader = static_cast<std::string>(sm().getFilename(sm().getSpellingLoc(minfo->getDefinitionLoc())));
if (!clazy::endsWith(qtheader, "qglobal.h") && !clazy::endsWith(qtheader, "qobjectdefs.h")) if (!clazy::endsWith(qtheader, "qglobal.h") && !clazy::endsWith(qtheader, "qobjectdefs.h"))
return; return;
......
...@@ -78,7 +78,8 @@ static bool isCandidateMethod(CXXMethodDecl *methodDecl) ...@@ -78,7 +78,8 @@ static bool isCandidateMethod(CXXMethodDecl *methodDecl)
if (!classDecl) if (!classDecl)
return false; return false;
if (!clazy::equalsAny(clazy::name(methodDecl), { "append", "push_back", "push", "operator<<", "operator+=" })) if (!clazy::equalsAny(static_cast<std::string>(clazy::name(methodDecl)),
{ "append", "push_back", "push", "operator<<", "operator+=" }))
return false; return false;
if (!clazy::isAReserveClass(classDecl)) if (!clazy::isAReserveClass(classDecl))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment