c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/tools-clang-tools-extra.patch
author Ilia Gromov <ilia@netbeans.org>
Wed, 07 Jun 2017 20:23:29 +0300
branchrelease82
changeset 18423 b9d9af239a0c
permissions -rw-r--r--
Fixing #270763 - Move clang-tidy integration to nb contrib
* * *
Fixing #270763 - Move clang-tidy integration to nb contrib - move wrapper
* * *
Fixing #270763 - Move clang-tidy integration to nb contrib - sign nbm
* * *
Fixing #270763 - Move clang-tidy integration to nb contrib - move tests
* * *
Fixing #270763 - Move clang-tidy integration to nb contrib - data for a new test
* * *
Fixed #270839 - [clang-tidy] Group checks in Editor hints
(transplanted from 35b6125ef00c470655dac6673075f5c12ec74593)
     1 Index: clang-tidy/ClangTidy.cpp
     2 ===================================================================
     3 --- clang-tidy/ClangTidy.cpp	(revision 278390)
     4 +++ clang-tidy/ClangTidy.cpp	(working copy)
     5 @@ -35,6 +35,7 @@
     6  #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
     7  #include "clang/Tooling/Refactoring.h"
     8  #include "clang/Tooling/ReplacementsYaml.h"
     9 +#include "clang/Tooling/DiagnosticsYaml.h"
    10  #include "clang/Tooling/Tooling.h"
    11  #include "llvm/Support/Process.h"
    12  #include "llvm/Support/Signals.h"
    13 @@ -509,13 +510,10 @@
    14  
    15  void exportReplacements(const std::vector<ClangTidyError> &Errors,
    16                          raw_ostream &OS) {
    17 -  tooling::TranslationUnitReplacements TUR;
    18 -  for (const ClangTidyError &Error : Errors)
    19 -    TUR.Replacements.insert(TUR.Replacements.end(), Error.Fix.begin(),
    20 -                            Error.Fix.end());
    21 -
    22    yaml::Output YAML(OS);
    23 -  YAML << TUR;
    24 +  TranslationUnitDiagnostics TUD;
    25 +  TUD.Diags.insert(TUD.Diags.end(), Errors.begin(), Errors.end());
    26 +  YAML << TUD;
    27  }
    28  
    29  } // namespace tidy
    30 Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
    31 ===================================================================
    32 --- clang-tidy/ClangTidyDiagnosticConsumer.cpp	(revision 278390)
    33 +++ clang-tidy/ClangTidyDiagnosticConsumer.cpp	(working copy)
    34 @@ -102,25 +102,6 @@
    35  };
    36  } // end anonymous namespace
    37  
    38 -ClangTidyMessage::ClangTidyMessage(StringRef Message)
    39 -    : Message(Message), FileOffset(0) {}
    40 -
    41 -ClangTidyMessage::ClangTidyMessage(StringRef Message,
    42 -                                   const SourceManager &Sources,
    43 -                                   SourceLocation Loc)
    44 -    : Message(Message) {
    45 -  assert(Loc.isValid() && Loc.isFileID());
    46 -  FilePath = Sources.getFilename(Loc);
    47 -  FileOffset = Sources.getFileOffset(Loc);
    48 -}
    49 -
    50 -ClangTidyError::ClangTidyError(StringRef CheckName,
    51 -                               ClangTidyError::Level DiagLevel,
    52 -                               bool IsWarningAsError,
    53 -                               StringRef BuildDirectory)
    54 -    : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel),
    55 -      IsWarningAsError(IsWarningAsError) {}
    56 -
    57  // Returns true if GlobList starts with the negative indicator ('-'), removes it
    58  // from the GlobList.
    59  static bool ConsumeNegativeIndicator(StringRef &GlobList) {
    60 Index: clang-tidy/ClangTidyDiagnosticConsumer.h
    61 ===================================================================
    62 --- clang-tidy/ClangTidyDiagnosticConsumer.h	(revision 278390)
    63 +++ clang-tidy/ClangTidyDiagnosticConsumer.h	(working copy)
    64 @@ -14,6 +14,7 @@
    65  #include "clang/Basic/Diagnostic.h"
    66  #include "clang/Basic/SourceManager.h"
    67  #include "clang/Tooling/Refactoring.h"
    68 +#include "clang/Tooling/Core/Diagnostics.h"
    69  #include "llvm/ADT/DenseMap.h"
    70  #include "llvm/ADT/StringMap.h"
    71  #include "llvm/Support/Regex.h"
    72 @@ -32,52 +33,9 @@
    73  
    74  namespace tidy {
    75  
    76 -/// \brief A message from a clang-tidy check.
    77 -///
    78 -/// Note that this is independent of a \c SourceManager.
    79 -struct ClangTidyMessage {
    80 -  ClangTidyMessage(StringRef Message = "");
    81 -  ClangTidyMessage(StringRef Message, const SourceManager &Sources,
    82 -                   SourceLocation Loc);
    83 -  std::string Message;
    84 -  std::string FilePath;
    85 -  unsigned FileOffset;
    86 -};
    87 +typedef clang::tooling::DiagnosticsMessage ClangTidyMessage;
    88 +typedef clang::tooling::Diagnostics ClangTidyError;
    89  
    90 -/// \brief A detected error complete with information to display diagnostic and
    91 -/// automatic fix.
    92 -///
    93 -/// This is used as an intermediate format to transport Diagnostics without a
    94 -/// dependency on a SourceManager.
    95 -///
    96 -/// FIXME: Make Diagnostics flexible enough to support this directly.
    97 -struct ClangTidyError {
    98 -  enum Level {
    99 -    Warning = DiagnosticsEngine::Warning,
   100 -    Error = DiagnosticsEngine::Error
   101 -  };
   102 -
   103 -  ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError,
   104 -                 StringRef BuildDirectory);
   105 -
   106 -  std::string CheckName;
   107 -  ClangTidyMessage Message;
   108 -  tooling::Replacements Fix;
   109 -  SmallVector<ClangTidyMessage, 1> Notes;
   110 -
   111 -  // A build directory of the diagnostic source file.
   112 -  //
   113 -  // It's an absolute path which is `directory` field of the source file in
   114 -  // compilation database. If users don't specify the compilation database
   115 -  // directory, it is the current directory where clang-tidy runs.
   116 -  //
   117 -  // Note: it is empty in unittest.
   118 -  std::string BuildDirectory;
   119 -
   120 -  Level DiagLevel;
   121 -  bool IsWarningAsError;
   122 -};
   123 -
   124  /// \brief Read-only set of strings represented as a list of positive and
   125  /// negative globs. Positive globs add all matched strings to the set, negative
   126  /// globs remove them in the order of appearance in the list.
   127 Index: clang-tidy/tool/ClangTidyMain.cpp
   128 ===================================================================
   129 --- clang-tidy/tool/ClangTidyMain.cpp	(revision 278390)
   130 +++ clang-tidy/tool/ClangTidyMain.cpp	(working copy)
   131 @@ -389,7 +389,7 @@
   132  
   133    // -fix-errors implies -fix.
   134    handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
   135 -
   136 +  
   137    if (!ExportFixes.empty() && !Errors.empty()) {
   138      std::error_code EC;
   139      llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);