[Libreoffice-commits] core.git: compilerplugins/clang solenv/CompilerTest_compilerplugins_clang.mk
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Fri Aug 16 17:55:11 UTC 2019
compilerplugins/clang/nullptr.cxx | 8 ++++++++
compilerplugins/clang/test/nullptr.cxx | 23 +++++++++++++++++++++++
solenv/CompilerTest_compilerplugins_clang.mk | 1 +
3 files changed, 32 insertions(+)
New commits:
commit e380e353485c3479abe645d3b6da9e007057a079
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Aug 16 16:25:48 2019 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Aug 16 19:54:25 2019 +0200
Adapt loplugin:nullptr to RecursiveASTVisitior::TraverseInitListExpr change
...<https://github.com/llvm/llvm-project/commit/
0a42fe70a566f22599e04a6f1344ca2dc5565e17> "[AST] Treat semantic form of
InitListExpr as implicit code in traversals"
Change-Id: Ifd17009fcc6933abf0e9178dbe47fb9c14b274b7
Reviewed-on: https://gerrit.libreoffice.org/77595
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/compilerplugins/clang/nullptr.cxx b/compilerplugins/clang/nullptr.cxx
index bcdf606c13e3..30458d7f7f5a 100644
--- a/compilerplugins/clang/nullptr.cxx
+++ b/compilerplugins/clang/nullptr.cxx
@@ -75,6 +75,8 @@ public:
bool TraverseLinkageSpecDecl(LinkageSpecDecl * decl);
+ bool TraverseInitListExpr(InitListExpr * expr, DataRecursionQueue * queue = nullptr);
+
// bool shouldVisitTemplateInstantiations() const { return true; }
private:
@@ -231,6 +233,12 @@ bool Nullptr::TraverseLinkageSpecDecl(LinkageSpecDecl * decl) {
return ret;
}
+bool Nullptr::TraverseInitListExpr(InitListExpr * expr, DataRecursionQueue * queue) {
+ return WalkUpFromInitListExpr(expr)
+ && TraverseSynOrSemInitListExpr(
+ expr->isSemanticForm() ? expr : expr->getSemanticForm(), queue);
+}
+
bool Nullptr::isInLokIncludeFile(SourceLocation spellingLocation) const {
return loplugin::hasPathnamePrefix(
getFileNameOfSpellingLoc(spellingLocation),
diff --git a/compilerplugins/clang/test/nullptr.cxx b/compilerplugins/clang/test/nullptr.cxx
new file mode 100644
index 000000000000..bf7376cb6562
--- /dev/null
+++ b/compilerplugins/clang/test/nullptr.cxx
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+struct S
+{
+ void* p;
+};
+
+int main()
+{
+ S s{
+ 0 // expected-error {{NullToPointer ValueDependentIsNotNull ZeroLiteral -> nullptr [loplugin:nullptr]}}
+ };
+ (void)s;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk
index 711137705ba3..caeee4333e78 100644
--- a/solenv/CompilerTest_compilerplugins_clang.mk
+++ b/solenv/CompilerTest_compilerplugins_clang.mk
@@ -36,6 +36,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
compilerplugins/clang/test/indentation \
compilerplugins/clang/test/logexceptionnicely \
compilerplugins/clang/test/loopvartoosmall \
+ compilerplugins/clang/test/nullptr \
compilerplugins/clang/test/mapindex \
compilerplugins/clang/test/oncevar \
compilerplugins/clang/test/oslendian-1 \
More information about the Libreoffice-commits
mailing list