diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-05 08:29:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-06 08:43:33 +0200 |
commit | dccd1633a111ba124f9868a4a51579c95200d745 (patch) | |
tree | 221a16d33215ffde2b249c7aca6f8c83981dbec4 /compilerplugins | |
parent | 9c34471f54870fc685c343f4af30310e75d3a9ca (diff) |
loplugin:unnecessaryparen include case statements
Change-Id: I79fb3eec0d5d466e33b2e18621a7169695edf82f
Reviewed-on: https://gerrit.libreoffice.org/41920
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/test/unnecessaryparen.cxx | 3 | ||||
-rw-r--r-- | compilerplugins/clang/unnecessaryparen.cxx | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/compilerplugins/clang/test/unnecessaryparen.cxx b/compilerplugins/clang/test/unnecessaryparen.cxx index 1ea22288673e..cb237c551889 100644 --- a/compilerplugins/clang/test/unnecessaryparen.cxx +++ b/compilerplugins/clang/test/unnecessaryparen.cxx @@ -23,10 +23,9 @@ int main() int y = (x); // expected-error {{unnecessary parentheses around identifier [loplugin:unnecessaryparen]}} (void)y; - // lots of our code uses this style, which I'm loathe to bulk-fix as yet EFoo foo = EFoo::Bar; switch (foo) { - case (EFoo::Bar): break; + 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 diff --git a/compilerplugins/clang/unnecessaryparen.cxx b/compilerplugins/clang/unnecessaryparen.cxx index 7f0e532585c1..8a94051d5bf4 100644 --- a/compilerplugins/clang/unnecessaryparen.cxx +++ b/compilerplugins/clang/unnecessaryparen.cxx @@ -55,6 +55,7 @@ public: bool VisitDoStmt(const DoStmt *); bool VisitWhileStmt(const WhileStmt *); bool VisitSwitchStmt(const SwitchStmt *); + bool VisitCaseStmt(const CaseStmt *); bool VisitReturnStmt(const ReturnStmt* ); bool VisitCallExpr(const CallExpr *); bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *); @@ -175,6 +176,12 @@ bool UnnecessaryParen::VisitSwitchStmt(const SwitchStmt* switchStmt) return true; } +bool UnnecessaryParen::VisitCaseStmt(const CaseStmt* caseStmt) +{ + VisitSomeStmt(caseStmt, caseStmt->getLHS(), "case"); + return true; +} + bool UnnecessaryParen::VisitReturnStmt(const ReturnStmt* returnStmt) { if (ignoreLocation(returnStmt)) |