Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: alexfh, LegalizeAdulthood, aaron.ballman.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.
This fix for PR26332. I checked it on my work code base.

Build and regressions were OK on RHEL 6.

Repository:
  rL LLVM

http://reviews.llvm.org/D16794

Files:
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp

Index: clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===================================================================
--- clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -273,7 +273,7 @@
                                                   StringRef BooleanId) {
   Finder->addMatcher(
       binaryOperator(
-          isExpansionInMainFile(), hasOperatorName(OperatorName),
+          hasOperatorName(OperatorName),
           hasLHS(allOf(expr().bind(LHSId),
                        cxxBoolLiteral(equals(Value)).bind(BooleanId))),
           hasRHS(expr().bind(RHSId)),
@@ -287,8 +287,7 @@
                                                   StringRef BooleanId) {
   Finder->addMatcher(
       binaryOperator(
-          isExpansionInMainFile(), hasOperatorName(OperatorName),
-          hasLHS(expr().bind(LHSId)),
+          hasOperatorName(OperatorName), hasLHS(expr().bind(LHSId)),
           unless(
               hasLHS(anyOf(cxxBoolLiteral(), 
hasDescendant(cxxBoolLiteral())))),
           hasRHS(allOf(expr().bind(RHSId),
@@ -301,7 +300,7 @@
                                                    StringRef OperatorName,
                                                    StringRef BooleanId) {
   Finder->addMatcher(
-      binaryOperator(isExpansionInMainFile(), hasOperatorName(OperatorName),
+      binaryOperator(hasOperatorName(OperatorName),
                      hasLHS(allOf(expr().bind(LHSId),
                                   
ignoringImpCasts(cxxBoolLiteral(equals(Value))
                                                        .bind(BooleanId)))),
@@ -315,7 +314,7 @@
                                                    StringRef OperatorName,
                                                    StringRef BooleanId) {
   Finder->addMatcher(
-      binaryOperator(isExpansionInMainFile(), hasOperatorName(OperatorName),
+      binaryOperator(hasOperatorName(OperatorName),
                      unless(hasLHS(hasDescendant(cxxBoolLiteral()))),
                      hasLHS(expr().bind(LHSId)),
                      hasRHS(allOf(expr().bind(RHSId),
@@ -327,8 +326,7 @@
 void SimplifyBooleanExprCheck::matchBoolCondition(MatchFinder *Finder,
                                                   bool Value,
                                                   StringRef BooleanId) {
-  Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-                            hasCondition(cxxBoolLiteral(equals(Value))
+  Finder->addMatcher(ifStmt(hasCondition(cxxBoolLiteral(equals(Value))
                                              .bind(BooleanId))).bind(IfStmtId),
                      this);
 }
@@ -337,8 +335,7 @@
                                                   bool Value,
                                                   StringRef TernaryId) {
   Finder->addMatcher(
-      conditionalOperator(isExpansionInMainFile(),
-                          hasTrueExpression(cxxBoolLiteral(equals(Value))),
+      conditionalOperator(hasTrueExpression(cxxBoolLiteral(equals(Value))),
                           hasFalseExpression(cxxBoolLiteral(equals(!Value))))
           .bind(TernaryId),
       this);
@@ -347,13 +344,11 @@
 void SimplifyBooleanExprCheck::matchIfReturnsBool(MatchFinder *Finder,
                                                   bool Value, StringRef Id) {
   if (ChainedConditionalReturn) {
-    Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-                              hasThen(returnsBool(Value, ThenLiteralId)),
+    Finder->addMatcher(ifStmt(hasThen(returnsBool(Value, ThenLiteralId)),
                               hasElse(returnsBool(!Value))).bind(Id),
                        this);
   } else {
-    Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-                              unless(hasParent(ifStmt())),
+    Finder->addMatcher(ifStmt(unless(hasParent(ifStmt())),
                               hasThen(returnsBool(Value, ThenLiteralId)),
                               hasElse(returnsBool(!Value))).bind(Id),
                        this);
@@ -376,12 +371,9 @@
   auto Else = anyOf(SimpleElse, compoundStmt(statementCountIs(1),
                                              hasAnySubstatement(SimpleElse)));
   if (ChainedConditionalAssignment) {
-    Finder->addMatcher(
-        ifStmt(isExpansionInMainFile(), hasThen(Then), hasElse(Else)).bind(Id),
-        this);
+    Finder->addMatcher(ifStmt(hasThen(Then), hasElse(Else)).bind(Id), this);
   } else {
-    Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-                              unless(hasParent(ifStmt())), hasThen(Then),
+    Finder->addMatcher(ifStmt(unless(hasParent(ifStmt())), hasThen(Then),
                               hasElse(Else)).bind(Id),
                        this);
   }


Index: clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===================================================================
--- clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -273,7 +273,7 @@
                                                   StringRef BooleanId) {
   Finder->addMatcher(
       binaryOperator(
-          isExpansionInMainFile(), hasOperatorName(OperatorName),
+          hasOperatorName(OperatorName),
           hasLHS(allOf(expr().bind(LHSId),
                        cxxBoolLiteral(equals(Value)).bind(BooleanId))),
           hasRHS(expr().bind(RHSId)),
@@ -287,8 +287,7 @@
                                                   StringRef BooleanId) {
   Finder->addMatcher(
       binaryOperator(
-          isExpansionInMainFile(), hasOperatorName(OperatorName),
-          hasLHS(expr().bind(LHSId)),
+          hasOperatorName(OperatorName), hasLHS(expr().bind(LHSId)),
           unless(
               hasLHS(anyOf(cxxBoolLiteral(), hasDescendant(cxxBoolLiteral())))),
           hasRHS(allOf(expr().bind(RHSId),
@@ -301,7 +300,7 @@
                                                    StringRef OperatorName,
                                                    StringRef BooleanId) {
   Finder->addMatcher(
-      binaryOperator(isExpansionInMainFile(), hasOperatorName(OperatorName),
+      binaryOperator(hasOperatorName(OperatorName),
                      hasLHS(allOf(expr().bind(LHSId),
                                   ignoringImpCasts(cxxBoolLiteral(equals(Value))
                                                        .bind(BooleanId)))),
@@ -315,7 +314,7 @@
                                                    StringRef OperatorName,
                                                    StringRef BooleanId) {
   Finder->addMatcher(
-      binaryOperator(isExpansionInMainFile(), hasOperatorName(OperatorName),
+      binaryOperator(hasOperatorName(OperatorName),
                      unless(hasLHS(hasDescendant(cxxBoolLiteral()))),
                      hasLHS(expr().bind(LHSId)),
                      hasRHS(allOf(expr().bind(RHSId),
@@ -327,8 +326,7 @@
 void SimplifyBooleanExprCheck::matchBoolCondition(MatchFinder *Finder,
                                                   bool Value,
                                                   StringRef BooleanId) {
-  Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-                            hasCondition(cxxBoolLiteral(equals(Value))
+  Finder->addMatcher(ifStmt(hasCondition(cxxBoolLiteral(equals(Value))
                                              .bind(BooleanId))).bind(IfStmtId),
                      this);
 }
@@ -337,8 +335,7 @@
                                                   bool Value,
                                                   StringRef TernaryId) {
   Finder->addMatcher(
-      conditionalOperator(isExpansionInMainFile(),
-                          hasTrueExpression(cxxBoolLiteral(equals(Value))),
+      conditionalOperator(hasTrueExpression(cxxBoolLiteral(equals(Value))),
                           hasFalseExpression(cxxBoolLiteral(equals(!Value))))
           .bind(TernaryId),
       this);
@@ -347,13 +344,11 @@
 void SimplifyBooleanExprCheck::matchIfReturnsBool(MatchFinder *Finder,
                                                   bool Value, StringRef Id) {
   if (ChainedConditionalReturn) {
-    Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-                              hasThen(returnsBool(Value, ThenLiteralId)),
+    Finder->addMatcher(ifStmt(hasThen(returnsBool(Value, ThenLiteralId)),
                               hasElse(returnsBool(!Value))).bind(Id),
                        this);
   } else {
-    Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-                              unless(hasParent(ifStmt())),
+    Finder->addMatcher(ifStmt(unless(hasParent(ifStmt())),
                               hasThen(returnsBool(Value, ThenLiteralId)),
                               hasElse(returnsBool(!Value))).bind(Id),
                        this);
@@ -376,12 +371,9 @@
   auto Else = anyOf(SimpleElse, compoundStmt(statementCountIs(1),
                                              hasAnySubstatement(SimpleElse)));
   if (ChainedConditionalAssignment) {
-    Finder->addMatcher(
-        ifStmt(isExpansionInMainFile(), hasThen(Then), hasElse(Else)).bind(Id),
-        this);
+    Finder->addMatcher(ifStmt(hasThen(Then), hasElse(Else)).bind(Id), this);
   } else {
-    Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-                              unless(hasParent(ifStmt())), hasThen(Then),
+    Finder->addMatcher(ifStmt(unless(hasParent(ifStmt())), hasThen(Then),
                               hasElse(Else)).bind(Id),
                        this);
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to