kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [1/3] kudu git commit: Remove kudu-lint tool
Date Tue, 24 Apr 2018 16:11:00 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 281ed6525 -> a6280bc5a


Remove kudu-lint tool

This tool had fallen far out of date and maintaining it wasn't worth the
incremental benefit. Let's remove it and if we find the need for
Kudu-specific lint checks perhaps we can bring it back some day.

Change-Id: I1fe1df8047dc0f918a8166d181e1061150ba29a5
Reviewed-on: http://gerrit.cloudera.org:8080/10170
Reviewed-by: Adar Dembo <adar@cloudera.com>
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/92785800
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/92785800
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/92785800

Branch: refs/heads/master
Commit: 9278580018dd2934845ac0afd26b65a80ef31c99
Parents: 281ed65
Author: Todd Lipcon <todd@apache.org>
Authored: Mon Apr 23 18:13:24 2018 -0700
Committer: Todd Lipcon <todd@apache.org>
Committed: Tue Apr 24 05:38:52 2018 +0000

----------------------------------------------------------------------
 build-support/tools/kudu-lint/.gitignore        |  19 --
 build-support/tools/kudu-lint/CMakeLists.txt    |  68 -----
 build-support/tools/kudu-lint/README            |  46 ----
 .../kudu-lint/cmake_modules/FindClang.cmake     |  51 ----
 .../kudu-lint/cmake_modules/FindLLVM.cmake      |  80 ------
 build-support/tools/kudu-lint/kudu-lint.cc      | 262 -------------------
 6 files changed, 526 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/92785800/build-support/tools/kudu-lint/.gitignore
----------------------------------------------------------------------
diff --git a/build-support/tools/kudu-lint/.gitignore b/build-support/tools/kudu-lint/.gitignore
deleted file mode 100644
index 5e1caf5..0000000
--- a/build-support/tools/kudu-lint/.gitignore
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# The binary
-kudu-lint

http://git-wip-us.apache.org/repos/asf/kudu/blob/92785800/build-support/tools/kudu-lint/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/build-support/tools/kudu-lint/CMakeLists.txt b/build-support/tools/kudu-lint/CMakeLists.txt
deleted file mode 100644
index 77101e9..0000000
--- a/build-support/tools/kudu-lint/CMakeLists.txt
+++ /dev/null
@@ -1,68 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-cmake_minimum_required(VERSION 2.8)
-
-set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
-
-# Find LLVM
-find_package(LLVM REQUIRED COMPONENTS
-  option
-  analysis
-  bitreader
-  mcparser
-  instrumentation
-)
-find_package(Clang REQUIRED COMPONENTS
-    clang
-    clangAnalysis
-    clangAST
-    clangASTMatchers
-    clangBasic
-    clangCodeGen
-    clangDriver
-    clangEdit
-    clangFrontend
-    clangFrontendTool
-    clangLex
-    clangParse
-    clangSema
-    clangSerialization
-    clangTooling
-)
-
-add_definitions(${LLVM_DEFINITIONS})
-include_directories(${CLANG_INCLUDE})
-include_directories(${LLVM_INCLUDE_DIRS} ${CLANG_INCLUDE_DIRS})
-link_directories(${LLVM_LIBRARY_DIRS})
-
-set(START_GROUP "-Wl,--start-group")
-set(END_GROUP "-Wl,--end-group")
-
-add_executable(kudu-lint kudu-lint.cc)
-target_link_libraries(kudu-lint
-  ${START_GROUP}
-  ${CLANG_LIBS}
-  ${LLVM_LIBS}
-  ${END_GROUP}
-  ${LLVM_LDFLAGS}
-  )
-
-# Disable RTTI since we have to inherit from Clang-provided classes,
-# and Clang does not enable RTTI.
-set_target_properties(kudu-lint PROPERTIES
-    COMPILE_FLAGS "${LLVM_CFLAGS} -fno-rtti -g")

