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

rename some fields

in preparation for const-method detection

Change-Id: Iecf7102892d664ded799615ce1a848a538dcfcef
üst d9575e72
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
*/ */
#include <algorithm> #include <algorithm>
#include <set>
#include <string> #include <string>
#include <unordered_set> #include <unordered_set>
#include <unordered_map> #include <unordered_map>
...@@ -60,8 +59,8 @@ public: ...@@ -60,8 +59,8 @@ public:
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
for (const ParmVarDecl *pParmVarDecl : interestingSet) { for (const ParmVarDecl *pParmVarDecl : interestingParamSet) {
if (cannotBeConstSet.find(pParmVarDecl) == cannotBeConstSet.end()) { if (paramCannotBeConstSet.find(pParmVarDecl) == paramCannotBeConstSet.end()) {
auto functionDecl = parmToFunction[pParmVarDecl]; auto functionDecl = parmToFunction[pParmVarDecl];
auto canonicalDecl = functionDecl->getCanonicalDecl(); auto canonicalDecl = functionDecl->getCanonicalDecl();
if (ignoredFunctions_.find(canonicalDecl) if (ignoredFunctions_.find(canonicalDecl)
...@@ -174,10 +173,10 @@ private: ...@@ -174,10 +173,10 @@ private:
bool checkIfCanBeConst(const Stmt*, const ParmVarDecl*); bool checkIfCanBeConst(const Stmt*, const ParmVarDecl*);
bool isPointerOrReferenceToConst(const QualType& qt); bool isPointerOrReferenceToConst(const QualType& qt);
std::unordered_set<const ParmVarDecl*> interestingSet; std::unordered_set<const ParmVarDecl*> interestingParamSet;
std::unordered_map<const ParmVarDecl*, const FunctionDecl*> parmToFunction; std::unordered_map<const ParmVarDecl*, const FunctionDecl*> parmToFunction;
std::unordered_set<const ParmVarDecl*> cannotBeConstSet; std::unordered_set<const ParmVarDecl*> paramCannotBeConstSet;
std::set<FunctionDecl const *> ignoredFunctions_; std::unordered_set<FunctionDecl const *> ignoredFunctions_;
Expr const * callee_ = nullptr; Expr const * callee_ = nullptr;
}; };
...@@ -257,7 +256,7 @@ bool ConstParams::VisitFunctionDecl(const FunctionDecl * functionDecl) ...@@ -257,7 +256,7 @@ bool ConstParams::VisitFunctionDecl(const FunctionDecl * functionDecl)
// ignore things with template params // ignore things with template params
if (pParmVarDecl->getType()->isInstantiationDependentType()) if (pParmVarDecl->getType()->isInstantiationDependentType())
continue; continue;
interestingSet.insert(pParmVarDecl); interestingParamSet.insert(pParmVarDecl);
parmToFunction[pParmVarDecl] = functionDecl; parmToFunction[pParmVarDecl] = functionDecl;
} }
...@@ -278,10 +277,10 @@ bool ConstParams::VisitDeclRefExpr( const DeclRefExpr* declRefExpr ) ...@@ -278,10 +277,10 @@ bool ConstParams::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
return true; return true;
} }
// no need to check again if we have already eliminated this one // no need to check again if we have already eliminated this one
if (cannotBeConstSet.find(parmVarDecl) != cannotBeConstSet.end()) if (paramCannotBeConstSet.find(parmVarDecl) != paramCannotBeConstSet.end())
return true; return true;
if (!checkIfCanBeConst(declRefExpr, parmVarDecl)) if (!checkIfCanBeConst(declRefExpr, parmVarDecl))
cannotBeConstSet.insert(parmVarDecl); paramCannotBeConstSet.insert(parmVarDecl);
return true; return true;
} }
......
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