summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-07-05 14:30:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-07-06 08:31:30 +0200
commita1ead1a0281a369087f1b2cce09431542c29bece (patch)
treedcc7dd8dc2fee88d4f125a7e1c8dd265b64030d5 /compilerplugins
parentee96ea7236958a89b60c87f688070412835ead3f (diff)
loplugin unnecessaryparan improvements
Change-Id: I73e945d6ec53537a0da45f6b6291018c7f251a7e Reviewed-on: https://gerrit.libreoffice.org/39587 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/unnecessaryparen.cxx11
1 files changed, 9 insertions, 2 deletions
diff --git a/compilerplugins/clang/unnecessaryparen.cxx b/compilerplugins/clang/unnecessaryparen.cxx
index 7c64b7077bee..cf65ecbabacf 100644
--- a/compilerplugins/clang/unnecessaryparen.cxx
+++ b/compilerplugins/clang/unnecessaryparen.cxx
@@ -31,6 +31,13 @@ public:
virtual void run() override
{
+ StringRef fn( compiler.getSourceManager().getFileEntryForID(
+ compiler.getSourceManager().getMainFileID())->getName() );
+ // fixing this makes the source in the .y files look horrible
+ if (loplugin::hasPathnamePrefix(fn, WORKDIR "/YaccTarget/unoidl/source/sourceprovider-parser.cxx"))
+ return;
+ if (loplugin::hasPathnamePrefix(fn, WORKDIR "/YaccTarget/idlc/source/parser.cxx"))
+ return;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
@@ -45,7 +52,7 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
if (parenExpr->getLocStart().isMacroID())
return true;
- auto subParenExpr = dyn_cast<ParenExpr>(parenExpr->getSubExpr());
+ auto subParenExpr = dyn_cast<ParenExpr>(parenExpr->getSubExpr()->IgnoreImpCasts());
if (subParenExpr) {
if (subParenExpr->getLocStart().isMacroID())
return true;
@@ -62,7 +69,7 @@ bool UnnecessaryParen::VisitIfStmt(const IfStmt* ifStmt)
if (ignoreLocation(ifStmt))
return true;
- if (auto parenExpr = dyn_cast<ParenExpr>(ifStmt->getCond())) {
+ if (auto parenExpr = dyn_cast<ParenExpr>(ifStmt->getCond()->IgnoreImpCasts())) {
if (parenExpr->getLocStart().isMacroID())
return true;
// assignments need extra parentheses or they generate a compiler warning