c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/tools-clang-tools-extra.patch
branchrelease82
changeset 18423 b9d9af239a0c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/tools-clang-tools-extra.patch	Wed Jun 07 20:23:29 2017 +0300
     1.3 @@ -0,0 +1,139 @@
     1.4 +Index: clang-tidy/ClangTidy.cpp
     1.5 +===================================================================
     1.6 +--- clang-tidy/ClangTidy.cpp	(revision 278390)
     1.7 ++++ clang-tidy/ClangTidy.cpp	(working copy)
     1.8 +@@ -35,6 +35,7 @@
     1.9 + #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
    1.10 + #include "clang/Tooling/Refactoring.h"
    1.11 + #include "clang/Tooling/ReplacementsYaml.h"
    1.12 ++#include "clang/Tooling/DiagnosticsYaml.h"
    1.13 + #include "clang/Tooling/Tooling.h"
    1.14 + #include "llvm/Support/Process.h"
    1.15 + #include "llvm/Support/Signals.h"
    1.16 +@@ -509,13 +510,10 @@
    1.17 + 
    1.18 + void exportReplacements(const std::vector<ClangTidyError> &Errors,
    1.19 +                         raw_ostream &OS) {
    1.20 +-  tooling::TranslationUnitReplacements TUR;
    1.21 +-  for (const ClangTidyError &Error : Errors)
    1.22 +-    TUR.Replacements.insert(TUR.Replacements.end(), Error.Fix.begin(),
    1.23 +-                            Error.Fix.end());
    1.24 +-
    1.25 +   yaml::Output YAML(OS);
    1.26 +-  YAML << TUR;
    1.27 ++  TranslationUnitDiagnostics TUD;
    1.28 ++  TUD.Diags.insert(TUD.Diags.end(), Errors.begin(), Errors.end());
    1.29 ++  YAML << TUD;
    1.30 + }
    1.31 + 
    1.32 + } // namespace tidy
    1.33 +Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
    1.34 +===================================================================
    1.35 +--- clang-tidy/ClangTidyDiagnosticConsumer.cpp	(revision 278390)
    1.36 ++++ clang-tidy/ClangTidyDiagnosticConsumer.cpp	(working copy)
    1.37 +@@ -102,25 +102,6 @@
    1.38 + };
    1.39 + } // end anonymous namespace
    1.40 + 
    1.41 +-ClangTidyMessage::ClangTidyMessage(StringRef Message)
    1.42 +-    : Message(Message), FileOffset(0) {}
    1.43 +-
    1.44 +-ClangTidyMessage::ClangTidyMessage(StringRef Message,
    1.45 +-                                   const SourceManager &Sources,
    1.46 +-                                   SourceLocation Loc)
    1.47 +-    : Message(Message) {
    1.48 +-  assert(Loc.isValid() && Loc.isFileID());
    1.49 +-  FilePath = Sources.getFilename(Loc);
    1.50 +-  FileOffset = Sources.getFileOffset(Loc);
    1.51 +-}
    1.52 +-
    1.53 +-ClangTidyError::ClangTidyError(StringRef CheckName,
    1.54 +-                               ClangTidyError::Level DiagLevel,
    1.55 +-                               bool IsWarningAsError,
    1.56 +-                               StringRef BuildDirectory)
    1.57 +-    : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel),
    1.58 +-      IsWarningAsError(IsWarningAsError) {}
    1.59 +-
    1.60 + // Returns true if GlobList starts with the negative indicator ('-'), removes it
    1.61 + // from the GlobList.
    1.62 + static bool ConsumeNegativeIndicator(StringRef &GlobList) {
    1.63 +Index: clang-tidy/ClangTidyDiagnosticConsumer.h
    1.64 +===================================================================
    1.65 +--- clang-tidy/ClangTidyDiagnosticConsumer.h	(revision 278390)
    1.66 ++++ clang-tidy/ClangTidyDiagnosticConsumer.h	(working copy)
    1.67 +@@ -14,6 +14,7 @@
    1.68 + #include "clang/Basic/Diagnostic.h"
    1.69 + #include "clang/Basic/SourceManager.h"
    1.70 + #include "clang/Tooling/Refactoring.h"
    1.71 ++#include "clang/Tooling/Core/Diagnostics.h"
    1.72 + #include "llvm/ADT/DenseMap.h"
    1.73 + #include "llvm/ADT/StringMap.h"
    1.74 + #include "llvm/Support/Regex.h"
    1.75 +@@ -32,52 +33,9 @@
    1.76 + 
    1.77 + namespace tidy {
    1.78 + 
    1.79 +-/// \brief A message from a clang-tidy check.
    1.80 +-///
    1.81 +-/// Note that this is independent of a \c SourceManager.
    1.82 +-struct ClangTidyMessage {
    1.83 +-  ClangTidyMessage(StringRef Message = "");
    1.84 +-  ClangTidyMessage(StringRef Message, const SourceManager &Sources,
    1.85 +-                   SourceLocation Loc);
    1.86 +-  std::string Message;
    1.87 +-  std::string FilePath;
    1.88 +-  unsigned FileOffset;
    1.89 +-};
    1.90 ++typedef clang::tooling::DiagnosticsMessage ClangTidyMessage;
    1.91 ++typedef clang::tooling::Diagnostics ClangTidyError;
    1.92 + 
    1.93 +-/// \brief A detected error complete with information to display diagnostic and
    1.94 +-/// automatic fix.
    1.95 +-///
    1.96 +-/// This is used as an intermediate format to transport Diagnostics without a
    1.97 +-/// dependency on a SourceManager.
    1.98 +-///
    1.99 +-/// FIXME: Make Diagnostics flexible enough to support this directly.
   1.100 +-struct ClangTidyError {
   1.101 +-  enum Level {
   1.102 +-    Warning = DiagnosticsEngine::Warning,
   1.103 +-    Error = DiagnosticsEngine::Error
   1.104 +-  };
   1.105 +-
   1.106 +-  ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError,
   1.107 +-                 StringRef BuildDirectory);
   1.108 +-
   1.109 +-  std::string CheckName;
   1.110 +-  ClangTidyMessage Message;
   1.111 +-  tooling::Replacements Fix;
   1.112 +-  SmallVector<ClangTidyMessage, 1> Notes;
   1.113 +-
   1.114 +-  // A build directory of the diagnostic source file.
   1.115 +-  //
   1.116 +-  // It's an absolute path which is `directory` field of the source file in
   1.117 +-  // compilation database. If users don't specify the compilation database
   1.118 +-  // directory, it is the current directory where clang-tidy runs.
   1.119 +-  //
   1.120 +-  // Note: it is empty in unittest.
   1.121 +-  std::string BuildDirectory;
   1.122 +-
   1.123 +-  Level DiagLevel;
   1.124 +-  bool IsWarningAsError;
   1.125 +-};
   1.126 +-
   1.127 + /// \brief Read-only set of strings represented as a list of positive and
   1.128 + /// negative globs. Positive globs add all matched strings to the set, negative
   1.129 + /// globs remove them in the order of appearance in the list.
   1.130 +Index: clang-tidy/tool/ClangTidyMain.cpp
   1.131 +===================================================================
   1.132 +--- clang-tidy/tool/ClangTidyMain.cpp	(revision 278390)
   1.133 ++++ clang-tidy/tool/ClangTidyMain.cpp	(working copy)
   1.134 +@@ -389,7 +389,7 @@
   1.135 + 
   1.136 +   // -fix-errors implies -fix.
   1.137 +   handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
   1.138 +-
   1.139 ++  
   1.140 +   if (!ExportFixes.empty() && !Errors.empty()) {
   1.141 +     std::error_code EC;
   1.142 +     llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);