summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/test/unnecessaryparen.cxx3
-rw-r--r--compilerplugins/clang/unnecessaryparen.cxx13
2 files changed, 1 insertions, 15 deletions
diff --git a/compilerplugins/clang/test/unnecessaryparen.cxx b/compilerplugins/clang/test/unnecessaryparen.cxx
index d07f4930c4d3..968522d63a73 100644
--- a/compilerplugins/clang/test/unnecessaryparen.cxx
+++ b/compilerplugins/clang/test/unnecessaryparen.cxx
@@ -31,8 +31,7 @@ int main()
case (EFoo::Bar): break; // expected-error {{parentheses immediately inside case statement [loplugin:unnecessaryparen]}}
}
- // lots of our code uses this style, which I'm loathe to bulk-fix as yet
- int z = (y) ? 1 : 0;
+ int z = (y) ? 1 : 0; // expected-error {{unnecessary parentheses around identifier [loplugin:unnecessaryparen]}}
(void)z;
int v1 = (static_cast<short>(1)) + 1; // expected-error {{unnecessary parentheses around cast [loplugin:unnecessaryparen]}}
diff --git a/compilerplugins/clang/unnecessaryparen.cxx b/compilerplugins/clang/unnecessaryparen.cxx
index fe3b0dd4b028..fdc83410cb0e 100644
--- a/compilerplugins/clang/unnecessaryparen.cxx
+++ b/compilerplugins/clang/unnecessaryparen.cxx
@@ -83,12 +83,10 @@ public:
bool VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *);
bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *);
bool TraverseCaseStmt(CaseStmt *);
- bool TraverseConditionalOperator(ConditionalOperator *);
private:
void VisitSomeStmt(Stmt const * stmt, const Expr* cond, StringRef stmtName);
Expr const * insideSizeof = nullptr;
Expr const * insideCaseStmt = nullptr;
- Expr const * insideConditionalOperator = nullptr;
};
bool UnnecessaryParen::TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr * expr)
@@ -111,15 +109,6 @@ bool UnnecessaryParen::TraverseCaseStmt(CaseStmt * caseStmt)
return ret;
}
-bool UnnecessaryParen::TraverseConditionalOperator(ConditionalOperator * conditionalOperator)
-{
- auto old = insideConditionalOperator;
- insideConditionalOperator = ignoreAllImplicit(conditionalOperator->getCond());
- bool ret = RecursiveASTVisitor::TraverseConditionalOperator(conditionalOperator);
- insideConditionalOperator = old;
- return ret;
-}
-
bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
{
if (ignoreLocation(parenExpr))
@@ -130,8 +119,6 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
return true;
if (insideCaseStmt && parenExpr == insideCaseStmt)
return true;
- if (insideConditionalOperator && parenExpr == insideConditionalOperator)
- return true;
auto subExpr = ignoreAllImplicit(parenExpr->getSubExpr());