Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: alexfh, aaron.ballman, hokein, etienneb.
Eugene.Zelenko added subscribers: cfe-commits, Prazek.
Eugene.Zelenko set the repository for this revision to rL LLVM.

Unfortunately, misc-redundant-expression didn't detect problem in own code.

I also fixed some  Include What You Use and modernize-use-bool-literals 
warnings.

See http://www.viva64.com/en/b/0446/ for full article about problems found in 
LLVM code by PVS-Studio.


Repository:
  rL LLVM

https://reviews.llvm.org/D26176

Files:
  
llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp


Index: 
llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===================================================================
--- 
llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ 
llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -12,7 +12,20 @@
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/Support/Casting.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+#include <set>
+#include <string>
+#include <vector>
 
 using namespace clang::ast_matchers;
 using namespace clang::tidy::matchers;
@@ -171,7 +184,7 @@
   }
 
   // Handle cases where the constants are different.
-  if ((OpcodeLHS == BO_EQ || OpcodeLHS == BO_LE || OpcodeLHS == BO_LE) &&
+  if ((OpcodeLHS == BO_EQ || OpcodeLHS == BO_LT || OpcodeLHS == BO_LE) &&
       (OpcodeRHS == BO_EQ || OpcodeRHS == BO_GT || OpcodeRHS == BO_GE))
     return true;
 
@@ -401,7 +414,7 @@
     // Operand received with implicit comparator (cast).
     Opcode = BO_NE;
     OperandExpr = Cast;
-    Value = APSInt(32, 0);
+    Value = APSInt(32, false);
   } else {
     return false;
   }


Index: llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===================================================================
--- llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -12,7 +12,20 @@
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/Support/Casting.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+#include <set>
+#include <string>
+#include <vector>
 
 using namespace clang::ast_matchers;
 using namespace clang::tidy::matchers;
@@ -171,7 +184,7 @@
   }
 
   // Handle cases where the constants are different.
-  if ((OpcodeLHS == BO_EQ || OpcodeLHS == BO_LE || OpcodeLHS == BO_LE) &&
+  if ((OpcodeLHS == BO_EQ || OpcodeLHS == BO_LT || OpcodeLHS == BO_LE) &&
       (OpcodeRHS == BO_EQ || OpcodeRHS == BO_GT || OpcodeRHS == BO_GE))
     return true;
 
@@ -401,7 +414,7 @@
     // Operand received with implicit comparator (cast).
     Opcode = BO_NE;
     OperandExpr = Cast;
-    Value = APSInt(32, 0);
+    Value = APSInt(32, false);
   } else {
     return false;
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to