aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2019-10-01 17:11:00 +0100
committerSergio Martins <smartins@kde.org>2019-10-01 17:11:00 +0100
commit61640dabc6e7590f11b53c9db56653b99dc225d4 (patch)
tree63c526bb513903152a841cf7984aa0018886f5b6 /src
parentc973a48c983f1d571d0489964f7226fcbe72f67c (diff)
qproperty-type-mismatch: Fix more false-positives due to typedefs
Diffstat (limited to 'src')
-rw-r--r--src/checks/manuallevel/qproperty-type-mismatch.cpp13
-rw-r--r--src/checks/manuallevel/qproperty-type-mismatch.h2
2 files changed, 7 insertions, 8 deletions
diff --git a/src/checks/manuallevel/qproperty-type-mismatch.cpp b/src/checks/manuallevel/qproperty-type-mismatch.cpp
index 5ca6f22c..7dc312ce 100644
--- a/src/checks/manuallevel/qproperty-type-mismatch.cpp
+++ b/src/checks/manuallevel/qproperty-type-mismatch.cpp
@@ -202,22 +202,21 @@ void QPropertyTypeMismatch::checkFieldAgainstProperty (const Property& prop, con
}
}
-bool QPropertyTypeMismatch::typesMatch(const string &type1, QualType type2Qt, std::string &cleaned) const
+bool QPropertyTypeMismatch::typesMatch(const string &type1, QualType type2Qt, std::string &type2Cleaned) const
{
- cleaned = cleanupType(type2Qt);
- if (type1 == cleaned)
+ type2Cleaned = cleanupType(type2Qt);
+ if (type1 == type2Cleaned)
return true;
// Maybe the difference is just the scope, if yes then don't warn. We already have a check for complaining about lack of scope
- cleaned = cleanupType(type2Qt, /*unscopped=*/ true);
- if (type1 == cleaned)
+ type2Cleaned = cleanupType(type2Qt, /*unscopped=*/ true);
+ if (type1 == type2Cleaned)
return true;
// Maybe it's a typedef
auto it = m_typedefMap.find(type1);
if (it != m_typedefMap.cend()) {
- return it->second == type2Qt;
-
+ return it->second == type2Qt || cleanupType(it->second) == type2Cleaned;
}
return false;
diff --git a/src/checks/manuallevel/qproperty-type-mismatch.h b/src/checks/manuallevel/qproperty-type-mismatch.h
index 078376d9..1099d876 100644
--- a/src/checks/manuallevel/qproperty-type-mismatch.h
+++ b/src/checks/manuallevel/qproperty-type-mismatch.h
@@ -71,7 +71,7 @@ private:
void checkMethodAgainstProperty(const Property &prop, const clang::CXXMethodDecl &method, const std::string &methodName);
void checkFieldAgainstProperty(const Property &prop, const clang::FieldDecl &method, const std::string &methodName);
- bool typesMatch(const std::string &type1, clang::QualType type2Qt, std::string &cleaned) const;
+ bool typesMatch(const std::string &type1, clang::QualType type2Qt, std::string &type2Cleaned) const;
std::unordered_map<std::string, clang::QualType> m_typedefMap;
};