Repository: kudu Updated Branches: refs/heads/master 2d30f3a96 -> 9ae11e6d8
Fix false positive clang-tidy warning when using gtest This applies a patch from https://reviews.llvm.org/D27048 to fix a false positive that has surfaced since upgrading to LLVM 4.0. I verified locally that this solved the spurious warnings on a test file. Change-Id: Iff972e198ba297a001b965f0012e1140112e553f Reviewed-on: http://gerrit.cloudera.org:8080/7119 Reviewed-by: Dan Burkert <[email protected]> Reviewed-by: Adar Dembo <[email protected]> Tested-by: Kudu Jenkins Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/a9ac82ff Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/a9ac82ff Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/a9ac82ff Branch: refs/heads/master Commit: a9ac82ff42738e759df21145dda0382b2996bf43 Parents: 2d30f3a Author: Todd Lipcon <[email protected]> Authored: Thu Jun 8 14:10:52 2017 -0700 Committer: Todd Lipcon <[email protected]> Committed: Thu Jun 8 21:45:28 2017 +0000 ---------------------------------------------------------------------- thirdparty/download-thirdparty.sh | 4 +- ...y-redundant-declaration-false-positive.patch | 101 +++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/a9ac82ff/thirdparty/download-thirdparty.sh ---------------------------------------------------------------------- diff --git a/thirdparty/download-thirdparty.sh b/thirdparty/download-thirdparty.sh index 4238c08..68950f5 100755 --- a/thirdparty/download-thirdparty.sh +++ b/thirdparty/download-thirdparty.sh @@ -238,13 +238,15 @@ if [ ! -d $PYTHON_SOURCE ]; then fetch_and_expand python-${PYTHON_VERSION}.tar.gz fi -LLVM_PATCHLEVEL=1 +LLVM_PATCHLEVEL=2 delete_if_wrong_patchlevel $LLVM_SOURCE $LLVM_PATCHLEVEL if [ ! -d $LLVM_SOURCE ]; then fetch_and_expand llvm-${LLVM_VERSION}.src.tar.gz pushd $LLVM_SOURCE patch -p1 < $TP_DIR/patches/llvm-fix-amazon-linux.patch + patch -p1 -d $LLVM_SOURCE/tools/clang/tools/extra \ + < $TP_DIR/patches/llvm-fix-readability-redundant-declaration-false-positive.patch touch patchlevel-$LLVM_PATCHLEVEL popd echo http://git-wip-us.apache.org/repos/asf/kudu/blob/a9ac82ff/thirdparty/patches/llvm-fix-readability-redundant-declaration-false-positive.patch ---------------------------------------------------------------------- diff --git a/thirdparty/patches/llvm-fix-readability-redundant-declaration-false-positive.patch b/thirdparty/patches/llvm-fix-readability-redundant-declaration-false-positive.patch new file mode 100644 index 0000000..87d682e --- /dev/null +++ b/thirdparty/patches/llvm-fix-readability-redundant-declaration-false-positive.patch @@ -0,0 +1,101 @@ +From 5978f7dc14b9d4e36f12ec3bb850b5d80f5a9045 Mon Sep 17 00:00:00 2001 +From: Daniel Marjamaki <[email protected]> +Date: Fri, 24 Feb 2017 09:02:44 +0000 +Subject: [PATCH] [clang-tidy] Fix readability-redundant-declaration false + positive + +Differential Revision: https://reviews.llvm.org/D27048 + + +git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@296100 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + .../readability/RedundantDeclarationCheck.cpp | 12 ++++------- + .../readability-redundant-declaration.cpp | 24 ++++++++++++++-------- + 2 files changed, 19 insertions(+), 17 deletions(-) + +diff --git a/clang-tidy/readability/RedundantDeclarationCheck.cpp b/clang-tidy/readability/RedundantDeclarationCheck.cpp +index 672cda655..1ee65d8d7 100644 +--- a/clang-tidy/readability/RedundantDeclarationCheck.cpp ++++ b/clang-tidy/readability/RedundantDeclarationCheck.cpp +@@ -19,7 +19,10 @@ namespace tidy { + namespace readability { + + void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) { +- Finder->addMatcher(namedDecl(anyOf(varDecl(), functionDecl())).bind("Decl"), ++ auto UnlessDefinition = unless(isDefinition()); ++ Finder->addMatcher(namedDecl(anyOf(varDecl(UnlessDefinition), ++ functionDecl(UnlessDefinition))) ++ .bind("Decl"), + this); + } + +@@ -41,9 +44,6 @@ void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) { + + bool MultiVar = false; + if (const auto *VD = dyn_cast<VarDecl>(D)) { +- if (VD->getPreviousDecl()->getStorageClass() == SC_Extern && +- VD->getStorageClass() != SC_Extern) +- return; + // Is this a multivariable declaration? + for (const auto Other : VD->getDeclContext()->decls()) { + if (Other != D && Other->getLocStart() == VD->getLocStart()) { +@@ -51,10 +51,6 @@ void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) { + break; + } + } +- } else { +- const auto *FD = cast<FunctionDecl>(D); +- if (FD->isThisDeclarationADefinition()) +- return; + } + + SourceLocation EndLoc = Lexer::getLocForEndOfToken( +diff --git a/test/clang-tidy/readability-redundant-declaration.cpp b/test/clang-tidy/readability-redundant-declaration.cpp +index e68b7f657..bedc68c4d 100644 +--- a/test/clang-tidy/readability-redundant-declaration.cpp ++++ b/test/clang-tidy/readability-redundant-declaration.cpp +@@ -1,9 +1,9 @@ + // RUN: %check_clang_tidy %s readability-redundant-declaration %t + + extern int Xyz; +-extern int Xyz; ++extern int Xyz; // Xyz + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'Xyz' declaration [readability-redundant-declaration] +-// CHECK-FIXES: {{^}}{{$}} ++// CHECK-FIXES: {{^}}// Xyz{{$}} + int Xyz = 123; + + extern int A; +@@ -12,19 +12,25 @@ extern int A, B; + // CHECK-FIXES: {{^}}extern int A, B;{{$}} + + extern int Buf[10]; +-extern int Buf[10]; ++extern int Buf[10]; // Buf[10] + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'Buf' declaration +-// CHECK-FIXES: {{^}}{{$}} ++// CHECK-FIXES: {{^}}// Buf[10]{{$}} + + static int f(); +-static int f(); ++static int f(); // f + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'f' declaration +-// CHECK-FIXES: {{^}}{{$}} ++// CHECK-FIXES: {{^}}// f{{$}} + static int f() {} + + // Original check crashed for the code below. + namespace std { +- typedef decltype(sizeof(0)) size_t; ++typedef decltype(sizeof(0)) size_t; + } +-void* operator new(std::size_t) __attribute__((__externally_visible__)); +-void* operator new[](std::size_t) __attribute__((__externally_visible__)); ++void *operator new(std::size_t) __attribute__((__externally_visible__)); ++void *operator new[](std::size_t) __attribute__((__externally_visible__)); ++ ++// Don't warn about static member definition. ++struct C { ++ static int I; ++}; ++int C::I;
