aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2017-10-12 23:00:03 +0100
committerSergio Martins <iamsergio@gmail.com>2017-10-12 23:00:03 +0100
commit28bf068903c179501d123a1982036b41c2b81803 (patch)
tree911e19e7785d420eee4c7b920b8a6eef05cf815f /src
parent9e850ca7b7d41ebf36a482f7144944ac3dc16dd4 (diff)
parent92f63820f918b13ee417cedf4c1f81803c35bf92 (diff)
Merge branch '1.2' into master
Diffstat (limited to 'src')
-rw-r--r--src/checks/level0/lambda-in-connect.cpp2
-rw-r--r--src/checks/level0/qcolor-from-literal.cpp4
-rw-r--r--src/checks/level0/qenums.cpp10
-rw-r--r--src/checks/level0/qfileinfo-exists.cpp2
-rw-r--r--src/checks/ruleofbase.cpp2
5 files changed, 15 insertions, 5 deletions
diff --git a/src/checks/level0/lambda-in-connect.cpp b/src/checks/level0/lambda-in-connect.cpp
index 7ecbacf7..2e3f76ae 100644
--- a/src/checks/level0/lambda-in-connect.cpp
+++ b/src/checks/level0/lambda-in-connect.cpp
@@ -66,7 +66,7 @@ void LambdaInConnect::VisitStmt(clang::Stmt *stmt)
if (capture.getCaptureKind() == clang::LCK_ByRef) {
VarDecl *declForCapture = capture.getCapturedVar();
if (declForCapture && declForCapture != receiverDecl && ContextUtils::isValueDeclInFunctionContext(declForCapture))
- emitWarning(capture.getLocation(), "capturing local variable by reference in lambda");
+ emitWarning(capture.getLocation(), "captured local variable by reference might go out of scope before lambda is called");
}
}
}
diff --git a/src/checks/level0/qcolor-from-literal.cpp b/src/checks/level0/qcolor-from-literal.cpp
index bff2a4d5..4daf712c 100644
--- a/src/checks/level0/qcolor-from-literal.cpp
+++ b/src/checks/level0/qcolor-from-literal.cpp
@@ -59,7 +59,7 @@ public :
{
const StringLiteral *lt = result.Nodes.getNodeAs<StringLiteral>("myLiteral");
if (handleStringLiteral(lt))
- m_check->emitWarning(lt, "The QColor ctor taking ints is much cheaper than the one taking string literals");
+ m_check->emitWarning(lt, "The QColor ctor taking ints is cheaper than the one taking string literals");
}
};
@@ -87,7 +87,7 @@ void QColorFromLiteral::VisitStmt(Stmt *stmt)
StringLiteral *lt = HierarchyUtils::getFirstChildOfType2<StringLiteral>(call->getArg(0));
if (handleStringLiteral(lt))
- emitWarning(lt, "The ctor taking ints is much cheaper than QColor::setNamedColor(QString)");
+ emitWarning(lt, "The ctor taking ints is cheaper than QColor::setNamedColor(QString)");
}
void QColorFromLiteral::registerASTMatchers(MatchFinder &finder)
diff --git a/src/checks/level0/qenums.cpp b/src/checks/level0/qenums.cpp
index 5bf2c14d..68ae409c 100644
--- a/src/checks/level0/qenums.cpp
+++ b/src/checks/level0/qenums.cpp
@@ -52,6 +52,16 @@ void Qenums::VisitMacroExpands(const Token &MacroNameTok, const SourceRange &ran
if (!ii || ii->getName() != "Q_ENUMS")
return;
+ {
+ // Don't warn when importing enums of other classes, because Q_ENUM doesn't support it.
+ // 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());
+ string text = Lexer::getSourceText(crange, sm(), lo());
+ if (clazy_std::contains(text, "::"))
+ return;
+ }
+
if (range.getBegin().isMacroID())
return;
diff --git a/src/checks/level0/qfileinfo-exists.cpp b/src/checks/level0/qfileinfo-exists.cpp
index 78ab7855..041423d8 100644
--- a/src/checks/level0/qfileinfo-exists.cpp
+++ b/src/checks/level0/qfileinfo-exists.cpp
@@ -47,7 +47,7 @@ void QFileInfoExists::VisitStmt(clang::Stmt *stmt)
if (!ctorExpr || StringUtils::simpleArgTypeName(ctorExpr->getConstructor(), 0, lo()) != "QString")
return;
- emitWarning(stmt->getLocStart(), "Use the static QFileInfo::exists() instead");
+ emitWarning(stmt->getLocStart(), "Use the static QFileInfo::exists() instead. It's documented to be faster.");
}
diff --git a/src/checks/ruleofbase.cpp b/src/checks/ruleofbase.cpp
index 1d0b774b..13972fb3 100644
--- a/src/checks/ruleofbase.cpp
+++ b/src/checks/ruleofbase.cpp
@@ -32,7 +32,7 @@ RuleOfBase::RuleOfBase(const std::string &name, ClazyContext *context)
bool RuleOfBase::isBlacklisted(CXXRecordDecl *record) const
{
- if (!record)
+ if (!record || clazy_std::startsWith(record->getQualifiedNameAsString(), "std::"))
return true;
const auto qualifiedName = StringUtils::classNameFor(record);