NFC: Clean up of IntrusiveRefCntPtr construction from raw pointers. (#151545)
Handles clang::DiagnosticsEngine and clang::DiagnosticIDs.
For DiagnosticIDs, this mostly migrates from `new DiagnosticIDs` to
convenience method `DiagnosticIDs::create()`.
Part of cleanup https://github.com/llvm/llvm-project/issues/151026
NOKEYCHECK=True
GitOrigin-RevId: c7f343750744fd0c928b1da67e9dd894a2fe52cf
diff --git a/ClangFormat.cpp b/ClangFormat.cpp
index afc40e9..5f6502f 100644
--- a/ClangFormat.cpp
+++ b/ClangFormat.cpp
@@ -241,8 +241,7 @@
makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diagnostics(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), DiagOpts);
+ DiagnosticsEngine Diagnostics(DiagnosticIDs::create(), DiagOpts);
SourceManager Sources(Diagnostics, Files);
const auto ID = createInMemoryFile("<irrelevant>", *Code, Sources, Files,
InMemoryFileSystem.get());
@@ -517,9 +516,8 @@
DiagnosticOptions DiagOpts;
ClangFormatDiagConsumer IgnoreDiagnostics;
- DiagnosticsEngine Diagnostics(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), DiagOpts,
- &IgnoreDiagnostics, false);
+ DiagnosticsEngine Diagnostics(DiagnosticIDs::create(), DiagOpts,
+ &IgnoreDiagnostics, false);
SourceManager Sources(Diagnostics, Files);
FileID ID = createInMemoryFile(AssumedFileName, *Code, Sources, Files,
InMemoryFileSystem.get());