diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-10-10 11:38:18 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-10-10 13:02:40 +0200 |
commit | bfaf25f59352eb81c7f53c741995a82021f4b0ff (patch) | |
tree | 2f42915362542c93a9ebdebdeae088e73c5eed6f /compilerplugins/clang/indentation.cxx | |
parent | 06767a5394f1dfba71c4f0a2a07daa5664bdbd01 (diff) |
Silence -Werror,-Wunused-variable (clang-cl)
Required a workaround for loplugin:indentation, until
<https://reviews.llvm.org/D68581> "Include leading attributes in DeclStmt's
SourceRange" lands in Clang.
Change-Id: I7192969d40fa4c50bbd603d059532b9344865248
Reviewed-on: https://gerrit.libreoffice.org/80596
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/indentation.cxx')
-rw-r--r-- | compilerplugins/clang/indentation.cxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/compilerplugins/clang/indentation.cxx b/compilerplugins/clang/indentation.cxx index eaa795e6765a..57fbd1b382a0 100644 --- a/compilerplugins/clang/indentation.cxx +++ b/compilerplugins/clang/indentation.cxx @@ -120,6 +120,22 @@ bool Indentation::VisitCompoundStmt(CompoundStmt const* compoundStmt) // these are always weirdly indented if (isa<LabelStmt>(stmt)) continue; + // At least until Clang 9.0.0, getBeginLoc of a VarDecl DeclStmt with an UnusedAttr points + // after the attr (and getLocation of the attr would point at "maybe_unused", not at the + // leading "[["), so just ignore those at least for now: + if (auto const declStmt = dyn_cast<DeclStmt>(stmt)) + { + if (declStmt->decl_begin() != declStmt->decl_end()) + { + if (auto const decl = dyn_cast<VarDecl>(*declStmt->decl_begin())) + { + if (decl->hasAttr<UnusedAttr>()) + { + continue; + } + } + } + } auto stmtLoc = compat::getBeginLoc(stmt); |