Kaydet (Commit) 5585bc2f authored tarafından Noel Grandin's avatar Noel Grandin

rename loplugin::Plugin::parentStmt

to getParentStmt and rename parentFunctionDecl to getParentFunctionDecl,
so I don't keep using accidentally naming my variables the same as the
functions.

Change-Id: I66f9452458c8b439e5132191ac5219fb6d420708
üst 13c26e56
......@@ -132,7 +132,7 @@ void CheckUnusedParams::checkForFunctionDecl(Expr const * expr, bool bCheckOnly)
if (!functionDecl)
return;
if (bCheckOnly)
parentStmt(expr)->dump();
getParentStmt(expr)->dump();
else
m_addressOfSet.insert(functionDecl->getCanonicalDecl());
}
......
......@@ -289,7 +289,7 @@ bool ConstParams::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
// related ParamVarDecl can be const.
bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVarDecl)
{
const Stmt* parent = parentStmt( stmt );
const Stmt* parent = getParentStmt( stmt );
if (!parent)
{
// check if we're inside a CXXCtorInitializer
......
......@@ -62,13 +62,13 @@ bool DodgySwitch::VisitCaseStmt(CaseStmt const * caseStmt)
bool DodgySwitch::IsParentSwitch(Stmt const * stmt)
{
auto parent = parentStmt(stmt);
auto parent = getParentStmt(stmt);
if (isa<CaseStmt>(parent) || isa<DefaultStmt>(parent)) // daisy chain
return true;
auto compoundStmt = dyn_cast<CompoundStmt>(parent);
if (!compoundStmt)
return false;
return isa<SwitchStmt>(parentStmt(compoundStmt));
return isa<SwitchStmt>(getParentStmt(compoundStmt));
}
loplugin::Plugin::Registration< DodgySwitch > X("dodgyswitch", false);
......
......@@ -272,7 +272,7 @@ void ExpandableMethods::functionTouchedFromExpr( const FunctionDecl* calleeFunct
calledFromSet.emplace(toString(expr->getLocStart()), niceName(canonicalFunctionDecl));
if (const UnaryOperator* unaryOp = dyn_cast_or_null<UnaryOperator>(parentStmt(expr))) {
if (const UnaryOperator* unaryOp = dyn_cast_or_null<UnaryOperator>(getParentStmt(expr))) {
if (unaryOp->getOpcode() == UO_AddrOf) {
addressOfSet.insert(niceName(canonicalFunctionDecl));
}
......
......@@ -184,7 +184,7 @@ bool InlineFields::VisitBinAssign(const BinaryOperator * binaryOp)
if (!fieldDecl || !fieldDecl->getType()->isPointerType()) {
return true;
}
const FunctionDecl* parentFunction = parentFunctionDecl(binaryOp);
const FunctionDecl* parentFunction = getParentFunctionDecl(binaryOp);
if (!parentFunction) {
return true;
}
......@@ -227,7 +227,7 @@ bool InlineFields::VisitCXXDeleteExpr(const CXXDeleteExpr * deleteExpr)
}
// TODO for some reason, this part is not working properly, it doesn't find the parent
// function for delete statements properly
const FunctionDecl* parentFunction = parentFunctionDecl(deleteExpr);
const FunctionDecl* parentFunction = getParentFunctionDecl(deleteExpr);
if (!parentFunction) {
return true;
}
......
......@@ -145,7 +145,7 @@ bool MemoryVar::VisitCXXNewExpr(const CXXNewExpr *newExpr)
if (ignoreLocation(newExpr)) {
return true;
}
const Stmt* stmt = parentStmt(newExpr);
const Stmt* stmt = getParentStmt(newExpr);
const DeclStmt* declStmt = dyn_cast<DeclStmt>(stmt);
if (declStmt) {
......
......@@ -118,7 +118,7 @@ void Plugin::registerPlugin( Plugin* (*create)( const InstantiationData& ), cons
std::unordered_map< const Stmt*, const Stmt* > Plugin::parents;
const Stmt* Plugin::parentStmt( const Stmt* stmt )
const Stmt* Plugin::getParentStmt( const Stmt* stmt )
{
if( parents.empty())
buildParents( compiler );
......@@ -127,7 +127,7 @@ const Stmt* Plugin::parentStmt( const Stmt* stmt )
return parents[ stmt ];
}
Stmt* Plugin::parentStmt( Stmt* stmt )
Stmt* Plugin::getParentStmt( Stmt* stmt )
{
if( parents.empty())
buildParents( compiler );
......@@ -153,7 +153,7 @@ static const Decl* getDeclContext(ASTContext& context, const Stmt* stmt)
return nullptr;
}
const FunctionDecl* Plugin::parentFunctionDecl( const Stmt* stmt )
const FunctionDecl* Plugin::getParentFunctionDecl( const Stmt* stmt )
{
const Decl *decl = getDeclContext(compiler.getASTContext(), stmt);
if (decl)
......
......@@ -67,9 +67,9 @@ protected:
Returns the parent of the given AST node. Clang's internal AST representation doesn't provide this information,
it can only provide children, but getting the parent is often useful for inspecting a part of the AST.
*/
const Stmt* parentStmt( const Stmt* stmt );
Stmt* parentStmt( Stmt* stmt );
const FunctionDecl* parentFunctionDecl( const Stmt* stmt );
const Stmt* getParentStmt( const Stmt* stmt );
Stmt* getParentStmt( Stmt* stmt );
const FunctionDecl* getParentFunctionDecl( const Stmt* stmt );
/**
Checks if the location is inside an UNO file, more specifically, if it forms part of the URE stable interface,
which is not allowed to be changed.
......
......@@ -245,21 +245,21 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
if (ignoreLocation(memberExpr) || !isInterestingType(fieldDecl->getType()))
return true;
const FunctionDecl* parentFunction = parentFunctionDecl(memberExpr);
const FunctionDecl* parentFunction = getParentFunctionDecl(memberExpr);
const CXXMethodDecl* methodDecl = dyn_cast_or_null<CXXMethodDecl>(parentFunction);
if (methodDecl && (methodDecl->isCopyAssignmentOperator() || methodDecl->isMoveAssignmentOperator()))
return true;
// walk up the tree until we find something interesting
const Stmt* child = memberExpr;
const Stmt* parent = parentStmt(memberExpr);
const Stmt* parent = getParentStmt(memberExpr);
bool bPotentiallyAssignedTo = false;
bool bDump = false;
std::string assignValue;
// check for field being returned by non-const ref eg. Foo& getFoo() { return f; }
if (parentFunction && parent && isa<ReturnStmt>(parent)) {
const Stmt* parent2 = parentStmt(parent);
const Stmt* parent2 = getParentStmt(parent);
if (parent2 && isa<CompoundStmt>(parent2)) {
QualType qt = compat::getReturnType(*parentFunction).getDesugaredType(compiler.getASTContext());
if (!qt.isConstQualified() && qt->isReferenceType()) {
......@@ -292,7 +292,7 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
|| isa<ExprWithCleanups>(parent))
{
child = parent;
parent = parentStmt(parent);
parent = getParentStmt(parent);
}
else if (isa<UnaryOperator>(parent))
{
......@@ -304,7 +304,7 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
break;
}
child = parent;
parent = parentStmt(parent);
parent = getParentStmt(parent);
}
else if (isa<CXXOperatorCallExpr>(parent))
{
......
......@@ -144,7 +144,7 @@ bool UnusedEnumConstants::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
const Stmt * parent = declRefExpr;
try_again:
parent = parentStmt(parent);
parent = getParentStmt(parent);
bool bWrite = false;
bool bRead = false;
bool bDump = false;
......
......@@ -930,7 +930,7 @@ bool UnusedFields::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
}
void UnusedFields::checkTouchedFromOutside(const FieldDecl* fieldDecl, const Expr* memberExpr) {
const FunctionDecl* memberExprParentFunction = parentFunctionDecl(memberExpr);
const FunctionDecl* memberExprParentFunction = getParentFunctionDecl(memberExpr);
const CXXMethodDecl* methodDecl = dyn_cast_or_null<CXXMethodDecl>(memberExprParentFunction);
MyFieldInfo fieldInfo = niceName(fieldDecl);
......
......@@ -230,13 +230,13 @@ bool UnusedMethods::VisitCallExpr(CallExpr* expr)
gotfunc:
logCallToRootMethods(calleeFunctionDecl, callSet);
const Stmt* parent = parentStmt(expr);
const Stmt* parent = getParentStmt(expr);
// Now do the checks necessary for the "can be private" analysis
CXXMethodDecl* calleeMethodDecl = dyn_cast<CXXMethodDecl>(calleeFunctionDecl);
if (calleeMethodDecl && calleeMethodDecl->getAccess() != AS_private)
{
const FunctionDecl* parentFunctionOfCallSite = parentFunctionDecl(expr);
const FunctionDecl* parentFunctionOfCallSite = getParentFunctionDecl(expr);
if (parentFunctionOfCallSite != calleeFunctionDecl) {
if (!parentFunctionOfCallSite || !ignoreLocation(parentFunctionOfCallSite)) {
calledFromOutsideSet.insert(niceName(calleeFunctionDecl));
......@@ -333,7 +333,7 @@ bool UnusedMethods::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
const CXXMethodDecl* methodDecl = dyn_cast<CXXMethodDecl>(functionDecl);
if (methodDecl && methodDecl->getAccess() != AS_private)
{
const FunctionDecl* parentFunctionOfCallSite = parentFunctionDecl(declRefExpr);
const FunctionDecl* parentFunctionOfCallSite = getParentFunctionDecl(declRefExpr);
if (parentFunctionOfCallSite != functionDecl) {
if (!parentFunctionOfCallSite || !ignoreLocation(parentFunctionOfCallSite)) {
calledFromOutsideSet.insert(niceName(functionDecl));
......
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