http://git-wip-us.apache.org/repos/asf/kudu/blob/92785800/build-support/tools/kudu-lint/README
----------------------------------------------------------------------
diff --git a/build-support/tools/kudu-lint/README b/build-support/tools/kudu-lint/README
deleted file mode 100644
index d2eff1b..0000000
--- a/build-support/tools/kudu-lint/README
+++ /dev/null
@@ -1,46 +0,0 @@
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Overview
-===============
-kudu-lint is a Clang-based tool for looking for kudu-specific coding errors.
-
-Currently, it only looks for cases where a function returning Status is called,
-and then that Status is ignored.
-
-Over time we can add more AST matchers for other Kudu-specific lint checks we'd
-like to implement.
-
-
-Requirements
-===============
-
-This has currently only been tested against clang 3.4. Clang APIs tend to change
-between versions, so this is unlikely to work on earlier versions of clang.
-
-Building
-=========
-
-Set the CLANG_ROOT environment variable to point to the path at which clang/llvm
-have been installed. This is the directory which contains bin/, lib/, etc.
-
-Run 'cmake .', followed by 'make', in this directory.
-
-Running
-=========
-
-In the top-level kudu source directory, run:
-
-$ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
-$ find src -name \*.cc | xargs -n1 -P8 ./build-support/tools/kudu-lint/kudu-lint \
-    -p . -extra-arg=-I$CLANG_ROOT/lib/clang/3.4/include

http://git-wip-us.apache.org/repos/asf/kudu/blob/92785800/build-support/tools/kudu-lint/cmake_modules/FindClang.cmake
----------------------------------------------------------------------
diff --git a/build-support/tools/kudu-lint/cmake_modules/FindClang.cmake b/build-support/tools/kudu-lint/cmake_modules/FindClang.cmake
deleted file mode 100644
index 34015d5..0000000
--- a/build-support/tools/kudu-lint/cmake_modules/FindClang.cmake
+++ /dev/null
@@ -1,51 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-# Find Clang
-#
-# It defines the following variables
-# CLANG_FOUND        - True if Clang found.
-# CLANG_INCLUDE_DIRS - where to find Clang include files
-# CLANG_LIBS         - list of clang libs
-# CLANG_LDFLAGS      - list w/format: -lclangAST -lclangLex...
-if(NOT LLVM_INCLUDE_DIRS OR NOT LLVM_LIBRARY_DIRS)
-  message(FATAL_ERROR "Clang support requires LLVM to be set up first.")
-endif()
-
-if(NOT Clang_FIND_COMPONENTS)
-  message(FATAL_ERROR "Must specify which clang COMPONENTS are required")
-endif()
-
-foreach(component ${Clang_FIND_COMPONENTS})
-  find_library(CLANG_${component}_LIB ${component}
-    PATHS ${LLVM_LIBRARY_DIRS} ${CLANG_LIBRARY_DIRS})
-  if(CLANG_${component}_LIB)
-    message(STATUS "Adding Clang component: ${component}")
-    set(CLANG_LIBS ${CLANG_LIBS} ${CLANG_${component}_LIB})
-    set(CLANG_LDFLAGS ${CLANG_LDFLAGS} "-l${component}")
-  elseif(Clang_FIND_REQUIRED_${component})
-    message(FATAL_ERROR "Could not find required Clang component ${component}\n"
-      "Please set CLANG_ROOT.")
-  endif()
-endforeach(component)
-
-find_path(CLANG_INCLUDE_DIRS clang/Basic/Version.h HINTS ${LLVM_INCLUDE_DIRS})
-if(CLANG_LIBS AND CLANG_INCLUDE_DIRS)
-  message(STATUS "Found Clang libs: ${CLANG_LIBS}")
-  message(STATUS "Found Clang includes: ${CLANG_INCLUDE_DIRS}")
-elseif(Clang_FIND_REQUIRED)
-  message(FATAL_ERROR "Could NOT find Clang")
-endif()

