diff options
| author | Tom Care <tom.care@uqconnect.edu.au> | 2010-09-07 20:27:56 +0000 |
|---|---|---|
| committer | Tom Care <tom.care@uqconnect.edu.au> | 2010-09-07 20:27:56 +0000 |
| commit | bc9eaef24cd9bf46eb2f99c876faeee214f75711 (patch) | |
| tree | 879f36701d010d16aadc503a80526dc28cb246e3 /clang/lib | |
| parent | 95852755a84a744f549dcbc15ca9e76a6d6cf3a5 (diff) | |
| download | bcm5719-llvm-bc9eaef24cd9bf46eb2f99c876faeee214f75711.tar.gz bcm5719-llvm-bc9eaef24cd9bf46eb2f99c876faeee214f75711.zip | |
Re-enabled truncation/extension checking in IdempotentOperationChecker and added a test case.
llvm-svn: 113269
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Checker/IdempotentOperationChecker.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Checker/IdempotentOperationChecker.cpp b/clang/lib/Checker/IdempotentOperationChecker.cpp index 6411c790ef7..2e85013a768 100644 --- a/clang/lib/Checker/IdempotentOperationChecker.cpp +++ b/clang/lib/Checker/IdempotentOperationChecker.cpp @@ -78,8 +78,8 @@ class IdempotentOperationChecker // False positive reduction methods static bool isSelfAssign(const Expr *LHS, const Expr *RHS); static bool isUnused(const Expr *E, AnalysisContext *AC); - //static bool isTruncationExtensionAssignment(const Expr *LHS, - // const Expr *RHS); + static bool isTruncationExtensionAssignment(const Expr *LHS, + const Expr *RHS); static bool PathWasCompletelyAnalyzed(const CFG *C, const CFGBlock *CB, const GRCoreEngine &CE); @@ -196,9 +196,10 @@ void IdempotentOperationChecker::PreVisitBinaryOperator( case BO_Assign: // x Assign x can be used to silence unused variable warnings intentionally. // If this is a self assignment and the variable is referenced elsewhere, - // then it is a false positive. + // and the assignment is not a truncation or extension, then it is a false + // positive. if (isSelfAssign(LHS, RHS)) { - if (!isUnused(LHS, AC)) { + if (!isUnused(LHS, AC) && !isTruncationExtensionAssignment(LHS, RHS)) { UpdateAssumption(A, Equal); return; } @@ -500,7 +501,6 @@ bool IdempotentOperationChecker::isUnused(const Expr *E, return true; } -#if 0 // Check for self casts truncating/extending a variable bool IdempotentOperationChecker::isTruncationExtensionAssignment( const Expr *LHS, @@ -523,7 +523,6 @@ bool IdempotentOperationChecker::isTruncationExtensionAssignment( return dyn_cast<DeclRefExpr>(RHS->IgnoreParens()) == NULL; } -#endif // Returns false if a path to this block was not completely analyzed, or true // otherwise. |

