[PATCH] D105408: [clang-format] Pass a TextDiagnosticPrinter when we can not create tempory file.

BRAMI Élie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 4 10:27:02 PDT 2021


Et7f3 created this revision.
Herald added a subscriber: mgorny.
Et7f3 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Co-authored-by: "tartine8" <pbpcf8 at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105408

Files:
  clang/tools/clang-format/CMakeLists.txt
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===================================================================
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Format/Format.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
@@ -443,9 +444,12 @@
     IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
         new llvm::vfs::InMemoryFileSystem);
     FileManager Files(FileSystemOptions(), InMemoryFileSystem);
+    IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions;
+    TextDiagnosticPrinter *DiagClient =
+        new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
     DiagnosticsEngine Diagnostics(
         IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
-        new DiagnosticOptions);
+        &*DiagOpts, DiagClient);
     SourceManager Sources(Diagnostics, Files);
     FileID ID = createInMemoryFile(AssumedFileName, *Code, Sources, Files,
                                    InMemoryFileSystem.get());
Index: clang/tools/clang-format/CMakeLists.txt
===================================================================
--- clang/tools/clang-format/CMakeLists.txt
+++ clang/tools/clang-format/CMakeLists.txt
@@ -7,6 +7,7 @@
 set(CLANG_FORMAT_LIB_DEPS
   clangBasic
   clangFormat
+  clangFrontend
   clangRewrite
   clangToolingCore
   )


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105408.356386.patch
Type: text/x-patch
Size: 1574 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210704/481d19c2/attachment.bin>


More information about the cfe-commits mailing list