[Libreoffice-commits] core.git: compilerplugins/clang
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 24 09:51:33 UTC 2019
compilerplugins/clang/indentation.cxx | 10 +++++++---
compilerplugins/clang/test/indentation.cxx | 9 +++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
New commits:
commit a246830d3feaab033a16b2332716cff05a7ec92c
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Oct 24 08:34:25 2019 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Oct 24 11:50:01 2019 +0200
This is fixed now on Clang trunk
...since <https://github.com/llvm/llvm-project/commit/
dc3957ec215dd17b8d293461f18696566637a6cd> "Include leading attributes in
DeclStmt's SourceRange"
Change-Id: I21859dfdcb454a9dd4444ce299548bf75043b1ab
Reviewed-on: https://gerrit.libreoffice.org/81424
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/compilerplugins/clang/indentation.cxx b/compilerplugins/clang/indentation.cxx
index 57fbd1b382a0..1b94eac3ec1a 100644
--- a/compilerplugins/clang/indentation.cxx
+++ b/compilerplugins/clang/indentation.cxx
@@ -120,9 +120,12 @@ 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 CLANG_VERSION < 100000
+ // Before
+ // <https://github.com/llvm/llvm-project/commit/dc3957ec215dd17b8d293461f18696566637a6cd>
+ // "Include leading attributes in DeclStmt's SourceRange", getBeginLoc of a VarDecl DeclStmt
+ // with an UnusedAttr pointed after the attr (and getLocation of the attr pointed at
+ // "maybe_unused", not at the leading "[["), so just ignore those in old compiler versions:
if (auto const declStmt = dyn_cast<DeclStmt>(stmt))
{
if (declStmt->decl_begin() != declStmt->decl_end())
@@ -136,6 +139,7 @@ bool Indentation::VisitCompoundStmt(CompoundStmt const* compoundStmt)
}
}
}
+#endif
auto stmtLoc = compat::getBeginLoc(stmt);
diff --git a/compilerplugins/clang/test/indentation.cxx b/compilerplugins/clang/test/indentation.cxx
index 3a76c2c97e2f..27e858fb319c 100644
--- a/compilerplugins/clang/test/indentation.cxx
+++ b/compilerplugins/clang/test/indentation.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include "config_clang.h"
+
int foo();
int foo2(int);
@@ -49,4 +51,11 @@ void attr() {
foo();
}
+#if CLANG_VERSION >= 100000
+void attr_bad() {
+ [[maybe_unused]] int i = foo(); // expected-note {{measured against this one [loplugin:indentation]}}
+ foo(); // expected-error {{statement mis-aligned compared to neighbours [loplugin:indentation]}}
+}
+#endif
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
More information about the Libreoffice-commits
mailing list