http://git-wip-us.apache.org/repos/asf/kudu/blob/92785800/build-support/tools/kudu-lint/cmake_modules/FindLLVM.cmake
----------------------------------------------------------------------
diff --git a/build-support/tools/kudu-lint/cmake_modules/FindLLVM.cmake b/build-support/tools/kudu-lint/cmake_modules/FindLLVM.cmake
deleted file mode 100644
index 346e89a..0000000
--- a/build-support/tools/kudu-lint/cmake_modules/FindLLVM.cmake
+++ /dev/null
@@ -1,80 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-# Find LLVM
-#
-# It defines the following variables
-#  LLVM_FOUND        - True if llvm found.
-#  LLVM_INCLUDE_DIRS - where to find llvm include files
-#  LLVM_LIBRARY_DIRS - where to find llvm libs
-#  LLVM_CFLAGS       - llvm compiler flags
-#  LLVM_LDFLAGS      - llvm linker flags
-#  LLVM_LIBS         - list of llvm libs for working with modules.
-
-if(NOT DEFINED CLANG_ROOT)
-  set(CLANG_ROOT $ENV{CLANG_ROOT})
-endif()
-
-find_program(LLVM_CONFIG_EXECUTABLE llvm-config
-  DOC "llvm-config executable"
-  HINTS ${CLANG_ROOT}/bin)
-
-if(LLVM_CONFIG_EXECUTABLE)
-  message(STATUS "LLVM llvm-config found at: ${LLVM_CONFIG_EXECUTABLE}")
-elseif(LLVM_FIND_REQUIRED)
-  message(FATAL_ERROR "Could NOT find llvm-config executable")
-endif()
-
-execute_process(
-  COMMAND ${LLVM_CONFIG_EXECUTABLE} --version
-  OUTPUT_VARIABLE LLVM_VERSION
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
-string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*" "\\1" LLVM_VERSION_MAJOR ${LLVM_VERSION})
-string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*" "\\2" LLVM_VERSION_MINOR ${LLVM_VERSION})
-
-execute_process(
-  COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir
-  OUTPUT_VARIABLE LLVM_INCLUDE_DIRS
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
-execute_process(
-  COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir
-  OUTPUT_VARIABLE LLVM_LIBRARY_DIRS
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
-execute_process(
-  COMMAND ${LLVM_CONFIG_EXECUTABLE} --cppflags
-  OUTPUT_VARIABLE LLVM_CFLAGS
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
-execute_process(
-  COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags
-  OUTPUT_VARIABLE LLVM_LDFLAGS
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
-execute_process(
-  COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs ${LLVM_FIND_COMPONENTS}
-  OUTPUT_VARIABLE LLVM_LIBS
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
-set(LLVM_FOUND TRUE)

http://git-wip-us.apache.org/repos/asf/kudu/blob/92785800/build-support/tools/kudu-lint/kudu-lint.cc
----------------------------------------------------------------------
diff --git a/build-support/tools/kudu-lint/kudu-lint.cc b/build-support/tools/kudu-lint/kudu-lint.cc
deleted file mode 100644
index a96fada..0000000
--- a/build-support/tools/kudu-lint/kudu-lint.cc
+++ /dev/null
@@ -1,262 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/ASTTypeTraits.h"
-#include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/AST/Stmt.h"
-#include "clang/Driver/Options.h"
-#include "clang/Frontend/FrontendActions.h"
-#include "clang/Frontend/TextDiagnostic.h"
-#include "clang/Tooling/CommonOptionsParser.h"
-#include "clang/Tooling/Tooling.h"
-#include "llvm/Option/OptTable.h"
-#include "llvm/Support/CommandLine.h"
-
-// Using clang without importing namespaces is damn near impossible.
-using namespace llvm; // NOLINT
-using namespace clang::ast_matchers; // NOLINT
-
-using llvm::opt::OptTable;
-using clang::ast_type_traits::DynTypedNode;
-using clang::driver::createDriverOptTable;
-using clang::driver::options::OPT_ast_dump;
-using clang::tooling::CommonOptionsParser;
-using clang::tooling::CommandLineArguments;
-using clang::tooling::ClangTool;
-using clang::tooling::newFrontendActionFactory;
-using clang::ASTContext;
-using clang::CharSourceRange;
-using clang::ClassTemplateSpecializationDecl;
-using clang::Decl;
-using clang::DiagnosticsEngine;
-using clang::Stmt;
-using clang::FixItHint;
-using clang::SourceLocation;
-using clang::SourceRange;
-using clang::Stmt;
-using clang::TextDiagnostic;
-using std::string;
-
-static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
-static cl::extrahelp MoreHelp(
-    "\tFor example, to run kudu-lint on all files in a subtree of the\n"
-    "\tsource tree, use:\n"
-    "\n"
-    "\t  find path/in/subtree -name '*.cc'|xargs kudu-lint\n"
-    "\n"
-    "\tor using a specific build path:\n"
-    "\n"
-    "\t  find path/in/subtree -name '*.cc'|xargs kudu-lint -p build/path\n"
-    "\n"
-    "\tNote, that path/in/subtree and current directory should follow the\n"
-    "\trules described above.\n"
-    "\n"
-    "\t Sometimes kudu-lint can't figure out the proper line number for an\n"
-    "\t error, and reports it inside some standard library. the -ast-dump\n"
-    "\t option can be useful for these circumstances.\n"
-    "\n"
-);
-
-// Command line flags.
-static OwningPtr<OptTable> gOptions(createDriverOptTable());
-static cl::list<std::string> gArgsAfter(
-  "extra-arg",
-  cl::desc("Additional argument to append to the compiler command line"));
-static cl::list<std::string> gArgsBefore(
-  "extra-arg-before",
-  cl::desc("Additional argument to prepend to the compiler command line"));
-static cl::opt<bool> gASTDump("ast-dump",
-                              cl::desc(gOptions->getOptionHelpText(OPT_ast_dump)));
-
-namespace {
-
-// Callback for unused statuses. Simply reports the error at the point where the
-// expression was found.
-template<class NODETYPE>
-class ErrorPrinter : public MatchFinder::MatchCallback {
- public:
-  ErrorPrinter(const std::string& error_msg,
-               const std::string& bound_name,
-               bool skip_system_headers)
-    : error_msg_(error_msg),
-      bound_name_(bound_name),
-      skip_system_headers_(skip_system_headers) {
-  }
-
-  virtual void run(const MatchFinder::MatchResult& result) {
-    const NODETYPE* node;
-    if ((node = result.Nodes.getNodeAs<NODETYPE>(bound_name_))) {
-      SourceRange r = node->getSourceRange();
-
-      if (skip_system_headers_ && result.SourceManager->isInSystemHeader(r.getBegin()))
{
-        return;
-      }
-
-      if (gASTDump) {
-        node->dump();
-      }
-
-      if (r.isValid()) {
-        TextDiagnostic td(llvm::outs(), result.Context->getLangOpts(),
-                          &result.Context->getDiagnostics().getDiagnosticOptions());
-        td.emitDiagnostic(r.getBegin(), DiagnosticsEngine::Error,
-                          error_msg_,
-                          ArrayRef<CharSourceRange>(CharSourceRange::getTokenRange(r)),
-                          ArrayRef<FixItHint>(), result.SourceManager);
-      }
-
-      SourceLocation instantiation_point;
-      if (FindInstantiationPoint(result, node, &instantiation_point)) {
-        TextDiagnostic td(llvm::outs(), result.Context->getLangOpts(),
-                          &result.Context->getDiagnostics().getDiagnosticOptions());
-        td.emitDiagnostic(instantiation_point, DiagnosticsEngine::Note,
-                          "previous error instantiated at",
-                          ArrayRef<CharSourceRange>(),
-                          ArrayRef<FixItHint>(), result.SourceManager);
-      }
-    } else {
-      llvm_unreachable("bound node missing");
-    }
-  }
-
- private:
-  bool GetParent(ASTContext* ctx, const DynTypedNode& node, DynTypedNode* parent) {
-    ASTContext::ParentVector parents = ctx->getParents(node);
-    if (parents.empty()) return false;
-    assert(parents.size() == 1);
-    *parent = parents[0];
-    return true;
-  }
-
-  // If the AST node 'node' has an ancestor which is a template instantiation,
-  // fill the source location of that instantiation into 'loc'. Unfortunately,
-  // Clang doesn't retain enough information in the AST nodes to recurse here --
-  // so in many cases this is useless, since the instantiation point will simply
-  // be inside another instantiated template.
-  bool FindInstantiationPoint(const MatchFinder::MatchResult& result,
-                              const NODETYPE* node,
-                              SourceLocation* loc) {
-    DynTypedNode dyn_node = DynTypedNode::create<NODETYPE>(*node);
-
-    // Recurse up the tree.
-    while (true) {
-      const ClassTemplateSpecializationDecl* D =
-          dyn_node.get<ClassTemplateSpecializationDecl>();
-      if (D) {
-        *loc = D->getPointOfInstantiation();
-        return true;
-      }
-      // TODO: there are probably other types of specializations to handle, but this is the
only
-      // one seen so far.
-
-      DynTypedNode parent;
-      if (!GetParent(result.Context, dyn_node, &parent)) {
-        return false;
-      }
-      dyn_node = parent;
-    }
-  }
-
-  string error_msg_;
-  string bound_name_;
-  bool skip_system_headers_;
-};
-
-// Inserts arguments before or after the usual command line arguments.
-class InsertAdjuster: public clang::tooling::ArgumentsAdjuster {
- public:
-  enum Position { BEGIN, END };
-
-  InsertAdjuster(const CommandLineArguments &extra, Position pos)
-    : extra_(extra), pos_(pos) {
-  }
-
-  InsertAdjuster(const char *extra_, Position pos)
-    : extra_(1, std::string(extra_)), pos_(pos) {
-  }
-
-  virtual CommandLineArguments Adjust(const CommandLineArguments &Args) LLVM_OVERRIDE
{
-    CommandLineArguments ret(Args);
-
-    CommandLineArguments::iterator I;
-    if (pos_ == END) {
-      I = ret.end();
-    } else {
-      I = ret.begin();
-      ++I; // To leave the program name in place
-    }
-
-    ret.insert(I, extra_.begin(), extra_.end());
-    return ret;
-  }
-
- private:
-  const CommandLineArguments extra_;
-  const Position pos_;
-};
-
-} // anonymous namespace
-
-int main(int argc, const char **argv) {
-  CommonOptionsParser options_parser(argc, argv);
-  ClangTool Tool(options_parser.getCompilations(),
-                 options_parser.getSourcePathList());
-  if (gArgsAfter.size() > 0) {
-    Tool.appendArgumentsAdjuster(new InsertAdjuster(gArgsAfter,
-          InsertAdjuster::END));
-  }
-  if (gArgsBefore.size() > 0) {
-    Tool.appendArgumentsAdjuster(new InsertAdjuster(gArgsBefore,
-          InsertAdjuster::BEGIN));
-  }
-
-  // Match expressions of type 'Status' which are parented by a compound statement.
-  // This implies that the expression is being thrown away, rather than assigned
-  // to some variable or function call.
-  //
-  // For more information on AST matchers, refer to:
-  // http://clang.llvm.org/docs/LibASTMatchersReference.html
-  StatementMatcher ignored_status_matcher =
-    expr(hasType(recordDecl(hasName("Status"))),
-         hasParent(compoundStmt())).bind("expr");
-  ErrorPrinter<Stmt> ignored_status_printer("Unused status result", "expr", false);
-
-  // Match class members which are reference-typed. This is confusing since they
-  // tend to "look like" copied values, but in fact often reference external
-  // entities passed in in the constructor.
-  DeclarationMatcher ref_member_matcher =
-    fieldDecl(hasType(referenceType()))
-    .bind("decl");
-  ErrorPrinter<Decl> ref_member_printer("Reference-typed member", "decl", true);
-
-  // Disallow calls to sleep, usleep, and nanosleep.
-  // SleepFor(MonoDelta) should be used instead, as it is not prone to
-  // unit conversion errors, and also ignores EINTR so will safely sleep
-  // at least the requested duration.
-  StatementMatcher sleep_matcher =
-    callExpr(callee(namedDecl(matchesName("(nano|u)?sleep")))).bind("sleep_expr");
-  ErrorPrinter<Stmt> sleep_printer("sleep, usleep or nanosleep call", "sleep_expr",
true);
-
-  MatchFinder finder;
-  finder.addMatcher(ignored_status_matcher, &ignored_status_printer);
-  finder.addMatcher(ref_member_matcher, &ref_member_printer);
-  finder.addMatcher(sleep_matcher, &sleep_printer);
-
-  return Tool.run(newFrontendActionFactory(&finder));
-}


Mime
View raw message