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>
This commit is contained in:
Stephan Bergmann 2019-10-10 11:38:18 +02:00
parent 06767a5394
commit bfaf25f593
3 changed files with 22 additions and 1 deletions

View File

@ -120,6 +120,22 @@ bool Indentation::VisitCompoundStmt(CompoundStmt const* compoundStmt)
// these are always weirdly indented // these are always weirdly indented
if (isa<LabelStmt>(stmt)) if (isa<LabelStmt>(stmt))
continue; 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); auto stmtLoc = compat::getBeginLoc(stmt);

View File

@ -44,4 +44,9 @@ void top1(int x) {
foo(); foo();
} }
void attr() {
[[maybe_unused]] int i = foo();
foo();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */

View File

@ -51,7 +51,7 @@ SecurityEnvironmentGpg::SecurityEnvironmentGpg()
// in instdir/program/python-core-x.y.z/bin, while gpgme-w32spawn.exe is in instdir/program. // in instdir/program/python-core-x.y.z/bin, while gpgme-w32spawn.exe is in instdir/program.
// If we can't find gpgme-w32spawn.exe in the current executable location, then try to find // If we can't find gpgme-w32spawn.exe in the current executable location, then try to find
// the spawn executable, and inform gpgme about actual location using gpgme_set_global_flag. // the spawn executable, and inform gpgme about actual location using gpgme_set_global_flag.
static bool bSpawnPathInitialized = [] { [[maybe_unused]] static bool bSpawnPathInitialized = [] {
auto accessUrl = [](const INetURLObject& url) { auto accessUrl = [](const INetURLObject& url) {
osl::File file(url.GetMainURL(INetURLObject::DecodeMechanism::NONE)); osl::File file(url.GetMainURL(INetURLObject::DecodeMechanism::NONE));
return file.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None; return file.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None;