diff options
Diffstat (limited to 'compilerplugins/clang/unusedfields.cxx')
-rw-r--r-- | compilerplugins/clang/unusedfields.cxx | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx index ac8a4d1aabf2..5ba6ac3c1cd6 100644 --- a/compilerplugins/clang/unusedfields.cxx +++ b/compilerplugins/clang/unusedfields.cxx @@ -70,7 +70,6 @@ static std::set<MyFieldInfo> touchedFromOutsideSet; static std::set<MyFieldInfo> touchedFromOutsideConstructorSet; static std::set<MyFieldInfo> readFromSet; static std::set<MyFieldInfo> writeToSet; -static std::set<MyFieldInfo> writeToOutsideConstructorSet; static std::set<MyFieldInfo> definitionSet; /** @@ -160,7 +159,6 @@ public: private: MyFieldInfo niceName(const FieldDecl*); void checkTouchedFromOutside(const FieldDecl* fieldDecl, const Expr* memberExpr); - void checkWriteFromOutsideConstructor(const FieldDecl* fieldDecl, const Expr* memberExpr); void checkWriteOnly(const FieldDecl* fieldDecl, const Expr* memberExpr); void checkReadOnly(const FieldDecl* fieldDecl, const Expr* memberExpr); bool isSomeKindOfZero(const Expr* arg); @@ -195,8 +193,6 @@ void UnusedFields::run() output += "read:\t" + s.parentClass + "\t" + s.fieldName + "\n"; for (const MyFieldInfo & s : writeToSet) output += "write:\t" + s.parentClass + "\t" + s.fieldName + "\n"; - for (const MyFieldInfo & s : writeToOutsideConstructorSet) - output += "write-outside-constructor:\t" + s.parentClass + "\t" + s.fieldName + "\n"; for (const MyFieldInfo & s : definitionSet) output += "definition:\t" + s.access + "\t" + s.parentClass + "\t" + s.fieldName + "\t" + s.fieldType + "\t" + s.sourceLocation + "\n"; std::ofstream myfile; @@ -676,8 +672,6 @@ void UnusedFields::checkReadOnly(const FieldDecl* fieldDecl, const Expr* memberE // we don't care about writes to a field when inside the copy/move constructor/operator= for that field if (cxxRecordDecl1 && (cxxRecordDecl1 == insideMoveOrCopyOrCloneDeclParent)) { - // ... but they matter to tbe can-be-const analysis - checkWriteFromOutsideConstructor(fieldDecl, memberExpr); return; } } @@ -891,7 +885,6 @@ void UnusedFields::checkReadOnly(const FieldDecl* fieldDecl, const Expr* memberE if (bPotentiallyWrittenTo) { writeToSet.insert(fieldInfo); - checkWriteFromOutsideConstructor(fieldDecl, memberExpr); } } @@ -1021,27 +1014,6 @@ void UnusedFields::checkTouchedFromOutside(const FieldDecl* fieldDecl, const Exp } } -// For the const-field analysis. -// Called when we have a write to a field, and we want to record that write only if it's writing from -// outside the constructor. -void UnusedFields::checkWriteFromOutsideConstructor(const FieldDecl* fieldDecl, const Expr* memberExpr) { - const FunctionDecl* memberExprParentFunction = getParentFunctionDecl(memberExpr); - bool doWrite = false; - - if (!memberExprParentFunction) - // If we are not inside a function - doWrite = true; - else if (memberExprParentFunction->getParent() != fieldDecl->getParent()) - // or we are inside a method from another class (than the one the field belongs to) - doWrite = true; - else if (!isa<CXXConstructorDecl>(memberExprParentFunction)) - // or we are not inside constructor - doWrite = true; - - if (doWrite) - writeToOutsideConstructorSet.insert(niceName(fieldDecl)); -} - llvm::Optional<CalleeWrapper> UnusedFields::getCallee(CallExpr const * callExpr) { FunctionDecl const * functionDecl = callExpr->getDirectCallee(); |