summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-10-20 08:27:55 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-10-20 10:49:58 +0200
commite9ada6294d08983c30e043dc79e441cafa92257c (patch)
tree67309ac89ac88beb607de149698d8791d8a77ad5 /compilerplugins
parent629bc69708a280b79f07b58adcda8593e22cf422 (diff)
fix bug in expandablemethods plugin
where using a std::map instead of a std::set meant that it sometimes miscounted the number of callsites Change-Id: I1e2ebcf44fe006827e66620ae4c9bbc813835414
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/expandablemethods.cxx22
1 files changed, 13 insertions, 9 deletions
diff --git a/compilerplugins/clang/expandablemethods.cxx b/compilerplugins/clang/expandablemethods.cxx
index 73946f5e3c1c..308c8f17c36a 100644
--- a/compilerplugins/clang/expandablemethods.cxx
+++ b/compilerplugins/clang/expandablemethods.cxx
@@ -48,7 +48,7 @@ bool operator < (const MyFuncInfo &lhs, const MyFuncInfo &rhs)
// try to limit the voluminous output a little
-static std::unordered_map<std::string, MyFuncInfo> calledFromMap;
+static std::set<std::pair<std::string, MyFuncInfo>> calledFromSet;
static std::set<MyFuncInfo> definitionSet;
static std::set<MyFuncInfo> calledFromOutsideSet;
static std::set<MyFuncInfo> largeFunctionSet;
@@ -73,7 +73,7 @@ public:
output += "definition:\t" + s.access + "\t" + s.returnType + "\t" + s.nameAndParams + "\t" + s.sourceLocation + "\n";
for (const MyFuncInfo & s : calledFromOutsideSet)
output += "outside:\t" + s.returnType + "\t" + s.nameAndParams + "\n";
- for (const std::pair<std::string,MyFuncInfo> & s : calledFromMap)
+ for (const std::pair<std::string,MyFuncInfo> & s : calledFromSet)
output += "calledFrom:\t" + s.first
+ "\t" + s.second.returnType + "\t" + s.second.nameAndParams + "\n";
for (const MyFuncInfo & s : largeFunctionSet)
@@ -265,15 +265,12 @@ bool ExpandableMethods::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
void ExpandableMethods::functionTouchedFromExpr( const FunctionDecl* calleeFunctionDecl, const Expr* expr )
{
- if (maTraversingFunctions.empty()) {
- return;
- }
const FunctionDecl* canonicalFunctionDecl = calleeFunctionDecl->getCanonicalDecl();
if (!isCalleeFunctionInteresting(canonicalFunctionDecl)) {
return;
}
- calledFromMap.emplace(toString(expr->getLocStart()), niceName(canonicalFunctionDecl));
+ calledFromSet.emplace(toString(expr->getLocStart()), niceName(canonicalFunctionDecl));
if (const UnaryOperator* unaryOp = dyn_cast_or_null<UnaryOperator>(parentStmt(expr))) {
if (unaryOp->getOpcode() == UO_AddrOf) {
@@ -282,12 +279,19 @@ void ExpandableMethods::functionTouchedFromExpr( const FunctionDecl* calleeFunct
}
const CXXMethodDecl* calleeMethodDecl = dyn_cast<CXXMethodDecl>(calleeFunctionDecl);
- const CXXMethodDecl* callsiteParentMethodDecl = dyn_cast<CXXMethodDecl>(maTraversingFunctions.back());
- if (!callsiteParentMethodDecl
- || calleeMethodDecl->getParent() != callsiteParentMethodDecl->getParent())
+ if (maTraversingFunctions.empty())
{
calledFromOutsideSet.insert(niceName(canonicalFunctionDecl));
}
+ else
+ {
+ const CXXMethodDecl* callsiteParentMethodDecl = dyn_cast<CXXMethodDecl>(maTraversingFunctions.back());
+ if (!callsiteParentMethodDecl
+ || calleeMethodDecl->getParent() != callsiteParentMethodDecl->getParent())
+ {
+ calledFromOutsideSet.insert(niceName(canonicalFunctionDecl));
+ }
+ }
}
bool ExpandableMethods::isCalleeFunctionInteresting(const FunctionDecl* functionDecl)