diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-05-16 09:39:23 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-05-16 09:39:23 +0200 |
commit | d39717a6d6e6b3f507423a5da6d338de2541e43a (patch) | |
tree | e230443ba8fa061648b60ccedc035aebae7559fc /compilerplugins | |
parent | d67747c59c22e0346e13560810b9f3bf6c698428 (diff) |
tighten up the check a little more
Change-Id: Ic19364d2daa064a20da0ed9d9641f1646d8f6ce3
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/unusedfields.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx index d3177e21ad24..60eca65e8fb0 100644 --- a/compilerplugins/clang/unusedfields.cxx +++ b/compilerplugins/clang/unusedfields.cxx @@ -188,6 +188,10 @@ static char easytolower(char in) return in-('Z'-'z'); return in; } +bool startswith(const std::string& rStr, const char* pSubStr) +{ + return rStr.compare(0, strlen(pSubStr), pSubStr) == 0; +} bool UnusedFields::VisitMemberExpr( const MemberExpr* memberExpr ) { @@ -248,11 +252,11 @@ bool UnusedFields::VisitMemberExpr( const MemberExpr* memberExpr ) { // check for calls to ReadXXX() type methods and the operator>>= methods on Any. const FunctionDecl * calleeFunctionDecl = callExpr->getDirectCallee(); - if (calleeFunctionDecl) + if (calleeFunctionDecl && calleeFunctionDecl->getIdentifier()) { - std::string name = calleeFunctionDecl->getQualifiedNameAsString(); + std::string name = calleeFunctionDecl->getNameAsString(); std::transform(name.begin(), name.end(), name.begin(), easytolower); - if (name.find("read") != std::string::npos || name.find(">>=") != std::string::npos) + if (startswith(name, "read") || name.find(">>=") != std::string::npos) // this is a write-only call ; else |